pub struct WrappedSleepConfig<'a> { /* private fields */ }unstable only.Expand description
The sleep configuration, as the entry hook of a wakeup source can see it.
A hook can only relax the sleep. It can keep a power domain powered, keep a clock running, refuse a light sleep, or shorten the sleep. The caller of the sleep function selects how much of the chip to power down, and it arms the wake timer. A wakeup source only adds the resources that it needs, refuses the sleep, or sets a shorter limit. It cannot request a power-down, stop a clock, cancel a refusal, or lengthen a limit.
Each request is idempotent. The order of the hooks cannot change the result. The source with the strongest request wins. One refusal is enough. The shortest limit wins.
Keep this property. A method that requests a power-down, stops a clock, cancels a refusal, or lengthens a limit removes it.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Implementations§
Source§impl<'a> WrappedSleepConfig<'a>
impl<'a> WrappedSleepConfig<'a>
Sourcepub fn is_deep_sleep(&self) -> bool
pub fn is_deep_sleep(&self) -> bool
Returns whether the chip is entering deep sleep, which resets it when it wakes.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn keep_clock_running(&mut self, source: ClockSource)
pub fn keep_clock_running(&mut self, source: ClockSource)
Keeps source running during the sleep.
Ask a clock tree node which source it runs on, and name the answer. A source that the chip keeps running anyway, or that it cannot power down, needs nothing.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn reject_sleep(&mut self)
pub fn reject_sleep(&mut self)
Refuses a light sleep.
Call this when software state makes the sleep unsafe and the hardware cannot see that state. One call is enough. A later hook cannot cancel it.
A deep sleep ignores the call. The wake resets the chip, so there is no caller to report
the refusal to. Read Self::is_deep_sleep when other work in the hook depends on the
kind of sleep.
The hardware also rejects a sleep when an enabled source is already asserted at sleep entry. This call is the software refusal.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn limit_sleep(&mut self, duration: Duration)
pub fn limit_sleep(&mut self, duration: Duration)
Limits this sleep to duration.
The duration starts when the driver programs the wake timer, after every hook has run. The shortest request wins. A later hook cannot make it longer.
The driver clamps the wake timer to the limit. When the timer wakeup source is not enabled, the limit enables it for this sleep. Nothing else wakes the chip at the limit. After a light sleep the driver restores the timer. A deadline the caller armed stays armed. A timer that only the limit enabled is disabled again.
The limit applies to deep sleep as well. The wake resets the chip. Read
Self::is_deep_sleep when the hook should bound only one kind of sleep.
A duration that the sleep transition cannot catch does not start the sleep. A light sleep
then returns as if it had ended. A deep sleep without rejection panics, because it cannot
return and the chip does not wake. This is not a refusal. Use Self::reject_sleep to
refuse a light sleep. A duration of zero is too short to sleep.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.