Crates.io | lis3dh-spi |
lib.rs | lis3dh-spi |
version | 0.0.5 |
source | src |
created_at | 2021-10-19 09:01:52.1641 |
updated_at | 2022-02-11 11:54:24.780944 |
description | no_std driver for the ultra-low-power high-performance 3-axis "nano" accelerometer LIS3DH using SPI |
homepage | |
repository | https://github.com/robhany/lis3dh-spi |
max_upload_size | |
id | 467294 |
size | 59,712 |
This crate is a no_std driver for the LIS3DH accelerometer using SPI.
https://www.st.com/resource/en/datasheet/lis3dh.pdf
This driver is not consuming the SPI bus the communication is running on. Bus has to be passed as mutable reference when interacting with the LIS3DH.
Add this to your Cargo.toml:
[dependencies]
lis3dh-spi = "0.0.5"
And this to your main.rs
let mut accelerometer = lis3dh_spi::Lis3dh::default();
accelerometer.set_l_p_en(LPEn::HighResolutionNormalMode);
accelerometer.set_output_data_rate(ODR::Hz400);
accelerometer.write_all_settings(&mut chip_select_pin, &mut spi_bus).ok();
let angle_and_gravity_offset = accelerometer.get_angle_and_gravity_offset(&mut chip_select_pin, &mut spi_bus).ok();
Licensed under either of
at your option.