Skip to content

sousandrei/iis2mdc

Folders and files

NameName
Last commit message
Last commit date
Oct 16, 2024
Jun 5, 2024
Jun 5, 2024
Jun 5, 2024
Jun 5, 2024
Jun 5, 2024
Jun 5, 2024
Sep 17, 2022
Sep 17, 2022
Jun 5, 2024

Repository files navigation

Build Status Docs.rs Crates.io

Table of Contents

About the Project πŸ“ƒ

This is a simple driver for ST's iis2mdc sensor.

Documentation for that sensor can be found at ST's website

Usage πŸ‘€

Check out the examples folder for simple implementation

To declare a sensor is pretty simple:

let sensor = Iis2mdc::new(&mut i2c).unwrap()

All registers have the bits addressed by their function, for example here se set the BOOT register in the CTRL_3C register to 1

sensor.cfg_reg_a.set_reboot(i2c, true).unwrap();

For bits that operate together, they have their custom type abstracted. For example, to set the accelerometer data rate you have to operate 4 bits. But here you just have to specify your desired data rate and the driver takes care of it.

// Sets the following bits
// ODR_0 to 1
// ODR_1 to 0

sensor
    .cfg_reg_a
    .set_data_rate(i2c, iis2mdc::cfg_reg_a::Odr::Hz50)
    .unwrap();

Help wanted 🀝

All contributions are welcome!

If you are using or plan to use this create don't hesitate to open an issue or a PR.

Multiple registers are yet to be referenced!

License

See LICENSE for more details.