From 000dad7f67303b3be90f59b8c173c4de20b0bcfd Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 23 May 2024 10:46:56 +0200 Subject: [PATCH 1/2] feat: support stm32 assert Fixes #2375. Signed-off-by: Frederic Pillon --- cores/arduino/stm32/stm32_assert.h | 10 ++++++++++ libraries/SrcWrapper/src/stm32/stm32_def.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 cores/arduino/stm32/stm32_assert.h diff --git a/cores/arduino/stm32/stm32_assert.h b/cores/arduino/stm32/stm32_assert.h new file mode 100644 index 0000000000..275dc3d536 --- /dev/null +++ b/cores/arduino/stm32/stm32_assert.h @@ -0,0 +1,10 @@ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32_ASSERT_H +#define STM32_ASSERT_H + +/* + * Header file required by LL layer but as USE_HAL_DRIVER is defined + * assert definitions are provided by stm32yyxx_hal_conf_default + */ + +#endif /* STM32_ASSERT_H */ diff --git a/libraries/SrcWrapper/src/stm32/stm32_def.c b/libraries/SrcWrapper/src/stm32/stm32_def.c index 1ea4fa6c82..3c12041914 100644 --- a/libraries/SrcWrapper/src/stm32/stm32_def.c +++ b/libraries/SrcWrapper/src/stm32/stm32_def.c @@ -20,6 +20,20 @@ WEAK void _Error_Handler(const char *msg, int val) } #endif +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +WEAK void assert_failed(uint8_t *file, uint32_t line) +{ + _Error_Handler((const char *)file, line); +} +#endif /* USE_FULL_ASSERT */ + #ifdef __cplusplus } #endif From 5388978ee1176a5735c91f81060b8bbfdf7572be Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 28 May 2024 11:30:40 +0200 Subject: [PATCH 2/2] fix: prevent unused warning When NDEBUG is defined and the _Error_Handler() is used inside a function using function arguments. Ex: void dummy(char *file, uint32_t line) { _Error_Handler(file, line); } Signed-off-by: Frederic Pillon --- cores/arduino/stm32/stm32_def.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cores/arduino/stm32/stm32_def.h b/cores/arduino/stm32/stm32_def.h index 00113faa89..f77538e4a7 100644 --- a/cores/arduino/stm32/stm32_def.h +++ b/cores/arduino/stm32/stm32_def.h @@ -133,6 +133,8 @@ void SystemClock_Config(void); #if !defined(_Error_Handler) #define _Error_Handler(str, value) \ while (1) {\ + (void)str;\ + (void)value;\ } #endif #if !defined(Error_Handler)