44 lines
1.0 KiB
Rust
44 lines
1.0 KiB
Rust
use embedded_hal::delay::DelayNs;
|
|
|
|
//TODO: Change to maybe async when available instead of always blocking
|
|
pub trait BlockingDelay {
|
|
/// Delay between spi write and read in a read data command
|
|
/// Total 50 master clock cycles
|
|
fn t6_delay(&mut self);
|
|
|
|
/// Delay after RREG, WREG, RDATA
|
|
/// Total 4 master clock cycles
|
|
fn t11_1_delay(&mut self);
|
|
|
|
/// Delay after RDATAC, RESET, SYNC
|
|
/// Total 24 master clock cycles
|
|
fn t11_2_delay(&mut self);
|
|
}
|
|
|
|
pub struct DefaultDelay<DelayT: DelayNs> {
|
|
delayer: DelayT,
|
|
}
|
|
|
|
impl<DelayT: DelayNs> DefaultDelay<DelayT> {
|
|
#[inline(always)]
|
|
pub const fn new(delayer: DelayT) -> Self {
|
|
Self { delayer }
|
|
}
|
|
}
|
|
|
|
impl<DelayT: DelayNs> BlockingDelay for DefaultDelay<DelayT> {
|
|
#[inline(always)]
|
|
fn t6_delay(&mut self) {
|
|
self.delayer.delay_us(7);
|
|
}
|
|
|
|
#[inline(always)]
|
|
fn t11_1_delay(&mut self) {
|
|
self.delayer.delay_us(1);
|
|
}
|
|
|
|
#[inline(always)]
|
|
fn t11_2_delay(&mut self) {
|
|
self.delayer.delay_us(4);
|
|
}
|
|
} |