| Crates.io | variegated-ads124s08 |
| lib.rs | variegated-ads124s08 |
| version | 0.1.0 |
| created_at | 2025-06-05 15:47:08.332044+00 |
| updated_at | 2025-06-05 15:47:08.332044+00 |
| description | Async driver for the Texas Instruments ADS124S08 24-bit precision ADC |
| homepage | |
| repository | https://github.com/variegated-coffee/variegated-rs |
| max_upload_size | |
| id | 1701725 |
| size | 3,280,413 |
Async driver for the Texas Instruments ADS124S08 24-bit precision ADC.
The ADS124S08 is a precision, 24-bit analog-to-digital converter with 12 single-ended or 6 differential inputs, programmable gain amplifier (PGA), voltage reference, and two excitation current sources (IDACs). It's ideal for high-precision sensor measurements in applications like temperature, pressure, and bridge sensors.
embedded-hal-asyncdefmt support for logging (behind defmt feature flag)Add this to your Cargo.toml:
[dependencies]
variegated-ads124s08 = "0.1"
# Optional: enable defmt support
variegated-ads124s08 = { version = "0.1", features = ["defmt"] }
use variegated_ads124s08::{ADS124S08, WaitStrategy, registers::Mux, ReferenceInput};
// Create the driver with SPI device, DRDY pin, and delay provider
let wait_strategy = WaitStrategy::UseDrdyPin(drdy_pin);
let mut adc = ADS124S08::new(spi_device, wait_strategy, delay);
// Perform a single-ended measurement on AIN0
let result = adc.measure_single_ended(
Mux::AIN0, // Input channel
ReferenceInput::REF0P_REF0N // Reference voltage
).await?;
// Convert to voltage
let voltage = result.to_voltage();
println!("Measured voltage: {:.6} V", voltage);
// Check for over/under range
if result.over_fs() {
println!("Measurement over full scale");
} else if result.below_fs() {
println!("Measurement below full scale");
}
For advanced users, the driver also provides direct register access:
// Read device ID
let id = adc.read_id_reg().await?;
println!("Device ID: 0x{:02X}", id.device_id);
// Configure registers manually
let mut config = adc.read_all_configuration_registers().await?;
config.pga.gain = PGAGain::GAIN32;
config.datarate.rate = DataRate::SPS1000;
adc.swap_all_configuration_registers(config).await?;
// Start continuous conversion
adc.start_conversion().await?;
let data = adc.read_data().await?;
adc.stop_conversion().await?;
See the datasheet for complete specifications and layout guidelines.
This crate can run on any async executor and is no_std compatible.