inv_mpu_dmp_motion_driver.h D:/gitt/MicrochipFor32/bsp_MPU6050/inv_mpu.c D:/gitt/MicrochipFor32/bsp_MPU6050/inv_mpu_dmp_motion_driver.c TAP_X (0x01) TAP_Y (0x02) TAP_Z (0x04) TAP_XYZ (0x07) TAP_X_UP (0x01) TAP_X_DOWN (0x02) TAP_Y_UP (0x03) TAP_Y_DOWN (0x04) TAP_Z_UP (0x05) TAP_Z_DOWN (0x06) ANDROID_ORIENT_PORTRAIT (0x00) ANDROID_ORIENT_LANDSCAPE (0x01) ANDROID_ORIENT_REVERSE_PORTRAIT (0x02) ANDROID_ORIENT_REVERSE_LANDSCAPE (0x03) DMP_INT_GESTURE (0x01) DMP_INT_CONTINUOUS (0x02) DMP_FEATURE_TAP (0x001) DMP_FEATURE_ANDROID_ORIENT (0x002) DMP_FEATURE_LP_QUAT (0x004) DMP_FEATURE_PEDOMETER (0x008) DMP_FEATURE_6X_LP_QUAT (0x010) DMP_FEATURE_GYRO_CAL (0x020) DMP_FEATURE_SEND_RAW_ACCEL (0x040) DMP_FEATURE_SEND_RAW_GYRO (0x080) DMP_FEATURE_SEND_CAL_GYRO (0x100) INV_WXYZ_QUAT (0x100) int int dmp_load_motion_driver_firmware (void) dmp_load_motion_driver_firmware void Load the DMP with this image. 0 if successful. DMP_CODE_SIZE dmp_memory DMP_SAMPLE_RATE mpu_load_firmware sStartAddress mpu_dmp_init int int dmp_set_fifo_rate (unsigned short rate) dmp_set_fifo_rate unsigned short rate Set DMP output rate. Only used when DMP is on. rate Desired fifo rate (Hz). 0 if successful. CFG_6 D_0_22 DINAAA DINAAB DINADF DINAF1 DINAF2 DINAFE dmp DMP_SAMPLE_RATE dmp_s::fifo_rate mpu_write_mem mpu_dmp_init int int dmp_get_fifo_rate (unsigned short *rate) dmp_get_fifo_rate unsigned short * rate Get DMP output rate. rate Current fifo rate (Hz). 0 if successful. dmp dmp_s::fifo_rate int int dmp_enable_feature (unsigned short mask) 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. mask Mask of features to enable. 0 if successful. CFG_15 CFG_20 CFG_27 CFG_ANDROID_ORIENT_INT CFG_GYRO_RAW_DATA D_0_104 DINA20 DINA80 DINA90 DINAC0 DINAC2 dmp dmp_enable_6x_lp_quat dmp_enable_gyro_cal dmp_enable_lp_quat DMP_FEATURE_6X_LP_QUAT DMP_FEATURE_ANDROID_ORIENT DMP_FEATURE_GYRO_CAL DMP_FEATURE_LP_QUAT DMP_FEATURE_PEDOMETER DMP_FEATURE_SEND_ANY_GYRO DMP_FEATURE_SEND_CAL_GYRO DMP_FEATURE_SEND_RAW_ACCEL DMP_FEATURE_TAP 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 dmp_s::feature_mask GYRO_SF mpu_reset_fifo mpu_write_mem dmp_s::packet_length TAP_XYZ mpu_dmp_init int int dmp_get_enabled_features (unsigned short *mask) dmp_get_enabled_features unsigned short * mask Get list of currently enabled DMP features. Mask of enabled features. 0 if successful. dmp dmp_s::feature_mask int int dmp_set_interrupt_mode (unsigned char mode) 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. mode DMP_INT_GESTURE or DMP_INT_CONTINUOUS. 0 if successful. CFG_FIFO_ON_EVENT DMP_INT_CONTINUOUS DMP_INT_GESTURE mpu_write_mem int int dmp_set_orientation (unsigned short orient) 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. orient Gyro and accel orientation in body frame. 0 if successful. DINA0C DINA26 DINA2C DINA36 DINA46 DINA4C DINA56 DINA66 DINA6C DINA76 DINAC9 DINACD dmp FCFG_1 FCFG_2 FCFG_3 FCFG_7 mpu_write_mem dmp_s::orient mpu_dmp_init int int dmp_set_gyro_bias (long *bias) 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. bias Gyro biases in q16. 0 if successful. D_EXT_GYRO_BIAS_X D_EXT_GYRO_BIAS_Y D_EXT_GYRO_BIAS_Z dmp GYRO_SF mpu_write_mem dmp_s::orient run_self_test int int dmp_set_accel_bias (long *bias) dmp_set_accel_bias long * bias Push accel biases to the DMP. These biases will be removed from the DMP 6-axis quaternion. bias Accel biases in q16. 0 if successful. D_ACCEL_BIAS dmp mpu_get_accel_sens mpu_write_mem dmp_s::orient run_self_test int int dmp_register_tap_cb (void(*func)(unsigned char, unsigned char)) 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 func Callback function. 0 if successful. dmp dmp_s::tap_cb int int dmp_set_tap_thresh (unsigned char axis, unsigned short thresh) dmp_set_tap_thresh unsigned char axis unsigned short thresh Set tap threshold for a specific axis. axis 1, 2, and 4 for XYZ accel, respectively. thresh Tap threshold, in mg/ms. 0 if successful. D_1_36 D_1_40 D_1_44 DMP_SAMPLE_RATE DMP_TAP_THX DMP_TAP_THY DMP_TAP_THZ mpu_get_accel_fsr mpu_write_mem TAP_X TAP_XYZ TAP_Y TAP_Z dmp_enable_feature int int dmp_set_tap_axes (unsigned char axis) dmp_set_tap_axes unsigned char axis Set which axes will register a tap. axis 1, 2, and 4 for XYZ, respectively. 0 if successful. D_1_72 mpu_write_mem TAP_X TAP_Y TAP_Z dmp_enable_feature int int dmp_set_tap_count (unsigned char min_taps) dmp_set_tap_count unsigned char min_taps Set minimum number of taps needed for an interrupt. min_taps Minimum consecutive taps (1-4). 0 if successful. D_1_79 mpu_write_mem dmp_enable_feature int int dmp_set_tap_time (unsigned short time) dmp_set_tap_time unsigned short time Set length between valid taps. time Milliseconds between taps. 0 if successful. DMP_SAMPLE_RATE DMP_TAPW_MIN mpu_write_mem dmp_enable_feature int int dmp_set_tap_time_multi (unsigned short time) dmp_set_tap_time_multi unsigned short time Set max time between taps to register as a multi-tap. time Max milliseconds between taps. 0 if successful. D_1_218 DMP_SAMPLE_RATE mpu_write_mem dmp_enable_feature int int dmp_set_shake_reject_thresh (long sf, unsigned short thresh) 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. sf Gyro scale factor. thresh Gyro threshold in dps. 0 if successful. D_1_92 mpu_write_mem dmp_enable_feature int int dmp_set_shake_reject_time (unsigned short time) 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. time Time in milliseconds. 0 if successful. D_1_90 DMP_SAMPLE_RATE mpu_write_mem dmp_enable_feature int int dmp_set_shake_reject_timeout (unsigned short time) 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. time Time in milliseconds. 0 if successful. D_1_88 DMP_SAMPLE_RATE mpu_write_mem dmp_enable_feature int int dmp_register_android_orient_cb (void(*func)(unsigned char)) dmp_register_android_orient_cb void(*)(unsigned char) func Register a function to be executed on a android orientation event. func Callback function. 0 if successful. dmp_s::android_orient_cb dmp int int dmp_enable_lp_quat (unsigned char enable) 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. enable 1 to enable 3-axis quaternion. 0 if successful. CFG_LP_QUAT DINBC0 DINBC2 DINBC4 DINBC6 mpu_reset_fifo mpu_write_mem dmp_enable_feature int int dmp_enable_6x_lp_quat (unsigned char enable) 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. enable 1 to enable 6-axis quaternion. 0 if successful. CFG_8 DINA20 DINA28 DINA30 DINA38 mpu_reset_fifo mpu_write_mem dmp_enable_feature int int dmp_get_pedometer_step_count (unsigned long *count) dmp_get_pedometer_step_count unsigned long * count Get current step count. count Number of steps detected. 0 if successful. D_PEDSTD_STEPCTR mpu_read_mem int int dmp_set_pedometer_step_count (unsigned long count) 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. count New step count. 0 if successful. D_PEDSTD_STEPCTR mpu_write_mem int int dmp_get_pedometer_walk_time (unsigned long *time) dmp_get_pedometer_walk_time unsigned long * time Get duration of walking time. time Walk time in milliseconds. 0 if successful. D_PEDSTD_TIMECTR mpu_read_mem int int dmp_set_pedometer_walk_time (unsigned long time) 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. time New walk time in milliseconds. D_PEDSTD_TIMECTR mpu_write_mem int int dmp_enable_gyro_cal (unsigned char enable) 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. enable 1 to enable gyro calibration. 0 if successful. CFG_MOTION_BIAS mpu_write_mem dmp_enable_feature int int dmp_read_fifo (short *gyro, short *accel, long *quat, unsigned long *timestamp, short *sensors, unsigned char *more) 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. gyro Gyro data in hardware units. accel Accel data in hardware units. quat 3-axis quaternion data in hardware units. timestamp Timestamp in milliseconds. sensors Mask of sensors read from FIFO. more Number of remaining packets. 0 if successful. decode_gesture dmp DMP_FEATURE_6X_LP_QUAT DMP_FEATURE_ANDROID_ORIENT DMP_FEATURE_LP_QUAT DMP_FEATURE_SEND_ANY_GYRO DMP_FEATURE_SEND_RAW_ACCEL DMP_FEATURE_TAP dmp_s::feature_mask get_ms INV_WXYZ_QUAT INV_XYZ_ACCEL INV_XYZ_GYRO MAX_PACKET_LENGTH mpu_read_fifo_stream mpu_reset_fifo dmp_s::packet_length QUAT_MAG_SQ_MAX QUAT_MAG_SQ_MIN mpu_dmp_get_data DMP image and interface functions. All functions are preceded by the dmp_ prefix to differentiate among MPL and general driver function calls. /* $License: Copyright(C)2011-2012InvenSenseCorporation,AllRightsReserved. SeeincludedLicense.txtforLicenseinformation. $ */ #ifndef_INV_MPU_DMP_MOTION_DRIVER_H_ #define_INV_MPU_DMP_MOTION_DRIVER_H_ #defineTAP_X(0x01) #defineTAP_Y(0x02) #defineTAP_Z(0x04) #defineTAP_XYZ(0x07) #defineTAP_X_UP(0x01) #defineTAP_X_DOWN(0x02) #defineTAP_Y_UP(0x03) #defineTAP_Y_DOWN(0x04) #defineTAP_Z_UP(0x05) #defineTAP_Z_DOWN(0x06) #defineANDROID_ORIENT_PORTRAIT(0x00) #defineANDROID_ORIENT_LANDSCAPE(0x01) #defineANDROID_ORIENT_REVERSE_PORTRAIT(0x02) #defineANDROID_ORIENT_REVERSE_LANDSCAPE(0x03) #defineDMP_INT_GESTURE(0x01) #defineDMP_INT_CONTINUOUS(0x02) #defineDMP_FEATURE_TAP(0x001) #defineDMP_FEATURE_ANDROID_ORIENT(0x002) #defineDMP_FEATURE_LP_QUAT(0x004) #defineDMP_FEATURE_PEDOMETER(0x008) #defineDMP_FEATURE_6X_LP_QUAT(0x010) #defineDMP_FEATURE_GYRO_CAL(0x020) #defineDMP_FEATURE_SEND_RAW_ACCEL(0x040) #defineDMP_FEATURE_SEND_RAW_GYRO(0x080) #defineDMP_FEATURE_SEND_CAL_GYRO(0x100) #defineINV_WXYZ_QUAT(0x100) /*Setupfunctions.*/ intdmp_load_motion_driver_firmware(void); intdmp_set_fifo_rate(unsignedshortrate); intdmp_get_fifo_rate(unsignedshort*rate); intdmp_enable_feature(unsignedshortmask); intdmp_get_enabled_features(unsignedshort*mask); intdmp_set_interrupt_mode(unsignedcharmode); intdmp_set_orientation(unsignedshortorient); intdmp_set_gyro_bias(long*bias); intdmp_set_accel_bias(long*bias); /*Tapfunctions.*/ intdmp_register_tap_cb(void(*func)(unsignedchar,unsignedchar)); intdmp_set_tap_thresh(unsignedcharaxis,unsignedshortthresh); intdmp_set_tap_axes(unsignedcharaxis); intdmp_set_tap_count(unsignedcharmin_taps); intdmp_set_tap_time(unsignedshorttime); intdmp_set_tap_time_multi(unsignedshorttime); intdmp_set_shake_reject_thresh(longsf,unsignedshortthresh); intdmp_set_shake_reject_time(unsignedshorttime); intdmp_set_shake_reject_timeout(unsignedshorttime); /*Androidorientationfunctions.*/ intdmp_register_android_orient_cb(void(*func)(unsignedchar)); /*LPquaternionfunctions.*/ intdmp_enable_lp_quat(unsignedcharenable); intdmp_enable_6x_lp_quat(unsignedcharenable); /*Pedometerfunctions.*/ intdmp_get_pedometer_step_count(unsignedlong*count); intdmp_set_pedometer_step_count(unsignedlongcount); intdmp_get_pedometer_walk_time(unsignedlong*time); intdmp_set_pedometer_walk_time(unsignedlongtime); /*DMPgyrocalibrationfunctions.*/ intdmp_enable_gyro_cal(unsignedcharenable); /*Readfunction.ThisfunctionshouldbecalledwhenevertheMPUinterruptis *detected. */ intdmp_read_fifo(short*gyro,short*accel,long*quat, unsignedlong*timestamp,short*sensors,unsignedchar*more); #endif/*#ifndef_INV_MPU_DMP_MOTION_DRIVER_H_*/