diff --git a/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_crc.c b/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_crc.c index b5b778e00e..80532e08f1 100644 --- a/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_crc.c +++ b/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_crc.c @@ -421,7 +421,14 @@ uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t return temp; } +#if __GNUC__ +# define MAY_ALIAS __attribute__ ((__may_alias__)) +#else +# define MAY_ALIAS +#endif +typedef __IO uint8_t MAY_ALIAS uint8_io_t; +typedef __IO uint16_t MAY_ALIAS uint16_io_t; /** * @} @@ -486,16 +493,16 @@ static uint32_t CRC_Handle_8(CRC_HandleTypeDef *hcrc, uint8_t pBuffer[], uint32_ { if (BufferLength%4U == 1U) { - *(uint8_t volatile*) (&hcrc->Instance->DR) = pBuffer[4U*i]; + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4U*i]; } if (BufferLength%4U == 2U) { - *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U]; + *(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U]; } if (BufferLength%4U == 3U) { - *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U]; - *(uint8_t volatile*) (&hcrc->Instance->DR) = pBuffer[4U*i+2U]; + *(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U]; + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4U*i+2U]; } } @@ -524,7 +531,7 @@ static uint32_t CRC_Handle_16(CRC_HandleTypeDef *hcrc, uint16_t pBuffer[], uint3 } if ((BufferLength%2U) != 0U) { - *(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2U*i]; + *(uint16_io_t*) (&hcrc->Instance->DR) = pBuffer[2U*i]; } /* Return the CRC computed value */ diff --git a/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_ll_spi.h b/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_ll_spi.h index 2e693f54ab..e4b962184e 100644 --- a/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_ll_spi.h +++ b/targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_ll_spi.h @@ -1121,6 +1121,14 @@ __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData) *((__IO uint8_t *)&SPIx->DR) = TxData; } +#if __GNUC__ +# define MAY_ALIAS __attribute__ ((__may_alias__)) +#else +# define MAY_ALIAS +#endif + +typedef __IO uint16_t MAY_ALIAS uint16_io_t; + /** * @brief Write 16-Bits in the data register * @rmtoll DR DR LL_SPI_TransmitData16 @@ -1130,7 +1138,7 @@ __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData) */ __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData) { - *((__IO uint16_t *)&SPIx->DR) = TxData; + *((uint16_io_t*)&SPIx->DR) = TxData; } /** diff --git a/targets/TARGET_STM/TARGET_STM32L0/serial_device.c b/targets/TARGET_STM/TARGET_STM32L0/serial_device.c index 63cf3154de..dad4bef293 100644 --- a/targets/TARGET_STM/TARGET_STM32L0/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32L0/serial_device.c @@ -46,7 +46,7 @@ UART_HandleTypeDef uart_handlers[UART_NUM]; static uart_irq_handler irq_handler; // Defined in serial_api.c -inline int8_t get_uart_index(UARTName uart_name); +extern int8_t get_uart_index(UARTName uart_name); /****************************************************************************** * INTERRUPTS HANDLING