86 #ifndef FOXBMS__FASSERT_H_
87 #define FOXBMS__FASSERT_H_
114 #pragma SWI_ALIAS(FAS_DisableInterrupts, 5)
126 #define FAS_TRAP (0u == 1u)
165 #define FAS_ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS (0u)
166 #define FAS_ASSERT_LEVEL_INF_LOOP_FOR_DEBUG (1u)
167 #define FAS_ASSERT_LEVEL_NO_OPERATION (2u)
173 #ifndef FAS_ASSERT_LEVEL
174 #define FAS_ASSERT_LEVEL FAS_ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS
178 #if FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS
187 #elif FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_INF_LOOP_FOR_DEBUG
194 #elif FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_NO_OPERATION
198 #error "Invalid value for FAS_ASSERT_LEVEL"
203 #ifdef UNITY_UNIT_TEST
221 #define FAS_ASSERT_RECORD() \
225 uint32_t *pc = (uint32_t *)__curpc(); \
226 FAS_StoreAssertLocation(pc, __LINE__); \
247 #ifdef UNITY_UNIT_TEST
248 #include "CException.h"
249 #define FAS_ASSERT(x) \
253 #define FAS_ASSERT(x) \
256 FAS_ASSERT_RECORD(); \
257 FAS_InfiniteLoop(); \
262 #if defined(__STDC_VERSION__)
263 #if __STDC_VERSION__ == 199409L
264 #warning "Ignoring static asserts in C94 mode (FAS_STATIC_ASSERT)."
265 #define FAS_STATIC_ASSERT(cond, msg)
266 #elif __STDC_VERSION__ == 199901L
267 #if defined(__TI_COMPILER_VERSION__)
269 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
271 #warning "Ignoring static asserts in C99 mode (FAS_STATIC_ASSERT)."
272 #define FAS_STATIC_ASSERT(...)
274 #elif __STDC_VERSION__ == 201112L
275 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
276 #elif __STDC_VERSION__ == 201710L
277 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
282 #warning "Ignoring static asserts in C89/C90 mode (FAS_STATIC_ASSERT)."
283 #define FAS_STATIC_ASSERT(cond, msg)
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.