This is a platform agnostic Rust driver for the KXCJ9 ultra-low-power tri-axis accelerometer
(up to +/-16g) using the [embedded-hal
] traits.
This driver allows you to:
- Enable/disable the device. See enable()
.
- Read the acceleration measurement. See read()
.
- Read the unscaled acceleration measurement. See read_unscaled()
.
- Set resolution. See set_resolution()
.
- Set output data rate. See set_output_data_rate()
.
- Set +/- G range. See set_scale()
.
- Read WHO_AM_I
register. See who_am_i()
.
- Perform a software reset. See reset()
.
- Run a communication self-test. See self_test()
.
The KXCJ9 is a high-performance, ultra-low-power, tri-axis accelerometer designed for mobile applications. It offers our best power performance along with an embedded wake-up feature, Fast-mode I²C and up to 14-bit resolution. The KXCJ9 sensor offers improved shock, reflow, and temperature performance, and the ASIC has internal voltage regulators that allow operation from 1.8 V to 3.6 V within the specified product performance.
The communication is done through an I2C bidirectional bus.
Datasheet: - KXCJ9-1008 - KXCJ9-1018
Application Note: - Getting started with the KXCJ9 and KXCJB
To use this driver, import this crate and an embedded_hal
implementation,
then instantiate the appropriate device.
Please find additional examples using hardware in this repository: [driver-examples]
```rust extern crate kxcj9; extern crate linuxembeddedhal as hal; use kxcj9::{Kxcj9, SlaveAddr};
fn main() { let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); let address = SlaveAddr::default(); let mut sensor = Kxcj9::new_1018(dev, address); sensor.enable().unwrap(); let acc = sensor.read().unwrap(); println!("X: {:2}, Y: {:2}, Z: {:2}", acc.x, acc.y, acc.z); } ```
For questions, issues, feature requests, and other changes, please file an issue in the github project.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.