1 /*******************************************************************************
2  * (c) Copyright 2009-2013 Microsemi SoC Products Group. All rights reserved.
3  *
4  * Assertion implementation.
5  *
6  * This file provides the implementation of the ASSERT macro. This file can be
7  * modified to cater for project specific requirements regarding the way
8  * assertions are handled.
9  *
10  * SVN $Revision: 6422 $
11  * SVN $Date: 2014-05-14 14:37:56 +0100 (Wed, 14 May 2014) $
12  */
13 #ifndef __MSS_ASSERT_H_
14 #define __MSS_ASSERT_H_
15 
16 #if defined(NDEBUG)
17 
18 #define ASSERT(CHECK)
19 
20 #else   /* NDEBUG */
21 
22 #include <assert.h>
23 
24 #if defined ( __GNUC__   )
25 
26 /*
27  * SoftConsole assertion handling
28  */
29 #define ASSERT(CHECK)  \
30     do { \
31         if (!(CHECK)) \
32         { \
33             __asm volatile ("BKPT\n\t"); \
34         } \
35     } while (0);
36 
37 #elif defined ( __ICCARM__ )
38 /*
39  * IAR Embedded Workbench assertion handling.
40  * Call C library assert function which should result in error message
41  * displayed in debugger.
42  */
43 #define ASSERT(X)   assert(X)
44 
45 #else
46 /*
47  * Keil assertion handling.
48  * Call C library assert function which should result in error message
49  * displayed in debugger.
50  */
51 
52 #ifndef __MICROLIB
53   #define ASSERT(X)   assert(X)
54 #else
55   #define ASSERT(X)
56 #endif
57 
58 #endif  /* Tool Chain */
59 
60 #endif  /* NDEBUG */
61 
62 #endif  /* __MSS_ASSERT_H_ */
63