D:/gitt/MicrochipFor32/bsp_MPU6050/inv_mpu_dmp_motion_driver.c 文件参考D:/gitt/MicrochipFor32/bsp_MPU6050/inv_mpu_dmp_motion_driver.cDMP image and interface functions. #include <stdio.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "inv_mpu.h"#include "inv_mpu_dmp_motion_driver.h"#include "dmpKey.h"#include "dmpmap.h"#include "usart.h"inv_mpu_dmp_motion_driver.c 的引用(Include)关系图:类 struct dmp_s宏定义 #define MOTION_DRIVER_TARGET_MSP430#define delay_ms HAL_Delay#define get_ms mget_ms#define log_i printf#define log_e printf#define CFG_LP_QUAT (2712)#define END_ORIENT_TEMP (1866)#define CFG_27 (2742)#define CFG_20 (2224)#define CFG_23 (2745)#define CFG_FIFO_ON_EVENT (2690)#define END_PREDICTION_UPDATE (1761)#define CGNOTICE_INTR (2620)#define X_GRT_Y_TMP (1358)#define CFG_DR_INT (1029)#define CFG_AUTH (1035)#define UPDATE_PROP_ROT (1835)#define END_COMPARE_Y_X_TMP2 (1455)#define SKIP_X_GRT_Y_TMP (1359)#define SKIP_END_COMPARE (1435)#define FCFG_3 (1088)#define FCFG_2 (1066)#define FCFG_1 (1062)#define END_COMPARE_Y_X_TMP3 (1434)#define FCFG_7 (1073)#define FCFG_6 (1106)#define FLAT_STATE_END (1713)#define SWING_END_4 (1616)#define SWING_END_2 (1565)#define SWING_END_3 (1587)#define SWING_END_1 (1550)#define CFG_8 (2718)#define CFG_15 (2727)#define CFG_16 (2746)#define CFG_EXT_GYRO_BIAS (1189)#define END_COMPARE_Y_X_TMP (1407)#define DO_NOT_UPDATE_PROP_ROT (1839)#define CFG_7 (1205)#define FLAT_STATE_END_TEMP (1683)#define END_COMPARE_Y_X (1484)#define SKIP_SWING_END_1 (1551)#define SKIP_SWING_END_3 (1588)#define SKIP_SWING_END_2 (1566)#define TILTG75_START (1672)#define CFG_6 (2753)#define TILTL75_END (1669)#define END_ORIENT (1884)#define CFG_FLICK_IN (2573)#define TILTL75_START (1643)#define CFG_MOTION_BIAS (1208)#define X_GRT_Y (1408)#define TEMPLABEL (2324)#define CFG_ANDROID_ORIENT_INT (1853)#define CFG_GYRO_RAW_DATA (2722)#define X_GRT_Y_TMP2 (1379)#define D_0_22 (22+512)#define D_0_24 (24+512)#define D_0_36 (36)#define D_0_52 (52)#define D_0_96 (96)#define D_0_104 (104)#define D_0_108 (108)#define D_0_163 (163)#define D_0_188 (188)#define D_0_192 (192)#define D_0_224 (224)#define D_0_228 (228)#define D_0_232 (232)#define D_0_236 (236)#define D_1_2 (256 + 2)#define D_1_4 (256 + 4)#define D_1_8 (256 + 8)#define D_1_10 (256 + 10)#define D_1_24 (256 + 24)#define D_1_28 (256 + 28)#define D_1_36 (256 + 36)#define D_1_40 (256 + 40)#define D_1_44 (256 + 44)#define D_1_72 (256 + 72)#define D_1_74 (256 + 74)#define D_1_79 (256 + 79)#define D_1_88 (256 + 88)#define D_1_90 (256 + 90)#define D_1_92 (256 + 92)#define D_1_96 (256 + 96)#define D_1_98 (256 + 98)#define D_1_106 (256 + 106)#define D_1_108 (256 + 108)#define D_1_112 (256 + 112)#define D_1_128 (256 + 144)#define D_1_152 (256 + 12)#define D_1_160 (256 + 160)#define D_1_176 (256 + 176)#define D_1_178 (256 + 178)#define D_1_218 (256 + 218)#define D_1_232 (256 + 232)#define D_1_236 (256 + 236)#define D_1_240 (256 + 240)#define D_1_244 (256 + 244)#define D_1_250 (256 + 250)#define D_1_252 (256 + 252)#define D_2_12 (512 + 12)#define D_2_96 (512 + 96)#define D_2_108 (512 + 108)#define D_2_208 (512 + 208)#define D_2_224 (512 + 224)#define D_2_236 (512 + 236)#define D_2_244 (512 + 244)#define D_2_248 (512 + 248)#define D_2_252 (512 + 252)#define CPASS_BIAS_X (35 * 16 + 4)#define CPASS_BIAS_Y (35 * 16 + 8)#define CPASS_BIAS_Z (35 * 16 + 12)#define CPASS_MTX_00 (36 * 16)#define CPASS_MTX_01 (36 * 16 + 4)#define CPASS_MTX_02 (36 * 16 + 8)#define CPASS_MTX_10 (36 * 16 + 12)#define CPASS_MTX_11 (37 * 16)#define CPASS_MTX_12 (37 * 16 + 4)#define CPASS_MTX_20 (37 * 16 + 8)#define CPASS_MTX_21 (37 * 16 + 12)#define CPASS_MTX_22 (43 * 16 + 12)#define D_EXT_GYRO_BIAS_X (61 * 16)#define D_EXT_GYRO_BIAS_Y (61 * 16) + 4#define D_EXT_GYRO_BIAS_Z (61 * 16) + 8#define D_ACT0 (40 * 16)#define D_ACSX (40 * 16 + 4)#define D_ACSY (40 * 16 + 8)#define D_ACSZ (40 * 16 + 12)#define FLICK_MSG (45 * 16 + 4)#define FLICK_COUNTER (45 * 16 + 8)#define FLICK_LOWER (45 * 16 + 12)#define FLICK_UPPER (46 * 16 + 12)#define D_AUTH_OUT (992)#define D_AUTH_IN (996)#define D_AUTH_A (1000)#define D_AUTH_B (1004)#define D_PEDSTD_BP_B (768 + 0x1C)#define D_PEDSTD_HP_A (768 + 0x78)#define D_PEDSTD_HP_B (768 + 0x7C)#define D_PEDSTD_BP_A4 (768 + 0x40)#define D_PEDSTD_BP_A3 (768 + 0x44)#define D_PEDSTD_BP_A2 (768 + 0x48)#define D_PEDSTD_BP_A1 (768 + 0x4C)#define D_PEDSTD_INT_THRSH (768 + 0x68)#define D_PEDSTD_CLIP (768 + 0x6C)#define D_PEDSTD_SB (768 + 0x28)#define D_PEDSTD_SB_TIME (768 + 0x2C)#define D_PEDSTD_PEAKTHRSH (768 + 0x98)#define D_PEDSTD_TIML (768 + 0x2A)#define D_PEDSTD_TIMH (768 + 0x2E)#define D_PEDSTD_PEAK (768 + 0X94)#define D_PEDSTD_STEPCTR (768 + 0x60)#define D_PEDSTD_TIMECTR (964)#define D_PEDSTD_DECI (768 + 0xA0)#define D_HOST_NO_MOT (976)#define D_ACCEL_BIAS (660)#define D_ORIENT_GAP (76)#define D_TILT0_H (48)#define D_TILT0_L (50)#define D_TILT1_H (52)#define D_TILT1_L (54)#define D_TILT2_H (56)#define D_TILT2_L (58)#define D_TILT3_H (60)#define D_TILT3_L (62)#define DMP_CODE_SIZE (3062)#define INT_SRC_TAP (0x01)#define INT_SRC_ANDROID_ORIENT (0x08)#define DMP_FEATURE_SEND_ANY_GYRO#define MAX_PACKET_LENGTH (32)#define DMP_SAMPLE_RATE (200)#define GYRO_SF (46850825LL * 200 / DMP_SAMPLE_RATE)#define FIFO_CORRUPTION_CHECK#define QUAT_ERROR_THRESH (1L<<24)#define QUAT_MAG_SQ_NORMALIZED (1L<<28)#define QUAT_MAG_SQ_MIN (QUAT_MAG_SQ_NORMALIZED - QUAT_ERROR_THRESH)#define QUAT_MAG_SQ_MAX (QUAT_MAG_SQ_NORMALIZED + QUAT_ERROR_THRESH)函数 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. The orientation is represented here as the output of inv_orientation_matrix_to_scalar. 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. int dmp_set_accel_bias (long *bias)Push accel biases to the DMP. These biases will be removed from the DMP 6-axis quaternion. int dmp_set_fifo_rate (unsigned short rate)Set DMP output rate. Only used when DMP is on. 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. If the DMP detects a gyro sample larger than thresh, taps are rejected. 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. 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. 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. WARNING: This function writes to DMP memory and could potentially encounter a race condition if called while the pedometer is enabled. 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. WARNING: This function writes to DMP memory and could potentially encounter a race condition if called while the pedometer is enabled. 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. 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. 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. 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. 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. 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. 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. 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. int dmp_register_tap_cb (void(*func)(unsigned char, unsigned char))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 int dmp_register_android_orient_cb (void(*func)(unsigned char))Register a function to be executed on a android orientation event. 变量 static const unsigned char dmp_memory [DMP_CODE_SIZE]static const unsigned short sStartAddress = 0x0400static struct dmp_s dmp详细描述DMP image and interface functions. All functions are preceded by the dmp_ prefix to differentiate among MPL and general driver function calls.
在文件 inv_mpu_dmp_motion_driver.c 中定义.