stm32-rs / stm32g0xx-hal

Peripheral access API for STM32G0 series microcontrollers
Apache License 2.0
73 stars 51 forks source link

I2C slave loses data on repeated start condition #136

Closed fayalalebrun closed 1 year ago

fayalalebrun commented 1 year ago

I am currently using the nonblocking I2C slave implementation. I noticed that whenever a repeated start condition was present, I lost data from everything but the last operation.

I believe the reason is because I2cResult::Data is only given by I2c::check_isr_flags when the stop condition interrupt is generated. The problem being that the stop condition interrupt is not generated on a repeated start condition.

Perhaps the solution is to also return I2cResult::Data from the address interrupt if no stop condition happened since the last address was received. The challenge is that I2c::check_isr_flags would then need to return two structs in that call, one for the data and one for the address.

It would be good to hear from those who have more insight into the current implementation.