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