Skip to content

Commit 8576993

Browse files
committed
Introduce stm32_assert.h for MBED port
When we want to activate USE_FULL_ASSERT macro in STM32 CUBE, there is a need to have the assert map to MBED. The easiest way to have this definition in a single place for all STM32 HAL and LL files using it, is to add a specific header file where the porting to MBED is done.
1 parent 5b510a3 commit 8576993

File tree

10 files changed

+61
-90
lines changed

10 files changed

+61
-90
lines changed

targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,8 @@
297297

298298
/* Exported macro ------------------------------------------------------------*/
299299
#ifdef USE_FULL_ASSERT
300-
/**
301-
* @brief The assert_param macro is used for function's parameters check.
302-
* @param expr: If expr is false, it calls assert_failed function
303-
* which reports the name of the source file and the source
304-
* line number of the call that failed.
305-
* If expr is true, it returns no value.
306-
* @retval None
307-
*/
308-
#include "mbed_assert.h"
309-
#define assert_param(expr) MBED_ASSERT(expr)
300+
/* ALL MBED targets use same stm32_assert.h */
301+
#include "stm32_assert.h"
310302
#else
311303
#define assert_param(expr) ((void)0U)
312304
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,8 @@
357357

358358
/* Exported macro ------------------------------------------------------------*/
359359
#ifdef USE_FULL_ASSERT
360-
/**
361-
* @brief The assert_param macro is used for function's parameters check.
362-
* @param expr: If expr is false, it calls assert_failed function
363-
* which reports the name of the source file and the source
364-
* line number of the call that failed.
365-
* If expr is true, it returns no value.
366-
* @retval None
367-
*/
368-
#include "mbed_assert.h"
369-
#define assert_param(expr) MBED_ASSERT(expr)
360+
/* ALL MBED targets use same stm32_assert.h */
361+
#include "stm32_assert.h"
370362
#else
371363
#define assert_param(expr) ((void)0U)
372364
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,8 @@
377377
#endif /* HAL_MMC_MODULE_ENABLED */
378378
/* Exported macro ------------------------------------------------------------*/
379379
#ifdef USE_FULL_ASSERT
380-
/**
381-
* @brief The assert_param macro is used for function's parameters check.
382-
* @param expr: If expr is false, it calls assert_failed function
383-
* which reports the name of the source file and the source
384-
* line number of the call that failed.
385-
* If expr is true, it returns no value.
386-
* @retval None
387-
*/
388-
#include "mbed_assert.h"
389-
#define assert_param(expr) MBED_ASSERT(expr)
380+
/* ALL MBED targets use same stm32_assert.h */
381+
#include "stm32_assert.h"
390382
#else
391383
#define assert_param(expr) ((void)0U)
392384
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,8 @@
313313

314314
/* Exported macro ------------------------------------------------------------*/
315315
#ifdef USE_FULL_ASSERT
316-
/**
317-
* @brief The assert_param macro is used for function's parameters check.
318-
* @param expr: If expr is false, it calls assert_failed function
319-
* which reports the name of the source file and the source
320-
* line number of the call that failed.
321-
* If expr is true, it returns no value.
322-
* @retval None
323-
*/
324-
#include "mbed_assert.h"
325-
#define assert_param(expr) MBED_ASSERT(expr)
316+
/* ALL MBED targets use same stm32_assert.h */
317+
#include "stm32_assert.h"
326318
#else
327319
#define assert_param(expr) ((void)0U)
328320
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,16 +431,8 @@
431431

432432
/* Exported macro ------------------------------------------------------------*/
433433
#ifdef USE_FULL_ASSERT
434-
/**
435-
* @brief The assert_param macro is used for function's parameters check.
436-
* @param expr: If expr is false, it calls assert_failed function
437-
* which reports the name of the source file and the source
438-
* line number of the call that failed.
439-
* If expr is true, it returns no value.
440-
* @retval None
441-
*/
442-
#include "mbed_assert.h"
443-
#define assert_param(expr) MBED_ASSERT(expr)
434+
/* ALL MBED targets use same stm32_assert.h */
435+
#include "stm32_assert.h"
444436
#else
445437
#define assert_param(expr) ((void)0U)
446438
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,16 +438,8 @@
438438

439439
/* Exported macro ------------------------------------------------------------*/
440440
#ifdef USE_FULL_ASSERT
441-
/**
442-
* @brief The assert_param macro is used for function's parameters check.
443-
* @param expr: If expr is false, it calls assert_failed function
444-
* which reports the name of the source file and the source
445-
* line number of the call that failed.
446-
* If expr is true, it returns no value.
447-
* @retval None
448-
*/
449-
#include "mbed_assert.h"
450-
#define assert_param(expr) MBED_ASSERT(expr)
441+
/* ALL MBED targets use same stm32_assert.h */
442+
#include "stm32_assert.h"
451443
#else
452444
#define assert_param(expr) ((void)0)
453445
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,8 @@
296296

297297
/* Exported macro ------------------------------------------------------------*/
298298
#ifdef USE_FULL_ASSERT
299-
/**
300-
* @brief The assert_param macro is used for function's parameters check.
301-
* @param expr: If expr is false, it calls assert_failed function
302-
* which reports the name of the source file and the source
303-
* line number of the call that failed.
304-
* If expr is true, it returns no value.
305-
* @retval None
306-
*/
307-
#include "mbed_assert.h"
308-
#define assert_param(expr) MBED_ASSERT(expr)
299+
/* ALL MBED targets use same stm32_assert.h */
300+
#include "stm32_assert.h"
309301
#else
310302
#define assert_param(expr) ((void)0U)
311303
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32L1/device/stm32l1xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,8 @@ extern "C" {
264264

265265
/* Exported macro ------------------------------------------------------------*/
266266
#ifdef USE_FULL_ASSERT
267-
/**
268-
* @brief The assert_param macro is used for function's parameters check.
269-
* @param expr: If expr is false, it calls assert_failed function
270-
* which reports the name of the source file and the source
271-
* line number of the call that failed.
272-
* If expr is true, it returns no value.
273-
* @retval None
274-
*/
275-
#include "mbed_assert.h"
276-
#define assert_param(expr) MBED_ASSERT(expr)
267+
/* ALL MBED targets use same stm32_assert.h */
268+
#include "stm32_assert.h"
277269
#else
278270
#define assert_param(expr) ((void)0U)
279271
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_conf.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,8 @@
381381

382382
/* Exported macro ------------------------------------------------------------*/
383383
#ifdef USE_FULL_ASSERT
384-
/**
385-
* @brief The assert_param macro is used for function's parameters check.
386-
* @param expr: If expr is false, it calls assert_failed function
387-
* which reports the name of the source file and the source
388-
* line number of the call that failed.
389-
* If expr is true, it returns no value.
390-
* @retval None
391-
*/
392-
#include "mbed_assert.h"
393-
#define assert_param(expr) MBED_ASSERT(expr)
384+
/* ALL MBED targets use same stm32_assert.h */
385+
#include "stm32_assert.h"
394386
#else
395387
#define assert_param(expr) ((void)0U)
396388
#endif /* USE_FULL_ASSERT */

targets/TARGET_STM/stm32_assert.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* mbed Microcontroller Library
2+
*******************************************************************************
3+
* Copyright (c) 2017, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*******************************************************************************
29+
*/
30+
#ifndef STM32_ASSERT_H
31+
#define STM32_ASSERT_H
32+
/**
33+
* @brief The assert_param macro is used for function's parameters check.
34+
* @param expr: If expr is false, it calls assert_failed function
35+
* which reports the name of the source file and the source
36+
* line number of the call that failed.
37+
* If expr is true, it returns no value.
38+
* @retval None
39+
*/
40+
#include "mbed_assert.h"
41+
#define assert_param(expr) MBED_ASSERT(expr)
42+
43+
#endif

0 commit comments

Comments
 (0)