Skip to content

feature request: add support for StopMode #1041

Closed
@smmoosavi

Description

@smmoosavi

To have low power mode, we should enter StopMode. Before entering stop mode, we should disable the SYST interrupt, and enable it when exiting stop mode.

We also need to fast-forward the SYSTICK_CNT value to keep it in sync with the real time.

Systick::disable_interrupt();

 // we will wake up every second with RTC interrupt. so we can estimate the number of ticks we miss when we are sleep
let duration = estimate_duration();
Systick::fast_forward(duration);

let mut stop_mode = PWR::stop_mode(&mut scb, &mut rcc, config);
stop_mode.enter(); // program stop here until the RTC interrupt 

Systick::enable_interrupt();
pub fn fast_forward(duration: u32) {
  SYSTICK_CNT.fetch_add(duration, Ordering::AcqRel);
}

pub fn disable_interrupt() {
  Self::systick().disable_interrupt();
}


pub fn enable_interrupt() {
  Self::systick().enable_interrupt();
}

I am not sure where is the best place for these functions to be implemented, SystickBackend or another struct/trait.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions