Files
physical/drivers/ads1256/driver/src/delay.rs
T
2025-03-09 12:13:14 -07:00

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);
}
}