Other Parts Discussed in Thread: TCA9539
One of our customers is using MSPM0 to communication with IO expander TCA9539 via I2C.
one operation is write-data-read-data with repeated START. Here is the code:
uint8 I2c_CfgReadTransfer (uint32* Register, uint32 slave_address, uint8 RegisterAddress, uint8 *I2c_in_buffer, uint8 i2c_buff_length )
{
T_I2C_MASTER_TRANSMIT_STATUS return_value = I2C_MASTER_ERR_BUFFER_OVERFLOW;
uint8 ReceptionCounter;
DL_I2C_enableControllerReadOnTXEmpty( ((I2C_Regs*)Register) );
/* Fill FIFO with Tx Data. Complete Transfer is of 8 bytes, only 4 are
* required for the GPIO Port Expanders */
DL_I2C_fillControllerTXFIFO( ((I2C_Regs*)Register), &RegisterAddress, (uint16)C_I2C_REG_ADD_SIZE);
if( (C_I2C_RX_MAX_PACKET_SIZE > i2c_buff_length) & (0U != i2c_buff_length) )
{
if ( C_I2C_MAX_7_BIT_ADD >= slave_address )
{
/* Wait for I2C to be Idle */
while (!( DL_I2C_getControllerStatus( ((I2C_Regs*)Register)) & C_I2C_CONTROLER_IN_IDLE_MASK));
/* This function sends Start + Stop automatically */
DL_I2C_startControllerTransfer( ((I2C_Regs*)Register), slave_address, DL_I2C_CONTROLLER_DIRECTION_RX, (i2c_buff_length) );
/* Receive all bytes from target */
........
}
The highlighted API calls are correct to start the required operation. However, it does not work, because the last API DL_I2C_startControllerTransfer() clear (overwrite) the RD_ON_TXEMPTY bit set by previous DL_I2C_enableControllerReadOnTXEmpty() call.
It is an issue on DL_I2C_startControllerTransfer API.