Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
defaults.hpp
Go to the documentation of this file.
1/**
2 * @file defaults.hpp
3 * @brief Default logger output sink and timestamp provider
4 *
5 * Provides UartOutput and TimerTimestamp that wrap standard SBL driver
6 * calls. Guarded by __has_include so unit tests compile without hw headers.
7 *
8 * When <sbl/hw/hw.hpp> is available (firmware builds), these defaults
9 * are used automatically by macros.hpp unless the application defines
10 * SBL_LOG_OUTPUT / SBL_LOG_TIMESTAMP explicitly.
11 */
12#pragma once
13
14#if __has_include(<sbl/hw/hw.hpp>)
15#include <sbl/hw/hw.hpp>
16
17namespace sbl::log {
18
19/// Default UART output sink — writes to Uart<0> (debug UART)
20struct UartOutput {
21 static void write(const char* str) { sbl::driver::Uart<>::write_string(str); }
22};
23
24/// Polling UART output — bypasses ring buffer, works with interrupts disabled.
25/// Use as SBL_FAULT_OUTPUT for fault/panic handlers.
26struct UartFaultOutput {
27 static void write(const char* str) { sbl::driver::Uart<>::write_string_polling(str); }
28};
29
30/// Default timestamp provider — milliseconds from Timer driver
31struct TimerTimestamp {
32 static uint32_t now() { return sbl::driver::Timer::millis(); }
33};
34
35} // namespace sbl::log
36
37#define SBL_LOG_HW_DEFAULTS_AVAILABLE 1
38#else
39#define SBL_LOG_HW_DEFAULTS_AVAILABLE 0
40#endif
41
42// USB CDC output — available when sbl_setup_usb() was called
43#if defined(SBL_HAS_USB) && __has_include(<sbl/usb/cdc.hpp>)
44#include <sbl/usb/cdc.hpp>
45#define SBL_LOG_USB_DEFAULTS_AVAILABLE 1
46#else
47#define SBL_LOG_USB_DEFAULTS_AVAILABLE 0
48#endif
USB CDC (Virtual COM Port) interface.
Uber-umbrella header for all target-specific code.
void write(const RgbLed &led, const GpioHandle &r, const GpioHandle &g, const GpioHandle &b)
Write RgbLed state to GPIO pins (bang-bang)
Definition output.hpp:48
Lightweight logging system.
Definition banner.hpp:50