Crates.io | kxcj9 |
lib.rs | kxcj9 |
version | 0.2.0 |
source | src |
created_at | 2019-04-28 17:01:38.495263 |
updated_at | 2019-05-11 08:55:03.60736 |
description | Platform-agnostic Rust driver for the KXCJ9 ultra-low-power tri-axis accelerometer. |
homepage | https://github.com/eldruin/kxcj9-rs |
repository | https://github.com/eldruin/kxcj9-rs |
max_upload_size | |
id | 130728 |
size | 95,034 |
This is a platform agnostic Rust driver for the KXCJ9 and KXCJB ultra-low-power
tri-axis accelerometers (up to +/-16g) using the embedded-hal
traits.
This driver allows you to:
enable()
.read()
.read_unscaled()
.set_resolution()
.set_output_data_rate()
.set_scale()
.WHO_AM_I
register. See who_am_i()
.reset()
.communication_self_test()
.enable_mems_self_test()
.enable_data_ready_interrupt()
.enable_wake_up_interrupt()
.enable_interrupt_pin()
.set_interrupt_pin_polarity()
.set_interrupt_pin_latching()
.has_interrupt_happened()
.clear_interrupts()
.read_interrupt_info()
.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 KXCJB is the thinnest tri-axis accelerometer available on the market today. This ultra-thin 3x3x0.45mm low-power accelerometer is also one of our most full-featured products. The KXCJB offers up to 14-bit resolution for greater precision. User-selectable parameters include ± 2g, 4g or 8g ranges and Output Data Rates (ODR) with programmable low-pass filter. The KXCJB also features the Kionix XAC sense element, our most advanced sense element, for outstanding stability over temperature, shock and post-reflow performance.
The communication is done through an I2C bidirectional bus.
Datasheets:
Application Note:
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
extern crate kxcj9;
extern crate linux_embedded_hal 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_kxcj9_1018(dev, address);
sensor.enable().unwrap();
loop {
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.