#no-std-driver #spi #accelerometer #en #nano #3-axis #lis3dh

no-std lis3dh-spi

no_std driver for the ultra-low-power high-performance 3-axis "nano" accelerometer LIS3DH using SPI

4 releases

0.0.5 Feb 11, 2022
0.0.4 Jan 24, 2022
0.0.3 Jan 19, 2022
0.0.2 Oct 19, 2021
0.0.1 Oct 19, 2021

#819 in Embedded development

MIT/Apache

47KB
1.5K SLoC

lis3dh-spi

build_workflow Crates.io Version Crates.io Downloads No Std

This crate is a no_std driver for the LIS3DH accelerometer using SPI.

Datasheet

https://www.st.com/resource/en/datasheet/lis3dh.pdf

About this driver

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.

Usage

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();

License

Licensed under either of

at your option.

Dependencies

~2.5MB
~54K SLoC