HAL modules?
Posted: Mon Jul 08, 2024 11:54 am
Some days before I tried out DAC on STMG431. At the beginning I placed a
inside my code. Later I found out, it's not necessary. But where are HAL-modules enabled?
1. First question: can I use a or
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:
__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:
#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:
So I still don't know, my my sketch worked without a #define HAL_DAC_MODULE_ENABLED
Code: Select all
#define HAL_DAC_MODULE_ENABLED
1. First question: can I use a
Code: Select all
#define HAL_***_MODULE_DISABLED
Code: Select all
#undef HAL_***_MODULE_ENABLED
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
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
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