![]()  | 
  
IME driver. More...
#include <stdio.h>#include <string.h>#include <stdarg.h>#include "ch.h"#include "hal.h"#include "vex.h"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... | |
| imeData * | vexImeGetPtr (tVexImeChannels channel) | 
| return pointer to IME data structure  More... | |
| int16_t | vexImeGetChannelMax () | 
| Get the number of IMEs found.  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... | |
| void | vexImeInit (I2CDriver *i2cp, vexStream *chp) | 
| Initialize IMEs on the I2C bus.  More... | |
| msg_t | vexIMEUpdateCounts (imeData *ime) | 
| Read encoder data and then calculate the rpm.  More... | |
| void | vexIMEDataInit (imeData *ime) | 
| Init data structure for one IME.  More... | |
| uint16_t | vexIMEFindEncoders () | 
| Search bus and add all encoders found (up to 8)  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, unsigned char newDevice) | 
| Set new Address in IME.  More... | |
| msg_t | vexIMEResetAll () | 
| 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.
| 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 | 
| imeData* vexImeGetPtr | ( | tVexImeChannels | channel) | 
return pointer to IME data structure
| [in] | channel | The encoder channel | 
| int16_t vexImeGetChannelMax | ( | void | ) | 
Get the number of IMEs found.
| 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 | 
| 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) | 
| 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 | 
| void vexIMEDataInit | ( | imeData * | ime) | 
Init data structure for one IME.
param[in] ime A pointer to a imeData structure
| uint16_t vexIMEFindEncoders | ( | void | ) | 
Search bus and add all encoders found (up to 8)
| 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, | 
| unsigned char | newDevice | ||
| ) | 
Set new Address in IME.
| [in] | device | The IME address | 
| [in] | newDevice | The new 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 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 |