The fsl_i2c.c drive file does not operate with i2c chips with base device adresses above < 128
The original code shifts out the 8 bit of the base adress. eg. If you wanted to adress a PCA5532 with base adress 0xc0 it will pass the wrong adress (0x40)
with some additional lines it wil works ok with al adresses.
status_t I2C_MasterStart(I2C_Type *base, uint8_t address, i2c_direction_t direction)
{
if (I2C_PendingStatusWait(base) == (uint32_t)kStatus_I2C_Timeout)
{
return kStatus_I2C_Timeout;
}
/* Write Address and RW bit to data register */
if (address < 127){
base->MSTDAT = ((uint32_t)address << 1) | ((uint32_t)direction & 1u);
}
else{
base->MSTDAT = ((uint32_t)address ) | ((uint32_t)direction & 1u);
}
/* Start the transfer */
base->MSTCTL = I2C_MSTCTL_MSTSTART_MASK;
return kStatus_Success;
}
Hi
I can not find out the data sheet of PCA5532, but I found out PCA9532 from the link:
https://www.nxp.com.cn/docs/en/data-sheet/PCA9532.pdf
If the A2/A1/A0 are 000 in binary, you can set the address as 0xC0>>1 or 0x60 when you call the I2C_MasterStart(I2C_Type *base, uint8_t address, i2c_direction_t direction)
Hope it can help you
BR
XiangJun Rong