pub struct AD7124Async<T> { /* private fields */ }Expand description
Asynchronous AD7124 driver
Implementations§
Source§impl<T> AD7124Async<T>where
T: AsyncSpiTransport,
impl<T> AD7124Async<T>where
T: AsyncSpiTransport,
Sourcepub fn new(
transport: T,
device_type: DeviceType,
) -> Result<Self, AD7124Error<T::Error, ()>>
pub fn new( transport: T, device_type: DeviceType, ) -> Result<Self, AD7124Error<T::Error, ()>>
Create new AD7124 driver instance
Sourcepub async fn new_with_detection(
transport: T,
) -> Result<Self, AD7124Error<T::Error, ()>>
pub async fn new_with_detection( transport: T, ) -> Result<Self, AD7124Error<T::Error, ()>>
Create new AD7124 driver with auto-detection
Sourcepub async fn init(&mut self) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn init(&mut self) -> Result<(), AD7124Error<T::Error, ()>>
Initialize the AD7124 device
Sourcepub async fn read_device_id(&mut self) -> Result<u8, AD7124Error<T::Error, ()>>
pub async fn read_device_id(&mut self) -> Result<u8, AD7124Error<T::Error, ()>>
Read device ID register
Sourcepub async fn read_status(
&mut self,
) -> Result<DeviceStatus, AD7124Error<T::Error, ()>>
pub async fn read_status( &mut self, ) -> Result<DeviceStatus, AD7124Error<T::Error, ()>>
Read device status
Sourcepub async fn configure_adc(
&mut self,
config: AD7124Config,
) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn configure_adc( &mut self, config: AD7124Config, ) -> Result<(), AD7124Error<T::Error, ()>>
Configure ADC control settings
Sourcepub async fn configure_channel(
&mut self,
channel: u8,
config: ChannelConfig,
) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn configure_channel( &mut self, channel: u8, config: ChannelConfig, ) -> Result<(), AD7124Error<T::Error, ()>>
Configure channel
Sourcepub async fn configure_setup(
&mut self,
setup_index: u8,
config: SetupConfig,
) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn configure_setup( &mut self, setup_index: u8, config: SetupConfig, ) -> Result<(), AD7124Error<T::Error, ()>>
Configure setup (PGA, reference, etc.)
Sourcepub async fn configure_filter(
&mut self,
setup_index: u8,
config: FilterConfig,
) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn configure_filter( &mut self, setup_index: u8, config: FilterConfig, ) -> Result<(), AD7124Error<T::Error, ()>>
Configure filter
Sourcepub async fn read_data(&mut self) -> Result<u32, AD7124Error<T::Error, ()>>
pub async fn read_data(&mut self) -> Result<u32, AD7124Error<T::Error, ()>>
Read raw ADC data (24-bit)
Sourcepub async fn read_voltage(
&mut self,
setup_index: u8,
) -> Result<f32, AD7124Error<T::Error, ()>>
pub async fn read_voltage( &mut self, setup_index: u8, ) -> Result<f32, AD7124Error<T::Error, ()>>
Read ADC data and convert to voltage
Sourcepub async fn wait_for_data_ready(
&mut self,
timeout_ms: u32,
) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn wait_for_data_ready( &mut self, timeout_ms: u32, ) -> Result<(), AD7124Error<T::Error, ()>>
Wait for data ready
Sourcepub async fn is_data_ready(&mut self) -> Result<bool, AD7124Error<T::Error, ()>>
pub async fn is_data_ready(&mut self) -> Result<bool, AD7124Error<T::Error, ()>>
Check if data is ready (non-blocking)
Sourcepub async fn wait_conv_ready(
&mut self,
timeout_ms: Option<u32>,
) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn wait_conv_ready( &mut self, timeout_ms: Option<u32>, ) -> Result<(), AD7124Error<T::Error, ()>>
Wait for conversion ready with optional timeout
Sourcepub async fn enable_channel(
&mut self,
channel: u8,
enable: bool,
) -> Result<(), AD7124Error<T::Error, ()>>
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)
Sourcepub async fn is_channel_enabled(
&mut self,
channel: u8,
) -> Result<bool, AD7124Error<T::Error, ()>>
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)
Sourcepub async fn get_enabled_channels(
&mut self,
) -> Result<Vec<u8, 8>, AD7124Error<T::Error, ()>>
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)
Sourcepub fn validate_channel(&self, channel: u8) -> bool
pub fn validate_channel(&self, channel: u8) -> bool
Validate channel number for this device (pure logic)
Sourcepub async fn get_active_channel(
&mut self,
) -> Result<u8, AD7124Error<T::Error, ()>>
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)
Sourcepub async fn current_channel(&mut self) -> Result<u8, AD7124Error<T::Error, ()>>
pub async fn current_channel(&mut self) -> Result<u8, AD7124Error<T::Error, ()>>
Get current channel from status register directly
Sourcepub async fn read_channel_data(
&mut self,
channel: u8,
) -> Result<u32, AD7124Error<T::Error, ()>>
pub async fn read_channel_data( &mut self, channel: u8, ) -> Result<u32, AD7124Error<T::Error, ()>>
Read data from a specific channel
Sourcepub async fn read_active_channel_data(
&mut self,
) -> Result<u32, AD7124Error<T::Error, ()>>
pub async fn read_active_channel_data( &mut self, ) -> Result<u32, AD7124Error<T::Error, ()>>
Simple read for already active channel (no channel switching)
Sourcepub async fn start_continuous_conversion(
&mut self,
) -> Result<(), AD7124Error<T::Error, ()>>
pub async fn start_continuous_conversion( &mut self, ) -> Result<(), AD7124Error<T::Error, ()>>
Start continuous conversions (useful after configuration)
Sourcepub async fn read_data_no_wait(
&mut self,
) -> Result<u32, AD7124Error<T::Error, ()>>
pub async fn read_data_no_wait( &mut self, ) -> Result<u32, AD7124Error<T::Error, ()>>
Read data register directly without waiting (for debugging)
Sourcepub async fn read_next_available(
&mut self,
) -> Result<(u8, u32), AD7124Error<T::Error, ()>>
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)
Sourcepub async fn read_channels_continuous(
&mut self,
channels: &[u8],
) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>
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
Sourcepub async fn read_channel_voltage(
&mut self,
channel: u8,
) -> Result<f32, AD7124Error<T::Error, ()>>
pub async fn read_channel_voltage( &mut self, channel: u8, ) -> Result<f32, AD7124Error<T::Error, ()>>
Read voltage from a specific channel
Sourcepub async fn read_multi_channel(
&mut self,
channels: &[u8],
) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>
pub async fn read_multi_channel( &mut self, channels: &[u8], ) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>
Read multiple channels sequentially
Sourcepub async fn read_multi_voltage(
&mut self,
channels: &[u8],
) -> Result<Vec<(u8, f32), 8>, AD7124Error<T::Error, ()>>
pub async fn read_multi_voltage( &mut self, channels: &[u8], ) -> Result<Vec<(u8, f32), 8>, AD7124Error<T::Error, ()>>
Read voltage from multiple channels
Sourcepub async fn scan_enabled_channels(
&mut self,
) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>
pub async fn scan_enabled_channels( &mut self, ) -> Result<Vec<(u8, u32), 8>, AD7124Error<T::Error, ()>>
Scan all enabled channels and read their data
Sourcepub async fn read_data_with_status(
&mut self,
) -> Result<(u8, u32), AD7124Error<T::Error, ()>>
pub async fn read_data_with_status( &mut self, ) -> Result<(u8, u32), AD7124Error<T::Error, ()>>
Read data with channel information from status
Sourcepub async fn read_data_fast(&mut self) -> Result<u32, AD7124Error<T::Error, ()>>
pub async fn read_data_fast(&mut self) -> Result<u32, AD7124Error<T::Error, ()>>
Fast data read (no status check)
Sourcepub fn capabilities(&self) -> &DeviceCapabilities
pub fn capabilities(&self) -> &DeviceCapabilities
Get device capabilities
Sourcepub fn config(&self) -> &AD7124Config
pub fn config(&self) -> &AD7124Config
Get current configuration
Sourcepub fn device_type(&self) -> DeviceType
pub fn device_type(&self) -> DeviceType
Get device type
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if driver is initialized
Sourcepub fn transport_mut(&mut self) -> &mut T
pub fn transport_mut(&mut self) -> &mut T
Get mutable reference to transport layer (for advanced usage)
Sourcepub async fn read_register(
&mut self,
register: Register,
) -> Result<u32, AD7124Error<T::Error, ()>>
pub async fn read_register( &mut self, register: Register, ) -> Result<u32, AD7124Error<T::Error, ()>>
Read value from specified register
Sourcepub async fn write_register(
&mut self,
register: Register,
value: u32,
) -> Result<(), AD7124Error<T::Error, ()>>
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>where
T: AsyncSpiTransport,
High-level convenience functions for common operations
impl<T> AD7124Async<T>where
T: AsyncSpiTransport,
High-level convenience functions for common operations
Sourcepub async fn setup_single_ended(
&mut self,
channel: u8,
positive_input: ChannelInput,
setup_index: u8,
) -> Result<(), AD7124Error<T::Error, ()>>
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
Sourcepub async fn setup_differential(
&mut self,
channel: u8,
positive_input: ChannelInput,
negative_input: ChannelInput,
setup_index: u8,
) -> Result<(), AD7124Error<T::Error, ()>>
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