Skip to main content
EdGi
Associate II
January 16, 2020
Question

Using STM32IDE, is there any way to enter preprocessor defines, as currently when regenerating code from the 'Device Configuration Tool', any defines entered manually for the project appear to be deleted?

  • January 16, 2020
  • 2 replies
  • 1123 views

I'm thinking in particular about defines to influence the HAL library code e.g. USE_HAL_TIM_REGISTER_CALLBACKS.

Adding user defines in MX just puts them in main.h and they are not seen by the library code.

    This topic has been closed for replies.

    2 replies

    Mundungus
    Associate
    June 30, 2020

    There is an hacky ingenious but convoluted suggestion on how to set those defines here: https://community.st.com/s/question/0D50X0000ArRvt6/stmcubeide-usehalregistercallbacks-definition

    It seems that CubeMX does not officially support enabling the USE_HAL_*_REGISTER_CALLBACKS options. Can anyone confirm this?

    S.Ma
    Principal
    June 30, 2020

    As HAL files are supposedly read-only and version volatile, I would look for a compiler option. Most decent SW tools provide in project settings the possibility to add global compiler options. This would probably be the way to activate/deactivate REGISTER_CALLBACKS (which to me seems defeating the interrupt routines to be snappy as it causes a switch/case execution). The other way (probably not allowed) would be to have a global user.h file included to all files (including ST source files) which enables same mechanism without being toolchain dependent. (the CMAKE way?)