#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

#459 in Embedded development

Download history 5653/week @ 2024-11-16 4757/week @ 2024-11-23 5213/week @ 2024-11-30 5867/week @ 2024-12-07 5051/week @ 2024-12-14 2274/week @ 2024-12-21 2570/week @ 2024-12-28 5380/week @ 2025-01-04 5746/week @ 2025-01-11 5550/week @ 2025-01-18 10306/week @ 2025-01-25 8473/week @ 2025-02-01 7559/week @ 2025-02-08 9211/week @ 2025-02-15 16131/week @ 2025-02-22 15642/week @ 2025-03-01

49,621 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