Poll example
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
#[cfg(feature = "standard-input")]
|
||||
#[cfg(feature = "standard-multiplexer")]
|
||||
pub mod multiplexer;
|
@ -25,6 +25,30 @@ where
|
||||
spi: &'a Mutex<DeviceMutexT, SpiT>,
|
||||
}
|
||||
|
||||
impl<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT>
|
||||
AutocalPoll<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT>
|
||||
where
|
||||
DeviceMutexT: RawMutex,
|
||||
ModInT: ModInput,
|
||||
DelayerT: BlockingDelay,
|
||||
SST: OutputPin,
|
||||
DrdyT: Wait,
|
||||
SpiT: SpiBus,
|
||||
{
|
||||
#[inline(always)]
|
||||
pub fn new(
|
||||
input_mod: ModInT,
|
||||
ads1256: &'a Mutex<DeviceMutexT, Ads1256<DelayerT, SST, DrdyT>>,
|
||||
spi: &'a Mutex<DeviceMutexT, SpiT>,
|
||||
) -> Self {
|
||||
Self {
|
||||
input_mod,
|
||||
ads1256,
|
||||
spi,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT> Poll
|
||||
for AutocalPoll<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT>
|
||||
where
|
||||
@ -40,6 +64,7 @@ where
|
||||
async fn poll(&self) -> Result<Self::Value, CriticalError> {
|
||||
let mut ads1256_guard = self.ads1256.lock().await;
|
||||
let ads1256 = ads1256_guard.deref_mut();
|
||||
ads1256.data_ready.wait_for_low().await;
|
||||
|
||||
let result = ads1256
|
||||
.autocal_convert_m(
|
||||
@ -71,6 +96,36 @@ pub trait ModInput: Copy {
|
||||
fn data_rate(self) -> Option<DataRate>;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub struct ModInputOnly {
|
||||
pub multiplexer: Multiplexer,
|
||||
/// Only used for converting to voltage, this value must match what is set on the ADS1256, it
|
||||
/// will not *be* set unlike the other fields.
|
||||
pub gain: Gain,
|
||||
}
|
||||
|
||||
impl ModInput for ModInputOnly {
|
||||
fn multiplexer(self) -> Multiplexer {
|
||||
self.multiplexer
|
||||
}
|
||||
|
||||
fn gain(self) -> Gain {
|
||||
self.gain
|
||||
}
|
||||
|
||||
fn status(self) -> Option<Status> {
|
||||
None
|
||||
}
|
||||
|
||||
fn ad_control(self) -> Option<AdControl> {
|
||||
None
|
||||
}
|
||||
|
||||
fn data_rate(self) -> Option<DataRate> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// buffer
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub struct ModInStatus {
|
||||
|
Reference in New Issue
Block a user