Infineon Logo AIROC BTSDK v4.9 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Defines an I2C driver to facilitate communication with other devices on an I2C bus (such as a temperature sensor, etc). More...

Modules

 I2C EEPROM Interface
 Defines a driver for the I2C EEPROM interface.
 

Typedefs

typedef void I2C_SLAVE_CALLBACK_HANDLER (uint32_t evtFlag, uint8_t *rx_PktPointer, uint16_t rx_PktLength)
 

Enumerations

enum  { I2CM_SPEED_100KHZ = 233, I2CM_SPEED_400KHZ = 53, I2CM_SPEED_800KHZ = 23, I2CM_SPEED_1000KHZ = 17 }
 Enumeration of speed options. More...
 
enum  { I2CM_SUCCESS, I2CM_OP_FAILED }
 Enumeration of I2C transaction return values. More...
 
enum  { I2C_TRAN_EVENT_MASK_RX_DONE = 1, I2C_TRAN_EVENT_MASK_TX_DONE = 2, I2C_TRAN_EVENT_MASK_RX_STOP = 4 }
 

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 particular 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 particular slave address. More...
 
void wiced_hal_i2c_select_pads (uint8_t scl_pin, uint8_t sda_pin)
 Configures GPIOs to use for I2C pins. 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...
 
void wiced_hal_i2c_slave_set_device_address (UINT8 address)
 
void wiced_hal_i2c_slave_select_pads (UINT32 scl_pin, UINT32 sda_pin)
 
void wiced_hal_i2c_slave_init (void)
 
void wiced_hal_i2c_slave_register_cb (I2C_SLAVE_CALLBACK_HANDLER *cb)
 
void wiced_hal_i2c_slave_synchronous_write (UINT8 *buffer, UINT32 length)
 

Detailed Description

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.

Enumeration Type Documentation

anonymous enum

Enumeration of speed options.

Enumerator
I2CM_SPEED_100KHZ 

I2C speed is 100kHz.

I2CM_SPEED_400KHZ 

I2C speed is 499kHz.

I2CM_SPEED_800KHZ 

I2C speed is 800kHz.

I2CM_SPEED_1000KHZ 

I2C speed is 1MHz.

anonymous enum

Enumeration of I2C transaction return values.

Enumerator
I2CM_SUCCESS 

I2C transaction was successful.

I2CM_OP_FAILED 

I2C transaction failed, possibly due to no ACK from slave.

Function Documentation

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.

Parameters
[in,out]rx_dataPointer to a buffer that will hold the incoming data
[in]rx_data_lenThe length in bytes of the data to read
[in]tx_dataPointer to a buffer that will hold the outgoing data
[in]tx_data_lenThe length in bytes of the data to write
[in]slaveThe 7-bit slave address
Returns
The status of the transaction. Refer to the transaction return values in the parameters section

hal/i2c_master

Note
The <rx_data> buffer should be large enough to hold <rx_data_len> bytes
uint8_t wiced_hal_i2c_get_speed ( void  )

Gets the current I2C bus speed.

Smaller numbers indicate higher speeds.

Parameters
none
Returns
The SCL clock cycle counter value which corresponds to the SCL speed
  • Refer to the speeds in the parameter section

hal/i2c_master

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.

Parameters
none
Returns
none

hal/i2c_master

Note
(!) Note that it is the user's responsibility to configure the desired GPIOs, since different HW platforms will have different configuration parameters. Please see the Kit Guide or HW User Manual for your device for more information. In case of change in I2C pins from default platform initialization, the user needs to use external pull-ups or internal GPIO pull-ups. It is recommended to use external pull-ups for a reliable design
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 particular 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.

Parameters
[in,out]dataPointer to a buffer that will hold the incoming data
[in]lengthThe length in bytes of the data to read
[in]slaveThe 7-bit slave address
Returns
The status of the transaction. Refer to the transaction return values in the parameters section
Note
Please see the Kit Guide or HW User Manual for your device for the actual limitation of the part on your platform.
The <data> buffer should be large enough to <length> bytes
void wiced_hal_i2c_select_pads ( uint8_t  scl_pin,
uint8_t  sda_pin 
)

Configures GPIOs to use for I2C pins.

Parameters
[in]scl_pinLHL GPIO to be used for SCL
[in]sda_pinLHL GPIO to be used for SDA
Returns
none
void wiced_hal_i2c_set_speed ( uint8_t  speed)

Sets the I2C bus speed.

Parameters
[in]speedThe new speed to be used. Refer to the speeds in the parameter section
Returns
none

hal/i2c_master

Note
By default, the speed after initialization is set to 100KHz
The clock frequency is determined by the input parameter which 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 particular 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.

Parameters
[in]dataPointer to a buffer that will hold the outgoing data
[in]lengthThe length in bytes of the data to write
[in]slaveThe 7-bit slave address
Returns
The status of the transaction. Refer to the transaction return values in the parameters section

hal/i2c_master

Note
Please see the Kit Guide or HW User Manual for your device for the actual limitation of the part on your platform.