Struct avr_oxide::devices::masterclock::MasterClock

source ·
pub struct MasterClock<'mc, T, S>
where T: 'static + TimerControl, S: EventSink,
{ /* private fields */ }

Implementations§

source§

impl<T, S> MasterClock<'_, T, S>
where T: 'static + TimerControl, S: EventSink,

source

pub fn using<OT: Into<OwnOrBorrowMut<'static, T>>, const FREQ_HZ: u16>( timer: OT ) -> Self

Create a MasterClock that uses the given AVR TimerControl device to schedule clock events. The desired frequency in Hz is provided as a static parameter. The timer will generate timer events to be consumed by the supervisor, which you can handle with the on_event method.

source

pub fn static_using<OT: Into<OwnOrBorrowMut<'static, T>>, const FREQ_HZ: u16>( timer: OT ) -> &'static mut Self

source

pub fn with_timer<const FREQ_HZ: u16>(timer: &'static mut T) -> Self

source

pub fn static_with_timer<const FREQ_HZ: u16>( timer: &'static mut T ) -> &'static mut Self

source

pub fn enable_preemption(&mut self)

Configure this MasterClock to drive the pre-emptive scheduling of threads (i.e. this clock will context switch each time it ticks.)

source

pub fn disable_preemption(&mut self)

Disable the preemption of threads using this clock.

source

pub fn wait(&self, delay: Duration)

Block the calling thread for (at least) the given duration.

§Important

Note that the clock must be running - i.e. the supervisor.listen_handle() method was called already - before you use the wait() method, or you can expect to block forever, , and that this method depends on the main supervisor to be running. In other words, this must be used in threads you have spawn()ed, not the main thread.

Trait Implementations§

source§

impl<'mc, T, S> DelayEvents<'mc> for MasterClock<'mc, T, S>
where T: 'static + TimerControl, S: EventSink,

§

type DelayHandle = DelayQueueHandle

source§

fn after_delay( &self, delay: Duration, bf: Box<dyn DelayCallback + 'mc> ) -> Self::DelayHandle

Call the given callback after /at least/ delay time has passed.
source§

fn cancel_delay(&self, handle: Self::DelayHandle) -> bool

Cancel a given delay event, if possible. Returns true if the event was cancelled, or false if not (because it either never existed, or it has already been executed.)
source§

impl<T, S> EventSource for MasterClock<'_, T, S>
where T: 'static + TimerControl, S: EventSink,

source§

fn listen(&'static self)

source§

fn process_event(&self, evt: OxideEvent)

source§

impl<'mc, T, S> TickEvents<'mc> for MasterClock<'mc, T, S>
where T: 'static + TimerControl, S: EventSink,

source§

fn on_tick(&self, bf: Box<dyn TickCallback + 'mc>)

Call the given closure every time the clock ticks.
source§

impl<T, S> Send for MasterClock<'_, T, S>
where T: 'static + TimerControl, S: EventSink,

source§

impl<T, S> Sync for MasterClock<'_, T, S>
where T: 'static + TimerControl, S: EventSink,

Auto Trait Implementations§

§

impl<'mc, T, S> !Freeze for MasterClock<'mc, T, S>

§

impl<'mc, T, S> !RefUnwindSafe for MasterClock<'mc, T, S>

§

impl<'mc, T, S> Unpin for MasterClock<'mc, T, S>
where S: Unpin,

§

impl<'mc, T, S> !UnwindSafe for MasterClock<'mc, T, S>

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>,

§

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>,

§

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.