i2cdev-lsm9ds0

Crates.ioi2cdev-lsm9ds0
lib.rsi2cdev-lsm9ds0
version0.1.3
sourcesrc
created_at2017-08-06 15:56:36.140169
updated_at2017-10-18 22:30:04.855945
descriptionI2C driver for the LSM9DS0 gyroscope, accelerometer, magnetometer.
homepage
repositoryhttps://github.com/martindeegan/i2cdev-sensors
max_upload_size
id26683
size26,428
Martin Deegan (martindeegan)

documentation

README

LSM9DS0

An I2C driver for the LSM9DS0 gyroscope, accelerometer, magnetometer.

Usage

Add the following to your Cargo.toml:

[dependencies]
i2csensors = "0.1.*"
i2cdev-lsm9ds0 = "0.1.*"

Next, add this to your crate root:

extern crate i2cdev_lsm9ds0;
extern crate i2csensors;

Initializing and reading from an L3GD20

use i2cdev_lsm9ds0::*;
use i2csensors::{Accelerometer,Magnetometer,Gyroscope};

fn main() {
    let (gyro_dev,accel_dev) = get_default_lsm9ds0_linux_i2c_devices().unwrap();

    let gyro_settings = LSM9DS0GyroscopeSettings {
        DR: LSM9DS0GyroscopeDataRate::Hz190,
        BW: LSM9DS0GyroscopeBandwidth::BW1,
        power_mode: LSM9DS0PowerMode::Normal,
        zen: true,
        yen: true,
        xen: true,
        sensitivity: LSM9DS0GyroscopeFS::dps500,
        continuous_update: true,
        high_pass_filter_enabled: true,
        high_pass_filter_mode: Some(LSM9DS0GyroscopeHighPassFilterMode::NormalMode),
        high_pass_filter_configuration: Some(LSM9DS0HighPassFilterCutOffConfig::HPCF_0)
    };

    let accel_mag_settings = LSM9DS0AccelerometerMagnetometerSettings {
        continuous_update: true,
        accelerometer_data_rate: LSM9DS0AccelerometerUpdateRate::Hz100,
        accelerometer_anti_alias_filter_bandwidth: LSM9DS0AccelerometerFilterBandwidth::Hz50,
        azen: true,
        ayen: true,
        axen: true,
        accelerometer_sensitivity: LSM9DS0AccelerometerFS::g4,
        magnetometer_resolution: LSM9DS0MagnetometerResolution::Low,
        magnetometer_data_rate: LSM9DS0MagnetometerUpdateRate::Hz50,
        magnetometer_low_power_mode: false,
        magnetometer_mode: LSM9DS0MagnetometerMode::ContinuousConversion,
        magnetometer_sensitivity: LSM9DS0MagnetometerFS::gauss2
    };

    let mut lsm9ds0 = LSM9DS0::new(accel_dev, gyro_dev, gyro_settings, accel_mag_settings).unwrap();
}

Settings can be adjusted according to the datasheet.

Commit count: 52

cargo fmt