|
WPILibC++
2020.3.2
|
Functions | |
| void | HAL_InitializeI2C (HAL_I2CPort port, int32_t *status) |
| Initializes the I2C port. More... | |
| int32_t | HAL_TransactionI2C (HAL_I2CPort port, int32_t deviceAddress, const uint8_t *dataToSend, int32_t sendSize, uint8_t *dataReceived, int32_t receiveSize) |
| Generic I2C read/write transaction. More... | |
| int32_t | HAL_WriteI2C (HAL_I2CPort port, int32_t deviceAddress, const uint8_t *dataToSend, int32_t sendSize) |
| Executes a write transaction with the device. More... | |
| int32_t | HAL_ReadI2C (HAL_I2CPort port, int32_t deviceAddress, uint8_t *buffer, int32_t count) |
| Executes a read transaction with the device. More... | |
| void | HAL_CloseI2C (HAL_I2CPort port) |
| Closes an I2C port. More... | |
| HAL_ENUM (HAL_I2CPort) | |
| void HAL_CloseI2C | ( | HAL_I2CPort | port | ) |
Closes an I2C port.
| port | The I2C port, 0 for the on-board, 1 for the MXP. |
| void HAL_InitializeI2C | ( | HAL_I2CPort | port, |
| int32_t * | status | ||
| ) |
Initializes the I2C port.
Opens the port if necessary and saves the handle. If opening the MXP port, also sets up the channel functions appropriately.
| port | The port to open, 0 for the on-board, 1 for the MXP. |
| int32_t HAL_ReadI2C | ( | HAL_I2CPort | port, |
| int32_t | deviceAddress, | ||
| uint8_t * | buffer, | ||
| int32_t | count | ||
| ) |
Executes a read transaction with the device.
Reads bytes from a device. Most I2C devices will auto-increment the register pointer internally allowing you to read consecutive registers on a device in a single transaction.
| port | The I2C port, 0 for the on-board, 1 for the MXP. |
| registerAddress | The register to read first in the transaction. |
| count | The number of bytes to read in the transaction. |
| buffer | A pointer to the array of bytes to store the data read from the device. |
| int32_t HAL_TransactionI2C | ( | HAL_I2CPort | port, |
| int32_t | deviceAddress, | ||
| const uint8_t * | dataToSend, | ||
| int32_t | sendSize, | ||
| uint8_t * | dataReceived, | ||
| int32_t | receiveSize | ||
| ) |
Generic I2C read/write transaction.
This is a lower-level interface to the I2C hardware giving you more control over each transaction.
| port | The I2C port, 0 for the on-board, 1 for the MXP. |
| dataToSend | Buffer of data to send as part of the transaction. |
| sendSize | Number of bytes to send as part of the transaction. |
| dataReceived | Buffer to read data into. |
| receiveSize | Number of bytes to read from the device. |
| int32_t HAL_WriteI2C | ( | HAL_I2CPort | port, |
| int32_t | deviceAddress, | ||
| const uint8_t * | dataToSend, | ||
| int32_t | sendSize | ||
| ) |
Executes a write transaction with the device.
Writes a single byte to a register on a device and wait until the transaction is complete.
| port | The I2C port, 0 for the on-board, 1 for the MXP. |
| registerAddress | The address of the register on the device to be written. |
| data | The byte to write to the register on the device. |