#timer #duration #naive #platform #callback #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

#431 in Embedded development

Download history 7145/week @ 2024-06-19 7827/week @ 2024-06-26 5265/week @ 2024-07-03 7091/week @ 2024-07-10 6296/week @ 2024-07-17 6345/week @ 2024-07-24 4273/week @ 2024-07-31 4682/week @ 2024-08-07 5935/week @ 2024-08-14 5460/week @ 2024-08-21 5511/week @ 2024-08-28 6681/week @ 2024-09-04 7250/week @ 2024-09-11 5882/week @ 2024-09-18 6628/week @ 2024-09-25 5505/week @ 2024-10-02

26,443 downloads per month
Used in 22 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