Bug in STM32F0 SPI Low-Level Driver LL_SPI_ReceiveData8 and LL_SPI_TransmitData8
Affected driver library STM32Cube_FW_F0_V1.9.0
Component SPI Low Level Driver in file "stm32f0xx_ll_spi.h"
Functions affected: LL_SPI_ReceiveData8 and LL_SPI_TransmitData8
Bug:
current implemented acces to SPIx->DR doesn't work as expected due to FIFO which resides in the STM32F0. Accessing the DR register with data wider than 8 Bit fills the FIFO and generates multiple physical reads / writes on the spi bus.
Correct implementation: cast DR register to 8 Bit.
__STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)
{
*((__IO uint8_t *)&SPIx->DR) = TxData;
}
__STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx)
{
return (uint8_t)(READ_REG(SPIx->DR));
}
Possibly LL_SPI_ReceiveData16 / LL_SPI_TransmitData16 are affected too. Have not tested this.
HAL implementation on the other hand is correct
