Embedded MotionDriver 6.1 Sourced from InvenSense
Hardware drivers to communicate with sensors via I2C. More...
Files | |
file | inv_mpu.c |
An I2C-based driver for Invensense gyroscopes. | |
file | inv_mpu.h |
An I2C-based driver for Invensense gyroscopes. | |
file | inv_mpu_dmp_motion_driver.c |
DMP image and interface functions. | |
file | inv_mpu_dmp_motion_driver.h |
DMP image and interface functions. | |
Functions | |
static int | set_int_enable (unsigned char enable) |
Enable/disable data ready interrupt. | |
int | mpu_reg_dump (void) |
Register dump for testing. | |
int | mpu_read_reg (unsigned char reg, unsigned char *data) |
Read from a single register. | |
int | mpu_init (struct int_param_s *int_param) |
Initialize hardware. | |
int | mpu_lp_accel_mode (unsigned short rate) |
Enter low-power accel-only mode. | |
int | mpu_get_gyro_reg (short *data, unsigned long *timestamp) |
Read raw gyro data directly from the registers. | |
int | mpu_get_accel_reg (short *data, unsigned long *timestamp) |
Read raw accel data directly from the registers. | |
int | mpu_get_temperature (long *data, unsigned long *timestamp) |
Read temperature data directly from the registers. | |
int | mpu_read_6500_accel_bias (long *accel_bias) |
Read biases to the accel bias 6500 registers. | |
int | mpu_read_6050_accel_bias (long *accel_bias) |
Read biases to the accel bias 6050 registers. | |
int | mpu_set_gyro_bias_reg (long *gyro_bias) |
Push biases to the gyro bias 6500/6050 registers. | |
int | mpu_set_accel_bias_6050_reg (const long *accel_bias) |
Push biases to the accel bias 6050 registers. | |
int | mpu_set_accel_bias_6500_reg (const long *accel_bias) |
Push biases to the accel bias 6500 registers. | |
int | mpu_reset_fifo (void) |
Reset FIFO read/write pointers. | |
int | mpu_get_gyro_fsr (unsigned short *fsr) |
Get the gyro full-scale range. | |
int | mpu_set_gyro_fsr (unsigned short fsr) |
Set the gyro full-scale range. | |
int | mpu_get_accel_fsr (unsigned char *fsr) |
Get the accel full-scale range. | |
int | mpu_set_accel_fsr (unsigned char fsr) |
Set the accel full-scale range. | |
int | mpu_get_lpf (unsigned short *lpf) |
Get the current DLPF setting. | |
int | mpu_set_lpf (unsigned short lpf) |
Set digital low pass filter. | |
int | mpu_get_sample_rate (unsigned short *rate) |
Get sampling rate. | |
int | mpu_set_sample_rate (unsigned short rate) |
Set sampling rate. | |
int | mpu_get_compass_sample_rate (unsigned short *rate) |
Get compass sampling rate. | |
int | mpu_set_compass_sample_rate (unsigned short rate) |
Set compass sampling rate. | |
int | mpu_get_gyro_sens (float *sens) |
Get gyro sensitivity scale factor. | |
int | mpu_get_accel_sens (unsigned short *sens) |
Get accel sensitivity scale factor. | |
int | mpu_get_fifo_config (unsigned char *sensors) |
Get current FIFO configuration. | |
int | mpu_configure_fifo (unsigned char sensors) |
Select which sensors are pushed to FIFO. | |
int | mpu_get_power_state (unsigned char *power_on) |
Get current power state. | |
int | mpu_set_sensors (unsigned char sensors) |
Turn specific sensors on/off. | |
int | mpu_get_int_status (short *status) |
Read the MPU interrupt status registers. | |
int | mpu_read_fifo (short *gyro, short *accel, unsigned long *timestamp, unsigned char *sensors, unsigned char *more) |
Get one packet from the FIFO. | |
int | mpu_read_fifo_stream (unsigned short length, unsigned char *data, unsigned char *more) |
Get one unparsed packet from the FIFO. | |
int | mpu_set_bypass (unsigned char bypass_on) |
Set device to bypass mode. | |
int | mpu_set_int_level (unsigned char active_low) |
Set interrupt level. | |
int | mpu_set_int_latched (unsigned char enable) |
Enable latched interrupts. | |
int | mpu_run_6500_self_test (long *gyro, long *accel, unsigned char debug) |
Trigger gyro/accel/compass self-test for MPU6500/MPU9250 On success/error, the self-test returns a mask representing the sensor(s) that failed. | |
int | mpu_write_mem (unsigned short mem_addr, unsigned short length, unsigned char *data) |
Write to the DMP memory. | |
int | mpu_read_mem (unsigned short mem_addr, unsigned short length, unsigned char *data) |
Read from the DMP memory. | |
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_set_dmp_state (unsigned char enable) |
Enable/disable DMP support. | |
int | mpu_get_dmp_state (unsigned char *enabled) |
Get DMP state. | |
int | mpu_get_compass_reg (short *data, unsigned long *timestamp) |
Read raw compass data. | |
int | mpu_get_compass_fsr (unsigned short *fsr) |
Get the compass full-scale range. | |
int | mpu_lp_motion_interrupt (unsigned short thresh, unsigned char time, unsigned short lpa_freq) |
Enters LP accel motion interrupt mode. | |
int | dmp_load_motion_driver_firmware (void) |
Load the DMP with this image. | |
int | dmp_set_orientation (unsigned short orient) |
Push gyro and accel orientation to the DMP. | |
int | dmp_set_gyro_bias (long *bias) |
Push gyro biases to the DMP. | |
int | dmp_set_accel_bias (long *bias) |
Push accel biases to the DMP. | |
int | dmp_set_fifo_rate (unsigned short rate) |
Set DMP output rate. | |
int | dmp_get_fifo_rate (unsigned short *rate) |
Get DMP output rate. | |
int | dmp_set_tap_thresh (unsigned char axis, unsigned short thresh) |
Set tap threshold for a specific axis. | |
int | dmp_set_tap_axes (unsigned char axis) |
Set which axes will register a tap. | |
int | dmp_set_tap_count (unsigned char min_taps) |
Set minimum number of taps needed for an interrupt. | |
int | dmp_set_tap_time (unsigned short time) |
Set length between valid taps. | |
int | dmp_set_tap_time_multi (unsigned short time) |
Set max time between taps to register as a multi-tap. | |
int | dmp_set_shake_reject_thresh (long sf, unsigned short thresh) |
Set shake rejection threshold. | |
int | dmp_set_shake_reject_time (unsigned short time) |
Set shake rejection time. | |
int | dmp_set_shake_reject_timeout (unsigned short time) |
Set shake rejection timeout. | |
int | dmp_get_pedometer_step_count (unsigned long *count) |
Get current step count. | |
int | dmp_set_pedometer_step_count (unsigned long count) |
Overwrite current step count. | |
int | dmp_get_pedometer_walk_time (unsigned long *time) |
Get duration of walking time. | |
int | dmp_set_pedometer_walk_time (unsigned long time) |
Overwrite current walk time. | |
int | dmp_enable_feature (unsigned short mask) |
Enable DMP features. | |
int | dmp_get_enabled_features (unsigned short *mask) |
Get list of currently enabled DMP features. | |
int | dmp_enable_gyro_cal (unsigned char enable) |
Calibrate the gyro data in the DMP. | |
int | dmp_enable_lp_quat (unsigned char enable) |
Generate 3-axis quaternions from the DMP. | |
int | dmp_enable_6x_lp_quat (unsigned char enable) |
Generate 6-axis quaternions from the DMP. | |
static int | decode_gesture (unsigned char *gesture) |
Decode the four-byte gesture data and execute any callbacks. | |
int | dmp_set_interrupt_mode (unsigned char mode) |
Specify when a DMP interrupt should occur. | |
int | dmp_read_fifo (short *gyro, short *accel, long *quat, unsigned long *timestamp, short *sensors, unsigned char *more) |
Get one packet from the FIFO. | |
int | dmp_register_tap_cb (void(*func)(unsigned char, unsigned char)) |
Register a function to be executed on a tap event. | |
int | dmp_register_android_orient_cb (void(*func)(unsigned char)) |
Register a function to be executed on a android orientation event. |
Detailed Description
Hardware drivers to communicate with sensors via I2C.
Function Documentation
static int decode_gesture | ( | unsigned char * | gesture ) | [static] |
Decode the four-byte gesture data and execute any callbacks.
- Parameters:
-
[in] gesture Gesture data from DMP packet.
- Returns:
- 0 if successful.
Definition at line 1194 of file inv_mpu_dmp_motion_driver.c.
int dmp_enable_6x_lp_quat | ( | unsigned char | enable ) |
Generate 6-axis quaternions from the DMP.
In this driver, the 3-axis and 6-axis DMP quaternion features are mutually exclusive.
- Parameters:
-
[in] enable 1 to enable 6-axis quaternion.
- Returns:
- 0 if successful.
Definition at line 1173 of file inv_mpu_dmp_motion_driver.c.
int dmp_enable_feature | ( | unsigned short | mask ) |
Enable DMP features.
The following #define's are used in the input mask:
DMP_FEATURE_TAP
DMP_FEATURE_ANDROID_ORIENT
DMP_FEATURE_LP_QUAT
DMP_FEATURE_6X_LP_QUAT
DMP_FEATURE_GYRO_CAL
DMP_FEATURE_SEND_RAW_ACCEL
DMP_FEATURE_SEND_RAW_GYRO
NOTE: DMP_FEATURE_LP_QUAT and DMP_FEATURE_6X_LP_QUAT are mutually exclusive.
NOTE: DMP_FEATURE_SEND_RAW_GYRO and DMP_FEATURE_SEND_CAL_GYRO are also mutually exclusive.
- Parameters:
-
[in] mask Mask of features to enable.
- Returns:
- 0 if successful.
Definition at line 994 of file inv_mpu_dmp_motion_driver.c.
int dmp_enable_gyro_cal | ( | unsigned char | enable ) |
Calibrate the gyro data in the DMP.
After eight seconds of no motion, the DMP will compute gyro biases and subtract them from the quaternion output. If dmp_enable_feature is called with DMP_FEATURE_SEND_CAL_GYRO, the biases will also be subtracted from the gyro output.
- Parameters:
-
[in] enable 1 to enable gyro calibration.
- Returns:
- 0 if successful.
Definition at line 1131 of file inv_mpu_dmp_motion_driver.c.
int dmp_enable_lp_quat | ( | unsigned char | enable ) |
Generate 3-axis quaternions from the DMP.
In this driver, the 3-axis and 6-axis DMP quaternion features are mutually exclusive.
- Parameters:
-
[in] enable 1 to enable 3-axis quaternion.
- Returns:
- 0 if successful.
Definition at line 1149 of file inv_mpu_dmp_motion_driver.c.
int dmp_get_enabled_features | ( | unsigned short * | mask ) |
Get list of currently enabled DMP features.
- Parameters:
-
[out] Mask of enabled features.
- Returns:
- 0 if successful.
Definition at line 1116 of file inv_mpu_dmp_motion_driver.c.
int dmp_get_fifo_rate | ( | unsigned short * | rate ) |
Get DMP output rate.
- Parameters:
-
[out] rate Current fifo rate (Hz).
- Returns:
- 0 if successful.
Definition at line 707 of file inv_mpu_dmp_motion_driver.c.
int dmp_get_pedometer_step_count | ( | unsigned long * | count ) |
Get current step count.
- Parameters:
-
[out] count Number of steps detected.
- Returns:
- 0 if successful.
Definition at line 907 of file inv_mpu_dmp_motion_driver.c.
int dmp_get_pedometer_walk_time | ( | unsigned long * | time ) |
Get duration of walking time.
- Parameters:
-
[in] time Walk time in milliseconds.
- Returns:
- 0 if successful.
Definition at line 944 of file inv_mpu_dmp_motion_driver.c.
int dmp_load_motion_driver_firmware | ( | void | ) |
Load the DMP with this image.
- Returns:
- 0 if successful.
Definition at line 509 of file inv_mpu_dmp_motion_driver.c.
int dmp_read_fifo | ( | short * | gyro, |
short * | accel, | ||
long * | quat, | ||
unsigned long * | timestamp, | ||
short * | sensors, | ||
unsigned char * | more | ||
) |
Get one packet from the FIFO.
If sensors does not contain a particular sensor, disregard the data returned to that pointer.
sensors can contain a combination of the following flags:
INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
INV_XYZ_GYRO
INV_XYZ_ACCEL
INV_WXYZ_QUAT
If the FIFO has no new data, sensors will be zero.
If the FIFO is disabled, sensors will be zero and this function will return a non-zero error code.
- Parameters:
-
[out] gyro Gyro data in hardware units. [out] accel Accel data in hardware units. [out] quat 3-axis quaternion data in hardware units. [out] timestamp Timestamp in milliseconds. [out] sensors Mask of sensors read from FIFO. [out] more Number of remaining packets.
- Returns:
- 0 if successful.
Definition at line 1265 of file inv_mpu_dmp_motion_driver.c.
int dmp_register_android_orient_cb | ( | void(*)(unsigned char) | func ) |
Register a function to be executed on a android orientation event.
- Parameters:
-
[in] func Callback function.
- Returns:
- 0 if successful.
Definition at line 1369 of file inv_mpu_dmp_motion_driver.c.
int dmp_register_tap_cb | ( | void(*)(unsigned char, unsigned char) | func ) |
Register a function to be executed on a tap event.
The tap direction is represented by one of the following:
TAP_X_UP
TAP_X_DOWN
TAP_Y_UP
TAP_Y_DOWN
TAP_Z_UP
TAP_Z_DOWN
- Parameters:
-
[in] func Callback function.
- Returns:
- 0 if successful.
Definition at line 1358 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_accel_bias | ( | long * | bias ) |
Push accel biases to the DMP.
These biases will be removed from the DMP 6-axis quaternion.
- Parameters:
-
[in] bias Accel biases in q16.
- Returns:
- 0 if successful.
Definition at line 629 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_fifo_rate | ( | unsigned short | rate ) |
Set DMP output rate.
Only used when DMP is on.
- Parameters:
-
[in] rate Desired fifo rate (Hz).
- Returns:
- 0 if successful.
Definition at line 681 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_gyro_bias | ( | long * | bias ) |
Push gyro biases to the DMP.
Because the gyro integration is handled in the DMP, any gyro biases calculated by the MPL should be pushed down to DMP memory to remove 3-axis quaternion drift.
NOTE: If the DMP-based gyro calibration is enabled, the DMP will overwrite the biases written to this location once a new one is computed.
- Parameters:
-
[in] bias Gyro biases in q16.
- Returns:
- 0 if successful.
Definition at line 577 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_interrupt_mode | ( | unsigned char | mode ) |
Specify when a DMP interrupt should occur.
A DMP interrupt can be configured to trigger on either of the two conditions below:
a. One FIFO period has elapsed (set by mpu_set_sample_rate).
b. A tap event has been detected.
- Parameters:
-
[in] mode DMP_INT_GESTURE or DMP_INT_CONTINUOUS.
- Returns:
- 0 if successful.
Definition at line 1226 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_orientation | ( | unsigned short | orient ) |
Push gyro and accel orientation to the DMP.
The orientation is represented here as the output of inv_orientation_matrix_to_scalar.
- Parameters:
-
[in] orient Gyro and accel orientation in body frame.
- Returns:
- 0 if successful.
Definition at line 522 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_pedometer_step_count | ( | unsigned long | count ) |
Overwrite current step count.
WARNING: This function writes to DMP memory and could potentially encounter a race condition if called while the pedometer is enabled.
- Parameters:
-
[in] count New step count.
- Returns:
- 0 if successful.
Definition at line 928 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_pedometer_walk_time | ( | unsigned long | time ) |
Overwrite current walk time.
WARNING: This function writes to DMP memory and could potentially encounter a race condition if called while the pedometer is enabled.
- Parameters:
-
[in] time New walk time in milliseconds.
Definition at line 964 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_shake_reject_thresh | ( | long | sf, |
unsigned short | thresh | ||
) |
Set shake rejection threshold.
If the DMP detects a gyro sample larger than thresh, taps are rejected.
- Parameters:
-
[in] sf Gyro scale factor. [in] thresh Gyro threshold in dps.
- Returns:
- 0 if successful.
Definition at line 855 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_shake_reject_time | ( | unsigned short | time ) |
Set shake rejection time.
Sets the length of time that the gyro must be outside of the threshold set by gyro_set_shake_reject_thresh before taps are rejected. A mandatory 60 ms is added to this parameter.
- Parameters:
-
[in] time Time in milliseconds.
- Returns:
- 0 if successful.
Definition at line 874 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_shake_reject_timeout | ( | unsigned short | time ) |
Set shake rejection timeout.
Sets the length of time after a shake rejection that the gyro must stay inside of the threshold before taps can be detected again. A mandatory 60 ms is added to this parameter.
- Parameters:
-
[in] time Time in milliseconds.
- Returns:
- 0 if successful.
Definition at line 892 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_tap_axes | ( | unsigned char | axis ) |
Set which axes will register a tap.
- Parameters:
-
[in] axis 1, 2, and 4 for XYZ, respectively.
- Returns:
- 0 if successful.
Definition at line 785 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_tap_count | ( | unsigned char | min_taps ) |
Set minimum number of taps needed for an interrupt.
- Parameters:
-
[in] min_taps Minimum consecutive taps (1-4).
- Returns:
- 0 if successful.
Definition at line 803 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_tap_thresh | ( | unsigned char | axis, |
unsigned short | thresh | ||
) |
Set tap threshold for a specific axis.
- Parameters:
-
[in] axis 1, 2, and 4 for XYZ accel, respectively. [in] thresh Tap threshold, in mg/ms.
- Returns:
- 0 if successful.
Definition at line 719 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_tap_time | ( | unsigned short | time ) |
Set length between valid taps.
- Parameters:
-
[in] time Milliseconds between taps.
- Returns:
- 0 if successful.
Definition at line 821 of file inv_mpu_dmp_motion_driver.c.
int dmp_set_tap_time_multi | ( | unsigned short | time ) |
Set max time between taps to register as a multi-tap.
- Parameters:
-
[in] time Max milliseconds between taps.
- Returns:
- 0 if successful.
Definition at line 837 of file inv_mpu_dmp_motion_driver.c.
int mpu_configure_fifo | ( | unsigned char | sensors ) |
int mpu_get_accel_fsr | ( | unsigned char * | fsr ) |
int mpu_get_accel_reg | ( | short * | data, |
unsigned long * | timestamp | ||
) |
int mpu_get_accel_sens | ( | unsigned short * | sens ) |
int mpu_get_compass_fsr | ( | unsigned short * | fsr ) |
int mpu_get_compass_reg | ( | short * | data, |
unsigned long * | timestamp | ||
) |
int mpu_get_compass_sample_rate | ( | unsigned short * | rate ) |
int mpu_get_dmp_state | ( | unsigned char * | enabled ) |
int mpu_get_fifo_config | ( | unsigned char * | sensors ) |
int mpu_get_gyro_fsr | ( | unsigned short * | fsr ) |
int mpu_get_gyro_reg | ( | short * | data, |
unsigned long * | timestamp | ||
) |
int mpu_get_gyro_sens | ( | float * | sens ) |
int mpu_get_int_status | ( | short * | status ) |
int mpu_get_lpf | ( | unsigned short * | lpf ) |
int mpu_get_power_state | ( | unsigned char * | power_on ) |
int mpu_get_sample_rate | ( | unsigned short * | rate ) |
int mpu_get_temperature | ( | long * | data, |
unsigned long * | timestamp | ||
) |
int mpu_init | ( | struct int_param_s * | int_param ) |
Initialize hardware.
Initial configuration:
Gyro FSR: +/- 2000DPS
Accel FSR +/- 2G
DLPF: 42Hz
FIFO rate: 50Hz
Clock source: Gyro PLL
FIFO: Disabled.
Data ready interrupt: Disabled, active low, unlatched.
- Parameters:
-
[in] int_param Platform-specific parameters to interrupt API.
- Returns:
- 0 if successful.
int mpu_load_firmware | ( | unsigned short | length, |
const unsigned char * | firmware, | ||
unsigned short | start_addr, | ||
unsigned short | sample_rate | ||
) |
int mpu_lp_accel_mode | ( | unsigned short | rate ) |
Enter low-power accel-only mode.
In low-power accel mode, the chip goes to sleep and only wakes up to sample the accelerometer at one of the following frequencies:
MPU6050: 1.25Hz, 5Hz, 20Hz, 40Hz
MPU6500: 1.25Hz, 2.5Hz, 5Hz, 10Hz, 20Hz, 40Hz, 80Hz, 160Hz, 320Hz, 640Hz
If the requested rate is not one listed above, the device will be set to the next highest rate. Requesting a rate above the maximum supported frequency will result in an error.
To select a fractional wake-up frequency, round down the value passed to rate.
- Parameters:
-
[in] rate Minimum sampling rate, or zero to disable LP accel mode.
- Returns:
- 0 if successful.
int mpu_lp_motion_interrupt | ( | unsigned short | thresh, |
unsigned char | time, | ||
unsigned short | lpa_freq | ||
) |
Enters LP accel motion interrupt mode.
The behaviour of this feature is very different between the MPU6050 and the MPU6500. Each chip's version of this feature is explained below.
The hardware motion threshold can be between 32mg and 8160mg in 32mg increments.
Low-power accel mode supports the following frequencies:
1.25Hz, 5Hz, 20Hz, 40Hz
MPU6500:
Unlike the MPU6050 version, the hardware does not "lock in" a reference sample. The hardware monitors the accel data and detects any large change over a short period of time.
The hardware motion threshold can be between 4mg and 1020mg in 4mg increments.
MPU6500 Low-power accel mode supports the following frequencies:
1.25Hz, 2.5Hz, 5Hz, 10Hz, 20Hz, 40Hz, 80Hz, 160Hz, 320Hz, 640Hz
NOTES:
The driver will round down thresh to the nearest supported value if an unsupported threshold is selected.
To select a fractional wake-up frequency, round down the value passed to lpa_freq.
The MPU6500 does not support a delay parameter. If this function is used for the MPU6500, the value passed to time will be ignored.
To disable this mode, set lpa_freq to zero. The driver will restore the previous configuration.
- Parameters:
-
[in] thresh Motion threshold in mg. [in] time Duration in milliseconds that the accel data must exceed thresh before motion is reported. [in] lpa_freq Minimum sampling rate, or zero to disable.
- Returns:
- 0 if successful.
int mpu_read_6050_accel_bias | ( | long * | accel_bias ) |
Read biases to the accel bias 6050 registers.
This function reads from the MPU6050 accel offset cancellations registers. The format are G in +-8G format. The register is initialized with OTP factory trim values.
- Parameters:
-
[in] accel_bias returned structure with the accel bias
- Returns:
- 0 if successful.
int mpu_read_6500_accel_bias | ( | long * | accel_bias ) |
Read biases to the accel bias 6500 registers.
This function reads from the MPU6500 accel offset cancellations registers. The format are G in +-8G format. The register is initialized with OTP factory trim values.
- Parameters:
-
[in] accel_bias returned structure with the accel bias
- Returns:
- 0 if successful.
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 returned to that pointer.
sensors can contain a combination of the following flags:
INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO
INV_XYZ_GYRO
INV_XYZ_ACCEL
If the FIFO has no new data, sensors will be zero.
If the FIFO is disabled, sensors will be zero and this function will return a non-zero error code.
- Parameters:
-
[out] gyro Gyro data in hardware units. [out] accel Accel data in hardware units. [out] timestamp Timestamp in milliseconds. [out] sensors Mask of sensors read from FIFO. [out] more Number of remaining packets.
- Returns:
- 0 if successful.
int mpu_read_fifo_stream | ( | unsigned short | length, |
unsigned char * | data, | ||
unsigned char * | more | ||
) |
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. The DMP memory is only accessible when the chip is awake.
- Parameters:
-
[in] mem_addr Memory location (bank << 8 | start address) [in] length Number of bytes to read. [out] data Bytes read from memory.
- Returns:
- 0 if successful.
int mpu_read_reg | ( | unsigned char | reg, |
unsigned char * | data | ||
) |
int mpu_reg_dump | ( | void | ) |
int mpu_reset_fifo | ( | void | ) |
int mpu_run_6500_self_test | ( | long * | gyro, |
long * | accel, | ||
unsigned char | debug | ||
) |
Trigger gyro/accel/compass self-test for MPU6500/MPU9250 On success/error, the self-test returns a mask representing the sensor(s) that failed.
For each bit, a one (1) represents a "pass" case; conversely, a zero (0) indicates a failure.
The mask is defined as follows:
Bit 0: Gyro.
Bit 1: Accel.
Bit 2: Compass.
- Parameters:
-
[out] gyro Gyro biases in q16 format. [out] accel Accel biases (if applicable) in q16 format. [in] debug Debug flag used to print out more detailed logs. Must first set up logging in Motion Driver.
- Returns:
- Result mask (see above).
int mpu_set_accel_bias_6050_reg | ( | const long * | accel_bias ) |
Push biases to the accel bias 6050 registers.
This function expects biases relative to the current sensor output, and these biases will be added to the factory-supplied values. Bias inputs are LSB in +-8G format.
- Parameters:
-
[in] accel_bias New biases.
- Returns:
- 0 if successful.
int mpu_set_accel_bias_6500_reg | ( | const long * | accel_bias ) |
Push biases to the accel bias 6500 registers.
This function expects biases relative to the current sensor output, and these biases will be added to the factory-supplied values. Bias inputs are LSB in +-8G format.
- Parameters:
-
[in] accel_bias New biases.
- Returns:
- 0 if successful.
int mpu_set_accel_fsr | ( | unsigned char | fsr ) |
int mpu_set_bypass | ( | unsigned char | bypass_on ) |
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 maximum of 100Hz. The actual rate can be set to a fraction of the gyro sampling rate.
WARNING: The new rate may be different than what was requested. Call mpu_get_compass_sample_rate to check the actual setting.
- Parameters:
-
[in] rate Desired compass sampling rate (Hz).
- Returns:
- 0 if successful.
int mpu_set_dmp_state | ( | unsigned char | enable ) |
int mpu_set_gyro_bias_reg | ( | long * | gyro_bias ) |
Push biases to the gyro bias 6500/6050 registers.
This function expects biases relative to the current sensor output, and these biases will be added to the factory-supplied values. Bias inputs are LSB in +-1000dps format.
- Parameters:
-
[in] gyro_bias New biases.
- Returns:
- 0 if successful.
int mpu_set_gyro_fsr | ( | unsigned short | fsr ) |
int mpu_set_int_latched | ( | unsigned char | enable ) |
int mpu_set_int_level | ( | unsigned char | active_low ) |
int mpu_set_lpf | ( | unsigned short | lpf ) |
int mpu_set_sample_rate | ( | unsigned short | rate ) |
int mpu_set_sensors | ( | unsigned char | sensors ) |
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. The DMP memory is only accessible when the chip is awake.
- Parameters:
-
[in] mem_addr Memory location (bank << 8 | start address) [in] length Number of bytes to write. [in] data Bytes to write to memory.
- Returns:
- 0 if successful.
static int set_int_enable | ( | unsigned char | enable ) | [static] |
Generated on Wed Jul 13 2022 02:12:00 by 1.7.2