stop3 working properly well
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
|
||||
pub mod standby;
|
||||
pub mod shutdown;
|
||||
pub mod stop3;
|
||||
|
||||
39
semestralka_2_uart/src/sleep/stop3.rs
Normal file
39
semestralka_2_uart/src/sleep/stop3.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
// src/sleep/stop3.rs
|
||||
|
||||
// #define PWR_STOPENTRY_WFI (0x01U) //*!< Wait For Interruption instruction to enter Stop mode */
|
||||
// #define PWR_STOPENTRY_WFE (0x02U) //*!< Wait For Event instruction to enter Stop mode */
|
||||
// #define PWR_STOPENTRY_WFE_NO_EVT_CLEAR (0x03U)
|
||||
|
||||
/// How to enter STOP3 mode
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
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_stop3(stop_entry: StopEntry) -> ! {
|
||||
unsafe extern "C" {
|
||||
fn HAL_PWREx_EnterSTOP3Mode(stop_entry: u8);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
HAL_PWREx_EnterSTOP3Mode(stop_entry.into());
|
||||
}
|
||||
|
||||
cortex_m::asm::udf(); //panic
|
||||
}
|
||||
|
||||
// Example usage:
|
||||
// enter_stop3(StopEntry::Wfi);
|
||||
// enter_stop3(StopEntry::Wfe);
|
||||
// enter_stop3(StopEntry::WfeNoEventClear);
|
||||
Reference in New Issue
Block a user