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
inv_mpu_dmp_motion_driver.c@0:5fa30cf392c3, 2014-08-24 (annotated)
- Committer:
- oprospero
- Date:
- Sun Aug 24 00:52:07 2014 +0000
- Revision:
- 0:5fa30cf392c3
- Child:
- 1:a6c3f8680fe0
Initial commit, copied from Motion Driver 6.1 no edits
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oprospero | 0:5fa30cf392c3 | 1 | /* |
oprospero | 0:5fa30cf392c3 | 2 | $License: |
oprospero | 0:5fa30cf392c3 | 3 | Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. |
oprospero | 0:5fa30cf392c3 | 4 | See included License.txt for License information. |
oprospero | 0:5fa30cf392c3 | 5 | $ |
oprospero | 0:5fa30cf392c3 | 6 | */ |
oprospero | 0:5fa30cf392c3 | 7 | /** |
oprospero | 0:5fa30cf392c3 | 8 | * @addtogroup DRIVERS Sensor Driver Layer |
oprospero | 0:5fa30cf392c3 | 9 | * @brief Hardware drivers to communicate with sensors via I2C. |
oprospero | 0:5fa30cf392c3 | 10 | * |
oprospero | 0:5fa30cf392c3 | 11 | * @{ |
oprospero | 0:5fa30cf392c3 | 12 | * @file inv_mpu_dmp_motion_driver.c |
oprospero | 0:5fa30cf392c3 | 13 | * @brief DMP image and interface functions. |
oprospero | 0:5fa30cf392c3 | 14 | * @details All functions are preceded by the dmp_ prefix to |
oprospero | 0:5fa30cf392c3 | 15 | * differentiate among MPL and general driver function calls. |
oprospero | 0:5fa30cf392c3 | 16 | */ |
oprospero | 0:5fa30cf392c3 | 17 | #include <stdio.h> |
oprospero | 0:5fa30cf392c3 | 18 | #include <stdint.h> |
oprospero | 0:5fa30cf392c3 | 19 | #include <stdlib.h> |
oprospero | 0:5fa30cf392c3 | 20 | #include <string.h> |
oprospero | 0:5fa30cf392c3 | 21 | #include <math.h> |
oprospero | 0:5fa30cf392c3 | 22 | #include "inv_mpu.h" |
oprospero | 0:5fa30cf392c3 | 23 | #include "inv_mpu_dmp_motion_driver.h" |
oprospero | 0:5fa30cf392c3 | 24 | #include "dmpKey.h" |
oprospero | 0:5fa30cf392c3 | 25 | #include "dmpmap.h" |
oprospero | 0:5fa30cf392c3 | 26 | |
oprospero | 0:5fa30cf392c3 | 27 | /* The following functions must be defined for this platform: |
oprospero | 0:5fa30cf392c3 | 28 | * i2c_write(unsigned char slave_addr, unsigned char reg_addr, |
oprospero | 0:5fa30cf392c3 | 29 | * unsigned char length, unsigned char const *data) |
oprospero | 0:5fa30cf392c3 | 30 | * i2c_read(unsigned char slave_addr, unsigned char reg_addr, |
oprospero | 0:5fa30cf392c3 | 31 | * unsigned char length, unsigned char *data) |
oprospero | 0:5fa30cf392c3 | 32 | * delay_ms(unsigned long num_ms) |
oprospero | 0:5fa30cf392c3 | 33 | * get_ms(unsigned long *count) |
oprospero | 0:5fa30cf392c3 | 34 | */ |
oprospero | 0:5fa30cf392c3 | 35 | #if defined EMPL_TARGET_STM32F4 |
oprospero | 0:5fa30cf392c3 | 36 | #include "i2c.h" |
oprospero | 0:5fa30cf392c3 | 37 | #include "main.h" |
oprospero | 0:5fa30cf392c3 | 38 | #include "board-st_discovery.h" |
oprospero | 0:5fa30cf392c3 | 39 | |
oprospero | 0:5fa30cf392c3 | 40 | #define i2c_write Sensors_I2C_WriteRegister |
oprospero | 0:5fa30cf392c3 | 41 | #define i2c_read Sensors_I2C_ReadRegister |
oprospero | 0:5fa30cf392c3 | 42 | #define get_ms get_tick_count |
oprospero | 0:5fa30cf392c3 | 43 | |
oprospero | 0:5fa30cf392c3 | 44 | #elif defined MOTION_DRIVER_TARGET_MSP430 |
oprospero | 0:5fa30cf392c3 | 45 | #include "msp430.h" |
oprospero | 0:5fa30cf392c3 | 46 | #include "msp430_clock.h" |
oprospero | 0:5fa30cf392c3 | 47 | #define delay_ms msp430_delay_ms |
oprospero | 0:5fa30cf392c3 | 48 | #define get_ms msp430_get_clock_ms |
oprospero | 0:5fa30cf392c3 | 49 | #define log_i(...) do {} while (0) |
oprospero | 0:5fa30cf392c3 | 50 | #define log_e(...) do {} while (0) |
oprospero | 0:5fa30cf392c3 | 51 | |
oprospero | 0:5fa30cf392c3 | 52 | #elif defined EMPL_TARGET_MSP430 |
oprospero | 0:5fa30cf392c3 | 53 | #include "msp430.h" |
oprospero | 0:5fa30cf392c3 | 54 | #include "msp430_clock.h" |
oprospero | 0:5fa30cf392c3 | 55 | #include "log.h" |
oprospero | 0:5fa30cf392c3 | 56 | #define delay_ms msp430_delay_ms |
oprospero | 0:5fa30cf392c3 | 57 | #define get_ms msp430_get_clock_ms |
oprospero | 0:5fa30cf392c3 | 58 | #define log_i MPL_LOGI |
oprospero | 0:5fa30cf392c3 | 59 | #define log_e MPL_LOGE |
oprospero | 0:5fa30cf392c3 | 60 | |
oprospero | 0:5fa30cf392c3 | 61 | #elif defined EMPL_TARGET_UC3L0 |
oprospero | 0:5fa30cf392c3 | 62 | /* Instead of using the standard TWI driver from the ASF library, we're using |
oprospero | 0:5fa30cf392c3 | 63 | * a TWI driver that follows the slave address + register address convention. |
oprospero | 0:5fa30cf392c3 | 64 | */ |
oprospero | 0:5fa30cf392c3 | 65 | #include "delay.h" |
oprospero | 0:5fa30cf392c3 | 66 | #include "sysclk.h" |
oprospero | 0:5fa30cf392c3 | 67 | #include "log.h" |
oprospero | 0:5fa30cf392c3 | 68 | #include "uc3l0_clock.h" |
oprospero | 0:5fa30cf392c3 | 69 | /* delay_ms is a function already defined in ASF. */ |
oprospero | 0:5fa30cf392c3 | 70 | #define get_ms uc3l0_get_clock_ms |
oprospero | 0:5fa30cf392c3 | 71 | #define log_i MPL_LOGI |
oprospero | 0:5fa30cf392c3 | 72 | #define log_e MPL_LOGE |
oprospero | 0:5fa30cf392c3 | 73 | |
oprospero | 0:5fa30cf392c3 | 74 | #else |
oprospero | 0:5fa30cf392c3 | 75 | #error Gyro driver is missing the system layer implementations. |
oprospero | 0:5fa30cf392c3 | 76 | #endif |
oprospero | 0:5fa30cf392c3 | 77 | |
oprospero | 0:5fa30cf392c3 | 78 | /* These defines are copied from dmpDefaultMPU6050.c in the general MPL |
oprospero | 0:5fa30cf392c3 | 79 | * releases. These defines may change for each DMP image, so be sure to modify |
oprospero | 0:5fa30cf392c3 | 80 | * these values when switching to a new image. |
oprospero | 0:5fa30cf392c3 | 81 | */ |
oprospero | 0:5fa30cf392c3 | 82 | #define CFG_LP_QUAT (2712) |
oprospero | 0:5fa30cf392c3 | 83 | #define END_ORIENT_TEMP (1866) |
oprospero | 0:5fa30cf392c3 | 84 | #define CFG_27 (2742) |
oprospero | 0:5fa30cf392c3 | 85 | #define CFG_20 (2224) |
oprospero | 0:5fa30cf392c3 | 86 | #define CFG_23 (2745) |
oprospero | 0:5fa30cf392c3 | 87 | #define CFG_FIFO_ON_EVENT (2690) |
oprospero | 0:5fa30cf392c3 | 88 | #define END_PREDICTION_UPDATE (1761) |
oprospero | 0:5fa30cf392c3 | 89 | #define CGNOTICE_INTR (2620) |
oprospero | 0:5fa30cf392c3 | 90 | #define X_GRT_Y_TMP (1358) |
oprospero | 0:5fa30cf392c3 | 91 | #define CFG_DR_INT (1029) |
oprospero | 0:5fa30cf392c3 | 92 | #define CFG_AUTH (1035) |
oprospero | 0:5fa30cf392c3 | 93 | #define UPDATE_PROP_ROT (1835) |
oprospero | 0:5fa30cf392c3 | 94 | #define END_COMPARE_Y_X_TMP2 (1455) |
oprospero | 0:5fa30cf392c3 | 95 | #define SKIP_X_GRT_Y_TMP (1359) |
oprospero | 0:5fa30cf392c3 | 96 | #define SKIP_END_COMPARE (1435) |
oprospero | 0:5fa30cf392c3 | 97 | #define FCFG_3 (1088) |
oprospero | 0:5fa30cf392c3 | 98 | #define FCFG_2 (1066) |
oprospero | 0:5fa30cf392c3 | 99 | #define FCFG_1 (1062) |
oprospero | 0:5fa30cf392c3 | 100 | #define END_COMPARE_Y_X_TMP3 (1434) |
oprospero | 0:5fa30cf392c3 | 101 | #define FCFG_7 (1073) |
oprospero | 0:5fa30cf392c3 | 102 | #define FCFG_6 (1106) |
oprospero | 0:5fa30cf392c3 | 103 | #define FLAT_STATE_END (1713) |
oprospero | 0:5fa30cf392c3 | 104 | #define SWING_END_4 (1616) |
oprospero | 0:5fa30cf392c3 | 105 | #define SWING_END_2 (1565) |
oprospero | 0:5fa30cf392c3 | 106 | #define SWING_END_3 (1587) |
oprospero | 0:5fa30cf392c3 | 107 | #define SWING_END_1 (1550) |
oprospero | 0:5fa30cf392c3 | 108 | #define CFG_8 (2718) |
oprospero | 0:5fa30cf392c3 | 109 | #define CFG_15 (2727) |
oprospero | 0:5fa30cf392c3 | 110 | #define CFG_16 (2746) |
oprospero | 0:5fa30cf392c3 | 111 | #define CFG_EXT_GYRO_BIAS (1189) |
oprospero | 0:5fa30cf392c3 | 112 | #define END_COMPARE_Y_X_TMP (1407) |
oprospero | 0:5fa30cf392c3 | 113 | #define DO_NOT_UPDATE_PROP_ROT (1839) |
oprospero | 0:5fa30cf392c3 | 114 | #define CFG_7 (1205) |
oprospero | 0:5fa30cf392c3 | 115 | #define FLAT_STATE_END_TEMP (1683) |
oprospero | 0:5fa30cf392c3 | 116 | #define END_COMPARE_Y_X (1484) |
oprospero | 0:5fa30cf392c3 | 117 | #define SKIP_SWING_END_1 (1551) |
oprospero | 0:5fa30cf392c3 | 118 | #define SKIP_SWING_END_3 (1588) |
oprospero | 0:5fa30cf392c3 | 119 | #define SKIP_SWING_END_2 (1566) |
oprospero | 0:5fa30cf392c3 | 120 | #define TILTG75_START (1672) |
oprospero | 0:5fa30cf392c3 | 121 | #define CFG_6 (2753) |
oprospero | 0:5fa30cf392c3 | 122 | #define TILTL75_END (1669) |
oprospero | 0:5fa30cf392c3 | 123 | #define END_ORIENT (1884) |
oprospero | 0:5fa30cf392c3 | 124 | #define CFG_FLICK_IN (2573) |
oprospero | 0:5fa30cf392c3 | 125 | #define TILTL75_START (1643) |
oprospero | 0:5fa30cf392c3 | 126 | #define CFG_MOTION_BIAS (1208) |
oprospero | 0:5fa30cf392c3 | 127 | #define X_GRT_Y (1408) |
oprospero | 0:5fa30cf392c3 | 128 | #define TEMPLABEL (2324) |
oprospero | 0:5fa30cf392c3 | 129 | #define CFG_ANDROID_ORIENT_INT (1853) |
oprospero | 0:5fa30cf392c3 | 130 | #define CFG_GYRO_RAW_DATA (2722) |
oprospero | 0:5fa30cf392c3 | 131 | #define X_GRT_Y_TMP2 (1379) |
oprospero | 0:5fa30cf392c3 | 132 | |
oprospero | 0:5fa30cf392c3 | 133 | #define D_0_22 (22+512) |
oprospero | 0:5fa30cf392c3 | 134 | #define D_0_24 (24+512) |
oprospero | 0:5fa30cf392c3 | 135 | |
oprospero | 0:5fa30cf392c3 | 136 | #define D_0_36 (36) |
oprospero | 0:5fa30cf392c3 | 137 | #define D_0_52 (52) |
oprospero | 0:5fa30cf392c3 | 138 | #define D_0_96 (96) |
oprospero | 0:5fa30cf392c3 | 139 | #define D_0_104 (104) |
oprospero | 0:5fa30cf392c3 | 140 | #define D_0_108 (108) |
oprospero | 0:5fa30cf392c3 | 141 | #define D_0_163 (163) |
oprospero | 0:5fa30cf392c3 | 142 | #define D_0_188 (188) |
oprospero | 0:5fa30cf392c3 | 143 | #define D_0_192 (192) |
oprospero | 0:5fa30cf392c3 | 144 | #define D_0_224 (224) |
oprospero | 0:5fa30cf392c3 | 145 | #define D_0_228 (228) |
oprospero | 0:5fa30cf392c3 | 146 | #define D_0_232 (232) |
oprospero | 0:5fa30cf392c3 | 147 | #define D_0_236 (236) |
oprospero | 0:5fa30cf392c3 | 148 | |
oprospero | 0:5fa30cf392c3 | 149 | #define D_1_2 (256 + 2) |
oprospero | 0:5fa30cf392c3 | 150 | #define D_1_4 (256 + 4) |
oprospero | 0:5fa30cf392c3 | 151 | #define D_1_8 (256 + 8) |
oprospero | 0:5fa30cf392c3 | 152 | #define D_1_10 (256 + 10) |
oprospero | 0:5fa30cf392c3 | 153 | #define D_1_24 (256 + 24) |
oprospero | 0:5fa30cf392c3 | 154 | #define D_1_28 (256 + 28) |
oprospero | 0:5fa30cf392c3 | 155 | #define D_1_36 (256 + 36) |
oprospero | 0:5fa30cf392c3 | 156 | #define D_1_40 (256 + 40) |
oprospero | 0:5fa30cf392c3 | 157 | #define D_1_44 (256 + 44) |
oprospero | 0:5fa30cf392c3 | 158 | #define D_1_72 (256 + 72) |
oprospero | 0:5fa30cf392c3 | 159 | #define D_1_74 (256 + 74) |
oprospero | 0:5fa30cf392c3 | 160 | #define D_1_79 (256 + 79) |
oprospero | 0:5fa30cf392c3 | 161 | #define D_1_88 (256 + 88) |
oprospero | 0:5fa30cf392c3 | 162 | #define D_1_90 (256 + 90) |
oprospero | 0:5fa30cf392c3 | 163 | #define D_1_92 (256 + 92) |
oprospero | 0:5fa30cf392c3 | 164 | #define D_1_96 (256 + 96) |
oprospero | 0:5fa30cf392c3 | 165 | #define D_1_98 (256 + 98) |
oprospero | 0:5fa30cf392c3 | 166 | #define D_1_106 (256 + 106) |
oprospero | 0:5fa30cf392c3 | 167 | #define D_1_108 (256 + 108) |
oprospero | 0:5fa30cf392c3 | 168 | #define D_1_112 (256 + 112) |
oprospero | 0:5fa30cf392c3 | 169 | #define D_1_128 (256 + 144) |
oprospero | 0:5fa30cf392c3 | 170 | #define D_1_152 (256 + 12) |
oprospero | 0:5fa30cf392c3 | 171 | #define D_1_160 (256 + 160) |
oprospero | 0:5fa30cf392c3 | 172 | #define D_1_176 (256 + 176) |
oprospero | 0:5fa30cf392c3 | 173 | #define D_1_178 (256 + 178) |
oprospero | 0:5fa30cf392c3 | 174 | #define D_1_218 (256 + 218) |
oprospero | 0:5fa30cf392c3 | 175 | #define D_1_232 (256 + 232) |
oprospero | 0:5fa30cf392c3 | 176 | #define D_1_236 (256 + 236) |
oprospero | 0:5fa30cf392c3 | 177 | #define D_1_240 (256 + 240) |
oprospero | 0:5fa30cf392c3 | 178 | #define D_1_244 (256 + 244) |
oprospero | 0:5fa30cf392c3 | 179 | #define D_1_250 (256 + 250) |
oprospero | 0:5fa30cf392c3 | 180 | #define D_1_252 (256 + 252) |
oprospero | 0:5fa30cf392c3 | 181 | #define D_2_12 (512 + 12) |
oprospero | 0:5fa30cf392c3 | 182 | #define D_2_96 (512 + 96) |
oprospero | 0:5fa30cf392c3 | 183 | #define D_2_108 (512 + 108) |
oprospero | 0:5fa30cf392c3 | 184 | #define D_2_208 (512 + 208) |
oprospero | 0:5fa30cf392c3 | 185 | #define D_2_224 (512 + 224) |
oprospero | 0:5fa30cf392c3 | 186 | #define D_2_236 (512 + 236) |
oprospero | 0:5fa30cf392c3 | 187 | #define D_2_244 (512 + 244) |
oprospero | 0:5fa30cf392c3 | 188 | #define D_2_248 (512 + 248) |
oprospero | 0:5fa30cf392c3 | 189 | #define D_2_252 (512 + 252) |
oprospero | 0:5fa30cf392c3 | 190 | |
oprospero | 0:5fa30cf392c3 | 191 | #define CPASS_BIAS_X (35 * 16 + 4) |
oprospero | 0:5fa30cf392c3 | 192 | #define CPASS_BIAS_Y (35 * 16 + 8) |
oprospero | 0:5fa30cf392c3 | 193 | #define CPASS_BIAS_Z (35 * 16 + 12) |
oprospero | 0:5fa30cf392c3 | 194 | #define CPASS_MTX_00 (36 * 16) |
oprospero | 0:5fa30cf392c3 | 195 | #define CPASS_MTX_01 (36 * 16 + 4) |
oprospero | 0:5fa30cf392c3 | 196 | #define CPASS_MTX_02 (36 * 16 + 8) |
oprospero | 0:5fa30cf392c3 | 197 | #define CPASS_MTX_10 (36 * 16 + 12) |
oprospero | 0:5fa30cf392c3 | 198 | #define CPASS_MTX_11 (37 * 16) |
oprospero | 0:5fa30cf392c3 | 199 | #define CPASS_MTX_12 (37 * 16 + 4) |
oprospero | 0:5fa30cf392c3 | 200 | #define CPASS_MTX_20 (37 * 16 + 8) |
oprospero | 0:5fa30cf392c3 | 201 | #define CPASS_MTX_21 (37 * 16 + 12) |
oprospero | 0:5fa30cf392c3 | 202 | #define CPASS_MTX_22 (43 * 16 + 12) |
oprospero | 0:5fa30cf392c3 | 203 | #define D_EXT_GYRO_BIAS_X (61 * 16) |
oprospero | 0:5fa30cf392c3 | 204 | #define D_EXT_GYRO_BIAS_Y (61 * 16) + 4 |
oprospero | 0:5fa30cf392c3 | 205 | #define D_EXT_GYRO_BIAS_Z (61 * 16) + 8 |
oprospero | 0:5fa30cf392c3 | 206 | #define D_ACT0 (40 * 16) |
oprospero | 0:5fa30cf392c3 | 207 | #define D_ACSX (40 * 16 + 4) |
oprospero | 0:5fa30cf392c3 | 208 | #define D_ACSY (40 * 16 + 8) |
oprospero | 0:5fa30cf392c3 | 209 | #define D_ACSZ (40 * 16 + 12) |
oprospero | 0:5fa30cf392c3 | 210 | |
oprospero | 0:5fa30cf392c3 | 211 | #define FLICK_MSG (45 * 16 + 4) |
oprospero | 0:5fa30cf392c3 | 212 | #define FLICK_COUNTER (45 * 16 + 8) |
oprospero | 0:5fa30cf392c3 | 213 | #define FLICK_LOWER (45 * 16 + 12) |
oprospero | 0:5fa30cf392c3 | 214 | #define FLICK_UPPER (46 * 16 + 12) |
oprospero | 0:5fa30cf392c3 | 215 | |
oprospero | 0:5fa30cf392c3 | 216 | #define D_AUTH_OUT (992) |
oprospero | 0:5fa30cf392c3 | 217 | #define D_AUTH_IN (996) |
oprospero | 0:5fa30cf392c3 | 218 | #define D_AUTH_A (1000) |
oprospero | 0:5fa30cf392c3 | 219 | #define D_AUTH_B (1004) |
oprospero | 0:5fa30cf392c3 | 220 | |
oprospero | 0:5fa30cf392c3 | 221 | #define D_PEDSTD_BP_B (768 + 0x1C) |
oprospero | 0:5fa30cf392c3 | 222 | #define D_PEDSTD_HP_A (768 + 0x78) |
oprospero | 0:5fa30cf392c3 | 223 | #define D_PEDSTD_HP_B (768 + 0x7C) |
oprospero | 0:5fa30cf392c3 | 224 | #define D_PEDSTD_BP_A4 (768 + 0x40) |
oprospero | 0:5fa30cf392c3 | 225 | #define D_PEDSTD_BP_A3 (768 + 0x44) |
oprospero | 0:5fa30cf392c3 | 226 | #define D_PEDSTD_BP_A2 (768 + 0x48) |
oprospero | 0:5fa30cf392c3 | 227 | #define D_PEDSTD_BP_A1 (768 + 0x4C) |
oprospero | 0:5fa30cf392c3 | 228 | #define D_PEDSTD_INT_THRSH (768 + 0x68) |
oprospero | 0:5fa30cf392c3 | 229 | #define D_PEDSTD_CLIP (768 + 0x6C) |
oprospero | 0:5fa30cf392c3 | 230 | #define D_PEDSTD_SB (768 + 0x28) |
oprospero | 0:5fa30cf392c3 | 231 | #define D_PEDSTD_SB_TIME (768 + 0x2C) |
oprospero | 0:5fa30cf392c3 | 232 | #define D_PEDSTD_PEAKTHRSH (768 + 0x98) |
oprospero | 0:5fa30cf392c3 | 233 | #define D_PEDSTD_TIML (768 + 0x2A) |
oprospero | 0:5fa30cf392c3 | 234 | #define D_PEDSTD_TIMH (768 + 0x2E) |
oprospero | 0:5fa30cf392c3 | 235 | #define D_PEDSTD_PEAK (768 + 0X94) |
oprospero | 0:5fa30cf392c3 | 236 | #define D_PEDSTD_STEPCTR (768 + 0x60) |
oprospero | 0:5fa30cf392c3 | 237 | #define D_PEDSTD_TIMECTR (964) |
oprospero | 0:5fa30cf392c3 | 238 | #define D_PEDSTD_DECI (768 + 0xA0) |
oprospero | 0:5fa30cf392c3 | 239 | |
oprospero | 0:5fa30cf392c3 | 240 | #define D_HOST_NO_MOT (976) |
oprospero | 0:5fa30cf392c3 | 241 | #define D_ACCEL_BIAS (660) |
oprospero | 0:5fa30cf392c3 | 242 | |
oprospero | 0:5fa30cf392c3 | 243 | #define D_ORIENT_GAP (76) |
oprospero | 0:5fa30cf392c3 | 244 | |
oprospero | 0:5fa30cf392c3 | 245 | #define D_TILT0_H (48) |
oprospero | 0:5fa30cf392c3 | 246 | #define D_TILT0_L (50) |
oprospero | 0:5fa30cf392c3 | 247 | #define D_TILT1_H (52) |
oprospero | 0:5fa30cf392c3 | 248 | #define D_TILT1_L (54) |
oprospero | 0:5fa30cf392c3 | 249 | #define D_TILT2_H (56) |
oprospero | 0:5fa30cf392c3 | 250 | #define D_TILT2_L (58) |
oprospero | 0:5fa30cf392c3 | 251 | #define D_TILT3_H (60) |
oprospero | 0:5fa30cf392c3 | 252 | #define D_TILT3_L (62) |
oprospero | 0:5fa30cf392c3 | 253 | |
oprospero | 0:5fa30cf392c3 | 254 | #define DMP_CODE_SIZE (3062) |
oprospero | 0:5fa30cf392c3 | 255 | |
oprospero | 0:5fa30cf392c3 | 256 | static const unsigned char dmp_memory[DMP_CODE_SIZE] = { |
oprospero | 0:5fa30cf392c3 | 257 | /* bank # 0 */ |
oprospero | 0:5fa30cf392c3 | 258 | 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 259 | 0x00, 0x65, 0x00, 0x54, 0xff, 0xef, 0x00, 0x00, 0xfa, 0x80, 0x00, 0x0b, 0x12, 0x82, 0x00, 0x01, |
oprospero | 0:5fa30cf392c3 | 260 | 0x03, 0x0c, 0x30, 0xc3, 0x0e, 0x8c, 0x8c, 0xe9, 0x14, 0xd5, 0x40, 0x02, 0x13, 0x71, 0x0f, 0x8e, |
oprospero | 0:5fa30cf392c3 | 261 | 0x38, 0x83, 0xf8, 0x83, 0x30, 0x00, 0xf8, 0x83, 0x25, 0x8e, 0xf8, 0x83, 0x30, 0x00, 0xf8, 0x83, |
oprospero | 0:5fa30cf392c3 | 262 | 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfe, 0xa9, 0xd6, 0x24, 0x00, 0x04, 0x00, 0x1a, 0x82, 0x79, 0xa1, |
oprospero | 0:5fa30cf392c3 | 263 | 0x00, 0x00, 0x00, 0x3c, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x38, 0x83, 0x6f, 0xa2, |
oprospero | 0:5fa30cf392c3 | 264 | 0x00, 0x3e, 0x03, 0x30, 0x40, 0x00, 0x00, 0x00, 0x02, 0xca, 0xe3, 0x09, 0x3e, 0x80, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 265 | 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 266 | 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x6e, 0x00, 0x00, 0x06, 0x92, 0x0a, 0x16, 0xc0, 0xdf, |
oprospero | 0:5fa30cf392c3 | 267 | 0xff, 0xff, 0x02, 0x56, 0xfd, 0x8c, 0xd3, 0x77, 0xff, 0xe1, 0xc4, 0x96, 0xe0, 0xc5, 0xbe, 0xaa, |
oprospero | 0:5fa30cf392c3 | 268 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x2b, 0x00, 0x00, 0x16, 0x57, 0x00, 0x00, 0x03, 0x59, |
oprospero | 0:5fa30cf392c3 | 269 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0xfa, 0x00, 0x02, 0x6c, 0x1d, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 270 | 0x3f, 0xff, 0xdf, 0xeb, 0x00, 0x3e, 0xb3, 0xb6, 0x00, 0x0d, 0x22, 0x78, 0x00, 0x00, 0x2f, 0x3c, |
oprospero | 0:5fa30cf392c3 | 271 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x42, 0xb5, 0x00, 0x00, 0x39, 0xa2, 0x00, 0x00, 0xb3, 0x65, |
oprospero | 0:5fa30cf392c3 | 272 | 0xd9, 0x0e, 0x9f, 0xc9, 0x1d, 0xcf, 0x4c, 0x34, 0x30, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 273 | 0x3b, 0xb6, 0x7a, 0xe8, 0x00, 0x64, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 274 | /* bank # 1 */ |
oprospero | 0:5fa30cf392c3 | 275 | 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0xfa, 0x92, 0x10, 0x00, 0x22, 0x5e, 0x00, 0x0d, 0x22, 0x9f, |
oprospero | 0:5fa30cf392c3 | 276 | 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0xff, 0x46, 0x00, 0x00, 0x63, 0xd4, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 277 | 0x10, 0x00, 0x00, 0x00, 0x04, 0xd6, 0x00, 0x00, 0x04, 0xcc, 0x00, 0x00, 0x04, 0xcc, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 278 | 0x00, 0x00, 0x10, 0x72, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 279 | 0x00, 0x06, 0x00, 0x02, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 280 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x64, 0x00, 0x20, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 281 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x03, 0x00, |
oprospero | 0:5fa30cf392c3 | 282 | 0x00, 0x00, 0x00, 0x32, 0xf8, 0x98, 0x00, 0x00, 0xff, 0x65, 0x00, 0x00, 0x83, 0x0f, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 283 | 0xff, 0x9b, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 284 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 285 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, |
oprospero | 0:5fa30cf392c3 | 286 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xb2, 0x6a, 0x00, 0x02, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 287 | 0x00, 0x01, 0xfb, 0x83, 0x00, 0x68, 0x00, 0x00, 0x00, 0xd9, 0xfc, 0x00, 0x7c, 0xf1, 0xff, 0x83, |
oprospero | 0:5fa30cf392c3 | 288 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x64, 0x03, 0xe8, 0x00, 0x64, 0x00, 0x28, |
oprospero | 0:5fa30cf392c3 | 289 | 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, |
oprospero | 0:5fa30cf392c3 | 290 | 0x00, 0x00, 0x10, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x10, 0x00, |
oprospero | 0:5fa30cf392c3 | 291 | /* bank # 2 */ |
oprospero | 0:5fa30cf392c3 | 292 | 0x00, 0x28, 0x00, 0x00, 0xff, 0xff, 0x45, 0x81, 0xff, 0xff, 0xfa, 0x72, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 293 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x05, 0x00, 0x05, 0xba, 0xc6, 0x00, 0x47, 0x78, 0xa2, |
oprospero | 0:5fa30cf392c3 | 294 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x14, |
oprospero | 0:5fa30cf392c3 | 295 | 0x00, 0x00, 0x25, 0x4d, 0x00, 0x2f, 0x70, 0x6d, 0x00, 0x00, 0x05, 0xae, 0x00, 0x0c, 0x02, 0xd0, |
oprospero | 0:5fa30cf392c3 | 296 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 297 | 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 298 | 0x00, 0x64, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 299 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 300 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 301 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 302 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 303 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 304 | 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0e, |
oprospero | 0:5fa30cf392c3 | 305 | 0x00, 0x00, 0x0a, 0xc7, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0xff, 0xff, 0xff, 0x9c, |
oprospero | 0:5fa30cf392c3 | 306 | 0x00, 0x00, 0x0b, 0x2b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, |
oprospero | 0:5fa30cf392c3 | 307 | 0xff, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 308 | /* bank # 3 */ |
oprospero | 0:5fa30cf392c3 | 309 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 310 | 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x24, 0x26, 0xd3, |
oprospero | 0:5fa30cf392c3 | 311 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x96, 0x00, 0x3c, |
oprospero | 0:5fa30cf392c3 | 312 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 313 | 0x0c, 0x0a, 0x4e, 0x68, 0xcd, 0xcf, 0x77, 0x09, 0x50, 0x16, 0x67, 0x59, 0xc6, 0x19, 0xce, 0x82, |
oprospero | 0:5fa30cf392c3 | 314 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 315 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0xd7, 0x84, 0x00, 0x03, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 316 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x93, 0x8f, 0x9d, 0x1e, 0x1b, 0x1c, 0x19, |
oprospero | 0:5fa30cf392c3 | 317 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 318 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x18, 0x85, 0x00, 0x00, 0x40, 0x00, |
oprospero | 0:5fa30cf392c3 | 319 | 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 320 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 321 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 322 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 323 | 0x00, 0x00, 0x00, 0x00, 0x67, 0x7d, 0xdf, 0x7e, 0x72, 0x90, 0x2e, 0x55, 0x4c, 0xf6, 0xe6, 0x88, |
oprospero | 0:5fa30cf392c3 | 324 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
oprospero | 0:5fa30cf392c3 | 325 | |
oprospero | 0:5fa30cf392c3 | 326 | /* bank # 4 */ |
oprospero | 0:5fa30cf392c3 | 327 | 0xd8, 0xdc, 0xb4, 0xb8, 0xb0, 0xd8, 0xb9, 0xab, 0xf3, 0xf8, 0xfa, 0xb3, 0xb7, 0xbb, 0x8e, 0x9e, |
oprospero | 0:5fa30cf392c3 | 328 | 0xae, 0xf1, 0x32, 0xf5, 0x1b, 0xf1, 0xb4, 0xb8, 0xb0, 0x80, 0x97, 0xf1, 0xa9, 0xdf, 0xdf, 0xdf, |
oprospero | 0:5fa30cf392c3 | 329 | 0xaa, 0xdf, 0xdf, 0xdf, 0xf2, 0xaa, 0xc5, 0xcd, 0xc7, 0xa9, 0x0c, 0xc9, 0x2c, 0x97, 0xf1, 0xa9, |
oprospero | 0:5fa30cf392c3 | 330 | 0x89, 0x26, 0x46, 0x66, 0xb2, 0x89, 0x99, 0xa9, 0x2d, 0x55, 0x7d, 0xb0, 0xb0, 0x8a, 0xa8, 0x96, |
oprospero | 0:5fa30cf392c3 | 331 | 0x36, 0x56, 0x76, 0xf1, 0xba, 0xa3, 0xb4, 0xb2, 0x80, 0xc0, 0xb8, 0xa8, 0x97, 0x11, 0xb2, 0x83, |
oprospero | 0:5fa30cf392c3 | 332 | 0x98, 0xba, 0xa3, 0xf0, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xb2, 0xb9, 0xb4, 0x98, 0x83, 0xf1, |
oprospero | 0:5fa30cf392c3 | 333 | 0xa3, 0x29, 0x55, 0x7d, 0xba, 0xb5, 0xb1, 0xa3, 0x83, 0x93, 0xf0, 0x00, 0x28, 0x50, 0xf5, 0xb2, |
oprospero | 0:5fa30cf392c3 | 334 | 0xb6, 0xaa, 0x83, 0x93, 0x28, 0x54, 0x7c, 0xf1, 0xb9, 0xa3, 0x82, 0x93, 0x61, 0xba, 0xa2, 0xda, |
oprospero | 0:5fa30cf392c3 | 335 | 0xde, 0xdf, 0xdb, 0x81, 0x9a, 0xb9, 0xae, 0xf5, 0x60, 0x68, 0x70, 0xf1, 0xda, 0xba, 0xa2, 0xdf, |
oprospero | 0:5fa30cf392c3 | 336 | 0xd9, 0xba, 0xa2, 0xfa, 0xb9, 0xa3, 0x82, 0x92, 0xdb, 0x31, 0xba, 0xa2, 0xd9, 0xba, 0xa2, 0xf8, |
oprospero | 0:5fa30cf392c3 | 337 | 0xdf, 0x85, 0xa4, 0xd0, 0xc1, 0xbb, 0xad, 0x83, 0xc2, 0xc5, 0xc7, 0xb8, 0xa2, 0xdf, 0xdf, 0xdf, |
oprospero | 0:5fa30cf392c3 | 338 | 0xba, 0xa0, 0xdf, 0xdf, 0xdf, 0xd8, 0xd8, 0xf1, 0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, |
oprospero | 0:5fa30cf392c3 | 339 | 0x5d, 0xb2, 0xb6, 0xba, 0xaf, 0x8c, 0x96, 0x19, 0x8f, 0x9f, 0xa7, 0x0e, 0x16, 0x1e, 0xb4, 0x9a, |
oprospero | 0:5fa30cf392c3 | 340 | 0xb8, 0xaa, 0x87, 0x2c, 0x54, 0x7c, 0xba, 0xa4, 0xb0, 0x8a, 0xb6, 0x91, 0x32, 0x56, 0x76, 0xb2, |
oprospero | 0:5fa30cf392c3 | 341 | 0x84, 0x94, 0xa4, 0xc8, 0x08, 0xcd, 0xd8, 0xb8, 0xb4, 0xb0, 0xf1, 0x99, 0x82, 0xa8, 0x2d, 0x55, |
oprospero | 0:5fa30cf392c3 | 342 | 0x7d, 0x98, 0xa8, 0x0e, 0x16, 0x1e, 0xa2, 0x2c, 0x54, 0x7c, 0x92, 0xa4, 0xf0, 0x2c, 0x50, 0x78, |
oprospero | 0:5fa30cf392c3 | 343 | /* bank # 5 */ |
oprospero | 0:5fa30cf392c3 | 344 | 0xf1, 0x84, 0xa8, 0x98, 0xc4, 0xcd, 0xfc, 0xd8, 0x0d, 0xdb, 0xa8, 0xfc, 0x2d, 0xf3, 0xd9, 0xba, |
oprospero | 0:5fa30cf392c3 | 345 | 0xa6, 0xf8, 0xda, 0xba, 0xa6, 0xde, 0xd8, 0xba, 0xb2, 0xb6, 0x86, 0x96, 0xa6, 0xd0, 0xf3, 0xc8, |
oprospero | 0:5fa30cf392c3 | 346 | 0x41, 0xda, 0xa6, 0xc8, 0xf8, 0xd8, 0xb0, 0xb4, 0xb8, 0x82, 0xa8, 0x92, 0xf5, 0x2c, 0x54, 0x88, |
oprospero | 0:5fa30cf392c3 | 347 | 0x98, 0xf1, 0x35, 0xd9, 0xf4, 0x18, 0xd8, 0xf1, 0xa2, 0xd0, 0xf8, 0xf9, 0xa8, 0x84, 0xd9, 0xc7, |
oprospero | 0:5fa30cf392c3 | 348 | 0xdf, 0xf8, 0xf8, 0x83, 0xc5, 0xda, 0xdf, 0x69, 0xdf, 0x83, 0xc1, 0xd8, 0xf4, 0x01, 0x14, 0xf1, |
oprospero | 0:5fa30cf392c3 | 349 | 0xa8, 0x82, 0x4e, 0xa8, 0x84, 0xf3, 0x11, 0xd1, 0x82, 0xf5, 0xd9, 0x92, 0x28, 0x97, 0x88, 0xf1, |
oprospero | 0:5fa30cf392c3 | 350 | 0x09, 0xf4, 0x1c, 0x1c, 0xd8, 0x84, 0xa8, 0xf3, 0xc0, 0xf9, 0xd1, 0xd9, 0x97, 0x82, 0xf1, 0x29, |
oprospero | 0:5fa30cf392c3 | 351 | 0xf4, 0x0d, 0xd8, 0xf3, 0xf9, 0xf9, 0xd1, 0xd9, 0x82, 0xf4, 0xc2, 0x03, 0xd8, 0xde, 0xdf, 0x1a, |
oprospero | 0:5fa30cf392c3 | 352 | 0xd8, 0xf1, 0xa2, 0xfa, 0xf9, 0xa8, 0x84, 0x98, 0xd9, 0xc7, 0xdf, 0xf8, 0xf8, 0xf8, 0x83, 0xc7, |
oprospero | 0:5fa30cf392c3 | 353 | 0xda, 0xdf, 0x69, 0xdf, 0xf8, 0x83, 0xc3, 0xd8, 0xf4, 0x01, 0x14, 0xf1, 0x98, 0xa8, 0x82, 0x2e, |
oprospero | 0:5fa30cf392c3 | 354 | 0xa8, 0x84, 0xf3, 0x11, 0xd1, 0x82, 0xf5, 0xd9, 0x92, 0x50, 0x97, 0x88, 0xf1, 0x09, 0xf4, 0x1c, |
oprospero | 0:5fa30cf392c3 | 355 | 0xd8, 0x84, 0xa8, 0xf3, 0xc0, 0xf8, 0xf9, 0xd1, 0xd9, 0x97, 0x82, 0xf1, 0x49, 0xf4, 0x0d, 0xd8, |
oprospero | 0:5fa30cf392c3 | 356 | 0xf3, 0xf9, 0xf9, 0xd1, 0xd9, 0x82, 0xf4, 0xc4, 0x03, 0xd8, 0xde, 0xdf, 0xd8, 0xf1, 0xad, 0x88, |
oprospero | 0:5fa30cf392c3 | 357 | 0x98, 0xcc, 0xa8, 0x09, 0xf9, 0xd9, 0x82, 0x92, 0xa8, 0xf5, 0x7c, 0xf1, 0x88, 0x3a, 0xcf, 0x94, |
oprospero | 0:5fa30cf392c3 | 358 | 0x4a, 0x6e, 0x98, 0xdb, 0x69, 0x31, 0xda, 0xad, 0xf2, 0xde, 0xf9, 0xd8, 0x87, 0x95, 0xa8, 0xf2, |
oprospero | 0:5fa30cf392c3 | 359 | 0x21, 0xd1, 0xda, 0xa5, 0xf9, 0xf4, 0x17, 0xd9, 0xf1, 0xae, 0x8e, 0xd0, 0xc0, 0xc3, 0xae, 0x82, |
oprospero | 0:5fa30cf392c3 | 360 | /* bank # 6 */ |
oprospero | 0:5fa30cf392c3 | 361 | 0xc6, 0x84, 0xc3, 0xa8, 0x85, 0x95, 0xc8, 0xa5, 0x88, 0xf2, 0xc0, 0xf1, 0xf4, 0x01, 0x0e, 0xf1, |
oprospero | 0:5fa30cf392c3 | 362 | 0x8e, 0x9e, 0xa8, 0xc6, 0x3e, 0x56, 0xf5, 0x54, 0xf1, 0x88, 0x72, 0xf4, 0x01, 0x15, 0xf1, 0x98, |
oprospero | 0:5fa30cf392c3 | 363 | 0x45, 0x85, 0x6e, 0xf5, 0x8e, 0x9e, 0x04, 0x88, 0xf1, 0x42, 0x98, 0x5a, 0x8e, 0x9e, 0x06, 0x88, |
oprospero | 0:5fa30cf392c3 | 364 | 0x69, 0xf4, 0x01, 0x1c, 0xf1, 0x98, 0x1e, 0x11, 0x08, 0xd0, 0xf5, 0x04, 0xf1, 0x1e, 0x97, 0x02, |
oprospero | 0:5fa30cf392c3 | 365 | 0x02, 0x98, 0x36, 0x25, 0xdb, 0xf9, 0xd9, 0x85, 0xa5, 0xf3, 0xc1, 0xda, 0x85, 0xa5, 0xf3, 0xdf, |
oprospero | 0:5fa30cf392c3 | 366 | 0xd8, 0x85, 0x95, 0xa8, 0xf3, 0x09, 0xda, 0xa5, 0xfa, 0xd8, 0x82, 0x92, 0xa8, 0xf5, 0x78, 0xf1, |
oprospero | 0:5fa30cf392c3 | 367 | 0x88, 0x1a, 0x84, 0x9f, 0x26, 0x88, 0x98, 0x21, 0xda, 0xf4, 0x1d, 0xf3, 0xd8, 0x87, 0x9f, 0x39, |
oprospero | 0:5fa30cf392c3 | 368 | 0xd1, 0xaf, 0xd9, 0xdf, 0xdf, 0xfb, 0xf9, 0xf4, 0x0c, 0xf3, 0xd8, 0xfa, 0xd0, 0xf8, 0xda, 0xf9, |
oprospero | 0:5fa30cf392c3 | 369 | 0xf9, 0xd0, 0xdf, 0xd9, 0xf9, 0xd8, 0xf4, 0x0b, 0xd8, 0xf3, 0x87, 0x9f, 0x39, 0xd1, 0xaf, 0xd9, |
oprospero | 0:5fa30cf392c3 | 370 | 0xdf, 0xdf, 0xf4, 0x1d, 0xf3, 0xd8, 0xfa, 0xfc, 0xa8, 0x69, 0xf9, 0xf9, 0xaf, 0xd0, 0xda, 0xde, |
oprospero | 0:5fa30cf392c3 | 371 | 0xfa, 0xd9, 0xf8, 0x8f, 0x9f, 0xa8, 0xf1, 0xcc, 0xf3, 0x98, 0xdb, 0x45, 0xd9, 0xaf, 0xdf, 0xd0, |
oprospero | 0:5fa30cf392c3 | 372 | 0xf8, 0xd8, 0xf1, 0x8f, 0x9f, 0xa8, 0xca, 0xf3, 0x88, 0x09, 0xda, 0xaf, 0x8f, 0xcb, 0xf8, 0xd8, |
oprospero | 0:5fa30cf392c3 | 373 | 0xf2, 0xad, 0x97, 0x8d, 0x0c, 0xd9, 0xa5, 0xdf, 0xf9, 0xba, 0xa6, 0xf3, 0xfa, 0xf4, 0x12, 0xf2, |
oprospero | 0:5fa30cf392c3 | 374 | 0xd8, 0x95, 0x0d, 0xd1, 0xd9, 0xba, 0xa6, 0xf3, 0xfa, 0xda, 0xa5, 0xf2, 0xc1, 0xba, 0xa6, 0xf3, |
oprospero | 0:5fa30cf392c3 | 375 | 0xdf, 0xd8, 0xf1, 0xba, 0xb2, 0xb6, 0x86, 0x96, 0xa6, 0xd0, 0xca, 0xf3, 0x49, 0xda, 0xa6, 0xcb, |
oprospero | 0:5fa30cf392c3 | 376 | 0xf8, 0xd8, 0xb0, 0xb4, 0xb8, 0xd8, 0xad, 0x84, 0xf2, 0xc0, 0xdf, 0xf1, 0x8f, 0xcb, 0xc3, 0xa8, |
oprospero | 0:5fa30cf392c3 | 377 | /* bank # 7 */ |
oprospero | 0:5fa30cf392c3 | 378 | 0xb2, 0xb6, 0x86, 0x96, 0xc8, 0xc1, 0xcb, 0xc3, 0xf3, 0xb0, 0xb4, 0x88, 0x98, 0xa8, 0x21, 0xdb, |
oprospero | 0:5fa30cf392c3 | 379 | 0x71, 0x8d, 0x9d, 0x71, 0x85, 0x95, 0x21, 0xd9, 0xad, 0xf2, 0xfa, 0xd8, 0x85, 0x97, 0xa8, 0x28, |
oprospero | 0:5fa30cf392c3 | 380 | 0xd9, 0xf4, 0x08, 0xd8, 0xf2, 0x8d, 0x29, 0xda, 0xf4, 0x05, 0xd9, 0xf2, 0x85, 0xa4, 0xc2, 0xf2, |
oprospero | 0:5fa30cf392c3 | 381 | 0xd8, 0xa8, 0x8d, 0x94, 0x01, 0xd1, 0xd9, 0xf4, 0x11, 0xf2, 0xd8, 0x87, 0x21, 0xd8, 0xf4, 0x0a, |
oprospero | 0:5fa30cf392c3 | 382 | 0xd8, 0xf2, 0x84, 0x98, 0xa8, 0xc8, 0x01, 0xd1, 0xd9, 0xf4, 0x11, 0xd8, 0xf3, 0xa4, 0xc8, 0xbb, |
oprospero | 0:5fa30cf392c3 | 383 | 0xaf, 0xd0, 0xf2, 0xde, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xd8, 0xf1, 0xb8, 0xf6, |
oprospero | 0:5fa30cf392c3 | 384 | 0xb5, 0xb9, 0xb0, 0x8a, 0x95, 0xa3, 0xde, 0x3c, 0xa3, 0xd9, 0xf8, 0xd8, 0x5c, 0xa3, 0xd9, 0xf8, |
oprospero | 0:5fa30cf392c3 | 385 | 0xd8, 0x7c, 0xa3, 0xd9, 0xf8, 0xd8, 0xf8, 0xf9, 0xd1, 0xa5, 0xd9, 0xdf, 0xda, 0xfa, 0xd8, 0xb1, |
oprospero | 0:5fa30cf392c3 | 386 | 0x85, 0x30, 0xf7, 0xd9, 0xde, 0xd8, 0xf8, 0x30, 0xad, 0xda, 0xde, 0xd8, 0xf2, 0xb4, 0x8c, 0x99, |
oprospero | 0:5fa30cf392c3 | 387 | 0xa3, 0x2d, 0x55, 0x7d, 0xa0, 0x83, 0xdf, 0xdf, 0xdf, 0xb5, 0x91, 0xa0, 0xf6, 0x29, 0xd9, 0xfb, |
oprospero | 0:5fa30cf392c3 | 388 | 0xd8, 0xa0, 0xfc, 0x29, 0xd9, 0xfa, 0xd8, 0xa0, 0xd0, 0x51, 0xd9, 0xf8, 0xd8, 0xfc, 0x51, 0xd9, |
oprospero | 0:5fa30cf392c3 | 389 | 0xf9, 0xd8, 0x79, 0xd9, 0xfb, 0xd8, 0xa0, 0xd0, 0xfc, 0x79, 0xd9, 0xfa, 0xd8, 0xa1, 0xf9, 0xf9, |
oprospero | 0:5fa30cf392c3 | 390 | 0xf9, 0xf9, 0xf9, 0xa0, 0xda, 0xdf, 0xdf, 0xdf, 0xd8, 0xa1, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xac, |
oprospero | 0:5fa30cf392c3 | 391 | 0xde, 0xf8, 0xad, 0xde, 0x83, 0x93, 0xac, 0x2c, 0x54, 0x7c, 0xf1, 0xa8, 0xdf, 0xdf, 0xdf, 0xf6, |
oprospero | 0:5fa30cf392c3 | 392 | 0x9d, 0x2c, 0xda, 0xa0, 0xdf, 0xd9, 0xfa, 0xdb, 0x2d, 0xf8, 0xd8, 0xa8, 0x50, 0xda, 0xa0, 0xd0, |
oprospero | 0:5fa30cf392c3 | 393 | 0xde, 0xd9, 0xd0, 0xf8, 0xf8, 0xf8, 0xdb, 0x55, 0xf8, 0xd8, 0xa8, 0x78, 0xda, 0xa0, 0xd0, 0xdf, |
oprospero | 0:5fa30cf392c3 | 394 | /* bank # 8 */ |
oprospero | 0:5fa30cf392c3 | 395 | 0xd9, 0xd0, 0xfa, 0xf8, 0xf8, 0xf8, 0xf8, 0xdb, 0x7d, 0xf8, 0xd8, 0x9c, 0xa8, 0x8c, 0xf5, 0x30, |
oprospero | 0:5fa30cf392c3 | 396 | 0xdb, 0x38, 0xd9, 0xd0, 0xde, 0xdf, 0xa0, 0xd0, 0xde, 0xdf, 0xd8, 0xa8, 0x48, 0xdb, 0x58, 0xd9, |
oprospero | 0:5fa30cf392c3 | 397 | 0xdf, 0xd0, 0xde, 0xa0, 0xdf, 0xd0, 0xde, 0xd8, 0xa8, 0x68, 0xdb, 0x70, 0xd9, 0xdf, 0xdf, 0xa0, |
oprospero | 0:5fa30cf392c3 | 398 | 0xdf, 0xdf, 0xd8, 0xf1, 0xa8, 0x88, 0x90, 0x2c, 0x54, 0x7c, 0x98, 0xa8, 0xd0, 0x5c, 0x38, 0xd1, |
oprospero | 0:5fa30cf392c3 | 399 | 0xda, 0xf2, 0xae, 0x8c, 0xdf, 0xf9, 0xd8, 0xb0, 0x87, 0xa8, 0xc1, 0xc1, 0xb1, 0x88, 0xa8, 0xc6, |
oprospero | 0:5fa30cf392c3 | 400 | 0xf9, 0xf9, 0xda, 0x36, 0xd8, 0xa8, 0xf9, 0xda, 0x36, 0xd8, 0xa8, 0xf9, 0xda, 0x36, 0xd8, 0xa8, |
oprospero | 0:5fa30cf392c3 | 401 | 0xf9, 0xda, 0x36, 0xd8, 0xa8, 0xf9, 0xda, 0x36, 0xd8, 0xf7, 0x8d, 0x9d, 0xad, 0xf8, 0x18, 0xda, |
oprospero | 0:5fa30cf392c3 | 402 | 0xf2, 0xae, 0xdf, 0xd8, 0xf7, 0xad, 0xfa, 0x30, 0xd9, 0xa4, 0xde, 0xf9, 0xd8, 0xf2, 0xae, 0xde, |
oprospero | 0:5fa30cf392c3 | 403 | 0xfa, 0xf9, 0x83, 0xa7, 0xd9, 0xc3, 0xc5, 0xc7, 0xf1, 0x88, 0x9b, 0xa7, 0x7a, 0xad, 0xf7, 0xde, |
oprospero | 0:5fa30cf392c3 | 404 | 0xdf, 0xa4, 0xf8, 0x84, 0x94, 0x08, 0xa7, 0x97, 0xf3, 0x00, 0xae, 0xf2, 0x98, 0x19, 0xa4, 0x88, |
oprospero | 0:5fa30cf392c3 | 405 | 0xc6, 0xa3, 0x94, 0x88, 0xf6, 0x32, 0xdf, 0xf2, 0x83, 0x93, 0xdb, 0x09, 0xd9, 0xf2, 0xaa, 0xdf, |
oprospero | 0:5fa30cf392c3 | 406 | 0xd8, 0xd8, 0xae, 0xf8, 0xf9, 0xd1, 0xda, 0xf3, 0xa4, 0xde, 0xa7, 0xf1, 0x88, 0x9b, 0x7a, 0xd8, |
oprospero | 0:5fa30cf392c3 | 407 | 0xf3, 0x84, 0x94, 0xae, 0x19, 0xf9, 0xda, 0xaa, 0xf1, 0xdf, 0xd8, 0xa8, 0x81, 0xc0, 0xc3, 0xc5, |
oprospero | 0:5fa30cf392c3 | 408 | 0xc7, 0xa3, 0x92, 0x83, 0xf6, 0x28, 0xad, 0xde, 0xd9, 0xf8, 0xd8, 0xa3, 0x50, 0xad, 0xd9, 0xf8, |
oprospero | 0:5fa30cf392c3 | 409 | 0xd8, 0xa3, 0x78, 0xad, 0xd9, 0xf8, 0xd8, 0xf8, 0xf9, 0xd1, 0xa1, 0xda, 0xde, 0xc3, 0xc5, 0xc7, |
oprospero | 0:5fa30cf392c3 | 410 | 0xd8, 0xa1, 0x81, 0x94, 0xf8, 0x18, 0xf2, 0xb0, 0x89, 0xac, 0xc3, 0xc5, 0xc7, 0xf1, 0xd8, 0xb8, |
oprospero | 0:5fa30cf392c3 | 411 | /* bank # 9 */ |
oprospero | 0:5fa30cf392c3 | 412 | 0xb4, 0xb0, 0x97, 0x86, 0xa8, 0x31, 0x9b, 0x06, 0x99, 0x07, 0xab, 0x97, 0x28, 0x88, 0x9b, 0xf0, |
oprospero | 0:5fa30cf392c3 | 413 | 0x0c, 0x20, 0x14, 0x40, 0xb0, 0xb4, 0xb8, 0xf0, 0xa8, 0x8a, 0x9a, 0x28, 0x50, 0x78, 0xb7, 0x9b, |
oprospero | 0:5fa30cf392c3 | 414 | 0xa8, 0x29, 0x51, 0x79, 0x24, 0x70, 0x59, 0x44, 0x69, 0x38, 0x64, 0x48, 0x31, 0xf1, 0xbb, 0xab, |
oprospero | 0:5fa30cf392c3 | 415 | 0x88, 0x00, 0x2c, 0x54, 0x7c, 0xf0, 0xb3, 0x8b, 0xb8, 0xa8, 0x04, 0x28, 0x50, 0x78, 0xf1, 0xb0, |
oprospero | 0:5fa30cf392c3 | 416 | 0x88, 0xb4, 0x97, 0x26, 0xa8, 0x59, 0x98, 0xbb, 0xab, 0xb3, 0x8b, 0x02, 0x26, 0x46, 0x66, 0xb0, |
oprospero | 0:5fa30cf392c3 | 417 | 0xb8, 0xf0, 0x8a, 0x9c, 0xa8, 0x29, 0x51, 0x79, 0x8b, 0x29, 0x51, 0x79, 0x8a, 0x24, 0x70, 0x59, |
oprospero | 0:5fa30cf392c3 | 418 | 0x8b, 0x20, 0x58, 0x71, 0x8a, 0x44, 0x69, 0x38, 0x8b, 0x39, 0x40, 0x68, 0x8a, 0x64, 0x48, 0x31, |
oprospero | 0:5fa30cf392c3 | 419 | 0x8b, 0x30, 0x49, 0x60, 0x88, 0xf1, 0xac, 0x00, 0x2c, 0x54, 0x7c, 0xf0, 0x8c, 0xa8, 0x04, 0x28, |
oprospero | 0:5fa30cf392c3 | 420 | 0x50, 0x78, 0xf1, 0x88, 0x97, 0x26, 0xa8, 0x59, 0x98, 0xac, 0x8c, 0x02, 0x26, 0x46, 0x66, 0xf0, |
oprospero | 0:5fa30cf392c3 | 421 | 0x89, 0x9c, 0xa8, 0x29, 0x51, 0x79, 0x24, 0x70, 0x59, 0x44, 0x69, 0x38, 0x64, 0x48, 0x31, 0xa9, |
oprospero | 0:5fa30cf392c3 | 422 | 0x88, 0x09, 0x20, 0x59, 0x70, 0xab, 0x11, 0x38, 0x40, 0x69, 0xa8, 0x19, 0x31, 0x48, 0x60, 0x8c, |
oprospero | 0:5fa30cf392c3 | 423 | 0xa8, 0x3c, 0x41, 0x5c, 0x20, 0x7c, 0x00, 0xf1, 0x87, 0x98, 0x19, 0x86, 0xa8, 0x6e, 0x76, 0x7e, |
oprospero | 0:5fa30cf392c3 | 424 | 0xa9, 0x99, 0x88, 0x2d, 0x55, 0x7d, 0xd8, 0xb1, 0xb5, 0xb9, 0xa3, 0xdf, 0xdf, 0xdf, 0xae, 0xd0, |
oprospero | 0:5fa30cf392c3 | 425 | 0xdf, 0xaa, 0xd0, 0xde, 0xf2, 0xab, 0xf8, 0xf9, 0xd9, 0xb0, 0x87, 0xc4, 0xaa, 0xf1, 0xdf, 0xdf, |
oprospero | 0:5fa30cf392c3 | 426 | 0xbb, 0xaf, 0xdf, 0xdf, 0xb9, 0xd8, 0xb1, 0xf1, 0xa3, 0x97, 0x8e, 0x60, 0xdf, 0xb0, 0x84, 0xf2, |
oprospero | 0:5fa30cf392c3 | 427 | 0xc8, 0xf8, 0xf9, 0xd9, 0xde, 0xd8, 0x93, 0x85, 0xf1, 0x4a, 0xb1, 0x83, 0xa3, 0x08, 0xb5, 0x83, |
oprospero | 0:5fa30cf392c3 | 428 | /* bank # 10 */ |
oprospero | 0:5fa30cf392c3 | 429 | 0x9a, 0x08, 0x10, 0xb7, 0x9f, 0x10, 0xd8, 0xf1, 0xb0, 0xba, 0xae, 0xb0, 0x8a, 0xc2, 0xb2, 0xb6, |
oprospero | 0:5fa30cf392c3 | 430 | 0x8e, 0x9e, 0xf1, 0xfb, 0xd9, 0xf4, 0x1d, 0xd8, 0xf9, 0xd9, 0x0c, 0xf1, 0xd8, 0xf8, 0xf8, 0xad, |
oprospero | 0:5fa30cf392c3 | 431 | 0x61, 0xd9, 0xae, 0xfb, 0xd8, 0xf4, 0x0c, 0xf1, 0xd8, 0xf8, 0xf8, 0xad, 0x19, 0xd9, 0xae, 0xfb, |
oprospero | 0:5fa30cf392c3 | 432 | 0xdf, 0xd8, 0xf4, 0x16, 0xf1, 0xd8, 0xf8, 0xad, 0x8d, 0x61, 0xd9, 0xf4, 0xf4, 0xac, 0xf5, 0x9c, |
oprospero | 0:5fa30cf392c3 | 433 | 0x9c, 0x8d, 0xdf, 0x2b, 0xba, 0xb6, 0xae, 0xfa, 0xf8, 0xf4, 0x0b, 0xd8, 0xf1, 0xae, 0xd0, 0xf8, |
oprospero | 0:5fa30cf392c3 | 434 | 0xad, 0x51, 0xda, 0xae, 0xfa, 0xf8, 0xf1, 0xd8, 0xb9, 0xb1, 0xb6, 0xa3, 0x83, 0x9c, 0x08, 0xb9, |
oprospero | 0:5fa30cf392c3 | 435 | 0xb1, 0x83, 0x9a, 0xb5, 0xaa, 0xc0, 0xfd, 0x30, 0x83, 0xb7, 0x9f, 0x10, 0xb5, 0x8b, 0x93, 0xf2, |
oprospero | 0:5fa30cf392c3 | 436 | 0x02, 0x02, 0xd1, 0xab, 0xda, 0xde, 0xd8, 0xf1, 0xb0, 0x80, 0xba, 0xab, 0xc0, 0xc3, 0xb2, 0x84, |
oprospero | 0:5fa30cf392c3 | 437 | 0xc1, 0xc3, 0xd8, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3, 0x91, 0xb6, 0x09, 0xb4, 0xd9, 0xab, 0xde, 0xb0, |
oprospero | 0:5fa30cf392c3 | 438 | 0x87, 0x9c, 0xb9, 0xa3, 0xdd, 0xf1, 0xb3, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0xb0, 0x87, 0xa3, 0xa3, |
oprospero | 0:5fa30cf392c3 | 439 | 0xa3, 0xa3, 0xb2, 0x8b, 0xb6, 0x9b, 0xf2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, |
oprospero | 0:5fa30cf392c3 | 440 | 0xa3, 0xf1, 0xb0, 0x87, 0xb5, 0x9a, 0xa3, 0xf3, 0x9b, 0xa3, 0xa3, 0xdc, 0xba, 0xac, 0xdf, 0xb9, |
oprospero | 0:5fa30cf392c3 | 441 | 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, |
oprospero | 0:5fa30cf392c3 | 442 | 0xd8, 0xd8, 0xd8, 0xbb, 0xb3, 0xb7, 0xf1, 0xaa, 0xf9, 0xda, 0xff, 0xd9, 0x80, 0x9a, 0xaa, 0x28, |
oprospero | 0:5fa30cf392c3 | 443 | 0xb4, 0x80, 0x98, 0xa7, 0x20, 0xb7, 0x97, 0x87, 0xa8, 0x66, 0x88, 0xf0, 0x79, 0x51, 0xf1, 0x90, |
oprospero | 0:5fa30cf392c3 | 444 | 0x2c, 0x87, 0x0c, 0xa7, 0x81, 0x97, 0x62, 0x93, 0xf0, 0x71, 0x71, 0x60, 0x85, 0x94, 0x01, 0x29, |
oprospero | 0:5fa30cf392c3 | 445 | /* bank # 11 */ |
oprospero | 0:5fa30cf392c3 | 446 | 0x51, 0x79, 0x90, 0xa5, 0xf1, 0x28, 0x4c, 0x6c, 0x87, 0x0c, 0x95, 0x18, 0x85, 0x78, 0xa3, 0x83, |
oprospero | 0:5fa30cf392c3 | 447 | 0x90, 0x28, 0x4c, 0x6c, 0x88, 0x6c, 0xd8, 0xf3, 0xa2, 0x82, 0x00, 0xf2, 0x10, 0xa8, 0x92, 0x19, |
oprospero | 0:5fa30cf392c3 | 448 | 0x80, 0xa2, 0xf2, 0xd9, 0x26, 0xd8, 0xf1, 0x88, 0xa8, 0x4d, 0xd9, 0x48, 0xd8, 0x96, 0xa8, 0x39, |
oprospero | 0:5fa30cf392c3 | 449 | 0x80, 0xd9, 0x3c, 0xd8, 0x95, 0x80, 0xa8, 0x39, 0xa6, 0x86, 0x98, 0xd9, 0x2c, 0xda, 0x87, 0xa7, |
oprospero | 0:5fa30cf392c3 | 450 | 0x2c, 0xd8, 0xa8, 0x89, 0x95, 0x19, 0xa9, 0x80, 0xd9, 0x38, 0xd8, 0xa8, 0x89, 0x39, 0xa9, 0x80, |
oprospero | 0:5fa30cf392c3 | 451 | 0xda, 0x3c, 0xd8, 0xa8, 0x2e, 0xa8, 0x39, 0x90, 0xd9, 0x0c, 0xd8, 0xa8, 0x95, 0x31, 0x98, 0xd9, |
oprospero | 0:5fa30cf392c3 | 452 | 0x0c, 0xd8, 0xa8, 0x09, 0xd9, 0xff, 0xd8, 0x01, 0xda, 0xff, 0xd8, 0x95, 0x39, 0xa9, 0xda, 0x26, |
oprospero | 0:5fa30cf392c3 | 453 | 0xff, 0xd8, 0x90, 0xa8, 0x0d, 0x89, 0x99, 0xa8, 0x10, 0x80, 0x98, 0x21, 0xda, 0x2e, 0xd8, 0x89, |
oprospero | 0:5fa30cf392c3 | 454 | 0x99, 0xa8, 0x31, 0x80, 0xda, 0x2e, 0xd8, 0xa8, 0x86, 0x96, 0x31, 0x80, 0xda, 0x2e, 0xd8, 0xa8, |
oprospero | 0:5fa30cf392c3 | 455 | 0x87, 0x31, 0x80, 0xda, 0x2e, 0xd8, 0xa8, 0x82, 0x92, 0xf3, 0x41, 0x80, 0xf1, 0xd9, 0x2e, 0xd8, |
oprospero | 0:5fa30cf392c3 | 456 | 0xa8, 0x82, 0xf3, 0x19, 0x80, 0xf1, 0xd9, 0x2e, 0xd8, 0x82, 0xac, 0xf3, 0xc0, 0xa2, 0x80, 0x22, |
oprospero | 0:5fa30cf392c3 | 457 | 0xf1, 0xa6, 0x2e, 0xa7, 0x2e, 0xa9, 0x22, 0x98, 0xa8, 0x29, 0xda, 0xac, 0xde, 0xff, 0xd8, 0xa2, |
oprospero | 0:5fa30cf392c3 | 458 | 0xf2, 0x2a, 0xf1, 0xa9, 0x2e, 0x82, 0x92, 0xa8, 0xf2, 0x31, 0x80, 0xa6, 0x96, 0xf1, 0xd9, 0x00, |
oprospero | 0:5fa30cf392c3 | 459 | 0xac, 0x8c, 0x9c, 0x0c, 0x30, 0xac, 0xde, 0xd0, 0xde, 0xff, 0xd8, 0x8c, 0x9c, 0xac, 0xd0, 0x10, |
oprospero | 0:5fa30cf392c3 | 460 | 0xac, 0xde, 0x80, 0x92, 0xa2, 0xf2, 0x4c, 0x82, 0xa8, 0xf1, 0xca, 0xf2, 0x35, 0xf1, 0x96, 0x88, |
oprospero | 0:5fa30cf392c3 | 461 | 0xa6, 0xd9, 0x00, 0xd8, 0xf1, 0xff |
oprospero | 0:5fa30cf392c3 | 462 | }; |
oprospero | 0:5fa30cf392c3 | 463 | |
oprospero | 0:5fa30cf392c3 | 464 | static const unsigned short sStartAddress = 0x0400; |
oprospero | 0:5fa30cf392c3 | 465 | |
oprospero | 0:5fa30cf392c3 | 466 | /* END OF SECTION COPIED FROM dmpDefaultMPU6050.c */ |
oprospero | 0:5fa30cf392c3 | 467 | |
oprospero | 0:5fa30cf392c3 | 468 | #define INT_SRC_TAP (0x01) |
oprospero | 0:5fa30cf392c3 | 469 | #define INT_SRC_ANDROID_ORIENT (0x08) |
oprospero | 0:5fa30cf392c3 | 470 | |
oprospero | 0:5fa30cf392c3 | 471 | #define DMP_FEATURE_SEND_ANY_GYRO (DMP_FEATURE_SEND_RAW_GYRO | \ |
oprospero | 0:5fa30cf392c3 | 472 | DMP_FEATURE_SEND_CAL_GYRO) |
oprospero | 0:5fa30cf392c3 | 473 | |
oprospero | 0:5fa30cf392c3 | 474 | #define MAX_PACKET_LENGTH (32) |
oprospero | 0:5fa30cf392c3 | 475 | |
oprospero | 0:5fa30cf392c3 | 476 | #define DMP_SAMPLE_RATE (200) |
oprospero | 0:5fa30cf392c3 | 477 | #define GYRO_SF (46850825LL * 200 / DMP_SAMPLE_RATE) |
oprospero | 0:5fa30cf392c3 | 478 | |
oprospero | 0:5fa30cf392c3 | 479 | #define FIFO_CORRUPTION_CHECK |
oprospero | 0:5fa30cf392c3 | 480 | #ifdef FIFO_CORRUPTION_CHECK |
oprospero | 0:5fa30cf392c3 | 481 | #define QUAT_ERROR_THRESH (1L<<24) |
oprospero | 0:5fa30cf392c3 | 482 | #define QUAT_MAG_SQ_NORMALIZED (1L<<28) |
oprospero | 0:5fa30cf392c3 | 483 | #define QUAT_MAG_SQ_MIN (QUAT_MAG_SQ_NORMALIZED - QUAT_ERROR_THRESH) |
oprospero | 0:5fa30cf392c3 | 484 | #define QUAT_MAG_SQ_MAX (QUAT_MAG_SQ_NORMALIZED + QUAT_ERROR_THRESH) |
oprospero | 0:5fa30cf392c3 | 485 | #endif |
oprospero | 0:5fa30cf392c3 | 486 | |
oprospero | 0:5fa30cf392c3 | 487 | struct dmp_s { |
oprospero | 0:5fa30cf392c3 | 488 | void (*tap_cb)(unsigned char count, unsigned char direction); |
oprospero | 0:5fa30cf392c3 | 489 | void (*android_orient_cb)(unsigned char orientation); |
oprospero | 0:5fa30cf392c3 | 490 | unsigned short orient; |
oprospero | 0:5fa30cf392c3 | 491 | unsigned short feature_mask; |
oprospero | 0:5fa30cf392c3 | 492 | unsigned short fifo_rate; |
oprospero | 0:5fa30cf392c3 | 493 | unsigned char packet_length; |
oprospero | 0:5fa30cf392c3 | 494 | }; |
oprospero | 0:5fa30cf392c3 | 495 | |
oprospero | 0:5fa30cf392c3 | 496 | static struct dmp_s dmp = { |
oprospero | 0:5fa30cf392c3 | 497 | .tap_cb = NULL, |
oprospero | 0:5fa30cf392c3 | 498 | .android_orient_cb = NULL, |
oprospero | 0:5fa30cf392c3 | 499 | .orient = 0, |
oprospero | 0:5fa30cf392c3 | 500 | .feature_mask = 0, |
oprospero | 0:5fa30cf392c3 | 501 | .fifo_rate = 0, |
oprospero | 0:5fa30cf392c3 | 502 | .packet_length = 0 |
oprospero | 0:5fa30cf392c3 | 503 | }; |
oprospero | 0:5fa30cf392c3 | 504 | |
oprospero | 0:5fa30cf392c3 | 505 | /** |
oprospero | 0:5fa30cf392c3 | 506 | * @brief Load the DMP with this image. |
oprospero | 0:5fa30cf392c3 | 507 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 508 | */ |
oprospero | 0:5fa30cf392c3 | 509 | int dmp_load_motion_driver_firmware(void) |
oprospero | 0:5fa30cf392c3 | 510 | { |
oprospero | 0:5fa30cf392c3 | 511 | return mpu_load_firmware(DMP_CODE_SIZE, dmp_memory, sStartAddress, |
oprospero | 0:5fa30cf392c3 | 512 | DMP_SAMPLE_RATE); |
oprospero | 0:5fa30cf392c3 | 513 | } |
oprospero | 0:5fa30cf392c3 | 514 | |
oprospero | 0:5fa30cf392c3 | 515 | /** |
oprospero | 0:5fa30cf392c3 | 516 | * @brief Push gyro and accel orientation to the DMP. |
oprospero | 0:5fa30cf392c3 | 517 | * The orientation is represented here as the output of |
oprospero | 0:5fa30cf392c3 | 518 | * @e inv_orientation_matrix_to_scalar. |
oprospero | 0:5fa30cf392c3 | 519 | * @param[in] orient Gyro and accel orientation in body frame. |
oprospero | 0:5fa30cf392c3 | 520 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 521 | */ |
oprospero | 0:5fa30cf392c3 | 522 | int dmp_set_orientation(unsigned short orient) |
oprospero | 0:5fa30cf392c3 | 523 | { |
oprospero | 0:5fa30cf392c3 | 524 | unsigned char gyro_regs[3], accel_regs[3]; |
oprospero | 0:5fa30cf392c3 | 525 | const unsigned char gyro_axes[3] = {DINA4C, DINACD, DINA6C}; |
oprospero | 0:5fa30cf392c3 | 526 | const unsigned char accel_axes[3] = {DINA0C, DINAC9, DINA2C}; |
oprospero | 0:5fa30cf392c3 | 527 | const unsigned char gyro_sign[3] = {DINA36, DINA56, DINA76}; |
oprospero | 0:5fa30cf392c3 | 528 | const unsigned char accel_sign[3] = {DINA26, DINA46, DINA66}; |
oprospero | 0:5fa30cf392c3 | 529 | |
oprospero | 0:5fa30cf392c3 | 530 | gyro_regs[0] = gyro_axes[orient & 3]; |
oprospero | 0:5fa30cf392c3 | 531 | gyro_regs[1] = gyro_axes[(orient >> 3) & 3]; |
oprospero | 0:5fa30cf392c3 | 532 | gyro_regs[2] = gyro_axes[(orient >> 6) & 3]; |
oprospero | 0:5fa30cf392c3 | 533 | accel_regs[0] = accel_axes[orient & 3]; |
oprospero | 0:5fa30cf392c3 | 534 | accel_regs[1] = accel_axes[(orient >> 3) & 3]; |
oprospero | 0:5fa30cf392c3 | 535 | accel_regs[2] = accel_axes[(orient >> 6) & 3]; |
oprospero | 0:5fa30cf392c3 | 536 | |
oprospero | 0:5fa30cf392c3 | 537 | /* Chip-to-body, axes only. */ |
oprospero | 0:5fa30cf392c3 | 538 | if (mpu_write_mem(FCFG_1, 3, gyro_regs)) |
oprospero | 0:5fa30cf392c3 | 539 | return -1; |
oprospero | 0:5fa30cf392c3 | 540 | if (mpu_write_mem(FCFG_2, 3, accel_regs)) |
oprospero | 0:5fa30cf392c3 | 541 | return -1; |
oprospero | 0:5fa30cf392c3 | 542 | |
oprospero | 0:5fa30cf392c3 | 543 | memcpy(gyro_regs, gyro_sign, 3); |
oprospero | 0:5fa30cf392c3 | 544 | memcpy(accel_regs, accel_sign, 3); |
oprospero | 0:5fa30cf392c3 | 545 | if (orient & 4) { |
oprospero | 0:5fa30cf392c3 | 546 | gyro_regs[0] |= 1; |
oprospero | 0:5fa30cf392c3 | 547 | accel_regs[0] |= 1; |
oprospero | 0:5fa30cf392c3 | 548 | } |
oprospero | 0:5fa30cf392c3 | 549 | if (orient & 0x20) { |
oprospero | 0:5fa30cf392c3 | 550 | gyro_regs[1] |= 1; |
oprospero | 0:5fa30cf392c3 | 551 | accel_regs[1] |= 1; |
oprospero | 0:5fa30cf392c3 | 552 | } |
oprospero | 0:5fa30cf392c3 | 553 | if (orient & 0x100) { |
oprospero | 0:5fa30cf392c3 | 554 | gyro_regs[2] |= 1; |
oprospero | 0:5fa30cf392c3 | 555 | accel_regs[2] |= 1; |
oprospero | 0:5fa30cf392c3 | 556 | } |
oprospero | 0:5fa30cf392c3 | 557 | |
oprospero | 0:5fa30cf392c3 | 558 | /* Chip-to-body, sign only. */ |
oprospero | 0:5fa30cf392c3 | 559 | if (mpu_write_mem(FCFG_3, 3, gyro_regs)) |
oprospero | 0:5fa30cf392c3 | 560 | return -1; |
oprospero | 0:5fa30cf392c3 | 561 | if (mpu_write_mem(FCFG_7, 3, accel_regs)) |
oprospero | 0:5fa30cf392c3 | 562 | return -1; |
oprospero | 0:5fa30cf392c3 | 563 | dmp.orient = orient; |
oprospero | 0:5fa30cf392c3 | 564 | return 0; |
oprospero | 0:5fa30cf392c3 | 565 | } |
oprospero | 0:5fa30cf392c3 | 566 | |
oprospero | 0:5fa30cf392c3 | 567 | /** |
oprospero | 0:5fa30cf392c3 | 568 | * @brief Push gyro biases to the DMP. |
oprospero | 0:5fa30cf392c3 | 569 | * Because the gyro integration is handled in the DMP, any gyro biases |
oprospero | 0:5fa30cf392c3 | 570 | * calculated by the MPL should be pushed down to DMP memory to remove |
oprospero | 0:5fa30cf392c3 | 571 | * 3-axis quaternion drift. |
oprospero | 0:5fa30cf392c3 | 572 | * \n NOTE: If the DMP-based gyro calibration is enabled, the DMP will |
oprospero | 0:5fa30cf392c3 | 573 | * overwrite the biases written to this location once a new one is computed. |
oprospero | 0:5fa30cf392c3 | 574 | * @param[in] bias Gyro biases in q16. |
oprospero | 0:5fa30cf392c3 | 575 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 576 | */ |
oprospero | 0:5fa30cf392c3 | 577 | int dmp_set_gyro_bias(long *bias) |
oprospero | 0:5fa30cf392c3 | 578 | { |
oprospero | 0:5fa30cf392c3 | 579 | long gyro_bias_body[3]; |
oprospero | 0:5fa30cf392c3 | 580 | unsigned char regs[4]; |
oprospero | 0:5fa30cf392c3 | 581 | |
oprospero | 0:5fa30cf392c3 | 582 | gyro_bias_body[0] = bias[dmp.orient & 3]; |
oprospero | 0:5fa30cf392c3 | 583 | if (dmp.orient & 4) |
oprospero | 0:5fa30cf392c3 | 584 | gyro_bias_body[0] *= -1; |
oprospero | 0:5fa30cf392c3 | 585 | gyro_bias_body[1] = bias[(dmp.orient >> 3) & 3]; |
oprospero | 0:5fa30cf392c3 | 586 | if (dmp.orient & 0x20) |
oprospero | 0:5fa30cf392c3 | 587 | gyro_bias_body[1] *= -1; |
oprospero | 0:5fa30cf392c3 | 588 | gyro_bias_body[2] = bias[(dmp.orient >> 6) & 3]; |
oprospero | 0:5fa30cf392c3 | 589 | if (dmp.orient & 0x100) |
oprospero | 0:5fa30cf392c3 | 590 | gyro_bias_body[2] *= -1; |
oprospero | 0:5fa30cf392c3 | 591 | |
oprospero | 0:5fa30cf392c3 | 592 | #ifdef EMPL_NO_64BIT |
oprospero | 0:5fa30cf392c3 | 593 | gyro_bias_body[0] = (long)(((float)gyro_bias_body[0] * GYRO_SF) / 1073741824.f); |
oprospero | 0:5fa30cf392c3 | 594 | gyro_bias_body[1] = (long)(((float)gyro_bias_body[1] * GYRO_SF) / 1073741824.f); |
oprospero | 0:5fa30cf392c3 | 595 | gyro_bias_body[2] = (long)(((float)gyro_bias_body[2] * GYRO_SF) / 1073741824.f); |
oprospero | 0:5fa30cf392c3 | 596 | #else |
oprospero | 0:5fa30cf392c3 | 597 | gyro_bias_body[0] = (long)(((long long)gyro_bias_body[0] * GYRO_SF) >> 30); |
oprospero | 0:5fa30cf392c3 | 598 | gyro_bias_body[1] = (long)(((long long)gyro_bias_body[1] * GYRO_SF) >> 30); |
oprospero | 0:5fa30cf392c3 | 599 | gyro_bias_body[2] = (long)(((long long)gyro_bias_body[2] * GYRO_SF) >> 30); |
oprospero | 0:5fa30cf392c3 | 600 | #endif |
oprospero | 0:5fa30cf392c3 | 601 | |
oprospero | 0:5fa30cf392c3 | 602 | regs[0] = (unsigned char)((gyro_bias_body[0] >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 603 | regs[1] = (unsigned char)((gyro_bias_body[0] >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 604 | regs[2] = (unsigned char)((gyro_bias_body[0] >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 605 | regs[3] = (unsigned char)(gyro_bias_body[0] & 0xFF); |
oprospero | 0:5fa30cf392c3 | 606 | if (mpu_write_mem(D_EXT_GYRO_BIAS_X, 4, regs)) |
oprospero | 0:5fa30cf392c3 | 607 | return -1; |
oprospero | 0:5fa30cf392c3 | 608 | |
oprospero | 0:5fa30cf392c3 | 609 | regs[0] = (unsigned char)((gyro_bias_body[1] >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 610 | regs[1] = (unsigned char)((gyro_bias_body[1] >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 611 | regs[2] = (unsigned char)((gyro_bias_body[1] >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 612 | regs[3] = (unsigned char)(gyro_bias_body[1] & 0xFF); |
oprospero | 0:5fa30cf392c3 | 613 | if (mpu_write_mem(D_EXT_GYRO_BIAS_Y, 4, regs)) |
oprospero | 0:5fa30cf392c3 | 614 | return -1; |
oprospero | 0:5fa30cf392c3 | 615 | |
oprospero | 0:5fa30cf392c3 | 616 | regs[0] = (unsigned char)((gyro_bias_body[2] >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 617 | regs[1] = (unsigned char)((gyro_bias_body[2] >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 618 | regs[2] = (unsigned char)((gyro_bias_body[2] >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 619 | regs[3] = (unsigned char)(gyro_bias_body[2] & 0xFF); |
oprospero | 0:5fa30cf392c3 | 620 | return mpu_write_mem(D_EXT_GYRO_BIAS_Z, 4, regs); |
oprospero | 0:5fa30cf392c3 | 621 | } |
oprospero | 0:5fa30cf392c3 | 622 | |
oprospero | 0:5fa30cf392c3 | 623 | /** |
oprospero | 0:5fa30cf392c3 | 624 | * @brief Push accel biases to the DMP. |
oprospero | 0:5fa30cf392c3 | 625 | * These biases will be removed from the DMP 6-axis quaternion. |
oprospero | 0:5fa30cf392c3 | 626 | * @param[in] bias Accel biases in q16. |
oprospero | 0:5fa30cf392c3 | 627 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 628 | */ |
oprospero | 0:5fa30cf392c3 | 629 | int dmp_set_accel_bias(long *bias) |
oprospero | 0:5fa30cf392c3 | 630 | { |
oprospero | 0:5fa30cf392c3 | 631 | long accel_bias_body[3]; |
oprospero | 0:5fa30cf392c3 | 632 | unsigned char regs[12]; |
oprospero | 0:5fa30cf392c3 | 633 | long long accel_sf; |
oprospero | 0:5fa30cf392c3 | 634 | unsigned short accel_sens; |
oprospero | 0:5fa30cf392c3 | 635 | |
oprospero | 0:5fa30cf392c3 | 636 | mpu_get_accel_sens(&accel_sens); |
oprospero | 0:5fa30cf392c3 | 637 | accel_sf = (long long)accel_sens << 15; |
oprospero | 0:5fa30cf392c3 | 638 | __no_operation(); |
oprospero | 0:5fa30cf392c3 | 639 | |
oprospero | 0:5fa30cf392c3 | 640 | accel_bias_body[0] = bias[dmp.orient & 3]; |
oprospero | 0:5fa30cf392c3 | 641 | if (dmp.orient & 4) |
oprospero | 0:5fa30cf392c3 | 642 | accel_bias_body[0] *= -1; |
oprospero | 0:5fa30cf392c3 | 643 | accel_bias_body[1] = bias[(dmp.orient >> 3) & 3]; |
oprospero | 0:5fa30cf392c3 | 644 | if (dmp.orient & 0x20) |
oprospero | 0:5fa30cf392c3 | 645 | accel_bias_body[1] *= -1; |
oprospero | 0:5fa30cf392c3 | 646 | accel_bias_body[2] = bias[(dmp.orient >> 6) & 3]; |
oprospero | 0:5fa30cf392c3 | 647 | if (dmp.orient & 0x100) |
oprospero | 0:5fa30cf392c3 | 648 | accel_bias_body[2] *= -1; |
oprospero | 0:5fa30cf392c3 | 649 | |
oprospero | 0:5fa30cf392c3 | 650 | #ifdef EMPL_NO_64BIT |
oprospero | 0:5fa30cf392c3 | 651 | accel_bias_body[0] = (long)(((float)accel_bias_body[0] * accel_sf) / 1073741824.f); |
oprospero | 0:5fa30cf392c3 | 652 | accel_bias_body[1] = (long)(((float)accel_bias_body[1] * accel_sf) / 1073741824.f); |
oprospero | 0:5fa30cf392c3 | 653 | accel_bias_body[2] = (long)(((float)accel_bias_body[2] * accel_sf) / 1073741824.f); |
oprospero | 0:5fa30cf392c3 | 654 | #else |
oprospero | 0:5fa30cf392c3 | 655 | accel_bias_body[0] = (long)(((long long)accel_bias_body[0] * accel_sf) >> 30); |
oprospero | 0:5fa30cf392c3 | 656 | accel_bias_body[1] = (long)(((long long)accel_bias_body[1] * accel_sf) >> 30); |
oprospero | 0:5fa30cf392c3 | 657 | accel_bias_body[2] = (long)(((long long)accel_bias_body[2] * accel_sf) >> 30); |
oprospero | 0:5fa30cf392c3 | 658 | #endif |
oprospero | 0:5fa30cf392c3 | 659 | |
oprospero | 0:5fa30cf392c3 | 660 | regs[0] = (unsigned char)((accel_bias_body[0] >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 661 | regs[1] = (unsigned char)((accel_bias_body[0] >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 662 | regs[2] = (unsigned char)((accel_bias_body[0] >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 663 | regs[3] = (unsigned char)(accel_bias_body[0] & 0xFF); |
oprospero | 0:5fa30cf392c3 | 664 | regs[4] = (unsigned char)((accel_bias_body[1] >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 665 | regs[5] = (unsigned char)((accel_bias_body[1] >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 666 | regs[6] = (unsigned char)((accel_bias_body[1] >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 667 | regs[7] = (unsigned char)(accel_bias_body[1] & 0xFF); |
oprospero | 0:5fa30cf392c3 | 668 | regs[8] = (unsigned char)((accel_bias_body[2] >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 669 | regs[9] = (unsigned char)((accel_bias_body[2] >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 670 | regs[10] = (unsigned char)((accel_bias_body[2] >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 671 | regs[11] = (unsigned char)(accel_bias_body[2] & 0xFF); |
oprospero | 0:5fa30cf392c3 | 672 | return mpu_write_mem(D_ACCEL_BIAS, 12, regs); |
oprospero | 0:5fa30cf392c3 | 673 | } |
oprospero | 0:5fa30cf392c3 | 674 | |
oprospero | 0:5fa30cf392c3 | 675 | /** |
oprospero | 0:5fa30cf392c3 | 676 | * @brief Set DMP output rate. |
oprospero | 0:5fa30cf392c3 | 677 | * Only used when DMP is on. |
oprospero | 0:5fa30cf392c3 | 678 | * @param[in] rate Desired fifo rate (Hz). |
oprospero | 0:5fa30cf392c3 | 679 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 680 | */ |
oprospero | 0:5fa30cf392c3 | 681 | int dmp_set_fifo_rate(unsigned short rate) |
oprospero | 0:5fa30cf392c3 | 682 | { |
oprospero | 0:5fa30cf392c3 | 683 | const unsigned char regs_end[12] = {DINAFE, DINAF2, DINAAB, |
oprospero | 0:5fa30cf392c3 | 684 | 0xc4, DINAAA, DINAF1, DINADF, DINADF, 0xBB, 0xAF, DINADF, DINADF}; |
oprospero | 0:5fa30cf392c3 | 685 | unsigned short div; |
oprospero | 0:5fa30cf392c3 | 686 | unsigned char tmp[8]; |
oprospero | 0:5fa30cf392c3 | 687 | |
oprospero | 0:5fa30cf392c3 | 688 | if (rate > DMP_SAMPLE_RATE) |
oprospero | 0:5fa30cf392c3 | 689 | return -1; |
oprospero | 0:5fa30cf392c3 | 690 | div = DMP_SAMPLE_RATE / rate - 1; |
oprospero | 0:5fa30cf392c3 | 691 | tmp[0] = (unsigned char)((div >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 692 | tmp[1] = (unsigned char)(div & 0xFF); |
oprospero | 0:5fa30cf392c3 | 693 | if (mpu_write_mem(D_0_22, 2, tmp)) |
oprospero | 0:5fa30cf392c3 | 694 | return -1; |
oprospero | 0:5fa30cf392c3 | 695 | if (mpu_write_mem(CFG_6, 12, (unsigned char*)regs_end)) |
oprospero | 0:5fa30cf392c3 | 696 | return -1; |
oprospero | 0:5fa30cf392c3 | 697 | |
oprospero | 0:5fa30cf392c3 | 698 | dmp.fifo_rate = rate; |
oprospero | 0:5fa30cf392c3 | 699 | return 0; |
oprospero | 0:5fa30cf392c3 | 700 | } |
oprospero | 0:5fa30cf392c3 | 701 | |
oprospero | 0:5fa30cf392c3 | 702 | /** |
oprospero | 0:5fa30cf392c3 | 703 | * @brief Get DMP output rate. |
oprospero | 0:5fa30cf392c3 | 704 | * @param[out] rate Current fifo rate (Hz). |
oprospero | 0:5fa30cf392c3 | 705 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 706 | */ |
oprospero | 0:5fa30cf392c3 | 707 | int dmp_get_fifo_rate(unsigned short *rate) |
oprospero | 0:5fa30cf392c3 | 708 | { |
oprospero | 0:5fa30cf392c3 | 709 | rate[0] = dmp.fifo_rate; |
oprospero | 0:5fa30cf392c3 | 710 | return 0; |
oprospero | 0:5fa30cf392c3 | 711 | } |
oprospero | 0:5fa30cf392c3 | 712 | |
oprospero | 0:5fa30cf392c3 | 713 | /** |
oprospero | 0:5fa30cf392c3 | 714 | * @brief Set tap threshold for a specific axis. |
oprospero | 0:5fa30cf392c3 | 715 | * @param[in] axis 1, 2, and 4 for XYZ accel, respectively. |
oprospero | 0:5fa30cf392c3 | 716 | * @param[in] thresh Tap threshold, in mg/ms. |
oprospero | 0:5fa30cf392c3 | 717 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 718 | */ |
oprospero | 0:5fa30cf392c3 | 719 | int dmp_set_tap_thresh(unsigned char axis, unsigned short thresh) |
oprospero | 0:5fa30cf392c3 | 720 | { |
oprospero | 0:5fa30cf392c3 | 721 | unsigned char tmp[4], accel_fsr; |
oprospero | 0:5fa30cf392c3 | 722 | float scaled_thresh; |
oprospero | 0:5fa30cf392c3 | 723 | unsigned short dmp_thresh, dmp_thresh_2; |
oprospero | 0:5fa30cf392c3 | 724 | if (!(axis & TAP_XYZ) || thresh > 1600) |
oprospero | 0:5fa30cf392c3 | 725 | return -1; |
oprospero | 0:5fa30cf392c3 | 726 | |
oprospero | 0:5fa30cf392c3 | 727 | scaled_thresh = (float)thresh / DMP_SAMPLE_RATE; |
oprospero | 0:5fa30cf392c3 | 728 | |
oprospero | 0:5fa30cf392c3 | 729 | mpu_get_accel_fsr(&accel_fsr); |
oprospero | 0:5fa30cf392c3 | 730 | switch (accel_fsr) { |
oprospero | 0:5fa30cf392c3 | 731 | case 2: |
oprospero | 0:5fa30cf392c3 | 732 | dmp_thresh = (unsigned short)(scaled_thresh * 16384); |
oprospero | 0:5fa30cf392c3 | 733 | /* dmp_thresh * 0.75 */ |
oprospero | 0:5fa30cf392c3 | 734 | dmp_thresh_2 = (unsigned short)(scaled_thresh * 12288); |
oprospero | 0:5fa30cf392c3 | 735 | break; |
oprospero | 0:5fa30cf392c3 | 736 | case 4: |
oprospero | 0:5fa30cf392c3 | 737 | dmp_thresh = (unsigned short)(scaled_thresh * 8192); |
oprospero | 0:5fa30cf392c3 | 738 | /* dmp_thresh * 0.75 */ |
oprospero | 0:5fa30cf392c3 | 739 | dmp_thresh_2 = (unsigned short)(scaled_thresh * 6144); |
oprospero | 0:5fa30cf392c3 | 740 | break; |
oprospero | 0:5fa30cf392c3 | 741 | case 8: |
oprospero | 0:5fa30cf392c3 | 742 | dmp_thresh = (unsigned short)(scaled_thresh * 4096); |
oprospero | 0:5fa30cf392c3 | 743 | /* dmp_thresh * 0.75 */ |
oprospero | 0:5fa30cf392c3 | 744 | dmp_thresh_2 = (unsigned short)(scaled_thresh * 3072); |
oprospero | 0:5fa30cf392c3 | 745 | break; |
oprospero | 0:5fa30cf392c3 | 746 | case 16: |
oprospero | 0:5fa30cf392c3 | 747 | dmp_thresh = (unsigned short)(scaled_thresh * 2048); |
oprospero | 0:5fa30cf392c3 | 748 | /* dmp_thresh * 0.75 */ |
oprospero | 0:5fa30cf392c3 | 749 | dmp_thresh_2 = (unsigned short)(scaled_thresh * 1536); |
oprospero | 0:5fa30cf392c3 | 750 | break; |
oprospero | 0:5fa30cf392c3 | 751 | default: |
oprospero | 0:5fa30cf392c3 | 752 | return -1; |
oprospero | 0:5fa30cf392c3 | 753 | } |
oprospero | 0:5fa30cf392c3 | 754 | tmp[0] = (unsigned char)(dmp_thresh >> 8); |
oprospero | 0:5fa30cf392c3 | 755 | tmp[1] = (unsigned char)(dmp_thresh & 0xFF); |
oprospero | 0:5fa30cf392c3 | 756 | tmp[2] = (unsigned char)(dmp_thresh_2 >> 8); |
oprospero | 0:5fa30cf392c3 | 757 | tmp[3] = (unsigned char)(dmp_thresh_2 & 0xFF); |
oprospero | 0:5fa30cf392c3 | 758 | |
oprospero | 0:5fa30cf392c3 | 759 | if (axis & TAP_X) { |
oprospero | 0:5fa30cf392c3 | 760 | if (mpu_write_mem(DMP_TAP_THX, 2, tmp)) |
oprospero | 0:5fa30cf392c3 | 761 | return -1; |
oprospero | 0:5fa30cf392c3 | 762 | if (mpu_write_mem(D_1_36, 2, tmp+2)) |
oprospero | 0:5fa30cf392c3 | 763 | return -1; |
oprospero | 0:5fa30cf392c3 | 764 | } |
oprospero | 0:5fa30cf392c3 | 765 | if (axis & TAP_Y) { |
oprospero | 0:5fa30cf392c3 | 766 | if (mpu_write_mem(DMP_TAP_THY, 2, tmp)) |
oprospero | 0:5fa30cf392c3 | 767 | return -1; |
oprospero | 0:5fa30cf392c3 | 768 | if (mpu_write_mem(D_1_40, 2, tmp+2)) |
oprospero | 0:5fa30cf392c3 | 769 | return -1; |
oprospero | 0:5fa30cf392c3 | 770 | } |
oprospero | 0:5fa30cf392c3 | 771 | if (axis & TAP_Z) { |
oprospero | 0:5fa30cf392c3 | 772 | if (mpu_write_mem(DMP_TAP_THZ, 2, tmp)) |
oprospero | 0:5fa30cf392c3 | 773 | return -1; |
oprospero | 0:5fa30cf392c3 | 774 | if (mpu_write_mem(D_1_44, 2, tmp+2)) |
oprospero | 0:5fa30cf392c3 | 775 | return -1; |
oprospero | 0:5fa30cf392c3 | 776 | } |
oprospero | 0:5fa30cf392c3 | 777 | return 0; |
oprospero | 0:5fa30cf392c3 | 778 | } |
oprospero | 0:5fa30cf392c3 | 779 | |
oprospero | 0:5fa30cf392c3 | 780 | /** |
oprospero | 0:5fa30cf392c3 | 781 | * @brief Set which axes will register a tap. |
oprospero | 0:5fa30cf392c3 | 782 | * @param[in] axis 1, 2, and 4 for XYZ, respectively. |
oprospero | 0:5fa30cf392c3 | 783 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 784 | */ |
oprospero | 0:5fa30cf392c3 | 785 | int dmp_set_tap_axes(unsigned char axis) |
oprospero | 0:5fa30cf392c3 | 786 | { |
oprospero | 0:5fa30cf392c3 | 787 | unsigned char tmp = 0; |
oprospero | 0:5fa30cf392c3 | 788 | |
oprospero | 0:5fa30cf392c3 | 789 | if (axis & TAP_X) |
oprospero | 0:5fa30cf392c3 | 790 | tmp |= 0x30; |
oprospero | 0:5fa30cf392c3 | 791 | if (axis & TAP_Y) |
oprospero | 0:5fa30cf392c3 | 792 | tmp |= 0x0C; |
oprospero | 0:5fa30cf392c3 | 793 | if (axis & TAP_Z) |
oprospero | 0:5fa30cf392c3 | 794 | tmp |= 0x03; |
oprospero | 0:5fa30cf392c3 | 795 | return mpu_write_mem(D_1_72, 1, &tmp); |
oprospero | 0:5fa30cf392c3 | 796 | } |
oprospero | 0:5fa30cf392c3 | 797 | |
oprospero | 0:5fa30cf392c3 | 798 | /** |
oprospero | 0:5fa30cf392c3 | 799 | * @brief Set minimum number of taps needed for an interrupt. |
oprospero | 0:5fa30cf392c3 | 800 | * @param[in] min_taps Minimum consecutive taps (1-4). |
oprospero | 0:5fa30cf392c3 | 801 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 802 | */ |
oprospero | 0:5fa30cf392c3 | 803 | int dmp_set_tap_count(unsigned char min_taps) |
oprospero | 0:5fa30cf392c3 | 804 | { |
oprospero | 0:5fa30cf392c3 | 805 | unsigned char tmp; |
oprospero | 0:5fa30cf392c3 | 806 | |
oprospero | 0:5fa30cf392c3 | 807 | if (min_taps < 1) |
oprospero | 0:5fa30cf392c3 | 808 | min_taps = 1; |
oprospero | 0:5fa30cf392c3 | 809 | else if (min_taps > 4) |
oprospero | 0:5fa30cf392c3 | 810 | min_taps = 4; |
oprospero | 0:5fa30cf392c3 | 811 | |
oprospero | 0:5fa30cf392c3 | 812 | tmp = min_taps - 1; |
oprospero | 0:5fa30cf392c3 | 813 | return mpu_write_mem(D_1_79, 1, &tmp); |
oprospero | 0:5fa30cf392c3 | 814 | } |
oprospero | 0:5fa30cf392c3 | 815 | |
oprospero | 0:5fa30cf392c3 | 816 | /** |
oprospero | 0:5fa30cf392c3 | 817 | * @brief Set length between valid taps. |
oprospero | 0:5fa30cf392c3 | 818 | * @param[in] time Milliseconds between taps. |
oprospero | 0:5fa30cf392c3 | 819 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 820 | */ |
oprospero | 0:5fa30cf392c3 | 821 | int dmp_set_tap_time(unsigned short time) |
oprospero | 0:5fa30cf392c3 | 822 | { |
oprospero | 0:5fa30cf392c3 | 823 | unsigned short dmp_time; |
oprospero | 0:5fa30cf392c3 | 824 | unsigned char tmp[2]; |
oprospero | 0:5fa30cf392c3 | 825 | |
oprospero | 0:5fa30cf392c3 | 826 | dmp_time = time / (1000 / DMP_SAMPLE_RATE); |
oprospero | 0:5fa30cf392c3 | 827 | tmp[0] = (unsigned char)(dmp_time >> 8); |
oprospero | 0:5fa30cf392c3 | 828 | tmp[1] = (unsigned char)(dmp_time & 0xFF); |
oprospero | 0:5fa30cf392c3 | 829 | return mpu_write_mem(DMP_TAPW_MIN, 2, tmp); |
oprospero | 0:5fa30cf392c3 | 830 | } |
oprospero | 0:5fa30cf392c3 | 831 | |
oprospero | 0:5fa30cf392c3 | 832 | /** |
oprospero | 0:5fa30cf392c3 | 833 | * @brief Set max time between taps to register as a multi-tap. |
oprospero | 0:5fa30cf392c3 | 834 | * @param[in] time Max milliseconds between taps. |
oprospero | 0:5fa30cf392c3 | 835 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 836 | */ |
oprospero | 0:5fa30cf392c3 | 837 | int dmp_set_tap_time_multi(unsigned short time) |
oprospero | 0:5fa30cf392c3 | 838 | { |
oprospero | 0:5fa30cf392c3 | 839 | unsigned short dmp_time; |
oprospero | 0:5fa30cf392c3 | 840 | unsigned char tmp[2]; |
oprospero | 0:5fa30cf392c3 | 841 | |
oprospero | 0:5fa30cf392c3 | 842 | dmp_time = time / (1000 / DMP_SAMPLE_RATE); |
oprospero | 0:5fa30cf392c3 | 843 | tmp[0] = (unsigned char)(dmp_time >> 8); |
oprospero | 0:5fa30cf392c3 | 844 | tmp[1] = (unsigned char)(dmp_time & 0xFF); |
oprospero | 0:5fa30cf392c3 | 845 | return mpu_write_mem(D_1_218, 2, tmp); |
oprospero | 0:5fa30cf392c3 | 846 | } |
oprospero | 0:5fa30cf392c3 | 847 | |
oprospero | 0:5fa30cf392c3 | 848 | /** |
oprospero | 0:5fa30cf392c3 | 849 | * @brief Set shake rejection threshold. |
oprospero | 0:5fa30cf392c3 | 850 | * If the DMP detects a gyro sample larger than @e thresh, taps are rejected. |
oprospero | 0:5fa30cf392c3 | 851 | * @param[in] sf Gyro scale factor. |
oprospero | 0:5fa30cf392c3 | 852 | * @param[in] thresh Gyro threshold in dps. |
oprospero | 0:5fa30cf392c3 | 853 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 854 | */ |
oprospero | 0:5fa30cf392c3 | 855 | int dmp_set_shake_reject_thresh(long sf, unsigned short thresh) |
oprospero | 0:5fa30cf392c3 | 856 | { |
oprospero | 0:5fa30cf392c3 | 857 | unsigned char tmp[4]; |
oprospero | 0:5fa30cf392c3 | 858 | long thresh_scaled = sf / 1000 * thresh; |
oprospero | 0:5fa30cf392c3 | 859 | tmp[0] = (unsigned char)(((long)thresh_scaled >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 860 | tmp[1] = (unsigned char)(((long)thresh_scaled >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 861 | tmp[2] = (unsigned char)(((long)thresh_scaled >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 862 | tmp[3] = (unsigned char)((long)thresh_scaled & 0xFF); |
oprospero | 0:5fa30cf392c3 | 863 | return mpu_write_mem(D_1_92, 4, tmp); |
oprospero | 0:5fa30cf392c3 | 864 | } |
oprospero | 0:5fa30cf392c3 | 865 | |
oprospero | 0:5fa30cf392c3 | 866 | /** |
oprospero | 0:5fa30cf392c3 | 867 | * @brief Set shake rejection time. |
oprospero | 0:5fa30cf392c3 | 868 | * Sets the length of time that the gyro must be outside of the threshold set |
oprospero | 0:5fa30cf392c3 | 869 | * by @e gyro_set_shake_reject_thresh before taps are rejected. A mandatory |
oprospero | 0:5fa30cf392c3 | 870 | * 60 ms is added to this parameter. |
oprospero | 0:5fa30cf392c3 | 871 | * @param[in] time Time in milliseconds. |
oprospero | 0:5fa30cf392c3 | 872 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 873 | */ |
oprospero | 0:5fa30cf392c3 | 874 | int dmp_set_shake_reject_time(unsigned short time) |
oprospero | 0:5fa30cf392c3 | 875 | { |
oprospero | 0:5fa30cf392c3 | 876 | unsigned char tmp[2]; |
oprospero | 0:5fa30cf392c3 | 877 | |
oprospero | 0:5fa30cf392c3 | 878 | time /= (1000 / DMP_SAMPLE_RATE); |
oprospero | 0:5fa30cf392c3 | 879 | tmp[0] = time >> 8; |
oprospero | 0:5fa30cf392c3 | 880 | tmp[1] = time & 0xFF; |
oprospero | 0:5fa30cf392c3 | 881 | return mpu_write_mem(D_1_90,2,tmp); |
oprospero | 0:5fa30cf392c3 | 882 | } |
oprospero | 0:5fa30cf392c3 | 883 | |
oprospero | 0:5fa30cf392c3 | 884 | /** |
oprospero | 0:5fa30cf392c3 | 885 | * @brief Set shake rejection timeout. |
oprospero | 0:5fa30cf392c3 | 886 | * Sets the length of time after a shake rejection that the gyro must stay |
oprospero | 0:5fa30cf392c3 | 887 | * inside of the threshold before taps can be detected again. A mandatory |
oprospero | 0:5fa30cf392c3 | 888 | * 60 ms is added to this parameter. |
oprospero | 0:5fa30cf392c3 | 889 | * @param[in] time Time in milliseconds. |
oprospero | 0:5fa30cf392c3 | 890 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 891 | */ |
oprospero | 0:5fa30cf392c3 | 892 | int dmp_set_shake_reject_timeout(unsigned short time) |
oprospero | 0:5fa30cf392c3 | 893 | { |
oprospero | 0:5fa30cf392c3 | 894 | unsigned char tmp[2]; |
oprospero | 0:5fa30cf392c3 | 895 | |
oprospero | 0:5fa30cf392c3 | 896 | time /= (1000 / DMP_SAMPLE_RATE); |
oprospero | 0:5fa30cf392c3 | 897 | tmp[0] = time >> 8; |
oprospero | 0:5fa30cf392c3 | 898 | tmp[1] = time & 0xFF; |
oprospero | 0:5fa30cf392c3 | 899 | return mpu_write_mem(D_1_88,2,tmp); |
oprospero | 0:5fa30cf392c3 | 900 | } |
oprospero | 0:5fa30cf392c3 | 901 | |
oprospero | 0:5fa30cf392c3 | 902 | /** |
oprospero | 0:5fa30cf392c3 | 903 | * @brief Get current step count. |
oprospero | 0:5fa30cf392c3 | 904 | * @param[out] count Number of steps detected. |
oprospero | 0:5fa30cf392c3 | 905 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 906 | */ |
oprospero | 0:5fa30cf392c3 | 907 | int dmp_get_pedometer_step_count(unsigned long *count) |
oprospero | 0:5fa30cf392c3 | 908 | { |
oprospero | 0:5fa30cf392c3 | 909 | unsigned char tmp[4]; |
oprospero | 0:5fa30cf392c3 | 910 | if (!count) |
oprospero | 0:5fa30cf392c3 | 911 | return -1; |
oprospero | 0:5fa30cf392c3 | 912 | |
oprospero | 0:5fa30cf392c3 | 913 | if (mpu_read_mem(D_PEDSTD_STEPCTR, 4, tmp)) |
oprospero | 0:5fa30cf392c3 | 914 | return -1; |
oprospero | 0:5fa30cf392c3 | 915 | |
oprospero | 0:5fa30cf392c3 | 916 | count[0] = ((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) | |
oprospero | 0:5fa30cf392c3 | 917 | ((unsigned long)tmp[2] << 8) | tmp[3]; |
oprospero | 0:5fa30cf392c3 | 918 | return 0; |
oprospero | 0:5fa30cf392c3 | 919 | } |
oprospero | 0:5fa30cf392c3 | 920 | |
oprospero | 0:5fa30cf392c3 | 921 | /** |
oprospero | 0:5fa30cf392c3 | 922 | * @brief Overwrite current step count. |
oprospero | 0:5fa30cf392c3 | 923 | * WARNING: This function writes to DMP memory and could potentially encounter |
oprospero | 0:5fa30cf392c3 | 924 | * a race condition if called while the pedometer is enabled. |
oprospero | 0:5fa30cf392c3 | 925 | * @param[in] count New step count. |
oprospero | 0:5fa30cf392c3 | 926 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 927 | */ |
oprospero | 0:5fa30cf392c3 | 928 | int dmp_set_pedometer_step_count(unsigned long count) |
oprospero | 0:5fa30cf392c3 | 929 | { |
oprospero | 0:5fa30cf392c3 | 930 | unsigned char tmp[4]; |
oprospero | 0:5fa30cf392c3 | 931 | |
oprospero | 0:5fa30cf392c3 | 932 | tmp[0] = (unsigned char)((count >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 933 | tmp[1] = (unsigned char)((count >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 934 | tmp[2] = (unsigned char)((count >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 935 | tmp[3] = (unsigned char)(count & 0xFF); |
oprospero | 0:5fa30cf392c3 | 936 | return mpu_write_mem(D_PEDSTD_STEPCTR, 4, tmp); |
oprospero | 0:5fa30cf392c3 | 937 | } |
oprospero | 0:5fa30cf392c3 | 938 | |
oprospero | 0:5fa30cf392c3 | 939 | /** |
oprospero | 0:5fa30cf392c3 | 940 | * @brief Get duration of walking time. |
oprospero | 0:5fa30cf392c3 | 941 | * @param[in] time Walk time in milliseconds. |
oprospero | 0:5fa30cf392c3 | 942 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 943 | */ |
oprospero | 0:5fa30cf392c3 | 944 | int dmp_get_pedometer_walk_time(unsigned long *time) |
oprospero | 0:5fa30cf392c3 | 945 | { |
oprospero | 0:5fa30cf392c3 | 946 | unsigned char tmp[4]; |
oprospero | 0:5fa30cf392c3 | 947 | if (!time) |
oprospero | 0:5fa30cf392c3 | 948 | return -1; |
oprospero | 0:5fa30cf392c3 | 949 | |
oprospero | 0:5fa30cf392c3 | 950 | if (mpu_read_mem(D_PEDSTD_TIMECTR, 4, tmp)) |
oprospero | 0:5fa30cf392c3 | 951 | return -1; |
oprospero | 0:5fa30cf392c3 | 952 | |
oprospero | 0:5fa30cf392c3 | 953 | time[0] = (((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) | |
oprospero | 0:5fa30cf392c3 | 954 | ((unsigned long)tmp[2] << 8) | tmp[3]) * 20; |
oprospero | 0:5fa30cf392c3 | 955 | return 0; |
oprospero | 0:5fa30cf392c3 | 956 | } |
oprospero | 0:5fa30cf392c3 | 957 | |
oprospero | 0:5fa30cf392c3 | 958 | /** |
oprospero | 0:5fa30cf392c3 | 959 | * @brief Overwrite current walk time. |
oprospero | 0:5fa30cf392c3 | 960 | * WARNING: This function writes to DMP memory and could potentially encounter |
oprospero | 0:5fa30cf392c3 | 961 | * a race condition if called while the pedometer is enabled. |
oprospero | 0:5fa30cf392c3 | 962 | * @param[in] time New walk time in milliseconds. |
oprospero | 0:5fa30cf392c3 | 963 | */ |
oprospero | 0:5fa30cf392c3 | 964 | int dmp_set_pedometer_walk_time(unsigned long time) |
oprospero | 0:5fa30cf392c3 | 965 | { |
oprospero | 0:5fa30cf392c3 | 966 | unsigned char tmp[4]; |
oprospero | 0:5fa30cf392c3 | 967 | |
oprospero | 0:5fa30cf392c3 | 968 | time /= 20; |
oprospero | 0:5fa30cf392c3 | 969 | |
oprospero | 0:5fa30cf392c3 | 970 | tmp[0] = (unsigned char)((time >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 971 | tmp[1] = (unsigned char)((time >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 972 | tmp[2] = (unsigned char)((time >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 973 | tmp[3] = (unsigned char)(time & 0xFF); |
oprospero | 0:5fa30cf392c3 | 974 | return mpu_write_mem(D_PEDSTD_TIMECTR, 4, tmp); |
oprospero | 0:5fa30cf392c3 | 975 | } |
oprospero | 0:5fa30cf392c3 | 976 | |
oprospero | 0:5fa30cf392c3 | 977 | /** |
oprospero | 0:5fa30cf392c3 | 978 | * @brief Enable DMP features. |
oprospero | 0:5fa30cf392c3 | 979 | * The following \#define's are used in the input mask: |
oprospero | 0:5fa30cf392c3 | 980 | * \n DMP_FEATURE_TAP |
oprospero | 0:5fa30cf392c3 | 981 | * \n DMP_FEATURE_ANDROID_ORIENT |
oprospero | 0:5fa30cf392c3 | 982 | * \n DMP_FEATURE_LP_QUAT |
oprospero | 0:5fa30cf392c3 | 983 | * \n DMP_FEATURE_6X_LP_QUAT |
oprospero | 0:5fa30cf392c3 | 984 | * \n DMP_FEATURE_GYRO_CAL |
oprospero | 0:5fa30cf392c3 | 985 | * \n DMP_FEATURE_SEND_RAW_ACCEL |
oprospero | 0:5fa30cf392c3 | 986 | * \n DMP_FEATURE_SEND_RAW_GYRO |
oprospero | 0:5fa30cf392c3 | 987 | * \n NOTE: DMP_FEATURE_LP_QUAT and DMP_FEATURE_6X_LP_QUAT are mutually |
oprospero | 0:5fa30cf392c3 | 988 | * exclusive. |
oprospero | 0:5fa30cf392c3 | 989 | * \n NOTE: DMP_FEATURE_SEND_RAW_GYRO and DMP_FEATURE_SEND_CAL_GYRO are also |
oprospero | 0:5fa30cf392c3 | 990 | * mutually exclusive. |
oprospero | 0:5fa30cf392c3 | 991 | * @param[in] mask Mask of features to enable. |
oprospero | 0:5fa30cf392c3 | 992 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 993 | */ |
oprospero | 0:5fa30cf392c3 | 994 | int dmp_enable_feature(unsigned short mask) |
oprospero | 0:5fa30cf392c3 | 995 | { |
oprospero | 0:5fa30cf392c3 | 996 | unsigned char tmp[10]; |
oprospero | 0:5fa30cf392c3 | 997 | |
oprospero | 0:5fa30cf392c3 | 998 | /* TODO: All of these settings can probably be integrated into the default |
oprospero | 0:5fa30cf392c3 | 999 | * DMP image. |
oprospero | 0:5fa30cf392c3 | 1000 | */ |
oprospero | 0:5fa30cf392c3 | 1001 | /* Set integration scale factor. */ |
oprospero | 0:5fa30cf392c3 | 1002 | tmp[0] = (unsigned char)((GYRO_SF >> 24) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 1003 | tmp[1] = (unsigned char)((GYRO_SF >> 16) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 1004 | tmp[2] = (unsigned char)((GYRO_SF >> 8) & 0xFF); |
oprospero | 0:5fa30cf392c3 | 1005 | tmp[3] = (unsigned char)(GYRO_SF & 0xFF); |
oprospero | 0:5fa30cf392c3 | 1006 | mpu_write_mem(D_0_104, 4, tmp); |
oprospero | 0:5fa30cf392c3 | 1007 | |
oprospero | 0:5fa30cf392c3 | 1008 | /* Send sensor data to the FIFO. */ |
oprospero | 0:5fa30cf392c3 | 1009 | tmp[0] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1010 | if (mask & DMP_FEATURE_SEND_RAW_ACCEL) { |
oprospero | 0:5fa30cf392c3 | 1011 | tmp[1] = 0xC0; |
oprospero | 0:5fa30cf392c3 | 1012 | tmp[2] = 0xC8; |
oprospero | 0:5fa30cf392c3 | 1013 | tmp[3] = 0xC2; |
oprospero | 0:5fa30cf392c3 | 1014 | } else { |
oprospero | 0:5fa30cf392c3 | 1015 | tmp[1] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1016 | tmp[2] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1017 | tmp[3] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1018 | } |
oprospero | 0:5fa30cf392c3 | 1019 | if (mask & DMP_FEATURE_SEND_ANY_GYRO) { |
oprospero | 0:5fa30cf392c3 | 1020 | tmp[4] = 0xC4; |
oprospero | 0:5fa30cf392c3 | 1021 | tmp[5] = 0xCC; |
oprospero | 0:5fa30cf392c3 | 1022 | tmp[6] = 0xC6; |
oprospero | 0:5fa30cf392c3 | 1023 | } else { |
oprospero | 0:5fa30cf392c3 | 1024 | tmp[4] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1025 | tmp[5] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1026 | tmp[6] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1027 | } |
oprospero | 0:5fa30cf392c3 | 1028 | tmp[7] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1029 | tmp[8] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1030 | tmp[9] = 0xA3; |
oprospero | 0:5fa30cf392c3 | 1031 | mpu_write_mem(CFG_15,10,tmp); |
oprospero | 0:5fa30cf392c3 | 1032 | |
oprospero | 0:5fa30cf392c3 | 1033 | /* Send gesture data to the FIFO. */ |
oprospero | 0:5fa30cf392c3 | 1034 | if (mask & (DMP_FEATURE_TAP | DMP_FEATURE_ANDROID_ORIENT)) |
oprospero | 0:5fa30cf392c3 | 1035 | tmp[0] = DINA20; |
oprospero | 0:5fa30cf392c3 | 1036 | else |
oprospero | 0:5fa30cf392c3 | 1037 | tmp[0] = 0xD8; |
oprospero | 0:5fa30cf392c3 | 1038 | mpu_write_mem(CFG_27,1,tmp); |
oprospero | 0:5fa30cf392c3 | 1039 | |
oprospero | 0:5fa30cf392c3 | 1040 | if (mask & DMP_FEATURE_GYRO_CAL) |
oprospero | 0:5fa30cf392c3 | 1041 | dmp_enable_gyro_cal(1); |
oprospero | 0:5fa30cf392c3 | 1042 | else |
oprospero | 0:5fa30cf392c3 | 1043 | dmp_enable_gyro_cal(0); |
oprospero | 0:5fa30cf392c3 | 1044 | |
oprospero | 0:5fa30cf392c3 | 1045 | if (mask & DMP_FEATURE_SEND_ANY_GYRO) { |
oprospero | 0:5fa30cf392c3 | 1046 | if (mask & DMP_FEATURE_SEND_CAL_GYRO) { |
oprospero | 0:5fa30cf392c3 | 1047 | tmp[0] = 0xB2; |
oprospero | 0:5fa30cf392c3 | 1048 | tmp[1] = 0x8B; |
oprospero | 0:5fa30cf392c3 | 1049 | tmp[2] = 0xB6; |
oprospero | 0:5fa30cf392c3 | 1050 | tmp[3] = 0x9B; |
oprospero | 0:5fa30cf392c3 | 1051 | } else { |
oprospero | 0:5fa30cf392c3 | 1052 | tmp[0] = DINAC0; |
oprospero | 0:5fa30cf392c3 | 1053 | tmp[1] = DINA80; |
oprospero | 0:5fa30cf392c3 | 1054 | tmp[2] = DINAC2; |
oprospero | 0:5fa30cf392c3 | 1055 | tmp[3] = DINA90; |
oprospero | 0:5fa30cf392c3 | 1056 | } |
oprospero | 0:5fa30cf392c3 | 1057 | mpu_write_mem(CFG_GYRO_RAW_DATA, 4, tmp); |
oprospero | 0:5fa30cf392c3 | 1058 | } |
oprospero | 0:5fa30cf392c3 | 1059 | |
oprospero | 0:5fa30cf392c3 | 1060 | if (mask & DMP_FEATURE_TAP) { |
oprospero | 0:5fa30cf392c3 | 1061 | /* Enable tap. */ |
oprospero | 0:5fa30cf392c3 | 1062 | tmp[0] = 0xF8; |
oprospero | 0:5fa30cf392c3 | 1063 | mpu_write_mem(CFG_20, 1, tmp); |
oprospero | 0:5fa30cf392c3 | 1064 | dmp_set_tap_thresh(TAP_XYZ, 250); |
oprospero | 0:5fa30cf392c3 | 1065 | dmp_set_tap_axes(TAP_XYZ); |
oprospero | 0:5fa30cf392c3 | 1066 | dmp_set_tap_count(1); |
oprospero | 0:5fa30cf392c3 | 1067 | dmp_set_tap_time(100); |
oprospero | 0:5fa30cf392c3 | 1068 | dmp_set_tap_time_multi(500); |
oprospero | 0:5fa30cf392c3 | 1069 | |
oprospero | 0:5fa30cf392c3 | 1070 | dmp_set_shake_reject_thresh(GYRO_SF, 200); |
oprospero | 0:5fa30cf392c3 | 1071 | dmp_set_shake_reject_time(40); |
oprospero | 0:5fa30cf392c3 | 1072 | dmp_set_shake_reject_timeout(10); |
oprospero | 0:5fa30cf392c3 | 1073 | } else { |
oprospero | 0:5fa30cf392c3 | 1074 | tmp[0] = 0xD8; |
oprospero | 0:5fa30cf392c3 | 1075 | mpu_write_mem(CFG_20, 1, tmp); |
oprospero | 0:5fa30cf392c3 | 1076 | } |
oprospero | 0:5fa30cf392c3 | 1077 | |
oprospero | 0:5fa30cf392c3 | 1078 | if (mask & DMP_FEATURE_ANDROID_ORIENT) { |
oprospero | 0:5fa30cf392c3 | 1079 | tmp[0] = 0xD9; |
oprospero | 0:5fa30cf392c3 | 1080 | } else |
oprospero | 0:5fa30cf392c3 | 1081 | tmp[0] = 0xD8; |
oprospero | 0:5fa30cf392c3 | 1082 | mpu_write_mem(CFG_ANDROID_ORIENT_INT, 1, tmp); |
oprospero | 0:5fa30cf392c3 | 1083 | |
oprospero | 0:5fa30cf392c3 | 1084 | if (mask & DMP_FEATURE_LP_QUAT) |
oprospero | 0:5fa30cf392c3 | 1085 | dmp_enable_lp_quat(1); |
oprospero | 0:5fa30cf392c3 | 1086 | else |
oprospero | 0:5fa30cf392c3 | 1087 | dmp_enable_lp_quat(0); |
oprospero | 0:5fa30cf392c3 | 1088 | |
oprospero | 0:5fa30cf392c3 | 1089 | if (mask & DMP_FEATURE_6X_LP_QUAT) |
oprospero | 0:5fa30cf392c3 | 1090 | dmp_enable_6x_lp_quat(1); |
oprospero | 0:5fa30cf392c3 | 1091 | else |
oprospero | 0:5fa30cf392c3 | 1092 | dmp_enable_6x_lp_quat(0); |
oprospero | 0:5fa30cf392c3 | 1093 | |
oprospero | 0:5fa30cf392c3 | 1094 | /* Pedometer is always enabled. */ |
oprospero | 0:5fa30cf392c3 | 1095 | dmp.feature_mask = mask | DMP_FEATURE_PEDOMETER; |
oprospero | 0:5fa30cf392c3 | 1096 | mpu_reset_fifo(); |
oprospero | 0:5fa30cf392c3 | 1097 | |
oprospero | 0:5fa30cf392c3 | 1098 | dmp.packet_length = 0; |
oprospero | 0:5fa30cf392c3 | 1099 | if (mask & DMP_FEATURE_SEND_RAW_ACCEL) |
oprospero | 0:5fa30cf392c3 | 1100 | dmp.packet_length += 6; |
oprospero | 0:5fa30cf392c3 | 1101 | if (mask & DMP_FEATURE_SEND_ANY_GYRO) |
oprospero | 0:5fa30cf392c3 | 1102 | dmp.packet_length += 6; |
oprospero | 0:5fa30cf392c3 | 1103 | if (mask & (DMP_FEATURE_LP_QUAT | DMP_FEATURE_6X_LP_QUAT)) |
oprospero | 0:5fa30cf392c3 | 1104 | dmp.packet_length += 16; |
oprospero | 0:5fa30cf392c3 | 1105 | if (mask & (DMP_FEATURE_TAP | DMP_FEATURE_ANDROID_ORIENT)) |
oprospero | 0:5fa30cf392c3 | 1106 | dmp.packet_length += 4; |
oprospero | 0:5fa30cf392c3 | 1107 | |
oprospero | 0:5fa30cf392c3 | 1108 | return 0; |
oprospero | 0:5fa30cf392c3 | 1109 | } |
oprospero | 0:5fa30cf392c3 | 1110 | |
oprospero | 0:5fa30cf392c3 | 1111 | /** |
oprospero | 0:5fa30cf392c3 | 1112 | * @brief Get list of currently enabled DMP features. |
oprospero | 0:5fa30cf392c3 | 1113 | * @param[out] Mask of enabled features. |
oprospero | 0:5fa30cf392c3 | 1114 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1115 | */ |
oprospero | 0:5fa30cf392c3 | 1116 | int dmp_get_enabled_features(unsigned short *mask) |
oprospero | 0:5fa30cf392c3 | 1117 | { |
oprospero | 0:5fa30cf392c3 | 1118 | mask[0] = dmp.feature_mask; |
oprospero | 0:5fa30cf392c3 | 1119 | return 0; |
oprospero | 0:5fa30cf392c3 | 1120 | } |
oprospero | 0:5fa30cf392c3 | 1121 | |
oprospero | 0:5fa30cf392c3 | 1122 | /** |
oprospero | 0:5fa30cf392c3 | 1123 | * @brief Calibrate the gyro data in the DMP. |
oprospero | 0:5fa30cf392c3 | 1124 | * After eight seconds of no motion, the DMP will compute gyro biases and |
oprospero | 0:5fa30cf392c3 | 1125 | * subtract them from the quaternion output. If @e dmp_enable_feature is |
oprospero | 0:5fa30cf392c3 | 1126 | * called with @e DMP_FEATURE_SEND_CAL_GYRO, the biases will also be |
oprospero | 0:5fa30cf392c3 | 1127 | * subtracted from the gyro output. |
oprospero | 0:5fa30cf392c3 | 1128 | * @param[in] enable 1 to enable gyro calibration. |
oprospero | 0:5fa30cf392c3 | 1129 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1130 | */ |
oprospero | 0:5fa30cf392c3 | 1131 | int dmp_enable_gyro_cal(unsigned char enable) |
oprospero | 0:5fa30cf392c3 | 1132 | { |
oprospero | 0:5fa30cf392c3 | 1133 | if (enable) { |
oprospero | 0:5fa30cf392c3 | 1134 | unsigned char regs[9] = {0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, 0x5d}; |
oprospero | 0:5fa30cf392c3 | 1135 | return mpu_write_mem(CFG_MOTION_BIAS, 9, regs); |
oprospero | 0:5fa30cf392c3 | 1136 | } else { |
oprospero | 0:5fa30cf392c3 | 1137 | unsigned char regs[9] = {0xb8, 0xaa, 0xaa, 0xaa, 0xb0, 0x88, 0xc3, 0xc5, 0xc7}; |
oprospero | 0:5fa30cf392c3 | 1138 | return mpu_write_mem(CFG_MOTION_BIAS, 9, regs); |
oprospero | 0:5fa30cf392c3 | 1139 | } |
oprospero | 0:5fa30cf392c3 | 1140 | } |
oprospero | 0:5fa30cf392c3 | 1141 | |
oprospero | 0:5fa30cf392c3 | 1142 | /** |
oprospero | 0:5fa30cf392c3 | 1143 | * @brief Generate 3-axis quaternions from the DMP. |
oprospero | 0:5fa30cf392c3 | 1144 | * In this driver, the 3-axis and 6-axis DMP quaternion features are mutually |
oprospero | 0:5fa30cf392c3 | 1145 | * exclusive. |
oprospero | 0:5fa30cf392c3 | 1146 | * @param[in] enable 1 to enable 3-axis quaternion. |
oprospero | 0:5fa30cf392c3 | 1147 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1148 | */ |
oprospero | 0:5fa30cf392c3 | 1149 | int dmp_enable_lp_quat(unsigned char enable) |
oprospero | 0:5fa30cf392c3 | 1150 | { |
oprospero | 0:5fa30cf392c3 | 1151 | unsigned char regs[4]; |
oprospero | 0:5fa30cf392c3 | 1152 | if (enable) { |
oprospero | 0:5fa30cf392c3 | 1153 | regs[0] = DINBC0; |
oprospero | 0:5fa30cf392c3 | 1154 | regs[1] = DINBC2; |
oprospero | 0:5fa30cf392c3 | 1155 | regs[2] = DINBC4; |
oprospero | 0:5fa30cf392c3 | 1156 | regs[3] = DINBC6; |
oprospero | 0:5fa30cf392c3 | 1157 | } |
oprospero | 0:5fa30cf392c3 | 1158 | else |
oprospero | 0:5fa30cf392c3 | 1159 | memset(regs, 0x8B, 4); |
oprospero | 0:5fa30cf392c3 | 1160 | |
oprospero | 0:5fa30cf392c3 | 1161 | mpu_write_mem(CFG_LP_QUAT, 4, regs); |
oprospero | 0:5fa30cf392c3 | 1162 | |
oprospero | 0:5fa30cf392c3 | 1163 | return mpu_reset_fifo(); |
oprospero | 0:5fa30cf392c3 | 1164 | } |
oprospero | 0:5fa30cf392c3 | 1165 | |
oprospero | 0:5fa30cf392c3 | 1166 | /** |
oprospero | 0:5fa30cf392c3 | 1167 | * @brief Generate 6-axis quaternions from the DMP. |
oprospero | 0:5fa30cf392c3 | 1168 | * In this driver, the 3-axis and 6-axis DMP quaternion features are mutually |
oprospero | 0:5fa30cf392c3 | 1169 | * exclusive. |
oprospero | 0:5fa30cf392c3 | 1170 | * @param[in] enable 1 to enable 6-axis quaternion. |
oprospero | 0:5fa30cf392c3 | 1171 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1172 | */ |
oprospero | 0:5fa30cf392c3 | 1173 | int dmp_enable_6x_lp_quat(unsigned char enable) |
oprospero | 0:5fa30cf392c3 | 1174 | { |
oprospero | 0:5fa30cf392c3 | 1175 | unsigned char regs[4]; |
oprospero | 0:5fa30cf392c3 | 1176 | if (enable) { |
oprospero | 0:5fa30cf392c3 | 1177 | regs[0] = DINA20; |
oprospero | 0:5fa30cf392c3 | 1178 | regs[1] = DINA28; |
oprospero | 0:5fa30cf392c3 | 1179 | regs[2] = DINA30; |
oprospero | 0:5fa30cf392c3 | 1180 | regs[3] = DINA38; |
oprospero | 0:5fa30cf392c3 | 1181 | } else |
oprospero | 0:5fa30cf392c3 | 1182 | memset(regs, 0xA3, 4); |
oprospero | 0:5fa30cf392c3 | 1183 | |
oprospero | 0:5fa30cf392c3 | 1184 | mpu_write_mem(CFG_8, 4, regs); |
oprospero | 0:5fa30cf392c3 | 1185 | |
oprospero | 0:5fa30cf392c3 | 1186 | return mpu_reset_fifo(); |
oprospero | 0:5fa30cf392c3 | 1187 | } |
oprospero | 0:5fa30cf392c3 | 1188 | |
oprospero | 0:5fa30cf392c3 | 1189 | /** |
oprospero | 0:5fa30cf392c3 | 1190 | * @brief Decode the four-byte gesture data and execute any callbacks. |
oprospero | 0:5fa30cf392c3 | 1191 | * @param[in] gesture Gesture data from DMP packet. |
oprospero | 0:5fa30cf392c3 | 1192 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1193 | */ |
oprospero | 0:5fa30cf392c3 | 1194 | static int decode_gesture(unsigned char *gesture) |
oprospero | 0:5fa30cf392c3 | 1195 | { |
oprospero | 0:5fa30cf392c3 | 1196 | unsigned char tap, android_orient; |
oprospero | 0:5fa30cf392c3 | 1197 | |
oprospero | 0:5fa30cf392c3 | 1198 | android_orient = gesture[3] & 0xC0; |
oprospero | 0:5fa30cf392c3 | 1199 | tap = 0x3F & gesture[3]; |
oprospero | 0:5fa30cf392c3 | 1200 | |
oprospero | 0:5fa30cf392c3 | 1201 | if (gesture[1] & INT_SRC_TAP) { |
oprospero | 0:5fa30cf392c3 | 1202 | unsigned char direction, count; |
oprospero | 0:5fa30cf392c3 | 1203 | direction = tap >> 3; |
oprospero | 0:5fa30cf392c3 | 1204 | count = (tap % 8) + 1; |
oprospero | 0:5fa30cf392c3 | 1205 | if (dmp.tap_cb) |
oprospero | 0:5fa30cf392c3 | 1206 | dmp.tap_cb(direction, count); |
oprospero | 0:5fa30cf392c3 | 1207 | } |
oprospero | 0:5fa30cf392c3 | 1208 | |
oprospero | 0:5fa30cf392c3 | 1209 | if (gesture[1] & INT_SRC_ANDROID_ORIENT) { |
oprospero | 0:5fa30cf392c3 | 1210 | if (dmp.android_orient_cb) |
oprospero | 0:5fa30cf392c3 | 1211 | dmp.android_orient_cb(android_orient >> 6); |
oprospero | 0:5fa30cf392c3 | 1212 | } |
oprospero | 0:5fa30cf392c3 | 1213 | |
oprospero | 0:5fa30cf392c3 | 1214 | return 0; |
oprospero | 0:5fa30cf392c3 | 1215 | } |
oprospero | 0:5fa30cf392c3 | 1216 | |
oprospero | 0:5fa30cf392c3 | 1217 | /** |
oprospero | 0:5fa30cf392c3 | 1218 | * @brief Specify when a DMP interrupt should occur. |
oprospero | 0:5fa30cf392c3 | 1219 | * A DMP interrupt can be configured to trigger on either of the two |
oprospero | 0:5fa30cf392c3 | 1220 | * conditions below: |
oprospero | 0:5fa30cf392c3 | 1221 | * \n a. One FIFO period has elapsed (set by @e mpu_set_sample_rate). |
oprospero | 0:5fa30cf392c3 | 1222 | * \n b. A tap event has been detected. |
oprospero | 0:5fa30cf392c3 | 1223 | * @param[in] mode DMP_INT_GESTURE or DMP_INT_CONTINUOUS. |
oprospero | 0:5fa30cf392c3 | 1224 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1225 | */ |
oprospero | 0:5fa30cf392c3 | 1226 | int dmp_set_interrupt_mode(unsigned char mode) |
oprospero | 0:5fa30cf392c3 | 1227 | { |
oprospero | 0:5fa30cf392c3 | 1228 | const unsigned char regs_continuous[11] = |
oprospero | 0:5fa30cf392c3 | 1229 | {0xd8, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3, 0x91, 0xb6, 0x09, 0xb4, 0xd9}; |
oprospero | 0:5fa30cf392c3 | 1230 | const unsigned char regs_gesture[11] = |
oprospero | 0:5fa30cf392c3 | 1231 | {0xda, 0xb1, 0xb9, 0xf3, 0x8b, 0xa3, 0x91, 0xb6, 0xda, 0xb4, 0xda}; |
oprospero | 0:5fa30cf392c3 | 1232 | |
oprospero | 0:5fa30cf392c3 | 1233 | switch (mode) { |
oprospero | 0:5fa30cf392c3 | 1234 | case DMP_INT_CONTINUOUS: |
oprospero | 0:5fa30cf392c3 | 1235 | return mpu_write_mem(CFG_FIFO_ON_EVENT, 11, |
oprospero | 0:5fa30cf392c3 | 1236 | (unsigned char*)regs_continuous); |
oprospero | 0:5fa30cf392c3 | 1237 | case DMP_INT_GESTURE: |
oprospero | 0:5fa30cf392c3 | 1238 | return mpu_write_mem(CFG_FIFO_ON_EVENT, 11, |
oprospero | 0:5fa30cf392c3 | 1239 | (unsigned char*)regs_gesture); |
oprospero | 0:5fa30cf392c3 | 1240 | default: |
oprospero | 0:5fa30cf392c3 | 1241 | return -1; |
oprospero | 0:5fa30cf392c3 | 1242 | } |
oprospero | 0:5fa30cf392c3 | 1243 | } |
oprospero | 0:5fa30cf392c3 | 1244 | |
oprospero | 0:5fa30cf392c3 | 1245 | /** |
oprospero | 0:5fa30cf392c3 | 1246 | * @brief Get one packet from the FIFO. |
oprospero | 0:5fa30cf392c3 | 1247 | * If @e sensors does not contain a particular sensor, disregard the data |
oprospero | 0:5fa30cf392c3 | 1248 | * returned to that pointer. |
oprospero | 0:5fa30cf392c3 | 1249 | * \n @e sensors can contain a combination of the following flags: |
oprospero | 0:5fa30cf392c3 | 1250 | * \n INV_X_GYRO, INV_Y_GYRO, INV_Z_GYRO |
oprospero | 0:5fa30cf392c3 | 1251 | * \n INV_XYZ_GYRO |
oprospero | 0:5fa30cf392c3 | 1252 | * \n INV_XYZ_ACCEL |
oprospero | 0:5fa30cf392c3 | 1253 | * \n INV_WXYZ_QUAT |
oprospero | 0:5fa30cf392c3 | 1254 | * \n If the FIFO has no new data, @e sensors will be zero. |
oprospero | 0:5fa30cf392c3 | 1255 | * \n If the FIFO is disabled, @e sensors will be zero and this function will |
oprospero | 0:5fa30cf392c3 | 1256 | * return a non-zero error code. |
oprospero | 0:5fa30cf392c3 | 1257 | * @param[out] gyro Gyro data in hardware units. |
oprospero | 0:5fa30cf392c3 | 1258 | * @param[out] accel Accel data in hardware units. |
oprospero | 0:5fa30cf392c3 | 1259 | * @param[out] quat 3-axis quaternion data in hardware units. |
oprospero | 0:5fa30cf392c3 | 1260 | * @param[out] timestamp Timestamp in milliseconds. |
oprospero | 0:5fa30cf392c3 | 1261 | * @param[out] sensors Mask of sensors read from FIFO. |
oprospero | 0:5fa30cf392c3 | 1262 | * @param[out] more Number of remaining packets. |
oprospero | 0:5fa30cf392c3 | 1263 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1264 | */ |
oprospero | 0:5fa30cf392c3 | 1265 | int dmp_read_fifo(short *gyro, short *accel, long *quat, |
oprospero | 0:5fa30cf392c3 | 1266 | unsigned long *timestamp, short *sensors, unsigned char *more) |
oprospero | 0:5fa30cf392c3 | 1267 | { |
oprospero | 0:5fa30cf392c3 | 1268 | unsigned char fifo_data[MAX_PACKET_LENGTH]; |
oprospero | 0:5fa30cf392c3 | 1269 | unsigned char ii = 0; |
oprospero | 0:5fa30cf392c3 | 1270 | |
oprospero | 0:5fa30cf392c3 | 1271 | /* TODO: sensors[0] only changes when dmp_enable_feature is called. We can |
oprospero | 0:5fa30cf392c3 | 1272 | * cache this value and save some cycles. |
oprospero | 0:5fa30cf392c3 | 1273 | */ |
oprospero | 0:5fa30cf392c3 | 1274 | sensors[0] = 0; |
oprospero | 0:5fa30cf392c3 | 1275 | |
oprospero | 0:5fa30cf392c3 | 1276 | /* Get a packet. */ |
oprospero | 0:5fa30cf392c3 | 1277 | if (mpu_read_fifo_stream(dmp.packet_length, fifo_data, more)) |
oprospero | 0:5fa30cf392c3 | 1278 | return -1; |
oprospero | 0:5fa30cf392c3 | 1279 | |
oprospero | 0:5fa30cf392c3 | 1280 | /* Parse DMP packet. */ |
oprospero | 0:5fa30cf392c3 | 1281 | if (dmp.feature_mask & (DMP_FEATURE_LP_QUAT | DMP_FEATURE_6X_LP_QUAT)) { |
oprospero | 0:5fa30cf392c3 | 1282 | #ifdef FIFO_CORRUPTION_CHECK |
oprospero | 0:5fa30cf392c3 | 1283 | long quat_q14[4], quat_mag_sq; |
oprospero | 0:5fa30cf392c3 | 1284 | #endif |
oprospero | 0:5fa30cf392c3 | 1285 | quat[0] = ((long)fifo_data[0] << 24) | ((long)fifo_data[1] << 16) | |
oprospero | 0:5fa30cf392c3 | 1286 | ((long)fifo_data[2] << 8) | fifo_data[3]; |
oprospero | 0:5fa30cf392c3 | 1287 | quat[1] = ((long)fifo_data[4] << 24) | ((long)fifo_data[5] << 16) | |
oprospero | 0:5fa30cf392c3 | 1288 | ((long)fifo_data[6] << 8) | fifo_data[7]; |
oprospero | 0:5fa30cf392c3 | 1289 | quat[2] = ((long)fifo_data[8] << 24) | ((long)fifo_data[9] << 16) | |
oprospero | 0:5fa30cf392c3 | 1290 | ((long)fifo_data[10] << 8) | fifo_data[11]; |
oprospero | 0:5fa30cf392c3 | 1291 | quat[3] = ((long)fifo_data[12] << 24) | ((long)fifo_data[13] << 16) | |
oprospero | 0:5fa30cf392c3 | 1292 | ((long)fifo_data[14] << 8) | fifo_data[15]; |
oprospero | 0:5fa30cf392c3 | 1293 | ii += 16; |
oprospero | 0:5fa30cf392c3 | 1294 | #ifdef FIFO_CORRUPTION_CHECK |
oprospero | 0:5fa30cf392c3 | 1295 | /* We can detect a corrupted FIFO by monitoring the quaternion data and |
oprospero | 0:5fa30cf392c3 | 1296 | * ensuring that the magnitude is always normalized to one. This |
oprospero | 0:5fa30cf392c3 | 1297 | * shouldn't happen in normal operation, but if an I2C error occurs, |
oprospero | 0:5fa30cf392c3 | 1298 | * the FIFO reads might become misaligned. |
oprospero | 0:5fa30cf392c3 | 1299 | * |
oprospero | 0:5fa30cf392c3 | 1300 | * Let's start by scaling down the quaternion data to avoid long long |
oprospero | 0:5fa30cf392c3 | 1301 | * math. |
oprospero | 0:5fa30cf392c3 | 1302 | */ |
oprospero | 0:5fa30cf392c3 | 1303 | quat_q14[0] = quat[0] >> 16; |
oprospero | 0:5fa30cf392c3 | 1304 | quat_q14[1] = quat[1] >> 16; |
oprospero | 0:5fa30cf392c3 | 1305 | quat_q14[2] = quat[2] >> 16; |
oprospero | 0:5fa30cf392c3 | 1306 | quat_q14[3] = quat[3] >> 16; |
oprospero | 0:5fa30cf392c3 | 1307 | quat_mag_sq = quat_q14[0] * quat_q14[0] + quat_q14[1] * quat_q14[1] + |
oprospero | 0:5fa30cf392c3 | 1308 | quat_q14[2] * quat_q14[2] + quat_q14[3] * quat_q14[3]; |
oprospero | 0:5fa30cf392c3 | 1309 | if ((quat_mag_sq < QUAT_MAG_SQ_MIN) || |
oprospero | 0:5fa30cf392c3 | 1310 | (quat_mag_sq > QUAT_MAG_SQ_MAX)) { |
oprospero | 0:5fa30cf392c3 | 1311 | /* Quaternion is outside of the acceptable threshold. */ |
oprospero | 0:5fa30cf392c3 | 1312 | mpu_reset_fifo(); |
oprospero | 0:5fa30cf392c3 | 1313 | sensors[0] = 0; |
oprospero | 0:5fa30cf392c3 | 1314 | return -1; |
oprospero | 0:5fa30cf392c3 | 1315 | } |
oprospero | 0:5fa30cf392c3 | 1316 | sensors[0] |= INV_WXYZ_QUAT; |
oprospero | 0:5fa30cf392c3 | 1317 | #endif |
oprospero | 0:5fa30cf392c3 | 1318 | } |
oprospero | 0:5fa30cf392c3 | 1319 | |
oprospero | 0:5fa30cf392c3 | 1320 | if (dmp.feature_mask & DMP_FEATURE_SEND_RAW_ACCEL) { |
oprospero | 0:5fa30cf392c3 | 1321 | accel[0] = ((short)fifo_data[ii+0] << 8) | fifo_data[ii+1]; |
oprospero | 0:5fa30cf392c3 | 1322 | accel[1] = ((short)fifo_data[ii+2] << 8) | fifo_data[ii+3]; |
oprospero | 0:5fa30cf392c3 | 1323 | accel[2] = ((short)fifo_data[ii+4] << 8) | fifo_data[ii+5]; |
oprospero | 0:5fa30cf392c3 | 1324 | ii += 6; |
oprospero | 0:5fa30cf392c3 | 1325 | sensors[0] |= INV_XYZ_ACCEL; |
oprospero | 0:5fa30cf392c3 | 1326 | } |
oprospero | 0:5fa30cf392c3 | 1327 | |
oprospero | 0:5fa30cf392c3 | 1328 | if (dmp.feature_mask & DMP_FEATURE_SEND_ANY_GYRO) { |
oprospero | 0:5fa30cf392c3 | 1329 | gyro[0] = ((short)fifo_data[ii+0] << 8) | fifo_data[ii+1]; |
oprospero | 0:5fa30cf392c3 | 1330 | gyro[1] = ((short)fifo_data[ii+2] << 8) | fifo_data[ii+3]; |
oprospero | 0:5fa30cf392c3 | 1331 | gyro[2] = ((short)fifo_data[ii+4] << 8) | fifo_data[ii+5]; |
oprospero | 0:5fa30cf392c3 | 1332 | ii += 6; |
oprospero | 0:5fa30cf392c3 | 1333 | sensors[0] |= INV_XYZ_GYRO; |
oprospero | 0:5fa30cf392c3 | 1334 | } |
oprospero | 0:5fa30cf392c3 | 1335 | |
oprospero | 0:5fa30cf392c3 | 1336 | /* Gesture data is at the end of the DMP packet. Parse it and call |
oprospero | 0:5fa30cf392c3 | 1337 | * the gesture callbacks (if registered). |
oprospero | 0:5fa30cf392c3 | 1338 | */ |
oprospero | 0:5fa30cf392c3 | 1339 | if (dmp.feature_mask & (DMP_FEATURE_TAP | DMP_FEATURE_ANDROID_ORIENT)) |
oprospero | 0:5fa30cf392c3 | 1340 | decode_gesture(fifo_data + ii); |
oprospero | 0:5fa30cf392c3 | 1341 | |
oprospero | 0:5fa30cf392c3 | 1342 | get_ms(timestamp); |
oprospero | 0:5fa30cf392c3 | 1343 | return 0; |
oprospero | 0:5fa30cf392c3 | 1344 | } |
oprospero | 0:5fa30cf392c3 | 1345 | |
oprospero | 0:5fa30cf392c3 | 1346 | /** |
oprospero | 0:5fa30cf392c3 | 1347 | * @brief Register a function to be executed on a tap event. |
oprospero | 0:5fa30cf392c3 | 1348 | * The tap direction is represented by one of the following: |
oprospero | 0:5fa30cf392c3 | 1349 | * \n TAP_X_UP |
oprospero | 0:5fa30cf392c3 | 1350 | * \n TAP_X_DOWN |
oprospero | 0:5fa30cf392c3 | 1351 | * \n TAP_Y_UP |
oprospero | 0:5fa30cf392c3 | 1352 | * \n TAP_Y_DOWN |
oprospero | 0:5fa30cf392c3 | 1353 | * \n TAP_Z_UP |
oprospero | 0:5fa30cf392c3 | 1354 | * \n TAP_Z_DOWN |
oprospero | 0:5fa30cf392c3 | 1355 | * @param[in] func Callback function. |
oprospero | 0:5fa30cf392c3 | 1356 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1357 | */ |
oprospero | 0:5fa30cf392c3 | 1358 | int dmp_register_tap_cb(void (*func)(unsigned char, unsigned char)) |
oprospero | 0:5fa30cf392c3 | 1359 | { |
oprospero | 0:5fa30cf392c3 | 1360 | dmp.tap_cb = func; |
oprospero | 0:5fa30cf392c3 | 1361 | return 0; |
oprospero | 0:5fa30cf392c3 | 1362 | } |
oprospero | 0:5fa30cf392c3 | 1363 | |
oprospero | 0:5fa30cf392c3 | 1364 | /** |
oprospero | 0:5fa30cf392c3 | 1365 | * @brief Register a function to be executed on a android orientation event. |
oprospero | 0:5fa30cf392c3 | 1366 | * @param[in] func Callback function. |
oprospero | 0:5fa30cf392c3 | 1367 | * @return 0 if successful. |
oprospero | 0:5fa30cf392c3 | 1368 | */ |
oprospero | 0:5fa30cf392c3 | 1369 | int dmp_register_android_orient_cb(void (*func)(unsigned char)) |
oprospero | 0:5fa30cf392c3 | 1370 | { |
oprospero | 0:5fa30cf392c3 | 1371 | dmp.android_orient_cb = func; |
oprospero | 0:5fa30cf392c3 | 1372 | return 0; |
oprospero | 0:5fa30cf392c3 | 1373 | } |
oprospero | 0:5fa30cf392c3 | 1374 | |
oprospero | 0:5fa30cf392c3 | 1375 | /** |
oprospero | 0:5fa30cf392c3 | 1376 | * @} |
oprospero | 0:5fa30cf392c3 | 1377 | */ |
oprospero | 0:5fa30cf392c3 | 1378 | |
oprospero | 0:5fa30cf392c3 | 1379 |