AIROC™ BTSDK v4.6 - Documentation | ||||
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... | |
anonymous enum |
Defines the I2C master driver.
The standard I2CM driver provides the status and control for the I2C HW.
anonymous enum |
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.
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.
secondTranBuf | Pointer to a buffer into which the read portion of the transaction is to read into. |
secondTranCount | Number of bytes to read in the second transaction. |
firstTranBuf | Pointer to a buffer from which the write portion of the transaction is to write from. |
firstTranCount | Number of bytes to write in the first transaction. |
slaveAdr | The address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid). |
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.
secondTranBuf | Pointer to a buffer from which the second write portion of the transaction is to write from. |
secondTranCount | Number of bytes to write in the second transaction. |
firstTranBuf | Pointer to a buffer from which the write portion of the transaction is to write from. |
firstTranCount | Number of bytes to write in the first transaction. |
slaveAdr | The address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid). |
UINT8 i2cm_getSpeed | ( | void | ) |
Gets the current speed set up by the application.
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.
length | Length of the data to read from slave device. |
slave | The address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid). |
void i2cm_setSpeed | ( | UINT8 | divisor | ) |
Allows the I2C speed to be selected.
Default is 100 KHz.
divisor | The 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.
length | Length of the data to write to slave device. |
slave | The address of the slave device. Slave address is always control address << 1 (slave[7:1] are valid). |