stm32f4xx_hal_spi.c, HAL_SPI_TransmitReceive - conversion of HW register pointer
Hi Everyone,
In HAL_SPI_TransmitReceive, around line 937, there is a gem like that:
*((__IO uint8_t*)&hspi->Instance->DR) = (*pTxData);
Isn't it a bit dangerous to convert the HW register, which always have a specific size and usually also access restrictions (in case of DR - reading it will delete the received data, for example), instead of converting the data read from the buffer? Wouldn't it be better to have something like that instead:
hspi->Instance->DR = (uint32_t)(*pTxData);
BR,
M.W.
#hw-register-access #spi #hal_spi_transmitreceive #data-integrity