AnsweredAssumed Answered

stm32l1xx_ll_spi.h BUG and Warning

Question asked by Kiss.Tibor on Dec 15, 2016
Latest reply on Mar 13, 2017 by Imen D

Dear Sirs


File : stm32l1xx_ll_spi.h

 

Very ugly BUG !!!!

 

__STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
{

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#if defined(GPIO_BRR_BR_0)   !!!!!!!   Correct : (GPIO_BRR)  !!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

WRITE_REG(GPIOx->BRR, PinMask);
#else
WRITE_REG(GPIOx->BSRR, (PinMask << 16));
#endif /* GPIO_BRR_BR_0 */
}

 

OpenSTM32 rise a warning :

arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -D__weak=__attribute__((weak)) -D__packed=__attribute__((__packed__)) -DUSE_HAL_DRIVER -DSTM32L100xC

 

stm32l1xx_ll_spi.h:1137:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

 

__STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
{
*((__IO uint16_t *)&SPIx->DR) = TxData;
}

 

This code compiled without warning :

__STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)
{
*((__IO uint8_t *)&SPIx->DR) = TxData;
}

 

Thanks

Tibor Kiss

Outcomes