Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
assert.hpp File Reference

Assert and panic for embedded firmware. More...

#include <cstdint>
#include <sbl/log/format.hpp>
#include <sbl/log/defaults.hpp>
Include dependency graph for assert.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sbl::fault::detail::NullFaultOutput
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs functionality.
 
namespace  sbl::fault
 
namespace  sbl::fault::detail
 

Macros

#define SBL_FAULT_OUTPUT   sbl::fault::detail::NullFaultOutput
 
#define SBL_PANIC(msg)   sbl::fault::panic("PANIC: " msg, __FILE__, __LINE__)
 
#define SBL_ASSERT_ENABLED   1
 
#define SBL_ASSERT(cond)   ((void)0)
 

Functions

void sbl::fault::panic (const char *msg, const char *file, int line)
 Halt with a diagnostic message. Does not return.
 

Detailed Description

Assert and panic for embedded firmware.

Provides SBL_ASSERT(cond) and SBL_PANIC(msg) macros that output diagnostic info and halt the processor. Output goes through the same sink as the logging system (SBL_LOG_OUTPUT).

This header is pure library code — no hardware dependencies. For HardFault register dumps, also include <sbl/fault.hpp>.

Usage: #include <sbl/assert.hpp>

void process(float* buf, uint16_t frames) { SBL_ASSERT(buf != nullptr); SBL_ASSERT(frames <= 48); // ... }

if (something_unrecoverable) { SBL_PANIC("DMA config failed"); }

Configuration: SBL_ASSERT_ENABLED - 1 (default) to enable, 0 to compile out SBL_FAULT_OUTPUT - output sink class (defaults to SBL_LOG_OUTPUT)

Definition in file assert.hpp.

Macro Definition Documentation

◆ SBL_ASSERT

#define SBL_ASSERT (   cond)    ((void)0)

Definition at line 100 of file assert.hpp.

◆ SBL_ASSERT_ENABLED

#define SBL_ASSERT_ENABLED   1

Definition at line 89 of file assert.hpp.

◆ SBL_FAULT_OUTPUT

#define SBL_FAULT_OUTPUT   sbl::fault::detail::NullFaultOutput

Definition at line 54 of file assert.hpp.

◆ SBL_PANIC

#define SBL_PANIC (   msg)    sbl::fault::panic("PANIC: " msg, __FILE__, __LINE__)

Definition at line 86 of file assert.hpp.