linux_embedded_hal/
delay.rs

1//! Implementation of [`embedded-hal`] delay traits
2//!
3//! [`embedded-hal`]: https://docs.rs/embedded-hal
4
5use cast::u64;
6use embedded_hal::delay::DelayNs;
7use std::thread;
8use std::time::Duration;
9
10/// Empty struct that provides delay functionality on top of `thread::sleep`
11pub struct Delay;
12
13impl DelayNs for Delay {
14    fn delay_ns(&mut self, n: u32) {
15        thread::sleep(Duration::from_nanos(u64(n)));
16    }
17}