diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/eval-clock-cw-tx/src/main.rs | 12 | ||||
-rw-r--r-- | sw/eval-clock-cw-tx/src/usb.rs | 11 |
2 files changed, 11 insertions, 12 deletions
diff --git a/sw/eval-clock-cw-tx/src/main.rs b/sw/eval-clock-cw-tx/src/main.rs index d30318b..a548f81 100644 --- a/sw/eval-clock-cw-tx/src/main.rs +++ b/sw/eval-clock-cw-tx/src/main.rs @@ -60,7 +60,7 @@ struct SharedWithISR { state : State, last_sequence_state_change : u32, cw_ptt_timestamp : u32, - cw_key_out : gpio::gpioa::PA15<gpio::Output<gpio::PushPull>>, + cw_key_out_n : gpio::gpioa::PA15<gpio::Output<gpio::PushPull>>, ui : ui::UI, cw_pwm: cw::CWPWM, cw_keyer: cw::Keyer, @@ -135,7 +135,7 @@ fn main() -> ! { led.set_low().unwrap(); let (pa15, pb3, _pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4); - let cw_key_out = pa15.into_push_pull_output_with_state(&mut gpioa.crh, gpio::State::Low); + let cw_key_out_n = pa15.into_push_pull_output_with_state(&mut gpioa.crh, gpio::State::High); let ptt_out = pb3.into_push_pull_output_with_state(&mut gpiob.crl, gpio::State::Low); let c1 = gpioa.pa6; @@ -192,7 +192,7 @@ fn main() -> ! { state : State::new(), last_sequence_state_change : 0, cw_ptt_timestamp : 0, - cw_key_out, + cw_key_out_n, ui, cw_pwm, cw_keyer : cw::Keyer::new(12, TICKS_PER_SECOND), @@ -340,16 +340,16 @@ fn TIM2() { SequenceState::TxCW => { if cw_beep { shared.cw_pwm.on(); - shared.cw_key_out.set_high().unwrap(); + shared.cw_key_out_n.set_low().unwrap(); } else { shared.cw_pwm.off(); - shared.cw_key_out.set_low().unwrap(); + shared.cw_key_out_n.set_high().unwrap(); } }, _ => { shared.cw_pwm.off(); - shared.cw_key_out.set_low().unwrap(); + shared.cw_key_out_n.set_high().unwrap(); }, } 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(); } _ => {} } |