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

Enumerations

enum  {
  I2CM_SPEED_100KHZ = (0x01 << 4), I2CM_SPEED_400KHZ = (0x00 << 4), I2CM_SPEED_800KHZ = (0x02 << 4), I2CM_SPEEC_1000KHZ = (0x03 << 4),
  I2CM_SPEEC_2000KHZ = (0x04 << 4)
}
 Defines the I2C master driver. More...
 
enum  { I2CM_SUCCESS, I2CM_OP_FAILED, I2CM_BUSY }
 Driver status. More...
 
enum  { I2CM_SCL_SPEED_MAX = 10, I2CM_SCL_SPEED_MIN = 255 }
 SCL speed is governed by a counter that counts the number of cycles of the reference clock which is always 24 MHz. More...
 

Functions

void i2cm_init (void)
 I2C master initialization routine.
 
void i2cm_setSpeed (UINT8 divisor)
 Allows the I2C speed to be selected. More...
 
void i2cm_setTransactionSpeed (void)
 Internal helper function to set speed.
 
UINT8 i2cm_getSpeed (void)
 Gets the current speed set up by the application. More...
 
UINT8 i2cm_write (UINT8 *data, UINT16 length, UINT8 slave)
 Writes data to the I2C slave. More...
 
UINT8 i2cm_read (UINT8 *data, UINT16 length, UINT8 slave)
 Reads data from the I2C slave. More...
 
UINT8 i2cm_comboRead (UINT8 *secondTranBuf, UINT16 secondTranCount, UINT8 *firstTranBuf, UINT8 firstTranCount, UINT8 slaveAdr)
 Do a combination write, followed by a repeated start followed by a read transaction. More...
 
UINT8 i2cm_comboWrite (UINT8 *secondTranBuf, UINT16 secondTranCount, UINT8 *firstTranBuf, UINT8 firstTranCount, UINT8 slaveAdr)
 Do a combination write, followed by a repeated start followed by a write transaction. More...
 

Detailed Description

Enumeration Type Documentation

anonymous enum

Defines the I2C master driver.

The standard I2CM driver provides the status and control for the I2C HW.

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_SPEEC_1000KHZ 

I2C speed is 1 MHz.

I2CM_SPEEC_2000KHZ 

I2C speed is 2 MHz NOT AVAILABLE IN ALL PARTS Contact Infineon support for more info I2C will default to 100 KHz if not supported.

anonymous enum

Driver status.

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.

anonymous enum

SCL speed is governed by a counter that counts the number of cycles of the reference clock which is always 24 MHz.

So, for a speed of 2.4 MHz, the counter has to be set to a value of 10 while for a speed of 100 KHz, the counter has to be set to 240.

Enumerator
I2CM_SCL_SPEED_MAX 

The minimum value of SCL counter for maximum SCL speed of 2.4 MHz.

Speeds higher than this may not be possible to achieve without restrictions.

I2CM_SCL_SPEED_MIN 

The maximum value of SCL counter for minimum SCL speed of ~94.1 KHz.

Speeds lower than this are not possible.

Function Documentation

UINT8 i2cm_comboRead ( UINT8 *  secondTranBuf,
UINT16  secondTranCount,
UINT8 *  firstTranBuf,
UINT8  firstTranCount,
UINT8  slaveAdr 
)

Do a combination write, followed by a repeated start followed by a read transaction.

If the second transaction is longer than 16 bytes, firstTranBuf will be treated as an address and automatically be incremented by the transaction size before the next chunk is read back in. This is useful when reading large number of bytes from an EEPROM.

Parameters
secondTranBufPointer to a buffer into which the read portion of the transaction is to read into.
secondTranCountNumber of bytes to read in the second transaction.
firstTranBufPointer to a buffer from which the write portion of the transaction is to write from.
firstTranCountNumber of bytes to write in the first transaction.
slaveAdrThe address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid).
Returns
Status - success, failure or busy.
UINT8 i2cm_comboWrite ( UINT8 *  secondTranBuf,
UINT16  secondTranCount,
UINT8 *  firstTranBuf,
UINT8  firstTranCount,
UINT8  slaveAdr 
)

Do a combination write, followed by a repeated start followed by a write transaction.

If the second transaction is longer than 16 bytes, firstTranBuf will be treated as an address and automatically be incremented by the transaction size before the next chunk is read back in.

Parameters
secondTranBufPointer to a buffer from which the second write portion of the transaction is to write from.
secondTranCountNumber of bytes to write in the second transaction.
firstTranBufPointer to a buffer from which the write portion of the transaction is to write from.
firstTranCountNumber of bytes to write in the first transaction.
slaveAdrThe address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid).
Returns
Status - success, failure or busy.
UINT8 i2cm_getSpeed ( void  )

Gets the current speed set up by the application.

Returns
The currently configured divisor.
UINT8 i2cm_read ( UINT8 *  data,
UINT16  length,
UINT8  slave 
)

Reads data from the I2C slave.

Max transaction length is 16 bytes. longer transactions will be broken down into multiple 16 byte transactions. param data Pointer to a buffer into which data is to be read.

Parameters
lengthLength of the data to read from slave device.
slaveThe address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid).
Returns
Status - success, failure or busy.
void i2cm_setSpeed ( UINT8  divisor)

Allows the I2C speed to be selected.

Default is 100 KHz.

Parameters
divisorThe divisor to use on the 24 MHz reference to get the desired I2C SCL speed.
UINT8 i2cm_write ( UINT8 *  data,
UINT16  length,
UINT8  slave 
)

Writes data to the I2C slave.

Max transaction length is 16 bytes. longer transactions will be broken down into multiple 16 byte transactions. param data Pointer to a buffer that has the data to write.

Parameters
lengthLength of the data to write to slave device.
slaveThe address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid).
Returns
Status - success, failure or busy.