Interact with FlexSense external i2c peripheral.
More...
|
int | FLEX_ExtI2CWrite (int Address, const uint8_t *const TxData, uint16_t TxLength) |
|
int | FLEX_ExtI2CRead (int Address, const uint8_t *const TxData, uint16_t TxLength, uint8_t *const RxData, uint16_t RxLength) |
|
Interact with FlexSense external i2c peripheral.
The FlexSense device supports i2c communication with external sensors through the cable interface.
- Warning
- The i2c communication should only be implemented with a cable length of 1m or less between the FlexSense and a sensor.
◆ FLEX_ExtI2CWrite()
int FLEX_ExtI2CWrite |
( |
int | Address, |
|
|
const uint8_t *const | TxData, |
|
|
uint16_t | TxLength ) |
Write to an i2c device at a given address.
- Note
- i2c Addresses 0x20 and 0x42 are reserved, and a sensor with this address should not be interfaced with FlexSense.
- Parameters
-
[in] | Address | the peripheral device address. |
[in] | TxData | pointer to the TX buffer containing registers address and command. |
[in] | TxLength | length of data to be sent. |
- Returns
- FLEX_SUCCESS (0) if succeeded and < 0 if failed.
- Return values
-
-FLEX_ERROR_EINVAL | invalid i2c address (address in use by internal device) |
-FLEX_ERROR_IO_EXPANDER | failed to initialise or configure expander device |
-FLEX_ERROR_POWER_OUT | failed to power on external i2c bus |
-FLEX_ERROR_I2C | error initialising i2c bus |
◆ FLEX_ExtI2CRead()
int FLEX_ExtI2CRead |
( |
int | Address, |
|
|
const uint8_t *const | TxData, |
|
|
uint16_t | TxLength, |
|
|
uint8_t *const | RxData, |
|
|
uint16_t | RxLength ) |
Write to an i2c device at a given address and then read the response.
- Note
- i2c Addresses 0x20 and 0x42 are reserved, and a sensor with this address should not be interfaced with FlexSense.
- Parameters
-
[in] | Address | the peripheral device address. |
[in] | TxData | pointer to TX buffer containing registers address and command. |
[in] | TxLength | length of data to be sent. |
[out] | RxData | pointer to the RX buffer. |
[in] | RxLength | length of data to be received. |
- Returns
- FLEX_SUCCESS (0) if succeeded and < 0 if failed.
- Return values
-
-FLEX_ERROR_EINVAL | invalid i2c address (address in use by internal device) |
-FLEX_ERROR_IO_EXPANDER | failed to initialise or configure expander device |
-FLEX_ERROR_POWER_OUT | failed to power on external i2c bus |
-FLEX_ERROR_I2C | error initialising i2c bus |