Question
HAL Bug in stm32l1xx_hal.c?
I'm using FirmwarePackage=STM32Cube FW_L1 V1.10.1
I'm looking at these functions in stm32l1xx_hal.c:
/**
* @brief Return the first word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier 31:0 bits
*/
uint32_t HAL_GetUIDw0(void)
{
return(READ_REG(*((uint32_t *)UID_BASE)));
}
/**
* @brief Return the second word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier 63:32 bits
*/
uint32_t HAL_GetUIDw1(void)
{
return(READ_REG(*((uint32_t *)(UID_BASE + 0x4U))));
}
/**
* @brief Return the third word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier 95:64 bits
*/
uint32_t HAL_GetUIDw2(void)
{
return(READ_REG(*((uint32_t *)(UID_BASE + 0x14U))));
}They do not use a volatile pointer. Shouldn't they? Could a compiler optimize this in a bad way?
I would write them as:
return *((__IO uint32_t *)UID_BASE);