|
hal
Hardware Abstraction Layer
|
The main data structure for interacting with the I2C module. More...
#include <i2c.h>
Public Attributes | |
| uint8_t | target_addr |
| hal_i2c_op_t | i2c_op |
| uint8_t | tx_data [TX_MESSAGE_MAX_LENGTH] |
| size_t | expected_bytes_to_tx |
| size_t | expected_bytes_to_rx |
| hal_i2c_txn_state_t | processing_state |
| hal_i2c_txn_result_t | transaction_result |
| size_t | actual_bytes_received |
| size_t | actual_bytes_transmitted |
| uint8_t | rx_data [RX_MESSAGE_MAX_LENGTH] |
The main data structure for interacting with the I2C module.
All interactions with the I2C driver involve using this data structure. In it is defined everything needed to initiate and complete a single I2C transaction with a target device, including the device address, the operation mode, the data to send (if any), and the expected data to receive (if any). It also includes status information used to track progress and check for success or failure.
The use of this transaction struct involves initializing the proper inputs, polling the the processing_state, and reading the outputs once the state is complete.
| size_t hal_i2c_txn_t::actual_bytes_received |
The actual number of bytes that got read during the transaction. Init to 0.
| size_t hal_i2c_txn_t::actual_bytes_transmitted |
The actual number of bytes that got transmitted during the transaction. Init to 0.
| size_t hal_i2c_txn_t::expected_bytes_to_rx |
The desired number of bytes to read from the device during this transaction. Only set for READ or WRITE-READ.
| size_t hal_i2c_txn_t::expected_bytes_to_tx |
The num of bytes to send the device. Include the reg addr in the count.
| hal_i2c_op_t hal_i2c_txn_t::i2c_op |
The type of transaction. i.e. READ, WRITE, or WRITE-READ.
| hal_i2c_txn_state_t hal_i2c_txn_t::processing_state |
Submit transaction with CREATED. When processing_state == COMPLETED then client can collect results. Safe to check periodically. Poll to determine when transaction has been completed.
| uint8_t hal_i2c_txn_t::rx_data[RX_MESSAGE_MAX_LENGTH] |
Data read from device will be stored here. Only valid after processing_state == COMPLETED. Init rx_data to zeros when creating the transaction struct.
| uint8_t hal_i2c_txn_t::target_addr |
The I2C address of the target device.
| hal_i2c_txn_result_t hal_i2c_txn_t::transaction_result |
Only valid once processing_state == COMPLETED. Contains the result of the transaction (success, fail, etc). Init to NONE.
| uint8_t hal_i2c_txn_t::tx_data[TX_MESSAGE_MAX_LENGTH] |
The data to send. Put the register addr in the first slot.