I'm trying to use my FRDM-K64F as an I2C Slave, and have found what I believe to be a few issues in the relevant i2c_api.c file. However, I'm only (currently) writing bytes to my board, and am not in a position to test it in master mode, so I don't know whether my changes only work in my case, or what a proper solution would be.
Has anyone got this code working - what environment was used to test it?
I've moved a few chunks of code around, but the things that most stood out as potentially problematic were:
- in i2c_slave_address(), there is a call to I2C_HAL_SetUpperAddress7bit() which I think should be instead made to I2C_HAL_SetAddress7bit() to set the slave address correctly.
- in i2c_slave_read(), the transfer direction is set up at the start, but in transmit mode. I believe that kI2CReceive should be used instead of kI2CSend in the call to I2C_HAL_SetDirMode().
- at the end of i2c_byte_read() the bus is put back into transmit mode. Removing the line I2C_HAL_SetDirMode(i2c_addrs[obj->instance], kI2CSend); seemed to make multi-byte reception better.
Can anyone comment whether any of these look like they're heading in the right direction?
Alan
I'm trying to use my FRDM-K64F as an I2C Slave, and have found what I believe to be a few issues in the relevant i2c_api.c file. However, I'm only (currently) writing bytes to my board, and am not in a position to test it in master mode, so I don't know whether my changes only work in my case, or what a proper solution would be.
Has anyone got this code working - what environment was used to test it?
I've moved a few chunks of code around, but the things that most stood out as potentially problematic were:
Can anyone comment whether any of these look like they're heading in the right direction?
Alan