diff options
Diffstat (limited to 'sw/eval-clock-cw-tx/src/usb.rs')
-rw-r--r-- | sw/eval-clock-cw-tx/src/usb.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sw/eval-clock-cw-tx/src/usb.rs b/sw/eval-clock-cw-tx/src/usb.rs index 941a024..e803c91 100644 --- a/sw/eval-clock-cw-tx/src/usb.rs +++ b/sw/eval-clock-cw-tx/src/usb.rs @@ -1,4 +1,4 @@ - +use core::fmt::Write; use stm32f1xx_hal::gpio; use stm32f1xx_hal::pac; use stm32f1xx_hal::pac::{interrupt, Interrupt}; @@ -74,17 +74,16 @@ fn usb_interrupt() { } let mut buf = [0u8; 8]; + let mut string = arrayvec::ArrayString::<[_; 16]>::new(); match serial.read(&mut buf) { Ok(count) if count > 0 => { // Echo back in upper case for c in buf[0..count].iter_mut() { - if 0x61 <= *c && *c <= 0x7a { - *c &= !0x20; - } + write!(string, "{:02x}", *c).ok(); } - - serial.write(&buf[0..count]).ok(); + serial.write(string.as_bytes()).ok(); + string.clear(); } _ => {} } |