inv_mpu.h main.h varint.h D:/gitt/MicrochipFor32/bsp_MPU6050/inv_mpu.c D:/gitt/MicrochipFor32/bsp_MPU6050/inv_mpu_dmp_motion_driver.c int_param_s DEFAULT_MPU_HZ (100) INV_X_GYRO (0x40) INV_Y_GYRO (0x20) INV_Z_GYRO (0x10) INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO) INV_XYZ_ACCEL (0x08) INV_XYZ_COMPASS (0x01) MPU_INT_STATUS_DATA_READY (0x0001) MPU_INT_STATUS_DMP (0x0002) MPU_INT_STATUS_PLL_READY (0x0004) MPU_INT_STATUS_I2C_MST (0x0008) MPU_INT_STATUS_FIFO_OVERFLOW (0x0010) MPU_INT_STATUS_ZMOT (0x0020) MPU_INT_STATUS_MOT (0x0040) MPU_INT_STATUS_FREE_FALL (0x0080) MPU_INT_STATUS_DMP_0 (0x0100) MPU_INT_STATUS_DMP_1 (0x0200) MPU_INT_STATUS_DMP_2 (0x0400) MPU_INT_STATUS_DMP_3 (0x0800) MPU_INT_STATUS_DMP_4 (0x1000) MPU_INT_STATUS_DMP_5 (0x2000) int int mpu_init (void) 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_param Platform-specific parameters to interrupt API. 0 if successful. chip_cfg_s::accel_fsr chip_cfg_s::accel_half gyro_reg_s::accel_offs chip_cfg_s::active_low_int hw_s::addr BIT_FIFO_SIZE_1024 BIT_RESET chip_cfg_s::bypass_mode chip_cfg_s::cache gyro_state_s::chip_cfg chip_cfg_s::clk_src delay_ms chip_cfg_s::dmp_loaded chip_cfg_s::dmp_on chip_cfg_s::dmp_sample_rate chip_cfg_s::fifo_enable chip_cfg_s::gyro_fsr gyro_state_s::hw i2c_read i2c_write chip_cfg_s::int_motion_only INV_CLK_PLL chip_cfg_s::latched_int log_e log_i chip_cfg_s::lp_accel_mode chip_cfg_s::lpf mpu_configure_fifo mpu_read_mem mpu_set_accel_fsr mpu_set_bypass mpu_set_compass_sample_rate mpu_set_gyro_fsr mpu_set_lpf mpu_set_sample_rate mpu_set_sensors gyro_reg_s::prod_id gyro_reg_s::pwr_mgmt_1 gyro_state_s::reg chip_cfg_s::sample_rate chip_cfg_s::sensors setup_compass st mpu_dmp_init int int mpu_init_slave (void) mpu_init_slave void int int mpu_set_bypass (unsigned char bypass_on) mpu_set_bypass unsigned char bypass_on Set device to bypass mode. bypass_on 1 to enable bypass mode. 0 if successful. chip_cfg_s::active_low_int hw_s::addr BIT_ACTL BIT_ANY_RD_CLR BIT_AUX_IF_EN BIT_BYPASS_EN BIT_LATCH_EN chip_cfg_s::bypass_mode gyro_state_s::chip_cfg delay_ms gyro_state_s::hw i2c_read i2c_write gyro_reg_s::int_pin_cfg INV_XYZ_COMPASS chip_cfg_s::latched_int gyro_state_s::reg chip_cfg_s::sensors st gyro_reg_s::user_ctrl mpu_init mpu_set_dmp_state mpu_set_sensors setup_compass int int mpu_lp_accel_mode (unsigned char rate) 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. rate Minimum sampling rate, or zero to disable LP accel mode. 0 if successful. hw_s::addr BIT_LPA_CYCLE BIT_STBY_XYZG gyro_state_s::chip_cfg chip_cfg_s::clk_src gyro_state_s::hw i2c_write INV_LPA_1_25HZ INV_LPA_20HZ INV_LPA_40HZ INV_LPA_5HZ INV_XYZ_ACCEL chip_cfg_s::lp_accel_mode mpu_configure_fifo mpu_set_int_latched mpu_set_lpf gyro_reg_s::pwr_mgmt_1 gyro_state_s::reg chip_cfg_s::sensors st mpu_lp_motion_interrupt mpu_set_sample_rate int int mpu_lp_motion_interrupt (unsigned short thresh, unsigned char time, unsigned char lpa_freq) 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. MPU6050: When this mode is first enabled, the hardware captures a single accel sample, and subsequent samples are compared with this one to determine if the device is in motion. Therefore, whenever this "locked" sample needs to be changed, this function must be called again. 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. thresh Motion threshold in mg. time Duration in milliseconds that the accel data must exceed thresh before motion is reported. lpa_freq Minimum sampling rate, or zero to disable. 0 if successful. gyro_reg_s::accel_cfg motion_int_cache_s::accel_fsr chip_cfg_s::accel_fsr hw_s::addr BIT_LPA_CYCLE BIT_MOT_INT_EN BIT_STBY_XYZG BITS_HPF BITS_WOM_EN chip_cfg_s::cache gyro_state_s::chip_cfg chip_cfg_s::clk_src delay_ms motion_int_cache_s::dmp_on chip_cfg_s::dmp_on chip_cfg_s::fifo_enable motion_int_cache_s::fifo_sensors motion_int_cache_s::gyro_fsr chip_cfg_s::gyro_fsr gyro_state_s::hw i2c_write gyro_reg_s::int_enable chip_cfg_s::int_motion_only INV_CLK_PLL INV_FILTER_256HZ_NOLPF2 INV_LPA_1_25HZ INV_LPA_20HZ INV_LPA_40HZ INV_LPA_5HZ gyro_reg_s::lpf motion_int_cache_s::lpf chip_cfg_s::lpf gyro_reg_s::motion_thr mpu_configure_fifo mpu_get_accel_fsr mpu_get_fifo_config mpu_get_gyro_fsr mpu_get_lpf mpu_get_sample_rate mpu_lp_accel_mode mpu_set_accel_fsr mpu_set_dmp_state mpu_set_gyro_fsr mpu_set_lpf mpu_set_sample_rate mpu_set_sensors gyro_reg_s::pwr_mgmt_1 gyro_state_s::reg motion_int_cache_s::sample_rate chip_cfg_s::sample_rate chip_cfg_s::sensors motion_int_cache_s::sensors_on set_int_enable st gyro_reg_s::user_ctrl int int mpu_set_int_level (unsigned char active_low) mpu_set_int_level unsigned char active_low Set interrupt level. active_low 1 for active low, 0 for active high. 0 if successful. chip_cfg_s::active_low_int gyro_state_s::chip_cfg st int int mpu_set_int_latched (unsigned char enable) mpu_set_int_latched unsigned char enable Enable latched interrupts. Any MPU register will clear the interrupt. enable 1 to enable, 0 to disable. 0 if successful. chip_cfg_s::active_low_int hw_s::addr BIT_ACTL BIT_ANY_RD_CLR BIT_BYPASS_EN BIT_LATCH_EN chip_cfg_s::bypass_mode gyro_state_s::chip_cfg gyro_state_s::hw i2c_write gyro_reg_s::int_pin_cfg chip_cfg_s::latched_int gyro_state_s::reg st mpu_lp_accel_mode mpu_set_sensors int int mpu_set_dmp_state (unsigned char enable) mpu_set_dmp_state unsigned char enable Enable/disable DMP support. enable 1 to turn on the DMP. 0 if successful. hw_s::addr gyro_state_s::chip_cfg chip_cfg_s::dmp_loaded chip_cfg_s::dmp_on chip_cfg_s::dmp_sample_rate chip_cfg_s::fifo_enable gyro_state_s::hw i2c_write mpu_reset_fifo mpu_set_bypass mpu_set_sample_rate set_int_enable st mpu_dmp_init mpu_lp_motion_interrupt mpu_run_self_test int int mpu_get_dmp_state (unsigned char *enabled) mpu_get_dmp_state unsigned char * enabled Get DMP state. enabled 1 if enabled. 0 if successful. gyro_state_s::chip_cfg chip_cfg_s::dmp_on st int int mpu_get_lpf (unsigned short *lpf) mpu_get_lpf unsigned short * lpf Get the current DLPF setting. lpf Current LPF setting. 0 if successful. gyro_state_s::chip_cfg INV_FILTER_10HZ INV_FILTER_188HZ INV_FILTER_20HZ INV_FILTER_2100HZ_NOLPF INV_FILTER_256HZ_NOLPF2 INV_FILTER_42HZ INV_FILTER_5HZ INV_FILTER_98HZ chip_cfg_s::lpf st mpu_lp_motion_interrupt mpu_run_self_test int int mpu_set_lpf (unsigned short lpf) mpu_set_lpf unsigned short lpf Set digital low pass filter. The following LPF settings are supported: 188, 98, 42, 20, 10, 5. lpf Desired LPF setting. 0 if successful. hw_s::addr gyro_state_s::chip_cfg gyro_state_s::hw i2c_write INV_FILTER_10HZ INV_FILTER_188HZ INV_FILTER_20HZ INV_FILTER_42HZ INV_FILTER_5HZ INV_FILTER_98HZ gyro_reg_s::lpf chip_cfg_s::lpf gyro_state_s::reg chip_cfg_s::sensors st mpu_init mpu_lp_accel_mode mpu_lp_motion_interrupt mpu_run_self_test mpu_set_sample_rate int int mpu_get_gyro_fsr (unsigned short *fsr) mpu_get_gyro_fsr unsigned short * fsr Get the gyro full-scale range. fsr Current full-scale range. 0 if successful. gyro_state_s::chip_cfg chip_cfg_s::gyro_fsr INV_FSR_1000DPS INV_FSR_2000DPS INV_FSR_250DPS INV_FSR_500DPS st mpu_lp_motion_interrupt mpu_run_self_test int int mpu_set_gyro_fsr (unsigned short fsr) mpu_set_gyro_fsr unsigned short fsr Set the gyro full-scale range. fsr Desired full-scale range. 0 if successful. hw_s::addr gyro_state_s::chip_cfg gyro_reg_s::gyro_cfg chip_cfg_s::gyro_fsr gyro_state_s::hw i2c_write INV_FSR_1000DPS INV_FSR_2000DPS INV_FSR_250DPS INV_FSR_500DPS gyro_state_s::reg chip_cfg_s::sensors st mpu_init mpu_lp_motion_interrupt mpu_run_self_test int int mpu_get_accel_fsr (unsigned char *fsr) mpu_get_accel_fsr unsigned char * fsr Get the accel full-scale range. fsr Current full-scale range. 0 if successful. chip_cfg_s::accel_fsr chip_cfg_s::accel_half gyro_state_s::chip_cfg INV_FSR_16G INV_FSR_2G INV_FSR_4G INV_FSR_8G st dmp_set_tap_thresh mpu_lp_motion_interrupt mpu_run_self_test int int mpu_set_accel_fsr (unsigned char fsr) mpu_set_accel_fsr unsigned char fsr Set the accel full-scale range. fsr Desired full-scale range. 0 if successful. gyro_reg_s::accel_cfg chip_cfg_s::accel_fsr hw_s::addr gyro_state_s::chip_cfg gyro_state_s::hw i2c_write INV_FSR_16G INV_FSR_2G INV_FSR_4G INV_FSR_8G gyro_state_s::reg chip_cfg_s::sensors st mpu_init mpu_lp_motion_interrupt mpu_run_self_test int int mpu_get_compass_fsr (unsigned short *fsr) mpu_get_compass_fsr unsigned short * fsr Get the compass full-scale range. fsr Current full-scale range. 0 if successful. gyro_state_s::hw st int int mpu_get_gyro_sens (float *sens) mpu_get_gyro_sens float * sens Get gyro sensitivity scale factor. sens Conversion from hardware units to dps. 0 if successful. gyro_state_s::chip_cfg chip_cfg_s::gyro_fsr INV_FSR_1000DPS INV_FSR_2000DPS INV_FSR_250DPS INV_FSR_500DPS st run_self_test int int mpu_get_accel_sens (unsigned short *sens) mpu_get_accel_sens unsigned short * sens Get accel sensitivity scale factor. sens Conversion from hardware units to g's. 0 if successful. chip_cfg_s::accel_fsr chip_cfg_s::accel_half gyro_state_s::chip_cfg INV_FSR_16G INV_FSR_2G INV_FSR_4G INV_FSR_8G st dmp_set_accel_bias run_self_test int int mpu_get_sample_rate (unsigned short *rate) mpu_get_sample_rate unsigned short * rate Get sampling rate. rate Current sampling rate (Hz). 0 if successful. gyro_state_s::chip_cfg chip_cfg_s::dmp_on chip_cfg_s::sample_rate st mpu_lp_motion_interrupt mpu_run_self_test int int mpu_set_sample_rate (unsigned short rate) mpu_set_sample_rate unsigned short rate Set sampling rate. Sampling rate must be between 4Hz and 1kHz. rate Desired sampling rate (Hz). 0 if successful. hw_s::addr gyro_state_s::chip_cfg chip_cfg_s::dmp_on gyro_state_s::hw i2c_write chip_cfg_s::lp_accel_mode min mpu_lp_accel_mode mpu_set_compass_sample_rate mpu_set_lpf gyro_reg_s::rate_div gyro_state_s::reg chip_cfg_s::sample_rate chip_cfg_s::sensors st mpu_dmp_init mpu_init mpu_lp_motion_interrupt mpu_run_self_test mpu_set_dmp_state int int mpu_get_compass_sample_rate (unsigned short *rate) mpu_get_compass_sample_rate unsigned short * rate Get compass sampling rate. rate Current compass sampling rate (Hz). 0 if successful. gyro_state_s::chip_cfg st int int mpu_set_compass_sample_rate (unsigned short rate) 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. rate Desired compass sampling rate (Hz). 0 if successful. hw_s::addr gyro_state_s::chip_cfg gyro_state_s::hw i2c_write gyro_state_s::reg chip_cfg_s::sample_rate st mpu_init mpu_set_sample_rate int int mpu_get_fifo_config (unsigned char *sensors) 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 sensors Mask of sensors in FIFO. 0 if successful. gyro_state_s::chip_cfg chip_cfg_s::fifo_enable st mpu_lp_motion_interrupt mpu_run_self_test int int mpu_configure_fifo (unsigned char sensors) 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 sensors Mask of sensors to push to FIFO. 0 if successful. gyro_state_s::chip_cfg chip_cfg_s::dmp_on chip_cfg_s::fifo_enable chip_cfg_s::lp_accel_mode mpu_reset_fifo chip_cfg_s::sensors set_int_enable st mpu_dmp_init mpu_init mpu_lp_accel_mode mpu_lp_motion_interrupt mpu_run_self_test int int mpu_get_power_state (unsigned char *power_on) mpu_get_power_state unsigned char * power_on Get current power state. power_on 1 if turned on, 0 if suspended. 0 if successful. gyro_state_s::chip_cfg chip_cfg_s::sensors st int int mpu_set_sensors (unsigned char sensors) 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 sensors Mask of sensors to wake. 0 if successful. hw_s::addr BIT_AUX_IF_EN BIT_DMP_EN BIT_SLEEP BIT_STBY_XG BIT_STBY_XYZA BIT_STBY_YG BIT_STBY_ZG gyro_state_s::chip_cfg chip_cfg_s::clk_src delay_ms chip_cfg_s::dmp_on gyro_state_s::hw i2c_read i2c_write INV_CLK_PLL INV_X_GYRO INV_XYZ_ACCEL INV_XYZ_COMPASS INV_XYZ_GYRO INV_Y_GYRO INV_Z_GYRO chip_cfg_s::lp_accel_mode mpu_set_bypass mpu_set_int_latched gyro_reg_s::pwr_mgmt_1 gyro_reg_s::pwr_mgmt_2 gyro_state_s::reg chip_cfg_s::sensors st gyro_reg_s::user_ctrl mpu_dmp_init mpu_init mpu_lp_motion_interrupt mpu_run_self_test int int mpu_set_accel_bias (const long *accel_bias) 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. accel_bias New biases. 0 if successful. hw_s::addr gyro_state_s::hw i2c_read i2c_write st int int mpu_get_gyro_reg (short *data, unsigned long *timestamp) mpu_get_gyro_reg short * data unsigned long * timestamp Read raw gyro data directly from the registers. data Raw data in hardware units. timestamp Timestamp in milliseconds. Null if not needed. 0 if successful. hw_s::addr gyro_state_s::chip_cfg get_ms gyro_state_s::hw i2c_read INV_XYZ_GYRO gyro_reg_s::raw_gyro gyro_state_s::reg chip_cfg_s::sensors st int int mpu_get_accel_reg (short *data, unsigned long *timestamp) mpu_get_accel_reg short * data unsigned long * timestamp Read raw accel data directly from the registers. data Raw data in hardware units. timestamp Timestamp in milliseconds. Null if not needed. 0 if successful. hw_s::addr gyro_state_s::chip_cfg get_ms gyro_state_s::hw i2c_read INV_XYZ_ACCEL gyro_reg_s::raw_accel gyro_state_s::reg chip_cfg_s::sensors st int int mpu_get_compass_reg (short *data, unsigned long *timestamp) mpu_get_compass_reg short * data unsigned long * timestamp Read raw compass data. data Raw data in hardware units. timestamp Timestamp in milliseconds. Null if not needed. 0 if successful. hw_s::addr gyro_state_s::chip_cfg get_ms gyro_state_s::hw i2c_read i2c_write INV_XYZ_COMPASS gyro_state_s::reg chip_cfg_s::sensors st int int mpu_get_temperature (long *data, unsigned long *timestamp) mpu_get_temperature long * data unsigned long * timestamp Read temperature data directly from the registers. data Data in q16 format. timestamp Timestamp in milliseconds. Null if not needed. 0 if successful. hw_s::addr gyro_state_s::chip_cfg get_ms gyro_state_s::hw i2c_read gyro_state_s::reg chip_cfg_s::sensors st gyro_reg_s::temp hw_s::temp_offset hw_s::temp_sens int int mpu_get_int_status (short *status) mpu_get_int_status short * status Read the MPU interrupt status registers. status Mask of interrupt bits. 0 if successful. hw_s::addr gyro_state_s::chip_cfg gyro_reg_s::dmp_int_status gyro_state_s::hw i2c_read gyro_state_s::reg chip_cfg_s::sensors st int int mpu_read_fifo (short *gyro, short *accel, unsigned long *timestamp, unsigned char *sensors, unsigned char *more) 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. gyro Gyro data in hardware units. accel Accel data in hardware units. timestamp Timestamp in milliseconds. sensors Mask of sensors read from FIFO. more Number of remaining packets. 0 if successful. hw_s::addr BIT_FIFO_OVERFLOW gyro_state_s::chip_cfg chip_cfg_s::dmp_on gyro_reg_s::fifo_count_h chip_cfg_s::fifo_enable gyro_reg_s::fifo_r_w get_ms gyro_state_s::hw i2c_read gyro_reg_s::int_status INV_X_GYRO INV_XYZ_ACCEL INV_Y_GYRO INV_Z_GYRO hw_s::max_fifo MAX_PACKET_LENGTH mpu_reset_fifo gyro_state_s::reg chip_cfg_s::sensors st int int mpu_read_fifo_stream (unsigned short length, unsigned char *data, unsigned char *more) 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. length Length of one FIFO packet. data FIFO packet. more Number of remaining packets. hw_s::addr BIT_FIFO_OVERFLOW gyro_state_s::chip_cfg chip_cfg_s::dmp_on gyro_reg_s::fifo_count_h gyro_reg_s::fifo_r_w gyro_state_s::hw i2c_read gyro_reg_s::int_status hw_s::max_fifo mpu_reset_fifo gyro_state_s::reg chip_cfg_s::sensors st dmp_read_fifo int int mpu_reset_fifo (void) mpu_reset_fifo void Reset FIFO read/write pointers. 0 if successful. hw_s::addr BIT_AUX_IF_EN BIT_DATA_RDY_EN BIT_DMP_EN BIT_DMP_INT_EN BIT_DMP_RST BIT_FIFO_EN BIT_FIFO_RST chip_cfg_s::bypass_mode gyro_state_s::chip_cfg delay_ms chip_cfg_s::dmp_on gyro_reg_s::fifo_en chip_cfg_s::fifo_enable gyro_state_s::hw i2c_write gyro_reg_s::int_enable chip_cfg_s::int_enable INV_XYZ_COMPASS gyro_state_s::reg chip_cfg_s::sensors st gyro_reg_s::user_ctrl dmp_enable_6x_lp_quat dmp_enable_feature dmp_enable_lp_quat dmp_read_fifo mpu_configure_fifo mpu_read_fifo mpu_read_fifo_stream mpu_set_dmp_state int int mpu_write_mem (unsigned short mem_addr, unsigned short length, unsigned char *data) 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. mem_addr Memory location (bank << 8 | start address) length Number of bytes to write. data Bytes to write to memory. 0 if successful. hw_s::addr gyro_reg_s::bank_sel hw_s::bank_size gyro_state_s::chip_cfg gyro_state_s::hw i2c_write gyro_reg_s::mem_r_w gyro_state_s::reg chip_cfg_s::sensors st dmp_enable_6x_lp_quat dmp_enable_feature dmp_enable_gyro_cal dmp_enable_lp_quat dmp_set_accel_bias dmp_set_fifo_rate dmp_set_gyro_bias dmp_set_interrupt_mode dmp_set_orientation dmp_set_pedometer_step_count dmp_set_pedometer_walk_time dmp_set_shake_reject_thresh dmp_set_shake_reject_time dmp_set_shake_reject_timeout dmp_set_tap_axes dmp_set_tap_count dmp_set_tap_thresh dmp_set_tap_time dmp_set_tap_time_multi mpu_load_firmware int int mpu_read_mem (unsigned short mem_addr, unsigned short length, unsigned char *data) 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. mem_addr Memory location (bank << 8 | start address) length Number of bytes to read. data Bytes read from memory. 0 if successful. hw_s::addr gyro_reg_s::bank_sel hw_s::bank_size gyro_state_s::chip_cfg gyro_state_s::hw i2c_read i2c_write gyro_reg_s::mem_r_w gyro_state_s::reg chip_cfg_s::sensors st dmp_get_pedometer_step_count dmp_get_pedometer_walk_time mpu_init mpu_load_firmware int int mpu_load_firmware (unsigned short length, const unsigned char *firmware, unsigned short start_addr, unsigned short sample_rate) mpu_load_firmware unsigned short length const unsigned char * firmware unsigned short start_addr unsigned short sample_rate Load and verify DMP image. length Length of DMP image. firmware DMP code. start_addr Starting address of DMP code memory. sample_rate Fixed sampling rate used when DMP is enabled. 0 if successful. hw_s::addr gyro_state_s::chip_cfg chip_cfg_s::dmp_loaded chip_cfg_s::dmp_sample_rate gyro_state_s::hw i2c_write LOAD_CHUNK min mpu_read_mem mpu_write_mem gyro_reg_s::prgm_start_h gyro_state_s::reg st dmp_load_motion_driver_firmware int int mpu_reg_dump (void) mpu_reg_dump void Register dump for testing. 0 if successful. hw_s::addr gyro_reg_s::fifo_r_w gyro_state_s::hw i2c_read log_i gyro_reg_s::mem_r_w hw_s::num_reg gyro_state_s::reg st int int mpu_read_reg (unsigned char reg, unsigned char *data) 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. reg Register address. data Register data. 0 if successful. hw_s::addr gyro_reg_s::fifo_r_w gyro_state_s::hw i2c_read gyro_reg_s::mem_r_w hw_s::num_reg gyro_state_s::reg reg st int int mpu_run_self_test (long *gyro, long *accel) 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. The mask is defined as follows: Bit 0: Gyro. Bit 1: Accel. Bit 2: Compass. Currently, the hardware self-test is unsupported for MPU6500. However, this function can still be used to obtain the accel and gyro biases. This function must be called with the device either face-up or face-down (z-axis is parallel to gravity). gyro Gyro biases in q16 format. accel Accel biases (if applicable) in q16 format. Result mask (see above). chip_cfg_s::accel_fsr accel_self_test gyro_state_s::chip_cfg chip_cfg_s::clk_src chip_cfg_s::dmp_on chip_cfg_s::fifo_enable get_st_biases chip_cfg_s::gyro_fsr gyro_self_test INV_CLK_PLL chip_cfg_s::lpf mpu_configure_fifo mpu_get_accel_fsr mpu_get_fifo_config mpu_get_gyro_fsr mpu_get_lpf mpu_get_sample_rate mpu_set_accel_fsr mpu_set_dmp_state mpu_set_gyro_fsr mpu_set_lpf mpu_set_sample_rate mpu_set_sensors chip_cfg_s::sample_rate chip_cfg_s::sensors st run_self_test int int mpu_register_tap_cb (void(*func)(unsigned char, unsigned char)) mpu_register_tap_cb void(*)(unsigned char, unsigned char) func void void mget_ms (unsigned long *time) mget_ms unsigned long * time unsigned short unsigned short inv_row_2_scale (const signed char *row) inv_row_2_scale const signed char * row inv_orientation_matrix_to_scalar unsigned short unsigned short inv_orientation_matrix_to_scalar (const signed char *mtx) inv_orientation_matrix_to_scalar const signed char * mtx inv_row_2_scale mpu_dmp_init u8 u8 run_self_test (void) run_self_test void dmp_set_accel_bias dmp_set_gyro_bias mpu_get_accel_sens mpu_get_gyro_sens mpu_run_self_test mpu_dmp_init u8 u8 mpu_dmp_init (void) mpu_dmp_init void DEFAULT_MPU_HZ dmp_enable_feature DMP_FEATURE_6X_LP_QUAT DMP_FEATURE_ANDROID_ORIENT DMP_FEATURE_GYRO_CAL DMP_FEATURE_SEND_CAL_GYRO DMP_FEATURE_SEND_RAW_ACCEL DMP_FEATURE_TAP dmp_load_motion_driver_firmware dmp_set_fifo_rate dmp_set_orientation gyro_orientation inv_orientation_matrix_to_scalar INV_XYZ_ACCEL INV_XYZ_GYRO mpu_configure_fifo mpu_init mpu_set_dmp_state mpu_set_sample_rate mpu_set_sensors run_self_test u8 u8 mpu_dmp_get_data (float *pitch, float *roll, float *yaw) mpu_dmp_get_data float * pitch float * roll float * yaw dmp_read_fifo INV_WXYZ_QUAT q30 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) /* $License: Copyright(C)2011-2012InvenSenseCorporation,AllRightsReserved. SeeincludedLicense.txtforLicenseinformation. $ */ #ifndef_INV_MPU_H_ #define_INV_MPU_H_ #include"main.h" #include"varint.h" //定义输出速度 #defineDEFAULT_MPU_HZ(100)//100Hz #defineINV_X_GYRO(0x40) #defineINV_Y_GYRO(0x20) #defineINV_Z_GYRO(0x10) #defineINV_XYZ_GYRO(INV_X_GYRO|INV_Y_GYRO|INV_Z_GYRO) #defineINV_XYZ_ACCEL(0x08) #defineINV_XYZ_COMPASS(0x01) //移植官方MSP430DMP驱动过来 structint_param_s{ //#ifdefinedEMPL_TARGET_MSP430||definedMOTION_DRIVER_TARGET_MSP430 void(*cb)(void); unsignedshortpin; unsignedcharlp_exit; unsignedcharactive_low; //#elifdefinedEMPL_TARGET_UC3L0 //unsignedlongpin; //void(*cb)(volatilevoid*); //void*arg; //#endif }; #defineMPU_INT_STATUS_DATA_READY(0x0001) #defineMPU_INT_STATUS_DMP(0x0002) #defineMPU_INT_STATUS_PLL_READY(0x0004) #defineMPU_INT_STATUS_I2C_MST(0x0008) #defineMPU_INT_STATUS_FIFO_OVERFLOW(0x0010) #defineMPU_INT_STATUS_ZMOT(0x0020) #defineMPU_INT_STATUS_MOT(0x0040) #defineMPU_INT_STATUS_FREE_FALL(0x0080) #defineMPU_INT_STATUS_DMP_0(0x0100) #defineMPU_INT_STATUS_DMP_1(0x0200) #defineMPU_INT_STATUS_DMP_2(0x0400) #defineMPU_INT_STATUS_DMP_3(0x0800) #defineMPU_INT_STATUS_DMP_4(0x1000) #defineMPU_INT_STATUS_DMP_5(0x2000) /*SetupAPIs*/ intmpu_init(void); intmpu_init_slave(void); intmpu_set_bypass(unsignedcharbypass_on); /*ConfigurationAPIs*/ intmpu_lp_accel_mode(unsignedcharrate); intmpu_lp_motion_interrupt(unsignedshortthresh,unsignedchartime, unsignedcharlpa_freq); intmpu_set_int_level(unsignedcharactive_low); intmpu_set_int_latched(unsignedcharenable); intmpu_set_dmp_state(unsignedcharenable); intmpu_get_dmp_state(unsignedchar*enabled); intmpu_get_lpf(unsignedshort*lpf); intmpu_set_lpf(unsignedshortlpf); intmpu_get_gyro_fsr(unsignedshort*fsr); intmpu_set_gyro_fsr(unsignedshortfsr); intmpu_get_accel_fsr(unsignedchar*fsr); intmpu_set_accel_fsr(unsignedcharfsr); intmpu_get_compass_fsr(unsignedshort*fsr); intmpu_get_gyro_sens(float*sens); intmpu_get_accel_sens(unsignedshort*sens); intmpu_get_sample_rate(unsignedshort*rate); intmpu_set_sample_rate(unsignedshortrate); intmpu_get_compass_sample_rate(unsignedshort*rate); intmpu_set_compass_sample_rate(unsignedshortrate); intmpu_get_fifo_config(unsignedchar*sensors); intmpu_configure_fifo(unsignedcharsensors); intmpu_get_power_state(unsignedchar*power_on); intmpu_set_sensors(unsignedcharsensors); intmpu_set_accel_bias(constlong*accel_bias); /*Datagetter/setterAPIs*/ intmpu_get_gyro_reg(short*data,unsignedlong*timestamp); intmpu_get_accel_reg(short*data,unsignedlong*timestamp); intmpu_get_compass_reg(short*data,unsignedlong*timestamp); intmpu_get_temperature(long*data,unsignedlong*timestamp); intmpu_get_int_status(short*status); intmpu_read_fifo(short*gyro,short*accel,unsignedlong*timestamp, unsignedchar*sensors,unsignedchar*more); intmpu_read_fifo_stream(unsignedshortlength,unsignedchar*data, unsignedchar*more); intmpu_reset_fifo(void); intmpu_write_mem(unsignedshortmem_addr,unsignedshortlength, unsignedchar*data); intmpu_read_mem(unsignedshortmem_addr,unsignedshortlength, unsignedchar*data); intmpu_load_firmware(unsignedshortlength,constunsignedchar*firmware, unsignedshortstart_addr,unsignedshortsample_rate); intmpu_reg_dump(void); intmpu_read_reg(unsignedcharreg,unsignedchar*data); intmpu_run_self_test(long*gyro,long*accel); intmpu_register_tap_cb(void(*func)(unsignedchar,unsignedchar)); //自行添加的一些函数 voidmget_ms(unsignedlong*time); unsignedshortinv_row_2_scale(constsignedchar*row); unsignedshortinv_orientation_matrix_to_scalar(constsignedchar*mtx); u8run_self_test(void); u8mpu_dmp_init(void); u8mpu_dmp_get_data(float*pitch,float*roll,float*yaw); #endif/*#ifndef_INV_MPU_H_*/