Crate ldc3114

Crate ldc3114 

Source
Expand description

§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.

Structs§

Channel0
Representation of registers for channel 0.
Channel1
Representation of registers for channel 1.
Channel2
Representation of registers for channel 2.
Channel3
Representation of registers for channel 3.
ChannelConfig
Channel configuration struct.
DeviceConfig
Device configuration struct.
Ldc3114
Driver for the LDC3114.
OutputLogicStates
Channel output logic states.
SensorConfig
Sensor configuration struct.
Status
Status flags.

Enums§

ChannelMode
Channel operational mode.
CounterScale
Counter scale.
DataPolarity
Processed button algorithm data polarity for a channel.
Error
Error type.
FastTrackingFactor
Fast Tracking Factor for button algorithm.
FrequencyRange
Channel sensor frequency range selection.
InterruptPolarity
Interrupt polarity.
LowPowerScanRate
Scan rate in low power mode.
OutputPolarity
Button output polarity for pin OUTX.
Register
LDC3114 registers.
RpRange
Channel sensor Rp range selection. Set based on the actual sensor Rp physical parameter.
ScanRate
Scan rate in normal mode.

Traits§

ChannelRegisters
Channel registers.