ASSERT - Assert

Description

Assert/error checking module.

This module contains functions to control the ASSERT peripheral of Silicon Labs 32-bit MCUs and SoCs.

By default, EMLIB library assert usage is not included to reduce footprint and processing overhead. Further, EMLIB assert usage is decoupled from ISO C assert handling (NDEBUG usage) to allow using ISO C assert without including EMLIB assert statements.

Below are available defines for controlling EMLIB assert inclusion. The defines are typically for a project to be used by the preprocessor.

  • If DEBUG_EFM is defined, the internal EMLIB library assert handling will be used. This is implemented as a simple while(true) loop. DEBUG_EFM is not defined by default.
  • If DEBUG_EFM_USER is defined, the user must provide custom implementation of the assertEFM() function.
  • If both DEBUG_EFM and DEBUG_EFM_USER are undefined, all EFM_ASSERT() statements are not operational.
Note
The internal EMLIB assert is documented because DEBUG_EFM is defined in the doxygen configuration.

Functions

void assertEFM (const char *file, int line)
EFM internal assert handling.

Macros

#define EFM_ASSERT (expr)   ((expr) ? ((void)0) : assertEFM (__FILE__, __LINE__))
Default assertion is not operational.

Function Documentation

assertEFM()

void assertEFM ( const char * file,
int line
)

EFM internal assert handling.

This function is invoked through EFM_ASSERT() macro usage only and should not be used explicitly.

This implementation enters an indefinite loop, allowing the use of a debugger to determine a cause of failure. By defining DEBUG_EFM_USER to the preprocessor for all files, a user-defined version of this function must be defined and will be invoked instead, possibly providing output of assertion location.

Note
This function is not used unless DEBUG_EFM is defined during preprocessing of EFM_ASSERT() usage.
Parameters
[in] file Name of the source file where assertion failed.
[in] line A line number in the source file where assertion failed.

Macro Definition Documentation

EFM_ASSERT

#define EFM_ASSERT ( expr ) ((expr) ? ((void)0) : assertEFM (__FILE__, __LINE__))

Default assertion is not operational.