nRF5 SDK for Mesh v1.0.1
Macros | Variables
Assert API

Allows the framework to propagate errors that can't be recovered from. More...

Macros

#define NRF_MESH_ASSERT(cond)
 Run-time assertion. More...
 
#define NRF_MESH_ASSERT_DEBUG(cond)   NRF_MESH_ASSERT(cond)
 Run-time assertion for debug use. More...
 
#define NRF_MESH_ERROR_CHECK(err)   NRF_MESH_ASSERT(err == NRF_SUCCESS)
 Asserts if an error code is not NRF_SUCCESS. More...
 
#define NRF_MESH_STATIC_ASSERT(cond)   typedef char static_assert[(cond) ? 1 : -1]
 Compile-time assertion. More...
 

Variables

nrf_mesh_assertion_handler_t m_assertion_handler
 Pointer to the assert handler. More...
 
#define HARD_FAULT()   __breakpoint(0)
 Produces a hardfault. More...
 
#define GET_PC(pc)
 Gets the current value of the program counter. More...
 
#define HARD_FAULT()   asm volatile(".inst.n 0xde00\n")
 Produces a hardfault. More...
 
#define GET_PC(pc)   asm volatile("mov %0, pc\n\t" : "=r" (pc))
 Gets the current value of the program counter. More...
 
#define HARD_FAULT()   abort()
 Produces a hardfault. More...
 
#define GET_PC(pc)   pc = 0xffffffff
 Gets the current value of the program counter. More...
 

Detailed Description

Allows the framework to propagate errors that can't be recovered from.

Macro Definition Documentation

◆ NRF_MESH_ASSERT

#define NRF_MESH_ASSERT (   cond)
Value:
if (!(cond)) \
{ \
uint32_t pc; \
GET_PC(pc); \
{ \
m_assertion_handler(pc); \
} \
else \
{ \
HARD_FAULT(); \
} \
}
nrf_mesh_assertion_handler_t m_assertion_handler
Pointer to the assert handler.

Run-time assertion.

Will trigger the assertion handler if the specified condition evaluates to false.

Parameters
[in]condCondition to evaluate.

Definition at line 73 of file nrf_mesh_assert.h.

◆ NRF_MESH_ASSERT_DEBUG

#define NRF_MESH_ASSERT_DEBUG (   cond)    NRF_MESH_ASSERT(cond)

Run-time assertion for debug use.

Debug assertions are only run if the stack is compiled in debug mode.

Definition at line 95 of file nrf_mesh_assert.h.

◆ NRF_MESH_ERROR_CHECK

#define NRF_MESH_ERROR_CHECK (   err)    NRF_MESH_ASSERT(err == NRF_SUCCESS)

Asserts if an error code is not NRF_SUCCESS.

Parameters
[in]errError code to check.

Definition at line 102 of file nrf_mesh_assert.h.

◆ NRF_MESH_STATIC_ASSERT

#define NRF_MESH_STATIC_ASSERT (   cond)    typedef char static_assert[(cond) ? 1 : -1]

Compile-time assertion.

Parameters
[in]condCondition to evaluate. If false, the compilation will be aborted with an error.

Definition at line 108 of file nrf_mesh_assert.h.

◆ HARD_FAULT [1/3]

#define HARD_FAULT ( )    __breakpoint(0)

Produces a hardfault.

Definition at line 60 of file nrf_mesh_assert_armcc.h.

◆ HARD_FAULT [2/3]

#define HARD_FAULT ( )    asm volatile(".inst.n 0xde00\n")

Produces a hardfault.

Definition at line 69 of file nrf_mesh_assert_gcc.h.

◆ HARD_FAULT [3/3]

#define HARD_FAULT ( )    abort()

Produces a hardfault.

Definition at line 58 of file nrf_mesh_assert_lint.h.

◆ GET_PC [1/3]

#define GET_PC (   pc)
Value:
do { \
pc = __current_pc(); \
} while (0)

Gets the current value of the program counter.

Parameters
[out]pcVariable to assign the obtained value to.

Definition at line 66 of file nrf_mesh_assert_armcc.h.

◆ GET_PC [2/3]

#define GET_PC (   pc)    asm volatile("mov %0, pc\n\t" : "=r" (pc))

Gets the current value of the program counter.

Parameters
[out]pcVariable to assign the obtained value to.

Definition at line 75 of file nrf_mesh_assert_gcc.h.

◆ GET_PC [3/3]

#define GET_PC (   pc)    pc = 0xffffffff

Gets the current value of the program counter.

Parameters
[out]pcVariable to assign the obtained value to.

Definition at line 64 of file nrf_mesh_assert_lint.h.

Variable Documentation

◆ m_assertion_handler

nrf_mesh_assertion_handler_t m_assertion_handler

Pointer to the assert handler.

This is normally defined in nrf_mesh.c. If writing unit tests, this is defined in test_assert.c, which can be found in the test source directory.


Documentation feedback | Developer Zone | Subscribe | Updated