InvenSense Motion Driver v5.1.2 ported

Dependents:   Sensorv2

Committer:
oprospero
Date:
Tue Jun 03 07:54:12 2014 +0000
Revision:
0:4dd021344a6b
Child:
3:8ac73f9099ab
Initial MotionDriver v5.1.2 ported from InvenSense

Who changed what in which revision?

UserRevisionLine numberNew contents of line
oprospero 0:4dd021344a6b 1 #ifndef _INV_MPU_DMP_MOTION_DRIVER_H_
oprospero 0:4dd021344a6b 2 #define _INV_MPU_DMP_MOTION_DRIVER_H_
oprospero 0:4dd021344a6b 3
oprospero 0:4dd021344a6b 4 #define TAP_X (0x01)
oprospero 0:4dd021344a6b 5 #define TAP_Y (0x02)
oprospero 0:4dd021344a6b 6 #define TAP_Z (0x04)
oprospero 0:4dd021344a6b 7 #define TAP_XYZ (0x07)
oprospero 0:4dd021344a6b 8
oprospero 0:4dd021344a6b 9 #define TAP_X_UP (0x01)
oprospero 0:4dd021344a6b 10 #define TAP_X_DOWN (0x02)
oprospero 0:4dd021344a6b 11 #define TAP_Y_UP (0x03)
oprospero 0:4dd021344a6b 12 #define TAP_Y_DOWN (0x04)
oprospero 0:4dd021344a6b 13 #define TAP_Z_UP (0x05)
oprospero 0:4dd021344a6b 14 #define TAP_Z_DOWN (0x06)
oprospero 0:4dd021344a6b 15
oprospero 0:4dd021344a6b 16 #define ANDROID_ORIENT_PORTRAIT (0x00)
oprospero 0:4dd021344a6b 17 #define ANDROID_ORIENT_LANDSCAPE (0x01)
oprospero 0:4dd021344a6b 18 #define ANDROID_ORIENT_REVERSE_PORTRAIT (0x02)
oprospero 0:4dd021344a6b 19 #define ANDROID_ORIENT_REVERSE_LANDSCAPE (0x03)
oprospero 0:4dd021344a6b 20
oprospero 0:4dd021344a6b 21 #define DMP_INT_GESTURE (0x01)
oprospero 0:4dd021344a6b 22 #define DMP_INT_CONTINUOUS (0x02)
oprospero 0:4dd021344a6b 23
oprospero 0:4dd021344a6b 24 #define DMP_FEATURE_TAP (0x001)
oprospero 0:4dd021344a6b 25 #define DMP_FEATURE_ANDROID_ORIENT (0x002)
oprospero 0:4dd021344a6b 26 #define DMP_FEATURE_LP_QUAT (0x004)
oprospero 0:4dd021344a6b 27 #define DMP_FEATURE_PEDOMETER (0x008)
oprospero 0:4dd021344a6b 28 #define DMP_FEATURE_6X_LP_QUAT (0x010)
oprospero 0:4dd021344a6b 29 #define DMP_FEATURE_GYRO_CAL (0x020)
oprospero 0:4dd021344a6b 30 #define DMP_FEATURE_SEND_RAW_ACCEL (0x040)
oprospero 0:4dd021344a6b 31 #define DMP_FEATURE_SEND_RAW_GYRO (0x080)
oprospero 0:4dd021344a6b 32 #define DMP_FEATURE_SEND_CAL_GYRO (0x100)
oprospero 0:4dd021344a6b 33
oprospero 0:4dd021344a6b 34 #define INV_WXYZ_QUAT (0x100)
oprospero 0:4dd021344a6b 35
oprospero 0:4dd021344a6b 36 #include "inv_mpu.h"
oprospero 0:4dd021344a6b 37 #include "helper_3dmath.h"
oprospero 0:4dd021344a6b 38
oprospero 0:4dd021344a6b 39 class DMP_Motion_Driver : public InvMpu
oprospero 0:4dd021344a6b 40 {
oprospero 0:4dd021344a6b 41 public:
oprospero 0:4dd021344a6b 42 DMP_Motion_Driver();
oprospero 0:4dd021344a6b 43
oprospero 0:4dd021344a6b 44 unsigned short inv_orientation_matrix_to_scalar(const signed char *mtx);
oprospero 0:4dd021344a6b 45 int dmp_get_packet_length();
oprospero 0:4dd021344a6b 46 int dmpGetGravity(VectorFloat *v, Quaternion *q) ;
oprospero 0:4dd021344a6b 47 int dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity) ;
oprospero 0:4dd021344a6b 48
oprospero 0:4dd021344a6b 49 // static
oprospero 0:4dd021344a6b 50 int decode_gesture(unsigned char *gesture);
oprospero 0:4dd021344a6b 51
oprospero 0:4dd021344a6b 52 /* Set up functions. */
oprospero 0:4dd021344a6b 53 int dmp_load_motion_driver_firmware(void);
oprospero 0:4dd021344a6b 54 int dmp_set_fifo_rate(unsigned short rate);
oprospero 0:4dd021344a6b 55 int dmp_get_fifo_rate(unsigned short *rate);
oprospero 0:4dd021344a6b 56 int dmp_enable_feature(unsigned short mask);
oprospero 0:4dd021344a6b 57 int dmp_get_enabled_features(unsigned short *mask);
oprospero 0:4dd021344a6b 58 int dmp_set_interrupt_mode(unsigned char mode);
oprospero 0:4dd021344a6b 59 int dmp_set_orientation(unsigned short orient);
oprospero 0:4dd021344a6b 60 int dmp_set_gyro_bias(long *bias);
oprospero 0:4dd021344a6b 61 int dmp_set_accel_bias(long *bias);
oprospero 0:4dd021344a6b 62
oprospero 0:4dd021344a6b 63 /* Tap functions. */
oprospero 0:4dd021344a6b 64 int dmp_register_tap_cb(void (*func)(unsigned char, unsigned char));
oprospero 0:4dd021344a6b 65 int dmp_set_tap_thresh(unsigned char axis, unsigned short thresh);
oprospero 0:4dd021344a6b 66 int dmp_set_tap_axes(unsigned char axis);
oprospero 0:4dd021344a6b 67 int dmp_set_tap_count(unsigned char min_taps);
oprospero 0:4dd021344a6b 68 int dmp_set_tap_time(unsigned short time);
oprospero 0:4dd021344a6b 69 int dmp_set_tap_time_multi(unsigned short time);
oprospero 0:4dd021344a6b 70 int dmp_set_shake_reject_thresh(long sf, unsigned short thresh);
oprospero 0:4dd021344a6b 71 int dmp_set_shake_reject_time(unsigned short time);
oprospero 0:4dd021344a6b 72 int dmp_set_shake_reject_timeout(unsigned short time);
oprospero 0:4dd021344a6b 73
oprospero 0:4dd021344a6b 74 /* Android orientation functions. */
oprospero 0:4dd021344a6b 75 int dmp_register_android_orient_cb(void (*func)(unsigned char));
oprospero 0:4dd021344a6b 76
oprospero 0:4dd021344a6b 77
oprospero 0:4dd021344a6b 78 /* Pedometer functions. */
oprospero 0:4dd021344a6b 79 int dmp_get_pedometer_step_count(unsigned long *count);
oprospero 0:4dd021344a6b 80 int dmp_set_pedometer_step_count(unsigned long count);
oprospero 0:4dd021344a6b 81 int dmp_get_pedometer_walk_time(unsigned long *time);
oprospero 0:4dd021344a6b 82 int dmp_set_pedometer_walk_time(unsigned long time);
oprospero 0:4dd021344a6b 83
oprospero 0:4dd021344a6b 84
oprospero 0:4dd021344a6b 85 /* Read function. This function should be called whenever the MPU interrupt is
oprospero 0:4dd021344a6b 86 * detected.
oprospero 0:4dd021344a6b 87 */
oprospero 0:4dd021344a6b 88 int dmp_read_fifo(short *gyro, short *accel, long *quat,
oprospero 0:4dd021344a6b 89 unsigned long *timestamp, short *sensors, unsigned char *more);
oprospero 0:4dd021344a6b 90
oprospero 0:4dd021344a6b 91 private:
oprospero 0:4dd021344a6b 92 /* DMP gyro calibration functions. */
oprospero 0:4dd021344a6b 93 int dmp_enable_gyro_cal(unsigned char enable);
oprospero 0:4dd021344a6b 94
oprospero 0:4dd021344a6b 95 /* LP quaternion functions. */
oprospero 0:4dd021344a6b 96 int dmp_enable_lp_quat(unsigned char enable);
oprospero 0:4dd021344a6b 97 int dmp_enable_6x_lp_quat(unsigned char enable);
oprospero 0:4dd021344a6b 98 };
oprospero 0:4dd021344a6b 99
oprospero 0:4dd021344a6b 100 #endif