AnsweredAssumed Answered

STM32CubeMX v4.17.0 - incorrectly generates the call of __HAL_DMA1_REMAP macro

Question asked by kiss.tibor.001 on Oct 18, 2016
Latest reply on Nov 8, 2016 by STM32Cube-T
THE SAME BUG IT WAS OBSERVED BY OTHERS, (compared to other posts this eventually helps to reproduce and understand the problem).

After upgrading STM32CubeMX from 4.16.1 to 4.17.0 I found a bug.

Environment: I use STM32Cube_FW_F0_V1.6.0 firmware library.

Symptom:
In the stm32f0xx_hal_dma_ex.h the __HAL_DMA1_REMAP macro, together with the change introduced by the generator in usart.c does not compiles.

Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_hal_dma_ex.h:796:10: error: expected expression before 'do'
          do { assert_param(IS_HAL_DMA1_REMAP(__REQUEST__));                                             \

In the usart.c by generator, it is replaced the line
__HAL_DMA1_REMAP(HAL_DMA1_CH3_USART1_RX);

with 

    if (__HAL_DMA1_REMAP(HAL_DMA1_CH3_USART1_RX) != HAL_OK)
    {
      Error_Handler();
    }

The problem is similar what we find in the following article
http://pilt.github.io/2009/10/16/the-use-of-do-while-0-in-c-macros/

Temporarily I revert the changes in usart.c as a temporary workaround.

The problem is in the driver code, but the changes in the STM32CubeMX v4.17.0 with regard to the use of the macro causes an error.

Outcomes