Skip to content

Disable HAL feature when not used in the sketch #228

Closed
@fpistm

Description

@fpistm

Goal of this issue is to be able to disable HAL module if not used in the sketch in order to reduce binary size.

  • I2C: done thanks 07dcdc4
  • SPI: done thanks c41d8af
  • ADC: done thanks e4b1121
  • DAC: done thanks 68d3450
  • TIM: done thanks b10696d
  • UART: done thanks 83d872f
  • ETH: done thanks 680e01b
  • SD: done thanks e0e90cc
  • QSPI: done thanks 4e25050
  • RTC: done thanks 0753358
  • USB: done thanks Arduino menu.
  • EXTI: done thanks 0e1f5a7. Interrupt API does not used HAL EXTI module anyway API is cleaned with HAL_EXTI_MODULE_DISABLED
  • RCC: mandatory. User can use LL to override SystemClock_Config()

Mainly useful for MCU with smallflash size (See #165)

Proposition:

handle a default HAL conf file which could be override by end user at sketch level or variant.
PeripheralPins arrays could also use new switch to force an array to be disable even if the HAL module is enabled.

Implementation done thanks #518

  • Extra HAL module can be enabled/disabled in variant.h if required or in a file named (at sketch level): hal_conf_extra.h

    • To enable a HAL modules use the standard HAL definition: HAL_PPP_MODULE_ENABLED with PPP the peripheral to enable.
    • To disable a HAL modules use one or more following values:
      • HAL_ADC_MODULE_DISABLED
      • HAL_I2C_MODULE_DISABLED
      • HAL_RTC_MODULE_DISABLED
      • HAL_SPI_MODULE_DISABLED
      • HAL_DAC_MODULE_DISABLED
      • HAL_ETH_MODULE_DISABLED
      • HAL_SD_MODULE_DISABLED
      • HAL_QSPI_MODULE_DISABLED
      • HAL_EXTI_MODULE_DISABLED
      • HAL_TIM_MODULE_DISABLED
        Note: HAL_UART_MODULE_ENABLED and HAL_PCD_MODULE_ENABLED are handled thanks Arduino menu.
  • Custom HAL configuration file can replace the default one by adding a file named (at sketch level):
    hal_conf_custom.h .

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions