From 4e16ca6dabaf65f551ac38b29bd1f92e500a13ca Mon Sep 17 00:00:00 2001 From: Bradley Myers Date: Sat, 5 Oct 2024 13:59:49 -0400 Subject: [PATCH] Migrated static RTC Mutex into SharedResources --- boards/pressure/src/main.rs | 8 ++----- boards/strain/src/main.rs | 8 ++----- boards/temperature/src/main.rs | 8 ++----- crates/common-arm-test/Cargo.toml | 35 ---------------------------- examples/rtic-playground/src/main.rs | 8 ++----- 5 files changed, 8 insertions(+), 59 deletions(-) delete mode 100644 crates/common-arm-test/Cargo.toml diff --git a/boards/pressure/src/main.rs b/boards/pressure/src/main.rs index a39429a..5ca0dbb 100644 --- a/boards/pressure/src/main.rs +++ b/boards/pressure/src/main.rs @@ -43,8 +43,6 @@ fn panic() -> ! { cortex_m::asm::udf() } -static RTC: Mutex>> = Mutex::new(RefCell::new(None)); - #[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])] mod app { @@ -65,6 +63,7 @@ mod app { can_command_manager: CanCommandManager, can_data_manager: CanDataManager, sbg_power: PB4>, + rtc: rtc::Rtc, } #[local] struct LocalResources { @@ -294,10 +293,6 @@ mod app { rtc.set_date_time(now); - cortex_m::interrupt::free(|cs| { - RTC.borrow(cs).replace(Some(rtc)); - }); - /* Monotonic clock */ Mono::start(core.SYST, 200_000_000); @@ -321,6 +316,7 @@ mod app { can_command_manager, can_data_manager, sbg_power, + rtc, }, LocalResources { led_red, diff --git a/boards/strain/src/main.rs b/boards/strain/src/main.rs index a39429a..5ca0dbb 100644 --- a/boards/strain/src/main.rs +++ b/boards/strain/src/main.rs @@ -43,8 +43,6 @@ fn panic() -> ! { cortex_m::asm::udf() } -static RTC: Mutex>> = Mutex::new(RefCell::new(None)); - #[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])] mod app { @@ -65,6 +63,7 @@ mod app { can_command_manager: CanCommandManager, can_data_manager: CanDataManager, sbg_power: PB4>, + rtc: rtc::Rtc, } #[local] struct LocalResources { @@ -294,10 +293,6 @@ mod app { rtc.set_date_time(now); - cortex_m::interrupt::free(|cs| { - RTC.borrow(cs).replace(Some(rtc)); - }); - /* Monotonic clock */ Mono::start(core.SYST, 200_000_000); @@ -321,6 +316,7 @@ mod app { can_command_manager, can_data_manager, sbg_power, + rtc, }, LocalResources { led_red, diff --git a/boards/temperature/src/main.rs b/boards/temperature/src/main.rs index a39429a..5ca0dbb 100644 --- a/boards/temperature/src/main.rs +++ b/boards/temperature/src/main.rs @@ -43,8 +43,6 @@ fn panic() -> ! { cortex_m::asm::udf() } -static RTC: Mutex>> = Mutex::new(RefCell::new(None)); - #[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])] mod app { @@ -65,6 +63,7 @@ mod app { can_command_manager: CanCommandManager, can_data_manager: CanDataManager, sbg_power: PB4>, + rtc: rtc::Rtc, } #[local] struct LocalResources { @@ -294,10 +293,6 @@ mod app { rtc.set_date_time(now); - cortex_m::interrupt::free(|cs| { - RTC.borrow(cs).replace(Some(rtc)); - }); - /* Monotonic clock */ Mono::start(core.SYST, 200_000_000); @@ -321,6 +316,7 @@ mod app { can_command_manager, can_data_manager, sbg_power, + rtc, }, LocalResources { led_red, diff --git a/crates/common-arm-test/Cargo.toml b/crates/common-arm-test/Cargo.toml deleted file mode 100644 index 40674af..0000000 --- a/crates/common-arm-test/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "common-arm-test" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -common-arm = { path = "../common-arm" } -cortex-m = { workspace = true } -cortex-m-rt = "0.7.3" -defmt = "0.3.4" -defmt-rtt = "0.4.0" -defmt-test = "0.3.0" -panic-probe = { version = "0.3.1", features = ["print-defmt" ] } - -# A [[test]] section is needed for each file in "tests" -[[test]] -name = "sd" -harness = false - -[features] -# set logging levels here -default = [ - # in tests, enable all logs - "defmt-trace", -] - -# do NOT modify these features -defmt-default = [] -defmt-trace = [] -defmt-debug = [] -defmt-info = [] -defmt-warn = [] -defmt-error = [] diff --git a/examples/rtic-playground/src/main.rs b/examples/rtic-playground/src/main.rs index a39429a..5ca0dbb 100644 --- a/examples/rtic-playground/src/main.rs +++ b/examples/rtic-playground/src/main.rs @@ -43,8 +43,6 @@ fn panic() -> ! { cortex_m::asm::udf() } -static RTC: Mutex>> = Mutex::new(RefCell::new(None)); - #[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])] mod app { @@ -65,6 +63,7 @@ mod app { can_command_manager: CanCommandManager, can_data_manager: CanDataManager, sbg_power: PB4>, + rtc: rtc::Rtc, } #[local] struct LocalResources { @@ -294,10 +293,6 @@ mod app { rtc.set_date_time(now); - cortex_m::interrupt::free(|cs| { - RTC.borrow(cs).replace(Some(rtc)); - }); - /* Monotonic clock */ Mono::start(core.SYST, 200_000_000); @@ -321,6 +316,7 @@ mod app { can_command_manager, can_data_manager, sbg_power, + rtc, }, LocalResources { led_red,