Infineon Logo AIROC BTSDK v4.7 - 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.
 

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, I2CM_BUSY }
 Transaction Status Return Values. More...
 
enum  { WICED_I2C_SDA_P35_SCL_P37 = 0, WICED_I2C_SDA_I2S_DOUT_PCM_OUT_SCL_I2S_DIN_PCM_IN = 1, WICED_I2C_SDA_SFLASH_MOSI_SCL_SFLASH_MISO = 2 }
 

Functions

wiced_result_t wiced_hal_i2c_init (UINT8 configure_path)
 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_combo_read (UINT8 *read_buff, UINT16 read_buff_length, UINT8 *write_buff, UINT8 write_buff_length, UINT8 slave_address)
 Executes two transactions back-to-back with a repeated start condition between the first and the second. 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...
 

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.

I2CM_BUSY 

The I2C HW block is busy with another transaction.

Function Documentation

UINT8 wiced_hal_i2c_combo_read ( UINT8 *  read_buff,
UINT16  read_buff_length,
UINT8 *  write_buff,
UINT8  write_buff_length,
UINT8  slave_address 
)

Executes two transactions back-to-back with a repeated start condition between the first and the second.

firstTranBuf is written to the slave in the first transaction while data is read back from the slave into secondTranBuf after the repeated start.

Parameters
read_buff- Pointer to the buffer where data is to be read after the repeated start
read_buff_length- Number of bytes to read from slave_address - read_buff should be at least this big
write_buff- Pointer to the buffer that is to be written to the slave ( eg : EEPROM read addr)
write_buff_length- Number of bytes to write to the slave starting from write_buff
slave_address- The source slave address.
Returns
The status of the transaction (success[0], failure[1], or busy[2]).
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.
wiced_result_t wiced_hal_i2c_init ( UINT8  configure_path)

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.

(!) 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 for your device for more information.

Parameters
configure_path: WICED_I2C_SDA_P35_SCL_P37 OR WICED_I2C_SDA_I2S_DOUT_PCM_OUT_SCL_I2S_DIN_PCM_IN OR WICED_I2C_SDA_SFLASH_MOSI_SCL_SFLASH_MISO
Returns
wiced_result_t : On success WICED_SUCCESS otherwise WICED_ERROR
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 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], or busy[2]).
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 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], or busy[2]).