1 /*******************************************************************************
2  * Copyright 2019-2020 Microchip FPGA Embedded Systems Solutions.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * MPFS HAL Embedded Software
7  *
8  */
9 #ifndef HAL_ASSERT_HEADER
10 #define HAL_ASSERT_HEADER
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /***************************************************************************//**
17  * ASSERT() implementation.
18  ******************************************************************************/
19 /* Disable assertions if we do not recognize the compiler. */
20 #if defined ( __GNUC__ )
21 #if defined(NDEBUG)
22 #define ASSERT(CHECK)
23 #else
24 #define ASSERT(CHECK)\
25     do { \
26         if (!(CHECK)) \
27         { \
28             __asm volatile ("ebreak"); \
29         }\
30     } while(0);
31 #endif /* NDEBUG check */
32 #endif /* compiler check */
33 
34 #if defined(NDEBUG)
35 /***************************************************************************//**
36  * HAL_ASSERT() is defined out when the NDEBUG symbol is used.
37  ******************************************************************************/
38 #define HAL_ASSERT(CHECK)
39 
40 #else
41 /***************************************************************************//**
42  * Default behaviour for HAL_ASSERT() macro:
43  *------------------------------------------------------------------------------
44   The behaviour is toolchain specific and project setting specific.
45  ******************************************************************************/
46 #define HAL_ASSERT(CHECK)     ASSERT(CHECK);
47 
48 #endif  /* NDEBUG */
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif  /* HAL_ASSERT_HEADER */
55 
56