diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/stm32f2_eth_init.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/stm32f2_eth_init.c index 54fcdc3679..df1e509ddf 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/stm32f2_eth_init.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/stm32f2_eth_init.c @@ -84,4 +84,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) /* Disable the Ethernet global Interrupt */ NVIC_DisableIRQ(ETH_IRQn); } -} \ No newline at end of file +} diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_ARCH_MAX/stm32f4_eth_init.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_ARCH_MAX/stm32f4_eth_init.c index 9123c87752..172ae42d70 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_ARCH_MAX/stm32f4_eth_init.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_ARCH_MAX/stm32f4_eth_init.c @@ -78,4 +78,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) /* Disable the Ethernet global Interrupt */ NVIC_DisableIRQ(ETH_IRQn); } -} \ No newline at end of file +} diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_MTB_UBLOX_ODIN_W2/stm32f4_eth_init.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_MTB_UBLOX_ODIN_W2/stm32f4_eth_init.c index 9baf012f2a..b9c1bb359e 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_MTB_UBLOX_ODIN_W2/stm32f4_eth_init.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_MTB_UBLOX_ODIN_W2/stm32f4_eth_init.c @@ -156,4 +156,4 @@ uint8_t mbed_otp_mac_address(char *mac) memcpy(mac, _macAddr, 6); return 1; -} \ No newline at end of file +} diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F429ZI/stm32f4_eth_init.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F429ZI/stm32f4_eth_init.c index 4f4d39f8b0..835119fad0 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F429ZI/stm32f4_eth_init.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F429ZI/stm32f4_eth_init.c @@ -84,4 +84,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) /* Disable the Ethernet global Interrupt */ NVIC_DisableIRQ(ETH_IRQn); } -} \ No newline at end of file +} diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F439ZI/stm32f4_eth_init.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F439ZI/stm32f4_eth_init.c index 4f4d39f8b0..835119fad0 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F439ZI/stm32f4_eth_init.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F439ZI/stm32f4_eth_init.c @@ -84,4 +84,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) /* Disable the Ethernet global Interrupt */ NVIC_DisableIRQ(ETH_IRQn); } -} \ No newline at end of file +} diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F746ZG/stm32f7_eth_init.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F746ZG/stm32f7_eth_init.c index 2c93885c12..758ae1cbb3 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F746ZG/stm32f7_eth_init.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F746ZG/stm32f7_eth_init.c @@ -86,4 +86,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) /* Disable the Ethernet global Interrupt */ NVIC_DisableIRQ(ETH_IRQn); } -} \ No newline at end of file +} diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F756ZG/stm32f7_eth_init.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F756ZG/stm32f7_eth_init.c index 2c93885c12..758ae1cbb3 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F756ZG/stm32f7_eth_init.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F756ZG/stm32f7_eth_init.c @@ -86,4 +86,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) /* Disable the Ethernet global Interrupt */ NVIC_DisableIRQ(ETH_IRQn); } -} \ No newline at end of file +} diff --git a/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_crc.c b/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_crc.c index cd94ee26f4..a5f2fa6b55 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_crc.c +++ b/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_crc.c @@ -421,6 +421,15 @@ uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t * @{ */ +#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; + /** * @brief Return the CRC handle state. * @param hcrc CRC handle @@ -468,16 +477,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[4*i]; + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4*i]; } if (BufferLength%4U == 2U) { - *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; + *(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; } if (BufferLength%4U == 3U) { - *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; - *(uint8_t volatile*) (&hcrc->Instance->DR) = pBuffer[4*i+2]; + *(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4*i+2]; } } @@ -508,7 +517,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[2*i]; + *(uint16_io_t*) (&hcrc->Instance->DR) = pBuffer[2*i]; } /* Return the CRC computed value */ diff --git a/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_ll_spi.h b/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_ll_spi.h index d3a638158f..7bfadbb36e 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_ll_spi.h +++ b/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_ll_spi.h @@ -1376,6 +1376,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 @@ -1385,7 +1393,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_STM32F0/serial_device.c b/targets/TARGET_STM/TARGET_STM32F0/serial_device.c index 616ff295be..d3f784e127 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32F0/serial_device.c @@ -48,7 +48,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 diff --git a/targets/TARGET_STM/TARGET_STM32F1/serial_device.c b/targets/TARGET_STM/TARGET_STM32F1/serial_device.c index b7f90176c9..6f344e9f1f 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32F1/serial_device.c @@ -40,7 +40,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 diff --git a/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_mmc.c b/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_mmc.c index 21801cf689..ed34e4d162 100644 --- a/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_mmc.c +++ b/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_mmc.c @@ -1309,7 +1309,7 @@ HAL_StatusTypeDef HAL_MMC_Erase(MMC_HandleTypeDef *hmmc, uint32_t BlockStartAdd, hmmc->State = HAL_MMC_STATE_BUSY; /* Check if the card command class supports erase command */ - if((hmmc->MmcCard.Class) & SDIO_CCCC_ERASE == 0U) + if(((hmmc->MmcCard.Class) & SDIO_CCCC_ERASE) == 0U) { /* Clear all the static flags */ __HAL_MMC_CLEAR_FLAG(hmmc, SDIO_STATIC_FLAGS); diff --git a/targets/TARGET_STM/TARGET_STM32F2/serial_device.c b/targets/TARGET_STM/TARGET_STM32F2/serial_device.c index 662a0083ac..93fba8f95e 100644 --- a/targets/TARGET_STM/TARGET_STM32F2/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32F2/serial_device.c @@ -40,7 +40,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 diff --git a/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_crc.c b/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_crc.c index c80edc2c0e..0ee8af6f19 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_crc.c +++ b/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_crc.c @@ -454,6 +454,15 @@ HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc) * @{ */ +#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; + /** * @brief Enter 8-bit input data to the CRC calculator. * Specific data handling to optimize processing time. @@ -478,16 +487,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[4*i]; + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4*i]; } if (BufferLength%4U == 2U) { - *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; + *(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; } if (BufferLength%4U == 3U) { - *(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; - *(uint8_t volatile*) (&hcrc->Instance->DR) = pBuffer[4*i+2]; + *(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1]; + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4*i+2]; } } @@ -518,7 +527,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[2*i]; + *(uint16_io_t*) (&hcrc->Instance->DR) = pBuffer[2*i]; } /* Return the CRC computed value */ diff --git a/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_ll_spi.h b/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_ll_spi.h index bdfc780cb1..e2bfd30fa4 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_ll_spi.h +++ b/targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_ll_spi.h @@ -1379,6 +1379,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 @@ -1388,7 +1396,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_STM32F3/serial_device.c b/targets/TARGET_STM/TARGET_STM32F3/serial_device.c index 244423a400..12fa338255 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32F3/serial_device.c @@ -44,7 +44,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 diff --git a/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_can_legacy.c b/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_can_legacy.c index 7a4cf5378e..d92b7e7e11 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_can_legacy.c +++ b/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_can_legacy.c @@ -136,7 +136,7 @@ #error 'The HAL CAN driver cannot be used with its legacy, Please ensure to enable only one HAL CAN module at once in stm32f4xx_hal_conf.h file' #endif /* HAL_CAN_MODULE_ENABLED */ -#warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' +// #warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ diff --git a/targets/TARGET_STM/TARGET_STM32F4/serial_device.c b/targets/TARGET_STM/TARGET_STM32F4/serial_device.c index 4d70743cfe..37c11d090d 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32F4/serial_device.c @@ -50,7 +50,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 diff --git a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_can_legacy.c b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_can_legacy.c index 33c70e9330..f47543a2d3 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_can_legacy.c +++ b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_can_legacy.c @@ -130,7 +130,7 @@ #error 'The HAL CAN driver cannot be used with its legacy, Please ensure to enable only one HAL CAN module at once in stm32f7xx_hal_conf.h file' #endif /* HAL_CAN_MODULE_ENABLED */ -#warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' +// #warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ diff --git a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_crc.c b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_crc.c index 74c94d2d0c..236d0418dc 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_crc.c +++ b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_crc.c @@ -405,9 +405,18 @@ 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; + +/** * @brief Enter 8-bit input data to the CRC calculator. - * Specific data handling to optimize processing time. + * Specific data handling to optimize processing time. * @param hcrc CRC handle * @param pBuffer pointer to the input data buffer * @param BufferLength input data buffer length @@ -429,16 +438,16 @@ static uint32_t CRC_Handle_8(CRC_HandleTypeDef *hcrc, uint8_t pBuffer[], uint32_ { if(BufferLength%4 == 1) { - *(__IO uint8_t*) (&hcrc->Instance->DR) = pBuffer[4*i]; + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4*i]; } if(BufferLength%4 == 2) { - *(__IO uint16_t*) (&hcrc->Instance->DR) = (uint16_t)((uint16_t)((uint16_t)(pBuffer[4*i])<<8) | (uint16_t)(pBuffer[4*i+1])); + *(uint16_io_t*) (&hcrc->Instance->DR) = (uint16_t)((uint16_t)((uint16_t)(pBuffer[4*i])<<8) | (uint16_t)(pBuffer[4*i+1])); } if(BufferLength%4 == 3) { - *(__IO uint16_t*) (&hcrc->Instance->DR) = (uint16_t)((uint16_t)((uint16_t)(pBuffer[4*i])<<8) | (uint16_t)(pBuffer[4*i+1])); - *(__IO uint8_t*) (&hcrc->Instance->DR) = pBuffer[4*i+2]; + *(uint16_io_t*) (&hcrc->Instance->DR) = (uint16_t)((uint16_t)((uint16_t)(pBuffer[4*i])<<8) | (uint16_t)(pBuffer[4*i+1])); + *(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4*i+2]; } } @@ -467,7 +476,7 @@ static uint32_t CRC_Handle_16(CRC_HandleTypeDef *hcrc, uint16_t pBuffer[], uint3 } if((BufferLength%2) != 0) { - *(__IO uint16_t*) (&hcrc->Instance->DR) = pBuffer[2*i]; + *(uint16_io_t*) (&hcrc->Instance->DR) = pBuffer[2*i]; } /* Return the CRC computed value */ diff --git a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_ll_spi.h b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_ll_spi.h index fd666f80cc..4bc61b6922 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_ll_spi.h +++ b/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_ll_spi.h @@ -48,7 +48,7 @@ extern "C" { * @{ */ -#if defined (SPI1) || defined (SPI2) || defined (SPI3) || defined(SPI4) || defined(SPI5) || defined(SPI6) +#if defined (SPI1) || defined (SPI2) || defined (SPI3) || defined(SPI4) || defined(SPI5) || defined(SPI6) /** @defgroup SPI_LL SPI * @{ @@ -1376,6 +1376,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 @@ -1385,7 +1393,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_STM32F7/serial_device.c b/targets/TARGET_STM/TARGET_STM32F7/serial_device.c index 1e88e67ae2..b9e5d6b096 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32F7/serial_device.c @@ -39,7 +39,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 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 diff --git a/targets/TARGET_STM/TARGET_STM32L1/serial_device.c b/targets/TARGET_STM/TARGET_STM32L1/serial_device.c index 60234cb95f..5d85a0a9c0 100755 --- a/targets/TARGET_STM/TARGET_STM32L1/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32L1/serial_device.c @@ -40,7 +40,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 diff --git a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_can_legacy.c b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_can_legacy.c index 7e93892d6a..3b88ba4f2f 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_can_legacy.c +++ b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_can_legacy.c @@ -120,7 +120,7 @@ #error 'The HAL CAN driver cannot be used with its legacy, Please ensure to enable only one HAL CAN module at once in stm32l4xx_hal_conf.h file' #endif /* HAL_CAN_MODULE_ENABLED */ -#warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' +// #warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' #if defined(CAN1) diff --git a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_ll_spi.h b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_ll_spi.h index b88bcd537c..108715f153 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_ll_spi.h +++ b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_ll_spi.h @@ -1376,6 +1376,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 @@ -1385,7 +1393,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_STM32L4/serial_device.c b/targets/TARGET_STM/TARGET_STM32L4/serial_device.c index c56f854be3..ac9bc85d1f 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32L4/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 diff --git a/targets/TARGET_STM/stm_spi_api.c b/targets/TARGET_STM/stm_spi_api.c index e93b23ff8d..73d632c45c 100644 --- a/targets/TARGET_STM/stm_spi_api.c +++ b/targets/TARGET_STM/stm_spi_api.c @@ -67,6 +67,10 @@ /* Consider 10ms as the default timeout for sending/receving 1 byte */ #define TIMEOUT_1_BYTE 10 +#if defined(SPI_FLAG_FRLVL) // STM32F0 STM32F3 STM32F7 STM32L4 +extern HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi); +#endif + void init_spi(spi_t *obj) { struct spi_s *spiobj = SPI_S(obj);