Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
inv_mpu.h
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 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 #define INV_X_GYRO (0x40) 00029 #define INV_Y_GYRO (0x20) 00030 #define INV_Z_GYRO (0x10) 00031 #define INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO) 00032 #define INV_XYZ_ACCEL (0x08) 00033 #define INV_XYZ_COMPASS (0x01) 00034 00035 struct int_param_s { 00036 #if defined EMPL_TARGET_MSP430 || defined MOTION_DRIVER_TARGET_MSP430 00037 void (*cb)(void); 00038 unsigned short pin; 00039 unsigned char lp_exit; 00040 unsigned char active_low; 00041 #elif defined EMPL_TARGET_UC3L0 00042 unsigned long pin; 00043 void (*cb)(volatile void*); 00044 void *arg; 00045 #endif 00046 }; 00047 00048 #define MPU_INT_STATUS_DATA_READY (0x0001) 00049 #define MPU_INT_STATUS_DMP (0x0002) 00050 #define MPU_INT_STATUS_PLL_READY (0x0004) 00051 #define MPU_INT_STATUS_I2C_MST (0x0008) 00052 #define MPU_INT_STATUS_FIFO_OVERFLOW (0x0010) 00053 #define MPU_INT_STATUS_ZMOT (0x0020) 00054 #define MPU_INT_STATUS_MOT (0x0040) 00055 #define MPU_INT_STATUS_FREE_FALL (0x0080) 00056 #define MPU_INT_STATUS_DMP_0 (0x0100) 00057 #define MPU_INT_STATUS_DMP_1 (0x0200) 00058 #define MPU_INT_STATUS_DMP_2 (0x0400) 00059 #define MPU_INT_STATUS_DMP_3 (0x0800) 00060 #define MPU_INT_STATUS_DMP_4 (0x1000) 00061 #define MPU_INT_STATUS_DMP_5 (0x2000) 00062 00063 /* Set up APIs */ 00064 int mpu_init(struct int_param_s *int_param); 00065 int mpu_init_slave(void); 00066 int mpu_set_bypass(unsigned char bypass_on); 00067 00068 /* Configuration APIs */ 00069 int mpu_lp_accel_mode(unsigned char rate); 00070 int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time, 00071 unsigned char lpa_freq); 00072 int mpu_set_int_level(unsigned char active_low); 00073 int mpu_set_int_latched(unsigned char enable); 00074 int mpu_enable_int(unsigned char enable); 00075 00076 int mpu_set_dmp_state(unsigned char enable); 00077 int mpu_get_dmp_state(unsigned char *enabled); 00078 00079 int mpu_get_lpf(unsigned short *lpf); 00080 int mpu_set_lpf(unsigned short lpf); 00081 00082 int mpu_get_gyro_fsr(unsigned short *fsr); 00083 int mpu_set_gyro_fsr(unsigned short fsr); 00084 00085 int mpu_get_accel_fsr(unsigned char *fsr); 00086 int mpu_set_accel_fsr(unsigned char fsr); 00087 00088 int mpu_get_compass_fsr(unsigned short *fsr); 00089 00090 int mpu_get_gyro_sens(float *sens); 00091 int mpu_get_accel_sens(unsigned short *sens); 00092 00093 int mpu_get_sample_rate(unsigned short *rate); 00094 int mpu_set_sample_rate(unsigned short rate); 00095 int mpu_get_compass_sample_rate(unsigned short *rate); 00096 int mpu_set_compass_sample_rate(unsigned short rate); 00097 00098 int mpu_get_fifo_config(unsigned char *sensors); 00099 int mpu_configure_fifo(unsigned char sensors); 00100 00101 int mpu_get_power_state(unsigned char *power_on); 00102 int mpu_set_sensors(unsigned char sensors); 00103 00104 int mpu_read_6500_accel_bias(long *accel_bias); 00105 int mpu_set_gyro_bias_reg(long * gyro_bias); 00106 int mpu_set_accel_bias_6500_reg(const long *accel_bias); 00107 int mpu_read_6050_accel_bias(long *accel_bias); 00108 int mpu_set_accel_bias_6050_reg(const long *accel_bias); 00109 00110 /* Data getter/setter APIs */ 00111 int mpu_get_gyro_reg(short *data, unsigned long *timestamp); 00112 int mpu_get_accel_reg(short *data, unsigned long *timestamp); 00113 int mpu_get_compass_reg(short *data, unsigned long *timestamp); 00114 int mpu_get_temperature(long *data, unsigned long *timestamp); 00115 00116 int mpu_get_int_status(short *status); 00117 int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp, 00118 unsigned char *sensors, unsigned char *more); 00119 int mpu_read_fifo_stream(unsigned short length, unsigned char *data, 00120 unsigned char *more); 00121 int mpu_reset_fifo(void); 00122 00123 int mpu_write_mem(unsigned short mem_addr, unsigned short length, 00124 unsigned char *data); 00125 int mpu_read_mem(unsigned short mem_addr, unsigned short length, 00126 unsigned char *data); 00127 int mpu_load_firmware(unsigned short length, const unsigned char *firmware, 00128 unsigned short start_addr, unsigned short sample_rate); 00129 00130 int mpu_reg_dump(void); 00131 int mpu_read_reg(unsigned char reg, unsigned char *data); 00132 int mpu_run_self_test(long *gyro, long *accel); 00133 int mpu_run_6500_self_test(long *gyro, long *accel, unsigned char debug); 00134 int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char)); 00135 00136 #ifdef __cplusplus 00137 } 00138 #endif 00139 00140 #endif /* #ifndef _INV_MPU_H_ */
Generated on Thu Jul 14 2022 05:48:42 by
1.7.2