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 Prosper Van

Committer:
mbedoguz
Date:
Mon Aug 14 07:36:07 2017 +0000
Revision:
6:7469a85601f1
Parent:
1:a6c3f8680fe0
get_ms now returns the counter.

Who changed what in which revision?

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