89 #ifndef FOXBMS__FASSERT_H_
90 #define FOXBMS__FASSERT_H_
117 #pragma SWI_ALIAS(FAS_DisableInterrupts, 5)
129 #define FAS_TRAP (0u == 1u)
168 #define FAS_ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS (0u)
169 #define FAS_ASSERT_LEVEL_INF_LOOP_FOR_DEBUG (1u)
170 #define FAS_ASSERT_LEVEL_NO_OPERATION (2u)
176 #ifndef FAS_ASSERT_LEVEL
177 #define FAS_ASSERT_LEVEL FAS_ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS
181 #if FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS
190 #elif FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_INF_LOOP_FOR_DEBUG
197 #elif FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_NO_OPERATION
201 #error "Invalid value for FAS_ASSERT_LEVEL"
205 #ifdef UNITY_UNIT_TEST
224 #define FAS_ASSERT_RECORD() \
226 uint32_t *pc = (uint32_t *)__curpc(); \
227 FAS_StoreAssertLocation(pc, __LINE__); \
248 #ifdef UNITY_UNIT_TEST
249 #include "CException.h"
250 #define FAS_ASSERT(x) \
254 #define FAS_ASSERT(x) \
257 FAS_ASSERT_RECORD(); \
258 FAS_InfiniteLoop(); \
263 #if defined(__STDC_VERSION__)
264 #if __STDC_VERSION__ == 199409L
265 #warning "Ignoring static asserts in C94 mode (FAS_STATIC_ASSERT)."
266 #define FAS_STATIC_ASSERT(cond, msg)
267 #elif __STDC_VERSION__ == 199901L
268 #if defined(__TI_COMPILER_VERSION__)
270 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
272 #warning "Ignoring static asserts in C99 mode (FAS_STATIC_ASSERT)."
273 #define FAS_STATIC_ASSERT(...)
275 #elif __STDC_VERSION__ == 201112L
276 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
277 #elif __STDC_VERSION__ == 201710L
278 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
283 #warning "Ignoring static asserts in C89/C90 mode (FAS_STATIC_ASSERT)."
284 #define FAS_STATIC_ASSERT(cond, msg)
292 #ifdef UNITY_UNIT_TEST
static uint32_t __curpc(void)
void FAS_StoreAssertLocation(uint32_t *pc, uint32_t line)
Copy the assert location into the assert struct.
void FAS_DisableInterrupts(void)
Disable interrupts.
static void FAS_InfiniteLoop(void)
Struct for storing assert information.