Skip to main content

WrappedSleepConfig

Struct WrappedSleepConfig 

Source
pub struct WrappedSleepConfig<'a> { /* private fields */ }
Available on crate feature 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>

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for WrappedSleepConfig<'a>

§

impl<'a> Freeze for WrappedSleepConfig<'a>

§

impl<'a> RefUnwindSafe for WrappedSleepConfig<'a>

§

impl<'a> Send for WrappedSleepConfig<'a>

§

impl<'a> Sync for WrappedSleepConfig<'a>

§

impl<'a> Unpin for WrappedSleepConfig<'a>

§

impl<'a> UnsafeUnpin for WrappedSleepConfig<'a>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.