Regular

Struct Regular 

Source
pub struct Regular<'r> { /* private fields */ }
Expand description

Regular sleep mode

Provides a Sleep implementation for the regular sleep mode and uses the WKT to wake the microcontroller up again, at the right time. Only clocks that the WKT supports can be used. See wkt::Clock for more details.

§Examples

use lpc8xx_hal::{
    prelude::*,
    Peripherals,
    clock::Ticks,
    pac::CorePeripherals,
    sleep,
};

let mut cp = CorePeripherals::take().unwrap();
let mut p = Peripherals::take().unwrap();

let mut pmu    = p.PMU.split();
let mut syscon = p.SYSCON.split();
let mut wkt    = p.WKT.enable(&mut syscon.handle);

let clock = syscon.iosc_derived_clock;

let mut sleep = sleep::Regular::prepare(
    &mut pmu.handle,
    &mut cp.SCB,
    &mut wkt,
);

let delay = Ticks { value: 750_000, clock: &clock }; // 1000 ms

// This will put the microcontroller into sleep mode.
sleep.sleep(delay);

Implementations§

Source§

impl<'r> Regular<'r>

Source

pub fn prepare(pmu: &'r mut Handle, scb: &'r mut SCB, wkt: &'r mut WKT) -> Self

Prepare regular sleep mode

Returns an instance of sleep::Regular, which implements Sleep and can therefore be used to put the microcontroller to sleep.

Requires references to various peripherals, which will be borrowed for as long as the sleep::Regular instance exists, as they will be needed for every call to Sleep::sleep.

Trait Implementations§

Source§

impl<'r, Clock> Sleep<Clock> for Regular<'r>
where Clock: Enabled + Clock,

Source§

fn sleep<'clock, T>(&mut self, ticks: T)
where Clock: 'clock, T: Into<Ticks<'clock, Clock>>,

Puts the processor to sleep for the given number of ticks of the clock

Auto Trait Implementations§

§

impl<'r> Freeze for Regular<'r>

§

impl<'r> RefUnwindSafe for Regular<'r>

§

impl<'r> Send for Regular<'r>

§

impl<'r> !Sync for Regular<'r>

§

impl<'r> Unpin for Regular<'r>

§

impl<'r> !UnwindSafe for Regular<'r>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.