HAL modules?

Post here first, or if you can't find a relevant section!
Post Reply
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

HAL modules?

Post by STM32ardui »

Some days before I tried out DAC on STMG431. At the beginning I placed a

Code: Select all

#define HAL_DAC_MODULE_ENABLED
inside my code. Later I found out, it's not necessary. But where are HAL-modules enabled?

1. First question: can I use a

Code: Select all

#define HAL_***_MODULE_DISABLED
or

Code: Select all

#undef HAL_***_MODULE_ENABLED
to disable some HAL-modules on sketch-level, if some peripheral modules are not used?


2. I looked at Wiki "HAL configuration".
Under the path \STMicroelectronics\hardware\stm32\2.7.1\system\STM32G4xx is a file stm32g4xx_hal_conf.h with this content:

Code: Select all

/* STM32G4xx specific HAL configuration options. */
#if __has_include("hal_conf_custom.h")
#include "hal_conf_custom.h"
#else
#if __has_include("hal_conf_extra.h")
#include "hal_conf_extra.h"
#endif
#include "stm32g4xx_hal_conf_default.h"
#endif
__has_include checks, if a file is extisting, only if it exists it is included?
So if there is no hal_conf_custom.h, it can include a headerfile hal_conf_extra.h, but it always include stm32g4xx_hal_conf_default.h - is this correct?

Inside stm32g4xx_hal_conf_default.h I see:

Code: Select all

#include "stm32yyxx_hal_conf.h"
#if 0
#define HAL_MODULE_ENABLED
#define HAL_ADC_MODULE_ENABLED
#define HAL_COMP_MODULE_ENABLED
#define HAL_CORDIC_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_CRC_MODULE_ENABLED
#define HAL_CRYP_MODULE_ENABLED
#define HAL_DAC_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_FDCAN_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_FMAC_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_HRTIM_MODULE_ENABLED
#define HAL_IRDA_MODULE_ENABLED
#define HAL_IWDG_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
#define HAL_I2S_MODULE_ENABLED
#define HAL_LPTIM_MODULE_ENABLED
#define HAL_NAND_MODULE_ENABLED
#define HAL_NOR_MODULE_ENABLED
#define HAL_OPAMP_MODULE_ENABLED
#define HAL_PCD_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_QSPI_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_RNG_MODULE_ENABLED
#define HAL_RTC_MODULE_ENABLED
#define HAL_SAI_MODULE_ENABLED
#define HAL_SMARTCARD_MODULE_ENABLED
#define HAL_SMBUS_MODULE_ENABLED
#define HAL_SPI_MODULE_ENABLED
#define HAL_SRAM_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
#define HAL_USART_MODULE_ENABLED
#define HAL_WWDG_MODULE_ENABLED 
#endif
#if 0 means, that none of following #define for HAL-modules is used up to the #eindif?

For that file stm32yyxx_hal_conf.h   \STMicroelectronics\hardware\stm32\2.7.1\cores\arduino\stm32 is the right path?

On my computer I see inside this file that on top at "Mandatory HAL modules" there is nothing for DAC and then below is a sequence:

Code: Select all

#if !defined(HAL_DAC_MODULE_DISABLED)
  /*#define HAL_DAC_MODULE_ENABLED*/
#else
  #undef HAL_DAC_MODULE_ENABLED
#endif
So I still don't know, my my sketch worked without a #define HAL_DAC_MODULE_ENABLED
by fpiSTM » Mon Jul 08, 2024 11:56 am
It is defined in the variant*.h of theboard.
Go to full post
fpiSTM
Posts: 1944
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 108
Location: Le Mans
Contact:

Re: HAL modules?

Post by fpiSTM »

It is defined in the variant*.h of theboard.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: HAL modules?

Post by STM32ardui »

Hmm ...

Exact name of the MCU is: STM32G431CBU6
So \variants\STM32G4xx\G431C(6-8-B)U_G441CBU is the correct path?

Inside variant_generic.h

Code: Select all

// Extra HAL modules
#if !defined(HAL_DAC_MODULE_DISABLED)
  #define HAL_DAC_MODULE_ENABLED
#endif
OK thanks.

There is also a file variant_B_G431B_ESC1.h, but it is only for MCUs STM32G431Bxx?
ESC = escape???
fpiSTM
Posts: 1944
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 108
Location: Le Mans
Contact:

Re: HAL modules?

Post by fpiSTM »

Post Reply

Return to “General discussion”