[][src]Module teensy4_bsp::usb

This is supported on crate feature usb-logging only.

Teensy 4 USB, taken from the original Teensy 4 C libraries.

The USB stack provides a log implementation for logging over USB

This is Serial.println() in Rust. Use the macros of the log crate to write data over USB.

Logging Example

use teensy4_bsp as bsp;

let core_peripherals = cortex_m::Peripherals::take().unwrap();
let mut systick = bsp::SysTick::new(core_peripherals.SYST);
bsp::usb::init(
    &systick,
    bsp::usb::LoggingConfig {
        filters: &[("motor", None)],
        ..Default::default()
    },
)
.unwrap();

log::info!("Hello world! 3 + 2 = {}", 5);

Reader / Writer Example

use teensy4_bsp as bsp;
use core::fmt::Write;

let core_peripherals = cortex_m::Peripherals::take().unwrap();
let mut systick = bsp::SysTick::new(core_peripherals.SYST);
let (mut reader, mut writer) = bsp::usb::split(&systick).unwrap();

write!(writer, "Hello world! 3 + 2 = {}", 5);

Structs

LoggingConfig

Logging configuration

Reader

A type that can read USB serial messages from a host

Writer

A type that can send data to a USB serial host

Enums

Error

Indicate an error when preparing the USB stack

Functions

init

Initializes the USB stack. This prepares the logging back-end. Returns a Reader that can read USB serial messages.

split