#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

#420 in Embedded development

Download history 6125/week @ 2024-04-05 7668/week @ 2024-04-12 7791/week @ 2024-04-19 5666/week @ 2024-04-26 6091/week @ 2024-05-03 9141/week @ 2024-05-10 8369/week @ 2024-05-17 7714/week @ 2024-05-24 7714/week @ 2024-05-31 8622/week @ 2024-06-07 7931/week @ 2024-06-14 8186/week @ 2024-06-21 5925/week @ 2024-06-28 6111/week @ 2024-07-05 7030/week @ 2024-07-12 5059/week @ 2024-07-19

25,847 downloads per month
Used in 21 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