Skip to content

Commit 71e3ce0

Browse files
committed
doc: add HAL assertion management
Added by stm32duino/Arduino_Core_STM32#2384 Signed-off-by: Frederic Pillon <[email protected]>
1 parent a743cd5 commit 71e3ce0

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

_custom/HAL-configuration.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# HAL module configuration
1+
# HAL configuration
22

33
Since core version greater than **1.5.0**, a default STM32 HAL configuration is provided per STM32 series.
44
As those files were almost the same for the same series, a default one per series avoid to add one for each variant.
55

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>
77

88
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)
99
```C
@@ -91,7 +91,7 @@ Custom HAL configuration file can replace the default one by adding a file named
9191

9292
### Other HAL configuration
9393

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.**
9595

9696
#### Oscillator Values adaptation
9797
Hereafter, list of possible oscillator values which can be redefined:
@@ -141,4 +141,29 @@ Hereafter list of possible definition:
141141
* `HAL_RTC_MODULE_ONLY`
142142
* `HAL_PWR_MODULE_ONLY`
143143

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

Comments
 (0)