IME driver macros and prototypes. More...
Go to the source code of this file.
Data Structures | |
struct | _imeData |
structure to hold everything for one encoder More... | |
struct | _vexImeData |
structure holding all IME data More... | |
Macros | |
#define | IME_MAX kImeTotal |
Maximum number of IMEs we search for. More... | |
#define | DEFAULT_DEVICE 0x60 |
Default IME address. More... | |
#define | IME_START_ADDRESS 0x20 |
Start address when reassigning. More... | |
#define | IME_VERSION_ADDR 0x00 |
Version request. More... | |
#define | IME_VENDOR_ADDR 0x08 |
Vendor request. More... | |
#define | IME_DEVICEID_ADDR 0x10 |
Device ID request. More... | |
#define | IME_STATUS_ADDR 0x20 |
Status command. More... | |
#define | IME_DATA_ADDR 0x40 |
Get data command. More... | |
#define | IME_SCRATCHR_ADDR 0x60 |
read register offset of scratchpad regs More... | |
#define | IME_SCRATCHW_ADDR 0xA0 |
write register offset of scratchpad regs More... | |
#define | IME_CLEAR_COUNTERS 0x4A |
Clear counters command. More... | |
#define | IME_DISABLE_TERM 0x4B |
disable termination command More... | |
#define | IME_ENABLE_TERM 0x4C |
enable termination command More... | |
#define | IME_SETDEV_REG 0x4D |
Set device address command. More... | |
#define | IME_RESET_REG 0x4E |
Reset command. More... | |
#define | IME_BUF_LEN 16 |
#define | ACTION_POLL 0 |
#define | ACTION_RENEGOTIATE 1 |
#define | IME_COUNT_RESET 0x7F000000 |
Dummy value used during IME reset. More... | |
IME motor types | |
#define | IME_269 0 |
#define | IME_393T 1 |
#define | IME_393S 2 |
#define | IME_UND 16 |
Typedefs | |
typedef struct _imeData | imeData |
structure to hold everything for one encoder More... | |
typedef struct _vexImeData | vexImeData |
structure holding all IME data More... | |
Enumerations | |
enum | tVexImeChannels { kImeChannel_1 = 0, kImeChannel_2 = 1, kImeChannel_3 = 2, kImeChannel_4 = 3, kImeChannel_5 = 4, kImeChannel_6 = 5, kImeChannel_7 = 6, kImeChannel_8 = 7, kImeTotal, kImeChannelNone = 99 } |
IME channel definitions. More... | |
Functions | |
int32_t | vexImeGetCount (int16_t channel) |
return encoder count More... | |
void | vexImeSetCount (int16_t channel, int32_t value) |
sets encoder count (stores an offset) More... | |
int16_t | vexImeGetId (int16_t channel) |
return encoder id More... | |
int16_t | vexImeGetChannelMax (void) |
Get the number of IMEs found. More... | |
imeData * | vexImeGetPtr (tVexImeChannels channel) |
return pointer to IME data structure More... | |
void | vexImeInit (I2CDriver *i2cp, vexStream *chp) |
Initialize IMEs on the I2C bus. More... | |
void | vexImeSetType (tVexImeChannels channel, tVexMotorType type) |
Set motor type that this IME is attached to. More... | |
void | vexImeSetMotor (tVexImeChannels channel, tVexMotor motor) |
Set the motor that this IME is attached to. More... | |
int32_t | vexImeMotorGetCount (tVexMotor motor) |
return encoder count based on motor index More... | |
uint16_t | vexIMEFindEncoders (void) |
Search bus and add all encoders found (up to 8) More... | |
void | vexIMEDataInit (imeData *ime) |
Init data structure for one IME. More... | |
msg_t | vexIMEUpdateCounts (imeData *ime) |
Read encoder data and then calculate the rpm. More... | |
msg_t | vexIMEGetVersion (uint8_t device, uint8_t *buf) |
Read version from IME. More... | |
msg_t | vexIMEGetVendor (uint8_t device, uint8_t *buf) |
Read vendor from IME. More... | |
msg_t | vexIMEGetDeviceId (uint8_t device, uint8_t *buf) |
Read device ID from IME. More... | |
msg_t | vexIMEGetStatus (uint8_t device, uint8_t *buf) |
Read Status from IME. More... | |
msg_t | vexIMEGetData (uint8_t device, uint8_t *buf) |
Read encoder data from IME. More... | |
msg_t | vexIMEGetScratchpad (uint8_t device, uint8_t *buf, uint8_t offset, uint8_t len) |
Read scratchpad data from IME. More... | |
msg_t | vexIMESetScratchpad (uint8_t device, uint8_t *buf, uint8_t offset, uint8_t len) |
Write scratchpad data to the IME. More... | |
msg_t | vexIMEClearCounters (uint8_t device) |
Clear Counters in IME. More... | |
msg_t | vexIMEDisableTermination (uint8_t device) |
Disable termination in IME. More... | |
msg_t | vexIMEEnableTermination (uint8_t device) |
Enable termination in IME. More... | |
msg_t | vexIMESetAddr (uint8_t *device, uint8_t newDevice) |
msg_t | vexIMEResetAll (void) |
Reset an IME. More... | |
void | vexIMEHandleErrors (msg_t status, i2cflags_t errors) |
Handle received IME I2C errors. More... | |
void | vexIMEPrintBuf (vexStream *chp, uint8_t *buf, uint8_t len) |
Print a buffer with IME data. More... | |
void | vexIMEDebug (vexStream *chp, int argc, char *argv[]) |
Debug function to dump IME buffers. More... | |
IME driver macros and prototypes.
#define IME_MAX kImeTotal |
Maximum number of IMEs we search for.
#define DEFAULT_DEVICE 0x60 |
Default IME address.
#define IME_START_ADDRESS 0x20 |
Start address when reassigning.
#define IME_VERSION_ADDR 0x00 |
Version request.
#define IME_VENDOR_ADDR 0x08 |
Vendor request.
#define IME_DEVICEID_ADDR 0x10 |
Device ID request.
#define IME_STATUS_ADDR 0x20 |
Status command.
#define IME_DATA_ADDR 0x40 |
Get data command.
#define IME_SCRATCHR_ADDR 0x60 |
read register offset of scratchpad regs
#define IME_SCRATCHW_ADDR 0xA0 |
write register offset of scratchpad regs
#define IME_CLEAR_COUNTERS 0x4A |
Clear counters command.
#define IME_DISABLE_TERM 0x4B |
disable termination command
#define IME_ENABLE_TERM 0x4C |
enable termination command
#define IME_SETDEV_REG 0x4D |
Set device address command.
#define IME_RESET_REG 0x4E |
Reset command.
#define IME_BUF_LEN 16 |
#define ACTION_POLL 0 |
#define ACTION_RENEGOTIATE 1 |
#define IME_COUNT_RESET 0x7F000000 |
Dummy value used during IME reset.
#define IME_269 0 |
#define IME_393T 1 |
#define IME_393S 2 |
#define IME_UND 16 |
typedef struct _vexImeData vexImeData |
structure holding all IME data
enum tVexImeChannels |
int32_t vexImeGetCount | ( | int16_t | channel) |
return encoder count
[in] | channel | The encoder channel |
void vexImeSetCount | ( | int16_t | channel, |
int32_t | value | ||
) |
sets encoder count (stores an offset)
[in] | channel | The encoder channel |
[in] | value | The new encoder count value |
int16_t vexImeGetId | ( | int16_t | channel) |
return encoder id
[in] | channel | The encoder channel |
int16_t vexImeGetChannelMax | ( | void | ) |
Get the number of IMEs found.
imeData* vexImeGetPtr | ( | tVexImeChannels | channel) |
return pointer to IME data structure
[in] | channel | The encoder channel |
void vexImeInit | ( | I2CDriver * | i2cp, |
vexStream * | chp | ||
) |
Initialize IMEs on the I2C bus.
[in] | i2cp | A pointer to the I2C driver (chibios hal driver) |
[in] | chp | A pointer to a vexStream object (used for debug output) |
void vexImeSetType | ( | tVexImeChannels | channel, |
tVexMotorType | type | ||
) |
Set motor type that this IME is attached to.
[in] | channel | The encoder channel |
[in] | type | The motor type |
void vexImeSetMotor | ( | tVexImeChannels | channel, |
tVexMotor | motor | ||
) |
Set the motor that this IME is attached to.
[in] | channel | The encoder channel |
[in] | motor | The motor index |
int32_t vexImeMotorGetCount | ( | tVexMotor | motor) |
return encoder count based on motor index
[in] | motor | The motor index |
uint16_t vexIMEFindEncoders | ( | void | ) |
Search bus and add all encoders found (up to 8)
void vexIMEDataInit | ( | imeData * | ime) |
Init data structure for one IME.
param[in] ime A pointer to a imeData structure
msg_t vexIMEUpdateCounts | ( | imeData * | ime) |
Read encoder data and then calculate the rpm.
[in] | ime | A pointer to an imeData structure |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
0 | ime pointer is NULL |
msg_t vexIMEGetVersion | ( | uint8_t | device, |
uint8_t * | buf | ||
) |
Read version from IME.
[in] | device | The IME address |
[out] | buf | Pointer to the buffer for reply data |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEGetVendor | ( | uint8_t | device, |
uint8_t * | buf | ||
) |
Read vendor from IME.
[in] | device | The IME address |
[out] | buf | Pointer to the buffer for reply data |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEGetDeviceId | ( | uint8_t | device, |
uint8_t * | buf | ||
) |
Read device ID from IME.
[in] | device | The IME address |
[out] | buf | Pointer to the buffer for reply data |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEGetStatus | ( | uint8_t | device, |
uint8_t * | buf | ||
) |
Read Status from IME.
[in] | device | The IME address |
[out] | buf | Pointer to the buffer for reply data |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEGetData | ( | uint8_t | device, |
uint8_t * | buf | ||
) |
Read encoder data from IME.
[in] | device | The IME address |
[out] | buf | Pointer to the buffer for reply data |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEGetScratchpad | ( | uint8_t | device, |
uint8_t * | buf, | ||
uint8_t | offset, | ||
uint8_t | len | ||
) |
Read scratchpad data from IME.
[in] | device | The IME address |
[in] | buf | Pointer to the scratchpad data |
[in] | offset | An offset into the scratchpad area |
[in] | len | The length of the scratchpad data to write |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMESetScratchpad | ( | uint8_t | device, |
uint8_t * | buf, | ||
uint8_t | offset, | ||
uint8_t | len | ||
) |
Write scratchpad data to the IME.
[in] | device | The IME address |
[in] | buf | Pointer to the scratchpad data |
[in] | offset | An offset into the scratchpad area |
[in] | len | The length of the scratchpad data to write |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEClearCounters | ( | uint8_t | device) |
Clear Counters in IME.
[in] | device | The IME address |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEDisableTermination | ( | uint8_t | device) |
Disable termination in IME.
[in] | device | The IME address |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMEEnableTermination | ( | uint8_t | device) |
Enable termination in IME.
[in] | device | The IME address |
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
msg_t vexIMESetAddr | ( | uint8_t * | device, |
uint8_t | newDevice | ||
) |
msg_t vexIMEResetAll | ( | void | ) |
Reset an IME.
RDY_OK | If the function succeeded |
RDY_RESET | if one or more I2C errors occurred. |
RDY_TIMEOUT | if a timeout occurred before operation end. |
void vexIMEHandleErrors | ( | msg_t | status, |
i2cflags_t | errors | ||
) |
Handle received IME I2C errors.
[in] | status | The received message from the I2C low level driver |
[in] | errors | The received error status |
void vexIMEPrintBuf | ( | vexStream * | chp, |
uint8_t * | buf, | ||
uint8_t | len | ||
) |
Print a buffer with IME data.
[in] | chp | A pointer to a vexStream object |
[in] | buf | A pointer to a buffer of uint8_t |
[in] | len | The buffer elngth |
void vexIMEDebug | ( | vexStream * | chp, |
int | argc, | ||
char * | argv[] | ||
) |
Debug function to dump IME buffers.
[in] | chp | A pointer to a vexStream object |
[in] | argc | The number of command line arguments |
[in] | argv | An array of pointers to the command line args |