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].cfile 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/hfiles can be integrated into the application to reuse the configuration from the example.
The aliases used to address the board parts in the example are defined in the
mx_
prefixed files. These files are located in the
parts/
subfolder of the
[board_name]/generated/
folder.
The hardware resources that the part drivers use are configured in the
mx_
prefixed files. These files are in the
hal/
subfolder in the
[board_name]/generated/
folder.
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.
Each part driver provides an interface via the
[part.h]
file, included through
mx_[part].h.
The application code, such as
example.c, can use these
[part.h]
functions with the
mx_[part].h
file aliases.
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.
The identifiers to address the board parts are prefixed with
MX_
for the constants and
mx_
for the functions.
STM32CubeMX2 generates the
mx_[part].h
files, which are not to be modified.
The aliases are generated based on the user labels defined in STM32CubeMX2 for the board parts.
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.