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