├── .gitignore ├── .gitmodules ├── README.md └── mtk ├── .gitignore ├── avr ├── avrdude.conf ├── boards.txt ├── bootloaders │ └── caterina │ │ ├── .gitignore │ │ ├── Caterina-promicro8.hex │ │ ├── Caterina-smart7688.hex │ │ ├── Caterina.c │ │ ├── Caterina.h │ │ ├── Descriptors.c │ │ ├── Descriptors.h │ │ ├── Makefile │ │ ├── Readme.txt │ │ ├── build.txt │ │ └── program.txt ├── driver │ └── linkit_smart_7688.inf ├── examples │ └── ArduinoISP_LinkItSmart7688 │ │ └── ArduinoISP_LinkItSmart7688.ino ├── platform.txt ├── programmers.txt └── variants │ └── smart7688 │ └── pins_arduino.h ├── gen_repo.bat ├── gen_repo.sh ├── gen_repo_json.py ├── package_linkit_index.json.template └── test_case ├── ADC_TEST └── ADC_TEST.ino └── libraries ├── Adafruit_10DOF ├── .gitignore ├── Adafruit_10DOF.cpp ├── Adafruit_10DOF.h ├── README.md ├── ahrs │ ├── ahrs.pde │ └── processing │ │ └── cuberotate │ │ ├── cuberotate.pde │ │ └── data │ │ ├── bunny.mtl │ │ └── bunny.obj ├── pitchrollheading │ └── pitchrollheading.pde └── tester │ └── tester.pde ├── Adafruit_BMP085_Unified ├── Adafruit_BMP085_U.cpp ├── Adafruit_BMP085_U.h ├── README.md ├── examples │ └── sensorapi │ │ └── sensorapi.pde └── library.properties ├── Adafruit_BMP183_Library ├── Adafruit_BMP183.cpp ├── Adafruit_BMP183.h ├── README.txt ├── examples │ └── BMP183test │ │ └── BMP183test.ino └── library.properties ├── Adafruit_BNO055 ├── Adafruit_BNO055.cpp ├── Adafruit_BNO055.h ├── README.md ├── examples │ ├── bunny │ │ ├── bunny.ino │ │ └── processing │ │ │ └── cuberotate │ │ │ ├── cuberotate.pde │ │ │ └── data │ │ │ ├── bunny.mtl │ │ │ └── bunny.obj │ ├── rawdata │ │ └── rawdata.ino │ └── sensorapi │ │ └── sensorapi.ino ├── library.properties └── utility │ ├── imumaths.h │ ├── matrix.h │ ├── quaternion.h │ └── vector.h ├── Adafruit_L3GD20_U ├── Adafruit_L3GD20_U.cpp ├── Adafruit_L3GD20_U.h ├── README.md ├── examples │ └── sensorapi │ │ └── sensorapi.pde └── library.properties ├── Adafruit_LSM303DLHC ├── .gitignore ├── Adafruit_LSM303_U.cpp ├── Adafruit_LSM303_U.h ├── README.md ├── examples │ ├── accelsensor │ │ └── accelsensor.pde │ └── magsensor │ │ └── magsensor.pde └── library.properties ├── Adafruit_MAX31855 ├── Adafruit_MAX31855.cpp ├── Adafruit_MAX31855.h ├── README.txt ├── examples │ ├── lcdthermocouple │ │ └── lcdthermocouple.ino │ └── serialthermocouple │ │ └── serialthermocouple.pde ├── keywords.txt ├── library.properties └── license.txt └── Adafruit_Sensor ├── Adafruit_Sensor.h ├── README.md └── library.properties /.gitignore: -------------------------------------------------------------------------------- 1 | mtk/avr/bootloaders/caterina/build.bat 2 | *.hex 3 | *.DS_Store -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "mtk/avr/bootloaders/caterina/LUFA-111009"] 2 | path = mtk/avr/bootloaders/caterina/LUFA-111009 3 | url = https://github.com/abcminiuser/lufa.git 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Arduino Supporting Package for LinkIt Smart 7688 Duo 2 | 3 | There is a Arduino IDE board support package for LinkIt Smart 7688 (Arduino Compatible). This allows you to program the ATMega32U4 with Arduino IDE. 4 | 5 | ## ENVIRONMENT 6 | The board support package shoud work with Arduino IDE 1.6.4 and later 7 | 8 | ## COM port 9 | The hardware is a USB serial COM port. 10 | - Bootloader COM port: `VID=0x0E8D, PID=0xAB00` 11 | - Arduino Sketch COM port: `VID=0x0E8D, PID=0xAB01` 12 | 13 | ### Windows 14 | A Windows Serial COM port INF driver is located in: `{ARDUINO_SKETCHBOOK_LOCATION}/hardware/mtk/avr/driver/linkit_smart_7688.inf` 15 | Note that in Window 8 you'll need to disable the "Driver Signature Enforcement" and in Windows 10 there is no need to install INF drivers - Windows 10 should recognize the board as a general USB Serial port. 16 | 17 | ### Linux 18 | It should work without the need to install a driver and mounted as. But just like normal arduino boards, it needs some additional permission configurations. For more detailed information, see the article on [ArchWiki](https://wiki.archlinux.org/index.php/arduino#Accessing_serial) and [Debian Wiki](https://wiki.debian.org/Arduino) for different distributions. 19 | 20 | ### OS X 21 | It should work without the need to install a driver and mounted as a serial device under `/dev/tty.usbmodem1413`. The number `1413` can be different on each OS X machine. 22 | 23 | ### How to Build the Release Package 24 | At this moment building the release pakcages requires: 25 | 26 | Requirements on Windows: 27 | - 7-zip 28 | - Python 2.7 with `requests` package installed 29 | - git 30 | - Internet connection 31 | 32 | Requirements on Linux: 33 | - zip command 34 | - Python 2.7 with `requests` package installed 35 | - git 36 | - Internet connection 37 | 38 | To build the release package on Windows 39 | - edit [`gen_repo.bat`](gen_repo.bat) and modify the version number 40 | - then execute `gen_repo.bat` 41 | 42 | To build the release package on Linux 43 | - edit [`gen_repo.sh`](gen_repo.sh) and modify the version number 44 | - then execute `bash gen_repo.sh` 45 | 46 | The build script will zip the `avr` supporting package and create a JSON description file, merging current JSON repository file from `download.labs.mediatek.com`. 47 | -------------------------------------------------------------------------------- /mtk/.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | -------------------------------------------------------------------------------- /mtk/avr/boards.txt: -------------------------------------------------------------------------------- 1 | 2 | menu.cpu=Processor 3 | 4 | 5 | 6 | ############################################################## 7 | 8 | smart7688.name=LinkIt Smart 7688 Duo 9 | smart7688.upload.via_ssh=true 10 | smart7688.vid.0=0x0E8D 11 | smart7688.pid.0=0xAB00 12 | smart7688.vid.1=0x0E8D 13 | smart7688.pid.1=0xAB01 14 | 15 | smart7688.upload.tool=avrdude 16 | smart7688.upload.protocol=avr109 17 | smart7688.upload.maximum_size=28672 18 | smart7688.upload.speed=57600 19 | smart7688.upload.disable_flushing=true 20 | smart7688.upload.use_1200bps_touch=true 21 | smart7688.upload.wait_for_upload_port=true 22 | 23 | smart7688.bootloader.tool=avrdude 24 | smart7688.bootloader.low_fuses=0xff 25 | smart7688.bootloader.high_fuses=0xd8 26 | smart7688.bootloader.extended_fuses=0xce 27 | smart7688.bootloader.file=caterina/Caterina-smart7688.hex 28 | smart7688.bootloader.unlock_bits=0x3F 29 | smart7688.bootloader.lock_bits=0x2F 30 | 31 | smart7688.build.board=AVR_LINKITSMART7688 32 | smart7688.build.mcu=atmega32u4 33 | smart7688.build.f_cpu=8000000L 34 | smart7688.build.vid=0x0E8D 35 | smart7688.build.pid=0xAB01 36 | smart7688.build.usb_product="LinkIt Smart 7688 Duo" 37 | smart7688.build.usb_manufacturer="MediaTek Labs" 38 | smart7688.build.core=arduino:arduino 39 | smart7688.build.variant=smart7688 40 | smart7688.build.extra_flags={build.usb_flags} 41 | -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/.gitignore: -------------------------------------------------------------------------------- 1 | .dep 2 | *.o 3 | *.lst 4 | *.lss 5 | *.map 6 | *.eep 7 | *.elf 8 | *.sym 9 | 10 | 11 | -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/Caterina-promicro8.hex: -------------------------------------------------------------------------------- 1 | :1070000055C000006EC000006CC000006AC00000E7 2 | :1070100068C0000066C0000064C0000062C00000DC 3 | :1070200060C000005EC00000FCC400005AC0000048 4 | :1070300058C0000056C0000054C0000052C00000FC 5 | :1070400050C000005DC000004CC000004AC00000FD 6 | :1070500048C0000046C0000044C0000042C000001C 7 | :1070600040C000003EC000003CC000003AC000002C 8 | :1070700038C0000036C0000034C0000032C000003C 9 | :1070800030C000002EC000002CC000002AC000004C 10 | :1070900028C0000026C0000024C0000022C000005C 11 | :1070A00020C000001EC000001CC0000011241FBE34 12 | :1070B000CFEFDAE0DEBFCDBF11E0A0E0B1E0E2E467 13 | :1070C000FFE702C005900D92A43BB107D9F711E08C 14 | :1070D000A4EBB1E001C01D92AD3CB107E1F74FD385 15 | :1070E0002EC78ECFF89410926F001092810081E02D 16 | :1070F00085BF15BE47985D9A289A0C9400000895A4 17 | :107100001F920F920FB60F9211242F938F939F937C 18 | :10711000EF93FF9310928500109284008091B40148 19 | :107120009091B501009741F001979093B50180933C 20 | :10713000B401892B09F45D9A8091B6019091B70151 21 | :10714000009741F001979093B7018093B601892B86 22 | :1071500009F4289A8091BA019091BB01019690930D 23 | :10716000BB018093BA01E0E0F0E0859194918F5FDC 24 | :107170009F4F49F08091B8019091B9010196909389 25 | :10718000B9018093B801FF91EF919F918F912F9159 26 | :107190000F900FBE0F901F90189584E08093E90028 27 | :1071A0000DC08091E8008B778093E80003C08EB318 28 | :1071B000882351F08091E80082FFF9CF8091E800A8 29 | :1071C00085FFEFCF8091F1000895982F83E08093A1 30 | :1071D000E9008091E80085FD0DC08091E8008E7780 31 | :1071E0008093E80003C08EB3882369F08091E800A3 32 | :1071F00080FFF9CF9093F1005D9884E690E0909342 33 | :10720000B5018093B40108954F925F926F927F927F 34 | :107210008F929F92AF92BF92CF92DF92EF92FF92A6 35 | :107220000F931F93CF93DF9384E08093E9008091C5 36 | :10723000E80082FF57C2289884E690E09093B70157 37 | :107240008093B601AADF182F853481F48CEA9DE083 38 | :107250009093B9018093B80107B600FCFDCFF9996E 39 | :10726000FECF81E180935700E89503C0843519F47F 40 | :1072700094DF8DE00DC28C34E1F38035D1F3843797 41 | :1072800021F484E4A2DF80E003C2813611F489E5B1 42 | :10729000FFC18134B1F481DF182F7FDF90E0880FC8 43 | :1072A000991FAA2797FDA095BA2F312F330F20E001 44 | :1072B000442737FD4095542F822B932BA42BB52BBD 45 | :1072C000B8C1803711F483E5E3C1833549F4C0E0E8 46 | :1072D000D1E089917ADF21E0C730D207D1F7D9C157 47 | :1072E000863521F481E371DF80E3D2C1833731F445 48 | :1072F00087E86BDF85E969DF8EE1CAC18536B9F4BD 49 | :10730000E0E0F0E093E085E090935700E89507B661 50 | :1073100000FCFDCF80935700E89507B600FCFDCF39 51 | :10732000E058FF4FA0E7E030FA0771F7A2CF8237AD 52 | :1073300039F4E1E0F0E089E0809357008491A8C13E 53 | :10734000863439F4E0E0F0E089E0809357008491DE 54 | :107350009FC18E3439F4E3E0F0E089E08093570078 55 | :10736000849196C1813539F4E2E0F0E089E08093C0 56 | :10737000570084918DC1823631F489E526DF80E0A3 57 | :1073800024DF80E885C1823419F0873609F0E5C032 58 | :107390001092B9011092B80100DF082FFEDEF82E1E 59 | :1073A000FCDE682E8554823008F071C1902F80E099 60 | :1073B000CF2DD0E0C82BD92B10926F00173609F0D3 61 | :1073C0004BC081E180935700E895DD24CC24C39421 62 | :1073D0003FC0E090BD01F090BE010091BF0110914F 63 | :1073E000C001B6E46B16D9F4ED2DF0E0EE29FF29CB 64 | :1073F000E4918E2FEADEDD2081F082E090E0A0E0D3 65 | :10740000B0E0E80EF91E0A1F1B1FE092BD01F092CA 66 | :10741000BE010093BF011093C001DC2418C0D80145 67 | :10742000C701B695A7959795879573D5CEDE82E06F 68 | :1074300090E0A0E0B0E0E80EF91E0A1F1B1FE092EA 69 | :10744000BD01F092BE010093BF011093C0012197CE 70 | :10745000209709F0BECF7DC08090BD019090BE0105 71 | :10746000A090BF01B090C00196E4691609F05DC01C 72 | :1074700083E0F40180935700E89507B600FCFDCF48 73 | :1074800054C0F6E46F1661F5772031F1E090BD014C 74 | :10749000F090BE010091BF011091C0017EDED82E98 75 | :1074A000CC24852D90E08C299D29F7010C01409278 76 | :1074B0005700E895112482E090E0A0E0B0E0E80EEB 77 | :1074C000F91E0A1F1B1FE092BD01F092BE0100933E 78 | :1074D000BF011093C00102C060DE582E742423C087 79 | :1074E000E090BD01F090BE010091BF011091C0017C 80 | :1074F00016950795F794E79450DE682FC70111D5CC 81 | :107500008091BD019091BE01A091BF01B091C001D9 82 | :107510000296A11DB11D8093BD019093BE01A09361 83 | :10752000BF01B093C001219704C05524772444249F 84 | :107530004394209709F0A5CF96E4691641F485E0BD 85 | :10754000F40180935700E89507B600FCFDCF8DE06D 86 | :107550003CDE82E080936F009CC0833471F4009124 87 | :10756000BD011091BE0119DE90E021E0F8010C018F 88 | :1075700020935700E89511247CCE833619F5E090CE 89 | :10758000BD01F090BE010091BF011091C00105DE68 90 | :10759000F701E16090E021E00C0120935700E895AD 91 | :1075A000112482E090E0A0E0B0E0E80EF91E0A1F8E 92 | :1075B0001B1FE092BD01F092BE010093BF0110932A 93 | :1075C000C00157CE8D3661F4E091BD01F091BE014E 94 | :1075D00085E080935700E89507B600FCFDCF49CEC3 95 | :1075E000823551F4E091BD01F091BE0105911491F5 96 | :1075F000812FEBDD802F4CC0843421F5E090BD015C 97 | :10760000F090BE010091BF011091C0011695079541 98 | :10761000F794E794C2DD682FC70183D48091BD0140 99 | :107620009091BE01A091BF01B091C0010296A11D31 100 | :10763000B11D8093BD019093BE01A093BF01B09393 101 | :10764000C00117CE843609F5E090BD01F090BE016F 102 | :107650000091BF011091C001D801C701B695A7954F 103 | :107660009795879556D4B1DD82E090E0A0E0B0E038 104 | :10767000E80EF91E0A1F1B1FE092BD01F092BE0129 105 | :107680000093BF011093C00104C08B3111F08FE350 106 | :107690009CDD83E08093E9009091E8008091E80010 107 | :1076A0008E778093E80095FF04C010C08EB38823C6 108 | :1076B000C9F08091E80080FFF9CF8091E8008E77D3 109 | :1076C0008093E80003C08EB3882361F08091E800C6 110 | :1076D00080FFF9CF84E08093E9008091E8008B7708 111 | :1076E0008093E800DF91CF911F910F91FF90EF9071 112 | :1076F000DF90CF90BF90AF909F908F907F906F90D2 113 | :107700005F904F9008959091C501892F8F778132B6 114 | :1077100049F58091C6018032A1F0813219F5913A84 115 | :1077200009F58091E800877F8093E8008CE091E084 116 | :1077300067E070E025D28091E8008B778093E800C5 117 | :107740000895913279F48091E800877F8093E80072 118 | :107750008CE091E067E070E077D28091E8008E776E 119 | :107760008093E800089582E061EC42E0D1D083E0AC 120 | :1077700061E842E1CDD084E060E842E1C9C01F93F6 121 | :10778000209100081092000844B714BE88E10FB69B 122 | :10779000F89480936000109260000FBE80E8E0E0F3 123 | :1077A000F0E00FB6F89480936100E09361000FBEA3 124 | :1077B00031E035BF92E095BF3F9A209A559A809369 125 | :1077C00061001092610047985D9A289A1092890092 126 | :1077D0008AEF8093880090936F0083E0809381000C 127 | :1077E000859194918F5F9F4F11F03093BC01942F3E 128 | :1077F00041FF19C0809109012817A9F08093000862 129 | :10780000789480911301882339F08091BA01909186 130 | :10781000BB0188579140C8F3F8941092000881E0AA 131 | :10782000809313010CC090FF04C08091BC01882399 132 | :1078300051F493FF09C080910901281729F0809124 133 | :10784000BC01882309F04EDCD4D078941092B901A1 134 | :107850001092B8011EEF20C0D7DC49D38091B80147 135 | :107860009091B901815A9F4010F0109213018091BC 136 | :10787000C1019091C20101969093C2018093C10110 137 | :10788000292F97FF03C0512F591B252F220F28178F 138 | :1078900010F4479801C0479A809113018823E1F6BC 139 | :1078A0008091E00081608093E0001CDC80E090E04B 140 | :1078B0001F910895FA01923049F0933061F09130B0 141 | :1078C000F9F484E191E022E130E01EC086E291E02B 142 | :1078D0002EE330E019C0882329F484E691E024E007 143 | :1078E00030E012C0813029F488E691E02EE130E0EA 144 | :1078F0000BC0823029F488E891E02AE230E004C02D 145 | :1079000080E090E020E030E091838083C901089519 146 | :107910008093E9008091EB0081608093EB001092EE 147 | :10792000ED006093EC004093ED008091EE00881F25 148 | :107930008827881F08958091C50188238CF403C08F 149 | :107940008EB38823B1F08091E80082FFF9CF809157 150 | :10795000E8008B778093E80008958EB3882349F080 151 | :107960008091E80080FFF9CF8091E8008E778093C6 152 | :10797000E8000895EF92FF920F931F9345D04CD0EB 153 | :1079800008ED10E0F80180818F7780838081806826 154 | :10799000808380818F7D808319BC1EBA1092C301C1 155 | :1079A00080EEE82EF12CF70180818B7F8083F80137 156 | :1079B00080818160808380E060E042E0A9DFE1EEC9 157 | :1079C000F0E080818E7F8083E2EEF0E08081816054 158 | :1079D0008083808188608083F70180818E7F8083AF 159 | :1079E000F8018081806180831F910F91FF90EF905B 160 | :1079F0000895E7EDF0E08081816080838AE482BFB2 161 | :107A000081E08093C401B6CFE8EDF0E080818E7F05 162 | :107A100080831092E20008951092DA001092E10043 163 | :107A200008951F920F920FB60F9211242F933F9338 164 | :107A30004F935F936F937F938F939F93AF93BF9376 165 | :107A4000EF93FF938091DA0080FF1AC08091D800F5 166 | :107A500080FF16C08091DA008E7F8093DA008091DB 167 | :107A6000D90080FF0AC019BC82E089BD09B400FEBC 168 | :107A7000FDCF81E08EBB3AD203C019BC1EBA36D20C 169 | :107A80008091E10080FF17C08091E20080FF13C069 170 | :107A90008091E2008E7F8093E2008091E20080611D 171 | :107AA0008093E2008091D80080628093D80019BC56 172 | :107AB00085E08EBB1BD28091E10084FF2BC08091BA 173 | :107AC000E20084FF27C019BC82E089BD09B400FE32 174 | :107AD000FDCF8091D8008F7D8093D8008091E10008 175 | :107AE0008F7E8093E1008091E2008F7E8093E200A0 176 | :107AF0008091E20081608093E2008091C30188233D 177 | :107B000031F48091E30087FD02C081E001C084E090 178 | :107B10008EBBECD18091E10083FF21C08091E20017 179 | :107B200083FF1DC08091E100877F8093E10082E0A8 180 | :107B30008EBB1092C3018091E1008E7F8093E100A3 181 | :107B40008091E2008E7F8093E2008091E20080616C 182 | :107B50008093E20080E060E042E0DADEC7D1FF918E 183 | :107B6000EF91BF91AF919F918F917F916F915F91B5 184 | :107B70004F913F912F910F900FBE0F901F9018952E 185 | :107B80009C014091CB015091CC014617570718F446 186 | :107B9000F90190E044C06115710511F0AB01F8CF17 187 | :107BA0008091E8008E778093E80040E050E0F0CFCD 188 | :107BB0008EB3882309F444C0853009F443C0809112 189 | :107BC000E80083FF02C081E008958091E80082FD13 190 | :107BD00031C08091E80080FF22C08091F300909135 191 | :107BE000F200782F60E0292F30E0262B372B07C0DA 192 | :107BF00081918093F100415050402F5F3F4F4115DC 193 | :107C0000510519F02830310598F390E028303105FE 194 | :107C100009F491E08091E8008E778093E8004115A7 195 | :107C2000510531F6992321F605C08EB3882341F022 196 | :107C3000853041F08091E80082FFF7CF80E0089521 197 | :107C400082E0089583E008959C016115710529F48F 198 | :107C50008091E8008B778093E800F90126C08EB30D 199 | :107C6000882391F1853091F18091E80083FF02C073 200 | :107C700081E008958091E80082FFF1CF06C08091F5 201 | :107C8000F10081936150704059F02091F300809190 202 | :107C9000F200322F20E090E0822B932B892B79F792 203 | :107CA0008091E8008B778093E80061157105B9F643 204 | :107CB00005C08EB3882341F0853041F08091E80003 205 | :107CC00080FFF7CF80E0089582E0089583E0089573 206 | :107CD0000F931F93DF93CF9300D0CDB7DEB7E5ECC2 207 | :107CE000F1E08091F100819381E0ED3CF807C9F764 208 | :107CF0000ADD8091E80083FFE4C08091C501909186 209 | :107D0000C601953009F46DC0963040F4913081F190 210 | :107D1000913070F0933009F0D4C02AC0983009F443 211 | :107D2000A3C0993009F4B2C0963009F0CAC07CC033 212 | :107D3000803809F4C6C0823809F0C3C08091C901F7 213 | :107D400087708093E9008091EB001092E900209108 214 | :107D5000E800277F2093E80090E025E0969587953E 215 | :107D60002A95E1F781708093F1001092F10087C0AD 216 | :107D7000882319F0823009F0A4C08F71823009F095 217 | :107D8000A0C08091C701882331F52091C9012770D7 218 | :107D900009F497C02093E9008091EB0080FF1BC09D 219 | :107DA000933021F48091EB00806213C08091EB004E 220 | :107DB00080618093EB0081E090E002C0880F991F02 221 | :107DC0002A95E2F78093EA001092EA008091EB0096 222 | :107DD00088608093EB001092E9008091E800877F33 223 | :107DE00051C0882309F06DC01091C7011F770FB7EC 224 | :107DF000F8948091E800877F8093E8009CDD809173 225 | :107E0000E80080FFFCCF8091E3008078812B809395 226 | :107E1000E30080688093E300112311F482E001C045 227 | :107E200083E08EBB0FBF4DC08058823008F049C040 228 | :107E30008091C7019091C8016091C901AE014F5F67 229 | :107E40005F4F38DDBC01009709F43BC08091E8002A 230 | :107E5000877F8093E80089819A8192DE8091E80093 231 | :107E60008B778093E8002DC0803859F58091E80029 232 | :107E7000877F8093E8008091C3018093F100809117 233 | :107E8000E8008E778093E80056DD1BC08823C9F494 234 | :107E90009091C7019230A8F48091E800877F809389 235 | :107EA000E8009093C30147DD8091C301882331F43A 236 | :107EB0008091E30087FD02C081E001C084E08EBBB9 237 | :107EC00052DC8091E80083FF0AC08091EB00806261 238 | :107ED0008093EB008091E800877F8093E8000F900B 239 | :107EE0000F90CF91DF911F910F91089508951F93E7 240 | :107EF0008EB3882361F01091E9001092E90080911F 241 | :107F0000E80083FF01C0E4DE17701093E9001F91C1 242 | :107F10000895F999FECF92BD81BDF89A992780B551 243 | :107F20000895262FF999FECF1FBA92BD81BD20BDBD 244 | :107F30000FB6F894FA9AF99A0FBE01960895F8943C 245 | :027F4000FFCF71 246 | :107F42004341544552494E41007700080000000069 247 | :107F52000000080112011001020000084F1B0392E9 248 | :107F620001000201000109023E0002010080320903 249 | :107F72000400000102020100052400100104240291 250 | :107F8200040524060001070582030800FF09040115 251 | :107F920000020A0000000705040210000107058321 252 | :107FA20002100001040309041E03500072006F0056 253 | :107FB20020004D006900630072006F002000330052 254 | :107FC2002E003300560000002A03530070006100A7 255 | :107FD20072006B00460075006E00200045006C00C8 256 | :107FE20065006300740072006F006E006900630038 257 | :047FF2007300000018 258 | :040000030000700089 259 | :00000001FF 260 | -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/Caterina.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for BootloaderCDC.c. 34 | */ 35 | 36 | #ifndef _CDC_H_ 37 | #define _CDC_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "Descriptors.h" 49 | 50 | #include 51 | /* Macros: */ 52 | /** Version major of the CDC bootloader. */ 53 | #define BOOTLOADER_VERSION_MAJOR 0x01 54 | 55 | /** Version minor of the CDC bootloader. */ 56 | #define BOOTLOADER_VERSION_MINOR 0x00 57 | 58 | /** Hardware version major of the CDC bootloader. */ 59 | #define BOOTLOADER_HWVERSION_MAJOR 0x01 60 | 61 | /** Hardware version minor of the CDC bootloader. */ 62 | #define BOOTLOADER_HWVERSION_MINOR 0x00 63 | 64 | /** Eight character bootloader firmware identifier reported to the host when requested */ 65 | #define SOFTWARE_IDENTIFIER "CATERINA" 66 | 67 | #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) 68 | #define LED_SETUP() DDRC |= (1<<7); DDRB |= (1<<0); DDRD |= (1<<5); 69 | #define L_LED_OFF() PORTC &= ~(1<<7) 70 | #define L_LED_ON() PORTC |= (1<<7) 71 | #define L_LED_TOGGLE() PORTC ^= (1<<7) 72 | #define TX_LED_OFF() PORTD |= (1<<5) 73 | #define TX_LED_ON() PORTD &= ~(1<<5) 74 | #define RX_LED_OFF() PORTB |= (1<<0) 75 | #define RX_LED_ON() PORTB &= ~(1<<0) 76 | 77 | /* Type Defines: */ 78 | /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ 79 | typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; 80 | 81 | /* Function Prototypes: */ 82 | void StartSketch(void); 83 | void LEDPulse(void); 84 | 85 | void CDC_Task(void); 86 | void SetupHardware(void); 87 | 88 | void EVENT_USB_Device_ConfigurationChanged(void); 89 | 90 | #if defined(INCLUDE_FROM_CATERINA_C) || defined(__DOXYGEN__) 91 | #if !defined(NO_BLOCK_SUPPORT) 92 | static void ReadWriteMemoryBlock(const uint8_t Command); 93 | #endif 94 | static uint8_t FetchNextCommandByte(void); 95 | static void WriteNextResponseByte(const uint8_t Response); 96 | #endif 97 | 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/Descriptors.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * USB Device Descriptors, for library use when in USB device mode. Descriptors are special 34 | * computer-readable structures which the host requests upon device enumeration, to determine 35 | * the device's capabilities and functions. 36 | */ 37 | 38 | #include "Descriptors.h" 39 | 40 | /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall 41 | * device characteristics, including the supported USB version, control endpoint size and the 42 | * number of device configurations. The descriptor is read out by the USB host when the enumeration 43 | * process begins. 44 | */ 45 | const USB_Descriptor_Device_t DeviceDescriptor = 46 | { 47 | .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, 48 | 49 | .USBSpecification = VERSION_BCD(01.10), 50 | .Class = CDC_CSCP_CDCClass, 51 | .SubClass = CDC_CSCP_NoSpecificSubclass, 52 | .Protocol = CDC_CSCP_NoSpecificProtocol, 53 | 54 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, 55 | 56 | .VendorID = DEVICE_VID, 57 | .ProductID = DEVICE_PID, 58 | .ReleaseNumber = VERSION_BCD(00.01), 59 | 60 | .ManufacturerStrIndex = 0x02, 61 | .ProductStrIndex = 0x01, 62 | .SerialNumStrIndex = NO_DESCRIPTOR, 63 | 64 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS 65 | }; 66 | 67 | /** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage 68 | * of the device in one of its supported configurations, including information about any device interfaces 69 | * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting 70 | * a configuration so that the host may correctly communicate with the USB device. 71 | */ 72 | const USB_Descriptor_Configuration_t ConfigurationDescriptor = 73 | { 74 | .Config = 75 | { 76 | .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, 77 | 78 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), 79 | .TotalInterfaces = 2, 80 | 81 | .ConfigurationNumber = 1, 82 | .ConfigurationStrIndex = NO_DESCRIPTOR, 83 | 84 | .ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED, 85 | 86 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) 87 | }, 88 | 89 | .CDC_CCI_Interface = 90 | { 91 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 92 | 93 | .InterfaceNumber = 0, 94 | .AlternateSetting = 0, 95 | 96 | .TotalEndpoints = 1, 97 | 98 | .Class = CDC_CSCP_CDCClass, 99 | .SubClass = CDC_CSCP_ACMSubclass, 100 | .Protocol = CDC_CSCP_ATCommandProtocol, 101 | 102 | .InterfaceStrIndex = NO_DESCRIPTOR 103 | }, 104 | 105 | .CDC_Functional_Header = 106 | { 107 | .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, 108 | .Subtype = 0x00, 109 | 110 | .CDCSpecification = VERSION_BCD(01.10), 111 | }, 112 | 113 | .CDC_Functional_ACM = 114 | { 115 | .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, 116 | .Subtype = 0x02, 117 | 118 | .Capabilities = 0x04, 119 | }, 120 | 121 | .CDC_Functional_Union = 122 | { 123 | .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, 124 | .Subtype = 0x06, 125 | 126 | .MasterInterfaceNumber = 0, 127 | .SlaveInterfaceNumber = 1, 128 | }, 129 | 130 | .CDC_NotificationEndpoint = 131 | { 132 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 133 | 134 | .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), 135 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 136 | .EndpointSize = CDC_NOTIFICATION_EPSIZE, 137 | .PollingIntervalMS = 0xFF 138 | }, 139 | 140 | .CDC_DCI_Interface = 141 | { 142 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 143 | 144 | .InterfaceNumber = 1, 145 | .AlternateSetting = 0, 146 | 147 | .TotalEndpoints = 2, 148 | 149 | .Class = CDC_CSCP_CDCDataClass, 150 | .SubClass = CDC_CSCP_NoDataSubclass, 151 | .Protocol = CDC_CSCP_NoDataProtocol, 152 | 153 | .InterfaceStrIndex = NO_DESCRIPTOR 154 | }, 155 | 156 | .CDC_DataOutEndpoint = 157 | { 158 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 159 | 160 | .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM), 161 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 162 | .EndpointSize = CDC_TXRX_EPSIZE, 163 | .PollingIntervalMS = 0x01 164 | }, 165 | 166 | .CDC_DataInEndpoint = 167 | { 168 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 169 | 170 | .EndpointAddress = (ENDPOINT_DIR_IN | CDC_TX_EPNUM), 171 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 172 | .EndpointSize = CDC_TXRX_EPSIZE, 173 | .PollingIntervalMS = 0x01 174 | } 175 | }; 176 | 177 | /** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests 178 | * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate 179 | * via the language ID table available at USB.org what languages the device supports for its string descriptors. 180 | */ 181 | const USB_Descriptor_String_t LanguageString = 182 | { 183 | .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, 184 | 185 | .UnicodeString = {LANGUAGE_ID_ENG} 186 | }; 187 | 188 | /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, 189 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device 190 | * Descriptor. 191 | */ 192 | const USB_Descriptor_String_t ProductString = 193 | { 194 | .Header = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String}, 195 | .UnicodeString = L"LinkIt Smart 7688 Duo" 196 | }; 197 | 198 | const USB_Descriptor_String_t ManufNameString = 199 | { 200 | .Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String}, 201 | .UnicodeString = L"MediaTek Labs" 202 | }; 203 | 204 | /** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors" 205 | * documentation) by the application code so that the address and size of a requested descriptor can be given 206 | * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function 207 | * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the 208 | * USB host. 209 | */ 210 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 211 | const uint8_t wIndex, 212 | const void** const DescriptorAddress) 213 | { 214 | const uint8_t DescriptorType = (wValue >> 8); 215 | const uint8_t DescriptorNumber = (wValue & 0xFF); 216 | 217 | const void* Address = NULL; 218 | uint16_t Size = NO_DESCRIPTOR; 219 | 220 | switch (DescriptorType) 221 | { 222 | case DTYPE_Device: 223 | Address = &DeviceDescriptor; 224 | Size = sizeof(USB_Descriptor_Device_t); 225 | break; 226 | case DTYPE_Configuration: 227 | Address = &ConfigurationDescriptor; 228 | Size = sizeof(USB_Descriptor_Configuration_t); 229 | break; 230 | case DTYPE_String: 231 | if (!(DescriptorNumber)) 232 | { 233 | Address = &LanguageString; 234 | Size = LanguageString.Header.Size; 235 | } 236 | else if (DescriptorNumber == DeviceDescriptor.ProductStrIndex) 237 | { 238 | Address = &ProductString; 239 | Size = ProductString.Header.Size; 240 | } else if (DescriptorNumber == DeviceDescriptor.ManufacturerStrIndex) 241 | { 242 | Address = &ManufNameString; 243 | Size = ManufNameString.Header.Size; 244 | } 245 | 246 | break; 247 | } 248 | 249 | *DescriptorAddress = Address; 250 | return Size; 251 | } 252 | 253 | -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Descriptors.c. 34 | */ 35 | 36 | #ifndef _DESCRIPTORS_H_ 37 | #define _DESCRIPTORS_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | /* Macros: */ 43 | #if defined(__AVR_AT90USB1287__) 44 | #define AVR_SIGNATURE_1 0x1E 45 | #define AVR_SIGNATURE_2 0x97 46 | #define AVR_SIGNATURE_3 0x82 47 | #elif defined(__AVR_AT90USB647__) 48 | #define AVR_SIGNATURE_1 0x1E 49 | #define AVR_SIGNATURE_2 0x96 50 | #define AVR_SIGNATURE_3 0x82 51 | #elif defined(__AVR_AT90USB1286__) 52 | #define AVR_SIGNATURE_1 0x1E 53 | #define AVR_SIGNATURE_2 0x97 54 | #define AVR_SIGNATURE_3 0x82 55 | #elif defined(__AVR_AT90USB646__) 56 | #define AVR_SIGNATURE_1 0x1E 57 | #define AVR_SIGNATURE_2 0x96 58 | #define AVR_SIGNATURE_3 0x82 59 | #elif defined(__AVR_ATmega32U6__) 60 | #define AVR_SIGNATURE_1 0x1E 61 | #define AVR_SIGNATURE_2 0x95 62 | #define AVR_SIGNATURE_3 0x88 63 | #elif defined(__AVR_ATmega32U4__) 64 | #define AVR_SIGNATURE_1 0x1E 65 | #define AVR_SIGNATURE_2 0x95 66 | #define AVR_SIGNATURE_3 0x87 67 | #elif defined(__AVR_ATmega16U4__) 68 | #define AVR_SIGNATURE_1 0x1E 69 | #define AVR_SIGNATURE_2 0x94 70 | #define AVR_SIGNATURE_3 0x88 71 | #elif defined(__AVR_ATmega32U2__) 72 | #define AVR_SIGNATURE_1 0x1E 73 | #define AVR_SIGNATURE_2 0x95 74 | #define AVR_SIGNATURE_3 0x8A 75 | #elif defined(__AVR_ATmega16U2__) 76 | #define AVR_SIGNATURE_1 0x1E 77 | #define AVR_SIGNATURE_2 0x94 78 | #define AVR_SIGNATURE_3 0x89 79 | #elif defined(__AVR_AT90USB162__) 80 | #define AVR_SIGNATURE_1 0x1E 81 | #define AVR_SIGNATURE_2 0x94 82 | #define AVR_SIGNATURE_3 0x82 83 | #elif defined(__AVR_ATmega8U2__) 84 | #define AVR_SIGNATURE_1 0x1E 85 | #define AVR_SIGNATURE_2 0x93 86 | #define AVR_SIGNATURE_3 0x89 87 | #elif defined(__AVR_AT90USB82__) 88 | #define AVR_SIGNATURE_1 0x1E 89 | #define AVR_SIGNATURE_2 0x94 90 | #define AVR_SIGNATURE_3 0x82 91 | #else 92 | #error The selected AVR part is not currently supported by this bootloader. 93 | #endif 94 | 95 | /** Endpoint number for the CDC control interface event notification endpoint. */ 96 | #define CDC_NOTIFICATION_EPNUM 2 97 | 98 | /** Endpoint number for the CDC data interface TX (data IN) endpoint. */ 99 | #define CDC_TX_EPNUM 3 100 | 101 | /** Endpoint number for the CDC data interface RX (data OUT) endpoint. */ 102 | #define CDC_RX_EPNUM 4 103 | 104 | /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ 105 | #define CDC_TXRX_EPSIZE 16 106 | 107 | /** Size of the CDC control interface notification endpoint bank, in bytes. */ 108 | #define CDC_NOTIFICATION_EPSIZE 8 109 | 110 | /* Type Defines: */ 111 | /** Type define for the device configuration descriptor structure. This must be defined in the 112 | * application code, as the configuration descriptor contains several sub-descriptors which 113 | * vary between devices, and which describe the device's usage to the host. 114 | */ 115 | typedef struct 116 | { 117 | USB_Descriptor_Configuration_Header_t Config; 118 | 119 | // CDC Control Interface 120 | USB_Descriptor_Interface_t CDC_CCI_Interface; 121 | USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; 122 | USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; 123 | USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; 124 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; 125 | 126 | // CDC Data Interface 127 | USB_Descriptor_Interface_t CDC_DCI_Interface; 128 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; 129 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; 130 | } USB_Descriptor_Configuration_t; 131 | 132 | /* Function Prototypes: */ 133 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 134 | const uint8_t wIndex, 135 | const void** const DescriptorAddress) 136 | ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); 137 | 138 | #endif 139 | 140 | -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MediaTek-Labs/linkit-smart-7688-duo-arduino/1a5397a98df1e5acf4612164a2551aff4083ef20/mtk/avr/bootloaders/caterina/Makefile -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/Readme.txt: -------------------------------------------------------------------------------- 1 | Notes on building LinkIt Smart 7688 Duo ATMega32u4 Caterina bootloader: 2 | 3 | 1. Must download LUFA-111009(http://www.github.com/abcminiuser/lufa/archive/LUFA-111009.zip) and extract to the same-named directory. Alternatively, if you pulled this repository with git, do a `git submodule update --init` to pull from its repository. 4 | 5 | 2. You need avr toolchain (Win-AVR / avr-gcc) to build this bootloader. 6 | 7 | 3. The "build.txt" file and "program.txt" files can be renamed 8 | to .bat files and run to build and program the boards listed 9 | herein (Windows only, unfortunately). 10 | 11 | Notes on this bootloader: 12 | 13 | This booloader is modified from SparkFun Arduino boards. https://github.com/sparkfun/Arduino_Boards.git -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/build.txt: -------------------------------------------------------------------------------- 1 | make clean 2 | make VID=0x0E8D PID=0x0AB00 F_CPU=8000000 3 | copy Caterina.hex Caterina-smart7688.hex 4 | -------------------------------------------------------------------------------- /mtk/avr/bootloaders/caterina/program.txt: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | IF "%1"=="" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina.hex -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m 3 | IF "%1"=="lilypadusb" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-lilypadusb.hex -U efuse:w:0xfe:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m 4 | IF "%1"=="fio" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-fio.hex -U efuse:w:0xfe:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m 5 | IF "%1"=="promicro8" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-promicro8.hex -U efuse:w:0xfe:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m 6 | IF "%1"=="promicro16" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-promicro16.hex -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m 7 | IF "%1"=="makey" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-makey.hex -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m 8 | IF "%1"=="wiflyin" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-wiflyin.hex -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m 9 | IF "%1"=="minibench" avrdude -p m32u4 -P usb -c avrispmkii -U flash:w:Caterina-minibench.hex -U efuse:w:0xcb:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m -------------------------------------------------------------------------------- /mtk/avr/driver/linkit_smart_7688.inf: -------------------------------------------------------------------------------- 1 | ;************************************************************ 2 | ; Windows USB CDC ACM Setup File 3 | ; Copyright (c) 2000 Microsoft Corporation 4 | 5 | 6 | [Version] 7 | Signature="$Windows NT$" 8 | Class=Ports 9 | ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 10 | Provider=%MFGNAME% 11 | LayoutFile=layout.inf 12 | CatalogFile=%MFGFILENAME%.cat 13 | DriverVer=10/27/2014,5.1.2600.0 14 | 15 | [Manufacturer] 16 | %MFGNAME%=DeviceList, NTamd64 17 | 18 | [DestinationDirs] 19 | DefaultDestDir=12 20 | 21 | [DefaultInstall] 22 | CopyINF=linkit_smart_7688.inf 23 | 24 | ;------------------------------------------------------------------------------ 25 | ; Windows 2000/XP/Vista-32bit Sections 26 | ;------------------------------------------------------------------------------ 27 | 28 | [DriverInstall.nt] 29 | include=mdmcpq.inf 30 | CopyFiles=DriverCopyFiles.nt 31 | AddReg=DriverInstall.nt.AddReg 32 | 33 | [DriverCopyFiles.nt] 34 | usbser.sys,,,0x20 35 | 36 | [DriverInstall.nt.AddReg] 37 | HKR,,DevLoader,,*ntkern 38 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 39 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 40 | 41 | [DriverInstall.nt.Services] 42 | AddService=usbser, 0x00000002, DriverService.nt 43 | 44 | [DriverService.nt] 45 | DisplayName=%SERVICE% 46 | ServiceType=1 47 | StartType=3 48 | ErrorControl=1 49 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 50 | 51 | ;------------------------------------------------------------------------------ 52 | ; Vista-64bit Sections 53 | ;------------------------------------------------------------------------------ 54 | 55 | [DriverInstall.NTamd64] 56 | include=mdmcpq.inf 57 | CopyFiles=DriverCopyFiles.NTamd64 58 | AddReg=DriverInstall.NTamd64.AddReg 59 | 60 | [DriverCopyFiles.NTamd64] 61 | %DRIVERFILENAME%.sys,,,0x20 62 | 63 | [DriverInstall.NTamd64.AddReg] 64 | HKR,,DevLoader,,*ntkern 65 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 66 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 67 | 68 | [DriverInstall.NTamd64.Services] 69 | AddService=usbser, 0x00000002, DriverService.NTamd64 70 | 71 | [DriverService.NTamd64] 72 | DisplayName=%SERVICE% 73 | ServiceType=1 74 | StartType=3 75 | ErrorControl=1 76 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 77 | 78 | 79 | ;------------------------------------------------------------------------------ 80 | ; Vendor and Product ID Definitions 81 | ;------------------------------------------------------------------------------ 82 | ; When developing your USB device, the VID and PID used in the PC side 83 | ; application program and the firmware on the microcontroller must match. 84 | ; Modify the below line to use your VID and PID. Use the format as shown below. 85 | ; Note: One INF file can be used for multiple devices with different VID and PIDs. 86 | ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. 87 | ;------------------------------------------------------------------------------ 88 | [SourceDisksFiles] 89 | [SourceDisksNames] 90 | [DeviceList] 91 | %Smart.7688.bootloader%=DriverInstall, USB\VID_0E8D&PID_AB00 92 | %Smart.7688.sketch%=DriverInstall, USB\VID_0E8D&PID_AB01&MI_00 93 | 94 | [DeviceList.NTamd64] 95 | %Smart.7688.bootloader%=DriverInstall, USB\VID_0E8D&PID_AB00 96 | %Smart.7688.sketch%=DriverInstall, USB\VID_0E8D&PID_AB01&MI_00 97 | 98 | ;------------------------------------------------------------------------------ 99 | ; String Definitions 100 | ;------------------------------------------------------------------------------ 101 | ;Modify these strings to customize your device 102 | ;------------------------------------------------------------------------------ 103 | [Strings] 104 | MFGFILENAME="linkit_smart_7688" 105 | DRIVERFILENAME ="usbser" 106 | MFGNAME="MediaTek" 107 | INSTDISK="MediaTek Smart 7688 Driver Installer" 108 | Smart.7688.bootloader="MediaTek LinkIt Smart 7688 Duo (Bootloader)" 109 | Smart.7688.sketch="MediaTek LinkIt Smart 7688 Duo" 110 | SERVICE="USB RS-232 Emulation Driver" 111 | -------------------------------------------------------------------------------- /mtk/avr/platform.txt: -------------------------------------------------------------------------------- 1 | 2 | # Arduino AVR Core and platform. 3 | # ------------------------------ 4 | 5 | # For more info: 6 | # https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification 7 | 8 | name=MediaTek LinkIt Boards 9 | version=1.6.0 10 | 11 | # AVR compile variables 12 | # --------------------- 13 | 14 | # Default "compiler.path" is correct, change only if you want to overidde the initial value 15 | #compiler.path={runtime.tools.avr-gcc.path}/bin/ 16 | compiler.c.cmd=avr-gcc 17 | compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD 18 | # -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396 19 | # This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain 20 | compiler.c.elf.flags=-w -Os -Wl,--gc-sections 21 | compiler.c.elf.cmd=avr-gcc 22 | compiler.S.flags=-c -g -x assembler-with-cpp 23 | compiler.cpp.cmd=avr-g++ 24 | compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD 25 | compiler.ar.cmd=avr-ar 26 | compiler.ar.flags=rcs 27 | compiler.objcopy.cmd=avr-objcopy 28 | compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 29 | compiler.elf2hex.flags=-O ihex -R .eeprom 30 | compiler.elf2hex.cmd=avr-objcopy 31 | compiler.ldflags= 32 | compiler.size.cmd=avr-size 33 | 34 | # This can be overriden in boards.txt 35 | build.extra_flags= 36 | 37 | # These can be overridden in platform.local.txt 38 | compiler.c.extra_flags= 39 | compiler.c.elf.extra_flags= 40 | compiler.S.extra_flags= 41 | compiler.cpp.extra_flags= 42 | compiler.ar.extra_flags= 43 | compiler.objcopy.eep.extra_flags= 44 | compiler.elf2hex.extra_flags= 45 | 46 | # AVR compile patterns 47 | # -------------------- 48 | 49 | ## Compile c files 50 | recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" 51 | 52 | ## Compile c++ files 53 | recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" 54 | 55 | ## Compile S files 56 | recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}" 57 | 58 | ## Create archives 59 | recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" 60 | 61 | ## Combine gc-sections, archives, and objects 62 | recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{archive_file_path}" "-L{build.path}" -lm 63 | 64 | ## Create eeprom 65 | recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep" 66 | 67 | ## Create hex 68 | recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" 69 | 70 | ## Compute size 71 | recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" 72 | recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).* 73 | recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).* 74 | recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).* 75 | 76 | 77 | # AVR Uploader/Programmers tools 78 | # ------------------------------ 79 | tools.avrdude.path={runtime.tools.avrdude.path} 80 | tools.avrdude.cmd.path={path}/bin/avrdude 81 | tools.avrdude.config.path={runtime.platform.path}/avrdude.conf 82 | 83 | tools.avrdude.upload.params.verbose=-v 84 | tools.avrdude.upload.params.quiet=-q -q 85 | tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i" 86 | 87 | tools.avrdude.program.params.verbose=-v 88 | tools.avrdude.program.params.quiet=-q -q 89 | tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i" 90 | 91 | tools.avrdude.erase.params.verbose=-v 92 | tools.avrdude.erase.params.quiet=-q -q 93 | tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m 94 | 95 | tools.avrdude.bootloader.params.verbose=-v 96 | tools.avrdude.bootloader.params.quiet=-q -q 97 | tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m 98 | 99 | # USB Default Flags 100 | # Default blank usb manufacturer will be filled it at compile time 101 | # - from numeric vendor ID, set to Unknown otherwise 102 | build.usb_manufacturer="MediaTek" 103 | build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} "-DUSB_MANUFACTURER={build.usb_manufacturer}" "-DUSB_PRODUCT={build.usb_product}" 104 | -------------------------------------------------------------------------------- /mtk/avr/programmers.txt: -------------------------------------------------------------------------------- 1 | 2 | # LinkIt Smart 7688 Duo uses ATMega32U4, so change protocol from stk500 to arduino 3 | arduinoisp_smart7688.name=LinkIt Smart 7688 Duo as ISP 4 | arduinoisp_smart7688.communication=serial 5 | arduinoisp_smart7688.protocol=arduino 6 | arduinoisp_smart7688.speed=19200 7 | arduinoisp_smart7688.program.protocol=arduino 8 | arduinoisp_smart7688.program.speed=19200 9 | arduinoisp_smart7688.program.tool=avrdude 10 | arduinoisp_smart7688.program.extra_params=-P{serial.port} -b{program.speed} -------------------------------------------------------------------------------- /mtk/avr/variants/smart7688/pins_arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | pins_arduino.h - Pin definition functions for Arduino 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2007 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | 22 | $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ 23 | */ 24 | 25 | #ifndef Pins_Arduino_h 26 | #define Pins_Arduino_h 27 | 28 | #include 29 | 30 | #define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0) 31 | #define TXLED0 PORTD |= (1<<5) 32 | #define TXLED1 PORTD &= ~(1<<5) 33 | #define RXLED0 PORTB |= (1<<0) 34 | #define RXLED1 PORTB &= ~(1<<0) 35 | 36 | static const uint8_t SDA = 2; 37 | static const uint8_t SCL = 3; 38 | 39 | // Map SPI port to 'new' pins D14..D17 40 | static const uint8_t SS = 17; 41 | static const uint8_t MOSI = 16; 42 | static const uint8_t MISO = 14; 43 | static const uint8_t SCK = 15; 44 | 45 | // Mapping of analog pins as digital I/O 46 | // A6-A11 share with digital pins 47 | static const uint8_t A0 = 18; 48 | static const uint8_t A1 = 19; 49 | static const uint8_t A2 = 20; 50 | static const uint8_t A3 = 21; 51 | static const uint8_t A4 = 22; 52 | static const uint8_t A5 = 23; 53 | static const uint8_t A6 = 24; // D4 54 | static const uint8_t A7 = 25; // D6 55 | static const uint8_t A8 = 26; // D8 56 | static const uint8_t A9 = 27; // D9 57 | static const uint8_t A10 = 28; // D10 58 | static const uint8_t A11 = 29; // D12 59 | 60 | #define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) 61 | #define digitalPinToPCICRbit(p) 0 62 | #define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) 63 | #define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4)))))) 64 | 65 | // __AVR_ATmega32U4__ has an unusual mapping of pins to channels 66 | extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; 67 | #define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) 68 | 69 | #ifdef ARDUINO_MAIN 70 | 71 | // On the Arduino board, digital pins are also used 72 | // for the analog output (software PWM). Analog input 73 | // pins are a separate set. 74 | 75 | // ATMEL ATMEGA32U4 / ARDUINO LEONARDO 76 | // 77 | // D0 PD2 RXD1/INT2 78 | // D1 PD3 TXD1/INT3 79 | // D2 PD1 SDA SDA/INT1 80 | // D3# PD0 PWM8/SCL OC0B/SCL/INT0 81 | // D4 A6 PD4 ADC8 82 | // D5# PC6 ??? OC3A/#OC4A 83 | // D6# A7 PD7 FastPWM #OC4D/ADC10 84 | // D7 PE6 INT6/AIN0 85 | // 86 | // D8 A8 PB4 ADC11/PCINT4 87 | // D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5 88 | // D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6 89 | // D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7 90 | // D12 A11 PD6 T1/#OC4D/ADC9 91 | // D13# PC7 PWM10 CLK0/OC4A 92 | // 93 | // A0 D18 PF0 ADC0 94 | // A1 D19 PF1 ADC1 95 | // A2 D20 PF4 ADC4 96 | // A3 D21 PF5 ADC5 97 | // A4 D22 PF6 ADC6 98 | // A5 D23 PF7 ADC7 99 | // 100 | // New pins D14..D17 to map SPI port to digital pins 101 | // 102 | // MISO D14 PB3 MISO,PCINT3 103 | // SCK D15 PB2 SCK,PCINT1 104 | // MOSI D16 PB1 MOSI,PCINT2 105 | // SS D17 PB0 RXLED,SS/PCINT0 106 | // 107 | // TXLED PD5 108 | // RXLED PB0 109 | // HWB PE2 HWB 110 | 111 | // these arrays map port names (e.g. port B) to the 112 | // appropriate addresses for various functions (e.g. reading 113 | // and writing) 114 | const uint16_t PROGMEM port_to_mode_PGM[] = { 115 | NOT_A_PORT, 116 | NOT_A_PORT, 117 | (uint16_t) &DDRB, 118 | (uint16_t) &DDRC, 119 | (uint16_t) &DDRD, 120 | (uint16_t) &DDRE, 121 | (uint16_t) &DDRF, 122 | }; 123 | 124 | const uint16_t PROGMEM port_to_output_PGM[] = { 125 | NOT_A_PORT, 126 | NOT_A_PORT, 127 | (uint16_t) &PORTB, 128 | (uint16_t) &PORTC, 129 | (uint16_t) &PORTD, 130 | (uint16_t) &PORTE, 131 | (uint16_t) &PORTF, 132 | }; 133 | 134 | const uint16_t PROGMEM port_to_input_PGM[] = { 135 | NOT_A_PORT, 136 | NOT_A_PORT, 137 | (uint16_t) &PINB, 138 | (uint16_t) &PINC, 139 | (uint16_t) &PIND, 140 | (uint16_t) &PINE, 141 | (uint16_t) &PINF, 142 | }; 143 | 144 | const uint8_t PROGMEM digital_pin_to_port_PGM[30] = { 145 | PD, // D0 - PD2 146 | PD, // D1 - PD3 147 | PD, // D2 - PD1 148 | PD, // D3 - PD0 149 | PD, // D4 - PD4 150 | PC, // D5 - PC6 151 | PD, // D6 - PD7 152 | PE, // D7 - PE6 153 | 154 | PB, // D8 - PB4 155 | PB, // D9 - PB5 156 | PB, // D10 - PB6 157 | PB, // D11 - PB7 158 | PD, // D12 - PD6 159 | PC, // D13 - PC7 160 | 161 | PB, // D14 - MISO - PB3 162 | PB, // D15 - MOSI - PB2 163 | PB, // D16 - SCK - PB1 164 | PB, // D17 - SS - PB0 165 | 166 | PF, // D18 - A0 - PF0 167 | PF, // D19 - A1 - PF1 168 | PF, // D20 - A2 - PF4 169 | PF, // D21 - A3 - PF5 170 | PF, // D22 - A4 - PF6 171 | PF, // D23 - A5 - PF7 172 | 173 | PD, // D24 / D4 - A6 - PD4 174 | PD, // D25 / D6 - A7 - PD7 175 | PB, // D26 / D8 - A8 - PB4 176 | PB, // D27 / D9 - A9 - PB5 177 | PB, // D28 / D10 - A10 - PB6 178 | PD, // D29 / D12 - A11 - PD6 179 | }; 180 | 181 | const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[30] = { 182 | _BV(2), // D0 - PD2 183 | _BV(3), // D1 - PD3 184 | _BV(1), // D2 - PD1 185 | _BV(0), // D3 - PD0 186 | _BV(4), // D4 - PD4 187 | _BV(6), // D5 - PC6 188 | _BV(7), // D6 - PD7 189 | _BV(6), // D7 - PE6 190 | 191 | _BV(4), // D8 - PB4 192 | _BV(5), // D9 - PB5 193 | _BV(6), // D10 - PB6 194 | _BV(7), // D11 - PB7 195 | _BV(6), // D12 - PD6 196 | _BV(7), // D13 - PC7 197 | 198 | _BV(3), // D14 - MISO - PB3 199 | _BV(2), // D15 - MOSI - PB2 200 | _BV(1), // D16 - SCK - PB1 201 | _BV(0), // D17 - SS - PB0 202 | 203 | _BV(0), // D18 - A0 - PF0 204 | _BV(1), // D19 - A1 - PF1 205 | _BV(4), // D20 - A2 - PF4 206 | _BV(5), // D21 - A3 - PF5 207 | _BV(6), // D22 - A4 - PF6 208 | _BV(7), // D23 - A5 - PF7 209 | 210 | _BV(4), // D24 / D4 - A6 - PD4 211 | _BV(7), // D25 / D6 - A7 - PD7 212 | _BV(4), // D26 / D8 - A8 - PB4 213 | _BV(5), // D27 / D9 - A9 - PB5 214 | _BV(6), // D28 / D10 - A10 - PB6 215 | _BV(6), // D29 / D12 - A11 - PD6 216 | }; 217 | 218 | const uint8_t PROGMEM digital_pin_to_timer_PGM[16] = { 219 | NOT_ON_TIMER, 220 | NOT_ON_TIMER, 221 | NOT_ON_TIMER, 222 | TIMER0B, /* 3 */ 223 | NOT_ON_TIMER, 224 | TIMER3A, /* 5 */ 225 | TIMER4D, /* 6 */ 226 | NOT_ON_TIMER, 227 | 228 | NOT_ON_TIMER, 229 | TIMER1A, /* 9 */ 230 | TIMER1B, /* 10 */ 231 | TIMER0A, /* 11 */ 232 | 233 | NOT_ON_TIMER, 234 | TIMER4A, /* 13 */ 235 | 236 | NOT_ON_TIMER, 237 | NOT_ON_TIMER, 238 | }; 239 | 240 | const uint8_t PROGMEM analog_pin_to_channel_PGM[12] = { 241 | 0, // A0 PF0 ADC0 242 | 1, // A1 PF1 ADC1 243 | 4, // A2 PF4 ADC4 244 | 5, // A3 PF5 ADC5 245 | 6, // A4 PF6 ADC6 246 | 7, // A5 PF7 ADC7 247 | 8, // A6 D4 PD4 ADC8 248 | 10, // A7 D6 PD7 ADC10 249 | 11, // A8 D8 PB4 ADC11 250 | 12, // A9 D9 PB5 ADC12 251 | 13, // A10 D10 PB6 ADC13 252 | 9 // A11 D12 PD6 ADC9 253 | }; 254 | 255 | #endif /* ARDUINO_MAIN */ 256 | 257 | // These serial port names are intended to allow libraries and architecture-neutral 258 | // sketches to automatically default to the correct port name for a particular type 259 | // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, 260 | // the first hardware serial port whose RX/TX pins are not dedicated to another use. 261 | // 262 | // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor 263 | // 264 | // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial 265 | // 266 | // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library 267 | // 268 | // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. 269 | // 270 | // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX 271 | // pins are NOT connected to anything by default. 272 | #define SERIAL_PORT_MONITOR Serial 273 | #define SERIAL_PORT_USBVIRTUAL Serial 274 | #define SERIAL_PORT_LINUXBRIDGE Serial1 275 | #define SERIAL_PORT_HARDWARE Serial1 276 | #define SERIAL_PORT_HARDWARE_OPEN Serial1 277 | 278 | // Alias SerialUSB to Serial 279 | #define SerialUSB SERIAL_PORT_USBVIRTUAL 280 | 281 | #endif /* Pins_Arduino_h */ 282 | -------------------------------------------------------------------------------- /mtk/gen_repo.bat: -------------------------------------------------------------------------------- 1 | :: !!! Set this version number before running this script !!! 2 | set version=0.1.7 3 | 4 | :: generate SDK zip file 5 | set setupname=mediatek_linkit_smart_7688_ 6 | set sdk_zip_name=%setupname%%version%.zip 7 | IF EXIST ".\out\%setupname%%version%.zip" del /F /Q ".\out\%setupname%%version%.zip" 8 | IF NOT EXIST ".\out" mkdir out 9 | 7z.exe a ".\out\%sdk_zip_name%" ".\avr" 10 | 11 | :: generate JSON repository file 12 | python.exe gen_repo_json.py %version% %sdk_zip_name% 13 | 14 | :: ask if the user want to update the tags 15 | echo "Files are generated in /out folder and version tag is added to your local git repository. To share this tag, use 'git push --tags'." -------------------------------------------------------------------------------- /mtk/gen_repo.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # Set this version number before running this script !!! 3 | version=0.1.7 4 | 5 | # generate SDK zip file 6 | setupname=mediatek_linkit_smart_7688_ 7 | sdk_zip_name=${setupname}${version}.zip 8 | if [[ -f "./out/${setupname}${version}.zip" ]]; then 9 | rm -f "./out/${setupname}${version}.zip" 10 | fi 11 | 12 | if ! [[ -e "./out" ]]; then 13 | mkdir "./out" 14 | fi 15 | zip -r "./out/${sdk_zip_name}" avr 16 | 17 | # generate JSON repository file 18 | python2 gen_repo_json.py $version $sdk_zip_name 19 | 20 | # ask if the user want to update the tags 21 | echo 'Files are generated in /out folder and version tag is added to your local git repository. To share this tag, use "git push --tags".' 22 | 23 | -------------------------------------------------------------------------------- /mtk/gen_repo_json.py: -------------------------------------------------------------------------------- 1 | ''' 2 | This file generates the Arduino Board Manager .json file for SDK releases. 3 | You will need internet connection to download the latest repostiory JSON file. 4 | ''' 5 | import sys 6 | import os 7 | import hashlib 8 | from string import Template 9 | import json 10 | import subprocess 11 | import requests 12 | 13 | TEMP_JSON_PATH = 'out/current_version.json' 14 | CURRENT_JSON_URL = 'http://download.labs.mediatek.com/package_mtk_linkit_smart_7688_test_index.json' 15 | MERGED_JSON_PATH = 'out/package_mtk_linkit_smart_7688_index.json' 16 | 17 | def get_current_version_content(new_entry): 18 | ''' 19 | load the newly generated JSON string 20 | and returns the platform object 21 | ''' 22 | j = json.loads(new_entry) 23 | platforms = j['packages'][0]['platforms'] 24 | assert len(platforms) == 1 25 | return j['packages'][0]['platforms'][0] 26 | 27 | def merge_with_existing_json(new_entry): 28 | ''' 29 | grabs JSON content from online repostiory and 30 | insert the newly generated platform object 31 | to its platform list 32 | ''' 33 | req = requests.get(CURRENT_JSON_URL) 34 | repo_content = json.loads(req.text) 35 | platforms = repo_content['packages'][0]['platforms'] 36 | print "how many versions (online repo):", len(platforms) 37 | 38 | platforms.append(get_current_version_content(new_entry)) 39 | print "how many version(merged):", len(platforms) 40 | json.dump(repo_content, 41 | open(MERGED_JSON_PATH, 'wb'), 42 | sort_keys=True, 43 | indent=4, 44 | separators=(',', ': ')) 45 | 46 | def get_sdk_version_string(): 47 | ''' 48 | Parse input arg and gives "sanitized" version string. 49 | Arduino IDE does not accepts version string like "1.1.05", 50 | where the "05" causes problems. 51 | ''' 52 | version_str = sys.argv[1] 53 | # fix malformed version name 54 | version_digits = version_str.split(".") 55 | arg_sdk_version = ".".join([str(int(v)) for v in version_digits]) 56 | return arg_sdk_version 57 | 58 | def generate_new_json_entry(): 59 | ''' 60 | Parse cmdline arguments and generate a new repo entry 61 | and return the resulting string 62 | ''' 63 | arg_sdk_zip_name = sys.argv[2] 64 | sdk_zip_path = "out/" + arg_sdk_zip_name 65 | 66 | template_str = Template(open("package_linkit_index.json.template", "rb").read()) 67 | file_check_sum = hashlib.sha256(open(sdk_zip_path, "rb").read()).hexdigest() 68 | json_content = template_str.substitute(sdk_version=get_sdk_version_string(), 69 | sdk_zip_name=arg_sdk_zip_name, 70 | sdk_zip_checksum=file_check_sum, 71 | sdk_zip_size=os.stat(sdk_zip_path).st_size) 72 | return json_content 73 | 74 | def tag_version(): 75 | ''' 76 | Add a git tag of current version 77 | ''' 78 | sdk_version = get_sdk_version_string() 79 | if not sdk_version: 80 | print "SDK Version not found" 81 | return 82 | cmd = "git tag -f " + sdk_version 83 | print "Add git tag:", cmd 84 | print subprocess.check_output(cmd, shell=True) 85 | 86 | def main(): 87 | ''' 88 | Generate a new JSON repo for new version, 89 | insert into existing repo, and update git tag 90 | ''' 91 | new_entry = generate_new_json_entry() 92 | merge_with_existing_json(new_entry) 93 | tag_version() 94 | 95 | if __name__ == '__main__': 96 | main() 97 | -------------------------------------------------------------------------------- /mtk/package_linkit_index.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | { 4 | "name": "LinkIt", 5 | "maintainer": "Seeed Studio and MediaTek Labs", 6 | "websiteURL": "http://labs.mediatek.com/7688", 7 | "help": { 8 | "online": "http://labs.mediatek.com/7688faq" 9 | }, 10 | "platforms":[ 11 | { 12 | "name":"LinkIt Smart 7688 Duo", 13 | "architecture":"avr", 14 | "version": "$sdk_version", 15 | "category":"Contributed", 16 | "url":"http://download.labs.mediatek.com/$sdk_zip_name", 17 | "archiveFileName": "$sdk_zip_name", 18 | "checksum": "SHA-256:$sdk_zip_checksum", 19 | "size": "$sdk_zip_size", 20 | "boards":[ 21 | { "name":"LinkIt Smart 7688 Duo" } 22 | ], 23 | "toolsDependencies":[ 24 | { 25 | "packager":"arduino", 26 | "name":"avr-gcc", 27 | "version":"4.8.1-arduino5" 28 | }, 29 | { 30 | "packager":"arduino", 31 | "name":"avrdude", 32 | "version":"6.0.1-arduino5" 33 | } 34 | ] 35 | } 36 | ], 37 | "tools":[] 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /mtk/test_case/ADC_TEST/ADC_TEST.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | void setup() { 4 | 5 | Serial.begin(115200); 6 | pinMode(A0,INPUT); 7 | pinMode(A1,INPUT); 8 | pinMode(A2,INPUT); 9 | pinMode(A3,INPUT); 10 | pinMode(A4,INPUT); 11 | } 12 | 13 | void loop() { 14 | 15 | // unsigned long t1 = millis(); 16 | int data = 0; 17 | //for (int i = 0; i < 100; ++i) 18 | //{ 19 | // data// =analogRead(A0) ; 20 | //} 21 | //unsigned long t2 = millis(); 22 | //Serial.println((t2-t1)/100.0); 23 | Serial.print(analogRead(A0)); 24 | Serial.print(","); 25 | Serial.print(analogRead(A1)); 26 | Serial.print(","); 27 | Serial.print(analogRead(A2)); 28 | Serial.print(","); 29 | Serial.print(analogRead(A3)); 30 | Serial.print(","); 31 | Serial.print(analogRead(A4)); 32 | Serial.print(","); 33 | Serial.println(analogRead(A5)); 34 | delay(1000); 35 | } 36 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/.gitignore: -------------------------------------------------------------------------------- 1 | serialconfig.txt 2 | 3 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/Adafruit_10DOF.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This is a library for the Adafruit 10DOF Breakout 3 | 4 | Designed specifically to work with the Adafruit 10DOF Breakout 5 | 6 | These displays use I2C to communicate, 2 pins are required to interface. 7 | 8 | Adafruit invests time and resources providing this open source code, 9 | please support Adafruit andopen-source hardware by purchasing products 10 | from Adafruit! 11 | 12 | Written by Kevin Townsend for Adafruit Industries. 13 | BSD license, all text above must be included in any redistribution 14 | ***************************************************************************/ 15 | #ifndef __ADAFRUIT_10DOF_H__ 16 | #define __ADAFRUIT_10DOF_H__ 17 | 18 | #if (ARDUINO >= 100) 19 | #include "Arduino.h" 20 | #else 21 | #include "WProgram.h" 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | /** Sensor axis */ 31 | typedef enum 32 | { 33 | SENSOR_AXIS_X = (1), 34 | SENSOR_AXIS_Y = (2), 35 | SENSOR_AXIS_Z = (3) 36 | } sensors_axis_t; 37 | 38 | /* Driver for the the 10DOF breakout sensors */ 39 | class Adafruit_10DOF 40 | { 41 | public: 42 | Adafruit_10DOF(void); 43 | bool begin(void); 44 | 45 | bool accelGetOrientation ( sensors_event_t *event, sensors_vec_t *orientation ); 46 | bool magTiltCompensation ( sensors_axis_t axis, sensors_event_t *mag_event, sensors_event_t *accel_event ); 47 | bool magGetOrientation ( sensors_axis_t axis, sensors_event_t *event, sensors_vec_t *mag_orientation ); 48 | bool fusionGetOrientation ( sensors_event_t *accel_event, sensors_event_t *mag_event, sensors_vec_t *orientation ); 49 | 50 | private: 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/README.md: -------------------------------------------------------------------------------- 1 | #Adafruit 10DOF Library # 2 | 3 | This driver is for the Adafruit 10DOF Breakout (http://www.adafruit.com/products/1604), and makes use of Adafruit's Unified Sensor Library (https://github.com/adafruit/Adafruit_Sensor) to provide standard SI units of measure and easy to reuse sensor data. 4 | 5 | For information about this breakout and how to use this library, consult our online learning guide at http://learn.adafruit.com/adafruit-10-dof-imu-breakout-lsm303-l3gd20-bmp180/introduction 6 | 7 | ## About the 10DOF Breakout ## 8 | 9 | Adafruit's 10DOF Breakout includes everything you need for accurate, meaningful motion capture and detection, including the following sensors: 10 | 11 | - L3GD20 3-axis gyroscope: ±250, ±500, or ±2000 degree-per-second scale 12 | - LSM303 3-axis compass: ±1.3 to ±8.1 gauss magnetic field scale 13 | - LSM303 3-axis accelerometer: ±2g/±4g/±8g/±16g selectable scale 14 | - BMP180 barometric pressure/temperature: -40 to 85 °C, 300 - 1100hPa range, 0.17m resolution 15 | 16 | ## About this Library ## 17 | 18 | The Adafruit_10DOF library makes use of Adafruit's existing libraries for the L3GD20, LSM303DLHC and BMP180, but also adds a few helper functions to generate values that are more useful for drones, motion detection, etc. 19 | 20 | Adafruit invests time and resources providing this open source code. Please support Adafruit and open-source hardware by purchasing products from Adafruit! 21 | 22 | Written by Kevin (KTOWN) Townsend for Adafruit Industries. -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/ahrs/ahrs.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* Assign a unique ID to the sensors */ 9 | Adafruit_10DOF dof = Adafruit_10DOF(); 10 | Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301); 11 | Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(30302); 12 | Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(18001); 13 | 14 | /* Update this with the correct SLP for accurate altitude measurements */ 15 | float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; 16 | 17 | /**************************************************************************/ 18 | /*! 19 | @brief Initialises all the sensors used by this example 20 | */ 21 | /**************************************************************************/ 22 | void initSensors() 23 | { 24 | if(!accel.begin()) 25 | { 26 | /* There was a problem detecting the LSM303 ... check your connections */ 27 | Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!")); 28 | while(1); 29 | } 30 | if(!mag.begin()) 31 | { 32 | /* There was a problem detecting the LSM303 ... check your connections */ 33 | Serial.println("Ooops, no LSM303 detected ... Check your wiring!"); 34 | while(1); 35 | } 36 | if(!bmp.begin()) 37 | { 38 | /* There was a problem detecting the BMP180 ... check your connections */ 39 | Serial.println("Ooops, no BMP180 detected ... Check your wiring!"); 40 | while(1); 41 | } 42 | } 43 | 44 | /**************************************************************************/ 45 | /*! 46 | 47 | */ 48 | /**************************************************************************/ 49 | void setup(void) 50 | { 51 | Serial.begin(115200); 52 | Serial.println(F("Adafruit 10 DOF Pitch/Roll/Heading Example")); Serial.println(""); 53 | 54 | /* Initialise the sensors */ 55 | initSensors(); 56 | } 57 | 58 | /**************************************************************************/ 59 | /*! 60 | @brief Constantly check the roll/pitch/heading/altitude/temperature 61 | */ 62 | /**************************************************************************/ 63 | void loop(void) 64 | { 65 | sensors_event_t accel_event; 66 | sensors_event_t mag_event; 67 | sensors_event_t bmp_event; 68 | sensors_vec_t orientation; 69 | 70 | /* Read the accelerometer and magnetometer */ 71 | accel.getEvent(&accel_event); 72 | mag.getEvent(&mag_event); 73 | 74 | /* Use the new fusionGetOrientation function to merge accel/mag data */ 75 | if (dof.fusionGetOrientation(&accel_event, &mag_event, &orientation)) 76 | { 77 | /* 'orientation' should have valid .roll and .pitch fields */ 78 | Serial.print(F("Orientation: ")); 79 | Serial.print(orientation.roll); 80 | Serial.print(F(" ")); 81 | Serial.print(orientation.pitch); 82 | Serial.print(F(" ")); 83 | Serial.print(orientation.heading); 84 | Serial.println(F("")); 85 | } 86 | 87 | /* Previous code removed handling accel and mag data separately */ 88 | // /* Calculate pitch and roll from the raw accelerometer data */ 89 | // Serial.print(F("Orientation: ")); 90 | // accel.getEvent(&accel_event); 91 | // if (dof.accelGetOrientation(&accel_event, &orientation)) 92 | // { 93 | // /* 'orientation' should have valid .roll and .pitch fields */ 94 | // Serial.print(orientation.roll); 95 | // Serial.print(F(" ")); 96 | // Serial.print(orientation.pitch); 97 | // Serial.print(F(" ")); 98 | // } 99 | // 100 | // /* Calculate the heading using the magnetometer */ 101 | // mag.getEvent(&mag_event); 102 | // if (dof.magGetOrientation(SENSOR_AXIS_Z, &mag_event, &orientation)) 103 | // { 104 | // /* 'orientation' should have valid .heading data now */ 105 | // Serial.print(orientation.heading); 106 | // } 107 | // Serial.println(F("")); 108 | 109 | /* Calculate the altitude using the barometric pressure sensor */ 110 | bmp.getEvent(&bmp_event); 111 | if (bmp_event.pressure) 112 | { 113 | /* Get ambient temperature in C */ 114 | float temperature; 115 | bmp.getTemperature(&temperature); 116 | /* Convert atmospheric pressure, SLP and temp to altitude */ 117 | Serial.print(F("Alt: ")); 118 | Serial.print(bmp.pressureToAltitude(seaLevelPressure, 119 | bmp_event.pressure, 120 | temperature)); 121 | Serial.println(F("")); 122 | /* Display the temperature */ 123 | Serial.print(F("Temp: ")); 124 | Serial.print(temperature); 125 | Serial.println(F("")); 126 | } 127 | 128 | delay(100); 129 | } 130 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/ahrs/processing/cuberotate/cuberotate.pde: -------------------------------------------------------------------------------- 1 | import processing.serial.*; 2 | import java.awt.datatransfer.*; 3 | import java.awt.Toolkit; 4 | import processing.opengl.*; 5 | import saito.objloader.*; 6 | import g4p_controls.*; 7 | 8 | float roll = 0.0F; 9 | float pitch = 0.0F; 10 | float yaw = 0.0F; 11 | float temp = 0.0F; 12 | float alt = 0.0F; 13 | 14 | OBJModel model; 15 | 16 | // Serial port state. 17 | Serial port; 18 | String buffer = ""; 19 | final String serialConfigFile = "serialconfig.txt"; 20 | boolean printSerial = false; 21 | 22 | // UI controls. 23 | GPanel configPanel; 24 | GDropList serialList; 25 | GLabel serialLabel; 26 | GCheckbox printSerialCheckbox; 27 | 28 | void setup() 29 | { 30 | size(400, 550, OPENGL); 31 | frameRate(30); 32 | model = new OBJModel(this); 33 | model.load("bunny.obj"); 34 | model.scale(20); 35 | 36 | // Serial port setup. 37 | // Grab list of serial ports and choose one that was persisted earlier or default to the first port. 38 | int selectedPort = 0; 39 | String[] availablePorts = Serial.list(); 40 | if (availablePorts == null) { 41 | println("ERROR: No serial ports available!"); 42 | exit(); 43 | } 44 | String[] serialConfig = loadStrings(serialConfigFile); 45 | if (serialConfig != null && serialConfig.length > 0) { 46 | String savedPort = serialConfig[0]; 47 | // Check if saved port is in available ports. 48 | for (int i = 0; i < availablePorts.length; ++i) { 49 | if (availablePorts[i].equals(savedPort)) { 50 | selectedPort = i; 51 | } 52 | } 53 | } 54 | // Build serial config UI. 55 | configPanel = new GPanel(this, 10, 10, width-20, 90, "Configuration (click to hide/show)"); 56 | serialLabel = new GLabel(this, 0, 20, 80, 25, "Serial port:"); 57 | configPanel.addControl(serialLabel); 58 | serialList = new GDropList(this, 90, 20, 200, 200, 6); 59 | serialList.setItems(availablePorts, selectedPort); 60 | configPanel.addControl(serialList); 61 | printSerialCheckbox = new GCheckbox(this, 5, 50, 200, 20, "Print serial data"); 62 | printSerialCheckbox.setSelected(printSerial); 63 | configPanel.addControl(printSerialCheckbox); 64 | // Set serial port. 65 | setSerialPort(serialList.getSelectedText()); 66 | } 67 | 68 | void draw() 69 | { 70 | background(0,0, 0); 71 | 72 | // Set a new co-ordinate space 73 | pushMatrix(); 74 | 75 | // Simple 3 point lighting for dramatic effect. 76 | // Slightly red light in upper right, slightly blue light in upper left, and white light from behind. 77 | pointLight(255, 200, 200, 400, 400, 500); 78 | pointLight(200, 200, 255, -400, 400, 500); 79 | pointLight(255, 255, 255, 0, 0, -500); 80 | 81 | // Displace objects from 0,0 82 | translate(200, 300, 0); 83 | 84 | // Rotate shapes around the X/Y/Z axis (values in radians, 0..Pi*2) 85 | rotateX(radians(roll)); 86 | rotateZ(radians(pitch)); 87 | rotateY(radians(yaw)); 88 | 89 | pushMatrix(); 90 | noStroke(); 91 | model.draw(); 92 | popMatrix(); 93 | popMatrix(); 94 | //print("draw"); 95 | } 96 | 97 | void serialEvent(Serial p) 98 | { 99 | String incoming = p.readString(); 100 | if (printSerial) { 101 | println(incoming); 102 | } 103 | 104 | if ((incoming.length() > 8)) 105 | { 106 | String[] list = split(incoming, " "); 107 | if ( (list.length > 0) && (list[0].equals("Orientation:")) ) 108 | { 109 | roll = float(list[1]); 110 | pitch = float(list[2]); 111 | yaw = float(list[3]); 112 | buffer = incoming; 113 | } 114 | if ( (list.length > 0) && (list[0].equals("Alt:")) ) 115 | { 116 | alt = float(list[1]); 117 | buffer = incoming; 118 | } 119 | if ( (list.length > 0) && (list[0].equals("Temp:")) ) 120 | { 121 | temp = float(list[1]); 122 | buffer = incoming; 123 | } 124 | } 125 | } 126 | 127 | // Set serial port to desired value. 128 | void setSerialPort(String portName) { 129 | // Close the port if it's currently open. 130 | if (port != null) { 131 | port.stop(); 132 | } 133 | try { 134 | // Open port. 135 | port = new Serial(this, portName, 115200); 136 | port.bufferUntil('\n'); 137 | // Persist port in configuration. 138 | saveStrings(serialConfigFile, new String[] { portName }); 139 | } 140 | catch (RuntimeException ex) { 141 | // Swallow error if port can't be opened, keep port closed. 142 | port = null; 143 | } 144 | } 145 | 146 | // UI event handlers 147 | 148 | void handlePanelEvents(GPanel panel, GEvent event) { 149 | // Panel events, do nothing. 150 | } 151 | 152 | void handleDropListEvents(GDropList list, GEvent event) { 153 | // Drop list events, check if new serial port is selected. 154 | if (list == serialList) { 155 | setSerialPort(serialList.getSelectedText()); 156 | } 157 | } 158 | 159 | void handleToggleControlEvents(GToggleControl checkbox, GEvent event) { 160 | // Checkbox toggle events, check if print events is toggled. 161 | if (checkbox == printSerialCheckbox) { 162 | printSerial = printSerialCheckbox.isSelected(); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/ahrs/processing/cuberotate/data/bunny.mtl: -------------------------------------------------------------------------------- 1 | # 3ds Max Wavefront OBJ Exporter v0.94b - (c)2007 guruware 2 | # File Created: 04.07.2010 10:41:39 3 | 4 | newmtl Body 5 | Ns 32 6 | d 1 7 | Tr 1 8 | Tf 1 1 1 9 | illum 2 10 | Ka 0.0000 0.0000 0.0000 11 | Kd 0.7412 0.4784 0.4765 12 | Ks 0.3500 0.3500 0.6500 13 | 14 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/pitchrollheading/pitchrollheading.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* Assign a unique ID to the sensors */ 9 | Adafruit_10DOF dof = Adafruit_10DOF(); 10 | Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301); 11 | Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(30302); 12 | Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(18001); 13 | 14 | /* Update this with the correct SLP for accurate altitude measurements */ 15 | float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; 16 | 17 | /**************************************************************************/ 18 | /*! 19 | @brief Initialises all the sensors used by this example 20 | */ 21 | /**************************************************************************/ 22 | void initSensors() 23 | { 24 | if(!accel.begin()) 25 | { 26 | /* There was a problem detecting the LSM303 ... check your connections */ 27 | Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!")); 28 | while(1); 29 | } 30 | if(!mag.begin()) 31 | { 32 | /* There was a problem detecting the LSM303 ... check your connections */ 33 | Serial.println("Ooops, no LSM303 detected ... Check your wiring!"); 34 | while(1); 35 | } 36 | if(!bmp.begin()) 37 | { 38 | /* There was a problem detecting the BMP180 ... check your connections */ 39 | Serial.println("Ooops, no BMP180 detected ... Check your wiring!"); 40 | while(1); 41 | } 42 | } 43 | 44 | /**************************************************************************/ 45 | /*! 46 | 47 | */ 48 | /**************************************************************************/ 49 | void setup(void) 50 | { 51 | Serial.begin(115200); 52 | Serial.println(F("Adafruit 10 DOF Pitch/Roll/Heading Example")); Serial.println(""); 53 | 54 | /* Initialise the sensors */ 55 | initSensors(); 56 | } 57 | 58 | /**************************************************************************/ 59 | /*! 60 | @brief Constantly check the roll/pitch/heading/altitude/temperature 61 | */ 62 | /**************************************************************************/ 63 | void loop(void) 64 | { 65 | sensors_event_t accel_event; 66 | sensors_event_t mag_event; 67 | sensors_event_t bmp_event; 68 | sensors_vec_t orientation; 69 | 70 | /* Calculate pitch and roll from the raw accelerometer data */ 71 | accel.getEvent(&accel_event); 72 | if (dof.accelGetOrientation(&accel_event, &orientation)) 73 | { 74 | /* 'orientation' should have valid .roll and .pitch fields */ 75 | Serial.print(F("Roll: ")); 76 | Serial.print(orientation.roll); 77 | Serial.print(F("; ")); 78 | Serial.print(F("Pitch: ")); 79 | Serial.print(orientation.pitch); 80 | Serial.print(F("; ")); 81 | } 82 | 83 | /* Calculate the heading using the magnetometer */ 84 | mag.getEvent(&mag_event); 85 | if (dof.magGetOrientation(SENSOR_AXIS_Z, &mag_event, &orientation)) 86 | { 87 | /* 'orientation' should have valid .heading data now */ 88 | Serial.print(F("Heading: ")); 89 | Serial.print(orientation.heading); 90 | Serial.print(F("; ")); 91 | } 92 | 93 | /* Calculate the altitude using the barometric pressure sensor */ 94 | bmp.getEvent(&bmp_event); 95 | if (bmp_event.pressure) 96 | { 97 | /* Get ambient temperature in C */ 98 | float temperature; 99 | bmp.getTemperature(&temperature); 100 | /* Convert atmospheric pressure, SLP and temp to altitude */ 101 | Serial.print(F("Alt: ")); 102 | Serial.print(bmp.pressureToAltitude(seaLevelPressure, 103 | bmp_event.pressure, 104 | temperature)); 105 | Serial.print(F(" m; ")); 106 | /* Display the temperature */ 107 | Serial.print(F("Temp: ")); 108 | Serial.print(temperature); 109 | Serial.print(F(" C")); 110 | } 111 | 112 | Serial.println(F("")); 113 | delay(1000); 114 | } 115 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_10DOF/tester/tester.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* Assign a unique ID to the sensors */ 9 | Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301); 10 | Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(30302); 11 | Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(18001); 12 | Adafruit_L3GD20_Unified gyro = Adafruit_L3GD20_Unified(20); 13 | 14 | void displaySensorDetails(void) 15 | { 16 | sensor_t sensor; 17 | 18 | accel.getSensor(&sensor); 19 | Serial.println(F("----------- ACCELEROMETER ----------")); 20 | Serial.print (F("Sensor: ")); Serial.println(sensor.name); 21 | Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); 22 | Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); 23 | Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F(" m/s^2")); 24 | Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F(" m/s^2")); 25 | Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F(" m/s^2")); 26 | Serial.println(F("------------------------------------")); 27 | Serial.println(F("")); 28 | 29 | gyro.getSensor(&sensor); 30 | Serial.println(F("------------- GYROSCOPE -----------")); 31 | Serial.print (F("Sensor: ")); Serial.println(sensor.name); 32 | Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); 33 | Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); 34 | Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F(" rad/s")); 35 | Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F(" rad/s")); 36 | Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F(" rad/s")); 37 | Serial.println(F("------------------------------------")); 38 | Serial.println(F("")); 39 | 40 | mag.getSensor(&sensor); 41 | Serial.println(F("----------- MAGNETOMETER -----------")); 42 | Serial.print (F("Sensor: ")); Serial.println(sensor.name); 43 | Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); 44 | Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); 45 | Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F(" uT")); 46 | Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F(" uT")); 47 | Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F(" uT")); 48 | Serial.println(F("------------------------------------")); 49 | Serial.println(F("")); 50 | 51 | bmp.getSensor(&sensor); 52 | Serial.println(F("-------- PRESSURE/ALTITUDE ---------")); 53 | Serial.print (F("Sensor: ")); Serial.println(sensor.name); 54 | Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); 55 | Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); 56 | Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F(" hPa")); 57 | Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F(" hPa")); 58 | Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F(" hPa")); 59 | Serial.println(F("------------------------------------")); 60 | Serial.println(F("")); 61 | 62 | delay(500); 63 | } 64 | 65 | void setup(void) 66 | { 67 | Serial.begin(115200); 68 | Serial.println(F("Adafruit 10DOF Tester")); Serial.println(""); 69 | 70 | /* Initialise the sensors */ 71 | if(!accel.begin()) 72 | { 73 | /* There was a problem detecting the ADXL345 ... check your connections */ 74 | Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!")); 75 | while(1); 76 | } 77 | if(!mag.begin()) 78 | { 79 | /* There was a problem detecting the LSM303 ... check your connections */ 80 | Serial.println("Ooops, no LSM303 detected ... Check your wiring!"); 81 | while(1); 82 | } 83 | if(!bmp.begin()) 84 | { 85 | /* There was a problem detecting the BMP085 ... check your connections */ 86 | Serial.print("Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!"); 87 | while(1); 88 | } 89 | if(!gyro.begin()) 90 | { 91 | /* There was a problem detecting the L3GD20 ... check your connections */ 92 | Serial.print("Ooops, no L3GD20 detected ... Check your wiring or I2C ADDR!"); 93 | while(1); 94 | } 95 | 96 | /* Display some basic information on this sensor */ 97 | displaySensorDetails(); 98 | } 99 | 100 | void loop(void) 101 | { 102 | /* Get a new sensor event */ 103 | sensors_event_t event; 104 | 105 | /* Display the results (acceleration is measured in m/s^2) */ 106 | accel.getEvent(&event); 107 | Serial.print(F("ACCEL ")); 108 | Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" "); 109 | Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" "); 110 | Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" ");Serial.println("m/s^2 "); 111 | 112 | /* Display the results (magnetic vector values are in micro-Tesla (uT)) */ 113 | mag.getEvent(&event); 114 | Serial.print(F("MAG ")); 115 | Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print(" "); 116 | Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print(" "); 117 | Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print(" ");Serial.println("uT"); 118 | 119 | /* Display the results (gyrocope values in rad/s) */ 120 | gyro.getEvent(&event); 121 | Serial.print(F("GYRO ")); 122 | Serial.print("X: "); Serial.print(event.gyro.x); Serial.print(" "); 123 | Serial.print("Y: "); Serial.print(event.gyro.y); Serial.print(" "); 124 | Serial.print("Z: "); Serial.print(event.gyro.z); Serial.print(" ");Serial.println("rad/s "); 125 | 126 | /* Display the pressure sensor results (barometric pressure is measure in hPa) */ 127 | bmp.getEvent(&event); 128 | if (event.pressure) 129 | { 130 | /* Display atmospheric pressure in hPa */ 131 | Serial.print(F("PRESS ")); 132 | Serial.print(event.pressure); 133 | Serial.print(F(" hPa, ")); 134 | /* Display ambient temperature in C */ 135 | float temperature; 136 | bmp.getTemperature(&temperature); 137 | Serial.print(temperature); 138 | Serial.print(F(" C, ")); 139 | /* Then convert the atmospheric pressure, SLP and temp to altitude */ 140 | /* Update this next line with the current SLP for better results */ 141 | float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; 142 | Serial.print(bmp.pressureToAltitude(seaLevelPressure, 143 | event.pressure, 144 | temperature)); 145 | Serial.println(F(" m")); 146 | } 147 | 148 | Serial.println(F("")); 149 | delay(1000); 150 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP085_Unified/Adafruit_BMP085_U.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This is a library for the BMP085 pressure sensor 3 | 4 | Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout 5 | ----> http://www.adafruit.com/products/391 6 | ----> http://www.adafruit.com/products/1603 7 | 8 | These displays use I2C to communicate, 2 pins are required to interface. 9 | 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit andopen-source hardware by purchasing products 12 | from Adafruit! 13 | 14 | Written by Kevin Townsend for Adafruit Industries. 15 | BSD license, all text above must be included in any redistribution 16 | ***************************************************************************/ 17 | #ifndef __BMP085_H__ 18 | #define __BMP085_H__ 19 | 20 | #if (ARDUINO >= 100) 21 | #include "Arduino.h" 22 | #else 23 | #include "WProgram.h" 24 | #endif 25 | 26 | #include 27 | 28 | #ifdef __AVR_ATtiny85__ 29 | #include "TinyWireM.h" 30 | #define Wire TinyWireM 31 | #else 32 | #include 33 | #endif 34 | 35 | /*========================================================================= 36 | I2C ADDRESS/BITS 37 | -----------------------------------------------------------------------*/ 38 | #define BMP085_ADDRESS (0x77) 39 | /*=========================================================================*/ 40 | 41 | /*========================================================================= 42 | REGISTERS 43 | -----------------------------------------------------------------------*/ 44 | enum 45 | { 46 | BMP085_REGISTER_CAL_AC1 = 0xAA, // R Calibration data (16 bits) 47 | BMP085_REGISTER_CAL_AC2 = 0xAC, // R Calibration data (16 bits) 48 | BMP085_REGISTER_CAL_AC3 = 0xAE, // R Calibration data (16 bits) 49 | BMP085_REGISTER_CAL_AC4 = 0xB0, // R Calibration data (16 bits) 50 | BMP085_REGISTER_CAL_AC5 = 0xB2, // R Calibration data (16 bits) 51 | BMP085_REGISTER_CAL_AC6 = 0xB4, // R Calibration data (16 bits) 52 | BMP085_REGISTER_CAL_B1 = 0xB6, // R Calibration data (16 bits) 53 | BMP085_REGISTER_CAL_B2 = 0xB8, // R Calibration data (16 bits) 54 | BMP085_REGISTER_CAL_MB = 0xBA, // R Calibration data (16 bits) 55 | BMP085_REGISTER_CAL_MC = 0xBC, // R Calibration data (16 bits) 56 | BMP085_REGISTER_CAL_MD = 0xBE, // R Calibration data (16 bits) 57 | BMP085_REGISTER_CHIPID = 0xD0, 58 | BMP085_REGISTER_VERSION = 0xD1, 59 | BMP085_REGISTER_SOFTRESET = 0xE0, 60 | BMP085_REGISTER_CONTROL = 0xF4, 61 | BMP085_REGISTER_TEMPDATA = 0xF6, 62 | BMP085_REGISTER_PRESSUREDATA = 0xF6, 63 | BMP085_REGISTER_READTEMPCMD = 0x2E, 64 | BMP085_REGISTER_READPRESSURECMD = 0x34 65 | }; 66 | /*=========================================================================*/ 67 | 68 | /*========================================================================= 69 | MODE SETTINGS 70 | -----------------------------------------------------------------------*/ 71 | typedef enum 72 | { 73 | BMP085_MODE_ULTRALOWPOWER = 0, 74 | BMP085_MODE_STANDARD = 1, 75 | BMP085_MODE_HIGHRES = 2, 76 | BMP085_MODE_ULTRAHIGHRES = 3 77 | } bmp085_mode_t; 78 | /*=========================================================================*/ 79 | 80 | /*========================================================================= 81 | CALIBRATION DATA 82 | -----------------------------------------------------------------------*/ 83 | typedef struct 84 | { 85 | int16_t ac1; 86 | int16_t ac2; 87 | int16_t ac3; 88 | uint16_t ac4; 89 | uint16_t ac5; 90 | uint16_t ac6; 91 | int16_t b1; 92 | int16_t b2; 93 | int16_t mb; 94 | int16_t mc; 95 | int16_t md; 96 | } bmp085_calib_data; 97 | /*=========================================================================*/ 98 | 99 | class Adafruit_BMP085_Unified : public Adafruit_Sensor 100 | { 101 | public: 102 | Adafruit_BMP085_Unified(int32_t sensorID = -1); 103 | 104 | bool begin(bmp085_mode_t mode = BMP085_MODE_ULTRAHIGHRES); 105 | void getTemperature(float *temp); 106 | void getPressure(float *pressure); 107 | float pressureToAltitude(float seaLvel, float atmospheric); 108 | float seaLevelForAltitude(float altitude, float atmospheric); 109 | // Note that the next two functions are just for compatibility with old 110 | // code that passed the temperature as a third parameter. A newer 111 | // calculation is used which does not need temperature. 112 | float pressureToAltitude(float seaLevel, float atmospheric, float temp); 113 | float seaLevelForAltitude(float altitude, float atmospheric, float temp); 114 | bool getEvent(sensors_event_t*); 115 | void getSensor(sensor_t*); 116 | 117 | private: 118 | int32_t computeB5(int32_t ut); 119 | int32_t _sensorID; 120 | }; 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP085_Unified/README.md: -------------------------------------------------------------------------------- 1 | #Adafruit Unified BMP085/BMP180 Driver (Barometric Pressure Sensor) # 2 | 3 | This driver is for the Adafruit BMP085 Breakout (http://www.adafruit.com/products/391) or BMP180 breakout (http://www.adafruit.com/products/1603), and is based on Adafruit's Unified Sensor Library (Adafruit_Sensor). 4 | 5 | ## About the BMP085 / BMP180 ## 6 | 7 | This precision sensor from Bosch is the best low-cost sensing solution for measuring barometric pressure and temperature. Because pressure changes with altitude you can also use it as an altimeter! 8 | 9 | ## What is the Adafruit Unified Sensor Library? ## 10 | 11 | The Adafruit Unified Sensor Library ([Adafruit_Sensor](https://github.com/adafruit/Adafruit_Sensor)) provides a common interface and data type for any supported sensor. It defines some basic information about the sensor (sensor limits, etc.), and returns standard SI units of a specific type and scale for each supported sensor type. 12 | 13 | It provides a simple abstraction layer between your application and the actual sensor HW, allowing you to drop in any comparable sensor with only one or two lines of code to change in your project (essentially the constructor since the functions to read sensor data and get information about the sensor are defined in the base Adafruit_Sensor class). 14 | 15 | This is imporant useful for two reasons: 16 | 17 | 1.) You can use the data right away because it's already converted to SI units that you understand and can compare, rather than meaningless values like 0..1023. 18 | 19 | 2.) Because SI units are standardised in the sensor library, you can also do quick sanity checks when working with new sensors, or drop in any comparable sensor if you need better sensitivity or if a lower cost unit becomes available, etc. 20 | 21 | Light sensors will always report units in lux, gyroscopes will always report units in rad/s, etc. ... freeing you up to focus on the data, rather than digging through the datasheet to understand what the sensor's raw numbers really mean. 22 | 23 | ## About this Driver ## 24 | 25 | Adafruit invests time and resources providing this open source code. Please support Adafruit and open-source hardware by purchasing products from Adafruit! 26 | 27 | Written by Kevin (KTOWN) Townsend for Adafruit Industries. 28 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP085_Unified/examples/sensorapi/sensorapi.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* This driver uses the Adafruit unified sensor library (Adafruit_Sensor), 6 | which provides a common 'type' for sensor data and some helper functions. 7 | 8 | To use this driver you will also need to download the Adafruit_Sensor 9 | library and include it in your libraries folder. 10 | 11 | You should also assign a unique ID to this sensor for use with 12 | the Adafruit Sensor API so that you can identify this particular 13 | sensor in any data logs, etc. To assign a unique ID, simply 14 | provide an appropriate value in the constructor below (12345 15 | is used by default in this example). 16 | 17 | Connections 18 | =========== 19 | Connect SCL to analog 5 20 | Connect SDA to analog 4 21 | Connect VDD to 3.3V DC 22 | Connect GROUND to common ground 23 | 24 | History 25 | ======= 26 | 2013/JUN/17 - Updated altitude calculations (KTOWN) 27 | 2013/FEB/13 - First version (KTOWN) 28 | */ 29 | 30 | Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); 31 | 32 | /**************************************************************************/ 33 | /* 34 | Displays some basic information on this sensor from the unified 35 | sensor API sensor_t type (see Adafruit_Sensor for more information) 36 | */ 37 | /**************************************************************************/ 38 | void displaySensorDetails(void) 39 | { 40 | sensor_t sensor; 41 | bmp.getSensor(&sensor); 42 | Serial.println("------------------------------------"); 43 | Serial.print ("Sensor: "); Serial.println(sensor.name); 44 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 45 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 46 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" hPa"); 47 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" hPa"); 48 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" hPa"); 49 | Serial.println("------------------------------------"); 50 | Serial.println(""); 51 | delay(500); 52 | } 53 | 54 | /**************************************************************************/ 55 | /* 56 | Arduino setup function (automatically called at startup) 57 | */ 58 | /**************************************************************************/ 59 | void setup(void) 60 | { 61 | Serial.begin(9600); 62 | Serial.println("Pressure Sensor Test"); Serial.println(""); 63 | 64 | /* Initialise the sensor */ 65 | if(!bmp.begin()) 66 | { 67 | /* There was a problem detecting the BMP085 ... check your connections */ 68 | Serial.print("Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!"); 69 | while(1); 70 | } 71 | 72 | /* Display some basic information on this sensor */ 73 | displaySensorDetails(); 74 | } 75 | 76 | /**************************************************************************/ 77 | /* 78 | Arduino loop function, called once 'setup' is complete (your own code 79 | should go here) 80 | */ 81 | /**************************************************************************/ 82 | void loop(void) 83 | { 84 | /* Get a new sensor event */ 85 | sensors_event_t event; 86 | bmp.getEvent(&event); 87 | 88 | /* Display the results (barometric pressure is measure in hPa) */ 89 | if (event.pressure) 90 | { 91 | /* Display atmospheric pressue in hPa */ 92 | Serial.print("Pressure: "); 93 | Serial.print(event.pressure); 94 | Serial.println(" hPa"); 95 | 96 | /* Calculating altitude with reasonable accuracy requires pressure * 97 | * sea level pressure for your position at the moment the data is * 98 | * converted, as well as the ambient temperature in degress * 99 | * celcius. If you don't have these values, a 'generic' value of * 100 | * 1013.25 hPa can be used (defined as SENSORS_PRESSURE_SEALEVELHPA * 101 | * in sensors.h), but this isn't ideal and will give variable * 102 | * results from one day to the next. * 103 | * * 104 | * You can usually find the current SLP value by looking at weather * 105 | * websites or from environmental information centers near any major * 106 | * airport. * 107 | * * 108 | * For example, for Paris, France you can check the current mean * 109 | * pressure and sea level at: http://bit.ly/16Au8ol */ 110 | 111 | /* First we get the current temperature from the BMP085 */ 112 | float temperature; 113 | bmp.getTemperature(&temperature); 114 | Serial.print("Temperature: "); 115 | Serial.print(temperature); 116 | Serial.println(" C"); 117 | 118 | /* Then convert the atmospheric pressure, and SLP to altitude */ 119 | /* Update this next line with the current SLP for better results */ 120 | float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; 121 | Serial.print("Altitude: "); 122 | Serial.print(bmp.pressureToAltitude(seaLevelPressure, 123 | event.pressure)); 124 | Serial.println(" m"); 125 | Serial.println(""); 126 | } 127 | else 128 | { 129 | Serial.println("Sensor error"); 130 | } 131 | delay(1000); 132 | } 133 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP085_Unified/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit BMP085 Unified 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Unified sensor driver for Adafruit's BMP085 & BMP180 breakouts 6 | paragraph=Unified sensor driver for Adafruit's BMP085 & BMP180 breakouts 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_BMP085_Unified 9 | architectures=* 10 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP183_Library/Adafruit_BMP183.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Adafruit BMP183 Barometric Pressure + Temp sensor 3 | 4 | Designed specifically to work with the Adafruit BMP183 Breakout 5 | ----> http://www.adafruit.com/products/1900 6 | 7 | These sensors use SPI to communicate, 4 pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #include "Adafruit_BMP183.h" 18 | #ifdef __AVR__ 19 | #include 20 | #endif 21 | #ifdef __SAM3X8E__ 22 | #define _delay_ms(t) delay(t) 23 | #endif 24 | #include 25 | 26 | 27 | Adafruit_BMP183::Adafruit_BMP183(int8_t SPICS ) { 28 | _cs = SPICS; 29 | _clk = _miso = _mosi = -1; 30 | } 31 | 32 | Adafruit_BMP183::Adafruit_BMP183(int8_t SPICLK, 33 | int8_t SPIMISO, 34 | int8_t SPIMOSI, 35 | int8_t SPICS) { 36 | _cs = SPICS; 37 | _clk = SPICLK; 38 | _miso = SPIMISO; 39 | _mosi = SPIMOSI; 40 | } 41 | 42 | 43 | boolean Adafruit_BMP183::begin(bmp183_mode_t mode) { 44 | if (_clk == -1) { 45 | SPI.begin(); 46 | SPI.setDataMode(SPI_MODE0); 47 | #ifdef __AVR__ 48 | SPI.setClockDivider(SPI_CLOCK_DIV16); 49 | #endif 50 | #ifdef __SAM3X8E__ 51 | SPI.setClockDivider(11); // 8-ish MHz (full! speed!) 52 | #endif 53 | } else { 54 | pinMode(_clk, OUTPUT); 55 | digitalWrite(_clk, HIGH); 56 | pinMode(_mosi, OUTPUT); 57 | digitalWrite(_mosi, HIGH); 58 | pinMode(_miso, INPUT); 59 | } 60 | pinMode(_cs, OUTPUT); 61 | digitalWrite(_cs, HIGH); 62 | 63 | 64 | /* Mode boundary check */ 65 | if ((mode > BMP183_MODE_ULTRAHIGHRES) || (mode < 0)) 66 | { 67 | mode = BMP183_MODE_ULTRAHIGHRES; 68 | } 69 | 70 | /* Set the mode indicator */ 71 | oversampling = mode; 72 | 73 | 74 | if (read8(0xD0) != 0x55) return false; 75 | 76 | /* read calibration data */ 77 | ac1 = read16(BMP183_REGISTER_CAL_AC1); 78 | ac2 = read16(BMP183_REGISTER_CAL_AC2); 79 | ac3 = read16(BMP183_REGISTER_CAL_AC3); 80 | ac4 = read16(BMP183_REGISTER_CAL_AC4); 81 | ac5 = read16(BMP183_REGISTER_CAL_AC5); 82 | ac6 = read16(BMP183_REGISTER_CAL_AC6); 83 | 84 | b1 = read16(BMP183_REGISTER_CAL_B1); 85 | b2 = read16(BMP183_REGISTER_CAL_B2); 86 | 87 | mb = read16(BMP183_REGISTER_CAL_MB); 88 | mc = read16(BMP183_REGISTER_CAL_MC); 89 | md = read16(BMP183_REGISTER_CAL_MD); 90 | #if (BMP183_DEBUG == 1) 91 | Serial.print("ac1 = "); Serial.println(ac1, DEC); 92 | Serial.print("ac2 = "); Serial.println(ac2, DEC); 93 | Serial.print("ac3 = "); Serial.println(ac3, DEC); 94 | Serial.print("ac4 = "); Serial.println(ac4, DEC); 95 | Serial.print("ac5 = "); Serial.println(ac5, DEC); 96 | Serial.print("ac6 = "); Serial.println(ac6, DEC); 97 | 98 | Serial.print("b1 = "); Serial.println(b1, DEC); 99 | Serial.print("b2 = "); Serial.println(b2, DEC); 100 | 101 | Serial.print("mb = "); Serial.println(mb, DEC); 102 | Serial.print("mc = "); Serial.println(mc, DEC); 103 | Serial.print("md = "); Serial.println(md, DEC); 104 | #endif 105 | } 106 | 107 | uint16_t Adafruit_BMP183::readRawTemperature(void) { 108 | write8(BMP183_REGISTER_CONTROL, BMP183_REGISTER_READTEMPCMD); 109 | _delay_ms(5); 110 | #if BMP183_DEBUG == 1 111 | Serial.print("Raw temp: "); Serial.println(read16(BMP183_REGISTER_TEMPDATA)); 112 | #endif 113 | return read16(BMP183_REGISTER_TEMPDATA); 114 | } 115 | 116 | uint32_t Adafruit_BMP183::readRawPressure(void) { 117 | uint32_t raw; 118 | 119 | write8(BMP183_REGISTER_CONTROL, BMP183_REGISTER_READPRESSURECMD + (oversampling << 6)); 120 | 121 | if (oversampling == BMP183_MODE_ULTRALOWPOWER) 122 | _delay_ms(5); 123 | else if (oversampling == BMP183_MODE_STANDARD) 124 | _delay_ms(8); 125 | else if (oversampling == BMP183_MODE_HIGHRES) 126 | _delay_ms(14); 127 | else 128 | _delay_ms(26); 129 | 130 | raw = read16(BMP183_REGISTER_PRESSUREDATA); 131 | 132 | raw <<= 8; 133 | raw |= read8(BMP183_REGISTER_PRESSUREDATA+2); 134 | raw >>= (8 - oversampling); 135 | 136 | /* this pull broke stuff, look at it later? 137 | if (oversampling==0) { 138 | raw <<= 8; 139 | raw |= read8(BMP183_PRESSUREDATA+2); 140 | raw >>= (8 - oversampling); 141 | } 142 | */ 143 | 144 | #if BMP183_DEBUG == 1 145 | Serial.print("Raw pressure: "); Serial.println(raw); 146 | #endif 147 | return raw; 148 | } 149 | 150 | 151 | int32_t Adafruit_BMP183::getPressure(void) { 152 | int32_t UT, UP, B3, B5, B6, X1, X2, X3, p; 153 | uint32_t B4, B7; 154 | 155 | UT = readRawTemperature(); 156 | UP = readRawPressure(); 157 | 158 | #if BMP183_DEBUG == 1 159 | // use datasheet numbers! 160 | UT = 27898; 161 | UP = 23843; 162 | ac6 = 23153; 163 | ac5 = 32757; 164 | mc = -8711; 165 | md = 2868; 166 | b1 = 6190; 167 | b2 = 4; 168 | ac3 = -14383; 169 | ac2 = -72; 170 | ac1 = 408; 171 | ac4 = 32741; 172 | oversampling = 0; 173 | #endif 174 | 175 | // do temperature calculations 176 | X1=(UT-(int32_t)(ac6))*((int32_t)(ac5))/pow(2,15); 177 | X2=((int32_t)mc*pow(2,11))/(X1+(int32_t)md); 178 | B5=X1 + X2; 179 | 180 | #if BMP183_DEBUG == 1 181 | Serial.print("X1 = "); Serial.println(X1); 182 | Serial.print("X2 = "); Serial.println(X2); 183 | Serial.print("B5 = "); Serial.println(B5); 184 | #endif 185 | 186 | // do pressure calcs 187 | B6 = B5 - 4000; 188 | X1 = ((int32_t)b2 * ( (B6 * B6)>>12 )) >> 11; 189 | X2 = ((int32_t)ac2 * B6) >> 11; 190 | X3 = X1 + X2; 191 | B3 = ((((int32_t)ac1*4 + X3) << oversampling) + 2) / 4; 192 | 193 | #if BMP183_DEBUG == 1 194 | Serial.print("B6 = "); Serial.println(B6); 195 | Serial.print("X1 = "); Serial.println(X1); 196 | Serial.print("X2 = "); Serial.println(X2); 197 | Serial.print("B3 = "); Serial.println(B3); 198 | #endif 199 | 200 | X1 = ((int32_t)ac3 * B6) >> 13; 201 | X2 = ((int32_t)b1 * ((B6 * B6) >> 12)) >> 16; 202 | X3 = ((X1 + X2) + 2) >> 2; 203 | B4 = ((uint32_t)ac4 * (uint32_t)(X3 + 32768)) >> 15; 204 | B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling ); 205 | 206 | #if BMP183_DEBUG == 1 207 | Serial.print("X1 = "); Serial.println(X1); 208 | Serial.print("X2 = "); Serial.println(X2); 209 | Serial.print("B4 = "); Serial.println(B4); 210 | Serial.print("B7 = "); Serial.println(B7); 211 | #endif 212 | 213 | if (B7 < 0x80000000) { 214 | p = (B7 * 2) / B4; 215 | } else { 216 | p = (B7 / B4) * 2; 217 | } 218 | X1 = (p >> 8) * (p >> 8); 219 | X1 = (X1 * 3038) >> 16; 220 | X2 = (-7357 * p) >> 16; 221 | 222 | #if BMP183_DEBUG == 1 223 | Serial.print("p = "); Serial.println(p); 224 | Serial.print("X1 = "); Serial.println(X1); 225 | Serial.print("X2 = "); Serial.println(X2); 226 | #endif 227 | 228 | p = p + ((X1 + X2 + (int32_t)3791)>>4); 229 | #if BMP183_DEBUG == 1 230 | Serial.print("p = "); Serial.println(p); 231 | #endif 232 | return p; 233 | } 234 | 235 | 236 | float Adafruit_BMP183::getTemperature(void) { 237 | int32_t UT, X1, X2, B5; // following ds convention 238 | float temp; 239 | 240 | UT = readRawTemperature(); 241 | 242 | #if BMP183_DEBUG == 1 243 | // use datasheet numbers! 244 | UT = 27898; 245 | ac6 = 23153; 246 | ac5 = 32757; 247 | mc = -8711; 248 | md = 2868; 249 | #endif 250 | 251 | // step 1 252 | X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) / pow(2,15); 253 | X2 = ((int32_t)mc * pow(2,11)) / (X1+(int32_t)md); 254 | B5 = X1 + X2; 255 | temp = (B5+8)/pow(2,4); 256 | temp /= 10; 257 | 258 | return temp; 259 | } 260 | 261 | float Adafruit_BMP183::getAltitude(float sealevelPressure) { 262 | float altitude; 263 | 264 | float pressure = getPressure(); // in Si units for Pascal 265 | pressure /= 100; 266 | 267 | altitude = 44330 * (1.0 - pow(pressure /sealevelPressure,0.1903)); 268 | 269 | return altitude; 270 | } 271 | 272 | 273 | /*********************************************************************/ 274 | 275 | uint8_t Adafruit_BMP183::SPIxfer(uint8_t x) { 276 | if (_clk == -1) { 277 | return SPI.transfer(x); 278 | } else { 279 | //Serial.println("Software SPI"); 280 | uint8_t reply = 0; 281 | for (int i=7; i>=0; i--) { 282 | reply <<= 1; 283 | digitalWrite(_clk, LOW); 284 | digitalWrite(_mosi, x & (1< http://www.adafruit.com/products/1900 6 | 7 | These sensors use SPI to communicate, 4 pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #ifndef ADAFRUIT_BMP183_H 18 | #define ADAFRUIT_BMP183_H 19 | 20 | #if (ARDUINO >= 100) 21 | #include "Arduino.h" 22 | #else 23 | #include "WProgram.h" 24 | #endif 25 | #include "SPI.h" 26 | 27 | // use the 'default' datasheet numbers to test calculations 28 | #define BMP183_DEBUG 0 29 | 30 | /*========================================================================= 31 | REGISTERS 32 | -----------------------------------------------------------------------*/ 33 | enum 34 | { 35 | BMP183_REGISTER_CAL_AC1 = 0xAA, // R Calibration data (16 bits) 36 | BMP183_REGISTER_CAL_AC2 = 0xAC, // R Calibration data (16 bits) 37 | BMP183_REGISTER_CAL_AC3 = 0xAE, // R Calibration data (16 bits) 38 | BMP183_REGISTER_CAL_AC4 = 0xB0, // R Calibration data (16 bits) 39 | BMP183_REGISTER_CAL_AC5 = 0xB2, // R Calibration data (16 bits) 40 | BMP183_REGISTER_CAL_AC6 = 0xB4, // R Calibration data (16 bits) 41 | BMP183_REGISTER_CAL_B1 = 0xB6, // R Calibration data (16 bits) 42 | BMP183_REGISTER_CAL_B2 = 0xB8, // R Calibration data (16 bits) 43 | BMP183_REGISTER_CAL_MB = 0xBA, // R Calibration data (16 bits) 44 | BMP183_REGISTER_CAL_MC = 0xBC, // R Calibration data (16 bits) 45 | BMP183_REGISTER_CAL_MD = 0xBE, // R Calibration data (16 bits) 46 | BMP183_REGISTER_CHIPID = 0xD0, 47 | BMP183_REGISTER_VERSION = 0xD1, 48 | BMP183_REGISTER_SOFTRESET = 0xE0, 49 | BMP183_REGISTER_CONTROL = 0xF4, 50 | BMP183_REGISTER_TEMPDATA = 0xF6, 51 | BMP183_REGISTER_PRESSUREDATA = 0xF6, 52 | BMP183_REGISTER_READTEMPCMD = 0x2E, 53 | BMP183_REGISTER_READPRESSURECMD = 0x34 54 | }; 55 | /*=========================================================================*/ 56 | 57 | /*========================================================================= 58 | MODE SETTINGS 59 | -----------------------------------------------------------------------*/ 60 | typedef enum 61 | { 62 | BMP183_MODE_ULTRALOWPOWER = 0, 63 | BMP183_MODE_STANDARD = 1, 64 | BMP183_MODE_HIGHRES = 2, 65 | BMP183_MODE_ULTRAHIGHRES = 3 66 | } bmp183_mode_t; 67 | /*=========================================================================*/ 68 | 69 | class Adafruit_BMP183 { 70 | public: 71 | Adafruit_BMP183(int8_t SPICS); 72 | Adafruit_BMP183(int8_t SPICLK, int8_t SPIMISO, int8_t SPIMOSI, int8_t SPICS); 73 | 74 | boolean begin(bmp183_mode_t mode = BMP183_MODE_ULTRAHIGHRES); // by default go highres 75 | float getTemperature(void); 76 | int32_t getPressure(void); 77 | float getAltitude(float sealevelPressure = 101325); // std atmosphere 78 | uint16_t readRawTemperature(void); 79 | uint32_t readRawPressure(void); 80 | 81 | private: 82 | uint8_t SPIxfer(uint8_t x); 83 | uint8_t read8(uint8_t addr); 84 | uint16_t read16(uint8_t addr); 85 | void write8(uint8_t addr, uint8_t data); 86 | 87 | 88 | int8_t _cs, _clk, _miso, _mosi; 89 | 90 | uint8_t oversampling; 91 | 92 | int16_t ac1, ac2, ac3, b1, b2, mb, mc, md; 93 | uint16_t ac4, ac5, ac6; 94 | }; 95 | 96 | 97 | #endif // ADAFRUIT_BMP183_H 98 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP183_Library/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for the Adafruit BMP183 Barometric Pressure + Temp sensor 2 | 3 | Designed specifically to work with the Adafruit BMP183 Breakout 4 | ----> http://www.adafruit.com/products/1900 5 | 6 | These Sensors use SPI to communicate, 4 pins are required to interface 7 | 8 | Adafruit invests time and resources providing this open source code, 9 | please support Adafruit and open-source hardware by purchasing 10 | products from Adafruit! 11 | 12 | Check out the links above for our tutorials and wiring diagrams 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | BSD license, all text above must be included in any redistribution 16 | 17 | To download. click the DOWNLOAD ZIP button, rename the uncompressed folder Adafruit_BMP183. 18 | Check that the Adafruit_BMP183 folder contains Adafruit_BMP183.cpp and Adafruit_BMP183.h 19 | 20 | Place the Adafruit_BMP183 library folder your arduinosketchfolder/libraries/ folder. 21 | You may need to create the libraries subfolder if its your first library. Restart the IDE. 22 | 23 | We also have a great tutorial on Arduino library installation at: 24 | http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP183_Library/examples/BMP183test/BMP183test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // For hardware SPI: 6 | // Connect SCK to SPI Clock, SDO to SPI MISO, and SDI to SPI MOSI 7 | // See http://arduino.cc/en/Reference/SPI for your Arduino's SPI pins! 8 | // On UNO, Clock is #13, SDO/MISO is #12 and SDI/MOSI is #11 9 | 10 | // You can also use software SPI and define your own pins! 11 | #define BMP183_CLK 13 12 | #define BMP183_SDO 12 // AKA MISO 13 | #define BMP183_SDI 11 // AKA MOSI 14 | 15 | // You'll also need a chip-select pin, use any pin! 16 | #define BMP183_CS 10 17 | 18 | // initialize with hardware SPI 19 | //Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CS); 20 | // or initialize with software SPI and use any 4 pins 21 | Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS); 22 | 23 | /**************************************************************************/ 24 | /* 25 | Arduino setup function (automatically called at startup) 26 | */ 27 | /**************************************************************************/ 28 | void setup(void) 29 | { 30 | Serial.begin(9600); 31 | Serial.println("BMP183 Pressure Sensor Test"); Serial.println(""); 32 | 33 | /* Initialise the sensor */ 34 | if(!bmp.begin()) 35 | { 36 | /* There was a problem detecting the BMP183 ... check your connections */ 37 | Serial.print("Ooops, no BMP183 detected ... Check your wiring!"); 38 | while(1); 39 | } 40 | } 41 | 42 | /**************************************************************************/ 43 | /* 44 | Arduino loop function, called once 'setup' is complete (your own code 45 | should go here) 46 | */ 47 | /**************************************************************************/ 48 | void loop(void) 49 | { 50 | /* Display atmospheric pressue in Pascals */ 51 | Serial.print("Pressure: "); 52 | Serial.print(bmp.getPressure()); 53 | Serial.print(" Pascals / "); 54 | Serial.print(bmp.getPressure() / 100); 55 | Serial.println(" millibar (hPa)"); 56 | 57 | /* First we get the current temperature from the BMP085 */ 58 | float temperature; 59 | temperature = bmp.getTemperature(); 60 | Serial.print("Temperature: "); 61 | Serial.print(temperature); 62 | Serial.println(" C"); 63 | 64 | /* Calculating altitude with reasonable accuracy requires pressure * 65 | * sea level pressure for your position at the moment the data is * 66 | * converted. If you don't have these values, a 'generic' value of * 67 | * 1013.25 mbar can be used (defined as SENSORS_PRESSURE_SEALEVELHPA * 68 | * in sensors.h), but this isn't ideal and will give variable * 69 | * results from one day to the next. * 70 | * * 71 | * You can usually find the current SLP value by looking at weather * 72 | * websites or from environmental information centers near any major * 73 | * airport. * 74 | * * 75 | * For example, for Paris, France you can check the current mean * 76 | * pressure and sea level at: http://bit.ly/16Au8ol */ 77 | 78 | 79 | /* Then convert the atmospheric pressure, SLP and temp to altitude */ 80 | /* Update this next line with the current SLP for better results */ 81 | float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; // should be ~1000 82 | Serial.print("Sea level pressure: "); 83 | Serial.print(SENSORS_PRESSURE_SEALEVELHPA); 84 | Serial.println(" millibar/hPa"); 85 | 86 | Serial.print("Altitude: "); 87 | Serial.print(bmp.getAltitude(seaLevelPressure)); 88 | Serial.println(" m"); 89 | Serial.println(""); 90 | 91 | delay(1000); 92 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BMP183_Library/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit BMP183 Library 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Non-Unified BMP library 6 | paragraph=Non-Unified BMP library 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_BMP183_Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/README.md: -------------------------------------------------------------------------------- 1 | #Adafruit Unified BNO055 Driver (AHRS/Orientation) # 2 | 3 | This driver is for the Adafruit BNO055 Breakout (http://www.adafruit.com/products/2472), 4 | and is based on Adafruit's Unified Sensor Library (Adafruit_Sensor). 5 | 6 | ## What is the Adafruit Unified Sensor Library? ## 7 | 8 | The Adafruit Unified Sensor Library ([Adafruit_Sensor](https://github.com/adafruit/Adafruit_Sensor)) provides a common interface and data type for any supported sensor. It defines some basic information about the sensor (sensor limits, etc.), and returns standard SI units of a specific type and scale for each supported sensor type. 9 | 10 | It provides a simple abstraction layer between your application and the actual sensor HW, allowing you to drop in any comparable sensor with only one or two lines of code to change in your project (essentially the constructor since the functions to read sensor data and get information about the sensor are defined in the base Adafruit_Sensor class). 11 | 12 | This is imporant useful for two reasons: 13 | 14 | 1.) You can use the data right away because it's already converted to SI units that you understand and can compare, rather than meaningless values like 0..1023. 15 | 16 | 2.) Because SI units are standardised in the sensor library, you can also do quick sanity checks when working with new sensors, or drop in any comparable sensor if you need better sensitivity or if a lower cost unit becomes available, etc. 17 | 18 | Light sensors will always report units in lux, gyroscopes will always report units in rad/s, etc. ... freeing you up to focus on the data, rather than digging through the datasheet to understand what the sensor's raw numbers really mean. 19 | 20 | ## About this Driver ## 21 | 22 | Adafruit invests time and resources providing this open source code. Please support Adafruit and open-source hardware by purchasing products from Adafruit! 23 | 24 | Written by Kevin (KTOWN) Townsend for Adafruit Industries. 25 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/examples/bunny/bunny.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* This driver uses the Adafruit unified sensor library (Adafruit_Sensor), 7 | which provides a common 'type' for sensor data and some helper functions. 8 | 9 | To use this driver you will also need to download the Adafruit_Sensor 10 | library and include it in your libraries folder. 11 | 12 | You should also assign a unique ID to this sensor for use with 13 | the Adafruit Sensor API so that you can identify this particular 14 | sensor in any data logs, etc. To assign a unique ID, simply 15 | provide an appropriate value in the constructor below (12345 16 | is used by default in this example). 17 | 18 | Connections 19 | =========== 20 | Connect SCL to analog 5 21 | Connect SDA to analog 4 22 | Connect VDD to 3.3-5V DC 23 | Connect GROUND to common ground 24 | 25 | History 26 | ======= 27 | 2015/MAR/03 - First release (KTOWN) 28 | */ 29 | 30 | /* Set the delay between fresh samples */ 31 | #define BNO055_SAMPLERATE_DELAY_MS (100) 32 | 33 | Adafruit_BNO055 bno = Adafruit_BNO055(55); 34 | 35 | /**************************************************************************/ 36 | /* 37 | Displays some basic information on this sensor from the unified 38 | sensor API sensor_t type (see Adafruit_Sensor for more information) 39 | */ 40 | /**************************************************************************/ 41 | void displaySensorDetails(void) 42 | { 43 | /* Unified Sensor API */ 44 | sensor_t sensor; 45 | bno.getSensor(&sensor); 46 | Serial.println("------------------------------------"); 47 | Serial.print ("Sensor: "); Serial.println(sensor.name); 48 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 49 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 50 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" xxx"); 51 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" xxx"); 52 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" xxx"); 53 | Serial.println("------------------------------------"); 54 | Serial.println(""); 55 | delay(500); 56 | } 57 | 58 | /**************************************************************************/ 59 | /* 60 | Displays some basic information on the BNO055 HW 61 | */ 62 | /**************************************************************************/ 63 | void displayChipDetails(void) 64 | { 65 | /* Chip Revision */ 66 | Adafruit_BNO055::adafruit_bno055_rev_info_t revInfo; 67 | bno.getRevInfo(&revInfo); 68 | Serial.println("------------------------------------"); 69 | Serial.print ("Accel Rev: 0x"); Serial.println(revInfo.accel_rev, HEX); 70 | Serial.print ("Mag Rev: 0x"); Serial.println(revInfo.mag_rev, HEX); 71 | Serial.print ("Gyro Rev: 0x"); Serial.println(revInfo.gyro_rev, HEX); 72 | Serial.print ("SW Rev: 0x"); Serial.println(revInfo.sw_rev, HEX); 73 | Serial.print ("Boot Rev: 0x"); Serial.println(revInfo.bl_rev, HEX); 74 | Serial.println("------------------------------------"); 75 | Serial.println(""); 76 | } 77 | 78 | /**************************************************************************/ 79 | /* 80 | Arduino setup function (automatically called at startup) 81 | */ 82 | /**************************************************************************/ 83 | void setup(void) 84 | { 85 | Serial.begin(115200); 86 | Serial.println("Orientation Sensor Test"); Serial.println(""); 87 | 88 | /* Initialise the sensor */ 89 | if(!bno.begin()) 90 | { 91 | /* There was a problem detecting the BNO055 ... check your connections */ 92 | Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); 93 | while(1); 94 | } 95 | 96 | delay(1000); 97 | 98 | /* Display the chip revision details */ 99 | displayChipDetails(); 100 | 101 | /* Display some basic information on this sensor */ 102 | displaySensorDetails(); 103 | 104 | /* Calibration info warning */ 105 | /* Move the device in a figure 8 motion to generate mag cal data */ 106 | Serial.println(F("* indicates calibrated data")); 107 | Serial.println(F("! indicates uncalibrated data")); 108 | Serial.println(F("")); 109 | } 110 | 111 | /**************************************************************************/ 112 | /* 113 | Arduino loop function, called once 'setup' is complete (your own code 114 | should go here) 115 | */ 116 | /**************************************************************************/ 117 | void loop(void) 118 | { 119 | /* Board layout: 120 | 121 | +----------+ 122 | |o | o| ______________ Z 123 | VIN |* | | / * /| ^ X 124 | 3Vo |* *| PS0 / / / | / 125 | GND |* *-- *| PS1 / / / |/ 126 | SDA |* --- *| INT -------------- / Y <--+ 127 | SCL |* *| ADR -------------- 128 | RST |* | BNO055 129 | |o o| 130 | +----------+ 131 | 132 | Roll: Rotation around the Y axis (-90° <= roll <= 90°) 133 | Positive values increasing when X moves towards Z 134 | Pitch: Rotation around the X axis (-180° <= pitch <= 180°C) 135 | Positive values increasing when Z moves towards Y 136 | Heading: Rotation around the Z axis (0° <= Heading < 360°) 137 | North = 0°, East = 90°, South = 180°, West = 270° 138 | */ 139 | 140 | /* Get a new sensor event */ 141 | sensors_event_t event; 142 | bno.getEvent(&event); 143 | 144 | /* The processing sketch expects data as roll, pitch, heading */ 145 | Serial.print(F("Orientation: ")); 146 | Serial.print((float)event.orientation.roll); 147 | Serial.print(F(" ")); 148 | Serial.print((float)event.orientation.pitch); 149 | Serial.print(F(" ")); 150 | Serial.print((float)event.orientation.heading); 151 | Serial.print(F(" ")); 152 | 153 | /* Make sure the magnetometer is fully calibrated (bits 4..5 = 11) */ 154 | uint8_t calStatus = bno.getCalStatus(); 155 | if (calStatus && 0x30) 156 | { 157 | /* Data comes from calibrated sensor */ 158 | Serial.println(F("*")); 159 | } 160 | else 161 | { 162 | /* Sensor is not fully calibrated ... move in figure-8 motion */ 163 | Serial.println(F("!")); 164 | } 165 | 166 | delay(BNO055_SAMPLERATE_DELAY_MS); 167 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/examples/bunny/processing/cuberotate/cuberotate.pde: -------------------------------------------------------------------------------- 1 | import processing.serial.*; 2 | import java.awt.datatransfer.*; 3 | import java.awt.Toolkit; 4 | import processing.opengl.*; 5 | import saito.objloader.*; 6 | import g4p_controls.*; 7 | 8 | // Quaternion Values 9 | float w = 0.0F; 10 | float x = 0.0F; 11 | float y = 0.0F; 12 | float z = 0.0F; 13 | 14 | // Euler Values 15 | float roll = 0.0F; 16 | float pitch = 0.0F; 17 | float yaw = 0.0F; 18 | float temp = 0.0F; 19 | float alt = 0.0F; 20 | 21 | /* Adjust these offset to orient the object properly */ 22 | float rollOffset = 0.0F; 23 | float pitchOffset = 0.0F; 24 | float yawOffset = 0.0F; 25 | 26 | OBJModel model; 27 | 28 | // Serial port state. 29 | Serial port; 30 | String buffer = ""; 31 | final String serialConfigFile = "serialconfig.txt"; 32 | boolean printSerial = false; 33 | 34 | // UI controls. 35 | GPanel configPanel; 36 | GDropList serialList; 37 | GLabel serialLabel; 38 | GCheckbox printSerialCheckbox; 39 | 40 | void setup() 41 | { 42 | size(400, 550, OPENGL); 43 | frameRate(30); 44 | model = new OBJModel(this); 45 | model.load("bunny.obj"); 46 | model.scale(20); 47 | 48 | // Serial port setup. 49 | // Grab list of serial ports and choose one that was persisted earlier or default to the first port. 50 | int selectedPort = 0; 51 | String[] availablePorts = Serial.list(); 52 | if (availablePorts == null) { 53 | println("ERROR: No serial ports available!"); 54 | exit(); 55 | } 56 | String[] serialConfig = loadStrings(serialConfigFile); 57 | if (serialConfig != null && serialConfig.length > 0) { 58 | String savedPort = serialConfig[0]; 59 | // Check if saved port is in available ports. 60 | for (int i = 0; i < availablePorts.length; ++i) { 61 | if (availablePorts[i].equals(savedPort)) { 62 | selectedPort = i; 63 | } 64 | } 65 | } 66 | // Build serial config UI. 67 | configPanel = new GPanel(this, 10, 10, width-20, 90, "Configuration (click to hide/show)"); 68 | serialLabel = new GLabel(this, 0, 20, 80, 25, "Serial port:"); 69 | configPanel.addControl(serialLabel); 70 | serialList = new GDropList(this, 90, 20, 200, 200, 6); 71 | serialList.setItems(availablePorts, selectedPort); 72 | configPanel.addControl(serialList); 73 | printSerialCheckbox = new GCheckbox(this, 5, 50, 200, 20, "Print serial data"); 74 | printSerialCheckbox.setSelected(printSerial); 75 | configPanel.addControl(printSerialCheckbox); 76 | // Set serial port. 77 | setSerialPort(serialList.getSelectedText()); 78 | } 79 | 80 | void draw() 81 | { 82 | background(0,0,0); 83 | 84 | // Set a new co-ordinate space 85 | pushMatrix(); 86 | 87 | // Simple 3 point lighting for dramatic effect. 88 | // Slightly red light in upper right, slightly blue light in upper left, and white light from behind. 89 | pointLight(255, 200, 200, 400, 400, 500); 90 | pointLight(200, 200, 255, -400, 400, 500); 91 | pointLight(255, 255, 255, 0, 0, -500); 92 | 93 | // Displace objects from 0,0 94 | translate(200, 300, 0); 95 | 96 | // Rotate shapes around the X/Y/Z axis (values in radians, 0..Pi*2) 97 | rotateY(-radians(roll)); 98 | rotateZ(radians(pitch)); 99 | rotateX(-radians(yaw)); 100 | 101 | pushMatrix(); 102 | noStroke(); 103 | model.draw(); 104 | popMatrix(); 105 | popMatrix(); 106 | //print("draw"); 107 | } 108 | 109 | void serialEvent(Serial p) 110 | { 111 | String incoming = p.readString(); 112 | if (printSerial) { 113 | println(incoming); 114 | } 115 | 116 | if ((incoming.length() > 8)) 117 | { 118 | String[] list = split(incoming, " "); 119 | if ( (list.length > 0) && (list[0].equals("Quaternions:")) ) 120 | { 121 | w = float(list[1]); 122 | x = float(list[2]); 123 | y = float(list[3]); 124 | z = float(list[4]); 125 | // Convert to Euler 126 | double sqw = w*w; 127 | double sqx = x*x; 128 | double sqy = y*y; 129 | double sqz = z*z; 130 | roll = (atan2(2.0*(y*z+x*w),(float)(-sqx-sqy+sqz+sqw))); 131 | pitch = (asin((float)(-2.0*(x*z-y*w)/(sqx+sqy+sqz+sqw)))); 132 | yaw = (atan2(2.0*(x*y+z*w),(float)(sqx-sqy-sqz+sqw))); 133 | buffer = incoming; 134 | } 135 | if ( (list.length > 0) && (list[0].equals("Orientation:")) ) 136 | { 137 | roll = float(list[3]); // Roll = Z 138 | pitch = float(list[2]); // Pitch = Y 139 | yaw = float(list[1]); // Yaw/Heading = X 140 | buffer = incoming; 141 | } 142 | if ( (list.length > 0) && (list[0].equals("Alt:")) ) 143 | { 144 | alt = float(list[1]); 145 | buffer = incoming; 146 | } 147 | if ( (list.length > 0) && (list[0].equals("Temp:")) ) 148 | { 149 | temp = float(list[1]); 150 | buffer = incoming; 151 | } 152 | } 153 | } 154 | 155 | // Set serial port to desired value. 156 | void setSerialPort(String portName) { 157 | // Close the port if it's currently open. 158 | if (port != null) { 159 | port.stop(); 160 | } 161 | try { 162 | // Open port. 163 | port = new Serial(this, portName, 115200); 164 | port.bufferUntil('\n'); 165 | // Persist port in configuration. 166 | saveStrings(serialConfigFile, new String[] { portName }); 167 | } 168 | catch (RuntimeException ex) { 169 | // Swallow error if port can't be opened, keep port closed. 170 | port = null; 171 | } 172 | } 173 | 174 | // UI event handlers 175 | 176 | void handlePanelEvents(GPanel panel, GEvent event) { 177 | // Panel events, do nothing. 178 | } 179 | 180 | void handleDropListEvents(GDropList list, GEvent event) { 181 | // Drop list events, check if new serial port is selected. 182 | if (list == serialList) { 183 | setSerialPort(serialList.getSelectedText()); 184 | } 185 | } 186 | 187 | void handleToggleControlEvents(GToggleControl checkbox, GEvent event) { 188 | // Checkbox toggle events, check if print events is toggled. 189 | if (checkbox == printSerialCheckbox) { 190 | printSerial = printSerialCheckbox.isSelected(); 191 | } 192 | } 193 | 194 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/examples/bunny/processing/cuberotate/data/bunny.mtl: -------------------------------------------------------------------------------- 1 | # 3ds Max Wavefront OBJ Exporter v0.94b - (c)2007 guruware 2 | # File Created: 04.07.2010 10:41:39 3 | 4 | newmtl Body 5 | Ns 32 6 | d 1 7 | Tr 1 8 | Tf 1 1 1 9 | illum 2 10 | Ka 0.0000 0.0000 0.0000 11 | Kd 0.7412 0.4784 0.4765 12 | Ks 0.3500 0.3500 0.6500 13 | 14 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/examples/rawdata/rawdata.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* This driver reads raw data from the BNO055 7 | 8 | Connections 9 | =========== 10 | Connect SCL to analog 5 11 | Connect SDA to analog 4 12 | Connect VDD to 3.3V DC 13 | Connect GROUND to common ground 14 | 15 | History 16 | ======= 17 | 2015/MAR/03 - First release (KTOWN) 18 | */ 19 | 20 | /* Set the delay between fresh samples */ 21 | #define BNO055_SAMPLERATE_DELAY_MS (100) 22 | 23 | Adafruit_BNO055 bno = Adafruit_BNO055(); 24 | 25 | /**************************************************************************/ 26 | /* 27 | Arduino setup function (automatically called at startup) 28 | */ 29 | /**************************************************************************/ 30 | void setup(void) 31 | { 32 | Serial.begin(9600); 33 | Serial.println("Orientation Sensor Raw Data Test"); Serial.println(""); 34 | 35 | /* Initialise the sensor */ 36 | if(!bno.begin()) 37 | { 38 | /* There was a problem detecting the BNO055 ... check your connections */ 39 | Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); 40 | while(1); 41 | } 42 | 43 | delay(1000); 44 | 45 | /* Display the current temperature */ 46 | int8_t temp = bno.getTemp(); 47 | Serial.print("Current Temperature: "); 48 | Serial.print(temp); 49 | Serial.println(" C"); 50 | Serial.println(""); 51 | 52 | bno.setExtCrystalUse(true); 53 | } 54 | 55 | /**************************************************************************/ 56 | /* 57 | Arduino loop function, called once 'setup' is complete (your own code 58 | should go here) 59 | */ 60 | /**************************************************************************/ 61 | void loop(void) 62 | { 63 | /* Board layout: 64 | 65 | +----------+ 66 | |o | o| ______________ Z 67 | VIN |* | | / * /| ^ X 68 | 3Vo |* *| PS0 / / / | / 69 | GND |* *-- *| PS1 / / / |/ 70 | SDA |* --- *| INT -------------- / Y <--+ 71 | SCL |* *| ADR -------------- 72 | RST |* | BNO055 73 | |o o| 74 | +----------+ 75 | */ 76 | 77 | // Possible vector values can be: 78 | // - VECTOR_ACCELEROMETER - m/s^2 79 | // - VECTOR_MAGNETOMETER - uT 80 | // - VECTOR_GYROSCOPE - rad/s 81 | // - VECTOR_EULER - degrees 82 | // - VECTOR_LINEARACCEL - m/s^2 83 | // - VECTOR_GRAVITY - m/s^2 84 | imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER); 85 | 86 | /* Display the floating point data */ 87 | Serial.print("X: "); 88 | Serial.print(euler.x()); 89 | Serial.print(" Y: "); 90 | Serial.print(euler.y()); 91 | Serial.print(" Z: "); 92 | Serial.print(euler.z()); 93 | Serial.println(""); 94 | 95 | /* 96 | // Quaternion data 97 | imu::Quaternion quat = bno.getQuat(); 98 | Serial.print("qW: "); 99 | Serial.print(quat.w(), 4); 100 | Serial.print(" qX: "); 101 | Serial.print(quat.y(), 4); 102 | Serial.print(" qY: "); 103 | Serial.print(quat.x(), 4); 104 | Serial.print(" qZ: "); 105 | Serial.print(quat.z(), 4); 106 | Serial.println(""); 107 | */ 108 | 109 | delay(BNO055_SAMPLERATE_DELAY_MS); 110 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/examples/sensorapi/sensorapi.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* This driver uses the Adafruit unified sensor library (Adafruit_Sensor), 7 | which provides a common 'type' for sensor data and some helper functions. 8 | 9 | To use this driver you will also need to download the Adafruit_Sensor 10 | library and include it in your libraries folder. 11 | 12 | You should also assign a unique ID to this sensor for use with 13 | the Adafruit Sensor API so that you can identify this particular 14 | sensor in any data logs, etc. To assign a unique ID, simply 15 | provide an appropriate value in the constructor below (12345 16 | is used by default in this example). 17 | 18 | Connections 19 | =========== 20 | Connect SCL to analog 5 21 | Connect SDA to analog 4 22 | Connect VDD to 3-5V DC 23 | Connect GROUND to common ground 24 | 25 | History 26 | ======= 27 | 2015/MAR/03 - First release (KTOWN) 28 | */ 29 | 30 | /* Set the delay between fresh samples */ 31 | #define BNO055_SAMPLERATE_DELAY_MS (100) 32 | 33 | Adafruit_BNO055 bno = Adafruit_BNO055(55); 34 | 35 | /**************************************************************************/ 36 | /* 37 | Displays some basic information on this sensor from the unified 38 | sensor API sensor_t type (see Adafruit_Sensor for more information) 39 | */ 40 | /**************************************************************************/ 41 | void displaySensorDetails(void) 42 | { 43 | sensor_t sensor; 44 | bno.getSensor(&sensor); 45 | Serial.println("------------------------------------"); 46 | Serial.print ("Sensor: "); Serial.println(sensor.name); 47 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 48 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 49 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" xxx"); 50 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" xxx"); 51 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" xxx"); 52 | Serial.println("------------------------------------"); 53 | Serial.println(""); 54 | delay(500); 55 | } 56 | 57 | /**************************************************************************/ 58 | /* 59 | Displays some basic information on the BNO055 HW 60 | */ 61 | /**************************************************************************/ 62 | void displayChipDetails(void) 63 | { 64 | /* Chip Revision */ 65 | Adafruit_BNO055::adafruit_bno055_rev_info_t revInfo; 66 | bno.getRevInfo(&revInfo); 67 | Serial.println("------------------------------------"); 68 | Serial.print ("Accel Rev: 0x"); Serial.println(revInfo.accel_rev, HEX); 69 | Serial.print ("Mag Rev: 0x"); Serial.println(revInfo.mag_rev, HEX); 70 | Serial.print ("Gyro Rev: 0x"); Serial.println(revInfo.gyro_rev, HEX); 71 | Serial.print ("SW Rev: 0x"); Serial.println(revInfo.sw_rev, HEX); 72 | Serial.print ("Boot Rev: 0x"); Serial.println(revInfo.bl_rev, HEX); 73 | Serial.println("------------------------------------"); 74 | Serial.println(""); 75 | } 76 | 77 | /**************************************************************************/ 78 | /* 79 | Arduino setup function (automatically called at startup) 80 | */ 81 | /**************************************************************************/ 82 | void setup(void) 83 | { 84 | Serial.begin(9600); 85 | Serial.println("Orientation Sensor Test"); Serial.println(""); 86 | 87 | /* Initialise the sensor */ 88 | if(!bno.begin()) 89 | { 90 | /* There was a problem detecting the BNO055 ... check your connections */ 91 | Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); 92 | while(1); 93 | } 94 | 95 | delay(1000); 96 | 97 | /* Display some basic information on this sensor */ 98 | displaySensorDetails(); 99 | 100 | /* Display some basic information on this sensor */ 101 | displayChipDetails(); 102 | 103 | /* Calibration info warning */ 104 | /* Move the device in a figure 8 motion to generate mag cal data */ 105 | Serial.println(F("* indicates calibrated data")); 106 | Serial.println(F("! indicates uncalibrated data")); 107 | Serial.println(F("")); 108 | 109 | bno.setExtCrystalUse(true); 110 | } 111 | 112 | /**************************************************************************/ 113 | /* 114 | Arduino loop function, called once 'setup' is complete (your own code 115 | should go here) 116 | */ 117 | /**************************************************************************/ 118 | void loop(void) 119 | { 120 | /* Get a new sensor event */ 121 | sensors_event_t event; 122 | bno.getEvent(&event); 123 | 124 | /* Board layout: 125 | +----------+ 126 | |o | o| ______________ Z 127 | VIN |* | | / * /| ^ X 128 | 3Vo |* *| PS0 / / / | / 129 | GND |* *-- *| PS1 / / / |/ 130 | SDA |* --- *| INT -------------- / Y <--+ 131 | SCL |* *| ADR -------------- 132 | RST |* | BNO055 133 | |o o| 134 | +----------+ 135 | 136 | Roll: Rotation around the Y axis (-90° <= roll <= 90°) 137 | Positive values increasing when X moves towards Z 138 | Pitch: Rotation around the X axis (-180° <= pitch <= 180°C) 139 | Positive values increasing when Z moves towards Y 140 | Heading: Rotation around the Z axis (0° <= Heading < 360°) 141 | North = 0°, East = 90°, South = 180°, West = 270° 142 | */ 143 | 144 | /* Display the floating point data */ 145 | Serial.print("Roll: "); 146 | Serial.print(event.orientation.roll); 147 | Serial.print("\tPitch: "); 148 | Serial.print(event.orientation.pitch); 149 | Serial.print("\tHeading: "); 150 | Serial.print(event.orientation.heading); 151 | Serial.print(""); 152 | 153 | /* Make sure the magnetometer is fully calibrated (bits 4..5 = 11) */ 154 | uint8_t calStatus = bno.getCalStatus(); 155 | if (calStatus && 0x30) 156 | { 157 | /* Data comes from calibrated sensor */ 158 | Serial.println(F("\t*")); 159 | } 160 | else 161 | { 162 | /* Sensor is not fully calibrated ... move in figure-8 motion */ 163 | Serial.println(F("\t!")); 164 | } 165 | 166 | delay(BNO055_SAMPLERATE_DELAY_MS); 167 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit BNO055 2 | version=1.0.3 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Library for the Adafruit BNO055 Absolute Orientation Sensor. 6 | paragraph=Designed specifically to work with the Adafruit BNO055 Breakout, and is based on Adafruit's Unified Sensor Library. 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_BNO055 9 | architectures=* 10 | 11 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/utility/imumaths.h: -------------------------------------------------------------------------------- 1 | /* 2 | Inertial Measurement Unit Maths Library 3 | Copyright (C) 2013-2014 Samuel Cowen 4 | www.camelsoftware.com 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #ifndef IMUMATH_H 21 | #define IMUMATH_H 22 | 23 | 24 | #include "vector.h" 25 | #include "matrix.h" 26 | #include "quaternion.h" 27 | 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/utility/matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | Inertial Measurement Unit Maths Library 3 | Copyright (C) 2013-2014 Samuel Cowen 4 | www.camelsoftware.com 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #ifndef IMUMATH_MATRIX_HPP 21 | #define IMUMATH_MATRIX_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace imu 29 | { 30 | 31 | 32 | template class Matrix 33 | { 34 | public: 35 | Matrix() 36 | { 37 | int r = sizeof(double)*N; 38 | _cell = &_cell_data[0]; 39 | memset(_cell, 0, r*r); 40 | } 41 | 42 | Matrix(const Matrix &v) 43 | { 44 | int r = sizeof(double)*N; 45 | _cell = &_cell_data[0]; 46 | memset(_cell, 0, r*r); 47 | for (int x = 0; x < N; x++ ) 48 | { 49 | for(int y = 0; y < N; y++) 50 | { 51 | _cell[x*N+y] = v._cell[x*N+y]; 52 | } 53 | } 54 | } 55 | 56 | ~Matrix() 57 | { 58 | } 59 | 60 | void operator = (Matrix m) 61 | { 62 | for(int x = 0; x < N; x++) 63 | { 64 | for(int y = 0; y < N; y++) 65 | { 66 | cell(x, y) = m.cell(x, y); 67 | } 68 | } 69 | } 70 | 71 | Vector row_to_vector(int y) 72 | { 73 | Vector ret; 74 | for(int i = 0; i < N; i++) 75 | { 76 | ret[i] = _cell[y*N+i]; 77 | } 78 | return ret; 79 | } 80 | 81 | Vector col_to_vector(int x) 82 | { 83 | Vector ret; 84 | for(int i = 0; i < N; i++) 85 | { 86 | ret[i] = _cell[i*N+x]; 87 | } 88 | return ret; 89 | } 90 | 91 | void vector_to_row(Vector v, int row) 92 | { 93 | for(int i = 0; i < N; i++) 94 | { 95 | cell(row, i) = v(i); 96 | } 97 | } 98 | 99 | void vector_to_col(Vector v, int col) 100 | { 101 | for(int i = 0; i < N; i++) 102 | { 103 | cell(i, col) = v(i); 104 | } 105 | } 106 | 107 | double& operator ()(int x, int y) 108 | { 109 | return _cell[x*N+y]; 110 | } 111 | 112 | double& cell(int x, int y) 113 | { 114 | return _cell[x*N+y]; 115 | } 116 | 117 | 118 | Matrix operator + (Matrix m) 119 | { 120 | Matrix ret; 121 | for(int x = 0; x < N; x++) 122 | { 123 | for(int y = 0; y < N; y++) 124 | { 125 | ret._cell[x*N+y] = _cell[x*N+y] + m._cell[x*N+y]; 126 | } 127 | } 128 | return ret; 129 | } 130 | 131 | Matrix operator - (Matrix m) 132 | { 133 | Matrix ret; 134 | for(int x = 0; x < N; x++) 135 | { 136 | for(int y = 0; y < N; y++) 137 | { 138 | ret._cell[x*N+y] = _cell[x*N+y] - m._cell[x*N+y]; 139 | } 140 | } 141 | return ret; 142 | } 143 | 144 | Matrix operator * (double scalar) 145 | { 146 | Matrix ret; 147 | for(int x = 0; x < N; x++) 148 | { 149 | for(int y = 0; y < N; y++) 150 | { 151 | ret._cell[x*N+y] = _cell[x*N+y] * scalar; 152 | } 153 | } 154 | return ret; 155 | } 156 | 157 | Matrix operator * (Matrix m) 158 | { 159 | Matrix ret; 160 | for(int x = 0; x < N; x++) 161 | { 162 | for(int y = 0; y < N; y++) 163 | { 164 | Vector row = row_to_vector(x); 165 | Vector col = m.col_to_vector(y); 166 | ret.cell(x, y) = row.dot(col); 167 | } 168 | } 169 | return ret; 170 | } 171 | 172 | Matrix transpose() 173 | { 174 | Matrix ret; 175 | for(int x = 0; x < N; x++) 176 | { 177 | for(int y = 0; y < N; y++) 178 | { 179 | ret.cell(y, x) = cell(x, y); 180 | } 181 | } 182 | return ret; 183 | } 184 | 185 | Matrix minor_matrix(int row, int col) 186 | { 187 | int colCount = 0, rowCount = 0; 188 | Matrix ret; 189 | for(int i = 0; i < N; i++ ) 190 | { 191 | if( i != row ) 192 | { 193 | for(int j = 0; j < N; j++ ) 194 | { 195 | if( j != col ) 196 | { 197 | ret(rowCount, colCount) = cell(i, j); 198 | colCount++; 199 | } 200 | } 201 | rowCount++; 202 | } 203 | } 204 | return ret; 205 | } 206 | 207 | double determinant() 208 | { 209 | if(N == 1) 210 | return cell(0, 0); 211 | 212 | float det = 0.0; 213 | for(int i = 0; i < N; i++ ) 214 | { 215 | Matrix minor = minor_matrix(0, i); 216 | det += (i%2==1?-1.0:1.0) * cell(0, i) * minor.determinant(); 217 | } 218 | return det; 219 | } 220 | 221 | Matrix invert() 222 | { 223 | Matrix ret; 224 | float det = determinant(); 225 | 226 | for(int x = 0; x < N; x++) 227 | { 228 | for(int y = 0; y < N; y++) 229 | { 230 | Matrix minor = minor_matrix(y, x); 231 | ret(x, y) = det*minor.determinant(); 232 | if( (x+y)%2 == 1) 233 | ret(x, y) = -ret(x, y); 234 | } 235 | } 236 | return ret; 237 | } 238 | 239 | private: 240 | double* _cell; 241 | double _cell_data[N*N]; 242 | }; 243 | 244 | 245 | }; 246 | 247 | #endif 248 | 249 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/utility/quaternion.h: -------------------------------------------------------------------------------- 1 | /* 2 | Inertial Measurement Unit Maths Library 3 | Copyright (C) 2013-2014 Samuel Cowen 4 | www.camelsoftware.com 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | 21 | #ifndef IMUMATH_QUATERNION_HPP 22 | #define IMUMATH_QUATERNION_HPP 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "vector.h" 30 | 31 | 32 | namespace imu 33 | { 34 | 35 | 36 | 37 | class Quaternion 38 | { 39 | public: 40 | Quaternion() 41 | { 42 | _w = 1.0; 43 | _x = _y = _z = 0.0; 44 | } 45 | 46 | Quaternion(double iw, double ix, double iy, double iz) 47 | { 48 | _w = iw; 49 | _x = ix; 50 | _y = iy; 51 | _z = iz; 52 | } 53 | 54 | Quaternion(double w, Vector<3> vec) 55 | { 56 | _w = w; 57 | _x = vec.x(); 58 | _y = vec.y(); 59 | _z = vec.z(); 60 | } 61 | 62 | double& w() 63 | { 64 | return _w; 65 | } 66 | double& x() 67 | { 68 | return _x; 69 | } 70 | double& y() 71 | { 72 | return _y; 73 | } 74 | double& z() 75 | { 76 | return _z; 77 | } 78 | 79 | double magnitude() 80 | { 81 | double res = (_w*_w) + (_x*_x) + (_y*_y) + (_z*_z); 82 | return sqrt(res); 83 | } 84 | 85 | void normalize() 86 | { 87 | double mag = magnitude(); 88 | *this = this->scale(1/mag); 89 | } 90 | 91 | 92 | Quaternion conjugate() 93 | { 94 | Quaternion q; 95 | q.w() = _w; 96 | q.x() = -_x; 97 | q.y() = -_y; 98 | q.z() = -_z; 99 | return q; 100 | } 101 | 102 | void fromAxisAngle(Vector<3> axis, double theta) 103 | { 104 | _w = cos(theta/2); 105 | //only need to calculate sine of half theta once 106 | double sht = sin(theta/2); 107 | _x = axis.x() * sht; 108 | _y = axis.y() * sht; 109 | _z = axis.z() * sht; 110 | } 111 | 112 | void fromMatrix(Matrix<3> m) 113 | { 114 | float tr = m(0, 0) + m(1, 1) + m(2, 2); 115 | 116 | float S = 0.0; 117 | if (tr > 0) 118 | { 119 | S = sqrt(tr+1.0) * 2; 120 | _w = 0.25 * S; 121 | _x = (m(2, 1) - m(1, 2)) / S; 122 | _y = (m(0, 2) - m(2, 0)) / S; 123 | _z = (m(1, 0) - m(0, 1)) / S; 124 | } 125 | else if ((m(0, 0) < m(1, 1))&(m(0, 0) < m(2, 2))) 126 | { 127 | S = sqrt(1.0 + m(0, 0) - m(1, 1) - m(2, 2)) * 2; 128 | _w = (m(2, 1) - m(1, 2)) / S; 129 | _x = 0.25 * S; 130 | _y = (m(0, 1) + m(1, 0)) / S; 131 | _z = (m(0, 2) + m(2, 0)) / S; 132 | } 133 | else if (m(1, 1) < m(2, 2)) 134 | { 135 | S = sqrt(1.0 + m(1, 1) - m(0, 0) - m(2, 2)) * 2; 136 | _w = (m(0, 2) - m(2, 0)) / S; 137 | _x = (m(0, 1) + m(1, 0)) / S; 138 | _y = 0.25 * S; 139 | _z = (m(1, 2) + m(2, 1)) / S; 140 | } 141 | else 142 | { 143 | S = sqrt(1.0 + m(2, 2) - m(0, 0) - m(1, 1)) * 2; 144 | _w = (m(1, 0) - m(0, 1)) / S; 145 | _x = (m(0, 2) + m(2, 0)) / S; 146 | _y = (m(1, 2) + m(2, 1)) / S; 147 | _z = 0.25 * S; 148 | } 149 | } 150 | 151 | void toAxisAngle(Vector<3>& axis, float& angle) 152 | { 153 | float sqw = sqrt(1-_w*_w); 154 | if(sqw == 0) //it's a singularity and divide by zero, avoid 155 | return; 156 | 157 | angle = 2 * acos(_w); 158 | axis.x() = _x / sqw; 159 | axis.y() = _y / sqw; 160 | axis.z() = _z / sqw; 161 | } 162 | 163 | Matrix<3> toMatrix() 164 | { 165 | Matrix<3> ret; 166 | ret.cell(0, 0) = 1-(2*(_y*_y))-(2*(_z*_z)); 167 | ret.cell(0, 1) = (2*_x*_y)-(2*_w*_z); 168 | ret.cell(0, 2) = (2*_x*_z)+(2*_w*_y); 169 | 170 | ret.cell(1, 0) = (2*_x*_y)+(2*_w*_z); 171 | ret.cell(1, 1) = 1-(2*(_x*_x))-(2*(_z*_z)); 172 | ret.cell(1, 2) = (2*(_y*_z))-(2*(_w*_x)); 173 | 174 | ret.cell(2, 0) = (2*(_x*_z))-(2*_w*_y); 175 | ret.cell(2, 1) = (2*_y*_z)+(2*_w*_x); 176 | ret.cell(2, 2) = 1-(2*(_x*_x))-(2*(_y*_y)); 177 | return ret; 178 | } 179 | 180 | 181 | Vector<3> toEuler() 182 | { 183 | Vector<3> ret; 184 | double sqw = _w*_w; 185 | double sqx = _x*_x; 186 | double sqy = _y*_y; 187 | double sqz = _z*_z; 188 | 189 | ret.x() = atan2(2.0*(_x*_y+_z*_w),(sqx-sqy-sqz+sqw)); 190 | ret.y() = asin(-2.0*(_x*_z-_y*_w)/(sqx+sqy+sqz+sqw)); 191 | ret.z() = atan2(2.0*(_y*_z+_x*_w),(-sqx-sqy+sqz+sqw)); 192 | 193 | return ret; 194 | } 195 | 196 | Vector<3> toAngularVelocity(float dt) 197 | { 198 | Vector<3> ret; 199 | Quaternion one(1.0, 0.0, 0.0, 0.0); 200 | Quaternion delta = one - *this; 201 | Quaternion r = (delta/dt); 202 | r = r * 2; 203 | r = r * one; 204 | 205 | ret.x() = r.x(); 206 | ret.y() = r.y(); 207 | ret.z() = r.z(); 208 | return ret; 209 | } 210 | 211 | Vector<3> rotateVector(Vector<2> v) 212 | { 213 | Vector<3> ret(v.x(), v.y(), 0.0); 214 | return rotateVector(ret); 215 | } 216 | 217 | Vector<3> rotateVector(Vector<3> v) 218 | { 219 | Vector<3> qv(this->x(), this->y(), this->z()); 220 | Vector<3> t; 221 | t = qv.cross(v) * 2.0; 222 | return v + (t * _w) + qv.cross(t); 223 | } 224 | 225 | 226 | Quaternion operator * (Quaternion q) 227 | { 228 | Quaternion ret; 229 | ret._w = ((_w*q._w) - (_x*q._x) - (_y*q._y) - (_z*q._z)); 230 | ret._x = ((_w*q._x) + (_x*q._w) + (_y*q._z) - (_z*q._y)); 231 | ret._y = ((_w*q._y) - (_x*q._z) + (_y*q._w) + (_z*q._x)); 232 | ret._z = ((_w*q._z) + (_x*q._y) - (_y*q._x) + (_z*q._w)); 233 | return ret; 234 | } 235 | 236 | Quaternion operator + (Quaternion q) 237 | { 238 | Quaternion ret; 239 | ret._w = _w + q._w; 240 | ret._x = _x + q._x; 241 | ret._y = _y + q._y; 242 | ret._z = _z + q._z; 243 | return ret; 244 | } 245 | 246 | Quaternion operator - (Quaternion q) 247 | { 248 | Quaternion ret; 249 | ret._w = _w - q._w; 250 | ret._x = _x - q._x; 251 | ret._y = _y - q._y; 252 | ret._z = _z - q._z; 253 | return ret; 254 | } 255 | 256 | Quaternion operator / (float scalar) 257 | { 258 | Quaternion ret; 259 | ret._w = this->_w/scalar; 260 | ret._x = this->_x/scalar; 261 | ret._y = this->_y/scalar; 262 | ret._z = this->_z/scalar; 263 | return ret; 264 | } 265 | 266 | Quaternion operator * (float scalar) 267 | { 268 | Quaternion ret; 269 | ret._w = this->_w*scalar; 270 | ret._x = this->_x*scalar; 271 | ret._y = this->_y*scalar; 272 | ret._z = this->_z*scalar; 273 | return ret; 274 | } 275 | 276 | Quaternion scale(double scalar) 277 | { 278 | Quaternion ret; 279 | ret._w = this->_w*scalar; 280 | ret._x = this->_x*scalar; 281 | ret._y = this->_y*scalar; 282 | ret._z = this->_z*scalar; 283 | return ret; 284 | } 285 | 286 | private: 287 | double _w, _x, _y, _z; 288 | }; 289 | 290 | 291 | }; 292 | 293 | #endif 294 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_BNO055/utility/vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | Inertial Measurement Unit Maths Library 3 | Copyright (C) 2013-2014 Samuel Cowen 4 | www.camelsoftware.com 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #ifndef IMUMATH_VECTOR_HPP 21 | #define IMUMATH_VECTOR_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | namespace imu 30 | { 31 | 32 | template class Vector 33 | { 34 | public: 35 | Vector() 36 | { 37 | p_vec = &p_vec_data[0]; 38 | memset(p_vec, 0, sizeof(double)*N); 39 | } 40 | 41 | Vector(double a) 42 | { 43 | p_vec = &p_vec_data[0]; 44 | memset(p_vec, 0, sizeof(double)*N); 45 | p_vec[0] = a; 46 | } 47 | 48 | Vector(double a, double b) 49 | { 50 | p_vec = &p_vec_data[0]; 51 | memset(p_vec, 0, sizeof(double)*N); 52 | p_vec[0] = a; 53 | p_vec[1] = b; 54 | } 55 | 56 | Vector(double a, double b, double c) 57 | { 58 | p_vec = &p_vec_data[0]; 59 | memset(p_vec, 0, sizeof(double)*N); 60 | p_vec[0] = a; 61 | p_vec[1] = b; 62 | p_vec[2] = c; 63 | } 64 | 65 | Vector(double a, double b, double c, double d) 66 | { 67 | p_vec = &p_vec_data[0]; 68 | memset(p_vec, 0, sizeof(double)*N); 69 | p_vec[0] = a; 70 | p_vec[1] = b; 71 | p_vec[2] = c; 72 | p_vec[3] = d; 73 | } 74 | 75 | Vector(const Vector &v) 76 | { 77 | p_vec = &p_vec_data[0]; 78 | memset(p_vec, 0, sizeof(double)*N); 79 | for (int x = 0; x < N; x++ ) 80 | p_vec[x] = v.p_vec[x]; 81 | } 82 | 83 | ~Vector() 84 | { 85 | } 86 | 87 | uint8_t n() { return N; } 88 | 89 | double magnitude() 90 | { 91 | double res = 0; 92 | int i; 93 | for(i = 0; i < N; i++) 94 | res += (p_vec[i] * p_vec[i]); 95 | 96 | if(isnan(res)) 97 | return 0; 98 | if((fabs(res)-1) >= 0.000001) //avoid a sqrt if possible 99 | return sqrt(res); 100 | return 1; 101 | } 102 | 103 | void normalize() 104 | { 105 | double mag = magnitude(); 106 | if(abs(mag) <= 0.0001) 107 | return; 108 | 109 | int i; 110 | for(i = 0; i < N; i++) 111 | p_vec[i] = p_vec[i]/mag; 112 | } 113 | 114 | double dot(Vector v) 115 | { 116 | double ret = 0; 117 | int i; 118 | for(i = 0; i < N; i++) 119 | ret += p_vec[i] * v.p_vec[i]; 120 | 121 | return ret; 122 | } 123 | 124 | Vector cross(Vector v) 125 | { 126 | Vector ret; 127 | 128 | //the cross product is only valid for vectors with 3 dimensions, 129 | //with the exception of higher dimensional stuff that is beyond the intended scope of this library 130 | if(N != 3) 131 | return ret; 132 | 133 | ret.p_vec[0] = (p_vec[1] * v.p_vec[2]) - (p_vec[2] * v.p_vec[1]); 134 | ret.p_vec[1] = (p_vec[2] * v.p_vec[0]) - (p_vec[0] * v.p_vec[2]); 135 | ret.p_vec[2] = (p_vec[0] * v.p_vec[1]) - (p_vec[1] * v.p_vec[0]); 136 | return ret; 137 | } 138 | 139 | Vector scale(double scalar) 140 | { 141 | Vector ret; 142 | for(int i = 0; i < N; i++) 143 | ret.p_vec[i] = p_vec[i] * scalar; 144 | return ret; 145 | } 146 | 147 | Vector invert() 148 | { 149 | Vector ret; 150 | for(int i = 0; i < N; i++) 151 | ret.p_vec[i] = -p_vec[i]; 152 | return ret; 153 | } 154 | 155 | Vector operator = (Vector v) 156 | { 157 | for (int x = 0; x < N; x++ ) 158 | p_vec[x] = v.p_vec[x]; 159 | return *this; 160 | } 161 | 162 | double& operator [](int n) 163 | { 164 | return p_vec[n]; 165 | } 166 | 167 | double& operator ()(int n) 168 | { 169 | return p_vec[n]; 170 | } 171 | 172 | Vector operator + (Vector v) 173 | { 174 | Vector ret; 175 | for(int i = 0; i < N; i++) 176 | ret.p_vec[i] = p_vec[i] + v.p_vec[i]; 177 | return ret; 178 | } 179 | 180 | Vector operator - (Vector v) 181 | { 182 | Vector ret; 183 | for(int i = 0; i < N; i++) 184 | ret.p_vec[i] = p_vec[i] - v.p_vec[i]; 185 | return ret; 186 | } 187 | 188 | Vector operator * (double scalar) 189 | { 190 | return scale(scalar); 191 | } 192 | 193 | Vector operator / (double scalar) 194 | { 195 | Vector ret; 196 | for(int i = 0; i < N; i++) 197 | ret.p_vec[i] = p_vec[i] / scalar; 198 | return ret; 199 | } 200 | 201 | void toDegrees() 202 | { 203 | for(int i = 0; i < N; i++) 204 | p_vec[i] *= 57.2957795131; //180/pi 205 | } 206 | 207 | void toRadians() 208 | { 209 | for(int i = 0; i < N; i++) 210 | p_vec[i] *= 0.01745329251; //pi/180 211 | } 212 | 213 | double& x() { return p_vec[0]; } 214 | double& y() { return p_vec[1]; } 215 | double& z() { return p_vec[2]; } 216 | 217 | 218 | private: 219 | double* p_vec; 220 | double p_vec_data[N]; 221 | }; 222 | 223 | 224 | }; 225 | 226 | #endif 227 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_L3GD20_U/Adafruit_L3GD20_U.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the L3GD20 GYROSCOPE 3 | 4 | Designed specifically to work with the Adafruit L3GD20 Breakout 5 | ----> https://www.adafruit.com/products/1032 6 | 7 | These sensors use I2C or SPI to communicate, 2 pins (I2C) 8 | or 4 pins (SPI) are required to interface. 9 | 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Kevin "KTOWN" Townsend for Adafruit Industries. 15 | BSD license, all text above must be included in any redistribution 16 | ****************************************************/ 17 | #ifndef __L3GD20_H__ 18 | #define __L3GD20_H__ 19 | 20 | #if (ARDUINO >= 100) 21 | #include "Arduino.h" 22 | #else 23 | #include "WProgram.h" 24 | #endif 25 | 26 | #include 27 | #include 28 | 29 | /*========================================================================= 30 | I2C ADDRESS/BITS AND SETTINGS 31 | -----------------------------------------------------------------------*/ 32 | #define L3GD20_ADDRESS (0x6B) // 1101011 33 | #define L3GD20_POLL_TIMEOUT (100) // Maximum number of read attempts 34 | #define L3GD20_ID 0xD4 35 | #define L3GD20H_ID 0xD7 36 | #define GYRO_SENSITIVITY_250DPS (0.00875F) // Roughly 22/256 for fixed point match 37 | #define GYRO_SENSITIVITY_500DPS (0.0175F) // Roughly 45/256 38 | #define GYRO_SENSITIVITY_2000DPS (0.070F) // Roughly 18/256 39 | /*=========================================================================*/ 40 | 41 | /*========================================================================= 42 | REGISTERS 43 | -----------------------------------------------------------------------*/ 44 | typedef enum 45 | { // DEFAULT TYPE 46 | GYRO_REGISTER_WHO_AM_I = 0x0F, // 11010100 r 47 | GYRO_REGISTER_CTRL_REG1 = 0x20, // 00000111 rw 48 | GYRO_REGISTER_CTRL_REG2 = 0x21, // 00000000 rw 49 | GYRO_REGISTER_CTRL_REG3 = 0x22, // 00000000 rw 50 | GYRO_REGISTER_CTRL_REG4 = 0x23, // 00000000 rw 51 | GYRO_REGISTER_CTRL_REG5 = 0x24, // 00000000 rw 52 | GYRO_REGISTER_REFERENCE = 0x25, // 00000000 rw 53 | GYRO_REGISTER_OUT_TEMP = 0x26, // r 54 | GYRO_REGISTER_STATUS_REG = 0x27, // r 55 | GYRO_REGISTER_OUT_X_L = 0x28, // r 56 | GYRO_REGISTER_OUT_X_H = 0x29, // r 57 | GYRO_REGISTER_OUT_Y_L = 0x2A, // r 58 | GYRO_REGISTER_OUT_Y_H = 0x2B, // r 59 | GYRO_REGISTER_OUT_Z_L = 0x2C, // r 60 | GYRO_REGISTER_OUT_Z_H = 0x2D, // r 61 | GYRO_REGISTER_FIFO_CTRL_REG = 0x2E, // 00000000 rw 62 | GYRO_REGISTER_FIFO_SRC_REG = 0x2F, // r 63 | GYRO_REGISTER_INT1_CFG = 0x30, // 00000000 rw 64 | GYRO_REGISTER_INT1_SRC = 0x31, // r 65 | GYRO_REGISTER_TSH_XH = 0x32, // 00000000 rw 66 | GYRO_REGISTER_TSH_XL = 0x33, // 00000000 rw 67 | GYRO_REGISTER_TSH_YH = 0x34, // 00000000 rw 68 | GYRO_REGISTER_TSH_YL = 0x35, // 00000000 rw 69 | GYRO_REGISTER_TSH_ZH = 0x36, // 00000000 rw 70 | GYRO_REGISTER_TSH_ZL = 0x37, // 00000000 rw 71 | GYRO_REGISTER_INT1_DURATION = 0x38 // 00000000 rw 72 | } gyroRegisters_t; 73 | /*=========================================================================*/ 74 | 75 | /*========================================================================= 76 | OPTIONAL SPEED SETTINGS 77 | -----------------------------------------------------------------------*/ 78 | typedef enum 79 | { 80 | GYRO_RANGE_250DPS = 250, 81 | GYRO_RANGE_500DPS = 500, 82 | GYRO_RANGE_2000DPS = 2000 83 | } gyroRange_t; 84 | /*=========================================================================*/ 85 | 86 | class Adafruit_L3GD20_Unified : public Adafruit_Sensor 87 | { 88 | public: 89 | Adafruit_L3GD20_Unified(int32_t sensorID = -1); 90 | 91 | bool begin ( gyroRange_t rng = GYRO_RANGE_250DPS ); 92 | void enableAutoRange ( bool enabled ); 93 | bool getEvent ( sensors_event_t* ); 94 | void getSensor ( sensor_t* ); 95 | 96 | private: 97 | void write8 ( byte reg, byte value ); 98 | byte read8 ( byte reg ); 99 | gyroRange_t _range; 100 | int32_t _sensorID; 101 | bool _autoRangeEnabled; 102 | }; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_L3GD20_U/README.md: -------------------------------------------------------------------------------- 1 | ## Adafruit Unified L3GD20 Driver ## 2 | 3 | This unified sensor driver is for use with the Adafruit Triple-Axis Gyro sensor and the Adafruit 10DOF Breakout, and has been designed specifically for these boards: 4 | 5 | ----> https://www.adafruit.com/products/1032 6 | ----> http://www.adafruit.com/products/1604 7 | 8 | Check out the links above for our tutorials and wiring diagrams 9 | 10 | The updated 'Unified' sensor driver (based on Adafruit's Sensor API) use I2C to communicate. If you need to use SPI on the L3GD20, please look at the original (non unified) driver that is still available here: https://github.com/adafruit/Adafruit_L3GD20 11 | 12 | Adafruit invests time and resources providing this open source code, 13 | please support Adafruit and open-source hardware by purchasing 14 | products from Adafruit! 15 | 16 | ## What is the Adafruit Unified Sensor Library? ## 17 | 18 | The Adafruit Unified Sensor Library ([Adafruit_Sensor](https://github.com/adafruit/Adafruit_Sensor)) provides a common interface and data type for any supported sensor. It defines some basic information about the sensor (sensor limits, etc.), and returns standard SI units of a specific type and scale for each supported sensor type. 19 | 20 | It provides a simple abstraction layer between your application and the actual sensor HW, allowing you to drop in any comparable sensor with only one or two lines of code to change in your project (essentially the constructor since the functions to read sensor data and get information about the sensor are defined in the base Adafruit_Sensor class). 21 | 22 | This is imporant useful for two reasons: 23 | 24 | 1.) You can use the data right away because it's already converted to SI units that you understand and can compare, rather than meaningless values like 0..1023. 25 | 26 | 2.) Because SI units are standardised in the sensor library, you can also do quick sanity checks when working with new sensors, or drop in any comparable sensor if you need better sensitivity or if a lower cost unit becomes available, etc. 27 | 28 | Light sensors will always report units in lux, gyroscopes will always report units in rad/s, etc. ... freeing you up to focus on the data, rather than digging through the datasheet to understand what the sensor's raw numbers really mean. 29 | 30 | ## About this Driver ## 31 | 32 | Written by Kevin Townsend for Adafruit Industries. 33 | BSD license, all text above must be included in any redistribution 34 | 35 | To download. click the **Download ZIP** in the right-hand column, rename the uncompressed folder Adafruit\_L3GD20\_U. Check that the Adafruit\_L3GD20\_U folder contains Adafruit\_L3GD20\U.cpp and Adafruit\_L3GD20\_U.h 36 | 37 | Place the Adafruit\_L3GD20\_U library folder your (arduinosketchfolder)/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. 38 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_L3GD20_U/examples/sensorapi/sensorapi.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Assign a unique ID to this sensor at the same time */ 6 | Adafruit_L3GD20_Unified gyro = Adafruit_L3GD20_Unified(20); 7 | 8 | void displaySensorDetails(void) 9 | { 10 | sensor_t sensor; 11 | gyro.getSensor(&sensor); 12 | Serial.println("------------------------------------"); 13 | Serial.print ("Sensor: "); Serial.println(sensor.name); 14 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 15 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 16 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" rad/s"); 17 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" rad/s"); 18 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" rad/s"); 19 | Serial.println("------------------------------------"); 20 | Serial.println(""); 21 | delay(500); 22 | } 23 | 24 | void setup(void) 25 | { 26 | Serial.begin(9600); 27 | Serial.println("Gyroscope Test"); Serial.println(""); 28 | 29 | /* Enable auto-ranging */ 30 | gyro.enableAutoRange(true); 31 | 32 | /* Initialise the sensor */ 33 | if(!gyro.begin()) 34 | { 35 | /* There was a problem detecting the L3GD20 ... check your connections */ 36 | Serial.println("Ooops, no L3GD20 detected ... Check your wiring!"); 37 | while(1); 38 | } 39 | 40 | /* Display some basic information on this sensor */ 41 | displaySensorDetails(); 42 | } 43 | 44 | void loop(void) 45 | { 46 | /* Get a new sensor event */ 47 | sensors_event_t event; 48 | gyro.getEvent(&event); 49 | 50 | /* Display the results (speed is measured in rad/s) */ 51 | Serial.print("X: "); Serial.print(event.gyro.x); Serial.print(" "); 52 | Serial.print("Y: "); Serial.print(event.gyro.y); Serial.print(" "); 53 | Serial.print("Z: "); Serial.print(event.gyro.z); Serial.print(" "); 54 | Serial.println("rad/s "); 55 | delay(500); 56 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_L3GD20_U/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit L3GD20 U 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Unified sensor driver for the L3GD20 Gyroscope 6 | paragraph=Unified sensor driver for the L3GD20 Gyroscope 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_L3GD20_U 9 | architectures=* 10 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_LSM303DLHC/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_LSM303DLHC/Adafruit_LSM303_U.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This is a library for the LSM303 Accelerometer and magnentometer/compass 3 | 4 | Designed specifically to work with the Adafruit LSM303DLHC Breakout 5 | 6 | These displays use I2C to communicate, 2 pins are required to interface. 7 | 8 | Adafruit invests time and resources providing this open source code, 9 | please support Adafruit andopen-source hardware by purchasing products 10 | from Adafruit! 11 | 12 | Written by Kevin Townsend for Adafruit Industries. 13 | BSD license, all text above must be included in any redistribution 14 | ***************************************************************************/ 15 | #ifndef __LSM303_H__ 16 | #define __LSM303_H__ 17 | 18 | #if (ARDUINO >= 100) 19 | #include "Arduino.h" 20 | #else 21 | #include "WProgram.h" 22 | #endif 23 | 24 | #include 25 | #ifdef __AVR_ATtiny85__ 26 | #include "TinyWireM.h" 27 | #define Wire TinyWireM 28 | #else 29 | #include 30 | #endif 31 | 32 | 33 | /*========================================================================= 34 | I2C ADDRESS/BITS 35 | -----------------------------------------------------------------------*/ 36 | #define LSM303_ADDRESS_ACCEL (0x32 >> 1) // 0011001x 37 | #define LSM303_ADDRESS_MAG (0x3C >> 1) // 0011110x 38 | /*=========================================================================*/ 39 | 40 | /*========================================================================= 41 | REGISTERS 42 | -----------------------------------------------------------------------*/ 43 | typedef enum 44 | { // DEFAULT TYPE 45 | LSM303_REGISTER_ACCEL_CTRL_REG1_A = 0x20, // 00000111 rw 46 | LSM303_REGISTER_ACCEL_CTRL_REG2_A = 0x21, // 00000000 rw 47 | LSM303_REGISTER_ACCEL_CTRL_REG3_A = 0x22, // 00000000 rw 48 | LSM303_REGISTER_ACCEL_CTRL_REG4_A = 0x23, // 00000000 rw 49 | LSM303_REGISTER_ACCEL_CTRL_REG5_A = 0x24, // 00000000 rw 50 | LSM303_REGISTER_ACCEL_CTRL_REG6_A = 0x25, // 00000000 rw 51 | LSM303_REGISTER_ACCEL_REFERENCE_A = 0x26, // 00000000 r 52 | LSM303_REGISTER_ACCEL_STATUS_REG_A = 0x27, // 00000000 r 53 | LSM303_REGISTER_ACCEL_OUT_X_L_A = 0x28, 54 | LSM303_REGISTER_ACCEL_OUT_X_H_A = 0x29, 55 | LSM303_REGISTER_ACCEL_OUT_Y_L_A = 0x2A, 56 | LSM303_REGISTER_ACCEL_OUT_Y_H_A = 0x2B, 57 | LSM303_REGISTER_ACCEL_OUT_Z_L_A = 0x2C, 58 | LSM303_REGISTER_ACCEL_OUT_Z_H_A = 0x2D, 59 | LSM303_REGISTER_ACCEL_FIFO_CTRL_REG_A = 0x2E, 60 | LSM303_REGISTER_ACCEL_FIFO_SRC_REG_A = 0x2F, 61 | LSM303_REGISTER_ACCEL_INT1_CFG_A = 0x30, 62 | LSM303_REGISTER_ACCEL_INT1_SOURCE_A = 0x31, 63 | LSM303_REGISTER_ACCEL_INT1_THS_A = 0x32, 64 | LSM303_REGISTER_ACCEL_INT1_DURATION_A = 0x33, 65 | LSM303_REGISTER_ACCEL_INT2_CFG_A = 0x34, 66 | LSM303_REGISTER_ACCEL_INT2_SOURCE_A = 0x35, 67 | LSM303_REGISTER_ACCEL_INT2_THS_A = 0x36, 68 | LSM303_REGISTER_ACCEL_INT2_DURATION_A = 0x37, 69 | LSM303_REGISTER_ACCEL_CLICK_CFG_A = 0x38, 70 | LSM303_REGISTER_ACCEL_CLICK_SRC_A = 0x39, 71 | LSM303_REGISTER_ACCEL_CLICK_THS_A = 0x3A, 72 | LSM303_REGISTER_ACCEL_TIME_LIMIT_A = 0x3B, 73 | LSM303_REGISTER_ACCEL_TIME_LATENCY_A = 0x3C, 74 | LSM303_REGISTER_ACCEL_TIME_WINDOW_A = 0x3D 75 | } lsm303AccelRegisters_t; 76 | 77 | typedef enum 78 | { 79 | LSM303_REGISTER_MAG_CRA_REG_M = 0x00, 80 | LSM303_REGISTER_MAG_CRB_REG_M = 0x01, 81 | LSM303_REGISTER_MAG_MR_REG_M = 0x02, 82 | LSM303_REGISTER_MAG_OUT_X_H_M = 0x03, 83 | LSM303_REGISTER_MAG_OUT_X_L_M = 0x04, 84 | LSM303_REGISTER_MAG_OUT_Z_H_M = 0x05, 85 | LSM303_REGISTER_MAG_OUT_Z_L_M = 0x06, 86 | LSM303_REGISTER_MAG_OUT_Y_H_M = 0x07, 87 | LSM303_REGISTER_MAG_OUT_Y_L_M = 0x08, 88 | LSM303_REGISTER_MAG_SR_REG_Mg = 0x09, 89 | LSM303_REGISTER_MAG_IRA_REG_M = 0x0A, 90 | LSM303_REGISTER_MAG_IRB_REG_M = 0x0B, 91 | LSM303_REGISTER_MAG_IRC_REG_M = 0x0C, 92 | LSM303_REGISTER_MAG_TEMP_OUT_H_M = 0x31, 93 | LSM303_REGISTER_MAG_TEMP_OUT_L_M = 0x32 94 | } lsm303MagRegisters_t; 95 | /*=========================================================================*/ 96 | 97 | /*========================================================================= 98 | MAGNETOMETER GAIN SETTINGS 99 | -----------------------------------------------------------------------*/ 100 | typedef enum 101 | { 102 | LSM303_MAGGAIN_1_3 = 0x20, // +/- 1.3 103 | LSM303_MAGGAIN_1_9 = 0x40, // +/- 1.9 104 | LSM303_MAGGAIN_2_5 = 0x60, // +/- 2.5 105 | LSM303_MAGGAIN_4_0 = 0x80, // +/- 4.0 106 | LSM303_MAGGAIN_4_7 = 0xA0, // +/- 4.7 107 | LSM303_MAGGAIN_5_6 = 0xC0, // +/- 5.6 108 | LSM303_MAGGAIN_8_1 = 0xE0 // +/- 8.1 109 | } lsm303MagGain; 110 | /*=========================================================================*/ 111 | 112 | /*========================================================================= 113 | MAGNETOMETER UPDATE RATE SETTINGS 114 | -----------------------------------------------------------------------*/ 115 | typedef enum 116 | { 117 | LSM303_MAGRATE_0_7 = 0x00, // 0.75 Hz 118 | LSM303_MAGRATE_1_5 = 0x01, // 1.5 Hz 119 | LSM303_MAGRATE_3_0 = 0x62, // 3.0 Hz 120 | LSM303_MAGRATE_7_5 = 0x03, // 7.5 Hz 121 | LSM303_MAGRATE_15 = 0x04, // 15 Hz 122 | LSM303_MAGRATE_30 = 0x05, // 30 Hz 123 | LSM303_MAGRATE_75 = 0x06, // 75 Hz 124 | LSM303_MAGRATE_220 = 0x07 // 200 Hz 125 | } lsm303MagRate; 126 | /*=========================================================================*/ 127 | 128 | /*========================================================================= 129 | INTERNAL MAGNETOMETER DATA TYPE 130 | -----------------------------------------------------------------------*/ 131 | typedef struct lsm303MagData_s 132 | { 133 | float x; 134 | float y; 135 | float z; 136 | } lsm303MagData; 137 | /*=========================================================================*/ 138 | 139 | /*========================================================================= 140 | INTERNAL ACCELERATION DATA TYPE 141 | -----------------------------------------------------------------------*/ 142 | typedef struct lsm303AccelData_s 143 | { 144 | float x; 145 | float y; 146 | float z; 147 | } lsm303AccelData; 148 | /*=========================================================================*/ 149 | 150 | /*========================================================================= 151 | CHIP ID 152 | -----------------------------------------------------------------------*/ 153 | #define LSM303_ID (0b11010100) 154 | /*=========================================================================*/ 155 | 156 | /* Unified sensor driver for the accelerometer */ 157 | class Adafruit_LSM303_Accel_Unified : public Adafruit_Sensor 158 | { 159 | public: 160 | Adafruit_LSM303_Accel_Unified(int32_t sensorID = -1); 161 | 162 | bool begin(void); 163 | bool getEvent(sensors_event_t*); 164 | void getSensor(sensor_t*); 165 | 166 | private: 167 | lsm303AccelData _accelData; // Last read accelerometer data will be available here 168 | int32_t _sensorID; 169 | 170 | void write8(byte address, byte reg, byte value); 171 | byte read8(byte address, byte reg); 172 | void read(void); 173 | }; 174 | 175 | /* Unified sensor driver for the magnetometer */ 176 | class Adafruit_LSM303_Mag_Unified : public Adafruit_Sensor 177 | { 178 | public: 179 | Adafruit_LSM303_Mag_Unified(int32_t sensorID = -1); 180 | 181 | bool begin(void); 182 | void enableAutoRange(bool enable); 183 | void setMagGain(lsm303MagGain gain); 184 | void setMagRate(lsm303MagRate rate); 185 | bool getEvent(sensors_event_t*); 186 | void getSensor(sensor_t*); 187 | 188 | private: 189 | lsm303MagGain _magGain; 190 | lsm303MagData _magData; // Last read magnetometer data will be available here 191 | int32_t _sensorID; 192 | bool _autoRangeEnabled; 193 | 194 | void write8(byte address, byte reg, byte value); 195 | byte read8(byte address, byte reg); 196 | void read(void); 197 | }; 198 | 199 | #endif 200 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_LSM303DLHC/README.md: -------------------------------------------------------------------------------- 1 | #Adafruit LSM303DLHC Driver (Accelerometer + Magnetometer) # 2 | 3 | This driver is for the Adafruit LSM303 Breakout (http://www.adafruit.com/products/1120), and is based on Adafruit's Unified Sensor Library (Adafruit_Sensor). 4 | 5 | ## About the LSM303 ## 6 | 7 | The LSM303 is a digital (I2C) accelerometer and digital compass (magnetometer). The accelerometer allows you to measure acceleration or direction towards the center or the earth, and the magnetometer measure magnetic force, which is useful to detect magnetic north. 8 | 9 | More information on the LSM303 can be found in the datasheet: http://www.adafruit.com/datasheets/LSM303DLHC.PDF 10 | 11 | ## What is the Adafruit Unified Sensor Library? ## 12 | 13 | The Adafruit Unified Sensor Library (**Adafruit_Sensor**) provides a common interface and data type for any supported sensor. It defines some basic information about the sensor (sensor limits, etc.), and returns standard SI units of a specific type and scale for each supported sensor type. 14 | 15 | It provides a simple abstraction layer between your application and the actual sensor HW, allowing you to drop in any comparable sensor with only one or two lines of code to change in your project (essentially the constructor since the functions to read sensor data and get information about the sensor are defined in the base Adafruit_Sensor class). 16 | 17 | This is imporant useful for two reasons: 18 | 19 | 1.) You can use the data right away because it's already converted to SI units that you understand and can compare, rather than meaningless values like 0..1023. 20 | 21 | 2.) Because SI units are standardised in the sensor library, you can also do quick sanity checks working with new sensors, or drop in any comparable sensor if you need better sensitivity or if a lower cost unit becomes available, etc. 22 | 23 | Light sensors will always report units in lux, gyroscopes will always report units in rad/s, etc. ... freeing you up to focus on the data, rather than digging through the datasheet to understand what the sensor's raw numbers really mean. 24 | 25 | ## About this Driver ## 26 | 27 | Adafruit invests time and resources providing this open source code. Please support Adafruit and open-source hardware by purchasing products from Adafruit! 28 | 29 | Written by Kevin (KTOWN) Townsend for Adafruit Industries. -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_LSM303DLHC/examples/accelsensor/accelsensor.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Assign a unique ID to this sensor at the same time */ 6 | Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(54321); 7 | 8 | void displaySensorDetails(void) 9 | { 10 | sensor_t sensor; 11 | accel.getSensor(&sensor); 12 | Serial.println("------------------------------------"); 13 | Serial.print ("Sensor: "); Serial.println(sensor.name); 14 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 15 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 16 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" m/s^2"); 17 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" m/s^2"); 18 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" m/s^2"); 19 | Serial.println("------------------------------------"); 20 | Serial.println(""); 21 | delay(500); 22 | } 23 | 24 | void setup(void) 25 | { 26 | Serial.begin(9600); 27 | Serial.println("Accelerometer Test"); Serial.println(""); 28 | 29 | /* Initialise the sensor */ 30 | if(!accel.begin()) 31 | { 32 | /* There was a problem detecting the ADXL345 ... check your connections */ 33 | Serial.println("Ooops, no LSM303 detected ... Check your wiring!"); 34 | while(1); 35 | } 36 | 37 | /* Display some basic information on this sensor */ 38 | displaySensorDetails(); 39 | } 40 | 41 | void loop(void) 42 | { 43 | /* Get a new sensor event */ 44 | sensors_event_t event; 45 | accel.getEvent(&event); 46 | 47 | /* Display the results (acceleration is measured in m/s^2) */ 48 | Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" "); 49 | Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" "); 50 | Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" ");Serial.println("m/s^2 "); 51 | delay(500); 52 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_LSM303DLHC/examples/magsensor/magsensor.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Assign a unique ID to this sensor at the same time */ 6 | Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(12345); 7 | 8 | void displaySensorDetails(void) 9 | { 10 | sensor_t sensor; 11 | mag.getSensor(&sensor); 12 | Serial.println("------------------------------------"); 13 | Serial.print ("Sensor: "); Serial.println(sensor.name); 14 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 15 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 16 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" uT"); 17 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" uT"); 18 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" uT"); 19 | Serial.println("------------------------------------"); 20 | Serial.println(""); 21 | delay(500); 22 | } 23 | 24 | void setup(void) 25 | { 26 | Serial.begin(9600); 27 | Serial.println("Magnetometer Test"); Serial.println(""); 28 | 29 | /* Enable auto-gain */ 30 | mag.enableAutoRange(true); 31 | 32 | /* Initialise the sensor */ 33 | if(!mag.begin()) 34 | { 35 | /* There was a problem detecting the LSM303 ... check your connections */ 36 | Serial.println("Ooops, no LSM303 detected ... Check your wiring!"); 37 | while(1); 38 | } 39 | 40 | /* Display some basic information on this sensor */ 41 | displaySensorDetails(); 42 | } 43 | 44 | void loop(void) 45 | { 46 | /* Get a new sensor event */ 47 | sensors_event_t event; 48 | mag.getEvent(&event); 49 | 50 | /* Display the results (magnetic vector values are in micro-Tesla (uT)) */ 51 | Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print(" "); 52 | Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print(" "); 53 | Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print(" ");Serial.println("uT"); 54 | delay(500); 55 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_LSM303DLHC/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit LSM303DLHC 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) 6 | paragraph=Unified sensor driver for Adafruit's LSM303 Breakout (Accelerometer + Magnetometer) 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_LSM303DLHC 9 | architectures=* 10 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/Adafruit_MAX31855.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Adafruit Thermocouple Sensor w/MAX31855K 3 | 4 | Designed specifically to work with the Adafruit Thermocouple Sensor 5 | ----> https://www.adafruit.com/products/269 6 | 7 | These displays use SPI to communicate, 3 pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #include "Adafruit_MAX31855.h" 18 | #include 19 | 20 | #include 21 | 22 | 23 | 24 | Adafruit_MAX31855::Adafruit_MAX31855() { 25 | 26 | } 27 | void Adafruit_MAX31855::begin(int8_t SCLK, int8_t CS, int8_t MISO) { 28 | sclk = SCLK; 29 | cs = CS; 30 | miso = MISO; 31 | hSPI = 0; 32 | 33 | //define pin modes 34 | pinMode(cs, OUTPUT); 35 | pinMode(sclk, OUTPUT); 36 | pinMode(miso, INPUT); 37 | 38 | digitalWrite(cs, HIGH); 39 | digitalWrite(sclk, LOW); 40 | } 41 | void Adafruit_MAX31855::begin(int8_t CS) { 42 | cs = CS; 43 | hSPI = 1; 44 | 45 | //define pin modes 46 | pinMode(cs, OUTPUT); 47 | 48 | //start and configure hardware SPI 49 | SPI.begin(); 50 | SPI.setBitOrder(MSBFIRST); 51 | SPI.setDataMode(SPI_MODE0); 52 | SPI.setClockDivider(SPI_CLOCK_DIV64); 53 | 54 | digitalWrite(cs, HIGH); 55 | } 56 | 57 | double Adafruit_MAX31855::readInternal(void) { 58 | uint32_t v; 59 | 60 | v = spiread32(); 61 | 62 | // ignore bottom 4 bits - they're just thermocouple data 63 | v >>= 4; 64 | 65 | // pull the bottom 11 bits off 66 | float internal = v & 0x7FF; 67 | // check sign bit! 68 | if (v & 0x800) { 69 | // Convert to negative value by extending sign and casting to signed type. 70 | int16_t tmp = 0xF800 | (v & 0x7FF); 71 | internal = tmp; 72 | } 73 | internal *= 0.0625; // LSB = 0.0625 degrees 74 | //Serial.print("\tInternal Temp: "); Serial.println(internal); 75 | return internal; 76 | } 77 | 78 | double Adafruit_MAX31855::readCelsius(void) { 79 | 80 | int32_t v; 81 | 82 | v = spiread32(); 83 | 84 | //Serial.print("0x"); Serial.println(v, HEX); 85 | 86 | /* 87 | float internal = (v >> 4) & 0x7FF; 88 | internal *= 0.0625; 89 | if ((v >> 4) & 0x800) 90 | internal *= -1; 91 | Serial.print("\tInternal Temp: "); Serial.println(internal); 92 | */ 93 | 94 | if (v & 0x7) { 95 | // uh oh, a serious problem! 96 | return NAN; 97 | } 98 | 99 | if (v & 0x80000000) { 100 | // Negative value, drop the lower 18 bits and explicitly extend sign bits. 101 | v = 0xFFFFC000 | ((v >> 18) & 0x00003FFFF); 102 | } 103 | else { 104 | // Positive value, just drop the lower 18 bits. 105 | v >>= 18; 106 | } 107 | //Serial.println(v, HEX); 108 | 109 | double centigrade = v; 110 | 111 | // LSB = 0.25 degrees C 112 | centigrade *= 0.25; 113 | return centigrade; 114 | } 115 | 116 | uint8_t Adafruit_MAX31855::readError() { 117 | return spiread32() & 0x7; 118 | } 119 | 120 | double Adafruit_MAX31855::readFarenheit(void) { 121 | float f = readCelsius(); 122 | f *= 9.0; 123 | f /= 5.0; 124 | f += 32; 125 | return f; 126 | } 127 | 128 | uint32_t Adafruit_MAX31855::spiread32(void) { 129 | int i; 130 | uint32_t d = 0; 131 | 132 | if(hSPI) { 133 | return hspiread32(); 134 | } 135 | 136 | digitalWrite(sclk, LOW); 137 | delay(1); 138 | digitalWrite(cs, LOW); 139 | delay(1); 140 | 141 | for (i=31; i>=0; i--) 142 | { 143 | digitalWrite(sclk, LOW); 144 | delay(1); 145 | d <<= 1; 146 | if (digitalRead(miso)) { 147 | d |= 1; 148 | } 149 | 150 | digitalWrite(sclk, HIGH); 151 | delay(1); 152 | } 153 | 154 | digitalWrite(cs, HIGH); 155 | Serial.println(d, HEX); 156 | return d; 157 | } 158 | 159 | uint32_t Adafruit_MAX31855::hspiread32(void) { 160 | int i; 161 | // easy conversion of four uint8_ts to uint32_t 162 | union bytes_to_uint32 { 163 | uint8_t bytes[4]; 164 | uint32_t integer; 165 | } buffer; 166 | 167 | digitalWrite(cs, LOW); 168 | delay(1); 169 | 170 | for (i=3;i>=0;i--) { 171 | buffer.bytes[i] = SPI.transfer(0x00); 172 | } 173 | 174 | digitalWrite(cs, HIGH); 175 | 176 | return buffer.integer; 177 | 178 | } 179 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/Adafruit_MAX31855.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Adafruit Thermocouple Sensor w/MAX31855K 3 | 4 | Designed specifically to work with the Adafruit Thermocouple Sensor 5 | ----> https://www.adafruit.com/products/269 6 | 7 | These displays use SPI to communicate, 3 pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #ifndef ADAFRUIT_MAX31855_H 18 | #define ADAFRUIT_MAX31855_H 19 | 20 | #if (ARDUINO >= 100) 21 | #include "Arduino.h" 22 | #else 23 | #include "WProgram.h" 24 | #endif 25 | 26 | class Adafruit_MAX31855 { 27 | public: 28 | 29 | Adafruit_MAX31855(); 30 | void begin(int8_t SCLK, int8_t CS, int8_t MISO); 31 | void begin(int8_t CS); 32 | 33 | double readInternal(void); 34 | double readCelsius(void); 35 | double readFarenheit(void); 36 | uint8_t readError(); 37 | 38 | private: 39 | int8_t sclk, miso, cs, hSPI; 40 | uint32_t spiread32(void); 41 | uint32_t hspiread32(void); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/README.txt: -------------------------------------------------------------------------------- 1 | This is the Adafruit MAX31885 Arduino Library 2 | 3 | Tested and works great with the Adafruit Thermocouple Breakout w/MAX31885K 4 | ------> http://www.adafruit.com/products/269 5 | 6 | These modules use SPI to communicate, 3 pins are required to 7 | interface 8 | 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, check license.txt for more information 15 | All text above must be included in any redistribution 16 | 17 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_MAX31885. Check that the Adafruit_MAX31885 folder contains Adafruit_MAX31885.cpp and Adafruit_MAX31885.h 18 | 19 | Place the Adafruit_MAX31885 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/examples/lcdthermocouple/lcdthermocouple.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is an example for the Adafruit Thermocouple Sensor w/MAX31855K 3 | 4 | Designed specifically to work with the Adafruit Thermocouple Sensor 5 | ----> https://www.adafruit.com/products/269 6 | 7 | These displays use SPI to communicate, 3 pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | #include 17 | #include "Adafruit_MAX31855.h" 18 | #include 19 | 20 | int thermoCLK = 3; 21 | int thermoCS = 4; 22 | int thermoDO = 5; 23 | 24 | // Initialize the Thermocouple 25 | Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO); 26 | // initialize the library with the numbers of the interface pins 27 | LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 28 | 29 | 30 | void setup() { 31 | Serial.begin(9600); 32 | // set up the LCD's number of columns and rows: 33 | lcd.begin(16, 2); 34 | 35 | lcd.print("MAX31855 test"); 36 | // wait for MAX chip to stabilize 37 | delay(500); 38 | } 39 | 40 | void loop() { 41 | // basic readout test, just print the current temp 42 | lcd.setCursor(0, 0); 43 | lcd.print("Int. Temp = "); 44 | lcd.println(thermocouple.readInternal()); 45 | lcd.print(" "); 46 | 47 | double c = thermocouple.readCelsius(); 48 | lcd.setCursor(0, 1); 49 | if (isnan(c)) 50 | { 51 | lcd.print("T/C Problem"); 52 | } 53 | else 54 | { 55 | lcd.print("C = "); 56 | lcd.print(c); 57 | lcd.print(" "); 58 | } 59 | 60 | delay(1000); 61 | } 62 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/examples/serialthermocouple/serialthermocouple.pde: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is an example for the Adafruit Thermocouple Sensor w/MAX31855K 3 | 4 | Designed specifically to work with the Adafruit Thermocouple Sensor 5 | ----> https://www.adafruit.com/products/269 6 | 7 | These displays use SPI to communicate, 3 pins are required to 8 | interface 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | BSD license, all text above must be included in any redistribution 15 | ****************************************************/ 16 | 17 | #include 18 | #include "Adafruit_MAX31855.h" 19 | 20 | // Default connection is using software SPI, but comment and uncomment one of 21 | // the two examples below to switch between software SPI and hardware SPI: 22 | 23 | // Example creating a thermocouple instance with software SPI on any three 24 | // digital IO pins. 25 | #define DO 12 26 | #define CS 9 27 | #define CLK 13 28 | Adafruit_MAX31855 thermocouple; 29 | 30 | // Example creating a thermocouple instance with hardware SPI (Uno/Mega only) 31 | // on a given CS pin. 32 | //#define CS 10 33 | //Adafruit_MAX31855 thermocouple(CS); 34 | 35 | void setup() { 36 | Serial.begin(9600); 37 | thermocouple.begin(CLK, CS, DO); 38 | Serial.println("MAX31855 test"); 39 | // wait for MAX chip to stabilize 40 | delay(500); 41 | } 42 | 43 | void loop() { 44 | // basic readout test, just print the current temp 45 | Serial.print("Internal Temp = "); 46 | Serial.println(thermocouple.readInternal()); 47 | 48 | double c = thermocouple.readCelsius(); 49 | if (isnan(c)) { 50 | Serial.println("Something wrong with thermocouple!"); 51 | } else { 52 | Serial.print("C = "); 53 | Serial.println(c); 54 | } 55 | //Serial.print("F = "); 56 | //Serial.println(thermocouple.readFarenheit()); 57 | 58 | delay(1000); 59 | } -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map for NewSoftSerial 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | max6675 KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | readCelsius KEYWORD2 16 | readFarenheit KEYWORD2 17 | 18 | ####################################### 19 | # Constants (LITERAL1) 20 | ####################################### 21 | 22 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit MAX31855 library 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Library for the Adafruit Thermocouple breakout with MAX31855K 6 | paragraph=Library for the Adafruit Thermocouple breakout with MAX31855K 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit-MAX31855-library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_MAX31855/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012, Adafruit Industries 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_Sensor/Adafruit_Sensor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MediaTek-Labs/linkit-smart-7688-duo-arduino/1a5397a98df1e5acf4612164a2551aff4083ef20/mtk/test_case/libraries/Adafruit_Sensor/Adafruit_Sensor.h -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_Sensor/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit Unified Sensor Driver # 2 | 3 | Many small embedded systems exist to collect data from sensors, analyse the data, and either take an appropriate action or send that sensor data to another system for processing. 4 | 5 | One of the many challenges of embedded systems design is the fact that parts you used today may be out of production tomorrow, or system requirements may change and you may need to choose a different sensor down the road. 6 | 7 | Creating new drivers is a relatively easy task, but integrating them into existing systems is both error prone and time consuming since sensors rarely use the exact same units of measurement. 8 | 9 | By reducing all data to a single **sensors\_event\_t** 'type' and settling on specific, **standardised SI units** for each sensor family the same sensor types return values that are comparable with any other similar sensor. This enables you to switch sensor models with very little impact on the rest of the system, which can help mitigate some of the risks and problems of sensor availability and code reuse. 10 | 11 | The unified sensor abstraction layer is also useful for data-logging and data-transmission since you only have one well-known type to log or transmit over the air or wire. 12 | 13 | ## Unified Sensor Drivers ## 14 | 15 | The following drivers are based on the Adafruit Unified Sensor Driver: 16 | 17 | **Accelerometers** 18 | - [Adafruit\_ADXL345](https://github.com/adafruit/Adafruit_ADXL345) 19 | - [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC) 20 | - [Adafruit\_MMA8451\_Library](https://github.com/adafruit/Adafruit_MMA8451_Library) 21 | 22 | **Gyroscope** 23 | - [Adafruit\_L3GD20\_U](https://github.com/adafruit/Adafruit_L3GD20_U) 24 | 25 | **Light** 26 | - [Adafruit\_TSL2561](https://github.com/adafruit/Adafruit_TSL2561) 27 | - [Adafruit\_TSL2591\_Library](https://github.com/adafruit/Adafruit_TSL2591_Library) 28 | 29 | **Magnetometers** 30 | - [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC) 31 | - [Adafruit\_HMC5883\_Unified](https://github.com/adafruit/Adafruit_HMC5883_Unified) 32 | 33 | **Barometric Pressure** 34 | - [Adafruit\_BMP085\_Unified](https://github.com/adafruit/Adafruit_BMP085_Unified) 35 | - [Adafruit\_BMP183\_Unified\_Library](https://github.com/adafruit/Adafruit_BMP183_Unified_Library) 36 | 37 | **Humidity & Temperature** 38 | - [Adafruit\_DHT\_Unified](https://github.com/adafruit/Adafruit_DHT_Unified) 39 | 40 | ## How Does it Work? ## 41 | 42 | Any driver that supports the Adafruit unified sensor abstraction layer will implement the Adafruit\_Sensor base class. There are two main typedefs and one enum defined in Adafruit_Sensor.h that are used to 'abstract' away the sensor details and values: 43 | 44 | **Sensor Types (sensors\_type\_t)** 45 | 46 | These pre-defined sensor types are used to properly handle the two related typedefs below, and allows us determine what types of units the sensor uses, etc. 47 | 48 | ``` 49 | /** Sensor types */ 50 | typedef enum 51 | { 52 | SENSOR_TYPE_ACCELEROMETER = (1), 53 | SENSOR_TYPE_MAGNETIC_FIELD = (2), 54 | SENSOR_TYPE_ORIENTATION = (3), 55 | SENSOR_TYPE_GYROSCOPE = (4), 56 | SENSOR_TYPE_LIGHT = (5), 57 | SENSOR_TYPE_PRESSURE = (6), 58 | SENSOR_TYPE_PROXIMITY = (8), 59 | SENSOR_TYPE_GRAVITY = (9), 60 | SENSOR_TYPE_LINEAR_ACCELERATION = (10), 61 | SENSOR_TYPE_ROTATION_VECTOR = (11), 62 | SENSOR_TYPE_RELATIVE_HUMIDITY = (12), 63 | SENSOR_TYPE_AMBIENT_TEMPERATURE = (13), 64 | SENSOR_TYPE_VOLTAGE = (15), 65 | SENSOR_TYPE_CURRENT = (16), 66 | SENSOR_TYPE_COLOR = (17) 67 | } sensors_type_t; 68 | ``` 69 | 70 | **Sensor Details (sensor\_t)** 71 | 72 | This typedef describes the specific capabilities of this sensor, and allows us to know what sensor we are using beneath the abstraction layer. 73 | 74 | ``` 75 | /* Sensor details (40 bytes) */ 76 | /** struct sensor_s is used to describe basic information about a specific sensor. */ 77 | typedef struct 78 | { 79 | char name[12]; 80 | int32_t version; 81 | int32_t sensor_id; 82 | int32_t type; 83 | float max_value; 84 | float min_value; 85 | float resolution; 86 | int32_t min_delay; 87 | } sensor_t; 88 | ``` 89 | 90 | The individual fields are intended to be used as follows: 91 | 92 | - **name**: The sensor name or ID, up to a maximum of twelve characters (ex. "MPL115A2") 93 | - **version**: The version of the sensor HW and the driver to allow us to differentiate versions of the board or driver 94 | - **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network 95 | - **type**: The sensor type, based on **sensors\_type\_t** in sensors.h 96 | - **max\_value**: The maximum value that this sensor can return (in the appropriate SI unit) 97 | - **min\_value**: The minimum value that this sensor can return (in the appropriate SI unit) 98 | - **resolution**: The smallest difference between two values that this sensor can report (in the appropriate SI unit) 99 | - **min\_delay**: The minimum delay in microseconds between two sensor events, or '0' if there is no constant sensor rate 100 | 101 | **Sensor Data/Events (sensors\_event\_t)** 102 | 103 | This typedef is used to return sensor data from any sensor supported by the abstraction layer, using standard SI units and scales. 104 | 105 | ``` 106 | /* Sensor event (36 bytes) */ 107 | /** struct sensor_event_s is used to provide a single sensor event in a common format. */ 108 | typedef struct 109 | { 110 | int32_t version; 111 | int32_t sensor_id; 112 | int32_t type; 113 | int32_t reserved0; 114 | int32_t timestamp; 115 | union 116 | { 117 | float data[4]; 118 | sensors_vec_t acceleration; 119 | sensors_vec_t magnetic; 120 | sensors_vec_t orientation; 121 | sensors_vec_t gyro; 122 | float temperature; 123 | float distance; 124 | float light; 125 | float pressure; 126 | float relative_humidity; 127 | float current; 128 | float voltage; 129 | sensors_color_t color; 130 | }; 131 | } sensors_event_t; 132 | ``` 133 | It includes the following fields: 134 | 135 | - **version**: Contain 'sizeof(sensors\_event\_t)' to identify which version of the API we're using in case this changes in the future 136 | - **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network (must match the sensor\_id value in the corresponding sensor\_t enum above!) 137 | - **type**: the sensor type, based on **sensors\_type\_t** in sensors.h 138 | - **timestamp**: time in milliseconds when the sensor value was read 139 | - **data[4]**: An array of four 32-bit values that allows us to encapsulate any type of sensor data via a simple union (further described below) 140 | 141 | **Required Functions** 142 | 143 | In addition to the two standard types and the sensor type enum, all drivers based on Adafruit_Sensor must also implement the following two functions: 144 | 145 | ``` 146 | bool getEvent(sensors_event_t*); 147 | ``` 148 | Calling this function will populate the supplied sensors\_event\_t reference with the latest available sensor data. You should call this function as often as you want to update your data. 149 | 150 | ``` 151 | void getSensor(sensor_t*); 152 | ``` 153 | Calling this function will provide some basic information about the sensor (the sensor name, driver version, min and max values, etc. 154 | 155 | **Standardised SI values for sensors\_event\_t** 156 | 157 | A key part of the abstraction layer is the standardisation of values on SI units of a particular scale, which is accomplished via the data[4] union in sensors\_event\_t above. This 16 byte union includes fields for each main sensor type, and uses the following SI units and scales: 158 | 159 | - **acceleration**: values are in **meter per second per second** (m/s^2) 160 | - **magnetic**: values are in **micro-Tesla** (uT) 161 | - **orientation**: values are in **degrees** 162 | - **gyro**: values are in **rad/s** 163 | - **temperature**: values in **degrees centigrade** (Celsius) 164 | - **distance**: values are in **centimeters** 165 | - **light**: values are in **SI lux** units 166 | - **pressure**: values are in **hectopascal** (hPa) 167 | - **relative\_humidity**: values are in **percent** 168 | - **current**: values are in **milliamps** (mA) 169 | - **voltage**: values are in **volts** (V) 170 | - **color**: values are in 0..1.0 RGB channel luminosity and 32-bit RGBA format 171 | 172 | ## The Unified Driver Abstraction Layer in Practice ## 173 | 174 | Using the unified sensor abstraction layer is relatively easy once a compliant driver has been created. 175 | 176 | Every compliant sensor can now be read using a single, well-known 'type' (sensors\_event\_t), and there is a standardised way of interrogating a sensor about its specific capabilities (via sensor\_t). 177 | 178 | An example of reading the [TSL2561](https://github.com/adafruit/Adafruit_TSL2561) light sensor can be seen below: 179 | 180 | ``` 181 | Adafruit_TSL2561 tsl = Adafruit_TSL2561(TSL2561_ADDR_FLOAT, 12345); 182 | ... 183 | /* Get a new sensor event */ 184 | sensors_event_t event; 185 | tsl.getEvent(&event); 186 | 187 | /* Display the results (light is measured in lux) */ 188 | if (event.light) 189 | { 190 | Serial.print(event.light); Serial.println(" lux"); 191 | } 192 | else 193 | { 194 | /* If event.light = 0 lux the sensor is probably saturated 195 | and no reliable data could be generated! */ 196 | Serial.println("Sensor overload"); 197 | } 198 | ``` 199 | 200 | Similarly, we can get the basic technical capabilities of this sensor with the following code: 201 | 202 | ``` 203 | sensor_t sensor; 204 | 205 | sensor_t sensor; 206 | tsl.getSensor(&sensor); 207 | 208 | /* Display the sensor details */ 209 | Serial.println("------------------------------------"); 210 | Serial.print ("Sensor: "); Serial.println(sensor.name); 211 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 212 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 213 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux"); 214 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux"); 215 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux"); 216 | Serial.println("------------------------------------"); 217 | Serial.println(""); 218 | ``` 219 | -------------------------------------------------------------------------------- /mtk/test_case/libraries/Adafruit_Sensor/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit Unified Sensor 2 | version=1.0.2 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Required for all Adafruit Unified Sensor based libraries. 6 | paragraph=A unified sensor abstraction layer used by many Adafruit sensor libraries. 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_Sensor 9 | architectures=* 10 | --------------------------------------------------------------------------------