Macros for parameter checking and similar tasks.
More...
Macros for parameter checking and similar tasks.
#define NRF_PARAM_CHECK |
( |
|
_module, |
|
|
|
_cond, |
|
|
|
_err, |
|
|
|
_printfn |
|
) |
| |
Macro for parameter checking.
If _cond
evaluates to true, does nothing. Otherwise, if _module
## _PARAM_CHECK_DISABLED is not set (default), prints an error message if _printfn
is provided, and returns from the calling function context with code _err
. If _module
## _PARAM_CHECK_DISABLED is set, behaves like the ASSERT macro.
Parameter checking implemented using this macro can be optionally turned off for release code. Only disable runtime parameter checks if size if a major concern.
- Parameters
-
_module | The module name. |
_cond | The condition to be evaluated. |
_err | The error to be returned. |
_printfn | A printf-compatible function used to log the error. Leave empty if no logging is needed. |
#define VERIFY_FALSE |
( |
|
statement, |
|
|
|
err_code |
|
) |
| |
Value:do \
{ \
if ((statement)) \
{ \
return err_code; \
} \
} while (0)
Macro for verifying statement to be false. It will cause the exterior function to return err_code if the statement is not false.
- Parameters
-
[in] | statement | Statement to test. |
[in] | err_code | Error value to return if test was invalid. |
- Return values
-
nothing,but | will cause the exterior function to return err_code if statement is true. |
#define VERIFY_FALSE_VOID |
( |
|
statement | ) |
VERIFY_FALSE((statement), ) |
Macro for verifying statement to be false. It will cause the exterior function to return if the statement is not false.
- Parameters
-
[in] | statement | Statement to test. |
Macro for verifying that the module is initialized. It will cause the exterior function to return NRF_ERROR_INVALID_STATE if not.
- Note
- MODULE_INITIALIZED must be defined in each module using this macro. MODULE_INITIALIZED should be true if the module is initialized, false if not.
#define VERIFY_MODULE_INITIALIZED_VOID |
( |
| ) |
VERIFY_TRUE_VOID((MODULE_INITIALIZED)) |
Macro for verifying that the module is initialized. It will cause the exterior function to return if not.
- Note
- MODULE_INITIALIZED must be defined in each module using this macro. MODULE_INITIALIZED should be true if the module is initialized, false if not.
Macro for verifying that the module is initialized. It will cause the exterior function to return if not.
- Parameters
-
[in] | param | The variable to check if is NULL. |
Macro for verifying that the module is initialized. It will cause the exterior function to return if not.
- Parameters
-
[in] | param | The variable to check if is NULL. |
#define VERIFY_SUCCESS |
( |
|
statement | ) |
|
Value:do \
{ \
uint32_t _err_code = (uint32_t) (statement); \
{ \
return _err_code; \
} \
} while(0)
Macro for verifying that a function returned NRF_SUCCESS. It will cause the exterior function to return error code of statement if it is not NRF_SUCCESS.
- Parameters
-
[in] | statement | Statement to check against NRF_SUCCESS. |
Macro for verifying that a function returned NRF_SUCCESS. It will cause the exterior function to return if the err_code is not NRF_SUCCESS.
- Parameters
-
[in] | err_code | The error code to check. |
#define VERIFY_TRUE |
( |
|
statement, |
|
|
|
err_code |
|
) |
| |
Value:do \
{ \
if (!(statement)) \
{ \
return err_code; \
} \
} while (0)
Macro for verifying statement to be true. It will cause the exterior function to return err_code if the statement is not true.
- Parameters
-
[in] | statement | Statement to test. |
[in] | err_code | Error value to return if test was invalid. |
- Return values
-
nothing,but | will cause the exterior function to return err_code if statement is false. |
#define VERIFY_TRUE_VOID |
( |
|
statement | ) |
VERIFY_TRUE((statement), ) |
Macro for verifying statement to be true. It will cause the exterior function to return if the statement is not true.
- Parameters
-
[in] | statement | Statement to test. |