|
XerolySkinnerBscpp 1.0.0
C++版本的驱动库
|
An I2C-based driver for Invensense gyroscopes. 更多...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "inv_mpu.h"#include "inv_mpu_dmp_motion_driver.h"#include "mpu6050.h"#include "usart.h"#include "varint.h"
类 | |
| struct | gyro_reg_s |
| struct | hw_s |
| struct | motion_int_cache_s |
| struct | chip_cfg_s |
| struct | test_s |
| struct | gyro_state_s |
宏定义 | |
| #define | MPU6050 |
| #define | MOTION_DRIVER_TARGET_MSP430 |
| #define | i2c_write MPU_Write_Len |
| #define | i2c_read MPU_Read_Len |
| #define | delay_ms HAL_Delay |
| #define | get_ms mget_ms |
| #define | log_i log_none |
| #define | log_e log_none |
| #define | fabs fabsf |
| #define | min(a, b) ((a<b)?a:b) |
| #define | BIT_I2C_MST_VDDIO (0x80) |
| #define | BIT_FIFO_EN (0x40) |
| #define | BIT_DMP_EN (0x80) |
| #define | BIT_FIFO_RST (0x04) |
| #define | BIT_DMP_RST (0x08) |
| #define | BIT_FIFO_OVERFLOW (0x10) |
| #define | BIT_DATA_RDY_EN (0x01) |
| #define | BIT_DMP_INT_EN (0x02) |
| #define | BIT_MOT_INT_EN (0x40) |
| #define | BITS_FSR (0x18) |
| #define | BITS_LPF (0x07) |
| #define | BITS_HPF (0x07) |
| #define | BITS_CLK (0x07) |
| #define | BIT_FIFO_SIZE_1024 (0x40) |
| #define | BIT_FIFO_SIZE_2048 (0x80) |
| #define | BIT_FIFO_SIZE_4096 (0xC0) |
| #define | BIT_RESET (0x80) |
| #define | BIT_SLEEP (0x40) |
| #define | BIT_S0_DELAY_EN (0x01) |
| #define | BIT_S2_DELAY_EN (0x04) |
| #define | BITS_SLAVE_LENGTH (0x0F) |
| #define | BIT_SLAVE_BYTE_SW (0x40) |
| #define | BIT_SLAVE_GROUP (0x10) |
| #define | BIT_SLAVE_EN (0x80) |
| #define | BIT_I2C_READ (0x80) |
| #define | BITS_I2C_MASTER_DLY (0x1F) |
| #define | BIT_AUX_IF_EN (0x20) |
| #define | BIT_ACTL (0x80) |
| #define | BIT_LATCH_EN (0x20) |
| #define | BIT_ANY_RD_CLR (0x10) |
| #define | BIT_BYPASS_EN (0x02) |
| #define | BITS_WOM_EN (0xC0) |
| #define | BIT_LPA_CYCLE (0x20) |
| #define | BIT_STBY_XA (0x20) |
| #define | BIT_STBY_YA (0x10) |
| #define | BIT_STBY_ZA (0x08) |
| #define | BIT_STBY_XG (0x04) |
| #define | BIT_STBY_YG (0x02) |
| #define | BIT_STBY_ZG (0x01) |
| #define | BIT_STBY_XYZA (BIT_STBY_XA | BIT_STBY_YA | BIT_STBY_ZA) |
| #define | BIT_STBY_XYZG (BIT_STBY_XG | BIT_STBY_YG | BIT_STBY_ZG) |
| #define | MAX_PACKET_LENGTH (12) |
| #define | LOAD_CHUNK (16) |
| #define | q30 1073741824.0f |
枚举 | |
| enum | lpf_e { INV_FILTER_256HZ_NOLPF2 = 0 , INV_FILTER_188HZ , INV_FILTER_98HZ , INV_FILTER_42HZ , INV_FILTER_20HZ , INV_FILTER_10HZ , INV_FILTER_5HZ , INV_FILTER_2100HZ_NOLPF , NUM_FILTER } |
| enum | gyro_fsr_e { INV_FSR_250DPS = 0 , INV_FSR_500DPS , INV_FSR_1000DPS , INV_FSR_2000DPS , NUM_GYRO_FSR } |
| enum | accel_fsr_e { INV_FSR_2G = 0 , INV_FSR_4G , INV_FSR_8G , INV_FSR_16G , NUM_ACCEL_FSR } |
| enum | clock_sel_e { INV_CLK_INTERNAL = 0 , INV_CLK_PLL , NUM_CLK } |
| enum | lp_accel_rate_e { INV_LPA_1_25HZ , INV_LPA_5HZ , INV_LPA_20HZ , INV_LPA_40HZ } |
函数 | |
| void | log_none (char *fmt,...) |
| static int | set_int_enable (unsigned char enable) |
| Enable/disable data ready interrupt. If the DMP is on, the DMP interrupt is enabled. Otherwise, the data ready interrupt is used. 更多... | |
| int | mpu_reg_dump (void) |
| Register dump for testing. 更多... | |
| 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_init (void) |
| 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. 更多... | |
| 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 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. 更多... | |
| 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_set_accel_bias (const long *accel_bias) |
| Push biases to the accel bias registers. This function expects biases relative to the current sensor output, and these biases will be added to the factory-supplied values. 更多... | |
| 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. The following LPF settings are supported: 188, 98, 42, 20, 10, 5. 更多... | |
| int | mpu_get_sample_rate (unsigned short *rate) |
| Get sampling rate. 更多... | |
| int | mpu_set_sample_rate (unsigned short rate) |
| Set sampling rate. Sampling rate must be between 4Hz and 1kHz. 更多... | |
| 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. 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. 更多... | |
| 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. sensors can contain a combination of the following flags: INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO INV_XYZ_GYRO INV_XYZ_ACCEL 更多... | |
| int | mpu_configure_fifo (unsigned char sensors) |
| Select which sensors are pushed to FIFO. sensors can contain a combination of the following flags: INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO INV_XYZ_GYRO INV_XYZ_ACCEL 更多... | |
| 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. 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_XYZ_COMPASS 更多... | |
| 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. 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. 更多... | |
| 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 elsewhere. 更多... | |
| 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. Any MPU register will clear the interrupt. 更多... | |
| static int | get_accel_prod_shift (float *st_shift) |
| static int | accel_self_test (long *bias_regular, long *bias_st) |
| static int | gyro_self_test (long *bias_regular, long *bias_st) |
| static int | get_st_biases (long *gyro, long *accel, unsigned char hw_test) |
| 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 sensor(s) that failed. For each bit, a one (1) represents a "pass" case; conversely, a zero (0) indicates a failure. 更多... | |
| 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. 更多... | |
| 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. 更多... | |
| 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 | setup_compass (void) |
| 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 char lpa_freq) |
| Enters LP accel motion interrupt mode. The behavior of this feature is very different between the MPU6050 and the MPU6500. Each chip's version of this feature is explained below. 更多... | |
| u8 | run_self_test (void) |
| unsigned short | inv_orientation_matrix_to_scalar (const signed char *mtx) |
| unsigned short | inv_row_2_scale (const signed char *row) |
| void | mget_ms (unsigned long *time) |
| u8 | mpu_dmp_init (void) |
| u8 | mpu_dmp_get_data (float *pitch, float *roll, float *yaw) |
变量 | |
| const struct gyro_reg_s | reg |
| const struct hw_s | hw |
| const struct test_s | test |
| static struct gyro_state_s | st |
| static signed char | gyro_orientation [9] |
An I2C-based driver for Invensense gyroscopes.
This driver currently works for the following devices: MPU6050 MPU6500 MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus) MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus)
在文件 inv_mpu.c 中定义.
| #define LOAD_CHUNK (16) |