27#define DEFAULT_MPU_HZ (100)
29#define INV_X_GYRO (0x40)
30#define INV_Y_GYRO (0x20)
31#define INV_Z_GYRO (0x10)
32#define INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO)
33#define INV_XYZ_ACCEL (0x08)
34#define INV_XYZ_COMPASS (0x01)
50#define MPU_INT_STATUS_DATA_READY (0x0001)
51#define MPU_INT_STATUS_DMP (0x0002)
52#define MPU_INT_STATUS_PLL_READY (0x0004)
53#define MPU_INT_STATUS_I2C_MST (0x0008)
54#define MPU_INT_STATUS_FIFO_OVERFLOW (0x0010)
55#define MPU_INT_STATUS_ZMOT (0x0020)
56#define MPU_INT_STATUS_MOT (0x0040)
57#define MPU_INT_STATUS_FREE_FALL (0x0080)
58#define MPU_INT_STATUS_DMP_0 (0x0100)
59#define MPU_INT_STATUS_DMP_1 (0x0200)
60#define MPU_INT_STATUS_DMP_2 (0x0400)
61#define MPU_INT_STATUS_DMP_3 (0x0800)
62#define MPU_INT_STATUS_DMP_4 (0x1000)
63#define MPU_INT_STATUS_DMP_5 (0x2000)
73 unsigned char lpa_freq);
114int mpu_read_fifo(
short *gyro,
short *accel,
unsigned long *timestamp,
115 unsigned char *sensors,
unsigned char *more);
117 unsigned char *more);
120int mpu_write_mem(
unsigned short mem_addr,
unsigned short length,
121 unsigned char *data);
122int mpu_read_mem(
unsigned short mem_addr,
unsigned short length,
123 unsigned char *data);
125 unsigned short start_addr,
unsigned short sample_rate);
132void mget_ms(
unsigned long *time);
int mpu_set_sample_rate(unsigned short rate)
Set sampling rate. Sampling rate must be between 4Hz and 1kHz.
int mpu_get_gyro_sens(float *sens)
Get gyro sensitivity scale factor.
int mpu_get_fifo_config(unsigned char *sensors)
Get current FIFO configuration. sensors can contain a combination of the following flags: INV_X_GYR...
int mpu_get_int_status(short *status)
Read the MPU interrupt status registers.
int mpu_register_tap_cb(void(*func)(unsigned char, unsigned char))
int mpu_reg_dump(void)
Register dump for testing.
int mpu_read_fifo_stream(unsigned short length, unsigned char *data, unsigned char *more)
Get one unparsed packet from the FIFO. This function should be used if the packet is to be parsed els...
int mpu_get_sample_rate(unsigned short *rate)
Get sampling rate.
int mpu_set_accel_fsr(unsigned char fsr)
Set the accel full-scale range.
unsigned short inv_row_2_scale(const signed char *row)
int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp, unsigned char *sensors, unsigned char *more)
Get one packet from the FIFO. If sensors does not contain a particular sensor, disregard the data ret...
int mpu_read_mem(unsigned short mem_addr, unsigned short length, unsigned char *data)
Read from the DMP memory. This function prevents I2C reads past the bank boundaries....
int mpu_set_bypass(unsigned char bypass_on)
Set device to bypass mode.
int mpu_run_self_test(long *gyro, long *accel)
Trigger gyro/accel/compass self-test. On success/error, the self-test returns a mask representing the...
int mpu_lp_accel_mode(unsigned char rate)
Enter low-power accel-only mode. In low-power accel mode, the chip goes to sleep and only wakes up to...
unsigned short inv_orientation_matrix_to_scalar(const signed char *mtx)
int mpu_set_accel_bias(const long *accel_bias)
Push biases to the accel bias registers. This function expects biases relative to the current sensor ...
const struct gyro_reg_s reg
int mpu_get_gyro_reg(short *data, unsigned long *timestamp)
Read raw gyro data directly from the registers.
int mpu_set_lpf(unsigned short lpf)
Set digital low pass filter. The following LPF settings are supported: 188, 98, 42,...
int mpu_read_reg(unsigned char reg, unsigned char *data)
Read from a single register. NOTE: The memory and FIFO read/write registers cannot be accessed.
int mpu_get_accel_sens(unsigned short *sens)
Get accel sensitivity scale factor.
int mpu_set_int_latched(unsigned char enable)
Enable latched interrupts. Any MPU register will clear the interrupt.
int mpu_get_compass_reg(short *data, unsigned long *timestamp)
Read raw compass data.
int mpu_set_dmp_state(unsigned char enable)
Enable/disable DMP support.
int mpu_set_sensors(unsigned char sensors)
Turn specific sensors on/off. sensors can contain a combination of the following flags: INV_X_GYRO,...
int mpu_set_compass_sample_rate(unsigned short rate)
Set compass sampling rate. The compass on the auxiliary I2C bus is read by the MPU hardware at a maxi...
int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time, unsigned char lpa_freq)
Enters LP accel motion interrupt mode. The behavior of this feature is very different between the MPU...
int mpu_load_firmware(unsigned short length, const unsigned char *firmware, unsigned short start_addr, unsigned short sample_rate)
Load and verify DMP image.
int mpu_get_temperature(long *data, unsigned long *timestamp)
Read temperature data directly from the registers.
int mpu_get_lpf(unsigned short *lpf)
Get the current DLPF setting.
int mpu_get_compass_sample_rate(unsigned short *rate)
Get compass sampling rate.
int mpu_get_accel_fsr(unsigned char *fsr)
Get the accel full-scale range.
int mpu_configure_fifo(unsigned char sensors)
Select which sensors are pushed to FIFO. sensors can contain a combination of the following flags: ...
int mpu_init(void)
Initialize hardware. Initial configuration: Gyro FSR: +/- 2000DPS Accel FSR +/- 2G DLPF: 42Hz FIFO ra...
u8 mpu_dmp_get_data(float *pitch, float *roll, float *yaw)
int mpu_set_int_level(unsigned char active_low)
Set interrupt level.
int mpu_set_gyro_fsr(unsigned short fsr)
Set the gyro full-scale range.
int mpu_get_compass_fsr(unsigned short *fsr)
Get the compass full-scale range.
int mpu_get_accel_reg(short *data, unsigned long *timestamp)
Read raw accel data directly from the registers.
int mpu_get_power_state(unsigned char *power_on)
Get current power state.
int mpu_reset_fifo(void)
Reset FIFO read/write pointers.
int mpu_get_gyro_fsr(unsigned short *fsr)
Get the gyro full-scale range.
void mget_ms(unsigned long *time)
int mpu_get_dmp_state(unsigned char *enabled)
Get DMP state.
int mpu_write_mem(unsigned short mem_addr, unsigned short length, unsigned char *data)
Write to the DMP memory. This function prevents I2C writes past the bank boundaries....