Skip to content

Commit eeca430

Browse files
committed
STM32L0 : correct compilation warnings
1 parent 2d0dce1 commit eeca430

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_crc.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,14 @@ uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t
421421
return temp;
422422
}
423423

424+
#if __GNUC__
425+
# define MAY_ALIAS __attribute__ ((__may_alias__))
426+
#else
427+
# define MAY_ALIAS
428+
#endif
424429

430+
typedef __IO uint8_t MAY_ALIAS uint8_io_t;
431+
typedef __IO uint16_t MAY_ALIAS uint16_io_t;
425432

426433
/**
427434
* @}
@@ -486,16 +493,16 @@ static uint32_t CRC_Handle_8(CRC_HandleTypeDef *hcrc, uint8_t pBuffer[], uint32_
486493
{
487494
if (BufferLength%4U == 1U)
488495
{
489-
*(uint8_t volatile*) (&hcrc->Instance->DR) = pBuffer[4U*i];
496+
*(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4U*i];
490497
}
491498
if (BufferLength%4U == 2U)
492499
{
493-
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U];
500+
*(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U];
494501
}
495502
if (BufferLength%4U == 3U)
496503
{
497-
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U];
498-
*(uint8_t volatile*) (&hcrc->Instance->DR) = pBuffer[4U*i+2U];
504+
*(uint16_io_t*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4U*i]<<8U) | (uint32_t)pBuffer[4U*i+1U];
505+
*(uint8_io_t*) (&hcrc->Instance->DR) = pBuffer[4U*i+2U];
499506
}
500507
}
501508

@@ -524,7 +531,7 @@ static uint32_t CRC_Handle_16(CRC_HandleTypeDef *hcrc, uint16_t pBuffer[], uint3
524531
}
525532
if ((BufferLength%2U) != 0U)
526533
{
527-
*(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2U*i];
534+
*(uint16_io_t*) (&hcrc->Instance->DR) = pBuffer[2U*i];
528535
}
529536

530537
/* Return the CRC computed value */

targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_ll_spi.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,14 @@ __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)
11211121
*((__IO uint8_t *)&SPIx->DR) = TxData;
11221122
}
11231123

1124+
#if __GNUC__
1125+
# define MAY_ALIAS __attribute__ ((__may_alias__))
1126+
#else
1127+
# define MAY_ALIAS
1128+
#endif
1129+
1130+
typedef __IO uint16_t MAY_ALIAS uint16_io_t;
1131+
11241132
/**
11251133
* @brief Write 16-Bits in the data register
11261134
* @rmtoll DR DR LL_SPI_TransmitData16
@@ -1130,7 +1138,7 @@ __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)
11301138
*/
11311139
__STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
11321140
{
1133-
*((__IO uint16_t *)&SPIx->DR) = TxData;
1141+
*((uint16_io_t*)&SPIx->DR) = TxData;
11341142
}
11351143

11361144
/**

targets/TARGET_STM/TARGET_STM32L0/serial_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ UART_HandleTypeDef uart_handlers[UART_NUM];
4646
static uart_irq_handler irq_handler;
4747

4848
// Defined in serial_api.c
49-
inline int8_t get_uart_index(UARTName uart_name);
49+
extern int8_t get_uart_index(UARTName uart_name);
5050

5151
/******************************************************************************
5252
* INTERRUPTS HANDLING

0 commit comments

Comments
 (0)