stm32-rs / stm32g0xx-hal

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

Fix i2c data lost on start repeat condition #137

Closed fayalalebrun closed 1 year ago

fayalalebrun commented 1 year ago

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.

This fixes the issue by checking if there is pending data when an address interrupt is pending. This means that there wasn't a stop condition after the last address event.

I2cResult::Data also now returns the type of event which marked the end of the data. This is useful if special functionality is desired depending on the type of event. For example, some I2C interfaces require that the register and read/write commands be issued with no stop conditions between them.

Fixes #136

dotcypress commented 1 year ago

Thank you!