aboutsummaryrefslogtreecommitdiffstats
path: root/sw/eval-clock-cw-tx/src/usb.rs
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-04-02 10:42:04 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-04-02 10:42:04 +0200
commit74792bbed5ba8028550238dde2a12eec715d4055 (patch)
treebe91575b810b5f4b88e9fc9722e11dd18ec919e2 /sw/eval-clock-cw-tx/src/usb.rs
parent62fdd309c55286222d1add4ca3051353da0e11b8 (diff)
downloadpicardy-74792bbed5ba8028550238dde2a12eec715d4055.tar.gz
picardy-74792bbed5ba8028550238dde2a12eec715d4055.tar.bz2
picardy-74792bbed5ba8028550238dde2a12eec715d4055.zip
Make cw key active low
Diffstat (limited to 'sw/eval-clock-cw-tx/src/usb.rs')
-rw-r--r--sw/eval-clock-cw-tx/src/usb.rs11
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();
}
_ => {}
}