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
uart_requirements.hpp File Reference

UART driver requirements validator. More...

Detailed Description

UART driver requirements validator.

Validates that UART drivers provide required functionality using the method detection system. This is the core UART contract enforcement for Sound Byte Libs drivers.

UART Driver Contract

Every Sound Byte Libs UART driver MUST implement these methods:

  • init(const UartHandle&) - Initialize UART with manifest-resolved handle
  • init_rx(const UartHandle&) - Initialize UART for RX-only (MIDI, sensors)
  • write_byte(uint8_t) - Write single byte (blocking)
  • write(const uint8_t*, size_t) - Write buffer (blocking)
  • write_string(const char*) - Write null-terminated string (blocking)
  • available() -> bool - Check if RX data is available
  • read_byte() -> uint8_t - Read single byte from RX buffer

Optional methods (validated if present):

  • try_write_byte(uint8_t) -> bool - Non-spinning TX (STM32 only)
  • try_write_string(const char*) -> size_t - Non-spinning TX (STM32 only)

Validation Usage

Add validation at the bottom of driver uart.hpp:

static_assert(sbl::validation::uart_driver_valid<sbl::driver::Uart<>>,
"UART driver missing required methods");
UART driver requirements validator.
See also
method_detection.hpp

Definition in file uart_requirements.hpp.

Go to the source code of this file.

Classes

class  sbl::validation::UartDriverRequirements< UartDriver >
 UART driver requirements validator. More...
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::validation
 Compile-time driver contracts.
 

Variables

template<typename UartDriver >
constexpr bool sbl::validation::uart_driver_valid = UartDriverRequirements<UartDriver>::validate()
 Helper to validate a UART driver implementation.