Struct mpu9250_dmp::Mpu9250 [−][src]
pub struct Mpu9250 { pub accel_fsr: AccelFsr, pub gyro_fsr: GyroFsr, pub debug: bool, pub ak8963_i2c_addr: u16, // some fields omitted }
Fields
accel_fsr: AccelFsr
gyro_fsr: GyroFsr
debug: bool
ak8963_i2c_addr: u16
Methods
impl Mpu9250
[src]
impl Mpu9250
pub fn new(
i2c_bus: i32,
i2c_addr: Option<u16>,
whoami: Option<u8>,
ak8963_i2c_addr: Option<u16>
) -> Result<Self, LinuxI2CError>
[src]
pub fn new(
i2c_bus: i32,
i2c_addr: Option<u16>,
whoami: Option<u8>,
ak8963_i2c_addr: Option<u16>
) -> Result<Self, LinuxI2CError>
Connects to MPU-9250 and checks the WHOAMI.
If i2c_addr is None, defaults to 0x68. From the datasheet, the chip can be configured to respond to 0x68 or 0x69.
If whoami is None, defaults to 0x71 per datasheet, but it is configurable on the chip.
If ak8963_i2c_addr is None, defaults to 0x0c.
Configures the MPU-9250 to:
- Acceleration full-scale range: 2G
- Gyroscope full-scale range: 2000dps
pub fn set_debug(&mut self, debug: bool)
[src]
pub fn set_debug(&mut self, debug: bool)
Debug mode prints various messages to stdout.
pub fn write_config(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn write_config(&mut self) -> Result<(), LinuxI2CError>
Writes the accel and gyro FSRs to the device.
pub fn write_accel_fsr(
&mut self,
accel_fsr: AccelFsr
) -> Result<(), LinuxI2CError>
[src]
pub fn write_accel_fsr(
&mut self,
accel_fsr: AccelFsr
) -> Result<(), LinuxI2CError>
pub fn write_accel_dlpf(
&mut self,
accel_dlpf: AccelDlpf
) -> Result<(), LinuxI2CError>
[src]
pub fn write_accel_dlpf(
&mut self,
accel_dlpf: AccelDlpf
) -> Result<(), LinuxI2CError>
pub fn write_gyro_fsr(&mut self, gyro_fsr: GyroFsr) -> Result<(), LinuxI2CError>
[src]
pub fn write_gyro_fsr(&mut self, gyro_fsr: GyroFsr) -> Result<(), LinuxI2CError>
pub fn write_gyro_dlpf(
&mut self,
gyro_dlpf: GyroDlpf
) -> Result<(), LinuxI2CError>
[src]
pub fn write_gyro_dlpf(
&mut self,
gyro_dlpf: GyroDlpf
) -> Result<(), LinuxI2CError>
pub fn wait_for_nonzero_gyro(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn wait_for_nonzero_gyro(&mut self) -> Result<(), LinuxI2CError>
When the gyro isn't initialized, the register values read zero. This makes it easy to wait for the gyro to initialize. TODO: Is there a ready bit we should be checking instead?
pub fn read_sample(&mut self) -> Result<Mpu9250Sample, LinuxI2CError>
[src]
pub fn read_sample(&mut self) -> Result<Mpu9250Sample, LinuxI2CError>
Reads from dedicated accel & gyro registers. (Not from FIFO)
pub fn enable_bypass(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn enable_bypass(&mut self) -> Result<(), LinuxI2CError>
By enabling bypass, the magnetometer will be directly accessible over the i2c bus.
pub fn disable_bypass(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn disable_bypass(&mut self) -> Result<(), LinuxI2CError>
pub fn reset(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn reset(&mut self) -> Result<(), LinuxI2CError>
After resetting the device, the FSR and DLPF values will need to be set again.
pub fn power_off(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn power_off(&mut self) -> Result<(), LinuxI2CError>
pub fn dmp_enable(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn dmp_enable(&mut self) -> Result<(), LinuxI2CError>
pub fn dmp_disable(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn dmp_disable(&mut self) -> Result<(), LinuxI2CError>
pub fn dmp_interrupt_enable(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn dmp_interrupt_enable(&mut self) -> Result<(), LinuxI2CError>
pub fn dmp_interrupt_disable(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn dmp_interrupt_disable(&mut self) -> Result<(), LinuxI2CError>
pub fn setup_mag_in_fifo(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn setup_mag_in_fifo(&mut self) -> Result<(), LinuxI2CError>
Sets up mag interface on Slv0 interface.
Does not enable fifo. You must still call enable_fifo() to begin populating the fifo with mag data.
Assumes mag is connected to Slv0.
pub fn set_sample_rate(&mut self, rate: u16) -> Result<(), LinuxI2CError>
[src]
pub fn set_sample_rate(&mut self, rate: u16) -> Result<(), LinuxI2CError>
rate is specified as the number of samples per second (Hz). It controls the rate the FIFO is populated by the MPU. It also sets the upper bound rate the FIFO is populated by the DMP. Note: Per the docs, this only works if internal sampling is set to 1kHz.
pub fn reset_fifo(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn reset_fifo(&mut self) -> Result<(), LinuxI2CError>
Disables and then re-enables the fifo. This clears the contents of the fifo.
pub fn enable_fifo(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn enable_fifo(&mut self) -> Result<(), LinuxI2CError>
Enables interrupt and fifo.
pub fn disable_fifo(&mut self) -> Result<(), LinuxI2CError>
[src]
pub fn disable_fifo(&mut self) -> Result<(), LinuxI2CError>
Disables interrupt and fifo. Also resets the fifo and dmp.
pub fn read_fifo_strict(&mut self, count: u16) -> Result<Vec<u8>, FifoReadError>
[src]
pub fn read_fifo_strict(&mut self, count: u16) -> Result<Vec<u8>, FifoReadError>
Reads exactly count bytes from the fifo.