Skip to content

Commit

Permalink
Provide init resources to board during shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
surban committed Feb 23, 2024
1 parent d5429b7 commit 30e1833
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions openemc-firmware/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ pub trait Board {
fn power_on(&mut self, _afio: &mut afio::Parts, _delay: &mut Delay) {}

/// Shutdown the system and go to sleep.
fn shutdown(&mut self) -> ! {
defmt::info!("entering standby mode");
fn shutdown(&mut self, _res: InitResources) -> ! {
boot::enter_standby();
}

Expand Down
2 changes: 2 additions & 0 deletions openemc-firmware/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ pub fn reset(bkp: &mut BackupDomain) -> ! {

/// Enters standby mode.
pub fn enter_standby() -> ! {
defmt::info!("preparing to enter standby mode");

let mut cp = unsafe { cortex_m::Peripherals::steal() };
let dp = unsafe { Peripherals::steal() };

Expand Down
3 changes: 2 additions & 1 deletion openemc-firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ mod app {
if bi.boot_reason == BootReason::PowerOff as _ {
board.set_power_led(false);
BootReason::PowerOn.set(&mut bkp);
board.shutdown();
let init_resources = InitResources { afio: &mut afio, delay: &mut delay };
board.shutdown(init_resources);
}
blink_charging!(board, delay, watchman, 3);

Expand Down

0 comments on commit 30e1833

Please sign in to comment.