![](/media/cache/profiles/c8045671083f48d8d09d1d2523ea8941.50x50_q85.jpg)
Complete MPU6050dmp example working with processing 2.1 teapot code v1.0 Jan. 2014
Fork of MPU6050 by
MPU6050_6Axis_MotionApps20.h@3:25e1a5a10e53, 2013-11-19 (annotated)
- Committer:
- syundo0730
- Date:
- Tue Nov 19 19:05:55 2013 +0000
- Revision:
- 3:25e1a5a10e53
- Child:
- 4:a1c169138c71
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
syundo0730 | 3:25e1a5a10e53 | 1 | // I2Cdev library collection - MPU6050 I2C device class, 6-axis MotionApps 2.0 implementation |
syundo0730 | 3:25e1a5a10e53 | 2 | // Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00) |
syundo0730 | 3:25e1a5a10e53 | 3 | // 5/20/2013 by Jeff Rowberg <jeff@rowberg.net> |
syundo0730 | 3:25e1a5a10e53 | 4 | // Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib |
syundo0730 | 3:25e1a5a10e53 | 5 | // |
syundo0730 | 3:25e1a5a10e53 | 6 | // Changelog: |
syundo0730 | 3:25e1a5a10e53 | 7 | // ... - ongoing debug release |
syundo0730 | 3:25e1a5a10e53 | 8 | |
syundo0730 | 3:25e1a5a10e53 | 9 | /* ============================================ |
syundo0730 | 3:25e1a5a10e53 | 10 | I2Cdev device library code is placed under the MIT license |
syundo0730 | 3:25e1a5a10e53 | 11 | Copyright (c) 2012 Jeff Rowberg |
syundo0730 | 3:25e1a5a10e53 | 12 | |
syundo0730 | 3:25e1a5a10e53 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy |
syundo0730 | 3:25e1a5a10e53 | 14 | of this software and associated documentation files (the "Software"), to deal |
syundo0730 | 3:25e1a5a10e53 | 15 | in the Software without restriction, including without limitation the rights |
syundo0730 | 3:25e1a5a10e53 | 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
syundo0730 | 3:25e1a5a10e53 | 17 | copies of the Software, and to permit persons to whom the Software is |
syundo0730 | 3:25e1a5a10e53 | 18 | furnished to do so, subject to the following conditions: |
syundo0730 | 3:25e1a5a10e53 | 19 | |
syundo0730 | 3:25e1a5a10e53 | 20 | The above copyright notice and this permission notice shall be included in |
syundo0730 | 3:25e1a5a10e53 | 21 | all copies or substantial portions of the Software. |
syundo0730 | 3:25e1a5a10e53 | 22 | |
syundo0730 | 3:25e1a5a10e53 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
syundo0730 | 3:25e1a5a10e53 | 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
syundo0730 | 3:25e1a5a10e53 | 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
syundo0730 | 3:25e1a5a10e53 | 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
syundo0730 | 3:25e1a5a10e53 | 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
syundo0730 | 3:25e1a5a10e53 | 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
syundo0730 | 3:25e1a5a10e53 | 29 | THE SOFTWARE. |
syundo0730 | 3:25e1a5a10e53 | 30 | =============================================== |
syundo0730 | 3:25e1a5a10e53 | 31 | */ |
syundo0730 | 3:25e1a5a10e53 | 32 | |
syundo0730 | 3:25e1a5a10e53 | 33 | #ifndef _MPU6050_6AXIS_MOTIONAPPS20_H_ |
syundo0730 | 3:25e1a5a10e53 | 34 | #define _MPU6050_6AXIS_MOTIONAPPS20_H_ |
syundo0730 | 3:25e1a5a10e53 | 35 | |
syundo0730 | 3:25e1a5a10e53 | 36 | #include "I2Cdev.h" |
syundo0730 | 3:25e1a5a10e53 | 37 | #include "helper_3dmath.h" |
syundo0730 | 3:25e1a5a10e53 | 38 | |
syundo0730 | 3:25e1a5a10e53 | 39 | // MotionApps 2.0 DMP implementation, built using the MPU-6050EVB evaluation board |
syundo0730 | 3:25e1a5a10e53 | 40 | #define MPU6050_INCLUDE_DMP_MOTIONAPPS20 |
syundo0730 | 3:25e1a5a10e53 | 41 | |
syundo0730 | 3:25e1a5a10e53 | 42 | #include "MPU6050.h" |
syundo0730 | 3:25e1a5a10e53 | 43 | |
syundo0730 | 3:25e1a5a10e53 | 44 | // Tom Carpenter's conditional PROGMEM code |
syundo0730 | 3:25e1a5a10e53 | 45 | // http://forum.arduino.cc/index.php?topic=129407.0 |
syundo0730 | 3:25e1a5a10e53 | 46 | #ifndef __arm__ |
syundo0730 | 3:25e1a5a10e53 | 47 | #include <avr/pgmspace.h> |
syundo0730 | 3:25e1a5a10e53 | 48 | #else |
syundo0730 | 3:25e1a5a10e53 | 49 | // Teensy 3.0 library conditional PROGMEM code from Paul Stoffregen |
syundo0730 | 3:25e1a5a10e53 | 50 | #ifndef __PGMSPACE_H_ |
syundo0730 | 3:25e1a5a10e53 | 51 | #define __PGMSPACE_H_ 1 |
syundo0730 | 3:25e1a5a10e53 | 52 | #include <inttypes.h> |
syundo0730 | 3:25e1a5a10e53 | 53 | |
syundo0730 | 3:25e1a5a10e53 | 54 | #define PROGMEM |
syundo0730 | 3:25e1a5a10e53 | 55 | #define PGM_P const char * |
syundo0730 | 3:25e1a5a10e53 | 56 | #define PSTR(str) (str) |
syundo0730 | 3:25e1a5a10e53 | 57 | #define F(x) x |
syundo0730 | 3:25e1a5a10e53 | 58 | |
syundo0730 | 3:25e1a5a10e53 | 59 | typedef void prog_void; |
syundo0730 | 3:25e1a5a10e53 | 60 | typedef char prog_char; |
syundo0730 | 3:25e1a5a10e53 | 61 | typedef unsigned char prog_uchar; |
syundo0730 | 3:25e1a5a10e53 | 62 | typedef int8_t prog_int8_t; |
syundo0730 | 3:25e1a5a10e53 | 63 | typedef uint8_t prog_uint8_t; |
syundo0730 | 3:25e1a5a10e53 | 64 | typedef int16_t prog_int16_t; |
syundo0730 | 3:25e1a5a10e53 | 65 | typedef uint16_t prog_uint16_t; |
syundo0730 | 3:25e1a5a10e53 | 66 | typedef int32_t prog_int32_t; |
syundo0730 | 3:25e1a5a10e53 | 67 | typedef uint32_t prog_uint32_t; |
syundo0730 | 3:25e1a5a10e53 | 68 | |
syundo0730 | 3:25e1a5a10e53 | 69 | #define strcpy_P(dest, src) strcpy((dest), (src)) |
syundo0730 | 3:25e1a5a10e53 | 70 | #define strcat_P(dest, src) strcat((dest), (src)) |
syundo0730 | 3:25e1a5a10e53 | 71 | #define strcmp_P(a, b) strcmp((a), (b)) |
syundo0730 | 3:25e1a5a10e53 | 72 | |
syundo0730 | 3:25e1a5a10e53 | 73 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) |
syundo0730 | 3:25e1a5a10e53 | 74 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) |
syundo0730 | 3:25e1a5a10e53 | 75 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) |
syundo0730 | 3:25e1a5a10e53 | 76 | #define pgm_read_float(addr) (*(const float *)(addr)) |
syundo0730 | 3:25e1a5a10e53 | 77 | |
syundo0730 | 3:25e1a5a10e53 | 78 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) |
syundo0730 | 3:25e1a5a10e53 | 79 | #define pgm_read_word_near(addr) pgm_read_word(addr) |
syundo0730 | 3:25e1a5a10e53 | 80 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) |
syundo0730 | 3:25e1a5a10e53 | 81 | #define pgm_read_float_near(addr) pgm_read_float(addr) |
syundo0730 | 3:25e1a5a10e53 | 82 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) |
syundo0730 | 3:25e1a5a10e53 | 83 | #define pgm_read_word_far(addr) pgm_read_word(addr) |
syundo0730 | 3:25e1a5a10e53 | 84 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) |
syundo0730 | 3:25e1a5a10e53 | 85 | #define pgm_read_float_far(addr) pgm_read_float(addr) |
syundo0730 | 3:25e1a5a10e53 | 86 | #endif |
syundo0730 | 3:25e1a5a10e53 | 87 | #endif |
syundo0730 | 3:25e1a5a10e53 | 88 | |
syundo0730 | 3:25e1a5a10e53 | 89 | /* Source is from the InvenSense MotionApps v2 demo code. Original source is |
syundo0730 | 3:25e1a5a10e53 | 90 | * unavailable, unless you happen to be amazing as decompiling binary by |
syundo0730 | 3:25e1a5a10e53 | 91 | * hand (in which case, please contact me, and I'm totally serious). |
syundo0730 | 3:25e1a5a10e53 | 92 | * |
syundo0730 | 3:25e1a5a10e53 | 93 | * Also, I'd like to offer many, many thanks to Noah Zerkin for all of the |
syundo0730 | 3:25e1a5a10e53 | 94 | * DMP reverse-engineering he did to help make this bit of wizardry |
syundo0730 | 3:25e1a5a10e53 | 95 | * possible. |
syundo0730 | 3:25e1a5a10e53 | 96 | */ |
syundo0730 | 3:25e1a5a10e53 | 97 | |
syundo0730 | 3:25e1a5a10e53 | 98 | // NOTE! Enabling DEBUG adds about 3.3kB to the flash program size. |
syundo0730 | 3:25e1a5a10e53 | 99 | // Debug output is now working even on ATMega328P MCUs (e.g. Arduino Uno) |
syundo0730 | 3:25e1a5a10e53 | 100 | // after moving string constants to flash memory storage using the F() |
syundo0730 | 3:25e1a5a10e53 | 101 | // compiler macro (Arduino IDE 1.0+ required). |
syundo0730 | 3:25e1a5a10e53 | 102 | |
syundo0730 | 3:25e1a5a10e53 | 103 | //#define DEBUG |
syundo0730 | 3:25e1a5a10e53 | 104 | #ifdef DEBUG |
syundo0730 | 3:25e1a5a10e53 | 105 | #define DEBUG_PRINT(x) Serial.print(x) |
syundo0730 | 3:25e1a5a10e53 | 106 | #define DEBUG_PRINTF(x, y) Serial.print(x, y) |
syundo0730 | 3:25e1a5a10e53 | 107 | #define DEBUG_PRINTLN(x) Serial.println(x) |
syundo0730 | 3:25e1a5a10e53 | 108 | #define DEBUG_PRINTLNF(x, y) Serial.println(x, y) |
syundo0730 | 3:25e1a5a10e53 | 109 | #else |
syundo0730 | 3:25e1a5a10e53 | 110 | #define DEBUG_PRINT(x) |
syundo0730 | 3:25e1a5a10e53 | 111 | #define DEBUG_PRINTF(x, y) |
syundo0730 | 3:25e1a5a10e53 | 112 | #define DEBUG_PRINTLN(x) |
syundo0730 | 3:25e1a5a10e53 | 113 | #define DEBUG_PRINTLNF(x, y) |
syundo0730 | 3:25e1a5a10e53 | 114 | #endif |
syundo0730 | 3:25e1a5a10e53 | 115 | |
syundo0730 | 3:25e1a5a10e53 | 116 | #define MPU6050_DMP_CODE_SIZE 1929 // dmpMemory[] |
syundo0730 | 3:25e1a5a10e53 | 117 | #define MPU6050_DMP_CONFIG_SIZE 192 // dmpConfig[] |
syundo0730 | 3:25e1a5a10e53 | 118 | #define MPU6050_DMP_UPDATES_SIZE 47 // dmpUpdates[] |
syundo0730 | 3:25e1a5a10e53 | 119 | |
syundo0730 | 3:25e1a5a10e53 | 120 | /* ================================================================================================ * |
syundo0730 | 3:25e1a5a10e53 | 121 | | Default MotionApps v2.0 42-byte FIFO packet structure: | |
syundo0730 | 3:25e1a5a10e53 | 122 | | | |
syundo0730 | 3:25e1a5a10e53 | 123 | | [QUAT W][ ][QUAT X][ ][QUAT Y][ ][QUAT Z][ ][GYRO X][ ][GYRO Y][ ] | |
syundo0730 | 3:25e1a5a10e53 | 124 | | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
syundo0730 | 3:25e1a5a10e53 | 125 | | | |
syundo0730 | 3:25e1a5a10e53 | 126 | | [GYRO Z][ ][ACC X ][ ][ACC Y ][ ][ACC Z ][ ][ ] | |
syundo0730 | 3:25e1a5a10e53 | 127 | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
syundo0730 | 3:25e1a5a10e53 | 128 | * ================================================================================================ */ |
syundo0730 | 3:25e1a5a10e53 | 129 | |
syundo0730 | 3:25e1a5a10e53 | 130 | // this block of memory gets written to the MPU on start-up, and it seems |
syundo0730 | 3:25e1a5a10e53 | 131 | // to be volatile memory, so it has to be done each time (it only takes ~1 |
syundo0730 | 3:25e1a5a10e53 | 132 | // second though) |
syundo0730 | 3:25e1a5a10e53 | 133 | const unsigned char dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = { |
syundo0730 | 3:25e1a5a10e53 | 134 | // bank 0, 256 bytes |
syundo0730 | 3:25e1a5a10e53 | 135 | 0xFB, 0x00, 0x00, 0x3E, 0x00, 0x0B, 0x00, 0x36, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 136 | 0x00, 0x65, 0x00, 0x54, 0xFF, 0xEF, 0x00, 0x00, 0xFA, 0x80, 0x00, 0x0B, 0x12, 0x82, 0x00, 0x01, |
syundo0730 | 3:25e1a5a10e53 | 137 | 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 138 | 0x00, 0x28, 0x00, 0x00, 0xFF, 0xFF, 0x45, 0x81, 0xFF, 0xFF, 0xFA, 0x72, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 139 | 0x00, 0x00, 0x03, 0xE8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7F, 0xFF, 0xFF, 0xFE, 0x80, 0x01, |
syundo0730 | 3:25e1a5a10e53 | 140 | 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 141 | 0x00, 0x3E, 0x03, 0x30, 0x40, 0x00, 0x00, 0x00, 0x02, 0xCA, 0xE3, 0x09, 0x3E, 0x80, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 142 | 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 143 | 0x41, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x2A, 0x00, 0x00, 0x16, 0x55, 0x00, 0x00, 0x21, 0x82, |
syundo0730 | 3:25e1a5a10e53 | 144 | 0xFD, 0x87, 0x26, 0x50, 0xFD, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x05, 0x80, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 145 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 146 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x6F, 0x00, 0x02, 0x65, 0x32, 0x00, 0x00, 0x5E, 0xC0, |
syundo0730 | 3:25e1a5a10e53 | 147 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 148 | 0xFB, 0x8C, 0x6F, 0x5D, 0xFD, 0x5D, 0x08, 0xD9, 0x00, 0x7C, 0x73, 0x3B, 0x00, 0x6C, 0x12, 0xCC, |
syundo0730 | 3:25e1a5a10e53 | 149 | 0x32, 0x00, 0x13, 0x9D, 0x32, 0x00, 0xD0, 0xD6, 0x32, 0x00, 0x08, 0x00, 0x40, 0x00, 0x01, 0xF4, |
syundo0730 | 3:25e1a5a10e53 | 150 | 0xFF, 0xE6, 0x80, 0x79, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xD6, 0x00, 0x00, 0x27, 0x10, |
syundo0730 | 3:25e1a5a10e53 | 151 | |
syundo0730 | 3:25e1a5a10e53 | 152 | // bank 1, 256 bytes |
syundo0730 | 3:25e1a5a10e53 | 153 | 0xFB, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 154 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 155 | 0x00, 0x00, 0xFA, 0x36, 0xFF, 0xBC, 0x30, 0x8E, 0x00, 0x05, 0xFB, 0xF0, 0xFF, 0xD9, 0x5B, 0xC8, |
syundo0730 | 3:25e1a5a10e53 | 156 | 0xFF, 0xD0, 0x9A, 0xBE, 0x00, 0x00, 0x10, 0xA9, 0xFF, 0xF4, 0x1E, 0xB2, 0x00, 0xCE, 0xBB, 0xF7, |
syundo0730 | 3:25e1a5a10e53 | 157 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x0C, |
syundo0730 | 3:25e1a5a10e53 | 158 | 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xCF, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 159 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x14, |
syundo0730 | 3:25e1a5a10e53 | 160 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 161 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 162 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 163 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x68, 0xB6, 0x79, 0x35, 0x28, 0xBC, 0xC6, 0x7E, 0xD1, 0x6C, |
syundo0730 | 3:25e1a5a10e53 | 164 | 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB2, 0x6A, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 165 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x30, |
syundo0730 | 3:25e1a5a10e53 | 166 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 167 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 168 | 0x00, 0x00, 0x25, 0x4D, 0x00, 0x2F, 0x70, 0x6D, 0x00, 0x00, 0x05, 0xAE, 0x00, 0x0C, 0x02, 0xD0, |
syundo0730 | 3:25e1a5a10e53 | 169 | |
syundo0730 | 3:25e1a5a10e53 | 170 | // bank 2, 256 bytes |
syundo0730 | 3:25e1a5a10e53 | 171 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x54, 0xFF, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 172 | 0x00, 0x00, 0x01, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 173 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0xFF, 0xEF, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 174 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 175 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 176 | 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 177 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 178 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 179 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 180 | 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 181 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 182 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 183 | 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 184 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 185 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 186 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 187 | |
syundo0730 | 3:25e1a5a10e53 | 188 | // bank 3, 256 bytes |
syundo0730 | 3:25e1a5a10e53 | 189 | 0xD8, 0xDC, 0xBA, 0xA2, 0xF1, 0xDE, 0xB2, 0xB8, 0xB4, 0xA8, 0x81, 0x91, 0xF7, 0x4A, 0x90, 0x7F, |
syundo0730 | 3:25e1a5a10e53 | 190 | 0x91, 0x6A, 0xF3, 0xF9, 0xDB, 0xA8, 0xF9, 0xB0, 0xBA, 0xA0, 0x80, 0xF2, 0xCE, 0x81, 0xF3, 0xC2, |
syundo0730 | 3:25e1a5a10e53 | 191 | 0xF1, 0xC1, 0xF2, 0xC3, 0xF3, 0xCC, 0xA2, 0xB2, 0x80, 0xF1, 0xC6, 0xD8, 0x80, 0xBA, 0xA7, 0xDF, |
syundo0730 | 3:25e1a5a10e53 | 192 | 0xDF, 0xDF, 0xF2, 0xA7, 0xC3, 0xCB, 0xC5, 0xB6, 0xF0, 0x87, 0xA2, 0x94, 0x24, 0x48, 0x70, 0x3C, |
syundo0730 | 3:25e1a5a10e53 | 193 | 0x95, 0x40, 0x68, 0x34, 0x58, 0x9B, 0x78, 0xA2, 0xF1, 0x83, 0x92, 0x2D, 0x55, 0x7D, 0xD8, 0xB1, |
syundo0730 | 3:25e1a5a10e53 | 194 | 0xB4, 0xB8, 0xA1, 0xD0, 0x91, 0x80, 0xF2, 0x70, 0xF3, 0x70, 0xF2, 0x7C, 0x80, 0xA8, 0xF1, 0x01, |
syundo0730 | 3:25e1a5a10e53 | 195 | 0xB0, 0x98, 0x87, 0xD9, 0x43, 0xD8, 0x86, 0xC9, 0x88, 0xBA, 0xA1, 0xF2, 0x0E, 0xB8, 0x97, 0x80, |
syundo0730 | 3:25e1a5a10e53 | 196 | 0xF1, 0xA9, 0xDF, 0xDF, 0xDF, 0xAA, 0xDF, 0xDF, 0xDF, 0xF2, 0xAA, 0xC5, 0xCD, 0xC7, 0xA9, 0x0C, |
syundo0730 | 3:25e1a5a10e53 | 197 | 0xC9, 0x2C, 0x97, 0x97, 0x97, 0x97, 0xF1, 0xA9, 0x89, 0x26, 0x46, 0x66, 0xB0, 0xB4, 0xBA, 0x80, |
syundo0730 | 3:25e1a5a10e53 | 198 | 0xAC, 0xDE, 0xF2, 0xCA, 0xF1, 0xB2, 0x8C, 0x02, 0xA9, 0xB6, 0x98, 0x00, 0x89, 0x0E, 0x16, 0x1E, |
syundo0730 | 3:25e1a5a10e53 | 199 | 0xB8, 0xA9, 0xB4, 0x99, 0x2C, 0x54, 0x7C, 0xB0, 0x8A, 0xA8, 0x96, 0x36, 0x56, 0x76, 0xF1, 0xB9, |
syundo0730 | 3:25e1a5a10e53 | 200 | 0xAF, 0xB4, 0xB0, 0x83, 0xC0, 0xB8, 0xA8, 0x97, 0x11, 0xB1, 0x8F, 0x98, 0xB9, 0xAF, 0xF0, 0x24, |
syundo0730 | 3:25e1a5a10e53 | 201 | 0x08, 0x44, 0x10, 0x64, 0x18, 0xF1, 0xA3, 0x29, 0x55, 0x7D, 0xAF, 0x83, 0xB5, 0x93, 0xAF, 0xF0, |
syundo0730 | 3:25e1a5a10e53 | 202 | 0x00, 0x28, 0x50, 0xF1, 0xA3, 0x86, 0x9F, 0x61, 0xA6, 0xDA, 0xDE, 0xDF, 0xD9, 0xFA, 0xA3, 0x86, |
syundo0730 | 3:25e1a5a10e53 | 203 | 0x96, 0xDB, 0x31, 0xA6, 0xD9, 0xF8, 0xDF, 0xBA, 0xA6, 0x8F, 0xC2, 0xC5, 0xC7, 0xB2, 0x8C, 0xC1, |
syundo0730 | 3:25e1a5a10e53 | 204 | 0xB8, 0xA2, 0xDF, 0xDF, 0xDF, 0xA3, 0xDF, 0xDF, 0xDF, 0xD8, 0xD8, 0xF1, 0xB8, 0xA8, 0xB2, 0x86, |
syundo0730 | 3:25e1a5a10e53 | 205 | |
syundo0730 | 3:25e1a5a10e53 | 206 | // bank 4, 256 bytes |
syundo0730 | 3:25e1a5a10e53 | 207 | 0xB4, 0x98, 0x0D, 0x35, 0x5D, 0xB8, 0xAA, 0x98, 0xB0, 0x87, 0x2D, 0x35, 0x3D, 0xB2, 0xB6, 0xBA, |
syundo0730 | 3:25e1a5a10e53 | 208 | 0xAF, 0x8C, 0x96, 0x19, 0x8F, 0x9F, 0xA7, 0x0E, 0x16, 0x1E, 0xB4, 0x9A, 0xB8, 0xAA, 0x87, 0x2C, |
syundo0730 | 3:25e1a5a10e53 | 209 | 0x54, 0x7C, 0xB9, 0xA3, 0xDE, 0xDF, 0xDF, 0xA3, 0xB1, 0x80, 0xF2, 0xC4, 0xCD, 0xC9, 0xF1, 0xB8, |
syundo0730 | 3:25e1a5a10e53 | 210 | 0xA9, 0xB4, 0x99, 0x83, 0x0D, 0x35, 0x5D, 0x89, 0xB9, 0xA3, 0x2D, 0x55, 0x7D, 0xB5, 0x93, 0xA3, |
syundo0730 | 3:25e1a5a10e53 | 211 | 0x0E, 0x16, 0x1E, 0xA9, 0x2C, 0x54, 0x7C, 0xB8, 0xB4, 0xB0, 0xF1, 0x97, 0x83, 0xA8, 0x11, 0x84, |
syundo0730 | 3:25e1a5a10e53 | 212 | 0xA5, 0x09, 0x98, 0xA3, 0x83, 0xF0, 0xDA, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xD8, 0xF1, 0xA5, |
syundo0730 | 3:25e1a5a10e53 | 213 | 0x29, 0x55, 0x7D, 0xA5, 0x85, 0x95, 0x02, 0x1A, 0x2E, 0x3A, 0x56, 0x5A, 0x40, 0x48, 0xF9, 0xF3, |
syundo0730 | 3:25e1a5a10e53 | 214 | 0xA3, 0xD9, 0xF8, 0xF0, 0x98, 0x83, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0x97, 0x82, 0xA8, 0xF1, |
syundo0730 | 3:25e1a5a10e53 | 215 | 0x11, 0xF0, 0x98, 0xA2, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xDA, 0xF3, 0xDE, 0xD8, 0x83, 0xA5, |
syundo0730 | 3:25e1a5a10e53 | 216 | 0x94, 0x01, 0xD9, 0xA3, 0x02, 0xF1, 0xA2, 0xC3, 0xC5, 0xC7, 0xD8, 0xF1, 0x84, 0x92, 0xA2, 0x4D, |
syundo0730 | 3:25e1a5a10e53 | 217 | 0xDA, 0x2A, 0xD8, 0x48, 0x69, 0xD9, 0x2A, 0xD8, 0x68, 0x55, 0xDA, 0x32, 0xD8, 0x50, 0x71, 0xD9, |
syundo0730 | 3:25e1a5a10e53 | 218 | 0x32, 0xD8, 0x70, 0x5D, 0xDA, 0x3A, 0xD8, 0x58, 0x79, 0xD9, 0x3A, 0xD8, 0x78, 0x93, 0xA3, 0x4D, |
syundo0730 | 3:25e1a5a10e53 | 219 | 0xDA, 0x2A, 0xD8, 0x48, 0x69, 0xD9, 0x2A, 0xD8, 0x68, 0x55, 0xDA, 0x32, 0xD8, 0x50, 0x71, 0xD9, |
syundo0730 | 3:25e1a5a10e53 | 220 | 0x32, 0xD8, 0x70, 0x5D, 0xDA, 0x3A, 0xD8, 0x58, 0x79, 0xD9, 0x3A, 0xD8, 0x78, 0xA8, 0x8A, 0x9A, |
syundo0730 | 3:25e1a5a10e53 | 221 | 0xF0, 0x28, 0x50, 0x78, 0x9E, 0xF3, 0x88, 0x18, 0xF1, 0x9F, 0x1D, 0x98, 0xA8, 0xD9, 0x08, 0xD8, |
syundo0730 | 3:25e1a5a10e53 | 222 | 0xC8, 0x9F, 0x12, 0x9E, 0xF3, 0x15, 0xA8, 0xDA, 0x12, 0x10, 0xD8, 0xF1, 0xAF, 0xC8, 0x97, 0x87, |
syundo0730 | 3:25e1a5a10e53 | 223 | |
syundo0730 | 3:25e1a5a10e53 | 224 | // bank 5, 256 bytes |
syundo0730 | 3:25e1a5a10e53 | 225 | 0x34, 0xB5, 0xB9, 0x94, 0xA4, 0x21, 0xF3, 0xD9, 0x22, 0xD8, 0xF2, 0x2D, 0xF3, 0xD9, 0x2A, 0xD8, |
syundo0730 | 3:25e1a5a10e53 | 226 | 0xF2, 0x35, 0xF3, 0xD9, 0x32, 0xD8, 0x81, 0xA4, 0x60, 0x60, 0x61, 0xD9, 0x61, 0xD8, 0x6C, 0x68, |
syundo0730 | 3:25e1a5a10e53 | 227 | 0x69, 0xD9, 0x69, 0xD8, 0x74, 0x70, 0x71, 0xD9, 0x71, 0xD8, 0xB1, 0xA3, 0x84, 0x19, 0x3D, 0x5D, |
syundo0730 | 3:25e1a5a10e53 | 228 | 0xA3, 0x83, 0x1A, 0x3E, 0x5E, 0x93, 0x10, 0x30, 0x81, 0x10, 0x11, 0xB8, 0xB0, 0xAF, 0x8F, 0x94, |
syundo0730 | 3:25e1a5a10e53 | 229 | 0xF2, 0xDA, 0x3E, 0xD8, 0xB4, 0x9A, 0xA8, 0x87, 0x29, 0xDA, 0xF8, 0xD8, 0x87, 0x9A, 0x35, 0xDA, |
syundo0730 | 3:25e1a5a10e53 | 230 | 0xF8, 0xD8, 0x87, 0x9A, 0x3D, 0xDA, 0xF8, 0xD8, 0xB1, 0xB9, 0xA4, 0x98, 0x85, 0x02, 0x2E, 0x56, |
syundo0730 | 3:25e1a5a10e53 | 231 | 0xA5, 0x81, 0x00, 0x0C, 0x14, 0xA3, 0x97, 0xB0, 0x8A, 0xF1, 0x2D, 0xD9, 0x28, 0xD8, 0x4D, 0xD9, |
syundo0730 | 3:25e1a5a10e53 | 232 | 0x48, 0xD8, 0x6D, 0xD9, 0x68, 0xD8, 0xB1, 0x84, 0x0D, 0xDA, 0x0E, 0xD8, 0xA3, 0x29, 0x83, 0xDA, |
syundo0730 | 3:25e1a5a10e53 | 233 | 0x2C, 0x0E, 0xD8, 0xA3, 0x84, 0x49, 0x83, 0xDA, 0x2C, 0x4C, 0x0E, 0xD8, 0xB8, 0xB0, 0xA8, 0x8A, |
syundo0730 | 3:25e1a5a10e53 | 234 | 0x9A, 0xF5, 0x20, 0xAA, 0xDA, 0xDF, 0xD8, 0xA8, 0x40, 0xAA, 0xD0, 0xDA, 0xDE, 0xD8, 0xA8, 0x60, |
syundo0730 | 3:25e1a5a10e53 | 235 | 0xAA, 0xDA, 0xD0, 0xDF, 0xD8, 0xF1, 0x97, 0x86, 0xA8, 0x31, 0x9B, 0x06, 0x99, 0x07, 0xAB, 0x97, |
syundo0730 | 3:25e1a5a10e53 | 236 | 0x28, 0x88, 0x9B, 0xF0, 0x0C, 0x20, 0x14, 0x40, 0xB8, 0xB0, 0xB4, 0xA8, 0x8C, 0x9C, 0xF0, 0x04, |
syundo0730 | 3:25e1a5a10e53 | 237 | 0x28, 0x51, 0x79, 0x1D, 0x30, 0x14, 0x38, 0xB2, 0x82, 0xAB, 0xD0, 0x98, 0x2C, 0x50, 0x50, 0x78, |
syundo0730 | 3:25e1a5a10e53 | 238 | 0x78, 0x9B, 0xF1, 0x1A, 0xB0, 0xF0, 0x8A, 0x9C, 0xA8, 0x29, 0x51, 0x79, 0x8B, 0x29, 0x51, 0x79, |
syundo0730 | 3:25e1a5a10e53 | 239 | 0x8A, 0x24, 0x70, 0x59, 0x8B, 0x20, 0x58, 0x71, 0x8A, 0x44, 0x69, 0x38, 0x8B, 0x39, 0x40, 0x68, |
syundo0730 | 3:25e1a5a10e53 | 240 | 0x8A, 0x64, 0x48, 0x31, 0x8B, 0x30, 0x49, 0x60, 0xA5, 0x88, 0x20, 0x09, 0x71, 0x58, 0x44, 0x68, |
syundo0730 | 3:25e1a5a10e53 | 241 | |
syundo0730 | 3:25e1a5a10e53 | 242 | // bank 6, 256 bytes |
syundo0730 | 3:25e1a5a10e53 | 243 | 0x11, 0x39, 0x64, 0x49, 0x30, 0x19, 0xF1, 0xAC, 0x00, 0x2C, 0x54, 0x7C, 0xF0, 0x8C, 0xA8, 0x04, |
syundo0730 | 3:25e1a5a10e53 | 244 | 0x28, 0x50, 0x78, 0xF1, 0x88, 0x97, 0x26, 0xA8, 0x59, 0x98, 0xAC, 0x8C, 0x02, 0x26, 0x46, 0x66, |
syundo0730 | 3:25e1a5a10e53 | 245 | 0xF0, 0x89, 0x9C, 0xA8, 0x29, 0x51, 0x79, 0x24, 0x70, 0x59, 0x44, 0x69, 0x38, 0x64, 0x48, 0x31, |
syundo0730 | 3:25e1a5a10e53 | 246 | 0xA9, 0x88, 0x09, 0x20, 0x59, 0x70, 0xAB, 0x11, 0x38, 0x40, 0x69, 0xA8, 0x19, 0x31, 0x48, 0x60, |
syundo0730 | 3:25e1a5a10e53 | 247 | 0x8C, 0xA8, 0x3C, 0x41, 0x5C, 0x20, 0x7C, 0x00, 0xF1, 0x87, 0x98, 0x19, 0x86, 0xA8, 0x6E, 0x76, |
syundo0730 | 3:25e1a5a10e53 | 248 | 0x7E, 0xA9, 0x99, 0x88, 0x2D, 0x55, 0x7D, 0x9E, 0xB9, 0xA3, 0x8A, 0x22, 0x8A, 0x6E, 0x8A, 0x56, |
syundo0730 | 3:25e1a5a10e53 | 249 | 0x8A, 0x5E, 0x9F, 0xB1, 0x83, 0x06, 0x26, 0x46, 0x66, 0x0E, 0x2E, 0x4E, 0x6E, 0x9D, 0xB8, 0xAD, |
syundo0730 | 3:25e1a5a10e53 | 250 | 0x00, 0x2C, 0x54, 0x7C, 0xF2, 0xB1, 0x8C, 0xB4, 0x99, 0xB9, 0xA3, 0x2D, 0x55, 0x7D, 0x81, 0x91, |
syundo0730 | 3:25e1a5a10e53 | 251 | 0xAC, 0x38, 0xAD, 0x3A, 0xB5, 0x83, 0x91, 0xAC, 0x2D, 0xD9, 0x28, 0xD8, 0x4D, 0xD9, 0x48, 0xD8, |
syundo0730 | 3:25e1a5a10e53 | 252 | 0x6D, 0xD9, 0x68, 0xD8, 0x8C, 0x9D, 0xAE, 0x29, 0xD9, 0x04, 0xAE, 0xD8, 0x51, 0xD9, 0x04, 0xAE, |
syundo0730 | 3:25e1a5a10e53 | 253 | 0xD8, 0x79, 0xD9, 0x04, 0xD8, 0x81, 0xF3, 0x9D, 0xAD, 0x00, 0x8D, 0xAE, 0x19, 0x81, 0xAD, 0xD9, |
syundo0730 | 3:25e1a5a10e53 | 254 | 0x01, 0xD8, 0xF2, 0xAE, 0xDA, 0x26, 0xD8, 0x8E, 0x91, 0x29, 0x83, 0xA7, 0xD9, 0xAD, 0xAD, 0xAD, |
syundo0730 | 3:25e1a5a10e53 | 255 | 0xAD, 0xF3, 0x2A, 0xD8, 0xD8, 0xF1, 0xB0, 0xAC, 0x89, 0x91, 0x3E, 0x5E, 0x76, 0xF3, 0xAC, 0x2E, |
syundo0730 | 3:25e1a5a10e53 | 256 | 0x2E, 0xF1, 0xB1, 0x8C, 0x5A, 0x9C, 0xAC, 0x2C, 0x28, 0x28, 0x28, 0x9C, 0xAC, 0x30, 0x18, 0xA8, |
syundo0730 | 3:25e1a5a10e53 | 257 | 0x98, 0x81, 0x28, 0x34, 0x3C, 0x97, 0x24, 0xA7, 0x28, 0x34, 0x3C, 0x9C, 0x24, 0xF2, 0xB0, 0x89, |
syundo0730 | 3:25e1a5a10e53 | 258 | 0xAC, 0x91, 0x2C, 0x4C, 0x6C, 0x8A, 0x9B, 0x2D, 0xD9, 0xD8, 0xD8, 0x51, 0xD9, 0xD8, 0xD8, 0x79, |
syundo0730 | 3:25e1a5a10e53 | 259 | |
syundo0730 | 3:25e1a5a10e53 | 260 | // bank 7, 138 bytes (remainder) |
syundo0730 | 3:25e1a5a10e53 | 261 | 0xD9, 0xD8, 0xD8, 0xF1, 0x9E, 0x88, 0xA3, 0x31, 0xDA, 0xD8, 0xD8, 0x91, 0x2D, 0xD9, 0x28, 0xD8, |
syundo0730 | 3:25e1a5a10e53 | 262 | 0x4D, 0xD9, 0x48, 0xD8, 0x6D, 0xD9, 0x68, 0xD8, 0xB1, 0x83, 0x93, 0x35, 0x3D, 0x80, 0x25, 0xDA, |
syundo0730 | 3:25e1a5a10e53 | 263 | 0xD8, 0xD8, 0x85, 0x69, 0xDA, 0xD8, 0xD8, 0xB4, 0x93, 0x81, 0xA3, 0x28, 0x34, 0x3C, 0xF3, 0xAB, |
syundo0730 | 3:25e1a5a10e53 | 264 | 0x8B, 0xF8, 0xA3, 0x91, 0xB6, 0x09, 0xB4, 0xD9, 0xAB, 0xDE, 0xFA, 0xB0, 0x87, 0x9C, 0xB9, 0xA3, |
syundo0730 | 3:25e1a5a10e53 | 265 | 0xDD, 0xF1, 0xA3, 0xA3, 0xA3, 0xA3, 0x95, 0xF1, 0xA3, 0xA3, 0xA3, 0x9D, 0xF1, 0xA3, 0xA3, 0xA3, |
syundo0730 | 3:25e1a5a10e53 | 266 | 0xA3, 0xF2, 0xA3, 0xB4, 0x90, 0x80, 0xF2, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, |
syundo0730 | 3:25e1a5a10e53 | 267 | 0xA3, 0xB2, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xB0, 0x87, 0xB5, 0x99, 0xF1, 0xA3, 0xA3, 0xA3, |
syundo0730 | 3:25e1a5a10e53 | 268 | 0x98, 0xF1, 0xA3, 0xA3, 0xA3, 0xA3, 0x97, 0xA3, 0xA3, 0xA3, 0xA3, 0xF3, 0x9B, 0xA3, 0xA3, 0xDC, |
syundo0730 | 3:25e1a5a10e53 | 269 | 0xB9, 0xA7, 0xF1, 0x26, 0x26, 0x26, 0xD8, 0xD8, 0xFF |
syundo0730 | 3:25e1a5a10e53 | 270 | }; |
syundo0730 | 3:25e1a5a10e53 | 271 | |
syundo0730 | 3:25e1a5a10e53 | 272 | // thanks to Noah Zerkin for piecing this stuff together! |
syundo0730 | 3:25e1a5a10e53 | 273 | const unsigned char dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = { |
syundo0730 | 3:25e1a5a10e53 | 274 | // BANK OFFSET LENGTH [DATA] |
syundo0730 | 3:25e1a5a10e53 | 275 | 0x03, 0x7B, 0x03, 0x4C, 0xCD, 0x6C, // FCFG_1 inv_set_gyro_calibration |
syundo0730 | 3:25e1a5a10e53 | 276 | 0x03, 0xAB, 0x03, 0x36, 0x56, 0x76, // FCFG_3 inv_set_gyro_calibration |
syundo0730 | 3:25e1a5a10e53 | 277 | 0x00, 0x68, 0x04, 0x02, 0xCB, 0x47, 0xA2, // D_0_104 inv_set_gyro_calibration |
syundo0730 | 3:25e1a5a10e53 | 278 | 0x02, 0x18, 0x04, 0x00, 0x05, 0x8B, 0xC1, // D_0_24 inv_set_gyro_calibration |
syundo0730 | 3:25e1a5a10e53 | 279 | 0x01, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, // D_1_152 inv_set_accel_calibration |
syundo0730 | 3:25e1a5a10e53 | 280 | 0x03, 0x7F, 0x06, 0x0C, 0xC9, 0x2C, 0x97, 0x97, 0x97, // FCFG_2 inv_set_accel_calibration |
syundo0730 | 3:25e1a5a10e53 | 281 | 0x03, 0x89, 0x03, 0x26, 0x46, 0x66, // FCFG_7 inv_set_accel_calibration |
syundo0730 | 3:25e1a5a10e53 | 282 | 0x00, 0x6C, 0x02, 0x20, 0x00, // D_0_108 inv_set_accel_calibration |
syundo0730 | 3:25e1a5a10e53 | 283 | 0x02, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_00 inv_set_compass_calibration |
syundo0730 | 3:25e1a5a10e53 | 284 | 0x02, 0x44, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_01 |
syundo0730 | 3:25e1a5a10e53 | 285 | 0x02, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_02 |
syundo0730 | 3:25e1a5a10e53 | 286 | 0x02, 0x4C, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_10 |
syundo0730 | 3:25e1a5a10e53 | 287 | 0x02, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_11 |
syundo0730 | 3:25e1a5a10e53 | 288 | 0x02, 0x54, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_12 |
syundo0730 | 3:25e1a5a10e53 | 289 | 0x02, 0x58, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_20 |
syundo0730 | 3:25e1a5a10e53 | 290 | 0x02, 0x5C, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_21 |
syundo0730 | 3:25e1a5a10e53 | 291 | 0x02, 0xBC, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_22 |
syundo0730 | 3:25e1a5a10e53 | 292 | 0x01, 0xEC, 0x04, 0x00, 0x00, 0x40, 0x00, // D_1_236 inv_apply_endian_accel |
syundo0730 | 3:25e1a5a10e53 | 293 | 0x03, 0x7F, 0x06, 0x0C, 0xC9, 0x2C, 0x97, 0x97, 0x97, // FCFG_2 inv_set_mpu_sensors |
syundo0730 | 3:25e1a5a10e53 | 294 | 0x04, 0x02, 0x03, 0x0D, 0x35, 0x5D, // CFG_MOTION_BIAS inv_turn_on_bias_from_no_motion |
syundo0730 | 3:25e1a5a10e53 | 295 | 0x04, 0x09, 0x04, 0x87, 0x2D, 0x35, 0x3D, // FCFG_5 inv_set_bias_update |
syundo0730 | 3:25e1a5a10e53 | 296 | 0x00, 0xA3, 0x01, 0x00, // D_0_163 inv_set_dead_zone |
syundo0730 | 3:25e1a5a10e53 | 297 | // SPECIAL 0x01 = enable interrupts |
syundo0730 | 3:25e1a5a10e53 | 298 | 0x00, 0x00, 0x00, 0x01, // SET INT_ENABLE at i=22, SPECIAL INSTRUCTION |
syundo0730 | 3:25e1a5a10e53 | 299 | 0x07, 0x86, 0x01, 0xFE, // CFG_6 inv_set_fifo_interupt |
syundo0730 | 3:25e1a5a10e53 | 300 | 0x07, 0x41, 0x05, 0xF1, 0x20, 0x28, 0x30, 0x38, // CFG_8 inv_send_quaternion |
syundo0730 | 3:25e1a5a10e53 | 301 | 0x07, 0x7E, 0x01, 0x30, // CFG_16 inv_set_footer |
syundo0730 | 3:25e1a5a10e53 | 302 | 0x07, 0x46, 0x01, 0x9A, // CFG_GYRO_SOURCE inv_send_gyro |
syundo0730 | 3:25e1a5a10e53 | 303 | 0x07, 0x47, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_9 inv_send_gyro -> inv_construct3_fifo |
syundo0730 | 3:25e1a5a10e53 | 304 | 0x07, 0x6C, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_12 inv_send_accel -> inv_construct3_fifo |
syundo0730 | 3:25e1a5a10e53 | 305 | 0x02, 0x16, 0x02, 0x00, 0x01 // D_0_22 inv_set_fifo_rate |
syundo0730 | 3:25e1a5a10e53 | 306 | |
syundo0730 | 3:25e1a5a10e53 | 307 | // This very last 0x01 WAS a 0x09, which drops the FIFO rate down to 20 Hz. 0x07 is 25 Hz, |
syundo0730 | 3:25e1a5a10e53 | 308 | // 0x01 is 100Hz. Going faster than 100Hz (0x00=200Hz) tends to result in very noisy data. |
syundo0730 | 3:25e1a5a10e53 | 309 | // DMP output frequency is calculated easily using this equation: (200Hz / (1 + value)) |
syundo0730 | 3:25e1a5a10e53 | 310 | |
syundo0730 | 3:25e1a5a10e53 | 311 | // It is important to make sure the host processor can keep up with reading and processing |
syundo0730 | 3:25e1a5a10e53 | 312 | // the FIFO output at the desired rate. Handling FIFO overflow cleanly is also a good idea. |
syundo0730 | 3:25e1a5a10e53 | 313 | }; |
syundo0730 | 3:25e1a5a10e53 | 314 | |
syundo0730 | 3:25e1a5a10e53 | 315 | const unsigned char dmpUpdates[MPU6050_DMP_UPDATES_SIZE] PROGMEM = { |
syundo0730 | 3:25e1a5a10e53 | 316 | 0x01, 0xB2, 0x02, 0xFF, 0xFF, |
syundo0730 | 3:25e1a5a10e53 | 317 | 0x01, 0x90, 0x04, 0x09, 0x23, 0xA1, 0x35, |
syundo0730 | 3:25e1a5a10e53 | 318 | 0x01, 0x6A, 0x02, 0x06, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 319 | 0x01, 0x60, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 320 | 0x00, 0x60, 0x04, 0x40, 0x00, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 321 | 0x01, 0x62, 0x02, 0x00, 0x00, |
syundo0730 | 3:25e1a5a10e53 | 322 | 0x00, 0x60, 0x04, 0x00, 0x40, 0x00, 0x00 |
syundo0730 | 3:25e1a5a10e53 | 323 | }; |
syundo0730 | 3:25e1a5a10e53 | 324 | |
syundo0730 | 3:25e1a5a10e53 | 325 | uint8_t MPU6050::dmpInitialize() { |
syundo0730 | 3:25e1a5a10e53 | 326 | // reset device |
syundo0730 | 3:25e1a5a10e53 | 327 | DEBUG_PRINTLN(F("\n\nResetting MPU6050...")); |
syundo0730 | 3:25e1a5a10e53 | 328 | reset(); |
syundo0730 | 3:25e1a5a10e53 | 329 | //delay(30); // wait after reset |
syundo0730 | 3:25e1a5a10e53 | 330 | wait_ms(30); |
syundo0730 | 3:25e1a5a10e53 | 331 | |
syundo0730 | 3:25e1a5a10e53 | 332 | // enable sleep mode and wake cycle |
syundo0730 | 3:25e1a5a10e53 | 333 | /*Serial.println(F("Enabling sleep mode...")); |
syundo0730 | 3:25e1a5a10e53 | 334 | setSleepEnabled(true); |
syundo0730 | 3:25e1a5a10e53 | 335 | Serial.println(F("Enabling wake cycle...")); |
syundo0730 | 3:25e1a5a10e53 | 336 | setWakeCycleEnabled(true);*/ |
syundo0730 | 3:25e1a5a10e53 | 337 | |
syundo0730 | 3:25e1a5a10e53 | 338 | // disable sleep mode |
syundo0730 | 3:25e1a5a10e53 | 339 | DEBUG_PRINTLN(F("Disabling sleep mode...")); |
syundo0730 | 3:25e1a5a10e53 | 340 | setSleepEnabled(false); |
syundo0730 | 3:25e1a5a10e53 | 341 | |
syundo0730 | 3:25e1a5a10e53 | 342 | // get MPU hardware revision |
syundo0730 | 3:25e1a5a10e53 | 343 | DEBUG_PRINTLN(F("Selecting user bank 16...")); |
syundo0730 | 3:25e1a5a10e53 | 344 | setMemoryBank(0x10, true, true); |
syundo0730 | 3:25e1a5a10e53 | 345 | DEBUG_PRINTLN(F("Selecting memory byte 6...")); |
syundo0730 | 3:25e1a5a10e53 | 346 | setMemoryStartAddress(0x06); |
syundo0730 | 3:25e1a5a10e53 | 347 | DEBUG_PRINTLN(F("Checking hardware revision...")); |
syundo0730 | 3:25e1a5a10e53 | 348 | uint8_t hwRevision = readMemoryByte(); |
syundo0730 | 3:25e1a5a10e53 | 349 | DEBUG_PRINT(F("Revision @ user[16][6] = ")); |
syundo0730 | 3:25e1a5a10e53 | 350 | DEBUG_PRINTLNF(hwRevision, HEX); |
syundo0730 | 3:25e1a5a10e53 | 351 | DEBUG_PRINTLN(F("Resetting memory bank selection to 0...")); |
syundo0730 | 3:25e1a5a10e53 | 352 | setMemoryBank(0, false, false); |
syundo0730 | 3:25e1a5a10e53 | 353 | |
syundo0730 | 3:25e1a5a10e53 | 354 | // check OTP bank valid |
syundo0730 | 3:25e1a5a10e53 | 355 | DEBUG_PRINTLN(F("Reading OTP bank valid flag...")); |
syundo0730 | 3:25e1a5a10e53 | 356 | uint8_t otpValid = getOTPBankValid(); |
syundo0730 | 3:25e1a5a10e53 | 357 | DEBUG_PRINT(F("OTP bank is ")); |
syundo0730 | 3:25e1a5a10e53 | 358 | DEBUG_PRINTLN(otpValid ? F("valid!") : F("invalid!")); |
syundo0730 | 3:25e1a5a10e53 | 359 | |
syundo0730 | 3:25e1a5a10e53 | 360 | // get X/Y/Z gyro offsets |
syundo0730 | 3:25e1a5a10e53 | 361 | DEBUG_PRINTLN(F("Reading gyro offset TC values...")); |
syundo0730 | 3:25e1a5a10e53 | 362 | //int8_t xgOffsetTC = getXGyroOffsetTC(); |
syundo0730 | 3:25e1a5a10e53 | 363 | //int8_t ygOffsetTC = getYGyroOffsetTC(); |
syundo0730 | 3:25e1a5a10e53 | 364 | //int8_t zgOffsetTC = getZGyroOffsetTC(); |
syundo0730 | 3:25e1a5a10e53 | 365 | DEBUG_PRINT(F("X gyro offset = ")); |
syundo0730 | 3:25e1a5a10e53 | 366 | DEBUG_PRINTLN(xgOffset); |
syundo0730 | 3:25e1a5a10e53 | 367 | DEBUG_PRINT(F("Y gyro offset = ")); |
syundo0730 | 3:25e1a5a10e53 | 368 | DEBUG_PRINTLN(ygOffset); |
syundo0730 | 3:25e1a5a10e53 | 369 | DEBUG_PRINT(F("Z gyro offset = ")); |
syundo0730 | 3:25e1a5a10e53 | 370 | DEBUG_PRINTLN(zgOffset); |
syundo0730 | 3:25e1a5a10e53 | 371 | |
syundo0730 | 3:25e1a5a10e53 | 372 | // setup weird slave stuff (?) |
syundo0730 | 3:25e1a5a10e53 | 373 | DEBUG_PRINTLN(F("Setting slave 0 address to 0x7F...")); |
syundo0730 | 3:25e1a5a10e53 | 374 | setSlaveAddress(0, 0x7F); |
syundo0730 | 3:25e1a5a10e53 | 375 | DEBUG_PRINTLN(F("Disabling I2C Master mode...")); |
syundo0730 | 3:25e1a5a10e53 | 376 | setI2CMasterModeEnabled(false); |
syundo0730 | 3:25e1a5a10e53 | 377 | DEBUG_PRINTLN(F("Setting slave 0 address to 0x68 (self)...")); |
syundo0730 | 3:25e1a5a10e53 | 378 | setSlaveAddress(0, 0x68); |
syundo0730 | 3:25e1a5a10e53 | 379 | DEBUG_PRINTLN(F("Resetting I2C Master control...")); |
syundo0730 | 3:25e1a5a10e53 | 380 | resetI2CMaster(); |
syundo0730 | 3:25e1a5a10e53 | 381 | //delay(20); |
syundo0730 | 3:25e1a5a10e53 | 382 | wait_ms(20); |
syundo0730 | 3:25e1a5a10e53 | 383 | |
syundo0730 | 3:25e1a5a10e53 | 384 | // load DMP code into memory banks |
syundo0730 | 3:25e1a5a10e53 | 385 | DEBUG_PRINT(F("Writing DMP code to MPU memory banks (")); |
syundo0730 | 3:25e1a5a10e53 | 386 | DEBUG_PRINT(MPU6050_DMP_CODE_SIZE); |
syundo0730 | 3:25e1a5a10e53 | 387 | DEBUG_PRINTLN(F(" bytes)")); |
syundo0730 | 3:25e1a5a10e53 | 388 | if (writeProgMemoryBlock(dmpMemory, MPU6050_DMP_CODE_SIZE)) { |
syundo0730 | 3:25e1a5a10e53 | 389 | DEBUG_PRINTLN(F("Success! DMP code written and verified.")); |
syundo0730 | 3:25e1a5a10e53 | 390 | |
syundo0730 | 3:25e1a5a10e53 | 391 | // write DMP configuration |
syundo0730 | 3:25e1a5a10e53 | 392 | DEBUG_PRINT(F("Writing DMP configuration to MPU memory banks (")); |
syundo0730 | 3:25e1a5a10e53 | 393 | DEBUG_PRINT(MPU6050_DMP_CONFIG_SIZE); |
syundo0730 | 3:25e1a5a10e53 | 394 | DEBUG_PRINTLN(F(" bytes in config def)")); |
syundo0730 | 3:25e1a5a10e53 | 395 | if (writeProgDMPConfigurationSet(dmpConfig, MPU6050_DMP_CONFIG_SIZE)) { |
syundo0730 | 3:25e1a5a10e53 | 396 | DEBUG_PRINTLN(F("Success! DMP configuration written and verified.")); |
syundo0730 | 3:25e1a5a10e53 | 397 | |
syundo0730 | 3:25e1a5a10e53 | 398 | DEBUG_PRINTLN(F("Setting clock source to Z Gyro...")); |
syundo0730 | 3:25e1a5a10e53 | 399 | setClockSource(MPU6050_CLOCK_PLL_ZGYRO); |
syundo0730 | 3:25e1a5a10e53 | 400 | |
syundo0730 | 3:25e1a5a10e53 | 401 | DEBUG_PRINTLN(F("Setting DMP and FIFO_OFLOW interrupts enabled...")); |
syundo0730 | 3:25e1a5a10e53 | 402 | setIntEnabled(0x12); |
syundo0730 | 3:25e1a5a10e53 | 403 | |
syundo0730 | 3:25e1a5a10e53 | 404 | DEBUG_PRINTLN(F("Setting sample rate to 200Hz...")); |
syundo0730 | 3:25e1a5a10e53 | 405 | setRate(4); // 1khz / (1 + 4) = 200 Hz |
syundo0730 | 3:25e1a5a10e53 | 406 | |
syundo0730 | 3:25e1a5a10e53 | 407 | DEBUG_PRINTLN(F("Setting external frame sync to TEMP_OUT_L[0]...")); |
syundo0730 | 3:25e1a5a10e53 | 408 | setExternalFrameSync(MPU6050_EXT_SYNC_TEMP_OUT_L); |
syundo0730 | 3:25e1a5a10e53 | 409 | |
syundo0730 | 3:25e1a5a10e53 | 410 | DEBUG_PRINTLN(F("Setting DLPF bandwidth to 42Hz...")); |
syundo0730 | 3:25e1a5a10e53 | 411 | setDLPFMode(MPU6050_DLPF_BW_42); |
syundo0730 | 3:25e1a5a10e53 | 412 | |
syundo0730 | 3:25e1a5a10e53 | 413 | DEBUG_PRINTLN(F("Setting gyro sensitivity to +/- 2000 deg/sec...")); |
syundo0730 | 3:25e1a5a10e53 | 414 | setFullScaleGyroRange(MPU6050_GYRO_FS_2000); |
syundo0730 | 3:25e1a5a10e53 | 415 | |
syundo0730 | 3:25e1a5a10e53 | 416 | DEBUG_PRINTLN(F("Setting DMP configuration bytes (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 417 | setDMPConfig1(0x03); |
syundo0730 | 3:25e1a5a10e53 | 418 | setDMPConfig2(0x00); |
syundo0730 | 3:25e1a5a10e53 | 419 | |
syundo0730 | 3:25e1a5a10e53 | 420 | DEBUG_PRINTLN(F("Clearing OTP Bank flag...")); |
syundo0730 | 3:25e1a5a10e53 | 421 | setOTPBankValid(false); |
syundo0730 | 3:25e1a5a10e53 | 422 | |
syundo0730 | 3:25e1a5a10e53 | 423 | DEBUG_PRINTLN(F("Setting X/Y/Z gyro offset TCs to previous values...")); |
syundo0730 | 3:25e1a5a10e53 | 424 | //setXGyroOffsetTC(xgOffsetTC); |
syundo0730 | 3:25e1a5a10e53 | 425 | //setYGyroOffsetTC(ygOffsetTC); |
syundo0730 | 3:25e1a5a10e53 | 426 | //setZGyroOffsetTC(zgOffsetTC); |
syundo0730 | 3:25e1a5a10e53 | 427 | |
syundo0730 | 3:25e1a5a10e53 | 428 | //DEBUG_PRINTLN(F("Setting X/Y/Z gyro user offsets to zero...")); |
syundo0730 | 3:25e1a5a10e53 | 429 | //setXGyroOffset(0); |
syundo0730 | 3:25e1a5a10e53 | 430 | //setYGyroOffset(0); |
syundo0730 | 3:25e1a5a10e53 | 431 | //setZGyroOffset(0); |
syundo0730 | 3:25e1a5a10e53 | 432 | |
syundo0730 | 3:25e1a5a10e53 | 433 | DEBUG_PRINTLN(F("Writing final memory update 1/7 (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 434 | uint8_t dmpUpdate[16], j; |
syundo0730 | 3:25e1a5a10e53 | 435 | uint16_t pos = 0; |
syundo0730 | 3:25e1a5a10e53 | 436 | for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]); |
syundo0730 | 3:25e1a5a10e53 | 437 | writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); |
syundo0730 | 3:25e1a5a10e53 | 438 | |
syundo0730 | 3:25e1a5a10e53 | 439 | DEBUG_PRINTLN(F("Writing final memory update 2/7 (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 440 | for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]); |
syundo0730 | 3:25e1a5a10e53 | 441 | writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); |
syundo0730 | 3:25e1a5a10e53 | 442 | |
syundo0730 | 3:25e1a5a10e53 | 443 | DEBUG_PRINTLN(F("Resetting FIFO...")); |
syundo0730 | 3:25e1a5a10e53 | 444 | resetFIFO(); |
syundo0730 | 3:25e1a5a10e53 | 445 | |
syundo0730 | 3:25e1a5a10e53 | 446 | DEBUG_PRINTLN(F("Reading FIFO count...")); |
syundo0730 | 3:25e1a5a10e53 | 447 | uint16_t fifoCount = getFIFOCount(); |
syundo0730 | 3:25e1a5a10e53 | 448 | uint8_t fifoBuffer[128]; |
syundo0730 | 3:25e1a5a10e53 | 449 | |
syundo0730 | 3:25e1a5a10e53 | 450 | DEBUG_PRINT(F("Current FIFO count=")); |
syundo0730 | 3:25e1a5a10e53 | 451 | DEBUG_PRINTLN(fifoCount); |
syundo0730 | 3:25e1a5a10e53 | 452 | getFIFOBytes(fifoBuffer, fifoCount); |
syundo0730 | 3:25e1a5a10e53 | 453 | |
syundo0730 | 3:25e1a5a10e53 | 454 | DEBUG_PRINTLN(F("Setting motion detection threshold to 2...")); |
syundo0730 | 3:25e1a5a10e53 | 455 | setMotionDetectionThreshold(2); |
syundo0730 | 3:25e1a5a10e53 | 456 | |
syundo0730 | 3:25e1a5a10e53 | 457 | DEBUG_PRINTLN(F("Setting zero-motion detection threshold to 156...")); |
syundo0730 | 3:25e1a5a10e53 | 458 | setZeroMotionDetectionThreshold(156); |
syundo0730 | 3:25e1a5a10e53 | 459 | |
syundo0730 | 3:25e1a5a10e53 | 460 | DEBUG_PRINTLN(F("Setting motion detection duration to 80...")); |
syundo0730 | 3:25e1a5a10e53 | 461 | setMotionDetectionDuration(80); |
syundo0730 | 3:25e1a5a10e53 | 462 | |
syundo0730 | 3:25e1a5a10e53 | 463 | DEBUG_PRINTLN(F("Setting zero-motion detection duration to 0...")); |
syundo0730 | 3:25e1a5a10e53 | 464 | setZeroMotionDetectionDuration(0); |
syundo0730 | 3:25e1a5a10e53 | 465 | |
syundo0730 | 3:25e1a5a10e53 | 466 | DEBUG_PRINTLN(F("Resetting FIFO...")); |
syundo0730 | 3:25e1a5a10e53 | 467 | resetFIFO(); |
syundo0730 | 3:25e1a5a10e53 | 468 | |
syundo0730 | 3:25e1a5a10e53 | 469 | DEBUG_PRINTLN(F("Enabling FIFO...")); |
syundo0730 | 3:25e1a5a10e53 | 470 | setFIFOEnabled(true); |
syundo0730 | 3:25e1a5a10e53 | 471 | |
syundo0730 | 3:25e1a5a10e53 | 472 | DEBUG_PRINTLN(F("Enabling DMP...")); |
syundo0730 | 3:25e1a5a10e53 | 473 | setDMPEnabled(true); |
syundo0730 | 3:25e1a5a10e53 | 474 | |
syundo0730 | 3:25e1a5a10e53 | 475 | DEBUG_PRINTLN(F("Resetting DMP...")); |
syundo0730 | 3:25e1a5a10e53 | 476 | resetDMP(); |
syundo0730 | 3:25e1a5a10e53 | 477 | |
syundo0730 | 3:25e1a5a10e53 | 478 | DEBUG_PRINTLN(F("Writing final memory update 3/7 (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 479 | for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]); |
syundo0730 | 3:25e1a5a10e53 | 480 | writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); |
syundo0730 | 3:25e1a5a10e53 | 481 | |
syundo0730 | 3:25e1a5a10e53 | 482 | DEBUG_PRINTLN(F("Writing final memory update 4/7 (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 483 | for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]); |
syundo0730 | 3:25e1a5a10e53 | 484 | writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); |
syundo0730 | 3:25e1a5a10e53 | 485 | |
syundo0730 | 3:25e1a5a10e53 | 486 | DEBUG_PRINTLN(F("Writing final memory update 5/7 (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 487 | for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]); |
syundo0730 | 3:25e1a5a10e53 | 488 | writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); |
syundo0730 | 3:25e1a5a10e53 | 489 | |
syundo0730 | 3:25e1a5a10e53 | 490 | DEBUG_PRINTLN(F("Waiting for FIFO count > 2...")); |
syundo0730 | 3:25e1a5a10e53 | 491 | while ((fifoCount = getFIFOCount()) < 3); |
syundo0730 | 3:25e1a5a10e53 | 492 | |
syundo0730 | 3:25e1a5a10e53 | 493 | DEBUG_PRINT(F("Current FIFO count=")); |
syundo0730 | 3:25e1a5a10e53 | 494 | DEBUG_PRINTLN(fifoCount); |
syundo0730 | 3:25e1a5a10e53 | 495 | DEBUG_PRINTLN(F("Reading FIFO data...")); |
syundo0730 | 3:25e1a5a10e53 | 496 | getFIFOBytes(fifoBuffer, fifoCount); |
syundo0730 | 3:25e1a5a10e53 | 497 | |
syundo0730 | 3:25e1a5a10e53 | 498 | DEBUG_PRINTLN(F("Reading interrupt status...")); |
syundo0730 | 3:25e1a5a10e53 | 499 | uint8_t mpuIntStatus = getIntStatus(); |
syundo0730 | 3:25e1a5a10e53 | 500 | |
syundo0730 | 3:25e1a5a10e53 | 501 | DEBUG_PRINT(F("Current interrupt status=")); |
syundo0730 | 3:25e1a5a10e53 | 502 | DEBUG_PRINTLNF(mpuIntStatus, HEX); |
syundo0730 | 3:25e1a5a10e53 | 503 | |
syundo0730 | 3:25e1a5a10e53 | 504 | DEBUG_PRINTLN(F("Reading final memory update 6/7 (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 505 | for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]); |
syundo0730 | 3:25e1a5a10e53 | 506 | readMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); |
syundo0730 | 3:25e1a5a10e53 | 507 | |
syundo0730 | 3:25e1a5a10e53 | 508 | DEBUG_PRINTLN(F("Waiting for FIFO count > 2...")); |
syundo0730 | 3:25e1a5a10e53 | 509 | while ((fifoCount = getFIFOCount()) < 3); |
syundo0730 | 3:25e1a5a10e53 | 510 | |
syundo0730 | 3:25e1a5a10e53 | 511 | DEBUG_PRINT(F("Current FIFO count=")); |
syundo0730 | 3:25e1a5a10e53 | 512 | DEBUG_PRINTLN(fifoCount); |
syundo0730 | 3:25e1a5a10e53 | 513 | |
syundo0730 | 3:25e1a5a10e53 | 514 | DEBUG_PRINTLN(F("Reading FIFO data...")); |
syundo0730 | 3:25e1a5a10e53 | 515 | getFIFOBytes(fifoBuffer, fifoCount); |
syundo0730 | 3:25e1a5a10e53 | 516 | |
syundo0730 | 3:25e1a5a10e53 | 517 | DEBUG_PRINTLN(F("Reading interrupt status...")); |
syundo0730 | 3:25e1a5a10e53 | 518 | mpuIntStatus = getIntStatus(); |
syundo0730 | 3:25e1a5a10e53 | 519 | |
syundo0730 | 3:25e1a5a10e53 | 520 | DEBUG_PRINT(F("Current interrupt status=")); |
syundo0730 | 3:25e1a5a10e53 | 521 | DEBUG_PRINTLNF(mpuIntStatus, HEX); |
syundo0730 | 3:25e1a5a10e53 | 522 | |
syundo0730 | 3:25e1a5a10e53 | 523 | DEBUG_PRINTLN(F("Writing final memory update 7/7 (function unknown)...")); |
syundo0730 | 3:25e1a5a10e53 | 524 | for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]); |
syundo0730 | 3:25e1a5a10e53 | 525 | writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); |
syundo0730 | 3:25e1a5a10e53 | 526 | |
syundo0730 | 3:25e1a5a10e53 | 527 | DEBUG_PRINTLN(F("DMP is good to go! Finally.")); |
syundo0730 | 3:25e1a5a10e53 | 528 | |
syundo0730 | 3:25e1a5a10e53 | 529 | DEBUG_PRINTLN(F("Disabling DMP (you turn it on later)...")); |
syundo0730 | 3:25e1a5a10e53 | 530 | setDMPEnabled(false); |
syundo0730 | 3:25e1a5a10e53 | 531 | |
syundo0730 | 3:25e1a5a10e53 | 532 | DEBUG_PRINTLN(F("Setting up internal 42-byte (default) DMP packet buffer...")); |
syundo0730 | 3:25e1a5a10e53 | 533 | dmpPacketSize = 42; |
syundo0730 | 3:25e1a5a10e53 | 534 | /*if ((dmpPacketBuffer = (uint8_t *)malloc(42)) == 0) { |
syundo0730 | 3:25e1a5a10e53 | 535 | return 3; // TODO: proper error code for no memory |
syundo0730 | 3:25e1a5a10e53 | 536 | }*/ |
syundo0730 | 3:25e1a5a10e53 | 537 | |
syundo0730 | 3:25e1a5a10e53 | 538 | DEBUG_PRINTLN(F("Resetting FIFO and clearing INT status one last time...")); |
syundo0730 | 3:25e1a5a10e53 | 539 | resetFIFO(); |
syundo0730 | 3:25e1a5a10e53 | 540 | getIntStatus(); |
syundo0730 | 3:25e1a5a10e53 | 541 | } else { |
syundo0730 | 3:25e1a5a10e53 | 542 | DEBUG_PRINTLN(F("ERROR! DMP configuration verification failed.")); |
syundo0730 | 3:25e1a5a10e53 | 543 | return 2; // configuration block loading failed |
syundo0730 | 3:25e1a5a10e53 | 544 | } |
syundo0730 | 3:25e1a5a10e53 | 545 | } else { |
syundo0730 | 3:25e1a5a10e53 | 546 | DEBUG_PRINTLN(F("ERROR! DMP code verification failed.")); |
syundo0730 | 3:25e1a5a10e53 | 547 | return 1; // main binary block loading failed |
syundo0730 | 3:25e1a5a10e53 | 548 | } |
syundo0730 | 3:25e1a5a10e53 | 549 | return 0; // success |
syundo0730 | 3:25e1a5a10e53 | 550 | } |
syundo0730 | 3:25e1a5a10e53 | 551 | |
syundo0730 | 3:25e1a5a10e53 | 552 | bool MPU6050::dmpPacketAvailable() { |
syundo0730 | 3:25e1a5a10e53 | 553 | return getFIFOCount() >= dmpGetFIFOPacketSize(); |
syundo0730 | 3:25e1a5a10e53 | 554 | } |
syundo0730 | 3:25e1a5a10e53 | 555 | |
syundo0730 | 3:25e1a5a10e53 | 556 | // uint8_t MPU6050::dmpSetFIFORate(uint8_t fifoRate); |
syundo0730 | 3:25e1a5a10e53 | 557 | // uint8_t MPU6050::dmpGetFIFORate(); |
syundo0730 | 3:25e1a5a10e53 | 558 | // uint8_t MPU6050::dmpGetSampleStepSizeMS(); |
syundo0730 | 3:25e1a5a10e53 | 559 | // uint8_t MPU6050::dmpGetSampleFrequency(); |
syundo0730 | 3:25e1a5a10e53 | 560 | // int32_t MPU6050::dmpDecodeTemperature(int8_t tempReg); |
syundo0730 | 3:25e1a5a10e53 | 561 | |
syundo0730 | 3:25e1a5a10e53 | 562 | //uint8_t MPU6050::dmpRegisterFIFORateProcess(inv_obj_func func, int16_t priority); |
syundo0730 | 3:25e1a5a10e53 | 563 | //uint8_t MPU6050::dmpUnregisterFIFORateProcess(inv_obj_func func); |
syundo0730 | 3:25e1a5a10e53 | 564 | //uint8_t MPU6050::dmpRunFIFORateProcesses(); |
syundo0730 | 3:25e1a5a10e53 | 565 | |
syundo0730 | 3:25e1a5a10e53 | 566 | // uint8_t MPU6050::dmpSendQuaternion(uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 567 | // uint8_t MPU6050::dmpSendGyro(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 568 | // uint8_t MPU6050::dmpSendAccel(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 569 | // uint8_t MPU6050::dmpSendLinearAccel(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 570 | // uint8_t MPU6050::dmpSendLinearAccelInWorld(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 571 | // uint8_t MPU6050::dmpSendControlData(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 572 | // uint8_t MPU6050::dmpSendSensorData(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 573 | // uint8_t MPU6050::dmpSendExternalSensorData(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 574 | // uint8_t MPU6050::dmpSendGravity(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 575 | // uint8_t MPU6050::dmpSendPacketNumber(uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 576 | // uint8_t MPU6050::dmpSendQuantizedAccel(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 577 | // uint8_t MPU6050::dmpSendEIS(uint_fast16_t elements, uint_fast16_t accuracy); |
syundo0730 | 3:25e1a5a10e53 | 578 | |
syundo0730 | 3:25e1a5a10e53 | 579 | uint8_t MPU6050::dmpGetAccel(int32_t *data, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 580 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 581 | if (packet == 0) packet = dmpPacketBuffer; |
syundo0730 | 3:25e1a5a10e53 | 582 | data[0] = ((packet[28] << 24) + (packet[29] << 16) + (packet[30] << 8) + packet[31]); |
syundo0730 | 3:25e1a5a10e53 | 583 | data[1] = ((packet[32] << 24) + (packet[33] << 16) + (packet[34] << 8) + packet[35]); |
syundo0730 | 3:25e1a5a10e53 | 584 | data[2] = ((packet[36] << 24) + (packet[37] << 16) + (packet[38] << 8) + packet[39]); |
syundo0730 | 3:25e1a5a10e53 | 585 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 586 | } |
syundo0730 | 3:25e1a5a10e53 | 587 | uint8_t MPU6050::dmpGetAccel(int16_t *data, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 588 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 589 | if (packet == 0) packet = dmpPacketBuffer; |
syundo0730 | 3:25e1a5a10e53 | 590 | data[0] = (packet[28] << 8) + packet[29]; |
syundo0730 | 3:25e1a5a10e53 | 591 | data[1] = (packet[32] << 8) + packet[33]; |
syundo0730 | 3:25e1a5a10e53 | 592 | data[2] = (packet[36] << 8) + packet[37]; |
syundo0730 | 3:25e1a5a10e53 | 593 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 594 | } |
syundo0730 | 3:25e1a5a10e53 | 595 | uint8_t MPU6050::dmpGetAccel(VectorInt16 *v, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 596 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 597 | if (packet == 0) packet = dmpPacketBuffer; |
syundo0730 | 3:25e1a5a10e53 | 598 | v -> x = (packet[28] << 8) + packet[29]; |
syundo0730 | 3:25e1a5a10e53 | 599 | v -> y = (packet[32] << 8) + packet[33]; |
syundo0730 | 3:25e1a5a10e53 | 600 | v -> z = (packet[36] << 8) + packet[37]; |
syundo0730 | 3:25e1a5a10e53 | 601 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 602 | } |
syundo0730 | 3:25e1a5a10e53 | 603 | uint8_t MPU6050::dmpGetQuaternion(int32_t *data, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 604 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 605 | if (packet == 0) packet = dmpPacketBuffer; |
syundo0730 | 3:25e1a5a10e53 | 606 | data[0] = ((packet[0] << 24) + (packet[1] << 16) + (packet[2] << 8) + packet[3]); |
syundo0730 | 3:25e1a5a10e53 | 607 | data[1] = ((packet[4] << 24) + (packet[5] << 16) + (packet[6] << 8) + packet[7]); |
syundo0730 | 3:25e1a5a10e53 | 608 | data[2] = ((packet[8] << 24) + (packet[9] << 16) + (packet[10] << 8) + packet[11]); |
syundo0730 | 3:25e1a5a10e53 | 609 | data[3] = ((packet[12] << 24) + (packet[13] << 16) + (packet[14] << 8) + packet[15]); |
syundo0730 | 3:25e1a5a10e53 | 610 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 611 | } |
syundo0730 | 3:25e1a5a10e53 | 612 | uint8_t MPU6050::dmpGetQuaternion(int16_t *data, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 613 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 614 | if (packet == 0) packet = dmpPacketBuffer; |
syundo0730 | 3:25e1a5a10e53 | 615 | data[0] = ((packet[0] << 8) + packet[1]); |
syundo0730 | 3:25e1a5a10e53 | 616 | data[1] = ((packet[4] << 8) + packet[5]); |
syundo0730 | 3:25e1a5a10e53 | 617 | data[2] = ((packet[8] << 8) + packet[9]); |
syundo0730 | 3:25e1a5a10e53 | 618 | data[3] = ((packet[12] << 8) + packet[13]); |
syundo0730 | 3:25e1a5a10e53 | 619 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 620 | } |
syundo0730 | 3:25e1a5a10e53 | 621 | uint8_t MPU6050::dmpGetQuaternion(Quaternion *q, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 622 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 623 | int16_t qI[4]; |
syundo0730 | 3:25e1a5a10e53 | 624 | uint8_t status = dmpGetQuaternion(qI, packet); |
syundo0730 | 3:25e1a5a10e53 | 625 | if (status == 0) { |
syundo0730 | 3:25e1a5a10e53 | 626 | q -> w = (float)qI[0] / 16384.0f; |
syundo0730 | 3:25e1a5a10e53 | 627 | q -> x = (float)qI[1] / 16384.0f; |
syundo0730 | 3:25e1a5a10e53 | 628 | q -> y = (float)qI[2] / 16384.0f; |
syundo0730 | 3:25e1a5a10e53 | 629 | q -> z = (float)qI[3] / 16384.0f; |
syundo0730 | 3:25e1a5a10e53 | 630 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 631 | } |
syundo0730 | 3:25e1a5a10e53 | 632 | return status; // int16 return value, indicates error if this line is reached |
syundo0730 | 3:25e1a5a10e53 | 633 | } |
syundo0730 | 3:25e1a5a10e53 | 634 | // uint8_t MPU6050::dmpGet6AxisQuaternion(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 635 | // uint8_t MPU6050::dmpGetRelativeQuaternion(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 636 | uint8_t MPU6050::dmpGetGyro(int32_t *data, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 637 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 638 | if (packet == 0) packet = dmpPacketBuffer; |
syundo0730 | 3:25e1a5a10e53 | 639 | data[0] = ((packet[16] << 24) + (packet[17] << 16) + (packet[18] << 8) + packet[19]); |
syundo0730 | 3:25e1a5a10e53 | 640 | data[1] = ((packet[20] << 24) + (packet[21] << 16) + (packet[22] << 8) + packet[23]); |
syundo0730 | 3:25e1a5a10e53 | 641 | data[2] = ((packet[24] << 24) + (packet[25] << 16) + (packet[26] << 8) + packet[27]); |
syundo0730 | 3:25e1a5a10e53 | 642 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 643 | } |
syundo0730 | 3:25e1a5a10e53 | 644 | uint8_t MPU6050::dmpGetGyro(int16_t *data, const uint8_t* packet) { |
syundo0730 | 3:25e1a5a10e53 | 645 | // TODO: accommodate different arrangements of sent data (ONLY default supported now) |
syundo0730 | 3:25e1a5a10e53 | 646 | if (packet == 0) packet = dmpPacketBuffer; |
syundo0730 | 3:25e1a5a10e53 | 647 | data[0] = (packet[16] << 8) + packet[17]; |
syundo0730 | 3:25e1a5a10e53 | 648 | data[1] = (packet[20] << 8) + packet[21]; |
syundo0730 | 3:25e1a5a10e53 | 649 | data[2] = (packet[24] << 8) + packet[25]; |
syundo0730 | 3:25e1a5a10e53 | 650 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 651 | } |
syundo0730 | 3:25e1a5a10e53 | 652 | // uint8_t MPU6050::dmpSetLinearAccelFilterCoefficient(float coef); |
syundo0730 | 3:25e1a5a10e53 | 653 | // uint8_t MPU6050::dmpGetLinearAccel(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 654 | uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity) { |
syundo0730 | 3:25e1a5a10e53 | 655 | // get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g) |
syundo0730 | 3:25e1a5a10e53 | 656 | v -> x = vRaw -> x - gravity -> x*8192; |
syundo0730 | 3:25e1a5a10e53 | 657 | v -> y = vRaw -> y - gravity -> y*8192; |
syundo0730 | 3:25e1a5a10e53 | 658 | v -> z = vRaw -> z - gravity -> z*8192; |
syundo0730 | 3:25e1a5a10e53 | 659 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 660 | } |
syundo0730 | 3:25e1a5a10e53 | 661 | // uint8_t MPU6050::dmpGetLinearAccelInWorld(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 662 | uint8_t MPU6050::dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q) { |
syundo0730 | 3:25e1a5a10e53 | 663 | // rotate measured 3D acceleration vector into original state |
syundo0730 | 3:25e1a5a10e53 | 664 | // frame of reference based on orientation quaternion |
syundo0730 | 3:25e1a5a10e53 | 665 | memcpy(v, vReal, sizeof(VectorInt16)); |
syundo0730 | 3:25e1a5a10e53 | 666 | v -> rotate(q); |
syundo0730 | 3:25e1a5a10e53 | 667 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 668 | } |
syundo0730 | 3:25e1a5a10e53 | 669 | // uint8_t MPU6050::dmpGetGyroAndAccelSensor(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 670 | // uint8_t MPU6050::dmpGetGyroSensor(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 671 | // uint8_t MPU6050::dmpGetControlData(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 672 | // uint8_t MPU6050::dmpGetTemperature(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 673 | // uint8_t MPU6050::dmpGetGravity(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 674 | uint8_t MPU6050::dmpGetGravity(VectorFloat *v, Quaternion *q) { |
syundo0730 | 3:25e1a5a10e53 | 675 | v -> x = 2 * (q -> x*q -> z - q -> w*q -> y); |
syundo0730 | 3:25e1a5a10e53 | 676 | v -> y = 2 * (q -> w*q -> x + q -> y*q -> z); |
syundo0730 | 3:25e1a5a10e53 | 677 | v -> z = q -> w*q -> w - q -> x*q -> x - q -> y*q -> y + q -> z*q -> z; |
syundo0730 | 3:25e1a5a10e53 | 678 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 679 | } |
syundo0730 | 3:25e1a5a10e53 | 680 | // uint8_t MPU6050::dmpGetUnquantizedAccel(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 681 | // uint8_t MPU6050::dmpGetQuantizedAccel(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 682 | // uint8_t MPU6050::dmpGetExternalSensorData(long *data, int size, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 683 | // uint8_t MPU6050::dmpGetEIS(long *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 684 | |
syundo0730 | 3:25e1a5a10e53 | 685 | uint8_t MPU6050::dmpGetEuler(float *data, Quaternion *q) { |
syundo0730 | 3:25e1a5a10e53 | 686 | data[0] = atan2(2*q -> x*q -> y - 2*q -> w*q -> z, 2*q -> w*q -> w + 2*q -> x*q -> x - 1); // psi |
syundo0730 | 3:25e1a5a10e53 | 687 | data[1] = -asin(2*q -> x*q -> z + 2*q -> w*q -> y); // theta |
syundo0730 | 3:25e1a5a10e53 | 688 | data[2] = atan2(2*q -> y*q -> z - 2*q -> w*q -> x, 2*q -> w*q -> w + 2*q -> z*q -> z - 1); // phi |
syundo0730 | 3:25e1a5a10e53 | 689 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 690 | } |
syundo0730 | 3:25e1a5a10e53 | 691 | uint8_t MPU6050::dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity) { |
syundo0730 | 3:25e1a5a10e53 | 692 | // yaw: (about Z axis) |
syundo0730 | 3:25e1a5a10e53 | 693 | data[0] = atan2(2*q -> x*q -> y - 2*q -> w*q -> z, 2*q -> w*q -> w + 2*q -> x*q -> x - 1); |
syundo0730 | 3:25e1a5a10e53 | 694 | // pitch: (nose up/down, about Y axis) |
syundo0730 | 3:25e1a5a10e53 | 695 | data[1] = atan(gravity -> x / sqrt(gravity -> y*gravity -> y + gravity -> z*gravity -> z)); |
syundo0730 | 3:25e1a5a10e53 | 696 | // roll: (tilt left/right, about X axis) |
syundo0730 | 3:25e1a5a10e53 | 697 | data[2] = atan(gravity -> y / sqrt(gravity -> x*gravity -> x + gravity -> z*gravity -> z)); |
syundo0730 | 3:25e1a5a10e53 | 698 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 699 | } |
syundo0730 | 3:25e1a5a10e53 | 700 | |
syundo0730 | 3:25e1a5a10e53 | 701 | // uint8_t MPU6050::dmpGetAccelFloat(float *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 702 | // uint8_t MPU6050::dmpGetQuaternionFloat(float *data, const uint8_t* packet); |
syundo0730 | 3:25e1a5a10e53 | 703 | |
syundo0730 | 3:25e1a5a10e53 | 704 | uint8_t MPU6050::dmpProcessFIFOPacket(const unsigned char *dmpData) { |
syundo0730 | 3:25e1a5a10e53 | 705 | /*for (uint8_t k = 0; k < dmpPacketSize; k++) { |
syundo0730 | 3:25e1a5a10e53 | 706 | if (dmpData[k] < 0x10) Serial.print("0"); |
syundo0730 | 3:25e1a5a10e53 | 707 | Serial.print(dmpData[k], HEX); |
syundo0730 | 3:25e1a5a10e53 | 708 | Serial.print(" "); |
syundo0730 | 3:25e1a5a10e53 | 709 | } |
syundo0730 | 3:25e1a5a10e53 | 710 | Serial.print("\n");*/ |
syundo0730 | 3:25e1a5a10e53 | 711 | //Serial.println((uint16_t)dmpPacketBuffer); |
syundo0730 | 3:25e1a5a10e53 | 712 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 713 | } |
syundo0730 | 3:25e1a5a10e53 | 714 | uint8_t MPU6050::dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed) { |
syundo0730 | 3:25e1a5a10e53 | 715 | uint8_t status; |
syundo0730 | 3:25e1a5a10e53 | 716 | uint8_t buf[dmpPacketSize]; |
syundo0730 | 3:25e1a5a10e53 | 717 | for (uint8_t i = 0; i < numPackets; i++) { |
syundo0730 | 3:25e1a5a10e53 | 718 | // read packet from FIFO |
syundo0730 | 3:25e1a5a10e53 | 719 | getFIFOBytes(buf, dmpPacketSize); |
syundo0730 | 3:25e1a5a10e53 | 720 | |
syundo0730 | 3:25e1a5a10e53 | 721 | // process packet |
syundo0730 | 3:25e1a5a10e53 | 722 | if ((status = dmpProcessFIFOPacket(buf)) > 0) return status; |
syundo0730 | 3:25e1a5a10e53 | 723 | |
syundo0730 | 3:25e1a5a10e53 | 724 | // increment external process count variable, if supplied |
syundo0730 | 3:25e1a5a10e53 | 725 | if (processed != 0) *processed++; |
syundo0730 | 3:25e1a5a10e53 | 726 | } |
syundo0730 | 3:25e1a5a10e53 | 727 | return 0; |
syundo0730 | 3:25e1a5a10e53 | 728 | } |
syundo0730 | 3:25e1a5a10e53 | 729 | |
syundo0730 | 3:25e1a5a10e53 | 730 | // uint8_t MPU6050::dmpSetFIFOProcessedCallback(void (*func) (void)); |
syundo0730 | 3:25e1a5a10e53 | 731 | |
syundo0730 | 3:25e1a5a10e53 | 732 | // uint8_t MPU6050::dmpInitFIFOParam(); |
syundo0730 | 3:25e1a5a10e53 | 733 | // uint8_t MPU6050::dmpCloseFIFO(); |
syundo0730 | 3:25e1a5a10e53 | 734 | // uint8_t MPU6050::dmpSetGyroDataSource(uint_fast8_t source); |
syundo0730 | 3:25e1a5a10e53 | 735 | // uint8_t MPU6050::dmpDecodeQuantizedAccel(); |
syundo0730 | 3:25e1a5a10e53 | 736 | // uint32_t MPU6050::dmpGetGyroSumOfSquare(); |
syundo0730 | 3:25e1a5a10e53 | 737 | // uint32_t MPU6050::dmpGetAccelSumOfSquare(); |
syundo0730 | 3:25e1a5a10e53 | 738 | // void MPU6050::dmpOverrideQuaternion(long *q); |
syundo0730 | 3:25e1a5a10e53 | 739 | uint16_t MPU6050::dmpGetFIFOPacketSize() { |
syundo0730 | 3:25e1a5a10e53 | 740 | return dmpPacketSize; |
syundo0730 | 3:25e1a5a10e53 | 741 | } |
syundo0730 | 3:25e1a5a10e53 | 742 | |
syundo0730 | 3:25e1a5a10e53 | 743 | #endif /* _MPU6050_6AXIS_MOTIONAPPS20_H_ */ |