Crates.io | adxl313 |
lib.rs | adxl313 |
version | 0.2.4 |
source | src |
created_at | 2020-06-24 20:49:41.390227 |
updated_at | 2020-10-08 11:24:09.897052 |
description | A platform agnostic driver to interface with the ADXL313 (accelerometer) through SPI |
homepage | |
repository | https://github.com/mvniekerk/adxl313-rs |
max_upload_size | |
id | 257672 |
size | 36,154 |
Rust HAL implementation (using SPI drivers) for Analog Device's ADXL313 3-axis accelerometer. Based off the adxl355 crate
Include library as a dependency in your Cargo.toml
[dependencies.adxl313]
version = "<version>"
Use embedded-hal implementation to get SPI and a GPIO OutputPin for the chip select, then create the accelerometer handle
use adxl313::{Adxl313, Accelerometer};
// to create sensor with default configuration:
let mut accelerometer = Adxl313::new(spi, cs)?;
// start measurements
accelerometer.start_measuring();
// to get 3d accerlation data:
let accel = accelerometer.acceleration()?;
println!("{:?}", accel);