The Common module offers assert capabilities that can be used in various situations in your application. For more information on asserts in general, please refer to Assertions.
APP_RTOS_ASSERT_DBG() macros check if a given expression is evaluated with a positive result. If the result is not positive, the macro will do one of the following operations:
RTOS_CFG_RTOS_ASSERT_DBG_FAILED_END_CALL(ret_val)are defined, the macro will call these.
- If they are not defined,
CPU_SW_EXCEPTION(ret_val)will be called.
The debug asserts typically check for conditions that are caused by invalid parameters or invalid configurations. They are used to notify the developer that something is not correct with the way the code is being used. Those can and should be disabled once development is completed.
The critical asserts typically check for conditions from which it is practically impossible to recover at run-time. Therefore, if such a condition is detected, the program's execution should be suspended before any more damage occurs.
An example of an assert using the macros is provided below.
Macro Fail Calls
These macro calls are intended to be used when an assert must be triggered without checking any additional expression results.
For example, ending in the default case of a switch statement when all known types have their specific case could be considered a critical failure. In these cases, you should use the
APP_RTOS_ASSERT_DBG_FAIL() macros. An example is provided below.