adxl355

Crates.ioadxl355
lib.rsadxl355
version0.2.3
sourcesrc
created_at2019-12-30 18:37:20.217488
updated_at2020-02-14 12:34:28.953151
descriptionA platform agnostic driver to interface with the ADXL355 (accelerometer) through SPI
homepage
repositoryhttps://github.com/JitterCompany/adxl355-rs
max_upload_size
id193587
size258,030
Ingmar Jager (ijager)

documentation

https://docs.rs/adxl355

README

ADXL355 embedded-hal SPI driver crate

Usage

Include library as a dependency in your Cargo.toml

[dependencies.adxl355]
version = "<version>"

Use embedded-hal implementation to get SPI and a GPIO OutputPin for the chip select, then create the accelerometer handle


use adxl355::{Adxl355, Accelerometer};

// to create sensor with default configuration:
let mut accelerometer = Adxl355::default(spi, cs)?;

// start measurements
accelerometer.start();

// to get 3d accerlation data:
let accel = accelerometer.acceleration()?;
println!("{:?}", accel);


// One can also use conf module to supply configuration:

use adxl355::{Adxl355, Config as ADXLConfig, ODR_LPF, Range, Accelerometer};

Adxl355::new(spi, cs,
                     ADXLConfig::new()
                     .odr(ODR_LPF::ODR_31_25_Hz)
                     .range(Range::_2G))?;

Running the examples

Blackpill board (STM32F103)

Example based on the stm32f103 microcontroller [examples/blackpill.rs]

To build an example

cargo build --example blackpill --features="stm32f103"

And run immediately. Flashing with black magic probe using bmp.sh script (only works for MacOS at the moment).

cargo run --example blackpill --features="stm32f103"

STM32G070 [DISABLED UNTIL NEXT STM32G0xx-hal UPDATE]

Example based on the stm32g070 microcontroller [examples/stm32g070.rs]

To build an example

cargo build --example stm32g070 --features=stm32g070 --target thumbv6m-none-eabi

The resulting ELF file can be found under target/thumbv6m-none-eabi/examples/.

To run immediately

cargo run --example stm32g070 --features=stm32g070 --target thumbv6m-none-eabi

This will make use of flash.sh that assumes the st-link utilities are available in your PATH.

Example with normalized data

cargo run --example norm_stm32g070 --features=stm32g070 --target thumbv6m-none-eabi
Commit count: 22

cargo fmt