mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
Fix: Ensure I2C bus is free before master-write operation
The I2C master-write function was failing when executed immediately after an I2C read operation, requiring manual delays to function correctly. This fix introduces a check to ensure the I2C bus is free before initiating the write operation. According to the RM0399 manual for STM32H7 chips, the BUSY bit (Bit 15 in the I2C ISR register) indicates whether a communication is in progress on the bus. The BUSY bit is set by hardware when a START condition is detected and cleared when a STOP condition is detected or when PE = 0. This fix prevents the write operation from starting until the BUSY bit is cleared.
This commit is contained in:
parent
d5badb94d2
commit
060d1f6e6f
@ -109,6 +109,11 @@ impl<'d, M: Mode> I2c<'d, M> {
|
||||
timeout.check()?;
|
||||
}
|
||||
|
||||
// Wait for the bus to be free
|
||||
while info.regs.isr().read().busy(){
|
||||
timeout.check()?;
|
||||
};
|
||||
|
||||
let reload = if reload {
|
||||
i2c::vals::Reload::NOTCOMPLETED
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user