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 Prosper Van

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers inv_mpu.h Source File

inv_mpu.h

Go to the documentation of this file.
00001 /*
00002  $License:
00003     Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
00004     See included License.txt for License information.
00005  $
00006  */
00007 /**
00008  *  @addtogroup  DRIVERS Sensor Driver Layer
00009  *  @brief       Hardware drivers to communicate with sensors via I2C.
00010  *
00011  *  @{
00012  *      @file       inv_mpu.h
00013  *      @brief      An I2C-based driver for Invensense gyroscopes.
00014  *      @details    This driver currently works for the following devices:
00015  *                  MPU6050
00016  *                  MPU6500
00017  *                  MPU9150 (or MPU6050 w/ AK8975 on the auxiliary bus)
00018  *                  MPU9250 (or MPU6500 w/ AK8963 on the auxiliary bus)
00019  */
00020 
00021 #ifndef _INV_MPU_H_
00022 #define _INV_MPU_H_
00023 
00024 #define INV_X_GYRO      (0x40)
00025 #define INV_Y_GYRO      (0x20)
00026 #define INV_Z_GYRO      (0x10)
00027 #define INV_XYZ_GYRO    (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO)
00028 #define INV_XYZ_ACCEL   (0x08)
00029 #define INV_XYZ_COMPASS (0x01)
00030 
00031 struct int_param_s {
00032 #if defined EMPL_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_MSP430
00033     void (*cb)(void);
00034     unsigned short pin;
00035     unsigned char lp_exit;
00036     unsigned char active_low;
00037 #elif defined EMPL_TARGET_UC3L0
00038     unsigned long pin;
00039     void (*cb)(volatile void*);
00040     void *arg;
00041 #elif defined EMPL_TARGET_STM32F4
00042     void (*cb)(void);
00043 #endif
00044 };
00045 
00046 #define MPU_INT_STATUS_DATA_READY       (0x0001)
00047 #define MPU_INT_STATUS_DMP              (0x0002)
00048 #define MPU_INT_STATUS_PLL_READY        (0x0004)
00049 #define MPU_INT_STATUS_I2C_MST          (0x0008)
00050 #define MPU_INT_STATUS_FIFO_OVERFLOW    (0x0010)
00051 #define MPU_INT_STATUS_ZMOT             (0x0020)
00052 #define MPU_INT_STATUS_MOT              (0x0040)
00053 #define MPU_INT_STATUS_FREE_FALL        (0x0080)
00054 #define MPU_INT_STATUS_DMP_0            (0x0100)
00055 #define MPU_INT_STATUS_DMP_1            (0x0200)
00056 #define MPU_INT_STATUS_DMP_2            (0x0400)
00057 #define MPU_INT_STATUS_DMP_3            (0x0800)
00058 #define MPU_INT_STATUS_DMP_4            (0x1000)
00059 #define MPU_INT_STATUS_DMP_5            (0x2000)
00060 
00061 /* Set up APIs */
00062 int set_int_enable(unsigned char enable);
00063 int mpu_init(struct int_param_s *int_param);
00064 int mpu_init_slave(void);
00065 int mpu_set_bypass(unsigned char bypass_on);
00066 
00067 /* Configuration APIs */
00068 int mpu_lp_accel_mode(unsigned short rate);
00069 int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time,
00070     unsigned short lpa_freq);
00071 int mpu_set_int_level(unsigned char active_low);
00072 int mpu_set_int_latched(unsigned char enable);
00073 
00074 int mpu_set_dmp_state(unsigned char enable);
00075 int mpu_get_dmp_state(unsigned char *enabled);
00076 
00077 int mpu_get_lpf(unsigned short *lpf);
00078 int mpu_set_lpf(unsigned short lpf);
00079 
00080 int mpu_get_gyro_fsr(unsigned short *fsr);
00081 int mpu_set_gyro_fsr(unsigned short fsr);
00082 
00083 int mpu_get_accel_fsr(unsigned char *fsr);
00084 int mpu_set_accel_fsr(unsigned char fsr);
00085 
00086 int mpu_get_compass_fsr(unsigned short *fsr);
00087 
00088 int mpu_get_gyro_sens(float *sens);
00089 int mpu_get_accel_sens(unsigned short *sens);
00090 
00091 int mpu_get_sample_rate(unsigned short *rate);
00092 int mpu_set_sample_rate(unsigned short rate);
00093 int mpu_get_compass_sample_rate(unsigned short *rate);
00094 int mpu_set_compass_sample_rate(unsigned short rate);
00095 
00096 int mpu_get_fifo_config(unsigned char *sensors);
00097 int mpu_configure_fifo(unsigned char sensors);
00098 
00099 int mpu_get_power_state(unsigned char *power_on);
00100 int mpu_set_sensors(unsigned char sensors);
00101 
00102 int mpu_read_6500_accel_bias(long *accel_bias);
00103 int mpu_set_gyro_bias_reg(long * gyro_bias);
00104 int mpu_set_accel_bias_6500_reg(const long *accel_bias);
00105 int mpu_read_6050_accel_bias(long *accel_bias);
00106 int mpu_set_accel_bias_6050_reg(const long *accel_bias);
00107 
00108 /* Data getter/setter APIs */
00109 int mpu_get_gyro_reg(short *data, unsigned long *timestamp);
00110 int mpu_get_accel_reg(short *data, unsigned long *timestamp);
00111 int mpu_get_compass_reg(short *data, unsigned long *timestamp);
00112 int mpu_get_temperature(long *data, unsigned long *timestamp);
00113 
00114 int mpu_get_int_status(short *status);
00115 int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp,
00116     unsigned char *sensors, unsigned char *more);
00117 int mpu_read_fifo_stream(unsigned short length, unsigned char *data,
00118     unsigned char *more);
00119 int mpu_reset_fifo(void);
00120 
00121 int mpu_write_mem(unsigned short mem_addr, unsigned short length,
00122     unsigned char *data);
00123 int mpu_read_mem(unsigned short mem_addr, unsigned short length,
00124     unsigned char *data);
00125 int mpu_load_firmware(unsigned short length, const unsigned char *firmware,
00126     unsigned short start_addr, unsigned short sample_rate);
00127 
00128 int mpu_reg_dump(void);
00129 int mpu_read_reg(unsigned char reg, unsigned char *data);
00130 int mpu_run_self_test(long *gyro, long *accel);
00131 int mpu_run_6500_self_test(long *gyro, long *accel, unsigned char debug);
00132 int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char));
00133 
00134 #endif  /* #ifndef _INV_MPU_H_ */
00135 
00136