Closed vadimol closed 6 years ago
We should also switch to using I2C_GetLastEvent
instead of I2C_GetFlagStatus
because the former allows checking for errors.
@rasendubi Makes sense.
@Dubland : check https://github.com/forGGe/theCore/issues/19#issuecomment-300573650
Function usage is described in stm32 i2c source.
Checks like these https://github.com/forGGe/theCore/blob/develop/platform/stm32/export/aux/i2c_bus.hpp#L586 must be re-implemented using I2C_GetFlagStatus
.
Error can be reported using bus event: https://github.com/forGGe/theCore/blob/develop/platform/common/export/common/bus.hpp#L26
After that, soft_reset
can try to repeat xfer if necessary:
https://github.com/forGGe/theCore/blob/develop/dev/sensor/htu21d/export/dev/sensor/htu21d.hpp#L177
Talk to @vadimol for more details of how i2c driver works if something unclear.
A small correction: checks must be re-implemented using I2C_GetLastEvent
.
I2C_GetFlagStatus
resets some status flags so is not appropriate to call multiple times in a row.
Implemented as a part of #279 Thanks to @Dubland !
For now i2c bus implementation does not support error handling. Actually device can hang in case of en error or glitch on a bus. For polling we can use timeouts for operations. For irq - there is a separate handler for errors.