Use monotonic implementation from HAL instead of Systick
This commit is contained in:
parent
f0e73df651
commit
586773a68d
|
@ -52,12 +52,9 @@ dependencies = [
|
|||
"cortex-m-rt",
|
||||
"cortex-m-rtic",
|
||||
"cortex-m-semihosting",
|
||||
"embedded-hal",
|
||||
"embedded-midi",
|
||||
"fugit",
|
||||
"panic-semihosting",
|
||||
"stm32f1xx-hal",
|
||||
"systick-monotonic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -451,6 +448,7 @@ dependencies = [
|
|||
"fugit",
|
||||
"fugit-timer",
|
||||
"nb 1.1.0",
|
||||
"rtic-monotonic",
|
||||
"stm32-usbd",
|
||||
"stm32f1",
|
||||
"void",
|
||||
|
@ -467,17 +465,6 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "systick-monotonic"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67fb822d5c615a0ae3a4795ee5b1d06381c7faf488d861c0a4fa8e6a88d5ff84"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"fugit",
|
||||
"rtic-monotonic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
|
|
|
@ -5,23 +5,16 @@ authors = ["toon <toon@c3d2.de>"]
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# core
|
||||
cortex-m = "0.7.7"
|
||||
cortex-m-rt = "0.7.3"
|
||||
# panic handler
|
||||
cortex-m-semihosting = "0.5.0"
|
||||
panic-semihosting = "0.6.0"
|
||||
# real time for the masses
|
||||
cortex-m-rtic = "1.1.4"
|
||||
fugit = "0.3.7"
|
||||
systick-monotonic = "1.0.1"
|
||||
embedded-hal = "0.2.7"
|
||||
embedded-midi = "0.1.2"
|
||||
|
||||
# hardware abstraction layer
|
||||
[dependencies.stm32f1xx-hal]
|
||||
version = "0.10.0"
|
||||
features = [ "rt", "stm32f103", "medium" ]
|
||||
features = [ "rtic", "stm32f103", "medium" ]
|
||||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = "z"
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -3,17 +3,18 @@
|
|||
|
||||
use panic_semihosting as _;
|
||||
use rtic::app;
|
||||
use systick_monotonic::*;
|
||||
use stm32f1xx_hal::{
|
||||
adc,
|
||||
dma,
|
||||
pac::ADC1,
|
||||
pac::{ADC1, TIM2},
|
||||
timer::monotonic::MonoTimer,
|
||||
prelude::*,
|
||||
gpio::{self, Analog},
|
||||
serial::{Config, Serial},
|
||||
};
|
||||
use embedded_midi::{self, MidiMessage};
|
||||
|
||||
// Number of control knobs
|
||||
const CONTROL_CNT: usize = 9;
|
||||
|
||||
// Concrete midi out type alias
|
||||
|
@ -82,8 +83,8 @@ mod app {
|
|||
midi_out: MidiOut,
|
||||
}
|
||||
|
||||
#[monotonic(priority = 1, binds = SysTick, default = true)]
|
||||
type MonoTimer = Systick<1000>;
|
||||
#[monotonic(priority = 1, binds = TIM2, default = true)]
|
||||
type MainMono = MonoTimer<TIM2, 1_000>;
|
||||
|
||||
#[init(local = [buffer: [u16; CONTROL_CNT] = [0u16; CONTROL_CNT]])]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
|
@ -98,7 +99,8 @@ mod app {
|
|||
.adcclk(2.MHz())
|
||||
.freeze(&mut flash.acr);
|
||||
|
||||
let mono = Systick::new(cx.core.SYST, 48_000_000);
|
||||
// Timer with 1 ms resolution
|
||||
let mono = cx.device.TIM2.monotonic::<1_000>(&clocks);
|
||||
|
||||
let mut afio = cx.device.AFIO.constrain();
|
||||
|
||||
|
@ -199,7 +201,7 @@ mod app {
|
|||
}
|
||||
}
|
||||
});
|
||||
read_adc::spawn_after(systick_monotonic::ExtU64::millis(100)).unwrap();
|
||||
read_adc::spawn_after(100.millis()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue