comparing
- (a) https://patchwork.kernel.org/patch/10205401/ and
- (b) https://github.com/DWagenk/zephyr/tree/stm32_i2c_v2_multi_master
relevant for zephyrproject-rtos/zephyr#5224
relevant functions
(a) | (b) |
---|---|
stm32f7_i2c_xfer |
i2c_stm32_transfer (i2c_ll_stm32.c) |
stm32f7_i2c_xfer_msg |
msg_init |
stm32f7_i2c_isr_event |
stm32_i2c_event_isr |
stm32f7_i2c_isr_error |
stm32_i2c_error_isr |
stm32f7_i2c_slave_isr_event |
stm32_i2c_slave_event and stm32_i2c_slave_error |
-
(a) switches to master_mode in
stm32f7_i2c_xfer_msg
, directly before generating start condition on bus(b) does it already when preparing the messages in
i2c_stm32_transfer
-
(a) exits master_mode in case of arbitration lost or when a stop condition is issued on the bus, both directly inside the isr
(b) exits master_mode in case of arbitration lost or when all messages that were passed to
i2c_stm32_transfer
have been transfered. -
(a) returns from
stm32f7_i2c_xfer
with-EAGAIN
in case of arbitration lost(b) returns from
i2c_stm32_transfer
with-EIO
in case of arbitration lost -
both (a) and (b) could loose arbitration in the middle of multiple messages passed to
stm32f7_i2c_xfer
/i2c_stm32_transfer
, if there's a stop condition somewhere inbetween them. Caller ofstm32f7_i2c_xfer
/i2c_stm32_transfer
will not know if none, or just parts of the messages have been transfered.--> this should be declared undefined behaviour! A stop condition is only allowed in the last message passed to
stm32f7_i2c_xfer
/i2c_stm32_transfer
-
(a) uses SlaveByteControl mode to ack/nack each byte, (b) doesn't
-
(a) flushes RX buffer when master mode read is finished, (b) doesn't
- move the switching ot master_mode directly before issuing start condition and disable it directly after issuing stop condition on the bus
- move the switching out of master_mode directly after arbitration lost is detected
- return
-EAGAIN
in case of arbitration lost