mciantyre / teensy4-rs

Rust support for the Teensy 4
Apache License 2.0
272 stars 32 forks source link

Expose USB writer #72

Closed mciantyre closed 4 years ago

mciantyre commented 4 years ago

The PR lets users split() the USB handle. When you split the handle, you get back a USB reader and USB writer. You can use the writer to send formatted / raw data back to the USB serial host.

See the new usb_writer.rs example for more information.

use core::fmt::Write;

let mut p = bsp::Peripherals::take().unwrap();
let (mut reader, mut writer) = p.usb.split();
writeln!(writer, "Hello world! 3 + 2 = {}", 3 + 2).unwrap();
mciantyre commented 4 years ago

bors r+

bors[bot] commented 4 years ago

Build succeeded: