Crate mc3479

Crate mc3479 

Source
Expand description

§MC3479

A Rust driver for the MEMSIC MC3479 16-bit 3-axis accelerometer.

The device has two different operational states, standby and wake, and reconfiguring the device is only allowed in the standby state. These two states are realized in the form of two different Rust types, StandbyState and WakeState, with methods that allow for transitioning from one state to the other.

§Example

let mut standby = match mc3479::StandbyState::new(i2c, TargetAddr::Addr0) {
    Ok(standby) => standby,
    Err((err, _i2c)) => {
        panic!("Failed to initialize MC3479 driver: {err}");
    },
};
standby.set_sample_rate(SampleRate::_1000Hz).unwrap();
standby.set_range(Range::_8g).unwrap();
standby.set_fifo_enabled(true).unwrap();
let wake = match standby.wake() {
    Ok(wake) => wake,
    Err((err, _standby)) => panic!("Failed to transition to wake state: {err}"),
};

Structs§

AccelerometerData
Accelerometer sensor values expressed in milli g-force.
FifoControl
FifoStatus
I2cReadError
I2cWriteError
StandbyState
Represents an MC3479 device in the standby state.
WakeState
An MC3479 device in the standby state

Enums§

InitializationError
Range
Accelerometer resolution range
Register
SampleRate
Selects the sampling output data rate.
TargetAddr
I2C address of the target

Constants§

MC3479_CHIP_ID
Expected chip ID of the device.