Inter-integrated Circuit. More...
Data Structures | |
struct | i2c_channel_attr_t |
struct | i2c_handle_t |
Enumerations | |
enum | i2c_result_t { I2C_RESULT_OK , I2C_RESULT_INVALID , I2C_RESULT_UNSUPPORTED , I2C_RESULT_BIT_ERROR , I2C_RESULT_TIMEOUT , I2C_RESULT_IDLE , I2C_RESULT_BUSY , I2C_RESULT_NAK , I2C_RESULT_ERR , TOTAL_I2C_RESULT } |
enum | i2c_status_t { I2C_STATUS_UNKNOWN , I2C_STATUS_OK , I2C_STATUS_BUSY , I2C_STATUS_STOP , I2C_STATUS_SENDING , I2C_STATUS_RECEIVING , I2C_STATUS_ERR , TOTAL_I2C_STATUS } |
enum | i2c_mode_t { I2C_MODE_MASTER , I2C_MODE_SLAVE , TOTAL_I2C_MODE } |
enum | i2c_baudrate_t { I2C_BAUDRATE_100KHZ = 100000U , I2C_BAUDRATE_400KHZ = 400000U , I2C_BAUDRATE_1MHZ = 1000000U , I2C_BAUDRATE_3_4MHZ = 3400000U , TOTAL_I2C_BAUDRATE } |
Functions | |
i2c_result_t | hal_i2c_init (i2c_handle_t *handle, const i2c_channel_attr_t attr) |
Configure I2C channel with specific attributes. | |
i2c_result_t | hal_i2c_write (i2c_handle_t *handle, const uint16_t address, const uint32_t reg_addr, const size_t reg_len, const uint8_t *tx_buffer, const size_t len) |
Write data to specific device address. | |
i2c_result_t | hal_i2c_read (i2c_handle_t *handle, const uint16_t address, const uint32_t reg_addr, const size_t reg_len, uint8_t *rx_buffer, const size_t len) |
Read data from specific device address. | |
i2c_result_t | hal_i2c_stop (i2c_handle_t *handle) |
Stop I2C operation. | |
i2c_result_t | hal_i2c_mutex_take (const uint8_t channel, const uint32_t timeout_ms) |
Try acquire RTOS mutex for specified channel. | |
i2c_result_t | hal_i2c_mutex_give (const uint8_t channel) |
Release RTOS mutex for specified channel. | |
Inter-integrated Circuit.
enum i2c_baudrate_t |
#include <i2c/public_inc/hal_i2c.h>
Enumerator | |
---|---|
I2C_BAUDRATE_100KHZ | |
I2C_BAUDRATE_400KHZ | |
I2C_BAUDRATE_1MHZ | |
I2C_BAUDRATE_3_4MHZ | |
TOTAL_I2C_BAUDRATE |
enum i2c_mode_t |
#include <i2c/public_inc/hal_i2c.h>
Enumerator | |
---|---|
I2C_MODE_MASTER | |
I2C_MODE_SLAVE | |
TOTAL_I2C_MODE |
enum i2c_result_t |
#include <i2c/public_inc/hal_i2c.h>
enum i2c_status_t |
#include <i2c/public_inc/hal_i2c.h>
i2c_result_t hal_i2c_init | ( | i2c_handle_t * | handle, |
const i2c_channel_attr_t | attr ) |
#include <i2c/public_inc/hal_i2c.h>
Configure I2C channel with specific attributes.
[in,out] | handle | I2C handler |
[in] | attr | I2C channel attributes |
I2C_RESULT_OK | Success configure I2C channel |
I2C_RESULT_INVALID | Configuration attributes invalid |
I2C_RESULT_UNSUPPORTED | Operation not supported |
I2C_RESULT_ERR | Failed configure I2C channel |
i2c_result_t hal_i2c_mutex_give | ( | const uint8_t | channel | ) |
#include <i2c/public_inc/hal_i2c.h>
Release RTOS mutex for specified channel.
[in] | channel | I2C channel's mutex to be released |
I2C_RESULT_OK | Success release mutex |
I2C_RESULT_INVALID | Invalid channel |
I2C_RESULT_UNSUPPORTED | Operation not supported |
I2C_RESULT_ERR | Failed release mutex |
i2c_result_t hal_i2c_mutex_take | ( | const uint8_t | channel, |
const uint32_t | timeout_ms ) |
#include <i2c/public_inc/hal_i2c.h>
Try acquire RTOS mutex for specified channel.
[in] | channel | I2C channel's mutex to be locked |
[in] | timeout_ms | Mutex acquiring timeout in milliseconds |
I2C_RESULT_OK | Success acquire mutex |
I2C_RESULT_INVALID | Invalid channel |
I2C_RESULT_UNSUPPORTED | Operation not supported |
I2C_RESULT_ERR | Failed acquire mutex |
i2c_result_t hal_i2c_read | ( | i2c_handle_t * | handle, |
const uint16_t | address, | ||
const uint32_t | reg_addr, | ||
const size_t | reg_len, | ||
uint8_t * | rx_buffer, | ||
const size_t | len ) |
#include <i2c/public_inc/hal_i2c.h>
Read data from specific device address.
[in,out] | handle | I2C handler |
[in] | address | Device address |
[in] | reg_addr | Register address |
[in] | reg_len | Register byte size |
[out] | rx_buffer | Receiving buffer |
[in] | len | Buffer size |
I2C_RESULT_OK | Success read data from I2C bus |
I2C_RESULT_TIMEOUT | Read data from I2C bus timeout |
I2C_RESULT_BUSY | Network busy |
I2C_RESULT_ERR | Failed read data from I2C bus |
i2c_result_t hal_i2c_stop | ( | i2c_handle_t * | handle | ) |
#include <i2c/public_inc/hal_i2c.h>
Stop I2C operation.
[in,out] | handle | I2C handler |
I2C_RESULT_OK | Success stop I2C transaction |
I2C_RESULT_UNSUPPORTED | Operation not supported |
I2C_RESULT_ERR | Failed stop I2C transaction |
i2c_result_t hal_i2c_write | ( | i2c_handle_t * | handle, |
const uint16_t | address, | ||
const uint32_t | reg_addr, | ||
const size_t | reg_len, | ||
const uint8_t * | tx_buffer, | ||
const size_t | len ) |
#include <i2c/public_inc/hal_i2c.h>
Write data to specific device address.
[in,out] | handle | I2C handler |
[in] | address | Device address |
[in] | reg_addr | Register address |
[in] | reg_len | Register byte size |
[in] | tx_buffer | Buffer to be transmitted |
[in] | len | Buffer size |
I2C_RESULT_OK | Success write data to I2C bus |
I2C_RESULT_TIMEOUT | Write to I2C bus timeout |
I2C_RESULT_BUSY | Network busy |
I2C_RESULT_ERR | Failed write data to I2C bus |