StratifyLabs / StratifyOS-mcu-stm32

Stratify OS MCU Abstraction Library for STM32 Cortex M Devices
MIT License
6 stars 5 forks source link

STM32F4 I2C Driver must have an elevated interrupt priority #37

Open tyler-gilbert opened 5 years ago

tyler-gilbert commented 5 years ago

When using HAL_I2C_Mem_Read_IT(), there is a race condition that happens if the interrupt priority of the I2C is not elevated.

The interrupt gets stuck in a loop handling I2C_MasterTransmit_BTF() because the state is set to RX so I2C_MasterReceive_BTF should be called rather than I2C_MasterTransmit_BTF().

tyler-gilbert commented 5 years ago

Use HAL_I2C_Master_Sequential_Transmit_IT() and HAL_I2C_Master_Sequential_Receive_IT() instead of HAL_I2C_Mem_Read_IT() to fix this.