Struct AD7124Async

Source
pub struct AD7124Async<T> { /* private fields */ }
Expand description

Asynchronous AD7124 driver

Implementations§

Source§

impl<T> AD7124Async<T>

Source

pub fn new( transport: T, device_type: DeviceType, ) -> Result<Self, AD7124Error<T::Error, ()>>

Create new AD7124 driver instance

Source

pub async fn new_with_detection( transport: T, ) -> Result<Self, AD7124Error<T::Error, ()>>

Create new AD7124 driver with auto-detection

Source

pub async fn init(&mut self) -> Result<(), AD7124Error<T::Error, ()>>

Initialize the AD7124 device

Source

pub async fn read_device_id(&mut self) -> Result<u8, AD7124Error<T::Error, ()>>

Read device ID register

Source

pub async fn read_status( &mut self, ) -> Result<DeviceStatus, AD7124Error<T::Error, ()>>

Read device status

Source

pub async fn configure_adc( &mut self, config: AD7124Config, ) -> Result<(), AD7124Error<T::Error, ()>>

Configure ADC control settings

Source

pub async fn configure_channel( &mut self, channel: u8, config: ChannelConfig, ) -> Result<(), AD7124Error<T::Error, ()>>

Configure channel

Source

pub async fn configure_setup( &mut self, setup_index: u8, config: SetupConfig, ) -> Result<(), AD7124Error<T::Error, ()>>

Configure setup (PGA, reference, etc.)

Source

pub async fn configure_filter( &mut self, setup_index: u8, config: FilterConfig, ) -> Result<(), AD7124Error<T::Error, ()>>

Configure filter

Source

pub async fn read_data(&mut self) -> Result<u32, AD7124Error<T::Error, ()>>

Read raw ADC data (24-bit)

Source

pub async fn read_voltage( &mut self, setup_index: u8, ) -> Result<f32, AD7124Error<T::Error, ()>>

Read ADC data and convert to voltage

Source

pub async fn wait_for_data_ready( &mut self, timeout_ms: u32, ) -> Result<(), AD7124Error<T::Error, ()>>

Wait for data ready

Source

pub async fn is_data_ready(&mut self) -> Result<bool, AD7124Error<T::Error, ()>>

Check if data is ready (non-blocking)

Source

pub async fn wait_conv_ready( &mut self, timeout_ms: Option<u32>, ) -> Result<(), AD7124Error<T::Error, ()>>

Wait for conversion ready with optional timeout

Source

pub async fn enable_channel( &mut self, channel: u8, enable: bool, ) -> Result<(), AD7124Error<T::Error, ()>>

Enable or disable a specific channel (requires I/O to read-modify-write register)

Source

pub async fn is_channel_enabled( &mut self, channel: u8, ) -> Result<bool, AD7124Error<T::Error, ()>>

Check if a channel is enabled (requires I/O to read register for accuracy)

Source

pub async fn get_enabled_channels( &mut self, ) -> Result<Vec<u8, 8>, AD7124Error<T::Error, ()>>

Get all enabled channels (requires I/O to read each channel register)

Source

pub fn validate_channel(&self, channel: u8) -> bool

Validate channel number for this device (pure logic)

Source

pub async fn get_active_channel( &mut self, ) -> Result<u8, AD7124Error<T::Error, ()>>

Get the currently active channel (requires I/O to read status register)

Source

pub async fn current_channel(&mut self) -> Result<u8, AD7124Error<T::Error, ()>>

Get current channel from status register directly

Source

pub async fn read_channel_data( &mut self, channel: u8, ) -> Result<u32, AD7124Error<T::Error, ()>>

Read data from a specific channel

Source

pub async fn read_active_channel_data( &mut self, ) -> Result<u32, AD7124Error<T::Error, ()>>

Simple read for already active channel (no channel switching)

Source

pub async fn start_continuous_conversion( &mut self, ) -> Result<(), AD7124Error<T::Error, ()>>

Start continuous conversions (useful after configuration)

Source

pub async fn read_data_no_wait( &mut self, ) -> Result<u32, AD7124Error<T::Error, ()>>

Read data register directly without waiting (for debugging)

Source

pub async fn read_next_available( &mut self, ) -> Result<(u8, u32), AD7124Error<T::Error, ()>>

Read next available data from any enabled channel in continuous mode Returns tuple of (channel_number, data_value)

Source

pub async fn read_channels_continuous( &mut self, channels: &[u8], ) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>

Read data from multiple channels efficiently in continuous mode Reads one sample from each specified channel

Source

pub async fn read_channel_voltage( &mut self, channel: u8, ) -> Result<f32, AD7124Error<T::Error, ()>>

Read voltage from a specific channel

Source

pub async fn read_multi_channel( &mut self, channels: &[u8], ) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>

Read multiple channels sequentially

Source

pub async fn read_multi_voltage( &mut self, channels: &[u8], ) -> Result<Vec<(u8, f32), 8>, AD7124Error<T::Error, ()>>

Read voltage from multiple channels

Source

pub async fn scan_enabled_channels( &mut self, ) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>

Scan all enabled channels and read their data

Source

pub async fn read_data_with_status( &mut self, ) -> Result<(u8, u32), AD7124Error<T::Error, ()>>

Read data with channel information from status

Source

pub async fn read_data_fast(&mut self) -> Result<u32, AD7124Error<T::Error, ()>>

Fast data read (no status check)

Source

pub async fn reset(&mut self) -> Result<(), AD7124Error<T::Error, ()>>

Perform software reset

Source

pub fn capabilities(&self) -> &DeviceCapabilities

Get device capabilities

Source

pub fn config(&self) -> &AD7124Config

Get current configuration

Source

pub fn device_type(&self) -> DeviceType

Get device type

Source

pub fn is_initialized(&self) -> bool

Check if driver is initialized

Source

pub fn transport(&self) -> &T

Get reference to transport layer (for advanced usage)

Source

pub fn transport_mut(&mut self) -> &mut T

Get mutable reference to transport layer (for advanced usage)

Source

pub async fn read_register( &mut self, register: Register, ) -> Result<u32, AD7124Error<T::Error, ()>>

Read value from specified register

Source

pub async fn write_register( &mut self, register: Register, value: u32, ) -> Result<(), AD7124Error<T::Error, ()>>

Write value to specified register

Source§

impl<T> AD7124Async<T>

High-level convenience functions for common operations

Source

pub async fn setup_single_ended( &mut self, channel: u8, positive_input: ChannelInput, setup_index: u8, ) -> Result<(), AD7124Error<T::Error, ()>>

Quick setup for single-ended measurement

Source

pub async fn setup_differential( &mut self, channel: u8, positive_input: ChannelInput, negative_input: ChannelInput, setup_index: u8, ) -> Result<(), AD7124Error<T::Error, ()>>

Quick setup for differential measurement

Trait Implementations§

Source§

impl<T: Debug> Debug for AD7124Async<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AD7124Async<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for AD7124Async<T>
where T: RefUnwindSafe,

§

impl<T> Send for AD7124Async<T>
where T: Send,

§

impl<T> Sync for AD7124Async<T>
where T: Sync,

§

impl<T> Unpin for AD7124Async<T>
where T: Unpin,

§

impl<T> UnwindSafe for AD7124Async<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.