Latest version of my quadcopter controller with an LPC1768 and MPU9250.
Currently running on a custom PCB with 30.5 x 30.5mm mounts. There are also 2 PC apps that go with the software; one to set up the PID controller and one to balance the motors and props. If anyone is interested, send me a message and I'll upload them.
MPU9250_SPI/MPU9250_SPI.h@6:033ad7377fee, 2018-07-14 (annotated)
- Committer:
- Anaesthetix
- Date:
- Sat Jul 14 10:30:20 2018 +0000
- Revision:
- 6:033ad7377fee
- Parent:
- 0:0929d3d566cf
Changed overall PID gains to gains per axis.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anaesthetix | 0:0929d3d566cf | 1 | /*CODED by Qiyong Mu on 21/06/2014 |
Anaesthetix | 0:0929d3d566cf | 2 | kylongmu@msn.com |
Anaesthetix | 0:0929d3d566cf | 3 | */ |
Anaesthetix | 0:0929d3d566cf | 4 | |
Anaesthetix | 0:0929d3d566cf | 5 | |
Anaesthetix | 0:0929d3d566cf | 6 | #ifndef mpu9250_spi_h |
Anaesthetix | 0:0929d3d566cf | 7 | #define mpu9250_spi_h |
Anaesthetix | 0:0929d3d566cf | 8 | #include "mbed.h" |
Anaesthetix | 0:0929d3d566cf | 9 | |
Anaesthetix | 0:0929d3d566cf | 10 | |
Anaesthetix | 0:0929d3d566cf | 11 | class mpu9250_spi |
Anaesthetix | 0:0929d3d566cf | 12 | { |
Anaesthetix | 0:0929d3d566cf | 13 | SPI& spi; |
Anaesthetix | 0:0929d3d566cf | 14 | DigitalOut cs; |
Anaesthetix | 0:0929d3d566cf | 15 | |
Anaesthetix | 0:0929d3d566cf | 16 | public: |
Anaesthetix | 0:0929d3d566cf | 17 | mpu9250_spi(SPI& _spi, PinName _cs); |
Anaesthetix | 0:0929d3d566cf | 18 | unsigned int WriteReg( uint8_t WriteAddr, uint8_t WriteData ); |
Anaesthetix | 0:0929d3d566cf | 19 | unsigned int ReadReg( uint8_t WriteAddr, uint8_t WriteData ); |
Anaesthetix | 0:0929d3d566cf | 20 | void ReadRegs( uint8_t ReadAddr, uint8_t *ReadBuf, unsigned int Bytes ); |
Anaesthetix | 0:0929d3d566cf | 21 | |
Anaesthetix | 0:0929d3d566cf | 22 | bool init(int sample_rate_div,int low_pass_filter); |
Anaesthetix | 0:0929d3d566cf | 23 | bool init2(int sample_rate_div,int low_pass_filter); |
Anaesthetix | 0:0929d3d566cf | 24 | void read_temp(); |
Anaesthetix | 0:0929d3d566cf | 25 | void read_acc(); |
Anaesthetix | 0:0929d3d566cf | 26 | void read_rot(); |
Anaesthetix | 0:0929d3d566cf | 27 | unsigned int set_gyro_scale(int scale); |
Anaesthetix | 0:0929d3d566cf | 28 | unsigned int set_acc_scale(int scale); |
Anaesthetix | 0:0929d3d566cf | 29 | void calib_acc(); |
Anaesthetix | 0:0929d3d566cf | 30 | void AK8963_calib_Magnetometer(); |
Anaesthetix | 0:0929d3d566cf | 31 | void select(); |
Anaesthetix | 0:0929d3d566cf | 32 | void deselect(); |
Anaesthetix | 0:0929d3d566cf | 33 | unsigned int whoami(); |
Anaesthetix | 0:0929d3d566cf | 34 | uint8_t AK8963_whoami(); |
Anaesthetix | 0:0929d3d566cf | 35 | void AK8963_read_Magnetometer(); |
Anaesthetix | 0:0929d3d566cf | 36 | void read_all(); |
Anaesthetix | 0:0929d3d566cf | 37 | |
Anaesthetix | 0:0929d3d566cf | 38 | |
Anaesthetix | 0:0929d3d566cf | 39 | |
Anaesthetix | 0:0929d3d566cf | 40 | float acc_divider; |
Anaesthetix | 0:0929d3d566cf | 41 | float gyro_divider; |
Anaesthetix | 0:0929d3d566cf | 42 | |
Anaesthetix | 0:0929d3d566cf | 43 | int calib_data[3]; |
Anaesthetix | 0:0929d3d566cf | 44 | float Magnetometer_ASA[3]; |
Anaesthetix | 0:0929d3d566cf | 45 | |
Anaesthetix | 0:0929d3d566cf | 46 | float accelerometer_data[3]; |
Anaesthetix | 0:0929d3d566cf | 47 | float Temperature; |
Anaesthetix | 0:0929d3d566cf | 48 | float gyroscope_data[3]; |
Anaesthetix | 0:0929d3d566cf | 49 | float Magnetometer[3]; |
Anaesthetix | 0:0929d3d566cf | 50 | |
Anaesthetix | 0:0929d3d566cf | 51 | private: |
Anaesthetix | 0:0929d3d566cf | 52 | PinName _CS_pin; |
Anaesthetix | 0:0929d3d566cf | 53 | PinName _SO_pin; |
Anaesthetix | 0:0929d3d566cf | 54 | PinName _SCK_pin; |
Anaesthetix | 0:0929d3d566cf | 55 | float _error; |
Anaesthetix | 0:0929d3d566cf | 56 | }; |
Anaesthetix | 0:0929d3d566cf | 57 | |
Anaesthetix | 0:0929d3d566cf | 58 | #endif |
Anaesthetix | 0:0929d3d566cf | 59 | |
Anaesthetix | 0:0929d3d566cf | 60 | |
Anaesthetix | 0:0929d3d566cf | 61 | |
Anaesthetix | 0:0929d3d566cf | 62 | // mpu9250 registers |
Anaesthetix | 0:0929d3d566cf | 63 | #define MPUREG_XG_OFFS_TC 0x00 |
Anaesthetix | 0:0929d3d566cf | 64 | #define MPUREG_YG_OFFS_TC 0x01 |
Anaesthetix | 0:0929d3d566cf | 65 | #define MPUREG_ZG_OFFS_TC 0x02 |
Anaesthetix | 0:0929d3d566cf | 66 | #define MPUREG_X_FINE_GAIN 0x03 |
Anaesthetix | 0:0929d3d566cf | 67 | #define MPUREG_Y_FINE_GAIN 0x04 |
Anaesthetix | 0:0929d3d566cf | 68 | #define MPUREG_Z_FINE_GAIN 0x05 |
Anaesthetix | 0:0929d3d566cf | 69 | #define MPUREG_XA_OFFS_H 0x06 |
Anaesthetix | 0:0929d3d566cf | 70 | #define MPUREG_XA_OFFS_L 0x07 |
Anaesthetix | 0:0929d3d566cf | 71 | #define MPUREG_YA_OFFS_H 0x08 |
Anaesthetix | 0:0929d3d566cf | 72 | #define MPUREG_YA_OFFS_L 0x09 |
Anaesthetix | 0:0929d3d566cf | 73 | #define MPUREG_ZA_OFFS_H 0x0A |
Anaesthetix | 0:0929d3d566cf | 74 | #define MPUREG_ZA_OFFS_L 0x0B |
Anaesthetix | 0:0929d3d566cf | 75 | #define MPUREG_PRODUCT_ID 0x0C |
Anaesthetix | 0:0929d3d566cf | 76 | #define MPUREG_SELF_TEST_X 0x0D |
Anaesthetix | 0:0929d3d566cf | 77 | #define MPUREG_SELF_TEST_Y 0x0E |
Anaesthetix | 0:0929d3d566cf | 78 | #define MPUREG_SELF_TEST_Z 0x0F |
Anaesthetix | 0:0929d3d566cf | 79 | #define MPUREG_SELF_TEST_A 0x10 |
Anaesthetix | 0:0929d3d566cf | 80 | #define MPUREG_XG_OFFS_USRH 0x13 |
Anaesthetix | 0:0929d3d566cf | 81 | #define MPUREG_XG_OFFS_USRL 0x14 |
Anaesthetix | 0:0929d3d566cf | 82 | #define MPUREG_YG_OFFS_USRH 0x15 |
Anaesthetix | 0:0929d3d566cf | 83 | #define MPUREG_YG_OFFS_USRL 0x16 |
Anaesthetix | 0:0929d3d566cf | 84 | #define MPUREG_ZG_OFFS_USRH 0x17 |
Anaesthetix | 0:0929d3d566cf | 85 | #define MPUREG_ZG_OFFS_USRL 0x18 |
Anaesthetix | 0:0929d3d566cf | 86 | #define MPUREG_SMPLRT_DIV 0x19 |
Anaesthetix | 0:0929d3d566cf | 87 | #define MPUREG_CONFIG 0x1A |
Anaesthetix | 0:0929d3d566cf | 88 | #define MPUREG_GYRO_CONFIG 0x1B |
Anaesthetix | 0:0929d3d566cf | 89 | #define MPUREG_ACCEL_CONFIG 0x1C |
Anaesthetix | 0:0929d3d566cf | 90 | #define MPUREG_ACCEL_CONFIG_2 0x1D |
Anaesthetix | 0:0929d3d566cf | 91 | #define MPUREG_LP_ACCEL_ODR 0x1E |
Anaesthetix | 0:0929d3d566cf | 92 | #define MPUREG_MOT_THR 0x1F |
Anaesthetix | 0:0929d3d566cf | 93 | #define MPUREG_FIFO_EN 0x23 |
Anaesthetix | 0:0929d3d566cf | 94 | #define MPUREG_I2C_MST_CTRL 0x24 |
Anaesthetix | 0:0929d3d566cf | 95 | #define MPUREG_I2C_SLV0_ADDR 0x25 |
Anaesthetix | 0:0929d3d566cf | 96 | #define MPUREG_I2C_SLV0_REG 0x26 |
Anaesthetix | 0:0929d3d566cf | 97 | #define MPUREG_I2C_SLV0_CTRL 0x27 |
Anaesthetix | 0:0929d3d566cf | 98 | #define MPUREG_I2C_SLV1_ADDR 0x28 |
Anaesthetix | 0:0929d3d566cf | 99 | #define MPUREG_I2C_SLV1_REG 0x29 |
Anaesthetix | 0:0929d3d566cf | 100 | #define MPUREG_I2C_SLV1_CTRL 0x2A |
Anaesthetix | 0:0929d3d566cf | 101 | #define MPUREG_I2C_SLV2_ADDR 0x2B |
Anaesthetix | 0:0929d3d566cf | 102 | #define MPUREG_I2C_SLV2_REG 0x2C |
Anaesthetix | 0:0929d3d566cf | 103 | #define MPUREG_I2C_SLV2_CTRL 0x2D |
Anaesthetix | 0:0929d3d566cf | 104 | #define MPUREG_I2C_SLV3_ADDR 0x2E |
Anaesthetix | 0:0929d3d566cf | 105 | #define MPUREG_I2C_SLV3_REG 0x2F |
Anaesthetix | 0:0929d3d566cf | 106 | #define MPUREG_I2C_SLV3_CTRL 0x30 |
Anaesthetix | 0:0929d3d566cf | 107 | #define MPUREG_I2C_SLV4_ADDR 0x31 |
Anaesthetix | 0:0929d3d566cf | 108 | #define MPUREG_I2C_SLV4_REG 0x32 |
Anaesthetix | 0:0929d3d566cf | 109 | #define MPUREG_I2C_SLV4_DO 0x33 |
Anaesthetix | 0:0929d3d566cf | 110 | #define MPUREG_I2C_SLV4_CTRL 0x34 |
Anaesthetix | 0:0929d3d566cf | 111 | #define MPUREG_I2C_SLV4_DI 0x35 |
Anaesthetix | 0:0929d3d566cf | 112 | #define MPUREG_I2C_MST_STATUS 0x36 |
Anaesthetix | 0:0929d3d566cf | 113 | #define MPUREG_INT_PIN_CFG 0x37 |
Anaesthetix | 0:0929d3d566cf | 114 | #define MPUREG_INT_ENABLE 0x38 |
Anaesthetix | 0:0929d3d566cf | 115 | #define MPUREG_ACCEL_XOUT_H 0x3B |
Anaesthetix | 0:0929d3d566cf | 116 | #define MPUREG_ACCEL_XOUT_L 0x3C |
Anaesthetix | 0:0929d3d566cf | 117 | #define MPUREG_ACCEL_YOUT_H 0x3D |
Anaesthetix | 0:0929d3d566cf | 118 | #define MPUREG_ACCEL_YOUT_L 0x3E |
Anaesthetix | 0:0929d3d566cf | 119 | #define MPUREG_ACCEL_ZOUT_H 0x3F |
Anaesthetix | 0:0929d3d566cf | 120 | #define MPUREG_ACCEL_ZOUT_L 0x40 |
Anaesthetix | 0:0929d3d566cf | 121 | #define MPUREG_TEMP_OUT_H 0x41 |
Anaesthetix | 0:0929d3d566cf | 122 | #define MPUREG_TEMP_OUT_L 0x42 |
Anaesthetix | 0:0929d3d566cf | 123 | #define MPUREG_GYRO_XOUT_H 0x43 |
Anaesthetix | 0:0929d3d566cf | 124 | #define MPUREG_GYRO_XOUT_L 0x44 |
Anaesthetix | 0:0929d3d566cf | 125 | #define MPUREG_GYRO_YOUT_H 0x45 |
Anaesthetix | 0:0929d3d566cf | 126 | #define MPUREG_GYRO_YOUT_L 0x46 |
Anaesthetix | 0:0929d3d566cf | 127 | #define MPUREG_GYRO_ZOUT_H 0x47 |
Anaesthetix | 0:0929d3d566cf | 128 | #define MPUREG_GYRO_ZOUT_L 0x48 |
Anaesthetix | 0:0929d3d566cf | 129 | #define MPUREG_EXT_SENS_DATA_00 0x49 |
Anaesthetix | 0:0929d3d566cf | 130 | #define MPUREG_EXT_SENS_DATA_01 0x4A |
Anaesthetix | 0:0929d3d566cf | 131 | #define MPUREG_EXT_SENS_DATA_02 0x4B |
Anaesthetix | 0:0929d3d566cf | 132 | #define MPUREG_EXT_SENS_DATA_03 0x4C |
Anaesthetix | 0:0929d3d566cf | 133 | #define MPUREG_EXT_SENS_DATA_04 0x4D |
Anaesthetix | 0:0929d3d566cf | 134 | #define MPUREG_EXT_SENS_DATA_05 0x4E |
Anaesthetix | 0:0929d3d566cf | 135 | #define MPUREG_EXT_SENS_DATA_06 0x4F |
Anaesthetix | 0:0929d3d566cf | 136 | #define MPUREG_EXT_SENS_DATA_07 0x50 |
Anaesthetix | 0:0929d3d566cf | 137 | #define MPUREG_EXT_SENS_DATA_08 0x51 |
Anaesthetix | 0:0929d3d566cf | 138 | #define MPUREG_EXT_SENS_DATA_09 0x52 |
Anaesthetix | 0:0929d3d566cf | 139 | #define MPUREG_EXT_SENS_DATA_10 0x53 |
Anaesthetix | 0:0929d3d566cf | 140 | #define MPUREG_EXT_SENS_DATA_11 0x54 |
Anaesthetix | 0:0929d3d566cf | 141 | #define MPUREG_EXT_SENS_DATA_12 0x55 |
Anaesthetix | 0:0929d3d566cf | 142 | #define MPUREG_EXT_SENS_DATA_13 0x56 |
Anaesthetix | 0:0929d3d566cf | 143 | #define MPUREG_EXT_SENS_DATA_14 0x57 |
Anaesthetix | 0:0929d3d566cf | 144 | #define MPUREG_EXT_SENS_DATA_15 0x58 |
Anaesthetix | 0:0929d3d566cf | 145 | #define MPUREG_EXT_SENS_DATA_16 0x59 |
Anaesthetix | 0:0929d3d566cf | 146 | #define MPUREG_EXT_SENS_DATA_17 0x5A |
Anaesthetix | 0:0929d3d566cf | 147 | #define MPUREG_EXT_SENS_DATA_18 0x5B |
Anaesthetix | 0:0929d3d566cf | 148 | #define MPUREG_EXT_SENS_DATA_19 0x5C |
Anaesthetix | 0:0929d3d566cf | 149 | #define MPUREG_EXT_SENS_DATA_20 0x5D |
Anaesthetix | 0:0929d3d566cf | 150 | #define MPUREG_EXT_SENS_DATA_21 0x5E |
Anaesthetix | 0:0929d3d566cf | 151 | #define MPUREG_EXT_SENS_DATA_22 0x5F |
Anaesthetix | 0:0929d3d566cf | 152 | #define MPUREG_EXT_SENS_DATA_23 0x60 |
Anaesthetix | 0:0929d3d566cf | 153 | #define MPUREG_I2C_SLV0_DO 0x63 |
Anaesthetix | 0:0929d3d566cf | 154 | #define MPUREG_I2C_SLV1_DO 0x64 |
Anaesthetix | 0:0929d3d566cf | 155 | #define MPUREG_I2C_SLV2_DO 0x65 |
Anaesthetix | 0:0929d3d566cf | 156 | #define MPUREG_I2C_SLV3_DO 0x66 |
Anaesthetix | 0:0929d3d566cf | 157 | #define MPUREG_I2C_MST_DELAY_CTRL 0x67 |
Anaesthetix | 0:0929d3d566cf | 158 | #define MPUREG_SIGNAL_PATH_RESET 0x68 |
Anaesthetix | 0:0929d3d566cf | 159 | #define MPUREG_MOT_DETECT_CTRL 0x69 |
Anaesthetix | 0:0929d3d566cf | 160 | #define MPUREG_USER_CTRL 0x6A |
Anaesthetix | 0:0929d3d566cf | 161 | #define MPUREG_PWR_MGMT_1 0x6B |
Anaesthetix | 0:0929d3d566cf | 162 | #define MPUREG_PWR_MGMT_2 0x6C |
Anaesthetix | 0:0929d3d566cf | 163 | #define MPUREG_BANK_SEL 0x6D |
Anaesthetix | 0:0929d3d566cf | 164 | #define MPUREG_MEM_START_ADDR 0x6E |
Anaesthetix | 0:0929d3d566cf | 165 | #define MPUREG_MEM_R_W 0x6F |
Anaesthetix | 0:0929d3d566cf | 166 | #define MPUREG_DMP_CFG_1 0x70 |
Anaesthetix | 0:0929d3d566cf | 167 | #define MPUREG_DMP_CFG_2 0x71 |
Anaesthetix | 0:0929d3d566cf | 168 | #define MPUREG_FIFO_COUNTH 0x72 |
Anaesthetix | 0:0929d3d566cf | 169 | #define MPUREG_FIFO_COUNTL 0x73 |
Anaesthetix | 0:0929d3d566cf | 170 | #define MPUREG_FIFO_R_W 0x74 |
Anaesthetix | 0:0929d3d566cf | 171 | #define MPUREG_WHOAMI 0x75 |
Anaesthetix | 0:0929d3d566cf | 172 | #define MPUREG_XA_OFFSET_H 0x77 |
Anaesthetix | 0:0929d3d566cf | 173 | #define MPUREG_XA_OFFSET_L 0x78 |
Anaesthetix | 0:0929d3d566cf | 174 | #define MPUREG_YA_OFFSET_H 0x7A |
Anaesthetix | 0:0929d3d566cf | 175 | #define MPUREG_YA_OFFSET_L 0x7B |
Anaesthetix | 0:0929d3d566cf | 176 | #define MPUREG_ZA_OFFSET_H 0x7D |
Anaesthetix | 0:0929d3d566cf | 177 | #define MPUREG_ZA_OFFSET_L 0x7E |
Anaesthetix | 0:0929d3d566cf | 178 | /* ---- AK8963 Reg In MPU9250 ----------------------------------------------- */ |
Anaesthetix | 0:0929d3d566cf | 179 | |
Anaesthetix | 0:0929d3d566cf | 180 | #define AK8963_I2C_ADDR 0x0c//0x18 |
Anaesthetix | 0:0929d3d566cf | 181 | #define AK8963_Device_ID 0x48 |
Anaesthetix | 0:0929d3d566cf | 182 | |
Anaesthetix | 0:0929d3d566cf | 183 | // Read-only Reg |
Anaesthetix | 0:0929d3d566cf | 184 | #define AK8963_WIA 0x00 |
Anaesthetix | 0:0929d3d566cf | 185 | #define AK8963_INFO 0x01 |
Anaesthetix | 0:0929d3d566cf | 186 | #define AK8963_ST1 0x02 |
Anaesthetix | 0:0929d3d566cf | 187 | #define AK8963_HXL 0x03 |
Anaesthetix | 0:0929d3d566cf | 188 | #define AK8963_HXH 0x04 |
Anaesthetix | 0:0929d3d566cf | 189 | #define AK8963_HYL 0x05 |
Anaesthetix | 0:0929d3d566cf | 190 | #define AK8963_HYH 0x06 |
Anaesthetix | 0:0929d3d566cf | 191 | #define AK8963_HZL 0x07 |
Anaesthetix | 0:0929d3d566cf | 192 | #define AK8963_HZH 0x08 |
Anaesthetix | 0:0929d3d566cf | 193 | #define AK8963_ST2 0x09 |
Anaesthetix | 0:0929d3d566cf | 194 | // Write/Read Reg |
Anaesthetix | 0:0929d3d566cf | 195 | #define AK8963_CNTL1 0x0A |
Anaesthetix | 0:0929d3d566cf | 196 | #define AK8963_CNTL2 0x0B |
Anaesthetix | 0:0929d3d566cf | 197 | #define AK8963_ASTC 0x0C |
Anaesthetix | 0:0929d3d566cf | 198 | #define AK8963_TS1 0x0D |
Anaesthetix | 0:0929d3d566cf | 199 | #define AK8963_TS2 0x0E |
Anaesthetix | 0:0929d3d566cf | 200 | #define AK8963_I2CDIS 0x0F |
Anaesthetix | 0:0929d3d566cf | 201 | // Read-only Reg ( ROM ) |
Anaesthetix | 0:0929d3d566cf | 202 | #define AK8963_ASAX 0x10 |
Anaesthetix | 0:0929d3d566cf | 203 | #define AK8963_ASAY 0x11 |
Anaesthetix | 0:0929d3d566cf | 204 | #define AK8963_ASAZ 0x12 |
Anaesthetix | 0:0929d3d566cf | 205 | |
Anaesthetix | 0:0929d3d566cf | 206 | // Configuration bits mpu9250 |
Anaesthetix | 0:0929d3d566cf | 207 | #define BIT_SLEEP 0x40 |
Anaesthetix | 0:0929d3d566cf | 208 | #define BIT_H_RESET 0x80 |
Anaesthetix | 0:0929d3d566cf | 209 | #define BITS_CLKSEL 0x07 |
Anaesthetix | 0:0929d3d566cf | 210 | #define MPU_CLK_SEL_PLLGYROX 0x01 |
Anaesthetix | 0:0929d3d566cf | 211 | #define MPU_CLK_SEL_PLLGYROZ 0x03 |
Anaesthetix | 0:0929d3d566cf | 212 | #define MPU_EXT_SYNC_GYROX 0x02 |
Anaesthetix | 0:0929d3d566cf | 213 | #define BITS_FS_250DPS 0x00 |
Anaesthetix | 0:0929d3d566cf | 214 | #define BITS_FS_500DPS 0x08 |
Anaesthetix | 0:0929d3d566cf | 215 | #define BITS_FS_1000DPS 0x10 |
Anaesthetix | 0:0929d3d566cf | 216 | #define BITS_FS_2000DPS 0x18 |
Anaesthetix | 0:0929d3d566cf | 217 | #define BITS_FS_2G 0x00 |
Anaesthetix | 0:0929d3d566cf | 218 | #define BITS_FS_4G 0x08 |
Anaesthetix | 0:0929d3d566cf | 219 | #define BITS_FS_8G 0x10 |
Anaesthetix | 0:0929d3d566cf | 220 | #define BITS_FS_16G 0x18 |
Anaesthetix | 0:0929d3d566cf | 221 | #define BITS_FS_MASK 0x18 |
Anaesthetix | 0:0929d3d566cf | 222 | #define BITS_DLPF_CFG_256HZ_NOLPF2 0x00 |
Anaesthetix | 0:0929d3d566cf | 223 | #define BITS_DLPF_CFG_188HZ 0x01 |
Anaesthetix | 0:0929d3d566cf | 224 | #define BITS_DLPF_CFG_98HZ 0x02 |
Anaesthetix | 0:0929d3d566cf | 225 | #define BITS_DLPF_CFG_42HZ 0x03 |
Anaesthetix | 0:0929d3d566cf | 226 | #define BITS_DLPF_CFG_20HZ 0x04 |
Anaesthetix | 0:0929d3d566cf | 227 | #define BITS_DLPF_CFG_10HZ 0x05 |
Anaesthetix | 0:0929d3d566cf | 228 | #define BITS_DLPF_CFG_5HZ 0x06 |
Anaesthetix | 0:0929d3d566cf | 229 | #define BITS_DLPF_CFG_2100HZ_NOLPF 0x07 |
Anaesthetix | 0:0929d3d566cf | 230 | #define BITS_DLPF_CFG_MASK 0x07 |
Anaesthetix | 0:0929d3d566cf | 231 | #define BIT_INT_ANYRD_2CLEAR 0x10 |
Anaesthetix | 0:0929d3d566cf | 232 | #define BIT_RAW_RDY_EN 0x01 |
Anaesthetix | 0:0929d3d566cf | 233 | #define BIT_I2C_IF_DIS 0x10 |
Anaesthetix | 0:0929d3d566cf | 234 | |
Anaesthetix | 0:0929d3d566cf | 235 | #define READ_FLAG 0x80 |
Anaesthetix | 0:0929d3d566cf | 236 | |
Anaesthetix | 0:0929d3d566cf | 237 | /* ---- Sensitivity --------------------------------------------------------- */ |
Anaesthetix | 0:0929d3d566cf | 238 | |
Anaesthetix | 0:0929d3d566cf | 239 | #define MPU9250A_2g ((float)0.000061035156f) // 0.000061035156 g/LSB |
Anaesthetix | 0:0929d3d566cf | 240 | #define MPU9250A_4g ((float)0.000122070312f) // 0.000122070312 g/LSB |
Anaesthetix | 0:0929d3d566cf | 241 | #define MPU9250A_8g ((float)0.000244140625f) // 0.000244140625 g/LSB |
Anaesthetix | 0:0929d3d566cf | 242 | #define MPU9250A_16g ((float)0.000488281250f) // 0.000488281250 g/LSB |
Anaesthetix | 0:0929d3d566cf | 243 | |
Anaesthetix | 0:0929d3d566cf | 244 | #define MPU9250G_250dps ((float)0.007633587786f) // 0.007633587786 dps/LSB |
Anaesthetix | 0:0929d3d566cf | 245 | #define MPU9250G_500dps ((float)0.015267175572f) // 0.015267175572 dps/LSB |
Anaesthetix | 0:0929d3d566cf | 246 | #define MPU9250G_1000dps ((float)0.030487804878f) // 0.030487804878 dps/LSB |
Anaesthetix | 0:0929d3d566cf | 247 | #define MPU9250G_2000dps ((float)0.060975609756f) // 0.060975609756 dps/LSB |
Anaesthetix | 0:0929d3d566cf | 248 | |
Anaesthetix | 0:0929d3d566cf | 249 | #define MPU9250M_4800uT ((float)0.6f) // 0.6 uT/LSB |
Anaesthetix | 0:0929d3d566cf | 250 | |
Anaesthetix | 0:0929d3d566cf | 251 | #define MPU9250T_85degC ((float)0.002995177763f) // 0.002995177763 degC/LSB |
Anaesthetix | 0:0929d3d566cf | 252 | |
Anaesthetix | 0:0929d3d566cf | 253 | #define Magnetometer_Sensitivity_Scale_Factor ((float)0.15f) |
Anaesthetix | 0:0929d3d566cf | 254 |