Adafruit Si5351 Library
Macros
asserts.h File Reference
#include "errors.h"

Go to the source code of this file.

Macros

#define ASSERT(condition, returnValue)
 Checks the condition, and if the assert fails the supplied returnValue will be returned in the calling function. More...
 
#define ASSERT_STATUS(sts)
 Checks the supplied err_t value (sts), and if it is not equal to ERROR_NONE the sts value will be returned. More...
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   condition,
  returnValue 
)
Value:
do { \
if (!(condition)) { \
return (returnValue); \
} \
} while (0)

Checks the condition, and if the assert fails the supplied returnValue will be returned in the calling function.

// Make sure 'addr' is within range
ASSERT(addr <= MAX_ADDR, ERROR_ADDRESSOUTOFRANGE);

◆ ASSERT_STATUS

#define ASSERT_STATUS (   sts)
Value:
do { \
err_t status = (sts); \
if (ERROR_NONE != status) { \
return status; \
} \
} while (0)
Definition: errors.h:14

Checks the supplied err_t value (sts), and if it is not equal to ERROR_NONE the sts value will be returned.

This macro is useful to check if a function returned an error without bloating your own code with endless "if (error) {...}".

// If anything other than ERROR_NONE is returned by tsl2561Enable()
// this macro will log the error and exit the function returning the
// error_t value.
ASSERT_STATUS(tsl2561Enable());