From d82b8e4d07c3435e760267e1e2b5694955e7fee9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Apr 2025 15:36:19 +0200 Subject: [PATCH] cleaned up dependencies --- examples/simple/examples/timer-ticks.rs | 6 ++---- va108xx-embassy/Cargo.toml | 2 +- va108xx-hal/Cargo.toml | 20 ++------------------ va108xx-hal/src/clock.rs | 20 -------------------- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/examples/simple/examples/timer-ticks.rs b/examples/simple/examples/timer-ticks.rs index 362075f..4640485 100644 --- a/examples/simple/examples/timer-ticks.rs +++ b/examples/simple/examples/timer-ticks.rs @@ -10,7 +10,6 @@ use panic_probe as _; use defmt_rtt as _; use portable_atomic::AtomicU32; use va108xx_hal::{ - clock::{get_sys_clock, set_sys_clock}, pac::{self, interrupt}, prelude::*, time::Hertz, @@ -32,7 +31,6 @@ fn main() -> ! { let mut delay = CountdownTimer::new(dp.tim2, 50.MHz()); let mut last_ms = 0; defmt::info!("-- Vorago system ticks using timers --"); - set_sys_clock(50.MHz()); let lib_type = LibType::Hal; match lib_type { LibType::Pac => { @@ -67,10 +65,10 @@ fn main() -> ! { } } LibType::Hal => { - let mut ms_timer = CountdownTimer::new(dp.tim0, get_sys_clock().unwrap()); + let mut ms_timer = CountdownTimer::new(dp.tim0, 50.MHz()); ms_timer.enable_interrupt(InterruptConfig::new(interrupt::OC0, true, true)); ms_timer.start(1.kHz()); - let mut second_timer = CountdownTimer::new(dp.tim1, get_sys_clock().unwrap()); + let mut second_timer = CountdownTimer::new(dp.tim1, 50.MHz()); second_timer.enable_interrupt(InterruptConfig::new(interrupt::OC1, true, true)); second_timer.start(1.Hz()); } diff --git a/va108xx-embassy/Cargo.toml b/va108xx-embassy/Cargo.toml index f8ed4ae..d956c7c 100644 --- a/va108xx-embassy/Cargo.toml +++ b/va108xx-embassy/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["no-std", "hal", "cortex-m", "vorago", "va108xx"] categories = ["aerospace", "embedded", "no-std", "hardware-support"] [dependencies] -vorago-shared-periphs = { git = "https://egit.irs.uni-stuttgart.de/rust/vorago-shared-periphs.git", features = ["vor1x"] } +vorago-shared-periphs = { path = "../../vorago-shared-periphs", features = ["vor1x"] } va108xx-hal = { path = "../va108xx-hal" } [features] diff --git a/va108xx-hal/Cargo.toml b/va108xx-hal/Cargo.toml index d5943a0..34eb3ba 100644 --- a/va108xx-hal/Cargo.toml +++ b/va108xx-hal/Cargo.toml @@ -13,26 +13,10 @@ categories = ["aerospace", "embedded", "no-std", "hardware-support"] [dependencies] cortex-m = { version = "0.7", features = ["critical-section-single-core"]} cortex-m-rt = "0.7" -nb = "1" -paste = "1" -vorago-shared-periphs = { git = "https://egit.irs.uni-stuttgart.de/rust/vorago-shared-periphs.git", features = ["vor1x"] } -embedded-hal = "1" -embedded-hal-async = "1" -embedded-hal-nb = "1" -embedded-io = "0.6" -embedded-io-async = "0.6" +vorago-shared-periphs = { path = "../../vorago-shared-periphs", features = ["vor1x"] } fugit = "0.3" -typenum = "1" -critical-section = "1" -delegate = ">=0.12, <=0.13" -heapless = "0.8" -static_cell = "2" thiserror = { version = "2", default-features = false } -void = { version = "1", default-features = false } -once_cell = { version = "1", default-features = false } va108xx = { version = "0.5", default-features = false, features = ["critical-section", "defmt"] } -embassy-sync = "0.6" - defmt = { version = "0.3", optional = true } [target.'cfg(all(target_arch = "arm", target_os = "none"))'.dependencies] @@ -43,7 +27,7 @@ portable-atomic = "1" [features] default = ["rt"] rt = ["va108xx/rt"] -defmt = ["dep:defmt", "fugit/defmt", "embedded-hal/defmt-03", "vorago-shared-periphs/defmt"] +defmt = ["dep:defmt", "vorago-shared-periphs/defmt"] [package.metadata.docs.rs] all-features = true diff --git a/va108xx-hal/src/clock.rs b/va108xx-hal/src/clock.rs index 6e9970a..6f28b49 100644 --- a/va108xx-hal/src/clock.rs +++ b/va108xx-hal/src/clock.rs @@ -1,29 +1,9 @@ //! # API for clock related functionality //! //! This also includes functionality to enable the peripheral clocks -use crate::time::Hertz; -use cortex_m::interrupt::{self, Mutex}; -use once_cell::unsync::OnceCell; - pub use vorago_shared_periphs::gpio::FilterClkSel; pub use vorago_shared_periphs::sysconfig::{disable_peripheral_clock, enable_peripheral_clock}; -static SYS_CLOCK: Mutex> = Mutex::new(OnceCell::new()); - -/// The Vorago in powered by an external clock which might have different frequencies. -/// The clock can be set here so it can be used by other software components as well. -/// The clock can be set exactly once -pub fn set_sys_clock(freq: impl Into) { - interrupt::free(|cs| { - SYS_CLOCK.borrow(cs).set(freq.into()).ok(); - }) -} - -/// Returns the configured system clock -pub fn get_sys_clock() -> Option { - interrupt::free(|cs| SYS_CLOCK.borrow(cs).get().copied()) -} - pub fn set_clk_div_register(syscfg: &mut va108xx::Sysconfig, clk_sel: FilterClkSel, div: u32) { match clk_sel { FilterClkSel::SysClk => (),