Update oXs_out_frsky.cpp
[openXsensor.git] / openXsensor / inv_mpu.h
blobcaa2dd95fb51f617ca83daefaeb3a370c43c7709
1 /*
2 $License:
3 Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
4 See included License.txt for License information.
5 * @file inv_mpu.h
6 * @brief An I2C-based driver for Invensense gyroscopes.
7 * @details This driver currently works for the following devices:
8 * MPU6050 (code for other has been removed)
9 */
11 #ifndef _INV_MPU_H_
12 #define _INV_MPU_H_
16 #define INV_X_GYRO (0x40)
17 #define INV_Y_GYRO (0x20)
18 #define INV_Z_GYRO (0x10)
19 #define INV_XYZ_GYRO (INV_X_GYRO | INV_Y_GYRO | INV_Z_GYRO)
20 #define INV_XYZ_ACCEL (0x08)
21 #define INV_XYZ_COMPASS (0x01)
24 struct int_param_s { //used for EMPL_TARGET_ATMEGA328
25 void (*cb)(void);
26 unsigned short pin;
30 #define MPU_INT_STATUS_DATA_READY (0x0001)
31 #define MPU_INT_STATUS_DMP (0x0002)
32 #define MPU_INT_STATUS_PLL_READY (0x0004)
33 #define MPU_INT_STATUS_I2C_MST (0x0008)
34 #define MPU_INT_STATUS_FIFO_OVERFLOW (0x0010)
35 #define MPU_INT_STATUS_ZMOT (0x0020)
36 #define MPU_INT_STATUS_MOT (0x0040)
37 #define MPU_INT_STATUS_FREE_FALL (0x0080)
38 #define MPU_INT_STATUS_DMP_0 (0x0100)
39 #define MPU_INT_STATUS_DMP_1 (0x0200)
40 #define MPU_INT_STATUS_DMP_2 (0x0400)
41 #define MPU_INT_STATUS_DMP_3 (0x0800)
42 #define MPU_INT_STATUS_DMP_4 (0x1000)
43 #define MPU_INT_STATUS_DMP_5 (0x2000)
46 void mpu_enable_pwm_mgnt() ;
47 //int getDataFromMpu() ;
48 unsigned short mpu_getfifo_count_debug() ;
50 /* Set up APIs */
51 int mpu_init();
52 int mpu_init_slave(void);
53 int mpu_set_bypass(unsigned char bypass_on);
54 void mpu_force_reset();
56 /* Configuration APIs */
57 int mpu_lp_accel_mode(unsigned char rate);
58 int mpu_lp_motion_interrupt(unsigned short thresh, unsigned char time,
59 unsigned char lpa_freq);
60 int mpu_set_int_level(unsigned char active_low);
61 int mpu_set_int_latched(unsigned char enable);
63 int mpu_set_dmp_state(unsigned char enable);
64 int mpu_set_dmp_state_on();
65 int mpu_get_dmp_state(unsigned char *enabled);
67 int mpu_get_lpf(unsigned short *lpf);
68 int mpu_set_lpf(unsigned short lpf);
70 int mpu_get_gyro_fsr(unsigned short *fsr);
71 int mpu_set_gyro_fsr(unsigned short fsr);
73 int mpu_get_accel_fsr(unsigned char *fsr);
74 int mpu_set_accel_fsr(unsigned char fsr);
76 int mpu_get_compass_fsr(unsigned short *fsr);
78 int mpu_get_gyro_sens(float *sens);
79 int mpu_get_accel_sens(unsigned short *sens);
81 int mpu_get_sample_rate(unsigned short *rate);
82 int mpu_set_sample_rate(unsigned short rate);
83 int mpu_set_sample_rate200hz();
84 int mpu_get_compass_sample_rate(unsigned short *rate);
85 int mpu_set_compass_sample_rate(unsigned short rate);
87 int mpu_get_fifo_config(unsigned char *sensors);
88 int mpu_configure_fifo(unsigned char sensors);
90 int mpu_get_power_state(unsigned char *power_on);
91 int mpu_set_sensors(unsigned char sensors);
93 int mpu_set_accel_bias(const long *accel_bias);
95 /* Data getter/setter APIs */
96 int mpu_get_gyro_reg(short *data);
97 int mpu_get_accel_reg(short *data);
98 int mpu_get_compass_reg(short *data);
99 int mpu_get_temperature(long *data);
101 int mpu_get_int_status(short *status);
102 int mpu_read_fifo(short *gyro, short *accel, unsigned char *sensors, unsigned char *more);
103 int mpu_read_fifo_stream(unsigned short length, unsigned char *data, unsigned char *more);
104 int mpu_reset_fifo(void);
106 int mpu_write_mem(unsigned short mem_addr, unsigned short length,
107 unsigned char *data);
108 int mpu_read_mem(unsigned short mem_addr, unsigned short length,
109 unsigned char *data);
110 int mpu_load_firmware(unsigned short length, const unsigned char *firmware, unsigned short start_addr );
112 int mpu_reg_dump(void);
113 int mpu_read_reg(unsigned char reg, unsigned char *data);
114 int mpu_run_self_test(long *gyro, long *accel);
115 int mpu_register_tap_cb(void (*func)(unsigned char, unsigned char));
117 int get_st_biases(long *gyro, long *accel, unsigned char hw_test) ; // added by MS
119 #endif /* #ifndef _INV_MPU_H_ */