| Crates.io | ldc3114 |
| lib.rs | ldc3114 |
| version | 0.2.0 |
| created_at | 2025-07-30 19:49:49.171988+00 |
| updated_at | 2025-08-13 18:10:48.828209+00 |
| description | Driver crate for the TI LDC3114 inductance-to-digital converter |
| homepage | |
| repository | https://github.com/andresovela/ldc3114-rs |
| max_upload_size | |
| id | 1773968 |
| size | 87,368 |
Driver crate for the TI LDC3114 Inductance-to-Digital Converter. Compatible with embedded-hal and embedded-hal-async traits.
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();
}
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();
This work is licensed under either of
at your option.