AIROC™ BTSDK v4.9 - Documentation | ||||
Defines an I2C driver to facilitate communication with other devices on an I2C bus (such as a temperature sensor, etc). More...
Enumerations | |
enum | { I2CM_SPEED_100KHZ = 16, I2CM_SPEED_400KHZ = 64, I2CM_SPEED_800KHZ = 128, I2CM_SPEED_1000KHZ = 160 } |
Speed Options. More... | |
enum | { I2CM_SUCCESS, I2CM_OP_FAILED, I2CM_BUSY } |
Transaction Status Return Values. More... | |
Functions | |
void | wiced_hal_i2c_init (void) |
Initializes the I2C driver and its private values. More... | |
void | wiced_hal_i2c_set_speed (uint8_t speed) |
Sets the I2C bus speed. More... | |
uint8_t | wiced_hal_i2c_get_speed (void) |
Gets the current I2C bus speed. More... | |
uint8_t | wiced_hal_i2c_read (uint8_t *data, uint16_t length, uint8_t slave) |
Reads data into given buffer from the I2C HW addressing a particualr slave address. More... | |
uint8_t | wiced_hal_i2c_write (uint8_t *data, uint16_t length, uint8_t slave) |
Writes the given data to the I2C HW addressing a particualr slave address. More... | |
uint8_t | wiced_hal_i2c_combined_read (uint8_t *rx_data, uint8_t rx_data_len, uint8_t *tx_data, uint16_t tx_data_len, uint8_t slave) |
Executes two transactions back-to-back with a repeated start condition between the first and the second. More... | |
Defines an I2C driver to facilitate communication with other devices on an I2C bus (such as a temperature sensor, etc).
The driver is only capable of assuming a master role. Applications use this driver to obtain the status from and control the behavior of the I2C hardware. This driver only offers services for speed control and data transfer operations.
Please note that even though this driver can access off-chip memory (if installed; EEPROM, etc), please use the drivers found in wiced_hal_ieeprom.h to access those modules, as those drivers include checks to ensure safe data handling operations. This driver is intended only to interface with other devices on the I2C bus, such as a motion sensor.
anonymous enum |
anonymous enum |
uint8_t wiced_hal_i2c_combined_read | ( | uint8_t * | rx_data, |
uint8_t | rx_data_len, | ||
uint8_t * | tx_data, | ||
uint16_t | tx_data_len, | ||
uint8_t | slave | ||
) |
Executes two transactions back-to-back with a repeated start condition between the first and the second.
tx_data is written to the slave in the first transaction while data is read back from the slave into rx_data after the repeated start.
rx_data | Pointer to the buffer where data is to be read after the repeated start |
rx_data_len | Number of bytes to read from slaveAdr - rx_data should be at least this big |
tx_data | Pointer to the buffer that is to be written to the slave |
tx_data_len | Number of bytes to write to the slave starting from tx_data |
slave | slave addr |
uint8_t wiced_hal_i2c_get_speed | ( | void | ) |
Gets the current I2C bus speed.
Smaller numbers indicate higher speeds. See the Parameters section for more information.
none |
void wiced_hal_i2c_init | ( | void | ) |
Initializes the I2C driver and its private values.
This initialization sets the bus speed to 100KHz by default (I2CM_SPEED_100KHZ). To make the bus run at another speed, call wiced_hal_i2c_setSpeed(<speed>) right after this call.
I2C pins are configured through platform_gpio_pins[] in wiced_platform_pin_config.c
none |
uint8_t wiced_hal_i2c_read | ( | uint8_t * | data, |
uint16_t | length, | ||
uint8_t | slave | ||
) |
Reads data into given buffer from the I2C HW addressing a particualr slave address.
The data bytes are transparent. Though any arbitrary length of data may be read from the slave, atomic transactions greater than HW's capability are not possible - they will be split into multiple transactions. This is a blocking call. Interrupts will not affect timing within a transaction. Note: Please see the Kit Guide or HW User Manual for your device for the actual limitation of the part on your platform.
data | - Pointer to a buffer that will hold the incoming data. |
length | - The length of the data to read. |
slave | - The source slave address. |
void wiced_hal_i2c_set_speed | ( | uint8_t | speed | ) |
Sets the I2C bus speed.
Note that the default after initialization is set to 100KHz by default (I2CM_SPEED_100KHZ). To make the bus run at another speed, use one of the following parameters (also see Parameters section):
// I2C speed is 100 KHz I2CM_SPEED_100KHZ // I2C speed is 400 KHz I2CM_SPEED_400KHZ // I2C speed is 800 KHz I2CM_SPEED_800KHZ // I2C speed is 1 MHz I2CM_SPEED_1000KHZ
speed | - The new speed to be used. This is the transport clock counter that counts the number of reference clock cycles. |
uint8_t wiced_hal_i2c_write | ( | uint8_t * | data, |
uint16_t | length, | ||
uint8_t | slave | ||
) |
Writes the given data to the I2C HW addressing a particualr slave address.
The data bytes are transparent. Though any arbitrary length of data may be written to the slave, atomic transactions greater than HW's capability are not possible - they will be split into multiple transactions. This is a blocking call. Interrupts will not affect timing within a transaction. Note: Please see the Kit Guide or HW User Manual for your device for the actual limitation of the part on your platform.
data | - Pointer to a buffer holding the data to write. |
length | - The length of the data to write. |
slave | - The destination slave address. |