[][src]Struct kxcj9::Kxcj9

pub struct Kxcj9<I2C, IC> { /* fields omitted */ }

KXCJ9/KXCJB device driver

Methods

impl<I2C, E> Kxcj9<I2C, G8Device> where
    I2C: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn new_kxcj9_1008(i2c: I2C, address: SlaveAddr) -> Self[src]

Create new instance of the KXCJ9-1008 device.

pub fn new_kxcjb_1041(i2c: I2C, address: SlaveAddr) -> Self[src]

Create new instance of the KXCJB-1041 device.

impl<I2C, E> Kxcj9<I2C, G16Device> where
    I2C: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn new_kxcj9_1018(i2c: I2C, address: SlaveAddr) -> Self[src]

Create new instance of the KXCJ9-1018 device.

impl<I2C, E, IC> Kxcj9<I2C, IC> where
    I2C: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

pub fn enable(&mut self) -> Result<(), Error<E>>[src]

Enable the device (starts taking measurements).

pub fn disable(&mut self) -> Result<(), Error<E>>[src]

Disable the device.

impl<I2C, E, IC> Kxcj9<I2C, IC> where
    I2C: WriteRead<Error = E> + Write<Error = E>,
    IC: ScaledDevice, 
[src]

pub fn read(&mut self) -> Result<Measurement, Error<E>>[src]

Read acceleration sensor data scaled to the configured G range.

impl<I2C, E, IC> Kxcj9<I2C, IC> where
    I2C: WriteRead<Error = E> + Write<Error = E>,
    IC: ScaledDevice, 
[src]

pub fn read_unscaled(&mut self) -> Result<UnscaledMeasurement, Error<E>>[src]

Read unscaled acceleration sensor data.

pub fn who_am_i(&mut self) -> Result<u8, Error<E>>[src]

Read the WHO_AM_I register. Depending on the device this should return:

  • 0x0A for KXCJ9-1008
  • 0x1D for KXCJ9-1018
  • 0x21 for KXCJB-1041

pub fn set_resolution(&mut self, resolution: Resolution) -> Result<(), Error<E>>[src]

Set resolution.

Returns Err(Error::InvalidSetting) if setting Resolution::Low but the configured output data rate is greater or equal to 400 Hz.

pub fn set_output_data_rate(
    &mut self,
    odr: OutputDataRate
) -> Result<(), Error<E>>
[src]

Set output data rate.

Setting a rate higher than or equal to 400Hz sets the resolution to high.

pub fn enable_data_ready_interrupt(&mut self) -> Result<(), Error<E>>[src]

Enable new acceleration data ready interrupt.

pub fn disable_data_ready_interrupt(&mut self) -> Result<(), Error<E>>[src]

Disable new acceleration data ready interrupt.

pub fn enable_wake_up_interrupt(
    &mut self,
    config: WakeUpInterruptConfig
) -> Result<(), Error<E>>
[src]

Configure and enable wake-up motion detected interrupt.

pub fn disable_wake_up_interrupt(&mut self) -> Result<(), Error<E>>[src]

Disable wake-up motion detected interrupt.

pub fn enable_interrupt_pin(&mut self) -> Result<(), Error<E>>[src]

Enable physical interrupt pin.

pub fn disable_interrupt_pin(&mut self) -> Result<(), Error<E>>[src]

Disable physical interrupt pin.

pub fn set_interrupt_pin_polarity(
    &mut self,
    polarity: InterruptPinPolarity
) -> Result<(), Error<E>>
[src]

Set physical interrupt pin polarity.

pub fn set_interrupt_pin_latching(
    &mut self,
    latching: InterruptPinLatching
) -> Result<(), Error<E>>
[src]

Set physical interrupt pin latching behavior.

pub fn has_interrupt_happened(&mut self) -> Result<bool, Error<E>>[src]

Check if any interrupt has happened.

pub fn read_interrupt_info(&mut self) -> Result<InterruptInfo, Error<E>>[src]

Read interrupt source information.

pub fn clear_interrupts(&mut self) -> Result<(), Error<E>>[src]

Clear interrupts.

This clears all interrupt source registers and changes the physical interrupt pin to its inactive state.

pub fn reset(&mut self) -> Result<(), Error<E>>[src]

Perform software reset.

This method offers a non-blocking interface. While the reset is in progress and when the reset was first triggered this will return nb::Error::WouldBlock.

pub fn communication_self_test(&mut self) -> Result<(), Error<E>>[src]

Perform a digital communication self-test.

pub fn enable_mems_self_test(&mut self) -> Result<(), Error<E>>[src]

Enable the MEMS self-test function.

pub fn disable_mems_self_test(&mut self) -> Result<(), Error<E>>[src]

Disable the MEMS self-test function.

impl<I2C, E> Kxcj9<I2C, G16Device> where
    I2C: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn set_scale(&mut self, scale: GScale16) -> Result<(), Error<E>>[src]

Set G scale.

impl<I2C, E> Kxcj9<I2C, G8Device> where
    I2C: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn set_scale(&mut self, scale: GScale8) -> Result<(), Error<E>>[src]

Set G scale.

Trait Implementations

impl<I2C: Debug, IC: Debug> Debug for Kxcj9<I2C, IC>[src]

Auto Trait Implementations

impl<I2C, IC> Send for Kxcj9<I2C, IC> where
    I2C: Send,
    IC: Send

impl<I2C, IC> Sync for Kxcj9<I2C, IC> where
    I2C: Sync,
    IC: Sync

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]