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§
- Accelerometer
Data - Accelerometer sensor values expressed in milli g-force.
- Fifo
Control - Fifo
Status - I2cRead
Error - I2cWrite
Error - Standby
State - Represents an MC3479 device in the standby state.
- Wake
State - An MC3479 device in the standby state
Enums§
- Initialization
Error - Range
- Accelerometer resolution range
- Register
- Sample
Rate - Selects the sampling output data rate.
- Target
Addr - I2C address of the target
Constants§
- MC3479_
CHIP_ ID - Expected chip ID of the device.