Initial proof of concept
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user