Resources configuration

STM32 hardware resources

Files

The STM32 microcontroller and its peripherals are configured with the mx_ prefixed files.

  • These files are in the hal/ subfolder of the [board_name]/generated/ folder.

  • STM32CubeMX2 generates these files, which are not to be modified.

Optionally, reconfigure the STM32 microcontroller and its peripherals using STM32CubeMX2 to generate configuration code tailored to customized use-cases. This new configuration code is regenerated in the mx_ prefixed files and overwrites the previous configuration code.

  • Each mx_[pppi].c file corresponds to the configuration of a specific peripheral (for example: mx_adc1.c, mx_i2c1.c, and so on).

Note

[pppi] is the instance name as per the CMSIS header files. The following files do not have the [pppi] in the file name:

  • mx_rcc.c/h (clocks)

  • mx_system.c/h (system module)

  • mx_gpio_<group_name>.c/h (user GPIOs).

  • These mx_[pppi].c/h files can be integrated into the application to reuse the configuration from the example.

Services

Each mx_pppi.c/h file provides the following services to configure their drivers:

  • HAL:

    • Initialization and configuration of the peripheral

    • Get the peripheral handle

    • Deinitialization of the peripheral

  • LL:

    • Initialization and configuration of the peripheral

These services are called from the app_init() and app_deinit() functions in example.c.

Naming conventions

The example code is designed to be hardware-agnostic. Therefore, the code in example.c does not use the STM32 peripheral instance names. The STM32 peripheral instance names are used in the mx_ prefixed files to configure the STM32 microcontroller and its peripherals. These files expose their services to the example code through a set of aliases defined in mx_hal_def.h.

All these identifiers are prefixed with MX_ for the constants and mx_ for the functions.

STM32CubeMX2 generates the mx_hal_def.h file, which is not to be modified. The aliases are generated based on the user labels defined in STM32CubeMX2 for the STM32 peripheral instances.

Other resources

In this revision of the document, we focus only on the STM32 microcontroller and its peripherals, and the parts of the STM32 board.