|
1 |
| -# HAL module configuration |
| 1 | +# HAL configuration |
2 | 2 |
|
3 | 3 | Since core version greater than **1.5.0**, a default STM32 HAL configuration is provided per STM32 series.
|
4 | 4 | As those files were almost the same for the same series, a default one per series avoid to add one for each variant.
|
5 | 5 |
|
6 |
| -Each required STM32 HAL configuration file is in `system/STM32YYxx/` (where `YY` is the MCU serie).<br> |
| 6 | +Each required STM32 HAL configuration file is in `system/STM32YYxx/` (where `YY` is the MCU series).<br> |
7 | 7 |
|
8 | 8 | It allows to wrap to the correct HAL configurations. Example for a STM32F2: [stm32f2xx_hal_conf.h](../blob/main/system/STM32F2xx/stm32f2xx_hal_conf.h)
|
9 | 9 | ```C
|
@@ -91,7 +91,7 @@ Custom HAL configuration file can replace the default one by adding a file named
|
91 | 91 |
|
92 | 92 | ### Other HAL configuration
|
93 | 93 |
|
94 |
| -[[/img/Important-icon.png|alt="Important"]] **Below HAL configurations are listed for convenience but may not be up to date. Refer to the required default STM32 HAL configuration file `stm32yyxx_hal_conf_default.h` in `system/STM32YYxx/` (where `YY` is the MCU serie) to make sure having up to date values.** |
| 94 | +[[/img/Important-icon.png|alt="Important"]] **Below HAL configurations are listed for convenience but may not be up to date. Refer to the required default STM32 HAL configuration file `stm32yyxx_hal_conf_default.h` in `system/STM32YYxx/` (where `YY` is the MCU series) to make sure having up to date values.** |
95 | 95 |
|
96 | 96 | #### Oscillator Values adaptation
|
97 | 97 | Hereafter, list of possible oscillator values which can be redefined:
|
@@ -141,4 +141,29 @@ Hereafter list of possible definition:
|
141 | 141 | * `HAL_RTC_MODULE_ONLY`
|
142 | 142 | * `HAL_PWR_MODULE_ONLY`
|
143 | 143 |
|
144 |
| -I2C and SPI do not required definition as used only thanks built-in library. Do not include `Wire.h` or `SPI.h` will allow to use the HAL module. |
| 144 | +I2C and SPI do not required definition as used only thanks built-in library. Do not include `Wire.h` or `SPI.h` will allow to use the HAL module. |
| 145 | + |
| 146 | +# HAL assertion management |
| 147 | + |
| 148 | +> [!NOTE] |
| 149 | +> Required core version higher than 2.7.1. |
| 150 | +
|
| 151 | +HAL and LL include assertions which can be enabled by defining `USE_FULL_ASSERT` in `build_opt.h`. |
| 152 | + |
| 153 | +By default, `assert_failed(uint8_t *file, uint32_t line)` will print the assertion location (file and line) and loop forever. Print rely on `_Error_Handler(const char *msg, int val)` so it is available only when debug is enabled anyway end user can redefine it as it is a `WEAK` function. |
| 154 | + |
| 155 | +#### Example at sketch level |
| 156 | + |
| 157 | +```C++ |
| 158 | +extern "C" void assert_failed(uint8_t *file, uint32_t line) { |
| 159 | + // Custom code |
| 160 | + printf("Assert failed: %s (%lu)\n", (char *)file, line); |
| 161 | +} |
| 162 | + |
| 163 | +// the setup function runs once when you press reset or power the board |
| 164 | +void setup() { |
| 165 | + // initialize digital pin LED_BUILTIN as an output. |
| 166 | + assert_param(LED_BUILTIN == 0); |
| 167 | + pinMode(LED_BUILTIN, OUTPUT); |
| 168 | +} |
| 169 | +``` |
0 commit comments