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
191 #elif FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_INF_LOOP_FOR_DEBUG
198 #elif FAS_ASSERT_LEVEL == FAS_ASSERT_LEVEL_NO_OPERATION
202 #error "Invalid value for FAS_ASSERT_LEVEL"
206 #ifdef UNITY_UNIT_TEST
225 #define FAS_ASSERT_RECORD() \
227 uint32_t *pc = (uint32_t *)__curpc(); \
228 FAS_StoreAssertLocation(pc, __LINE__); \
249 #ifdef UNITY_UNIT_TEST
250 #include "CException.h"
251 #define FAS_ASSERT(x) \
255 #define FAS_ASSERT(x) \
258 FAS_ASSERT_RECORD(); \
259 FAS_InfiniteLoop(); \
264 #if defined(__STDC_VERSION__)
265 #if __STDC_VERSION__ == 199409L
266 #warning "Ignoring static asserts in C94 mode (FAS_STATIC_ASSERT)."
267 #define FAS_STATIC_ASSERT(cond, msg)
268 #elif __STDC_VERSION__ == 199901L
269 #if defined(__TI_COMPILER_VERSION__)
271 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
273 #warning "Ignoring static asserts in C99 mode (FAS_STATIC_ASSERT)."
274 #define FAS_STATIC_ASSERT(...)
276 #elif __STDC_VERSION__ == 201112L
277 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
278 #elif __STDC_VERSION__ == 201710L
279 #define FAS_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
284 #warning "Ignoring static asserts in C89/C90 mode (FAS_STATIC_ASSERT)."
285 #define FAS_STATIC_ASSERT(cond, msg)
293 #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.