1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use embedded_hal_v0::blocking::delay::{DelayMs, DelayUs};

/// Delay type for `embedded-hal` compatibility.
///
/// This type can be used to pass a generic delay utility to `embedded-hal` drivers.  For direct
/// use in `arduino-hal` code, usage of [`delay_ms`] or [`delay_us`] is preferred.
pub type Delay = avr_hal_generic::delay::Delay<crate::DefaultClock>;

/// Delay execution for a number of milliseconds.
///
/// Busy-loop for the given time.  This function assumes the default clock speed defined by
/// [`arduino_hal::DefaultClock`][crate::DefaultClock].
pub fn delay_ms(ms: u16) {
    Delay::new().delay_ms(ms)
}

/// Delay execution for a number of microseconds.
///
/// Busy-loop for the given time.  This function assumes the default clock speed defined by
/// [`arduino_hal::DefaultClock`][crate::DefaultClock].
pub fn delay_us(us: u32) {
    Delay::new().delay_us(us)
}