ADS1256 poll input.
This commit is contained in:
@ -63,7 +63,7 @@ pub fn poll_variant_macro(input: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
// ----- Add publisher generics ----------------------------------
|
// ----- Add publisher generics ----------------------------------
|
||||||
// MutexT
|
// MutexT
|
||||||
const MUTEX_T_NAME: &str = "MutexT";
|
const MUTEX_T_NAME: &str = "PublishMutexT";
|
||||||
let mutex_t_ident = Ident::new(MUTEX_T_NAME, Span::call_site());
|
let mutex_t_ident = Ident::new(MUTEX_T_NAME, Span::call_site());
|
||||||
const CAPACITY_NAME: &str = "CAPACITY";
|
const CAPACITY_NAME: &str = "CAPACITY";
|
||||||
let capacity_ident = Ident::new(CAPACITY_NAME, Span::call_site());
|
let capacity_ident = Ident::new(CAPACITY_NAME, Span::call_site());
|
||||||
|
@ -8,7 +8,8 @@ readme.workspace = true
|
|||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
poll = ["node-poll-variants"]
|
embassy-sync = ["dep:embassy-sync", "ads1256/embassy-sync"]
|
||||||
|
poll = ["standard-multiplexer", "embassy-sync"]
|
||||||
config = ["physical-ads1256-types/config"]
|
config = ["physical-ads1256-types/config"]
|
||||||
standard-input = ["physical-ads1256-types/standard-input"]
|
standard-input = ["physical-ads1256-types/standard-input"]
|
||||||
standard-multiplexer = ["standard-input"]
|
standard-multiplexer = ["standard-input"]
|
||||||
@ -17,7 +18,6 @@ standard-multiplexer = ["standard-input"]
|
|||||||
path = "../../../node"
|
path = "../../../node"
|
||||||
[dependencies.node-poll-variants]
|
[dependencies.node-poll-variants]
|
||||||
path = "../../../macros/node-poll-variants"
|
path = "../../../macros/node-poll-variants"
|
||||||
optional = true
|
|
||||||
[dependencies.physical-ads1256-types]
|
[dependencies.physical-ads1256-types]
|
||||||
path = "../types"
|
path = "../types"
|
||||||
features = ["defmt"]
|
features = ["defmt"]
|
||||||
@ -30,4 +30,7 @@ workspace = true
|
|||||||
[dependencies.defmt]
|
[dependencies.defmt]
|
||||||
workspace = true
|
workspace = true
|
||||||
[dependencies.uom]
|
[dependencies.uom]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
[dependencies.embassy-sync]
|
||||||
|
workspace = true
|
||||||
|
optional = true
|
@ -1,7 +1,9 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![feature(async_fn_in_trait, impl_trait_projections)]
|
||||||
|
|
||||||
#[cfg(feature = "standard-multiplexer")]
|
#[cfg(feature = "standard-multiplexer")]
|
||||||
mod standard_multiplexer;
|
mod standard_multiplexer;
|
||||||
|
#[cfg(feature = "poll")]
|
||||||
mod poll;
|
mod poll;
|
||||||
|
|
||||||
pub use physical_ads1256_types::*;
|
pub use physical_ads1256_types::*;
|
@ -0,0 +1,4 @@
|
|||||||
|
mod sync;
|
||||||
|
|
||||||
|
#[cfg(feature = "embassy-sync")]
|
||||||
|
pub use sync::*;
|
@ -0,0 +1,2 @@
|
|||||||
|
#[cfg(feature = "poll")]
|
||||||
|
pub mod poll;
|
@ -0,0 +1,249 @@
|
|||||||
|
use core::ops::DerefMut;
|
||||||
|
use ads1256::{
|
||||||
|
AdControl, Ads1256, BlockingDelay, DataRate, Multiplexer, OutputPin, SpiBus, Status, Wait,
|
||||||
|
};
|
||||||
|
use embassy_sync::blocking_mutex::raw::RawMutex;
|
||||||
|
use embassy_sync::mutex::Mutex;
|
||||||
|
use physical_node::transducer::input::Poll;
|
||||||
|
|
||||||
|
pub struct AutocalPoll<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT>
|
||||||
|
where
|
||||||
|
DeviceMutexT: RawMutex,
|
||||||
|
ModInT: ModInput,
|
||||||
|
DelayerT: BlockingDelay,
|
||||||
|
SST: OutputPin,
|
||||||
|
DrdyT: Wait,
|
||||||
|
SpiT: SpiBus,
|
||||||
|
{
|
||||||
|
input_mod: ModInT,
|
||||||
|
ads1256: &'a Mutex<DeviceMutexT, Ads1256<DelayerT, SST, DrdyT>>,
|
||||||
|
spi: &'a Mutex<DeviceMutexT, SpiT>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT> Poll
|
||||||
|
for AutocalPoll<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT>
|
||||||
|
where
|
||||||
|
DeviceMutexT: RawMutex,
|
||||||
|
ModInT: ModInput,
|
||||||
|
DelayerT: BlockingDelay,
|
||||||
|
SST: OutputPin,
|
||||||
|
DrdyT: Wait,
|
||||||
|
SpiT: SpiBus,
|
||||||
|
{
|
||||||
|
type Value = ();
|
||||||
|
|
||||||
|
async fn poll(&self) -> Self::Value {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait ModInput {
|
||||||
|
fn multiplexer(self) -> Multiplexer;
|
||||||
|
|
||||||
|
fn status(self) -> Option<Status>;
|
||||||
|
|
||||||
|
fn ad_control(self) -> Option<AdControl>;
|
||||||
|
|
||||||
|
fn data_rate(self) -> Option<DataRate>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// buffer
|
||||||
|
pub struct ModInStatus {
|
||||||
|
pub multiplexer: Multiplexer,
|
||||||
|
pub status: Status,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ModInput for ModInStatus {
|
||||||
|
#[inline(always)]
|
||||||
|
fn multiplexer(self) -> Multiplexer {
|
||||||
|
self.multiplexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn status(self) -> Option<Status> {
|
||||||
|
Some(self.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn ad_control(self) -> Option<AdControl> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn data_rate(self) -> Option<DataRate> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// gain
|
||||||
|
pub struct ModInAdControl {
|
||||||
|
pub multiplexer: Multiplexer,
|
||||||
|
pub ad_control: AdControl,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ModInput for ModInAdControl {
|
||||||
|
#[inline(always)]
|
||||||
|
fn multiplexer(self) -> Multiplexer {
|
||||||
|
self.multiplexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn status(self) -> Option<Status> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn ad_control(self) -> Option<AdControl> {
|
||||||
|
Some(self.ad_control)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn data_rate(self) -> Option<DataRate> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// data rate
|
||||||
|
pub struct ModInDataRate {
|
||||||
|
pub multiplexer: Multiplexer,
|
||||||
|
pub data_rate: DataRate,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ModInput for ModInDataRate {
|
||||||
|
#[inline(always)]
|
||||||
|
fn multiplexer(self) -> Multiplexer {
|
||||||
|
self.multiplexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn status(self) -> Option<Status> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn ad_control(self) -> Option<AdControl> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn data_rate(self) -> Option<DataRate> {
|
||||||
|
Some(self.data_rate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// buffer, gain
|
||||||
|
pub struct ModInStatAdc {
|
||||||
|
pub multiplexer: Multiplexer,
|
||||||
|
pub status: Status,
|
||||||
|
pub ad_control: AdControl,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ModInput for ModInStatAdc {
|
||||||
|
#[inline(always)]
|
||||||
|
fn multiplexer(self) -> Multiplexer {
|
||||||
|
self.multiplexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn status(self) -> Option<Status> {
|
||||||
|
Some(self.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn ad_control(self) -> Option<AdControl> {
|
||||||
|
Some(self.ad_control)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn data_rate(self) -> Option<DataRate> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// buffer, data rate
|
||||||
|
pub struct ModInStatDrate {
|
||||||
|
pub multiplexer: Multiplexer,
|
||||||
|
pub status: Status,
|
||||||
|
pub data_rate: DataRate,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ModInput for ModInStatDrate {
|
||||||
|
#[inline(always)]
|
||||||
|
fn multiplexer(self) -> Multiplexer {
|
||||||
|
self.multiplexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn status(self) -> Option<Status> {
|
||||||
|
Some(self.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn ad_control(self) -> Option<AdControl> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn data_rate(self) -> Option<DataRate> {
|
||||||
|
Some(self.data_rate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// gain, data rate
|
||||||
|
pub struct ModInAdcDrate {
|
||||||
|
pub multiplexer: Multiplexer,
|
||||||
|
pub ad_control: AdControl,
|
||||||
|
pub data_rate: DataRate,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ModInput for ModInAdcDrate {
|
||||||
|
#[inline(always)]
|
||||||
|
fn multiplexer(self) -> Multiplexer {
|
||||||
|
self.multiplexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn status(self) -> Option<Status> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn ad_control(self) -> Option<AdControl> {
|
||||||
|
Some(self.ad_control)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn data_rate(self) -> Option<DataRate> {
|
||||||
|
Some(self.data_rate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// buffer, gain, data rate
|
||||||
|
pub struct ModInAll {
|
||||||
|
pub multiplexer: Multiplexer,
|
||||||
|
pub status: Status,
|
||||||
|
pub ad_control: AdControl,
|
||||||
|
pub data_rate: DataRate,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ModInput for ModInAll {
|
||||||
|
#[inline(always)]
|
||||||
|
fn multiplexer(self) -> Multiplexer {
|
||||||
|
self.multiplexer
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn status(self) -> Option<Status> {
|
||||||
|
Some(self.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn ad_control(self) -> Option<AdControl> {
|
||||||
|
Some(self.ad_control)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn data_rate(self) -> Option<DataRate> {
|
||||||
|
Some(self.data_rate)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user