Skip to main content

usb_stack/
lib.rs

1#![doc = include_str!("../README.md")]
2#![no_std]
3#![deny(missing_docs)]
4
5/// Logging facade.
6///
7/// With the `defmt` feature these are `defmt`'s own macros; without it they
8/// expand to nothing so the stack builds without the logging dependency.
9#[cfg(feature = "defmt")]
10pub mod log {
11    pub use defmt::*;
12}
13
14/// No-op logging macros used when the `defmt` feature is disabled.
15#[cfg(not(feature = "defmt"))]
16#[allow(missing_docs)]
17pub mod log {
18    #[macro_export]
19    macro_rules! trace {
20        ($($arg:tt)*) => {};
21    }
22    #[macro_export]
23    macro_rules! debug {
24        ($($arg:tt)*) => {};
25    }
26    #[macro_export]
27    macro_rules! info {
28        ($($arg:tt)*) => {};
29    }
30    #[macro_export]
31    macro_rules! warn {
32        ($($arg:tt)*) => {};
33    }
34    #[macro_export]
35    macro_rules! error {
36        ($($arg:tt)*) => {};
37    }
38
39    pub use crate::{debug, error, info, trace, warn};
40}
41
42// ── Modules ──────────────────────────────────────────────────────────────────
43
44pub mod descriptor;
45pub mod device;
46pub mod endpoint;
47pub mod host;
48pub mod request;
49
50// ── Crate-level constants ─────────────────────────────────────────────────────
51
52/// Maximum number of endpoints the device stack can track (endpoint numbers
53/// 0–15, IN and OUT). Peripheral implementations may support fewer.
54pub const MAX_ENDPOINTS: usize = 16;
55
56/// Maximum packet size for EP0 (full-speed USB 2.0).
57pub const CONTROL_MAX_PACKET_SIZE: u16 = 64;
58
59/// Maximum packet size for bulk/interrupt endpoints (full-speed USB 2.0).
60pub const BULK_MAX_PACKET_SIZE: u16 = 64;