ldc3114

Crates.ioldc3114
lib.rsldc3114
version0.2.0
created_at2025-07-30 19:49:49.171988+00
updated_at2025-08-13 18:10:48.828209+00
descriptionDriver crate for the TI LDC3114 inductance-to-digital converter
homepage
repositoryhttps://github.com/andresovela/ldc3114-rs
max_upload_size
id1773968
size87,368
Andres O. Vela (andresovela)

documentation

https://docs.rs/ldc3114

README

LDC3114

Driver crate for the TI LDC3114 Inductance-to-Digital Converter. Compatible with embedded-hal and embedded-hal-async traits.

Example usage

let mut inductance_sensor = Ldc3114::new(inductance_sensor_i2c);

// Set the device in configuration mode
inductance_sensor.config_mode().await.unwrap();

// Wait until the registers are ready to write
loop {
    if inductance_sensor.is_ready_to_write().await.unwrap() {
        break;
    }
    Timer::after_millis(5).await;
}

// Your setup
inductance_sensor.set_normal_scan_rate(ScanRate::Lowest).await.unwrap();
inductance_sensor.set_low_power_scan_rate(LowPowerScanRate::Low).await.unwrap();
inductance_sensor.enable_button_press_detection_algorithm(false).await.unwrap();

// Set the device in normal mode
inductance_sensor.normal_mode().await.unwrap();

// Wait until the chip is ready
loop {
    if inductance_sensor.is_chip_ready().await.unwrap() {
        break;
    }
    Timer::after_millis(5).await;
}

loop {
    // Read status to update raw data registers
    let _ = inductance_sensor.read_status().await.unwrap();
    let ch0 = inductance_sensor.read_raw_data(Channel0).await.unwrap();
    let ch1 = inductance_sensor.read_raw_data(Channel1).await.unwrap();
    let ch2 = inductance_sensor.read_raw_data(Channel2).await.unwrap();
    let ch3 = inductance_sensor.read_raw_data(Channel3).await.unwrap();
}

Alternative setup

If you have many configurations to set, set up a const DeviceConfig:

const LDC3114_CONFIG: DeviceConfig = DeviceConfig {
    scan_rate: ScanRate::Highest,
    ..DeviceConfig::const_default()
};

and then call

inductance_sensor.set_device_configuration(&LDC3114_CONFIG).await.unwrap();

Resources

License

This work is licensed under either of

at your option.

Commit count: 0

cargo fmt