Skip to content

hal::power

A low-power sleep primitive, for the SoCs that have one.

Like [crate::clock], the kernel drives this through the trait and selects one implementation with the SoC (board::SelectedSoc), so the kernel’s neutral power module names no chip. A SoC with no sleep FSM implements nothing and takes the default: every call reports [SleepError::Unsupported].

enum SleepError {
Unsupported,
NoClock,
Timeout,
Rejected,
}

Why a sleep could not be entered or measured.

Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq

trait LowPower {
unsafe fn light_sleep(_us: u64) -> Result<u64, SleepError>
unsafe fn deep_sleep(_us: u64) -> Result<(), SleepError>
}

A SoC’s low-power sleep, selected by the kernel together with the SoC.

Both methods default to “there is no sleep FSM”, so a SoC that has none implements the trait with an empty body and the kernel’s power module still compiles and dispatches — it just reports [SleepError::Unsupported].