// src/sleep/sleep.rs

use cortex_m::Peripherals;

#[derive(Clone, Copy, Debug, defmt::Format)]
pub enum SleepEntry {
    Wfi,
    Wfe,
}

pub fn enter_sleep_mode(entry: SleepEntry) {
    let mut core = unsafe { Peripherals::steal() };
    core.SCB.clear_sleepdeep();

    match entry {
        SleepEntry::Wfi => cortex_m::asm::wfi(),
        SleepEntry::Wfe => cortex_m::asm::wfe(),
    }
}
