#timer #naive #platform #callback #duration #events

no-std naive-timer

A minimal naive timer for embedded (no_std) platforms

2 unstable releases

0.2.0 Aug 8, 2021
0.1.0 Jun 23, 2020

#458 in Embedded development

Download history 5054/week @ 2024-11-22 4850/week @ 2024-11-29 6097/week @ 2024-12-06 5162/week @ 2024-12-13 2700/week @ 2024-12-20 2102/week @ 2024-12-27 5333/week @ 2025-01-03 5663/week @ 2025-01-10 5330/week @ 2025-01-17 9014/week @ 2025-01-24 9834/week @ 2025-01-31 7036/week @ 2025-02-07 8909/week @ 2025-02-14 15415/week @ 2025-02-21 17899/week @ 2025-02-28 21458/week @ 2025-03-07

65,438 downloads per month
Used in 25 crates (via madsim)

MIT license

7KB
58 lines

naive-timer

Crate Docs Actions Status Coverage Status

A minimal naive timer for embedded platforms in Rust (no_std + alloc).

Example

let mut timer = naive_timer::Timer::default();
let event = Arc::new(AtomicBool::new(false));

// add a timer with callback
timer.add(Duration::from_secs(1), {
    let event = event.clone();
    move |_now| event.store(true, Ordering::SeqCst)
});

// expire timers (usually from timer interrupt)
timer.expire(Duration::from_millis(1000));
assert_eq!(event.load(Ordering::SeqCst), true);
assert_eq!(timer.next(), None);

License

The code in this repository is licensed under the MIT License.

No runtime deps