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

#478 in Embedded development

Download history 11460/week @ 2023-11-23 11604/week @ 2023-11-30 11383/week @ 2023-12-07 9486/week @ 2023-12-14 10852/week @ 2023-12-21 8061/week @ 2023-12-28 12776/week @ 2024-01-04 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 5946/week @ 2024-03-07

37,327 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