Sound Byte Libs 0.5.1-121-g3358a44
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#ifndef SBL_COMMON_LOG_DEFAULTS_HPP_
13#define SBL_COMMON_LOG_DEFAULTS_HPP_
14
15#if __has_include(<sbl/hw/hw.hpp>)
16#include <sbl/hw/hw.hpp>
17
18namespace sbl::log {
19
20/// Default UART output sink — writes to Uart<0> (debug UART)
21struct UartOutput {
22 static void write(const char* str) { sbl::driver::Uart<>::write_string(str); }
23};
24
25/// Polling UART output — bypasses ring buffer, works with interrupts disabled.
26/// Use as SBL_FAULT_OUTPUT for fault/panic handlers.
27struct UartFaultOutput {
28 static void write(const char* str) { sbl::driver::Uart<>::write_string_polling(str); }
29};
30
31/// Default timestamp provider — milliseconds from Timer driver
32struct TimerTimestamp {
33 static uint32_t now() { return sbl::driver::Timer::millis(); }
34};
35
36} // namespace sbl::log
37
38#define SBL_LOG_HW_DEFAULTS_AVAILABLE 1
39#else
40#define SBL_LOG_HW_DEFAULTS_AVAILABLE 0
41#endif
42
43// USB CDC output — available when sbl_setup_usb() was called
44#if defined(SBL_HAS_USB) && __has_include(<sbl/usb/cdc.hpp>)
45#include <sbl/usb/cdc.hpp>
46#define SBL_LOG_USB_DEFAULTS_AVAILABLE 1
47#else
48#define SBL_LOG_USB_DEFAULTS_AVAILABLE 0
49#endif
50
51#endif // SBL_COMMON_LOG_DEFAULTS_HPP_
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
Logging.
Definition banner.hpp:51