Bug in Low-Level driver LL_SPI_ReceiveData8 for STM32L0, STM32L4, STM32L5 and possibly others
Affected driver libraries: STM32Cube_FW_L5_V1.4.0, STM32Cube_FW_L4_V1.16.0, STM32Cube_FW_L0_V1.11.2 and possibly other device driver libraries based on the same SPI peripheral
File: stm32yyxx_ll_spi.h (Replace yy by L5, L4, F0, ...)
Functions affected: LL_SPI_ReceiveData8
Bug: Current implementation performs a 16bit read access to DR register and then casts the result to 8 bits. This leads to unexpected behavior. For example STM32L5 supports data packing, when SPI data frame size is less than or equal to 8 bits and 16 bits are read. In this case, the current implementation of LL_SPI_ReceiveData8 reads two (packed) bytes from DR register and discards the second one when casting the read result to 8 bits.
Correct implementation: Cast pointer to DR register to uint8_t before access.
__STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx)
{
return *((__IO uint8_t *)&SPIx->DR)
}
