2021-12-03 05:52 AM
Affected driver library: STM32Cube_FW_U5 v1.0.0 and patch v1.0.2
File: stm32u5xx_ll_spi.h
Function affected: LL_SPI_ReceiveData16
Bug: Current implementation performs a 32bit access to RXDR register and then casts the result to 16 bits. This leads to unexpected behavior due to data packing, when SPI data frame size is less than or equal to 8 bits. In this case, the current implementation of LL_SPI_ReceiveData16 reads four (packed) bytes from RXDR register and discards the upper 2 ones when casting the read result to 16 bits.
Correct implementation: Cast pointer to RXDR register to uint16_t before access (analog to LL_SPI_ReceiveData8 and LL_SPI_ReceiveData32.
__STATIC_INLINE uint16_t LL_SPI_ReceiveData16(SPI_TypeDef *SPIx)
{
return (*((__IO uint16_t *)&SPIx->RXDR));
}
2021-12-03 05:55 AM
Hello @SOfne.1 ,
Thank you for pointing out this issue.
I am checking it internally and I will come back to you with update.
Imen
2021-12-16 12:55 AM
Hi @SOfne.1
An internal ticket ID 118898 is created in order to correct the HAL.
(PS: Internal ticket ID 118898 is an internal tracking number and is not accessible or usable by customers).
Thanks
Imen