Skip to main content

Crate imxrt_usbd

Crate imxrt_usbd 

Source
Expand description

A USB driver for i.MX RT processors

imxrt-usbd provides a usb-device USB bus implementation, allowing you to add USB device features to your embedded Rust program. See each module for usage and examples.

§General guidance

The driver does not configure any of the CCM or CCM_ANALOG registers. You are responsible for configuring these peripherals for proper USB functionality. See the imxrt-usbd hardware examples to see different ways of configuring PLLs and clocks.

You, or something in your dependency hierarchy, must enable an imxrt-ral chip feature; otherwise, this package will not build.

§Debugging features

Enable the defmt feature to activate internal logging using defmt.

§Example

use imxrt_ral as ral;
use imxrt_usbd::{BusAdapter, Instances};

static EP_MEMORY: imxrt_usbd::EndpointMemory<1024> = imxrt_usbd::EndpointMemory::new();
static EP_STATE: imxrt_usbd::EndpointState = imxrt_usbd::EndpointState::max_endpoints();

let instances = Instances {
    usb: unsafe { ral::usb::USB::instance() },
    usbnc: unsafe { ral::usbnc::USBNC::instance() },
    usbphy: unsafe { ral::usbphy::USBPHY::instance() },
};

let bus_adapter = BusAdapter::new(
    instances,
    &EP_MEMORY,
    &EP_STATE,
);

Modules§

gpt
USB general purpose timers.

Structs§

BusAdapter
A full- and high-speed UsbBus implementation
EndpointMemory
Memory for endpoint I/O.
EndpointState
Driver state associated with endpoints.
Instances
Aggregate of imxrt-ral USB peripheral instances.

Enums§

Speed
USB low / full / high speed setting.

Constants§

MAX_ENDPOINTS
The maximum supported number of endpoints.