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 #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 mpu_init(struct int_param_s *int_param); 00063 int mpu_init_slave(void); 00064 int mpu_set_bypass(unsigned char bypass_on); 00065 00066 /* Configuration APIs */ 00067 int mpu_lp_accel_mode(unsigned short rate); 00068 int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time, 00069 unsigned short lpa_freq); 00070 int mpu_set_int_level(unsigned char active_low); 00071 int mpu_set_int_latched(unsigned char enable); 00072 00073 int mpu_set_dmp_state(unsigned char enable); 00074 int mpu_get_dmp_state(unsigned char *enabled); 00075 00076 int mpu_get_lpf(unsigned short *lpf); 00077 int mpu_set_lpf(unsigned short lpf); 00078 00079 int mpu_get_gyro_fsr(unsigned short *fsr); 00080 int mpu_set_gyro_fsr(unsigned short fsr); 00081 00082 int mpu_get_accel_fsr(unsigned char *fsr); 00083 int mpu_set_accel_fsr(unsigned char fsr); 00084 00085 int mpu_get_compass_fsr(unsigned short *fsr); 00086 00087 int mpu_get_gyro_sens(float *sens); 00088 int mpu_get_accel_sens(unsigned short *sens); 00089 00090 int mpu_get_sample_rate(unsigned short *rate); 00091 int mpu_set_sample_rate(unsigned short rate); 00092 int mpu_get_compass_sample_rate(unsigned short *rate); 00093 int mpu_set_compass_sample_rate(unsigned short rate); 00094 00095 int mpu_get_fifo_config(unsigned char *sensors); 00096 int mpu_configure_fifo(unsigned char sensors); 00097 00098 int mpu_get_power_state(unsigned char *power_on); 00099 int mpu_set_sensors(unsigned char sensors); 00100 00101 int mpu_read_6500_accel_bias(long *accel_bias); 00102 int mpu_set_gyro_bias_reg(long * gyro_bias); 00103 int mpu_set_accel_bias_6500_reg(const long *accel_bias); 00104 int mpu_read_6050_accel_bias(long *accel_bias); 00105 int mpu_set_accel_bias_6050_reg(const long *accel_bias); 00106 00107 /* Data getter/setter APIs */ 00108 int mpu_get_gyro_reg(short *data, unsigned long *timestamp); 00109 int mpu_get_accel_reg(short *data, unsigned long *timestamp); 00110 int mpu_get_compass_reg(short *data, unsigned long *timestamp); 00111 int mpu_get_temperature(long *data, unsigned long *timestamp); 00112 00113 int mpu_get_int_status(short *status); 00114 int mpu_read_fifo(short *gyro, short *accel, unsigned long *timestamp, 00115 unsigned char *sensors, unsigned char *more); 00116 int mpu_read_fifo_stream(unsigned short length, unsigned char *data, 00117 unsigned char *more); 00118 int mpu_reset_fifo(void); 00119 00120 int mpu_write_mem(unsigned short mem_addr, unsigned short length, 00121 unsigned char *data); 00122 int mpu_read_mem(unsigned short mem_addr, unsigned short length, 00123 unsigned char *data); 00124 int mpu_load_firmware(unsigned short length, const unsigned char *firmware, 00125 unsigned short start_addr, unsigned short sample_rate); 00126 00127 int mpu_reg_dump(void); 00128 int mpu_read_reg(unsigned char reg, unsigned char *data); 00129 int mpu_run_self_test(long *gyro, long *accel); 00130 int mpu_run_6500_self_test(long *gyro, long *accel, unsigned char debug); 00131 int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char)); 00132 00133 #endif /* #ifndef _INV_MPU_H_ */ 00134 00135
Generated on Wed Jul 13 2022 02:12:00 by
1.7.2