Skip to content

STM32 compilation warning issues #6599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 16, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
/* Disable the Ethernet global Interrupt */
NVIC_DisableIRQ(ETH_IRQn);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
/* Disable the Ethernet global Interrupt */
NVIC_DisableIRQ(ETH_IRQn);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ uint8_t mbed_otp_mac_address(char *mac)
memcpy(mac, _macAddr, 6);

return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
/* Disable the Ethernet global Interrupt */
NVIC_DisableIRQ(ETH_IRQn);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
/* Disable the Ethernet global Interrupt */
NVIC_DisableIRQ(ETH_IRQn);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
/* Disable the Ethernet global Interrupt */
NVIC_DisableIRQ(ETH_IRQn);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
/* Disable the Ethernet global Interrupt */
NVIC_DisableIRQ(ETH_IRQn);
}
}
}
19 changes: 14 additions & 5 deletions targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
}
}

Expand Down Expand Up @@ -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 */
Expand Down
10 changes: 9 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_ll_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F0/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F1/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F2/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,15 @@ HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc)
* @{
*/

#if __GNUC__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this solving for GCC?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pauluap@27425bc

The warning messages that this change clears is shown in the commit message. The warning only appears at the -O3 optimization level

# 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.
Expand All @@ -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];
}
}

Expand Down Expand Up @@ -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 */
Expand Down
10 changes: 9 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_ll_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F3/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F4/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------------*/
Expand Down
23 changes: 16 additions & 7 deletions targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
}
}

Expand Down Expand Up @@ -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 */
Expand Down
12 changes: 10 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_ll_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
* @{
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32F7/serial_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* @}
Expand Down Expand Up @@ -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];
}
}

Expand Down Expand Up @@ -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 */
Expand Down
Loading