implementation of stops and reorganization of the codebase

This commit is contained in:
Priec
2025-12-12 22:25:36 +01:00
parent 72a731abef
commit 2c9433cb84
6 changed files with 156 additions and 128 deletions

View File

@@ -0,0 +1,55 @@
// src/sleep/stop.rs
/// How to enter STOPx mode (STOP0STOP3)
#[derive(Debug, Clone, Copy, PartialEq, Eq, defmt::Format)]
pub enum StopEntry {
Wfi,
Wfe,
WfeNoEventClear,
}
impl From<StopEntry> for u8 {
fn from(value: StopEntry) -> Self {
match value {
StopEntry::Wfi => 0x01,
StopEntry::Wfe => 0x02,
StopEntry::WfeNoEventClear => 0x03,
}
}
}
pub fn enter_stop1(entry: StopEntry) -> ! {
unsafe extern "C" {
fn HAL_PWREx_EnterSTOP1Mode(entry: u8);
}
unsafe {
HAL_PWREx_EnterSTOP1Mode(entry.into());
}
cortex_m::asm::udf()
}
pub fn enter_stop2(entry: StopEntry) -> ! {
unsafe extern "C" {
fn HAL_PWREx_EnterSTOP2Mode(entry: u8);
}
unsafe {
HAL_PWREx_EnterSTOP2Mode(entry.into());
}
cortex_m::asm::udf()
}
pub fn enter_stop3(entry: StopEntry) -> ! {
unsafe extern "C" {
fn HAL_PWREx_EnterSTOP3Mode(entry: u8);
}
unsafe {
HAL_PWREx_EnterSTOP3Mode(entry.into());
}
cortex_m::asm::udf()
}