arduino_hal/
delay.rs

1use embedded_hal::delay::DelayNs;
2
3/// Delay type for `embedded-hal` compatibility.
4///
5/// This type can be used to pass a generic delay utility to `embedded-hal` drivers.  For direct
6/// use in `arduino-hal` code, usage of [`delay_ms`] or [`delay_us`] is preferred.
7pub type Delay = avr_hal_generic::delay::Delay<crate::DefaultClock>;
8
9/// Delay execution for a number of milliseconds.
10///
11/// Busy-loop for the given time.  This function assumes the default clock speed defined by
12/// [`arduino_hal::DefaultClock`][crate::DefaultClock].
13pub fn delay_ms(ms: u32) {
14    Delay::new().delay_ms(ms)
15}
16
17/// Delay execution for a number of microseconds.
18///
19/// Busy-loop for the given time.  This function assumes the default clock speed defined by
20/// [`arduino_hal::DefaultClock`][crate::DefaultClock].
21pub fn delay_us(us: u32) {
22    Delay::new().delay_us(us)
23}
24
25/// Delay execution for a number of nanoseconds.
26///
27/// Busy-loop for the given time.  This function assumes the default clock speed defined by
28/// [`arduino_hal::DefaultClock`][crate::DefaultClock].
29pub fn delay_ns(ns: u32) {
30    Delay::new().delay_ns(ns)
31}