#timer #naive #platform #duration #interrupt #no-std

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

#628 in Embedded development

Download history 12114/week @ 2024-01-11 14943/week @ 2024-01-18 15004/week @ 2024-01-25 13723/week @ 2024-02-01 9566/week @ 2024-02-08 10370/week @ 2024-02-15 10937/week @ 2024-02-22 8478/week @ 2024-02-29 8508/week @ 2024-03-07 9394/week @ 2024-03-14 8687/week @ 2024-03-21 9289/week @ 2024-03-28 6214/week @ 2024-04-04 7280/week @ 2024-04-11 7942/week @ 2024-04-18 5203/week @ 2024-04-25

28,093 downloads per month
Used in 15 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