Skip to content

Commit

Permalink
Merge pull request #5 from uorocketry/remove_mutex
Browse files Browse the repository at this point in the history
Migrated static RTC Mutex into SharedResources
  • Loading branch information
NoahSprenger authored Oct 5, 2024
2 parents c108137 + 4e16ca6 commit 0968981
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 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 @@ -292,10 +291,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 @@ -319,6 +314,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 @@ -292,10 +291,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 @@ -319,6 +314,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,

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

View workflow job for this annotation

GitHub Actions / All

field `rtc` is never read
}
#[local]
struct LocalResources {
Expand Down Expand Up @@ -292,10 +291,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 @@ -319,6 +314,7 @@ mod app {
can_command_manager,
can_data_manager,
sbg_power,
rtc,
},
LocalResources {
led_red,
Expand Down
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,
}
#[local]
struct LocalResources {
Expand Down Expand Up @@ -292,10 +291,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 @@ -319,6 +314,7 @@ mod app {
can_command_manager,
can_data_manager,
sbg_power,
rtc,
},
LocalResources {
led_red,
Expand Down

0 comments on commit 0968981

Please sign in to comment.