STM32 chip header. This header supplies various series-specific and chip-specific macros for the current build target. It’s useful both to abstract away hardware details (e.g. through use of STM32_NR_INTERRUPTS) and to decide what to do when you want something nonportable (e.g. by checking STM32_MCU_SERIES).
Contents
The STM32 series (e.g. STM32F1, STM32F2, etc.) of the current target can be inspected with STM32_MCU_SERIES.
STM32 series value for the MCU being targeted.
At time of writing, allowed values are: STM32_SERIES_F1, STM32_SERIES_F2. This set of values will expand as libmaple adds support for more STM32 series MCUs.
Allowed values for STM32_MCU_SERIES are the following. This set is expected to grow over time.
STM32F1 series.
STM32F2 series.
STM32L1 series.
STM32F4 series.
The macros in this section are only available on some STM32 series.
Note
These macros are only available when the current target is an STM32F1 series MCU (i.e., when STM32_MCU_SERIES is STM32_SERIES_F1).
The STM32F1 series is further subdivided into lines. The line of the current target can be inspected with STM32_F1_LINE.
STM32 line value for the STM32F1 MCU being targeted.
At time of writing, allowed values are: STM32_F1_LINE_PERFORMANCE, STM32_F1_LINE_VALUE. This set of values may expand as libmaple adds support for more STM32F1 lines.
There are five STM32F1 lines. The corresponding values STM32_F1_LINE can take are the following, though libmaple doesn’t currently support all of them.
STM32F1 value line (STM32F100 MCUs).
STM32F1 access line (STM32F101 MCUs).
STM32F1 USB access line (STM32F102 MCUs).
STM32F1 performance line (STM32F103 MCUs).
STM32F1 connectivity line (STM32F105/F107 MCUs).
The following defines can be used to determine if the target MCU has a particular feature.
1 if the target MCU has the FSMC peripheral, and 0 otherwise.
Note that the feature set of the FSMC peripheral is restricted on some MCUs.
1 if the target MCU has a USB peripheral, and 0 otherwise.
Note that a variety of USB peripherals are available across the different series, with widely varying feature sets and programming interfaces. This macro will be 1 if any such peripheral is present.
The following defines give salient characteristics of the target MCU.
Number of GPIO ports.
Number of interrupts in the vector table.
This does not include Cortex-M interrupts (NMI, HardFault, etc.).
Pointer to end of built-in SRAM.
Points to the address which is 1 byte past the last valid SRAM address.
The macros in this section are related to clock rates. As such, they are really part of the configuration of the MCU, rather than inherent characteristics of the MCU itself. For instance, it’s possible to change the PCLK1 and PCLK2 clock rates by reconfiguring the RCC. libmaple proper never changes any clock rates, but it does have APIs for doing so (such as rcc_configure_pll()). Because of this, be careful when using the macros in this section, as they assume that some values are constant which in fact may be changed.
The values these macros actually take are typically the maximum values supported by the MCU. Since these are their actual values in practice (at least in LeafLabs’ current use cases, which have the chips running as fast as possible), they’re still considered useful.
APB1 clock speed, in Hz.
APB2 clock speed, in Hz.
The following macro, STM32_DELAY_US_MULT, is a libmaple implementation detail. It was included in this public API page in a previous release by mistake, and is not deprecated, but using it in your own code is a bad idea.
Multiplier to convert microseconds into loop iterations in delay_us().
See: | delay_us() |
---|
Warning
The macros in this section are deprecated, and are available for backwards compatibility only. Do not use them in new code.
Deprecated.
Use STM32_PCLK1 instead.
Deprecated.
Use STM32_PCLK2 instead.
Deprecated.
Use STM32_NR_INTERRUPTS instead.
Deprecated.
Use STM32_NR_GPIO_PORTS instead.
Deprecated.
Use STM32_DELAY_US_MULT instead.