Skip to main content
Mihaita Ivascu
Associate III
May 25, 2025
Question

function macro usage issues in stm32cubeIDE

  • May 25, 2025
  • 1 reply
  • 486 views

Hello,

 

       I have some issues with function macros usage in my stm32cubeIDE project after importing some generated code in cubeIMX.

      This issues come on the back of my work related to this topic : is there any sample for X-NUCLEO-NFC08A1 to be use... - STMicroelectronics Community

 

  And the macro usage issues I have might be similar to the topic here 

Multiple "expected expression before 'do'" errors - Page 2 - STMicroelectronics Community

 

but I could not figure out what is the issue and solution in my case

 

in rfal_platform.h from the X-CUBE_NFC6 example I have error "expected expression before ',' for these macros:

 

 
#define platformGpioSet( port, pin ) HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET) /*!< Turns the given GPIO High */

#define platformGpioClear( port, pin ) HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET) /*!< Turns the given GPIO Low */

#define platformGpioToogle( port, pin ) HAL_GPIO_TogglePin(port, pin) /*!< Toogles the given GPIO */

#define platformGpioIsHigh( port, pin ) (HAL_GPIO_ReadPin(port, pin) == GPIO_PIN_SET) /*!< Checks if the given LED is High */

 

expect the TogglePin one.

 

../X-CUBE-NFC6/Target/rfal_platform.h:99:77: error: expected expression before ',' token
 99 | #define platformGpioClear( port, pin ) HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET) /*!< Turns the given GPIO Low */
 | ^
../X-CUBE-NFC6/Target/rfal_platform.h:104:55: note: in expansion of macro 'platformGpioClear'
 104 | #define platformLedOff( port, pin ) platformGpioClear(port, pin) /*!< Turns the given LED Off */
 | ^~~~~~~~~~~~~~~~~
../Drivers/BSP/Components/ST25R3916/st25r3916_led.c:53:43: note: in expansion of macro 'platformLedOff'
 53 | #define st25r3916ledFieldOff() platformLedOff( PLATFORM_LED_FIELD_PORT, PLATFORM_LED_FIELD_PIN ); /*!< LED Field 

 

 I mention I did not modify the code generated in cubeIMX

 

Thanks,

Mihai

 

 

1 reply

CTapp.1
Senior III
May 27, 2025

I assume this happens when you invoke the st25r3916ledFieldOff() macro?

What do PLATFORM_LED_FIELD_PORT and PLATFORM_LED_FIELD_PIN expand as?

All posts are made in a personal capacityMISRA C++ ChairMISRA C WG MemberDirector The MISRA Consortium Limited (TMCL)