Wire fixes for repeated start(slave) and multiple .write in onRequestEvent()#1221
Conversation
ABOSTM
left a comment
There was a problem hiding this comment.
Hi @DanielLiebler,
Thanks for your Pull Request.
After review, it looks good to me,
but I would like to test, specially because there are 2 major I2C Hardware implementation within STM32 families.
Can you tell me what you tested ? which boards ...
Can you tell me how you tested ? Which master with repeated start?
Can you share you sketch () ?
|
Thank I will test that. |
|
Thanks @DanielLiebler for this PR. Note: The CI core compilation issue is normal as I'm updating some dependencies and will be back to normal soon. |
8447ea4 to
f873eda
Compare
|
@fpistm should be done. I didnt know you could do such things, even though I guess you can mess up things really bad with squashing^^ |
|
Thanks @DanielLiebler |
f873eda to
3624374
Compare
…stEvent() as Slave
…/no stop condition is sent in slave mode
3624374 to
65335d8
Compare
Summary
This PR fixes/implements the following bugs/features
Description
The slave implementation doesn't seem to work with repeated starts, but this is also a quick fix by sending out an onReceiveEvent() when getting the new address callback.
In could'nt recieve integers at master from slave #488 it was mentioned to just use one write, but I think this is not good behavior, since it's not mentioned in the documentation. Nevertheless, it seems to be a quick fix, so I just created this PR.
How it works
When getting the address callback, the data which has been cached is sent to an onReceiveEvent, when still in SLAVE_MODE_RECEIVE mode.
We are resetting i2cTxRxBufferSize before calling i2c_onSlaveTransmit() in HAL_I2C_AddrCallback()
and modify the function i2c_slave_write_IT() to start writing in the i2cTxRxBuffer with the size of the buffer as offset and add up the sizes.