aboutsummaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-03 15:07:57 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-03 15:07:57 +0100
commitaa999d4c4bdf4ede912f3aa833e7045ccfcca4b1 (patch)
tree76b114d14cbdec0cb8f74b06e17a0cc662b74fff /sw
parent9684038c8ed57e11177e9b786f38bdfcb8fa4c93 (diff)
downloadpicardy-aa999d4c4bdf4ede912f3aa833e7045ccfcca4b1.tar.gz
picardy-aa999d4c4bdf4ede912f3aa833e7045ccfcca4b1.tar.bz2
picardy-aa999d4c4bdf4ede912f3aa833e7045ccfcca4b1.zip
Update eval-clock-cw-tx prerequisites
Diffstat (limited to 'sw')
-rw-r--r--sw/eval-clock-cw-tx/Cargo.lock200
-rw-r--r--sw/eval-clock-cw-tx/Cargo.toml11
-rw-r--r--sw/eval-clock-cw-tx/Makefile2
-rw-r--r--sw/eval-clock-cw-tx/src/cw.rs13
-rw-r--r--sw/eval-clock-cw-tx/src/main.rs122
-rw-r--r--sw/eval-clock-cw-tx/src/ui.rs18
-rw-r--r--sw/eval-clock-cw-tx/src/usb.rs30
7 files changed, 221 insertions, 175 deletions
diff --git a/sw/eval-clock-cw-tx/Cargo.lock b/sw/eval-clock-cw-tx/Cargo.lock
index e0152f2..51094b1 100644
--- a/sw/eval-clock-cw-tx/Cargo.lock
+++ b/sw/eval-clock-cw-tx/Cargo.lock
@@ -1,19 +1,21 @@
# 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"
@@ -23,11 +25,20 @@ checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0"
dependencies = [
"generic-array 0.12.4",
"generic-array 0.13.3",
- "generic-array 0.14.4",
+ "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.2",
+ "cortex-m 0.7.7",
"volatile-register",
]
[[package]]
name = "cortex-m"
-version = "0.7.2"
+version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "643a210c1bdc23d0db511e2a576082f4ff4dcae9d0c37f50b431b8f8439d6d6b"
+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.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "980c9d0233a909f355ed297ef122f257942de5e0a2cb1c39f60684b65bcb90fb"
+checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1"
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",
@@ -109,23 +128,38 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc"
dependencies = [
- "cortex-m 0.7.2",
+ "cortex-m 0.7.7",
+]
+
+[[package]]
+name = "cortex-m-semihosting"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c23234600452033cc77e4b761e740e02d2c4168e11dbf36ab14a0f58973592b0"
+dependencies = [
+ "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",
@@ -136,9 +170,9 @@ name = "eval_clock_cw_tx"
version = "0.1.0"
dependencies = [
"arrayvec",
- "cortex-m 0.6.7",
+ "cortex-m 0.7.7",
"cortex-m-rt",
- "cortex-m-semihosting",
+ "cortex-m-semihosting 0.5.0",
"embedded-hal",
"hd44780-driver",
"nb 1.0.0",
@@ -151,6 +185,31 @@ dependencies = [
]
[[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.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a"
+
+[[package]]
name = "generic-array"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -170,9 +229,9 @@ dependencies = [
[[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",
@@ -206,35 +265,29 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec"
dependencies = [
- "cortex-m 0.7.2",
- "cortex-m-semihosting",
+ "cortex-m 0.7.7",
+ "cortex-m-semihosting 0.3.7",
]
[[package]]
name = "proc-macro2"
-version = "1.0.24"
+version = "1.0.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
+checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
dependencies = [
- "unicode-xid",
+ "unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.9"
+version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
+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"
@@ -260,12 +313,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]]
@@ -284,39 +339,42 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "stm32-usbd"
-version = "0.5.1"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70d13eca735cae37df697f599777b000cc0ee924df8452f2b4bfaa6798ab0338"
+checksum = "c6c94998f166d66b210a164648a0b7866428d8f1e0740bf8a4c5edd89d4750c1"
dependencies = [
- "cortex-m 0.6.7",
+ "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",
@@ -324,32 +382,32 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.64"
+version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
- "unicode-xid",
+ "unicode-ident",
]
[[package]]
name = "typenum"
-version = "1.13.0"
+version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
+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 = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
+checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
[[package]]
name = "usb-device"
-version = "0.2.8"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6be90410d4772074ea49525e2e753b65920b94b57eee21a6ef7b6a6fe6296245"
+checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508"
[[package]]
name = "usbd-serial"
@@ -370,9 +428,9 @@ checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
[[package]]
name = "version_check"
-version = "0.9.3"
+version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "void"
@@ -382,9 +440,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/eval-clock-cw-tx/Cargo.toml b/sw/eval-clock-cw-tx/Cargo.toml
index ebf3e20..d83b9b2 100644
--- a/sw/eval-clock-cw-tx/Cargo.toml
+++ b/sw/eval-clock-cw-tx/Cargo.toml
@@ -6,16 +6,15 @@ edition = "2018"
license = "MIT"
[dependencies]
-arrayvec = { version = "0.5", default-features = false, features = [] }
+arrayvec = { version = "0.7", 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"
+cortex-m = "0.7"
+cortex-m-rt = "0.7"
+cortex-m-semihosting = "0.5"
panic-semihosting = "0.5"
nb = "1.0"
#stm32h7 = { version = "0.9", features = ["stm32h743", "rt"] }
-stm32f1xx-hal = { version = "0.7", features = ["rt", "stm32f103", "medium", "stm32-usbd"] }
+stm32f1xx-hal = { version = "0.10", features = ["rt", "stm32f103", "medium", "stm32-usbd"] }
embedded-hal = { version = "0.2", features = [] }
shared-bus = { version = "0.2", features = ["cortex-m"] }
hd44780-driver = { path = "../deps/hd44780-driver"}
diff --git a/sw/eval-clock-cw-tx/Makefile b/sw/eval-clock-cw-tx/Makefile
index 1679b79..f58614d 100644
--- a/sw/eval-clock-cw-tx/Makefile
+++ b/sw/eval-clock-cw-tx/Makefile
@@ -2,7 +2,7 @@
OPENOCD := openocd
OPENOCD_OPT := -f interface/stlink.cfg -f target/stm32f1x.cfg
-BIN := target/thumbv7m-none-eabi/debug/picardy
+BIN := target/thumbv7m-none-eabi/debug/eval_clock_cw_tx
# Build and flash in release mode
all:
diff --git a/sw/eval-clock-cw-tx/src/cw.rs b/sw/eval-clock-cw-tx/src/cw.rs
index 337a3ab..23a74a9 100644
--- a/sw/eval-clock-cw-tx/src/cw.rs
+++ b/sw/eval-clock-cw-tx/src/cw.rs
@@ -1,25 +1,18 @@
//! CW output using PWM on PA8, TIM1 CH1
use stm32f1xx_hal::{
- prelude::*,
timer,
pac::TIM1,
- gpio::gpioa::*,
- gpio::{Alternate, PushPull},
- afio::MAPR,
- pwm,
};
-const SIDETONE_FREQ : u32 = 1000;
+pub const SIDETONE_FREQ : u32 = 1000;
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/eval-clock-cw-tx/src/main.rs b/sw/eval-clock-cw-tx/src/main.rs
index 2dce7bc..b256926 100644
--- a/sw/eval-clock-cw-tx/src/main.rs
+++ b/sw/eval-clock-cw-tx/src/main.rs
@@ -1,7 +1,7 @@
/*
The MIT License (MIT)
- Copyright (c) 2021 Matthias P. Braendli
+ Copyright (c) 2023 Matthias P. Braendli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -24,7 +24,6 @@
#![no_main]
#![no_std]
-
use core::mem::MaybeUninit;
use cortex_m_rt::ExceptionFrame;
use cortex_m_semihosting::hprintln;
@@ -36,13 +35,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;
@@ -57,12 +54,12 @@ use state::*;
const TICKS_PER_SECOND : u32 = 100;
struct SharedWithISR {
- state : State,
- last_sequence_state_change : u32,
- feldhell_ptt : bool,
- cw_ptt_timestamp : u32,
- cw_key_out_n : gpio::gpioa::PA15<gpio::Output<gpio::PushPull>>,
- ui : ui::UI,
+ state: State,
+ last_sequence_state_change: u32,
+ feldhell_ptt: bool,
+ cw_ptt_timestamp: u32,
+ cw_key_out_n: 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>>,
@@ -73,7 +70,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 {
@@ -86,27 +83,27 @@ 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(48.mhz())
- .pclk1(24.mhz())
- .adcclk(2.mhz())
+ .use_hse(16.MHz())
+ .sysclk(48.MHz())
+ .pclk1(24.MHz())
+ .adcclk(2.MHz())
.freeze(&mut flash.acr);
assert!(clocks.usbclk_valid());
- 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();
- let mut timer4 = Timer::tim4(dp.TIM4, &clocks, &mut rcc.apb1)
- .start_count_down(usb::TIMER_FREQ_HZ.hz());
+ let mut timer4 = Timer::new(dp.TIM4, &clocks).counter_hz();
+ timer4.start(usb::TIMER_FREQ_HZ.Hz()).unwrap();
timer4.listen(Event::Update);
let usb_dm = gpioa.pa11;
@@ -124,8 +121,9 @@ fn main() -> ! {
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
@@ -133,16 +131,16 @@ fn main() -> ! {
// 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_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 seq_switch = gpiob.pb5.into_push_pull_output_with_state(&mut gpiob.crl, gpio::State::Low);
+ let cw_key_out_n = pa15.into_push_pull_output_with_state(&mut gpioa.crh, PinState::High);
+ let ptt_out = pb3.into_push_pull_output_with_state(&mut gpiob.crl, PinState::Low);
+ let seq_switch = gpiob.pb5.into_push_pull_output_with_state(&mut gpiob.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 I2C1 to be used for Si5351 and display
@@ -154,10 +152,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,
@@ -183,20 +180,20 @@ fn main() -> ! {
lcd.set_cursor_pos(0, &mut delay).unwrap();
lcd.write_str(" HB9EGM ", &mut delay).unwrap();
lcd.set_cursor_pos(40, &mut delay).unwrap();
- lcd.write_str(" 30m CW TX 2021 ", &mut delay).unwrap();
+ lcd.write_str(" 30m TX 2023 ", &mut delay).unwrap();
delay.delay_ms(1_500u16);
let mut siclock = {
let shared = unsafe { &mut *SHARED.as_mut_ptr() };
*shared = SharedWithISR {
- state : State::new(),
- last_sequence_state_change : 0,
- feldhell_ptt : false,
- cw_ptt_timestamp : 0,
+ state: State::new(),
+ last_sequence_state_change: 0,
+ feldhell_ptt: false,
+ cw_ptt_timestamp: 0,
cw_key_out_n,
ui,
cw_pwm,
- cw_keyer : cw::Keyer::new(12, TICKS_PER_SECOND),
+ cw_keyer: cw::Keyer::new(12, TICKS_PER_SECOND),
cw_paddle_tip, cw_paddle_ring, ptt_out, seq_switch, led,
};
@@ -214,8 +211,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);
}
@@ -248,6 +245,7 @@ fn main() -> ! {
(*shared).state.clone()
});
+
let encoder_count : u16 = qei.count();
if encoder_count != last_encoder_count {
let delta = encoder_count.wrapping_sub(last_encoder_count);
@@ -296,7 +294,7 @@ fn main() -> ! {
#[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;
@@ -308,8 +306,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();
let cw_ptt_delay : u32 = TICKS_PER_SECOND * 800 / 1000;
let ptt = match shared.state.mode {
@@ -335,8 +333,8 @@ fn TIM2() {
let next_state = match shared.state.sequence_state {
SequenceState::Rx => {
- shared.ptt_out.set_low().unwrap();
- shared.seq_switch.set_low().unwrap();
+ shared.ptt_out.set_low();
+ shared.seq_switch.set_low();
if ptt {
if shared.state.mode == Mode::FeldHell {
SequenceState::Switching(SequenceMode::FeldHell)
@@ -350,8 +348,8 @@ fn TIM2() {
}
},
SequenceState::Switching(m) => {
- shared.ptt_out.set_low().unwrap();
- shared.seq_switch.set_high().unwrap();
+ shared.ptt_out.set_low();
+ shared.seq_switch.set_high();
if ptt {
SequenceState::Tx(m)
}
@@ -360,8 +358,8 @@ fn TIM2() {
}
},
SequenceState::Tx(m) => {
- shared.ptt_out.set_high().unwrap();
- shared.seq_switch.set_high().unwrap();
+ shared.ptt_out.set_high();
+ shared.seq_switch.set_high();
if ptt {
SequenceState::Tx(m)
}
@@ -375,22 +373,22 @@ fn TIM2() {
SequenceState::Tx(SequenceMode::CW) => {
if cw_beep {
shared.cw_pwm.on();
- shared.cw_key_out_n.set_low().unwrap();
- shared.led.set_low().unwrap();
+ shared.cw_key_out_n.set_low();
+ shared.led.set_low();
}
else {
shared.cw_pwm.off();
- shared.cw_key_out_n.set_high().unwrap();
- shared.led.set_high().unwrap();
+ shared.cw_key_out_n.set_high();
+ shared.led.set_high();
}
},
SequenceState::Tx(SequenceMode::FeldHell) => {
- shared.led.set_low().unwrap();
+ shared.led.set_low();
},
_ => {
- shared.led.set_high().unwrap();
+ shared.led.set_high();
shared.cw_pwm.off();
- shared.cw_key_out_n.set_high().unwrap();
+ shared.cw_key_out_n.set_high();
},
}
@@ -404,20 +402,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/eval-clock-cw-tx/src/ui.rs b/sw/eval-clock-cw-tx/src/ui.rs
index 809dd8d..9f3d985 100644
--- a/sw/eval-clock-cw-tx/src/ui.rs
+++ b/sw/eval-clock-cw-tx/src/ui.rs
@@ -28,13 +28,12 @@ use core::fmt;
use core::fmt::Write;
use stm32f1xx_hal::{
- delay::Delay,
gpio::gpiob::*,
gpio::gpioc::*,
gpio::{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)]
@@ -125,8 +124,8 @@ impl UI {
fn read_buttons(&mut self) -> ButtonState {
let mut buttons = ButtonState::default();
- let b0_low = self.btn0.is_low().unwrap();
- let b1_low = self.btn1.is_low().unwrap();
+ let b0_low = self.btn0.is_low();
+ let b1_low = self.btn1.is_low();
if b0_low && b1_low {
buttons.e = true;
@@ -138,15 +137,15 @@ impl UI {
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;
}
@@ -239,9 +238,10 @@ impl UI {
}
}
-pub fn update_disp<T: hd44780_driver::bus::DataBus>(lcd: &mut HD44780<T>, state: &State, delay: &mut Delay)
+pub fn update_disp<T: hd44780_driver::bus::DataBus, D: DelayUs<u16> + DelayMs<u8>>(
+ lcd: &mut HD44780<T>, state: &State, delay: &mut D)
{
- let mut string = arrayvec::ArrayString::<[_; 16]>::new();
+ let mut string = arrayvec::ArrayString::<16>::new();
let disp_freq = state.vfo_display() as i32;
write!(string, "{:<05}.{:<03} ", disp_freq / 1000, disp_freq % 1000).unwrap();
diff --git a/sw/eval-clock-cw-tx/src/usb.rs b/sw/eval-clock-cw-tx/src/usb.rs
index a74ac20..d75c287 100644
--- a/sw/eval-clock-cw-tx/src/usb.rs
+++ b/sw/eval-clock-cw-tx/src/usb.rs
@@ -4,7 +4,7 @@ use stm32f1xx_hal::{
pac,
pac::{interrupt, Interrupt},
gpio,
- timer::CountDownTimer,
+ timer::{CounterHz, Event},
};
use stm32f1xx_hal::usb::{Peripheral, UsbBus, UsbBusType};
use usb_device::{bus::UsbBusAllocator, prelude::*};
@@ -19,7 +19,7 @@ pub const TIMER_FREQ_HZ : u32 = 245;
const FELDHELL_PATTERN_LEN : usize = 16;
const MESSAGE_LEN : usize = 64;
-static mut FELDHELL_TIMER: MaybeUninit<CountDownTimer<pac::TIM4>> = MaybeUninit::uninit();
+static mut FELDHELL_TIMER: MaybeUninit<CounterHz<pac::TIM4>> = MaybeUninit::uninit();
static mut SHARED_USB: MaybeUninit<USBSharedData> = MaybeUninit::uninit();
@@ -63,8 +63,8 @@ enum Font {
// Shared between application and interrupt context
struct USBSharedData {
- incoming_buf: ArrayVec::<[u8; MESSAGE_LEN]>,
- feldhell_pattern: ArrayVec::<[u16; FELDHELL_PATTERN_LEN]>, // FELDHELL columns to transmit
+ incoming_buf: ArrayVec::<u8, MESSAGE_LEN>,
+ feldhell_pattern: ArrayVec::<u16, FELDHELL_PATTERN_LEN>, // FELDHELL columns to transmit
}
pub fn enable_interrupts() {
@@ -80,13 +80,13 @@ pub struct USBData {
pub frequency : u32,
pub transmit : bool,
- current_str : ArrayVec::<[u8; 96]>,
+ current_str : ArrayVec::<u8, 96>,
send_ix : usize,
}
impl USBData {
pub fn new(
- timer4: CountDownTimer<pac::TIM4>,
+ timer4: CounterHz<pac::TIM4>,
usb: pac::USB,
pin_dm: gpio::gpioa::PA11<gpio::Input<gpio::Floating>>,
pin_dp: gpio::gpioa::PA12<gpio::Input<gpio::Floating>>) -> USBData {
@@ -148,7 +148,7 @@ impl USBData {
let in_message = cortex_m::interrupt::free(|_cs| {
let shared_usb = unsafe { &mut *SHARED_USB.as_mut_ptr() };
- let mut message = ArrayString::<[u8; MESSAGE_LEN]>::new();
+ let mut message = ArrayString::<MESSAGE_LEN>::new();
let mut split_at = None;
for (i, c) in shared_usb.incoming_buf.iter().enumerate() {
@@ -168,7 +168,7 @@ impl USBData {
write!(&mut message, "{}", core::str::from_utf8(front).unwrap()).ok();
- let mut keep = ArrayVec::<[u8; MESSAGE_LEN]>::new();
+ let mut keep = ArrayVec::<u8, MESSAGE_LEN>::new();
keep.try_extend_from_slice(back).ok();
shared_usb.incoming_buf.clear();
@@ -185,7 +185,7 @@ impl USBData {
}
});
- let mut outgoing = ArrayVec::<[u8; MESSAGE_LEN]>::new();
+ let mut outgoing = ArrayVec::<u8, MESSAGE_LEN>::new();
if let Some(m) = in_message {
if m.as_str() == "tx\n" {
outgoing.try_extend_from_slice(b"TX ok\n").ok();
@@ -212,7 +212,7 @@ impl USBData {
outgoing.try_extend_from_slice(b"fontn ok\n").ok();
}
else if m.chars().nth(0).unwrap() == 'f' {
- let mut as_str = ArrayString::<[u8; MESSAGE_LEN]>::new();
+ let mut as_str = ArrayString::<MESSAGE_LEN>::new();
for c in m.chars().skip(1) {
as_str.push(c);
@@ -269,7 +269,7 @@ impl USBData {
if self.send_ix >= self.current_str.len() {
cortex_m::interrupt::free(|_cs| {
let serial = unsafe { USB_SERIAL.as_mut().unwrap() };
- let mut outgoing = ArrayString::<[u8; 16]>::new();
+ let mut outgoing = ArrayString::<16>::new();
write!(&mut outgoing, "FH sent {}\n", self.send_ix).ok();
serial.write(outgoing.as_bytes()).ok();
});
@@ -322,7 +322,7 @@ fn usb_interrupt() {
#[interrupt]
fn TIM4() {
let timer = unsafe { &mut *FELDHELL_TIMER.as_mut_ptr() };
- timer.clear_update_interrupt_flag();
+ timer.clear_interrupt(Event::Update);
let shared_usb = unsafe { &mut *SHARED_USB.as_mut_ptr() };
while shared_usb.feldhell_pattern.len() > 0 && shared_usb.feldhell_pattern.as_slice()[0] == 0 {
@@ -335,13 +335,11 @@ fn TIM4() {
let shared = unsafe { &mut *crate::SHARED.as_mut_ptr() };
- use embedded_hal::digital::v2::OutputPin;
-
if shared.state.allow_feldhell_keying() && (*pat & 0b1) == 0b1 {
- shared.cw_key_out_n.set_low().unwrap();
+ shared.cw_key_out_n.set_low();
}
else {
- shared.cw_key_out_n.set_high().unwrap();
+ shared.cw_key_out_n.set_high();
}
*pat >>= 1;