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,
impl<T, S> MasterClock<'_, T, S>where
T: 'static + TimerControl,
S: EventSink,
sourcepub fn using<OT: Into<OwnOrBorrowMut<'static, T>>, const FREQ_HZ: u16>(
timer: OT
) -> Self
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.
pub fn static_using<OT: Into<OwnOrBorrowMut<'static, T>>, const FREQ_HZ: u16>( timer: OT ) -> &'static mut Self
pub fn with_timer<const FREQ_HZ: u16>(timer: &'static mut T) -> Self
pub fn static_with_timer<const FREQ_HZ: u16>( timer: &'static mut T ) -> &'static mut Self
sourcepub fn enable_preemption(&mut self)
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.)
sourcepub fn disable_preemption(&mut self)
pub fn disable_preemption(&mut self)
Disable the preemption of threads using this clock.
sourcepub fn wait(&self, delay: Duration)
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,
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
fn after_delay( &self, delay: Duration, bf: Box<dyn DelayCallback + 'mc> ) -> Self::DelayHandle
delay
time has passed.source§fn cancel_delay(&self, handle: Self::DelayHandle) -> bool
fn cancel_delay(&self, handle: Self::DelayHandle) -> bool
true
if the event
was cancelled, or false
if not (because it either never existed,
or it has already been executed.)