Skip to content

Commit

Permalink
Migrated static RTC Mutex into SharedResources
Browse files Browse the repository at this point in the history
  • Loading branch information
BLM16 committed Oct 5, 2024
1 parent 38173cf commit 4e16ca6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 59 deletions.
8 changes: 2 additions & 6 deletions boards/pressure/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ fn panic() -> ! {
cortex_m::asm::udf()
}

static RTC: Mutex<RefCell<Option<rtc::Rtc>>> = Mutex::new(RefCell::new(None));

#[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])]
mod app {

Expand All @@ -65,6 +63,7 @@ mod app {
can_command_manager: CanCommandManager,
can_data_manager: CanDataManager,
sbg_power: PB4<Output<PushPull>>,
rtc: rtc::Rtc,

Check warning on line 66 in boards/pressure/src/main.rs

View workflow job for this annotation

GitHub Actions / All

field `rtc` is never read
}
#[local]
struct LocalResources {
Expand Down Expand Up @@ -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);

Expand All @@ -321,6 +316,7 @@ mod app {
can_command_manager,
can_data_manager,
sbg_power,
rtc,
},
LocalResources {
led_red,
Expand Down
8 changes: 2 additions & 6 deletions boards/strain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ fn panic() -> ! {
cortex_m::asm::udf()
}

static RTC: Mutex<RefCell<Option<rtc::Rtc>>> = Mutex::new(RefCell::new(None));

#[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])]
mod app {

Expand All @@ -65,6 +63,7 @@ mod app {
can_command_manager: CanCommandManager,
can_data_manager: CanDataManager,
sbg_power: PB4<Output<PushPull>>,
rtc: rtc::Rtc,

Check warning on line 66 in boards/strain/src/main.rs

View workflow job for this annotation

GitHub Actions / All

field `rtc` is never read
}
#[local]
struct LocalResources {
Expand Down Expand Up @@ -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);

Expand All @@ -321,6 +316,7 @@ mod app {
can_command_manager,
can_data_manager,
sbg_power,
rtc,
},
LocalResources {
led_red,
Expand Down
8 changes: 2 additions & 6 deletions boards/temperature/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ fn panic() -> ! {
cortex_m::asm::udf()
}

static RTC: Mutex<RefCell<Option<rtc::Rtc>>> = Mutex::new(RefCell::new(None));

#[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])]
mod app {

Expand All @@ -65,6 +63,7 @@ mod app {
can_command_manager: CanCommandManager,
can_data_manager: CanDataManager,
sbg_power: PB4<Output<PushPull>>,
rtc: rtc::Rtc,
}
#[local]
struct LocalResources {
Expand Down Expand Up @@ -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);

Expand All @@ -321,6 +316,7 @@ mod app {
can_command_manager,
can_data_manager,
sbg_power,
rtc,
},
LocalResources {
led_red,
Expand Down
35 changes: 0 additions & 35 deletions crates/common-arm-test/Cargo.toml

This file was deleted.

8 changes: 2 additions & 6 deletions examples/rtic-playground/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ fn panic() -> ! {
cortex_m::asm::udf()
}

static RTC: Mutex<RefCell<Option<rtc::Rtc>>> = Mutex::new(RefCell::new(None));

#[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, dispatchers = [EXTI0, EXTI1, EXTI2, SPI3, SPI2])]
mod app {

Expand All @@ -65,6 +63,7 @@ mod app {
can_command_manager: CanCommandManager,
can_data_manager: CanDataManager,
sbg_power: PB4<Output<PushPull>>,
rtc: rtc::Rtc,

Check warning on line 66 in examples/rtic-playground/src/main.rs

View workflow job for this annotation

GitHub Actions / All

field `rtc` is never read
}
#[local]
struct LocalResources {
Expand Down Expand Up @@ -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);

Expand All @@ -321,6 +316,7 @@ mod app {
can_command_manager,
can_data_manager,
sbg_power,
rtc,
},
LocalResources {
led_red,
Expand Down

0 comments on commit 4e16ca6

Please sign in to comment.