aboutsummaryrefslogtreecommitdiffstats
path: root/sw/eval-clock-cw-tx/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'sw/eval-clock-cw-tx/src/main.rs')
-rw-r--r--sw/eval-clock-cw-tx/src/main.rs43
1 files changed, 22 insertions, 21 deletions
diff --git a/sw/eval-clock-cw-tx/src/main.rs b/sw/eval-clock-cw-tx/src/main.rs
index 4d2dae5..c91c545 100644
--- a/sw/eval-clock-cw-tx/src/main.rs
+++ b/sw/eval-clock-cw-tx/src/main.rs
@@ -59,13 +59,13 @@ struct SharedWithISR {
state : State,
last_sequence_state_change : u32,
cw_ptt_timestamp : u32,
- cw_key_n : gpio::gpioa::PA15<gpio::Output<gpio::OpenDrain>>,
+ cw_key_out : gpio::gpioa::PA15<gpio::Output<gpio::PushPull>>,
ui : ui::UI,
cw_pwm: cw::CWPWM,
cw_keyer: cw::Keyer,
cw_paddle_tip: gpio::gpiob::PB8<gpio::Input<gpio::PullUp>>,
cw_paddle_ring: gpio::gpiob::PB9<gpio::Input<gpio::PullUp>>,
- ptt_out_n: gpio::gpiob::PB3<gpio::Output<gpio::PushPull>>,
+ ptt_out: gpio::gpiob::PB3<gpio::Output<gpio::PushPull>>,
led : gpio::gpiob::PB14<gpio::Output<gpio::PushPull>>,
}
@@ -73,7 +73,7 @@ static mut SHARED: MaybeUninit<SharedWithISR> = MaybeUninit::uninit();
static mut CLOCK_TIMER: MaybeUninit<CountDownTimer<pac::TIM2>> = MaybeUninit::uninit();
static mut TICK_COUNTER: MaybeUninit<u32> = MaybeUninit::uninit();
-fn ticks_now() -> u32 {
+fn _ticks_now() -> u32 {
cortex_m::interrupt::free(|_cs| unsafe { *TICK_COUNTER.as_ptr() })
}
@@ -124,8 +124,8 @@ fn main() -> ! {
led.set_low().unwrap();
let (pa15, pb3, _pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4);
- let cw_key_n = pa15.into_open_drain_output_with_state(&mut gpioa.crh, gpio::State::High);
- let ptt_out_n = pb3.into_push_pull_output_with_state(&mut gpiob.crl, gpio::State::High);
+ let cw_key_out = pa15.into_push_pull_output_with_state(&mut gpioa.crh, gpio::State::Low);
+ let ptt_out = pb3.into_push_pull_output_with_state(&mut gpiob.crl, gpio::State::Low);
let c1 = gpioa.pa6;
let c2 = gpioa.pa7;
@@ -180,14 +180,14 @@ fn main() -> ! {
state : State::new(),
last_sequence_state_change : 0,
cw_ptt_timestamp : 0,
- cw_key_n,
+ cw_key_out,
ui,
cw_pwm,
cw_keyer : cw::Keyer::new(12, TICKS_PER_SECOND),
- cw_paddle_tip, cw_paddle_ring, ptt_out_n, led
+ cw_paddle_tip, cw_paddle_ring, ptt_out, led
};
- si_clock::SiClock::new(i2c_busmanager.acquire_i2c(), 0, shared.state.vfo())
+ si_clock::SiClock::new(i2c_busmanager.acquire_i2c(), 0, shared.state.vfo_display())
};
ui::update_disp(&mut lcd, &get_state_copy(), &mut delay);
@@ -210,6 +210,7 @@ fn main() -> ! {
let mut last_disp_update_counter = 1;
let mut previous_vfo = 0;
+ let mut previous_state = SequenceState::Rx;
loop {
let mut update_disp_required = false;
@@ -229,15 +230,15 @@ fn main() -> ! {
}
});
- siclock.set_vfo(state.vfo());
update_disp_required = true;
}
- let vfo = state.vfo();
- if previous_vfo != vfo {
- siclock.set_vfo(vfo);
+ let vfo = state.vfo_display();
+ if previous_vfo != vfo || previous_state != state.sequence_state {
+ siclock.set_vfo(state.vfo_siclock());
}
previous_vfo = vfo;
+ previous_state = state.sequence_state.clone();
if last_disp_update_counter != state.update_disp_counter {
update_disp_required = true;
@@ -292,7 +293,8 @@ fn TIM2() {
let next_state = match shared.state.sequence_state {
SequenceState::Rx => {
- shared.ptt_out_n.set_high().unwrap();
+ shared.ptt_out.set_low().unwrap();
+ shared.led.set_high().unwrap();
if cw_ptt {
SequenceState::SwitchingCW
}
@@ -301,7 +303,8 @@ fn TIM2() {
}
},
SequenceState::SwitchingCW => {
- shared.ptt_out_n.set_low().unwrap();
+ shared.ptt_out.set_high().unwrap();
+ shared.led.set_low().unwrap();
if cw_ptt {
SequenceState::TxCW
}
@@ -310,7 +313,8 @@ fn TIM2() {
}
},
SequenceState::TxCW => {
- shared.ptt_out_n.set_low().unwrap();
+ shared.ptt_out.set_high().unwrap();
+ shared.led.set_low().unwrap();
if cw_ptt {
SequenceState::TxCW
}
@@ -323,20 +327,17 @@ fn TIM2() {
match shared.state.sequence_state {
SequenceState::TxCW => {
if cw_beep {
- shared.led.set_low().unwrap();
shared.cw_pwm.on();
- shared.cw_key_n.set_low().unwrap();
+ shared.cw_key_out.set_high().unwrap();
}
else {
- shared.led.set_high().unwrap();
shared.cw_pwm.off();
- shared.cw_key_n.set_high().unwrap();
+ shared.cw_key_out.set_low().unwrap();
}
},
_ => {
- shared.led.set_high().unwrap();
shared.cw_pwm.off();
- shared.cw_key_n.set_high().unwrap();
+ shared.cw_key_out.set_low().unwrap();
},
}