|
37 | 37 | * manipulation that you are told to stay away.
|
38 | 38 | *
|
39 | 39 | * This contains macros for both VERIFY and ASSERT:
|
40 |
| - * |
| 40 | + * |
41 | 41 | * VERIFY: Used when there is an error condition which is not the
|
42 | 42 | * fault of the MCU. For example, bounds checking on data
|
43 | 43 | * sent to the micro over USB should use this function.
|
44 | 44 | * Another example is checking for buffer overflows, where
|
45 | 45 | * returning from the active function causes a NAK.
|
46 |
| - * |
| 46 | + * |
47 | 47 | * ASSERT: Used for error conditions that are caused by MCU firmware
|
48 | 48 | * bugs. This is used to discover bugs in the code more
|
49 | 49 | * quickly. One example would be adding assertions in library
|
50 | 50 | * function calls to confirm a function's (untainted)
|
51 | 51 | * parameters are valid.
|
52 |
| - * |
| 52 | + * |
53 | 53 | * The difference in behavior is that ASSERT triggers a breakpoint while
|
54 | 54 | * verify does not.
|
55 | 55 | *
|
56 | 56 | * #define TU_VERIFY(cond) if(cond) return false;
|
57 | 57 | * #define TU_VERIFY(cond,ret) if(cond) return ret;
|
58 |
| - * |
| 58 | + * |
59 | 59 | * #define TU_VERIFY_HDLR(cond,handler) if(cond) {handler; return false;}
|
60 | 60 | * #define TU_VERIFY_HDLR(cond,ret,handler) if(cond) {handler; return ret;}
|
61 | 61 | *
|
62 | 62 | * #define TU_ASSERT(cond) if(cond) {_MESS_FAILED(); TU_BREAKPOINT(), return false;}
|
63 | 63 | * #define TU_ASSERT(cond,ret) if(cond) {_MESS_FAILED(); TU_BREAKPOINT(), return ret;}
|
64 |
| - * |
| 64 | + * |
65 | 65 | *------------------------------------------------------------------*/
|
66 | 66 |
|
67 | 67 | #ifdef __cplusplus
|
|
81 | 81 | #define _MESS_FAILED() do {} while (0)
|
82 | 82 | #endif
|
83 | 83 |
|
84 |
| -// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7 |
85 |
| -#if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__) |
| 84 | +// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7, M33 |
| 85 | +#if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__) |
86 | 86 | #define TU_BREAKPOINT() do \
|
87 | 87 | { \
|
88 | 88 | volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
|
|
0 commit comments