Sound Byte Libs 1ee2ca6
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
driver.hpp
Go to the documentation of this file.
1/**
2 * @file driver.hpp
3 * @brief UART driver interface - canonical types for MCU driver implementations
4 * @ingroup hal
5 *
6 * This header documents the UART driver interface that MCU drivers implement.
7 *
8 * Drivers implement the following static interface:
9 * static void init(uint32_t baud_rate);
10 * static void write_byte(uint8_t byte);
11 * static void write(const uint8_t* data, size_t len);
12 *
13 * Optional methods for bidirectional communication:
14 * static bool available();
15 * static uint8_t read_byte();
16 *
17 * Usage in driver:
18 * #include <sbl/hal/uart/driver.hpp>
19 *
20 * ## Design Notes
21 *
22 * UART is designed as a simple debug output interface. The initial implementation
23 * focuses on TX-only operation for debug logging. RX support can be added later
24 * for MIDI input or debug console features.
25 *
26 * The driver uses polling/blocking mode for simplicity. Interrupt-driven or DMA
27 * modes can be added as separate driver variants (UartAsync, UartDma) if needed.
28 */
29
30#ifndef SBL_HAL_UART_DRIVER_HPP_
31#define SBL_HAL_UART_DRIVER_HPP_
32
33#include <cstdint>
34#include <cstddef>
35
36namespace sbl {
37
38/**
39 * @brief Standard baud rates for UART communication
40 */
41namespace uart {
42 constexpr uint32_t BAUD_9600 = 9600;
43 constexpr uint32_t BAUD_19200 = 19200;
44 constexpr uint32_t BAUD_38400 = 38400;
45 constexpr uint32_t BAUD_57600 = 57600;
46 constexpr uint32_t BAUD_115200 = 115200;
47 constexpr uint32_t BAUD_230400 = 230400;
48 constexpr uint32_t BAUD_460800 = 460800;
49 constexpr uint32_t BAUD_921600 = 921600;
50
51 // MIDI baud rate
52 constexpr uint32_t BAUD_MIDI = 31250;
53} // namespace uart
54
55} // namespace sbl
56
57#endif // SBL_HAL_UART_DRIVER_HPP_
constexpr uint32_t BAUD_9600
Definition driver.hpp:42
constexpr uint32_t BAUD_460800
Definition driver.hpp:48
constexpr uint32_t BAUD_19200
Definition driver.hpp:43
constexpr uint32_t BAUD_115200
Definition driver.hpp:46
constexpr uint32_t BAUD_230400
Definition driver.hpp:47
constexpr uint32_t BAUD_921600
Definition driver.hpp:49
constexpr uint32_t BAUD_MIDI
Definition driver.hpp:52
constexpr uint32_t BAUD_57600
Definition driver.hpp:45
constexpr uint32_t BAUD_38400
Definition driver.hpp:44
Root namespace for all Sound Byte Libs functionality.
Definition aliases.hpp:24