2 unstable releases
0.2.0 | Aug 8, 2021 |
---|---|
0.1.0 | Jun 23, 2020 |
#397 in Embedded development
23,990 downloads per month
Used in 24 crates
(via madsim)
7KB
58 lines
naive-timer
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.