diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-01-14 15:20:24 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-01-14 15:20:24 +0100 |
commit | 5385d3a08251e5bb982e10e39ac8c67a5d66ac04 (patch) | |
tree | 32ac70a7a1579f998347a346b1ebc3ffadd7d5ff | |
parent | 98451b507792db8602c87707f14c1f1bfbcd7357 (diff) | |
download | picardy-5385d3a08251e5bb982e10e39ac8c67a5d66ac04.tar.gz picardy-5385d3a08251e5bb982e10e39ac8c67a5d66ac04.tar.bz2 picardy-5385d3a08251e5bb982e10e39ac8c67a5d66ac04.zip |
Update picardy sw to latest dependencies
-rw-r--r-- | sw/picardy/Cargo.lock | 219 | ||||
-rw-r--r-- | sw/picardy/Cargo.toml | 17 | ||||
-rw-r--r-- | sw/picardy/src/cw.rs | 13 | ||||
-rw-r--r-- | sw/picardy/src/main.rs | 129 | ||||
-rw-r--r-- | sw/picardy/src/ui.rs | 22 |
5 files changed, 226 insertions, 174 deletions
diff --git a/sw/picardy/Cargo.lock b/sw/picardy/Cargo.lock index 485ecc2..53d82dd 100644 --- a/sw/picardy/Cargo.lock +++ b/sw/picardy/Cargo.lock @@ -1,33 +1,44 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aligned" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19796bd8d477f1a9d4ac2465b464a8b1359474f06a96bb3cda650b4fca309bf" +checksum = "3a785a543aea40f5e4e2e93bb2655d31bc21bb391fff65697150973e383f16bb" dependencies = [ "as-slice", ] [[package]] name = "arrayvec" -version = "0.5.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "as-slice" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4d1c23475b74e3672afa8c2be22040b8b7783ad9b461021144ed10a46bb0e6" +checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" dependencies = [ - "generic-array 0.12.3", - "generic-array 0.13.2", - "generic-array 0.14.4", + "generic-array 0.12.4", + "generic-array 0.13.3", + "generic-array 0.14.6", "stable_deref_trait", ] [[package]] +name = "atomic-polyfill" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" +dependencies = [ + "critical-section", +] + +[[package]] name = "bare-metal" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -37,6 +48,12 @@ dependencies = [ ] [[package]] +name = "bare-metal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" + +[[package]] name = "bitfield" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -44,17 +61,20 @@ checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "cast" -version = "0.2.3" +name = "bxcan" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +checksum = "40ac3d0c0a542d0ab5521211f873f62706a7136df415676f676d347e5a41dd80" dependencies = [ - "rustc_version", + "bitflags", + "embedded-hal", + "nb 1.0.0", + "vcell", ] [[package]] @@ -64,19 +84,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9075300b07c6a56263b9b582c214d0ff037b00d45ec9fde1cc711490c56f1bb9" dependencies = [ "aligned", - "bare-metal", + "bare-metal 0.2.5", "bitfield", - "cortex-m 0.7.1", + "cortex-m 0.7.7", "volatile-register", ] [[package]] name = "cortex-m" -version = "0.7.1" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0b756a8bffc56025de45218a48ff9b801180440c0ee49a722b32d49dcebc771" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ - "bare-metal", + "bare-metal 0.2.5", "bitfield", "embedded-hal", "volatile-register", @@ -84,19 +104,18 @@ dependencies = [ [[package]] name = "cortex-m-rt" -version = "0.6.13" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "980c9d0233a909f355ed297ef122f257942de5e0a2cb1c39f60684b65bcb90fb" +checksum = "d6d3328b8b5534f0c90acd66b68950f2763b37e0173cac4d8b4937c4a80761f9" dependencies = [ "cortex-m-rt-macros", - "r0", ] [[package]] name = "cortex-m-rt-macros" -version = "0.1.8" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4717562afbba06e760d34451919f5c3bf3ac15c7bb897e8b04862a7428378647" +checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" dependencies = [ "proc-macro2", "quote", @@ -105,55 +124,86 @@ dependencies = [ [[package]] name = "cortex-m-semihosting" -version = "0.3.7" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc" +checksum = "c23234600452033cc77e4b761e740e02d2c4168e11dbf36ab14a0f58973592b0" dependencies = [ - "cortex-m 0.7.1", + "cortex-m 0.7.7", ] [[package]] +name = "critical-section" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" + +[[package]] name = "embedded-dma" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c8c02e4347a0267ca60813c952017f4c5948c232474c6010a381a337f1bda4" +checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446" dependencies = [ "stable_deref_trait", ] [[package]] name = "embedded-hal" -version = "0.2.4" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" dependencies = [ "nb 0.1.3", "void", ] [[package]] +name = "fugit" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab17bb279def6720d058cb6c052249938e7f99260ab534879281a95367a87e5" +dependencies = [ + "gcd", +] + +[[package]] +name = "fugit-timer" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9607bfc4c388f9d629704f56ede4a007546cad417b3bcd6fc7c87dc7edce04a" +dependencies = [ + "fugit", + "nb 1.0.0", +] + +[[package]] +name = "gcd" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1b088ad0a967aa29540456b82fc8903f854775d33f71e9709c4efb3dfbfd2" + +[[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] [[package]] name = "generic-array" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd" +checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" dependencies = [ "typenum", ] [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -183,11 +233,11 @@ checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" [[package]] name = "panic-semihosting" -version = "0.5.6" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec" +checksum = "ee8a3e1233d9073d76a870223512ce4eeea43c067a94a445c13bd6d792d7b1ab" dependencies = [ - "cortex-m 0.7.1", + "cortex-m 0.7.7", "cortex-m-semihosting", ] @@ -196,7 +246,7 @@ name = "picardy" version = "0.1.0" dependencies = [ "arrayvec", - "cortex-m 0.6.7", + "cortex-m 0.7.7", "cortex-m-rt", "cortex-m-semihosting", "embedded-hal", @@ -210,29 +260,23 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.8" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] [[package]] -name = "r0" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" - -[[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -258,12 +302,14 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "shared-bus" -version = "0.2.0" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f42e140835229dea9c0b2498d2c88afe52ed2bd42a7cc6068c95adb5134b541" +checksum = "05f8438a40b91c8b9531c664e9680c55b92bd78cd6809a8b45b4512b1e5765f2" dependencies = [ + "atomic-polyfill", "cortex-m 0.6.7", "embedded-hal", + "nb 0.1.3", ] [[package]] @@ -281,55 +327,76 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] +name = "stm32-usbd" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6c94998f166d66b210a164648a0b7866428d8f1e0740bf8a4c5edd89d4750c1" +dependencies = [ + "cortex-m 0.7.7", + "usb-device", + "vcell", +] + +[[package]] name = "stm32f1" -version = "0.11.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "849b1e8d9bcfd792c9d9178cf86165d299a661c26e35d9322ae9382d3f3fe460" +checksum = "f2dc80735831c28fe85384e1e28428fb6d201f67c696e369a239ed9c5eba369d" dependencies = [ - "bare-metal", - "cortex-m 0.6.7", + "bare-metal 1.0.0", + "cortex-m 0.7.7", "cortex-m-rt", "vcell", ] [[package]] name = "stm32f1xx-hal" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf679de34580d2f8806d9a6384c110b6df002404e1ff024cf8d567c91df4d4b2" +checksum = "30845662b9ce46a2ec04da97666a2b32458bee5032bb0452d0caf1536a96a542" dependencies = [ - "cast", - "cortex-m 0.6.7", + "bitflags", + "bxcan", + "cortex-m 0.7.7", "cortex-m-rt", "embedded-dma", "embedded-hal", - "nb 0.1.3", + "fugit", + "fugit-timer", + "nb 1.0.0", + "stm32-usbd", "stm32f1", "void", ] [[package]] name = "syn" -version = "1.0.60" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "typenum" -version = "1.12.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] -name = "unicode-xid" -version = "0.2.1" +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "usb-device" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508" [[package]] name = "vcell" @@ -339,9 +406,9 @@ checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -351,9 +418,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "volatile-register" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" +checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" dependencies = [ "vcell", ] diff --git a/sw/picardy/Cargo.toml b/sw/picardy/Cargo.toml index e773d57..2c649ca 100644 --- a/sw/picardy/Cargo.toml +++ b/sw/picardy/Cargo.toml @@ -2,20 +2,17 @@ name = "picardy" version = "0.1.0" authors = ["Matthias P. Braendli <matthias.braendli@mpb.li>"] -edition = "2018" +edition = "2021" license = "MIT" [dependencies] -arrayvec = { version = "0.5", default-features = false, features = [] } -# alloc-cortex-m = "0.3" # requires nightly -cortex-m = "0.6" -cortex-m-rt = "0.6" -# consider cortex-m-rtfm -cortex-m-semihosting = "0.3" -panic-semihosting = "0.5" +arrayvec = { version = "0.7", default-features = false, features = [] } +cortex-m = "0.7" +cortex-m-rt = "0.7" +cortex-m-semihosting = "0.5" +panic-semihosting = "0.6" nb = "1.0" -#stm32h7 = { version = "0.9", features = ["stm32h743", "rt"] } -stm32f1xx-hal = { version = "0.7", features = ["rt", "stm32f103", "medium"] } +stm32f1xx-hal = { version = "0.10", features = ["rt", "stm32f103", "medium"] } 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/cw.rs b/sw/picardy/src/cw.rs index 508b939..4656f81 100644 --- a/sw/picardy/src/cw.rs +++ b/sw/picardy/src/cw.rs @@ -1,13 +1,8 @@ //! CW output using PWM on PA8, TIM1 CH1 use stm32f1xx_hal::{ - prelude::*, timer, pac::TIM1, - gpio::gpioa::*, - gpio::{Alternate, PushPull}, - afio::MAPR, - pwm, }; const CW_MAPPING : [u8; 50] = [ //{{{ @@ -75,16 +70,14 @@ const CW_MAPPING : [u8; 50] = [ //{{{ const CW_MACRO : &[u8; 28] = b"CQ DE HB9EGM HB9EGM HB9EGM K"; -const SIDETONE_FREQ : u32 = 800; +pub const SIDETONE_FREQ : u32 = 800; pub struct CWPWM { - channel : pwm::PwmChannel<TIM1, pwm::C1>, + channel : timer::pwm::PwmChannel<TIM1, { timer::pwm::C1 }>, } impl CWPWM { - pub fn new(pa8: PA8<Alternate<PushPull>>, tim1: timer::Timer<TIM1>, mapr: &mut MAPR) -> Self { - let pwm = tim1.pwm(pa8, mapr, SIDETONE_FREQ.hz()); - let mut channel = pwm.split(); + pub fn new(mut channel: timer::pwm::PwmChannel<TIM1, { timer::pwm::C1 }>) -> Self { channel.enable(); channel.set_duty(0); CWPWM { channel } diff --git a/sw/picardy/src/main.rs b/sw/picardy/src/main.rs index 2e7d9a1..3beefee 100644 --- a/sw/picardy/src/main.rs +++ b/sw/picardy/src/main.rs @@ -37,13 +37,11 @@ use stm32f1xx_hal::{ pac::interrupt, i2c, gpio, - delay::Delay, - timer::{CountDownTimer, Timer, Event}, + gpio::PinState, + timer::{CounterHz, Timer, Event}, qei::QeiOptions, }; -use embedded_hal::digital::v2::OutputPin; -use embedded_hal::digital::v2::InputPin; use hd44780_driver::{Cursor, CursorBlink, Display, DisplayMode, HD44780}; pub mod ui; @@ -75,7 +73,7 @@ struct SharedWithISR { } static mut SHARED: MaybeUninit<SharedWithISR> = MaybeUninit::uninit(); -static mut CLOCK_TIMER: MaybeUninit<CountDownTimer<pac::TIM2>> = MaybeUninit::uninit(); +static mut CLOCK_TIMER: MaybeUninit<CounterHz<pac::TIM2>> = MaybeUninit::uninit(); static mut TICK_COUNTER: MaybeUninit<u32> = MaybeUninit::uninit(); fn ticks_now() -> u32 { @@ -94,21 +92,21 @@ fn main() -> ! { let dp = pac::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); - let mut rcc = dp.RCC.constrain(); - let mut afio = dp.AFIO.constrain(&mut rcc.apb2); + let rcc = dp.RCC.constrain(); + let mut afio = dp.AFIO.constrain(); let clocks = rcc.cfgr - .use_hse(16.mhz()) - .sysclk(32.mhz()) - .pclk1(24.mhz()) - .adcclk(2.mhz()) + .use_hse(16.MHz()) + .sysclk(32.MHz()) + .pclk1(24.MHz()) + .adcclk(2.MHz()) .freeze(&mut flash.acr); - let mut delay = Delay::new(cp.SYST, clocks); + let mut delay = cp.SYST.delay(&clocks); delay.delay_ms(200u16); - let mut gpioa = dp.GPIOA.split(&mut rcc.apb2); - let mut gpiob = dp.GPIOB.split(&mut rcc.apb2); - let mut gpioc = dp.GPIOC.split(&mut rcc.apb2); + let mut gpioa = dp.GPIOA.split(); + let mut gpiob = dp.GPIOB.split(); + let mut gpioc = dp.GPIOC.split(); // Buttons as analog inputs (multi-level) let mic_sw1 = gpioa.pa3.into_analog(&mut gpioa.crl); @@ -119,39 +117,40 @@ fn main() -> ! { 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 ui = ui::UI::new(mic_sw1, mic_sw2, pb0, pb1, adc1, &mut rcc.apb2, &clocks, pb12, pb13, pc15); + let ui = ui::UI::new(mic_sw1, mic_sw2, pb0, pb1, adc1, &clocks, pb12, pb13, pc15); let cw_pwm = { let pa8 = gpioa.pa8.into_alternate_push_pull(&mut gpioa.crh); // CW PWM output using TIM1 Ch1 - let tim1 = Timer::tim1(dp.TIM1, &clocks, &mut rcc.apb2); - cw::CWPWM::new(pa8, tim1, &mut afio.mapr) + let pwm = dp.TIM1.pwm_hz(pa8, &mut afio.mapr, cw::SIDETONE_FREQ.Hz(), &clocks); + let channel = pwm.split(); + cw::CWPWM::new(channel) }; let cw_paddle_tip = gpiob.pb8.into_pull_up_input(&mut gpiob.crh); // CW paddle tip let cw_paddle_ring = gpiob.pb9.into_pull_up_input(&mut gpiob.crh); // CW paddle ring let mut s_meter = gpioa.pa5.into_analog(&mut gpioa.crl); - let mut adc2 = adc::Adc::adc2(dp.ADC2, &mut rcc.apb2, clocks); + let mut adc2 = adc::Adc::adc2(dp.ADC2, clocks); let mut last_s_meter_update_time = 0; // Configure PB14 as output. (LED) let mut led = gpiob.pb14.into_push_pull_output(&mut gpiob.crh); - led.set_low().unwrap(); + led.set_low(); 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 cw_key_n = pa15.into_open_drain_output_with_state(&mut gpioa.crh, PinState::High); - let seq0n = pb3.into_push_pull_output_with_state(&mut gpiob.crl, gpio::State::High); - let seq1_pa = pb4.into_push_pull_output_with_state(&mut gpiob.crl, gpio::State::Low); - let seq2_switch = gpiob.pb5.into_push_pull_output_with_state(&mut gpiob.crl, gpio::State::Low); + let seq0n = pb3.into_push_pull_output_with_state(&mut gpiob.crl, PinState::High); + let seq1_pa = pb4.into_push_pull_output_with_state(&mut gpiob.crl, PinState::Low); + let seq2_switch = gpiob.pb5.into_push_pull_output_with_state(&mut gpiob.crl, PinState::Low); - let mute_spkr = gpioa.pa2.into_push_pull_output_with_state(&mut gpioa.crl, gpio::State::Low); - let mute_micn = gpioa.pa1.into_push_pull_output_with_state(&mut gpioa.crl, gpio::State::Low); + let mute_spkr = gpioa.pa2.into_push_pull_output_with_state(&mut gpioa.crl, PinState::Low); + let mute_micn = gpioa.pa1.into_push_pull_output_with_state(&mut gpioa.crl, PinState::Low); let c1 = gpioa.pa6; let c2 = gpioa.pa7; - let qei = Timer::tim3(dp.TIM3, &clocks, &mut rcc.apb1) + let qei = Timer::new(dp.TIM3, &clocks) .qei((c1, c2), &mut afio.mapr, QeiOptions::default()); // Configure I2C2 for display @@ -162,11 +161,10 @@ fn main() -> ! { dp.I2C2, (scl2, sda2), i2c::Mode::Fast { - frequency: 400_000.hz(), + frequency: 400_000.Hz(), duty_cycle: i2c::DutyCycle::Ratio2to1, }, clocks, - &mut rcc.apb1, /* start_timeout_us */ 1000, /* start_retries */ 10, /* addr_timeout_us */ 1000, @@ -205,10 +203,9 @@ fn main() -> ! { (scl, sda), &mut afio.mapr, i2c::Mode::Standard { - frequency: 100_000.hz(), + frequency: 100_000.Hz(), }, clocks, - &mut rcc.apb1, /* start_timeout_us */ 1000, /* start_retries */ 10, /* addr_timeout_us */ 1000, @@ -245,8 +242,8 @@ fn main() -> ! { { let timer = unsafe { &mut *CLOCK_TIMER.as_mut_ptr() }; - *timer = Timer::tim2(dp.TIM2, &clocks, &mut rcc.apb1) - .start_count_down(TICKS_PER_SECOND.hz()); + *timer = Timer::new(dp.TIM2, &clocks).counter_hz(); + timer.start(TICKS_PER_SECOND.Hz()).unwrap(); timer.listen(Event::Update); } @@ -350,7 +347,7 @@ fn s_meter_from_adc(adc : u16) -> u8 { #[interrupt] fn TIM2() { let timer = unsafe { &mut *CLOCK_TIMER.as_mut_ptr() }; - timer.clear_update_interrupt_flag(); + timer.clear_interrupt(Event::Update); let ticks = unsafe { &mut *TICK_COUNTER.as_mut_ptr() }; *ticks += 1; @@ -362,8 +359,8 @@ fn TIM2() { shared.state.update_disp_counter += 1; } - let cw_paddle_tip_low = shared.cw_paddle_tip.is_low().unwrap(); - let cw_paddle_ring_low = shared.cw_paddle_ring.is_low().unwrap(); + let cw_paddle_tip_low = shared.cw_paddle_tip.is_low(); + let cw_paddle_ring_low = shared.cw_paddle_ring.is_low(); if cw_paddle_tip_low || cw_paddle_ring_low { shared.state.send_tone = false; @@ -393,10 +390,10 @@ fn TIM2() { let next_state = match shared.state.sequence_state { SequenceState::Rx => { - shared.mute_spkr.set_low().unwrap(); - shared.mute_micn.set_low().unwrap(); - shared.seq2_switch.set_low().unwrap(); - shared.seq0n.set_high().unwrap(); + shared.mute_spkr.set_low(); + shared.mute_micn.set_low(); + shared.seq2_switch.set_low(); + shared.seq0n.set_high(); if button_result.ptt || cw_ptt { SequenceState::MutingSpkr } @@ -405,10 +402,10 @@ fn TIM2() { } }, SequenceState::MutingSpkr => { - shared.mute_spkr.set_high().unwrap(); - shared.mute_micn.set_low().unwrap(); - shared.seq2_switch.set_low().unwrap(); - shared.seq0n.set_high().unwrap(); + shared.mute_spkr.set_high(); + shared.mute_micn.set_low(); + shared.seq2_switch.set_low(); + shared.seq0n.set_high(); if button_result.ptt { SequenceState::SwitchingSSB } @@ -420,11 +417,11 @@ fn TIM2() { } }, SequenceState::SwitchingSSB => { - shared.mute_spkr.set_high().unwrap(); - shared.seq2_switch.set_high().unwrap(); - shared.seq0n.set_low().unwrap(); - shared.seq1_pa.set_low().unwrap(); - shared.mute_micn.set_high().unwrap(); + shared.mute_spkr.set_high(); + shared.seq2_switch.set_high(); + shared.seq0n.set_low(); + shared.seq1_pa.set_low(); + shared.mute_micn.set_high(); if button_result.ptt { SequenceState::TxSSB @@ -434,11 +431,11 @@ fn TIM2() { } }, SequenceState::SwitchingCW => { - shared.mute_spkr.set_high().unwrap(); - shared.seq2_switch.set_high().unwrap(); - shared.seq0n.set_low().unwrap(); - shared.seq1_pa.set_low().unwrap(); - shared.mute_micn.set_low().unwrap(); + shared.mute_spkr.set_high(); + shared.seq2_switch.set_high(); + shared.seq0n.set_low(); + shared.seq1_pa.set_low(); + shared.mute_micn.set_low(); if cw_ptt { SequenceState::TxCW } @@ -447,7 +444,7 @@ fn TIM2() { } }, SequenceState::TxSSB => { - shared.seq1_pa.set_high().unwrap(); + shared.seq1_pa.set_high(); if button_result.ptt { SequenceState::TxSSB @@ -457,7 +454,7 @@ fn TIM2() { } }, SequenceState::TxCW => { - shared.seq1_pa.set_high().unwrap(); + shared.seq1_pa.set_high(); if cw_ptt { SequenceState::TxCW @@ -471,20 +468,20 @@ fn TIM2() { match shared.state.sequence_state { SequenceState::TxCW => { if cw_beep { - shared.led.set_low().unwrap(); + shared.led.set_low(); shared.cw_pwm.on(); - shared.cw_key_n.set_low().unwrap(); + shared.cw_key_n.set_low(); } else { - shared.led.set_high().unwrap(); + shared.led.set_high(); shared.cw_pwm.off(); - shared.cw_key_n.set_high().unwrap(); + shared.cw_key_n.set_high(); } }, _ => { - shared.led.set_high().unwrap(); + shared.led.set_high(); shared.cw_pwm.off(); - shared.cw_key_n.set_high().unwrap(); + shared.cw_key_n.set_high(); }, } @@ -498,20 +495,20 @@ fn TIM2() { #[allow(non_snake_case)] #[cortex_m_rt::exception] -fn HardFault(ef: &ExceptionFrame) -> ! { +unsafe fn HardFault(ef: &ExceptionFrame) -> ! { let periph = unsafe { cortex_m::Peripherals::steal() }; let hfsr = periph.SCB.hfsr.read(); let cfsr = periph.SCB.cfsr.read(); - hprintln!("Hardfault {:x} {:x} at {:x}\n", hfsr, cfsr, ef.pc).unwrap(); + hprintln!("Hardfault {:x} {:x} at {:x}\n", hfsr, cfsr, ef.pc()); cortex_m::asm::bkpt(); loop { } } #[allow(non_snake_case)] #[cortex_m_rt::exception] -fn DefaultHandler(irqn: i16) { - hprintln!("Unhandled exception (IRQn = {})", irqn).unwrap(); +unsafe fn DefaultHandler(irqn: i16) { + hprintln!("Unhandled exception (IRQn = {})", irqn); cortex_m::asm::bkpt(); loop { } } diff --git a/sw/picardy/src/ui.rs b/sw/picardy/src/ui.rs index ad85a3e..ad29722 100644 --- a/sw/picardy/src/ui.rs +++ b/sw/picardy/src/ui.rs @@ -30,16 +30,15 @@ use core::fmt::Write; use stm32f1xx_hal::{ prelude::*, adc, - rcc::{APB2, Clocks}, + rcc::Clocks, stm32::ADC1, - delay::Delay, gpio::gpioa::*, gpio::gpiob::*, gpio::gpioc::*, gpio::{Analog, Input, PullUp, Floating}, }; -use embedded_hal::digital::v2::InputPin; +use embedded_hal::blocking::delay::{DelayMs, DelayUs}; use hd44780_driver::HD44780; #[derive(PartialEq, Eq, Clone, Copy)] @@ -124,13 +123,12 @@ impl UI { pb0: PB0<Input<Floating>>, pb1: PB1<Input<Floating>>, adc1: ADC1, - mut apb2: &mut APB2, clocks: &Clocks, pb12: PB12<Input<PullUp>>, pb13: PB13<Input<PullUp>>, pc15 : PC15<Input<PullUp>>) -> UI { - let adc1 = adc::Adc::adc1(adc1, &mut apb2, *clocks); + let adc1 = adc::Adc::adc1(adc1, *clocks); UI { btn0 : pb1, @@ -152,23 +150,23 @@ impl UI { //let mic_sw2_value: u16 = self.adc.read(&mut self.mic_sw2).unwrap(); buttons.ptt = mic_sw1_value < 500; - if self.btn0.is_low().unwrap() { + if self.btn0.is_low() { buttons.a = true; } - if self.btn1.is_low().unwrap() { + if self.btn1.is_low() { buttons.b = true; } - if self.btn2.is_low().unwrap() { + if self.btn2.is_low() { buttons.c = true; } - if self.btn3.is_low().unwrap() { + if self.btn3.is_low() { buttons.d = true; } - if self.btn_enc.is_low().unwrap() { + if self.btn_enc.is_low() { buttons.enc = true; } @@ -315,9 +313,9 @@ impl UI { } } -pub fn update_disp<T: hd44780_driver::bus::DataBus>(lcd: &mut HD44780<T>, state: &State, delay: &mut Delay, s_meter_value: u8, bfo_tune_fail: bool) +pub fn update_disp<T: hd44780_driver::bus::DataBus, D: DelayUs<u16> + DelayMs<u8>>(lcd: &mut HD44780<T>, state: &State, delay: &mut D, s_meter_value: u8, bfo_tune_fail: bool) { - let mut string = arrayvec::ArrayString::<[_; 16]>::new(); + let mut string = arrayvec::ArrayString::<16>::new(); /* Shorten the QRG to avoid using three digits for nothing */ let disp_freq = (state.vhf_qrg() as i32) - (VHF_BAND_EDGE as i32); |