Skip to content

Commit 884f626

Browse files
committed
Restore capability of enabling parameter assertion of peripheral libraries
Signed-off-by: Marcos Chaparro <[email protected]>
1 parent 43dbe80 commit 884f626

14 files changed

+59
-56
lines changed

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/misc.c

-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@
7575
/* Includes ------------------------------------------------------------------*/
7676
#include "misc.h"
7777

78-
#ifndef assert_param
79-
#define assert_param(expr) ((void)0)
80-
#endif
81-
8278
/** @addtogroup STM32F4xx_StdPeriph_Driver
8379
* @{
8480
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_adc.c

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106
#include "stm32f4xx_adc.h"
107107
#include "stm32f4xx_rcc.h"
108108

109-
#ifndef assert_param
110-
#define assert_param(expr) ((void)0)
111-
#endif
112109

113110
/** @addtogroup STM32F4xx_StdPeriph_Driver
114111
* @{

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_dac.c

-4
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@
131131
#include "stm32f4xx_dac.h"
132132
#include "stm32f4xx_rcc.h"
133133

134-
#ifndef assert_param
135-
#define assert_param(expr) ((void)0)
136-
#endif
137-
138134
/** @addtogroup STM32F4xx_StdPeriph_Driver
139135
* @{
140136
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_dma.c

-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@
124124
#include "stm32f4xx_dma.h"
125125
#include "stm32f4xx_rcc.h"
126126

127-
#ifndef assert_param
128-
#define assert_param(expr) ((void)0)
129-
#endif
130-
131127
/** @addtogroup STM32F4xx_StdPeriph_Driver
132128
* @{
133129
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_exti.c

-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@
6767
/* Includes ------------------------------------------------------------------*/
6868
#include "stm32f4xx_exti.h"
6969

70-
#ifndef assert_param
71-
#define assert_param(expr) ((void)0)
72-
#endif
73-
7470
/** @addtogroup STM32F4xx_StdPeriph_Driver
7571
* @{
7672
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_flash.c

-6
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@
8383
#define FLASH_OPTCR_BFB2 ((uint32_t)0x00000010)
8484
#endif
8585

86-
#ifndef assert_param
87-
#define assert_param(expr) ((void)0)
88-
#endif
89-
90-
#define STM32F40_41xxx
91-
9286
/** @addtogroup STM32F4xx_StdPeriph_Driver
9387
* @{
9488
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_iwdg.c

-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@
8484
/* Includes ------------------------------------------------------------------*/
8585
#include "stm32f4xx_iwdg.h"
8686

87-
#ifndef assert_param
88-
#define assert_param(expr) ((void)0)
89-
#endif
90-
9187
/** @addtogroup STM32F4xx_StdPeriph_Driver
9288
* @{
9389
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_rcc.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@
7474
#define RCC_BDCR_LSEMOD ((uint32_t)0x00000008)
7575
#endif
7676

77-
#ifndef assert_param
78-
#define assert_param(expr) ((void)0)
79-
#endif
80-
8177
/** @addtogroup STM32F4xx_StdPeriph_Driver
8278
* @{
8379
*/
@@ -261,7 +257,7 @@ void RCC_DeInit(void)
261257
RCC->PLLI2SCFGR = 0x20003000;
262258
#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE || STM32F446xx || STM32F469_479xx */
263259

264-
#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
260+
#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
265261
/* Reset PLLSAICFGR register, only available for STM32F42xxx/43xxx/446xx/469xx/479xx devices */
266262
RCC->PLLSAICFGR = 0x24003000;
267263
#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
@@ -827,7 +823,7 @@ void RCC_PLLSAIConfig(uint32_t PLLSAIM, uint32_t PLLSAIN, uint32_t PLLSAIP, uint
827823
}
828824
#endif /* STM32F446xx */
829825

830-
#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE)
826+
#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE)
831827
/**
832828
* @brief Configures the PLLSAI clock multiplication and division factors.
833829
*
@@ -1660,7 +1656,7 @@ void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource)
16601656
}
16611657
#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE || STM32F469_479xx */
16621658

1663-
#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx)
1659+
#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx)
16641660
/**
16651661
* @brief Configures SAI1BlockA clock source selection.
16661662
*

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_syscfg.c

-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
#include "stm32f4xx_syscfg.h"
5151
#include "stm32f4xx_rcc.h"
5252

53-
#ifndef assert_param
54-
#define assert_param(expr) ((void)0)
55-
#endif
56-
5753
/** @addtogroup STM32F4xx_StdPeriph_Driver
5854
* @{
5955
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_tim.c

-4
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@
119119
#include "stm32f4xx_tim.h"
120120
#include "stm32f4xx_rcc.h"
121121

122-
#ifndef assert_param
123-
#define assert_param(expr) ((void)0)
124-
#endif
125-
126122
/** @addtogroup STM32F4xx_StdPeriph_Driver
127123
* @{
128124
*/

ChibiOS_3.0.2/ext/stdperiph_stm32f4/src/stm32f4xx_wwdg.c

-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@
8484
#include "stm32f4xx_wwdg.h"
8585
#include "stm32f4xx_rcc.h"
8686

87-
#ifndef assert_param
88-
#define assert_param(expr) ((void)0)
89-
#endif
90-
9187
/** @addtogroup STM32F4xx_StdPeriph_Driver
9288
* @{
9389
*/

ChibiOS_3.0.2/os/ext/CMSIS/ST/stm32f4xx.h

+50-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#ifdef __cplusplus
6060
extern "C" {
6161
#endif /* __cplusplus */
62-
62+
6363
/** @addtogroup Library_configuration_section
6464
* @{
6565
*/
@@ -125,6 +125,29 @@
125125
#define STM32F407xx
126126
#endif
127127

128+
#if defined(STM32F439xx) || defined(STM32F429xx)
129+
#define STM32F429_439xx
130+
131+
#elif defined(STM32F437xx) || defined(STM32F427xx)
132+
#define STM32F427_437xx
133+
134+
#elif defined(STM32F405xx) || defined(STM32F415xx) || \
135+
defined(STM32F407xx) || defined(STM32F417xx)
136+
#define STM32F40_41xxx
137+
138+
#elif defined(STM32F401xC) || defined(STM32F401xE)
139+
#define STM32F401xx
140+
141+
#elif defined(STM32F411xE)
142+
#define STM32F411xx
143+
144+
#elif defined(STM32F2XX)
145+
146+
#else
147+
#error "STM32F2xx/F4xx device not specified"
148+
#endif
149+
150+
128151
#if defined(STM32F405xx)
129152
#include "stm32f405xx.h"
130153
#elif defined(STM32F415xx)
@@ -210,6 +233,32 @@ typedef enum
210233
#include "stm32f4xx_hal.h"
211234
#endif /* USE_HAL_DRIVER */
212235

236+
237+
/* Uncomment the line below to expanse the "assert_param" macro in the
238+
Standard Peripheral Library drivers code */
239+
//#define USE_FULL_ASSERT 1
240+
241+
/* Exported macro ------------------------------------------------------------*/
242+
#ifdef USE_FULL_ASSERT
243+
244+
/**
245+
* @brief The assert_param macro is used for function's parameters check.
246+
* @param expr: If expr is false, it calls assert_failed function
247+
* which reports the name of the source file and the source
248+
* line number of the call that failed.
249+
* If expr is true, it returns no value.
250+
* @retval None
251+
*/
252+
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
253+
/* Exported functions ------------------------------------------------------- */
254+
void assert_failed(uint8_t* file, uint32_t line);
255+
#else
256+
#ifndef assert_param
257+
#define assert_param(expr) ((void)0)
258+
#endif
259+
#endif /* USE_FULL_ASSERT */
260+
261+
213262
#ifdef __cplusplus
214263
}
215264
#endif /* __cplusplus */

main.c

+6
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ static THD_FUNCTION(timer_thread, arg) {
176176
}
177177
}
178178

179+
void assert_failed(uint8_t* file, uint32_t line) {
180+
commands_printf("Wrong parameters value: file %s on line %d\r\n", file, line);
181+
while(1)
182+
;
183+
}
184+
179185
int main(void) {
180186
halInit();
181187
chSysInit();

stm32f4xx_conf.h

-7
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,4 @@
1515
#include "stm32f4xx_wwdg.h"
1616
#include "stm32f4xx_iwdg.h"
1717

18-
#ifdef USE_FULL_ASSERT
19-
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
20-
void assert_failed(uint8_t* file, uint32_t line);
21-
#else
22-
#define assert_param(expr) ((void)0)
23-
#endif
24-
2518
#endif

0 commit comments

Comments
 (0)