From 28bc0e6d03f221b4292be8e76e4bd019ebcc4616 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 15 Dec 2020 22:36:19 +0100 Subject: Power decoupling and IF improvements --- sw/picardy/Cargo.lock | 35 ++++++++++++++++++++++------------- sw/picardy/Cargo.toml | 2 +- sw/picardy/src/main.rs | 29 ++++++++++++++++++----------- sw/picardy/src/state.rs | 5 +++-- sw/picardy/src/ui.rs | 7 ++++--- 5 files changed, 48 insertions(+), 30 deletions(-) (limited to 'sw') diff --git a/sw/picardy/Cargo.lock b/sw/picardy/Cargo.lock index bc7632c..bc9fcba 100644 --- a/sw/picardy/Cargo.lock +++ b/sw/picardy/Cargo.lock @@ -11,9 +11,9 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "as-slice" @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "cortex-m" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be99930c99669a74d986f7fd2162085498b322e6daae8ef63a97cc9ac1dc73c" +checksum = "88cdafeafba636c00c467ded7f1587210725a1adfab0c24028a7844b87738263" dependencies = [ "aligned", "bare-metal", @@ -92,13 +92,22 @@ dependencies = [ [[package]] name = "cortex-m-semihosting" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "113ef0ecffee2b62b58f9380f4469099b30e9f9cbee2804771b4203ba1762cfa" +checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc" dependencies = [ "cortex-m", ] +[[package]] +name = "embedded-dma" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c8c02e4347a0267ca60813c952017f4c5948c232474c6010a381a337f1bda4" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "embedded-hal" version = "0.2.4" @@ -161,9 +170,9 @@ checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" [[package]] name = "panic-semihosting" -version = "0.5.3" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03864ac862876c16a308f5286f4aa217f1a69ac45df87ad3cd2847f818a642c" +checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec" dependencies = [ "cortex-m", "cortex-m-semihosting", @@ -272,14 +281,14 @@ dependencies = [ [[package]] name = "stm32f1xx-hal" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af9b9e5d7c2901ee39fc9527412327a1fe08f1d84e9d7f4b3497448e655e5098" +checksum = "bf679de34580d2f8806d9a6384c110b6df002404e1ff024cf8d567c91df4d4b2" dependencies = [ - "as-slice", "cast", "cortex-m", "cortex-m-rt", + "embedded-dma", "embedded-hal", "nb 0.1.3", "stm32f1", @@ -288,9 +297,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.44" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fdd" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" dependencies = [ "proc-macro2", "quote", diff --git a/sw/picardy/Cargo.toml b/sw/picardy/Cargo.toml index 26b794d..5b15949 100644 --- a/sw/picardy/Cargo.toml +++ b/sw/picardy/Cargo.toml @@ -15,7 +15,7 @@ cortex-m-semihosting = "0.3" panic-semihosting = "0.5" nb = "1.0" #stm32h7 = { version = "0.9", features = ["stm32h743", "rt"] } -stm32f1xx-hal = { version = "0.6", features = ["rt", "stm32f103"] } +stm32f1xx-hal = { version = "0.7", features = ["rt", "stm32f103"] } embedded-hal = { version = "0.2", features = [] } shared-bus = { version = "0.2", features = ["cortex-m"] } hd44780-driver = { path = "../deps/hd44780-driver"} diff --git a/sw/picardy/src/main.rs b/sw/picardy/src/main.rs index 0d27f7a..04f8fa5 100644 --- a/sw/picardy/src/main.rs +++ b/sw/picardy/src/main.rs @@ -55,6 +55,9 @@ use state::*; static mut TIMER1: MaybeUninit> = MaybeUninit::uninit(); static mut DECISECONDS_COUNTER: MaybeUninit = MaybeUninit::uninit(); +fn time_now() -> usize { + cortex_m::interrupt::free(|_cs| unsafe { *DECISECONDS_COUNTER.as_ptr() }) +} #[cortex_m_rt::entry] fn main() -> ! { @@ -78,10 +81,10 @@ fn main() -> ! { // Buttons as analog inputs (multi-level) let mic_sw1 = gpioa.pa3.into_analog(&mut gpioa.crl); let mic_sw2 = gpioa.pa4.into_analog(&mut gpioa.crl); - let pb0 = gpiob.pb0.into_analog(&mut gpiob.crl); - let pb1 = gpiob.pb1.into_analog(&mut gpiob.crl); - let pb12 = gpiob.pb12.into_pull_up_input(&mut gpiob.crh); - let pb13 = gpiob.pb13.into_pull_up_input(&mut gpiob.crh); + let pb0 = gpiob.pb0.into_analog(&mut gpiob.crl); // BTN1 Buttons B D C + let pb1 = gpiob.pb1.into_analog(&mut gpiob.crl); // BTN0 Buttons A F + let pb12 = gpiob.pb12.into_pull_up_input(&mut gpiob.crh); // BTN2 Button E + let pb13 = gpiob.pb13.into_pull_up_input(&mut gpiob.crh); // BTN3 Button G let pc15 = gpioc.pc15.into_pull_up_input(&mut gpioc.crh); let adc1 = dp.ADC1; let mut ui = ui::UI::new(mic_sw1, mic_sw2, pb0, pb1, adc1, &mut rcc.apb2, &clocks, pb12, pb13, pc15); @@ -177,13 +180,17 @@ fn main() -> ! { let mut last_encoder_count = qei.count(); - let deciseconds_counter = unsafe { &mut *DECISECONDS_COUNTER.as_mut_ptr() }; - *deciseconds_counter = 0; + { + let deciseconds_counter = unsafe { &mut *DECISECONDS_COUNTER.as_mut_ptr() }; + *deciseconds_counter = 0; + } - let timer1 = unsafe { &mut *TIMER1.as_mut_ptr() }; - *timer1 = Timer::tim1(dp.TIM1, &clocks, &mut rcc.apb2) - .start_count_down(10.hz()); - timer1.listen(Event::Update); + { + let timer1 = unsafe { &mut *TIMER1.as_mut_ptr() }; + *timer1 = Timer::tim1(dp.TIM1, &clocks, &mut rcc.apb2) + .start_count_down(10.hz()); + timer1.listen(Event::Update); + } unsafe { pac::NVIC::unmask(pac::Interrupt::TIM1_UP); } @@ -257,7 +264,7 @@ fn main() -> ! { } }; - let t_now = unsafe { *DECISECONDS_COUNTER.as_ptr() }; + let t_now = time_now(); if state.sequence_state != next_state && last_sequence_state_change + 1 <= t_now { update_disp_required = true; diff --git a/sw/picardy/src/state.rs b/sw/picardy/src/state.rs index b29b8b4..bfe0212 100644 --- a/sw/picardy/src/state.rs +++ b/sw/picardy/src/state.rs @@ -1,8 +1,8 @@ pub const VHF_BAND_EDGE : u32 = 144_000_000; pub const VHF_INITIAL_VFO : u32 = 144_300_000; pub const VHF_LO : u32 = 114_286_400; -pub const BFO_LSB : u32 = 6_000_700 + 2_200; -pub const BFO_USB : u32 = 6_000_700 - 2_200; +pub const BFO_LSB : u32 = 6_000_700 + 1_100; +pub const BFO_USB : u32 = 6_000_700 - 1_100; // Defines which parameter is changed by the encoder #[derive(Clone, Copy, PartialEq, Eq)] @@ -12,6 +12,7 @@ pub enum UISelection { IFShift, } +#[derive(Clone, Copy)] pub enum VFOSelection { A, B, diff --git a/sw/picardy/src/ui.rs b/sw/picardy/src/ui.rs index baaebf0..e3f172e 100644 --- a/sw/picardy/src/ui.rs +++ b/sw/picardy/src/ui.rs @@ -252,9 +252,10 @@ impl UI { result.ptt = button_updates.ptt; if button_updates.a { - state.vfo_sel = match state.vfo_sel { - VFOSelection::A => VFOSelection::B, - VFOSelection::B => VFOSelection::A, + state.vfo_sel = match (state.ui_sel, state.vfo_sel) { + (UISelection::VFO, VFOSelection::A) => VFOSelection::B, + (UISelection::VFO, VFOSelection::B) => VFOSelection::A, + _ => state.vfo_sel.clone(), }; state.ui_sel = UISelection::VFO; result.display_update = true; -- cgit v1.2.3