Infineon Logo AIROC BTSDK v4.6 - 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 = 240, I2CM_SPEED_400KHZ = 60, I2CM_SPEED_800KHZ = 30, I2CM_SPEED_1000KHZ = 24 }
 Speed Options. More...
 
enum  { I2CM_SUCCESS, I2CM_OP_FAILED }
 Transaction Status 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 speed)
 Sets the I2C bus speed. More...
 
UINT8 wiced_hal_i2c_get_speed (void)
 Gets the current I2C bus speed. More...
 
UINT8 wiced_hal_i2c_read (UINT8 *data, UINT16 length, UINT8 slave)
 Reads data into given buffer from the I2C HW addressing a particualr slave address. More...
 
UINT8 wiced_hal_i2c_write (UINT8 *data, UINT16 length, UINT8 slave)
 Writes the given data to the I2C HW addressing a particualr slave address. More...
 
void wiced_hal_i2c_select_pads (UINT8 scl_pin, UINT8 sda_pin)
 Configures I2C pins. More...
 
UINT8 wiced_hal_i2c_combined_read (UINT8 *rx_data, UINT8 rx_data_len, UINT8 *tx_data, UINT16 tx_data_len, UINT8 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

Speed Options.

Enumerator
I2CM_SPEED_100KHZ 

I2C speed is 100 KHz.

I2CM_SPEED_400KHZ 

I2C speed is 400 KHz.

I2CM_SPEED_800KHZ 

I2C speed is 800 KHz.

I2CM_SPEED_1000KHZ 

I2C speed is 1 MHz.

anonymous enum

Transaction Status Return Values.

Enumerator
I2CM_SUCCESS 

The transaction was sucessful.

I2CM_OP_FAILED 

The attempted operation failed, possibly because of no ack from slave.

Function Documentation

UINT8 wiced_hal_i2c_combined_read ( UINT8 rx_data,
UINT8  rx_data_len,
UINT8 tx_data,
UINT16  tx_data_len,
UINT8  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
rx_dataPointer to the buffer where data is to be read after the repeated start
rx_data_lenNumber of bytes to read from slaveAdr - rx_data should be at least this big
tx_dataPointer to the buffer that is to be written to the slave
tx_data_lenNumber of bytes to write to the slave starting from tx_data
slaveslave addr
Returns
The status of the transaction (success[0], failure[1])
UINT8 wiced_hal_i2c_get_speed ( void  )

Gets the current I2C bus speed.

Smaller numbers indicate higher speeds. See the Parameters section for more information.

Parameters
none
Returns
The SCL ref clock cycle counter value that corresponding to the SCL speed.
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 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

Parameters
none
Returns
none
UINT8 wiced_hal_i2c_read ( UINT8 data,
UINT16  length,
UINT8  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.

Parameters
data- Pointer to a buffer that will hold the incoming data.
length- The length of the data to read.
slave- The source slave address.
Returns
The status of the transaction (success[0], failure[1]).
void wiced_hal_i2c_select_pads ( UINT8  scl_pin,
UINT8  sda_pin 
)

Configures I2C pins.

Parameters
scl_pinLHL GPIO to be used for SCL
sda_pinLHL GPIO to be used for SDA
void wiced_hal_i2c_set_speed ( UINT8  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
Parameters
speed- The new speed to be used. This is the transport clock counter that counts the number of reference clock cycles.
Returns
none
UINT8 wiced_hal_i2c_write ( UINT8 data,
UINT16  length,
UINT8  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.

Parameters
data- Pointer to a buffer holding the data to write.
length- The length of the data to write.
slave- The destination slave address.
Returns
The status of the transaction (success[0], failure[1]).