Skip to content

usb_device

Portable, allocation-free USB CDC device service. The board constructs it; the controller only handles packets. Call service from its IRQ and at least once per millisecond from a task, then handle take_reset in task context.

struct Identity {
pub vid: u16,
pub pid: u16,
pub manufacturer: &'static str,
pub product: &'static str,
pub serial: Option<&'static str>,
pub allow_reset: bool,
}

Implements: Clone, Copy

struct Status {
pub configured: bool,
pub connected: bool,
pub resets: u32,
pub stalls: u32,
pub setups: u32,
pub received: u32,
pub transmitted: u32,
pub transmit_idle: bool,
}

Implements: Clone, Copy, Debug, Default

struct UsbSerial<C> { /* private fields */ }

Implements: ByteStream, Serial

trait Serial: ByteStream {
fn service(&self) -> Result<(), Error>
fn status(&self) -> Status
fn take_reset(&self) -> Option<ResetTarget>
}

Board-facing service; applications need not name a physical controller.