use crate::rtc_cntl::SocResetReason;
#[derive(Debug, Copy, Clone)]
pub enum SleepSource {
Undefined = 0,
All,
Ext0,
Ext1,
Timer,
TouchPad,
Ulp,
Gpio,
Uart,
Wifi,
Cocpu,
CocpuTrapTrig,
BT,
}
bitflags::bitflags! {
#[allow(unused)]
pub(crate) struct WakeupReason: u32 {
const NoSleep = 0;
#[cfg(pm_support_ext0_wakeup)]
const ExtEvent0Trig = 1 << 0;
#[cfg(pm_support_ext1_wakeup)]
const ExtEvent1Trig = 1 << 1;
const GpioTrigEn = 1 << 2;
#[cfg(not(any(esp32c6, esp32h2)))]
const TimerTrigEn = 1 << 3;
#[cfg(any(esp32c6, esp32h2))]
const TimerTrigEn = 1 << 4;
#[cfg(pm_support_wifi_wakeup)]
const WifiTrigEn = 1 << 5;
const Uart0TrigEn = 1 << 6;
const Uart1TrigEn = 1 << 7;
#[cfg(pm_support_touch_sensor_wakeup)]
const TouchTrigEn = 1 << 8;
#[cfg(ulp_supported)]
const UlpTrigEn = 1 << 9;
#[cfg(pm_support_bt_wakeup)]
const BtTrigEn = 1 << 10;
#[cfg(riscv_coproc_supported)]
const CocpuTrigEn = 1 << 11;
#[cfg(riscv_coproc_supported)]
const CocpuTrapTrigEn = 1 << 13;
}
}
pub fn software_reset() {
unsafe { crate::rtc_cntl::software_reset() }
}
pub fn software_reset_cpu() {
unsafe { crate::rtc_cntl::software_reset_cpu() }
}
pub fn get_reset_reason() -> Option<SocResetReason> {
crate::rtc_cntl::get_reset_reason(crate::get_core())
}
pub fn get_wakeup_cause() -> SleepSource {
crate::rtc_cntl::get_wakeup_cause()
}