#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

#467 in Embedded development

Download history 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 5225/week @ 2024-11-12 5836/week @ 2024-11-19 4408/week @ 2024-11-26 5813/week @ 2024-12-03 5560/week @ 2024-12-10 4693/week @ 2024-12-17 1853/week @ 2024-12-24 3301/week @ 2024-12-31 5231/week @ 2025-01-07 5509/week @ 2025-01-14 5092/week @ 2025-01-21

19,506 downloads per month
Used in 25 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