lsm303dlhc-registers

Crates.iolsm303dlhc-registers
lib.rslsm303dlhc-registers
version0.1.4
created_at2024-07-01 16:45:40.709678+00
updated_at2024-07-05 13:31:08.738233+00
descriptionA typed map of the STMicroelectronics LSM303DLHC E-Compass registers
homepagehttps://github.com/sunsided/lsm303dlhc-registers
repositoryhttps://github.com/sunsided/lsm303dlhc-registers
max_upload_size
id1288855
size88,742
Markus Mayer (sunsided)

documentation

README

STMicroelectronics LSM303DLHC E-Compass Registers

Crates.io Docs Build Status Safety Dance MSRV EUPL 1.2 licensed Apache 2.0 licensed MIT licensed

A typed map of the LSM303DLHC's I²C registers.

Provides functions and named fields to read and modify the sensor registers. For example:

fn configure_sensor(sensor: &mut LSM303DLHC) {
    // configure the accelerometer to operate at 400 Hz
    sensor.write_register(
        ControlRegister1A::new()
            .with_output_data_rate(AccelOdr::Hz400)
            .with_low_power_enable(false)
            .with_x_enable(true)
            .with_y_enable(true)
            .with_z_enable(true),
    )?;

    // Reset other accelerometer control registers.
    sensor.write_register(ControlRegister2A::new())?;
    sensor.write_register(ControlRegister3A::new())?;
    sensor.write_register(ControlRegister4A::new())?;
    sensor.write_register(ControlRegister5A::new())?;
    sensor.write_register(ControlRegister6A::new())?;

    // Configure the magnetometer to operate in continuous mode.
    sensor.write_register(
        ModeRegisterM::new()
            .with_sleep_mode(false)
            .with_single_conversion(false),
    )?;

    // Enable the temperature sensor.
    sensor.write_register(
        CraRegisterM::new()
            .with_temp_en(true)
            .with_data_output_rate(MagOdr::Hz75),
    )?;
}

Code of Conduct

We abide by the Contributor Covenant and ask that you do as well.

License

Copyright © 2024 Markus Mayer

Triple licensed under your choice of either of:

This work includes parts of Jorge Aparicio's lsm303dlhc crate, made available under MIT and Apache 2.0 licenses.

Commit count: 105

cargo fmt