cancel
Showing results for 
Search instead for 
Did you mean: 

STMCubeIDE USE_HAL_***_REGISTER_CALLBACKS definition

LLea
Associate

Hi all,

I'd like to register some user defined callbacks using the HAL_***_RegisterCallback() functions.

I understood that first I need to define the compilation flag USE_HAL_***_REGISTER_CALLBACKS but where should I put it? Looking through the various examples I stepped into F4-Discovery DMA_FLASHtoRAM example and its stm32fxxx_hal_conf.h, copied below, which (hopefully) provides the answer.

Considering that i don't want to manually modify this file in my project (nor there is a user code section in it), how can i set the code generator to automatically insert the required defines?

Thanks,

Lorenzo

/* ########################### System Configuration ######################### */
/**
  * @brief This is the HAL system configuration section
  */     
#define  VDD_VALUE                    (3300U) /*!< Value of VDD in mv */
#define  TICK_INT_PRIORITY            (0x0FU) /*!< tick interrupt priority */
#define  USE_RTOS                     0U
#define  PREFETCH_ENABLE              0U /* The prefetch will be enabled in SystemClock_Config(), depending on the used 
                                            STM32F405/415/07/417 device: RevA (prefetch must be off) or RevZ (prefetch can be on/off) */
#define  INSTRUCTION_CACHE_ENABLE     1U
#define  DATA_CACHE_ENABLE            1U
 
#define  USE_HAL_ADC_REGISTER_CALLBACKS         0U /* ADC register callback disabled       */
#define  USE_HAL_CAN_REGISTER_CALLBACKS         0U /* CAN register callback disabled       */
#define  USE_HAL_CEC_REGISTER_CALLBACKS         0U /* CEC register callback disabled       */
#define  USE_HAL_CRYP_REGISTER_CALLBACKS        0U /* CRYP register callback disabled      */
#define  USE_HAL_DAC_REGISTER_CALLBACKS         0U /* DAC register callback disabled       */
#define  USE_HAL_DCMI_REGISTER_CALLBACKS        0U /* DCMI register callback disabled      */
#define  USE_HAL_DFSDM_REGISTER_CALLBACKS       0U /* DFSDM register callback disabled     */
#define  USE_HAL_DMA2D_REGISTER_CALLBACKS       0U /* DMA2D register callback disabled     */
#define  USE_HAL_DSI_REGISTER_CALLBACKS         0U /* DSI register callback disabled       */
#define  USE_HAL_ETH_REGISTER_CALLBACKS         0U /* ETH register callback disabled       */
#define  USE_HAL_HASH_REGISTER_CALLBACKS        0U /* HASH register callback disabled      */
#define  USE_HAL_HCD_REGISTER_CALLBACKS         0U /* HCD register callback disabled       */
#define  USE_HAL_I2C_REGISTER_CALLBACKS         0U /* I2C register callback disabled       */
#define  USE_HAL_FMPI2C_REGISTER_CALLBACKS      0U /* FMPI2C register callback disabled    */
#define  USE_HAL_I2S_REGISTER_CALLBACKS         0U /* I2S register callback disabled       */
#define  USE_HAL_IRDA_REGISTER_CALLBACKS        0U /* IRDA register callback disabled      */
#define  USE_HAL_LPTIM_REGISTER_CALLBACKS       0U /* LPTIM register callback disabled     */
#define  USE_HAL_LTDC_REGISTER_CALLBACKS        0U /* LTDC register callback disabled      */
#define  USE_HAL_MMC_REGISTER_CALLBACKS         0U /* MMC register callback disabled       */
#define  USE_HAL_NAND_REGISTER_CALLBACKS        0U /* NAND register callback disabled      */
#define  USE_HAL_NOR_REGISTER_CALLBACKS         0U /* NOR register callback disabled       */
#define  USE_HAL_PCCARD_REGISTER_CALLBACKS      0U /* PCCARD register callback disabled    */
#define  USE_HAL_PCD_REGISTER_CALLBACKS         0U /* PCD register callback disabled       */
#define  USE_HAL_QSPI_REGISTER_CALLBACKS        0U /* QSPI register callback disabled      */
#define  USE_HAL_RNG_REGISTER_CALLBACKS         0U /* RNG register callback disabled       */
#define  USE_HAL_RTC_REGISTER_CALLBACKS         0U /* RTC register callback disabled       */
#define  USE_HAL_SAI_REGISTER_CALLBACKS         0U /* SAI register callback disabled       */
#define  USE_HAL_SD_REGISTER_CALLBACKS          0U /* SD register callback disabled        */
#define  USE_HAL_SMARTCARD_REGISTER_CALLBACKS   0U /* SMARTCARD register callback disabled */
#define  USE_HAL_SDRAM_REGISTER_CALLBACKS       0U /* SDRAM register callback disabled     */
#define  USE_HAL_SRAM_REGISTER_CALLBACKS        0U /* SRAM register callback disabled      */
#define  USE_HAL_SPDIFRX_REGISTER_CALLBACKS     0U /* SPDIFRX register callback disabled   */
#define  USE_HAL_SMBUS_REGISTER_CALLBACKS       0U /* SMBUS register callback disabled     */
#define  USE_HAL_SPI_REGISTER_CALLBACKS         0U /* SPI register callback disabled       */
#define  USE_HAL_TIM_REGISTER_CALLBACKS         0U /* TIM register callback disabled       */
#define  USE_HAL_UART_REGISTER_CALLBACKS        0U /* UART register callback disabled      */
#define  USE_HAL_USART_REGISTER_CALLBACKS       0U /* USART register callback disabled     */
#define  USE_HAL_WWDG_REGISTER_CALLBACKS        0U /* WWDG register callback disabled      */

28 REPLIES 28
FVasi.1
Associate

In CubeIDE 1.5.1 in ioc device configuration tool select tab Progect Manager, sub Advansed setting on left side, on rigt side You will see register callback list.

Choose what You need

0693W000006GvynQAC.png

jnewcomb
Associate II

The cleanest solution I could find is to modify it using CubeMX.

Select Project Manager->Advanced settings (Also mentioned in the help pdf)

0693W000007D0XnQAK.png 

angus schmaloer
Associate III

Hello, i found your awnser.

In CubeMX, go to "Project manager", in the left side you will see "Advanced Settings".

if you go over there, you can see all Register Callbacks on the right side. They are all disabled my default, you can eable them there.

GL ^^

Angus

angus schmaloer
Associate III

Hello, i found your awnser.

In CubeMX, go to "Project manager", in the left side you will see "Advanced Settings".

if you go over there, you can see all Register Callbacks on the right side. They are all disabled my default, you can eable them there.

GL ^^

Angus

robsen223
Associate II

You can set the register callback manually in CubeMx via Project Manager -> Advanced Settings -> Register Callbacks (right-hand site). There you can enable/disable register callbacks for each peripheral individually.

0693W000007ZD9OQAW.png

SStar.2
Associate

Sorry, I didn't notice the link with the latest comments. Please, delete this comment

_richard
Associate III

as i see it the problem is not the lack of a define as USE_HAL_UART_REGISTER_CALLBACKS

as i see it the problem is, that the define is clearly made in code and user changes are overwritten by cubemx.

have a look at

https://community.st.com/s/question/0D53W00002DyVZzSAN/how-to-handle-cube-mx-overwriting-the-halconf-that-has-to-be-modified-by-devs-this-looks-like-a-long-standing-problem-half-a-decade-an-i-see-no-stable-solution