#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

#397 in Embedded development

Download history 4916/week @ 2024-07-30 4517/week @ 2024-08-06 5714/week @ 2024-08-13 5781/week @ 2024-08-20 5268/week @ 2024-08-27 6568/week @ 2024-09-03 7218/week @ 2024-09-10 5774/week @ 2024-09-17 7104/week @ 2024-09-24 6300/week @ 2024-10-01 8211/week @ 2024-10-08 8923/week @ 2024-10-15 7716/week @ 2024-10-22 7315/week @ 2024-10-29 3160/week @ 2024-11-05 4303/week @ 2024-11-12

23,990 downloads per month
Used in 24 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