time: add more tick rates, use 1mhz as default.

This commit is contained in:
Dario Nieuwenhuis
2022-09-02 00:58:31 +02:00
parent 835b69456d
commit 5327b9c289
38 changed files with 418 additions and 135 deletions

View File

@ -10,7 +10,7 @@ src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32
# TODO: sdmmc
# TODO: net
# TODO: subghz
features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-time/tick-32768hz"]
features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any"]
flavors = [
{ regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" },
{ regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" },

View File

@ -7,7 +7,7 @@ use atomic_polyfill::{AtomicU32, AtomicU8};
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::blocking_mutex::Mutex;
use embassy_time::driver::{AlarmHandle, Driver};
use embassy_time::TICKS_PER_SECOND;
use embassy_time::TICK_HZ;
use stm32_metapac::timer::regs;
use crate::interrupt::{CriticalSection, InterruptExt};
@ -153,7 +153,7 @@ impl RtcDriver {
r.cr1().modify(|w| w.set_cen(false));
r.cnt().write(|w| w.set_cnt(0));
let psc = timer_freq.0 / TICKS_PER_SECOND as u32 - 1;
let psc = timer_freq.0 / TICK_HZ as u32 - 1;
let psc: u16 = match psc.try_into() {
Err(_) => panic!("psc division overflow: {}", psc),
Ok(n) => n,