Expand description
§AD7124 Driver
A platform-independent driver for the AD7124 family (AD7124-4/AD7124-8) with comprehensive embedded-hal support.
This v4.0 driver implements lessons learned from comprehensive architecture refactoring:
- Unified Naming: Family-consistent type naming throughout
- Core-Transport Separation: Business logic independent of transport layer
- Embassy Ready: Full async/await support with Embassy templates
- Simple Construction: Direct driver construction for both sync and async
§Features
- Multiple Device Support: AD7124-4 (4-channel), AD7124-8 (8-channel)
- Transport Layer: SPI with embedded-hal integration
- Sync & Async: Both blocking and non-blocking APIs
- 24-bit Precision: High-resolution ADC measurements
- Programmable Gain: 1x to 128x amplification
- Multiple Reference Sources: Internal 2.5V, external, or AVDD-AVSS
- No-std Compatible: Works in embedded environments
- C FFI Support: Static library generation for C integration
§Quick Start
§Synchronous Usage
ⓘ
use ad7124_rs::{AD7124Sync, DeviceType, SpiTransport};
// Create SPI transport (example with embedded-hal)
let transport = SpiTransport::new(spi, cs, delay);
// Create and initialize driver
let mut adc = AD7124Sync::new(transport, DeviceType::AD7124_8)?;
adc.init()?;
// Setup single-ended measurement on channel 0
adc.setup_single_ended(0, ad7124_rs::ChannelInput::Ain0, 0)?;
// Read voltage
let voltage = adc.read_voltage(0)?;
println!("Voltage: {:.3}V", voltage);
§Asynchronous Usage
ⓘ
use ad7124_rs::{AD7124Async, DeviceType, SpiTransport};
// Create SPI transport
let transport = SpiTransport::new(spi, cs, delay);
// Create and initialize async driver
let mut adc = AD7124Async::new(transport, DeviceType::AD7124_8)?;
adc.init().await?;
// Setup differential measurement
adc.setup_differential(0, ad7124_driver::ChannelInput::Ain0,
ad7124_driver::ChannelInput::Ain1, 0).await?;
// Read voltage
let voltage = adc.read_voltage(0).await?;
Re-exports§
pub use device_type::DeviceCapabilities;
pub use device_type::DeviceFeature;
pub use device_type::DeviceType;
pub use errors::AD7124CoreError;
pub use errors::AD7124Error;
pub use transport::spi_speeds;
pub use transport::SpiSpeedValidator;
pub use transport::SyncSpiTransport;
pub use transport::AsyncSpiTransport;
pub use transport::SpiTransport;
pub use ad7124::AD7124Sync;
pub use ad7124::AD7124Async;
pub use ad7124::AD7124Config;
pub use ad7124::ChannelConfig;
pub use ad7124::FilterConfig;
pub use ad7124::SetupConfig;
pub use registers::*;
Modules§
- ad7124
- AD7124 Driver Core
- device_
type - Device type detection and capability management for AD7124 family
- errors
- Error handling for AD7124 driver
- ffi
- C FFI (Foreign Function Interface) module for AD7124 driver
- prelude
- Prelude module for common imports
- registers
- Register definitions and configuration structures for AD7124
- transport
- Transport layer abstractions for AD7124 driver
- types
- Common type aliases for convenience
- version
- Library version information