pub struct Timer { /* private fields */ }Expand description
Software timer with a safe Rust callback.
The timer stores a function pointer and generates an internal trampoline
so the user callback is a plain fn() — no unsafe, no raw pointers.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn new(callback: fn(), period_ms: u32, one_shot: bool) -> Result<Self>
pub fn new(callback: fn(), period_ms: u32, one_shot: bool) -> Result<Self>
Create a new timer via heap allocation (only in heap mode).
callback— safe Rust function called each time the timer fires.period_ms— timer period in milliseconds.one_shot— iftrue, the timer fires once and stops.
Sourcepub fn create(
storage: &'static TimerStorage,
callback: fn(),
period_ms: u32,
one_shot: bool,
) -> Result<Self>
pub fn create( storage: &'static TimerStorage, callback: fn(), period_ms: u32, one_shot: bool, ) -> Result<Self>
Mode-agnostic constructor (see crate::Mutex::create). Heap mode
ignores storage; zero-heap mode backs the timer with it.
Sourcepub fn start(&self) -> Result<()>
pub fn start(&self) -> Result<()>
Start the timer, beginning countdown from now.
§Errors
Returns an error if the underlying RTOS call fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Timer
impl RefUnwindSafe for Timer
impl Unpin for Timer
impl UnsafeUnpin for Timer
impl UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more