It is modified accordingly to work with sparkfun dmp library under mbed platform
Dependents: MPU9250-dmp-bluepill MPU9250-dmp
Fork of MotionDriver_6_1 by
inv_mpu.h@1:a6c3f8680fe0, 2017-08-07 (annotated)
- Committer:
- mbedoguz
- Date:
- Mon Aug 07 13:49:51 2017 +0000
- Revision:
- 1:a6c3f8680fe0
- Parent:
- 0:5fa30cf392c3
It is modified to work wirh mbed platform. Now compiles but fifo is not available (Using sparkfun dmp library)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oprospero | 0:5fa30cf392c3 | 1 | /* |
oprospero | 0:5fa30cf392c3 | 2 | $License: |
oprospero | 0:5fa30cf392c3 | 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. |
oprospero | 0:5fa30cf392c3 | 4 | See included License.txt for License information. |
oprospero | 0:5fa30cf392c3 | 5 | $ |
oprospero | 0:5fa30cf392c3 | 6 | */ |
oprospero | 0:5fa30cf392c3 | 7 | /** |
oprospero | 0:5fa30cf392c3 | 8 | * @addtogroup DRIVERS Sensor Driver Layer |
oprospero | 0:5fa30cf392c3 | 9 | * @brief Hardware drivers to communicate with sensors via I2C. |
oprospero | 0:5fa30cf392c3 | 10 | * |
oprospero | 0:5fa30cf392c3 | 11 | * @{ |
oprospero | 0:5fa30cf392c3 | 12 | * @file inv_mpu.h |
oprospero | 0:5fa30cf392c3 | 13 | * @brief An I2C-based driver for Invensense gyroscopes. |
oprospero | 0:5fa30cf392c3 | 14 | * @details This driver currently works for the following devices: |
oprospero | 0:5fa30cf392c3 | 15 | * MPU6050 |
oprospero | 0:5fa30cf392c3 | 16 | * MPU6500 |
oprospero | 0:5fa30cf392c3 | 17 | * MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus) |
oprospero | 0:5fa30cf392c3 | 18 | * MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus) |
oprospero | 0:5fa30cf392c3 | 19 | */ |
oprospero | 0:5fa30cf392c3 | 20 | |
oprospero | 0:5fa30cf392c3 | 21 | #ifndef _INV_MPU_H_ |
oprospero | 0:5fa30cf392c3 | 22 | #define _INV_MPU_H_ |
oprospero | 0:5fa30cf392c3 | 23 | |
oprospero | 0:5fa30cf392c3 | 24 | #define INV_X_GYRO (0x40) |
oprospero | 0:5fa30cf392c3 | 25 | #define INV_Y_GYRO (0x20) |
oprospero | 0:5fa30cf392c3 | 26 | #define INV_Z_GYRO (0x10) |
oprospero | 0:5fa30cf392c3 | 27 | #define INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO) |
oprospero | 0:5fa30cf392c3 | 28 | #define INV_XYZ_ACCEL (0x08) |
oprospero | 0:5fa30cf392c3 | 29 | #define INV_XYZ_COMPASS (0x01) |
oprospero | 0:5fa30cf392c3 | 30 | |
oprospero | 0:5fa30cf392c3 | 31 | struct int_param_s { |
oprospero | 0:5fa30cf392c3 | 32 | #if defined EMPL_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_MSP430 |
oprospero | 0:5fa30cf392c3 | 33 | void (*cb)(void); |
oprospero | 0:5fa30cf392c3 | 34 | unsigned short pin; |
oprospero | 0:5fa30cf392c3 | 35 | unsigned char lp_exit; |
oprospero | 0:5fa30cf392c3 | 36 | unsigned char active_low; |
oprospero | 0:5fa30cf392c3 | 37 | #elif defined EMPL_TARGET_UC3L0 |
oprospero | 0:5fa30cf392c3 | 38 | unsigned long pin; |
oprospero | 0:5fa30cf392c3 | 39 | void (*cb)(volatile void*); |
oprospero | 0:5fa30cf392c3 | 40 | void *arg; |
oprospero | 0:5fa30cf392c3 | 41 | #elif defined EMPL_TARGET_STM32F4 |
oprospero | 0:5fa30cf392c3 | 42 | void (*cb)(void); |
oprospero | 0:5fa30cf392c3 | 43 | #endif |
oprospero | 0:5fa30cf392c3 | 44 | }; |
oprospero | 0:5fa30cf392c3 | 45 | |
oprospero | 0:5fa30cf392c3 | 46 | #define MPU_INT_STATUS_DATA_READY (0x0001) |
oprospero | 0:5fa30cf392c3 | 47 | #define MPU_INT_STATUS_DMP (0x0002) |
oprospero | 0:5fa30cf392c3 | 48 | #define MPU_INT_STATUS_PLL_READY (0x0004) |
oprospero | 0:5fa30cf392c3 | 49 | #define MPU_INT_STATUS_I2C_MST (0x0008) |
oprospero | 0:5fa30cf392c3 | 50 | #define MPU_INT_STATUS_FIFO_OVERFLOW (0x0010) |
oprospero | 0:5fa30cf392c3 | 51 | #define MPU_INT_STATUS_ZMOT (0x0020) |
oprospero | 0:5fa30cf392c3 | 52 | #define MPU_INT_STATUS_MOT (0x0040) |
oprospero | 0:5fa30cf392c3 | 53 | #define MPU_INT_STATUS_FREE_FALL (0x0080) |
oprospero | 0:5fa30cf392c3 | 54 | #define MPU_INT_STATUS_DMP_0 (0x0100) |
oprospero | 0:5fa30cf392c3 | 55 | #define MPU_INT_STATUS_DMP_1 (0x0200) |
oprospero | 0:5fa30cf392c3 | 56 | #define MPU_INT_STATUS_DMP_2 (0x0400) |
oprospero | 0:5fa30cf392c3 | 57 | #define MPU_INT_STATUS_DMP_3 (0x0800) |
oprospero | 0:5fa30cf392c3 | 58 | #define MPU_INT_STATUS_DMP_4 (0x1000) |
oprospero | 0:5fa30cf392c3 | 59 | #define MPU_INT_STATUS_DMP_5 (0x2000) |
oprospero | 0:5fa30cf392c3 | 60 | |
oprospero | 0:5fa30cf392c3 | 61 | /* Set up APIs */ |
mbedoguz | 1:a6c3f8680fe0 | 62 | int set_int_enable(unsigned char enable); |
oprospero | 0:5fa30cf392c3 | 63 | int mpu_init(struct int_param_s *int_param); |
oprospero | 0:5fa30cf392c3 | 64 | int mpu_init_slave(void); |
oprospero | 0:5fa30cf392c3 | 65 | int mpu_set_bypass(unsigned char bypass_on); |
oprospero | 0:5fa30cf392c3 | 66 | |
oprospero | 0:5fa30cf392c3 | 67 | /* Configuration APIs */ |
oprospero | 0:5fa30cf392c3 | 68 | int mpu_lp_accel_mode(unsigned short rate); |
oprospero | 0:5fa30cf392c3 | 69 | int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time, |
oprospero | 0:5fa30cf392c3 | 70 | unsigned short lpa_freq); |
oprospero | 0:5fa30cf392c3 | 71 | int mpu_set_int_level(unsigned char active_low); |
oprospero | 0:5fa30cf392c3 | 72 | int mpu_set_int_latched(unsigned char enable); |
oprospero | 0:5fa30cf392c3 | 73 | |
oprospero | 0:5fa30cf392c3 | 74 | int mpu_set_dmp_state(unsigned char enable); |
oprospero | 0:5fa30cf392c3 | 75 | int mpu_get_dmp_state(unsigned char *enabled); |
oprospero | 0:5fa30cf392c3 | 76 | |
oprospero | 0:5fa30cf392c3 | 77 | int mpu_get_lpf(unsigned short *lpf); |
oprospero | 0:5fa30cf392c3 | 78 | int mpu_set_lpf(unsigned short lpf); |
oprospero | 0:5fa30cf392c3 | 79 | |
oprospero | 0:5fa30cf392c3 | 80 | int mpu_get_gyro_fsr(unsigned short *fsr); |
oprospero | 0:5fa30cf392c3 | 81 | int mpu_set_gyro_fsr(unsigned short fsr); |
oprospero | 0:5fa30cf392c3 | 82 | |
oprospero | 0:5fa30cf392c3 | 83 | int mpu_get_accel_fsr(unsigned char *fsr); |
oprospero | 0:5fa30cf392c3 | 84 | int mpu_set_accel_fsr(unsigned char fsr); |
oprospero | 0:5fa30cf392c3 | 85 | |
oprospero | 0:5fa30cf392c3 | 86 | int mpu_get_compass_fsr(unsigned short *fsr); |
oprospero | 0:5fa30cf392c3 | 87 | |
oprospero | 0:5fa30cf392c3 | 88 | int mpu_get_gyro_sens(float *sens); |
oprospero | 0:5fa30cf392c3 | 89 | int mpu_get_accel_sens(unsigned short *sens); |
oprospero | 0:5fa30cf392c3 | 90 | |
oprospero | 0:5fa30cf392c3 | 91 | int mpu_get_sample_rate(unsigned short *rate); |
oprospero | 0:5fa30cf392c3 | 92 | int mpu_set_sample_rate(unsigned short rate); |
oprospero | 0:5fa30cf392c3 | 93 | int mpu_get_compass_sample_rate(unsigned short *rate); |
oprospero | 0:5fa30cf392c3 | 94 | int mpu_set_compass_sample_rate(unsigned short rate); |
oprospero | 0:5fa30cf392c3 | 95 | |
oprospero | 0:5fa30cf392c3 | 96 | int mpu_get_fifo_config(unsigned char *sensors); |
oprospero | 0:5fa30cf392c3 | 97 | int mpu_configure_fifo(unsigned char sensors); |
oprospero | 0:5fa30cf392c3 | 98 | |
oprospero | 0:5fa30cf392c3 | 99 | int mpu_get_power_state(unsigned char *power_on); |
oprospero | 0:5fa30cf392c3 | 100 | int mpu_set_sensors(unsigned char sensors); |
oprospero | 0:5fa30cf392c3 | 101 | |
oprospero | 0:5fa30cf392c3 | 102 | int mpu_read_6500_accel_bias(long *accel_bias); |
oprospero | 0:5fa30cf392c3 | 103 | int mpu_set_gyro_bias_reg(long * gyro_bias); |
oprospero | 0:5fa30cf392c3 | 104 | int mpu_set_accel_bias_6500_reg(const long *accel_bias); |
oprospero | 0:5fa30cf392c3 | 105 | int mpu_read_6050_accel_bias(long *accel_bias); |
oprospero | 0:5fa30cf392c3 | 106 | int mpu_set_accel_bias_6050_reg(const long *accel_bias); |
oprospero | 0:5fa30cf392c3 | 107 | |
oprospero | 0:5fa30cf392c3 | 108 | /* Data getter/setter APIs */ |
oprospero | 0:5fa30cf392c3 | 109 | int mpu_get_gyro_reg(short *data, unsigned long *timestamp); |
oprospero | 0:5fa30cf392c3 | 110 | int mpu_get_accel_reg(short *data, unsigned long *timestamp); |
oprospero | 0:5fa30cf392c3 | 111 | int mpu_get_compass_reg(short *data, unsigned long *timestamp); |
oprospero | 0:5fa30cf392c3 | 112 | int mpu_get_temperature(long *data, unsigned long *timestamp); |
oprospero | 0:5fa30cf392c3 | 113 | |
oprospero | 0:5fa30cf392c3 | 114 | int mpu_get_int_status(short *status); |
oprospero | 0:5fa30cf392c3 | 115 | int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp, |
oprospero | 0:5fa30cf392c3 | 116 | unsigned char *sensors, unsigned char *more); |
oprospero | 0:5fa30cf392c3 | 117 | int mpu_read_fifo_stream(unsigned short length, unsigned char *data, |
oprospero | 0:5fa30cf392c3 | 118 | unsigned char *more); |
oprospero | 0:5fa30cf392c3 | 119 | int mpu_reset_fifo(void); |
oprospero | 0:5fa30cf392c3 | 120 | |
oprospero | 0:5fa30cf392c3 | 121 | int mpu_write_mem(unsigned short mem_addr, unsigned short length, |
oprospero | 0:5fa30cf392c3 | 122 | unsigned char *data); |
oprospero | 0:5fa30cf392c3 | 123 | int mpu_read_mem(unsigned short mem_addr, unsigned short length, |
oprospero | 0:5fa30cf392c3 | 124 | unsigned char *data); |
oprospero | 0:5fa30cf392c3 | 125 | int mpu_load_firmware(unsigned short length, const unsigned char *firmware, |
oprospero | 0:5fa30cf392c3 | 126 | unsigned short start_addr, unsigned short sample_rate); |
oprospero | 0:5fa30cf392c3 | 127 | |
oprospero | 0:5fa30cf392c3 | 128 | int mpu_reg_dump(void); |
oprospero | 0:5fa30cf392c3 | 129 | int mpu_read_reg(unsigned char reg, unsigned char *data); |
oprospero | 0:5fa30cf392c3 | 130 | int mpu_run_self_test(long *gyro, long *accel); |
oprospero | 0:5fa30cf392c3 | 131 | int mpu_run_6500_self_test(long *gyro, long *accel, unsigned char debug); |
oprospero | 0:5fa30cf392c3 | 132 | int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char)); |
oprospero | 0:5fa30cf392c3 | 133 | |
oprospero | 0:5fa30cf392c3 | 134 | #endif /* #ifndef _INV_MPU_H_ */ |
oprospero | 0:5fa30cf392c3 | 135 | |
oprospero | 0:5fa30cf392c3 | 136 |