Sound Byte Libs 1ee2ca6
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
usb.hpp
Go to the documentation of this file.
1#pragma once
2/**
3 * @file usb.hpp
4 * @brief USB subsystem control
5 *
6 * Provides initialization and task processing for USB functionality.
7 * The actual implementation is MCU-specific and lives in sbl-hardware.
8 *
9 * Usage:
10 * #include <sbl/usb/usb.hpp>
11 *
12 * int main() {
13 * sbl::driver::init();
14 * sbl::usb::init();
15 *
16 * while (true) {
17 * sbl::usb::task(); // Process USB events
18 * // ... application code ...
19 * }
20 * }
21 */
22
23#include <cstdint>
24
25namespace sbl::usb {
26
27/**
28 * @brief Initialize USB subsystem
29 *
30 * Sets up USB peripheral clocks, pins, and initializes TinyUSB.
31 * Call once at startup after sbl::driver::init().
32 */
33void init();
34
35/**
36 * @brief Process USB events
37 *
38 * Must be called periodically (from main loop or timer) to handle
39 * USB enumeration, data transfer, and protocol handling.
40 *
41 * On RP2xxx: Can also be IRQ-driven, but task() still needs calling.
42 * On STM32: Typically polled from main loop.
43 */
44void task();
45
46/**
47 * @brief Check if USB is enumerated and ready
48 *
49 * @return true if USB device is configured and ready for communication
50 */
51bool ready();
52
53} // namespace sbl::usb
void init()
Initialize USB subsystem.
void task()
Process USB events.
bool ready()
Check if USB is enumerated and ready.