diff --git a/.DS_Store.REMOVED.git-id.REMOVED.git-id b/.DS_Store.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index c0afee48..00000000
--- a/.DS_Store.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-07fd5f30875d2bc15afcc83055ee4000a0b7acd2
\ No newline at end of file
diff --git a/._.DS_Store.REMOVED.git-id.REMOVED.git-id b/._.DS_Store.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 95175ab4..00000000
--- a/._.DS_Store.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-301d01b13096dca1cd26a9b8830a99612aa2553b
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..5ecfcdaa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.csv
+/.project
diff --git a/.gitignore.REMOVED.git-id.REMOVED.git-id b/.gitignore.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 49ab68a1..00000000
--- a/.gitignore.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3c234b962282580cddee0b6d5f8eb4fae2feee8d
\ No newline at end of file
diff --git a/AVR Code/.vs/USB_BULK_TEST/v14/.atsuo b/AVR Code/.vs/USB_BULK_TEST/v14/.atsuo
new file mode 100644
index 00000000..b0425510
Binary files /dev/null and b/AVR Code/.vs/USB_BULK_TEST/v14/.atsuo differ
diff --git a/AVR Code/.vs/USB_BULK_TEST/v14/.atsuo.REMOVED.git-id b/AVR Code/.vs/USB_BULK_TEST/v14/.atsuo.REMOVED.git-id
deleted file mode 100644
index d5b314c8..00000000
--- a/AVR Code/.vs/USB_BULK_TEST/v14/.atsuo.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b0425510fe37aefb3e097ee1d324ce58289db692
\ No newline at end of file
diff --git a/AVR Code/PRODUCTION/EEPROM.eep.REMOVED.git-id b/AVR Code/PRODUCTION/EEPROM.eep.REMOVED.git-id
deleted file mode 100644
index 93704c5b..00000000
--- a/AVR Code/PRODUCTION/EEPROM.eep.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-18628c0284cf09b51812cf534acccabbe149f9a7
\ No newline at end of file
diff --git a/AVR Code/PRODUCTION/FLASH.hex.REMOVED.git-id b/AVR Code/PRODUCTION/FLASH.hex.REMOVED.git-id
deleted file mode 100644
index fc103313..00000000
--- a/AVR Code/PRODUCTION/FLASH.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5f1f7084dc45171b5b705dd350003ec686cd9673
\ No newline at end of file
diff --git a/AVR Code/PRODUCTION/USER_SIGNATURES.hex.REMOVED.git-id b/AVR Code/PRODUCTION/USER_SIGNATURES.hex.REMOVED.git-id
deleted file mode 100644
index 1f07f264..00000000
--- a/AVR Code/PRODUCTION/USER_SIGNATURES.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-81817d5221b066f2b509d433e8993e91a8b58386
\ No newline at end of file
diff --git a/AVR Code/PRODUCTION/labrador-ba94.elf.REMOVED.git-id b/AVR Code/PRODUCTION/labrador-ba94.elf.REMOVED.git-id
deleted file mode 100644
index faa464b1..00000000
--- a/AVR Code/PRODUCTION/labrador-ba94.elf.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-13a8f78b24a1efe08d7e032557c1e4705ee3cede
\ No newline at end of file
diff --git a/AVR Code/PRODUCTION/labrador.elf.REMOVED.git-id b/AVR Code/PRODUCTION/labrador.elf.REMOVED.git-id
deleted file mode 100644
index 37fa2544..00000000
--- a/AVR Code/PRODUCTION/labrador.elf.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6045df59563c016446f7f75c6ab08fefad8be790
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST.atsln b/AVR Code/USB_BULK_TEST.atsln
new file mode 100644
index 00000000..39d696da
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST.atsln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Atmel Studio Solution File, Format Version 11.00
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "USB_BULK_TEST", "USB_BULK_TEST\USB_BULK_TEST.cproj", "{BD2AA8D9-491B-4ECD-9255-825EAABC7BA4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|AVR = Debug|AVR
+ Release|AVR = Release|AVR
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BD2AA8D9-491B-4ECD-9255-825EAABC7BA4}.Debug|AVR.ActiveCfg = Debug|AVR
+ {BD2AA8D9-491B-4ECD-9255-825EAABC7BA4}.Debug|AVR.Build.0 = Debug|AVR
+ {BD2AA8D9-491B-4ECD-9255-825EAABC7BA4}.Release|AVR.ActiveCfg = Release|AVR
+ {BD2AA8D9-491B-4ECD-9255-825EAABC7BA4}.Release|AVR.Build.0 = Release|AVR
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/AVR Code/USB_BULK_TEST.atsln.REMOVED.git-id b/AVR Code/USB_BULK_TEST.atsln.REMOVED.git-id
deleted file mode 100644
index 1e669861..00000000
--- a/AVR Code/USB_BULK_TEST.atsln.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-39d696da99993e89d69ed499ff1514c0556104ce
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST.atsuo b/AVR Code/USB_BULK_TEST.atsuo
new file mode 100644
index 00000000..d20afbd3
Binary files /dev/null and b/AVR Code/USB_BULK_TEST.atsuo differ
diff --git a/AVR Code/USB_BULK_TEST.atsuo.REMOVED.git-id b/AVR Code/USB_BULK_TEST.atsuo.REMOVED.git-id
deleted file mode 100644
index a031f993..00000000
--- a/AVR Code/USB_BULK_TEST.atsuo.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d20afbd372a73154b5b74452dced748255ec0578
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/Makefile.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/Makefile.REMOVED.git-id
deleted file mode 100644
index 0015dfb8..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/Makefile.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5d9342282bd9e5cec14a00dafa34e65566dc75ac
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.eep.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.eep.REMOVED.git-id
deleted file mode 100644
index bd662121..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.eep.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7c166a13c19d7811fbf00e7e334ad40eebfcbe2f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.elf.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.elf.REMOVED.git-id
deleted file mode 100644
index e16e4a8d..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.elf.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b32256faf53600ebdbacbf778dd4e755479c7b3a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.hex.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.hex.REMOVED.git-id
deleted file mode 100644
index 2085bbb2..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-728e9e5182f1248d37038474b5ef358f03e0a546
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.lss.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.lss.REMOVED.git-id
deleted file mode 100644
index bfbb5507..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.lss.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8e4d695e19a7cdfd133c4cb5fcf596214dd4fdca
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.map.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.map.REMOVED.git-id
deleted file mode 100644
index 1371f591..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.map.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-620b84bbb4a02f9e1b0fa4d5dac1f2f17a245932
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.srec.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.srec.REMOVED.git-id
deleted file mode 100644
index d65d6cdb..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/USB_BULK_TEST.srec.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c7bf90f8efb130b20ca372c7084ccf3915d91c8b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/makedep.mk.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/makedep.mk.REMOVED.git-id
deleted file mode 100644
index 933cec14..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/makedep.mk.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-39b6d418feb9451846091d4f8b02f6178b662787
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/boards/user_board/init.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/boards/user_board/init.d.REMOVED.git-id
deleted file mode 100644
index ef880328..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/boards/user_board/init.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-72fbb82ce899ecad41ea37b50a819b78b770f2b7
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/boards/user_board/init.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/boards/user_board/init.o.REMOVED.git-id
deleted file mode 100644
index 40705846..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/boards/user_board/init.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-106c90d2b446ea3de5a2aee9695225011d7cf748
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/clock/xmega/sysclk.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/clock/xmega/sysclk.d.REMOVED.git-id
deleted file mode 100644
index 0db57f92..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/clock/xmega/sysclk.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-35c4a6114f3c290992adedd53336a50f9efcc07f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/clock/xmega/sysclk.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/clock/xmega/sysclk.o.REMOVED.git-id
deleted file mode 100644
index e39d2e04..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/clock/xmega/sysclk.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a634afecc1826672afd7af866395930f8817767a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/ioport/xmega/ioport_compat.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/ioport/xmega/ioport_compat.d.REMOVED.git-id
deleted file mode 100644
index b4ce3e97..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/ioport/xmega/ioport_compat.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1d491823486282983c2b92e7ef9e078815c716fa
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/ioport/xmega/ioport_compat.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/ioport/xmega/ioport_compat.o.REMOVED.git-id
deleted file mode 100644
index f18fcc1e..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/ioport/xmega/ioport_compat.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c8ca9c133746a4917c48bab12e52d4a1b84af99d
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/sleepmgr/xmega/sleepmgr.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/sleepmgr/xmega/sleepmgr.d.REMOVED.git-id
deleted file mode 100644
index 4e7a0338..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/sleepmgr/xmega/sleepmgr.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-37537db1ec527dd9a123a966a0566fdfb61e3af2
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/sleepmgr/xmega/sleepmgr.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/sleepmgr/xmega/sleepmgr.o.REMOVED.git-id
deleted file mode 100644
index 302f9a75..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/sleepmgr/xmega/sleepmgr.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-67b1d35612797655dc0064b66805ac82e44c6769
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d.REMOVED.git-id
deleted file mode 100644
index 22bd9599..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5c4260aaa0a3c3306e4bc5698404578231239c88
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o.REMOVED.git-id
deleted file mode 100644
index 0c30e57f..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a8f9116279c3229297d8b012dc38ca1fa3583396
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor.d.REMOVED.git-id
deleted file mode 100644
index b4d0b248..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-db3dd5ec2c5ff9b5e199751b90feb91577d00b11
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor.o.REMOVED.git-id
deleted file mode 100644
index b483d4a2..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-29a1b7abf2baf31b14db89d0f828f3e3da89786f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d.REMOVED.git-id
deleted file mode 100644
index 980f2301..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-94cc3abb6ddb957afcb7e6b81990adcecbda0090
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o.REMOVED.git-id
deleted file mode 100644
index 61cbc58c..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ad7b70be963700678586e89d9baa4701680ee6d1
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/udc/udc.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/udc/udc.d.REMOVED.git-id
deleted file mode 100644
index 7384c559..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/udc/udc.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ed7f4d2d45a89f270dc9d0aaffd0a75e8fb2090d
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/udc/udc.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/udc/udc.o.REMOVED.git-id
deleted file mode 100644
index f1f829c7..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/common/services/usb/udc/udc.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-92ada3896e0c9de0fa0cf921fbb5c4165204855b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/cpu/ccp.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/cpu/ccp.d.REMOVED.git-id
deleted file mode 100644
index c70bbd21..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/cpu/ccp.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9eed18c8185f635ec502905bee11ad12eb105a02
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/cpu/ccp.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/cpu/ccp.o.REMOVED.git-id
deleted file mode 100644
index beee8639..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/cpu/ccp.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fd457ecf9238b3ac1068e0c00b5b245843fa4d7e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm.d.REMOVED.git-id
deleted file mode 100644
index 0cced544..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7efcb915d6cf7f829757ac7b0ab0c5cc21597e71
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm.o.REMOVED.git-id
deleted file mode 100644
index 7ce57de7..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1a78298dc01d42dc58f7307c77d81f294f4a5145
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm_asm.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm_asm.d.REMOVED.git-id
deleted file mode 100644
index 9e08b412..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm_asm.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f222d9bd3f855a764a788c74efa9ac2cc1a27ef2
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm_asm.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm_asm.o.REMOVED.git-id
deleted file mode 100644
index bb74f8f2..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/nvm/nvm_asm.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f3db8dacf8f538915f10b968296d76b1332e0e5e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/usb/usb_device.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/usb/usb_device.d.REMOVED.git-id
deleted file mode 100644
index cd25aa15..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/usb/usb_device.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-75c961d1aea87e51d5c99e624a25a0235986f34e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/usb/usb_device.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/usb/usb_device.o.REMOVED.git-id
deleted file mode 100644
index 941c78b8..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/ASF/xmega/drivers/usb/usb_device.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-91eaced37dea3f9ac59df57d58ab2908eef8f9d8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/main.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/main.d.REMOVED.git-id
deleted file mode 100644
index 8423483f..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/main.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3639cd654ea38e37377dbc81928b7f05d9216fa1
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/main.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/main.o.REMOVED.git-id
deleted file mode 100644
index 6bcc4585..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/main.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b7ad4d7b5b09b6912c087929dbe8db05116670b8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_adc.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_adc.d.REMOVED.git-id
deleted file mode 100644
index d0b7aad2..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_adc.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d08a1c880873ec3b5fa541c0b3466acef46d5044
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_adc.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_adc.o.REMOVED.git-id
deleted file mode 100644
index 62c9d0dd..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_adc.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ff8f06d883ba5bc77c2ce555406a58755a66c439
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_calibration.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_calibration.d.REMOVED.git-id
deleted file mode 100644
index 29ddb797..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_calibration.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-039191a18d85f2d70c16b9028a87eb7f8f30d581
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_calibration.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_calibration.o.REMOVED.git-id
deleted file mode 100644
index 10a96eee..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_calibration.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3cde6c7b1491f21ca8360fbb38d2452b3356fbd2
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dac.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_dac.d.REMOVED.git-id
deleted file mode 100644
index 16863e56..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dac.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-bb5ffab188c34a323ab96531806e6f36a706d136
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dac.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_dac.o.REMOVED.git-id
deleted file mode 100644
index bdee88e6..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dac.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-349444cadd03a4f09868d01b5de9c8ae3059802f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dig.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_dig.d.REMOVED.git-id
deleted file mode 100644
index 3308c0d5..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dig.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4b21c82a3e6ad5103ca9d8c4149d529aa993fe8a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dig.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_dig.o.REMOVED.git-id
deleted file mode 100644
index 8dac18c5..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dig.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b795b5c9f284f51d3c3017c7a63c5602daac0a1e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dma.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_dma.d.REMOVED.git-id
deleted file mode 100644
index bd91a5f1..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dma.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8a50f8ad90c2036f98e82aa782133b1b2ad0c036
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dma.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_dma.o.REMOVED.git-id
deleted file mode 100644
index 48f0f843..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_dma.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7f6d2cde9ffb4bdb92262847aa3b79098a0af4d8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_eeprom.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_eeprom.d.REMOVED.git-id
deleted file mode 100644
index 24a9ad0d..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_eeprom.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-287cf5d9efef1dbb7d415cefeb99d0e5644dd92f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_eeprom.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_eeprom.o.REMOVED.git-id
deleted file mode 100644
index babbfdcd..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_eeprom.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-82c983dfd5c509530561c2243b26d887bfe69368
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_timer.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_timer.d.REMOVED.git-id
deleted file mode 100644
index e215d95b..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_timer.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4882e9999d78dadae5e743313359febd8406e18f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_timer.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_timer.o.REMOVED.git-id
deleted file mode 100644
index 9ffdda82..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_timer.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b81730484a5a8d482abe13b74fa81294b1fa8e62
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_uart.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_uart.d.REMOVED.git-id
deleted file mode 100644
index f8f4fc12..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_uart.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-aee87ec58561da038369a2e7bbabf2cc40d723f8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Debug/src/tiny_uart.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Debug/src/tiny_uart.o.REMOVED.git-id
deleted file mode 100644
index a4df1b7d..00000000
--- a/AVR Code/USB_BULK_TEST/Debug/src/tiny_uart.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-aba99b4cd260dc07166e879897f840366a15badb
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/Makefile.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/Makefile.REMOVED.git-id
deleted file mode 100644
index 9360a732..00000000
--- a/AVR Code/USB_BULK_TEST/Release/Makefile.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6cc08fb8d835e5eb776bfd1851c9b1e1245a58a2
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.eep.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.eep.REMOVED.git-id
deleted file mode 100644
index bd662121..00000000
--- a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.eep.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7c166a13c19d7811fbf00e7e334ad40eebfcbe2f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.elf.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.elf.REMOVED.git-id
deleted file mode 100644
index ff002924..00000000
--- a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.elf.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9f89cf82ce049475369780f2a0cdc02be513c2d5
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.hex.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.hex.REMOVED.git-id
deleted file mode 100644
index 42c42b45..00000000
--- a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-879125a9685d89a7f05bd38994079919338f49b6
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.lss.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.lss.REMOVED.git-id
deleted file mode 100644
index ef852a03..00000000
--- a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.lss.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b406b76b903a439b21fce909991ba737bda29cfc
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.map.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.map.REMOVED.git-id
deleted file mode 100644
index 0a80c0ad..00000000
--- a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.map.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0fec8ec9acb97731a04a8baa7901c4c0c8ca84c8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.srec.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.srec.REMOVED.git-id
deleted file mode 100644
index 9af282c3..00000000
--- a/AVR Code/USB_BULK_TEST/Release/USB_BULK_TEST.srec.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f2c7a9e7828b9e65490e84fdcd77a805711b35f7
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/makedep.mk.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/makedep.mk.REMOVED.git-id
deleted file mode 100644
index 933cec14..00000000
--- a/AVR Code/USB_BULK_TEST/Release/makedep.mk.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-39b6d418feb9451846091d4f8b02f6178b662787
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/boards/user_board/init.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/boards/user_board/init.d.REMOVED.git-id
deleted file mode 100644
index ef880328..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/boards/user_board/init.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-72fbb82ce899ecad41ea37b50a819b78b770f2b7
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/boards/user_board/init.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/boards/user_board/init.o.REMOVED.git-id
deleted file mode 100644
index b0045558..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/boards/user_board/init.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-904c1b6e11e9f116a364b731be8b410c7856a501
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/clock/xmega/sysclk.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/clock/xmega/sysclk.d.REMOVED.git-id
deleted file mode 100644
index 0db57f92..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/clock/xmega/sysclk.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-35c4a6114f3c290992adedd53336a50f9efcc07f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/clock/xmega/sysclk.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/clock/xmega/sysclk.o.REMOVED.git-id
deleted file mode 100644
index b75aeaaa..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/clock/xmega/sysclk.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0b7967a50932626d89f597638c94a816e7f4c127
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/ioport/xmega/ioport_compat.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/ioport/xmega/ioport_compat.d.REMOVED.git-id
deleted file mode 100644
index b4ce3e97..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/ioport/xmega/ioport_compat.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1d491823486282983c2b92e7ef9e078815c716fa
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/ioport/xmega/ioport_compat.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/ioport/xmega/ioport_compat.o.REMOVED.git-id
deleted file mode 100644
index b3fd54e0..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/ioport/xmega/ioport_compat.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ab55998976e607fdbda8724521b9b5d456ddddc8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/sleepmgr/xmega/sleepmgr.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/sleepmgr/xmega/sleepmgr.d.REMOVED.git-id
deleted file mode 100644
index 4e7a0338..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/sleepmgr/xmega/sleepmgr.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-37537db1ec527dd9a123a966a0566fdfb61e3af2
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/sleepmgr/xmega/sleepmgr.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/sleepmgr/xmega/sleepmgr.o.REMOVED.git-id
deleted file mode 100644
index 9dd0a346..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/sleepmgr/xmega/sleepmgr.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-83b8226444b433f0a7a6815c351e0a92133015bf
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d.REMOVED.git-id
deleted file mode 100644
index 22bd9599..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5c4260aaa0a3c3306e4bc5698404578231239c88
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o.REMOVED.git-id
deleted file mode 100644
index 16bd0182..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d0b23ad47eb219e319a766a123413fb04dd902ed
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor.d.REMOVED.git-id
deleted file mode 100644
index b4d0b248..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-db3dd5ec2c5ff9b5e199751b90feb91577d00b11
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor.o.REMOVED.git-id
deleted file mode 100644
index 0e505b52..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-80e4467cac19d50a8a8ae90b01e08786e93fd6b0
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d.REMOVED.git-id
deleted file mode 100644
index 980f2301..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-94cc3abb6ddb957afcb7e6b81990adcecbda0090
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o.REMOVED.git-id
deleted file mode 100644
index c15b2c3e..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c48edfecfcd7085d51768de1a167caf4060367d5
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/udc/udc.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/udc/udc.d.REMOVED.git-id
deleted file mode 100644
index 7384c559..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/udc/udc.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ed7f4d2d45a89f270dc9d0aaffd0a75e8fb2090d
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/udc/udc.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/udc/udc.o.REMOVED.git-id
deleted file mode 100644
index eebfee2f..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/common/services/usb/udc/udc.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8954d0cefbff2cd0892b4e4301a5f8f2169d1f4f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/cpu/ccp.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/cpu/ccp.d.REMOVED.git-id
deleted file mode 100644
index c70bbd21..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/cpu/ccp.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9eed18c8185f635ec502905bee11ad12eb105a02
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/cpu/ccp.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/cpu/ccp.o.REMOVED.git-id
deleted file mode 100644
index 69651235..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/cpu/ccp.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-34a0448329bf456d5a69b62e952372ad2753d907
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm.d.REMOVED.git-id
deleted file mode 100644
index 0cced544..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7efcb915d6cf7f829757ac7b0ab0c5cc21597e71
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm.o.REMOVED.git-id
deleted file mode 100644
index 18ebd9f6..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-80c6b3b9275c7220f0520e5f52dee1fd13b32a75
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm_asm.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm_asm.d.REMOVED.git-id
deleted file mode 100644
index 9e08b412..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm_asm.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f222d9bd3f855a764a788c74efa9ac2cc1a27ef2
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm_asm.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm_asm.o.REMOVED.git-id
deleted file mode 100644
index 66128843..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/nvm/nvm_asm.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-33efe4841140e2530d145e3fde7113ad9ad7ce78
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/usb/usb_device.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/usb/usb_device.d.REMOVED.git-id
deleted file mode 100644
index cd25aa15..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/usb/usb_device.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-75c961d1aea87e51d5c99e624a25a0235986f34e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/usb/usb_device.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/usb/usb_device.o.REMOVED.git-id
deleted file mode 100644
index a643d895..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/ASF/xmega/drivers/usb/usb_device.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d76c48c10c1c1bd2b19e7703cdcf4980734d7a31
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/main.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/main.d.REMOVED.git-id
deleted file mode 100644
index 8423483f..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/main.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3639cd654ea38e37377dbc81928b7f05d9216fa1
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/main.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/main.o.REMOVED.git-id
deleted file mode 100644
index 5f33dbb8..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/main.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b5ba5743bf2540bd9cdf6ed001dd3019eaf8359f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_adc.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_adc.d.REMOVED.git-id
deleted file mode 100644
index d0b7aad2..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_adc.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d08a1c880873ec3b5fa541c0b3466acef46d5044
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_adc.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_adc.o.REMOVED.git-id
deleted file mode 100644
index f278269f..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_adc.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5239cd1fd850fc8a6327ebda1a2dee46fd18975a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_calibration.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_calibration.d.REMOVED.git-id
deleted file mode 100644
index 29ddb797..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_calibration.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-039191a18d85f2d70c16b9028a87eb7f8f30d581
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_calibration.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_calibration.o.REMOVED.git-id
deleted file mode 100644
index 2f4b5f99..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_calibration.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9f652f5c817f655f59165abd62e6c26537fe8ced
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_dac.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_dac.d.REMOVED.git-id
deleted file mode 100644
index 16863e56..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_dac.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-bb5ffab188c34a323ab96531806e6f36a706d136
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_dac.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_dac.o.REMOVED.git-id
deleted file mode 100644
index e816e23e..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_dac.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6dd71268fb79a36cb4eebacdefed1263e1be67c0
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_dig.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_dig.d.REMOVED.git-id
deleted file mode 100644
index 3308c0d5..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_dig.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4b21c82a3e6ad5103ca9d8c4149d529aa993fe8a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_dig.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_dig.o.REMOVED.git-id
deleted file mode 100644
index 4a18f78c..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_dig.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-06501cb01524911283dc083e386b8643c8d3e888
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_dma.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_dma.d.REMOVED.git-id
deleted file mode 100644
index bd91a5f1..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_dma.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8a50f8ad90c2036f98e82aa782133b1b2ad0c036
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_dma.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_dma.o.REMOVED.git-id
deleted file mode 100644
index ea9b1877..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_dma.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fdbd27679843541577b42a06247a4da86d163398
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_eeprom.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_eeprom.d.REMOVED.git-id
deleted file mode 100644
index 24a9ad0d..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_eeprom.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-287cf5d9efef1dbb7d415cefeb99d0e5644dd92f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_eeprom.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_eeprom.o.REMOVED.git-id
deleted file mode 100644
index e476e53c..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_eeprom.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-edaabceaf58b981d808753b9651f0d8ef73a7e57
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_timer.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_timer.d.REMOVED.git-id
deleted file mode 100644
index e215d95b..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_timer.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4882e9999d78dadae5e743313359febd8406e18f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_timer.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_timer.o.REMOVED.git-id
deleted file mode 100644
index a0652b10..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_timer.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6f1d433f15b166a9f29457c53e8e8f80240820fa
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_uart.d.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_uart.d.REMOVED.git-id
deleted file mode 100644
index f8f4fc12..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_uart.d.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-aee87ec58561da038369a2e7bbabf2cc40d723f8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/Release/src/tiny_uart.o.REMOVED.git-id b/AVR Code/USB_BULK_TEST/Release/src/tiny_uart.o.REMOVED.git-id
deleted file mode 100644
index 262fb629..00000000
--- a/AVR Code/USB_BULK_TEST/Release/src/tiny_uart.o.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1dc4f7c23a085ecf71dfc00bfecf9d8dbbd50adb
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/USB_BULK_TEST.componentinfo.xml b/AVR Code/USB_BULK_TEST/USB_BULK_TEST.componentinfo.xml
new file mode 100644
index 00000000..958c6281
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/USB_BULK_TEST.componentinfo.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+ Device
+ Startup
+
+
+ Atmel
+ 1.0.0
+ C:/Program Files (x86)\Atmel\Studio\7.0\Packs
+
+
+
+
+ C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\XMEGAA_DFP\1.0.39\include
+
+ include
+ C
+
+
+ include
+
+
+
+
+ C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\XMEGAA_DFP\1.0.39\include\avr\iox32a4u.h
+
+ header
+ C
+ KyiKDrCTHLqSzerM5JnazQ==
+
+ include/avr/iox32a4u.h
+
+
+
+
+ C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\XMEGAA_DFP\1.0.39\templates\main.c
+ template
+ source
+ C Exe
+ GD1k8YYhulqRs6FD1B2Hog==
+
+ templates/main.c
+ Main file (.c)
+
+
+
+ C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\XMEGAA_DFP\1.0.39\templates\main.cpp
+ template
+ source
+ C Exe
+ YXFphlh0CtZJU+ebktABgQ==
+
+ templates/main.cpp
+ Main file (.cpp)
+
+
+
+ C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\XMEGAA_DFP\1.0.39\gcc\dev\atxmega32a4u
+
+ libraryPrefix
+ GCC
+
+
+ gcc/dev/atxmega32a4u
+
+
+
+
+ XMEGAA_DFP
+ C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/XMEGAA_DFP/1.0.39/Atmel.XMEGAA_DFP.pdsc
+ 1.0.39
+ true
+ ATxmega32A4U
+
+
+
+ Resolved
+ Fixed
+ true
+
+
+
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/USB_BULK_TEST.componentinfo.xml.REMOVED.git-id b/AVR Code/USB_BULK_TEST/USB_BULK_TEST.componentinfo.xml.REMOVED.git-id
deleted file mode 100644
index 7b52dce9..00000000
--- a/AVR Code/USB_BULK_TEST/USB_BULK_TEST.componentinfo.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-958c62813dfddca94844c415ca12b0fdd460e317
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/USB_BULK_TEST.cproj b/AVR Code/USB_BULK_TEST/USB_BULK_TEST.cproj
new file mode 100644
index 00000000..7f53efbd
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/USB_BULK_TEST.cproj
@@ -0,0 +1,594 @@
+
+
+
+ 2.0
+ 7.0
+ com.Atmel.AVRGCC8.C
+ {bd2aa8d9-491b-4ecd-9255-825eaabc7ba4}
+ atxmega32a4u
+ xmegaau
+ Executable
+ C
+ $(MSBuildProjectName)
+ .elf
+ $(MSBuildProjectDirectory)\$(Configuration)
+ USB_BULK_TEST
+ USB_BULK_TEST
+ USB_BULK_TEST
+ Native
+ true
+ false
+ true
+ true
+ 0x20000000
+
+ true
+ exception_table
+ 2
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.atmel.avrdbg.tool.atmelice
+
+
+
+ 4000000
+ 7500000
+
+ PDI
+
+ com.atmel.avrdbg.tool.atmelice
+ J41800006314
+ Atmel-ICE
+
+ PDI
+
+
+
+
+ PDI
+
+ com.atmel.avrdbg.tool.simulator
+
+
+ Simulator
+
+ J41800006314
+ 0x1E9541
+ 4000000
+
+
+
+
+ -mmcu=atxmega32a4u -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.0.39\gcc\dev\atxmega32a4u"
+ True
+ True
+ True
+ True
+ True
+ False
+
+
+ NDEBUG
+ BOARD=USER_BOARD
+
+
+
+
+ ../common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained
+ ../common/services/usb/class/vendor/device/example
+ ../src/ASF/common/services/usb/udc
+ ../src/ASF/xmega/drivers/nvm
+ ../src/ASF/common/services/sleepmgr
+ ../src/ASF/common/services/clock
+ ../src/ASF/xmega/drivers/sleep
+ ../src/ASF/xmega/drivers/usb
+ ../src/ASF/xmega/drivers/cpu
+ ../src/ASF/common/services/usb/class/vendor
+ ../src/ASF/common/services/usb/class/vendor/device
+ ../src/ASF/common/services/usb
+ ../common/applications/user_application/user_board/config
+ ../src/ASF/xmega/utils
+ ../src/config
+ ../src/ASF/common/boards
+ ../src/ASF/xmega/utils/preprocessor
+ ../src/ASF/common/utils
+ ../src
+ ../src/ASF/common/boards/user_board
+ ../src/ASF/common/services/ioport
+ %24(PackRepoDir)\atmel\XMEGAA_DFP\1.0.39\include
+
+
+ Optimize for size (-Os)
+ -fdata-sections
+ True
+ True
+ True
+ -std=gnu99 -fno-strict-aliasing -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax
+
+
+ libm
+
+
+ -Wl,--relax
+ -mrelax -DBOARD=USER_BOARD
+
+
+ ../common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained
+ ../common/services/usb/class/vendor/device/example
+ ../src/ASF/common/services/usb/udc
+ ../src/ASF/xmega/drivers/nvm
+ ../src/ASF/common/services/sleepmgr
+ ../src/ASF/common/services/clock
+ ../src/ASF/xmega/drivers/sleep
+ ../src/ASF/xmega/drivers/usb
+ ../src/ASF/xmega/drivers/cpu
+ ../src/ASF/common/services/usb/class/vendor
+ ../src/ASF/common/services/usb/class/vendor/device
+ ../src/ASF/common/services/usb
+ ../common/applications/user_application/user_board/config
+ ../src/ASF/xmega/utils
+ ../src/config
+ ../src/ASF/common/boards
+ ../src/ASF/xmega/utils/preprocessor
+ ../src/ASF/common/utils
+ ../src
+ ../src/ASF/common/boards/user_board
+ ../src/ASF/common/services/ioport
+ %24(PackRepoDir)\atmel\XMEGAA_DFP\1.0.39\include
+
+
+
+
+
+
+
+
+ -mmcu=atxmega32a4u -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.0.39\gcc\dev\atxmega32a4u"
+ True
+ True
+ True
+ True
+ True
+ False
+
+
+ DEBUG
+ BOARD=USER_BOARD
+
+
+
+
+ ../common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained
+ ../common/services/usb/class/vendor/device/example
+ ../src/ASF/common/services/usb/udc
+ ../src/ASF/xmega/drivers/nvm
+ ../src/ASF/common/services/sleepmgr
+ ../src/ASF/common/services/clock
+ ../src/ASF/xmega/drivers/sleep
+ ../src/ASF/xmega/drivers/usb
+ ../src/ASF/xmega/drivers/cpu
+ ../src/ASF/common/services/usb/class/vendor
+ ../src/ASF/common/services/usb/class/vendor/device
+ ../src/ASF/common/services/usb
+ ../common/applications/user_application/user_board/config
+ ../src/ASF/xmega/utils
+ ../src/config
+ ../src/ASF/common/boards
+ ../src/ASF/xmega/utils/preprocessor
+ ../src/ASF/common/utils
+ ../src
+ ../src/ASF/common/boards/user_board
+ ../src/ASF/common/services/ioport
+ %24(PackRepoDir)\atmel\XMEGAA_DFP\1.0.39\include
+
+
+ Optimize (-O1)
+ -fdata-sections
+ True
+ True
+ Maximum (-g3)
+ True
+ -std=gnu99 -fno-strict-aliasing -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax
+
+
+ libm
+
+
+ -Wl,--relax
+ -mrelax -DBOARD=USER_BOARD
+
+
+ ../common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained
+ ../common/services/usb/class/vendor/device/example
+ ../src/ASF/common/services/usb/udc
+ ../src/ASF/xmega/drivers/nvm
+ ../src/ASF/common/services/sleepmgr
+ ../src/ASF/common/services/clock
+ ../src/ASF/xmega/drivers/sleep
+ ../src/ASF/xmega/drivers/usb
+ ../src/ASF/xmega/drivers/cpu
+ ../src/ASF/common/services/usb/class/vendor
+ ../src/ASF/common/services/usb/class/vendor/device
+ ../src/ASF/common/services/usb
+ ../common/applications/user_application/user_board/config
+ ../src/ASF/xmega/utils
+ ../src/config
+ ../src/ASF/common/boards
+ ../src/ASF/xmega/utils/preprocessor
+ ../src/ASF/common/utils
+ ../src
+ ../src/ASF/common/boards/user_board
+ ../src/ASF/common/services/ioport
+ %24(PackRepoDir)\atmel\XMEGAA_DFP\1.0.39\include
+
+
+ Default (-Wa,-g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+ compile
+
+
+
+
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/USB_BULK_TEST.cproj.REMOVED.git-id b/AVR Code/USB_BULK_TEST/USB_BULK_TEST.cproj.REMOVED.git-id
deleted file mode 100644
index 5f4fdb37..00000000
--- a/AVR Code/USB_BULK_TEST/USB_BULK_TEST.cproj.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7f53efbdce024f6fdff72d3aab71b56e7ac9f5df
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/USB_BULK_TEST_6_2.cproj.REMOVED.git-id b/AVR Code/USB_BULK_TEST/USB_BULK_TEST_6_2.cproj.REMOVED.git-id
deleted file mode 100644
index ff4ec4a9..00000000
--- a/AVR Code/USB_BULK_TEST/USB_BULK_TEST_6_2.cproj.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-66ffcb4ccf5a4f2e63134282d64a4e2da1d0a35e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/board.h b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/board.h
new file mode 100644
index 00000000..63d76ae9
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/board.h
@@ -0,0 +1,398 @@
+/**
+ * \file
+ *
+ * \brief Standard board header file.
+ *
+ * This file includes the appropriate board header file according to the
+ * defined board (parameter BOARD).
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+/**
+ * \defgroup group_common_boards Generic board support
+ *
+ * The generic board support module includes board-specific definitions
+ * and function prototypes, such as the board initialization function.
+ *
+ * \{
+ */
+
+#include "compiler.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*! \name Base Boards
+ */
+//! @{
+#define EVK1100 1 //!< AT32UC3A EVK1100 board.
+#define EVK1101 2 //!< AT32UC3B EVK1101 board.
+#define UC3C_EK 3 //!< AT32UC3C UC3C-EK board.
+#define EVK1104 4 //!< AT32UC3A3 EVK1104 board.
+#define EVK1105 5 //!< AT32UC3A EVK1105 board.
+#define STK600_RCUC3L0 6 //!< STK600 RCUC3L0 board.
+#define UC3L_EK 7 //!< AT32UC3L-EK board.
+#define XPLAIN 8 //!< ATxmega128A1 Xplain board.
+#define STK600_RC064X 10 //!< ATxmega256A3 STK600 board.
+#define STK600_RC100X 11 //!< ATxmega128A1 STK600 board.
+#define UC3_A3_XPLAINED 13 //!< ATUC3A3 UC3-A3 Xplained board.
+#define UC3_L0_XPLAINED 15 //!< ATUC3L0 UC3-L0 Xplained board.
+#define STK600_RCUC3D 16 //!< STK600 RCUC3D board.
+#define STK600_RCUC3C0 17 //!< STK600 RCUC3C board.
+#define XMEGA_B1_XPLAINED 18 //!< ATxmega128B1 Xplained board.
+#define XMEGA_A1_XPLAINED 19 //!< ATxmega128A1 Xplain-A1 board.
+#define XMEGA_A1U_XPLAINED_PRO 20 //!< ATxmega128A1U XMEGA-A1U Xplained Pro board.
+#define STK600_RCUC3L4 21 //!< ATUCL4 STK600 board.
+#define UC3_L0_XPLAINED_BC 22 //!< ATUC3L0 UC3-L0 Xplained board controller board.
+#define MEGA1284P_XPLAINED_BC 23 //!< ATmega1284P-Xplained board controller board.
+#define STK600_RC044X 24 //!< STK600 with RC044X routing card board.
+#define STK600_RCUC3B0 25 //!< STK600 RCUC3B0 board.
+#define UC3_L0_QT600 26 //!< QT600 UC3L0 MCU board.
+#define XMEGA_A3BU_XPLAINED 27 //!< ATxmega256A3BU Xplained board.
+#define STK600_RC064X_LCDX 28 //!< XMEGAB3 STK600 RC064X LCDX board.
+#define STK600_RC100X_LCDX 29 //!< XMEGAB1 STK600 RC100X LCDX board.
+#define UC3B_BOARD_CONTROLLER 30 //!< AT32UC3B1 board controller for Atmel boards.
+#define RZ600 31 //!< AT32UC3A RZ600 MCU board.
+#define SAM3S_EK 32 //!< SAM3S-EK board.
+#define SAM3U_EK 33 //!< SAM3U-EK board.
+#define SAM3X_EK 34 //!< SAM3X-EK board.
+#define SAM3N_EK 35 //!< SAM3N-EK board.
+#define SAM3S_EK2 36 //!< SAM3S-EK2 board.
+#define SAM4S_EK 37 //!< SAM4S-EK board.
+#define STK600_RCUC3A0 38 //!< STK600 RCUC3A0 board.
+#define STK600_MEGA 39 //!< STK600 MEGA board.
+#define MEGA_1284P_XPLAINED 40 //!< ATmega1284P Xplained board.
+#define SAM4S_XPLAINED 41 //!< SAM4S Xplained board.
+#define ATXMEGA128A1_QT600 42 //!< QT600 ATXMEGA128A1 MCU board.
+#define ARDUINO_DUE_X 43 //!< Arduino Due/X board.
+#define STK600_RCUC3L3 44 //!< ATUCL3 STK600 board.
+#define SAM4L_EK 45 //!< SAM4L-EK board.
+#define STK600_MEGA_RF 46 //!< STK600 MEGA RF EVK board.
+#define XMEGA_C3_XPLAINED 47 //!< ATxmega384C3 Xplained board.
+#define STK600_RC032X 48 //!< STK600 with RC032X routing card board.
+#define SAM4S_EK2 49 //!< SAM4S-EK2 board.
+#define XMEGA_E5_XPLAINED 50 //!< ATxmega32E5 Xplained board.
+#define SAM4E_EK 51 //!< SAM4E-EK board.
+#define ATMEGA256RFR2_XPLAINED_PRO 52 //!< ATmega256RFR2 Xplained Pro board.
+#define SAM4S_XPLAINED_PRO 53 //!< SAM4S Xplained Pro board.
+#define SAM4L_XPLAINED_PRO 54 //!< SAM4L Xplained Pro board.
+#define ATMEGA256RFR2_ZIGBIT 55 //!< ATmega256RFR2 zigbit.
+#define XMEGA_RF233_ZIGBIT 56 //!< ATxmega256A3U with AT86RF233 Zigbit.
+#define XMEGA_RF212B_ZIGBIT 57 //!< ATxmega256A3U with AT86RF212B Zigbit.
+#define SAM4S_WPIR_RD 58 //!< SAM4S-WPIR-RD board.
+#define SAMD20_XPLAINED_PRO 59 //!< SAM D20 Xplained Pro board.
+#define SAM4L8_XPLAINED_PRO 60 //!< SAM4L8 Xplained Pro board.
+#define SAM4N_XPLAINED_PRO 61 //!< SAM4N Xplained Pro board.
+#define XMEGA_A3_REB_CBB 62 //!< XMEGA REB Controller Base board.
+#define ATMEGARFX_RCB 63 //!< RFR2 & RFA1 RCB.
+#define SAM4C_EK 64 //!< SAM4C-EK board.
+#define RCB256RFR2_XPRO 65 //!< RFR2 RCB Xplained Pro board.
+#define SAMG53_XPLAINED_PRO 66 //!< SAMG53 Xplained Pro board.
+#define SAM4CP16BMB 67 //!< SAM4CP16BMB board.
+#define SAM4E_XPLAINED_PRO 68 //!< SAM4E Xplained Pro board.
+#define SAMD21_XPLAINED_PRO 69 //!< SAM D21 Xplained Pro board.
+#define SAMR21_XPLAINED_PRO 70 //!< SAM R21 Xplained Pro board.
+#define SAM4CMP_DB 71 //!< SAM4CMP demo board.
+#define SAM4CMS_DB 72 //!< SAM4CMS demo board.
+#define ATPL230AMB 73 //!< ATPL230AMB board.
+#define SAMD11_XPLAINED_PRO 74 //!< SAM D11 Xplained Pro board.
+#define SAMG55_XPLAINED_PRO 75 //!< SAMG55 Xplained Pro board.
+#define SAML21_XPLAINED_PRO 76 //!< SAM L21 Xplained Pro board.
+#define SAMD10_XPLAINED_MINI 77 //!< SAM D10 Xplained Mini board.
+#define SAMW25_XPLAINED_PRO 79 //!< SAMW25 Xplained Pro board.
+#define SIMULATOR_XMEGA_A1 97 //!< Simulator for XMEGA A1 devices.
+#define AVR_SIMULATOR_UC3 98 //!< Simulator for the AVR UC3 device family.
+#define USER_BOARD 99 //!< User-reserved board (if any).
+#define DUMMY_BOARD 100 //!< Dummy board to support board-independent applications (e.g. bootloader).
+//! @}
+
+/*! \name Extension Boards
+ */
+//! @{
+#define EXT1102 1 //!< AT32UC3B EXT1102 board
+#define MC300 2 //!< AT32UC3 MC300 board
+#define SENSORS_XPLAINED_INERTIAL_1 3 //!< Xplained inertial sensor board 1
+#define SENSORS_XPLAINED_INERTIAL_2 4 //!< Xplained inertial sensor board 2
+#define SENSORS_XPLAINED_PRESSURE_1 5 //!< Xplained pressure sensor board
+#define SENSORS_XPLAINED_LIGHTPROX_1 6 //!< Xplained light & proximity sensor board
+#define SENSORS_XPLAINED_INERTIAL_A1 7 //!< Xplained inertial sensor board "A"
+#define RZ600_AT86RF231 8 //!< AT86RF231 RF board in RZ600
+#define RZ600_AT86RF230B 9 //!< AT86RF230B RF board in RZ600
+#define RZ600_AT86RF212 10 //!< AT86RF212 RF board in RZ600
+#define SENSORS_XPLAINED_BREADBOARD 11 //!< Xplained sensor development breadboard
+#define SECURITY_XPLAINED 12 //!< Xplained ATSHA204 board
+#define USER_EXT_BOARD 99 //!< User-reserved extension board (if any).
+//! @}
+
+#if BOARD == EVK1100
+# include "evk1100/evk1100.h"
+#elif BOARD == EVK1101
+# include "evk1101/evk1101.h"
+#elif BOARD == UC3C_EK
+# include "uc3c_ek/uc3c_ek.h"
+#elif BOARD == EVK1104
+# include "evk1104/evk1104.h"
+#elif BOARD == EVK1105
+# include "evk1105/evk1105.h"
+#elif BOARD == STK600_RCUC3L0
+# include "stk600/rcuc3l0/stk600_rcuc3l0.h"
+#elif BOARD == UC3L_EK
+# include "uc3l_ek/uc3l_ek.h"
+#elif BOARD == STK600_RCUC3L4
+# include "stk600/rcuc3l4/stk600_rcuc3l4.h"
+#elif BOARD == XPLAIN
+# include "xplain/xplain.h"
+#elif BOARD == STK600_MEGA
+ /*No header-file to include*/
+#elif BOARD == STK600_MEGA_RF
+# include "stk600.h"
+#elif BOARD == ATMEGA256RFR2_XPLAINED_PRO
+# include "atmega256rfr2_xplained_pro/atmega256rfr2_xplained_pro.h"
+#elif BOARD == ATMEGA256RFR2_ZIGBIT
+# include "atmega256rfr2_zigbit/atmega256rfr2_zigbit.h"
+#elif BOARD == STK600_RC032X
+# include "stk600/rc032x/stk600_rc032x.h"
+#elif BOARD == STK600_RC044X
+# include "stk600/rc044x/stk600_rc044x.h"
+#elif BOARD == STK600_RC064X
+# include "stk600/rc064x/stk600_rc064x.h"
+#elif BOARD == STK600_RC100X
+# include "stk600/rc100x/stk600_rc100x.h"
+#elif BOARD == UC3_A3_XPLAINED
+# include "uc3_a3_xplained/uc3_a3_xplained.h"
+#elif BOARD == UC3_L0_XPLAINED
+# include "uc3_l0_xplained/uc3_l0_xplained.h"
+#elif BOARD == STK600_RCUC3B0
+# include "stk600/rcuc3b0/stk600_rcuc3b0.h"
+#elif BOARD == STK600_RCUC3D
+# include "stk600/rcuc3d/stk600_rcuc3d.h"
+#elif BOARD == STK600_RCUC3C0
+# include "stk600/rcuc3c0/stk600_rcuc3c0.h"
+#elif BOARD == SAMG53_XPLAINED_PRO
+# include "samg53_xplained_pro/samg53_xplained_pro.h"
+#elif BOARD == SAMG55_XPLAINED_PRO
+# include "samg55_xplained_pro/samg55_xplained_pro.h"
+#elif BOARD == XMEGA_B1_XPLAINED
+# include "xmega_b1_xplained/xmega_b1_xplained.h"
+#elif BOARD == STK600_RC064X_LCDX
+# include "stk600/rc064x_lcdx/stk600_rc064x_lcdx.h"
+#elif BOARD == STK600_RC100X_LCDX
+# include "stk600/rc100x_lcdx/stk600_rc100x_lcdx.h"
+#elif BOARD == XMEGA_A1_XPLAINED
+# include "xmega_a1_xplained/xmega_a1_xplained.h"
+#elif BOARD == XMEGA_A1U_XPLAINED_PRO
+# include "xmega_a1u_xplained_pro/xmega_a1u_xplained_pro.h"
+#elif BOARD == UC3_L0_XPLAINED_BC
+# include "uc3_l0_xplained_bc/uc3_l0_xplained_bc.h"
+#elif BOARD == SAM3S_EK
+# include "sam3s_ek/sam3s_ek.h"
+# include "system_sam3s.h"
+#elif BOARD == SAM3S_EK2
+# include "sam3s_ek2/sam3s_ek2.h"
+# include "system_sam3sd8.h"
+#elif BOARD == SAM3U_EK
+# include "sam3u_ek/sam3u_ek.h"
+# include "system_sam3u.h"
+#elif BOARD == SAM3X_EK
+# include "sam3x_ek/sam3x_ek.h"
+# include "system_sam3x.h"
+#elif BOARD == SAM3N_EK
+# include "sam3n_ek/sam3n_ek.h"
+# include "system_sam3n.h"
+#elif BOARD == SAM4S_EK
+# include "sam4s_ek/sam4s_ek.h"
+# include "system_sam4s.h"
+#elif BOARD == SAM4S_WPIR_RD
+# include "sam4s_wpir_rd/sam4s_wpir_rd.h"
+# include "system_sam4s.h"
+#elif BOARD == SAM4S_XPLAINED
+# include "sam4s_xplained/sam4s_xplained.h"
+# include "system_sam4s.h"
+#elif BOARD == SAM4S_EK2
+# include "sam4s_ek2/sam4s_ek2.h"
+# include "system_sam4s.h"
+#elif BOARD == MEGA_1284P_XPLAINED
+ /*No header-file to include*/
+#elif BOARD == ARDUINO_DUE_X
+# include "arduino_due_x/arduino_due_x.h"
+# include "system_sam3x.h"
+#elif BOARD == SAM4L_EK
+# include "sam4l_ek/sam4l_ek.h"
+#elif BOARD == SAM4E_EK
+# include "sam4e_ek/sam4e_ek.h"
+#elif BOARD == SAMD20_XPLAINED_PRO
+# include "samd20_xplained_pro/samd20_xplained_pro.h"
+#elif BOARD == SAMD21_XPLAINED_PRO
+# include "samd21_xplained_pro/samd21_xplained_pro.h"
+#elif BOARD == SAMR21_XPLAINED_PRO
+# include "samr21_xplained_pro/samr21_xplained_pro.h"
+#elif BOARD == SAMD11_XPLAINED_PRO
+# include "samd11_xplained_pro/samd11_xplained_pro.h"
+#elif BOARD == SAML21_XPLAINED_PRO
+# include "saml21_xplained_pro/saml21_xplained_pro.h"
+#elif BOARD == SAMD10_XPLAINED_MINI
+# include "samd10_xplained_mini/samd10_xplained_mini.h"
+#elif BOARD == SAM4N_XPLAINED_PRO
+# include "sam4n_xplained_pro/sam4n_xplained_pro.h"
+#elif BOARD == SAMW25_XPLAINED_PRO
+# include "samw25_xplained_pro/samw25_xplained_pro.h"
+#elif BOARD == MEGA1284P_XPLAINED_BC
+# include "mega1284p_xplained_bc/mega1284p_xplained_bc.h"
+#elif BOARD == UC3_L0_QT600
+# include "uc3_l0_qt600/uc3_l0_qt600.h"
+#elif BOARD == XMEGA_A3BU_XPLAINED
+# include "xmega_a3bu_xplained/xmega_a3bu_xplained.h"
+#elif BOARD == XMEGA_E5_XPLAINED
+# include "xmega_e5_xplained/xmega_e5_xplained.h"
+#elif BOARD == UC3B_BOARD_CONTROLLER
+# include "uc3b_board_controller/uc3b_board_controller.h"
+#elif BOARD == RZ600
+# include "rz600/rz600.h"
+#elif BOARD == STK600_RCUC3A0
+# include "stk600/rcuc3a0/stk600_rcuc3a0.h"
+#elif BOARD == ATXMEGA128A1_QT600
+# include "atxmega128a1_qt600/atxmega128a1_qt600.h"
+#elif BOARD == STK600_RCUC3L3
+# include "stk600/rcuc3l3/stk600_rcuc3l3.h"
+#elif BOARD == SAM4S_XPLAINED_PRO
+# include "sam4s_xplained_pro/sam4s_xplained_pro.h"
+#elif BOARD == SAM4L_XPLAINED_PRO
+# include "sam4l_xplained_pro/sam4l_xplained_pro.h"
+#elif BOARD == SAM4L8_XPLAINED_PRO
+# include "sam4l8_xplained_pro/sam4l8_xplained_pro.h"
+#elif BOARD == SAM4C_EK
+# include "sam4c_ek/sam4c_ek.h"
+#elif BOARD == SAM4CMP_DB
+# include "sam4cmp_db/sam4cmp_db.h"
+#elif BOARD == SAM4CMS_DB
+# include "sam4cms_db/sam4cms_db.h"
+#elif BOARD == SAM4CP16BMB
+# include "sam4cp16bmb/sam4cp16bmb.h"
+#elif BOARD == ATPL230AMB
+# include "atpl230amb/atpl230amb.h"
+#elif BOARD == SIMULATOR_XMEGA_A1
+# include "simulator/xmega_a1/simulator_xmega_a1.h"
+#elif BOARD == XMEGA_C3_XPLAINED
+# include "xmega_c3_xplained/xmega_c3_xplained.h"
+#elif BOARD == XMEGA_RF233_ZIGBIT
+# include "xmega_rf233_zigbit/xmega_rf233_zigbit.h"
+#elif BOARD == XMEGA_A3_REB_CBB
+# include "xmega_a3_reb_cbb/xmega_a3_reb_cbb.h"
+#elif BOARD == ATMEGARFX_RCB
+# include "atmegarfx_rcb/atmegarfx_rcb.h"
+#elif BOARD == RCB256RFR2_XPRO
+# include "atmega256rfr2_rcb_xpro/atmega256rfr2_rcb_xpro.h"
+#elif BOARD == XMEGA_RF212B_ZIGBIT
+# include "xmega_rf212b_zigbit/xmega_rf212b_zigbit.h"
+#elif BOARD == SAM4E_XPLAINED_PRO
+# include "sam4e_xplained_pro/sam4e_xplained_pro.h"
+#elif BOARD == AVR_SIMULATOR_UC3
+# include "avr_simulator_uc3/avr_simulator_uc3.h"
+#elif BOARD == USER_BOARD
+ // User-reserved area: #include the header file of your board here (if any).
+# include "user_board.h"
+#elif BOARD == DUMMY_BOARD
+# include "dummy/dummy_board.h"
+#else
+# error No known Atmel board defined
+#endif
+
+#if (defined EXT_BOARD)
+# if EXT_BOARD == MC300
+# include "mc300/mc300.h"
+# elif (EXT_BOARD == SENSORS_XPLAINED_INERTIAL_1) || \
+ (EXT_BOARD == SENSORS_XPLAINED_INERTIAL_2) || \
+ (EXT_BOARD == SENSORS_XPLAINED_INERTIAL_A1) || \
+ (EXT_BOARD == SENSORS_XPLAINED_PRESSURE_1) || \
+ (EXT_BOARD == SENSORS_XPLAINED_LIGHTPROX_1) || \
+ (EXT_BOARD == SENSORS_XPLAINED_BREADBOARD)
+# include "sensors_xplained/sensors_xplained.h"
+# elif EXT_BOARD == RZ600_AT86RF231
+# include "at86rf231/at86rf231.h"
+# elif EXT_BOARD == RZ600_AT86RF230B
+# include "at86rf230b/at86rf230b.h"
+# elif EXT_BOARD == RZ600_AT86RF212
+# include "at86rf212/at86rf212.h"
+# elif EXT_BOARD == SECURITY_XPLAINED
+# include "security_xplained.h"
+# elif EXT_BOARD == USER_EXT_BOARD
+ // User-reserved area: #include the header file of your extension board here
+ // (if any).
+# endif
+#endif
+
+
+#if (defined(__GNUC__) && defined(__AVR32__)) || (defined(__ICCAVR32__) || defined(__AAVR32__))
+#ifdef __AVR32_ABI_COMPILER__ // Automatically defined when compiling for AVR32, not when assembling.
+
+/*! \brief This function initializes the board target resources
+ *
+ * This function should be called to ensure proper initialization of the target
+ * board hardware connected to the part.
+ */
+extern void board_init(void);
+
+#endif // #ifdef __AVR32_ABI_COMPILER__
+#else
+/*! \brief This function initializes the board target resources
+ *
+ * This function should be called to ensure proper initialization of the target
+ * board hardware connected to the part.
+ */
+extern void board_init(void);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * \}
+ */
+
+#endif // _BOARD_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/board.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/board.h.REMOVED.git-id
deleted file mode 100644
index aaab3c0a..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/board.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-63d76ae9f8ad6b36a18af2d915996af68ca6c094
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/init.c b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/init.c
new file mode 100644
index 00000000..32fba369
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/init.c
@@ -0,0 +1,21 @@
+/**
+ * \file
+ *
+ * \brief User board initialization template
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include
+#include
+#include
+
+void board_init(void)
+{
+ /* This function is meant to contain board-specific initialization code
+ * for, e.g., the I/O pins. The initialization can rely on application-
+ * specific board configuration, found in conf_board.h.
+ */
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/init.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/init.c.REMOVED.git-id
deleted file mode 100644
index bddbbdfa..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/init.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-32fba3695e759c0557b46daf5a77a051f57b20cc
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/user_board.h b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/user_board.h
new file mode 100644
index 00000000..39980a7d
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/user_board.h
@@ -0,0 +1,40 @@
+/**
+ * \file
+ *
+ * \brief User board definition template
+ *
+ */
+
+ /* This file is intended to contain definitions and configuration details for
+ * features and devices that are available on the board, e.g., frequency and
+ * startup time for an external crystal, external memory devices, LED and USART
+ * pins.
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef USER_BOARD_H
+#define USER_BOARD_H
+
+#include
+
+// External oscillator settings.
+// Uncomment and set correct values if external oscillator is used.
+
+// External oscillator frequency
+//#define BOARD_XOSC_HZ 8000000
+
+// External oscillator type.
+//!< External clock signal
+//#define BOARD_XOSC_TYPE XOSC_TYPE_EXTERNAL
+//!< 32.768 kHz resonator on TOSC
+//#define BOARD_XOSC_TYPE XOSC_TYPE_32KHZ
+//!< 0.4 to 16 MHz resonator on XTALS
+//#define BOARD_XOSC_TYPE XOSC_TYPE_XTAL
+
+// External oscillator startup time
+//#define BOARD_XOSC_STARTUP_US 500000
+
+
+#endif // USER_BOARD_H
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/user_board.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/user_board.h.REMOVED.git-id
deleted file mode 100644
index a605e78a..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/boards/user_board/user_board.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-39980a7d2e46bb1a0c9e0a93930f392bd83c5677
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.c b/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.c
new file mode 100644
index 00000000..cb51cfb8
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.c
@@ -0,0 +1,125 @@
+/**
+ * \file
+ *
+ * \brief ST7565R display controller driver.
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include "st7565r.h"
+
+/**
+ * \internal
+ * \brief Initialize the hardware interface
+ *
+ * Depending on what interface used for interfacing the LCD controller this
+ * function will initialize the necessary hardware.
+ */
+static void st7565r_interface_init(void)
+{
+#ifdef ST7565R_SERIAL_INTERFACE
+ spi_flags_t spi_flags = SPI_MODE_3;
+ board_spi_select_id_t spi_select_id = 0;
+#endif
+
+#if defined(ST7565R_USART_SPI_INTERFACE)
+ struct usart_spi_device device = {
+ .id = ST7565R_CS_PIN,
+ };
+ usart_spi_init(ST7565R_USART_SPI);
+ usart_spi_setup_device(ST7565R_USART_SPI, &device, spi_flags,
+ ST7565R_CLOCK_SPEED, spi_select_id);
+#elif defined(ST7565R_SPI_INTERFACE)
+ struct spi_device device = {
+ .id = ST7565R_CS_PIN,
+ };
+ spi_master_init(ST7565R_SPI);
+ spi_master_setup_device(ST7565R_SPI, &device, spi_flags,
+ ST7565R_CLOCK_SPEED, spi_select_id);
+#endif
+}
+
+/**
+ * \brief Initialize the LCD controller
+ *
+ * Call this function to initialize the hardware interface and the LCD
+ * controller. When initialization is done the display is turned on and ready
+ * to receive data.
+ */
+void st7565r_init(void)
+{
+ // Do a hard reset of the LCD display controller
+ st7565r_hard_reset();
+
+ // Initialize the interface
+ st7565r_interface_init();
+
+ // Set the A0 pin to the default state (command)
+ ioport_set_pin_low(ST7565R_A0_PIN);
+
+ // The column address is set to increasing
+ st7565r_write_command(ST7565R_CMD_ADC_NORMAL);
+
+ // Non-inverted display
+ st7565r_display_invert_disable();
+
+ // The common mode scan direction is reversed COM31->COM0
+ st7565r_write_command(ST7565R_CMD_REVERSE_SCAN_DIRECTION);
+
+ // Set the voltage bias ratio to 1/6
+ st7565r_write_command(ST7565R_CMD_LCD_BIAS_1_DIV_6_DUTY33);
+
+ // Set booster circuit, voltage regulator and voltage follower all to on
+ st7565r_write_command(ST7565R_CMD_POWER_CTRL_ALL_ON);
+
+ // Set the booster ratio to 2X,3X,4X
+ st7565r_write_command(ST7565R_CMD_BOOSTER_RATIO_SET);
+ st7565r_write_command(ST7565R_CMD_BOOSTER_RATIO_2X_3X_4X);
+
+ // Set voltage resistor ratio to 1
+ st7565r_write_command(ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_1);
+
+ /* Set contrast to min value, no need to check return value as the contrast
+ is set to the defined min*/
+ st7565r_set_contrast(ST7565R_DISPLAY_CONTRAST_MIN);
+
+ // Turn on the display
+ st7565r_display_on();
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.c.REMOVED.git-id
deleted file mode 100644
index 0e1ab871..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cb51cfb8d9d84ce3e4eea63f12065af87db702a4
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.h b/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.h
new file mode 100644
index 00000000..436d354a
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.h
@@ -0,0 +1,463 @@
+/**
+ * \file
+ *
+ * \brief ST7565R display controller driver.
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef ST7565R_H_INCLUDED
+#define ST7565R_H_INCLUDED
+
+#include
+#include
+#include
+#include
+#include
+
+// controller and LCD configuration file
+#include "conf_st7565r.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup st7565r_lcd_controller_group ST7565R LCD Controller Low-level\
+ * driver
+ *
+ * This is a low level driver for the ST7565R LCD controller. It provides basic
+ * functions for initializing and writing to the LCD controller. In addition to
+ * hardware control and use of the LCD controller internal functions .
+ *
+ * Before writing data to the display call \ref st7565r_init() which will set up
+ * the physical interface and the LCD. A file named \ref conf_st7565r.h is needed
+ * to define which interface to use. For more information see the Interface
+ * selection section. In addition one also need to define the pins
+ * \ref ST7565R_A0_PIN, \ref ST7565R_CS_PIN and \ref ST7565R_RESET_PIN and the
+ * display \ref ST7565R_CLOCK_SPEED.
+ *
+ * \warning This driver is not reentrant and can not be used in interrupt\
+ * service routines without extra care.
+ *
+ * As a safety feature one also need to set the max and min contrast levels that
+ * the \ref st7565r_set_contrast using the defines
+ * \ref ST7565R_DISPLAY_CONTRAST_MAX and \ref ST7565R_DISPLAY_CONTRAST_MIN to
+ * protect the display from too high voltage, please see the
+ * \ref st7565r_set_contrast function for more details.
+ *
+ * An example \ref conf_st7565r.h file could look like
+ * \code
+ // interface selection
+ #define ST7565R_USART_SPI_INTERFACE
+ #define ST7565R_USART_SPI &USARTD0
+
+ // minimum clock period is 50ns@3.3V -> max frequency is 20MHz
+ #define ST7565R_CLOCK_SPEED 1000000
+
+ #define ST7565R_DISPLAY_CONTRAST_MAX 40
+ #define ST7565R_DISPLAY_CONTRAST_MIN 30
+
+ #define ST7565R_A0_PIN NHD_C12832A1Z_REGISTER_SELECT
+ #define ST7565R_CS_PIN NHD_C12832A1Z_CSN
+ #define ST7565R_RESET_PIN NHD_C12832A1Z_RESETN
+\endcode
+ *
+ * \section dependencies Dependencies
+ * This driver depends on the following modules:
+ * - \ref ioport_group for IO port control.
+ * - \ref sysclk_group for getting system clock speeds for init functions.
+ * - \ref usart_spi_group or \ref spi_group for communication with the LCD
+ * controller
+ * @{
+ */
+
+//! \name Command defines
+//@{
+#define ST7565R_CMD_DISPLAY_ON 0xAF
+#define ST7565R_CMD_DISPLAY_OFF 0xAE
+#define ST7565R_CMD_START_LINE_SET(line) (0x40 | (line))
+#define ST7565R_CMD_PAGE_ADDRESS_SET(page) (0xB0 | (page))
+#define ST7565R_CMD_COLUMN_ADDRESS_SET_MSB(column) (0x10 | (column))
+#define ST7565R_CMD_COLUMN_ADDRESS_SET_LSB(column) (0x00 | (column))
+#define ST7565R_CMD_ADC_NORMAL 0xA0
+#define ST7565R_CMD_ADC_REVERSE 0xA1
+#define ST7565R_CMD_DISPLAY_NORMAL 0xA6
+#define ST7565R_CMD_DISPLAY_REVERSE 0xA7
+#define ST7565R_CMD_DISPLAY_ALL_POINTS_OFF 0xA4
+#define ST7565R_CMD_DISPLAY_ALL_POINTS_ON 0xA5
+#define ST7565R_CMD_LCD_BIAS_1_DIV_5_DUTY33 0xA1
+#define ST7565R_CMD_LCD_BIAS_1_DIV_6_DUTY33 0xA2
+#define ST7565R_CMD_NORMAL_SCAN_DIRECTION 0xC0
+#define ST7565R_CMD_REVERSE_SCAN_DIRECTION 0xC8
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_0 0x20
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_1 0x21
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_2 0x22
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_3 0x23
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_4 0x24
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_5 0x25
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_6 0x26
+#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_7 0x27
+#define ST7565R_CMD_POWER_CTRL_ALL_ON 0x2F
+#define ST7565R_CMD_SLEEP_MODE 0xAC
+#define ST7565R_CMD_NORMAL_MODE 0xAD
+#define ST7565R_CMD_RESET 0xE2
+#define ST7565R_CMD_NOP 0xE3
+#define ST7565R_CMD_ELECTRONIC_VOLUME_MODE_SET 0x81
+#define ST7565R_CMD_ELECTRONIC_VOLUME(volume) (0x3F & (~volume))
+#define ST7565R_CMD_BOOSTER_RATIO_SET 0xF8
+#define ST7565R_CMD_BOOSTER_RATIO_2X_3X_4X 0x00
+#define ST7565R_CMD_BOOSTER_RATIO_5X 0x01
+#define ST7565R_CMD_BOOSTER_RATIO_6X 0x03
+#define ST7565R_CMD_STATUS_READ 0x00
+#define ST7565R_CMD_END 0xEE
+#define ST7565R_CMD_READ_MODIFY_WRITE 0xE0
+//@}
+
+/**
+ * \name Interface selection
+ *
+ * The LCD controller support both serial and parallel mode, that means there
+ * is a number of possible ways of interfacing the controller using different
+ * AVR peripherals. The different interfaces can be selected using different
+ * defines. This driver supports the serial communication mode using an
+ * USART in Master SPI mode by defining \ref ST7565R_USART_SPI_INTERFACE, and a
+ * normal SPI in Master Mode by defining \ref ST7565R_SPI_INTERFACE.
+ *
+ * \note The current driver only support serial mode.
+ */
+//@{
+#if defined(__DOXYGEN__)
+//! \brief Select the a USART SPI interface.
+# define ST7565R_USART_SPI_INTERFACE
+//! \brief Select the normal SPI peripheral interface.
+# define ST7565R_SPI_INTERFACE
+#endif
+
+#if defined(ST7565R_USART_SPI_INTERFACE)
+# include
+#elif defined(ST7565R_SPI_INTERFACE)
+# include
+#else
+#error "Interface not supported by the driver"
+#endif
+//@}
+
+#if defined(ST7565R_USART_SPI_INTERFACE) || defined(ST7565R_SPI_INTERFACE)
+//
+# define ST7565R_SERIAL_INTERFACE
+#endif
+
+//! \name LCD controller write and read functions
+//@{
+/**
+ * \brief Writes a command to the display controller
+ *
+ * This functions pull pin A0 low before writing to the controller. Different
+ * data write function is called based on the selected interface.
+ *
+ * \param command the command to write
+ */
+static inline void st7565r_write_command(uint8_t command)
+{
+#if defined(ST7565R_USART_SPI_INTERFACE)
+ struct usart_spi_device device = {.id = ST7565R_CS_PIN};
+ usart_spi_select_device(ST7565R_USART_SPI, &device);
+ ioport_set_pin_low(ST7565R_A0_PIN);
+ usart_spi_transmit(ST7565R_USART_SPI, command);
+ usart_spi_deselect_device(ST7565R_USART_SPI, &device);
+#elif defined(ST7565R_SPI_INTERFACE)
+ struct spi_device device = {.id = ST7565R_CS_PIN};
+ spi_select_device(ST7565R_SPI, &device);
+ ioport_set_pin_low(ST7565R_A0_PIN);
+ spi_write_single(ST7565R_SPI, command);
+ spi_deselect_device(ST7565R_SPI, &device);
+#endif
+}
+
+/**
+ * \brief Write data to the display controller
+ *
+ * This functions sets the pin A0 before writing to the controller. Different
+ * data write function is called based on the selected interface.
+ *
+ * \param data the data to write
+ */
+static inline void st7565r_write_data(uint8_t data)
+{
+#if defined(ST7565R_USART_SPI_INTERFACE)
+ struct usart_spi_device device = {.id = ST7565R_CS_PIN};
+ usart_spi_select_device(ST7565R_USART_SPI, &device);
+ ioport_set_pin_high(ST7565R_A0_PIN);
+ usart_spi_transmit(ST7565R_USART_SPI, data);
+ ioport_set_pin_low(ST7565R_A0_PIN);
+ usart_spi_deselect_device(ST7565R_USART_SPI, &device);
+#elif defined(ST7565R_SPI_INTERFACE)
+ struct spi_device device = {.id = ST7565R_CS_PIN};
+ spi_select_device(ST7565R_SPI, &device);
+ ioport_set_pin_high(ST7565R_A0_PIN);
+ spi_write_single(ST7565R_SPI, data);
+ ioport_set_pin_low(ST7565R_A0_PIN);
+ spi_deselect_device(ST7565R_SPI, &device);
+#endif
+}
+
+/**
+ * \brief Read data from the controller
+ *
+ * \note The controller does not support read in serial mode.
+ *
+ * \retval 8 bit data read from the controller
+ */
+static inline uint8_t st7565r_read_data(void)
+{
+ return 0;
+}
+
+/**
+ * \brief Read status from the controller
+ *
+ * \note The controller does not support read in serial mode.
+ *
+ * \retval 8 bit status read from the controller
+ */
+static inline uint8_t st7565r_get_status(void)
+{
+ return 0;
+}
+//@}
+
+//! \name LCD Controller reset
+//@{
+/**
+ * \brief Perform a soft reset of the LCD controller
+ *
+ * This functions will reset the LCD controller by sending the reset command.
+ * \note this functions should not be confused with the \ref st7565r_hard_reset()
+ * function, this command will not control the RST pin.
+ */
+static inline void st7565r_soft_reset(void)
+{
+ st7565r_write_command(ST7565R_CMD_RESET);
+}
+
+/**
+ * \brief Perform a hard reset of the LCD controller
+ *
+ * This functions will reset the LCD controller by setting the reset pin low.
+ * \note this functions should not be confused with the \ref st7565r_soft_reset()
+ * function, this command will control the RST pin.
+ */
+static inline void st7565r_hard_reset(void)
+{
+ ioport_set_pin_low(ST7565R_RESET_PIN);
+ delay_us(10);
+ ioport_set_pin_high(ST7565R_RESET_PIN);
+ delay_us(10);
+}
+//@}
+
+//! \name Sleep control
+//@{
+/**
+ * \brief Enable the LCD sleep mode
+ */
+static inline void st7565r_sleep_enable(void)
+{
+ st7565r_write_command(ST7565R_CMD_SLEEP_MODE);
+}
+
+/**
+ * \brief Disable the LCD sleep mode
+ */
+static inline void st7565r_sleep_disable(void)
+{
+ st7565r_write_command(ST7565R_CMD_NORMAL_MODE);
+}
+//@}
+
+//! \name Address setup for the LCD
+//@{
+/**
+ * \brief Set current page in display RAM
+ *
+ * This command is usually followed by the configuration of the column address
+ * because this scheme will provide access to all locations in the display
+ * RAM.
+ *
+ * \param address the page address
+ */
+static inline void st7565r_set_page_address(uint8_t address)
+{
+ // Make sure that the address is 4 bits (only 8 pages)
+ address &= 0x0F;
+ st7565r_write_command(ST7565R_CMD_PAGE_ADDRESS_SET(address));
+}
+
+/**
+ * \brief Set current column in display RAM
+ *
+ * \param address the column address
+ */
+static inline void st7565r_set_column_address(uint8_t address)
+{
+ // Make sure the address is 7 bits
+ address &= 0x7F;
+ st7565r_write_command(ST7565R_CMD_COLUMN_ADDRESS_SET_MSB(address >> 4));
+ st7565r_write_command(ST7565R_CMD_COLUMN_ADDRESS_SET_LSB(address & 0x0F));
+}
+
+/**
+ * \brief Set the display start draw line address
+ *
+ * This function will set which line should be the start draw line for the LCD.
+ */
+static inline void st7565r_set_display_start_line_address(uint8_t address)
+{
+ // Make sure address is 6 bits
+ address &= 0x3F;
+ st7565r_write_command(ST7565R_CMD_START_LINE_SET(address));
+}
+//@}
+
+//! \name Display hardware control
+//@{
+/**
+ * \brief Turn the LCD display on
+ *
+ * This function will turn on the LCD.
+ */
+static inline void st7565r_display_on(void)
+{
+ st7565r_write_command(ST7565R_CMD_DISPLAY_ON);
+}
+
+/**
+ * \brief Turn the LCD display off
+ *
+ * This function will turn off the LCD.
+ */
+static inline void st7565r_display_off(void)
+{
+ st7565r_write_command(ST7565R_CMD_DISPLAY_OFF);
+}
+
+/**
+ * \brief Sets all LCD pixels on
+ *
+ * This function can be used to test the LCD by setting all pixels on, this will
+ * not affect the current LCD RAM.
+ *
+ * \param pixels_on if true all the LCD pixels are turned on, false the display
+ * is back in normal mode displaying what is in the display
+ * RAM.
+ */
+static inline void st7565r_set_all_pixels(bool pixels_on)
+{
+ if (pixels_on) {
+ st7565r_write_command(ST7565R_CMD_DISPLAY_ALL_POINTS_ON);
+ } else {
+ st7565r_write_command(ST7565R_CMD_DISPLAY_ALL_POINTS_OFF);
+ }
+}
+
+/**
+ * \brief Set the LCD contrast level
+ *
+ * \warning This will set the voltage for the LCD, settings this value too high
+ * may result in damage to the LCD. Hence the limit for these settings must be
+ * defined in the \ref conf_st7565r.h file.
+ *
+ * Contrast values outside the max and min values will be clipped to the defined
+ * \ref ST7565R_DISPLAY_CONTRAST_MAX and \ref ST7565R_DISPLAY_CONTRAST_MIN.
+ *
+ * \param contrast a number between 0 and 63 where the max values is given by
+ * the LCD.
+ *
+ * \retval contrast the contrast value written to the LCD controller
+ */
+static inline uint8_t st7565r_set_contrast(uint8_t contrast)
+{
+ if (contrast < ST7565R_DISPLAY_CONTRAST_MIN) {
+ contrast = ST7565R_DISPLAY_CONTRAST_MIN;
+ }
+ if (contrast > ST7565R_DISPLAY_CONTRAST_MAX) {
+ contrast = ST7565R_DISPLAY_CONTRAST_MAX;
+ }
+ st7565r_write_command(ST7565R_CMD_ELECTRONIC_VOLUME_MODE_SET);
+ st7565r_write_command(ST7565R_CMD_ELECTRONIC_VOLUME(contrast));
+ return contrast;
+}
+
+/**
+ * \brief Invert all pixels on the device
+ *
+ * This function will invert all pixels on the LCD
+ *
+ */
+static inline void st7565r_display_invert_enable(void)
+{
+ st7565r_write_command(ST7565R_CMD_DISPLAY_REVERSE);
+}
+
+/**
+ * \brief Disable invert of all pixels on the device
+ *
+ * This function will disable invert on all pixels on the LCD
+ *
+ */
+static inline void st7565r_display_invert_disable(void)
+{
+ st7565r_write_command(ST7565R_CMD_DISPLAY_NORMAL);
+}
+//@}
+
+//! \name Initialization
+//@{
+void st7565r_init(void);
+//@}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ST7565R_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.h.REMOVED.git-id
deleted file mode 100644
index 057974ae..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/components/display/st7565r/st7565r.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-436d354a6809406213467b7c79eaf4f7138f5e02
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/genclk.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/genclk.h
new file mode 100644
index 00000000..f910d8bb
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/genclk.h
@@ -0,0 +1,191 @@
+/**
+ * \file
+ *
+ * \brief Generic clock management
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CLK_GENCLK_H_INCLUDED
+#define CLK_GENCLK_H_INCLUDED
+
+#include "parts.h"
+
+#if SAM3S
+# include "sam3s/genclk.h"
+#elif SAM3U
+# include "sam3u/genclk.h"
+#elif SAM3N
+# include "sam3n/genclk.h"
+#elif SAM3XA
+# include "sam3x/genclk.h"
+#elif SAM4S
+# include "sam4s/genclk.h"
+#elif SAM4L
+# include "sam4l/genclk.h"
+#elif SAM4E
+# include "sam4e/genclk.h"
+#elif SAM4N
+# include "sam4n/genclk.h"
+#elif SAM4C
+# include "sam4c/genclk.h"
+#elif SAM4CM
+# include "sam4cm/genclk.h"
+#elif SAM4CP
+# include "sam4cp/genclk.h"
+#elif SAMG
+# include "samg/genclk.h"
+#elif (UC3A0 || UC3A1)
+# include "uc3a0_a1/genclk.h"
+#elif UC3A3
+# include "uc3a3_a4/genclk.h"
+#elif UC3B
+# include "uc3b0_b1/genclk.h"
+#elif UC3C
+# include "uc3c/genclk.h"
+#elif UC3D
+# include "uc3d/genclk.h"
+#elif UC3L
+# include "uc3l/genclk.h"
+#else
+# error Unsupported chip type
+#endif
+
+/**
+ * \ingroup clk_group
+ * \defgroup genclk_group Generic Clock Management
+ *
+ * Generic clocks are configurable clocks which run outside the system
+ * clock domain. They are often connected to peripherals which have an
+ * asynchronous component running independently of the bus clock, e.g.
+ * USB controllers, low-power timers and RTCs, etc.
+ *
+ * Note that not all platforms have support for generic clocks; on such
+ * platforms, this API will not be available.
+ *
+ * @{
+ */
+
+/**
+ * \def GENCLK_DIV_MAX
+ * \brief Maximum divider supported by the generic clock implementation
+ */
+/**
+ * \enum genclk_source
+ * \brief Generic clock source ID
+ *
+ * Each generic clock may be generated from a different clock source.
+ * These are the available alternatives provided by the chip.
+ */
+
+//! \name Generic clock configuration
+//@{
+/**
+ * \struct genclk_config
+ * \brief Hardware representation of a set of generic clock parameters
+ */
+/**
+ * \fn void genclk_config_defaults(struct genclk_config *cfg,
+ * unsigned int id)
+ * \brief Initialize \a cfg to the default configuration for the clock
+ * identified by \a id.
+ */
+/**
+ * \fn void genclk_config_read(struct genclk_config *cfg, unsigned int id)
+ * \brief Read the currently active configuration of the clock
+ * identified by \a id into \a cfg.
+ */
+/**
+ * \fn void genclk_config_write(const struct genclk_config *cfg,
+ * unsigned int id)
+ * \brief Activate the configuration \a cfg on the clock identified by
+ * \a id.
+ */
+/**
+ * \fn void genclk_config_set_source(struct genclk_config *cfg,
+ * enum genclk_source src)
+ * \brief Select a new source clock \a src in configuration \a cfg.
+ */
+/**
+ * \fn void genclk_config_set_divider(struct genclk_config *cfg,
+ * unsigned int divider)
+ * \brief Set a new \a divider in configuration \a cfg.
+ */
+/**
+ * \fn void genclk_enable_source(enum genclk_source src)
+ * \brief Enable the source clock \a src used by a generic clock.
+ */
+ //@}
+
+//! \name Enabling and disabling Generic Clocks
+//@{
+/**
+ * \fn void genclk_enable(const struct genclk_config *cfg, unsigned int id)
+ * \brief Activate the configuration \a cfg on the clock identified by
+ * \a id and enable it.
+ */
+/**
+ * \fn void genclk_disable(unsigned int id)
+ * \brief Disable the generic clock identified by \a id.
+ */
+//@}
+
+/**
+ * \brief Enable the configuration defined by \a src and \a divider
+ * for the generic clock identified by \a id.
+ *
+ * \param id The ID of the generic clock.
+ * \param src The source clock of the generic clock.
+ * \param divider The divider used to generate the generic clock.
+ */
+static inline void genclk_enable_config(unsigned int id, enum genclk_source src, unsigned int divider)
+{
+ struct genclk_config gcfg;
+
+ genclk_config_defaults(&gcfg, id);
+ genclk_enable_source(src);
+ genclk_config_set_source(&gcfg, src);
+ genclk_config_set_divider(&gcfg, divider);
+ genclk_enable(&gcfg, id);
+}
+
+//! @}
+
+#endif /* CLK_GENCLK_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/genclk.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/genclk.h.REMOVED.git-id
deleted file mode 100644
index cb24b607..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/genclk.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f910d8bb324a902e904e49c5de6cea41d018bb34
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/osc.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/osc.h
new file mode 100644
index 00000000..678f4200
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/osc.h
@@ -0,0 +1,177 @@
+/**
+ * \file
+ *
+ * \brief Oscillator management
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef OSC_H_INCLUDED
+#define OSC_H_INCLUDED
+
+#include "parts.h"
+#include "conf_clock.h"
+
+#if SAM3S
+# include "sam3s/osc.h"
+#elif SAM3XA
+# include "sam3x/osc.h"
+#elif SAM3U
+# include "sam3u/osc.h"
+#elif SAM3N
+# include "sam3n/osc.h"
+#elif SAM4S
+# include "sam4s/osc.h"
+#elif SAM4E
+# include "sam4e/osc.h"
+#elif SAM4C
+# include "sam4c/osc.h"
+#elif SAM4CM
+# include "sam4cm/osc.h"
+#elif SAM4CP
+# include "sam4cp/osc.h"
+#elif SAM4L
+# include "sam4l/osc.h"
+#elif SAM4N
+# include "sam4n/osc.h"
+#elif SAMG
+# include "samg/osc.h"
+#elif (UC3A0 || UC3A1)
+# include "uc3a0_a1/osc.h"
+#elif UC3A3
+# include "uc3a3_a4/osc.h"
+#elif UC3B
+# include "uc3b0_b1/osc.h"
+#elif UC3C
+# include "uc3c/osc.h"
+#elif UC3D
+# include "uc3d/osc.h"
+#elif UC3L
+# include "uc3l/osc.h"
+#elif XMEGA
+# include "xmega/osc.h"
+#else
+# error Unsupported chip type
+#endif
+
+/**
+ * \ingroup clk_group
+ * \defgroup osc_group Oscillator Management
+ *
+ * This group contains functions and definitions related to configuring
+ * and enabling/disabling on-chip oscillators. Internal RC-oscillators,
+ * external crystal oscillators and external clock generators are
+ * supported by this module. What all of these have in common is that
+ * they swing at a fixed, nominal frequency which is normally not
+ * adjustable.
+ *
+ * \par Example: Enabling an oscillator
+ *
+ * The following example demonstrates how to enable the external
+ * oscillator on XMEGA A and wait for it to be ready to use. The
+ * oscillator identifiers are platform-specific, so while the same
+ * procedure is used on all platforms, the parameter to osc_enable()
+ * will be different from device to device.
+ * \code
+ osc_enable(OSC_ID_XOSC);
+ osc_wait_ready(OSC_ID_XOSC); \endcode
+ *
+ * \section osc_group_board Board-specific Definitions
+ * If external oscillators are used, the board code must provide the
+ * following definitions for each of those:
+ * - \b BOARD__HZ: The nominal frequency of the oscillator.
+ * - \b BOARD__STARTUP_US: The startup time of the
+ * oscillator in microseconds.
+ * - \b BOARD__TYPE: The type of oscillator connected, i.e.
+ * whether it's a crystal or external clock, and sometimes what kind
+ * of crystal it is. The meaning of this value is platform-specific.
+ *
+ * @{
+ */
+
+//! \name Oscillator Management
+//@{
+/**
+ * \fn void osc_enable(uint8_t id)
+ * \brief Enable oscillator \a id
+ *
+ * The startup time and mode value is automatically determined based on
+ * definitions in the board code.
+ */
+/**
+ * \fn void osc_disable(uint8_t id)
+ * \brief Disable oscillator \a id
+ */
+/**
+ * \fn osc_is_ready(uint8_t id)
+ * \brief Determine whether oscillator \a id is ready.
+ * \retval true Oscillator \a id is running and ready to use as a clock
+ * source.
+ * \retval false Oscillator \a id is not running.
+ */
+/**
+ * \fn uint32_t osc_get_rate(uint8_t id)
+ * \brief Return the frequency of oscillator \a id in Hz
+ */
+
+#ifndef __ASSEMBLY__
+
+/**
+ * \brief Wait until the oscillator identified by \a id is ready
+ *
+ * This function will busy-wait for the oscillator identified by \a id
+ * to become stable and ready to use as a clock source.
+ *
+ * \param id A number identifying the oscillator to wait for.
+ */
+static inline void osc_wait_ready(uint8_t id)
+{
+ while (!osc_is_ready(id)) {
+ /* Do nothing */
+ }
+}
+
+#endif /* __ASSEMBLY__ */
+
+//@}
+
+//! @}
+
+#endif /* OSC_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/osc.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/osc.h.REMOVED.git-id
deleted file mode 100644
index a161affa..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/osc.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-678f4200c1d15181908876e0ac021d00958ad33f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/pll.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/pll.h
new file mode 100644
index 00000000..ce88b96b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/pll.h
@@ -0,0 +1,333 @@
+/**
+ * \file
+ *
+ * \brief PLL management
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CLK_PLL_H_INCLUDED
+#define CLK_PLL_H_INCLUDED
+
+#include "parts.h"
+#include "conf_clock.h"
+
+#if SAM3S
+# include "sam3s/pll.h"
+#elif SAM3XA
+# include "sam3x/pll.h"
+#elif SAM3U
+# include "sam3u/pll.h"
+#elif SAM3N
+# include "sam3n/pll.h"
+#elif SAM4S
+# include "sam4s/pll.h"
+#elif SAM4E
+# include "sam4e/pll.h"
+#elif SAM4C
+# include "sam4c/pll.h"
+#elif SAM4CM
+# include "sam4cm/pll.h"
+#elif SAM4CP
+# include "sam4cp/pll.h"
+#elif SAM4L
+# include "sam4l/pll.h"
+#elif SAM4N
+# include "sam4n/pll.h"
+#elif SAMG
+# include "samg/pll.h"
+#elif (UC3A0 || UC3A1)
+# include "uc3a0_a1/pll.h"
+#elif UC3A3
+# include "uc3a3_a4/pll.h"
+#elif UC3B
+# include "uc3b0_b1/pll.h"
+#elif UC3C
+# include "uc3c/pll.h"
+#elif UC3D
+# include "uc3d/pll.h"
+#elif (UC3L0128 || UC3L0256 || UC3L3_L4)
+# include "uc3l/pll.h"
+#elif XMEGA
+# include "xmega/pll.h"
+#else
+# error Unsupported chip type
+#endif
+
+/**
+ * \ingroup clk_group
+ * \defgroup pll_group PLL Management
+ *
+ * This group contains functions and definitions related to configuring
+ * and enabling/disabling on-chip PLLs. A PLL will take an input signal
+ * (the \em source), optionally divide the frequency by a configurable
+ * \em divider, and then multiply the frequency by a configurable \em
+ * multiplier.
+ *
+ * Some devices don't support input dividers; specifying any other
+ * divisor than 1 on these devices will result in an assertion failure.
+ * Other devices may have various restrictions to the frequency range of
+ * the input and output signals.
+ *
+ * \par Example: Setting up PLL0 with default parameters
+ *
+ * The following example shows how to configure and enable PLL0 using
+ * the default parameters specified using the configuration symbols
+ * listed above.
+ * \code
+ pll_enable_config_defaults(0); \endcode
+ *
+ * To configure, enable PLL0 using the default parameters and to disable
+ * a specific feature like Wide Bandwidth Mode (a UC3A3-specific
+ * PLL option.), you can use this initialization process.
+ * \code
+ struct pll_config pllcfg;
+ if (pll_is_locked(pll_id)) {
+ return; // Pll already running
+ }
+ pll_enable_source(CONFIG_PLL0_SOURCE);
+ pll_config_defaults(&pllcfg, 0);
+ pll_config_set_option(&pllcfg, PLL_OPT_WBM_DISABLE);
+ pll_enable(&pllcfg, 0);
+ pll_wait_for_lock(0); \endcode
+ *
+ * When the last function call returns, PLL0 is ready to be used as the
+ * main system clock source.
+ *
+ * \section pll_group_config Configuration Symbols
+ *
+ * Each PLL has a set of default parameters determined by the following
+ * configuration symbols in the application's configuration file:
+ * - \b CONFIG_PLLn_SOURCE: The default clock source connected to the
+ * input of PLL \a n. Must be one of the values defined by the
+ * #pll_source enum.
+ * - \b CONFIG_PLLn_MUL: The default multiplier (loop divider) of PLL
+ * \a n.
+ * - \b CONFIG_PLLn_DIV: The default input divider of PLL \a n.
+ *
+ * These configuration symbols determine the result of calling
+ * pll_config_defaults() and pll_get_default_rate().
+ *
+ * @{
+ */
+
+//! \name Chip-specific PLL characteristics
+//@{
+/**
+ * \def PLL_MAX_STARTUP_CYCLES
+ * \brief Maximum PLL startup time in number of slow clock cycles
+ */
+/**
+ * \def NR_PLLS
+ * \brief Number of on-chip PLLs
+ */
+
+/**
+ * \def PLL_MIN_HZ
+ * \brief Minimum frequency that the PLL can generate
+ */
+/**
+ * \def PLL_MAX_HZ
+ * \brief Maximum frequency that the PLL can generate
+ */
+/**
+ * \def PLL_NR_OPTIONS
+ * \brief Number of PLL option bits
+ */
+//@}
+
+/**
+ * \enum pll_source
+ * \brief PLL clock source
+ */
+
+//! \name PLL configuration
+//@{
+
+/**
+ * \struct pll_config
+ * \brief Hardware-specific representation of PLL configuration.
+ *
+ * This structure contains one or more device-specific values
+ * representing the current PLL configuration. The contents of this
+ * structure is typically different from platform to platform, and the
+ * user should not access any fields except through the PLL
+ * configuration API.
+ */
+
+/**
+ * \fn void pll_config_init(struct pll_config *cfg,
+ * enum pll_source src, unsigned int div, unsigned int mul)
+ * \brief Initialize PLL configuration from standard parameters.
+ *
+ * \note This function may be defined inline because it is assumed to be
+ * called very few times, and usually with constant parameters. Inlining
+ * it will in such cases reduce the code size significantly.
+ *
+ * \param cfg The PLL configuration to be initialized.
+ * \param src The oscillator to be used as input to the PLL.
+ * \param div PLL input divider.
+ * \param mul PLL loop divider (i.e. multiplier).
+ *
+ * \return A configuration which will make the PLL run at
+ * (\a mul / \a div) times the frequency of \a src
+ */
+/**
+ * \def pll_config_defaults(cfg, pll_id)
+ * \brief Initialize PLL configuration using default parameters.
+ *
+ * After this function returns, \a cfg will contain a configuration
+ * which will make the PLL run at (CONFIG_PLLx_MUL / CONFIG_PLLx_DIV)
+ * times the frequency of CONFIG_PLLx_SOURCE.
+ *
+ * \param cfg The PLL configuration to be initialized.
+ * \param pll_id Use defaults for this PLL.
+ */
+/**
+ * \def pll_get_default_rate(pll_id)
+ * \brief Get the default rate in Hz of \a pll_id
+ */
+/**
+ * \fn void pll_config_set_option(struct pll_config *cfg,
+ * unsigned int option)
+ * \brief Set the PLL option bit \a option in the configuration \a cfg.
+ *
+ * \param cfg The PLL configuration to be changed.
+ * \param option The PLL option bit to be set.
+ */
+/**
+ * \fn void pll_config_clear_option(struct pll_config *cfg,
+ * unsigned int option)
+ * \brief Clear the PLL option bit \a option in the configuration \a cfg.
+ *
+ * \param cfg The PLL configuration to be changed.
+ * \param option The PLL option bit to be cleared.
+ */
+/**
+ * \fn void pll_config_read(struct pll_config *cfg, unsigned int pll_id)
+ * \brief Read the currently active configuration of \a pll_id.
+ *
+ * \param cfg The configuration object into which to store the currently
+ * active configuration.
+ * \param pll_id The ID of the PLL to be accessed.
+ */
+/**
+ * \fn void pll_config_write(const struct pll_config *cfg,
+ * unsigned int pll_id)
+ * \brief Activate the configuration \a cfg on \a pll_id
+ *
+ * \param cfg The configuration object representing the PLL
+ * configuration to be activated.
+ * \param pll_id The ID of the PLL to be updated.
+ */
+
+//@}
+
+//! \name Interaction with the PLL hardware
+//@{
+/**
+ * \fn void pll_enable(const struct pll_config *cfg,
+ * unsigned int pll_id)
+ * \brief Activate the configuration \a cfg and enable PLL \a pll_id.
+ *
+ * \param cfg The PLL configuration to be activated.
+ * \param pll_id The ID of the PLL to be enabled.
+ */
+/**
+ * \fn void pll_disable(unsigned int pll_id)
+ * \brief Disable the PLL identified by \a pll_id.
+ *
+ * After this function is called, the PLL identified by \a pll_id will
+ * be disabled. The PLL configuration stored in hardware may be affected
+ * by this, so if the caller needs to restore the same configuration
+ * later, it should either do a pll_config_read() before disabling the
+ * PLL, or remember the last configuration written to the PLL.
+ *
+ * \param pll_id The ID of the PLL to be disabled.
+ */
+/**
+ * \fn bool pll_is_locked(unsigned int pll_id)
+ * \brief Determine whether the PLL is locked or not.
+ *
+ * \param pll_id The ID of the PLL to check.
+ *
+ * \retval true The PLL is locked and ready to use as a clock source
+ * \retval false The PLL is not yet locked, or has not been enabled.
+ */
+/**
+ * \fn void pll_enable_source(enum pll_source src)
+ * \brief Enable the source of the pll.
+ * The source is enabled, if the source is not already running.
+ *
+ * \param src The ID of the PLL source to enable.
+ */
+/**
+ * \fn void pll_enable_config_defaults(unsigned int pll_id)
+ * \brief Enable the pll with the default configuration.
+ * PLL is enabled, if the PLL is not already locked.
+ *
+ * \param pll_id The ID of the PLL to enable.
+ */
+
+/**
+ * \brief Wait for PLL \a pll_id to become locked
+ *
+ * \todo Use a timeout to avoid waiting forever and hanging the system
+ *
+ * \param pll_id The ID of the PLL to wait for.
+ *
+ * \retval STATUS_OK The PLL is now locked.
+ * \retval ERR_TIMEOUT Timed out waiting for PLL to become locked.
+ */
+static inline int pll_wait_for_lock(unsigned int pll_id)
+{
+ Assert(pll_id < NR_PLLS);
+
+ while (!pll_is_locked(pll_id)) {
+ /* Do nothing */
+ }
+
+ return 0;
+}
+
+//@}
+//! @}
+
+#endif /* CLK_PLL_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/pll.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/pll.h.REMOVED.git-id
deleted file mode 100644
index 72b463a8..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/pll.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ce88b96b836306afe5a861940a491f55ebdb77b5
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/sysclk.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/sysclk.h
new file mode 100644
index 00000000..cd9457b5
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/sysclk.h
@@ -0,0 +1,186 @@
+/**
+ * \file
+ *
+ * \brief System clock management
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef SYSCLK_H_INCLUDED
+#define SYSCLK_H_INCLUDED
+
+#include "parts.h"
+#include "conf_clock.h"
+
+#if SAM3S
+# include "sam3s/sysclk.h"
+#elif SAM3U
+# include "sam3u/sysclk.h"
+#elif SAM3N
+# include "sam3n/sysclk.h"
+#elif SAM3XA
+# include "sam3x/sysclk.h"
+#elif SAM4S
+# include "sam4s/sysclk.h"
+#elif SAM4E
+# include "sam4e/sysclk.h"
+#elif SAM4C
+# include "sam4c/sysclk.h"
+#elif SAM4CM
+# include "sam4cm/sysclk.h"
+#elif SAM4CP
+# include "sam4cp/sysclk.h"
+#elif SAM4L
+# include "sam4l/sysclk.h"
+#elif SAM4N
+# include "sam4n/sysclk.h"
+#elif SAMG
+# include "samg/sysclk.h"
+#elif (UC3A0 || UC3A1)
+# include "uc3a0_a1/sysclk.h"
+#elif UC3A3
+# include "uc3a3_a4/sysclk.h"
+#elif UC3B
+# include "uc3b0_b1/sysclk.h"
+#elif UC3C
+# include "uc3c/sysclk.h"
+#elif UC3D
+# include "uc3d/sysclk.h"
+#elif UC3L
+# include "uc3l/sysclk.h"
+#elif XMEGA
+# include "xmega/sysclk.h"
+#elif MEGA
+# include "mega/sysclk.h"
+#else
+# error Unsupported chip type
+#endif
+
+/**
+ * \defgroup clk_group Clock Management
+ */
+
+/**
+ * \ingroup clk_group
+ * \defgroup sysclk_group System Clock Management
+ *
+ * See \ref sysclk_quickstart.
+ *
+ * The sysclk API covers the system clock and all
+ * clocks derived from it. The system clock is a chip-internal clock on
+ * which all synchronous clocks, i.e. CPU and bus/peripheral
+ * clocks, are based. The system clock is typically generated from one
+ * of a variety of sources, which may include crystal and RC oscillators
+ * as well as PLLs. The clocks derived from the system clock are
+ * sometimes also known as synchronous clocks, since they
+ * always run synchronously with respect to each other, as opposed to
+ * generic clocks which may run from different oscillators or
+ * PLLs.
+ *
+ * Most applications should simply call sysclk_init() to initialize
+ * everything related to the system clock and its source (oscillator,
+ * PLL or DFLL), and leave it at that. More advanced applications, and
+ * platform-specific drivers, may require additional services from the
+ * clock system, some of which may be platform-specific.
+ *
+ * \section sysclk_group_platform Platform Dependencies
+ *
+ * The sysclk API is partially chip- or platform-specific. While all
+ * platforms provide mostly the same functionality, there are some
+ * variations around how different bus types and clock tree structures
+ * are handled.
+ *
+ * The following functions are available on all platforms with the same
+ * parameters and functionality. These functions may be called freely by
+ * portable applications, drivers and services:
+ * - sysclk_init()
+ * - sysclk_set_source()
+ * - sysclk_get_main_hz()
+ * - sysclk_get_cpu_hz()
+ * - sysclk_get_peripheral_bus_hz()
+ *
+ * The following functions are available on all platforms, but there may
+ * be variations in the function signature (i.e. parameters) and
+ * behavior. These functions are typically called by platform-specific
+ * parts of drivers, and applications that aren't intended to be
+ * portable:
+ * - sysclk_enable_peripheral_clock()
+ * - sysclk_disable_peripheral_clock()
+ * - sysclk_enable_module()
+ * - sysclk_disable_module()
+ * - sysclk_module_is_enabled()
+ * - sysclk_set_prescalers()
+ *
+ * All other functions should be considered platform-specific.
+ * Enabling/disabling clocks to specific peripherals as well as
+ * determining the speed of these clocks should be done by calling
+ * functions provided by the driver for that peripheral.
+ *
+ * @{
+ */
+
+//! \name System Clock Initialization
+//@{
+/**
+ * \fn void sysclk_init(void)
+ * \brief Initialize the synchronous clock system.
+ *
+ * This function will initialize the system clock and its source. This
+ * includes:
+ * - Mask all synchronous clocks except for any clocks which are
+ * essential for normal operation (for example internal memory
+ * clocks).
+ * - Set up the system clock prescalers as specified by the
+ * application's configuration file.
+ * - Enable the clock source specified by the application's
+ * configuration file (oscillator or PLL) and wait for it to become
+ * stable.
+ * - Set the main system clock source to the clock specified by the
+ * application's configuration file.
+ *
+ * Since all non-essential peripheral clocks are initially disabled, it
+ * is the responsibility of the peripheral driver to re-enable any
+ * clocks that are needed for normal operation.
+ */
+//@}
+
+//! @}
+
+#endif /* SYSCLK_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/sysclk.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/sysclk.h.REMOVED.git-id
deleted file mode 100644
index ceed16d2..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/sysclk.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cd9457b517e66f743f67f3f698807f36425e3561
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/osc.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/osc.h
new file mode 100644
index 00000000..a37ad2cf
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/osc.h
@@ -0,0 +1,507 @@
+/**
+ * \file
+ *
+ * \brief Chip-specific oscillator management functions
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef XMEGA_OSC_H_INCLUDED
+#define XMEGA_OSC_H_INCLUDED
+
+#include
+#include
+
+/**
+ * \weakgroup osc_group
+ *
+ * \section osc_group_errata Errata
+ * - Auto-calibration does not work on XMEGA A1 revision H and
+ * earlier.
+ * @{
+ */
+
+//! \name Oscillator identifiers
+//@{
+//! 2 MHz Internal RC Oscillator
+#define OSC_ID_RC2MHZ OSC_RC2MEN_bm
+//! 32 MHz Internal RC Oscillator
+#define OSC_ID_RC32MHZ OSC_RC32MEN_bm
+//! 32 KHz Internal RC Oscillator
+#define OSC_ID_RC32KHZ OSC_RC32KEN_bm
+//! External Oscillator
+#define OSC_ID_XOSC OSC_XOSCEN_bm
+#if XMEGA_E
+//! 8 MHz Internal RC Oscillator
+# define OSC_ID_RC8MHZ OSC_RC8MEN_bm
+#endif
+
+/**
+ * \brief Reference from USB Start Of Frame
+ * \note This cannot be enabled or disabled, but can be used as a reference for
+ * the autocalibration (DFLL).
+ */
+#define OSC_ID_USBSOF 0xff
+//@}
+
+//! \name External oscillator types
+//@{
+#define XOSC_TYPE_EXTERNAL 0 //!< External clock signal
+#define XOSC_TYPE_32KHZ 2 //!< 32.768 kHz resonator on TOSC
+#define XOSC_TYPE_XTAL 3 //!< 0.4 to 16 MHz resonator on XTAL
+//@}
+
+/**
+ * \def CONFIG_XOSC_32KHZ_LPM
+ * \brief Define for enabling Low Power Mode for 32 kHz external oscillator.
+ */
+#ifdef __DOXYGEN__
+# define CONFIG_XOSC_32KHZ_LPM
+#endif /* __DOXYGEN__ */
+
+/**
+ * \def CONFIG_XOSC_STARTUP
+ * \brief Board-dependent value that determines the number of start-up cycles
+ * for external resonators, based on BOARD_XOSC_STARTUP_US. This is written to
+ * the two MSB of the XOSCSEL field of OSC.XOSCCTRL.
+ *
+ * \note This is automatically computed from BOARD_XOSC_HZ and
+ * BOARD_XOSC_STARTUP_US if it is not manually set.
+ */
+
+//! \name XTAL resonator start-up cycles
+//@{
+#define XOSC_STARTUP_256 0 //!< 256 cycle start-up time
+#define XOSC_STARTUP_1024 1 //!< 1 k cycle start-up time
+#define XOSC_STARTUP_16384 2 //!< 16 k cycle start-up time
+//@}
+
+/**
+ * \def CONFIG_XOSC_RANGE
+ * \brief Board-dependent value that sets the frequency range of the external
+ * oscillator. This is written to the FRQRANGE field of OSC.XOSCCTRL.
+ *
+ * \note This is automatically computed from BOARD_XOSC_HZ if it is not manually
+ * set.
+ */
+
+//! \name XTAL resonator frequency range
+//@{
+//! 0.4 to 2 MHz frequency range
+#define XOSC_RANGE_04TO2 OSC_FRQRANGE_04TO2_gc
+//! 2 to 9 MHz frequency range
+#define XOSC_RANGE_2TO9 OSC_FRQRANGE_2TO9_gc
+//! 9 to 12 MHz frequency range
+#define XOSC_RANGE_9TO12 OSC_FRQRANGE_9TO12_gc
+//! 12 to 16 MHz frequency range
+#define XOSC_RANGE_12TO16 OSC_FRQRANGE_12TO16_gc
+//@}
+
+/**
+ * \def XOSC_STARTUP_TIMEOUT
+ * \brief Number of us to wait for XOSC to start
+ *
+ * This is the number of slow clock cycles corresponding to
+ * OSC0_STARTUP_VALUE with an additional 25% safety margin. If the
+ * oscillator isn't running when this timeout has expired, it is assumed
+ * to have failed to start.
+ */
+
+// If application intends to use XOSC.
+#ifdef BOARD_XOSC_HZ
+// Get start-up config for XOSC, if not manually set.
+# ifndef CONFIG_XOSC_STARTUP
+# ifndef BOARD_XOSC_STARTUP_US
+# error BOARD_XOSC_STARTUP_US must be configured.
+# else
+//! \internal Number of start-up cycles for the board's XOSC.
+# define BOARD_XOSC_STARTUP_CYCLES \
+ (BOARD_XOSC_HZ / 1000000 * BOARD_XOSC_STARTUP_US)
+
+# if (BOARD_XOSC_TYPE == XOSC_TYPE_XTAL)
+# if (BOARD_XOSC_STARTUP_CYCLES > 16384)
+# error BOARD_XOSC_STARTUP_US is too high for current BOARD_XOSC_HZ.
+
+# elif (BOARD_XOSC_STARTUP_CYCLES > 1024)
+# define CONFIG_XOSC_STARTUP XOSC_STARTUP_16384
+# define XOSC_STARTUP_TIMEOUT (16384*(1000000/BOARD_XOSC_HZ))
+
+# elif (BOARD_XOSC_STARTUP_CYCLES > 256)
+# define CONFIG_XOSC_STARTUP XOSC_STARTUP_1024
+# define XOSC_STARTUP_TIMEOUT (1024*(1000000/BOARD_XOSC_HZ))
+
+# else
+# define CONFIG_XOSC_STARTUP XOSC_STARTUP_256
+# define XOSC_STARTUP_TIMEOUT (256*(1000000/BOARD_XOSC_HZ))
+# endif
+# else /* BOARD_XOSC_TYPE == XOSC_TYPE_XTAL */
+# define CONFIG_XOSC_STARTUP 0
+# endif
+# endif /* BOARD_XOSC_STARTUP_US */
+# endif /* CONFIG_XOSC_STARTUP */
+
+// Get frequency range setting for XOSC, if not manually set.
+# ifndef CONFIG_XOSC_RANGE
+# if (BOARD_XOSC_TYPE == XOSC_TYPE_XTAL)
+# if (BOARD_XOSC_HZ < 400000)
+# error BOARD_XOSC_HZ is below minimum frequency of 400 kHz.
+
+# elif (BOARD_XOSC_HZ < 2000000)
+# define CONFIG_XOSC_RANGE XOSC_RANGE_04TO2
+
+# elif (BOARD_XOSC_HZ < 9000000)
+# define CONFIG_XOSC_RANGE XOSC_RANGE_2TO9
+
+# elif (BOARD_XOSC_HZ < 12000000)
+# define CONFIG_XOSC_RANGE XOSC_RANGE_9TO12
+
+# elif (BOARD_XOSC_HZ <= 16000000)
+# define CONFIG_XOSC_RANGE XOSC_RANGE_12TO16
+
+# else
+# error BOARD_XOSC_HZ is above maximum frequency of 16 MHz.
+# endif
+# else /* BOARD_XOSC_TYPE == XOSC_TYPE_XTAL */
+# define CONFIG_XOSC_RANGE 0
+# endif
+# endif /* CONFIG_XOSC_RANGE */
+#endif /* BOARD_XOSC_HZ */
+
+#ifndef __ASSEMBLY__
+
+/**
+ * \internal
+ * \brief Enable internal oscillator \a id
+ *
+ * Do not call this function directly. Use osc_enable() instead.
+ */
+static inline void osc_enable_internal(uint8_t id)
+{
+ irqflags_t flags;
+
+ Assert(id != OSC_ID_USBSOF);
+
+ flags = cpu_irq_save();
+ OSC.CTRL |= id;
+#if (XMEGA_E && CONFIG_SYSCLK_RC8MHZ_LPM)
+ if(id == OSC_ID_RC8MHZ) {
+ OSC.CTRL |= OSC_RC8MLPM_bm;
+ }
+#endif
+ cpu_irq_restore(flags);
+}
+
+#if defined(BOARD_XOSC_HZ) || defined(__DOXYGEN__)
+
+/**
+ * \internal
+ * \brief Enable external oscillator \a id
+ *
+ * Do not call this function directly. Use osc_enable() instead. Also
+ * note that this function is only available if the board actually has
+ * an external oscillator crystal.
+ */
+static inline void osc_enable_external(uint8_t id)
+{
+ irqflags_t flags;
+
+ Assert(id == OSC_ID_XOSC);
+
+#ifndef CONFIG_XOSC_32KHZ_LPM
+# if (XMEGA_E && (BOARD_XOSC_TYPE == XOSC_TYPE_EXTERNAL) && defined(CONFIG_XOSC_EXTERNAL_PC4))
+ OSC.XOSCCTRL = OSC_XOSCSEL4_bm;
+# else
+ OSC.XOSCCTRL = BOARD_XOSC_TYPE | (CONFIG_XOSC_STARTUP << 2) |
+ CONFIG_XOSC_RANGE;
+# endif
+#else
+ OSC.XOSCCTRL = BOARD_XOSC_TYPE | (CONFIG_XOSC_STARTUP << 2) |
+ CONFIG_XOSC_RANGE | OSC_X32KLPM_bm;
+#endif /* CONFIG_XOSC_32KHZ_LPM */
+
+ flags = cpu_irq_save();
+ OSC.CTRL |= id;
+ cpu_irq_restore(flags);
+}
+#else
+
+static inline void osc_enable_external(uint8_t id)
+{
+ Assert(false); // No external oscillator on the selected board
+}
+#endif
+
+static inline void osc_disable(uint8_t id)
+{
+ irqflags_t flags;
+
+ Assert(id != OSC_ID_USBSOF);
+
+ flags = cpu_irq_save();
+ OSC.CTRL &= ~id;
+ cpu_irq_restore(flags);
+}
+
+static inline void osc_enable(uint8_t id)
+{
+ if (id != OSC_ID_XOSC) {
+ osc_enable_internal(id);
+ } else {
+ osc_enable_external(id);
+ }
+}
+
+static inline bool osc_is_ready(uint8_t id)
+{
+ Assert(id != OSC_ID_USBSOF);
+
+ return OSC.STATUS & id;
+}
+
+//! \name XMEGA-Specific Oscillator Features
+//@{
+
+/**
+ * \brief Enable DFLL-based automatic calibration of an internal
+ * oscillator.
+ *
+ * The XMEGA features two Digital Frequency Locked Loops (DFLLs) which
+ * can be used to improve the accuracy of the 2 MHz and 32 MHz internal
+ * RC oscillators. The DFLL compares the oscillator frequency with a
+ * more accurate reference clock to do automatic run-time calibration of
+ * the oscillator.
+ *
+ * This function enables auto-calibration for either the 2 MHz or 32 MHz
+ * internal oscillator using either the 32.768 kHz calibrated internal
+ * oscillator or an external crystal oscillator as a reference. If the
+ * latter option is used, the crystal must be connected to the TOSC pins
+ * and run at 32.768 kHz.
+ *
+ * \param id The ID of the oscillator for which to enable
+ * auto-calibration:
+ * \arg \c OSC_ID_RC2MHZ or \c OSC_ID_RC32MHZ.
+ * \param ref_id The ID of the oscillator to use as a reference:
+ * \arg \c OSC_ID_RC32KHZ or \c OSC_ID_XOSC for internal or external 32 kHz
+ * reference, respectively.
+ * \arg \c OSC_ID_USBSOF for 32 MHz only when USB is available and running.
+ */
+static inline void osc_enable_autocalibration(uint8_t id, uint8_t ref_id)
+{
+ irqflags_t flags;
+
+ flags = cpu_irq_save();
+ switch (id) {
+ case OSC_ID_RC2MHZ:
+#if !XMEGA_E
+ Assert((ref_id == OSC_ID_RC32KHZ) || (ref_id == OSC_ID_XOSC));
+ if (ref_id == OSC_ID_XOSC) {
+ osc_enable(OSC_ID_RC32KHZ);
+ OSC.DFLLCTRL |= OSC_RC2MCREF_bm;
+ } else {
+ OSC.DFLLCTRL &= ~(OSC_RC2MCREF_bm);
+ }
+ DFLLRC2M.CTRL |= DFLL_ENABLE_bm;
+#endif
+ break;
+
+ case OSC_ID_RC32MHZ:
+#if XMEGA_AU || XMEGA_B || XMEGA_C || XMEGA_E
+ Assert((ref_id == OSC_ID_RC32KHZ)
+ || (ref_id == OSC_ID_XOSC)
+# if !XMEGA_E
+ || (ref_id == OSC_ID_USBSOF)
+#endif
+ );
+
+ OSC.DFLLCTRL &= ~(OSC_RC32MCREF_gm);
+
+ if (ref_id == OSC_ID_XOSC) {
+ osc_enable(OSC_ID_RC32KHZ);
+ OSC.DFLLCTRL |= OSC_RC32MCREF_XOSC32K_gc;
+ }
+ else if (ref_id == OSC_ID_RC32KHZ) {
+ OSC.DFLLCTRL |= OSC_RC32MCREF_RC32K_gc;
+ }
+# if !XMEGA_E
+ else if (ref_id == OSC_ID_USBSOF) {
+ /*
+ * Calibrate 32MRC at 48MHz using USB SOF
+ * 48MHz / 1kHz = 0xBB80
+ */
+ DFLLRC32M.COMP1 = 0x80;
+ DFLLRC32M.COMP2 = 0xBB;
+ OSC.DFLLCTRL |= OSC_RC32MCREF_USBSOF_gc;
+ }
+# endif
+#else
+ Assert((ref_id == OSC_ID_RC32KHZ) ||
+ (ref_id == OSC_ID_XOSC));
+
+# if defined(OSC_RC32MCREF_gm)
+ OSC.DFLLCTRL &= ~(OSC_RC32MCREF_gm);
+# endif
+
+ if (ref_id == OSC_ID_XOSC) {
+ osc_enable(OSC_ID_RC32KHZ);
+# if defined(OSC_RC32MCREF_gm)
+ OSC.DFLLCTRL |= OSC_RC32MCREF_XOSC32K_gc;
+# else
+ OSC.DFLLCTRL |= OSC_RC32MCREF_bm;
+# endif
+ }
+ else if (ref_id == OSC_ID_RC32KHZ) {
+# if defined(OSC_RC32MCREF_gm)
+ OSC.DFLLCTRL |= OSC_RC32MCREF_RC32K_gc;
+# else
+ OSC.DFLLCTRL &= ~(OSC_RC32MCREF_bm);
+# endif
+ }
+#endif
+
+ DFLLRC32M.CTRL |= DFLL_ENABLE_bm;
+ break;
+
+ default:
+ Assert(false);
+ break;
+ }
+ cpu_irq_restore(flags);
+}
+
+/**
+ * \brief Disable DFLL-based automatic calibration of an internal
+ * oscillator.
+ *
+ * \see osc_enable_autocalibration
+ *
+ * \param id The ID of the oscillator for which to disable
+ * auto-calibration:
+ * \arg \c OSC_ID_RC2MHZ or \c OSC_ID_RC32MHZ.
+ */
+static inline void osc_disable_autocalibration(uint8_t id)
+{
+ switch (id) {
+ case OSC_ID_RC2MHZ:
+#if !XMEGA_E
+ DFLLRC2M.CTRL = 0;
+#endif
+ break;
+
+ case OSC_ID_RC32MHZ:
+ DFLLRC32M.CTRL = 0;
+ break;
+
+ default:
+ Assert(false);
+ break;
+ }
+}
+
+/**
+ * \brief Load a specific calibration value for the specified oscillator.
+ *
+ * \param id The ID of the oscillator for which to disable
+ * auto-calibration:
+ * \arg \c OSC_ID_RC2MHZ or \c OSC_ID_RC32MHZ.
+ * \param calib The specific calibration value required:
+ *
+ */
+static inline void osc_user_calibration(uint8_t id, uint16_t calib)
+{
+ switch (id) {
+ case OSC_ID_RC2MHZ:
+#if !XMEGA_E
+ DFLLRC2M.CALA=LSB(calib);
+ DFLLRC2M.CALB=MSB(calib);
+#endif
+ break;
+
+ case OSC_ID_RC32MHZ:
+ DFLLRC32M.CALA=LSB(calib);
+ DFLLRC32M.CALB=MSB(calib);
+ break;
+
+#if XMEGA_E
+ case OSC_ID_RC8MHZ:
+ OSC.RC8MCAL=LSB(calib);
+ break;
+#endif
+
+ default:
+ Assert(false);
+ break;
+ }
+}
+//@}
+
+static inline uint32_t osc_get_rate(uint8_t id)
+{
+ Assert(id != OSC_ID_USBSOF);
+
+ switch (id) {
+ case OSC_ID_RC2MHZ:
+ return 2000000UL;
+
+ case OSC_ID_RC32MHZ:
+#ifdef CONFIG_OSC_RC32_CAL
+ return CONFIG_OSC_RC32_CAL;
+#else
+ return 32000000UL;
+#endif
+
+ case OSC_ID_RC32KHZ:
+ return 32768UL;
+
+#ifdef BOARD_XOSC_HZ
+ case OSC_ID_XOSC:
+ return BOARD_XOSC_HZ;
+#endif
+
+ default:
+ Assert(false);
+ return 0;
+ }
+}
+
+#endif /* __ASSEMBLY__ */
+
+//! @}
+
+#endif /* XMEGA_OSC_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/osc.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/osc.h.REMOVED.git-id
deleted file mode 100644
index bbff3c1a..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/osc.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a37ad2cf9d6be3bb6c2e598169991056b1957bfc
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/pll.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/pll.h
new file mode 100644
index 00000000..b3254c77
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/pll.h
@@ -0,0 +1,274 @@
+/**
+ * \file
+ *
+ * \brief Chip-specific PLL management functions
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef XMEGA_PLL_H_INCLUDED
+#define XMEGA_PLL_H_INCLUDED
+
+#include
+
+/**
+ * \weakgroup pll_group
+ * @{
+ */
+
+#define NR_PLLS 1
+#define PLL_MIN_HZ 10000000UL
+#define PLL_MAX_HZ 200000000UL
+#define PLL_NR_OPTIONS 0
+
+enum pll_source {
+ //! 2 MHz Internal RC Oscillator
+ PLL_SRC_RC2MHZ = OSC_PLLSRC_RC2M_gc,
+ //! 32 MHz Internal RC Oscillator
+ PLL_SRC_RC32MHZ = OSC_PLLSRC_RC32M_gc,
+ //! External Clock Source
+ PLL_SRC_XOSC = OSC_PLLSRC_XOSC_gc,
+};
+
+#define pll_get_default_rate(pll_id) \
+ pll_get_default_rate_priv(CONFIG_PLL##pll_id##_SOURCE, \
+ CONFIG_PLL##pll_id##_MUL, \
+ CONFIG_PLL##pll_id##_DIV)
+
+/**
+ * \internal
+ * \brief Return clock rate for specified PLL settings.
+ *
+ * \note Due to the hardware implementation of the PLL, \a div must be 4 if the
+ * 32 MHz RC oscillator is used as reference and 1 otherwise. The reference must
+ * be above 440 kHz, and the output between 10 and 200 MHz.
+ *
+ * \param src ID of the PLL's reference source oscillator.
+ * \param mul Multiplier for the PLL.
+ * \param div Divisor for the PLL.
+ *
+ * \retval Output clock rate from PLL.
+ */
+static inline uint32_t pll_get_default_rate_priv(enum pll_source src,
+ unsigned int mul, unsigned int div)
+{
+ uint32_t rate;
+
+ switch (src) {
+ case PLL_SRC_RC2MHZ:
+ rate = 2000000UL;
+ Assert(div == 1);
+ break;
+
+ case PLL_SRC_RC32MHZ:
+#ifdef CONFIG_OSC_RC32_CAL //32MHz oscillator is calibrated to another frequency
+ rate = CONFIG_OSC_RC32_CAL / 4;
+#else
+ rate = 8000000UL;
+ #endif
+ Assert(div == 4);
+ break;
+
+ case PLL_SRC_XOSC:
+ rate = osc_get_rate(OSC_ID_XOSC);
+ Assert(div == 1);
+ break;
+
+ default:
+ break;
+ }
+
+ Assert(rate >= 440000UL);
+
+ rate *= mul;
+
+ Assert(rate >= PLL_MIN_HZ);
+ Assert(rate <= PLL_MAX_HZ);
+
+ return rate;
+}
+
+struct pll_config {
+ uint8_t ctrl;
+};
+
+/**
+ * \note The XMEGA PLL hardware uses hard-wired input dividers, so the
+ * user must ensure that \a div is set as follows:
+ * - If \a src is PLL_SRC_32MHZ, \a div must be set to 4.
+ * - Otherwise, \a div must be set to 1.
+ */
+static inline void pll_config_init(struct pll_config *cfg, enum pll_source src,
+ unsigned int div, unsigned int mul)
+{
+ Assert(mul >= 1 && mul <= 31);
+
+ if (src == PLL_SRC_RC32MHZ) {
+ Assert(div == 4);
+ } else {
+ Assert(div == 1);
+ }
+
+ /* Initialize the configuration */
+ cfg->ctrl = src | (mul << OSC_PLLFAC_gp);
+}
+
+#define pll_config_defaults(cfg, pll_id) \
+ pll_config_init(cfg, \
+ CONFIG_PLL##pll_id##_SOURCE, \
+ CONFIG_PLL##pll_id##_DIV, \
+ CONFIG_PLL##pll_id##_MUL)
+
+static inline void pll_config_read(struct pll_config *cfg, unsigned int pll_id)
+{
+ Assert(pll_id < NR_PLLS);
+
+ cfg->ctrl = OSC.PLLCTRL;
+}
+
+static inline void pll_config_write(const struct pll_config *cfg,
+ unsigned int pll_id)
+{
+ Assert(pll_id < NR_PLLS);
+
+ OSC.PLLCTRL = cfg->ctrl;
+}
+
+/**
+ * \note If a different PLL reference oscillator than those enabled by
+ * \ref sysclk_init() is used, the user must ensure that the desired reference
+ * is enabled prior to calling this function.
+ */
+static inline void pll_enable(const struct pll_config *cfg,
+ unsigned int pll_id)
+{
+ irqflags_t flags;
+
+ Assert(pll_id < NR_PLLS);
+
+ flags = cpu_irq_save();
+ pll_config_write(cfg, pll_id);
+ OSC.CTRL |= OSC_PLLEN_bm;
+ cpu_irq_restore(flags);
+}
+
+/*! \note This will not automatically disable the reference oscillator that is
+ * configured for the PLL.
+ */
+static inline void pll_disable(unsigned int pll_id)
+{
+ irqflags_t flags;
+
+ Assert(pll_id < NR_PLLS);
+
+ flags = cpu_irq_save();
+ OSC.CTRL &= ~OSC_PLLEN_bm;
+ cpu_irq_restore(flags);
+}
+
+static inline bool pll_is_locked(unsigned int pll_id)
+{
+ Assert(pll_id < NR_PLLS);
+
+ return OSC.STATUS & OSC_PLLRDY_bm;
+}
+
+static inline void pll_enable_source(enum pll_source src)
+{
+ switch (src) {
+ case PLL_SRC_RC2MHZ:
+ break;
+
+ case PLL_SRC_RC32MHZ:
+ if (!osc_is_ready(OSC_ID_RC32MHZ)) {
+ osc_enable(OSC_ID_RC32MHZ);
+ osc_wait_ready(OSC_ID_RC32MHZ);
+#ifdef CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+ if (CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+ != OSC_ID_USBSOF) {
+ osc_enable(CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+ osc_wait_ready(CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+ }
+ osc_enable_autocalibration(OSC_ID_RC32MHZ,
+ CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+#endif
+ }
+ break;
+
+ case PLL_SRC_XOSC:
+ if (!osc_is_ready(OSC_ID_XOSC)) {
+ osc_enable(OSC_ID_XOSC);
+ osc_wait_ready(OSC_ID_XOSC);
+ }
+ break;
+ default:
+ Assert(false);
+ break;
+ }
+}
+
+static inline void pll_enable_config_defaults(unsigned int pll_id)
+{
+ struct pll_config pllcfg;
+
+ if (pll_is_locked(pll_id)) {
+ return; // Pll already running
+ }
+ switch (pll_id) {
+#ifdef CONFIG_PLL0_SOURCE
+ case 0:
+ pll_enable_source(CONFIG_PLL0_SOURCE);
+ pll_config_init(&pllcfg,
+ CONFIG_PLL0_SOURCE,
+ CONFIG_PLL0_DIV,
+ CONFIG_PLL0_MUL);
+ break;
+#endif
+ default:
+ Assert(false);
+ break;
+ }
+ pll_enable(&pllcfg, pll_id);
+ while (!pll_is_locked(pll_id));
+}
+
+//! @}
+
+#endif /* XMEGA_PLL_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/pll.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/pll.h.REMOVED.git-id
deleted file mode 100644
index b26aa0ba..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/pll.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b3254c7778142cd0ad66cc5108d2277b393cc014
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.c
new file mode 100644
index 00000000..103c131b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.c
@@ -0,0 +1,260 @@
+/**
+ * \file
+ *
+ * \brief Chip-specific system clock management functions
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include
+
+#include
+#include
+#include
+
+#if XMEGA_AU || XMEGA_B || XMEGA_C
+# include
+#endif
+
+
+void sysclk_init(void)
+{
+ uint8_t *reg = (uint8_t *)&PR.PRGEN;
+ uint8_t i;
+#ifdef CONFIG_OSC_RC32_CAL
+ uint16_t cal;
+ /* avoid Cppcheck Warning */
+ UNUSED(cal);
+#endif
+ bool need_rc2mhz = false;
+
+ /* Turn off all peripheral clocks that can be turned off. */
+ for (i = 0; i <= SYSCLK_PORT_F; i++) {
+ *(reg++) = 0xff;
+ }
+
+ /* Set up system clock prescalers if different from defaults */
+ if ((CONFIG_SYSCLK_PSADIV != SYSCLK_PSADIV_1)
+ || (CONFIG_SYSCLK_PSBCDIV != SYSCLK_PSBCDIV_1_1)) {
+ sysclk_set_prescalers(CONFIG_SYSCLK_PSADIV,
+ CONFIG_SYSCLK_PSBCDIV);
+ }
+#if (CONFIG_OSC_RC32_CAL==48000000UL)
+ MSB(cal) = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(USBRCOSC));
+ LSB(cal) = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(USBRCOSCA));
+ /*
+ * If a device has an uncalibrated value in the
+ * production signature row (early sample part), load a
+ * sane default calibration value.
+ */
+ if (cal == 0xFFFF) {
+ cal = 0x2340;
+ }
+ osc_user_calibration(OSC_ID_RC32MHZ,cal);
+#endif
+ /*
+ * Switch to the selected initial system clock source, unless
+ * the default internal 2 MHz oscillator is selected.
+ */
+ if (CONFIG_SYSCLK_SOURCE == SYSCLK_SRC_RC2MHZ) {
+ need_rc2mhz = true;
+ } else {
+ switch (CONFIG_SYSCLK_SOURCE) {
+ case SYSCLK_SRC_RC32MHZ:
+ osc_enable(OSC_ID_RC32MHZ);
+ osc_wait_ready(OSC_ID_RC32MHZ);
+#ifdef CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+ if (CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+ != OSC_ID_USBSOF) {
+ osc_enable(CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+ osc_wait_ready(CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+ }
+ osc_enable_autocalibration(OSC_ID_RC32MHZ,
+ CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+#endif
+ break;
+
+ case SYSCLK_SRC_RC32KHZ:
+ osc_enable(OSC_ID_RC32KHZ);
+ osc_wait_ready(OSC_ID_RC32KHZ);
+ break;
+
+ case SYSCLK_SRC_XOSC:
+ osc_enable(OSC_ID_XOSC);
+ osc_wait_ready(OSC_ID_XOSC);
+ break;
+
+#ifdef CONFIG_PLL0_SOURCE
+ case SYSCLK_SRC_PLL:
+ if (CONFIG_PLL0_SOURCE == PLL_SRC_RC2MHZ) {
+ need_rc2mhz = true;
+ }
+ pll_enable_config_defaults(0);
+ break;
+#endif
+#if XMEGA_E
+ case SYSCLK_SRC_RC8MHZ:
+ osc_enable(OSC_ID_RC8MHZ);
+ osc_wait_ready(OSC_ID_RC8MHZ);
+ break;
+#endif
+ default:
+ //unhandled_case(CONFIG_SYSCLK_SOURCE);
+ return;
+ }
+
+ ccp_write_io((uint8_t *)&CLK.CTRL, CONFIG_SYSCLK_SOURCE);
+ Assert(CLK.CTRL == CONFIG_SYSCLK_SOURCE);
+ }
+
+ if (need_rc2mhz) {
+#ifdef CONFIG_OSC_AUTOCAL_RC2MHZ_REF_OSC
+ osc_enable(CONFIG_OSC_AUTOCAL_RC2MHZ_REF_OSC);
+ osc_wait_ready(CONFIG_OSC_AUTOCAL_RC2MHZ_REF_OSC);
+ osc_enable_autocalibration(OSC_ID_RC2MHZ,
+ CONFIG_OSC_AUTOCAL_RC2MHZ_REF_OSC);
+#endif
+ } else {
+ osc_disable(OSC_ID_RC2MHZ);
+ }
+
+#ifdef CONFIG_RTC_SOURCE
+ sysclk_rtcsrc_enable(CONFIG_RTC_SOURCE);
+#endif
+}
+
+void sysclk_enable_module(enum sysclk_port_id port, uint8_t id)
+{
+ irqflags_t flags = cpu_irq_save();
+
+ *((uint8_t *)&PR.PRGEN + port) &= ~id;
+
+ cpu_irq_restore(flags);
+}
+
+void sysclk_disable_module(enum sysclk_port_id port, uint8_t id)
+{
+ irqflags_t flags = cpu_irq_save();
+
+ *((uint8_t *)&PR.PRGEN + port) |= id;
+
+ cpu_irq_restore(flags);
+}
+
+#if XMEGA_AU || XMEGA_B || XMEGA_C || defined(__DOXYGEN__)
+
+/**
+ * \brief Enable clock for the USB module
+ *
+ * \pre CONFIG_USBCLK_SOURCE must be defined.
+ *
+ * \param frequency The required USB clock frequency in MHz:
+ * \arg \c 6 for 6 MHz
+ * \arg \c 48 for 48 MHz
+ */
+void sysclk_enable_usb(uint8_t frequency)
+{
+ uint8_t prescaler;
+
+ Assert((frequency == 6) || (frequency == 48));
+
+ /*
+ * Enable or disable prescaler depending on if the USB frequency is 6
+ * MHz or 48 MHz. Only 6 MHz USB frequency requires prescaling.
+ */
+ if (frequency == 6) {
+ prescaler = CLK_USBPSDIV_8_gc;
+ }
+ else {
+ prescaler = 0;
+ }
+
+ /*
+ * Switch to the system clock selected by the user.
+ */
+ switch (CONFIG_USBCLK_SOURCE) {
+ case USBCLK_SRC_RCOSC:
+ if (!osc_is_ready(OSC_ID_RC32MHZ)) {
+ osc_enable(OSC_ID_RC32MHZ);
+ osc_wait_ready(OSC_ID_RC32MHZ);
+#ifdef CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+ if (CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+ != OSC_ID_USBSOF) {
+ osc_enable(CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+ osc_wait_ready(CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+ }
+ osc_enable_autocalibration(OSC_ID_RC32MHZ,
+ CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC);
+#endif
+ }
+ ccp_write_io((uint8_t *)&CLK.USBCTRL, (prescaler)
+ | CLK_USBSRC_RC32M_gc
+ | CLK_USBSEN_bm);
+ break;
+
+#ifdef CONFIG_PLL0_SOURCE
+ case USBCLK_SRC_PLL:
+ pll_enable_config_defaults(0);
+ ccp_write_io((uint8_t *)&CLK.USBCTRL, (prescaler)
+ | CLK_USBSRC_PLL_gc
+ | CLK_USBSEN_bm);
+ break;
+#endif
+
+ default:
+ Assert(false);
+ break;
+ }
+
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_USB);
+}
+
+/**
+ * \brief Disable clock for the USB module
+ */
+void sysclk_disable_usb(void)
+{
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_USB);
+ ccp_write_io((uint8_t *)&CLK.USBCTRL, 0);
+}
+#endif // XMEGA_AU || XMEGA_B || XMEGA_C
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.c.REMOVED.git-id
deleted file mode 100644
index 5e10f37a..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-103c131b686868352cb9e9733ae5a3b56aae2478
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.h
new file mode 100644
index 00000000..062a4462
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.h
@@ -0,0 +1,1534 @@
+/**
+ * \file
+ *
+ * \brief Chip-specific system clock management functions
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef XMEGA_SYSCLK_H_INCLUDED
+#define XMEGA_SYSCLK_H_INCLUDED
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+// Include clock configuration for the project.
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \page sysclk_quickstart Quick Start Guide for the System Clock Management service (XMEGA)
+ *
+ * This is the quick start guide for the \ref sysclk_group "System Clock Management"
+ * service, with step-by-step instructions on how to configure and use the service for
+ * specific use cases.
+ *
+ * \section sysclk_quickstart_usecases System Clock Management use cases
+ * - \ref sysclk_quickstart_basic
+ * - \ref sysclk_quickstart_use_case_2
+ * - \ref sysclk_quickstart_use_case_3
+ *
+ * \section sysclk_quickstart_basic Basic usage of the System Clock Management service
+ * This section will present a basic use case for the System Clock Management service.
+ * This use case will configure the main system clock to 32MHz, using an internal PLL
+ * module to multiply the frequency of a crystal attached to the microcontroller. The
+ * secondary peripheral bus clock and CPU clock are scaled down from the speed of the
+ * main system clock.
+ *
+ * \subsection sysclk_quickstart_use_case_1_prereq Prerequisites
+ * - None
+ *
+ * \subsection sysclk_quickstart_use_case_1_setup_steps Initialization code
+ * Add to the application initialization code:
+ * \code
+ sysclk_init();
+\endcode
+ *
+ * \subsection sysclk_quickstart_use_case_1_setup_steps_workflow Workflow
+ * -# Configure the system clocks according to the settings in conf_clock.h:
+ * \code sysclk_init(); \endcode
+ *
+ * \subsection sysclk_quickstart_use_case_1_example_code Example code
+ * Add or uncomment the following in your conf_clock.h header file, commenting out all other
+ * definitions of the same symbol(s):
+ * \code
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL
+
+ // Fpll0 = (Fclk * PLL_mul) / PLL_div
+ #define CONFIG_PLL0_SOURCE PLL_SRC_XOSC
+ #define CONFIG_PLL0_MUL (32000000UL / BOARD_XOSC_HZ)
+ #define CONFIG_PLL0_DIV 1
+
+ // Fbus = Fsys / (2 ^ BUS_div)
+ #define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1
+ #define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_2
+\endcode
+ *
+ * \subsection sysclk_quickstart_use_case_1_example_workflow Workflow
+ * -# Configure the main system clock to use the output of the PLL module as its source:
+ * \code #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL \endcode
+ * -# Configure the PLL0 module to use external crystal oscillator XOSC as its source:
+ * \code #define CONFIG_PLL0_SOURCE PLL_SRC_XOSC \endcode
+ * -# Configure the PLL0 module to multiply the external oscillator XOSC frequency up to 32MHz:
+ * \code
+ #define CONFIG_PLL0_MUL (32000000UL / BOARD_XOSC_HZ)
+ #define CONFIG_PLL0_DIV 1
+\endcode
+ * \note For user boards, \c BOARD_XOSC_HZ should be defined in the board \c conf_board.h configuration
+ * file as the frequency of the crystal attached to XOSC.
+ * -# Configure the main CPU clock and slow peripheral bus to run at 16MHz, run the fast peripheral bus
+ * at the full 32MHz speed:
+ * \code
+ #define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1
+ #define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_2
+\endcode
+ * \note Some dividers are powers of two, while others are integer division factors. Refer to the
+ * formulas in the conf_clock.h template commented above each division define.
+ */
+
+/**
+ * \page sysclk_quickstart_use_case_2 Advanced use case - Peripheral Bus Clock Management (XMEGA)
+ *
+ * \section sysclk_quickstart_use_case_2 Advanced use case - Peripheral Bus Clock Management
+ * This section will present a more advanced use case for the System Clock Management service.
+ * This use case will configure the main system clock to 32MHz, using an internal PLL
+ * module to multiply the frequency of a crystal attached to the microcontroller. The peripheral bus
+ * clocks will run at the same speed as the CPU clock, and the USB clock will be configured to use
+ * the internal 32MHz (nominal) RC oscillator calibrated to 48MHz with the USB Start-of-Frame as the
+ * calibration reference.
+ *
+ * \subsection sysclk_quickstart_use_case_2_prereq Prerequisites
+ * - None
+ *
+ * \subsection sysclk_quickstart_use_case_2_setup_steps Initialization code
+ * Add to the application initialization code:
+ * \code
+ sysclk_init();
+\endcode
+ *
+ * \subsection sysclk_quickstart_use_case_2_setup_steps_workflow Workflow
+ * -# Configure the system clocks according to the settings in conf_clock.h:
+ * \code sysclk_init(); \endcode
+ *
+ * \subsection sysclk_quickstart_use_case_2_example_code Example code
+ * Add or uncomment the following in your conf_clock.h header file, commenting out all other
+ * definitions of the same symbol(s):
+ * \code
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL
+
+ // Fpll0 = (Fclk * PLL_mul) / PLL_div
+ #define CONFIG_PLL0_SOURCE PLL_SRC_XOSC
+ #define CONFIG_PLL0_MUL (32000000UL / BOARD_XOSC_HZ)
+ #define CONFIG_PLL0_DIV 1
+
+ // Fbus = Fsys / (2 ^ BUS_div)
+ #define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1
+ #define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1
+
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+ #define CONFIG_OSC_RC32_CAL 48000000UL
+ #define CONFIG_OSC_AUTOCAL OSC_ID_RC32MHZ
+ #define CONFIG_OSC_AUTOCAL_REF_OSC OSC_ID_USBSOF
+\endcode
+ *
+ * \subsection sysclk_quickstart_use_case_2_example_workflow Workflow
+ * -# Configure the main system clock to use the output of the PLL module as its source:
+ * \code #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL \endcode
+ * -# Configure the PLL0 module to use external crystal oscillator XOSC as its source:
+ * \code #define CONFIG_PLL0_SOURCE PLL_SRC_XOSC \endcode
+ * -# Configure the PLL0 module to multiply the external oscillator XOSC frequency up to 32MHz:
+ * \code
+ #define CONFIG_PLL0_MUL (32000000UL / BOARD_XOSC_HZ)
+ #define CONFIG_PLL0_DIV 1
+\endcode
+ * \note For user boards, \c BOARD_XOSC_HZ should be defined in the board \c conf_board.h configuration
+ * file as the frequency of the crystal attached to XOSC.
+ * -# Configure the main CPU and peripheral bus clocks to run at 32MHz:
+ * \code
+ #define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1
+ #define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_2
+\endcode
+ * \note Some dividers are powers of two, while others are integer division factors. Refer to the
+ * formulas in the conf_clock.h template commented above each division define.
+ * -# Configure the USB module clock to use the internal fast (32MHz) RC oscillator:
+ * \code
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+\endcode
+ * \note When the internal RC oscillator is used for the USB module, it must be recalibrated to 48MHz for
+ * the USB peripheral to function. If this oscillator is then used as the main system clock source,
+ * the clock must be divided down via the peripheral and CPU bus clock division constants to ensure
+ * that the maximum allowable CPU frequency is not exceeded.
+ * -# Configure the internal fast (32MHz) RC oscillator to calibrate to 48MHz using the USB Start of Frame (SOF)
+ * as the calibration reference:
+ * \code
+ #define CONFIG_OSC_RC32_CAL 48000000UL
+ #define CONFIG_OSC_AUTOCAL OSC_ID_RC32MHZ
+ #define CONFIG_OSC_AUTOCAL_REF_OSC OSC_ID_USBSOF
+\endcode
+ */
+
+/**
+ * \page sysclk_quickstart_use_case_3 Advanced use case - DFLL auto-calibration (XMEGA)
+ *
+ * \section sysclk_quickstart_use_case_3 Advanced use case - DFLL auto-calibration
+ * This section will present a more advanced use case for the System Clock
+ * Management service. This use case will configure the main system clock to
+ * 2MHz, using the internal 2MHz RC oscillator calibrated against the internal
+ * 32KHz oscillator. The peripheral bus clocks will run at the same speed as
+ * the CPU clock, and the USB clock will be configured to use the internal
+ * 32MHz (nominal) RC oscillator calibrated to 48MHz with the USB
+ * Start-of-Frame as the calibration reference.
+ *
+ * \subsection sysclk_quickstart_use_case_3_prereq Prerequisites
+ * - None
+ *
+ * \subsection sysclk_quickstart_use_case_3_setup_steps Initialization code
+ * Add to the application initialization code:
+ * \code
+ sysclk_init();
+\endcode
+ *
+ * \subsection sysclk_quickstart_use_case_3_setup_steps_workflow Workflow
+ * -# Configure the system clocks according to the settings in conf_clock.h:
+ * \code sysclk_init(); \endcode
+ *
+ * \subsection sysclk_quickstart_use_case_3_example_code Example code
+ * Add or uncomment the following in your conf_clock.h header file,
+ * commenting out all other definitions of the same symbol(s):
+ * \code
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC2MHZ
+
+ #define CONFIG_OSC_AUTOCAL_RC2MHZ_REF_OSC OSC_ID_RC32KHZ
+
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+ #define CONFIG_OSC_RC32_CAL 48000000UL
+ #define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC OSC_ID_USBSOF
+\endcode
+ *
+ * \subsection sysclk_quickstart_use_case_3_example_workflow Workflow
+ * -# Configure the main system clock to use the internal 2MHz RC oscillator
+ * as its source:
+ * \code
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC2MHZ
+\endcode
+ * -# Configure the 2MHz DFLL auto-calibration to use the internal 32KHz RC
+ * oscillator:
+ * \code
+ #define CONFIG_OSC_AUTOCAL_RC2MHZ_REF_OSC OSC_ID_RC32KHZ
+\endcode
+ * \note For auto-calibration it's typically more relevant to use an external
+ * 32KHz crystal. So if that's the case use OSC_ID_XOSC instead.
+ * -# Configure the USB module clock to use the internal fast (32MHz) RC oscillator:
+ * \code
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+\endcode
+ * -# Configure the internal fast (32MHz) RC oscillator to calibrate to 48MHz
+ * using the USB Start of Frame (SOF) as the calibration reference:
+ * \code
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+ #define CONFIG_OSC_RC32_CAL 48000000UL
+ #define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC OSC_ID_USBSOF
+\endcode
+ */
+
+/* Wrap old config into new one */
+#ifdef CONFIG_OSC_AUTOCAL
+# if CONFIG_OSC_AUTOCAL == OSC_ID_RC2MHZ
+# define CONFIG_OSC_AUTOCAL_RC2MHZ_REF_OSC CONFIG_OSC_AUTOCAL_REF_OSC
+# elif CONFIG_OSC_AUTOCAL == OSC_ID_RC32MHZ
+# define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC CONFIG_OSC_AUTOCAL_REF_OSC
+# else
+# error Bad configuration of CONFIG_OSC_AUTOCAL and/or CONFIG_OSC_AUTOCAL_REF_OSC
+# endif
+#endif
+
+// Use 2 MHz with no prescaling if config was empty.
+#ifndef CONFIG_SYSCLK_SOURCE
+# define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC2MHZ
+#endif /* CONFIG_SYSCLK_SOURCE */
+
+#ifndef CONFIG_SYSCLK_PSADIV
+# define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_1
+#endif /* CONFIG_SYSCLK_PSADIV */
+
+#ifndef CONFIG_SYSCLK_PSBCDIV
+# define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1
+#endif /* CONFIG_SYSCLK_PSBCDIV */
+
+/**
+ * \weakgroup sysclk_group
+ *
+ * \section sysclk_group_config Configuration Symbols
+ *
+ * The following configuration symbols may be used to specify the
+ * initial system clock configuration. If any of the symbols are not
+ * set, reasonable defaults will be provided.
+ * - \b CONFIG_SYSCLK_SOURCE: The initial system clock source.
+ * - \b CONFIG_SYSCLK_PSADIV: The initial Prescaler A setting.
+ * - \b CONFIG_SYSCLK_PSBCDIV: The initial Prescaler B setting.
+ * - \b CONFIG_USBCLK_SOURCE: The initial USB clock source.
+ *
+ * @{
+ */
+
+//! \name System Clock Sources
+//@{
+//! Internal 2 MHz RC oscillator
+#define SYSCLK_SRC_RC2MHZ CLK_SCLKSEL_RC2M_gc
+//! Internal 32 MHz RC oscillator
+#define SYSCLK_SRC_RC32MHZ CLK_SCLKSEL_RC32M_gc
+//! Internal 32 KHz RC oscillator
+#define SYSCLK_SRC_RC32KHZ CLK_SCLKSEL_RC32K_gc
+//! External oscillator
+#define SYSCLK_SRC_XOSC CLK_SCLKSEL_XOSC_gc
+//! Phase-Locked Loop
+#define SYSCLK_SRC_PLL CLK_SCLKSEL_PLL_gc
+#if XMEGA_E
+//! Internal 8 MHz RC oscillator
+# define SYSCLK_SRC_RC8MHZ CLK_SCLKSEL_RC8M_gc
+#endif
+//@}
+
+//! \name Prescaler A Setting (relative to CLKsys)
+//@{
+#define SYSCLK_PSADIV_1 CLK_PSADIV_1_gc //!< Do not prescale
+#define SYSCLK_PSADIV_2 CLK_PSADIV_2_gc //!< Prescale CLKper4 by 2
+#define SYSCLK_PSADIV_4 CLK_PSADIV_4_gc //!< Prescale CLKper4 by 4
+#define SYSCLK_PSADIV_8 CLK_PSADIV_8_gc //!< Prescale CLKper4 by 8
+#define SYSCLK_PSADIV_16 CLK_PSADIV_16_gc //!< Prescale CLKper4 by 16
+#define SYSCLK_PSADIV_32 CLK_PSADIV_32_gc //!< Prescale CLKper4 by 32
+#define SYSCLK_PSADIV_64 CLK_PSADIV_64_gc //!< Prescale CLKper4 by 64
+#define SYSCLK_PSADIV_128 CLK_PSADIV_128_gc //!< Prescale CLKper4 by 128
+#define SYSCLK_PSADIV_256 CLK_PSADIV_256_gc //!< Prescale CLKper4 by 256
+#define SYSCLK_PSADIV_512 CLK_PSADIV_512_gc //!< Prescale CLKper4 by 512
+
+#if XMEGA_E
+# define SYSCLK_PSADIV_6 CLK_PSADIV_6_gc //!< Prescale CLKper4 by 6
+# define SYSCLK_PSADIV_10 CLK_PSADIV_10_gc //!< Prescale CLKper4 by 10
+# define SYSCLK_PSADIV_12 CLK_PSADIV_12_gc //!< Prescale CLKper4 by 12
+# define SYSCLK_PSADIV_24 CLK_PSADIV_24_gc //!< Prescale CLKper4 by 24
+# define SYSCLK_PSADIV_48 CLK_PSADIV_48_gc //!< Prescale CLKper4 by 48
+#endif
+//@}
+
+//! \name Prescaler B and C Setting (relative to CLKper4)
+//@{
+//! Do not prescale
+#define SYSCLK_PSBCDIV_1_1 CLK_PSBCDIV_1_1_gc
+//! Prescale CLKper and CLKcpu by 2
+#define SYSCLK_PSBCDIV_1_2 CLK_PSBCDIV_1_2_gc
+//! Prescale CLKper2, CLKper and CLKcpu by 4
+#define SYSCLK_PSBCDIV_4_1 CLK_PSBCDIV_4_1_gc
+//! Prescale CLKper2 by 2, CLKper and CLKcpu by 4
+#define SYSCLK_PSBCDIV_2_2 CLK_PSBCDIV_2_2_gc
+//@}
+
+//! \name System Clock Port Numbers
+enum sysclk_port_id {
+ SYSCLK_PORT_GEN, //!< Devices not associated with a specific port.
+ SYSCLK_PORT_A, //!< Devices on PORTA
+ SYSCLK_PORT_B, //!< Devices on PORTB
+ SYSCLK_PORT_C, //!< Devices on PORTC
+ SYSCLK_PORT_D, //!< Devices on PORTD
+ SYSCLK_PORT_E, //!< Devices on PORTE
+ SYSCLK_PORT_F, //!< Devices on PORTF
+};
+
+/*! \name Clocks not associated with any port
+ *
+ * \note See the datasheet for available modules in the device.
+ */
+//@{
+#define SYSCLK_DMA PR_DMA_bm //!< DMA Controller
+#define SYSCLK_EDMA PR_EDMA_bm //!< EDMA Controller
+#define SYSCLK_EVSYS PR_EVSYS_bm //!< Event System
+#define SYSCLK_RTC PR_RTC_bm //!< Real-Time Counter
+#define SYSCLK_EBI PR_EBI_bm //!< Ext Bus Interface
+#define SYSCLK_AES PR_AES_bm //!< AES Module
+#define SYSCLK_USB PR_USB_bm //!< USB Module
+#define SYSCLK_XCL PR_XCL_bm //!< USB Module
+//@}
+
+/*! \name Clocks on PORTA and PORTB
+ *
+ * \note See the datasheet for available modules in the device.
+ */
+//@{
+#define SYSCLK_AC PR_AC_bm //!< Analog Comparator
+#define SYSCLK_ADC PR_ADC_bm //!< A/D Converter
+#define SYSCLK_DAC PR_DAC_bm //!< D/A Converter
+//@}
+
+/*! \name Clocks on PORTC, PORTD, PORTE and PORTF
+ *
+ * \note See the datasheet for available modules in the device.
+ */
+//@{
+#define SYSCLK_TC0 PR_TC0_bm //!< Timer/Counter 0
+#define SYSCLK_TC1 PR_TC1_bm //!< Timer/Counter 1
+#define SYSCLK_TC4 PR_TC4_bm //!< Timer/Counter 0
+#define SYSCLK_TC5 PR_TC5_bm //!< Timer/Counter 1
+#define SYSCLK_HIRES PR_HIRES_bm //!< Hi-Res Extension
+#define SYSCLK_SPI PR_SPI_bm //!< SPI controller
+#define SYSCLK_USART0 PR_USART0_bm //!< USART 0
+#define SYSCLK_USART1 PR_USART1_bm //!< USART 1
+#define SYSCLK_TWI PR_TWI_bm //!< TWI controller
+//@}
+
+/**
+ * \name RTC clock source identifiers
+ *
+ * @{
+ */
+
+/** 1kHz from internal ULP oscillator. Low precision */
+#define SYSCLK_RTCSRC_ULP CLK_RTCSRC_ULP_gc
+/** 1.024kHz from 32.768kHz crystal oscillator TOSC */
+#define SYSCLK_RTCSRC_TOSC CLK_RTCSRC_TOSC_gc
+/** 1.024kHz from 32.768kHz internal RC oscillator */
+#define SYSCLK_RTCSRC_RCOSC CLK_RTCSRC_RCOSC_gc
+/** 32.768kHz from crystal oscillator TOSC */
+#define SYSCLK_RTCSRC_TOSC32 CLK_RTCSRC_TOSC32_gc
+/** 32.768kHz from internal RC oscillator */
+#define SYSCLK_RTCSRC_RCOSC32 CLK_RTCSRC_RCOSC32_gc
+/** External clock on TOSC1 */
+#define SYSCLK_RTCSRC_EXTCLK CLK_RTCSRC_EXTCLK_gc
+
+/** @} */
+
+#if XMEGA_AU || XMEGA_B || XMEGA_C
+//! \name USB Clock Sources
+//@{
+//! Internal 32 MHz RC oscillator
+#define USBCLK_SRC_RCOSC 0
+//! Phase-Locked Loop
+#define USBCLK_SRC_PLL 1
+//@}
+
+/**
+ * \def CONFIG_USBCLK_SOURCE
+ * \brief Configuration symbol for the USB clock source
+ *
+ * If the device features an USB module, and this is intended to be used, this
+ * symbol must be defined with the clock source configuration.
+ *
+ * Define this as one of the \c USBCLK_SRC_xxx definitions. If the PLL is
+ * selected, it must be configured to run at 48 MHz. If the 32 MHz RC oscillator
+ * is selected, it must be tuned to 48 MHz by means of the DFLL.
+ */
+#ifdef __DOXYGEN__
+# define CONFIG_USBCLK_SOURCE
+#endif
+
+#endif // XMEGA_AU || XMEGA_B || XMEGA_C
+
+#ifndef __ASSEMBLY__
+
+/**
+ * \name Querying the system clock and its derived clocks
+ */
+//@{
+
+/**
+ * \brief Return the current rate in Hz of the main system clock
+ *
+ * \todo This function assumes that the main clock source never changes
+ * once it's been set up, and that PLL0 always runs at the compile-time
+ * configured default rate. While this is probably the most common
+ * configuration, which we want to support as a special case for
+ * performance reasons, we will at some point need to support more
+ * dynamic setups as well.
+ *
+ * \return Frequency of the main system clock, in Hz.
+ */
+static inline uint32_t sysclk_get_main_hz(void)
+{
+ switch (CONFIG_SYSCLK_SOURCE) {
+ case SYSCLK_SRC_RC2MHZ:
+ return 2000000UL;
+#if XMEGA_E
+ case SYSCLK_SRC_RC8MHZ:
+ return 8000000UL;
+#endif
+ case SYSCLK_SRC_RC32MHZ:
+#ifdef CONFIG_OSC_RC32_CAL
+ return CONFIG_OSC_RC32_CAL;
+#else
+ return 32000000UL;
+#endif
+
+ case SYSCLK_SRC_RC32KHZ:
+ return 32768UL;
+
+#ifdef BOARD_XOSC_HZ
+ case SYSCLK_SRC_XOSC:
+ return BOARD_XOSC_HZ;
+#endif
+
+#ifdef CONFIG_PLL0_SOURCE
+ case SYSCLK_SRC_PLL:
+ return pll_get_default_rate(0);
+#endif
+
+ default:
+ //unhandled_case(CONFIG_SYSCLK_SOURCE);
+ return 0;
+ }
+}
+
+/**
+ * \brief Return the current rate in Hz of clk_PER4.
+ *
+ * This clock can run up to four times faster than the CPU clock.
+ *
+ * \return Frequency of the clk_PER4 clock, in Hz.
+ */
+static inline uint32_t sysclk_get_per4_hz(void)
+{
+ uint8_t shift = 0;
+
+#if XMEGA_E
+ if (CONFIG_SYSCLK_PSADIV > SYSCLK_PSADIV_512) {
+ switch (CONFIG_SYSCLK_PSADIV) {
+ case SYSCLK_PSADIV_6:
+ return sysclk_get_main_hz() / 6;
+ case SYSCLK_PSADIV_10:
+ return sysclk_get_main_hz() / 10;
+ case SYSCLK_PSADIV_12:
+ return sysclk_get_main_hz() / 12;
+ case SYSCLK_PSADIV_24:
+ return sysclk_get_main_hz() / 24;
+ case SYSCLK_PSADIV_48:
+ return sysclk_get_main_hz() / 48;
+ default:
+ //unhandled_case;
+ return 0;
+ }
+ }
+#endif
+ if (CONFIG_SYSCLK_PSADIV & (1U << CLK_PSADIV_gp)) {
+ shift = (CONFIG_SYSCLK_PSADIV >> (1 + CLK_PSADIV_gp)) + 1;
+ }
+
+ return sysclk_get_main_hz() >> shift;
+}
+
+/**
+ * \brief Return the current rate in Hz of clk_PER2.
+ *
+ * This clock can run up to two times faster than the CPU clock.
+ *
+ * \return Frequency of the clk_PER2 clock, in Hz.
+ */
+static inline uint32_t sysclk_get_per2_hz(void)
+{
+ switch (CONFIG_SYSCLK_PSBCDIV) {
+ case SYSCLK_PSBCDIV_1_1: /* Fall through */
+ case SYSCLK_PSBCDIV_1_2:
+ return sysclk_get_per4_hz();
+
+ case SYSCLK_PSBCDIV_4_1:
+ return sysclk_get_per4_hz() / 4;
+
+ case SYSCLK_PSBCDIV_2_2:
+ return sysclk_get_per4_hz() / 2;
+
+ default:
+ //unhandled_case(CONFIG_SYSCLK_PSBCDIV);
+ return 0;
+ }
+}
+
+/**
+ * \brief Return the current rate in Hz of clk_PER.
+ *
+ * This clock always runs at the same rate as the CPU clock unless the divider
+ * is set.
+ *
+ * \return Frequency of the clk_PER clock, in Hz.
+ */
+static inline uint32_t sysclk_get_per_hz(void)
+{
+ if (CONFIG_SYSCLK_PSBCDIV & (1U << CLK_PSBCDIV_gp))
+ return sysclk_get_per2_hz() / 2;
+ else
+ return sysclk_get_per2_hz();
+}
+
+/**
+ * \brief Return the current rate in Hz of the CPU clock.
+ *
+ * \return Frequency of the CPU clock, in Hz.
+ */
+static inline uint32_t sysclk_get_cpu_hz(void)
+{
+ return sysclk_get_per_hz();
+}
+
+/**
+ * \brief Retrieves the current rate in Hz of the Peripheral Bus clock attached
+ * to the specified peripheral.
+ *
+ * \param module Pointer to the module's base address.
+ *
+ * \return Frequency of the bus attached to the specified peripheral, in Hz.
+ */
+static inline uint32_t sysclk_get_peripheral_bus_hz(const volatile void *module)
+{
+ if (module == NULL) {
+ Assert(false);
+ return 0;
+ }
+#ifdef AES
+ else if (module == &AES) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef EBI
+ else if (module == &EBI) {
+ return sysclk_get_per2_hz();
+ }
+#endif
+#ifdef RTC
+ else if (module == &RTC) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef EVSYS
+ else if (module == &EVSYS) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef DMA
+ else if (module == &DMA) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef EDMA
+ else if (module == &EDMA) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef ACA
+ else if (module == &ACA) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef ACB
+ else if (module == &ACB) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef ADCA
+ else if (module == &ADCA) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef ADCB
+ else if (module == &ADCB) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef DACA
+ else if (module == &DACA) {
+ return sysclk_get_per_hz();
+ }
+#endif
+// Workaround for bad XMEGA D header file
+#if !XMEGA_D
+#ifdef DACB
+ else if (module == &DACB) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#endif // Workaround end
+#ifdef FAULTC0
+ else if (module == &FAULTC0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef FAULTC1
+ else if (module == &FAULTC1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCC0
+ else if (module == &TCC0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCD0
+ else if (module == &TCD0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCE0
+ else if (module == &TCE0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCF0
+ else if (module == &TCF0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCC1
+ else if (module == &TCC1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCD1
+ else if (module == &TCD1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCE1
+ else if (module == &TCE1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCF1
+ else if (module == &TCF1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCC4
+ else if (module == &TCC4) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCC5
+ else if (module == &TCC5) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCD4
+ else if (module == &TCD4) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TCD5
+ else if (module == &TCD5) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef HIRESC
+ else if (module == &HIRESC) {
+ return sysclk_get_per4_hz();
+ }
+#endif
+#ifdef HIRESD
+ else if (module == &HIRESD) {
+ return sysclk_get_per4_hz();
+ }
+#endif
+#ifdef HIRESE
+ else if (module == &HIRESE) {
+ return sysclk_get_per4_hz();
+ }
+#endif
+#ifdef HIRESF
+ else if (module == &HIRESF) {
+ return sysclk_get_per4_hz();
+ }
+#endif
+#ifdef SPIC
+ else if (module == &SPIC) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef SPID
+ else if (module == &SPID) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef SPIE
+ else if (module == &SPIE) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef SPIF
+ else if (module == &SPIF) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTC0
+ else if (module == &USARTC0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTD0
+ else if (module == &USARTD0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTE0
+ else if (module == &USARTE0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTF0
+ else if (module == &USARTF0) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTC1
+ else if (module == &USARTC1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTD1
+ else if (module == &USARTD1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTE1
+ else if (module == &USARTE1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef USARTF1
+ else if (module == &USARTF1) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TWIC
+ else if (module == &TWIC) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TWID
+ else if (module == &TWID) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TWIE
+ else if (module == &TWIE) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef TWIF
+ else if (module == &TWIF) {
+ return sysclk_get_per_hz();
+ }
+#endif
+#ifdef XCL
+ else if (module == &XCL) {
+ return sysclk_get_per_hz();
+ }
+#endif
+ else {
+ Assert(false);
+ return 0;
+ }
+}
+
+//@}
+
+//! \name Enabling and disabling synchronous clocks
+//@{
+
+/**
+ * \brief Enable the clock to peripheral \a id on port \a port
+ *
+ * \param port ID of the port to which the module is connected (one of
+ * the \c SYSCLK_PORT_* definitions).
+ * \param id The ID (bitmask) of the peripheral module to be enabled.
+ */
+extern void sysclk_enable_module(enum sysclk_port_id port, uint8_t id);
+
+/**
+ * \brief Disable the clock to peripheral \a id on port \a port
+ *
+ * \param port ID of the port to which the module is connected (one of
+ * the \c SYSCLK_PORT_* definitions).
+ * \param id The ID (bitmask) of the peripheral module to be disabled.
+ */
+extern void sysclk_disable_module(enum sysclk_port_id port, uint8_t id);
+
+/**
+ * \brief Enable a peripheral's clock from its base address.
+ *
+ * Enables the clock to a peripheral, given its base address. If the peripheral
+ * has an associated clock on the HSB bus, this will be enabled also.
+ *
+ * \param module Pointer to the module's base address.
+ */
+static inline void sysclk_enable_peripheral_clock(const volatile void *module)
+{
+ if (module == NULL) {
+ Assert(false);
+ }
+#ifdef AES
+ else if (module == &AES) {
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_AES);
+ }
+#endif
+#ifdef EBI
+ else if (module == &EBI) {
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_EBI);
+ }
+#endif
+#ifdef RTC
+ else if (module == &RTC) {
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC);
+ }
+#endif
+#ifdef EVSYS
+ else if (module == &EVSYS) {
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_EVSYS);
+ }
+#endif
+#ifdef DMA
+ else if (module == &DMA) {
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_DMA);
+ }
+#endif
+#ifdef EDMA
+ else if (module == &EDMA) {
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_EDMA);
+ }
+#endif
+#ifdef ACA
+ else if (module == &ACA) {
+ sysclk_enable_module(SYSCLK_PORT_A, SYSCLK_AC);
+ }
+#endif
+#ifdef ACB
+ else if (module == &ACB) {
+ sysclk_enable_module(SYSCLK_PORT_B, SYSCLK_AC);
+ }
+#endif
+#ifdef ADCA
+ else if (module == &ADCA) {
+ sysclk_enable_module(SYSCLK_PORT_A, SYSCLK_ADC);
+ }
+#endif
+#ifdef ADCB
+ else if (module == &ADCB) {
+ sysclk_enable_module(SYSCLK_PORT_B, SYSCLK_ADC);
+ }
+#endif
+#ifdef DACA
+ else if (module == &DACA) {
+ sysclk_enable_module(SYSCLK_PORT_A, SYSCLK_DAC);
+ }
+#endif
+// Workaround for bad XMEGA D header file
+#if !XMEGA_D
+#ifdef DACB
+ else if (module == &DACB) {
+ sysclk_enable_module(SYSCLK_PORT_B, SYSCLK_DAC);
+ }
+#endif
+#endif // Workaround end
+#ifdef TCC0
+ else if (module == &TCC0) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCD0
+ else if (module == &TCD0) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCE0
+ else if (module == &TCE0) {
+ sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCF0
+ else if (module == &TCF0) {
+ sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCC1
+ else if (module == &TCC1) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCD1
+ else if (module == &TCD1) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCE1
+ else if (module == &TCE1) {
+ sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCF1
+ else if (module == &TCF1) {
+ sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCC4
+ else if (module == &TCC4) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC4);
+ }
+#endif
+#ifdef TCC5
+ else if (module == &TCC5) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TC5);
+ }
+#endif
+#ifdef TCD4
+ else if (module == &TCD4) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC4);
+ }
+#endif
+#ifdef TCD5
+ else if (module == &TCD5) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TC5);
+ }
+#endif
+#ifdef HIRESC
+ else if (module == &HIRESC) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_HIRES);
+ }
+#endif
+#ifdef HIRESD
+ else if (module == &HIRESD) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_HIRES);
+ }
+#endif
+#ifdef HIRESE
+ else if (module == &HIRESE) {
+ sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_HIRES);
+ }
+#endif
+#ifdef HIRESF
+ else if (module == &HIRESF) {
+ sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_HIRES);
+ }
+#endif
+#ifdef SPIC
+ else if (module == &SPIC) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_SPI);
+ }
+#endif
+#ifdef SPID
+ else if (module == &SPID) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_SPI);
+ }
+#endif
+#ifdef SPIE
+ else if (module == &SPIE) {
+ sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_SPI);
+ }
+#endif
+#ifdef SPIF
+ else if (module == &SPIF) {
+ sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_SPI);
+ }
+#endif
+#ifdef USARTC0
+ else if (module == &USARTC0) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTD0
+ else if (module == &USARTD0) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTE0
+ else if (module == &USARTE0) {
+ sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTF0
+ else if (module == &USARTF0) {
+ sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTC1
+ else if (module == &USARTC1) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_USART1);
+ }
+#endif
+#ifdef USARTD1
+ else if (module == &USARTD1) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_USART1);
+ }
+#endif
+#ifdef USARTE1
+ else if (module == &USARTE1) {
+ sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_USART1);
+ }
+#endif
+#ifdef USARTF1
+ else if (module == &USARTF1) {
+ sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_USART1);
+ }
+#endif
+#ifdef TWIC
+ else if (module == &TWIC) {
+ sysclk_enable_module(SYSCLK_PORT_C, SYSCLK_TWI);
+ }
+#endif
+#ifdef TWID
+ else if (module == &TWID) {
+ sysclk_enable_module(SYSCLK_PORT_D, SYSCLK_TWI);
+ }
+#endif
+#ifdef TWIE
+ else if (module == &TWIE) {
+ sysclk_enable_module(SYSCLK_PORT_E, SYSCLK_TWI);
+ }
+#endif
+#ifdef TWIF
+ else if (module == &TWIF) {
+ sysclk_enable_module(SYSCLK_PORT_F, SYSCLK_TWI);
+ }
+#endif
+#ifdef XCL
+ else if (module == &XCL) {
+ sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_XCL);
+ }
+#endif
+ else {
+ Assert(false);
+ }
+}
+
+/**
+ * \brief Disable a peripheral's clock from its base address.
+ *
+ * Disables the clock to a peripheral, given its base address. If the peripheral
+ * has an associated clock on the HSB bus, this will be disabled also.
+ *
+ * \param module Pointer to the module's base address.
+ */
+static inline void sysclk_disable_peripheral_clock(const volatile void *module)
+{
+ if (module == NULL) {
+ Assert(false);
+ }
+#ifdef AES
+ else if (module == &AES) {
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_AES);
+ }
+#endif
+#ifdef EBI
+ else if (module == &EBI) {
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_EBI);
+ }
+#endif
+#ifdef RTC
+ else if (module == &RTC) {
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_RTC);
+ }
+#endif
+#ifdef EVSYS
+ else if (module == &EVSYS) {
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_EVSYS);
+ }
+#endif
+#ifdef DMA
+ else if (module == &DMA) {
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_DMA);
+ }
+#endif
+#ifdef EDMA
+ else if (module == &EDMA) {
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_EDMA);
+ }
+#endif
+#ifdef ACA
+ else if (module == &ACA) {
+ sysclk_disable_module(SYSCLK_PORT_A, SYSCLK_AC);
+ }
+#endif
+#ifdef ACB
+ else if (module == &ACB) {
+ sysclk_disable_module(SYSCLK_PORT_B, SYSCLK_AC);
+ }
+#endif
+#ifdef ADCA
+ else if (module == &ADCA) {
+ sysclk_disable_module(SYSCLK_PORT_A, SYSCLK_ADC);
+ }
+#endif
+#ifdef ADCB
+ else if (module == &ADCB) {
+ sysclk_disable_module(SYSCLK_PORT_B, SYSCLK_ADC);
+ }
+#endif
+#ifdef DACA
+ else if (module == &DACA) {
+ sysclk_disable_module(SYSCLK_PORT_A, SYSCLK_DAC);
+ }
+#endif
+// Workaround for bad XMEGA D header file
+#if !XMEGA_D
+#ifdef DACB
+ else if (module == &DACB) {
+ sysclk_disable_module(SYSCLK_PORT_B, SYSCLK_DAC);
+ }
+#endif
+#endif // Workaround end
+#ifdef TCC0
+ else if (module == &TCC0) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCD0
+ else if (module == &TCD0) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCE0
+ else if (module == &TCE0) {
+ sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCF0
+ else if (module == &TCF0) {
+ sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TC0);
+ }
+#endif
+#ifdef TCC1
+ else if (module == &TCC1) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCD1
+ else if (module == &TCD1) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCE1
+ else if (module == &TCE1) {
+ sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCF1
+ else if (module == &TCF1) {
+ sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TC1);
+ }
+#endif
+#ifdef TCC4
+ else if (module == &TCC4) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC4);
+ }
+#endif
+#ifdef TCC5
+ else if (module == &TCC5) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TC5);
+ }
+#endif
+#ifdef TCD4
+ else if (module == &TCD4) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC4);
+ }
+#endif
+#ifdef TCD5
+ else if (module == &TCD5) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TC5);
+ }
+#endif
+#ifdef HIRESC
+ else if (module == &HIRESC) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_HIRES);
+ }
+#endif
+#ifdef HIRESD
+ else if (module == &HIRESD) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_HIRES);
+ }
+#endif
+#ifdef HIRESE
+ else if (module == &HIRESE) {
+ sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_HIRES);
+ }
+#endif
+#ifdef HIRESF
+ else if (module == &HIRESF) {
+ sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_HIRES);
+ }
+#endif
+#ifdef SPIC
+ else if (module == &SPIC) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_SPI);
+ }
+#endif
+#ifdef SPID
+ else if (module == &SPID) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_SPI);
+ }
+#endif
+#ifdef SPIE
+ else if (module == &SPIE) {
+ sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_SPI);
+ }
+#endif
+#ifdef SPIF
+ else if (module == &SPIF) {
+ sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_SPI);
+ }
+#endif
+#ifdef USARTC0
+ else if (module == &USARTC0) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTD0
+ else if (module == &USARTD0) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTE0
+ else if (module == &USARTE0) {
+ sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTF0
+ else if (module == &USARTF0) {
+ sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_USART0);
+ }
+#endif
+#ifdef USARTC1
+ else if (module == &USARTC1) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_USART1);
+ }
+#endif
+#ifdef USARTD1
+ else if (module == &USARTD1) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_USART1);
+ }
+#endif
+#ifdef USARTE1
+ else if (module == &USARTE1) {
+ sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_USART1);
+ }
+#endif
+#ifdef USARTF1
+ else if (module == &USARTF1) {
+ sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_USART1);
+ }
+#endif
+#ifdef TWIC
+ else if (module == &TWIC) {
+ sysclk_disable_module(SYSCLK_PORT_C, SYSCLK_TWI);
+ }
+#endif
+#ifdef TWID
+ else if (module == &TWID) {
+ sysclk_disable_module(SYSCLK_PORT_D, SYSCLK_TWI);
+ }
+#endif
+#ifdef TWIE
+ else if (module == &TWIE) {
+ sysclk_disable_module(SYSCLK_PORT_E, SYSCLK_TWI);
+ }
+#endif
+#ifdef TWIF
+ else if (module == &TWIF) {
+ sysclk_disable_module(SYSCLK_PORT_F, SYSCLK_TWI);
+ }
+#endif
+#ifdef XCL
+ else if (module == &XCL) {
+ sysclk_disable_module(SYSCLK_PORT_GEN, SYSCLK_XCL);
+ }
+#endif
+ else {
+ Assert(false);
+ }
+}
+
+/**
+ * \brief Check if the synchronous clock is enabled for a module
+ *
+ * \param port ID of the port to which the module is connected (one of
+ * the \c SYSCLK_PORT_* definitions).
+ * \param id The ID (bitmask) of the peripheral module to check (one of
+ * the \c SYSCLK_* module definitions).
+ *
+ * \retval true If the clock for module \a id on \a port is enabled.
+ * \retval false If the clock for module \a id on \a port is disabled.
+ */
+static inline bool sysclk_module_is_enabled(enum sysclk_port_id port,
+ uint8_t id)
+{
+ uint8_t mask = *((uint8_t *)&PR.PRGEN + port);
+ return (mask & id) == 0;
+}
+
+#if XMEGA_AU || XMEGA_B || XMEGA_C || defined(__DOXYGEN__)
+# if defined(CONFIG_USBCLK_SOURCE) || defined(__DOXYGEN__)
+# if (CONFIG_USBCLK_SOURCE == USBCLK_SRC_RCOSC)
+# define USBCLK_STARTUP_TIMEOUT 1
+# elif (CONFIG_USBCLK_SOURCE == USBCLK_SRC_PLL)
+# if (CONFIG_PLL0_SOURCE == PLL_SRC_XOSC)
+# define USBCLK_STARTUP_TIMEOUT XOSC_STARTUP_TIMEOUT
+# elif (CONFIG_PLL0_SOURCE == PLL_SRC_RC32MHZ)
+# define USBCLK_STARTUP_TIMEOUT 1
+# elif (CONFIG_PLL0_SOURCE == PLL_SRC_RC2MHZ)
+# define USBCLK_STARTUP_TIMEOUT 1
+# else
+# error Unknow value for CONFIG_PLL0_SOURCE, see conf_clock.h.
+# endif
+# endif
+# else /* CONFIG_USBCLK_SOURCE not defined */
+# define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+# define USBCLK_STARTUP_TIMEOUT 1
+# endif /* CONFIG_USBCLK_SOURCE */
+void sysclk_enable_usb(uint8_t frequency);
+void sysclk_disable_usb(void);
+#endif /* XMEGA_AU || XMEGA_B || XMEGA_C */
+//@}
+
+//! \name System Clock Source and Prescaler configuration
+//@{
+
+/**
+ * \brief Set system clock prescaler configuration
+ *
+ * This function will change the system clock prescaler configuration to
+ * match the parameters.
+ *
+ * \note The parameters to this function are device-specific.
+ *
+ * \param psadiv The prescaler A setting (one of the \c SYSCLK_PSADIV_*
+ * definitions). This determines the clkPER4 frequency.
+ * \param psbcdiv The prescaler B and C settings (one of the \c SYSCLK_PSBCDIV_*
+ * definitions). These determine the clkPER2, clkPER and clkCPU frequencies.
+ */
+static inline void sysclk_set_prescalers(uint8_t psadiv, uint8_t psbcdiv)
+{
+ ccp_write_io((uint8_t *)&CLK.PSCTRL, psadiv | psbcdiv);
+}
+
+/**
+ * \brief Change the source of the main system clock.
+ *
+ * \param src The new system clock source. Must be one of the constants
+ * from the System Clock Sources section.
+ */
+static inline void sysclk_set_source(uint8_t src)
+{
+ ccp_write_io((uint8_t *)&CLK.CTRL, src);
+}
+
+/**
+ * \brief Lock the system clock configuration
+ *
+ * This function will lock the current system clock source and prescaler
+ * configuration, preventing any further changes.
+ */
+static inline void sysclk_lock(void)
+{
+ ccp_write_io((uint8_t *)&CLK.LOCK, CLK_LOCK_bm);
+}
+
+//@}
+
+/**
+ * \name RTC clock source control
+ * @{
+ */
+
+/**
+ * \brief Enable RTC clock with specified clock source
+ *
+ * \param id RTC clock source ID. Select from SYSCLK_RTCSRC_ULP,
+ * SYSCLK_RTCSRC_RCOSC, SYSCLK_RTCSRC_TOSC, SYSCLK_RTCSRC_RCOSC32,
+ * SYSCLK_RTCSRC_TOSC32 or SYSCLK_RTCSRC_EXTCLK
+ */
+static inline void sysclk_rtcsrc_enable(uint8_t id)
+{
+ Assert((id & ~CLK_RTCSRC_gm) == 0);
+
+ switch (id) {
+ case SYSCLK_RTCSRC_RCOSC:
+#if !XMEGA_A && !XMEGA_D
+ case SYSCLK_RTCSRC_RCOSC32:
+#endif
+ osc_enable(OSC_ID_RC32KHZ);
+ osc_wait_ready(OSC_ID_RC32KHZ);
+ break;
+ case SYSCLK_RTCSRC_TOSC:
+ case SYSCLK_RTCSRC_TOSC32:
+#if !XMEGA_A && !XMEGA_D
+ case SYSCLK_RTCSRC_EXTCLK:
+#endif
+ osc_enable(OSC_ID_XOSC);
+ osc_wait_ready(OSC_ID_XOSC);
+ break;
+ }
+
+ CLK.RTCCTRL = id | CLK_RTCEN_bm;
+}
+
+/**
+ * \brief Disable RTC clock
+ */
+static inline void sysclk_rtcsrc_disable(void)
+{
+ CLK.RTCCTRL = 0;
+}
+
+/** @} */
+
+//! \name System Clock Initialization
+//@{
+
+extern void sysclk_init(void);
+
+//@}
+
+#endif /* !__ASSEMBLY__ */
+
+//! @}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XMEGA_SYSCLK_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.h.REMOVED.git-id
deleted file mode 100644
index 4aa8716a..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/clock/xmega/sysclk.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-062a4462dce2581b8d87c172250bbf346d226198
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/delay.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/delay.h
new file mode 100644
index 00000000..c845e44b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/delay.h
@@ -0,0 +1,139 @@
+/**
+ * \file
+ *
+ * \brief Common Delay Service
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _DELAY_H_
+#define _DELAY_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include
+
+#if UC3
+# include
+#elif XMEGA
+# include "xmega/cycle_counter.h"
+#elif MEGA
+# include "mega/cycle_counter.h"
+#elif SAM
+# include "sam/cycle_counter.h"
+#endif
+
+/**
+ * @defgroup group_common_services_delay Busy-Wait Delay Routines
+ *
+ * This module provides simple loop-based delay routines for those
+ * applications requiring a brief wait during execution. Common API
+ * for UC3, XMEGA, and AVR MEGA.
+ *
+ * @{
+ */
+
+/**
+ * @def F_CPU
+ * @brief MCU Clock Frequency (Hertz)
+ *
+ * @deprecated
+ * The \ref F_CPU configuration constant is used for compatibility with the
+ * \ref group_common_services_delay routines. The common loop-based delay
+ * routines are designed to use the \ref clk_group modules while anticipating
+ * support for legacy applications assuming a statically defined clock
+ * frequency. Applications using a statically configured MCU clock frequency
+ * can define \ref F_CPU (Hertz), in which case the common delay routines will
+ * use this value rather than calling sysclk_get_cpu_hz() to get the current
+ * MCU clock frequency.
+ */
+#ifndef F_CPU
+# define F_CPU sysclk_get_cpu_hz()
+#endif
+
+/**
+ * @def delay_init
+ *
+ * @brief Initialize the delay driver.
+ * @param fcpu_hz CPU frequency in Hz
+ *
+ * @deprecated
+ * This function is provided for compatibility with ASF applications that
+ * may not have been updated to configure the system clock via the common
+ * clock service; e.g. sysclk_init() and a configuration header file are
+ * used to configure clocks.
+ *
+ * The functions in this module call \ref sysclk_get_cpu_hz() function to
+ * obtain the system clock frequency.
+ */
+#define delay_init(fcpu_hz)
+
+/**
+ * @def delay_s
+ * @brief Delay in seconds.
+ * @param delay Delay in seconds
+ */
+#define delay_s(delay) cpu_delay_ms(1000 * delay, F_CPU)
+
+/**
+ * @def delay_ms
+ * @brief Delay in milliseconds.
+ * @param delay Delay in milliseconds
+ */
+#define delay_ms(delay) cpu_delay_ms(delay, F_CPU)
+
+/**
+ * @def delay_us
+ * @brief Delay in microseconds.
+ * @param delay Delay in microseconds
+ */
+#define delay_us(delay) cpu_delay_us(delay, F_CPU)
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * @}
+ */
+
+#endif /* _DELAY_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/delay.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/delay.h.REMOVED.git-id
deleted file mode 100644
index 65a442ea..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/delay.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c845e44bac7b9b16b7f308066cdc09d04be43191
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/xmega/cycle_counter.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/xmega/cycle_counter.h
new file mode 100644
index 00000000..e67e520a
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/xmega/cycle_counter.h
@@ -0,0 +1,116 @@
+/**
+ * \file
+ *
+ * \brief AVR functions for busy-wait delay loops
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _CYCLE_COUNTER_H_
+#define _CYCLE_COUNTER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include
+
+/**
+ * @name Convenience functions for busy-wait delay loops
+ *
+ * @def delay_cycles
+ * @brief Delay program execution for a specified number of CPU cycles.
+ * @param n number of CPU cycles to wait
+ *
+ * @def cpu_delay_ms
+ * @brief Delay program execution for a specified number of milliseconds.
+ * @param delay number of milliseconds to wait
+ * @param f_cpu CPU frequency in Hertz
+ *
+ * @def cpu_delay_us
+ * @brief Delay program execution for a specified number of microseconds.
+ * @param delay number of microseconds to wait
+ * @param f_cpu CPU frequency in Hertz
+ *
+ * @def cpu_ms_2_cy
+ * @brief Convert milli-seconds into CPU cycles.
+ * @param ms number of milliseconds
+ * @param f_cpu CPU frequency in Hertz
+ * @return the converted number of CPU cycles
+ *
+ * @def cpu_us_2_cy
+ * @brief Convert micro-seconds into CPU cycles.
+ * @param ms number of microseconds
+ * @param f_cpu CPU frequency in Hertz
+ * @return the converted number of CPU cycles
+ *
+ * @{
+ */
+__always_optimize
+static inline void __portable_avr_delay_cycles(unsigned long n)
+{
+ do { barrier(); } while (--n);
+}
+
+#if !defined(__DELAY_CYCLE_INTRINSICS__)
+# define delay_cycles __portable_avr_delay_cycles
+# define cpu_ms_2_cy(ms, f_cpu) (((uint64_t)(ms) * (f_cpu) + 999) / 6e3)
+# define cpu_us_2_cy(us, f_cpu) (((uint64_t)(us) * (f_cpu) + 999999ul) / 6e6)
+#else
+# if defined(__GNUC__)
+# define delay_cycles __builtin_avr_delay_cycles
+# elif defined(__ICCAVR__)
+# define delay_cycles __delay_cycles
+# endif
+# define cpu_ms_2_cy(ms, f_cpu) (((uint64_t)(ms) * (f_cpu) + 999) / 1e3)
+# define cpu_us_2_cy(us, f_cpu) (((uint64_t)(us) * (f_cpu) + 999999ul) / 1e6)
+#endif
+
+#define cpu_delay_ms(delay, f_cpu) delay_cycles((uint64_t)cpu_ms_2_cy(delay, f_cpu))
+#define cpu_delay_us(delay, f_cpu) delay_cycles((uint64_t)cpu_us_2_cy(delay, f_cpu))
+//! @}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CYCLE_COUNTER_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/xmega/cycle_counter.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/xmega/cycle_counter.h.REMOVED.git-id
deleted file mode 100644
index a4bf8a94..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/delay/xmega/cycle_counter.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e67e520aad3e670d18d4a7e46ea3b52d41d455c6
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/docsrc/gfx_mono_overview.png b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/docsrc/gfx_mono_overview.png
new file mode 100644
index 00000000..1e85b6b9
Binary files /dev/null and b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/docsrc/gfx_mono_overview.png differ
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/docsrc/gfx_mono_overview.png.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/docsrc/gfx_mono_overview.png.REMOVED.git-id
deleted file mode 100644
index e074b2d1..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/docsrc/gfx_mono_overview.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1e85b6b922f786034e87b59f33489b4b1849073c
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono.h
new file mode 100644
index 00000000..c5488805
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono.h
@@ -0,0 +1,306 @@
+/**
+ * \file
+ *
+ * \brief Monochrome graphic library API header file
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef GFX_MONO_H
+#define GFX_MONO_H
+
+#include
+
+#include "compiler.h"
+#include "progmem.h"
+#ifdef CONFIG_HAVE_HUGEMEM
+# include "hugemem.h"
+#endif
+
+/**
+ * \defgroup gfx_mono Monochrome graphical display system
+ *
+ * See \ref gfx_mono_quickstart.
+ *
+ * This library provides an interface to drawing graphics on monochrome
+ * graphical displays
+ *
+ * The graphics drivers consists of the following:
+ * - Display driver interface (gfx_mono.h)
+ * - General graphics drawing primitives (gfx_mono_generic.h)
+ * - Display specific implementation (ex. gfx_mono_c12832_a1z.h)
+ *
+ * The generic drawing primitives is a library of functions for drawing
+ * graphics primitives such as lines, rectangles and circles. It uses other
+ * functions implemented by the display driver for drawing the primitives. The
+ * implementation of these functions can optionally be used by a display
+ * driver, but if the hardware of the display allows faster handling of any of
+ * the primitives, the display driver can implement it directly.
+ *
+ * The display specific drivers provides an interface to the graphical display.
+ * It implements the low level communication with the display hardware, putting
+ * pixels on the display and drawing primitives such as lines, circles and
+ * rectangles. Depending on the display driver implementation, drawing the
+ * graphics primitives might be handled by the generic graphics drawing
+ * primitives rather than the display driver itself.
+ *
+ * \note The functions in the library are not interrupt safe.
+ * @{
+ */
+
+typedef uint8_t gfx_mono_color_t;
+typedef uint8_t gfx_coord_t;
+
+/** Pixel operations */
+enum gfx_mono_color {
+ /** Pixel is cleared */
+ GFX_PIXEL_CLR = 0,
+ /** Pixel is set on screen (OR) */
+ GFX_PIXEL_SET = 1,
+ /** Pixel is XORed */
+ GFX_PIXEL_XOR = 2,
+};
+
+/** Bitmap types */
+enum gfx_mono_bitmap_type {
+ /** Bitmap stored in SRAM */
+ GFX_MONO_BITMAP_RAM,
+ /** Bitmap stored in progmem */
+ GFX_MONO_BITMAP_PROGMEM
+};
+
+/* Cannot be moved to top, as they use the bitmap and color enums. */
+#ifdef USE_SDL
+# include "gfx_mono_sdl.h"
+#elif defined(GFX_MONO_C12832_A1Z)
+# include "gfx_mono_c12832_a1z.h"
+#elif defined(GFX_MONO_UG_2832HSWEG04)
+# include "gfx_mono_ug_2832hsweg04.h"
+#else
+/* NULL driver by default */
+# include "gfx_mono_null.h"
+#endif
+#include "gfx_mono_generic.h"
+
+/** \name Circle Sector Definitions */
+/** @{ */
+
+/** Bitmask for drawing circle octant 0. */
+#define GFX_OCTANT0 (1 << 0)
+/** Bitmask for drawing circle octant 1. */
+#define GFX_OCTANT1 (1 << 1)
+/** Bitmask for drawing circle octant 2. */
+#define GFX_OCTANT2 (1 << 2)
+/** Bitmask for drawing circle octant 3. */
+#define GFX_OCTANT3 (1 << 3)
+/** Bitmask for drawing circle octant 4. */
+#define GFX_OCTANT4 (1 << 4)
+/** Bitmask for drawing circle octant 5. */
+#define GFX_OCTANT5 (1 << 5)
+/** Bitmask for drawing circle octant 6. */
+#define GFX_OCTANT6 (1 << 6)
+/** Bitmask for drawing circle octant 7. */
+#define GFX_OCTANT7 (1 << 7)
+
+/** Bitmask for drawing circle quadrant 0. */
+#define GFX_QUADRANT0 (GFX_OCTANT0 | GFX_OCTANT1)
+/** Bitmask for drawing circle quadrant 1. */
+#define GFX_QUADRANT1 (GFX_OCTANT2 | GFX_OCTANT3)
+/** Bitmask for drawing circle quadrant 2. */
+#define GFX_QUADRANT2 (GFX_OCTANT4 | GFX_OCTANT5)
+/** Bitmask for drawing circle quadrant 3. */
+#define GFX_QUADRANT3 (GFX_OCTANT6 | GFX_OCTANT7)
+
+/** Bitmask for drawing left half of circle. */
+#define GFX_LEFTHALF (GFX_QUADRANT3 | GFX_QUADRANT0)
+/** Bitmask for drawing top half of circle. */
+#define GFX_TOPHALF (GFX_QUADRANT0 | GFX_QUADRANT1)
+/** Bitmask for drawing right half of circle. */
+#define GFX_RIGHTHALF (GFX_QUADRANT1 | GFX_QUADRANT2)
+/** Bitmask for drawing bottom half of circle. */
+#define GFX_BOTTOMHALF (GFX_QUADRANT2 | GFX_QUADRANT3)
+
+/** Bitmask for drawing whole circle. */
+#define GFX_WHOLE 0xFF
+
+/** @} */
+
+/** \name Graphic Drawing Primitives */
+/** @{ */
+
+/**
+ * \def gfx_mono_draw_horizontal_line(x, y, length, color)
+ * \brief Draw a horizontal line, one pixel wide.
+ *
+ * \param x X coordinate of leftmost pixel.
+ * \param y Y coordinate of the line.
+ * \param length Length of the line in pixels.
+ * \param color Pixel operation of the line.
+ */
+
+/**
+ * \def gfx_mono_draw_vertical_line(x, y, length, color)
+ * \brief Draw a vertical line, one pixel wide.
+ *
+ * \param x X coordinate of the line.
+ * \param y Y coordinate of the topmost pixel.
+ * \param length Length of the line in pixels.
+ * \param color Pixel operation of the line.
+ */
+
+/**
+ * \def gfx_mono_draw_line(x1, y1, x2, y2, color)
+ * \brief Draw a line between two arbitrary points.
+ *
+ * \param x1 Start X coordinate.
+ * \param y1 Start Y coordinate.
+ * \param x2 End X coordinate.
+ * \param y2 End Y coordinate.
+ * \param color Pixel operation of the line.
+ */
+
+/**
+ * \def gfx_mono_draw_rect(x, y, width, height, color)
+ * \brief Draw an outline of a rectangle.
+ *
+ * \param x X coordinate of the left side.
+ * \param y Y coordinate of the top side.
+ * \param width Width of the rectangle.
+ * \param height Height of the rectangle.
+ * \param color Pixel operation of the line.
+ */
+
+/**
+ * \def gfx_mono_draw_filled_rect(x, y, width, height, color)
+ * \brief Draw a filled rectangle.
+ *
+ * \param x X coordinate of the left side.
+ * \param y Y coordinate of the top side.
+ * \param width Width of the rectangle.
+ * \param height Height of the rectangle.
+ * \param color Pixel operation of the line
+ */
+
+/**
+ * \def gfx_mono_draw_circle(x, y, radius, color, octant_mask)
+ * \brief Draw an outline of a circle or arc.
+ *
+ * The radius is the distance from the center to the circumference,
+ * which means that the total width or height of a circle will be
+ * (radius*2+1).
+ *
+ * The octant_mask parameter is a bitmask that decides which octants of
+ * the circle to draw. Use the GFX_OCTANTn, GFX_QUADRANTn, GFX_xHALF and
+ * GFX_WHOLE constants and OR them together if required. Radius equal to
+ * zero gives a single pixel.
+ *
+ * \param x X coordinate of center.
+ * \param y Y coordinate of center.
+ * \param radius Circle radius in pixels.
+ * \param color Pixel operation.
+ * \param octant_mask Bitmask indicating which octants to draw.
+ */
+
+/**
+ * \def gfx_mono_draw_filled_circle(x, y, radius, color, quadrant_mask)
+ * \brief Draw a filled circle or sector.
+ *
+ * The radius is the distance from the center to the circumference,
+ * which means that the total width or height of a circle will be
+ * (radius*2+1).
+ *
+ * The quadrant_mask parameter is a bitmask that decides which quadrants
+ * of the circle to draw. Use the GFX_QUADRANTn, GFX_xHALF and
+ * GFX_WHOLE constants and OR them together if required. Radius equal to
+ * zero gives a single pixel.
+ *
+ * \note This function only supports quadrants while gfx_draw_circle()
+ * supports octants. This is to improve performance on drawing
+ * filled circles.
+ *
+ * \param x X coordinate of center.
+ * \param y Y coordinate of center.
+ * \param radius Circle radius in pixels.
+ * \param color Pixel operation.
+ * \param quadrant_mask Bitmask indicating which quadrants to draw.
+ */
+
+/** @} */
+
+/** @} */
+
+/**
+ * \page gfx_mono_quickstart Quick Start Guide for the mono graphics service
+ *
+ * This is the quick start guide for the \ref gfx_mono "Monochrome Graphics service",
+ * with step-by-step instructions on how to configure and use it for a specific
+ * use case.
+ *
+ * \section gfx_mono_quickstart_basic Basic usage of the graphics service
+ * This use case will demonstrate initializing the mono graphics service and
+ * then draw a black line on the screen from coordinates X=10, Y=10 to X=20,
+ * Y=20.
+ *
+ * \section gfx_mono_basic_usage Usage steps
+ * \subsection gfx_mono_basic_usage_code Example code
+ * Add to, e.g., the main function in the application C-file:
+ * \code
+ board_init();
+ sysclk_init();
+ gfx_mono_init();
+ gfx_mono_draw_line(10, 10, 20, 20, GFX_PIXEL_SET);
+\endcode
+ *
+ * \subsection gfx_mono_basic_usage Workflow
+ * -# Initialize board IO:
+ * - \code board_init(); \endcode
+ * -# Initialize clocks:
+ * - \code sysclk_init(); \endcode
+ * -# Initialize monochrome graphics service
+ * - \code gfx_mono_init(); \endcode
+ * - \note This will call the init function for the low level display
+ * controller driver and intialize the screen to a cleared background.
+ * -# Draw a line from 10,10 to 20,20:
+ * - \code gfx_mono_draw_line(10, 10, 20, 20, GFX_PIXEL_SET); \endcode
+ * - \note This uses GFX_PIXEL_SET to set the display pixels on the line;
+ * other options can be found in \ref gfx_mono_color.
+ */
+
+#endif /* GFX_MONO_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono.h.REMOVED.git-id
deleted file mode 100644
index 24a4a681..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c548880590e71946b4e3b1e4e85ddcac9caa9cb5
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.c
new file mode 100644
index 00000000..ba3758c5
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.c
@@ -0,0 +1,369 @@
+/**
+ * \file
+ *
+ * \brief Haven Display C12832 A1Z display glue code for display controller
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include "gfx_mono_c12832_a1z.h"
+
+/* If we are using a serial interface without readback, use framebuffer */
+#ifdef ST7565R_SERIAL_INTERFACE
+# define CONFIG_ST7565R_FRAMEBUFFER
+#endif
+
+#ifdef CONFIG_ST7565R_FRAMEBUFFER
+static uint8_t framebuffer[GFX_MONO_LCD_FRAMEBUFFER_SIZE];
+#endif
+
+/**
+ * \brief Initialize ST7565R controller and LCD display.
+ * It will also write the graphic controller RAM to all zeroes.
+ *
+ * \note This function will clear the contents of the display.
+ */
+void gfx_mono_st7565r_init(void)
+{
+ uint8_t page;
+ uint8_t column;
+
+#ifdef CONFIG_ST7565R_FRAMEBUFFER
+ gfx_mono_set_framebuffer(framebuffer);
+#endif
+
+ /* Initialize the low-level display controller. */
+ st7565r_init();
+
+ /* Set display to output data from line 0 */
+ st7565r_set_display_start_line_address(0);
+
+ /* Clear the contents of the display.
+ * If using a framebuffer (SPI interface) it will both clear the
+ * controller memory and the framebuffer.
+ */
+ for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
+ for (column = 0; column < GFX_MONO_LCD_WIDTH; column++) {
+ gfx_mono_put_byte(page, column, 0x00);
+ }
+ }
+}
+
+/**
+ * \brief Put framebuffer to LCD controller
+ *
+ * This function will output the complete framebuffer from RAM to the
+ * LCD controller.
+ *
+ * \note This is done automatically if using the graphic primitives. Only
+ * needed if you are manipulating the framebuffer directly in your code.
+ */
+void gfx_mono_st7565r_put_framebuffer(void)
+{
+ uint8_t page;
+
+ for (page = 0; page < GFX_MONO_LCD_PAGES; page++) {
+ st7565r_set_page_address(page);
+ st7565r_set_column_address(0);
+ gfx_mono_st7565r_put_page(framebuffer
+ + (page * GFX_MONO_LCD_WIDTH), page, 0,
+ GFX_MONO_LCD_WIDTH);
+ }
+}
+
+/**
+ * \brief Draw pixel to screen
+ *
+ * \param x X coordinate of the pixel
+ * \param y Y coordinate of the pixel
+ * \param color Pixel operation
+ *
+ * The following will set the pixel at x=10,y=10:
+ * \code
+ gfx_mono_st7565r_draw_pixel(10, 10, GFX_PIXEL_SET);
+\endcode
+ * The following example will clear the pixel at x=10,y=10:
+ * \code
+ gfx_mono_st7565r_draw_pixel(10, 10, GFX_PIXEL_CLR);
+\endcode
+ * And the following will toggle the pixel at x=10,y=10:
+ * \code
+ gfx_mono_st7565r_draw_pixel(10, 10, GFX_PIXEL_XOR);
+\endcode
+ */
+void gfx_mono_st7565r_draw_pixel(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t color)
+{
+ uint8_t page;
+ uint8_t pixel_mask;
+ uint8_t pixel_value;
+
+ /* Discard pixels drawn outside the screen */
+ if ((x > GFX_MONO_LCD_WIDTH - 1) || (y > GFX_MONO_LCD_HEIGHT - 1)) {
+ return;
+ }
+
+ page = y / GFX_MONO_LCD_PIXELS_PER_BYTE;
+ pixel_mask = (1 << (y - (page * 8)));
+
+ /*
+ * Read the page containing the pixel in interest, then perform the
+ * requested action on this pixel before writing the page back to the
+ * display.
+ */
+ pixel_value = gfx_mono_get_byte(page, x);
+
+ switch (color) {
+ case GFX_PIXEL_SET:
+ pixel_value |= pixel_mask;
+ break;
+
+ case GFX_PIXEL_CLR:
+ pixel_value &= ~pixel_mask;
+ break;
+
+ case GFX_PIXEL_XOR:
+ pixel_value ^= pixel_mask;
+ break;
+
+ default:
+ break;
+ }
+
+ gfx_mono_put_byte(page, x, pixel_value);
+}
+
+/**
+ * \brief Get the pixel value at x,y
+ *
+ * \param x X coordinate of pixel
+ * \param y Y coordinate of pixel
+ * \return Non zero value if pixel is set.
+ *
+ * The following example will read the pixel value from x=10,y=10:
+ * \code
+ pixelval = gfx_mono_st7565r_get_pixel(10,10);
+\endcode
+ */
+uint8_t gfx_mono_st7565r_get_pixel(gfx_coord_t x, gfx_coord_t y)
+{
+ uint8_t page;
+ uint8_t pixel_mask;
+
+ if ((x > GFX_MONO_LCD_WIDTH - 1) || (y > GFX_MONO_LCD_HEIGHT - 1)) {
+ return 0;
+ }
+
+ page = y / GFX_MONO_LCD_PIXELS_PER_BYTE;
+ pixel_mask = (1 << (y - (page * 8)));
+
+ return gfx_mono_get_byte(page, x) & pixel_mask;
+}
+
+/**
+ * \brief Put a page from RAM to display controller.
+ *
+ * If the controller is accessed by the SPI interface, we can not read
+ * back data from the LCD controller RAM. Because of this all data that is
+ * written to the LCD controller in this mode is also written to a framebuffer
+ * in MCU RAM.
+ *
+ * \param data Pointer to data to be written
+ * \param page Page address
+ * \param column Offset into page (x coordinate)
+ * \param width Number of bytes to be written.
+ *
+ * The following example will write 32 bytes from data_buf to the page 0,
+ * column 10. This will place data_buf in the rectangle x1=10,y1=0,x2=42,y2=8
+ * (10 pixels from the upper left corner of the screen):
+ * \code
+ gfx_mono_st7565r_put_page(data_buf, 0, 10, 32);
+\endcode
+ */
+void gfx_mono_st7565r_put_page(gfx_mono_color_t *data, gfx_coord_t page,
+ gfx_coord_t column, gfx_coord_t width)
+{
+#ifdef CONFIG_ST7565R_FRAMEBUFFER
+ gfx_mono_framebuffer_put_page(data, page, column, width);
+#endif
+ st7565r_set_page_address(page);
+ st7565r_set_column_address(column);
+
+ do {
+ st7565r_write_data(*data++);
+ } while (--width);
+}
+
+/**
+ * \brief Read a page from the LCD controller
+ *
+ * If the LCD controller is accessed by the SPI interface we cannot read
+ * data directly from the controller. In that case we will read the data from
+ * the local framebuffer instead.
+ *
+ * \param data Pointer where to store the read data
+ * \param page Page address
+ * \param column Offset into page (x coordinate)
+ * \param width Number of bytes to be read
+ *
+ * The following example will read back the first 128 bytes (first page) from
+ * the display memory:
+ * \code
+ gfx_mono_st7565r_get_page(read_buffer, 0, 0, 128);
+\endcode
+ */
+void gfx_mono_st7565r_get_page(gfx_mono_color_t *data, gfx_coord_t page,
+ gfx_coord_t column, gfx_coord_t width)
+{
+#ifdef CONFIG_ST7565R_FRAMEBUFFER
+ gfx_mono_framebuffer_get_page(data, page, column, width);
+#else
+ st7565r_set_page_address(page);
+ st7565r_set_column_address(column);
+
+ do {
+ *data++ = st7565r_read_data();
+ } while (--width);
+#endif
+}
+
+/**
+ * \brief Put a byte to the display controller RAM
+ *
+ * If the LCD controller is accessed by the SPI interface we will also put the
+ * data to the local framebuffer.
+ *
+ * \param page Page address
+ * \param column Page offset (x coordinate)
+ * \param data Data to be written
+ *
+ * This example will put the value 0xFF to the first byte in the display memory
+ * setting a 8 pixel high column of pixels in the upper left corner of the
+ * display.
+ * \code
+ gfx_mono_st7565r_put_byte(0, 0, 0xFF);
+\endcode
+ */
+void gfx_mono_st7565r_put_byte(gfx_coord_t page, gfx_coord_t column,
+ uint8_t data)
+{
+#ifdef CONFIG_ST7565R_FRAMEBUFFER
+ gfx_mono_framebuffer_put_byte(page, column, data);
+#endif
+
+ st7565r_set_page_address(page);
+ st7565r_set_column_address(column);
+
+ st7565r_write_data(data);
+}
+
+/**
+ * \brief Get a byte from the display controller RAM
+ *
+ * If the LCD controller is accessed by the SPI interface we cannot read the
+ * data. In this case return the data from the local framebuffer instead.
+ *
+ * \param page Page address
+ * \param column Page offset (x coordinate)
+ * \return data from LCD controller or framebuffer.
+ *
+ * The following code will read the first byte from the display memory or the
+ * local framebuffer if direct read is not possible. The data represents the
+ * pixels from x = 0 and y = 0 to y = 7.
+ * \code
+ data = gfx_mono_st7565r_get_byte(0, 0);
+\endcode
+ */
+uint8_t gfx_mono_st7565r_get_byte(gfx_coord_t page, gfx_coord_t column)
+{
+#ifdef CONFIG_ST7565R_FRAMEBUFFER
+ return gfx_mono_framebuffer_get_byte(page, column);
+
+#else
+ st7565r_set_page_address(page);
+ st7565r_set_column_address(column);
+
+ return st7565r_read_data();
+
+#endif
+}
+
+/**
+ * \brief Read/Modify/Write a byte on the display controller
+ *
+ * This function will read the byte from the display controller (or the
+ * framebuffer if we cannot read directly from the controller) and
+ * do a mask operation on the byte according to the pixel operation selected
+ * by the color argument and the pixel mask provided.
+ *
+ * \param page Page address
+ * \param column Page offset (x coordinate)
+ * \param pixel_mask Mask for pixel operation
+ * \param color Pixel operation
+ *
+ * A small example that will XOR the first byte of display memory with 0xAA
+ * \code
+ gfx_mono_st7565r_mask_byte(0,0,0xAA,GFX_PIXEL_XOR);
+\endcode
+ */
+void gfx_mono_st7565r_mask_byte(gfx_coord_t page, gfx_coord_t column,
+ gfx_mono_color_t pixel_mask, gfx_mono_color_t color)
+{
+ gfx_mono_color_t temp = gfx_mono_get_byte(page, column);
+
+ switch (color) {
+ case GFX_PIXEL_SET:
+ temp |= pixel_mask;
+ break;
+
+ case GFX_PIXEL_CLR:
+ temp &= ~pixel_mask;
+ break;
+
+ case GFX_PIXEL_XOR:
+ temp ^= pixel_mask;
+ break;
+
+ default:
+ break;
+ }
+
+ gfx_mono_put_byte(page, column, temp);
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.c.REMOVED.git-id
deleted file mode 100644
index 46a5bfc2..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ba3758c5bed09192126124cfc926e6fc75637b87
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.h
new file mode 100644
index 00000000..1fe5acff
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.h
@@ -0,0 +1,158 @@
+/**
+ * \file
+ *
+ * \brief Haven Display C12832 A1Z display glue code for display controller
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef GFX_MONO_C12832_A1Z_H
+#define GFX_MONO_C12832_A1Z_H
+#include "compiler.h"
+#include "st7565r.h"
+
+#include "gfx_mono.h"
+#include "gfx_mono_framebuffer.h"
+
+/**
+ * \ingroup gfx_mono
+ * \defgroup gfx_mono_C12832_A1Z_group C12832_A1Z graphic library abstraction
+ *
+ * This module is an abstraction layer between the graphic library and the
+ * C12832_A1Z monochrome LCD display connected to a ST7565R LCD controller.
+ *
+ * As the controller does not provide any hardware accelerated graphic, all the
+ * graphic primitives are provided by the \ref gfx_mono_generic_group service.
+ *
+ * \note Do not call the gfx_mono_st7565r_ functions directly. use the gfx_mono
+ * names that are defined in this header and documented in \ref gfx_mono .
+ * Ie. gfx_mono_draw_pixel() should be used, not gfx_mono_st7565r_draw_pixel()
+ * @{
+ */
+
+#define GFX_MONO_LCD_WIDTH 128
+#define GFX_MONO_LCD_HEIGHT 32
+#define GFX_MONO_LCD_PIXELS_PER_BYTE 8
+#define GFX_MONO_LCD_PAGES (GFX_MONO_LCD_HEIGHT / \
+ GFX_MONO_LCD_PIXELS_PER_BYTE)
+#define GFX_MONO_LCD_FRAMEBUFFER_SIZE ((GFX_MONO_LCD_WIDTH * \
+ GFX_MONO_LCD_HEIGHT) / GFX_MONO_LCD_PIXELS_PER_BYTE)
+
+#define gfx_mono_draw_horizontal_line(x, y, length, color) \
+ gfx_mono_generic_draw_horizontal_line(x, y, length, color)
+
+#define gfx_mono_draw_vertical_line(x, y, length, color) \
+ gfx_mono_generic_draw_vertical_line(x, y, length, color)
+
+#define gfx_mono_draw_line(x1, y1, x2, y2, color) \
+ gfx_mono_generic_draw_line(x1, y1, x2, y2, color)
+
+#define gfx_mono_draw_rect(x, y, width, height, color) \
+ gfx_mono_generic_draw_rect(x, y, width, height, color)
+
+#define gfx_mono_draw_filled_rect(x, y, width, height, color) \
+ gfx_mono_generic_draw_filled_rect(x, y, width, height, \
+ color)
+
+#define gfx_mono_draw_circle(x, y, radius, color, octant_mask) \
+ gfx_mono_generic_draw_circle(x, y, radius, color, \
+ octant_mask)
+
+#define gfx_mono_draw_filled_circle(x, y, radius, color, quadrant_mask) \
+ gfx_mono_generic_draw_filled_circle(x, y, radius, \
+ color, quadrant_mask)
+
+#define gfx_mono_put_bitmap(bitmap, x, y) \
+ gfx_mono_generic_put_bitmap(bitmap, x, y)
+
+#define gfx_mono_draw_pixel(x, y, color) \
+ gfx_mono_st7565r_draw_pixel(x, y, color)
+
+#define gfx_mono_get_pixel(x, y) \
+ gfx_mono_st7565r_get_pixel(x, y)
+
+#define gfx_mono_init() \
+ gfx_mono_st7565r_init()
+
+#define gfx_mono_put_page(data, page, column, width) \
+ gfx_mono_st7565r_put_page(data, page, column, width)
+
+#define gfx_mono_get_page(data, page, column, width) \
+ gfx_mono_st7565r_get_page(data, page, column, width)
+
+#define gfx_mono_put_byte(page, column, data) \
+ gfx_mono_st7565r_put_byte(page, column, data)
+
+#define gfx_mono_get_byte(page, column) \
+ gfx_mono_st7565r_get_byte(page, column)
+
+#define gfx_mono_mask_byte(page, column, pixel_mask, color) \
+ gfx_mono_st7565r_mask_byte(page, column, pixel_mask, color)
+
+#define gfx_mono_put_framebuffer() \
+ gfx_mono_st7565r_put_framebuffer()
+
+void gfx_mono_st7565r_put_framebuffer(void);
+
+void gfx_mono_st7565r_put_page(gfx_mono_color_t *data, gfx_coord_t page,
+ gfx_coord_t page_offset, gfx_coord_t width);
+
+void gfx_mono_st7565r_get_page(gfx_mono_color_t *data, gfx_coord_t page,
+ gfx_coord_t page_offset, gfx_coord_t width);
+
+void gfx_mono_st7565r_init(void);
+
+void gfx_mono_st7565r_draw_pixel(gfx_coord_t x, gfx_coord_t y,
+ gfx_mono_color_t color);
+
+uint8_t gfx_mono_st7565r_get_pixel(gfx_coord_t x, gfx_coord_t y);
+
+void gfx_mono_st7565r_put_byte(gfx_coord_t page, gfx_coord_t column,
+ uint8_t data);
+
+uint8_t gfx_mono_st7565r_get_byte(gfx_coord_t page, gfx_coord_t column);
+
+void gfx_mono_st7565r_mask_byte(gfx_coord_t page, gfx_coord_t column,
+ gfx_mono_color_t pixel_mask, gfx_mono_color_t color);
+
+/** @} */
+
+#endif /* GFX_MONO_C12832_A1Z_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.h.REMOVED.git-id
deleted file mode 100644
index 5c440351..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_c12832_a1z.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1fe5acffbf067acbfa022e9a98e0245d20a2ebd8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.c
new file mode 100644
index 00000000..4a1d2939
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.c
@@ -0,0 +1,265 @@
+/**
+ * \file
+ *
+ * \brief Local framebuffer
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "gfx_mono_framebuffer.h"
+
+/* Pointer to the framebuffer; updated by the gfx_mono_set_framebuffer function */
+static uint8_t *fbpointer;
+
+/* \brief Set the LCD framebuffer.
+ *
+ * \param framebuffer A pointer to an allocated area of RAM that can hold the
+ * framebuffer.
+ *
+ * A small example:
+ * \code
+ uint8_t framebuffer[FRAMEBUFFER_SIZE];
+ gfx_mono_set_framebuffer(framebuffer);
+\endcode
+ */
+void gfx_mono_set_framebuffer(uint8_t *framebuffer)
+{
+ fbpointer = framebuffer;
+}
+
+/**
+ * \brief Put a page from RAM to the framebuffer
+ *
+ * \param data Pointer to data to be written
+ * \param page Page address
+ * \param column Offset into page (x coordinate)
+ * \param width Number of bytes to be written.
+ *
+ * The following example will write 32 bytes from data_buf to the page 0,
+ * column 10 (byte 10 to 42 in the framebuffer).
+ * \code
+ gfx_mono_framebuffer_put_page(data_buf, 0, 10, 32);
+\endcode
+ */
+void gfx_mono_framebuffer_put_page(gfx_mono_color_t *data, gfx_coord_t page,
+ gfx_coord_t column, gfx_coord_t width)
+{
+ gfx_mono_color_t *data_pt = data;
+ gfx_coord_t *framebuffer_pt = fbpointer +
+ ((page * GFX_MONO_LCD_WIDTH) + column);
+
+ do {
+ *framebuffer_pt++ = *data_pt++;
+ } while (--width > 0);
+}
+
+/**
+ * \brief Read a page from the framebuffer
+ *
+ * \param data Pointer where to store the read data
+ * \param page Page address
+ * \param column Offset into page (x coordinate)
+ * \param width Number of bytes to be read
+ *
+ * The following example will read back the first 128 bytes (first page) from
+ * the framebuffer:
+ * \code
+ gfx_mono_framebuffer_get_page(read_buffer, 0, 0, 128);
+\endcode
+ */
+void gfx_mono_framebuffer_get_page(gfx_mono_color_t *data, gfx_coord_t page, \
+ gfx_coord_t column, gfx_coord_t width)
+{
+ gfx_coord_t *framebuffer_pt = fbpointer +
+ ((page * GFX_MONO_LCD_WIDTH) + column);
+ do {
+ *data++ = *framebuffer_pt++;
+ } while (--width > 0);
+}
+
+/**
+ * \brief Draw pixel to framebuffer
+ *
+ * \param x X coordinate of the pixel
+ * \param y Y coordinate of the pixel
+ * \param color Pixel operation
+ *
+ */
+void gfx_mono_framebuffer_draw_pixel(gfx_coord_t x, gfx_coord_t y,
+ gfx_mono_color_t color)
+{
+ uint8_t page;
+ uint8_t pixel_mask;
+ uint8_t pixel_value;
+
+ /* Discard pixels drawn outside the screen */
+ if ((x > GFX_MONO_LCD_WIDTH - 1) || (y > GFX_MONO_LCD_HEIGHT - 1)) {
+ return;
+ }
+
+ page = y / GFX_MONO_LCD_PIXELS_PER_BYTE;
+ pixel_mask = (1 << (y - (page * 8)));
+
+ /*
+ * Read the page containing the pixel in interest, then perform the
+ * requested action on this pixel before writing the page back to the
+ * display.
+ */
+ pixel_value = gfx_mono_framebuffer_get_byte(page, x);
+
+ switch (color) {
+ case GFX_PIXEL_SET:
+ pixel_value |= pixel_mask;
+ break;
+
+ case GFX_PIXEL_CLR:
+ pixel_value &= ~pixel_mask;
+ break;
+
+ case GFX_PIXEL_XOR:
+ pixel_value ^= pixel_mask;
+ break;
+
+ default:
+ break;
+ }
+
+ gfx_mono_framebuffer_put_byte(page, x, pixel_value);
+}
+
+/**
+ * \brief Get the pixel value at x,y in framebuffer
+ *
+ * \param x X coordinate of pixel
+ * \param y Y coordinate of pixel
+ * \return Non zero value if pixel is set.
+ *
+ */
+uint8_t gfx_mono_framebuffer_get_pixel(gfx_coord_t x, gfx_coord_t y)
+{
+ uint8_t page;
+ uint8_t pixel_mask;
+
+ if ((x > GFX_MONO_LCD_WIDTH - 1) || (y > GFX_MONO_LCD_HEIGHT - 1)) {
+ return 0;
+ }
+
+ page = y / GFX_MONO_LCD_PIXELS_PER_BYTE;
+ pixel_mask = (1 << (y - (page * 8)));
+
+ return gfx_mono_framebuffer_get_byte(page, x) & pixel_mask;
+}
+
+/**
+ * \brief Put a byte to the framebuffer
+ *
+ * \param page Page address
+ * \param column Page offset (x coordinate)
+ * \param data Data to be written
+ *
+ * This example will put the value 0xFF to the first byte in the framebuffer
+ * \code
+ gfx_mono_framebuffer_put_byte(0, 0, 0xFF);
+\endcode
+ */
+void gfx_mono_framebuffer_put_byte(gfx_coord_t page, gfx_coord_t column,
+ uint8_t data)
+{
+ *(fbpointer + (page * GFX_MONO_LCD_WIDTH) + column) = data;
+}
+
+/**
+ * \brief Get a byte from the framebuffer
+ *
+ * \param page Page address
+ * \param column Page offset (x coordinate)
+ * \return data from LCD controller or framebuffer.
+ *
+ * The following code will read the first byte of the framebuffer
+ * \code
+ data = gfx_mono_framebuffer_get_byte(0, 0);
+\endcode
+ */
+uint8_t gfx_mono_framebuffer_get_byte(gfx_coord_t page, gfx_coord_t column)
+{
+ return *(fbpointer + (page * GFX_MONO_LCD_WIDTH) + column);
+}
+
+/**
+ * \brief Read/Modify/Write a byte in the framebuffer
+ *
+ * This function will read the byte from the framebuffer and
+ * do a mask operation on the byte according to the pixel operation selected
+ * by the color argument and the pixel mask provided.
+ *
+ * \param page Page address
+ * \param column Page offset (x coordinate)
+ * \param pixel_mask Mask for pixel operation
+ * \param color Pixel operation
+ *
+ * A small example that will XOR the first byte of the framebuffer with 0xAA
+ * \code
+ gfx_mono_framebuffer_mask_byte(0,0,0xAA,GFX_PIXEL_XOR);
+\endcode
+ */
+void gfx_mono_framebuffer_mask_byte(gfx_coord_t page, gfx_coord_t column,
+ gfx_mono_color_t pixel_mask, gfx_mono_color_t color)
+{
+ gfx_mono_color_t temp;
+
+ temp = gfx_mono_get_byte(page, column);
+
+ switch (color) {
+ case GFX_PIXEL_SET:
+ temp |= pixel_mask;
+ break;
+
+ case GFX_PIXEL_CLR:
+ temp &= ~pixel_mask;
+ break;
+
+ case GFX_PIXEL_XOR:
+ temp ^= pixel_mask;
+ break;
+ }
+
+ gfx_mono_put_byte(page, column, temp);
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.c.REMOVED.git-id
deleted file mode 100644
index 9ae63d7f..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4a1d293910dd0d9f4355d64bfa35254788288fc6
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.h
new file mode 100644
index 00000000..a3118409
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.h
@@ -0,0 +1,87 @@
+/**
+ * \file
+ *
+ * \brief Monochrome graphic library framebuffer device
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef GFX_MONO_FRAMEBUFFER
+#define GFX_MONO_FRAMEBUFFER
+
+#include "gfx_mono.h"
+
+/**
+ * \ingroup gfx_mono
+ * \defgroup gfx_mono_framebuffer_group Framebuffer
+ *
+ * This module provides read/write from and to a framebuffer in RAM. This is
+ * needed when using a controller that does not provide a way to read back data
+ * from the LCD controller memory. In this case we need to buffer the data in
+ * a local framebuffer to allow manipulation on pixel level. It is generally
+ * not recommended to access the framebuffer directly; this is handled by the
+ * graphic driver when needed.
+ *
+ * @{
+ */
+
+void gfx_mono_set_framebuffer(uint8_t *framebuffer);
+
+void gfx_mono_framebuffer_put_page(gfx_mono_color_t *data, gfx_coord_t page,
+ gfx_coord_t page_offset, gfx_coord_t width);
+
+void gfx_mono_framebuffer_get_page(gfx_mono_color_t *data, gfx_coord_t page,
+ gfx_coord_t page_offset, gfx_coord_t width);
+
+void gfx_mono_framebuffer_draw_pixel(gfx_coord_t x, gfx_coord_t y,
+ gfx_mono_color_t color);
+
+uint8_t gfx_mono_framebuffer_get_pixel(gfx_coord_t x, gfx_coord_t y);
+
+void gfx_mono_framebuffer_put_byte(gfx_coord_t page, gfx_coord_t column,
+ uint8_t data);
+
+uint8_t gfx_mono_framebuffer_get_byte(gfx_coord_t page, gfx_coord_t column);
+
+void gfx_mono_framebuffer_mask_byte(gfx_coord_t page, gfx_coord_t column,
+ gfx_mono_color_t pixel_mask, gfx_mono_color_t color);
+
+/** @} */
+#endif /* GFX_MONO_FRAMEBUFFER */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.h.REMOVED.git-id
deleted file mode 100644
index 2d449820..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_framebuffer.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a31184094b0e2a83f94f2b50d60d9a81447d419f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.c
new file mode 100644
index 00000000..38e98345
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.c
@@ -0,0 +1,506 @@
+/**
+ * \file
+ *
+ * \brief Generic monochrome LCD graphic primitives
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+/**
+ * \ingroup gfx_mono_generic_group
+ * @{
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include "gfx_mono_generic.h"
+
+/**
+ * \brief Draw a horizontal line, one pixel wide (generic implementation)
+ *
+ * \note This function does a very simple bounds checking that does not
+ * check if the line is placed outside the screen. If you supply an
+ * x- or y-coordinate outside the display the behaviour is undefined,
+ * and you risk overwriting portions of internal SRAM.
+ *
+ * \param x X coordinate of leftmost pixel.
+ * \param y Y coordinate of the line.
+ * \param length Length of the line in pixels.
+ * \param color Pixel operation of the line.
+ */
+void gfx_mono_generic_draw_horizontal_line(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t length, enum gfx_mono_color color)
+{
+ uint8_t page;
+ uint8_t pixelmask;
+ uint8_t temp;
+
+ /* Clip line length if too long */
+ if (x + length > GFX_MONO_LCD_WIDTH) {
+ length = GFX_MONO_LCD_WIDTH - x;
+ }
+
+ page = y / 8;
+ pixelmask = (1 << (y - (page * 8)));
+
+ if (length == 0) {
+ /* Nothing to do. Move along. */
+ return;
+ }
+
+ switch (color) {
+ case GFX_PIXEL_SET:
+ while (length-- > 0) {
+ temp = gfx_mono_get_byte(page, x + length);
+ temp |= pixelmask;
+ gfx_mono_put_byte(page, x + length, temp);
+ }
+ break;
+
+ case GFX_PIXEL_CLR:
+ while (length-- > 0) {
+ temp = gfx_mono_get_byte(page, x + length);
+ temp &= ~pixelmask;
+ gfx_mono_put_byte(page, x + length, temp);
+ }
+ break;
+
+ case GFX_PIXEL_XOR:
+ while (length-- > 0) {
+ temp = gfx_mono_get_byte(page, x + length);
+ temp ^= pixelmask;
+ gfx_mono_put_byte(page, x + length, temp);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/**
+ * \brief Draw a vertical line, one pixel wide (generic implementation)
+ *
+ * \note This function does a very simple bounds checking that does not
+ * check if the line is placed outside the screen. If you supply an
+ * x- or y-coordinate outside the display the behaviour is undefined,
+ * and you risk overwriting portions of internal SRAM.
+ *
+ * \param x X coordinate of the line.
+ * \param y Y coordinate of the topmost pixel.
+ * \param length Length of the line in pixels.
+ * \param color Pixel operation of the line.
+ */
+void gfx_mono_generic_draw_vertical_line(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t length, enum gfx_mono_color color)
+{
+ if (length == 0) {
+ return;
+ }
+
+ gfx_coord_t y2 = y + length - 1;
+
+ if (y == y2) {
+ gfx_mono_draw_pixel(x, y, color);
+ return;
+ }
+
+ if (y2 >= GFX_MONO_LCD_HEIGHT - 1) {
+ y2 = GFX_MONO_LCD_HEIGHT - 1;
+ }
+
+ gfx_coord_t y1page = y / 8;
+ gfx_coord_t y2page = y2 / 8;
+
+ uint8_t y1bitpos = y & 0x07;
+ uint8_t y2bitpos = y2 & 0x07;
+
+ uint8_t y1pixelmask = 0xFF << y1bitpos;
+ uint8_t y2pixelmask = 0xFF >> (7 - y2bitpos);
+
+ /* The pixels are on the same page; combine masks */
+ if (y1page == y2page) {
+ uint8_t pixelmask = y1pixelmask & y2pixelmask;
+ gfx_mono_mask_byte(y1page, x, pixelmask, color);
+ } else {
+ gfx_mono_mask_byte(y1page, x, y1pixelmask, color);
+
+ while (++y1page < y2page) {
+ gfx_mono_mask_byte(y1page, x, 0xFF, color);
+ }
+
+ gfx_mono_mask_byte(y2page, x, y2pixelmask, color);
+ }
+}
+
+/**
+ * \brief Draw a line between two arbitrary points (generic implementation).
+ *
+ * \param x1 Start X coordinate.
+ * \param y1 Start Y coordinate.
+ * \param x2 End X coordinate.
+ * \param y2 End Y coordinate.
+ * \param color Pixel operation of the line.
+ */
+void gfx_mono_generic_draw_line(gfx_coord_t x1, gfx_coord_t y1,
+ gfx_coord_t x2, gfx_coord_t y2,
+ enum gfx_mono_color color)
+{
+ uint8_t i;
+ uint8_t x;
+ uint8_t y;
+ int8_t xinc;
+ int8_t yinc;
+ int8_t dx;
+ int8_t dy;
+ int8_t e;
+
+ /* swap x1,y1 with x2,y2 */
+ if (x1 > x2) {
+ dx = x1;
+ x1 = x2;
+ x2 = dx;
+ dy = y1;
+ y1 = y2;
+ y2 = dy;
+ }
+
+ dx = x2 - x1;
+ dy = y2 - y1;
+
+ x = x1;
+ y = y1;
+
+ if (dx < 0) {
+ xinc = -1;
+ dx = -dx;
+ } else {
+ xinc = 1;
+ }
+
+ if (dy < 0) {
+ yinc = -1;
+ dy = -dy;
+ } else {
+ yinc = 1;
+ }
+
+ if (dx > dy) {
+ e = dy - dx;
+ for (i = 0; i <= dx; i++) {
+ gfx_mono_draw_pixel(x, y, color);
+ if (e >= 0) {
+ e -= dx;
+ y += yinc;
+ }
+
+ e += dy;
+ x += xinc;
+ }
+ } else {
+ e = dx - dy;
+ for (i = 0; i <= dy; i++) {
+ gfx_mono_draw_pixel(x, y, color);
+ if (e >= 0) {
+ e -= dy;
+ x += xinc;
+ }
+
+ e += dx;
+ y += yinc;
+ }
+ }
+}
+
+/**
+ * \brief Draw an outline of a rectangle (generic implementation).
+ *
+ * \param x X coordinate of the left side.
+ * \param y Y coordinate of the top side.
+ * \param width Width of the rectangle.
+ * \param height Height of the rectangle.
+ * \param color Pixel operation of the line.
+ */
+void gfx_mono_generic_draw_rect(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t width, gfx_coord_t height,
+ enum gfx_mono_color color)
+{
+ gfx_mono_draw_horizontal_line(x, y, width, color);
+ gfx_mono_draw_horizontal_line(x, y + height - 1, width, color);
+
+ gfx_mono_draw_vertical_line(x, y, height, color);
+ gfx_mono_draw_vertical_line(x + width - 1, y, height, color);
+}
+
+/**
+ * \brief Draw a filled rectangle (generic implementation).
+ *
+ * \param x X coordinate of the left side.
+ * \param y Y coordinate of the top side.
+ * \param width Width of the rectangle.
+ * \param height Height of the rectangle.
+ * \param color Pixel operation of the line
+ */
+void gfx_mono_generic_draw_filled_rect(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t width, gfx_coord_t height,
+ enum gfx_mono_color color)
+{
+ if (height == 0) {
+ /* Nothing to do. Move along. */
+ return;
+ }
+
+ while (height-- > 0) {
+ gfx_mono_draw_horizontal_line(x, y + height, width, color);
+ }
+}
+
+/**
+ * \brief Draw an outline of a circle or arc (generic implementation).
+ *
+ * The radius is the distance from the center to the circumference,
+ * which means that the total width or height of a circle will be
+ * (radius*2+1).
+ *
+ * The octant_mask parameter is a bitmask that decides which octants of
+ * the circle to draw. Use the GFX_OCTANTn, GFX_QUADRANTn, GFX_xHALF and
+ * GFX_WHOLE constants and OR them together if required. Radius equal to
+ * zero gives a single pixel.
+ *
+ * \param x X coordinate of center.
+ * \param y Y coordinate of center.
+ * \param radius Circle radius in pixels.
+ * \param color Pixel operation.
+ * \param octant_mask Bitmask indicating which octants to draw.
+ */
+void gfx_mono_generic_draw_circle(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t radius, enum gfx_mono_color color,
+ uint8_t octant_mask)
+{
+ gfx_coord_t offset_x;
+ gfx_coord_t offset_y;
+ int16_t error;
+
+ /* Draw only a pixel if radius is zero. */
+ if (radius == 0) {
+ gfx_mono_draw_pixel(x, y, color);
+ return;
+ }
+
+ /* Set up start iterators. */
+ offset_x = 0;
+ offset_y = radius;
+ error = 3 - 2 * radius;
+
+ /* Iterate offsetX from 0 to radius. */
+ while (offset_x <= offset_y) {
+ /* Draw one pixel for each octant enabled in octant_mask. */
+ if (octant_mask & GFX_OCTANT0) {
+ gfx_mono_draw_pixel(x + offset_y, y - offset_x, color);
+ }
+
+ if (octant_mask & GFX_OCTANT1) {
+ gfx_mono_draw_pixel(x + offset_x, y - offset_y, color);
+ }
+
+ if (octant_mask & GFX_OCTANT2) {
+ gfx_mono_draw_pixel(x - offset_x, y - offset_y, color);
+ }
+
+ if (octant_mask & GFX_OCTANT3) {
+ gfx_mono_draw_pixel(x - offset_y, y - offset_x, color);
+ }
+
+ if (octant_mask & GFX_OCTANT4) {
+ gfx_mono_draw_pixel(x - offset_y, y + offset_x, color);
+ }
+
+ if (octant_mask & GFX_OCTANT5) {
+ gfx_mono_draw_pixel(x - offset_x, y + offset_y, color);
+ }
+
+ if (octant_mask & GFX_OCTANT6) {
+ gfx_mono_draw_pixel(x + offset_x, y + offset_y, color);
+ }
+
+ if (octant_mask & GFX_OCTANT7) {
+ gfx_mono_draw_pixel(x + offset_y, y + offset_x, color);
+ }
+
+ /* Update error value and step offset_y when required. */
+ if (error < 0) {
+ error += ((offset_x << 2) + 6);
+ } else {
+ error += (((offset_x - offset_y) << 2) + 10);
+ --offset_y;
+ }
+
+ /* Next X. */
+ ++offset_x;
+ }
+}
+
+/**
+ * \brief Draw a filled circle or sector (generic implementation).
+ *
+ * The radius is the distance from the center to the circumference,
+ * which means that the total width or height of a circle will be
+ * (radius*2+1).
+ *
+ * The quadrant_mask parameter is a bitmask that decides which quadrants
+ * of the circle to draw. Use the GFX_QUADRANTn, GFX_xHALF and
+ * GFX_WHOLE constants and OR them together if required. Radius equal to
+ * zero gives a single pixel.
+ *
+ * \note This function only supports quadrants while gfx_draw_circle()
+ * supports octants. This is to improve performance on drawing
+ * filled circles.
+ *
+ * \param x X coordinate of center.
+ * \param y Y coordinate of center.
+ * \param radius Circle radius in pixels.
+ * \param color Pixel operation.
+ * \param quadrant_mask Bitmask indicating which quadrants to draw.
+ */
+void gfx_mono_generic_draw_filled_circle(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t radius, enum gfx_mono_color color,
+ uint8_t quadrant_mask)
+{
+ gfx_coord_t offset_x;
+ gfx_coord_t offset_y;
+ int16_t error;
+
+ /* Draw only a pixel if radius is zero. */
+ if (radius == 0) {
+ gfx_mono_draw_pixel(x, y, color);
+ return;
+ }
+
+ /* Set up start iterators. */
+ offset_x = 0;
+ offset_y = radius;
+ error = 3 - 2 * radius;
+
+ /* Iterate offset_x from 0 to radius. */
+ while (offset_x <= offset_y) {
+ /* Draw vertical lines tracking each quadrant. */
+ if (quadrant_mask & GFX_QUADRANT0) {
+ gfx_mono_draw_vertical_line(x + offset_y,
+ y - offset_x, offset_x + 1, color);
+ gfx_mono_draw_vertical_line(x + offset_x,
+ y - offset_y, offset_y + 1, color);
+ }
+
+ if (quadrant_mask & GFX_QUADRANT1) {
+ gfx_mono_draw_vertical_line(x - offset_y,
+ y - offset_x, offset_x + 1, color);
+ gfx_mono_draw_vertical_line(x - offset_x,
+ y - offset_y, offset_y + 1, color);
+ }
+
+ if (quadrant_mask & GFX_QUADRANT2) {
+ gfx_mono_draw_vertical_line(x - offset_y,
+ y, offset_x + 1, color);
+ gfx_mono_draw_vertical_line(x - offset_x,
+ y, offset_y + 1, color);
+ }
+
+ if (quadrant_mask & GFX_QUADRANT3) {
+ gfx_mono_draw_vertical_line(x + offset_y,
+ y, offset_x + 1, color);
+ gfx_mono_draw_vertical_line(x + offset_x,
+ y, offset_y + 1, color);
+ }
+
+ /* Update error value and step offset_y when required. */
+ if (error < 0) {
+ error += ((offset_x << 2) + 6);
+ } else {
+ error += (((offset_x - offset_y) << 2) + 10);
+ --offset_y;
+ }
+
+ /* Next X. */
+ ++offset_x;
+ }
+}
+
+/**
+ * \brief Put bitmap from FLASH or RAM to display
+ *
+ * This function will output bitmap data from FLASH or RAM.
+ * The bitmap y-coordinate will be aligned with display pages, rounded down.
+ * Ie: placing a bitmap at x=10, y=5 will put the bitmap at x = 10,y = 0 and
+ * placing a bitmap at x = 10, y = 10 will put the bitmap at x = 10, y = 8
+ *
+ */
+void gfx_mono_generic_put_bitmap(struct gfx_mono_bitmap *bitmap, gfx_coord_t x,
+ gfx_coord_t y)
+{
+ gfx_coord_t num_pages = bitmap->height / 8;
+ gfx_coord_t page = y / 8;
+ gfx_coord_t column;
+ gfx_coord_t i;
+ gfx_mono_color_t temp;
+
+ switch (bitmap->type) {
+ case GFX_MONO_BITMAP_PROGMEM:
+ for (i = 0; i < num_pages; i++) {
+ for (column = 0; column < bitmap->width; column++) {
+ temp = PROGMEM_READ_BYTE(bitmap->data.progmem
+ + (i * bitmap->width)
+ + column);
+ gfx_mono_put_byte(i + page, column + x, temp);
+ }
+ }
+ break;
+
+ case GFX_MONO_BITMAP_RAM:
+ for (i = 0; i < num_pages; i++) {
+ gfx_mono_put_page(bitmap->data.pixmap
+ + (i * bitmap->width), page + i, x,
+ bitmap->width);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/** @} */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.c.REMOVED.git-id
deleted file mode 100644
index c92358fe..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-38e98345e46d2183e8a8340da0d395ddf857c183
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.h
new file mode 100644
index 00000000..4701e943
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.h
@@ -0,0 +1,123 @@
+/**
+ * \file
+ *
+ * \brief Generic monochrome LCD graphic primitives
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef GFX_MONO_GENERIC
+#define GFX_MONO_GENERIC
+#include "gfx_mono.h"
+
+/**
+ * \ingroup gfx_mono
+ * \defgroup gfx_mono_generic_group Generic monochrome graphic primitives
+ *
+ * This is a service providing generic implementations of graphic primitives
+ * - Horizontal line
+ * - Vertical line
+ * - Line
+ * - Circle (filled/not filled)
+ * - Rectangle (filled/not filled)
+ *
+ * it also provides functionality to draw a bitmap to the graphic memory.
+ *
+ * These functions are made available if the graphic hardware being used do
+ * not implement the functionality in hardware. This is true in most cases.
+ *
+ * This service is included as a requirement for a
+ * hardware specific component that uses these functions, and provides a
+ * gfx_draw_pixel function.
+ *
+ * @{
+ */
+
+/**
+ * \brief Storage structure for bitmap pixel data and metadata
+ */
+struct gfx_mono_bitmap {
+ /** Width of bitmap */
+ gfx_coord_t width;
+ /** Height of bitmap */
+ gfx_coord_t height;
+ /** Bitmap type */
+ enum gfx_mono_bitmap_type type;
+ union {
+ /** Pointer to pixels for bitmap stored in RAM */
+ gfx_mono_color_t *pixmap;
+ /** Pointer to pixels for bitmap stored in progmem */
+ gfx_mono_color_t PROGMEM_T *progmem;
+ }
+ data;
+};
+
+void gfx_mono_generic_draw_horizontal_line(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t length, enum gfx_mono_color color);
+
+void gfx_mono_generic_draw_vertical_line(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t length, enum gfx_mono_color color);
+
+void gfx_mono_generic_draw_line(gfx_coord_t x1, gfx_coord_t y1,
+ gfx_coord_t x2, gfx_coord_t y2,
+ enum gfx_mono_color color);
+
+void gfx_mono_generic_draw_rect(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t width, gfx_coord_t height,
+ enum gfx_mono_color color);
+
+void gfx_mono_generic_draw_filled_rect(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t width, gfx_coord_t height,
+ enum gfx_mono_color color);
+
+void gfx_mono_generic_draw_circle(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t radius, enum gfx_mono_color color,
+ uint8_t octant_mask);
+
+void gfx_mono_generic_draw_filled_circle(gfx_coord_t x, gfx_coord_t y,
+ gfx_coord_t radius, enum gfx_mono_color color,
+ uint8_t quadrant_mask);
+
+void gfx_mono_generic_put_bitmap(struct gfx_mono_bitmap *bitmap, gfx_coord_t x,
+ gfx_coord_t y);
+
+/** @} */
+
+#endif /* GFX_MONO_GENERIC */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.h.REMOVED.git-id
deleted file mode 100644
index 5a73cc38..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_generic.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4701e943c5ebcf0f92cb5c3583d76f3eb415dc4b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.c
new file mode 100644
index 00000000..f278a292
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.c
@@ -0,0 +1,188 @@
+/**
+ * \file
+ *
+ * \brief Simple menu system
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "sysfont.h"
+#include "gfx_mono.h"
+#include
+
+#include "gfx_mono_menu.h"
+
+/**
+ * \ingroup gfx_mono_menu
+ * @{
+ */
+
+PROGMEM_DECLARE(gfx_mono_color_t, arrow_right_data[]) = {
+ GFX_MONO_MENU_INDICATOR_BITMAP
+};
+
+struct gfx_mono_bitmap menu_bitmap_indicator = {
+ .height = GFX_MONO_MENU_INDICATOR_HEIGHT,
+ .width = GFX_MONO_MENU_INDICATOR_WIDTH,
+ .type = GFX_MONO_BITMAP_PROGMEM,
+ .data.progmem = arrow_right_data
+};
+
+/**
+ * \brief Draw menu strings and an icon by the current selection.
+ *
+ * \param menu a menu struct with menu settings
+ * \param redraw clear screen before drawing menu
+ */
+static void menu_draw(struct gfx_mono_menu *menu, bool redraw)
+{
+ static bool redraw_state;
+ uint8_t i;
+ uint8_t line = 1;
+ uint8_t menu_page = menu->current_selection /
+ GFX_MONO_MENU_ELEMENTS_PER_SCREEN;
+
+ if (menu->current_page != menu_page || redraw == true) {
+ /* clear screen if we have changed the page or menu and prepare
+ * redraw */
+ gfx_mono_draw_filled_rect(0, SYSFONT_LINESPACING,
+ GFX_MONO_LCD_WIDTH,
+ GFX_MONO_LCD_HEIGHT - SYSFONT_LINESPACING,
+ GFX_PIXEL_CLR);
+ redraw_state = true;
+ }
+
+ menu->current_page = menu_page;
+
+ /* Clear old indicator icon */
+ gfx_mono_draw_filled_rect(0, SYSFONT_LINESPACING,
+ GFX_MONO_MENU_INDICATOR_WIDTH, GFX_MONO_LCD_HEIGHT -
+ SYSFONT_LINESPACING, GFX_PIXEL_CLR);
+
+ /* Put indicator icon on current selection */
+ gfx_mono_put_bitmap(&menu_bitmap_indicator, 0,
+ SYSFONT_LINESPACING * ((menu->current_selection %
+ GFX_MONO_MENU_ELEMENTS_PER_SCREEN) + 1));
+
+ /* Print visible options if page or menu has changed */
+ if (redraw_state == true) {
+ for (i = menu_page * GFX_MONO_MENU_ELEMENTS_PER_SCREEN;
+ i < menu_page *
+ GFX_MONO_MENU_ELEMENTS_PER_SCREEN +
+ GFX_MONO_MENU_ELEMENTS_PER_SCREEN &&
+ i < menu->num_elements; i++) {
+ gfx_mono_draw_progmem_string(
+ (char PROGMEM_PTR_T)menu->strings[i],
+ GFX_MONO_MENU_INDICATOR_WIDTH + 1,
+ line * SYSFONT_LINESPACING, &sysfont);
+ line++;
+ }
+ redraw_state = false;
+ }
+}
+
+/**
+ * *\brief Initialize the menu handling. Clear screen and draw menu.
+ *
+ * \param menu menu struct with menu options
+ *
+ */
+void gfx_mono_menu_init(struct gfx_mono_menu *menu)
+{
+ /* Clear screen */
+ gfx_mono_draw_filled_rect(0, 0,
+ GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT, GFX_PIXEL_CLR);
+
+ /* Draw the menu title on the top of the screen */
+ gfx_mono_draw_progmem_string((char PROGMEM_PTR_T)menu->title,
+ 0, 0, &sysfont);
+
+ /* Draw menu options below */
+ menu_draw(menu, true);
+}
+
+/**
+ * \brief Update menu depending on input.
+ *
+ * \param menu menu struct with menu options
+ * \param keycode keycode to process
+ *
+ * \retval selected menu option or status code
+ */
+uint8_t gfx_mono_menu_process_key(struct gfx_mono_menu *menu, uint8_t keycode)
+{
+ switch (keycode) {
+ case GFX_MONO_MENU_KEYCODE_DOWN:
+ if (menu->current_selection == menu->num_elements - 1) {
+ menu->current_selection = 0;
+ } else {
+ menu->current_selection++;
+ }
+
+ /* Update menu on display */
+ menu_draw(menu, false);
+ /* Nothing selected yet */
+ return GFX_MONO_MENU_EVENT_IDLE;
+
+ case GFX_MONO_MENU_KEYCODE_UP:
+ if (menu->current_selection) {
+ menu->current_selection--;
+ } else {
+ menu->current_selection = menu->num_elements - 1;
+ }
+
+ /* Update menu on display */
+ menu_draw(menu, false);
+ /* Nothing selected yet */
+ return GFX_MONO_MENU_EVENT_IDLE;
+
+ case GFX_MONO_MENU_KEYCODE_ENTER:
+ /* Got what we want. Return selection. */
+ return menu->current_selection;
+
+ case GFX_MONO_MENU_KEYCODE_BACK:
+ /* User pressed "back" key, inform user */
+ return GFX_MONO_MENU_EVENT_EXIT;
+
+ default:
+ /* Unknown key event */
+ return GFX_MONO_MENU_EVENT_IDLE;
+ }
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.c.REMOVED.git-id
deleted file mode 100644
index 1f8843c9..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f278a2926bda7a4c5250345994e843b91d548173
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.h
new file mode 100644
index 00000000..1536a823
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.h
@@ -0,0 +1,127 @@
+/**
+ * \file
+ *
+ * \brief Simple menu system
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef GFX_MONO_MENU_H
+#define GFX_MONO_MENU_H
+
+#include "compiler.h"
+#include "conf_menu.h"
+
+/**
+ * \ingroup gfx_mono
+ * \defgroup gfx_mono_menu Menu system for monochrome graphical displays
+ *
+ * This module provides a simple menu system for monochrome graphical
+ * displays.
+ *
+ * Typical flow of an application using the menu system:
+ *
+ * 1) Define menu structure.\n
+ * 2) Call gfx_mono_menu_init.\n
+ * 3) Get user input.\n
+ * 4) Update menu with user input using function \ref
+ * gfx_mono_menu_process_key.\n
+ * 5) Interpret \ref gfx_mono_menu_process_key return value.\n
+ * 6) Go to 3.\n
+ *
+ * The menu is declared using the \ref gfx_mono_menu struct.
+ *
+ * To start the menu system, call the \ref gfx_mono_menu_init function.
+ * This function will clear the display and draw the menu.
+ *
+ * Before the menu can be updated, you need input from the user. Methods for
+ * getting input is not part of the menu module.
+ *
+ * As soon as input is received, inform the menu system using the
+ * \ref gfx_mono_menu_process_key function.
+ * This function will then return a status code and act depending on the given
+ * keycode:
+ *
+ * MENU_KEYCODE_DOWN : Change selection to next menu item (or first if at
+ * bottom).
+ * Returns MENU_EVENT_IDLE.
+ *
+ * MENU_KEYCODE_UP : Change selection to previous menu item (or last if at top).
+ * Returns MENU_EVENT_IDLE.
+ *
+ * MENU_KEYCODE_ENTER : Nothing changes in menu. Returns the line selected.
+ *
+ * MENU_KEYCODE_BACK : Nothing changes in menu. Returns MENU_EVENT_EXIT.
+ *
+ * The value of the keycodes used are defined in conf_menu.h. These value can
+ * be changed if needed.
+ *
+ * The graphical indicator used to indicate menu selection is defined in
+ * conf_menu.h. This indicator can be changed if needed.
+ * @{
+ */
+
+/** \name Menu events definitions */
+/** @{ */
+/** Idle. Nothing to report. */
+#define GFX_MONO_MENU_EVENT_IDLE 0xFF
+/** Exit. User has pressed the back button. */
+#define GFX_MONO_MENU_EVENT_EXIT 0xFE
+/** @} */
+
+/** Maximum number of menu elements on display */
+#define GFX_MONO_MENU_ELEMENTS_PER_SCREEN ((GFX_MONO_LCD_HEIGHT / \
+ SYSFONT_LINESPACING) - 1)
+
+/** Menu struct */
+struct gfx_mono_menu {
+ PROGMEM_STRING_T title;
+ PROGMEM_STRING_T *strings;
+ uint8_t num_elements;
+ uint8_t current_selection;
+ uint8_t current_page;
+};
+
+void gfx_mono_menu_init(struct gfx_mono_menu *menu);
+uint8_t gfx_mono_menu_process_key(struct gfx_mono_menu *menu, uint8_t keycode);
+
+/** @} */
+
+#endif /* GFX_MONO_MENU_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.h.REMOVED.git-id
deleted file mode 100644
index f7af767e..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_menu.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1536a823252b9c40f438ded4f9e94c38e067364e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.c
new file mode 100644
index 00000000..4c97c1ee
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.c
@@ -0,0 +1,697 @@
+/**
+ * \file
+ *
+ * \brief Spin control widget
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "sysfont.h"
+#include "stdio.h"
+#include "gfx_mono.h"
+#include "gfx_mono_spinctrl.h"
+
+PROGMEM_DECLARE(gfx_mono_color_t, spin_indicator_data[]) = {
+ GFX_MONO_SPINCTRL_SPIN_INDICATOR_BITMAP
+};
+
+PROGMEM_DECLARE(gfx_mono_color_t, indicator_data[]) = {
+ GFX_MONO_SPINCTRL_INDICATOR_BITMAP
+};
+
+struct gfx_mono_bitmap gfx_mono_spinctrl_bitmap_spin_indicator = {
+ .height = GFX_MONO_SPINCTRL_SPIN_INDICATOR_HEIGHT,
+ .width = GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH,
+ .type = GFX_MONO_BITMAP_PROGMEM,
+ .data.progmem = spin_indicator_data
+};
+
+struct gfx_mono_bitmap gfx_mono_spinctrl_bitmap_indicator = {
+ .height = GFX_MONO_SPINCTRL_INDICATOR_HEIGHT,
+ .width = GFX_MONO_SPINCTRL_INDICATOR_WIDTH,
+ .type = GFX_MONO_BITMAP_PROGMEM,
+ .data.progmem = indicator_data
+};
+
+/**
+ * \brief Draw or delete indicator arrow in front of spinner
+ *
+ * \param *spinner initialized gfx_mono_spinctrl struct
+ * \param draw true on draw, false on delete
+ */
+static void gfx_mono_spinctrl_draw_indicator(struct gfx_mono_spinctrl *spinner,
+ bool draw)
+{
+ if (draw) {
+ gfx_mono_put_bitmap(&gfx_mono_spinctrl_bitmap_indicator, 0,
+ spinner->y);
+ } else {
+ gfx_mono_draw_filled_rect(0, spinner->y,
+ GFX_MONO_SPINCTRL_INDICATOR_WIDTH,
+ GFX_MONO_SPINCTRL_INDICATOR_HEIGHT,
+ GFX_PIXEL_CLR);
+ }
+}
+
+/**
+ * \brief Draw or delete indicator in front of spinner data
+ *
+ * \param spinner pointer to initialized gfx_mono_spinctrl struct
+ * \param draw true on draw, false on delete
+ */
+static void gfx_mono_spinctrl_draw_spin_indicator(struct gfx_mono_spinctrl
+ *spinner, bool draw)
+{
+ if (draw) {
+ gfx_mono_put_bitmap(&gfx_mono_spinctrl_bitmap_spin_indicator,
+ GFX_MONO_LCD_WIDTH - GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH,
+ spinner->y);
+ } else {
+ gfx_mono_draw_filled_rect(GFX_MONO_LCD_WIDTH -
+ GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH,
+ spinner->y,
+ GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH,
+ GFX_MONO_SPINCTRL_SPIN_INDICATOR_HEIGHT,
+ GFX_PIXEL_CLR);
+ }
+}
+
+/**
+ * \brief Draw OK button at bottom of screen
+ *
+ * This function draws an OK button at the bottom of the screen. It will
+ * also draw an indicator arrow in front of the button if the indicator bool
+ * is true. If the draw bool is false, the OK button will be deleted, and if
+ * the indicator bool is false, the indicator will be deleted.
+ *
+ * \param draw true on draw, false on delete
+ * \param indicator true on draw indicator, false on delete
+ */
+static void gfx_mono_spinctrl_draw_button(bool draw, bool indicator)
+{
+ uint8_t width;
+ uint8_t height;
+ uint8_t offset;
+ char string_buf[22];
+
+ /* Clear bottom line */
+ gfx_mono_draw_filled_rect(0,
+ (SYSFONT_HEIGHT + 1) *
+ GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION,
+ GFX_MONO_LCD_WIDTH, SYSFONT_HEIGHT, GFX_PIXEL_CLR);
+
+ snprintf(string_buf, sizeof(string_buf), "OK");
+ gfx_mono_get_string_bounding_box(string_buf, &sysfont, &width, &height);
+ offset = (GFX_MONO_LCD_WIDTH - width) / 2;
+
+ if (draw) {
+ /* Draw OK button in the middle of the last line */
+ gfx_mono_draw_string(string_buf, offset,
+ (SYSFONT_HEIGHT + 1) *
+ GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION,
+ &sysfont);
+ if (indicator) {
+ /* Draw indicator arrow in front of button */
+ gfx_mono_put_bitmap(&gfx_mono_spinctrl_bitmap_indicator,
+ offset - GFX_MONO_SPINCTRL_INDICATOR_WIDTH,
+ (SYSFONT_HEIGHT + 1) *
+ GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION);
+ } else {
+ /* Delete indicator */
+ gfx_mono_draw_filled_rect(offset -
+ GFX_MONO_SPINCTRL_INDICATOR_WIDTH,
+ (SYSFONT_HEIGHT + 1) *
+ GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION,
+ GFX_MONO_SPINCTRL_INDICATOR_WIDTH,
+ GFX_MONO_SPINCTRL_INDICATOR_HEIGHT,
+ GFX_PIXEL_CLR);
+ }
+ } else {
+ /* Delete OK button */
+ gfx_mono_draw_filled_rect(
+ offset - GFX_MONO_SPINCTRL_INDICATOR_WIDTH,
+ (SYSFONT_HEIGHT + 1) *
+ GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION, 20,
+ SYSFONT_HEIGHT, GFX_PIXEL_CLR);
+ }
+}
+
+/**
+ * \brief Draw spinner at its position.
+ *
+ * This function draws a spinner at its position.
+ * The title of the spinner is only drawn if the redraw option is set.
+ * If the spinner is in focus, arrows will be drawn next to the spinner value
+ * to indicate that it is spinnable.
+ *
+ * \param spinner pointer to initialized gfx_mono_spinctrl struct
+ * \param redraw true if title of spinner should be drawn
+ */
+void gfx_mono_spinctrl_draw(struct gfx_mono_spinctrl *spinner, bool redraw)
+{
+ char string_buf[GFX_MONO_SPINCTRL_INT_SPINNER_WIDTH];
+ uint8_t index;
+ uint8_t offset;
+
+ if (redraw) {
+ /* Clear line */
+ gfx_mono_draw_filled_rect(0, spinner->y, GFX_MONO_LCD_WIDTH,
+ SYSFONT_HEIGHT, GFX_PIXEL_CLR);
+ /* Draw title */
+ gfx_mono_draw_progmem_string((char PROGMEM_PTR_T)spinner->title,
+ GFX_MONO_SPINCTRL_INDICATOR_WIDTH + 1,
+ spinner->y, &sysfont);
+ }
+
+ if (spinner->in_focus) {
+ gfx_mono_spinctrl_draw_spin_indicator(spinner, true);
+ } else {
+ gfx_mono_spinctrl_draw_spin_indicator(spinner, false);
+ }
+
+ if (spinner->datatype == SPINTYPE_INTEGER) {
+ offset = GFX_MONO_LCD_WIDTH -
+ (SYSFONT_WIDTH *
+ GFX_MONO_SPINCTRL_INT_SPINNER_WIDTH);
+ snprintf(string_buf, sizeof(string_buf), "%d",
+ spinner->integer_data);
+ /* Delete previous spinner data */
+ gfx_mono_draw_filled_rect(offset, spinner->y,
+ GFX_MONO_LCD_WIDTH - offset -
+ GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH,
+ SYSFONT_HEIGHT,
+ GFX_PIXEL_CLR);
+ /* Draw integer data */
+ gfx_mono_draw_string(string_buf, offset, spinner->y, &sysfont);
+ } else if (spinner->datatype == SPINTYPE_STRING) {
+ index = spinner->strings.index;
+ offset = GFX_MONO_LCD_WIDTH -
+ (SYSFONT_WIDTH *
+ GFX_MONO_SPINCTRL_STRING_SPINNER_WIDTH);
+
+ /* Delete previous spinner data */
+ gfx_mono_draw_filled_rect(offset, spinner->y,
+ GFX_MONO_LCD_WIDTH - offset -
+ GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH,
+ SYSFONT_HEIGHT,
+ GFX_PIXEL_CLR);
+
+ /* Draw string data */
+ gfx_mono_draw_progmem_string(
+ (char PROGMEM_PTR_T)spinner->strings.data[index], offset,
+ spinner->y, &sysfont);
+ }
+}
+
+/**
+ * \brief Initialize a spinner.
+ *
+ * This function initializes a spinner to either
+ * \ref gfx_mono_spinctrl_type_t "SPINTYPE_STRING" spinner that spins through
+ * the strings in a \ref PROGMEM_STRING_T or a
+ * \ref gfx_mono_spinctrl_type_t "SPINTYPE_INTEGER" spinner that spins through
+ * integers.
+ * If the spinner type is SPINTYPE_INTEGER, it will spin from lower_limit to
+ * upper_limit.
+ * If the spinner type is SPINTYPE_STRING, a pointer to a PROGMEM_STRING_T must
+ * be provided, and the spinner will spin through the strings starting at
+ * index lower_limit ending at index upper_limit.
+ * The y parameter specifies where to place the spinner on the screen, but is
+ * overwritten if the spinner is put in a spincollection.
+ *
+ * \param spinner pointer to initialized gfx_mono_spinctrl struct
+ * \param datatype typer of spinner, integer or string
+ * \param title title of spinner
+ * \param data pointer to progmem string array if datatype is string.
+ * NULL if datatype is integer.
+ * \param lower_limit lower limit and start value of spinner's data
+ * \param upper_limit upper limit of spinner's data
+ * \param y y position of spinner
+ */
+void gfx_mono_spinctrl_init(struct gfx_mono_spinctrl *spinner,
+ gfx_mono_spinctrl_type_t datatype, PROGMEM_STRING_T title,
+ PROGMEM_STRING_T *data, int16_t lower_limit,
+ int16_t upper_limit,
+ gfx_coord_t y)
+{
+ /* Initialization of spinner parameters */
+ spinner->title = title;
+ spinner->datatype = datatype;
+ spinner->lower_limit = lower_limit;
+ spinner->upper_limit = upper_limit;
+ spinner->y = y;
+ spinner->in_focus = false;
+ spinner->last_saved_value = spinner->lower_limit;
+
+ if (datatype == SPINTYPE_STRING) {
+ spinner->strings.data = data;
+ spinner->strings.index = lower_limit;
+ } else {
+ spinner->integer_data = lower_limit;
+ }
+}
+
+/**
+ * \brief Initialize a spincollection.
+ *
+ * This function initializes a spincollection to which spinners can be added.
+ *
+ * \param collection pointer to gfx_mono_spinctrl_spincollection to Initialize
+ */
+void gfx_mono_spinctrl_spincollection_init(struct
+ gfx_mono_spinctrl_spincollection *collection)
+{
+ collection->active_spinner = false;
+ collection->current_selection = 0;
+ collection->number_of_spinners = 0;
+ collection->init = true;
+}
+
+/**
+ * \brief Add spinner to spincollection
+ *
+ * This function adds an initialized spinner to a spincollection and positions
+ * it below any other spinners in the spincollection on the screen. The
+ * spinners in the spincollection are linked together and number of spinners is
+ * updated.
+ * It is not possible to add more spinners than
+ * \ref GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION "maximum number of
+ * spinners in a spincollection".
+ *
+ * \param spinner pointer to initialized gfx_mono_spinctrl struct to add
+ * to collection
+ * \param spinners pointer to initialized gfx_mono_spinctrl_spincollection
+ * struct
+ *
+ */
+void gfx_mono_spinctrl_spincollection_add_spinner(struct
+ gfx_mono_spinctrl *spinner,
+ struct gfx_mono_spinctrl_spincollection *spinners)
+{
+ uint8_t i;
+ struct gfx_mono_spinctrl *lastspinner;
+
+ /* Do not add more spinner elements than maximum number of spinners */
+ if (spinners->number_of_spinners >=
+ GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION) {
+ return;
+ }
+
+ /* Place new spinner below previous spinners on screen */
+ spinner->y = (SYSFONT_HEIGHT + 1) * spinners->number_of_spinners;
+
+ /* Add pointer to the spinner in spincollection if empty */
+ if (spinners->number_of_spinners == 0) {
+ spinners->collection = spinner;
+ } else {
+ lastspinner = spinners->collection;
+ for (i = 1; i < spinners->number_of_spinners; i++) {
+ lastspinner = lastspinner->next;
+ }
+ /* Link the new spinner to the current last spinner in the
+ * collection */
+ lastspinner->next = spinner;
+ /* Link the current last spinner as previous spinner for new
+ * spinner */
+ spinner->prev = lastspinner;
+ }
+
+ /* Set added spinner as last spinner in collection */
+ spinners->collection_last = spinner;
+ /* Update number of spinners in collection */
+ spinners->number_of_spinners++;
+}
+
+/**
+ * \brief Show spincollection
+ *
+ * This function draws all the spinners in a spincollection to the screen,
+ * together with an OK button at the bottom. It also draws an indicator arrow
+ * in front of the top spinner.
+ *
+ * \param spinners pointer to initialized spincollection to display
+ */
+void gfx_mono_spinctrl_spincollection_show(struct
+ gfx_mono_spinctrl_spincollection *spinners)
+{
+ uint8_t i;
+ struct gfx_mono_spinctrl *iterator;
+
+ /* Clear screen */
+ gfx_mono_draw_filled_rect(0, 0, GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT,
+ GFX_PIXEL_CLR);
+
+ /* Make sure there are spinners in the collection */
+ if (spinners->number_of_spinners == 0) {
+ return;
+ }
+
+ /* Draw spinners on screen */
+ iterator = spinners->collection;
+ for (i = 0; i < spinners->number_of_spinners; i++) {
+ gfx_mono_spinctrl_draw(iterator, true);
+ iterator = iterator->next;
+ }
+ /* Draw OK button at bottom of screen */
+ gfx_mono_spinctrl_draw_button(true, false);
+ /* Draw indicator arrow in front of first spinner */
+ gfx_mono_spinctrl_draw_indicator(spinners->collection, true);
+}
+
+/**
+ * \brief Step up spinner data
+ *
+ * This function steps up the data, making sure it does not go
+ * beyond the upper limit. Wraps around if it does.
+ *
+ * \param spinner pointer to initialized spinner.
+ */
+static void gfx_mono_spinctrl_step_up(struct gfx_mono_spinctrl *spinner)
+{
+ /* Check if spinner type is integer or string, increment integer data or
+ * move to next string index.
+ */
+ if (spinner->datatype == SPINTYPE_INTEGER) {
+ if (spinner->integer_data < spinner->upper_limit) {
+ spinner->integer_data++;
+ } else {
+ spinner->integer_data = spinner->lower_limit;
+ }
+ } else if (spinner->datatype == SPINTYPE_STRING) {
+ if (spinner->strings.index < spinner->upper_limit) {
+ spinner->strings.index++;
+ } else {
+ (spinner->strings.index) = spinner->lower_limit;
+ }
+ }
+}
+
+/**
+ * \brief Step down spinner data
+ *
+ * * This function steps down the data, making sure it does not go
+ * below the lower limit. Wraps around if it does.
+ *
+ * \param spinner pointer to initialized spinner.
+ */
+static void gfx_mono_spinctrl_step_down(struct gfx_mono_spinctrl *spinner)
+{
+ /* Check if spinner type is integer or string, increment integer data,
+ * move to next string index.
+ */
+ if (spinner->datatype == SPINTYPE_INTEGER) {
+ if (spinner->integer_data > spinner->lower_limit) {
+ spinner->integer_data--;
+ } else {
+ spinner->integer_data = spinner->upper_limit;
+ }
+ } else if (spinner->datatype == SPINTYPE_STRING) {
+ if (spinner->strings.index > (spinner->lower_limit)) {
+ spinner->strings.index--;
+ } else {
+ spinner->strings.index = spinner->upper_limit;
+ }
+ }
+}
+
+/**
+ * \brief Update single spinner depending on input.
+ *
+ * \param spinner pointer to initialized spinner.
+ * \param keycode keycode to process
+ *
+ * \retval selected selected spinner value
+ * \retval GFX_MONO_SPINCTRL_EVENT_IDLE spinner spinning
+ * \retval GFX_MONO_SPINCTRL_EVENT_BACK spinner deselected
+ */
+int16_t gfx_mono_spinctrl_process_key(struct gfx_mono_spinctrl *spinner,
+ uint8_t keycode)
+{
+ switch (keycode) {
+ case GFX_MONO_SPINCTRL_KEYCODE_DOWN:
+ if (spinner->in_focus) {
+ gfx_mono_spinctrl_step_down(spinner);
+ /* Update spinner on display */
+ gfx_mono_spinctrl_draw(spinner, false);
+ }
+
+ /* Nothing selected yet */
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+
+ case GFX_MONO_SPINCTRL_KEYCODE_UP:
+ if (spinner->in_focus) {
+ gfx_mono_spinctrl_step_up(spinner);
+ /* Update spinner on display */
+ gfx_mono_spinctrl_draw(spinner, false);
+ }
+
+ /* Nothing selected yet */
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+
+ case GFX_MONO_SPINCTRL_KEYCODE_ENTER:
+ if (spinner->in_focus) {
+ if (spinner->datatype == SPINTYPE_INTEGER) {
+ spinner->in_focus = false;
+ gfx_mono_spinctrl_draw(spinner, false);
+ /* Store saved value in case of aborting spinner
+ * later */
+ spinner->last_saved_value
+ = spinner->integer_data;
+ /* Got what we want. Return selection. */
+ return spinner->integer_data;
+ } else if (spinner->datatype == SPINTYPE_STRING) {
+ spinner->in_focus = false;
+ gfx_mono_spinctrl_draw(spinner, false);
+ /* Store saved value in case of aborting spinner
+ * later */
+ spinner->last_saved_value
+ = spinner->strings.index;
+ /* Got what we want. Return selection. */
+ return spinner->strings.index;
+ }
+ } else {
+ /* Spinner selected */
+ spinner->in_focus = true;
+ gfx_mono_spinctrl_draw(spinner, false);
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+ }
+
+ case GFX_MONO_SPINCTRL_KEYCODE_BACK:
+ /* User pressed "back" key, */
+ spinner->in_focus = false;
+ /* Spinner choice aborted, show last saved value instead */
+ if (spinner->datatype == SPINTYPE_INTEGER) {
+ spinner->integer_data = spinner->last_saved_value;
+ } else if (spinner->datatype == SPINTYPE_STRING) {
+ spinner->strings.index = spinner->last_saved_value;
+ }
+
+ gfx_mono_spinctrl_draw(spinner, false);
+ return GFX_MONO_SPINCTRL_EVENT_BACK;
+
+ default:
+ /* Unknown key event */
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+ }
+}
+
+/**
+ * \brief Update spincollection on screen depending on input
+ *
+ * This function returns \ref GFX_MONO_SPINCTRL_EVENT_FINISH if user has
+ * pressed the OK button. The spinner choices can then be extracted from the
+ * results array. If a spinner is of type SPINTYPE_STRING, the index of the
+ * progmem string will be stored in the results array, else the selected
+ * integer value will be stored.
+ * The choice from the first spinner added to the spincollection will be stored
+ * at index 0 in the results array, the second at index 1 and so on.
+ * If user has pressed the back button, \ref GFX_MONO_SPINCTRL_EVENT_BACK is
+ * returned, signalling that the application should be cancelled.
+ *
+ * \param spinners pointer to initialized
+ * gfx_mono_spinctrl_spincollection
+ * \param keycode keycode to process
+ * \param results array to store results from the spinners, must be of
+ * same length as number of spinners
+ *
+ * \retval GFX_MONO_SPINCTRL_EVENT_FINISH user pressed ok button
+ * \retval GFX_MONO_SPINCTRL_EVENT_BACK user cancelled
+ * \retval GFX_MONO_SPINCTRL_EVENT_IDLE user is navigating in spincollection
+ */
+int16_t gfx_mono_spinctrl_spincollection_process_key(struct
+ gfx_mono_spinctrl_spincollection *spinners, uint8_t keycode,
+ int16_t results[])
+{
+ uint8_t i;
+ struct gfx_mono_spinctrl *iterator;
+
+ /* Make sure there are spinners in the collection, if not, cancel */
+ if (spinners->number_of_spinners == 0) {
+ return GFX_MONO_SPINCTRL_EVENT_BACK;
+ }
+
+ /* Store initial values in results array first time function is run */
+ if (spinners->init) {
+ iterator = spinners->collection;
+ for (i = 0; i < spinners->number_of_spinners; i++) {
+ if (iterator->datatype == SPINTYPE_INTEGER) {
+ results[i] = iterator->integer_data;
+ } else {
+ results[i] = iterator->strings.index;
+ }
+
+ iterator = iterator->next;
+ }
+ spinners->init = false;
+ }
+
+ /* Find current spinner selection */
+ iterator = spinners->collection;
+ if (spinners->current_selection != GFX_MONO_SPINCTRL_BUTTON) {
+ for (i = 0; i < spinners->current_selection; i++) {
+ iterator = iterator->next;
+ }
+ }
+
+ if (spinners->active_spinner) {
+ /* Process chosen spinner */
+ spinners->selection = gfx_mono_spinctrl_process_key(iterator,
+ keycode);
+ if (spinners->selection == GFX_MONO_SPINCTRL_EVENT_BACK) {
+ /* User has exited spinner without saving the result */
+ spinners->active_spinner = false;
+ } else if (spinners->selection !=
+ GFX_MONO_SPINCTRL_EVENT_IDLE) {
+ /* Value selected, store in array */
+ results[spinners->current_selection]
+ = spinners->selection;
+ /* Step out of spinner and into spincollection */
+ spinners->active_spinner = false;
+ }
+
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+ } else {
+ switch (keycode) {
+ case GFX_MONO_SPINCTRL_KEYCODE_DOWN:
+ if (spinners->current_selection ==
+ GFX_MONO_SPINCTRL_BUTTON) {
+ spinners->current_selection = 0;
+ /* Delete indicator arrow in front of button */
+ gfx_mono_spinctrl_draw_button(true, false);
+ /* Draw indicator arrow in front of first
+ * spinner */
+ gfx_mono_spinctrl_draw_indicator(iterator,
+ true);
+ } else if (spinners->current_selection <
+ spinners->number_of_spinners - 1) {
+ /* Delete indicator arrow */
+ gfx_mono_spinctrl_draw_indicator(iterator,
+ false);
+ spinners->current_selection++;
+ /* Draw indicator arrow in front of new spinner */
+ gfx_mono_spinctrl_draw_indicator(iterator->next,
+ true);
+ } else {
+ /* Delete indicator arrow */
+ gfx_mono_spinctrl_draw_indicator(iterator,
+ false);
+ spinners->current_selection
+ = GFX_MONO_SPINCTRL_BUTTON;
+ /* Draw indicator arrow in front of button */
+ gfx_mono_spinctrl_draw_button(true, true);
+ }
+
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+
+ case GFX_MONO_SPINCTRL_KEYCODE_UP:
+ if (spinners->current_selection ==
+ GFX_MONO_SPINCTRL_BUTTON) {
+ /* Delete indicator arrow in front of button */
+ gfx_mono_spinctrl_draw_button(true, false);
+ spinners->current_selection
+ = spinners->number_of_spinners - 1;
+ /* Draw indicator arrow in front of new spinner */
+ gfx_mono_spinctrl_draw_indicator(
+ spinners->collection_last,
+ true);
+ } else if (spinners->current_selection > 0) {
+ /* Delete indicator arrow */
+ gfx_mono_spinctrl_draw_indicator(iterator,
+ false);
+ spinners->current_selection--;
+ /* Draw indicator arrow in front of new spinner */
+ gfx_mono_spinctrl_draw_indicator(iterator->prev,
+ true);
+ } else {
+ /* Delete indicator arrow */
+ gfx_mono_spinctrl_draw_indicator(iterator,
+ false);
+ spinners->current_selection
+ = GFX_MONO_SPINCTRL_BUTTON;
+ /* Draw indicator arrow in front of button */
+ gfx_mono_spinctrl_draw_button(true, true);
+ }
+
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+
+ case GFX_MONO_SPINCTRL_KEYCODE_ENTER:
+ if (spinners->current_selection ==
+ GFX_MONO_SPINCTRL_BUTTON) {
+ /* Finished with all selections, return */
+ return GFX_MONO_SPINCTRL_EVENT_FINISH;
+ } else {
+ /* Spinner selected, send next keycode directly
+ * to spinner */
+ gfx_mono_spinctrl_process_key(iterator,
+ keycode);
+ spinners->active_spinner = true;
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+ }
+
+ case GFX_MONO_SPINCTRL_KEYCODE_BACK:
+ /* User pressed "back" key, */
+ return GFX_MONO_SPINCTRL_EVENT_BACK;
+
+ default:
+ /* Unknown key event */
+ return GFX_MONO_SPINCTRL_EVENT_IDLE;
+ }
+ }
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.c.REMOVED.git-id
deleted file mode 100644
index 546457d2..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4c97c1ee1900d01814db4885dd5c35ed0c11a4e5
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.h
new file mode 100644
index 00000000..98ec70ee
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.h
@@ -0,0 +1,243 @@
+/**
+ * \file
+ *
+ * \brief Spin control widget
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef GFX_MONO_SPINCTRL_H
+#define GFX_MONO_SPINCTRL_H
+
+#include "gfx_mono.h"
+#include "conf_spinctrl.h"
+
+/**
+ * \ingroup gfx_mono
+ * \defgroup gfx_mono_spinctrl Spinner widget for monochrome graphical displays
+ *
+ * This module provides a spinner widget system for monochrome graphical
+ * displays.
+ *
+ * There is support for having one single spinner on the screen, or a
+ * collection of spinners.
+ *
+ * Typical flow of an application using the spincollection system:
+ *
+ * 1) Define spinners.\n
+ * 2) Initialize each spinners with \ref gfx_mono_spinctrl_init.\n
+ * 3) Define a spincollection struct and initialize it with
+ * \ref gfx_mono_spinctrl_spincollection_init.\n
+ * 4) Add spinners to spincollection with
+ * \ref gfx_mono_spinctrl_spincollection_add_spinner.\n
+ * 5) Draw spincollection to screen with
+ * \ref gfx_mono_spinctrl_spincollection_show.\n
+ * 6) Define a result array to store the spinner choices.\n
+ * 7) Update spinners and result array with user input using function
+ * \ref gfx_mono_spinctrl_spincollection_process_key.\n
+ * 8) Interpret \ref gfx_mono_spinctrl_spincollection_process_key return
+ * value.\n
+ * 9) Go to 7.\n
+ *
+ * Typical flow of an application using a single spinner:
+ *
+ * 1) Define spinner.\n
+ * 2) Initialize the spinners with \ref gfx_mono_spinctrl_init with preferred y
+ * position on screen.\n
+ * 3) Draw spinner to screen with \ref gfx_mono_spinctrl_draw.\n
+ * 4) Update spinner with user input using function
+ * \ref gfx_mono_spinctrl_process_key.\n
+ * 5) Interpret \ref gfx_mono_spinctrl_process_key return value.\n
+ * 6) Go to 4.\n
+ *
+ * Before the spinners can be updated, you need input from the user. Methods
+ * for getting input is not part of the spinner widget.
+ *
+ * \note The spinners will be linked together when added to a spincollection,
+ * and can therefore not be used in two spincollections at the same time.
+ *
+ * As soon as input is received, inform the spincollection system or the single
+ * spinner using the \ref gfx_mono_spinctrl_spincollection_process_key function
+ * or the \ref gfx_mono_spinctrl_process_key function.
+ * These functions will then return a status code and act depending on the
+ * given keycode:
+ *
+ * GFX_MONO_SPINCTRL_KEYCODE_DOWN : Change selection to next spinner value or
+ * to next spinner or OK button in a spincollection.
+ *
+ * GFX_MONO_SPINCTRL_KEYCODE_UP : Change selection to previous spinner value
+ * or to previous spinner or OK button in a spincollection.
+ *
+ * GFX_MONO_SPINCTRL_KEYCODE_ENTER : Select spinner value or select spinner or
+ * OK button in a spincollection.
+ *
+ * GFX_MONO_SPINCTRL_KEYCODE_BACK : Deselect spinner or cancel spincollection
+ * application.
+ *
+ * The value of the keycodes used are defined in conf_spinctrl.h. These values
+ * can be changed if needed.
+ *
+ * The graphical indicators used to indicate spinner selections are defined in
+ * conf_spinctrl.h. These indicators can be changed if needed.
+ * @{
+ */
+
+/** Spinner idle event */
+#define GFX_MONO_SPINCTRL_EVENT_IDLE 0xFF
+/** Spinner back button pressed event */
+#define GFX_MONO_SPINCTRL_EVENT_BACK 0xFE
+/** Spinner ok button pressed event */
+#define GFX_MONO_SPINCTRL_EVENT_FINISH 0xFD
+
+/** OK button */
+#define GFX_MONO_SPINCTRL_BUTTON 0xFF
+
+/** Maximum number of spinner elements on display */
+#define GFX_MONO_SPINCTRL_ELEMENTS_PER_SCREEN \
+ ((GFX_MONO_LCD_HEIGHT / SYSFONT_LINESPACING) - 1)
+
+/**
+ * Maximum numbers of spinner elements in a spincollection - limited to
+ * one screen.
+ */
+#define GFX_MONO_SPINCTRL_MAX_ELEMENTS_IN_SPINCOLLECTION \
+ GFX_MONO_SPINCTRL_ELEMENTS_PER_SCREEN
+
+/** Width of string spinner choices */
+#define GFX_MONO_SPINCTRL_STRING_SPINNER_WIDTH 9
+/** Width of integer spinner choices */
+#define GFX_MONO_SPINCTRL_INT_SPINNER_WIDTH 9
+
+/** Enum to specify what kind of data spinner should spin */
+typedef enum gfx_mono_spinctrl_type_enum {
+ SPINTYPE_STRING,
+ SPINTYPE_INTEGER
+} gfx_mono_spinctrl_type_t;
+
+/** String struct */
+struct gfx_mono_spinctrl_string {
+ /** Pointer to progmem strings to spin through
+ * \note Each string must be shorter than
+ * \ref GFX_MONO_SPINCTRL_STRING_SPINNER_WIDTH characters.
+ * If not, printing it to the screen will corrupt the spinner
+ * appearance.
+ */
+ PROGMEM_STRING_T *data;
+ /** Index in string array */
+ uint8_t index;
+};
+
+/** Spin control struct */
+struct gfx_mono_spinctrl {
+ /** Spinner title */
+ PROGMEM_STRING_T title;
+ /** Type of data to spin */
+ gfx_mono_spinctrl_type_t datatype;
+ /** Spinner data, depends on spinner datatype. */
+ union {
+ /** Spinner strings and index */
+ struct gfx_mono_spinctrl_string strings;
+ /** Spinner integer data */
+ int16_t integer_data;
+ };
+ /** Variable to store the last selected spinner value */
+ uint16_t last_saved_value;
+
+ /**
+ * Lower limit for spinning, must be positive and fit in uin8_t for
+ * spinner type SPINTYPE_STRING
+ */
+ int16_t lower_limit;
+
+ /**
+ * Upper limit for spinning, must be positive and fit in uin8_t for
+ * spinner type SPINTYPE_STRING
+ */
+ int16_t upper_limit;
+ /** Y coordinate for placement of spinner on screen */
+ gfx_coord_t y;
+ /** Boolean to tell if spinner is in focus or not */
+ bool in_focus;
+ /** Pointer to next spinner in a spincollection */
+ struct gfx_mono_spinctrl *next;
+ /** Pointer to previous spinner in a spincollection */
+ struct gfx_mono_spinctrl *prev;
+};
+
+/** Collection of spinners struct */
+struct gfx_mono_spinctrl_spincollection {
+ /** Pointer to the first spinner in the collection */
+ struct gfx_mono_spinctrl *collection;
+ /** Pointer to the last spinner in the collection */
+ struct gfx_mono_spinctrl *collection_last;
+ /** Number of spinners in collection */
+ uint8_t number_of_spinners;
+ /** Current spinner/button */
+ uint8_t current_selection;
+ /** Return value from selected spinner */
+ uint16_t selection;
+ /** Boolean to tell if input should be sent directly to a spinner */
+ bool active_spinner;
+ /** Boolean to initialize results array when starting key processing */
+ bool init;
+};
+
+void gfx_mono_spinctrl_init(struct gfx_mono_spinctrl *spinner,
+ gfx_mono_spinctrl_type_t datatype, PROGMEM_STRING_T title,
+ PROGMEM_STRING_T *data, int16_t lower_limit,
+ int16_t upper_limit,
+ gfx_coord_t y);
+void gfx_mono_spinctrl_draw(struct gfx_mono_spinctrl *spinner, bool redraw);
+void gfx_mono_spinctrl_spincollection_init(struct
+ gfx_mono_spinctrl_spincollection *collection);
+void gfx_mono_spinctrl_spincollection_add_spinner(struct gfx_mono_spinctrl
+ *spinner, struct gfx_mono_spinctrl_spincollection *spinners);
+void gfx_mono_spinctrl_spincollection_show(struct
+ gfx_mono_spinctrl_spincollection *spinners);
+int16_t gfx_mono_spinctrl_process_key(struct gfx_mono_spinctrl *spinner,
+ uint8_t keycode);
+
+int16_t gfx_mono_spinctrl_spincollection_process_key(struct
+gfx_mono_spinctrl_spincollection *spinners, uint8_t keycode,
+int16_t results[]);
+
+/** @} */
+
+#endif /* GFX_MONO_SPINCTRL_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.h.REMOVED.git-id
deleted file mode 100644
index bfda6d5a..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_spinctrl.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-98ec70ee8bbb53184bed42ebe03e4b80f3446d66
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.c
new file mode 100644
index 00000000..1412c5ef
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.c
@@ -0,0 +1,428 @@
+/**
+ * \file
+ *
+ * \brief Font and text drawing routines
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include "stddef.h"
+#include "assert.h"
+#ifdef CONFIG_HUGEMEM
+# include "hugemem.h"
+#endif
+#include "progmem.h"
+
+#include "gfx_mono.h"
+#include "gfx_mono_text.h"
+
+#ifndef CONFIG_FONT_PIXELS_PER_BYTE
+# define CONFIG_FONT_PIXELS_PER_BYTE 8
+#endif
+
+#define EXTMEM_BUF_SIZE 20
+
+#if defined(CONFIG_HUGEMEM) || defined(__DOXYGEN__)
+
+/**
+ * \internal
+ * \brief Helper function that draws a character from a font in hugemem
+ * to the display
+ *
+ * This function will first calculate the start offset in the font character
+ * data before iterating over the specific character data.
+ *
+ * Only pixels in the character that should be enabled are done so, the caller
+ * is required to prepare the drawing area before printing a character to it.
+ * This is done by the gfx_mono_draw_string() and
+ * gfx_mono_draw_progmem_string() functions.
+ *
+ * \param ch Character to be drawn
+ * \param x X coordinate on screen.
+ * \param y Y coordinate on screen.
+ * \param font Font to draw character in
+ */
+static void gfx_mono_draw_char_hugemem(const char ch, const gfx_coord_t x,
+ const gfx_coord_t y, const struct font *font)
+{
+ uint8_t i;
+ uint8_t char_row_size;
+ uint8_t glyph_size;
+ uint16_t glyph_data_offset;
+ uint8_t char_buff[EXTMEM_BUF_SIZE];
+ uint8_t buffer_pos;
+ uint8_t rows_left;
+
+ /* Sanity check on parameters, assert if font is NULL. */
+ Assert(font != NULL);
+
+ gfx_coord_t inc_x = x;
+ gfx_coord_t inc_y = y;
+
+ char_row_size = font->width / CONFIG_FONT_PIXELS_PER_BYTE;
+ if (font->width % CONFIG_FONT_PIXELS_PER_BYTE) {
+ char_row_size++;
+ }
+
+ glyph_size = char_row_size * font->height;
+ glyph_data_offset = glyph_size * ((uint8_t)ch - font->first_char);
+ buffer_pos = EXTMEM_BUF_SIZE;
+ rows_left = font->height;
+
+ do {
+ static uint8_t glyph_byte = 0;
+ uint8_t pixelsToDraw = font->width;
+
+ for (i = 0; i < pixelsToDraw; i++) {
+ if (i % CONFIG_FONT_PIXELS_PER_BYTE == 0) {
+ /* Read another byte from hugemem */
+ if (buffer_pos >= EXTMEM_BUF_SIZE) {
+ hugemem_ptr_t source
+ = font->data.hugemem;
+ source = (hugemem_ptr_t)
+ ((uint32_t)source +
+ glyph_data_offset);
+
+ hugemem_read_block(char_buff, source,
+ EXTMEM_BUF_SIZE);
+
+ glyph_data_offset += EXTMEM_BUF_SIZE;
+ buffer_pos = 0;
+ }
+
+ glyph_byte = char_buff[buffer_pos];
+ buffer_pos++;
+ }
+
+ /* Draw bit of glyph to screen */
+ if ((glyph_byte & 0x80)) {
+ gfx_mono_draw_pixel(inc_x, inc_y,
+ GFX_PIXEL_SET);
+ }
+
+ inc_x += 1;
+ glyph_byte <<= 1;
+ }
+
+ inc_y += 1;
+ inc_x = x;
+ } while (--rows_left > 0);
+}
+
+#endif
+
+/**
+ * \internal
+ * \brief Helper function that draws a character from a font in progmem
+ * to the display
+ *
+ * This function will first calculate the start offset in the font character
+ * data before iterating over the specific character data.
+ *
+ * Only pixels in the character that should be enabled are done so, the caller
+ * is required to prepare the drawing area before printing a character to it.
+ * This is done by the gfx_mono_draw_string() and
+ * gfx_mono_draw_progmem_string() functions.
+ *
+ * \param ch Character to be drawn
+ * \param x X coordinate on screen.
+ * \param y Y coordinate on screen.
+ * \param font Font to draw character in
+ */
+static void gfx_mono_draw_char_progmem(const char ch, const gfx_coord_t x,
+ const gfx_coord_t y, const struct font *font)
+{
+ uint8_t PROGMEM_PTR_T glyph_data;
+ uint16_t glyph_data_offset;
+ uint8_t char_row_size;
+ uint8_t rows_left;
+ uint8_t i;
+
+ /* Sanity check on parameters, assert if font is NULL. */
+ Assert(font != NULL);
+
+ gfx_coord_t inc_x = x;
+ gfx_coord_t inc_y = y;
+
+ char_row_size = font->width / CONFIG_FONT_PIXELS_PER_BYTE;
+ if (font->width % CONFIG_FONT_PIXELS_PER_BYTE) {
+ char_row_size++;
+ }
+
+ glyph_data_offset = char_row_size * font->height *
+ ((uint8_t)ch - font->first_char);
+ glyph_data = font->data.progmem + glyph_data_offset;
+ rows_left = font->height;
+
+ do {
+ uint8_t glyph_byte = 0;
+ uint8_t pixelsToDraw = font->width;
+
+ for (i = 0; i < pixelsToDraw; i++) {
+ if (i % CONFIG_FONT_PIXELS_PER_BYTE == 0) {
+ glyph_byte = PROGMEM_READ_BYTE(glyph_data);
+ glyph_data++;
+ }
+
+ if ((glyph_byte & 0x80)) {
+ gfx_mono_draw_pixel(inc_x, inc_y,
+ GFX_PIXEL_SET);
+ }
+
+ inc_x += 1;
+ glyph_byte <<= 1;
+ }
+
+ inc_y += 1;
+ inc_x = x;
+ rows_left--;
+ } while (rows_left > 0);
+}
+
+/**
+ * \brief Draws a character to the display
+ *
+ * \param c Character to be drawn
+ * \param x X coordinate on screen.
+ * \param y Y coordinate on screen.
+ * \param font Font to draw character in
+ */
+void gfx_mono_draw_char(const char c, const gfx_coord_t x, const gfx_coord_t y,
+ const struct font *font)
+{
+ gfx_mono_draw_filled_rect(x, y, font->width, font->height,
+ GFX_PIXEL_CLR);
+
+ switch (font->type) {
+ case FONT_LOC_PROGMEM:
+ gfx_mono_draw_char_progmem(c, x, y, font);
+ break;
+
+#ifdef CONFIG_HUGEMEM
+ case FONT_LOC_HUGEMEM:
+ gfx_mono_draw_char_hugemem(c, x, y, font);
+ break;
+
+#endif
+ default:
+ /* Unsupported mode, call assert */
+ Assert(false);
+ break;
+ }
+}
+
+/**
+ * \brief Draws a string to the display
+ *
+ * This function will draw a string located in memory to the display.
+ *
+ * \param str Pointer to string
+ * \param x X coordinate on screen.
+ * \param y Y coordinate on screen.
+ * \param font Font to draw string in
+ */
+void gfx_mono_draw_string(const char *str, gfx_coord_t x, gfx_coord_t y,
+ const struct font *font)
+{
+ /* Save X in order to know where to return to on CR. */
+ const gfx_coord_t start_of_string_position_x = x;
+
+ /* Sanity check on parameters, assert if str or font is NULL. */
+ Assert(str != NULL);
+ Assert(font != NULL);
+
+ /* Draw characters until trailing null byte */
+ do {
+ /* Handle '\n' as newline, draw normal characters. */
+ if (*str == '\n') {
+ x = start_of_string_position_x;
+ y += font->height + 1;
+ } else if (*str == '\r') {
+ /* Skip '\r' characters. */
+ } else {
+ gfx_mono_draw_char(*str, x, y, font);
+ x += font->width;
+ }
+ } while (*(++str));
+}
+
+/**
+ * \brief Draws a string located in program memory to the display
+ *
+ * This function will draw a string located in program memory to the display,
+ * this differs from gfx_mono_draw_string() by using constant string data from
+ * the program memory instead of string data in RAM.
+ *
+ * Using program memory for constant strings will reduce the applications need
+ * for RAM, and thus lower the overall size footprint.
+ *
+ * \param str Pointer to string located in program memory
+ * \param x X coordinate on screen.
+ * \param y Y coordinate on screen.
+ * \param font Font to draw string in
+ */
+void gfx_mono_draw_progmem_string(char PROGMEM_PTR_T str, gfx_coord_t x,
+ gfx_coord_t y, const struct font *font)
+{
+ char temp_char;
+
+ /* Sanity check on parameters, assert if str or font is NULL. */
+ Assert(str != NULL);
+ Assert(font != NULL);
+
+ /* Save X in order to know where to return to on CR. */
+ const gfx_coord_t start_of_string_position_x = x;
+
+ /* Draw characters until trailing null byte */
+ temp_char = PROGMEM_READ_BYTE((uint8_t PROGMEM_PTR_T)str);
+
+ while (temp_char) {
+ /* Handle '\n' as newline, draw normal characters. */
+ if (temp_char == '\n') {
+ x = start_of_string_position_x;
+ y += font->height + 1;
+ } else if (temp_char == '\r') {
+ /* Skip '\r' characters. */
+ } else {
+ gfx_mono_draw_char(temp_char, x, y, font);
+ x += font->width;
+ }
+
+ temp_char = PROGMEM_READ_BYTE((uint8_t PROGMEM_PTR_T)(++str));
+ }
+}
+
+/**
+ * \brief Computes the bounding box of a string
+ *
+ * \note If string is empty the returned width will be 1 pixel and the height
+ * equal to the font height.
+ *
+ * \param str String to calculate bounding box for
+ * \param font Font used
+ * \param width Pointer to width result
+ * \param height Pointer to height result
+ */
+void gfx_mono_get_string_bounding_box(const char *str, const struct font *font,
+ gfx_coord_t *width, gfx_coord_t *height)
+{
+ gfx_coord_t font_width = font->width;
+ gfx_coord_t font_height = font->height;
+
+ gfx_coord_t max_width = 1;
+ gfx_coord_t max_height = font_height;
+ gfx_coord_t x = 0;
+
+ /* Sanity check on parameters, assert if str or font is NULL. */
+ Assert(str != NULL);
+ Assert(font != NULL);
+
+ /* Handle each character until trailing null byte */
+ do {
+ /* Handle '\n' as newline, draw normal characters. */
+ if (*str == '\n') {
+ x = 0;
+ max_height += font_height;
+ } else if (*str == '\r') {
+ /* Skip '\r' characters. */
+ } else {
+ x += font_width;
+ if (x > max_width) {
+ max_width = x;
+ }
+ }
+ } while (*(++str));
+
+ /* Return values through references */
+ *width = max_width;
+ *height = max_height;
+}
+
+/**
+ * \brief Computes the bounding box of a string located in program memory
+ *
+ * \note If string is empty the returned width will be 1 pixel and the height
+ * equal to the font height.
+ *
+ * \param str String in program memory to calculate bounding box for
+ * \param font Font used
+ * \param width Pointer to width result
+ * \param height Pointer to height result
+ */
+void gfx_mono_get_progmem_string_bounding_box(char PROGMEM_PTR_T str,
+ const struct font *font, gfx_coord_t *width,
+ gfx_coord_t *height)
+{
+ gfx_coord_t font_width = font->width;
+ gfx_coord_t font_height = font->height;
+
+ char temp_char;
+ gfx_coord_t max_width = 1;
+ gfx_coord_t max_height = font_height;
+ gfx_coord_t x = 0;
+
+ /* Sanity check on parameters, assert if str or font is NULL. */
+ Assert(str != NULL);
+ Assert(font != NULL);
+
+ /* Handle each character until trailing null byte */
+ temp_char = PROGMEM_READ_BYTE((uint8_t PROGMEM_PTR_T)str);
+
+ while (temp_char) {
+ /* Handle '\n' as newline, draw normal characters. */
+ if (temp_char == '\n') {
+ x = 0;
+ max_height += font_height;
+ } else if (*str == '\r') {
+ /* Skip '\r' characters. */
+ } else {
+ x += font_width;
+ if (x > max_width) {
+ max_width = x;
+ }
+ }
+
+ temp_char = PROGMEM_READ_BYTE((uint8_t PROGMEM_PTR_T)(++str));
+ }
+
+ /* Return values through references */
+ *width = max_width;
+ *height = max_height;
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.c.REMOVED.git-id
deleted file mode 100644
index b2cb8a5e..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1412c5ef14fe715d6f65a036a704041096a11faf
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.h
new file mode 100644
index 00000000..ecbe790c
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.h
@@ -0,0 +1,131 @@
+/**
+ * \file
+ *
+ * \brief Monochrome graphic library API header file
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef GFX_MONO_TEXT_H_INCLUDED
+#define GFX_MONO_TEXT_H_INCLUDED
+
+#include
+
+#include "compiler.h"
+#include "progmem.h"
+#ifdef CONFIG_HAVE_HUGEMEM
+# include "hugemem.h"
+#endif
+
+/**
+ * \ingroup gfx_mono
+ * \defgroup gfx_mono_font Font support
+ * This modules provides functionality for outputting a monochrome font
+ * to a display.
+ *
+ * @{
+ */
+
+/**
+ * \brief Valid storage locations for font data
+ *
+ * \todo Add support for fonts in regular ram
+ */
+enum font_data_type {
+ /** Font data stored in program/flash memory. */
+ FONT_LOC_PROGMEM,
+#ifdef CONFIG_HAVE_HUGEMEM
+ /** Font data stored in HUGEMEM. */
+ FONT_LOC_HUGEMEM,
+#endif
+};
+
+/** Storage structure for font meta data. */
+struct font {
+ /** Type of storage used for binary font data. See \ref font_data_type. */
+ enum font_data_type type;
+ union {
+ /**
+ * Pointer to where the binary font data is stored. This
+ * variable is accessed either through hugemem or progmem
+ * depending on the value of \a type.
+ */
+#ifdef CONFIG_HAVE_HUGEMEM
+ hugemem_ptr_t hugemem;
+#endif
+ uint8_t PROGMEM_PTR_T progmem;
+ } data;
+ /** Width of one font character, in pixels. */
+ uint8_t width;
+ /** Height of one font character, in pixels. */
+ uint8_t height;
+ /** ASCII value of first character in font set. */
+ uint8_t first_char;
+ /** ASCII value of last character in the set. */
+ uint8_t last_char;
+};
+
+/** \name Strings and characters located in RAM */
+/** @{ */
+void gfx_mono_draw_char(const char c, const gfx_coord_t x, const gfx_coord_t y,
+ const struct font *font);
+
+void gfx_mono_draw_string(const char *str, const gfx_coord_t x,
+ const gfx_coord_t y, const struct font *font);
+
+void gfx_mono_get_string_bounding_box(char const *str, const struct font *font,
+ gfx_coord_t *width, gfx_coord_t *height);
+
+/** @} */
+
+/** \name Strings located in flash */
+/** @{ */
+void gfx_mono_draw_progmem_string(char PROGMEM_PTR_T str, gfx_coord_t x,
+ gfx_coord_t y, const struct font *font);
+
+void gfx_mono_get_progmem_string_bounding_box(char PROGMEM_PTR_T str,
+ const struct font *font, gfx_coord_t *width,
+ gfx_coord_t *height);
+
+/** @} */
+
+/** @} */
+
+#endif /* GFX_MONO_TEXT_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.h.REMOVED.git-id
deleted file mode 100644
index 38c1d085..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/gfx_mono_text.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ecbe790c335b59001bbd2cd25be836d4c43be231
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.c
new file mode 100644
index 00000000..cd0d0275
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.c
@@ -0,0 +1,75 @@
+/**
+ * \file
+ *
+ * \brief Graphical font support
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include
+#include
+#include
+#include
+
+#include "conf_sysfont.h"
+
+#include "gfx_mono.h"
+#include "sysfont.h"
+
+// Use macro from conf_sysfont.h to define font glyph data.
+SYSFONT_DEFINE_GLYPHS;
+
+/**
+ * \brief Initialize a basic system font
+ *
+ * This initializes a basic system font globally usable by the application.
+ */
+struct font sysfont = {
+ .type = FONT_LOC_PROGMEM,
+ .width = SYSFONT_WIDTH,
+ .height = SYSFONT_HEIGHT,
+ .first_char = SYSFONT_FIRSTCHAR,
+ .last_char = SYSFONT_LASTCHAR,
+ .data = {
+ .progmem = sysfont_glyphs,
+ },
+};
+
+/** @} */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.c.REMOVED.git-id
deleted file mode 100644
index 3eb3d5dc..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cd0d0275c448af573ee6850aadb90ec763159a63
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.h
new file mode 100644
index 00000000..8e57567b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.h
@@ -0,0 +1,70 @@
+/**
+ * \file
+ *
+ * \brief Graphical System Font system
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef SYSFONT_H_INCLUDED
+#define SYSFONT_H_INCLUDED
+
+#include "conf_sysfont.h"
+#include "gfx_mono.h"
+#include "gfx_mono_text.h"
+
+/**
+ * \ingroup gfx_mono_font
+ * \defgroup gfx_mono_sysfont System font
+ *
+ * The system font objects are globally available for a graphical application.
+ * System fonts are by design read only, hence there are not any functions to
+ * change them during runtime. If the application needs additional fonts it
+ * should add additional font objects.
+ *
+ * @{
+ */
+
+extern struct font sysfont;
+
+/** @} */
+
+#endif /* SYSFONT_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.h.REMOVED.git-id
deleted file mode 100644
index f464db4f..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/sysfont.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8e57567b40b7903168a57089624d38e2bd8a7fc6
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/bitmap.py b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/bitmap.py
new file mode 100644
index 00000000..fcddb9ca
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/bitmap.py
@@ -0,0 +1,58 @@
+##
+# \file
+#
+# \brief Output a 2 color bitmap as an uint8_t array
+#
+# Copyright (C) 2011-2014 Atmel Corporation. All rights reserved.
+#
+# \page License
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. The name of Atmel may not be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# 4. This software may only be redistributed and used in connection with an
+# Atmel microcontroller product.
+#
+# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from PIL import Image
+import sys
+
+im = Image.open(sys.argv[1]);
+new_im = im.load()
+
+width, height = im.size
+
+for y in range(0, height) :
+ for x in range(0, width) :
+ if 0 < new_im[x, y]:
+ new_im[x, y] = 1
+ sys.stdout.write(str(new_im[x, y]))
+ sys.stdout.write("\n")
+
+sys.stdout.write("\n uint8_t image_header[] = {\n")
+for y in range(0, height, 8) :
+ for x in range(0, width) :
+ first_byte = str(new_im[x, y + 7]) + str(new_im[x, y+6]) + str(new_im[x, y+5]) + str(new_im[x, y+4]) + str(new_im[x, y+3]) + str(new_im[x, y+2]) + str(new_im[x, y+1]) + str(new_im[x, y+0])
+ print "0x%x," % int(first_byte, 2),
+
+sys.stdout.write("};\n")
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/bitmap.py.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/bitmap.py.REMOVED.git-id
deleted file mode 100644
index c7b5bcd4..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/bitmap.py.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fcddb9ca488821674cbb91087cb479149a9d829c
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/dump_display_over_serial.py b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/dump_display_over_serial.py
new file mode 100644
index 00000000..5b532420
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/dump_display_over_serial.py
@@ -0,0 +1,133 @@
+##
+# \file
+#
+# \brief Convert display data on a serial line to a graphical representation
+#
+# Copyright (C) 2011-2014 Atmel Corporation. All rights reserved.
+#
+# \page License
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. The name of Atmel may not be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# 4. This software may only be redistributed and used in connection with an
+# Atmel microcontroller product.
+#
+# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import sys
+import serial
+import os.path
+import argparse
+
+def scan_for_ports():
+ available_ports = []
+
+ for index in range(64):
+ try:
+ serial_port = serial.Serial(index)
+ available_ports.append((index, serial_port.portstr))
+ serial_port.close()
+ except serial.SerialException:
+ pass
+ except IndexError as Error:
+ pass
+
+ for port_number, port_name in available_ports:
+ print "%02d - %s" % (port_number, port_name)
+
+ return available_ports
+
+def dump_display_data(serial_port, baud_rate, output_file_name):
+ try:
+ output_file = open(output_file_name, 'w')
+ port = serial.Serial(port = serial_port,
+ baudrate = baud_rate, timeout = 1)
+ port.close()
+ port.open()
+ except ValueError as e:
+ print "error: invalid serial port parameters. %s" % (str(e))
+ output_file.close()
+ return -1
+ except serial.SerialException as e:
+ print "error: could not open serial port. %s" % (str(e))
+ output_file.close()
+ return -1
+ except IOError as e:
+ print "error: could not open output file. %s" % (str(e))
+ return -1
+
+ print "Display on %s: %u,8,N,1" % (port.name, port.baudrate)
+ port.write("D")
+ line = port.readline()
+ display_data = ""
+ while(line[:2] != "};") :
+ display_data = display_data + line[:-1]
+ line = port.readline()
+ display_data = display_data + line
+ port.close()
+
+ print "Writing data to file %s" % (output_file_name)
+ output_file.write(display_data)
+
+ output_file.close()
+
+def main():
+ parser = argparse.ArgumentParser(description="This script will try to "
+ "open the given serial port, send a string to "
+ "instruct the target device to dump the contents of "
+ "the display to a serial link in XPM format. The "
+ "received file is then written to 'display.xpm', "
+ "unless a file is specified by the -o option.")
+ parser.add_argument("-p", "--port", dest="serial_port",
+ help="which serial port to open")
+ parser.add_argument("-b", "--baud", dest="baudrate", type=int,
+ help="baud rate to use for serial communication",
+ default=19200)
+ parser.add_argument("-o", "--output", dest="output_file",
+ help="write XPM image to FILE. Default is display.xpm.",
+ metavar="FILE", default="display.xpm")
+ parser.add_argument("-s", "--scan", action="store_true",
+ dest="scan_ports",
+ help="scan for available serial ports and exit",
+ default=False)
+
+ arguments = parser.parse_args()
+
+ if arguments.scan_ports:
+ scan_for_ports()
+ sys.exit()
+
+ if arguments.serial_port is None:
+ parser.print_usage()
+ sys.exit()
+
+ if os.path.exists(arguments.output_file):
+ print "Warning: output file '%s' already exists" % (arguments.output_file)
+ print "Do you want to write over file '%s'?" % (arguments.output_file)
+ answer = raw_input("[yes/NO] ")
+ if answer not in ("yes", "Yes", "YES"):
+ sys.exit()
+
+ dump_display_data(arguments.serial_port, arguments.baudrate, arguments.output_file)
+
+if __name__ == "__main__":
+ main()
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/dump_display_over_serial.py.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/dump_display_over_serial.py.REMOVED.git-id
deleted file mode 100644
index f8d6ecbf..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/dump_display_over_serial.py.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5b532420fac4c1e3025c6ff62c63f5fdff77242a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/readme.txt b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/readme.txt
new file mode 100644
index 00000000..ebe2b166
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/readme.txt
@@ -0,0 +1,6 @@
+
+dump_display_over_serial.py
+ Convert display data on a serial line to a .XPM file
+
+bitmap.py
+ Convert an indexed 2 color bitmap to an uint8_t array
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/readme.txt.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/readme.txt.REMOVED.git-id
deleted file mode 100644
index dba66857..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gfx_mono/tools/readme.txt.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ebe2b166ab92575d0c3553501b18d3a6d4d53d3d
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/gpio.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/gpio.h
new file mode 100644
index 00000000..2b261aad
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/gpio.h
@@ -0,0 +1,86 @@
+/**
+ * \file
+ *
+ * \brief Common GPIO API.
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _GPIO_H_
+#define _GPIO_H_
+
+#include
+
+#if (SAM3S || SAM3U || SAM3N || SAM3XA || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM)
+# include "sam_gpio/sam_gpio.h"
+#elif XMEGA
+# include "xmega_gpio/xmega_gpio.h"
+#elif MEGA || MEGA_RF
+# include "mega_gpio/mega_gpio.h"
+#else
+# error Unsupported chip type
+#endif
+
+/**
+ * \defgroup gpio_group General Purpose Input/Output
+ *
+ * This is the common API for GPIO. Additional features are available
+ * in the documentation of the specific modules.
+ *
+ * \section io_group_platform Platform Dependencies
+ *
+ * The following functions are available on all platforms, but there may
+ * be variations in the function signature (i.e. parameters) and
+ * behaviour. These functions are typically called by platform-specific
+ * parts of drivers, and applications that aren't intended to be
+ * portable:
+ * - gpio_pin_is_low()
+ * - gpio_pin_is_high()
+ * - gpio_set_pin_high()
+ * - gpio_set_pin_group_high()
+ * - gpio_set_pin_low()
+ * - gpio_set_pin_group_low()
+ * - gpio_toggle_pin()
+ * - gpio_toggle_pin_group()
+ * - gpio_configure_pin()
+ * - gpio_configure_group()
+ */
+
+#endif /* _GPIO_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/gpio.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/gpio.h.REMOVED.git-id
deleted file mode 100644
index 5c96ae1c..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/gpio.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2b261aad859f43d5fe29001de27bf81a36fa96b1
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/xmega_gpio/xmega_gpio.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/xmega_gpio/xmega_gpio.h
new file mode 100644
index 00000000..110d9c36
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/xmega_gpio/xmega_gpio.h
@@ -0,0 +1,83 @@
+/**
+ * \file
+ *
+ * \brief Common gpio data/structure for all AVR XMEGA implementations.
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _XMEGA_GPIO_H_
+#define _XMEGA_GPIO_H_
+
+#include "compiler.h"
+#include "ioport.h"
+
+#define gpio_pin_is_low(io_id) \
+ ioport_pin_is_low(io_id)
+
+#define gpio_pin_is_high(io_id) \
+ ioport_pin_is_high(io_id)
+
+#define gpio_set_pin_high(io_id) \
+ ioport_set_value(io_id,1)
+
+#define gpio_set_pin_low(io_id) \
+ ioport_set_value(io_id,0)
+
+#define gpio_toggle_pin(io_id) \
+ ioport_toggle_pin(io_id)
+
+#define gpio_configure_pin(io_id,io_flags) \
+ ioport_configure_pin(io_id,io_flags)
+
+#define gpio_configure_group(port_id,port_mask,io_flags) \
+ ioport_configure_group(port_id,port_mask,io_flags)
+
+#define gpio_set_pin_group_high(port_id,mask) \
+ ioport_set_group_high(port_id,mask)
+
+#define gpio_set_pin_group_low(port_id,mask) \
+ ioport_set_group_low(port_id,mask)
+
+#define gpio_toggle_pin_group(port_id,mask) \
+ ioport_tgl_group(port_id,mask)
+
+#endif // _XMEGA_GPIO_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/xmega_gpio/xmega_gpio.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/xmega_gpio/xmega_gpio.h.REMOVED.git-id
deleted file mode 100644
index a1cdb815..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/gpio/xmega_gpio/xmega_gpio.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-110d9c362b77b4099a14a9ef7193f91a315c3420
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/ioport.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/ioport.h
new file mode 100644
index 00000000..a0320956
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/ioport.h
@@ -0,0 +1,541 @@
+/**
+ * \file
+ *
+ * \brief Common IOPORT service main header file for AVR, UC3 and ARM
+ * architectures.
+ *
+ * Copyright (c) 2012-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef IOPORT_H
+#define IOPORT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include
+#include
+
+/**
+ * \defgroup ioport_group Common IOPORT API
+ *
+ * See \ref ioport_quickstart.
+ *
+ * This is common IOPORT service for GPIO pin configuration and control in a
+ * standardized manner across the MEGA, MEGA_RF, XMEGA, UC3 and ARM devices.
+ *
+ * Port pin control code is optimized for each platform, and should produce
+ * both compact and fast execution times when used with constant values.
+ *
+ * \section dependencies Dependencies
+ * This driver depends on the following modules:
+ * - \ref sysclk_group for clock speed and functions.
+ * @{
+ */
+
+/**
+ * \def IOPORT_CREATE_PIN(port, pin)
+ * \brief Create IOPORT pin number
+ *
+ * Create a IOPORT pin number for use with the IOPORT functions.
+ *
+ * \param port IOPORT port (e.g. PORTA, PA or PIOA depending on chosen
+ * architecture)
+ * \param pin IOPORT zero-based index of the I/O pin
+ */
+
+/** \brief IOPORT pin directions */
+enum ioport_direction {
+ IOPORT_DIR_INPUT, /*!< IOPORT input direction */
+ IOPORT_DIR_OUTPUT, /*!< IOPORT output direction */
+};
+
+/** \brief IOPORT levels */
+enum ioport_value {
+ IOPORT_PIN_LEVEL_LOW, /*!< IOPORT pin value low */
+ IOPORT_PIN_LEVEL_HIGH, /*!< IOPORT pin value high */
+};
+
+#if MEGA_RF
+/** \brief IOPORT edge sense modes */
+enum ioport_sense {
+ IOPORT_SENSE_LEVEL, /*!< IOPORT sense low level */
+ IOPORT_SENSE_BOTHEDGES, /*!< IOPORT sense both rising and falling edges */
+ IOPORT_SENSE_FALLING, /*!< IOPORT sense falling edges */
+ IOPORT_SENSE_RISING, /*!< IOPORT sense rising edges */
+};
+#elif SAM && !SAM4L
+/** \brief IOPORT edge sense modes */
+enum ioport_sense {
+ IOPORT_SENSE_BOTHEDGES, /*!< IOPORT sense both rising and falling edges */
+ IOPORT_SENSE_FALLING, /*!< IOPORT sense falling edges */
+ IOPORT_SENSE_RISING, /*!< IOPORT sense rising edges */
+ IOPORT_SENSE_LEVEL_LOW, /*!< IOPORT sense low level */
+ IOPORT_SENSE_LEVEL_HIGH,/*!< IOPORT sense High level */
+};
+#else
+enum ioport_sense {
+ IOPORT_SENSE_BOTHEDGES, /*!< IOPORT sense both rising and falling edges */
+ IOPORT_SENSE_RISING, /*!< IOPORT sense rising edges */
+ IOPORT_SENSE_FALLING, /*!< IOPORT sense falling edges */
+};
+#endif
+
+
+#if XMEGA
+# include "xmega/ioport.h"
+# if defined(IOPORT_XMEGA_COMPAT)
+# include "xmega/ioport_compat.h"
+# endif
+#elif MEGA
+# include "mega/ioport.h"
+#elif UC3
+# include "uc3/ioport.h"
+#elif SAM
+# if SAM4L
+# include "sam/ioport_gpio.h"
+# elif (SAMD20 | SAMD21)
+# include "sam0/ioport.h"
+# else
+# include "sam/ioport_pio.h"
+# endif
+#endif
+
+/**
+ * \brief Initializes the IOPORT service, ready for use.
+ *
+ * This function must be called before using any other functions in the IOPORT
+ * service.
+ */
+static inline void ioport_init(void)
+{
+ arch_ioport_init();
+}
+
+/**
+ * \brief Enable an IOPORT pin, based on a pin created with \ref
+ * IOPORT_CREATE_PIN().
+ *
+ * \param pin IOPORT pin to enable
+ */
+static inline void ioport_enable_pin(ioport_pin_t pin)
+{
+ arch_ioport_enable_pin(pin);
+}
+
+/**
+ * \brief Enable multiple pins in a single IOPORT port.
+ *
+ * \param port IOPORT port to enable
+ * \param mask Mask of pins within the port to enable
+ */
+static inline void ioport_enable_port(ioport_port_t port,
+ ioport_port_mask_t mask)
+{
+ arch_ioport_enable_port(port, mask);
+}
+
+/**
+ * \brief Disable IOPORT pin, based on a pin created with \ref
+ * IOPORT_CREATE_PIN().
+ *
+ * \param pin IOPORT pin to disable
+ */
+static inline void ioport_disable_pin(ioport_pin_t pin)
+{
+ arch_ioport_disable_pin(pin);
+}
+
+/**
+ * \brief Disable multiple pins in a single IOPORT port.
+ *
+ * \param port IOPORT port to disable
+ * \param mask Pin mask of pins to disable
+ */
+static inline void ioport_disable_port(ioport_port_t port,
+ ioport_port_mask_t mask)
+{
+ arch_ioport_disable_port(port, mask);
+}
+
+/**
+ * \brief Set multiple pin modes in a single IOPORT port, such as pull-up,
+ * pull-down, etc. configuration.
+ *
+ * \param port IOPORT port to configure
+ * \param mask Pin mask of pins to configure
+ * \param mode Mode masks to configure for the specified pins (\ref
+ * ioport_modes)
+ */
+static inline void ioport_set_port_mode(ioport_port_t port,
+ ioport_port_mask_t mask, ioport_mode_t mode)
+{
+ arch_ioport_set_port_mode(port, mask, mode);
+}
+
+/**
+ * \brief Set pin mode for one single IOPORT pin.
+ *
+ * \param pin IOPORT pin to configure
+ * \param mode Mode masks to configure for the specified pin (\ref ioport_modes)
+ */
+static inline void ioport_set_pin_mode(ioport_pin_t pin, ioport_mode_t mode)
+{
+ arch_ioport_set_pin_mode(pin, mode);
+}
+
+/**
+ * \brief Reset multiple pin modes in a specified IOPORT port to defaults.
+ *
+ * \param port IOPORT port to configure
+ * \param mask Mask of pins whose mode configuration is to be reset
+ */
+static inline void ioport_reset_port_mode(ioport_port_t port,
+ ioport_port_mask_t mask)
+{
+ arch_ioport_set_port_mode(port, mask, 0);
+}
+
+/**
+ * \brief Reset pin mode configuration for a single IOPORT pin
+ *
+ * \param pin IOPORT pin to configure
+ */
+static inline void ioport_reset_pin_mode(ioport_pin_t pin)
+{
+ arch_ioport_set_pin_mode(pin, 0);
+}
+
+/**
+ * \brief Set I/O direction for a group of pins in a single IOPORT.
+ *
+ * \param port IOPORT port to configure
+ * \param mask Pin mask of pins to configure
+ * \param dir Direction to set for the specified pins (\ref ioport_direction)
+ */
+static inline void ioport_set_port_dir(ioport_port_t port,
+ ioport_port_mask_t mask, enum ioport_direction dir)
+{
+ arch_ioport_set_port_dir(port, mask, dir);
+}
+
+/**
+ * \brief Set direction for a single IOPORT pin.
+ *
+ * \param pin IOPORT pin to configure
+ * \param dir Direction to set for the specified pin (\ref ioport_direction)
+ */
+static inline void ioport_set_pin_dir(ioport_pin_t pin,
+ enum ioport_direction dir)
+{
+ arch_ioport_set_pin_dir(pin, dir);
+}
+
+/**
+ * \brief Set an IOPORT pin to a specified logical value.
+ *
+ * \param pin IOPORT pin to configure
+ * \param level Logical value of the pin
+ */
+static inline void ioport_set_pin_level(ioport_pin_t pin, bool level)
+{
+ arch_ioport_set_pin_level(pin, level);
+}
+
+/**
+ * \brief Set a group of IOPORT pins in a single port to a specified logical
+ * value.
+ *
+ * \param port IOPORT port to write to
+ * \param mask Pin mask of pins to modify
+ * \param level Level of the pins to be modified
+ */
+static inline void ioport_set_port_level(ioport_port_t port,
+ ioport_port_mask_t mask, ioport_port_mask_t level)
+{
+ arch_ioport_set_port_level(port, mask, level);
+}
+
+/**
+ * \brief Get current value of an IOPORT pin, which has been configured as an
+ * input.
+ *
+ * \param pin IOPORT pin to read
+ * \return Current logical value of the specified pin
+ */
+static inline bool ioport_get_pin_level(ioport_pin_t pin)
+{
+ return arch_ioport_get_pin_level(pin);
+}
+
+/**
+ * \brief Get current value of several IOPORT pins in a single port, which have
+ * been configured as an inputs.
+ *
+ * \param port IOPORT port to read
+ * \param mask Pin mask of pins to read
+ * \return Logical levels of the specified pins from the read port, returned as
+ * a mask.
+ */
+static inline ioport_port_mask_t ioport_get_port_level(ioport_pin_t port,
+ ioport_port_mask_t mask)
+{
+ return arch_ioport_get_port_level(port, mask);
+}
+
+/**
+ * \brief Toggle the value of an IOPORT pin, which has previously configured as
+ * an output.
+ *
+ * \param pin IOPORT pin to toggle
+ */
+static inline void ioport_toggle_pin_level(ioport_pin_t pin)
+{
+ arch_ioport_toggle_pin_level(pin);
+}
+
+/**
+ * \brief Toggle the values of several IOPORT pins located in a single port.
+ *
+ * \param port IOPORT port to modify
+ * \param mask Pin mask of pins to toggle
+ */
+static inline void ioport_toggle_port_level(ioport_port_t port,
+ ioport_port_mask_t mask)
+{
+ arch_ioport_toggle_port_level(port, mask);
+}
+
+/**
+ * \brief Set the pin sense mode of a single IOPORT pin.
+ *
+ * \param pin IOPORT pin to configure
+ * \param pin_sense Edge to sense for the pin (\ref ioport_sense)
+ */
+static inline void ioport_set_pin_sense_mode(ioport_pin_t pin,
+ enum ioport_sense pin_sense)
+{
+ arch_ioport_set_pin_sense_mode(pin, pin_sense);
+}
+
+/**
+ * \brief Set the pin sense mode of a multiple IOPORT pins on a single port.
+ *
+ * \param port IOPORT port to configure
+ * \param mask Bitmask if pins whose edge sense is to be configured
+ * \param pin_sense Edge to sense for the pins (\ref ioport_sense)
+ */
+static inline void ioport_set_port_sense_mode(ioport_port_t port,
+ ioport_port_mask_t mask,
+ enum ioport_sense pin_sense)
+{
+ arch_ioport_set_port_sense_mode(port, mask, pin_sense);
+}
+
+/**
+ * \brief Convert a pin ID into a its port ID.
+ *
+ * \param pin IOPORT pin ID to convert
+ * \retval Port ID for the given pin ID
+ */
+static inline ioport_port_t ioport_pin_to_port_id(ioport_pin_t pin)
+{
+ return arch_ioport_pin_to_port_id(pin);
+}
+
+/**
+ * \brief Convert a pin ID into a bitmask mask for the given pin on its port.
+ *
+ * \param pin IOPORT pin ID to convert
+ * \retval Bitmask with a bit set that corresponds to the given pin ID in its port
+ */
+static inline ioport_port_mask_t ioport_pin_to_mask(ioport_pin_t pin)
+{
+ return arch_ioport_pin_to_mask(pin);
+}
+
+/** @} */
+
+/**
+ * \page ioport_quickstart Quick start guide for the common IOPORT service
+ *
+ * This is the quick start guide for the \ref ioport_group, with
+ * step-by-step instructions on how to configure and use the service in a
+ * selection of use cases.
+ *
+ * The use cases contain several code fragments. The code fragments in the
+ * steps for setup can be copied into a custom initialization function, while
+ * the steps for usage can be copied into, e.g., the main application function.
+ *
+ * \section ioport_quickstart_basic Basic use case
+ * In this use case we will configure one IO pin for button input and one for
+ * LED control. Then it will read the button state and output it on the LED.
+ *
+ * \section ioport_quickstart_basic_setup Setup steps
+ *
+ * \subsection ioport_quickstart_basic_setup_code Example code
+ * \code
+ #define MY_LED IOPORT_CREATE_PIN(PORTA, 5)
+ #define MY_BUTTON IOPORT_CREATE_PIN(PORTA, 6)
+
+ ioport_init();
+
+ ioport_set_pin_dir(MY_LED, IOPORT_DIR_OUTPUT);
+ ioport_set_pin_dir(MY_BUTTON, IOPORT_DIR_INPUT);
+ ioport_set_pin_mode(MY_BUTTON, IOPORT_MODE_PULLUP);
+\endcode
+ *
+ * \subsection ioport_quickstart_basic_setup_flow Workflow
+ * -# It's useful to give the GPIOs symbolic names and this can be done with
+ * the \ref IOPORT_CREATE_PIN macro. We define one for a LED and one for a
+ * button.
+ * - \code
+ #define MY_LED IOPORT_CREATE_PIN(PORTA, 5)
+ #define MY_BUTTON IOPORT_CREATE_PIN(PORTA, 6)
+\endcode
+ * - \note The usefulness of the \ref IOPORT_CREATE_PIN macro and port names
+ * differ between architectures:
+ * - MEGA, MEGA_RF and XMEGA: Use \ref IOPORT_CREATE_PIN macro with port definitions
+ * PORTA, PORTB ...
+ * - UC3: Most convenient to pick up the device header file pin definition
+ * and us it directly. E.g.: AVR32_PIN_PB06
+ * - SAM: Most convenient to pick up the device header file pin definition
+ * and us it directly. E.g.: PIO_PA5_IDX
+ * \ref IOPORT_CREATE_PIN can also be used with port definitions
+ * PIOA, PIOB ...
+ * -# Initialize the ioport service. This typically enables the IO module if
+ * needed.
+ * - \code ioport_init(); \endcode
+ * -# Set the LED GPIO as output:
+ * - \code ioport_set_pin_dir(MY_LED, IOPORT_DIR_OUTPUT); \endcode
+ * -# Set the button GPIO as input:
+ * - \code ioport_set_pin_dir(MY_BUTTON, IOPORT_DIR_INPUT); \endcode
+ * -# Enable pull-up for the button GPIO:
+ * - \code ioport_set_pin_mode(MY_BUTTON, IOPORT_MODE_PULLUP); \endcode
+ *
+ * \section ioport_quickstart_basic_usage Usage steps
+ *
+ * \subsection ioport_quickstart_basic_usage_code Example code
+ * \code
+ bool value;
+
+ value = ioport_get_pin_level(MY_BUTTON);
+ ioport_set_pin_level(MY_LED, value);
+\endcode
+ *
+ * \subsection ioport_quickstart_basic_usage_flow Workflow
+ * -# Define a boolean variable for state storage:
+ * - \code bool value; \endcode
+ * -# Read out the button level into variable value:
+ * - \code value = ioport_get_pin_level(MY_BUTTON); \endcode
+ * -# Set the LED to read out value from the button:
+ * - \code ioport_set_pin_level(MY_LED, value); \endcode
+ *
+ * \section ioport_quickstart_advanced Advanced use cases
+ * - \subpage ioport_quickstart_use_case_1 : Port access
+ */
+
+/**
+ * \page ioport_quickstart_use_case_1 Advanced use case doing port access
+ *
+ * In this case we will read out the pins from one whole port and write the
+ * read value to another port.
+ *
+ * \section ioport_quickstart_use_case_1_setup Setup steps
+ *
+ * \subsection ioport_quickstart_use_case_1_setup_code Example code
+ * \code
+ #define IN_PORT IOPORT_PORTA
+ #define OUT_PORT IOPORT_PORTB
+ #define MASK 0x00000060
+
+ ioport_init();
+
+ ioport_set_port_dir(IN_PORT, MASK, IOPORT_DIR_INPUT);
+ ioport_set_port_dir(OUT_PORT, MASK, IOPORT_DIR_OUTPUT);
+\endcode
+ *
+ * \subsection ioport_quickstart_basic_setup_flow Workflow
+ * -# It's useful to give the ports symbolic names:
+ * - \code
+ #define IN_PORT IOPORT_PORTA
+ #define OUT_PORT IOPORT_PORTB
+\endcode
+ * - \note The port names differ between architectures:
+ * - MEGA_RF, MEGA and XMEGA: There are predefined names for ports: IOPORT_PORTA,
+ * IOPORT_PORTB ...
+ * - UC3: Use the index value of the different IO blocks: 0, 1 ...
+ * - SAM: There are predefined names for ports: IOPORT_PIOA, IOPORT_PIOB
+ * ...
+ * -# Also useful to define a mask for the bits to work with:
+ * - \code #define MASK 0x00000060 \endcode
+ * -# Initialize the ioport service. This typically enables the IO module if
+ * needed.
+ * - \code ioport_init(); \endcode
+ * -# Set one of the ports as input:
+ * - \code ioport_set_pin_dir(IN_PORT, MASK, IOPORT_DIR_INPUT); \endcode
+ * -# Set the other port as output:
+ * - \code ioport_set_pin_dir(OUT_PORT, MASK, IOPORT_DIR_OUTPUT); \endcode
+ *
+ * \section ioport_quickstart_basic_usage Usage steps
+ *
+ * \subsection ioport_quickstart_basic_usage_code Example code
+ * \code
+ ioport_port_mask_t value;
+
+ value = ioport_get_port_level(IN_PORT, MASK);
+ ioport_set_port_level(OUT_PORT, MASK, value);
+\endcode
+ *
+ * \subsection ioport_quickstart_basic_usage_flow Workflow
+ * -# Define a variable for port date storage:
+ * - \code ioport_port_mask_t value; \endcode
+ * -# Read out from one port:
+ * - \code value = ioport_get_port_level(IN_PORT, MASK); \endcode
+ * -# Put the read data out on the other port:
+ * - \code ioport_set_port_level(OUT_PORT, MASK, value); \endcode
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IOPORT_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/ioport.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/ioport.h.REMOVED.git-id
deleted file mode 100644
index 9976be3c..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/ioport.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a03209562a3bd7abd18ef9c237dbb7c4b9d98a89
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport.h
new file mode 100644
index 00000000..00b66e8b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport.h
@@ -0,0 +1,364 @@
+/**
+ * \file
+ *
+ * \brief XMEGA architecture specific IOPORT service implementation header file.
+ *
+ * Copyright (c) 2012-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef IOPORT_XMEGA_H
+#define IOPORT_XMEGA_H
+
+#define IOPORT_CREATE_PIN(port, pin) ((IOPORT_ ## port) * 8 + (pin))
+#define IOPORT_BASE_ADDRESS 0x600
+#define IOPORT_PORT_OFFSET 0x20
+
+/** \name IOPORT port numbers */
+/** @{ */
+#if !XMEGA_B3
+# define IOPORT_PORTA 0
+#endif
+
+#define IOPORT_PORTB 1
+#define IOPORT_PORTC 2
+#define IOPORT_PORTD 3
+
+#if !XMEGA_B3
+# define IOPORT_PORTE 4
+#endif
+
+#if XMEGA_A1 || XMEGA_A1U || XMEGA_A3 || XMEGA_A3U || XMEGA_A3B || XMEGA_A3BU || \
+ XMEGA_C3 || XMEGA_D3
+# define IOPORT_PORTF 5
+#endif
+
+#if XMEGA_B1 || XMEGA_B3
+# define IOPORT_PORTG 6
+#endif
+
+#if XMEGA_A1 || XMEGA_A1U
+# define IOPORT_PORTH 7
+# define IOPORT_PORTJ 8
+# define IOPORT_PORTK 9
+#endif
+
+#if XMEGA_B1 || XMEGA_B3
+# define IOPORT_PORTM 11
+#endif
+
+#if XMEGA_A1 || XMEGA_A1U
+# define IOPORT_PORTQ 14
+#endif
+
+#define IOPORT_PORTR 15
+/** @} */
+
+/**
+ * \weakgroup ioport_group
+ * \section ioport_modes IOPORT Modes
+ *
+ * For details on these please see the XMEGA Manual.
+ *
+ * @{
+ */
+
+/** \name IOPORT Mode bit definitions */
+/** @{ */
+#define IOPORT_MODE_TOTEM (0x00 << 3) /*!< Totem-pole */
+#define IOPORT_MODE_BUSKEEPER (0x01 << 3) /*!< Buskeeper */
+#define IOPORT_MODE_PULLDOWN (0x02 << 3) /*!< Pull-down */
+#define IOPORT_MODE_PULLUP (0x03 << 3) /*!< Pull-up */
+#define IOPORT_MODE_WIREDOR (0x04 << 3) /*!< Wired OR */
+#define IOPORT_MODE_WIREDAND (0x05 << 3) /*!< Wired AND */
+#define IOPORT_MODE_WIREDORPULL (0x06 << 3) /*!< Wired OR with pull-down */
+#define IOPORT_MODE_WIREDANDPULL (0x07 << 3) /*!< Wired AND with pull-up */
+#define IOPORT_MODE_INVERT_PIN (0x01 << 6) /*!< Invert output and input */
+#define IOPORT_MODE_SLEW_RATE_LIMIT (0x01 << 7) /*!< Slew rate limiting */
+/** @} */
+
+/** @} */
+
+typedef uint8_t ioport_mode_t;
+typedef uint8_t ioport_pin_t;
+typedef uint8_t ioport_port_t;
+typedef uint8_t ioport_port_mask_t;
+
+__always_inline static ioport_port_t arch_ioport_pin_to_port_id(ioport_pin_t pin)
+{
+ return pin >> 3;
+}
+
+__always_inline static PORT_t *arch_ioport_port_to_base(ioport_port_t port)
+{
+ return (PORT_t *)((uintptr_t)IOPORT_BASE_ADDRESS +
+ (port * IOPORT_PORT_OFFSET));
+}
+
+__always_inline static PORT_t *arch_ioport_pin_to_base(ioport_pin_t pin)
+{
+ return arch_ioport_port_to_base(arch_ioport_pin_to_port_id(pin));
+}
+
+__always_inline static ioport_port_mask_t arch_ioport_pin_to_mask(
+ ioport_pin_t pin)
+{
+ return 1U << (pin & 0x07);
+}
+
+__always_inline static ioport_port_mask_t arch_ioport_pin_to_index(
+ ioport_pin_t pin)
+{
+ return (pin & 0x07);
+}
+
+__always_inline static void arch_ioport_init(void)
+{
+}
+
+__always_inline static void arch_ioport_enable_port(ioport_port_t port,
+ ioport_port_mask_t mask)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+ volatile uint8_t *pin_ctrl = &base->PIN0CTRL;
+
+ uint8_t flags = cpu_irq_save();
+
+ for (uint8_t i = 0; i < 8; i++) {
+ if (mask & arch_ioport_pin_to_mask(i)) {
+ pin_ctrl[i] &= ~PORT_ISC_gm;
+ }
+ }
+
+ cpu_irq_restore(flags);
+}
+
+__always_inline static void arch_ioport_enable_pin(ioport_pin_t pin)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+ volatile uint8_t *pin_ctrl
+ = (&base->PIN0CTRL + arch_ioport_pin_to_index(pin));
+
+ uint8_t flags = cpu_irq_save();
+
+ *pin_ctrl &= ~PORT_ISC_gm;
+
+ cpu_irq_restore(flags);
+}
+
+__always_inline static void arch_ioport_disable_port(ioport_port_t port,
+ ioport_port_mask_t mask)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+ volatile uint8_t *pin_ctrl = &base->PIN0CTRL;
+
+ uint8_t flags = cpu_irq_save();
+
+ for (uint8_t i = 0; i < 8; i++) {
+ if (mask & arch_ioport_pin_to_mask(i)) {
+ pin_ctrl[i] |= PORT_ISC_INPUT_DISABLE_gc;
+ }
+ }
+
+ cpu_irq_restore(flags);
+}
+
+__always_inline static void arch_ioport_disable_pin(ioport_pin_t pin)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+ volatile uint8_t *pin_ctrl
+ = (&base->PIN0CTRL + arch_ioport_pin_to_index(pin));
+
+ uint8_t flags = cpu_irq_save();
+
+ *pin_ctrl |= PORT_ISC_INPUT_DISABLE_gc;
+
+ cpu_irq_restore(flags);
+}
+
+__always_inline static void arch_ioport_set_port_mode(ioport_port_t port,
+ ioport_port_mask_t mask, ioport_mode_t mode)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+ volatile uint8_t *pin_ctrl = &base->PIN0CTRL;
+ uint8_t new_mode_bits = (mode & ~PORT_ISC_gm);
+
+ uint8_t flags = cpu_irq_save();
+
+ for (uint8_t i = 0; i < 8; i++) {
+ if (mask & arch_ioport_pin_to_mask(i)) {
+ pin_ctrl[i]
+ = (pin_ctrl[i] &
+ PORT_ISC_gm) | new_mode_bits;
+ }
+ }
+
+ cpu_irq_restore(flags);
+}
+
+__always_inline static void arch_ioport_set_pin_mode(ioport_pin_t pin,
+ ioport_mode_t mode)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+ volatile uint8_t *pin_ctrl
+ = (&base->PIN0CTRL + arch_ioport_pin_to_index(pin));
+
+ uint8_t flags = cpu_irq_save();
+
+ *pin_ctrl &= PORT_ISC_gm;
+ *pin_ctrl |= mode;
+
+ cpu_irq_restore(flags);
+}
+
+__always_inline static void arch_ioport_set_port_dir(ioport_port_t port,
+ ioport_port_mask_t mask, enum ioport_direction dir)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+
+ if (dir == IOPORT_DIR_OUTPUT) {
+ base->DIRSET = mask;
+ } else if (dir == IOPORT_DIR_INPUT) {
+ base->DIRCLR = mask;
+ }
+}
+
+__always_inline static void arch_ioport_set_pin_dir(ioport_pin_t pin,
+ enum ioport_direction dir)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+
+ if (dir == IOPORT_DIR_OUTPUT) {
+ base->DIRSET = arch_ioport_pin_to_mask(pin);
+ } else if (dir == IOPORT_DIR_INPUT) {
+ base->DIRCLR = arch_ioport_pin_to_mask(pin);
+ }
+}
+
+__always_inline static void arch_ioport_set_pin_level(ioport_pin_t pin,
+ bool level)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+
+ if (level) {
+ base->OUTSET = arch_ioport_pin_to_mask(pin);
+ } else {
+ base->OUTCLR = arch_ioport_pin_to_mask(pin);
+ }
+}
+
+__always_inline static void arch_ioport_set_port_level(ioport_port_t port,
+ ioport_port_mask_t mask, ioport_port_mask_t level)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+ if (level) {
+ base->OUTSET |= mask;
+ base->OUTCLR &= ~mask;
+ } else {
+ base->OUTSET &= ~mask;
+ base->OUTCLR |= mask;
+ }
+}
+
+__always_inline static bool arch_ioport_get_pin_level(ioport_pin_t pin)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+
+ return base->IN & arch_ioport_pin_to_mask(pin);
+}
+
+__always_inline static ioport_port_mask_t arch_ioport_get_port_level(
+ ioport_port_t port, ioport_port_mask_t mask)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+
+ return base->IN & mask;
+}
+
+__always_inline static void arch_ioport_toggle_pin_level(ioport_pin_t pin)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+
+ base->OUTTGL = arch_ioport_pin_to_mask(pin);
+}
+
+__always_inline static void arch_ioport_toggle_port_level(ioport_port_t port,
+ ioport_port_mask_t mask)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+
+ base->OUTTGL = mask;
+}
+
+__always_inline static void arch_ioport_set_pin_sense_mode(ioport_pin_t pin,
+ enum ioport_sense pin_sense)
+{
+ PORT_t *base = arch_ioport_pin_to_base(pin);
+ volatile uint8_t *pin_ctrl
+ = (&base->PIN0CTRL + arch_ioport_pin_to_index(pin));
+
+ uint8_t flags = cpu_irq_save();
+
+ *pin_ctrl &= ~PORT_ISC_gm;
+ *pin_ctrl |= (pin_sense & PORT_ISC_gm);
+
+ cpu_irq_restore(flags);
+}
+
+__always_inline static void arch_ioport_set_port_sense_mode(ioport_port_t port,
+ ioport_port_mask_t mask, enum ioport_sense pin_sense)
+{
+ PORT_t *base = arch_ioport_port_to_base(port);
+ volatile uint8_t *pin_ctrl = &base->PIN0CTRL;
+ uint8_t new_sense_bits = (pin_sense & PORT_ISC_gm);
+
+ uint8_t flags = cpu_irq_save();
+
+ for (uint8_t i = 0; i < 8; i++) {
+ if (mask & arch_ioport_pin_to_mask(i)) {
+ pin_ctrl[i]
+ = (pin_ctrl[i] &
+ ~PORT_ISC_gm) | new_sense_bits;
+ }
+ }
+
+ cpu_irq_restore(flags);
+}
+
+#endif /* IOPORT_XMEGA_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport.h.REMOVED.git-id
deleted file mode 100644
index d21d4146..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-00b66e8b6733eb6d8f883d766a9382050dda722a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.c
new file mode 100644
index 00000000..ce47189a
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.c
@@ -0,0 +1,73 @@
+/**
+ * \file
+ *
+ * \brief XMEGA legacy IOPORT software compatibility driver interface.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include "ioport_compat.h"
+
+#if defined(IOPORT_XMEGA_COMPAT)
+void ioport_configure_port_pin(void *port, pin_mask_t pin_mask,
+ port_pin_flags_t flags)
+{
+ uint8_t pin;
+
+ for (pin = 0; pin < 8; pin++) {
+ if (pin_mask & (1 << pin)) {
+ *((uint8_t *)port + PORT_PIN0CTRL + pin) = flags >> 8;
+ }
+ }
+ /* Select direction and initial pin state */
+ if (flags & IOPORT_DIR_OUTPUT) {
+ if (flags & IOPORT_INIT_HIGH) {
+ *((uint8_t *)port + PORT_OUTSET) = pin_mask;
+ } else {
+ *((uint8_t *)port + PORT_OUTCLR) = pin_mask;
+ }
+
+ *((uint8_t *)port + PORT_DIRSET) = pin_mask;
+ } else {
+ *((uint8_t *)port + PORT_DIRCLR) = pin_mask;
+ }
+}
+
+#endif
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.c.REMOVED.git-id
deleted file mode 100644
index 780fcccd..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ce47189a899d1ceabb8e881e162c6b822627191c
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.h
new file mode 100644
index 00000000..aaba63f4
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.h
@@ -0,0 +1,321 @@
+/**
+ * \file
+ *
+ * \brief XMEGA legacy IOPORT software compatibility driver interface header
+ * file.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef IOPORT_XMEGA_COMPAT_H_
+#define IOPORT_XMEGA_COMPAT_H_
+
+#include "../ioport.h"
+
+/**
+ * \brief A pin mask
+ *
+ * This type is used to describe the port pin mask on the part.
+ */
+typedef uint8_t pin_mask_t;
+
+/**
+ * \brief A PORT pin
+ *
+ * This type is used to describe the PORT pins on the part.
+ */
+typedef uint8_t port_pin_t;
+
+/**
+ * \brief Pin configuration flags
+ *
+ * This is a bitmask containing configuration flags for the pins that shall be
+ * configured.
+ */
+typedef uint16_t port_pin_flags_t;
+
+/**
+ * \brief A port id
+ *
+ * This type is used to describe the port id on the part (0 is PORTA).
+ */
+typedef uint8_t port_id_t;
+
+/** \name Initial Output State Flags */
+/** @{ */
+#define IOPORT_INIT_LOW (0 << 1) /*!< Initial Output State Low */
+#define IOPORT_INIT_HIGH (1 << 1) /*!< Initial Output State High */
+/** @} */
+
+/** \name Input/Sense Configuration Flags */
+/** @{ */
+#define IOPORT_BOTHEDGES (0 << 8) /*!< Sense Both Edges */
+#define IOPORT_RISING (1 << 8) /*!< Sense Rising Edge */
+#define IOPORT_FALLING (2 << 8) /*!< Sense Falling Edge */
+#define IOPORT_LEVEL (3 << 8) /*!< Sense Low Level */
+#if XMEGA_E
+# define IOPORT_FORCE_ENABLE (6 << 8) /*!< Sense Force Input Enable Low Level */
+#endif
+#define IOPORT_INPUT_DISABLE (7 << 8) /*!< Input Buffer Disabled */
+/** @} */
+
+/** \name Output and Pull Configuration Flags */
+/** @{ */
+#define IOPORT_TOTEM (0 << 11) /*!< Normal push/pull output */
+#define IOPORT_BUSKEEPER (1 << 11) /*!< Bus Keeper */
+#define IOPORT_PULL_DOWN (2 << 11) /*!< Pull-Down (when input) */
+#define IOPORT_PULL_UP (3 << 11) /*!< Pull-Up (when input) */
+#define IOPORT_WIRED_OR (4 << 11) /*!< Wired OR */
+#define IOPORT_WIRED_AND (5 << 11) /*!< Wired AND */
+#define IOPORT_WIRED_OR_PULL_DOWN (6 << 11) /*!< Wired OR and Pull-Down */
+#define IOPORT_WIRED_AND_PULL_UP (7 << 11) /*!< Wired AND and Pull-Up */
+/** @} */
+
+/** \name Inverted I/O Configuration Flags */
+/** @{ */
+#define IOPORT_INV_ENABLED (1 << 14) /*!< I/O is Inverted */
+#define IOPORT_INV_DISABLE (0 << 14) /*!< I/O is Not Inverted */
+/** @} */
+
+/** \name Slew Rate Limit Configuration Flags */
+/** @{ */
+#define IOPORT_SRL_ENABLED (1 << 15) /*!< Slew Rate Limit Enabled */
+#define IOPORT_SRL_DISABLED (0 << 15) /*!< Slew Rate Limit Disabled */
+/** @} */
+
+/**
+ * \internal
+ * \name PORT fields structure offset
+ *
+ * These macros are used to compute the field offset number with the PORT_t
+ * structure.
+ */
+/** @{ */
+#define PORT_DIR 0x00 /*!< Data Direction */
+#define PORT_DIRSET 0x01 /*!< Data Direction Set */
+#define PORT_DIRCLR 0x02 /*!< Data Direction Clear */
+#define PORT_DIRTGL 0x03 /*!< Data Direction Toggle */
+#define PORT_OUT 0x04 /*!< Data Output Value */
+#define PORT_OUTSET 0x05 /*!< Data Output Value Set */
+#define PORT_OUTCLR 0x06 /*!< Data Output Value Clear */
+#define PORT_OUTTGL 0x07 /*!< Data Output Value Toggle */
+#define PORT_IN 0x08 /*!< Data Input Value */
+#define PORT_INTCTRL 0x09 /*!< Interrupt Control */
+#define PORT_INT0MASK 0x0A /*!< Interrupt 0 Mask */
+#define PORT_INT1MASK 0x0B /*!< Interrupt 1 Mask */
+#define PORT_INTFLAGS 0x0C /*!< Interrupt Flags */
+#define PORT_PIN0CTRL 0x10 /*!< Pin 0 Configuration */
+#define PORT_PIN1CTRL 0x11 /*!< Pin 1 Configuration */
+#define PORT_PIN2CTRL 0x12 /*!< Pin 2 Configuration */
+#define PORT_PIN3CTRL 0x13 /*!< Pin 3 Configuration */
+#define PORT_PIN4CTRL 0x14 /*!< Pin 4 Configuration */
+#define PORT_PIN5CTRL 0x15 /*!< Pin 5 Configuration */
+#define PORT_PIN6CTRL 0x16 /*!< Pin 6 Configuration */
+#define PORT_PIN7CTRL 0x17 /*!< Pin 7 Configuration */
+/** @} */
+
+static inline PORT_t *ioport_pin_to_port(port_pin_t pin)
+{
+ return arch_ioport_pin_to_base(pin);
+}
+
+static inline PORT_t *ioport_id_pin_to_port(port_id_t port)
+{
+ return arch_ioport_port_to_base(port);
+}
+
+/**
+ * \brief Configure the IO PORT pin function for a set of pins on a port
+ *
+ * \param port Pointer to the port
+ * \param pin_mask Mask containing the pins that should be configured
+ * \param flags Bitmask of flags specifying additional configuration
+ * parameters.
+ */
+void ioport_configure_port_pin(void *port, pin_mask_t pin_mask,
+ port_pin_flags_t flags);
+
+/**
+ * \brief Select the port function for a single pin
+ *
+ * \param pin The pin to configure
+ * \param flags Bitmask of flags specifying additional configuration
+ * parameters.
+ */
+static inline void ioport_configure_pin(port_pin_t pin, port_pin_flags_t flags)
+{
+ ioport_configure_port_pin(arch_ioport_pin_to_base(pin),
+ arch_ioport_pin_to_mask(pin), flags);
+}
+
+/**
+ * \brief Configure a group of I/O pins on a specified port number
+ *
+ * \param port The port number
+ * \param pin_mask The pin mask to configure
+ * \param flags Bitmask of flags specifying additional configuration
+ * parameters.
+ */
+static inline void ioport_configure_group(port_id_t port, pin_mask_t pin_mask,
+ port_pin_flags_t flags)
+{
+ ioport_configure_port_pin(arch_ioport_port_to_base(port), pin_mask, flags);
+}
+
+/**
+ * \brief Drive a PORT pin to a given state
+ *
+ * This function will only have an effect if \a pin is configured as
+ * an output.
+ *
+ * \param pin A number identifying the pin to act on.
+ * \param value The desired state of the pin. \a true means drive the
+ * pin high (towards Vdd), while \a false means drive the pin low
+ * (towards Vss).
+ */
+static inline void ioport_set_value(port_pin_t pin, bool value)
+{
+ arch_ioport_set_pin_level(pin, value);
+}
+
+/**
+ * \brief Drive a PORT pin to a low level
+ *
+ * This function will only have an effect if \a pin is configured as
+ * an output.
+ *
+ * \param pin A number identifying the pin to act on.
+ */
+static inline void ioport_set_pin_low(port_pin_t pin)
+{
+ arch_ioport_set_pin_level(pin, false);
+}
+
+/**
+ * \brief Drive a PORT pin to a high level
+ *
+ * This function will only have an effect if \a pin is configured as
+ * an output.
+ *
+ * \param pin A number identifying the pin to act on.
+ */
+static inline void ioport_set_pin_high(port_pin_t pin)
+{
+ arch_ioport_set_pin_level(pin, true);
+}
+
+/**
+ * \brief Read the current state of a PORT pin
+ *
+ * \param pin A number identifying the pin to read.
+ * \retval true The pin is currently high (close to Vdd)
+ * \retval false The pin is currently low (close to Vss)
+ */
+static inline bool ioport_get_value(port_pin_t pin)
+{
+ return arch_ioport_get_pin_level(pin);
+}
+
+/**
+ * \brief Read the current state of a PORT pin and test high level
+ *
+ * \param pin A number identifying the pin to read.
+ * \retval true The pin is currently high (close to Vdd)
+ * \retval false The pin is currently low (close to Vss)
+ */
+static inline bool ioport_pin_is_high(port_pin_t pin)
+{
+ return (arch_ioport_get_pin_level(pin) == true);
+}
+
+/**
+ * \brief Read the current state of a PORT pin and test high level
+ *
+ * \param pin A number identifying the pin to read.
+ * \retval true The pin is currently high (close to Vdd)
+ * \retval false The pin is currently low (close to Vss)
+ */
+static inline bool ioport_pin_is_low(port_pin_t pin)
+{
+ return (arch_ioport_get_pin_level(pin) == false);
+}
+
+/**
+ * \brief Toggle the current state of a PORT pin
+ *
+ * \param pin A number identifying the pin to act on.
+ */
+static inline void ioport_toggle_pin(port_pin_t pin)
+{
+ arch_ioport_toggle_pin_level(pin);
+}
+
+/*! \brief Drives a group of I/O pin of a port to high level.
+ *
+ * \param port_id The port number.
+ * \param port_mask The mask.
+ */
+static inline void ioport_set_group_high(port_id_t port_id,
+ pin_mask_t port_mask)
+{
+ arch_ioport_set_port_level(port_id, port_mask, port_mask);
+}
+
+/*! \brief Drives a group of I/O pin of a port to low level.
+ *
+ * \param port_id The port number.
+ * \param port_mask The mask.
+ */
+static inline void ioport_set_group_low(port_id_t port_id, pin_mask_t port_mask)
+{
+ arch_ioport_set_port_level(port_id, port_mask, 0);
+}
+
+/*! \brief Toggles a group of I/O pin of a port.
+ *
+ * \param port_id The port number.
+ * \param port_mask The mask.
+ */
+static inline void ioport_tgl_group(port_id_t port_id, pin_mask_t port_mask)
+{
+ arch_ioport_toggle_port_level(port_id, port_mask);
+}
+
+#endif /* IOPORT_COMPAT_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.h.REMOVED.git-id
deleted file mode 100644
index 902defce..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/ioport/xmega/ioport_compat.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-aaba63f4d4fd13628d025cda510c12a2393f5b37
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/sleepmgr.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/sleepmgr.h
new file mode 100644
index 00000000..2435d44c
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/sleepmgr.h
@@ -0,0 +1,271 @@
+/**
+ * \file
+ *
+ * \brief Sleep manager
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef SLEEPMGR_H
+#define SLEEPMGR_H
+
+#include
+#include
+
+#if (SAM3S || SAM3U || SAM3N || SAM3XA || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM)
+# include "sam/sleepmgr.h"
+#elif XMEGA
+# include "xmega/sleepmgr.h"
+#elif UC3
+# include "uc3/sleepmgr.h"
+#elif SAM4L
+# include "sam4l/sleepmgr.h"
+#elif MEGA
+# include "mega/sleepmgr.h"
+#elif (SAMD20 || SAMD21 || SAMR21 || SAMD11)
+# include "samd/sleepmgr.h"
+#elif (SAML21)
+# include "saml/sleepmgr.h"
+#else
+# error Unsupported device.
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup sleepmgr_group Sleep manager
+ *
+ * The sleep manager is a service for ensuring that the device is not put to
+ * sleep in deeper sleep modes than the system (e.g., peripheral drivers,
+ * services or the application) allows at any given time.
+ *
+ * It is based on the use of lock counting for the individual sleep modes, and
+ * will put the device to sleep in the shallowest sleep mode that has a non-zero
+ * lock count. The drivers/services/application can change these counts by use
+ * of \ref sleepmgr_lock_mode and \ref sleepmgr_unlock_mode.
+ * Refer to \ref sleepmgr_mode for a list of the sleep modes available for
+ * locking, and the device datasheet for information on their effect.
+ *
+ * The application must supply the file \ref conf_sleepmgr.h.
+ *
+ * For the sleep manager to be enabled, the symbol \ref CONFIG_SLEEPMGR_ENABLE
+ * must be defined, e.g., in \ref conf_sleepmgr.h. If this symbol is not
+ * defined, the functions are replaced with dummy functions and no RAM is used.
+ *
+ * @{
+ */
+
+/**
+ * \def CONFIG_SLEEPMGR_ENABLE
+ * \brief Configuration symbol for enabling the sleep manager
+ *
+ * If this symbol is not defined, the functions of this service are replaced
+ * with dummy functions. This is useful for reducing code size and execution
+ * time if the sleep manager is not needed in the application.
+ *
+ * This symbol may be defined in \ref conf_sleepmgr.h.
+ */
+#if defined(__DOXYGEN__) && !defined(CONFIG_SLEEPMGR_ENABLE)
+# define CONFIG_SLEEPMGR_ENABLE
+#endif
+
+/**
+ * \enum sleepmgr_mode
+ * \brief Sleep mode locks
+ *
+ * Identifiers for the different sleep mode locks.
+ */
+
+/**
+ * \brief Initialize the lock counts
+ *
+ * Sets all lock counts to 0, except the very last one, which is set to 1. This
+ * is done to simplify the algorithm for finding the deepest allowable sleep
+ * mode in \ref sleepmgr_enter_sleep.
+ */
+static inline void sleepmgr_init(void)
+{
+#ifdef CONFIG_SLEEPMGR_ENABLE
+ uint8_t i;
+
+ for (i = 0; i < SLEEPMGR_NR_OF_MODES - 1; i++) {
+ sleepmgr_locks[i] = 0;
+ }
+ sleepmgr_locks[SLEEPMGR_NR_OF_MODES - 1] = 1;
+#endif /* CONFIG_SLEEPMGR_ENABLE */
+}
+
+/**
+ * \brief Increase lock count for a sleep mode
+ *
+ * Increases the lock count for \a mode to ensure that the sleep manager does
+ * not put the device to sleep in the deeper sleep modes.
+ *
+ * \param mode Sleep mode to lock.
+ */
+static inline void sleepmgr_lock_mode(enum sleepmgr_mode mode)
+{
+#ifdef CONFIG_SLEEPMGR_ENABLE
+ irqflags_t flags;
+
+ if(sleepmgr_locks[mode] >= 0xff) {
+ while (true) {
+ // Warning: maximum value of sleepmgr_locks buffer is no more than 255.
+ // Check APP or change the data type to uint16_t.
+ }
+ }
+
+ // Enter a critical section
+ flags = cpu_irq_save();
+
+ ++sleepmgr_locks[mode];
+
+ // Leave the critical section
+ cpu_irq_restore(flags);
+#else
+ UNUSED(mode);
+#endif /* CONFIG_SLEEPMGR_ENABLE */
+}
+
+/**
+ * \brief Decrease lock count for a sleep mode
+ *
+ * Decreases the lock count for \a mode. If the lock count reaches 0, the sleep
+ * manager can put the device to sleep in the deeper sleep modes.
+ *
+ * \param mode Sleep mode to unlock.
+ */
+static inline void sleepmgr_unlock_mode(enum sleepmgr_mode mode)
+{
+#ifdef CONFIG_SLEEPMGR_ENABLE
+ irqflags_t flags;
+
+ if(sleepmgr_locks[mode] == 0) {
+ while (true) {
+ // Warning: minimum value of sleepmgr_locks buffer is no less than 0.
+ // Check APP.
+ }
+ }
+
+ // Enter a critical section
+ flags = cpu_irq_save();
+
+ --sleepmgr_locks[mode];
+
+ // Leave the critical section
+ cpu_irq_restore(flags);
+#else
+ UNUSED(mode);
+#endif /* CONFIG_SLEEPMGR_ENABLE */
+}
+
+ /**
+ * \brief Retrieves the deepest allowable sleep mode
+ *
+ * Searches through the sleep mode lock counts, starting at the shallowest sleep
+ * mode, until the first non-zero lock count is found. The deepest allowable
+ * sleep mode is then returned.
+ */
+static inline enum sleepmgr_mode sleepmgr_get_sleep_mode(void)
+{
+ enum sleepmgr_mode sleep_mode = SLEEPMGR_ACTIVE;
+
+#ifdef CONFIG_SLEEPMGR_ENABLE
+ uint8_t *lock_ptr = sleepmgr_locks;
+
+ // Find first non-zero lock count, starting with the shallowest modes.
+ while (!(*lock_ptr)) {
+ lock_ptr++;
+ sleep_mode = (enum sleepmgr_mode)(sleep_mode + 1);
+ }
+
+ // Catch the case where one too many sleepmgr_unlock_mode() call has been
+ // performed on the deepest sleep mode.
+ Assert((uintptr_t)(lock_ptr - sleepmgr_locks) < SLEEPMGR_NR_OF_MODES);
+
+#endif /* CONFIG_SLEEPMGR_ENABLE */
+
+ return sleep_mode;
+}
+
+/**
+ * \fn sleepmgr_enter_sleep
+ * \brief Go to sleep in the deepest allowed mode
+ *
+ * Searches through the sleep mode lock counts, starting at the shallowest sleep
+ * mode, until the first non-zero lock count is found. The device is then put to
+ * sleep in the sleep mode that corresponds to the lock.
+ *
+ * \note This function enables interrupts before going to sleep, and will leave
+ * them enabled upon return. This also applies if sleep is skipped due to ACTIVE
+ * mode being locked.
+ */
+
+static inline void sleepmgr_enter_sleep(void)
+{
+#ifdef CONFIG_SLEEPMGR_ENABLE
+ enum sleepmgr_mode sleep_mode;
+
+ cpu_irq_disable();
+
+ // Find the deepest allowable sleep mode
+ sleep_mode = sleepmgr_get_sleep_mode();
+ // Return right away if first mode (ACTIVE) is locked.
+ if (sleep_mode==SLEEPMGR_ACTIVE) {
+ cpu_irq_enable();
+ return;
+ }
+ // Enter the deepest allowable sleep mode with interrupts enabled
+ sleepmgr_sleep(sleep_mode);
+#else
+ cpu_irq_enable();
+#endif /* CONFIG_SLEEPMGR_ENABLE */
+}
+
+
+//! @}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SLEEPMGR_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/sleepmgr.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/sleepmgr.h.REMOVED.git-id
deleted file mode 100644
index 114fa659..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/sleepmgr.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2435d44c0e504c229767482b27af83535dccb994
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.c
new file mode 100644
index 00000000..0877e284
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.c
@@ -0,0 +1,61 @@
+/**
+ * \file
+ *
+ * \brief Sleep manager
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include
+#include
+
+#if defined(CONFIG_SLEEPMGR_ENABLE) || defined(__DOXYGEN__)
+
+uint8_t sleepmgr_locks[SLEEPMGR_NR_OF_MODES];
+
+enum SLEEP_SMODE_enum sleepmgr_configs[SLEEPMGR_NR_OF_MODES] = {
+ SLEEP_SMODE_IDLE_gc,
+ SLEEP_SMODE_ESTDBY_gc,
+ SLEEP_SMODE_PSAVE_gc,
+ SLEEP_SMODE_STDBY_gc,
+ SLEEP_SMODE_PDOWN_gc,
+};
+
+#endif /* CONFIG_SLEEPMGR_ENABLE */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.c.REMOVED.git-id
deleted file mode 100644
index d310d98d..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0877e284b4e07f3e29337ceb9e41be9308a84ae9
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.h
new file mode 100644
index 00000000..7ca32273
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.h
@@ -0,0 +1,117 @@
+/**
+ * \file
+ *
+ * \brief AVR XMEGA Sleep manager implementation
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef XMEGA_SLEEPMGR_H
+#define XMEGA_SLEEPMGR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include
+#include
+#include
+
+/**
+ * \weakgroup sleepmgr_group
+ * @{
+ */
+
+enum sleepmgr_mode {
+ //! Active mode.
+ SLEEPMGR_ACTIVE = 0,
+ //! Idle mode.
+ SLEEPMGR_IDLE,
+ //! Extended Standby mode.
+ SLEEPMGR_ESTDBY,
+ //! Power Save mode.
+ SLEEPMGR_PSAVE,
+ //! Standby mode.
+ SLEEPMGR_STDBY,
+ //! Power Down mode.
+ SLEEPMGR_PDOWN,
+ SLEEPMGR_NR_OF_MODES,
+};
+
+/**
+ * \internal
+ * \name Internal arrays
+ * @{
+ */
+#if defined(CONFIG_SLEEPMGR_ENABLE) || defined(__DOXYGEN__)
+//! Sleep mode lock counters
+extern uint8_t sleepmgr_locks[];
+/**
+ * \brief Look-up table with sleep mode configurations
+ * \note This is located in program memory (Flash) as it is constant.
+ */
+extern enum SLEEP_SMODE_enum sleepmgr_configs[];
+#endif /* CONFIG_SLEEPMGR_ENABLE */
+//! @}
+
+static inline void sleepmgr_sleep(const enum sleepmgr_mode sleep_mode)
+{
+ Assert(sleep_mode != SLEEPMGR_ACTIVE);
+#ifdef CONFIG_SLEEPMGR_ENABLE
+ sleep_set_mode(sleepmgr_configs[sleep_mode-1]);
+ sleep_enable();
+
+ cpu_irq_enable();
+ sleep_enter();
+
+ sleep_disable();
+#else
+ cpu_irq_enable();
+#endif /* CONFIG_SLEEPMGR_ENABLE */
+
+}
+
+//! @}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XMEGA_SLEEPMGR_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.h.REMOVED.git-id
deleted file mode 100644
index 2509aca1..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/sleepmgr/xmega/sleepmgr.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7ca322738b55b4b099718f32844e4bc1b3749503
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/spi_master.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/spi_master.h
new file mode 100644
index 00000000..e92f4ca5
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/spi_master.h
@@ -0,0 +1,273 @@
+/**
+ * \file
+ *
+ * \brief SPI Master Mode management
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef SPI_MASTER_H_INCLUDED
+#define SPI_MASTER_H_INCLUDED
+
+#include
+
+#if XMEGA
+# include "xmega_spi/spi_master.h"
+#elif MEGA_RF
+# include "megarf_spi/spi_master.h"
+#elif UC3
+# include "uc3_spi/spi_master.h"
+#elif SAM
+# include "sam_spi/spi_master.h"
+#else
+# error Unsupported chip type
+#endif
+
+/**
+ *
+ * \defgroup spi_group Serial Peripheral Interface (SPI)
+ *
+ * This is the common API for SPI interface. Additional features are available
+ * in the documentation of the specific modules.
+ *
+ * \section spi_group_platform Platform Dependencies
+ *
+ * The SPI API is partially chip- or platform-specific. While all
+ * platforms provide mostly the same functionality, there are some
+ * variations around how different bus types and clock tree structures
+ * are handled.
+ *
+ * The following functions are available on all platforms, but there may
+ * be variations in the function signature (i.e. parameters) and
+ * behavior. These functions are typically called by platform-specific
+ * parts of drivers, and applications that aren't intended to be
+ * portable:
+ * - spi_master_init()
+ * - spi_master_setup_device()
+ * - spi_select_device()
+ * - spi_deselect_device()
+ * - spi_write_single()
+ * - spi_write_packet()
+ * - spi_read_single()
+ * - spi_read_packet()
+ * - spi_is_tx_empty()
+ * - spi_is_tx_ready()
+ * - spi_is_rx_full()
+ * - spi_is_rx_ready()
+ * - spi_enable()
+ * - spi_disable()
+ * - spi_is_enabled()
+ *
+ * \section spi_master_quickstart_section Quick Start Guide
+ * See \ref common_spi_master_quickstart
+ * @{
+ */
+
+//! @}
+
+/**
+ * \page common_spi_master_quickstart Quick Start Guide for the SPI Master Driver
+ *
+ * This is the quick start guide for the \ref spi_group "SPI Driver", with
+ * step-by-step instructions on how to configure and use the driver for a
+ * specific use case.
+ *
+ * The use case contain several code fragments. The code fragments in the
+ * steps for setup can be copied into a custom initialization function, while
+ * the steps for usage can be copied into, e.g., the main application function.
+ *
+ * The steps for setting up the SPI master for XMEGA and UC3 use exactly the
+ * same approach, but note that there are different names on the peripherals. So
+ * to use this Quick Start for UC3 please make sure that all the peripheral
+ * names are updated according to the UC3 datasheet.
+ * - \subpage spi_master_xmega
+ *
+ */
+/**
+ * \page spi_master_xmega Basic setup for SPI master on XMEGA devices
+ *
+ * \section spi_master_xmega_basic Basic setup for XMEGA devices
+ * The SPI module will be set up as master:
+ * - SPI on PORTD
+ * - 1MHz SPI clock speed
+ * - Slave Chip Select connected on PORTD pin 1
+ * - SPI mode 0 (data on rising clock edge)
+ *
+ * \section spi_master_xmega_basic_setup Setup steps
+ * \subsection spi_master_xmega_basic_setup_code Example code
+ * Add to application C-file (e.g. main.c):
+ * \code
+ void spi_init_pins(void)
+ {
+ ioport_configure_port_pin(&PORTD, PIN1_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+
+ ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_PULL_UP | IOPORT_DIR_INPUT);
+ ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+ ioport_configure_port_pin(&PORTD, PIN6_bm, IOPORT_DIR_INPUT);
+ ioport_configure_port_pin(&PORTD, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+ }
+
+ void spi_init_module(void)
+ {
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+
+ spi_master_init(&SPID);
+ spi_master_setup_device(&SPID, &spi_device_conf, SPI_MODE_0, 1000000, 0);
+ spi_enable(&SPID);
+ }
+\endcode
+ *
+ * \subsection spi_master_xmega_basic_setup Workflow
+ * -# Ensure that \ref conf_spi_master.h is present for the driver.
+ * - \note This file is only for the driver and should not be included by the
+ * user. In this example the file can be left empty.
+ * -# Initialize the pins used by the SPI interface (this initialization is for
+ * the ATxmega32A4U device).
+ * -# Set the pin used for slave select as output high:
+ * \code
+ ioport_configure_port_pin(&PORTD, PIN1_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+\endcode
+ * -# Enable pull-up on own chip select (SS):
+ * \code
+ ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_PULL_UP | IOPORT_DIR_INPUT);
+\endcode
+ * \attention If this pin is pulled low the SPI module will go into slave mode.
+ * -# Set MOSI and SCL as output high, and set MISO as input:
+ * \code
+ ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+ ioport_configure_port_pin(&PORTD, PIN6_bm, IOPORT_DIR_INPUT);
+ ioport_configure_port_pin(&PORTD, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+\endcode
+ * -# Define the SPI device configuration struct to describe which pin the
+ * slave select (slave chip select) is connected to, in this case the slave
+ * select pin has been connected to PORTD pin 1 (PD1):
+ * - \code
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+\endcode
+ * -# Initialize the SPI module, in this case SPI on PORTD has been chosen:
+ * - \code
+ spi_master_init(&SPID);
+\endcode
+ * -# Setup the SPI master module for a specific device:
+ * - \code
+ spi_master_setup_device(&SPID, &spi_device_conf, SPI_MODE_0, 1000000, 0);
+\endcode
+ * - \note The last argument, which is zero in this case, can be ignored and is
+ * only included for compatibility purposes.
+ * -# Then enable the SPI:
+ * - \code
+ spi_enable(&SPID);
+\endcode
+ *
+ * \section spi_master_xmega_basic_usage Usage steps
+ * \subsection spi_master_xmega_basic_usage_code Example code
+ * Add to, e.g., the main loop in the application C-file:
+ * \code
+ uint8_t data_buffer[1] = {0xAA};
+
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+
+ spi_select_device(&SPID, &spi_device_conf);
+
+ spi_write_packet(&SPID, data_buffer, 1);
+ spi_read_packet(&SPID, data_buffer, 1);
+
+ spi_deselect_device(&SPID, &spi_device_conf);
+\endcode
+ *
+ * \subsection spi_master_xmega_basic_usage_flow Workflow
+ * -# Create a buffer for data to be sent/received on the SPI bus, in this case
+ * a single byte buffer is used. The buffer can be of arbitrary size as long as
+ * there is space left in SRAM:
+ * - \code
+ uint8_t data_buffer[1] = {0xAA};
+\endcode
+ * -# Define the SPI device configuration struct to describe which pin the
+ * slave select (slave chip select) is connected to, in this case the slave
+ * select pin has been connected to PORTD pin 1 (PD1):
+ * - \code
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+\endcode
+ * - \note As this struct is the same for both the initializing part and the usage
+ * part it could be a good idea to make the struct global, and hence accessible
+ * for both the initializing part and usage part. Another solution could be to
+ * create the struct in the main function and pass the address of the struct to
+ * the spi_init_module() function, e.g.:
+ * \code
+ void spi_init_module(struct spi_device *spi_device_conf)
+ {
+ ...
+
+ spi_master_setup_device(&SPID, spi_device_conf, SPI_MODE_0, 1000000, 0);
+
+ ...
+ }
+\endcode
+ * -# Write data to the SPI slave device, in this case write one byte from the
+ * data_buffer:
+ * - \code
+ spi_write_packet(&SPID, data_buffer, 1);
+\endcode
+ * -# Read data from the SPI slave device, in this case read one byte and put it
+ * into the data_buffer:
+ * - \code
+ spi_read_packet(&SPID, data_buffer, 1);
+\endcode
+ * - \attention As the SPI works as a shift register so that data is shifted in at
+ * the same time as data is shifted out a read operation will mean that a dummy
+ * byte \ref CONFIG_SPI_MASTER_DUMMY is written to the SPI bus. \ref CONFIG_SPI_MASTER_DUMMY
+ * defaults to 0xFF, but can be changed by defining it inside the \ref conf_spi_master.h
+ * file.
+ * -# When read and write operations is done de-select the slave:
+ * - \code
+ spi_deselect_device(&SPID, &spi_device_conf);
+\endcode
+ *
+ */
+
+#endif /* SPI_MASTER_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/spi_master.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/spi_master.h.REMOVED.git-id
deleted file mode 100644
index 0165616c..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/spi_master.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e92f4ca5acb245de380ce60d0cc4c9b8c8829e7e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/usart_spi.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/usart_spi.h
new file mode 100644
index 00000000..92b407ff
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/usart_spi.h
@@ -0,0 +1,104 @@
+/**
+ * \file
+ *
+ * \brief USART in SPI mode driver functions.
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef USART_SPI_H_INCLUDED
+#define USART_SPI_H_INCLUDED
+
+#include
+
+#if XMEGA
+# include "xmega_usart_spi/usart_spi.h"
+#elif MEGA_RF
+# include "megarf_usart_spi/usart_spi.h"
+#elif UC3
+# include "uc3_usart_spi/usart_spi.h"
+#elif SAM
+# include "sam_usart_spi/usart_spi.h"
+#else
+# error Unsupported chip type
+#endif
+
+/**
+ *
+ * \defgroup usart_spi_group USART in SPI (Serial Peripheral Interface) mode
+ *
+ * This is the common API for USART in SPI mode. Additional features are available
+ * in the documentation of the specific modules.
+ *
+ * \section spi_group_platform Platform Dependencies
+ *
+ * The spi API is partially chip- or platform-specific. While all
+ * platforms provide mostly the same functionality, there are some
+ * variations around how different bus types and clock tree structures
+ * are handled.
+ *
+ * The following functions are available on all platforms, but there may
+ * be variations in the function signature (i.e. parameters) and
+ * behaviour. These functions are typically called by platform-specific
+ * parts of drivers, and applications that aren't intended to be
+ * portable:
+ * - usart_spi_init()
+ * - usart_spi_setup_device()
+ * - usart_spi_select_device()
+ * - usart_spi_deselect_device()
+ * - usart_spi_write_single()
+ * - usart_spi_write_packet()
+ * - usart_spi_read_single()
+ * - usart_spi_read_packet()
+ * - usart_spi_is_tx_empty()
+ * - usart_spi_is_tx_ready()
+ * - usart_spi_is_rx_full()
+ * - usart_spi_is_rx_ready()
+ * - usart_spi_enable()
+ * - usart_spi_disable()
+ * - usart_spi_is_enabled()
+ *
+ *
+ * @{
+ */
+
+//! @}
+
+#endif /* USART_SPI_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/usart_spi.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/usart_spi.h.REMOVED.git-id
deleted file mode 100644
index 6d2d8c88..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/usart_spi.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-92b407ff5c005cb60ac2ef0fd1bcf767f0de6598
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.c
new file mode 100644
index 00000000..9feeebcf
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.c
@@ -0,0 +1,195 @@
+/*****************************************************************************
+ *
+ * \file
+ *
+ * \brief SPI software driver functions.
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ *****************************************************************************/
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "spi_master.h"
+#include "sysclk.h"
+
+/*! \brief Initializes the SPI in master mode.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ */
+void spi_master_init(SPI_t *spi)
+{
+#ifdef SPIA
+ if ((uint16_t)spi == (uint16_t)&SPIA) {
+ sysclk_enable_module(SYSCLK_PORT_A, PR_SPI_bm);
+ }
+#endif
+#ifdef SPIB
+ if ((uint16_t)spi == (uint16_t)&SPIB) {
+ sysclk_enable_module(SYSCLK_PORT_B, PR_SPI_bm);
+ }
+#endif
+#ifdef SPIC
+ if ((uint16_t)spi == (uint16_t)&SPIC) {
+ sysclk_enable_module(SYSCLK_PORT_C, PR_SPI_bm);
+ }
+#endif
+#ifdef SPID
+ if ((uint16_t)spi == (uint16_t)&SPID) {
+ sysclk_enable_module(SYSCLK_PORT_D, PR_SPI_bm);
+ }
+#endif
+#ifdef SPIE
+ if ((uint16_t)spi == (uint16_t)&SPIE) {
+ sysclk_enable_module(SYSCLK_PORT_E, PR_SPI_bm);
+ }
+#endif
+#ifdef SPIF
+ if ((uint16_t)spi == (uint16_t)&SPIF) {
+ sysclk_enable_module(SYSCLK_PORT_F, PR_SPI_bm);
+ }
+#endif
+ spi_enable_master_mode(spi);
+}
+
+/**
+ * \brief Setup a SPI device.
+ *
+ * The returned device descriptor structure must be passed to the driver
+ * whenever that device should be used as current slave device.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param device Pointer to SPI device struct that should be initialized.
+ * \param flags SPI configuration flags. Common flags for all
+ * implementations are the SPI modes SPI_MODE_0 ...
+ * SPI_MODE_3.
+ * \param baud_rate Baud rate for communication with slave device in Hz.
+ * \param sel_id Board specific select id
+ */
+void spi_master_setup_device(SPI_t *spi, struct spi_device *device,
+ spi_flags_t flags, uint32_t baud_rate,
+ board_spi_select_id_t sel_id)
+{
+ if (spi_xmega_set_baud_div(spi, baud_rate, sysclk_get_cpu_hz()) < 0) {
+ Assert(false);
+ return;
+ }
+
+ /* Clear any set SPI mode flags and set them to the user-specified mode */
+ spi->CTRL = (spi->CTRL & ~SPI_MODE_gm) |
+ ((flags << SPI_MODE_gp) & SPI_MODE_gm);
+}
+
+/**
+ * \brief Send a sequence of bytes to a SPI device
+ *
+ * Received bytes on the SPI bus are discarded.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param data data buffer to write
+ * \param len Length of data
+ *
+ * \pre SPI device must be selected with spi_select_device() first
+ */
+status_code_t spi_write_packet(SPI_t *spi, const uint8_t *data, size_t len)
+{
+ while (len--) {
+ spi_write_single(spi, *data++);
+
+ while (!spi_is_rx_full(spi)) {
+ }
+ }
+
+ return STATUS_OK;
+}
+
+/**
+ * \brief Receive a sequence of bytes from a SPI device
+ *
+ * All bytes sent out on SPI bus are sent as value 0.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param data data buffer to read
+ * \param len Length of data
+ *
+ * \pre SPI device must be selected with spi_select_device() first
+ */
+status_code_t spi_read_packet(SPI_t *spi, uint8_t *data, size_t len)
+{
+ while (len--) {
+ spi_write_single(spi,CONFIG_SPI_MASTER_DUMMY); //Dummy write
+
+ while (!spi_is_rx_full(spi)) {
+ }
+
+ spi_read_single(spi, data);
+ data++;
+ }
+
+ return STATUS_OK;
+}
+
+/**
+ * \brief Select given device on the SPI bus
+ *
+ * Set device specific setting and calls board chip select.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param device SPI device
+ *
+ */
+void spi_select_device(SPI_t *spi, struct spi_device *device)
+{
+ ioport_set_pin_low(device->id);
+}
+
+/**
+ * \brief Deselect given device on the SPI bus
+ *
+ * Calls board chip deselect.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param device SPI device
+ *
+ * \pre SPI device must be selected with spi_select_device() first
+ */
+void spi_deselect_device(SPI_t *spi, struct spi_device *device)
+{
+ ioport_set_pin_high(device->id);
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.c.REMOVED.git-id
deleted file mode 100644
index f3aa21eb..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9feeebcff33d69c58a2619b43bd092ed11830359
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.h
new file mode 100644
index 00000000..12fc7088
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.h
@@ -0,0 +1,450 @@
+/*****************************************************************************
+ *
+ * \file
+ *
+ * \brief SPI Master driver for AVR.
+ *
+ * This file defines a useful set of functions for the SPI interface on AVR
+ * devices.
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ ******************************************************************************/
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+
+#ifndef _SPI_MASTER_H_
+#define _SPI_MASTER_H_
+
+#include "compiler.h"
+#include "status_codes.h"
+#include "ioport.h"
+#include "spi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup xmega_spi_master_group XMEGA SPI master service.
+ *
+ * This is the API for SPI master service on XMEGA.
+ *
+ * @{
+ *
+ * \section xmega_spi_master_qucikstart_section Quick Start Guide
+ * See \ref common_spi_master_quickstart
+ */
+
+/*! \name Spi Master Management Configuration
+ */
+//! @{
+#include "conf_spi_master.h"
+
+//! Default Config Spi Master Dummy Field
+#ifndef CONFIG_SPI_MASTER_DUMMY
+#define CONFIG_SPI_MASTER_DUMMY 0xFF
+#endif
+//! @}
+
+/**
+ * \brief Clock phase
+ */
+#define SPI_CPHA (1 << 0)
+
+/**
+ * \brief Clock polarity
+ */
+#define SPI_CPOL (1 << 1)
+
+/**
+ * \brief SPI mode 0
+ */
+#define SPI_MODE_0 0
+/**
+ * \brief SPI mode 1
+ */
+#define SPI_MODE_1 (SPI_CPHA)
+/**
+ * \brief SPI mode 2
+ */
+#define SPI_MODE_2 (SPI_CPOL)
+/**
+ * \brief SPI mode 3
+ */
+#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA)
+
+typedef uint8_t spi_flags_t;
+typedef uint32_t board_spi_select_id_t;
+
+//! \brief Polled SPI device definition
+struct spi_device {
+ //! Board specific select id
+ port_pin_t id;
+};
+
+/*! \brief Initializes the SPI in master mode.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ */
+extern void spi_master_init(SPI_t *spi);
+
+/**
+ * \brief Setup a SPI device.
+ *
+ * The returned device descriptor structure must be passed to the driver
+ * whenever that device should be used as current slave device.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param device Pointer to SPI device struct that should be initialized.
+ * \param flags SPI configuration flags. Common flags for all
+ * implementations are the SPI modes SPI_MODE_0 ...
+ * SPI_MODE_3.
+ * \param baud_rate Baud rate for communication with slave device in Hz.
+ * \param sel_id Board specific select id
+ */
+extern void spi_master_setup_device(SPI_t *spi, struct spi_device *device,
+ spi_flags_t flags, unsigned long baud_rate,
+ board_spi_select_id_t sel_id);
+
+/*! \brief Enables the SPI.
+ *
+ * \param spi Base address of the SPI instance.
+ */
+extern void spi_enable(SPI_t *spi);
+
+/*! \brief Disables the SPI.
+ *
+ * Ensures that nothing is transferred while setting up buffers.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \warning This may cause data loss if used on a slave SPI.
+ */
+extern void spi_disable(SPI_t *spi);
+
+
+/*! \brief Tests if the SPI is enabled.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \return \c 1 if the SPI is enabled, otherwise \c 0.
+ */
+extern bool spi_is_enabled(SPI_t *spi);
+
+/**
+ * \brief Select given device on the SPI bus
+ *
+ * Set device specific setting and calls board chip select.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param device SPI device
+ *
+ */
+extern void spi_select_device(SPI_t *spi, struct spi_device *device);
+
+/**
+ * \brief Deselect given device on the SPI bus
+ *
+ * Calls board chip deselect.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param device SPI device
+ *
+ * \pre SPI device must be selected with spi_select_device() first
+ */
+extern void spi_deselect_device(SPI_t *spi, struct spi_device *device);
+
+/*! \brief Write one byte to a SPI device.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param data The data byte to be loaded
+ *
+ */
+__always_inline static void spi_write_single(SPI_t *spi, uint8_t data)
+{
+ spi_put(spi,data);
+}
+
+/**
+ * \brief Send a sequence of bytes to a SPI device
+ *
+ * Received bytes on the SPI bus are discarded.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param data data buffer to write
+ * \param len Length of data
+ *
+ * \pre SPI device must be selected with spi_select_device() first
+ */
+extern status_code_t spi_write_packet(SPI_t *spi,const uint8_t *data, size_t len);
+
+
+/*! \brief Receive one byte from a SPI device.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param data Pointer to the data byte where to store the received data.
+ *
+ */
+inline static void spi_read_single(SPI_t *spi, uint8_t *data)
+{
+ *data=spi_get(spi);
+}
+
+/**
+ * \brief Receive a sequence of bytes from a SPI device
+ *
+ * All bytes sent out on SPI bus are sent as value 0.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param data data buffer to read
+ * \param len Length of data
+ *
+ * \pre SPI device must be selected with spi_select_device() first
+ */
+extern status_code_t spi_read_packet(SPI_t *spi, uint8_t *data, size_t len);
+
+/*! \brief Checks if all transmissions are complete.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \return Status.
+ * \retval 1 All transmissions complete.
+ * \retval 0 Transmissions not complete.
+ */
+inline static bool spi_is_tx_empty(SPI_t *spi)
+{
+ return spi_is_tx_ok(spi);
+}
+
+/*! \brief Checks if all transmissions is ready.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \return Status.
+ * \retval 1 All transmissions complete.
+ * \retval 0 Transmissions not complete.
+ */
+inline static bool spi_is_tx_ready(SPI_t *spi)
+{
+ return spi_is_tx_ok(spi);
+}
+
+/*! \brief Tests if the SPI contains a received character.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \return \c 1 if the SPI Receive Holding Register is full, otherwise \c 0.
+ */
+inline static bool spi_is_rx_full(SPI_t *spi)
+{
+ return spi_is_tx_ok(spi);
+}
+
+/*! \brief Checks if all reception is ready.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \return \c 1 if the SPI Receiver is ready, otherwise \c 0.
+ */
+inline static bool spi_is_rx_ready(SPI_t *spi)
+{
+ return spi_is_tx_ok(spi);
+}
+
+//! @}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * \page spi_master_xmega Quick start guide for SPI master on XMEGA devices
+ *
+ * \section spi_master_xmega_basic Basic setup for XMEGA devices
+ * The SPI module will be set up as master:
+ * - SPI on PORTD
+ * - 1MHz SPI clock speed
+ * - Slave Chip Select connected on PORTD pin 1
+ * - SPI mode 0 (data on rising clock edge)
+ *
+ * \section spi_master_xmega_basic_setup Setup steps
+ * \subsection spi_master_xmega_basic_setup_code Example code
+ * Add to application C-file (e.g. main.c):
+ * \code
+ void spi_init_pins(void)
+ {
+ ioport_configure_port_pin(&PORTD, PIN1_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+
+ ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_PULL_UP | IOPORT_DIR_INPUT);
+ ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+ ioport_configure_port_pin(&PORTD, PIN6_bm, IOPORT_DIR_INPUT);
+ ioport_configure_port_pin(&PORTD, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+ }
+
+ void spi_init_module(void)
+ {
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+
+ spi_master_init(&SPID);
+ spi_master_setup_device(&SPID, &spi_device_conf, SPI_MODE_0, 1000000, 0);
+ spi_enable(&SPID);
+ }
+\endcode
+ *
+ * \subsection spi_master_xmega_basic_setup Workflow
+ * -# Ensure that \ref conf_spi_master.h is present for the driver.
+ * - \note This file is only for the driver and should not be included by the
+ * user. In this example the file can be left empty.
+ * -# Initialize the pins used by the SPI interface (this initialization is for
+ * the ATxmega32A4U device).
+ * -# Set the pin used for slave select as output high:
+ * \code
+ ioport_configure_port_pin(&PORTD, PIN1_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+\endcode
+ * -# Enable pull-up on own chip select (SS):
+ * \code
+ ioport_configure_port_pin(&PORTD, PIN4_bm, IOPORT_PULL_UP | IOPORT_DIR_INPUT);
+\endcode
+ * \attention If this pin is pulled low the SPI module will go into slave mode.
+ * -# Set MOSI and SCL as output high, and set MISO as input:
+ * \code
+ ioport_configure_port_pin(&PORTD, PIN5_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+ ioport_configure_port_pin(&PORTD, PIN6_bm, IOPORT_DIR_INPUT);
+ ioport_configure_port_pin(&PORTD, PIN7_bm, IOPORT_INIT_HIGH | IOPORT_DIR_OUTPUT);
+\endcode
+ * -# Define the SPI device configuration struct to describe which pin the
+ * slave select (slave chip select) is connected to, in this case the slave
+ * select pin has been connected to PORTD pin 1 (PD1):
+ * - \code
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+\endcode
+ * -# Initialize the SPI module, in this case SPI on PORTD has been chosen:
+ * - \code
+ spi_master_init(&SPID);
+\endcode
+ * -# Setup the SPI master module for a specific device:
+ * - \code
+ spi_master_setup_device(&SPID, &spi_device_conf, SPI_MODE_0, 1000000, 0);
+\endcode
+ * - \note The last argument, which is zero in this case, can be ignored and is
+ * only included for compatibility purposes.
+ * -# Then enable the SPI:
+ * - \code
+ spi_enable(&SPID);
+\endcode
+ *
+ * \section spi_master_xmega_basic_usage Usage steps
+ * \subsection spi_master_xmega_basic_usage_code Example code
+ * Add to, e.g., the main loop in the application C-file:
+ * \code
+ uint8_t data_buffer[1] = {0xAA};
+
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+
+ spi_select_device(&SPID, &spi_device_conf);
+
+ spi_write_packet(&SPID, data_buffer, 1);
+ spi_read_packet(&SPID, data_buffer, 1);
+
+ spi_deselect_device(&SPID, &spi_device_conf);
+\endcode
+ *
+ * \subsection spi_master_xmega_basic_usage_flow Workflow
+ * -# Create a buffer for data to be sent/received on the SPI bus, in this case
+ * a single byte buffer is used. The buffer can be of arbitrary size as long as
+ * there is space left in SRAM:
+ * - \code
+ uint8_t data_buffer[1] = {0xAA};
+\endcode
+ * -# Define the SPI device configuration struct to describe which pin the
+ * slave select (slave chip select) is connected to, in this case the slave
+ * select pin has been connected to PORTD pin 1 (PD1):
+ * - \code
+ struct spi_device spi_device_conf = {
+ .id = IOPORT_CREATE_PIN(PORTD, 1)
+ };
+\endcode
+ * - \note As this struct is the same for both the initializing part and the usage
+ * part it could be a good idea to make the struct global, and hence accessible
+ * for both the initializing part and usage part. Another solution could be to
+ * create the struct in the main function and pass the address of the struct to
+ * the spi_init_module() function, e.g.:
+ * \code
+ void spi_init_module(struct spi_device *spi_device_conf)
+ {
+ ...
+
+ spi_master_setup_device(&SPID, spi_device_conf, SPI_MODE_0, 1000000, 0);
+
+ ...
+ }
+\endcode
+ * -# Write data to the SPI slave device, in this case write one byte from the
+ * data_buffer:
+ * - \code
+ spi_write_packet(&SPID, data_buffer, 1);
+\endcode
+ * -# Read data from the SPI slave device, in this case read one byte and put it
+ * into the data_buffer:
+ * - \code
+ spi_read_packet(&SPID, data_buffer, 1);
+\endcode
+ * - \attention As the SPI works as a shift register so that data is shifted in at
+ * the same time as data is shifted out a read operation will mean that a dummy
+ * byte \ref CONFIG_SPI_MASTER_DUMMY is written to the SPI bus. \ref CONFIG_SPI_MASTER_DUMMY
+ * defaults to 0xFF, but can be changed by defining it inside the \ref conf_spi_master.h
+ * file.
+ * -# When read and write operations is done de-select the slave:
+ * - \code
+ spi_deselect_device(&SPID, &spi_device_conf);
+\endcode
+ *
+ */
+
+#endif // _SPI_MASTER_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.h.REMOVED.git-id
deleted file mode 100644
index 70cb4af8..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_spi/spi_master.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-12fc708809ef040b50a0ae09dfa31096af58f73a
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.c
new file mode 100644
index 00000000..7a406d70
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.c
@@ -0,0 +1,140 @@
+/**
+ * \file
+ *
+ * \brief AVR XMEGA USART in SPI mode driver functions.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include "usart_spi.h"
+#include "sysclk.h"
+
+void usart_spi_init(USART_t *usart)
+{
+#ifdef USARTC0
+ if((uint16_t)usart == (uint16_t)&USARTC0) {
+ sysclk_enable_module(SYSCLK_PORT_C,PR_USART0_bm);
+ }
+#endif
+#ifdef USARTC1
+ else
+ if((uint16_t)usart == (uint16_t)&USARTC1) {
+ sysclk_enable_module(SYSCLK_PORT_C,PR_USART1_bm);
+ }
+#endif
+#ifdef USARTD0
+ else
+ if((uint16_t)usart == (uint16_t)&USARTD0) {
+ sysclk_enable_module(SYSCLK_PORT_D,PR_USART0_bm);
+ }
+#endif
+#ifdef USARTD1
+ else
+ if((uint16_t)usart == (uint16_t)&USARTD1) {
+ sysclk_enable_module(SYSCLK_PORT_D,PR_USART1_bm);
+ }
+#endif
+#ifdef USARTE0
+ else
+ if((uint16_t)usart == (uint16_t)&USARTE0) {
+ sysclk_enable_module(SYSCLK_PORT_E,PR_USART0_bm);
+ }
+#endif
+#ifdef USARTE1
+ else
+ if((uint16_t)usart == (uint16_t)&USARTE1) {
+ sysclk_enable_module(SYSCLK_PORT_E,PR_USART1_bm);
+ }
+#endif
+#ifdef USARTF0
+ else
+ if((uint16_t)usart == (uint16_t)&USARTF0) {
+ sysclk_enable_module(SYSCLK_PORT_F,PR_USART0_bm);
+ }
+#endif
+#ifdef USARTF1
+ else
+ if((uint16_t)usart == (uint16_t)&USARTF1) {
+ sysclk_enable_module(SYSCLK_PORT_F,PR_USART1_bm);
+ }
+#endif
+}
+
+void usart_spi_setup_device(USART_t *usart, struct usart_spi_device *device,
+ spi_flags_t flags, unsigned long baud_rate,
+ board_spi_select_id_t sel_id)
+{
+ usart_spi_options_t opt;
+ opt.baudrate=baud_rate;
+ opt.spimode=flags;
+ opt.data_order=false;
+ usart_init_spi(usart, &opt);
+}
+
+status_code_t usart_spi_write_packet(USART_t *usart,const uint8_t *data, size_t len)
+{
+ size_t i=0;
+ while(len) {
+ usart_spi_transmit(usart,*(data+i));
+ len--;
+ i++;
+ }
+ return STATUS_OK;
+}
+
+status_code_t usart_spi_read_packet(USART_t *usart, uint8_t *data, size_t len)
+{
+ while(len) {
+ *data = usart_spi_transmit(usart, CONFIG_USART_SPI_DUMMY);
+ len--;
+ data++;
+ }
+ return STATUS_OK;
+}
+
+void usart_spi_select_device(USART_t *usart, struct usart_spi_device *device)
+{
+ ioport_set_pin_low(device->id);
+}
+
+void usart_spi_deselect_device(USART_t *usart, struct usart_spi_device *device)
+{
+ ioport_set_pin_high(device->id);
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.c.REMOVED.git-id
deleted file mode 100644
index c360af51..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7a406d7089281b83780e00251f2b9a9591744e12
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.h
new file mode 100644
index 00000000..d5d5a95f
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.h
@@ -0,0 +1,279 @@
+/**
+ * \file
+ *
+ * \brief AVR XMEGA USART in SPI mode driver functions.
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _USART_SPI_H_
+#define _USART_SPI_H_
+
+#include "compiler.h"
+#include "status_codes.h"
+#include "ioport.h"
+#include "usart.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \name USART in SPI mode Management Configuration
+ */
+//! @{
+#include "conf_usart_spi.h"
+
+//! Default Config Spi Master Dummy Field
+#ifndef CONFIG_USART_SPI_DUMMY
+ #define CONFIG_USART_SPI_DUMMY 0xFF
+#endif
+//! @}
+
+/**
+ * \brief Clock phase
+ */
+#define SPI_CPHA (1 << 0)
+
+/**
+ * \brief Clock polarity
+ */
+#define SPI_CPOL (1 << 1)
+
+/**
+ * \brief SPI mode 0
+ */
+#define SPI_MODE_0 0
+/**
+ * \brief SPI mode 1
+ */
+#define SPI_MODE_1 (SPI_CPHA)
+/**
+ * \brief SPI mode 2
+ */
+#define SPI_MODE_2 (SPI_CPOL)
+/**
+ * \brief SPI mode 3
+ */
+#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA)
+
+typedef uint8_t spi_flags_t;
+typedef uint32_t board_spi_select_id_t;
+
+//! \brief Polled SPI device definition
+struct usart_spi_device {
+ //! Board specific select id
+ port_pin_t id;
+};
+
+/*! \brief Initializes the USART in SPI master mode.
+ *
+ * \param usart Base address of the USART instance.
+ *
+ */
+extern void usart_spi_init(USART_t *usart);
+
+/**
+ * \brief Setup a USART in SPI mode device.
+ *
+ * The returned device descriptor structure must be passed to the driver
+ * whenever that device should be used as current slave device.
+ *
+ * \param usart Base address of the USART instance.
+ * \param device Pointer to usart device struct that should be initialized.
+ * \param flags USART configuration flags. Common flags for all
+ * implementations are the usart modes SPI_MODE_0 ...
+ * SPI_MODE_3.
+ * \param baud_rate Baud rate for communication with slave device in Hz.
+ * \param sel_id Board specific select id
+ */
+extern void usart_spi_setup_device(USART_t *usart, struct usart_spi_device *device,
+ spi_flags_t flags, unsigned long baud_rate,
+ board_spi_select_id_t sel_id);
+
+/*! \brief Enables the USART for the specified USART in SPI mode.
+ *
+ * \param usart Base address of the USART instance.
+ */
+extern void usart_spi_enable(USART_t *usart);
+
+/*! \brief Disables the USART.
+ *
+ * Ensures that nothing is transferred while setting up buffers.
+ *
+ * \param usart Base address of the USART instance.
+ *
+ */
+extern void usart_spi_disable(USART_t *usart);
+
+
+/*! \brief Tests if the USART in SPI mode is enabled.
+ *
+ * \param usart Base address of the usart instance.
+ *
+ * \return \c 1 if the usart is enabled, otherwise \c 0.
+ */
+extern bool usart_spi_is_enabled(USART_t *usart);
+
+/**
+ * \brief Select given device on the SPI bus
+ *
+ * Set device specific setting and calls board chip select.
+ *
+ * \param usart Base address of the USART instance.
+ * \param device SPI device
+ *
+ */
+extern void usart_spi_select_device(USART_t *usart, struct usart_spi_device *device);
+
+/**
+ * \brief Deselect given device on the SPI bus
+ *
+ * Calls board chip deselect.
+ *
+ * \param usart Base address of the USART instance.
+ * \param device SPI device
+ *
+ * \pre SPI device must be selected with usart_spi_select_device() first
+ */
+extern void usart_spi_deselect_device(USART_t *usart, struct usart_spi_device *device);
+
+/*! \brief Write one byte to a SPI device using USART in SPI mode
+ *
+ * \param usart Base address of the usart instance.
+ * \param data The data byte to be loaded
+ *
+ */
+__always_inline static void usart_spi_write_single(USART_t *usart, uint8_t data)
+{
+ usart_spi_transmit(usart, data);
+}
+
+/**
+ * \brief Send a sequence of bytes to a SPI device using USART in SPI mode
+ *
+ * Received bytes on the USART in SPI mode are discarded.
+ *
+ * \param usart Base address of the USART instance.
+ * \param data Data buffer to write
+ * \param len Length of data
+ *
+ * \pre usart device must be selected with usart_spi_select_device() first
+ */
+extern status_code_t usart_spi_write_packet(USART_t *usart,const uint8_t *data, size_t len);
+
+
+/*! \brief Receive one byte from a SPI device using USART in SPI mode
+ *
+ * \param usart Base address of the USART instance.
+ * \param data Pointer to the data byte where to store the received data.
+ *
+ */
+inline static void usart_spi_read_single(USART_t *usart, uint8_t *data)
+{
+ *data = usart_spi_transmit(usart, CONFIG_USART_SPI_DUMMY);
+}
+
+/**
+ * \brief Receive a sequence of bytes from a USART in SPI mode device
+ *
+ * All bytes sent out on usart bus are sent as value 0.
+ *
+ * \param usart Base address of the usart instance.
+ * \param data data buffer to read
+ * \param len Length of data
+ *
+ * \pre usart device must be selected with usart_spi_select_device() first
+ */
+extern status_code_t usart_spi_read_packet(USART_t *usart, uint8_t *data, size_t len);
+
+/*! \brief Check whether there are data in Transmit Holding Register or
+ * Transmit Shift Register in SPI master mode.
+ *
+ * \param usart Base address of the USART instance.
+ *
+ * \retval 1 The two registers are empty.
+ * \retval 0 One of the two registers contains data.
+ */
+inline static bool usart_spi_is_tx_empty(USART_t *usart)
+{
+ return usart_data_register_is_empty(usart);
+}
+
+/*! \brief Check whether the USART in SPI master mode contains a received character.
+ *
+ * \param usart Base address of the USART instance.
+ *
+ * \retval 1 Some data have been received.
+ * \retval 0 No data has been received.
+ */
+inline static bool usart_spi_is_rx_ready(USART_t *usart)
+{
+ return usart_rx_is_complete(usart);
+}
+
+/*! \brief Check if the USART Transmit Register is empty.
+ *
+ * \param usart Base address of the USART instance.
+ *
+ * \retval 1 There is no data in the Transmit Holding Register.
+ * \retval 0 There are data in the Transmit Holding Register.
+ */
+inline static bool usart_spi_is_tx_ready(USART_t *usart)
+{
+ return usart_data_register_is_empty(usart);
+}
+
+/*! \brief Tests if the USART in SPI mode contains a received character.
+ *
+ * \param usart Base address of the USART instance.
+ *
+ * \return \c 1 if the USART Receive Holding Register is full, otherwise \c 0.
+ */
+inline static bool usart_spi_is_rx_full(USART_t *usart)
+{
+ return usart_rx_is_complete(usart);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _USART_SPI_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.h.REMOVED.git-id
deleted file mode 100644
index cc1d7612..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/spi/xmega_usart_spi/usart_spi.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d5d5a95f1ee6943e3286f8d2e9d936ea9b7c1de4
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c
new file mode 100644
index 00000000..fd035fe1
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c
@@ -0,0 +1,84 @@
+/**
+ * \file
+ *
+ * \brief User Interface
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include
+#include "ui.h"
+
+void ui_init(void)
+{
+ return;
+}
+
+void ui_powerdown(void)
+{
+ return;
+}
+
+void ui_wakeup(void)
+{
+ return;
+}
+
+void ui_loop_back_state(bool b_started)
+{
+ return;
+}
+
+void ui_process(uint16_t framenumber)
+{
+ return;
+}
+
+
+/**
+ * \defgroup UI User Interface
+ *
+ * Human interface on XMEGA-A3BU Xplained:
+ * - Led green (close to USB connector) is on at power on
+ * - Led 0 is on when USB line is in IDLE mode, and off in SUSPEND mode
+ * - Led 1 blinks when USB host has checked and enabled vendor interface
+ * - Red LED (Led 2) close to USB connector is on when loopback is running
+ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c.REMOVED.git-id
deleted file mode 100644
index 82a90d08..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/example/atxmega256a3bu_xmega_a3bu_xplained/ui.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fd035fe1de454228afb754f138e9a19216463ee0
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.c
new file mode 100644
index 00000000..bd1dfdd8
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.c
@@ -0,0 +1,295 @@
+/**
+ * \file
+ *
+ * \brief USB Vendor class interface.
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "conf_usb.h"
+#include "usb_protocol.h"
+#include "usb_protocol_vendor.h"
+#include "udd.h"
+#include "udc.h"
+#include "udi_vendor.h"
+#include
+
+// Configuration check
+#ifndef UDI_VENDOR_ENABLE_EXT
+# error UDI_VENDOR_ENABLE_EXT must be defined in conf_usb.h file.
+#endif
+#ifndef UDI_VENDOR_DISABLE_EXT
+# error UDI_VENDOR_DISABLE_EXT must be defined in conf_usb.h file.
+#endif
+
+/**
+ * \ingroup udi_vendor_group
+ * \defgroup udi_vendor_group_udc Interface with USB Device Core (UDC)
+ *
+ * Structures and functions required by UDC.
+ *
+ * @{
+ */
+bool udi_vendor_enable(void);
+void udi_vendor_disable(void);
+bool udi_vendor_setup(void);
+uint8_t udi_vendor_getsetting(void);
+
+//! Global structure which contains standard UDI API for UDC
+UDC_DESC_STORAGE udi_api_t udi_api_vendor = {
+ .enable = udi_vendor_enable,
+ .disable = udi_vendor_disable,
+ .setup = udi_vendor_setup,
+ .getsetting = udi_vendor_getsetting,
+ .sof_notify = NULL,
+};
+//@}
+
+
+/**
+ * \ingroup udi_vendor_group
+ * \defgroup udi_vendor_group_internal Implementation of UDI Vendor Class
+ *
+ * Class internal implementation
+ * @{
+ */
+
+//! USB descriptor alternate setting used
+static uint8_t udi_vendor_alternate_setting = 0;
+
+/**
+ * \name Internal routines
+ */
+//@{
+bool udi_vendor_enable(void)
+{
+ udi_vendor_alternate_setting = udc_get_interface_desc()->bAlternateSetting;
+ if (0 == udi_vendor_alternate_setting) {
+ // Call application callback
+ // to notify that interface is enabled
+ if (!UDI_VENDOR_ENABLE_EXT()) {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+void udi_vendor_disable(void)
+{
+ if (1 == udi_vendor_alternate_setting) {
+ UDI_VENDOR_DISABLE_EXT();
+ }
+}
+
+
+bool udi_vendor_setup(void)
+{
+ if (Udd_setup_is_in()) {
+ if ((Udd_setup_type() == USB_REQ_TYPE_VENDOR)
+ && (udd_g_ctrlreq.req.bRequest == 0)) {
+ return UDI_VENDOR_SETUP_IN_RECEIVED();
+ }
+ }
+ if (Udd_setup_is_out()) {
+ if ((Udd_setup_type() == USB_REQ_TYPE_VENDOR)
+ && (udd_g_ctrlreq.req.bRequest == 0)
+ && (0 != udd_g_ctrlreq.req.wLength)) {
+ return UDI_VENDOR_SETUP_OUT_RECEIVED();
+ }
+ }
+ return false; // Not supported request
+}
+
+uint8_t udi_vendor_getsetting(void)
+{
+ return udi_vendor_alternate_setting;
+}
+//@}
+
+#if UDI_VENDOR_EPS_SIZE_INT_FS
+/**
+ * \brief Start a transfer on interrupt IN
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_interrupt_in_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback)
+{
+ return udd_ep_run(UDI_VENDOR_EP_INTERRUPT_IN,
+ false,
+ buf,
+ buf_size,
+ callback);
+}
+
+
+/**
+ * \brief Start a transfer on interrupt OUT
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_interrupt_out_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback)
+{
+ return udd_ep_run(UDI_VENDOR_EP_INTERRUPT_OUT,
+ false,
+ buf,
+ buf_size,
+ callback);
+}
+#endif
+
+#if UDI_VENDOR_EPS_SIZE_BULK_FS
+/**
+ * \brief Start a transfer on bulk IN
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_bulk_in_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback)
+{
+ return udd_ep_run(UDI_VENDOR_EP_BULK_IN,
+ false,
+ buf,
+ buf_size,
+ callback);
+}
+
+
+/**
+ * \brief Start a transfer on bulk OUT
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_bulk_out_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback)
+{
+ return udd_ep_run(UDI_VENDOR_EP_BULK_OUT,
+ false,
+ buf,
+ buf_size,
+ callback);
+}
+#endif
+
+
+#if UDI_VENDOR_EPS_SIZE_ISO_FS
+/**
+ * \brief Start a transfer on interrupt IN
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_iso_in_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback)
+{
+ return udd_ep_run(UDI_VENDOR_EP_ISO_IN,
+ false,
+ buf,
+ buf_size,
+ callback);
+}
+
+/**
+ * \brief Start a transfer on interrupt OUT
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_iso_out_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback)
+{
+ return udd_ep_run(UDI_VENDOR_EP_ISO_OUT,
+ false,
+ buf,
+ buf_size,
+ callback);
+}
+#endif
+
+//@}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.c.REMOVED.git-id
deleted file mode 100644
index 8a4f14f0..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-bd1dfdd8a732702bca11fac24cc351736f189726
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.h
new file mode 100644
index 00000000..2aaaac5d
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.h
@@ -0,0 +1,687 @@
+/**
+ * \file
+ *
+ * \brief USB Vendor class interface definitions.
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _UDI_VENDOR_H_
+#define _UDI_VENDOR_H_
+
+#include "conf_usb.h"
+#include "usb_protocol.h"
+#include "usb_protocol_vendor.h"
+#include "udd.h"
+#include "udc_desc.h"
+#include "udi.h"
+#include "globals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Configuration Full Speed check
+#ifndef UDI_VENDOR_EPS_SIZE_INT_FS
+# error UDI_VENDOR_EPS_SIZE_INT_FS must be defined in conf_usb.h file.
+#endif
+#ifndef UDI_VENDOR_EPS_SIZE_BULK_FS
+# error UDI_VENDOR_EPS_SIZE_BULK_FS must be defined in conf_usb.h file.
+#endif
+#ifndef UDI_VENDOR_EPS_SIZE_ISO_FS
+# error UDI_VENDOR_EPS_SIZE_ISO_FS must be defined in conf_usb.h file.
+#endif
+
+// Configuration High Speed check
+#ifdef USB_DEVICE_HS_SUPPORT
+# ifndef UDI_VENDOR_EPS_SIZE_INT_HS
+# error UDI_VENDOR_EPS_SIZE_INT_HS must be defined in conf_usb.h file.
+# endif
+# ifndef UDI_VENDOR_EPS_SIZE_BULK_HS
+# error UDI_VENDOR_EPS_SIZE_BULK_HS must be defined in conf_usb.h file.
+# endif
+# ifndef UDI_VENDOR_EPS_SIZE_ISO_HS
+# error UDI_VENDOR_EPS_SIZE_ISO_HS must be defined in conf_usb.h file.
+# endif
+#endif
+
+/**
+ * \addtogroup udi_vendor_group_udc
+ * @{
+ */
+//! Global structure which contains standard UDI interface for UDC
+extern UDC_DESC_STORAGE udi_api_t udi_api_vendor;
+//@}
+
+/**
+ * \ingroup udi_vendor_group
+ * \defgroup udi_vendor_group_desc USB interface descriptors
+ *
+ * The following structures provide predefined USB interface descriptors.
+ * It must be used to define the final USB descriptors.
+ */
+//@{
+
+/**
+ * \name Endpoint descriptors
+ * @{
+ */
+#if UDI_VENDOR_EPS_SIZE_INT_FS
+# define UDI_VENDOR_EPS_INT_DESC \
+ .ep_interrupt_in.bLength = sizeof(usb_ep_desc_t),\
+ .ep_interrupt_in.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_interrupt_in.bEndpointAddress = UDI_VENDOR_EP_INTERRUPT_IN,\
+ .ep_interrupt_in.bmAttributes = USB_EP_TYPE_INTERRUPT,\
+ .ep_interrupt_in.bInterval = 1,\
+ .ep_interrupt_out.bLength = sizeof(usb_ep_desc_t),\
+ .ep_interrupt_out.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_interrupt_out.bEndpointAddress = UDI_VENDOR_EP_INTERRUPT_OUT,\
+ .ep_interrupt_out.bmAttributes = USB_EP_TYPE_INTERRUPT,\
+ .ep_interrupt_out.bInterval = 1,
+
+# define UDI_VENDOR_EPS_INT_DESC_FS \
+ .ep_interrupt_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_INT_FS),\
+ .ep_interrupt_out.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_INT_FS),
+
+# define UDI_VENDOR_EPS_INT_DESC_HS \
+ .ep_interrupt_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_INT_HS),\
+ .ep_interrupt_out.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_INT_HS),
+
+#else
+# define UDI_VENDOR_EPS_INT_DESC
+# define UDI_VENDOR_EPS_INT_DESC_FS
+# define UDI_VENDOR_EPS_INT_DESC_HS
+#endif
+
+#if UDI_VENDOR_EPS_SIZE_BULK_FS
+# define UDI_VENDOR_EPS_BULK_DESC \
+ .ep_bulk_in.bLength = sizeof(usb_ep_desc_t),\
+ .ep_bulk_in.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_bulk_in.bEndpointAddress = UDI_VENDOR_EP_BULK_IN,\
+ .ep_bulk_in.bmAttributes = USB_EP_TYPE_BULK,\
+ .ep_bulk_in.bInterval = 0,\
+ .ep_bulk_out.bLength = sizeof(usb_ep_desc_t),\
+ .ep_bulk_out.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_bulk_out.bEndpointAddress = UDI_VENDOR_EP_BULK_OUT,\
+ .ep_bulk_out.bmAttributes = USB_EP_TYPE_BULK,\
+ .ep_bulk_out.bInterval = 0,
+
+# define UDI_VENDOR_EPS_BULK_DESC_FS \
+ .ep_bulk_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_BULK_FS),\
+ .ep_bulk_out.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_BULK_FS),
+
+# define UDI_VENDOR_EPS_BULK_DESC_HS \
+ .ep_bulk_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_BULK_HS),\
+ .ep_bulk_out.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_BULK_HS),
+
+#else
+# define UDI_VENDOR_EPS_BULK_DESC
+# define UDI_VENDOR_EPS_BULK_DESC_FS
+# define UDI_VENDOR_EPS_BULK_DESC_HS
+#endif
+
+#ifndef SINGLE_ENDPOINT_INTERFACE
+
+ #if UDI_VENDOR_EPS_SIZE_ISO_FS
+ # define UDI_VENDOR_EPS_ISO_DESC \
+ .ep_iso_in.bLength = sizeof(usb_ep_desc_t),\
+ .ep_iso_in.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_iso_in.bEndpointAddress = UDI_VENDOR_EP_ISO_IN,\
+ .ep_iso_in.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ .ep_iso_in.bInterval = 1,\
+ .ep_iso_in2.bLength = sizeof(usb_ep_desc_t),\
+ .ep_iso_in2.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_iso_in2.bEndpointAddress = UDI_VENDOR_EP_ISO_IN + 1,\
+ .ep_iso_in2.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ .ep_iso_in2.bInterval = 1,\
+ .ep_iso_in3.bLength = sizeof(usb_ep_desc_t),\
+ .ep_iso_in3.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_iso_in3.bEndpointAddress = UDI_VENDOR_EP_ISO_IN + 2,\
+ .ep_iso_in3.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ .ep_iso_in3.bInterval = 1,\
+ .ep_iso_in4.bLength = sizeof(usb_ep_desc_t),\
+ .ep_iso_in4.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_iso_in4.bEndpointAddress = UDI_VENDOR_EP_ISO_IN + 3,\
+ .ep_iso_in4.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ .ep_iso_in4.bInterval = 1,\
+ .ep_iso_in5.bLength = sizeof(usb_ep_desc_t),\
+ .ep_iso_in5.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_iso_in5.bEndpointAddress = UDI_VENDOR_EP_ISO_IN + 4,\
+ .ep_iso_in5.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ .ep_iso_in5.bInterval = 1,\
+ .ep_iso_in6.bLength = sizeof(usb_ep_desc_t),\
+ .ep_iso_in6.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_iso_in6.bEndpointAddress = UDI_VENDOR_EP_ISO_IN + 5,\
+ .ep_iso_in6.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ .ep_iso_in6.bInterval = 1,
+
+ //.ep_iso_out.bLength = sizeof(usb_ep_desc_t),\
+ //.ep_iso_out.bDescriptorType = USB_DT_ENDPOINT,\
+ //.ep_iso_out.bEndpointAddress = UDI_VENDOR_EP_ISO_OUT,\
+ //.ep_iso_out.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ //.ep_iso_out.bInterval = 1,
+
+ # define UDI_VENDOR_EPS_ISO_DESC_FS \
+ .ep_iso_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),\
+ .ep_iso_in2.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),\
+ .ep_iso_in3.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),\
+ .ep_iso_in4.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),\
+ .ep_iso_in5.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),\
+ .ep_iso_in6.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),
+
+ //.ep_iso_out.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),
+
+ # define UDI_VENDOR_EPS_ISO_DESC_HS \
+ .ep_iso_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),\
+ .ep_iso_in2.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),\
+ .ep_iso_in3.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),\
+ .ep_iso_in4.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),\
+ .ep_iso_in5.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),\
+ .ep_iso_in6.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),
+ //.ep_iso_out.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),
+
+ #else
+ # define UDI_VENDOR_EPS_ISO_DESC
+ # define UDI_VENDOR_EPS_ISO_DESC_FS
+ # define UDI_VENDOR_EPS_ISO_DESC_HS
+ #endif
+ #else
+ # define UDI_VENDOR_EPS_ISO_DESC \
+ .ep_iso_in.bLength = sizeof(usb_ep_desc_t),\
+ .ep_iso_in.bDescriptorType = USB_DT_ENDPOINT,\
+ .ep_iso_in.bEndpointAddress = UDI_VENDOR_EP_ISO_IN,\
+ .ep_iso_in.bmAttributes = USB_EP_TYPE_ISOCHRONOUS,\
+ .ep_iso_in.bInterval = 1,
+
+ # define UDI_VENDOR_EPS_ISO_DESC_FS \
+ .ep_iso_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_FS),\
+
+ # define UDI_VENDOR_EPS_ISO_DESC_HS \
+ .ep_iso_in.wMaxPacketSize = LE16(UDI_VENDOR_EPS_SIZE_ISO_HS),\
+
+ #endif
+
+//@}
+
+//! Interface descriptor structure for vendor Class interface
+typedef struct {
+ //usb_iface_desc_t iface0;
+ usb_iface_desc_t iface1;
+#if UDI_VENDOR_EPS_SIZE_INT_FS
+ usb_ep_desc_t ep_interrupt_in;
+ usb_ep_desc_t ep_interrupt_out;
+#endif
+#if UDI_VENDOR_EPS_SIZE_BULK_FS
+ usb_ep_desc_t ep_bulk_in;
+ usb_ep_desc_t ep_bulk_out;
+#endif
+#if UDI_VENDOR_EPS_SIZE_ISO_FS
+ usb_ep_desc_t ep_iso_in;
+ #ifndef SINGLE_ENDPOINT_INTERFACE
+ usb_ep_desc_t ep_iso_in2;
+ usb_ep_desc_t ep_iso_in3;
+ usb_ep_desc_t ep_iso_in4;
+ usb_ep_desc_t ep_iso_in5;
+ usb_ep_desc_t ep_iso_in6;
+ #endif
+ //usb_ep_desc_t ep_iso_out;
+#endif
+} udi_vendor_desc_t;
+
+//! By default no string associated to this interface
+#ifndef UDI_VENDOR_STRING_ID
+#define UDI_VENDOR_STRING_ID 0
+#endif
+
+//! Maximum 6 endpoints used by vendor interface
+#define UDI_VENDOR_EP_NB_INT ((UDI_VENDOR_EPS_SIZE_INT_FS)?2:0)
+#define UDI_VENDOR_EP_NB_BULK ((UDI_VENDOR_EPS_SIZE_BULK_FS)?2:0)
+#ifdef SINGLE_ENDPOINT_INTERFACE
+ #define UDI_VENDOR_EP_NB_ISO ((UDI_VENDOR_EPS_SIZE_ISO_FS)?1:0) //Used to be 2:0, back when there were only two EPs!!
+#else
+ #define UDI_VENDOR_EP_NB_ISO ((UDI_VENDOR_EPS_SIZE_ISO_FS)?6:0) //Used to be 2:0, back when there were only two EPs!!
+#endif
+#define UDI_VENDOR_EP_NB (UDI_VENDOR_EP_NB_INT+UDI_VENDOR_EP_NB_BULK+UDI_VENDOR_EP_NB_ISO)
+
+
+//! Content of vendor interface descriptor for all speeds
+#define UDI_VENDOR_DESC \
+ /*.iface0.bLength = sizeof(usb_iface_desc_t),\
+ .iface0.bDescriptorType = USB_DT_INTERFACE,\
+ .iface0.bInterfaceNumber = UDI_VENDOR_IFACE_NUMBER,\
+ .iface0.bAlternateSetting = 0,\
+ .iface0.bNumEndpoints = 0,\
+ .iface0.bInterfaceClass = VENDOR_CLASS,\
+ .iface0.bInterfaceSubClass = VENDOR_SUBCLASS,\
+ .iface0.bInterfaceProtocol = VENDOR_PROTOCOL,\
+ .iface0.iInterface = UDI_VENDOR_STRING_ID,\
+ */.iface1.bLength = sizeof(usb_iface_desc_t),\
+ .iface1.bDescriptorType = USB_DT_INTERFACE,\
+ .iface1.bInterfaceNumber = UDI_VENDOR_IFACE_NUMBER,\
+ .iface1.bAlternateSetting = 0,\
+ .iface1.bNumEndpoints = UDI_VENDOR_EP_NB,\
+ .iface1.bInterfaceClass = VENDOR_CLASS,\
+ .iface1.bInterfaceSubClass = VENDOR_SUBCLASS,\
+ .iface1.bInterfaceProtocol = VENDOR_PROTOCOL,\
+ .iface1.iInterface = UDI_VENDOR_STRING_ID,\
+ UDI_VENDOR_EPS_INT_DESC \
+ UDI_VENDOR_EPS_BULK_DESC \
+ UDI_VENDOR_EPS_ISO_DESC \
+
+//! Content of vendor interface descriptor for full speed only
+#define UDI_VENDOR_DESC_FS {\
+ UDI_VENDOR_DESC \
+ UDI_VENDOR_EPS_INT_DESC_FS \
+ UDI_VENDOR_EPS_BULK_DESC_FS \
+ UDI_VENDOR_EPS_ISO_DESC_FS \
+ }
+
+//! Content of vendor interface descriptor for high speed only
+#define UDI_VENDOR_DESC_HS {\
+ UDI_VENDOR_DESC \
+ UDI_VENDOR_EPS_INT_DESC_HS \
+ UDI_VENDOR_EPS_BULK_DESC_HS \
+ UDI_VENDOR_EPS_ISO_DESC_HS \
+ }
+//@}
+
+
+/**
+ * \ingroup udi_group
+ * \defgroup udi_vendor_group USB Device Interface (UDI) for Vendor Class
+ *
+ * Common APIs used by high level application to use this USB class.
+ *
+ * These routines are used to transfer data to/from USB VENDOR endpoints.
+ *
+ * See \ref udi_vendor_quickstart.
+ * @{
+ */
+
+#if UDI_VENDOR_EPS_SIZE_INT_FS || defined(__DOXYGEN__)
+/**
+ * \brief Start a transfer on interrupt IN
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_interrupt_in_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback);
+
+/**
+ * \brief Start a transfer on interrupt OUT
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_interrupt_out_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback);
+#endif
+
+#if UDI_VENDOR_EPS_SIZE_BULK_FS || defined(__DOXYGEN__)
+/**
+ * \brief Start a transfer on bulk IN
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_bulk_in_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback);
+
+/**
+ * \brief Start a transfer on bulk OUT
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_bulk_out_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback);
+#endif
+
+
+#if UDI_VENDOR_EPS_SIZE_ISO_FS || defined(__DOXYGEN__)
+/**
+ * \brief Start a transfer on isochronous IN
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_iso_in_run(uint8_t * buf, iram_size_t buf_size, udd_callback_trans_t callback);
+
+/**
+ * \brief Start a transfer on isochronous OUT
+ *
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ *
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udi_vendor_iso_out_run(uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback);
+#endif
+
+//@}
+
+/**
+ * \page udi_vendor_quickstart Quick start guide for USB Device Vendor module (UDI Vendor)
+ *
+ * This is the quick start guide for the \ref udi_vendor_group
+ * "USB device interface Vendor module (UDI Vendor)" with step-by-step instructions on
+ * how to configure and use the modules in a selection of use cases.
+ *
+ * The use cases contain several code fragments. The code fragments in the
+ * steps for setup can be copied into a custom initialization function, while
+ * the steps for usage can be copied into, e.g., the main application function.
+ *
+ * Also, you can refer to application note
+ *
+ * AVR4901: ASF - USB Device Vendor Class Application.
+ *
+ * \section udi_vendor_basic_use_case Basic use case
+ * In this basic use case, the "USB Vendor (Single Interface Device)" module is used.
+ * The "USB Vendor (Composite Device)" module usage is described in \ref udi_vendor_use_cases
+ * "Advanced use cases".
+ *
+ * \section udi_vendor_basic_use_case_setup Setup steps
+ * \subsection udi_vendor_basic_use_case_setup_prereq Prerequisites
+ * \copydetails udc_basic_use_case_setup_prereq
+ * \subsection udi_vendor_basic_use_case_setup_code Example code
+ * \copydetails udc_basic_use_case_setup_code
+ * \subsection udi_vendor_basic_use_case_setup_flow Workflow
+ * \copydetails udc_basic_use_case_setup_flow
+ *
+ * \section udi_vendor_basic_use_case_usage Usage steps
+ *
+ * \subsection udi_vendor_basic_use_case_usage_code Example code
+ * Content of conf_usb.h:
+ * \code
+ * #define UDI_VENDOR_ENABLE_EXT() my_callback_vendor_enable()
+ * extern bool my_callback_vendor_enable(void);
+ * #define UDI_VENDOR_DISABLE_EXT() my_callback_vendor_disable()
+ * extern void my_callback_vendor_disable(void);
+ *
+ * #define UDI_VENDOR_SETUP_OUT_RECEIVED() my_vendor_setup_out_received()
+ * extern bool my_vendor_setup_out_received(void);
+ * #define UDI_VENDOR_SETUP_IN_RECEIVED() my_vendor_setup_in_received()
+ * extern bool my_vendor_setup_in_received(void);
+ *
+ * #define UDI_VENDOR_EPS_SIZE_INT_FS 64
+ * #define UDI_VENDOR_EPS_SIZE_BULK_FS 64
+ * #define UDI_VENDOR_EPS_SIZE_ISO_FS 256
+ * #define UDI_VENDOR_EPS_SIZE_INT_HS 64
+ * #define UDI_VENDOR_EPS_SIZE_BULK_HS 512
+ * #define UDI_VENDOR_EPS_SIZE_ISO_HS 64
+
+ * #include "udi_vendor_conf.h" // At the end of conf_usb.h file
+\endcode
+ *
+ * Add to application C-file:
+ * \code
+ static bool my_flag_autorize_vendor_transfert = false;
+ bool my_callback_vendor_enable(void)
+ {
+ my_flag_autorize_vendor_transfert = true;
+ return true;
+ }
+ void my_callback_vendor_disable(void)
+ {
+ my_flag_autorize_vendor_transfert = false;
+ }
+
+ uint8_t global_buffer[X];
+ void task(void)
+ {
+ if (my_flag_autorize_vendor_transfert) {
+ // Enable a transfer on OUT interrupt endpoint
+ udi_vendor_interrupt_out_run(
+ global_buffer,
+ sizeof(global_buffer),
+ NULL);
+ // Enable a transfer on IN interrupt endpoint
+ udi_vendor_interrupt_in_run(
+ global_buffer,
+ sizeof(global_buffer),
+ NULL);
+ ...
+ }
+ }
+\endcode
+ *
+ * \subsection udi_vendor_basic_use_case_setup_flow Workflow
+ * -# Ensure that conf_usb.h is available and contains the following configuration
+ * which is the USB device Vendor configuration:
+ * - \code #define UDI_VENDOR_ENABLE_EXT() my_callback_vendor_enable()
+ extern bool my_callback_vendor_enable(void); \endcode
+ * \note After the device enumeration (detecting and identifying USB devices),
+ * the USB host starts the device configuration. When the USB Vendor interface
+ * from the device is accepted by the host, the USB host enables this interface and the
+ * UDI_VENDOR_ENABLE_EXT() callback function is called and return true.
+ * Thus, when this event is received, the Vendor transfers can start.
+ * - \code #define UDI_VENDOR_DISABLE_EXT() my_callback_vendor_disable()
+ extern void my_callback_vendor_disable(void); \endcode
+ * \note When the USB device is unplugged or is reset by the USB host, the USB
+ * interface is disabled and the UDI_VENDOR_DISABLE_EXT() callback function
+ * is called. Thus, it is recommended to disable the data Vendor transfer.
+ * - \code #define UDI_VENDOR_SETUP_OUT_RECEIVED() my_vendor_setup_out_received()
+ extern bool my_vendor_setup_out_received(void);
+ #define UDI_VENDOR_SETUP_IN_RECEIVED() my_vendor_setup_in_received()
+ extern bool my_vendor_setup_in_received(void); \endcode
+ * \note The control requests for the interface Vendor will be processed
+ * through these both callbacks.
+ * - \code #define UDI_VENDOR_EPS_SIZE_INT_FS 64
+ #define UDI_VENDOR_EPS_SIZE_BULK_FS 64
+ #define UDI_VENDOR_EPS_SIZE_ISO_FS 256
+ #define UDI_VENDOR_EPS_SIZE_INT_HS 64
+ #define UDI_VENDOR_EPS_SIZE_BULK_HS 512
+ #define UDI_VENDOR_EPS_SIZE_ISO_HS 64 \endcode
+ * \note The endpoint size is defined by the final application, and can be
+ * disabled if the full speed size is zero.
+ * -# The Vendor transfers on interrupt, bulk and isochronous endpoints are
+ * done through these functions:
+ * - \code // Start a transfer on interrupt IN
+ udi_vendor_interrupt_in_run();
+ // Start a transfer on interrupt OUT
+ udi_vendor_interrupt_out_run();
+ // Start a transfer on bulk IN
+ udi_vendor_bulk_in_run();
+ // Start a transfer on bulk OUT
+ udi_vendor_bulk_out_run();
+ // Start a transfer on isochronous IN
+ udi_vendor_iso_in_run();
+ // Start a transfer on isochronous OUT
+ udi_vendor_iso_out_run(); \endcode
+ *
+ * \section udi_vendor_use_cases Advanced use cases
+ * For more advanced use of the UDI Vendor module, see the following use cases:
+ * - \subpage udi_vendor_use_case_composite
+ * - \subpage udc_use_case_1
+ * - \subpage udc_use_case_2
+ * - \subpage udc_use_case_3
+ * - \subpage udc_use_case_5
+ * - \subpage udc_use_case_6
+ */
+
+/**
+ * \page udi_vendor_use_case_composite Vendor in a composite device
+ *
+ * A USB Composite Device is a USB Device which uses more than one USB class.
+ * In this use case, the "USB Vendor (Composite Device)" module is used to
+ * create a USB composite device. Thus, this USB module can be associated with
+ * another "Composite Device" module, like "USB HID Mouse (Composite Device)".
+ *
+ * Also, you can refer to application note
+ *
+ * AVR4902 ASF - USB Composite Device.
+ *
+ * \section udi_vendor_use_case_composite_setup Setup steps
+ * For the setup code of this use case to work, the
+ * \ref udi_vendor_basic_use_case "basic use case" must be followed.
+ *
+ * \section udi_vendor_use_case_composite_usage Usage steps
+ *
+ * \subsection udi_vendor_use_case_composite_usage_code Example code
+ * Content of conf_usb.h:
+ * \code
+ #define USB_DEVICE_EP_CTRL_SIZE 64
+ #define USB_DEVICE_NB_INTERFACE (X+1)
+ #define USB_DEVICE_MAX_EP (X) to (X+6)
+
+ #define UDI_VENDOR_EP_INTERRUPT_IN (1 | USB_EP_DIR_IN)
+ #define UDI_VENDOR_EP_INTERRUPT_OUT (2 | USB_EP_DIR_OUT)
+ #define UDI_VENDOR_EP_BULK_IN (3 | USB_EP_DIR_IN)
+ #define UDI_VENDOR_EP_BULK_OUT (4 | USB_EP_DIR_OUT)
+ #define UDI_VENDOR_EP_ISO_IN (5 | USB_EP_DIR_IN)
+ #define UDI_VENDOR_EP_ISO_OUT (6 | USB_EP_DIR_OUT)
+
+ #define UDI_VENDOR_IFACE_NUMBER X
+
+ #define UDI_COMPOSITE_DESC_T \
+ udi_vendor_desc_t udi_vendor; \
+ ...
+ #define UDI_COMPOSITE_DESC_FS \
+ .udi_vendor = UDI_VENDOR_DESC, \
+ ...
+ #define UDI_COMPOSITE_DESC_HS \
+ .udi_vendor = UDI_VENDOR_DESC, \
+ ...
+ #define UDI_COMPOSITE_API \
+ &udi_api_vendor, \
+ ...
+\endcode
+ *
+ * \subsection udi_vendor_use_case_composite_usage_flow Workflow
+ * -# Ensure that conf_usb.h is available and contains the following parameters
+ * required for a USB composite device configuration:
+ * - \code // Endpoint control size, This must be:
+ // - 8, 16, 32 or 64 for full speed device (8 is recommended to save RAM)
+ // - 64 for a high speed device
+ #define USB_DEVICE_EP_CTRL_SIZE 64
+ // Total Number of interfaces on this USB device.
+ // Add 1 for Vendor.
+ #define USB_DEVICE_NB_INTERFACE (X+1)
+ // Total number of endpoints on this USB device.
+ // This must include each endpoint for each interface.
+ // Add 0 to 6 for Vendor interface.
+ // The number depends on UDI_VENDOR_EPS_SIZE_..._FS defines.
+ #define USB_DEVICE_MAX_EP (X) to (X+6) \endcode
+ * -# Ensure that conf_usb.h contains the description of
+ * composite device:
+ * - \code // The endpoint numbers chosen by you for the Vendor.
+ // The endpoint numbers starting from 1.
+ #define UDI_VENDOR_EP_INTERRUPT_IN (1 | USB_EP_DIR_IN)
+ #define UDI_VENDOR_EP_INTERRUPT_OUT (2 | USB_EP_DIR_OUT)
+ #define UDI_VENDOR_EP_BULK_IN (3 | USB_EP_DIR_IN)
+ #define UDI_VENDOR_EP_BULK_OUT (4 | USB_EP_DIR_OUT)
+ #define UDI_VENDOR_EP_ISO_IN (5 | USB_EP_DIR_IN)
+ #define UDI_VENDOR_EP_ISO_OUT (6 | USB_EP_DIR_OUT)
+ // The interface index of an interface starting from 0
+ #define UDI_VENDOR_IFACE_NUMBER X \endcode
+ * -# Ensure that conf_usb.h contains the following parameters
+ * required for a USB composite device configuration:
+ * - \code // USB Interfaces descriptor structure
+ #define UDI_COMPOSITE_DESC_T \
+ ...
+ udi_vendor_desc_t udi_vendor; \
+ ...
+ // USB Interfaces descriptor value for Full Speed
+ #define UDI_COMPOSITE_DESC_FS \
+ ...
+ .udi_vendor = UDI_VENDOR_DESC_FS, \
+ ...
+ // USB Interfaces descriptor value for High Speed
+ #define UDI_COMPOSITE_DESC_HS \
+ ...
+ .udi_vendor = UDI_VENDOR_DESC_HS, \
+ ...
+ // USB Interface APIs
+ #define UDI_COMPOSITE_API \
+ ...
+ &udi_api_vendor, \
+ ... \endcode
+ * - \note The descriptors order given in the four lists above must be the
+ * same as the order defined by all interface indexes. The interface index
+ * orders are defined through UDI_X_IFACE_NUMBER defines.
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _UDI_VENDOR_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.h.REMOVED.git-id
deleted file mode 100644
index a576d603..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2aaaac5d32de216c19d704aa822dbce60dbccc13
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_conf.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_conf.h
new file mode 100644
index 00000000..e2fef15a
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_conf.h
@@ -0,0 +1,123 @@
+/**
+ * \file
+ *
+ * \brief Default Vendor class configuration for a USB Device
+ * with a single interface
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _UDI_VENDOR_CONF_H_
+#define _UDI_VENDOR_CONF_H_
+
+#include "conf_usb.h"
+
+/**
+ * \addtogroup udi_vendor_group_single_desc
+ * @{
+ */
+
+//! Control endpoint size
+#define USB_DEVICE_EP_CTRL_SIZE 64
+
+//! Endpoint numbers used by vendor interface.
+//! Note: The order of endpoint can depend on USB hardware capability
+//! when a specific mapping is used on USB DPRAM.
+#if SAM3S || SAM4S || SAM4E
+# define UDI_VENDOR_EP_INTERRUPT_IN (3 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_INTERRUPT_OUT (6 | USB_EP_DIR_OUT)
+# define UDI_VENDOR_EP_BULK_IN (1 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_BULK_OUT (2 | USB_EP_DIR_OUT)
+# define UDI_VENDOR_EP_ISO_IN (4 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_ISO_OUT (5 | USB_EP_DIR_OUT)
+#elif SAM3U
+# define UDI_VENDOR_EP_INTERRUPT_IN (3 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_INTERRUPT_OUT (4 | USB_EP_DIR_OUT)
+# define UDI_VENDOR_EP_BULK_IN (1 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_BULK_OUT (2 | USB_EP_DIR_OUT)
+# define UDI_VENDOR_EP_ISO_IN (5 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_ISO_OUT (6 | USB_EP_DIR_OUT)
+#elif SAM3XA
+# define UDI_VENDOR_EP_INTERRUPT_IN (3 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_INTERRUPT_OUT (4 | USB_EP_DIR_OUT)
+# define UDI_VENDOR_EP_BULK_IN (5 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_BULK_OUT (6 | USB_EP_DIR_OUT)
+# define UDI_VENDOR_EP_ISO_IN (1 | USB_EP_DIR_IN)
+# define UDI_VENDOR_EP_ISO_OUT (2 | USB_EP_DIR_OUT)
+#elif SAMG55
+#define UDI_VENDOR_EP_INTERRUPT_IN (1 | USB_EP_DIR_IN)
+#define UDI_VENDOR_EP_INTERRUPT_OUT (2 | USB_EP_DIR_OUT)
+#define UDI_VENDOR_EP_BULK_IN (3 | USB_EP_DIR_IN)
+#define UDI_VENDOR_EP_BULK_OUT (4 | USB_EP_DIR_OUT)
+#else
+#define UDI_VENDOR_EP_INTERRUPT_IN (1 | USB_EP_DIR_IN)
+#define UDI_VENDOR_EP_INTERRUPT_OUT (2 | USB_EP_DIR_OUT)
+#define UDI_VENDOR_EP_BULK_IN ((((UDI_VENDOR_EPS_SIZE_INT_FS)?2:0)+1)\
+ | USB_EP_DIR_IN)
+#define UDI_VENDOR_EP_BULK_OUT ((((UDI_VENDOR_EPS_SIZE_INT_FS)?2:0)+2)\
+ | USB_EP_DIR_OUT)
+#define UDI_VENDOR_EP_ISO_IN ((((UDI_VENDOR_EPS_SIZE_INT_FS)?2:0)+ \
+ ((UDI_VENDOR_EPS_SIZE_BULK_FS)?2:0)+1)\
+ | USB_EP_DIR_IN)
+#define UDI_VENDOR_EP_ISO_OUT ((((UDI_VENDOR_EPS_SIZE_INT_FS)?2:0)+ \
+ ((UDI_VENDOR_EPS_SIZE_BULK_FS)?2:0)+2)\
+ | USB_EP_DIR_OUT)
+#endif
+
+//! Interface number is 0 because it is the unique interface
+#define UDI_VENDOR_IFACE_NUMBER 0
+
+/**
+ * \name UDD Configuration
+ */
+//@{
+//! Maximum 6 endpoints used by vendor interface
+#define UDI_VENDOR_EP_NB_INT ((UDI_VENDOR_EPS_SIZE_INT_FS)?2:0)
+#define UDI_VENDOR_EP_NB_BULK ((UDI_VENDOR_EPS_SIZE_BULK_FS)?2:0)
+#define UDI_VENDOR_EP_NB_ISO ((UDI_VENDOR_EPS_SIZE_ISO_FS)?2:0)
+#define USB_DEVICE_MAX_EP (UDI_VENDOR_EP_NB_INT+UDI_VENDOR_EP_NB_BULK+UDI_VENDOR_EP_NB_ISO)
+//@}
+
+//@}
+
+#include "udi_vendor.h"
+
+#endif // _UDI_VENDOR_CONF_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_conf.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_conf.h.REMOVED.git-id
deleted file mode 100644
index e9dadc8c..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_conf.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e2fef15a41dd54b700f22ad9afb78714fed317e9
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c
new file mode 100644
index 00000000..ae0cc47d
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c
@@ -0,0 +1,190 @@
+/**
+ * \file
+ *
+ * \brief Default descriptors for a USB Device with a single vendor class
+ * interface
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "conf_usb.h"
+#include "udd.h"
+#include "udc_desc.h"
+#include "udi_vendor.h"
+
+
+/**
+ * \defgroup udi_vendor_group_single_desc USB device descriptors for a single interface
+ *
+ * The following structures provide the USB device descriptors required for
+ * USB Device with a single interface Vendor Class.
+ *
+ * It is ready to use and do not require more definition.
+ * @{
+ */
+
+//! Only one interface for this device
+#define USB_DEVICE_NB_INTERFACE 1
+
+//! USB Device Descriptor
+UDC_DATA(4)
+UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
+ .bLength = sizeof(usb_dev_desc_t),
+ .bDescriptorType = USB_DT_DEVICE,
+ .bcdUSB = LE16(USB_V2_0),
+ .bDeviceClass = 0,
+ .bDeviceSubClass = 0,
+ .bDeviceProtocol = 0,
+ .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
+ .idVendor = LE16(USB_DEVICE_VENDOR_ID),
+ .idProduct = LE16(USB_DEVICE_PRODUCT_ID),
+ .bcdDevice = LE16((USB_DEVICE_MAJOR_VERSION << 8)
+ | USB_DEVICE_MINOR_VERSION),
+#ifdef USB_DEVICE_MANUFACTURE_NAME
+ .iManufacturer = 1,
+#else
+ .iManufacturer = 0, // No manufacture string
+#endif
+#ifdef USB_DEVICE_PRODUCT_NAME
+ .iProduct = 2,
+#else
+ .iProduct = 0, // No product string
+#endif
+#ifdef USB_DEVICE_SERIAL_NAME
+ .iSerialNumber = 3,
+#else
+ .iSerialNumber = 0, // No serial string
+#endif
+ .bNumConfigurations = 1
+};
+
+
+#ifdef USB_DEVICE_HS_SUPPORT
+//! USB Device Qualifier Descriptor for HS
+UDC_DATA(4)
+UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
+ .bLength = sizeof(usb_dev_qual_desc_t),
+ .bDescriptorType = USB_DT_DEVICE_QUALIFIER,
+ .bcdUSB = LE16(USB_V2_0),
+ .bDeviceClass = 0,
+ .bDeviceSubClass = 0,
+ .bDeviceProtocol = 0,
+ .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
+ .bNumConfigurations = 1
+};
+#endif
+
+//! Structure for USB Device Configuration Descriptor
+COMPILER_PACK_SET(1)
+typedef struct {
+ usb_conf_desc_t conf;
+ udi_vendor_desc_t udi_vendor;
+} udc_desc_t;
+COMPILER_PACK_RESET()
+
+//! USB Device Configuration Descriptor filled for FS
+UDC_DATA(4)
+UDC_DESC_STORAGE udc_desc_t udc_desc_fs = {
+ .conf.bLength = sizeof(usb_conf_desc_t),
+ .conf.bDescriptorType = USB_DT_CONFIGURATION,
+ .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
+ .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE,
+ .conf.bConfigurationValue = 1,
+ .conf.iConfiguration = 0,
+ .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
+ .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
+ .udi_vendor = UDI_VENDOR_DESC_FS,
+};
+
+#ifdef USB_DEVICE_HS_SUPPORT
+//! USB Device Configuration Descriptor filled for HS
+UDC_DATA(4)
+UDC_DESC_STORAGE udc_desc_t udc_desc_hs = {
+ .conf.bLength = sizeof(usb_conf_desc_t),
+ .conf.bDescriptorType = USB_DT_CONFIGURATION,
+ .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
+ .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE,
+ .conf.bConfigurationValue = 1,
+ .conf.iConfiguration = 0,
+ .conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
+ .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
+ .udi_vendor = UDI_VENDOR_DESC_HS,
+};
+#endif
+
+
+/**
+ * \name UDC structures which contains all USB Device definitions
+ */
+//@{
+
+//! Associate an UDI for each USB interface
+UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
+ &udi_api_vendor,
+};
+
+//! Add UDI with USB Descriptors FS
+UDC_DESC_STORAGE udc_config_speed_t udc_config_lsfs[1] = {{
+ .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_fs,
+ .udi_apis = udi_apis,
+}};
+
+#ifdef USB_DEVICE_HS_SUPPORT
+//! Add UDI with USB Descriptors HS
+UDC_DESC_STORAGE udc_config_speed_t udc_config_hs[1] = {{
+ .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_hs,
+ .udi_apis = udi_apis,
+}};
+#endif
+
+//! Add all information about USB Device in global structure for UDC
+UDC_DESC_STORAGE udc_config_t udc_config = {
+ .confdev_lsfs = &udc_device_desc,
+ .conf_lsfs = udc_config_lsfs,
+#ifdef USB_DEVICE_HS_SUPPORT
+ .confdev_hs = &udc_device_desc,
+ .qualifier = &udc_device_qual,
+ .conf_hs = udc_config_hs,
+#endif
+};
+
+//@}
+//@}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c.REMOVED.git-id
deleted file mode 100644
index fdee5321..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/device/udi_vendor_desc.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae0cc47dbb2e39a2716fb79cc891c859cd27e54d
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/usb_protocol_vendor.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/usb_protocol_vendor.h
new file mode 100644
index 00000000..5a2df8bc
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/usb_protocol_vendor.h
@@ -0,0 +1,69 @@
+/**
+ * \file
+ *
+ * \brief USB Vendor class protocol definitions.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _USB_PROTOCOL_VENDOR_H_
+#define _USB_PROTOCOL_VENDOR_H_
+
+/**
+ * \ingroup usb_protocol_group
+ * \defgroup usb_vendor_protocol USB Vendor Class definitions
+ *
+ * @{
+ */
+
+/**
+ * \name Vendor class values
+ */
+//@{
+#define VENDOR_CLASS 0xFF
+#define VENDOR_SUBCLASS 0xFF
+#define VENDOR_PROTOCOL 0xFF
+//@}
+
+
+//@}
+
+#endif // _USB_PROTOCOL_VENDOR_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/usb_protocol_vendor.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/usb_protocol_vendor.h.REMOVED.git-id
deleted file mode 100644
index 5b8f6522..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/class/vendor/usb_protocol_vendor.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5a2df8bc08fc3f43624a6509b55e966415c901ec
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c
new file mode 100644
index 00000000..ea6e7ad4
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c
@@ -0,0 +1,1276 @@
+/**
+ * \file
+ *
+ * \brief USB Device Controller (UDC)
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include
+
+#include "conf_usb.h"
+#include "usb_protocol.h"
+#include "udd.h"
+#include "udc_desc.h"
+#include "udi.h"
+#include "udc.h"
+
+#include "globals.h"
+#include "tiny_dma.h"
+#include "tiny_adc.h"
+#include "tiny_calibration.h"
+#include "tiny_eeprom.h"
+/**
+ * \ingroup udc_group
+ * \defgroup udc_group_interne Implementation of UDC
+ *
+ * Internal implementation
+ * @{
+ */
+
+//! \name Internal variables to manage the USB device
+//! @{
+
+//! Device status state (see enum usb_device_status in usb_protocol.h)
+static le16_t udc_device_status;
+
+COMPILER_WORD_ALIGNED
+//! Device interface setting value
+static uint8_t udc_iface_setting = 0;
+
+//! Device Configuration number selected by the USB host
+COMPILER_WORD_ALIGNED
+static uint8_t udc_num_configuration = 0;
+
+//! Pointer on the selected speed device configuration
+static udc_config_speed_t UDC_DESC_STORAGE *udc_ptr_conf;
+
+//! Pointer on interface descriptor used by SETUP request.
+static usb_iface_desc_t UDC_DESC_STORAGE *udc_ptr_iface;
+
+//! @}
+
+
+//! \name Internal structure to store the USB device main strings
+//! @{
+
+/**
+ * \brief Language ID of USB device (US ID by default)
+ */
+COMPILER_WORD_ALIGNED
+static UDC_DESC_STORAGE usb_str_lgid_desc_t udc_string_desc_languageid = {
+ .desc.bLength = sizeof(usb_str_lgid_desc_t),
+ .desc.bDescriptorType = USB_DT_STRING,
+ .string = {LE16(USB_LANGID_EN_US)}
+};
+
+/**
+ * \brief USB device manufacture name storage
+ * String is allocated only if USB_DEVICE_MANUFACTURE_NAME is declared
+ * by usb application configuration
+ */
+#ifdef USB_DEVICE_MANUFACTURE_NAME
+static uint8_t udc_string_manufacturer_name[] = USB_DEVICE_MANUFACTURE_NAME;
+# define USB_DEVICE_MANUFACTURE_NAME_SIZE \
+ (sizeof(udc_string_manufacturer_name)-1)
+#else
+# define USB_DEVICE_MANUFACTURE_NAME_SIZE 0
+#endif
+
+/**
+ * \brief USB device product name storage
+ * String is allocated only if USB_DEVICE_PRODUCT_NAME is declared
+ * by usb application configuration
+ */
+#ifdef USB_DEVICE_PRODUCT_NAME
+static uint8_t udc_string_product_name[] = USB_DEVICE_PRODUCT_NAME;
+# define USB_DEVICE_PRODUCT_NAME_SIZE (sizeof(udc_string_product_name)-1)
+#else
+# define USB_DEVICE_PRODUCT_NAME_SIZE 0
+#endif
+
+/**
+ * \brief Get USB device serial number
+ *
+ * Use the define USB_DEVICE_SERIAL_NAME to set static serial number.
+ *
+ * For dynamic serial number set the define USB_DEVICE_GET_SERIAL_NAME_POINTER
+ * to a suitable pointer. This will also require the serial number length
+ * define USB_DEVICE_GET_SERIAL_NAME_LENGTH.
+ */
+#if defined USB_DEVICE_GET_SERIAL_NAME_POINTER
+ static const uint8_t *udc_get_string_serial_name(void)
+ {
+ return (const uint8_t *)USB_DEVICE_GET_SERIAL_NAME_POINTER;
+ }
+# define USB_DEVICE_SERIAL_NAME_SIZE \
+ USB_DEVICE_GET_SERIAL_NAME_LENGTH
+#elif defined USB_DEVICE_SERIAL_NAME
+ static const uint8_t *udc_get_string_serial_name(void)
+ {
+ return (const uint8_t *)USB_DEVICE_SERIAL_NAME;
+ }
+# define USB_DEVICE_SERIAL_NAME_SIZE \
+ (sizeof(USB_DEVICE_SERIAL_NAME)-1)
+#else
+# define USB_DEVICE_SERIAL_NAME_SIZE 0
+#endif
+
+/**
+ * \brief USB device string descriptor
+ * Structure used to transfer ASCII strings to USB String descriptor structure.
+ */
+struct udc_string_desc_t {
+ usb_str_desc_t header;
+ le16_t string[Max(Max(USB_DEVICE_MANUFACTURE_NAME_SIZE, \
+ USB_DEVICE_PRODUCT_NAME_SIZE), USB_DEVICE_SERIAL_NAME_SIZE)];
+};
+COMPILER_WORD_ALIGNED
+static UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc = {
+ .header.bDescriptorType = USB_DT_STRING
+};
+//! @}
+
+usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void)
+{
+ return udc_ptr_iface;
+}
+
+/**
+ * \brief Returns a value to check the end of USB Configuration descriptor
+ *
+ * \return address after the last byte of USB Configuration descriptor
+ */
+static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void)
+{
+ return (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *)
+ udc_ptr_conf->desc +
+ le16_to_cpu(udc_ptr_conf->desc->wTotalLength));
+}
+
+#if (0!=USB_DEVICE_MAX_EP)
+/**
+ * \brief Search specific descriptor in global interface descriptor
+ *
+ * \param desc Address of interface descriptor
+ * or previous specific descriptor found
+ * \param desc_id Descriptor ID to search
+ *
+ * \return address of specific descriptor found
+ * \return NULL if it is the end of global interface descriptor
+ */
+static usb_conf_desc_t UDC_DESC_STORAGE *udc_next_desc_in_iface(usb_conf_desc_t
+ UDC_DESC_STORAGE * desc, uint8_t desc_id)
+{
+ usb_conf_desc_t UDC_DESC_STORAGE *ptr_eof_desc;
+
+ ptr_eof_desc = udc_get_eof_conf();
+ // Go to next descriptor
+ desc = (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) desc +
+ desc->bLength);
+ // Check the end of configuration descriptor
+ while (ptr_eof_desc > desc) {
+ // If new interface descriptor is found,
+ // then it is the end of the current global interface descriptor
+ if (USB_DT_INTERFACE == desc->bDescriptorType) {
+ break; // End of global interface descriptor
+ }
+ if (desc_id == desc->bDescriptorType) {
+ return desc; // Specific descriptor found
+ }
+ // Go to next descriptor
+ desc = (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) desc +
+ desc->bLength);
+ }
+ return NULL; // No specific descriptor found
+}
+#endif
+
+/**
+ * \brief Search an interface descriptor
+ * This routine updates the internal pointer udc_ptr_iface.
+ *
+ * \param iface_num Interface number to find in Configuration Descriptor
+ * \param setting_num Setting number of interface to find
+ *
+ * \return 1 if found or 0 if not found
+ */
+static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num)
+{
+ usb_conf_desc_t UDC_DESC_STORAGE *ptr_end_desc;
+
+ if (0 == udc_num_configuration) {
+ return false;
+ }
+
+ if (iface_num >= udc_ptr_conf->desc->bNumInterfaces) {
+ return false;
+ }
+
+ // Start at the beginning of configuration descriptor
+ udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *)
+ udc_ptr_conf->desc;
+
+ // Check the end of configuration descriptor
+ ptr_end_desc = udc_get_eof_conf();
+ while (ptr_end_desc >
+ (UDC_DESC_STORAGE usb_conf_desc_t *) udc_ptr_iface) {
+ if (USB_DT_INTERFACE == udc_ptr_iface->bDescriptorType) {
+ // A interface descriptor is found
+ // Check interface and alternate setting number
+ if ((iface_num == udc_ptr_iface->bInterfaceNumber) &&
+ (setting_num ==
+ udc_ptr_iface->bAlternateSetting)) {
+ return true; // Interface found
+ }
+ }
+ // Go to next descriptor
+ udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *) (
+ (uint8_t *) udc_ptr_iface +
+ udc_ptr_iface->bLength);
+ }
+ return false; // Interface not found
+}
+
+/**
+ * \brief Disables an usb device interface (UDI)
+ * This routine call the UDI corresponding to interface number
+ *
+ * \param iface_num Interface number to disable
+ *
+ * \return 1 if it is done or 0 if interface is not found
+ */
+static bool udc_iface_disable(uint8_t iface_num)
+{
+ udi_api_t UDC_DESC_STORAGE *udi_api;
+
+ // Select first alternate setting of the interface
+ // to update udc_ptr_iface before call iface->getsetting()
+ if (!udc_update_iface_desc(iface_num, 0)) {
+ return false;
+ }
+
+ // Select the interface with the current alternate setting
+ udi_api = udc_ptr_conf->udi_apis[iface_num];
+
+#if (0!=USB_DEVICE_MAX_EP)
+ if (!udc_update_iface_desc(iface_num, udi_api->getsetting())) {
+ return false;
+ }
+
+ // Start at the beginning of interface descriptor
+ {
+ usb_ep_desc_t UDC_DESC_STORAGE *ep_desc;
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) udc_ptr_iface;
+ while (1) {
+ // Search Endpoint descriptor included in global interface descriptor
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)
+ udc_next_desc_in_iface((UDC_DESC_STORAGE
+ usb_conf_desc_t *)
+ ep_desc, USB_DT_ENDPOINT);
+ if (NULL == ep_desc) {
+ break;
+ }
+ // Free the endpoint used by the interface
+ udd_ep_free(ep_desc->bEndpointAddress);
+ }
+ }
+#endif
+
+ // Disable interface
+ udi_api->disable();
+ return true;
+}
+
+/**
+ * \brief Enables an usb device interface (UDI)
+ * This routine calls the UDI corresponding
+ * to the interface and setting number.
+ *
+ * \param iface_num Interface number to enable
+ * \param setting_num Setting number to enable
+ *
+ * \return 1 if it is done or 0 if interface is not found
+ */
+static bool udc_iface_enable(uint8_t iface_num, uint8_t setting_num)
+{
+ // Select the interface descriptor
+ if (!udc_update_iface_desc(iface_num, setting_num)) {
+ return false;
+ }
+
+#if (0!=USB_DEVICE_MAX_EP)
+ usb_ep_desc_t UDC_DESC_STORAGE *ep_desc;
+
+ // Start at the beginning of the global interface descriptor
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) udc_ptr_iface;
+ while (1) {
+ // Search Endpoint descriptor included in the global interface descriptor
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)
+ udc_next_desc_in_iface((UDC_DESC_STORAGE
+ usb_conf_desc_t *) ep_desc,
+ USB_DT_ENDPOINT);
+ if (NULL == ep_desc)
+ break;
+ // Alloc the endpoint used by the interface
+ if (!udd_ep_alloc(ep_desc->bEndpointAddress,
+ ep_desc->bmAttributes,
+ le16_to_cpu
+ (ep_desc->wMaxPacketSize))) {
+ return false;
+ }
+ }
+#endif
+ // Enable the interface
+ return udc_ptr_conf->udi_apis[iface_num]->enable();
+}
+
+/*! \brief Start the USB Device stack
+ */
+void udc_start(void)
+{
+ udd_enable();
+}
+
+/*! \brief Stop the USB Device stack
+ */
+void udc_stop(void)
+{
+ udd_disable();
+ udc_reset();
+}
+
+/**
+ * \brief Reset the current configuration of the USB device,
+ * This routines can be called by UDD when a RESET on the USB line occurs.
+ */
+void udc_reset(void)
+{
+ uint8_t iface_num;
+
+ if (udc_num_configuration) {
+ for (iface_num = 0;
+ iface_num < udc_ptr_conf->desc->bNumInterfaces;
+ iface_num++) {
+ udc_iface_disable(iface_num);
+ }
+ }
+ udc_num_configuration = 0;
+#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \
+ == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
+ if (CPU_TO_LE16(USB_DEV_STATUS_REMOTEWAKEUP) & udc_device_status) {
+ // Remote wakeup is enabled then disable it
+ UDC_REMOTEWAKEUP_DISABLE();
+ }
+#endif
+ udc_device_status =
+#if (USB_DEVICE_ATTR & USB_CONFIG_ATTR_SELF_POWERED)
+ CPU_TO_LE16(USB_DEV_STATUS_SELF_POWERED);
+#else
+ CPU_TO_LE16(USB_DEV_STATUS_BUS_POWERED);
+#endif
+}
+
+void udc_sof_notify(void)
+{
+ uint8_t iface_num;
+
+ if (udc_num_configuration) {
+ for (iface_num = 0;
+ iface_num < udc_ptr_conf->desc->bNumInterfaces;
+ iface_num++) {
+ if (udc_ptr_conf->udi_apis[iface_num]->sof_notify != NULL) {
+ udc_ptr_conf->udi_apis[iface_num]->sof_notify();
+ }
+ }
+ }
+}
+
+/**
+ * \brief Standard device request to get device status
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_get_status(void)
+{
+ if (udd_g_ctrlreq.req.wLength != sizeof(udc_device_status)) {
+ return false;
+ }
+
+ udd_set_setup_payload( (uint8_t *) & udc_device_status,
+ sizeof(udc_device_status));
+ return true;
+}
+
+#if (0!=USB_DEVICE_MAX_EP)
+/**
+ * \brief Standard endpoint request to get endpoint status
+ *
+ * \return true if success
+ */
+static bool udc_req_std_ep_get_status(void)
+{
+ static le16_t udc_ep_status;
+
+ if (udd_g_ctrlreq.req.wLength != sizeof(udc_ep_status)) {
+ return false;
+ }
+
+ udc_ep_status = udd_ep_is_halted(udd_g_ctrlreq.req.
+ wIndex & 0xFF) ? CPU_TO_LE16(USB_EP_STATUS_HALTED) : 0;
+
+ udd_set_setup_payload( (uint8_t *) & udc_ep_status,
+ sizeof(udc_ep_status));
+ return true;
+}
+#endif
+
+/**
+ * \brief Standard device request to change device status
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_clear_feature(void)
+{
+ if (udd_g_ctrlreq.req.wLength) {
+ return false;
+ }
+
+ if (udd_g_ctrlreq.req.wValue == USB_DEV_FEATURE_REMOTE_WAKEUP) {
+ udc_device_status &= CPU_TO_LE16(~(uint32_t)USB_DEV_STATUS_REMOTEWAKEUP);
+#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \
+ == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
+ UDC_REMOTEWAKEUP_DISABLE();
+#endif
+ return true;
+ }
+ return false;
+}
+
+#if (0!=USB_DEVICE_MAX_EP)
+/**
+ * \brief Standard endpoint request to clear endpoint feature
+ *
+ * \return true if success
+ */
+static bool udc_req_std_ep_clear_feature(void)
+{
+ if (udd_g_ctrlreq.req.wLength) {
+ return false;
+ }
+
+ if (udd_g_ctrlreq.req.wValue == USB_EP_FEATURE_HALT) {
+ return udd_ep_clear_halt(udd_g_ctrlreq.req.wIndex & 0xFF);
+ }
+ return false;
+}
+#endif
+
+/**
+ * \brief Standard device request to set a feature
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_set_feature(void)
+{
+ if (udd_g_ctrlreq.req.wLength) {
+ return false;
+ }
+
+ switch (udd_g_ctrlreq.req.wValue) {
+
+ case USB_DEV_FEATURE_REMOTE_WAKEUP:
+#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \
+ == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
+ udc_device_status |= CPU_TO_LE16(USB_DEV_STATUS_REMOTEWAKEUP);
+ UDC_REMOTEWAKEUP_ENABLE();
+ return true;
+#else
+ return false;
+#endif
+
+#ifdef USB_DEVICE_HS_SUPPORT
+ case USB_DEV_FEATURE_TEST_MODE:
+ if (!udd_is_high_speed()) {
+ break;
+ }
+ if (udd_g_ctrlreq.req.wIndex & 0xff) {
+ break;
+ }
+ // Unconfigure the device, terminating all ongoing requests
+ udc_reset();
+ switch ((udd_g_ctrlreq.req.wIndex >> 8) & 0xFF) {
+ case USB_DEV_TEST_MODE_J:
+ udd_g_ctrlreq.callback = udd_test_mode_j;
+ return true;
+
+ case USB_DEV_TEST_MODE_K:
+ udd_g_ctrlreq.callback = udd_test_mode_k;
+ return true;
+
+ case USB_DEV_TEST_MODE_SE0_NAK:
+ udd_g_ctrlreq.callback = udd_test_mode_se0_nak;
+ return true;
+
+ case USB_DEV_TEST_MODE_PACKET:
+ udd_g_ctrlreq.callback = udd_test_mode_packet;
+ return true;
+
+ case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports
+ default:
+ break;
+ }
+ break;
+#endif
+ default:
+ break;
+ }
+ return false;
+}
+
+/**
+ * \brief Standard endpoint request to halt an endpoint
+ *
+ * \return true if success
+ */
+#if (0!=USB_DEVICE_MAX_EP)
+static bool udc_req_std_ep_set_feature(void)
+{
+ if (udd_g_ctrlreq.req.wLength) {
+ return false;
+ }
+ if (udd_g_ctrlreq.req.wValue == USB_EP_FEATURE_HALT) {
+ udd_ep_abort(udd_g_ctrlreq.req.wIndex & 0xFF);
+ return udd_ep_set_halt(udd_g_ctrlreq.req.wIndex & 0xFF);
+ }
+ return false;
+}
+#endif
+
+/**
+ * \brief Change the address of device
+ * Callback called at the end of request set address
+ */
+static void udc_valid_address(void)
+{
+ udd_set_address(udd_g_ctrlreq.req.wValue & 0x7F);
+}
+
+/**
+ * \brief Standard device request to set device address
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_set_address(void)
+{
+ if (udd_g_ctrlreq.req.wLength) {
+ return false;
+ }
+
+ // The address must be changed at the end of setup request after the handshake
+ // then we use a callback to change address
+ udd_g_ctrlreq.callback = udc_valid_address;
+ return true;
+}
+
+/**
+ * \brief Standard device request to get device string descriptor
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_get_str_desc(void)
+{
+ uint8_t i;
+ const uint8_t *str;
+ uint8_t str_length = 0;
+
+ // Link payload pointer to the string corresponding at request
+ switch (udd_g_ctrlreq.req.wValue & 0xff) {
+ case 0:
+ udd_set_setup_payload((uint8_t *) &udc_string_desc_languageid,
+ sizeof(udc_string_desc_languageid));
+ break;
+
+#ifdef USB_DEVICE_MANUFACTURE_NAME
+ case 1:
+ str_length = USB_DEVICE_MANUFACTURE_NAME_SIZE;
+ str = udc_string_manufacturer_name;
+ break;
+#endif
+#ifdef USB_DEVICE_PRODUCT_NAME
+ case 2:
+ str_length = USB_DEVICE_PRODUCT_NAME_SIZE;
+ str = udc_string_product_name;
+ break;
+#endif
+#if defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER
+ case 3:
+ str_length = USB_DEVICE_SERIAL_NAME_SIZE;
+ str = udc_get_string_serial_name();
+ break;
+#endif
+ default:
+#ifdef UDC_GET_EXTRA_STRING
+ if (UDC_GET_EXTRA_STRING()) {
+ break;
+ }
+#endif
+ return false;
+ }
+
+ if (str_length) {
+ for(i = 0; i < str_length; i++) {
+ udc_string_desc.string[i] = cpu_to_le16((le16_t)str[i]);
+ }
+
+ udc_string_desc.header.bLength = 2 + (str_length) * 2;
+ udd_set_setup_payload(
+ (uint8_t *) &udc_string_desc,
+ udc_string_desc.header.bLength);
+ }
+
+ return true;
+}
+
+/**
+ * \brief Standard device request to get descriptors about USB device
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_get_descriptor(void)
+{
+ uint8_t conf_num;
+
+ conf_num = udd_g_ctrlreq.req.wValue & 0xff;
+
+ // Check descriptor ID
+ switch ((uint8_t) (udd_g_ctrlreq.req.wValue >> 8)) {
+ case USB_DT_DEVICE:
+ // Device descriptor requested
+#ifdef USB_DEVICE_HS_SUPPORT
+ if (!udd_is_high_speed()) {
+ udd_set_setup_payload(
+ (uint8_t *) udc_config.confdev_hs,
+ udc_config.confdev_hs->bLength);
+ } else
+#endif
+ {
+ udd_set_setup_payload(
+ (uint8_t *) udc_config.confdev_lsfs,
+ udc_config.confdev_lsfs->bLength);
+ }
+ break;
+
+ case USB_DT_CONFIGURATION:
+ // Configuration descriptor requested
+#ifdef USB_DEVICE_HS_SUPPORT
+ if (udd_is_high_speed()) {
+ // HS descriptor
+ if (conf_num >= udc_config.confdev_hs->
+ bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload(
+ (uint8_t *)udc_config.conf_hs[conf_num].desc,
+ le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength));
+ } else
+#endif
+ {
+ // FS descriptor
+ if (conf_num >= udc_config.confdev_lsfs->
+ bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload(
+ (uint8_t *)udc_config.conf_lsfs[conf_num].desc,
+ le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength));
+ }
+ ((usb_conf_desc_t *) udd_g_ctrlreq.payload)->bDescriptorType =
+ USB_DT_CONFIGURATION;
+ break;
+
+#ifdef USB_DEVICE_HS_SUPPORT
+ case USB_DT_DEVICE_QUALIFIER:
+ // Device qualifier descriptor requested
+ udd_set_setup_payload( (uint8_t *) udc_config.qualifier,
+ udc_config.qualifier->bLength);
+ break;
+
+ case USB_DT_OTHER_SPEED_CONFIGURATION:
+ // Other configuration descriptor requested
+ if (!udd_is_high_speed()) {
+ // HS descriptor
+ if (conf_num >= udc_config.confdev_hs->
+ bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload(
+ (uint8_t *)udc_config.conf_hs[conf_num].desc,
+ le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength));
+ } else {
+ // FS descriptor
+ if (conf_num >= udc_config.confdev_lsfs->
+ bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload(
+ (uint8_t *)udc_config.conf_lsfs[conf_num].desc,
+ le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength));
+ }
+ ((usb_conf_desc_t *) udd_g_ctrlreq.payload)->bDescriptorType =
+ USB_DT_OTHER_SPEED_CONFIGURATION;
+ break;
+#endif
+
+ case USB_DT_BOS:
+ // Device BOS descriptor requested
+ if (udc_config.conf_bos == NULL) {
+ return false;
+ }
+ udd_set_setup_payload( (uint8_t *) udc_config.conf_bos,
+ udc_config.conf_bos->wTotalLength);
+ break;
+
+ case USB_DT_STRING:
+ // String descriptor requested
+ if (!udc_req_std_dev_get_str_desc()) {
+ return false;
+ }
+ break;
+
+ default:
+ // Unknown descriptor requested
+ return false;
+ }
+ // if the descriptor is larger than length requested, then reduce it
+ if (udd_g_ctrlreq.req.wLength < udd_g_ctrlreq.payload_size) {
+ udd_g_ctrlreq.payload_size = udd_g_ctrlreq.req.wLength;
+ }
+ return true;
+}
+
+/**
+ * \brief Standard device request to get configuration number
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_get_configuration(void)
+{
+ if (udd_g_ctrlreq.req.wLength != 1) {
+ return false;
+ }
+
+ udd_set_setup_payload(&udc_num_configuration,1);
+ return true;
+}
+
+/**
+ * \brief Standard device request to enable a configuration
+ *
+ * \return true if success
+ */
+static bool udc_req_std_dev_set_configuration(void)
+{
+ uint8_t iface_num;
+
+ // Check request length
+ if (udd_g_ctrlreq.req.wLength) {
+ return false;
+ }
+ // Authorize configuration only if the address is valid
+ if (!udd_getaddress()) {
+ return false;
+ }
+ // Check the configuration number requested
+#ifdef USB_DEVICE_HS_SUPPORT
+ if (udd_is_high_speed()) {
+ // HS descriptor
+ if ((udd_g_ctrlreq.req.wValue & 0xFF) >
+ udc_config.confdev_hs->bNumConfigurations) {
+ return false;
+ }
+ } else
+#endif
+ {
+ // FS descriptor
+ if ((udd_g_ctrlreq.req.wValue & 0xFF) >
+ udc_config.confdev_lsfs->bNumConfigurations) {
+ return false;
+ }
+ }
+
+ // Reset current configuration
+ udc_reset();
+
+ // Enable new configuration
+ udc_num_configuration = udd_g_ctrlreq.req.wValue & 0xFF;
+ if (udc_num_configuration == 0) {
+ return true; // Default empty configuration requested
+ }
+ // Update pointer of the configuration descriptor
+#ifdef USB_DEVICE_HS_SUPPORT
+ if (udd_is_high_speed()) {
+ // HS descriptor
+ udc_ptr_conf = &udc_config.conf_hs[udc_num_configuration - 1];
+ } else
+#endif
+ {
+ // FS descriptor
+ udc_ptr_conf = &udc_config.conf_lsfs[udc_num_configuration - 1];
+ }
+ // Enable all interfaces of the selected configuration
+ for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces;
+ iface_num++) {
+ if (!udc_iface_enable(iface_num, 0)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+/**
+ * \brief Standard interface request
+ * to get the alternate setting number of an interface
+ *
+ * \return true if success
+ */
+static bool udc_req_std_iface_get_setting(void)
+{
+ uint8_t iface_num;
+ udi_api_t UDC_DESC_STORAGE *udi_api;
+
+ if (udd_g_ctrlreq.req.wLength != 1) {
+ return false; // Error in request
+ }
+ if (!udc_num_configuration) {
+ return false; // The device is not is configured state yet
+ }
+
+ // Check the interface number included in the request
+ iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
+ if (iface_num >= udc_ptr_conf->desc->bNumInterfaces) {
+ return false;
+ }
+
+ // Select first alternate setting of the interface to update udc_ptr_iface
+ // before call iface->getsetting()
+ if (!udc_update_iface_desc(iface_num, 0)) {
+ return false;
+ }
+ // Get alternate setting from UDI
+ udi_api = udc_ptr_conf->udi_apis[iface_num];
+ udc_iface_setting = udi_api->getsetting();
+
+ // Link value to payload pointer of request
+ udd_set_setup_payload(&udc_iface_setting,1);
+ return true;
+}
+
+/**
+ * \brief Standard interface request
+ * to set an alternate setting of an interface
+ *
+ * \return true if success
+ */
+static bool udc_req_std_iface_set_setting(void)
+{
+ uint8_t iface_num, setting_num;
+
+ if (udd_g_ctrlreq.req.wLength) {
+ return false; // Error in request
+ }
+ if (!udc_num_configuration) {
+ return false; // The device is not is configured state yet
+ }
+
+ iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
+ setting_num = udd_g_ctrlreq.req.wValue & 0xFF;
+
+ // Disable current setting
+ if (!udc_iface_disable(iface_num)) {
+ return false;
+ }
+
+ // Enable new setting
+ return udc_iface_enable(iface_num, setting_num);
+}
+
+/**
+ * \brief Main routine to manage the standard USB SETUP request
+ *
+ * \return true if the request is supported
+ */
+static bool udc_reqstd(void)
+{
+ if (Udd_setup_is_in()) {
+ // GET Standard Requests
+ if (udd_g_ctrlreq.req.wLength == 0) {
+ return false; // Error for USB host
+ }
+
+ if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) {
+ // Standard Get Device request
+ switch (udd_g_ctrlreq.req.bRequest) {
+ case USB_REQ_GET_STATUS:
+ return udc_req_std_dev_get_status();
+ case USB_REQ_GET_DESCRIPTOR:
+ return udc_req_std_dev_get_descriptor();
+ case USB_REQ_GET_CONFIGURATION:
+ return udc_req_std_dev_get_configuration();
+ default:
+ break;
+ }
+ }
+
+ if (USB_REQ_RECIP_INTERFACE == Udd_setup_recipient()) {
+ // Standard Get Interface request
+ switch (udd_g_ctrlreq.req.bRequest) {
+ case USB_REQ_GET_INTERFACE:
+ return udc_req_std_iface_get_setting();
+ default:
+ break;
+ }
+ }
+#if (0!=USB_DEVICE_MAX_EP)
+ if (USB_REQ_RECIP_ENDPOINT == Udd_setup_recipient()) {
+ // Standard Get Endpoint request
+ switch (udd_g_ctrlreq.req.bRequest) {
+ case USB_REQ_GET_STATUS:
+ return udc_req_std_ep_get_status();
+ default:
+ break;
+ }
+ }
+#endif
+ } else {
+ // SET Standard Requests
+ if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) {
+ // Standard Set Device request
+ switch (udd_g_ctrlreq.req.bRequest) {
+ case USB_REQ_SET_ADDRESS:
+ return udc_req_std_dev_set_address();
+ case USB_REQ_CLEAR_FEATURE:
+ return udc_req_std_dev_clear_feature();
+ case USB_REQ_SET_FEATURE:
+ return udc_req_std_dev_set_feature();
+ case USB_REQ_SET_CONFIGURATION:
+ return udc_req_std_dev_set_configuration();
+ case USB_REQ_SET_DESCRIPTOR:
+ /* Not supported (defined as optional by the USB 2.0 spec) */
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (USB_REQ_RECIP_INTERFACE == Udd_setup_recipient()) {
+ // Standard Set Interface request
+ switch (udd_g_ctrlreq.req.bRequest) {
+ case USB_REQ_SET_INTERFACE:
+ return udc_req_std_iface_set_setting();
+ default:
+ break;
+ }
+ }
+#if (0!=USB_DEVICE_MAX_EP)
+ if (USB_REQ_RECIP_ENDPOINT == Udd_setup_recipient()) {
+ // Standard Set Endpoint request
+ switch (udd_g_ctrlreq.req.bRequest) {
+ case USB_REQ_CLEAR_FEATURE:
+ return udc_req_std_ep_clear_feature();
+ case USB_REQ_SET_FEATURE:
+ return udc_req_std_ep_set_feature();
+ default:
+ break;
+ }
+ }
+#endif
+ }
+ return false;
+}
+
+/**
+ * \brief Send the SETUP interface request to UDI
+ *
+ * \return true if the request is supported
+ */
+static bool udc_req_iface(void)
+{
+ uint8_t iface_num;
+ udi_api_t UDC_DESC_STORAGE *udi_api;
+
+ if (0 == udc_num_configuration) {
+ return false; // The device is not is configured state yet
+ }
+ // Check interface number
+ iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
+ if (iface_num >= udc_ptr_conf->desc->bNumInterfaces) {
+ return false;
+ }
+
+ //* To update udc_ptr_iface with the selected interface in request
+ // Select first alternate setting of interface to update udc_ptr_iface
+ // before calling udi_api->getsetting()
+ if (!udc_update_iface_desc(iface_num, 0)) {
+ return false;
+ }
+ // Select the interface with the current alternate setting
+ udi_api = udc_ptr_conf->udi_apis[iface_num];
+ if (!udc_update_iface_desc(iface_num, udi_api->getsetting())) {
+ return false;
+ }
+
+ // Send the SETUP request to the UDI corresponding to the interface number
+ return udi_api->setup();
+}
+
+/**
+ * \brief Send the SETUP interface request to UDI
+ *
+ * \return true if the request is supported
+ */
+static bool udc_req_ep(void)
+{
+ uint8_t iface_num;
+ udi_api_t UDC_DESC_STORAGE *udi_api;
+
+ if (0 == udc_num_configuration) {
+ return false; // The device is not is configured state yet
+ }
+ // Send this request on all enabled interfaces
+ iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
+ for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces;
+ iface_num++) {
+ // Select the interface with the current alternate setting
+ udi_api = udc_ptr_conf->udi_apis[iface_num];
+ if (!udc_update_iface_desc(iface_num, udi_api->getsetting())) {
+ return false;
+ }
+
+ // Send the SETUP request to the UDI
+ if (udi_api->setup()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool udc_reqvend(void){
+ switch (udd_g_ctrlreq.req.bRequest){
+ case 0xa0: //Break! (Debug command)
+ debugOnNextEnd = 1;
+ uds.medianTrfcntL = median_TRFCNT & 0xff;
+ uds.medianTrfcntH = (median_TRFCNT >> 8) & 0xff;
+ uds.calValNeg = cali_value_negative_gradient;
+ uds.calValPos = cali_value_positive_gradient;
+ uds.CALA = DFLLRC2M.CALA;
+ uds.CALB = DFLLRC2M.CALB;
+ udd_set_setup_payload(&uds, udd_g_ctrlreq.req.wLength);
+ //asm("nop");
+ return 1;
+ case 0xa1: //Receive waveform for signal gen
+ TC_DAC.CTRLA = 0x00;
+ TC_DAC.PERBUF = udd_g_ctrlreq.req.wValue;
+ TC_DAC.CTRLA = (unsigned char) udd_g_ctrlreq.req.wIndex & 0x0F;
+ udd_set_setup_payload(dacBuf_CH1, udd_g_ctrlreq.req.wLength);
+ if(dacBuf_len != udd_g_ctrlreq.req.wLength){
+ dacBuf_len = udd_g_ctrlreq.req.wLength;
+ tiny_dma_delayed_set(global_mode);
+ }
+ return 1;
+ case 0xa2: //CH2 waveform
+ TC_AUXDAC.CTRLA = 0x00;
+ TC_AUXDAC.PERBUF = udd_g_ctrlreq.req.wValue;
+ TC_AUXDAC.CTRLA = (unsigned char) udd_g_ctrlreq.req.wIndex & 0x0F;
+ udd_set_setup_payload(dacBuf_CH2, udd_g_ctrlreq.req.wLength);
+ if(auxDacBufLen != udd_g_ctrlreq.req.wLength){
+ auxDacBufLen = udd_g_ctrlreq.req.wLength;
+ tiny_dma_delayed_set(global_mode);
+ }
+ return 1;
+ case 0xa3: //PSU voltage control
+ TC_PSU.CCA = 0;
+ PSU_target = udd_g_ctrlreq.req.wValue;
+ return 1;
+ case 0xa4: //Triple mode
+ PORTB.OUT = udd_g_ctrlreq.req.wValue;
+ return 1;
+ case 0xa5: //Control Gain and Scope modes
+ switch(udd_g_ctrlreq.req.wValue){
+ case 0: //Mode 0
+ tiny_adc_setup(0, 0);
+ tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
+ tiny_dma_delayed_set(0);
+ break;
+ case 1: //Mode 1
+ tiny_adc_setup(0, 0);
+ tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
+ tiny_dma_delayed_set(1);
+ break;
+ case 2: //Mode 2
+ tiny_adc_setup(1, 1);
+ tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
+ tiny_adc_ch1setup(udd_g_ctrlreq.req.wIndex>>8);
+ tiny_dma_delayed_set(2);
+ break;
+ case 3: //Mode 3
+ tiny_dma_delayed_set(3);
+ break;
+ case 4: //Mode 4
+ tiny_dma_delayed_set(4);
+ break;
+ case 5: //Mode 5
+ tiny_adc_setup(0, 0);
+ tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
+ tiny_dma_delayed_set(5);
+ break;
+ case 6: //Mode 6
+ tiny_adc_setup(0, 1);
+ tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
+ tiny_dma_delayed_set(6);
+ break;
+ case 7: //Mode 7
+ tiny_adc_setup(0, 2);
+ tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex | 0x80);
+ tiny_dma_delayed_set(7);
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+ case 0xa6: //Digital out???
+ PORTE.OUT = udd_g_ctrlreq.req.wValue;
+ return 1;
+ case 0xa7: //Soft Reset
+ //Fill EEPROM buffer with value
+
+ if(udd_g_ctrlreq.req.wValue){
+ eeprom_safe_read();
+ memcpy(eeprom_buffer_write, eeprom_buffer_read, EEPROM_PAGE_SIZE);
+ eeprom_buffer_write[0] = 1;
+ eeprom_safe_write();
+ eeprom_safe_read();
+ }
+
+ //Code here from SprinterSB
+ //http://www.avrfreaks.net/comment/872674
+ //I don't understand it, but it seems to do the job
+ __asm volatile ("cli" "\n\t"
+ "out __CCP__, %[ccp]" "\n\t"
+ "st %a[rst], %[swrst]"
+ :
+ : [ccp] "r" ((uint8_t) CCP_IOREG_gc),
+ [swrst] "r" ((uint8_t) RST_SWRST_bm),
+ [rst] "e" (&RST.CTRL)
+ : "memory");
+ __builtin_unreachable();
+ case 0xa8: //Firmware Version Request
+ udd_set_setup_payload(&firmver, udd_g_ctrlreq.req.wLength);
+ return 1;
+ case 0xa9: //Variant Version Request
+ udd_set_setup_payload(&variant, udd_g_ctrlreq.req.wLength);
+ return 1;
+ default:
+ return 0;
+ }
+}
+/**
+ * \brief Main routine to manage the USB SETUP request.
+ *
+ * This function parses a USB SETUP request and submits an appropriate
+ * response back to the host or, in the case of SETUP OUT requests
+ * with data, sets up a buffer for receiving the data payload.
+ *
+ * The main standard requests defined by the USB 2.0 standard are handled
+ * internally. The interface requests are sent to UDI, and the specific request
+ * sent to a specific application callback.
+ *
+ * \return true if the request is supported, else the request is stalled by UDD
+ */
+bool udc_process_setup(void)
+{
+ // By default no data (receive/send) and no callbacks registered
+ udd_g_ctrlreq.payload_size = 0;
+ udd_g_ctrlreq.callback = NULL;
+ udd_g_ctrlreq.over_under_run = NULL;
+
+ if (Udd_setup_is_in()) {
+ if (udd_g_ctrlreq.req.wLength == 0) {
+ return false; // Error from USB host
+ }
+ }
+
+ if (Udd_setup_type() == USB_REQ_TYPE_VENDOR){
+ if (udc_reqvend()) {
+ return true;
+ }
+ }
+
+ // If standard request then try to decode it in UDC
+ if (Udd_setup_type() == USB_REQ_TYPE_STANDARD) {
+ if (udc_reqstd()) {
+ return true;
+ }
+ }
+
+ // If interface request then try to decode it in UDI
+ if (Udd_setup_recipient() == USB_REQ_RECIP_INTERFACE) {
+ if (udc_req_iface()) {
+ return true;
+ }
+ }
+
+ // If endpoint request then try to decode it in UDI
+ if (Udd_setup_recipient() == USB_REQ_RECIP_ENDPOINT) {
+ if (udc_req_ep()) {
+ return true;
+ }
+ }
+
+ // Here SETUP request unknown by UDC and UDIs
+#ifdef USB_DEVICE_SPECIFIC_REQUEST
+ // Try to decode it in specific callback
+ return USB_DEVICE_SPECIFIC_REQUEST(); // Ex: Vendor request,...
+#else
+ return false;
+#endif
+}
+
+//! @}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c.REMOVED.git-id
deleted file mode 100644
index 50f24419..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ea6e7ad4969e07a1472ad1893273afa05b503593
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.h
new file mode 100644
index 00000000..edfe7078
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.h
@@ -0,0 +1,697 @@
+/**
+ * \file
+ *
+ * \brief Interface of the USB Device Controller (UDC)
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _UDC_H_
+#define _UDC_H_
+
+#include "conf_usb.h"
+#include "usb_protocol.h"
+#include "udc_desc.h"
+#include "udd.h"
+
+#if USB_DEVICE_VENDOR_ID == 0
+# error USB_DEVICE_VENDOR_ID cannot be equal to 0
+#endif
+
+#if USB_DEVICE_PRODUCT_ID == 0
+# error USB_DEVICE_PRODUCT_ID cannot be equal to 0
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup usb_device_group
+ * \defgroup udc_group USB Device Controller (UDC)
+ *
+ * The UDC provides a high-level abstraction of the usb device.
+ * You can use these functions to control the main device state
+ * (start/attach/wakeup).
+ *
+ * \section USB_DEVICE_CONF USB Device Custom configuration
+ * The following USB Device configuration must be included in the conf_usb.h
+ * file of the application.
+ *
+ * USB_DEVICE_VENDOR_ID (Word)
+ * Vendor ID provided by USB org (ATMEL 0x03EB).
+ *
+ * USB_DEVICE_PRODUCT_ID (Word)
+ * Product ID (Referenced in usb_atmel.h).
+ *
+ * USB_DEVICE_MAJOR_VERSION (Byte)
+ * Major version of the device
+ *
+ * USB_DEVICE_MINOR_VERSION (Byte)
+ * Minor version of the device
+ *
+ * USB_DEVICE_MANUFACTURE_NAME (string)
+ * ASCII name for the manufacture
+ *
+ * USB_DEVICE_PRODUCT_NAME (string)
+ * ASCII name for the product
+ *
+ * USB_DEVICE_SERIAL_NAME (string)
+ * ASCII name to enable and set a serial number
+ *
+ * USB_DEVICE_POWER (Numeric)
+ * (unit mA) Maximum device power
+ *
+ * USB_DEVICE_ATTR (Byte)
+ * USB attributes available:
+ * - USB_CONFIG_ATTR_SELF_POWERED
+ * - USB_CONFIG_ATTR_REMOTE_WAKEUP
+ * Note: if remote wake enabled then defines remotewakeup callbacks,
+ * see Table 5-2. External API from UDC - Callback
+ *
+ * USB_DEVICE_LOW_SPEED (Only defined)
+ * Force the USB Device to run in low speed
+ *
+ * USB_DEVICE_HS_SUPPORT (Only defined)
+ * Authorize the USB Device to run in high speed
+ *
+ * USB_DEVICE_MAX_EP (Byte)
+ * Define the maximum endpoint number used by the USB Device.
+ * This one is already defined in UDI default configuration.
+ * Ex:
+ * - When endpoint control 0x00, endpoint 0x01 and
+ * endpoint 0x82 is used then USB_DEVICE_MAX_EP=2
+ * - When only endpoint control 0x00 is used then USB_DEVICE_MAX_EP=0
+ * - When endpoint 0x01 and endpoint 0x81 is used then USB_DEVICE_MAX_EP=1
+ * (configuration not possible on USBB interface)
+ * @{
+ */
+
+/**
+ * \brief Authorizes the VBUS event
+ *
+ * \return true, if the VBUS monitoring is possible.
+ *
+ * \section udc_vbus_monitoring VBus monitoring used cases
+ *
+ * The VBus monitoring is used only for USB SELF Power application.
+ *
+ * - By default the USB device is automatically attached when Vbus is high
+ * or when USB is start for devices without internal Vbus monitoring.
+ * conf_usb.h file does not contains define USB_DEVICE_ATTACH_AUTO_DISABLE.
+ * \code //#define USB_DEVICE_ATTACH_AUTO_DISABLE \endcode
+ *
+ * - Add custom VBUS monitoring. conf_usb.h file contains define
+ * USB_DEVICE_ATTACH_AUTO_DISABLE:
+ * \code #define USB_DEVICE_ATTACH_AUTO_DISABLE \endcode
+ * User C file contains:
+ * \code
+ // Authorize VBUS monitoring
+ if (!udc_include_vbus_monitoring()) {
+ // Implement custom VBUS monitoring via GPIO or other
+ }
+ Event_VBUS_present() // VBUS interrupt or GPIO interrupt or other
+ {
+ // Attach USB Device
+ udc_attach();
+ }
+\endcode
+ *
+ * - Case of battery charging. conf_usb.h file contains define
+ * USB_DEVICE_ATTACH_AUTO_DISABLE:
+ * \code #define USB_DEVICE_ATTACH_AUTO_DISABLE \endcode
+ * User C file contains:
+ * \code
+ Event VBUS present() // VBUS interrupt or GPIO interrupt or ..
+ {
+ // Authorize battery charging, but wait key press to start USB.
+ }
+ Event Key press()
+ {
+ // Stop batteries charging
+ // Start USB
+ udc_attach();
+ }
+\endcode
+ */
+static inline bool udc_include_vbus_monitoring(void)
+{
+ return udd_include_vbus_monitoring();
+}
+
+/*! \brief Start the USB Device stack
+ */
+void udc_start(void);
+
+/*! \brief Stop the USB Device stack
+ */
+void udc_stop(void);
+
+/**
+ * \brief Attach device to the bus when possible
+ *
+ * \warning If a VBus control is included in driver,
+ * then it will attach device when an acceptable Vbus
+ * level from the host is detected.
+ */
+static inline void udc_attach(void)
+{
+ udd_attach();
+}
+
+
+/**
+ * \brief Detaches the device from the bus
+ *
+ * The driver must remove pull-up on USB line D- or D+.
+ */
+static inline void udc_detach(void)
+{
+ udd_detach();
+}
+
+
+/*! \brief The USB driver sends a resume signal called \e "Upstream Resume"
+ * This is authorized only when the remote wakeup feature is enabled by host.
+ */
+static inline void udc_remotewakeup(void)
+{
+ udd_send_remotewakeup();
+}
+
+
+/**
+ * \brief Returns a pointer on the current interface descriptor
+ *
+ * \return pointer on the current interface descriptor.
+ */
+usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
+
+//@}
+
+/**
+ * \ingroup usb_group
+ * \defgroup usb_device_group USB Stack Device
+ *
+ * This module includes USB Stack Device implementation.
+ * The stack is divided in three parts:
+ * - USB Device Controller (UDC) provides USB chapter 9 compliance
+ * - USB Device Interface (UDI) provides USB Class compliance
+ * - USB Device Driver (UDD) provides USB Driver for each Atmel MCU
+
+ * Many USB Device applications can be implemented on Atmel MCU.
+ * Atmel provides many application notes for different applications:
+ * - AVR4900, provides general information about Device Stack
+ * - AVR4901, explains how to create a new class
+ * - AVR4902, explains how to create a composite device
+ * - AVR49xx, all device classes provided in ASF have an application note
+ *
+ * A basic USB knowledge is required to understand the USB Device
+ * Class application notes (HID,MS,CDC,PHDC,...).
+ * Then, to create an USB device with
+ * only one class provided by ASF, refer directly to the application note
+ * corresponding to this USB class. The USB Device application note for
+ * New Class and Composite is dedicated to advanced USB users.
+ *
+ * @{
+ */
+
+//! @}
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * \ingroup udc_group
+ * \defgroup udc_basic_use_case_setup_prereq USB Device Controller (UDC) - Prerequisites
+ * Common prerequisites for all USB devices.
+ *
+ * This module is based on USB device stack full interrupt driven, and supporting
+ * \ref sleepmgr_group sleepmgr. For AVR and SAM3/4 devices the \ref clk_group clock services
+ * is supported. For SAMD devices the \ref asfdoc_sam0_system_clock_group clock driver is supported.
+ *
+ * The following procedure must be executed to setup the project correctly:
+ * - Specify the clock configuration:
+ * - XMEGA USB devices need 48MHz clock input.\n
+ * XMEGA USB devices need CPU frequency higher than 12MHz.\n
+ * You can use either an internal RC48MHz auto calibrated by Start of Frames
+ * or an external OSC.
+ * - UC3 and SAM3/4 devices without USB high speed support need 48MHz clock input.\n
+ * You must use a PLL and an external OSC.
+ * - UC3 and SAM3/4 devices with USB high speed support need 12MHz clock input.\n
+ * You must use an external OSC.
+ * - UC3 devices with USBC hardware need CPU frequency higher than 25MHz.
+ * - SAMD devices without USB high speed support need 48MHz clock input.\n
+ * You should use DFLL with USBCRM.
+ * - In conf_board.h, the define CONF_BOARD_USB_PORT must be added to enable USB lines.
+ * (Not mandatory for all boards)
+ * - Enable interrupts
+ * - Initialize the clock service
+ *
+ * The usage of \ref sleepmgr_group sleepmgr service is optional, but recommended to reduce power
+ * consumption:
+ * - Initialize the sleep manager service
+ * - Activate sleep mode when the application is in IDLE state
+ *
+ * \subpage udc_conf_clock.
+ *
+ * for AVR and SAM3/4 devices, add to the initialization code:
+ * \code
+ sysclk_init();
+ irq_initialize_vectors();
+ cpu_irq_enable();
+ board_init();
+ sleepmgr_init(); // Optional
+\endcode
+ *
+ * For SAMD devices, add to the initialization code:
+ * \code
+ system_init();
+ irq_initialize_vectors();
+ cpu_irq_enable();
+ sleepmgr_init(); // Optional
+\endcode
+ * Add to the main IDLE loop:
+ * \code
+ sleepmgr_enter_sleep(); // Optional
+\endcode
+ *
+ */
+
+/**
+ * \ingroup udc_group
+ * \defgroup udc_basic_use_case_setup_code USB Device Controller (UDC) - Example code
+ * Common example code for all USB devices.
+ *
+ * Content of conf_usb.h:
+ * \code
+ #define USB_DEVICE_VENDOR_ID 0x03EB
+ #define USB_DEVICE_PRODUCT_ID 0xXXXX
+ #define USB_DEVICE_MAJOR_VERSION 1
+ #define USB_DEVICE_MINOR_VERSION 0
+ #define USB_DEVICE_POWER 100
+ #define USB_DEVICE_ATTR USB_CONFIG_ATTR_BUS_POWERED
+\endcode
+ *
+ * Add to application C-file:
+ * \code
+ void usb_init(void)
+ {
+ udc_start();
+ }
+\endcode
+ */
+
+/**
+ * \ingroup udc_group
+ * \defgroup udc_basic_use_case_setup_flow USB Device Controller (UDC) - Workflow
+ * Common workflow for all USB devices.
+ *
+ * -# Ensure that conf_usb.h is available and contains the following configuration
+ * which is the main USB device configuration:
+ * - \code // Vendor ID provided by USB org (ATMEL 0x03EB)
+ #define USB_DEVICE_VENDOR_ID 0x03EB // Type Word
+ // Product ID (Atmel PID referenced in usb_atmel.h)
+ #define USB_DEVICE_PRODUCT_ID 0xXXXX // Type Word
+ // Major version of the device
+ #define USB_DEVICE_MAJOR_VERSION 1 // Type Byte
+ // Minor version of the device
+ #define USB_DEVICE_MINOR_VERSION 0 // Type Byte
+ // Maximum device power (mA)
+ #define USB_DEVICE_POWER 100 // Type 9-bits
+ // USB attributes to enable features
+ #define USB_DEVICE_ATTR USB_CONFIG_ATTR_BUS_POWERED // Flags \endcode
+ * -# Call the USB device stack start function to enable stack and start USB:
+ * - \code udc_start(); \endcode
+ * \note In case of USB dual roles (Device and Host) managed through USB OTG connector
+ * (USB ID pin), the call of udc_start() must be removed and replaced by uhc_start().
+ * SeRefer to "AVR4950 section 6.1 Dual roles" for further information about dual roles.
+ */
+
+/**
+ * \page udc_conf_clock conf_clock.h examples with USB support
+ *
+ * Content of XMEGA conf_clock.h:
+ * \code
+ // Configuration based on internal RC:
+ // USB clock need of 48Mhz
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+ #define CONFIG_OSC_RC32_CAL 48000000UL
+ #define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC OSC_ID_USBSOF
+ // CPU clock need of clock > 12MHz to run with USB (Here 24MHz)
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC32MHZ
+ #define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_2
+ #define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1
+\endcode
+ *
+ * Content of conf_clock.h for AT32UC3A0, AT32UC3A1, AT32UC3B devices (USBB):
+ * \code
+ // Configuration based on 12MHz external OSC:
+ #define CONFIG_PLL1_SOURCE PLL_SRC_OSC0
+ #define CONFIG_PLL1_MUL 8
+ #define CONFIG_PLL1_DIV 2
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
+ #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
+\endcode
+ *
+ * Content of conf_clock.h for AT32UC3A3, AT32UC3A4 devices (USBB with high speed support):
+ * \code
+ // Configuration based on 12MHz external OSC:
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_OSC0
+ #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
+\endcode
+ *
+ * Content of conf_clock.h for AT32UC3C, ATUCXXD, ATUCXXL3U, ATUCXXL4U devices (USBC):
+ * \code
+ // Configuration based on 12MHz external OSC:
+ #define CONFIG_PLL1_SOURCE PLL_SRC_OSC0
+ #define CONFIG_PLL1_MUL 8
+ #define CONFIG_PLL1_DIV 2
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
+ #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
+ // CPU clock need of clock > 25MHz to run with USBC
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL1
+\endcode
+ *
+ * Content of conf_clock.h for SAM3S, SAM3SD, SAM4S devices (UPD: USB Peripheral Device):
+ * \code
+ // PLL1 (B) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
+ #define CONFIG_PLL1_SOURCE PLL_SRC_MAINCK_XTAL
+ #define CONFIG_PLL1_MUL 16
+ #define CONFIG_PLL1_DIV 2
+ // USB Clock Source Options (Fusb = FpllX / USB_div)
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
+ #define CONFIG_USBCLK_DIV 2
+\endcode
+ *
+ * Content of conf_clock.h for SAM3U device (UPDHS: USB Peripheral Device High Speed):
+ * \code
+ // USB Clock Source fixed at UPLL.
+\endcode
+ *
+ * Content of conf_clock.h for SAM3X, SAM3A devices (UOTGHS: USB OTG High Speed):
+ * \code
+ // USB Clock Source fixed at UPLL.
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_UPLL
+ #define CONFIG_USBCLK_DIV 1
+\endcode
+ *
+ * Content of conf_clocks.h for SAMD devices (USB):
+ * \code
+ // System clock bus configuration
+ # define CONF_CLOCK_FLASH_WAIT_STATES 2
+
+ // USB Clock Source fixed at DFLL.
+ // SYSTEM_CLOCK_SOURCE_DFLL configuration - Digital Frequency Locked Loop
+ # define CONF_CLOCK_DFLL_ENABLE true
+ # define CONF_CLOCK_DFLL_LOOP_MODE SYSTEM_CLOCK_DFLL_LOOP_MODE_USB_RECOVERY
+ # define CONF_CLOCK_DFLL_ON_DEMAND true
+
+ // Set this to true to configure the GCLK when running clocks_init.
+ // If set to false, none of the GCLK generators will be configured in clocks_init().
+ # define CONF_CLOCK_CONFIGURE_GCLK true
+
+ // Configure GCLK generator 0 (Main Clock)
+ # define CONF_CLOCK_GCLK_0_ENABLE true
+ # define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY true
+ # define CONF_CLOCK_GCLK_0_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_DFLL
+ # define CONF_CLOCK_GCLK_0_PRESCALER 1
+ # define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE false
+\endcode
+ */
+
+/**
+ * \page udc_use_case_1 Change USB speed
+ *
+ * In this use case, the USB device is used with different USB speeds.
+ *
+ * \section udc_use_case_1_setup Setup steps
+ *
+ * Prior to implement this use case, be sure to have already
+ * apply the UDI module "basic use case".
+ *
+ * \section udc_use_case_1_usage Usage steps
+ *
+ * \subsection udc_use_case_1_usage_code Example code
+ * Content of conf_usb.h:
+ * \code
+ #if // Low speed
+ #define USB_DEVICE_LOW_SPEED
+ // #define USB_DEVICE_HS_SUPPORT
+
+ #elif // Full speed
+ // #define USB_DEVICE_LOW_SPEED
+ // #define USB_DEVICE_HS_SUPPORT
+
+ #elif // High speed
+ // #define USB_DEVICE_LOW_SPEED
+ #define USB_DEVICE_HS_SUPPORT
+
+ #endif
+\endcode
+ *
+ * \subsection udc_use_case_1_usage_flow Workflow
+ * -# Ensure that conf_usb.h is available and contains the following parameters
+ * required for a USB device low speed (1.5Mbit/s):
+ * - \code #define USB_DEVICE_LOW_SPEED
+ //#define USB_DEVICE_HS_SUPPORT \endcode
+ * -# Ensure that conf_usb.h contains the following parameters
+ * required for a USB device full speed (12Mbit/s):
+ * - \code //#define USB_DEVICE_LOW_SPEED
+ //#define USB_DEVICE_HS_SUPPORT \endcode
+ * -# Ensure that conf_usb.h contains the following parameters
+ * required for a USB device high speed (480Mbit/s):
+ * - \code //#define USB_DEVICE_LOW_SPEED
+ #define USB_DEVICE_HS_SUPPORT \endcode
+ */
+
+/**
+ * \page udc_use_case_2 Use USB strings
+ *
+ * In this use case, the usual USB strings is added in the USB device.
+ *
+ * \section udc_use_case_2_setup Setup steps
+ * Prior to implement this use case, be sure to have already
+ * apply the UDI module "basic use case".
+ *
+ * \section udc_use_case_2_usage Usage steps
+ *
+ * \subsection udc_use_case_2_usage_code Example code
+ * Content of conf_usb.h:
+ * \code
+ #define USB_DEVICE_MANUFACTURE_NAME "Manufacture name"
+ #define USB_DEVICE_PRODUCT_NAME "Product name"
+ #define USB_DEVICE_SERIAL_NAME "12...EF"
+\endcode
+ *
+ * \subsection udc_use_case_2_usage_flow Workflow
+ * -# Ensure that conf_usb.h is available and contains the following parameters
+ * required to enable different USB strings:
+ * - \code // Static ASCII name for the manufacture
+ #define USB_DEVICE_MANUFACTURE_NAME "Manufacture name" \endcode
+ * - \code // Static ASCII name for the product
+ #define USB_DEVICE_PRODUCT_NAME "Product name" \endcode
+ * - \code // Static ASCII name to enable and set a serial number
+ #define USB_DEVICE_SERIAL_NAME "12...EF" \endcode
+ */
+
+/**
+ * \page udc_use_case_3 Use USB remote wakeup feature
+ *
+ * In this use case, the USB remote wakeup feature is enabled.
+ *
+ * \section udc_use_case_3_setup Setup steps
+ * Prior to implement this use case, be sure to have already
+ * apply the UDI module "basic use case".
+ *
+ * \section udc_use_case_3_usage Usage steps
+ *
+ * \subsection udc_use_case_3_usage_code Example code
+ * Content of conf_usb.h:
+ * \code
+ #define USB_DEVICE_ATTR \
+ (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED)
+ #define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
+ extern void my_callback_remotewakeup_enable(void);
+ #define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
+ extern void my_callback_remotewakeup_disable(void);
+\endcode
+ *
+ * Add to application C-file:
+ * \code
+ void my_callback_remotewakeup_enable(void)
+ {
+ // Enable application wakeup events (e.g. enable GPIO interrupt)
+ }
+ void my_callback_remotewakeup_disable(void)
+ {
+ // Disable application wakeup events (e.g. disable GPIO interrupt)
+ }
+
+ void my_interrupt_event(void)
+ {
+ udc_remotewakeup();
+ }
+\endcode
+ *
+ * \subsection udc_use_case_3_usage_flow Workflow
+ * -# Ensure that conf_usb.h is available and contains the following parameters
+ * required to enable remote wakeup feature:
+ * - \code // Authorizes the remote wakeup feature
+ #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED) \endcode
+ * - \code // Define callback called when the host enables the remotewakeup feature
+ #define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
+ extern void my_callback_remotewakeup_enable(void); \endcode
+ * - \code // Define callback called when the host disables the remotewakeup feature
+ #define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
+ extern void my_callback_remotewakeup_disable(void); \endcode
+ * -# Send a remote wakeup (USB upstream):
+ * - \code udc_remotewakeup(); \endcode
+ */
+
+/**
+ * \page udc_use_case_5 Bus power application recommendations
+ *
+ * In this use case, the USB device BUS power feature is enabled.
+ * This feature requires a correct power consumption management.
+ *
+ * \section udc_use_case_5_setup Setup steps
+ * Prior to implement this use case, be sure to have already
+ * apply the UDI module "basic use case".
+ *
+ * \section udc_use_case_5_usage Usage steps
+ *
+ * \subsection udc_use_case_5_usage_code Example code
+ * Content of conf_usb.h:
+ * \code
+ #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED)
+ #define UDC_SUSPEND_EVENT() user_callback_suspend_action()
+ extern void user_callback_suspend_action(void)
+ #define UDC_RESUME_EVENT() user_callback_resume_action()
+ extern void user_callback_resume_action(void)
+\endcode
+ *
+ * Add to application C-file:
+ * \code
+ void user_callback_suspend_action(void)
+ {
+ // Disable hardware component to reduce power consumption
+ }
+ void user_callback_resume_action(void)
+ {
+ // Re-enable hardware component
+ }
+\endcode
+ *
+ * \subsection udc_use_case_5_usage_flow Workflow
+ * -# Ensure that conf_usb.h is available and contains the following parameters:
+ * - \code // Authorizes the BUS power feature
+ #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED) \endcode
+ * - \code // Define callback called when the host suspend the USB line
+ #define UDC_SUSPEND_EVENT() user_callback_suspend_action()
+ extern void user_callback_suspend_action(void); \endcode
+ * - \code // Define callback called when the host or device resume the USB line
+ #define UDC_RESUME_EVENT() user_callback_resume_action()
+ extern void user_callback_resume_action(void); \endcode
+ * -# Reduce power consumption in suspend mode (max. 2.5mA on Vbus):
+ * - \code void user_callback_suspend_action(void)
+ {
+ turn_off_components();
+ } \endcode
+ */
+
+/**
+ * \page udc_use_case_6 USB dynamic serial number
+ *
+ * In this use case, the USB serial strings is dynamic.
+ * For a static serial string refer to \ref udc_use_case_2.
+ *
+ * \section udc_use_case_6_setup Setup steps
+ * Prior to implement this use case, be sure to have already
+ * apply the UDI module "basic use case".
+ *
+ * \section udc_use_case_6_usage Usage steps
+ *
+ * \subsection udc_use_case_6_usage_code Example code
+ * Content of conf_usb.h:
+ * \code
+ #define USB_DEVICE_SERIAL_NAME
+ #define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number
+ #define USB_DEVICE_GET_SERIAL_NAME_LENGTH 12
+ extern uint8_t serial_number[];
+\endcode
+ *
+ * Add to application C-file:
+ * \code
+ uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
+
+ void init_build_usb_serial_number(void)
+ {
+ serial_number[0] = 'A';
+ serial_number[1] = 'B';
+ ...
+ serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH-1] = 'C';
+ } \endcode
+ *
+ * \subsection udc_use_case_6_usage_flow Workflow
+ * -# Ensure that conf_usb.h is available and contains the following parameters
+ * required to enable a USB serial number strings dynamically:
+ * - \code #define USB_DEVICE_SERIAL_NAME // Define this empty
+ #define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number // Give serial array pointer
+ #define USB_DEVICE_GET_SERIAL_NAME_LENGTH 12 // Give size of serial array
+ extern uint8_t serial_number[]; // Declare external serial array \endcode
+ * -# Before start USB stack, initialize the serial array
+ * - \code
+ uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
+
+ void init_build_usb_serial_number(void)
+ {
+ serial_number[0] = 'A';
+ serial_number[1] = 'B';
+ ...
+ serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH-1] = 'C';
+ } \endcode
+ */
+
+
+
+#endif // _UDC_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.h.REMOVED.git-id
deleted file mode 100644
index e62d6b98..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-edfe70788b075f89f1db3c17450ad33ca4916353
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc_desc.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc_desc.h
new file mode 100644
index 00000000..88ed08a9
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc_desc.h
@@ -0,0 +1,135 @@
+/**
+ * \file
+ *
+ * \brief Common API for USB Device Interface
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _UDC_DESC_H_
+#define _UDC_DESC_H_
+
+#include "conf_usb.h"
+#include "usb_protocol.h"
+#include "udi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup udc_group
+ * \defgroup udc_desc_group USB Device Descriptor
+ *
+ * @{
+ */
+
+/**
+ * \brief Defines the memory's location of USB descriptors
+ *
+ * By default the Descriptor is stored in RAM
+ * (UDC_DESC_STORAGE is defined empty).
+ *
+ * If you have need to free RAM space,
+ * it is possible to put descriptor in flash in following case:
+ * - USB driver authorize flash transfer (USBB on UC3 and USB on Mega)
+ * - USB Device is not high speed (UDC no need to change USB descriptors)
+ *
+ * For UC3 application used "const".
+ *
+ * For Mega application used "code".
+ */
+#define UDC_DESC_STORAGE
+ // Descriptor storage in internal RAM
+#if (defined UDC_DATA_USE_HRAM_SUPPORT)
+# if defined(__GNUC__)
+# define UDC_DATA(x) COMPILER_WORD_ALIGNED __attribute__((__section__(".data_hram0")))
+# define UDC_BSS(x) COMPILER_ALIGNED(x) __attribute__((__section__(".bss_hram0")))
+# elif defined(__ICCAVR32__)
+# define UDC_DATA(x) COMPILER_ALIGNED(x) __data32
+# define UDC_BSS(x) COMPILER_ALIGNED(x) __data32
+# endif
+#else
+# define UDC_DATA(x) COMPILER_ALIGNED(x)
+# define UDC_BSS(x) COMPILER_ALIGNED(x)
+#endif
+
+
+
+/**
+ * \brief Configuration descriptor and UDI link for one USB speed
+ */
+typedef struct {
+ //! USB configuration descriptor
+ usb_conf_desc_t UDC_DESC_STORAGE *desc;
+ //! Array of UDI API pointer
+ udi_api_t UDC_DESC_STORAGE *UDC_DESC_STORAGE * udi_apis;
+} udc_config_speed_t;
+
+
+/**
+ * \brief All information about the USB Device
+ */
+typedef struct {
+ //! USB device descriptor for low or full speed
+ usb_dev_desc_t UDC_DESC_STORAGE *confdev_lsfs;
+ //! USB configuration descriptor and UDI API pointers for low or full speed
+ udc_config_speed_t UDC_DESC_STORAGE *conf_lsfs;
+#ifdef USB_DEVICE_HS_SUPPORT
+ //! USB device descriptor for high speed
+ usb_dev_desc_t UDC_DESC_STORAGE *confdev_hs;
+ //! USB device qualifier, only use in high speed mode
+ usb_dev_qual_desc_t UDC_DESC_STORAGE *qualifier;
+ //! USB configuration descriptor and UDI API pointers for high speed
+ udc_config_speed_t UDC_DESC_STORAGE *conf_hs;
+#endif
+ usb_dev_bos_desc_t UDC_DESC_STORAGE *conf_bos;
+} udc_config_t;
+
+//! Global variables of USB Device Descriptor and UDI links
+extern UDC_DESC_STORAGE udc_config_t udc_config;
+
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _UDC_DESC_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc_desc.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc_desc.h.REMOVED.git-id
deleted file mode 100644
index ceea95ad..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udc_desc.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-88ed08a96118be1b177bd0edf0c4fabc11a46da5
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udd.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udd.h
new file mode 100644
index 00000000..10807f43
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udd.h
@@ -0,0 +1,396 @@
+/**
+ * \file
+ *
+ * \brief Common API for USB Device Drivers (UDD)
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _UDD_H_
+#define _UDD_H_
+
+#include "usb_protocol.h"
+#include "udc_desc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup usb_device_group
+ * \defgroup udd_group USB Device Driver (UDD)
+ *
+ * The UDD driver provides a low-level abstraction of the device
+ * controller hardware. Most events coming from the hardware such as
+ * interrupts, which may cause the UDD to call into the UDC and UDI.
+ *
+ * @{
+ */
+
+//! \brief Endpoint identifier
+typedef uint8_t udd_ep_id_t;
+
+//! \brief Endpoint transfer status
+//! Returned in parameters of callback register via udd_ep_run routine.
+typedef enum {
+ UDD_EP_TRANSFER_OK = 0,
+ UDD_EP_TRANSFER_ABORT = 1,
+} udd_ep_status_t;
+
+/**
+ * \brief Global variable to give and record information of the setup request management
+ *
+ * This global variable allows to decode and response a setup request.
+ * It can be updated by udc_process_setup() from UDC or *setup() from UDIs.
+ */
+typedef struct {
+ //! Data received in USB SETUP packet
+ //! Note: The swap of "req.wValues" from uin16_t to le16_t is done by UDD.
+ usb_setup_req_t req;
+
+ //! Point to buffer to send or fill with data following SETUP packet
+ //! This buffer must be word align for DATA IN phase (use prefix COMPILER_WORD_ALIGNED for buffer)
+ uint8_t *payload;
+
+ //! Size of buffer to send or fill, and content the number of byte transfered
+ uint16_t payload_size;
+
+ //! Callback called after reception of ZLP from setup request
+ void (*callback) (void);
+
+ //! Callback called when the buffer given (.payload) is full or empty.
+ //! This one return false to abort data transfer, or true with a new buffer in .payload.
+ bool(*over_under_run) (void);
+} udd_ctrl_request_t;
+extern udd_ctrl_request_t udd_g_ctrlreq;
+
+//! Return true if the setup request \a udd_g_ctrlreq indicates IN data transfer
+#define Udd_setup_is_in() \
+ (USB_REQ_DIR_IN == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
+
+//! Return true if the setup request \a udd_g_ctrlreq indicates OUT data transfer
+#define Udd_setup_is_out() \
+ (USB_REQ_DIR_OUT == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
+
+//! Return the type of the SETUP request \a udd_g_ctrlreq. \see usb_reqtype.
+#define Udd_setup_type() \
+ (udd_g_ctrlreq.req.bmRequestType & USB_REQ_TYPE_MASK)
+
+//! Return the recipient of the SETUP request \a udd_g_ctrlreq. \see usb_recipient
+#define Udd_setup_recipient() \
+ (udd_g_ctrlreq.req.bmRequestType & USB_REQ_RECIP_MASK)
+
+/**
+ * \brief End of halt callback function type.
+ * Registered by routine udd_ep_wait_stall_clear()
+ * Callback called when endpoint stall is cleared.
+ */
+typedef void (*udd_callback_halt_cleared_t) (void);
+
+/**
+ * \brief End of transfer callback function type.
+ * Registered by routine udd_ep_run()
+ * Callback called by USB interrupt after data transfer or abort (reset,...).
+ *
+ * \param status UDD_EP_TRANSFER_OK, if transfer is complete
+ * \param status UDD_EP_TRANSFER_ABORT, if transfer is aborted
+ * \param n number of data transfered
+ */
+typedef void (*udd_callback_trans_t) (udd_ep_status_t status,
+ iram_size_t nb_transfered, udd_ep_id_t ep);
+
+/**
+ * \brief Authorizes the VBUS event
+ *
+ * \return true, if the VBUS monitoring is possible.
+ */
+bool udd_include_vbus_monitoring(void);
+
+/**
+ * \brief Enables the USB Device mode
+ */
+void udd_enable(void);
+
+/**
+ * \brief Disables the USB Device mode
+ */
+void udd_disable(void);
+
+/**
+ * \brief Attach device to the bus when possible
+ *
+ * \warning If a VBus control is included in driver,
+ * then it will attach device when an acceptable Vbus
+ * level from the host is detected.
+ */
+void udd_attach(void);
+
+/**
+ * \brief Detaches the device from the bus
+ *
+ * The driver must remove pull-up on USB line D- or D+.
+ */
+void udd_detach(void);
+
+/**
+ * \brief Test whether the USB Device Controller is running at high
+ * speed or not.
+ *
+ * \return \c true if the Device is running at high speed mode, otherwise \c false.
+ */
+bool udd_is_high_speed(void);
+
+/**
+ * \brief Changes the USB address of device
+ *
+ * \param address New USB address
+ */
+void udd_set_address(uint8_t address);
+
+/**
+ * \brief Returns the USB address of device
+ *
+ * \return USB address
+ */
+uint8_t udd_getaddress(void);
+
+/**
+ * \brief Returns the current start of frame number
+ *
+ * \return current start of frame number.
+ */
+uint16_t udd_get_frame_number(void);
+
+/**
+ * \brief Returns the current micro start of frame number
+ *
+ * \return current micro start of frame number required in high speed mode.
+ */
+uint16_t udd_get_micro_frame_number(void);
+
+/*! \brief The USB driver sends a resume signal called Upstream Resume
+ */
+void udd_send_remotewakeup(void);
+
+/**
+ * \brief Load setup payload
+ *
+ * \param payload Pointer on payload
+ * \param payload_size Size of payload
+ */
+void udd_set_setup_payload( uint8_t *payload, uint16_t payload_size );
+
+
+/**
+ * \name Endpoint Management
+ *
+ * The following functions allow drivers to create and remove
+ * endpoints, as well as set, clear and query their "halted" and
+ * "wedged" states.
+ */
+//@{
+
+#if (USB_DEVICE_MAX_EP != 0)
+
+/**
+ * \brief Configures and enables an endpoint
+ *
+ * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT).
+ * \param bmAttributes Attributes of endpoint declared in the descriptor.
+ * \param MaxEndpointSize Endpoint maximum size
+ *
+ * \return \c 1 if the endpoint is enabled, otherwise \c 0.
+ */
+bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes,
+ uint16_t MaxEndpointSize);
+
+/**
+ * \brief Disables an endpoint
+ *
+ * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT).
+ */
+void udd_ep_free(udd_ep_id_t ep);
+
+/**
+ * \brief Check if the endpoint \a ep is halted.
+ *
+ * \param ep The ID of the endpoint to check.
+ *
+ * \return \c 1 if \a ep is halted, otherwise \c 0.
+ */
+bool udd_ep_is_halted(udd_ep_id_t ep);
+
+/**
+ * \brief Set the halted state of the endpoint \a ep
+ *
+ * After calling this function, any transaction on \a ep will result
+ * in a STALL handshake being sent. Any pending transactions will be
+ * performed first, however.
+ *
+ * \param ep The ID of the endpoint to be halted
+ *
+ * \return \c 1 if \a ep is halted, otherwise \c 0.
+ */
+bool udd_ep_set_halt(udd_ep_id_t ep);
+
+/**
+ * \brief Clear the halted state of the endpoint \a ep
+ *
+ * After calling this function, any transaction on \a ep will
+ * be handled normally, i.e. a STALL handshake will not be sent, and
+ * the data toggle sequence will start at DATA0.
+ *
+ * \param ep The ID of the endpoint to be un-halted
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udd_ep_clear_halt(udd_ep_id_t ep);
+
+/**
+ * \brief Registers a callback to call when endpoint halt is cleared
+ *
+ * \param ep The ID of the endpoint to use
+ * \param callback NULL or function to call when endpoint halt is cleared
+ *
+ * \warning if the endpoint is not halted then the \a callback is called immediately.
+ *
+ * \return \c 1 if the register is accepted, otherwise \c 0.
+ */
+bool udd_ep_wait_stall_clear(udd_ep_id_t ep,
+ udd_callback_halt_cleared_t callback);
+
+/**
+ * \brief Allows to receive or send data on an endpoint
+ *
+ * The driver uses a specific DMA USB to transfer data
+ * from internal RAM to endpoint, if this one is available.
+ * When the transfer is finished or aborted (stall, reset, ...), the \a callback is called.
+ * The \a callback returns the transfer status and eventually the number of byte transfered.
+ * Note: The control endpoint is not authorized.
+ *
+ * \param ep The ID of the endpoint to use
+ * \param b_shortpacket Enabled automatic short packet
+ * \param buf Buffer on Internal RAM to send or fill.
+ * It must be align, then use COMPILER_WORD_ALIGNED.
+ * \param buf_size Buffer size to send or fill
+ * \param callback NULL or function to call at the end of transfer
+ *
+ * \warning About \a b_shortpacket, for IN endpoint it means that a short packet
+ * (or a Zero Length Packet) will be sent to the USB line to properly close the usb
+ * transfer at the end of the data transfer.
+ * For Bulk and Interrupt OUT endpoint, it will automatically stop the transfer
+ * at the end of the data transfer (received short packet).
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket,
+ uint8_t * buf, iram_size_t buf_size,
+ udd_callback_trans_t callback);
+/**
+ * \brief Aborts transfer on going on endpoint
+ *
+ * If a transfer is on going, then it is stopped and
+ * the callback registered is called to signal the end of transfer.
+ * Note: The control endpoint is not authorized.
+ *
+ * \param ep Endpoint to abort
+ */
+void udd_ep_abort(udd_ep_id_t ep);
+
+#endif
+
+//@}
+
+
+/**
+ * \name High speed test mode management
+ *
+ * The following functions allow the device to jump to a specific test mode required in high speed mode.
+ */
+//@{
+void udd_test_mode_j(void);
+void udd_test_mode_k(void);
+void udd_test_mode_se0_nak(void);
+void udd_test_mode_packet(void);
+//@}
+
+
+/**
+ * \name UDC callbacks to provide for UDD
+ *
+ * The following callbacks are used by UDD.
+ */
+//@{
+
+/**
+ * \brief Decodes and manages a setup request
+ *
+ * The driver call it when a SETUP packet is received.
+ * The \c udd_g_ctrlreq contains the data of SETUP packet.
+ * If this callback accepts the setup request then it must
+ * return \c 1 and eventually update \c udd_g_ctrlreq to send or receive data.
+ *
+ * \return \c 1 if the request is accepted, otherwise \c 0.
+ */
+extern bool udc_process_setup(void);
+
+/**
+ * \brief Reset the UDC
+ *
+ * The UDC must reset all configuration.
+ */
+extern void udc_reset(void);
+
+/**
+ * \brief To signal that a SOF is occurred
+ *
+ * The UDC must send the signal to all UDIs enabled
+ */
+extern void udc_sof_notify(void);
+
+//@}
+
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _UDD_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udd.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udd.h.REMOVED.git-id
deleted file mode 100644
index 4f90b2c0..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udd.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-10807f43d79e2ad521e08c907e549df8ce64bd36
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udi.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udi.h
new file mode 100644
index 00000000..1fc7ae5d
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udi.h
@@ -0,0 +1,133 @@
+/**
+ * \file
+ *
+ * \brief Common API for USB Device Interface
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _UDI_H_
+#define _UDI_H_
+
+#include "conf_usb.h"
+#include "usb_protocol.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup usb_device_group
+ * \defgroup udi_group USB Device Interface (UDI)
+ * The UDI provides a common API for all classes,
+ * and this is used by UDC for the main control of USB Device interface.
+ * @{
+ */
+
+/**
+ * \brief UDI API.
+ *
+ * The callbacks within this structure are called only by
+ * USB Device Controller (UDC)
+ *
+ * The udc_get_interface_desc() can be use by UDI to know the interface descriptor
+ * selected by UDC.
+ */
+typedef struct {
+ /**
+ * \brief Enable the interface.
+ *
+ * This function is called when the host selects a configuration
+ * to which this interface belongs through a Set Configuration
+ * request, and when the host selects an alternate setting of
+ * this interface through a Set Interface request.
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+ bool(*enable) (void);
+
+ /**
+ * \brief Disable the interface.
+ *
+ * This function is called when this interface is currently
+ * active, and
+ * - the host selects any configuration through a Set
+ * Configuration request, or
+ * - the host issues a USB reset, or
+ * - the device is detached from the host (i.e. Vbus is no
+ * longer present)
+ */
+ void (*disable) (void);
+
+ /**
+ * \brief Handle a control request directed at an interface.
+ *
+ * This function is called when this interface is currently
+ * active and the host sends a SETUP request
+ * with this interface as the recipient.
+ *
+ * Use udd_g_ctrlreq to decode and response to SETUP request.
+ *
+ * \return \c 1 if this interface supports the SETUP request, otherwise \c 0.
+ */
+ bool(*setup) (void);
+
+ /**
+ * \brief Returns the current setting of the selected interface.
+ *
+ * This function is called when UDC when know alternate setting of selected interface.
+ *
+ * \return alternate setting of selected interface
+ */
+ uint8_t(*getsetting) (void);
+
+ /**
+ * \brief To signal that a SOF is occurred
+ */
+ void(*sof_notify) (void);
+} udi_api_t;
+
+//@}
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _UDI_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udi.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udi.h.REMOVED.git-id
deleted file mode 100644
index 66f5daad..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/udc/udi.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1fc7ae5d01a43eec2181fb52327d80f8edde0f74
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_atmel.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_atmel.h
new file mode 100644
index 00000000..049459cc
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_atmel.h
@@ -0,0 +1,190 @@
+/**
+ * \file
+ *
+ * \brief All USB VIDs and PIDs from Atmel USB applications
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _USB_ATMEL_H_
+#define _USB_ATMEL_H_
+
+/**
+ * \defgroup usb_group USB Stack
+ *
+ * This stack includes the USB Device Stack, USB Host Stack and common
+ * definitions.
+ * @{
+ */
+
+//! @}
+
+/**
+ * \ingroup usb_group
+ * \defgroup usb_atmel_ids_group Atmel USB Identifiers
+ *
+ * This module defines Atmel PID and VIDs constants.
+ *
+ * @{
+ */
+
+//! \name Vendor Identifier assigned by USB org to ATMEL
+#define USB_VID_ATMEL 0x03EB
+
+
+//! \name Product Identifier assigned by ATMEL to AVR applications
+//! @{
+
+//! \name The range from 2000h to 20FFh is reserved to the old PID for C51, MEGA, and others.
+//! @{
+#define USB_PID_ATMEL_MEGA_HIDGENERIC 0x2013
+#define USB_PID_ATMEL_MEGA_HIDKEYBOARD 0x2017
+#define USB_PID_ATMEL_MEGA_CDC 0x2018
+#define USB_PID_ATMEL_MEGA_AUDIO_IN 0x2019
+#define USB_PID_ATMEL_MEGA_MS 0x201A
+#define USB_PID_ATMEL_MEGA_AUDIO_IN_OUT 0x201B
+#define USB_PID_ATMEL_MEGA_HIDMOUSE 0x201C
+#define USB_PID_ATMEL_MEGA_HIDMOUSE_CERTIF_U4 0x201D
+#define USB_PID_ATMEL_MEGA_CDC_MULTI 0x201E
+#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_USBKEY 0x2022
+#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_STK525 0x2023
+#define USB_PID_ATMEL_MEGA_MS_2 0x2029
+#define USB_PID_ATMEL_MEGA_MS_HIDMS 0x202A
+#define USB_PID_ATMEL_MEGA_MS_3 0x2032
+#define USB_PID_ATMEL_MEGA_LIBUSB 0x2050
+//! @}
+
+//! \name The range 2100h to 21FFh is reserved to PIDs for AVR Tools.
+//! @{
+#define USB_PID_ATMEL_XPLAINED 0x2122
+#define USB_PID_ATMEL_XMEGA_USB_ZIGBIT_2_4GHZ 0x214A
+#define USB_PID_ATMEL_XMEGA_USB_ZIGBIT_SUBGHZ 0x214B
+//! @}
+
+//! \name The range 2300h to 23FFh is reserved to PIDs for demo from ASF1.7=>
+//! @{
+#define USB_PID_ATMEL_UC3_ENUM 0x2300
+#define USB_PID_ATMEL_UC3_MS 0x2301
+#define USB_PID_ATMEL_UC3_MS_SDRAM_LOADER 0x2302
+#define USB_PID_ATMEL_UC3_EVK1100_CTRLPANEL 0x2303
+#define USB_PID_ATMEL_UC3_HID 0x2304
+#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID 0x2305
+#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID_MS 0x2306
+#define USB_PID_ATMEL_UC3_CDC 0x2307
+#define USB_PID_ATMEL_UC3_AUDIO_MICRO 0x2308
+#define USB_PID_ATMEL_UC3_CDC_DEBUG 0x2310 // Virtual Com (debug interface) on EVK11xx
+#define USB_PID_ATMEL_UC3_AUDIO_SPEAKER_MICRO 0x2311
+#define USB_PID_ATMEL_UC3_CDC_MSC 0x2312
+//! @}
+
+//! \name The range 2400h to 24FFh is reserved to PIDs for ASF applications
+//! @{
+#define USB_PID_ATMEL_ASF_HIDMOUSE 0x2400
+#define USB_PID_ATMEL_ASF_HIDKEYBOARD 0x2401
+#define USB_PID_ATMEL_ASF_HIDGENERIC 0x2402
+#define USB_PID_ATMEL_ASF_MSC 0x2403
+#define USB_PID_ATMEL_ASF_CDC 0x2404
+#define USB_PID_ATMEL_ASF_PHDC 0x2405
+#define USB_PID_ATMEL_ASF_MSC_HIDMOUSE 0x2420
+#define USB_PID_ATMEL_ASF_MSC_HIDS_CDC 0x2421
+#define USB_PID_ATMEL_ASF_MSC_HIDKEYBOARD 0x2422
+#define USB_PID_ATMEL_ASF_VENDOR_CLASS 0x2423
+#define USB_PID_ATMEL_ASF_MSC_CDC 0x2424
+#define USB_PID_ATMEL_ASF_TWO_CDC 0x2425
+#define USB_PID_ATMEL_ASF_SEVEN_CDC 0x2426
+#define USB_PID_ATMEL_ASF_XPLAIN_BC_POWERONLY 0x2430
+#define USB_PID_ATMEL_ASF_XPLAIN_BC_TERMINAL 0x2431
+#define USB_PID_ATMEL_ASF_XPLAIN_BC_TOUCH 0x2432
+#define USB_PID_ATMEL_ASF_AUDIO_SPEAKER 0x2433
+#define USB_PID_ATMEL_ASF_XMEGA_B1_XPLAINED 0x2434
+//! @}
+
+//! \name The range 2F00h to 2FFFh is reserved to official PIDs for AVR bootloaders
+//! Note, !!!! don't use this range for demos or examples !!!!
+//! @{
+#define USB_PID_ATMEL_DFU_ATXMEGA64C3 0x2FD6
+#define USB_PID_ATMEL_DFU_ATXMEGA128C3 0x2FD7
+#define USB_PID_ATMEL_DFU_ATXMEGA16C4 0x2FD8
+#define USB_PID_ATMEL_DFU_ATXMEGA32C4 0x2FD9
+#define USB_PID_ATMEL_DFU_ATXMEGA256C3 0x2FDA
+#define USB_PID_ATMEL_DFU_ATXMEGA384C3 0x2FDB
+#define USB_PID_ATMEL_DFU_ATUCL3_L4 0x2FDC
+#define USB_PID_ATMEL_DFU_ATXMEGA64A4U 0x2FDD
+#define USB_PID_ATMEL_DFU_ATXMEGA128A4U 0x2FDE
+
+#define USB_PID_ATMEL_DFU_ATXMEGA64B3 0x2FDF
+#define USB_PID_ATMEL_DFU_ATXMEGA128B3 0x2FE0
+#define USB_PID_ATMEL_DFU_ATXMEGA64B1 0x2FE1
+#define USB_PID_ATMEL_DFU_ATXMEGA256A3BU 0x2FE2
+#define USB_PID_ATMEL_DFU_ATXMEGA16A4U 0x2FE3
+#define USB_PID_ATMEL_DFU_ATXMEGA32A4U 0x2FE4
+#define USB_PID_ATMEL_DFU_ATXMEGA64A3U 0x2FE5
+#define USB_PID_ATMEL_DFU_ATXMEGA128A3U 0x2FE6
+#define USB_PID_ATMEL_DFU_ATXMEGA192A3U 0x2FE7
+#define USB_PID_ATMEL_DFU_ATXMEGA64A1U 0x2FE8
+#define USB_PID_ATMEL_DFU_ATUC3D 0x2FE9
+#define USB_PID_ATMEL_DFU_ATXMEGA128B1 0x2FEA
+#define USB_PID_ATMEL_DFU_AT32UC3C 0x2FEB
+#define USB_PID_ATMEL_DFU_ATXMEGA256A3U 0x2FEC
+#define USB_PID_ATMEL_DFU_ATXMEGA128A1U 0x2FED
+#define USB_PID_ATMEL_DFU_ATMEGA8U2 0x2FEE
+#define USB_PID_ATMEL_DFU_ATMEGA16U2 0x2FEF
+#define USB_PID_ATMEL_DFU_ATMEGA32U2 0x2FF0
+#define USB_PID_ATMEL_DFU_AT32UC3A3 0x2FF1
+#define USB_PID_ATMEL_DFU_ATMEGA32U6 0x2FF2
+#define USB_PID_ATMEL_DFU_ATMEGA16U4 0x2FF3
+#define USB_PID_ATMEL_DFU_ATMEGA32U4 0x2FF4
+#define USB_PID_ATMEL_DFU_AT32AP7200 0x2FF5
+#define USB_PID_ATMEL_DFU_AT32UC3B 0x2FF6
+#define USB_PID_ATMEL_DFU_AT90USB82 0x2FF7
+#define USB_PID_ATMEL_DFU_AT32UC3A 0x2FF8
+#define USB_PID_ATMEL_DFU_AT90USB64 0x2FF9
+#define USB_PID_ATMEL_DFU_AT90USB162 0x2FFA
+#define USB_PID_ATMEL_DFU_AT90USB128 0x2FFB
+// 2FFCh to 2FFFh used by C51 family products
+//! @}
+
+//! @}
+
+//! @}
+
+
+#endif // _USB_ATMEL_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_atmel.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_atmel.h.REMOVED.git-id
deleted file mode 100644
index c48c06d6..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_atmel.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-049459cc1040ae3651b953c3cf070c0a3cea6224
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_protocol.h b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_protocol.h
new file mode 100644
index 00000000..0b532938
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_protocol.h
@@ -0,0 +1,505 @@
+/**
+ * \file
+ *
+ * \brief USB protocol definitions.
+ *
+ * This file contains the USB definitions and data structures provided by the
+ * USB 2.0 specification.
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _USB_PROTOCOL_H_
+#define _USB_PROTOCOL_H_
+
+#include "usb_atmel.h"
+
+/**
+ * \ingroup usb_group
+ * \defgroup usb_protocol_group USB Protocol Definitions
+ *
+ * This module defines constants and data structures provided by the USB
+ * 2.0 specification.
+ *
+ * @{
+ */
+
+//! Value for field bcdUSB
+#define USB_V2_0 0x0200 //!< USB Specification version 2.00
+#define USB_V2_1 0x0201 //!< USB Specification version 2.01
+
+/*! \name Generic definitions (Class, subclass and protocol)
+ */
+//! @{
+#define NO_CLASS 0x00
+#define CLASS_VENDOR_SPECIFIC 0xFF
+#define NO_SUBCLASS 0x00
+#define NO_PROTOCOL 0x00
+//! @}
+
+//! \name IAD (Interface Association Descriptor) constants
+//! @{
+#define CLASS_IAD 0xEF
+#define SUB_CLASS_IAD 0x02
+#define PROTOCOL_IAD 0x01
+//! @}
+
+/**
+ * \brief USB request data transfer direction (bmRequestType)
+ */
+#define USB_REQ_DIR_OUT (0<<7) //!< Host to device
+#define USB_REQ_DIR_IN (1<<7) //!< Device to host
+#define USB_REQ_DIR_MASK (1<<7) //!< Mask
+
+/**
+ * \brief USB request types (bmRequestType)
+ */
+#define USB_REQ_TYPE_STANDARD (0<<5) //!< Standard request
+#define USB_REQ_TYPE_CLASS (1<<5) //!< Class-specific request
+#define USB_REQ_TYPE_VENDOR (2<<5) //!< Vendor-specific request
+#define USB_REQ_TYPE_MASK (3<<5) //!< Mask
+
+/**
+ * \brief USB recipient codes (bmRequestType)
+ */
+#define USB_REQ_RECIP_DEVICE (0<<0) //!< Recipient device
+#define USB_REQ_RECIP_INTERFACE (1<<0) //!< Recipient interface
+#define USB_REQ_RECIP_ENDPOINT (2<<0) //!< Recipient endpoint
+#define USB_REQ_RECIP_OTHER (3<<0) //!< Recipient other
+#define USB_REQ_RECIP_MASK (0x1F) //!< Mask
+
+/**
+ * \brief Standard USB requests (bRequest)
+ */
+enum usb_reqid {
+ USB_REQ_GET_STATUS = 0,
+ USB_REQ_CLEAR_FEATURE = 1,
+ USB_REQ_SET_FEATURE = 3,
+ USB_REQ_SET_ADDRESS = 5,
+ USB_REQ_GET_DESCRIPTOR = 6,
+ USB_REQ_SET_DESCRIPTOR = 7,
+ USB_REQ_GET_CONFIGURATION = 8,
+ USB_REQ_SET_CONFIGURATION = 9,
+ USB_REQ_GET_INTERFACE = 10,
+ USB_REQ_SET_INTERFACE = 11,
+ USB_REQ_SYNCH_FRAME = 12,
+};
+
+/**
+ * \brief Standard USB device status flags
+ *
+ */
+enum usb_device_status {
+ USB_DEV_STATUS_BUS_POWERED = 0,
+ USB_DEV_STATUS_SELF_POWERED = 1,
+ USB_DEV_STATUS_REMOTEWAKEUP = 2
+};
+
+/**
+ * \brief Standard USB Interface status flags
+ *
+ */
+enum usb_interface_status {
+ USB_IFACE_STATUS_RESERVED = 0
+};
+
+/**
+ * \brief Standard USB endpoint status flags
+ *
+ */
+enum usb_endpoint_status {
+ USB_EP_STATUS_HALTED = 1,
+};
+
+/**
+ * \brief Standard USB device feature flags
+ *
+ * \note valid for SetFeature request.
+ */
+enum usb_device_feature {
+ USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled
+ USB_DEV_FEATURE_TEST_MODE = 2, //!< USB test mode
+ USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3,
+ USB_DEV_FEATURE_OTG_A_HNP_SUPPORT = 4,
+ USB_DEV_FEATURE_OTG_A_ALT_HNP_SUPPORT = 5
+};
+
+/**
+ * \brief Test Mode possible on HS USB device
+ *
+ * \note valid for USB_DEV_FEATURE_TEST_MODE request.
+ */
+enum usb_device_hs_test_mode {
+ USB_DEV_TEST_MODE_J = 1,
+ USB_DEV_TEST_MODE_K = 2,
+ USB_DEV_TEST_MODE_SE0_NAK = 3,
+ USB_DEV_TEST_MODE_PACKET = 4,
+ USB_DEV_TEST_MODE_FORCE_ENABLE = 5,
+};
+
+/**
+ * \brief Standard USB endpoint feature/status flags
+ */
+enum usb_endpoint_feature {
+ USB_EP_FEATURE_HALT = 0,
+};
+
+/**
+ * \brief Standard USB Test Mode Selectors
+ */
+enum usb_test_mode_selector {
+ USB_TEST_J = 0x01,
+ USB_TEST_K = 0x02,
+ USB_TEST_SE0_NAK = 0x03,
+ USB_TEST_PACKET = 0x04,
+ USB_TEST_FORCE_ENABLE = 0x05,
+};
+
+/**
+ * \brief Standard USB descriptor types
+ */
+enum usb_descriptor_type {
+ USB_DT_DEVICE = 1,
+ USB_DT_CONFIGURATION = 2,
+ USB_DT_STRING = 3,
+ USB_DT_INTERFACE = 4,
+ USB_DT_ENDPOINT = 5,
+ USB_DT_DEVICE_QUALIFIER = 6,
+ USB_DT_OTHER_SPEED_CONFIGURATION = 7,
+ USB_DT_INTERFACE_POWER = 8,
+ USB_DT_OTG = 9,
+ USB_DT_IAD = 0x0B,
+ USB_DT_BOS = 0x0F,
+ USB_DT_DEVICE_CAPABILITY = 0x10,
+};
+
+/**
+ * \brief USB Device Capability types
+ */
+enum usb_capability_type {
+ USB_DC_USB20_EXTENSION = 0x02,
+};
+
+/**
+ * \brief USB Device Capability - USB 2.0 Extension
+ * To fill bmAttributes field of usb_capa_ext_desc_t structure.
+ */
+enum usb_capability_extension_attr {
+ USB_DC_EXT_LPM = 0x00000002,
+ USB_DC_EXT_BESL = 0x00000004,
+ USB_DC_EXT_BESL_BASELINE_VALID = 0x00000008,
+ USB_DC_EXT_BESL_DEEP_VALID = 0x00000010,
+};
+#define USB_DC_EXT_BESL_DEEP_OFFSET 8
+#define USB_DC_EXT_BESL_DEEP(besl) ((besl & 0xF) << USB_DC_EXT_BESL_DEEP_OFFSET)
+#define USB_DC_EXT_BESL_BASELINE_OFFSET 12
+#define USB_DC_EXT_BESL_BASELINE(besl) ((besl & 0xF) << USB_DC_EXT_BESL_BASELINE_OFFSET)
+
+#define BESL_125_US 0
+#define BESL_150_US 1
+#define BESL_200_US 2
+#define BESL_300_US 3
+#define BESL_400_US 4
+#define BESL_500_US 5
+#define BESL_1000_US 6
+#define BESL_2000_US 7
+#define BESL_3000_US 8
+#define BESL_4000_US 9
+#define BESL_5000_US 10
+#define BESL_6000_US 11
+#define BESL_7000_US 12
+#define BESL_8000_US 13
+#define BESL_9000_US 14
+#define BESL_10000_US 15
+
+/** Fields definition from a LPM TOKEN */
+#define USB_LPM_ATTRIBUT_BLINKSTATE_MASK (0xF << 0)
+#define USB_LPM_ATTRIBUT_BESL_MASK (0xF << 4)
+#define USB_LPM_ATTRIBUT_REMOTEWAKE_MASK (1 << 8)
+#define USB_LPM_ATTRIBUT_BLINKSTATE(value) ((value & 0xF) << 0)
+#define USB_LPM_ATTRIBUT_BESL(value) ((value & 0xF) << 4)
+#define USB_LPM_ATTRIBUT_REMOTEWAKE(value) ((value & 1) << 8)
+#define USB_LPM_ATTRIBUT_BLINKSTATE_L1 USB_LPM_ATTRIBUT_BLINKSTATE(1)
+
+/**
+ * \brief Standard USB endpoint transfer types
+ */
+enum usb_ep_type {
+ USB_EP_TYPE_CONTROL = 0x00,
+ USB_EP_TYPE_ISOCHRONOUS = 0x01,
+ USB_EP_TYPE_BULK = 0x02,
+ USB_EP_TYPE_INTERRUPT = 0x03,
+ USB_EP_TYPE_MASK = 0x03,
+};
+
+/**
+ * \brief Standard USB language IDs for string descriptors
+ */
+enum usb_langid {
+ USB_LANGID_EN_US = 0x0409, //!< English (United States)
+};
+
+/**
+ * \brief Mask selecting the index part of an endpoint address
+ */
+#define USB_EP_ADDR_MASK 0x0f
+
+//! \brief USB address identifier
+typedef uint8_t usb_add_t;
+
+/**
+ * \brief Endpoint transfer direction is IN
+ */
+#define USB_EP_DIR_IN 0x80
+
+/**
+ * \brief Endpoint transfer direction is OUT
+ */
+#define USB_EP_DIR_OUT 0x00
+
+//! \brief Endpoint identifier
+typedef uint8_t usb_ep_t;
+
+/**
+ * \brief Maximum length in bytes of a USB descriptor
+ *
+ * The maximum length of a USB descriptor is limited by the 8-bit
+ * bLength field.
+ */
+#define USB_MAX_DESC_LEN 255
+
+/*
+ * 2-byte alignment requested for all USB structures.
+ */
+COMPILER_PACK_SET(1)
+
+/**
+ * \brief A USB Device SETUP request
+ *
+ * The data payload of SETUP packets always follows this structure.
+ */
+typedef struct {
+ uint8_t bmRequestType;
+ uint8_t bRequest;
+ le16_t wValue;
+ le16_t wIndex;
+ le16_t wLength;
+} usb_setup_req_t;
+
+/**
+ * \brief Standard USB device descriptor structure
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ le16_t bcdUSB;
+ uint8_t bDeviceClass;
+ uint8_t bDeviceSubClass;
+ uint8_t bDeviceProtocol;
+ uint8_t bMaxPacketSize0;
+ le16_t idVendor;
+ le16_t idProduct;
+ le16_t bcdDevice;
+ uint8_t iManufacturer;
+ uint8_t iProduct;
+ uint8_t iSerialNumber;
+ uint8_t bNumConfigurations;
+} usb_dev_desc_t;
+
+/**
+ * \brief Standard USB device qualifier descriptor structure
+ *
+ * This descriptor contains information about the device when running at
+ * the "other" speed (i.e. if the device is currently operating at high
+ * speed, this descriptor can be used to determine what would change if
+ * the device was operating at full speed.)
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ le16_t bcdUSB;
+ uint8_t bDeviceClass;
+ uint8_t bDeviceSubClass;
+ uint8_t bDeviceProtocol;
+ uint8_t bMaxPacketSize0;
+ uint8_t bNumConfigurations;
+ uint8_t bReserved;
+} usb_dev_qual_desc_t;
+
+/**
+ * \brief USB Device BOS descriptor structure
+ *
+ * The BOS descriptor (Binary device Object Store) defines a root
+ * descriptor that is similar to the configuration descriptor, and is
+ * the base descriptor for accessing a family of related descriptors.
+ * A host can read a BOS descriptor and learn from the wTotalLength field
+ * the entire size of the device-level descriptor set, or it can read in
+ * the entire BOS descriptor set of device capabilities.
+ * The host accesses this descriptor using the GetDescriptor() request.
+ * The descriptor type in the GetDescriptor() request is set to BOS.
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ le16_t wTotalLength;
+ uint8_t bNumDeviceCaps;
+} usb_dev_bos_desc_t;
+
+
+/**
+ * \brief USB Device Capabilities - USB 2.0 Extension Descriptor structure
+ *
+ * Defines the set of USB 1.1-specific device level capabilities.
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bDevCapabilityType;
+ le32_t bmAttributes;
+} usb_dev_capa_ext_desc_t;
+
+/**
+ * \brief USB Device LPM Descriptor structure
+ *
+ * The BOS descriptor and capabilities descriptors for LPM.
+ */
+typedef struct {
+ usb_dev_bos_desc_t bos;
+ usb_dev_capa_ext_desc_t capa_ext;
+} usb_dev_lpm_desc_t;
+
+/**
+ * \brief Standard USB Interface Association Descriptor structure
+ */
+typedef struct {
+ uint8_t bLength; //!< size of this descriptor in bytes
+ uint8_t bDescriptorType; //!< INTERFACE descriptor type
+ uint8_t bFirstInterface; //!< Number of interface
+ uint8_t bInterfaceCount; //!< value to select alternate setting
+ uint8_t bFunctionClass; //!< Class code assigned by the USB
+ uint8_t bFunctionSubClass;//!< Sub-class code assigned by the USB
+ uint8_t bFunctionProtocol;//!< Protocol code assigned by the USB
+ uint8_t iFunction; //!< Index of string descriptor
+} usb_association_desc_t;
+
+
+/**
+ * \brief Standard USB configuration descriptor structure
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ le16_t wTotalLength;
+ uint8_t bNumInterfaces;
+ uint8_t bConfigurationValue;
+ uint8_t iConfiguration;
+ uint8_t bmAttributes;
+ uint8_t bMaxPower;
+} usb_conf_desc_t;
+
+
+#define USB_CONFIG_ATTR_MUST_SET (1 << 7) //!< Must always be set
+#define USB_CONFIG_ATTR_BUS_POWERED (0 << 6) //!< Bus-powered
+#define USB_CONFIG_ATTR_SELF_POWERED (1 << 6) //!< Self-powered
+#define USB_CONFIG_ATTR_REMOTE_WAKEUP (1 << 5) //!< remote wakeup supported
+
+#define USB_CONFIG_MAX_POWER(ma) (((ma) + 1) / 2) //!< Max power in mA
+
+/**
+ * \brief Standard USB association descriptor structure
+ */
+typedef struct {
+ uint8_t bLength; //!< Size of this descriptor in bytes
+ uint8_t bDescriptorType; //!< Interface descriptor type
+ uint8_t bFirstInterface; //!< Number of interface
+ uint8_t bInterfaceCount; //!< value to select alternate setting
+ uint8_t bFunctionClass; //!< Class code assigned by the USB
+ uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB
+ uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB
+ uint8_t iFunction; //!< Index of string descriptor
+} usb_iad_desc_t;
+
+/**
+ * \brief Standard USB interface descriptor structure
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bInterfaceNumber;
+ uint8_t bAlternateSetting;
+ uint8_t bNumEndpoints;
+ uint8_t bInterfaceClass;
+ uint8_t bInterfaceSubClass;
+ uint8_t bInterfaceProtocol;
+ uint8_t iInterface;
+} usb_iface_desc_t;
+
+/**
+ * \brief Standard USB endpoint descriptor structure
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bEndpointAddress;
+ uint8_t bmAttributes;
+ le16_t wMaxPacketSize;
+ uint8_t bInterval;
+} usb_ep_desc_t;
+
+
+/**
+ * \brief A standard USB string descriptor structure
+ */
+typedef struct {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+} usb_str_desc_t;
+
+typedef struct {
+ usb_str_desc_t desc;
+ le16_t string[1];
+} usb_str_lgid_desc_t;
+
+COMPILER_PACK_RESET()
+
+//! @}
+
+#endif /* _USB_PROTOCOL_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_protocol.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_protocol.h.REMOVED.git-id
deleted file mode 100644
index cb7e03ae..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/services/usb/usb_protocol.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0b532938d869768db918ec20ab880c0db3a2335b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt.h b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt.h
new file mode 100644
index 00000000..80401572
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt.h
@@ -0,0 +1,142 @@
+/**
+ * \file
+ *
+ * \brief Global interrupt management for 8- and 32-bit AVR
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef UTILS_INTERRUPT_H
+#define UTILS_INTERRUPT_H
+
+#include
+
+#if XMEGA || MEGA || TINY
+# include "interrupt/interrupt_avr8.h"
+#elif UC3
+# include "interrupt/interrupt_avr32.h"
+#elif SAM
+# include "interrupt/interrupt_sam_nvic.h"
+#else
+# error Unsupported device.
+#endif
+
+/**
+ * \defgroup interrupt_group Global interrupt management
+ *
+ * This is a driver for global enabling and disabling of interrupts.
+ *
+ * @{
+ */
+
+#if defined(__DOXYGEN__)
+/**
+ * \def CONFIG_INTERRUPT_FORCE_INTC
+ * \brief Force usage of the ASF INTC driver
+ *
+ * Predefine this symbol when preprocessing to force the use of the ASF INTC driver.
+ * This is useful to ensure compatibility across compilers and shall be used only when required
+ * by the application needs.
+ */
+# define CONFIG_INTERRUPT_FORCE_INTC
+#endif
+
+//! \name Global interrupt flags
+//@{
+/**
+ * \typedef irqflags_t
+ * \brief Type used for holding state of interrupt flag
+ */
+
+/**
+ * \def cpu_irq_enable
+ * \brief Enable interrupts globally
+ */
+
+/**
+ * \def cpu_irq_disable
+ * \brief Disable interrupts globally
+ */
+
+/**
+ * \fn irqflags_t cpu_irq_save(void)
+ * \brief Get and clear the global interrupt flags
+ *
+ * Use in conjunction with \ref cpu_irq_restore.
+ *
+ * \return Current state of interrupt flags.
+ *
+ * \note This function leaves interrupts disabled.
+ */
+
+/**
+ * \fn void cpu_irq_restore(irqflags_t flags)
+ * \brief Restore global interrupt flags
+ *
+ * Use in conjunction with \ref cpu_irq_save.
+ *
+ * \param flags State to set interrupt flag to.
+ */
+
+/**
+ * \fn bool cpu_irq_is_enabled_flags(irqflags_t flags)
+ * \brief Check if interrupts are globally enabled in supplied flags
+ *
+ * \param flags Currents state of interrupt flags.
+ *
+ * \return True if interrupts are enabled.
+ */
+
+/**
+ * \def cpu_irq_is_enabled
+ * \brief Check if interrupts are globally enabled
+ *
+ * \return True if interrupts are enabled.
+ */
+//@}
+
+//! @}
+
+/**
+ * \ingroup interrupt_group
+ * \defgroup interrupt_deprecated_group Deprecated interrupt definitions
+ */
+
+#endif /* UTILS_INTERRUPT_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt.h.REMOVED.git-id
deleted file mode 100644
index f5ac3ef7..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8040157237414e1f5865d2c638c7d15ef621dd5f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt/interrupt_avr8.h b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt/interrupt_avr8.h
new file mode 100644
index 00000000..1c55fb29
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt/interrupt_avr8.h
@@ -0,0 +1,148 @@
+/**
+ * \file
+ *
+ * \brief Global interrupt management for 8-bit AVR
+ *
+ * Copyright (C) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef UTILS_INTERRUPT_INTERRUPT_H
+#define UTILS_INTERRUPT_INTERRUPT_H
+
+#include
+#include
+
+/**
+ * \weakgroup interrupt_group
+ *
+ * @{
+ */
+
+#ifdef ISR_CUSTOM_H
+# include ISR_CUSTOM_H
+#else
+
+/**
+ * \def ISR
+ * \brief Define service routine for specified interrupt vector
+ *
+ * Usage:
+ * \code
+ ISR(FOO_vect)
+ {
+ ...
+ }
+\endcode
+ *
+ * \param vect Interrupt vector name as found in the device header files.
+ */
+#if defined(__DOXYGEN__)
+# define ISR(vect)
+#elif defined(__GNUC__)
+# include
+#elif defined(__ICCAVR__)
+# define __ISR(x) _Pragma(#x)
+# define ISR(vect) __ISR(vector=vect) __interrupt void handler_##vect(void)
+#endif
+#endif // ISR_CUSTOM_H
+
+#if XMEGA
+/**
+ * \brief Initialize interrupt vectors
+ * Enables all interrupt levels, with vectors located in the application section
+ * and fixed priority scheduling.
+ */
+#define irq_initialize_vectors() \
+ PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm;
+#elif MEGA_RF
+#define irq_initialize_vectors()
+#endif
+
+#ifdef __GNUC__
+# define cpu_irq_enable() sei()
+# define cpu_irq_disable() cli()
+#else
+# define cpu_irq_enable() __enable_interrupt()
+# define cpu_irq_disable() __disable_interrupt()
+#endif
+
+typedef uint8_t irqflags_t;
+
+static inline irqflags_t cpu_irq_save(void)
+{
+ irqflags_t flags = SREG;
+ cpu_irq_disable();
+ return flags;
+}
+
+static inline void cpu_irq_restore(irqflags_t flags)
+{
+ barrier();
+ SREG = flags;
+}
+
+static inline bool cpu_irq_is_enabled_flags(irqflags_t flags)
+{
+#if XMEGA
+# ifdef __GNUC__
+ return flags & CPU_I_bm;
+# else
+ return flags & I_bm;
+# endif
+#elif MEGA || TINY
+ return flags & (1 << SREG_I);
+#endif
+}
+
+#define cpu_irq_is_enabled() cpu_irq_is_enabled_flags(SREG)
+
+//! @}
+
+/**
+ * \weakgroup interrupt_deprecated_group
+ * @{
+ */
+// Deprecated definitions.
+#define Enable_global_interrupt() cpu_irq_enable()
+#define Disable_global_interrupt() cpu_irq_disable()
+#define Is_global_interrupt_enabled() cpu_irq_is_enabled()
+//! @}
+
+#endif /* UTILS_INTERRUPT_INTERRUPT_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt/interrupt_avr8.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt/interrupt_avr8.h.REMOVED.git-id
deleted file mode 100644
index e5d6c122..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/interrupt/interrupt_avr8.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1c55fb290d29fa6f8a5a8dd0ace44842db9ab27b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/make/Makefile.avr.in b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/make/Makefile.avr.in
new file mode 100644
index 00000000..5d9a8375
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/make/Makefile.avr.in
@@ -0,0 +1,483 @@
+# List of available make goals:
+#
+# all Default target, builds the project
+# clean Clean up the project
+# rebuild Rebuild the project
+#
+# doc Build the documentation
+# cleandoc Clean up the documentation
+# rebuilddoc Rebuild the documentation
+#
+#
+# Copyright (c) 2009 - 2013 Atmel Corporation. All rights reserved.
+#
+# \asf_license_start
+#
+# \page License
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. The name of Atmel may not be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# 4. This software may only be redistributed and used in connection with an
+# Atmel microcontroller product.
+#
+# THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+# EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# \asf_license_stop
+#
+
+# Include the config.mk file from the current working path, e.g., where the
+# user called make.
+include config.mk
+
+# Tool to use to generate documentation from the source code
+DOCGEN ?= doxygen
+
+# Look for source files relative to the top-level source directory
+VPATH := $(PRJ_PATH)
+
+# Output target file
+target := $(TARGET)
+
+# Output project name (target name minus suffix)
+project := $(basename $(target))
+
+# Output target file (typically ELF or static library)
+ifeq ($(suffix $(target)),.a)
+target_type := lib
+else
+ifeq ($(suffix $(target)),.elf)
+target_type := elf
+else
+$(error "Target type $(target_type) is not supported")
+endif
+endif
+
+# Allow override of operating system detection. The user can add OS=Linux or
+# OS=Windows on the command line to explicit set the host OS.
+#
+# This allows to work around broken uname utility on certain systems.
+ifdef OS
+ ifeq ($(strip $(OS)), Linux)
+ os_type := Linux
+ endif
+ ifeq ($(strip $(OS)), Windows)
+ os_type := windows32_64
+ endif
+endif
+
+os_type ?= $(strip $(shell uname))
+
+ifeq ($(os_type),windows32)
+os := Windows
+else
+ifeq ($(os_type),windows64)
+os := Windows
+else
+ifeq ($(os_type),windows32_64)
+os ?= Windows
+else
+ifeq ($(os_type),)
+os := Windows
+else
+# Default to Linux style operating system. Both Cygwin and mingw are fully
+# compatible (for this Makefile) with Linux.
+os := Linux
+endif
+endif
+endif
+endif
+
+# Output documentation directory and configuration file.
+docdir := ../doxygen/html
+doccfg := ../doxygen/doxyfile.doxygen
+
+CROSS ?= avr-
+AR := $(CROSS)ar
+AS := $(CROSS)as
+CC := $(CROSS)gcc
+CPP := $(CROSS)gcc -E
+CXX := $(CROSS)g++
+LD := $(CROSS)gcc
+NM := $(CROSS)nm
+OBJCOPY := $(CROSS)objcopy
+OBJDUMP := $(CROSS)objdump
+SIZE := $(CROSS)size
+
+RM := rm
+ifeq ($(os),Windows)
+RMDIR := rmdir /S /Q
+else
+RMDIR := rmdir -p --ignore-fail-on-non-empty
+endif
+
+# On Windows, we need to override the shell to force the use of cmd.exe
+ifeq ($(os),Windows)
+SHELL := cmd
+endif
+
+# Strings for beautifying output
+MSG_CLEAN_FILES = "RM *.o *.d"
+MSG_CLEAN_DIRS = "RMDIR $(strip $(clean-dirs))"
+MSG_CLEAN_DOC = "RMDIR $(docdir)"
+MSG_MKDIR = "MKDIR $(dir $@)"
+
+MSG_INFO = "INFO "
+MSG_PREBUILD = "PREBUILD $(PREBUILD_CMD)"
+MSG_POSTBUILD = "POSTBUILD $(POSTBUILD_CMD)"
+
+MSG_ARCHIVING = "AR $@"
+MSG_ASSEMBLING = "AS $@"
+MSG_BINARY_IMAGE = "OBJCOPY $@"
+MSG_COMPILING = "CC $@"
+MSG_COMPILING_CXX = "CXX $@"
+MSG_EEPROM_IMAGE = "OBJCOPY $@"
+MSG_EXTENDED_LISTING = "OBJDUMP $@"
+MSG_IHEX_IMAGE = "OBJCOPY $@"
+MSG_LINKING = "LN $@"
+MSG_PREPROCESSING = "CPP $@"
+MSG_SIZE = "SIZE $@"
+MSG_SYMBOL_TABLE = "NM $@"
+
+MSG_GENERATING_DOC = "DOXYGEN $(docdir)"
+
+# Don't use make's built-in rules and variables
+MAKEFLAGS += -rR
+
+# Don't print 'Entering directory ...'
+MAKEFLAGS += --no-print-directory
+
+# Function for reversing the order of a list
+reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
+
+# Hide command output by default, but allow the user to override this
+# by adding V=1 on the command line.
+#
+# This is inspired by the Kbuild system used by the Linux kernel.
+ifdef V
+ ifeq ("$(origin V)", "command line")
+ VERBOSE = $(V)
+ endif
+endif
+ifndef VERBOSE
+ VERBOSE = 0
+endif
+
+ifeq ($(VERBOSE), 1)
+ Q =
+else
+ Q = @
+endif
+
+arflags-gnu-y := $(ARFLAGS)
+asflags-gnu-y := $(ASFLAGS)
+cflags-gnu-y := $(CFLAGS)
+cxxflags-gnu-y := $(CXXFLAGS)
+cppflags-gnu-y := $(CPPFLAGS)
+cpuflags-gnu-y :=
+dbgflags-gnu-y := $(DBGFLAGS)
+libflags-gnu-y := $(foreach LIB,$(LIBS),-l$(LIB))
+ldflags-gnu-y := $(LDFLAGS)
+flashflags-gnu-y := $(FLASHFLAGS)
+eepromflags-gnu-y := $(EEPROMFLAGS)
+clean-files :=
+clean-dirs :=
+
+clean-files += $(wildcard $(target) $(project).map)
+clean-files += $(wildcard $(project).hex $(project).eep)
+clean-files += $(wildcard $(project).lss $(project).sym)
+clean-files += $(wildcard $(build))
+
+# Use pipes instead of temporary files for communication between processes
+cflags-gnu-y += -pipe
+asflags-gnu-y += -pipe
+ldflags-gnu-y += -pipe
+
+# Archiver flags.
+arflags-gnu-y += rcs
+
+# Always enable warnings. And be very careful about implicit
+# declarations.
+cflags-gnu-y += -Wall -Wstrict-prototypes -Wmissing-prototypes
+cflags-gnu-y += -Werror-implicit-function-declaration
+cxxflags-gnu-y += -Wall
+# IAR doesn't allow arithmetic on void pointers, so warn about that.
+cflags-gnu-y += -Wpointer-arith
+cxxflags-gnu-y += -Wpointer-arith
+
+# Preprocessor flags.
+cppflags-gnu-y += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),-I$(INC))
+asflags-gnu-y += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),'-Wa,-I$(INC)')
+
+# CPU specific flags.
+cpuflags-gnu-y += -mmcu=$(MCU)
+
+# Dependency file flags.
+depflags = -MD -MP -MQ $@
+
+# Debug specific flags.
+ifdef BUILD_DEBUG_LEVEL
+dbgflags-gnu-y += -g$(BUILD_DEBUG_LEVEL)
+else
+dbgflags-gnu-y += -gdwarf-2
+endif
+
+# Optimization specific flags.
+ifdef BUILD_OPTIMIZATION
+optflags-gnu-y = -O$(BUILD_OPTIMIZATION)
+else
+optflags-gnu-y = $(OPTIMIZATION)
+endif
+
+# Relax compilation and linking.
+cflags-gnu-y += -mrelax
+cxxflags-gnu-y += -mrelax
+asflags-gnu-y += -mrelax
+ldflags-gnu-y += -Wl,--relax
+
+# Always preprocess assembler files.
+asflags-gnu-y += -x assembler-with-cpp
+# Compile C files using the GNU99 standard.
+cflags-gnu-y += -std=gnu99
+# Compile C++ files using the GNU++98 standard.
+cxxflags-gnu-y += -std=gnu++98
+
+# Use unsigned character type when compiling.
+cflags-gnu-y += -funsigned-char
+cxxflags-gnu-y += -funsigned-char
+
+# Don't use strict aliasing (very common in embedded applications).
+cflags-gnu-y += -fno-strict-aliasing
+cxxflags-gnu-y += -fno-strict-aliasing
+
+# Separate each function and data into its own separate section to allow
+# garbage collection of unused sections.
+cflags-gnu-y += -ffunction-sections -fdata-sections
+cxxflags-gnu-y += -ffunction-sections -fdata-sections
+
+# Garbage collect unreferred sections when linking.
+ldflags-gnu-y += -Wl,--gc-sections
+
+# Output a link map file and a cross reference table
+ldflags-gnu-y += -Wl,-Map=$(project).map,--cref
+
+# Add library search paths relative to the top level directory.
+ldflags-gnu-y += $(foreach _LIB_PATH,$(addprefix $(PRJ_PATH)/,$(LIB_PATH)),-L$(_LIB_PATH))
+
+a_flags = $(cpuflags-gnu-y) $(depflags) $(cppflags-gnu-y) $(asflags-gnu-y) -D__ASSEMBLY__
+c_flags = $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cflags-gnu-y)
+cxx_flags= $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cxxflags-gnu-y)
+l_flags = $(cpuflags-gnu-y) $(optflags-gnu-y) $(ldflags-gnu-y)
+ar_flags = $(arflags-gnu-y)
+
+# Intel Hex file production flags
+flashflags-gnu-y += -R .eeprom -R .usb_descriptor_table
+
+# Eeprom file production flags
+eepromflags-gnu-y += -j .eeprom
+eepromflags-gnu-y += --set-section-flags=.eeprom="alloc,load"
+eepromflags-gnu-y += --change-section-lma .eeprom=0
+
+# Source files list and part informations must already be included before
+# running this makefile
+
+# If a custom build directory is specified, use it -- force trailing / in directory name.
+ifdef BUILD_DIR
+ build-dir := $(dir $(BUILD_DIR))$(if $(notdir $(BUILD_DIR)),$(notdir $(BUILD_DIR))/)
+else
+ build-dir =
+endif
+
+# Create object files list from source files list.
+obj-y := $(addprefix $(build-dir), $(addsuffix .o,$(basename $(CSRCS) $(ASSRCS))))
+
+# Create dependency files list from source files list.
+dep-files := $(wildcard $(foreach f,$(obj-y),$(basename $(f)).d))
+
+clean-files += $(wildcard $(obj-y))
+clean-files += $(dep-files)
+
+clean-dirs += $(call reverse,$(sort $(wildcard $(dir $(obj-y)))))
+
+# Default target.
+.PHONY: all
+ifeq ($(target_type),lib)
+all: $(target) $(project).lss $(project).sym
+else
+ifeq ($(target_type),elf)
+all: prebuild $(target) $(project).lss $(project).sym $(project).hex $(project).bin postbuild
+endif
+endif
+
+prebuild:
+ifneq ($(strip $(PREBUILD_CMD)),)
+ @echo $(MSG_PREBUILD)
+ $(Q)$(PREBUILD_CMD)
+endif
+
+postbuild:
+ifneq ($(strip $(POSTBUILD_CMD)),)
+ @echo $(MSG_POSTBUILD)
+ $(Q)$(POSTBUILD_CMD)
+endif
+
+# Clean up the project.
+.PHONY: clean
+clean:
+ @$(if $(strip $(clean-files)),echo $(MSG_CLEAN_FILES))
+ $(if $(strip $(clean-files)),$(Q)$(RM) $(clean-files),)
+ @$(if $(strip $(clean-dirs)),echo $(MSG_CLEAN_DIRS))
+# Remove created directories, and make sure we only remove existing
+# directories, since recursive rmdir might help us a bit on the way.
+ifeq ($(os),Windows)
+ $(Q)$(if $(strip $(clean-dirs)), \
+ $(RMDIR) $(strip $(subst /,\,$(clean-dirs))))
+else
+ $(Q)$(if $(strip $(clean-dirs)), \
+ for directory in $(strip $(clean-dirs)); do \
+ if [ -d "$$directory" ]; then \
+ $(RMDIR) $$directory; \
+ fi \
+ done \
+ )
+endif
+
+# Rebuild the project.
+.PHONY: rebuild
+rebuild: clean all
+
+.PHONY: objfiles
+objfiles: $(obj-y)
+
+# Create object files from C source files.
+$(build-dir)%.o: %.c $(MAKEFILE_PATH) config.mk
+ $(Q)test -d $(dir $@) || echo $(MSG_MKDIR)
+ifeq ($(os),Windows)
+ $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@))
+else
+ $(Q)test -d $(dir $@) || mkdir -p $(dir $@)
+endif
+ @echo $(MSG_COMPILING)
+ $(Q)$(CC) $(c_flags) -c $< -o $@
+
+# Create object files from C++ source files.
+$(build-dir)%.o: %.cpp $(MAKEFILE_PATH) config.mk
+ $(Q)test -d $(dir $@) || echo $(MSG_MKDIR)
+ifeq ($(os),Windows)
+ $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@))
+else
+ $(Q)test -d $(dir $@) || mkdir -p $(dir $@)
+endif
+ @echo $(MSG_COMPILING_CXX)
+ $(Q)$(CXX) $(cxx_flags) -c $< -o $@
+
+# Preprocess and assemble: create object files from assembler source files.
+$(build-dir)%.o: %.s $(MAKEFILE_PATH) config.mk
+ $(Q)test -d $(dir $@) || echo $(MSG_MKDIR)
+ifeq ($(os),Windows)
+ $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@))
+else
+ $(Q)test -d $(dir $@) || mkdir -p $(dir $@)
+endif
+ @echo $(MSG_ASSEMBLING)
+ $(Q)$(CC) $(a_flags) -c $< -o $@
+
+# Preprocess and assemble: create object files from assembler source files.
+$(build-dir)%.o: %.S $(MAKEFILE_PATH) config.mk
+ $(Q)test -d $(dir $@) || echo $(MSG_MKDIR)
+ifeq ($(os),Windows)
+ $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@))
+else
+ $(Q)test -d $(dir $@) || mkdir -p $(dir $@)
+endif
+ @echo $(MSG_ASSEMBLING)
+ $(Q)$(CC) $(a_flags) -c $< -o $@
+
+# Include all dependency files to add depedency to all header files in use.
+include $(dep-files)
+
+ifeq ($(target_type),lib)
+# Archive object files into an archive
+$(target): $(MAKEFILE_PATH) config.mk $(obj-y)
+ @echo $(MSG_ARCHIVING)
+ $(Q)$(AR) $(ar_flags) $@ $(obj-y)
+ @echo $(MSG_SIZE)
+ $(Q)$(SIZE) -Bxt $@
+else
+ifeq ($(target_type),elf)
+# Link the object files into an ELF file. Also make sure the target is rebuilt
+# if the common Makefile.avr.in or project config.mk is changed.
+$(target): $(MAKEFILE_PATH) config.mk $(obj-y)
+ @echo $(MSG_LINKING)
+ $(Q)$(LD) $(l_flags) $(obj-y) $(libflags-gnu-y) -o $@
+ @echo $(MSG_SIZE)
+ $(Q)$(SIZE) -Ax $@
+ $(Q)$(SIZE) -Bx $@
+endif
+endif
+
+# Create extended function listing from target output file.
+%.lss: $(target)
+ @echo $(MSG_EXTENDED_LISTING)
+ $(Q)$(OBJDUMP) -h -S $< > $@
+
+# Create symbol table from target output file.
+%.sym: $(target)
+ @echo $(MSG_SYMBOL_TABLE)
+ $(Q)$(NM) -n $< > $@
+
+# Create Intel HEX image from ELF output file.
+%.hex: $(target)
+ @echo $(MSG_IHEX_IMAGE)
+ $(Q)$(OBJCOPY) -O ihex $(flashflags-gnu-y) $< $@
+
+# Create EEPROM Intel HEX image from ELF output file.
+%.eep: $(target)
+ @echo $(MSG_EEPROM_IMAGE)
+ $(Q)$(OBJCOPY) $(eepromflags-gnu-y) -O ihex $< $@ || exit 0
+
+# Create binary image from ELF output file.
+%.bin: $(target)
+ @echo $(MSG_BINARY_IMAGE)
+ $(Q)$(OBJCOPY) -O binary $< $@
+
+# Provide information about the detected host operating system.
+.SECONDARY: info-os
+info-os:
+ @echo $(MSG_INFO)$(os) build host detected
+
+# Build Doxygen generated documentation.
+.PHONY: doc
+doc:
+ @echo $(MSG_GENERATING_DOC)
+ $(Q)cd $(dir $(doccfg)) && $(DOCGEN) $(notdir $(doccfg))
+
+# Clean Doxygen generated documentation.
+.PHONY: cleandoc
+cleandoc:
+ @$(if $(wildcard $(docdir)),echo $(MSG_CLEAN_DOC))
+ $(Q)$(if $(wildcard $(docdir)),$(RM) --recursive $(docdir))
+
+# Rebuild the Doxygen generated documentation.
+.PHONY: rebuilddoc
+rebuilddoc: cleandoc doc
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/make/Makefile.avr.in.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/make/Makefile.avr.in.REMOVED.git-id
deleted file mode 100644
index fd0ff90e..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/make/Makefile.avr.in.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5d9a83754735b62ce6f57c15c478be32f708c33b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/parts.h b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/parts.h
new file mode 100644
index 00000000..b0ddbdf4
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/parts.h
@@ -0,0 +1,1292 @@
+/**
+ * \file
+ *
+ * \brief Atmel part identification macros
+ *
+ * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef ATMEL_PARTS_H
+#define ATMEL_PARTS_H
+
+/**
+ * \defgroup part_macros_group Atmel part identification macros
+ *
+ * This collection of macros identify which series and families that the various
+ * Atmel parts belong to. These can be used to select part-dependent sections of
+ * code at compile time.
+ *
+ * @{
+ */
+
+/**
+ * \name Convenience macros for part checking
+ * @{
+ */
+/* ! Check GCC and IAR part definition for 8-bit AVR */
+#define AVR8_PART_IS_DEFINED(part) \
+ (defined(__ ## part ## __) || defined(__AVR_ ## part ## __))
+
+/* ! Check GCC and IAR part definition for 32-bit AVR */
+#define AVR32_PART_IS_DEFINED(part) \
+ (defined(__AT32 ## part ## __) || defined(__AVR32_ ## part ## __))
+
+/* ! Check GCC and IAR part definition for SAM */
+#define SAM_PART_IS_DEFINED(part) (defined(__ ## part ## __))
+/** @} */
+
+/**
+ * \defgroup uc3_part_macros_group AVR UC3 parts
+ * @{
+ */
+
+/**
+ * \name AVR UC3 A series
+ * @{
+ */
+#define UC3A0 ( \
+ AVR32_PART_IS_DEFINED(UC3A0128) || \
+ AVR32_PART_IS_DEFINED(UC3A0256) || \
+ AVR32_PART_IS_DEFINED(UC3A0512) \
+ )
+
+#define UC3A1 ( \
+ AVR32_PART_IS_DEFINED(UC3A1128) || \
+ AVR32_PART_IS_DEFINED(UC3A1256) || \
+ AVR32_PART_IS_DEFINED(UC3A1512) \
+ )
+
+#define UC3A3 ( \
+ AVR32_PART_IS_DEFINED(UC3A364) || \
+ AVR32_PART_IS_DEFINED(UC3A364S) || \
+ AVR32_PART_IS_DEFINED(UC3A3128) || \
+ AVR32_PART_IS_DEFINED(UC3A3128S) || \
+ AVR32_PART_IS_DEFINED(UC3A3256) || \
+ AVR32_PART_IS_DEFINED(UC3A3256S) \
+ )
+
+#define UC3A4 ( \
+ AVR32_PART_IS_DEFINED(UC3A464) || \
+ AVR32_PART_IS_DEFINED(UC3A464S) || \
+ AVR32_PART_IS_DEFINED(UC3A4128) || \
+ AVR32_PART_IS_DEFINED(UC3A4128S) || \
+ AVR32_PART_IS_DEFINED(UC3A4256) || \
+ AVR32_PART_IS_DEFINED(UC3A4256S) \
+ )
+/** @} */
+
+/**
+ * \name AVR UC3 B series
+ * @{
+ */
+#define UC3B0 ( \
+ AVR32_PART_IS_DEFINED(UC3B064) || \
+ AVR32_PART_IS_DEFINED(UC3B0128) || \
+ AVR32_PART_IS_DEFINED(UC3B0256) || \
+ AVR32_PART_IS_DEFINED(UC3B0512) \
+ )
+
+#define UC3B1 ( \
+ AVR32_PART_IS_DEFINED(UC3B164) || \
+ AVR32_PART_IS_DEFINED(UC3B1128) || \
+ AVR32_PART_IS_DEFINED(UC3B1256) || \
+ AVR32_PART_IS_DEFINED(UC3B1512) \
+ )
+/** @} */
+
+/**
+ * \name AVR UC3 C series
+ * @{
+ */
+#define UC3C0 ( \
+ AVR32_PART_IS_DEFINED(UC3C064C) || \
+ AVR32_PART_IS_DEFINED(UC3C0128C) || \
+ AVR32_PART_IS_DEFINED(UC3C0256C) || \
+ AVR32_PART_IS_DEFINED(UC3C0512C) \
+ )
+
+#define UC3C1 ( \
+ AVR32_PART_IS_DEFINED(UC3C164C) || \
+ AVR32_PART_IS_DEFINED(UC3C1128C) || \
+ AVR32_PART_IS_DEFINED(UC3C1256C) || \
+ AVR32_PART_IS_DEFINED(UC3C1512C) \
+ )
+
+#define UC3C2 ( \
+ AVR32_PART_IS_DEFINED(UC3C264C) || \
+ AVR32_PART_IS_DEFINED(UC3C2128C) || \
+ AVR32_PART_IS_DEFINED(UC3C2256C) || \
+ AVR32_PART_IS_DEFINED(UC3C2512C) \
+ )
+/** @} */
+
+/**
+ * \name AVR UC3 D series
+ * @{
+ */
+#define UC3D3 ( \
+ AVR32_PART_IS_DEFINED(UC64D3) || \
+ AVR32_PART_IS_DEFINED(UC128D3) \
+ )
+
+#define UC3D4 ( \
+ AVR32_PART_IS_DEFINED(UC64D4) || \
+ AVR32_PART_IS_DEFINED(UC128D4) \
+ )
+/** @} */
+
+/**
+ * \name AVR UC3 L series
+ * @{
+ */
+#define UC3L0 ( \
+ AVR32_PART_IS_DEFINED(UC3L016) || \
+ AVR32_PART_IS_DEFINED(UC3L032) || \
+ AVR32_PART_IS_DEFINED(UC3L064) \
+ )
+
+#define UC3L0128 ( \
+ AVR32_PART_IS_DEFINED(UC3L0128) \
+ )
+
+#define UC3L0256 ( \
+ AVR32_PART_IS_DEFINED(UC3L0256) \
+ )
+
+#define UC3L3 ( \
+ AVR32_PART_IS_DEFINED(UC64L3U) || \
+ AVR32_PART_IS_DEFINED(UC128L3U) || \
+ AVR32_PART_IS_DEFINED(UC256L3U) \
+ )
+
+#define UC3L4 ( \
+ AVR32_PART_IS_DEFINED(UC64L4U) || \
+ AVR32_PART_IS_DEFINED(UC128L4U) || \
+ AVR32_PART_IS_DEFINED(UC256L4U) \
+ )
+
+#define UC3L3_L4 (UC3L3 || UC3L4)
+/** @} */
+
+/**
+ * \name AVR UC3 families
+ * @{
+ */
+/** AVR UC3 A family */
+#define UC3A (UC3A0 || UC3A1 || UC3A3 || UC3A4)
+
+/** AVR UC3 B family */
+#define UC3B (UC3B0 || UC3B1)
+
+/** AVR UC3 C family */
+#define UC3C (UC3C0 || UC3C1 || UC3C2)
+
+/** AVR UC3 D family */
+#define UC3D (UC3D3 || UC3D4)
+
+/** AVR UC3 L family */
+#define UC3L (UC3L0 || UC3L0128 || UC3L0256 || UC3L3_L4)
+/** @} */
+
+/** AVR UC3 product line */
+#define UC3 (UC3A || UC3B || UC3C || UC3D || UC3L)
+
+/** @} */
+
+/**
+ * \defgroup xmega_part_macros_group AVR XMEGA parts
+ * @{
+ */
+
+/**
+ * \name AVR XMEGA A series
+ * @{
+ */
+#define XMEGA_A1 ( \
+ AVR8_PART_IS_DEFINED(ATxmega64A1) || \
+ AVR8_PART_IS_DEFINED(ATxmega128A1) \
+ )
+
+#define XMEGA_A3 ( \
+ AVR8_PART_IS_DEFINED(ATxmega64A3) || \
+ AVR8_PART_IS_DEFINED(ATxmega128A3) || \
+ AVR8_PART_IS_DEFINED(ATxmega192A3) || \
+ AVR8_PART_IS_DEFINED(ATxmega256A3) \
+ )
+
+#define XMEGA_A3B ( \
+ AVR8_PART_IS_DEFINED(ATxmega256A3B) \
+ )
+
+#define XMEGA_A4 ( \
+ AVR8_PART_IS_DEFINED(ATxmega16A4) || \
+ AVR8_PART_IS_DEFINED(ATxmega32A4) \
+ )
+/** @} */
+
+/**
+ * \name AVR XMEGA AU series
+ * @{
+ */
+#define XMEGA_A1U ( \
+ AVR8_PART_IS_DEFINED(ATxmega64A1U) || \
+ AVR8_PART_IS_DEFINED(ATxmega128A1U) \
+ )
+
+#define XMEGA_A3U ( \
+ AVR8_PART_IS_DEFINED(ATxmega64A3U) || \
+ AVR8_PART_IS_DEFINED(ATxmega128A3U) || \
+ AVR8_PART_IS_DEFINED(ATxmega192A3U) || \
+ AVR8_PART_IS_DEFINED(ATxmega256A3U) \
+ )
+
+#define XMEGA_A3BU ( \
+ AVR8_PART_IS_DEFINED(ATxmega256A3BU) \
+ )
+
+#define XMEGA_A4U ( \
+ AVR8_PART_IS_DEFINED(ATxmega16A4U) || \
+ AVR8_PART_IS_DEFINED(ATxmega32A4U) || \
+ AVR8_PART_IS_DEFINED(ATxmega64A4U) || \
+ AVR8_PART_IS_DEFINED(ATxmega128A4U) \
+ )
+/** @} */
+
+/**
+ * \name AVR XMEGA B series
+ * @{
+ */
+#define XMEGA_B1 ( \
+ AVR8_PART_IS_DEFINED(ATxmega64B1) || \
+ AVR8_PART_IS_DEFINED(ATxmega128B1) \
+ )
+
+#define XMEGA_B3 ( \
+ AVR8_PART_IS_DEFINED(ATxmega64B3) || \
+ AVR8_PART_IS_DEFINED(ATxmega128B3) \
+ )
+/** @} */
+
+/**
+ * \name AVR XMEGA C series
+ * @{
+ */
+#define XMEGA_C3 ( \
+ AVR8_PART_IS_DEFINED(ATxmega384C3) || \
+ AVR8_PART_IS_DEFINED(ATxmega256C3) || \
+ AVR8_PART_IS_DEFINED(ATxmega192C3) || \
+ AVR8_PART_IS_DEFINED(ATxmega128C3) || \
+ AVR8_PART_IS_DEFINED(ATxmega64C3) || \
+ AVR8_PART_IS_DEFINED(ATxmega32C3) \
+ )
+
+#define XMEGA_C4 ( \
+ AVR8_PART_IS_DEFINED(ATxmega32C4) || \
+ AVR8_PART_IS_DEFINED(ATxmega16C4) \
+ )
+/** @} */
+
+/**
+ * \name AVR XMEGA D series
+ * @{
+ */
+#define XMEGA_D3 ( \
+ AVR8_PART_IS_DEFINED(ATxmega32D3) || \
+ AVR8_PART_IS_DEFINED(ATxmega64D3) || \
+ AVR8_PART_IS_DEFINED(ATxmega128D3) || \
+ AVR8_PART_IS_DEFINED(ATxmega192D3) || \
+ AVR8_PART_IS_DEFINED(ATxmega256D3) || \
+ AVR8_PART_IS_DEFINED(ATxmega384D3) \
+ )
+
+#define XMEGA_D4 ( \
+ AVR8_PART_IS_DEFINED(ATxmega16D4) || \
+ AVR8_PART_IS_DEFINED(ATxmega32D4) || \
+ AVR8_PART_IS_DEFINED(ATxmega64D4) || \
+ AVR8_PART_IS_DEFINED(ATxmega128D4) \
+ )
+/** @} */
+
+/**
+ * \name AVR XMEGA E series
+ * @{
+ */
+#define XMEGA_E5 ( \
+ AVR8_PART_IS_DEFINED(ATxmega8E5) || \
+ AVR8_PART_IS_DEFINED(ATxmega16E5) || \
+ AVR8_PART_IS_DEFINED(ATxmega32E5) \
+ )
+/** @} */
+
+
+/**
+ * \name AVR XMEGA families
+ * @{
+ */
+/** AVR XMEGA A family */
+#define XMEGA_A (XMEGA_A1 || XMEGA_A3 || XMEGA_A3B || XMEGA_A4)
+
+/** AVR XMEGA AU family */
+#define XMEGA_AU (XMEGA_A1U || XMEGA_A3U || XMEGA_A3BU || XMEGA_A4U)
+
+/** AVR XMEGA B family */
+#define XMEGA_B (XMEGA_B1 || XMEGA_B3)
+
+/** AVR XMEGA C family */
+#define XMEGA_C (XMEGA_C3 || XMEGA_C4)
+
+/** AVR XMEGA D family */
+#define XMEGA_D (XMEGA_D3 || XMEGA_D4)
+
+/** AVR XMEGA E family */
+#define XMEGA_E (XMEGA_E5)
+/** @} */
+
+
+/** AVR XMEGA product line */
+#define XMEGA (XMEGA_A || XMEGA_AU || XMEGA_B || XMEGA_C || XMEGA_D || XMEGA_E)
+
+/** @} */
+
+/**
+ * \defgroup mega_part_macros_group megaAVR parts
+ *
+ * \note These megaAVR groupings are based on the groups in AVR Libc for the
+ * part header files. They are not names of official megaAVR device series or
+ * families.
+ *
+ * @{
+ */
+
+/**
+ * \name ATmegaxx0/xx1 subgroups
+ * @{
+ */
+#define MEGA_XX0 ( \
+ AVR8_PART_IS_DEFINED(ATmega640) || \
+ AVR8_PART_IS_DEFINED(ATmega1280) || \
+ AVR8_PART_IS_DEFINED(ATmega2560) \
+ )
+
+#define MEGA_XX1 ( \
+ AVR8_PART_IS_DEFINED(ATmega1281) || \
+ AVR8_PART_IS_DEFINED(ATmega2561) \
+ )
+/** @} */
+
+/**
+ * \name megaAVR groups
+ * @{
+ */
+/** ATmegaxx0/xx1 group */
+#define MEGA_XX0_1 (MEGA_XX0 || MEGA_XX1)
+
+/** ATmegaxx4 group */
+#define MEGA_XX4 ( \
+ AVR8_PART_IS_DEFINED(ATmega164A) || \
+ AVR8_PART_IS_DEFINED(ATmega164PA) || \
+ AVR8_PART_IS_DEFINED(ATmega324A) || \
+ AVR8_PART_IS_DEFINED(ATmega324PA) || \
+ AVR8_PART_IS_DEFINED(ATmega644) || \
+ AVR8_PART_IS_DEFINED(ATmega644A) || \
+ AVR8_PART_IS_DEFINED(ATmega644PA) || \
+ AVR8_PART_IS_DEFINED(ATmega1284P) || \
+ AVR8_PART_IS_DEFINED(ATmega128RFA1) \
+ )
+
+/** ATmegaxx4 group */
+#define MEGA_XX4_A ( \
+ AVR8_PART_IS_DEFINED(ATmega164A) || \
+ AVR8_PART_IS_DEFINED(ATmega164PA) || \
+ AVR8_PART_IS_DEFINED(ATmega324A) || \
+ AVR8_PART_IS_DEFINED(ATmega324PA) || \
+ AVR8_PART_IS_DEFINED(ATmega644A) || \
+ AVR8_PART_IS_DEFINED(ATmega644PA) || \
+ AVR8_PART_IS_DEFINED(ATmega1284P) \
+ )
+
+/** ATmegaxx8 group */
+#define MEGA_XX8 ( \
+ AVR8_PART_IS_DEFINED(ATmega48) || \
+ AVR8_PART_IS_DEFINED(ATmega48A) || \
+ AVR8_PART_IS_DEFINED(ATmega48PA) || \
+ AVR8_PART_IS_DEFINED(ATmega88) || \
+ AVR8_PART_IS_DEFINED(ATmega88A) || \
+ AVR8_PART_IS_DEFINED(ATmega88PA) || \
+ AVR8_PART_IS_DEFINED(ATmega168) || \
+ AVR8_PART_IS_DEFINED(ATmega168A) || \
+ AVR8_PART_IS_DEFINED(ATmega168PA) || \
+ AVR8_PART_IS_DEFINED(ATmega328) || \
+ AVR8_PART_IS_DEFINED(ATmega328P) \
+ )
+
+/** ATmegaxx8A/P/PA group */
+#define MEGA_XX8_A ( \
+ AVR8_PART_IS_DEFINED(ATmega48A) || \
+ AVR8_PART_IS_DEFINED(ATmega48PA) || \
+ AVR8_PART_IS_DEFINED(ATmega88A) || \
+ AVR8_PART_IS_DEFINED(ATmega88PA) || \
+ AVR8_PART_IS_DEFINED(ATmega168A) || \
+ AVR8_PART_IS_DEFINED(ATmega168PA) || \
+ AVR8_PART_IS_DEFINED(ATmega328P) \
+ )
+
+/** ATmegaxx group */
+#define MEGA_XX ( \
+ AVR8_PART_IS_DEFINED(ATmega16) || \
+ AVR8_PART_IS_DEFINED(ATmega16A) || \
+ AVR8_PART_IS_DEFINED(ATmega32) || \
+ AVR8_PART_IS_DEFINED(ATmega32A) || \
+ AVR8_PART_IS_DEFINED(ATmega64) || \
+ AVR8_PART_IS_DEFINED(ATmega64A) || \
+ AVR8_PART_IS_DEFINED(ATmega128) || \
+ AVR8_PART_IS_DEFINED(ATmega128A) \
+ )
+
+/** ATmegaxxA/P/PA group */
+#define MEGA_XX_A ( \
+ AVR8_PART_IS_DEFINED(ATmega16A) || \
+ AVR8_PART_IS_DEFINED(ATmega32A) || \
+ AVR8_PART_IS_DEFINED(ATmega64A) || \
+ AVR8_PART_IS_DEFINED(ATmega128A) \
+ )
+/** ATmegaxxRFA1 group */
+#define MEGA_RFA1 ( \
+ AVR8_PART_IS_DEFINED(ATmega128RFA1) \
+ )
+
+/** ATmegaxxRFR2 group */
+#define MEGA_RFR2 ( \
+ AVR8_PART_IS_DEFINED(ATmega64RFR2) || \
+ AVR8_PART_IS_DEFINED(ATmega128RFR2) || \
+ AVR8_PART_IS_DEFINED(ATmega256RFR2) || \
+ AVR8_PART_IS_DEFINED(ATmega644RFR2) || \
+ AVR8_PART_IS_DEFINED(ATmega1284RFR2) || \
+ AVR8_PART_IS_DEFINED(ATmega2564RFR2) \
+ )
+
+
+/** ATmegaxxRFxx group */
+#define MEGA_RF (MEGA_RFA1 || MEGA_RFR2)
+
+/**
+ * \name ATmegaxx_un0/un1/un2 subgroups
+ * @{
+ */
+#define MEGA_XX_UN0 ( \
+ AVR8_PART_IS_DEFINED(ATmega16) || \
+ AVR8_PART_IS_DEFINED(ATmega16A) || \
+ AVR8_PART_IS_DEFINED(ATmega32) || \
+ AVR8_PART_IS_DEFINED(ATmega32A) \
+ )
+
+/** ATmegaxx group without power reduction and
+ * And interrupt sense register.
+ */
+#define MEGA_XX_UN1 ( \
+ AVR8_PART_IS_DEFINED(ATmega64) || \
+ AVR8_PART_IS_DEFINED(ATmega64A) || \
+ AVR8_PART_IS_DEFINED(ATmega128) || \
+ AVR8_PART_IS_DEFINED(ATmega128A) \
+ )
+
+/** ATmegaxx group without power reduction and
+ * And interrupt sense register.
+ */
+#define MEGA_XX_UN2 ( \
+ AVR8_PART_IS_DEFINED(ATmega169P) || \
+ AVR8_PART_IS_DEFINED(ATmega169PA) || \
+ AVR8_PART_IS_DEFINED(ATmega329P) || \
+ AVR8_PART_IS_DEFINED(ATmega329PA) \
+ )
+
+/** Devices added to complete megaAVR offering.
+ * Please do not use this group symbol as it is not intended
+ * to be permanent: the devices should be regrouped.
+ */
+#define MEGA_UNCATEGORIZED ( \
+ AVR8_PART_IS_DEFINED(AT90CAN128) || \
+ AVR8_PART_IS_DEFINED(AT90CAN32) || \
+ AVR8_PART_IS_DEFINED(AT90CAN64) || \
+ AVR8_PART_IS_DEFINED(AT90PWM1) || \
+ AVR8_PART_IS_DEFINED(AT90PWM216) || \
+ AVR8_PART_IS_DEFINED(AT90PWM2B) || \
+ AVR8_PART_IS_DEFINED(AT90PWM316) || \
+ AVR8_PART_IS_DEFINED(AT90PWM3B) || \
+ AVR8_PART_IS_DEFINED(AT90PWM81) || \
+ AVR8_PART_IS_DEFINED(AT90USB1286) || \
+ AVR8_PART_IS_DEFINED(AT90USB1287) || \
+ AVR8_PART_IS_DEFINED(AT90USB162) || \
+ AVR8_PART_IS_DEFINED(AT90USB646) || \
+ AVR8_PART_IS_DEFINED(AT90USB647) || \
+ AVR8_PART_IS_DEFINED(AT90USB82) || \
+ AVR8_PART_IS_DEFINED(ATmega1284) || \
+ AVR8_PART_IS_DEFINED(ATmega162) || \
+ AVR8_PART_IS_DEFINED(ATmega164P) || \
+ AVR8_PART_IS_DEFINED(ATmega165A) || \
+ AVR8_PART_IS_DEFINED(ATmega165P) || \
+ AVR8_PART_IS_DEFINED(ATmega165PA) || \
+ AVR8_PART_IS_DEFINED(ATmega168P) || \
+ AVR8_PART_IS_DEFINED(ATmega169A) || \
+ AVR8_PART_IS_DEFINED(ATmega16M1) || \
+ AVR8_PART_IS_DEFINED(ATmega16U2) || \
+ AVR8_PART_IS_DEFINED(ATmega16U4) || \
+ AVR8_PART_IS_DEFINED(ATmega256RFA2) || \
+ AVR8_PART_IS_DEFINED(ATmega324P) || \
+ AVR8_PART_IS_DEFINED(ATmega325) || \
+ AVR8_PART_IS_DEFINED(ATmega3250) || \
+ AVR8_PART_IS_DEFINED(ATmega3250A) || \
+ AVR8_PART_IS_DEFINED(ATmega3250P) || \
+ AVR8_PART_IS_DEFINED(ATmega3250PA) || \
+ AVR8_PART_IS_DEFINED(ATmega325A) || \
+ AVR8_PART_IS_DEFINED(ATmega325P) || \
+ AVR8_PART_IS_DEFINED(ATmega325PA) || \
+ AVR8_PART_IS_DEFINED(ATmega329) || \
+ AVR8_PART_IS_DEFINED(ATmega3290) || \
+ AVR8_PART_IS_DEFINED(ATmega3290A) || \
+ AVR8_PART_IS_DEFINED(ATmega3290P) || \
+ AVR8_PART_IS_DEFINED(ATmega3290PA) || \
+ AVR8_PART_IS_DEFINED(ATmega329A) || \
+ AVR8_PART_IS_DEFINED(ATmega32M1) || \
+ AVR8_PART_IS_DEFINED(ATmega32U2) || \
+ AVR8_PART_IS_DEFINED(ATmega32U4) || \
+ AVR8_PART_IS_DEFINED(ATmega48P) || \
+ AVR8_PART_IS_DEFINED(ATmega644P) || \
+ AVR8_PART_IS_DEFINED(ATmega645) || \
+ AVR8_PART_IS_DEFINED(ATmega6450) || \
+ AVR8_PART_IS_DEFINED(ATmega6450A) || \
+ AVR8_PART_IS_DEFINED(ATmega6450P) || \
+ AVR8_PART_IS_DEFINED(ATmega645A) || \
+ AVR8_PART_IS_DEFINED(ATmega645P) || \
+ AVR8_PART_IS_DEFINED(ATmega649) || \
+ AVR8_PART_IS_DEFINED(ATmega6490) || \
+ AVR8_PART_IS_DEFINED(ATmega6490A) || \
+ AVR8_PART_IS_DEFINED(ATmega6490P) || \
+ AVR8_PART_IS_DEFINED(ATmega649A) || \
+ AVR8_PART_IS_DEFINED(ATmega649P) || \
+ AVR8_PART_IS_DEFINED(ATmega64M1) || \
+ AVR8_PART_IS_DEFINED(ATmega64RFA2) || \
+ AVR8_PART_IS_DEFINED(ATmega8) || \
+ AVR8_PART_IS_DEFINED(ATmega8515) || \
+ AVR8_PART_IS_DEFINED(ATmega8535) || \
+ AVR8_PART_IS_DEFINED(ATmega88P) || \
+ AVR8_PART_IS_DEFINED(ATmega8A) || \
+ AVR8_PART_IS_DEFINED(ATmega8U2) \
+ )
+
+/** Unspecified group */
+#define MEGA_UNSPECIFIED (MEGA_XX_UN0 || MEGA_XX_UN1 || MEGA_XX_UN2 || \
+ MEGA_UNCATEGORIZED)
+
+/** @} */
+
+/** megaAVR product line */
+#define MEGA (MEGA_XX0_1 || MEGA_XX4 || MEGA_XX8 || MEGA_XX || MEGA_RF || \
+ MEGA_UNSPECIFIED)
+
+/** @} */
+
+/**
+ * \defgroup tiny_part_macros_group tinyAVR parts
+ *
+ * @{
+ */
+
+/**
+ * \name tinyAVR groups
+ * @{
+ */
+
+/** Devices added to complete tinyAVR offering.
+ * Please do not use this group symbol as it is not intended
+ * to be permanent: the devices should be regrouped.
+ */
+#define TINY_UNCATEGORIZED ( \
+ AVR8_PART_IS_DEFINED(ATtiny10) || \
+ AVR8_PART_IS_DEFINED(ATtiny13) || \
+ AVR8_PART_IS_DEFINED(ATtiny13A) || \
+ AVR8_PART_IS_DEFINED(ATtiny1634) || \
+ AVR8_PART_IS_DEFINED(ATtiny167) || \
+ AVR8_PART_IS_DEFINED(ATtiny20) || \
+ AVR8_PART_IS_DEFINED(ATtiny2313) || \
+ AVR8_PART_IS_DEFINED(ATtiny2313A) || \
+ AVR8_PART_IS_DEFINED(ATtiny24) || \
+ AVR8_PART_IS_DEFINED(ATtiny24A) || \
+ AVR8_PART_IS_DEFINED(ATtiny25) || \
+ AVR8_PART_IS_DEFINED(ATtiny26) || \
+ AVR8_PART_IS_DEFINED(ATtiny261) || \
+ AVR8_PART_IS_DEFINED(ATtiny261A) || \
+ AVR8_PART_IS_DEFINED(ATtiny4) || \
+ AVR8_PART_IS_DEFINED(ATtiny40) || \
+ AVR8_PART_IS_DEFINED(ATtiny4313) || \
+ AVR8_PART_IS_DEFINED(ATtiny43U) || \
+ AVR8_PART_IS_DEFINED(ATtiny44) || \
+ AVR8_PART_IS_DEFINED(ATtiny44A) || \
+ AVR8_PART_IS_DEFINED(ATtiny45) || \
+ AVR8_PART_IS_DEFINED(ATtiny461) || \
+ AVR8_PART_IS_DEFINED(ATtiny461A) || \
+ AVR8_PART_IS_DEFINED(ATtiny48) || \
+ AVR8_PART_IS_DEFINED(ATtiny5) || \
+ AVR8_PART_IS_DEFINED(ATtiny828) || \
+ AVR8_PART_IS_DEFINED(ATtiny84) || \
+ AVR8_PART_IS_DEFINED(ATtiny84A) || \
+ AVR8_PART_IS_DEFINED(ATtiny85) || \
+ AVR8_PART_IS_DEFINED(ATtiny861) || \
+ AVR8_PART_IS_DEFINED(ATtiny861A) || \
+ AVR8_PART_IS_DEFINED(ATtiny87) || \
+ AVR8_PART_IS_DEFINED(ATtiny88) || \
+ AVR8_PART_IS_DEFINED(ATtiny9) \
+ )
+
+/** @} */
+
+/** tinyAVR product line */
+#define TINY (TINY_UNCATEGORIZED)
+
+/** @} */
+
+/**
+ * \defgroup sam_part_macros_group SAM parts
+ * @{
+ */
+
+/**
+ * \name SAM3S series
+ * @{
+ */
+#define SAM3S1 ( \
+ SAM_PART_IS_DEFINED(SAM3S1A) || \
+ SAM_PART_IS_DEFINED(SAM3S1B) || \
+ SAM_PART_IS_DEFINED(SAM3S1C) \
+ )
+
+#define SAM3S2 ( \
+ SAM_PART_IS_DEFINED(SAM3S2A) || \
+ SAM_PART_IS_DEFINED(SAM3S2B) || \
+ SAM_PART_IS_DEFINED(SAM3S2C) \
+ )
+
+#define SAM3S4 ( \
+ SAM_PART_IS_DEFINED(SAM3S4A) || \
+ SAM_PART_IS_DEFINED(SAM3S4B) || \
+ SAM_PART_IS_DEFINED(SAM3S4C) \
+ )
+
+#define SAM3S8 ( \
+ SAM_PART_IS_DEFINED(SAM3S8B) || \
+ SAM_PART_IS_DEFINED(SAM3S8C) \
+ )
+
+#define SAM3SD8 ( \
+ SAM_PART_IS_DEFINED(SAM3SD8B) || \
+ SAM_PART_IS_DEFINED(SAM3SD8C) \
+ )
+/** @} */
+
+/**
+ * \name SAM3U series
+ * @{
+ */
+#define SAM3U1 ( \
+ SAM_PART_IS_DEFINED(SAM3U1C) || \
+ SAM_PART_IS_DEFINED(SAM3U1E) \
+ )
+
+#define SAM3U2 ( \
+ SAM_PART_IS_DEFINED(SAM3U2C) || \
+ SAM_PART_IS_DEFINED(SAM3U2E) \
+ )
+
+#define SAM3U4 ( \
+ SAM_PART_IS_DEFINED(SAM3U4C) || \
+ SAM_PART_IS_DEFINED(SAM3U4E) \
+ )
+/** @} */
+
+/**
+ * \name SAM3N series
+ * @{
+ */
+#define SAM3N00 ( \
+ SAM_PART_IS_DEFINED(SAM3N00A) || \
+ SAM_PART_IS_DEFINED(SAM3N00B) \
+ )
+
+#define SAM3N0 ( \
+ SAM_PART_IS_DEFINED(SAM3N0A) || \
+ SAM_PART_IS_DEFINED(SAM3N0B) || \
+ SAM_PART_IS_DEFINED(SAM3N0C) \
+ )
+
+#define SAM3N1 ( \
+ SAM_PART_IS_DEFINED(SAM3N1A) || \
+ SAM_PART_IS_DEFINED(SAM3N1B) || \
+ SAM_PART_IS_DEFINED(SAM3N1C) \
+ )
+
+#define SAM3N2 ( \
+ SAM_PART_IS_DEFINED(SAM3N2A) || \
+ SAM_PART_IS_DEFINED(SAM3N2B) || \
+ SAM_PART_IS_DEFINED(SAM3N2C) \
+ )
+
+#define SAM3N4 ( \
+ SAM_PART_IS_DEFINED(SAM3N4A) || \
+ SAM_PART_IS_DEFINED(SAM3N4B) || \
+ SAM_PART_IS_DEFINED(SAM3N4C) \
+ )
+/** @} */
+
+/**
+ * \name SAM3X series
+ * @{
+ */
+#define SAM3X4 ( \
+ SAM_PART_IS_DEFINED(SAM3X4C) || \
+ SAM_PART_IS_DEFINED(SAM3X4E) \
+ )
+
+#define SAM3X8 ( \
+ SAM_PART_IS_DEFINED(SAM3X8C) || \
+ SAM_PART_IS_DEFINED(SAM3X8E) || \
+ SAM_PART_IS_DEFINED(SAM3X8H) \
+ )
+/** @} */
+
+/**
+ * \name SAM3A series
+ * @{
+ */
+#define SAM3A4 ( \
+ SAM_PART_IS_DEFINED(SAM3A4C) \
+ )
+
+#define SAM3A8 ( \
+ SAM_PART_IS_DEFINED(SAM3A8C) \
+ )
+/** @} */
+
+/**
+ * \name SAM4S series
+ * @{
+ */
+#define SAM4S2 ( \
+ SAM_PART_IS_DEFINED(SAM4S2A) || \
+ SAM_PART_IS_DEFINED(SAM4S2B) || \
+ SAM_PART_IS_DEFINED(SAM4S2C) \
+ )
+
+#define SAM4S4 ( \
+ SAM_PART_IS_DEFINED(SAM4S4A) || \
+ SAM_PART_IS_DEFINED(SAM4S4B) || \
+ SAM_PART_IS_DEFINED(SAM4S4C) \
+ )
+
+#define SAM4S8 ( \
+ SAM_PART_IS_DEFINED(SAM4S8B) || \
+ SAM_PART_IS_DEFINED(SAM4S8C) \
+ )
+
+#define SAM4S16 ( \
+ SAM_PART_IS_DEFINED(SAM4S16B) || \
+ SAM_PART_IS_DEFINED(SAM4S16C) \
+ )
+
+#define SAM4SA16 ( \
+ SAM_PART_IS_DEFINED(SAM4SA16B) || \
+ SAM_PART_IS_DEFINED(SAM4SA16C) \
+ )
+
+#define SAM4SD16 ( \
+ SAM_PART_IS_DEFINED(SAM4SD16B) || \
+ SAM_PART_IS_DEFINED(SAM4SD16C) \
+ )
+
+#define SAM4SD32 ( \
+ SAM_PART_IS_DEFINED(SAM4SD32B) || \
+ SAM_PART_IS_DEFINED(SAM4SD32C) \
+ )
+/** @} */
+
+/**
+ * \name SAM4L series
+ * @{
+ */
+#define SAM4LS ( \
+ SAM_PART_IS_DEFINED(SAM4LS2A) || \
+ SAM_PART_IS_DEFINED(SAM4LS2B) || \
+ SAM_PART_IS_DEFINED(SAM4LS2C) || \
+ SAM_PART_IS_DEFINED(SAM4LS4A) || \
+ SAM_PART_IS_DEFINED(SAM4LS4B) || \
+ SAM_PART_IS_DEFINED(SAM4LS4C) || \
+ SAM_PART_IS_DEFINED(SAM4LS8A) || \
+ SAM_PART_IS_DEFINED(SAM4LS8B) || \
+ SAM_PART_IS_DEFINED(SAM4LS8C) \
+ )
+
+#define SAM4LC ( \
+ SAM_PART_IS_DEFINED(SAM4LC2A) || \
+ SAM_PART_IS_DEFINED(SAM4LC2B) || \
+ SAM_PART_IS_DEFINED(SAM4LC2C) || \
+ SAM_PART_IS_DEFINED(SAM4LC4A) || \
+ SAM_PART_IS_DEFINED(SAM4LC4B) || \
+ SAM_PART_IS_DEFINED(SAM4LC4C) || \
+ SAM_PART_IS_DEFINED(SAM4LC8A) || \
+ SAM_PART_IS_DEFINED(SAM4LC8B) || \
+ SAM_PART_IS_DEFINED(SAM4LC8C) \
+ )
+/** @} */
+
+/**
+ * \name SAMD20 series
+ * @{
+ */
+#define SAMD20J ( \
+ SAM_PART_IS_DEFINED(SAMD20J14) || \
+ SAM_PART_IS_DEFINED(SAMD20J15) || \
+ SAM_PART_IS_DEFINED(SAMD20J16) || \
+ SAM_PART_IS_DEFINED(SAMD20J17) || \
+ SAM_PART_IS_DEFINED(SAMD20J18) \
+ )
+
+#define SAMD20G ( \
+ SAM_PART_IS_DEFINED(SAMD20G14) || \
+ SAM_PART_IS_DEFINED(SAMD20G15) || \
+ SAM_PART_IS_DEFINED(SAMD20G16) || \
+ SAM_PART_IS_DEFINED(SAMD20G17) || \
+ SAM_PART_IS_DEFINED(SAMD20G17U) || \
+ SAM_PART_IS_DEFINED(SAMD20G18) || \
+ SAM_PART_IS_DEFINED(SAMD20G18U) \
+ )
+
+#define SAMD20E ( \
+ SAM_PART_IS_DEFINED(SAMD20E14) || \
+ SAM_PART_IS_DEFINED(SAMD20E15) || \
+ SAM_PART_IS_DEFINED(SAMD20E16) || \
+ SAM_PART_IS_DEFINED(SAMD20E17) || \
+ SAM_PART_IS_DEFINED(SAMD20E18) || \
+ SAM_PART_IS_DEFINED(SAMD20E1F) \
+ )
+/** @} */
+
+/**
+ * \name SAMD21 series
+ * @{
+ */
+#define SAMD21J ( \
+ SAM_PART_IS_DEFINED(SAMD21J15A) || \
+ SAM_PART_IS_DEFINED(SAMD21J16A) || \
+ SAM_PART_IS_DEFINED(SAMD21J17A) || \
+ SAM_PART_IS_DEFINED(SAMD21J18A) || \
+ SAM_PART_IS_DEFINED(SAMD21J15B) || \
+ SAM_PART_IS_DEFINED(SAMD21J16B) \
+ )
+
+#define SAMD21G ( \
+ SAM_PART_IS_DEFINED(SAMD21G15A) || \
+ SAM_PART_IS_DEFINED(SAMD21G16A) || \
+ SAM_PART_IS_DEFINED(SAMD21G17A) || \
+ SAM_PART_IS_DEFINED(SAMD21G17AU) || \
+ SAM_PART_IS_DEFINED(SAMD21G18A) || \
+ SAM_PART_IS_DEFINED(SAMD21G18AU) || \
+ SAM_PART_IS_DEFINED(SAMD21G15B) || \
+ SAM_PART_IS_DEFINED(SAMD21G16B) \
+ )
+
+#define SAMD21E ( \
+ SAM_PART_IS_DEFINED(SAMD21E15A) || \
+ SAM_PART_IS_DEFINED(SAMD21E16A) || \
+ SAM_PART_IS_DEFINED(SAMD21E17A) || \
+ SAM_PART_IS_DEFINED(SAMD21E18A) || \
+ SAM_PART_IS_DEFINED(SAMD21E15B) || \
+ SAM_PART_IS_DEFINED(SAMD21E15BU) || \
+ SAM_PART_IS_DEFINED(SAMD21E16B) || \
+ SAM_PART_IS_DEFINED(SAMD21E16BU) || \
+ SAM_PART_IS_DEFINED(SAMD21E15L) || \
+ SAM_PART_IS_DEFINED(SAMD21E16L) \
+ )
+/** @} */
+
+/**
+ * \name SAMR21 series
+ * @{
+ */
+#define SAMR21G ( \
+ SAM_PART_IS_DEFINED(SAMR21G16A) || \
+ SAM_PART_IS_DEFINED(SAMR21G17A) || \
+ SAM_PART_IS_DEFINED(SAMR21G18A) \
+ )
+
+#define SAMR21E ( \
+ SAM_PART_IS_DEFINED(SAMR21E16A) || \
+ SAM_PART_IS_DEFINED(SAMR21E17A) || \
+ SAM_PART_IS_DEFINED(SAMR21E18A) \
+ )
+/** @} */
+
+/**
+ * \name SAMD10 series
+ * @{
+ */
+#define SAMD10C ( \
+ SAM_PART_IS_DEFINED(SAMD10C12A) || \
+ SAM_PART_IS_DEFINED(SAMD10C13A) || \
+ SAM_PART_IS_DEFINED(SAMD10C14A) \
+ )
+
+#define SAMD10DS ( \
+ SAM_PART_IS_DEFINED(SAMD10D12AS) || \
+ SAM_PART_IS_DEFINED(SAMD10D13AS) || \
+ SAM_PART_IS_DEFINED(SAMD10D14AS) \
+ )
+
+#define SAMD10DM ( \
+ SAM_PART_IS_DEFINED(SAMD10D12AM) || \
+ SAM_PART_IS_DEFINED(SAMD10D13AM) || \
+ SAM_PART_IS_DEFINED(SAMD10D14AM) \
+ )
+/** @} */
+
+/**
+ * \name SAMD11 series
+ * @{
+ */
+#define SAMD11C ( \
+ SAM_PART_IS_DEFINED(SAMD11C14A) \
+ )
+
+#define SAMD11DS ( \
+ SAM_PART_IS_DEFINED(SAMD11D14AS) \
+ )
+
+#define SAMD11DM ( \
+ SAM_PART_IS_DEFINED(SAMD11D14AM) \
+ )
+/** @} */
+
+/**
+ * \name SAML21 series
+ * @{
+ */
+#define SAML21E ( \
+ SAM_PART_IS_DEFINED(SAML21E15A) || \
+ SAM_PART_IS_DEFINED(SAML21E16A) || \
+ SAM_PART_IS_DEFINED(SAML21E17A) || \
+ SAM_PART_IS_DEFINED(SAML21E18A) \
+ )
+
+#define SAML21G ( \
+ SAM_PART_IS_DEFINED(SAML21G16A) || \
+ SAM_PART_IS_DEFINED(SAML21G17A) || \
+ SAM_PART_IS_DEFINED(SAML21G18A) \
+ )
+
+#define SAML21J ( \
+ SAM_PART_IS_DEFINED(SAML21J16A) || \
+ SAM_PART_IS_DEFINED(SAML21J17A) || \
+ SAM_PART_IS_DEFINED(SAML21J18A) \
+ )
+/** @} */
+
+/**
+ * \name SAM4E series
+ * @{
+ */
+#define SAM4E8 ( \
+ SAM_PART_IS_DEFINED(SAM4E8C) || \
+ SAM_PART_IS_DEFINED(SAM4E8E) \
+ )
+
+#define SAM4E16 ( \
+ SAM_PART_IS_DEFINED(SAM4E16C) || \
+ SAM_PART_IS_DEFINED(SAM4E16E) \
+ )
+/** @} */
+
+/**
+ * \name SAM4N series
+ * @{
+ */
+#define SAM4N8 ( \
+ SAM_PART_IS_DEFINED(SAM4N8A) || \
+ SAM_PART_IS_DEFINED(SAM4N8B) || \
+ SAM_PART_IS_DEFINED(SAM4N8C) \
+ )
+
+#define SAM4N16 ( \
+ SAM_PART_IS_DEFINED(SAM4N16B) || \
+ SAM_PART_IS_DEFINED(SAM4N16C) \
+ )
+/** @} */
+
+/**
+ * \name SAM4C series
+ * @{
+ */
+#define SAM4C8_0 ( \
+ SAM_PART_IS_DEFINED(SAM4C8C_0) \
+ )
+
+#define SAM4C8_1 ( \
+ SAM_PART_IS_DEFINED(SAM4C8C_1) \
+ )
+
+#define SAM4C8 (SAM4C8_0 || SAM4C8_1)
+
+#define SAM4C16_0 ( \
+ SAM_PART_IS_DEFINED(SAM4C16C_0) \
+ )
+
+#define SAM4C16_1 ( \
+ SAM_PART_IS_DEFINED(SAM4C16C_1) \
+ )
+
+#define SAM4C16 (SAM4C16_0 || SAM4C16_1)
+
+#define SAM4C32_0 ( \
+ SAM_PART_IS_DEFINED(SAM4C32C_0) ||\
+ SAM_PART_IS_DEFINED(SAM4C32E_0) \
+ )
+
+#define SAM4C32_1 ( \
+ SAM_PART_IS_DEFINED(SAM4C32C_1) ||\
+ SAM_PART_IS_DEFINED(SAM4C32E_1) \
+ )
+
+
+#define SAM4C32 (SAM4C32_0 || SAM4C32_1)
+
+/** @} */
+
+/**
+ * \name SAM4CM series
+ * @{
+ */
+#define SAM4CMP8_0 ( \
+ SAM_PART_IS_DEFINED(SAM4CMP8C_0) \
+ )
+
+#define SAM4CMP8_1 ( \
+ SAM_PART_IS_DEFINED(SAM4CMP8C_1) \
+ )
+
+#define SAM4CMP8 (SAM4CMP8_0 || SAM4CMP8_1)
+
+#define SAM4CMP16_0 ( \
+ SAM_PART_IS_DEFINED(SAM4CMP16C_0) \
+ )
+
+#define SAM4CMP16_1 ( \
+ SAM_PART_IS_DEFINED(SAM4CMP16C_1) \
+ )
+
+#define SAM4CMP16 (SAM4CMP16_0 || SAM4CMP16_1)
+
+#define SAM4CMP32_0 ( \
+ SAM_PART_IS_DEFINED(SAM4CMP32C_0) \
+ )
+
+#define SAM4CMP32_1 ( \
+ SAM_PART_IS_DEFINED(SAM4CMP32C_1) \
+ )
+
+#define SAM4CMP32 (SAM4CMP32_0 || SAM4CMP32_1)
+
+#define SAM4CMS8_0 ( \
+ SAM_PART_IS_DEFINED(SAM4CMS8C_0) \
+ )
+
+#define SAM4CMS8_1 ( \
+ SAM_PART_IS_DEFINED(SAM4CMS8C_1) \
+ )
+
+#define SAM4CMS8 (SAM4CMS8_0 || SAM4CMS8_1)
+
+#define SAM4CMS16_0 ( \
+ SAM_PART_IS_DEFINED(SAM4CMS16C_0) \
+ )
+
+#define SAM4CMS16_1 ( \
+ SAM_PART_IS_DEFINED(SAM4CMS16C_1) \
+ )
+
+#define SAM4CMS16 (SAM4CMS16_0 || SAM4CMS16_1)
+
+#define SAM4CMS32_0 ( \
+ SAM_PART_IS_DEFINED(SAM4CMS32C_0) \
+ )
+
+#define SAM4CMS32_1 ( \
+ SAM_PART_IS_DEFINED(SAM4CMS32C_1) \
+ )
+
+#define SAM4CMS32 (SAM4CMS32_0 || SAM4CMS32_1)
+
+/** @} */
+
+/**
+ * \name SAM4CP series
+ * @{
+ */
+#define SAM4CP16_0 ( \
+ SAM_PART_IS_DEFINED(SAM4CP16B_0) \
+ )
+
+#define SAM4CP16_1 ( \
+ SAM_PART_IS_DEFINED(SAM4CP16B_1) \
+ )
+
+#define SAM4CP16 (SAM4CP16_0 || SAM4CP16_1)
+/** @} */
+
+/**
+ * \name SAMG series
+ * @{
+ */
+#define SAMG51 ( \
+ SAM_PART_IS_DEFINED(SAMG51G18) \
+ )
+
+#define SAMG53 ( \
+ SAM_PART_IS_DEFINED(SAMG53G19) ||\
+ SAM_PART_IS_DEFINED(SAMG53N19) \
+ )
+
+#define SAMG54 ( \
+ SAM_PART_IS_DEFINED(SAMG54G19) ||\
+ SAM_PART_IS_DEFINED(SAMG54J19) ||\
+ SAM_PART_IS_DEFINED(SAMG54N19) \
+ )
+
+#define SAMG55 ( \
+ SAM_PART_IS_DEFINED(SAMG55G18) ||\
+ SAM_PART_IS_DEFINED(SAMG55G19) ||\
+ SAM_PART_IS_DEFINED(SAMG55J18) ||\
+ SAM_PART_IS_DEFINED(SAMG55J19) ||\
+ SAM_PART_IS_DEFINED(SAMG55N19) \
+ )
+/** @} */
+/**
+ * \name SAM families
+ * @{
+ */
+/** SAM3S Family */
+#define SAM3S (SAM3S1 || SAM3S2 || SAM3S4 || SAM3S8 || SAM3SD8)
+
+/** SAM3U Family */
+#define SAM3U (SAM3U1 || SAM3U2 || SAM3U4)
+
+/** SAM3N Family */
+#define SAM3N (SAM3N00 || SAM3N0 || SAM3N1 || SAM3N2 || SAM3N4)
+
+/** SAM3XA Family */
+#define SAM3XA (SAM3X4 || SAM3X8 || SAM3A4 || SAM3A8)
+
+/** SAM4S Family */
+#define SAM4S (SAM4S2 || SAM4S4 || SAM4S8 || SAM4S16 || SAM4SA16 || SAM4SD16 || SAM4SD32)
+
+/** SAM4L Family */
+#define SAM4L (SAM4LS || SAM4LC)
+
+/** SAMD20 Family */
+#define SAMD20 (SAMD20J || SAMD20G || SAMD20E)
+
+/** SAMD21 Family */
+#define SAMD21 (SAMD21J || SAMD21G || SAMD21E)
+
+/** SAMD10 Family */
+#define SAMD10 (SAMD10C || SAMD10DS || SAMD10DM)
+
+/** SAMD11 Family */
+#define SAMD11 (SAMD11C || SAMD11DS || SAMD11DM)
+
+/** SAMD Family */
+#define SAMD (SAMD20 || SAMD21 || SAMD10 || SAMD11)
+
+/** SAMR21 Family */
+#define SAMR21 (SAMR21G || SAMR21E)
+
+/** SAML21 Family */
+#define SAML21 (SAML21J || SAML21G || SAML21E)
+
+/** SAM4E Family */
+#define SAM4E (SAM4E8 || SAM4E16)
+
+/** SAM4N Family */
+#define SAM4N (SAM4N8 || SAM4N16)
+
+/** SAM4C Family */
+#define SAM4C_0 (SAM4C8_0 || SAM4C16_0 || SAM4C32_0)
+#define SAM4C_1 (SAM4C8_1 || SAM4C16_1 || SAM4C32_1)
+#define SAM4C (SAM4C8 || SAM4C16 || SAM4C32)
+
+/** SAM4CM Family */
+#define SAM4CM_0 (SAM4CMP8_0 || SAM4CMP16_0 || SAM4CMP32_0 || SAM4CMS8_0 || \
+ SAM4CMS16_0 || SAM4CMS32_0)
+#define SAM4CM_1 (SAM4CMP8_1 || SAM4CMP16_1 || SAM4CMP32_1 || SAM4CMS8_1 || \
+ SAM4CMS16_1 || SAM4CMS32_1)
+#define SAM4CM (SAM4CMP8 || SAM4CMP16 || SAM4CMP32 || SAM4CMS8 || \
+ SAM4CMS16 || SAM4CMS32)
+
+/** SAM4CP Family */
+#define SAM4CP_0 (SAM4CP16_0)
+#define SAM4CP_1 (SAM4CP16_1)
+#define SAM4CP (SAM4CP16)
+
+/** SAMG Family */
+#define SAMG (SAMG51 || SAMG53 || SAMG54 || SAMG55)
+
+/** SAM0 product line (cortex-m0+) */
+#define SAM0 (SAMD20 || SAMD21 || SAMR21 || SAMD10 || SAMD11 || SAML21)
+
+/** @} */
+
+/** SAM product line */
+#define SAM (SAM3S || SAM3U || SAM3N || SAM3XA || SAM4S || SAM4L || SAM4E || \
+ SAM0 || SAM4N || SAM4C || SAM4CM || SAM4CP || SAMG)
+
+/** @} */
+
+/** @} */
+
+/** @} */
+
+#endif /* ATMEL_PARTS_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/parts.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/common/utils/parts.h.REMOVED.git-id
deleted file mode 100644
index ad358fbe..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/common/utils/parts.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b0ddbdf452609855bc00ead95bd72eff266ac6be
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/init.c b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/init.c
new file mode 100644
index 00000000..571692ee
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/init.c
@@ -0,0 +1,163 @@
+/**
+ * \file
+ *
+ * \brief XMEGA-A3BU Xplained board init.
+ *
+ * This file contains board initialization function.
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include
+#include
+#include
+
+/**
+ * \addtogroup xmega_a3bu_xplained_group
+ * @{
+ */
+
+void board_init(void)
+{
+ ioport_configure_pin(LED0_GPIO, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
+ ioport_configure_pin(LED1_GPIO, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
+ ioport_configure_pin(LED2_GPIO, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
+ ioport_configure_pin(LED3_GPIO, IOPORT_DIR_OUTPUT | IOPORT_INIT_LOW
+ | IOPORT_INV_ENABLED);
+
+ ioport_configure_pin(GPIO_PUSH_BUTTON_0, IOPORT_DIR_INPUT
+ | IOPORT_LEVEL | IOPORT_PULL_UP);
+ ioport_configure_pin(GPIO_PUSH_BUTTON_1, IOPORT_DIR_INPUT
+ | IOPORT_LEVEL | IOPORT_PULL_UP);
+ ioport_configure_pin(GPIO_PUSH_BUTTON_2, IOPORT_DIR_INPUT
+ | IOPORT_LEVEL | IOPORT_PULL_UP);
+
+#ifdef CONF_BOARD_C12832A1Z
+ ioport_configure_pin(NHD_C12832A1Z_SPI_SCK, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(NHD_C12832A1Z_SPI_MOSI, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(NHD_C12832A1Z_CSN, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(NHD_C12832A1Z_REGISTER_SELECT, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(NHD_C12832A1Z_RESETN, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(NHD_C12832A1Z_BACKLIGHT, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_LOW);
+#endif
+
+#ifdef CONF_BOARD_AT45DBX
+ ioport_configure_pin(AT45DBX_MASTER_SCK, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(AT45DBX_MASTER_MOSI, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(AT45DBX_MASTER_MISO, IOPORT_DIR_INPUT);
+ ioport_configure_pin(AT45DBX_CS, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
+#endif
+
+#ifdef CONF_BOARD_ENABLE_MXT143E_XPLAINED
+ ioport_configure_pin(MXT143E_XPLAINED_SCK, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(MXT143E_XPLAINED_MOSI, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(MXT143E_XPLAINED_MISO, IOPORT_DIR_INPUT);
+ ioport_configure_pin(MXT143E_XPLAINED_CS, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(MXT143E_XPLAINED_CHG, IOPORT_DIR_INPUT);
+ ioport_configure_pin(MXT143E_XPLAINED_DC, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_LOW);
+ #ifndef MXT143E_XPLAINED_BACKLIGHT_DISABLE
+ ioport_configure_pin(MXT143E_XPLAINED_BACKLIGHT, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_LOW);
+ #endif
+ ioport_configure_pin(MXT143E_XPLAINED_LCD_RESET, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_LOW);
+#endif
+
+#ifdef CONF_BOARD_ENABLE_AC_PINS
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTA, 0), IOPORT_DIR_INPUT);
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTA, 2), IOPORT_DIR_INPUT);
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTB, 1), IOPORT_DIR_INPUT);
+#endif
+
+#ifdef CONF_BOARD_ENABLE_USARTC0
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTC, 3), IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTC, 2), IOPORT_DIR_INPUT);
+#endif
+
+#ifdef CONF_BOARD_ENABLE_USARTD0
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTD, 3), IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTD, 2), IOPORT_DIR_INPUT);
+#endif
+
+#ifdef CONF_BOARD_ENABLE_USARTE0
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTE, 3), IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(IOPORT_CREATE_PIN(PORTE, 2), IOPORT_DIR_INPUT);
+#endif
+
+#if defined (SENSORS_XPLAINED_BOARD)
+ /* Configure the Xplained Sensor extension board, if any, after
+ * the platform Xplained board has configured basic clock settings,
+ * GPIO pin mapping, interrupt controller options, etc.
+ */
+ sensor_board_init ();
+#endif
+
+#ifdef CONF_BOARD_AT86RFX
+ ioport_configure_pin(AT86RFX_SPI_SCK, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(AT86RFX_SPI_MOSI, IOPORT_DIR_OUTPUT
+ | IOPORT_INIT_HIGH);
+ ioport_configure_pin(AT86RFX_SPI_MISO, IOPORT_DIR_INPUT);
+ ioport_configure_pin(AT86RFX_SPI_CS, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
+
+ /* Initialize TRX_RST and SLP_TR as GPIO. */
+ ioport_configure_pin(AT86RFX_RST_PIN, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
+ ioport_configure_pin(AT86RFX_SLP_PIN, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
+#endif
+}
+
+/**
+ * @}
+ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/init.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/init.c.REMOVED.git-id
deleted file mode 100644
index beaf1c89..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/init.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-571692eecb0d2c5e207b7bbb547de6e5ea0c3d79
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/led.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/led.h
new file mode 100644
index 00000000..702e895f
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/led.h
@@ -0,0 +1,83 @@
+/**
+ * \file
+ *
+ * \brief XMEGA-A3BU board LEDs support package.
+ *
+ * This file contains definitions and services related to the LED features of
+ * the XMEGA-A3BU Xplained board.
+ *
+ * To use this board, define BOARD=XMEGA_A3BU_XPLAINED.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _LED_H_
+#define _LED_H_
+
+#include "gpio.h"
+
+/**
+ * \brief Turns off the specified LEDs.
+ *
+ * \param led_gpio LED to turn off (LEDx_GPIO).
+ *
+ * \note The pins of the specified LEDs are set to GPIO output mode.
+ */
+#define LED_Off(led_gpio) gpio_set_pin_high(led_gpio)
+
+/**
+ * \brief Turns on the specified LEDs.
+ *
+ * \param led_gpio LED to turn on (LEDx_GPIO).
+ *
+ * \note The pins of the specified LEDs are set to GPIO output mode.
+ */
+#define LED_On(led_gpio) gpio_set_pin_low(led_gpio)
+
+/**
+ * \brief Toggles the specified LEDs.
+ *
+ * \param led_gpio LED to toggle (LEDx_GPIO).
+ *
+ * \note The pins of the specified LEDs are set to GPIO output mode.
+ */
+#define LED_Toggle(led_gpio) gpio_toggle_pin(led_gpio)
+
+#endif /* _LED_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/led.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/led.h.REMOVED.git-id
deleted file mode 100644
index bdabf7e2..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/led.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-702e895f177e913969bfd5223c93d3ed2fbe05b7
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/xmega_a3bu_xplained.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/xmega_a3bu_xplained.h
new file mode 100644
index 00000000..e8165188
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/xmega_a3bu_xplained.h
@@ -0,0 +1,417 @@
+/**
+ * \file
+ *
+ * \brief XMEGA-A3BU-XPLAINED board header file.
+ *
+ * This file contains definitions and services related to the features of the
+ * XMEGA-A3BU Xplained board.
+ *
+ * To use this board define BOARD=XMEGA_A3BU_XPLAINED.
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _XMEGA_A3BU_XPLAINED_H_
+#define _XMEGA_A3BU_XPLAINED_H_
+
+#include
+
+#define MCU_SOC_NAME "ATxmega256A3BU"
+#define BOARD_NAME "XMEGA-A3BU-XPLAINED"
+/**
+ * \defgroup xmega_a3bu_xplained_group XMEGA-A3BU Xplained board
+ * @{
+ */
+
+/**
+ * \defgroup xmega_a3bu_xplained_feature_group Feature definitions
+ * @{
+ */
+
+//! \name Miscellaneous data
+//@{
+//! Validate board support for the common sensor service.
+#define COMMON_SENSOR_PLATFORM
+//@}
+
+/**
+ * \name LEDs
+ *
+ * LED0 and LED1 are single yellow LEDs that are active low..
+ * LED2 and LED3 are inside one package (Led red and green close
+ * to USB connector) but can be controlled individually.
+ * LED2 has a red color and is active low. This LED can be
+ * used for general purposes.
+ * LED3 has a green color and is active high. By default this
+ * LED is on since it shall indicate that power is applied to the
+ * board. By pulling the gate of a N-FET low it is possible to
+ * turn off the LED if needed.
+ */
+//@{
+#define LED0_GPIO IOPORT_CREATE_PIN(PORTR, 0)
+#define LED1_GPIO IOPORT_CREATE_PIN(PORTR, 1)
+#define LED2_GPIO IOPORT_CREATE_PIN(PORTD, 4)
+#define LED3_GPIO IOPORT_CREATE_PIN(PORTD, 5)
+#define LED0 LED0_GPIO
+#define LED1 LED1_GPIO
+#define LED2 LED2_GPIO
+#define LED3 LED3_GPIO
+//! Number of LEDs.
+#define LED_COUNT 4
+//@}
+
+//! \name Push buttons
+//@{
+#define GPIO_PUSH_BUTTON_0 IOPORT_CREATE_PIN(PORTE, 5)
+#define GPIO_PUSH_BUTTON_1 IOPORT_CREATE_PIN(PORTF, 1)
+#define GPIO_PUSH_BUTTON_2 IOPORT_CREATE_PIN(PORTF, 2)
+//@}
+
+//! \name QTouch button
+//! This button requires the software QTouch library
+//@{
+#define QTOUCH_BUTTON_SNS IOPORT_CREATE_PIN(PORTF, 6)
+#define QTOUCH_BUTTON_SNSK IOPORT_CREATE_PIN(PORTF, 7)
+//@}
+
+//! \name Light sensor
+//@{
+#define LIGHT_SENSOR_ADC_MODULE ADCA
+#define LIGHT_SENSOR_ADC_INPUT ADCCH_POS_PIN0
+#define LIGHT_SENSOR_SIGNAL_PIN IOPORT_CREATE_PIN(PORTA, 0)
+//@}
+
+//! \name Temperature sensor (NTC)
+//@{
+#define TEMPERATURE_SENSOR_ADC_MODULE ADCA
+#define TEMPERATURE_SENSOR_ADC_INPUT ADCCH_POS_PIN1
+#define TEMPERATURE_SENSOR_SIGNAL_PIN IOPORT_CREATE_PIN(PORTA, 1)
+//@}
+
+//! \name Analog filter (lowpass RC @ 159 Hz)
+//@{
+#define FILTER_INPUT_SIGNAL_PIN IOPORT_CREATE_PIN(PORTF, 0)
+#define FILTER_OUTPUT_ADC_MODULE ADCA
+#define FILTER_OUTPUT_ADC_INPUT ADCCH_POS_PIN2
+#define FILTER_OUTPUT_SIGNAL_PIN IOPORT_CREATE_PIN(PORTA, 2)
+//@}
+
+//! \name LCD backlight
+//@{
+#define LCD_BACKLIGHT_ENABLE_PIN IOPORT_CREATE_PIN(PORTE, 4)
+#define LCD_BACKLIGHT_ENABLE_LEVEL true
+//@}
+
+//! \name LCD controller (NHD-C12832A1Z-FSW-FBW-3V3)
+//@{
+#define NHD_C12832A1Z_SPI &USARTD0
+#define NHD_C12832A1Z_SPI_SCK IOPORT_CREATE_PIN(PORTD, 1)
+#define NHD_C12832A1Z_SPI_MOSI IOPORT_CREATE_PIN(PORTD, 3)
+#define NHD_C12832A1Z_CSN IOPORT_CREATE_PIN(PORTF, 3)
+//! If this signal is set high display data is sent otherwise commands
+#define NHD_C12832A1Z_REGISTER_SELECT IOPORT_CREATE_PIN(PORTD, 0)
+#define NHD_C12832A1Z_RESETN IOPORT_CREATE_PIN(PORTA, 3)
+//! The backlight is active high
+#define NHD_C12832A1Z_BACKLIGHT IOPORT_CREATE_PIN(PORTE, 4)
+//@}
+
+//! \name LCD dimensions
+//@{
+#define LCD_WIDTH_PIXELS (128)
+#define LCD_HEIGHT_PIXELS (32)
+//@}
+
+//! \name DataFlash memory (AT45DBX)
+//@{
+#define AT45DBX_SPI &USARTD0
+#define AT45DBX_CS IOPORT_CREATE_PIN(PORTF, 4)
+//! SCK pin
+#define AT45DBX_MASTER_SCK IOPORT_CREATE_PIN(PORTD, 1)
+//! MOSI pin
+#define AT45DBX_MASTER_MOSI IOPORT_CREATE_PIN(PORTD, 3)
+//! MISO pin
+#define AT45DBX_MASTER_MISO IOPORT_CREATE_PIN(PORTD, 2)
+//@}
+
+//! \name MXT143E Xplained top module
+//@{
+#define MXT143E_XPLAINED_TWI &TWIC
+#define MXT143E_XPLAINED_USART_SPI &USARTC1
+#define MXT143E_XPLAINED_CS IOPORT_CREATE_PIN(PORTC, 4)
+#define MXT143E_XPLAINED_SCK IOPORT_CREATE_PIN(PORTC, 7)
+#define MXT143E_XPLAINED_MOSI IOPORT_CREATE_PIN(PORTC, 5)
+#define MXT143E_XPLAINED_MISO IOPORT_CREATE_PIN(PORTC, 6)
+#define MXT143E_XPLAINED_CHG IOPORT_CREATE_PIN(PORTC, 2)
+#define MXT143E_XPLAINED_DC IOPORT_CREATE_PIN(PORTC, 3)
+#define MXT143E_XPLAINED_BACKLIGHT IOPORT_CREATE_PIN(PORTA, 4)
+#define MXT143E_XPLAINED_LCD_RESET IOPORT_CREATE_PIN(PORTA, 6)
+//@}
+
+/**
+ * \name External oscillator
+ *
+ * \todo Need to measure the actual startup time on the hardware.
+ */
+//@{
+#define BOARD_XOSC_HZ 32768
+#define BOARD_XOSC_TYPE XOSC_TYPE_32KHZ
+#define BOARD_XOSC_STARTUP_US 1000000
+//@}
+
+//! \name Communication interfaces on header J1
+//@{
+#define TWIC_SDA IOPORT_CREATE_PIN(PORTC, 0)
+#define TWIC_SCL IOPORT_CREATE_PIN(PORTC, 1)
+#define USARTC0_RXD IOPORT_CREATE_PIN(PORTC, 2)
+#define USARTC0_TXD IOPORT_CREATE_PIN(PORTC, 3)
+#define SPIC_SS IOPORT_CREATE_PIN(PORTC, 4)
+#define SPIC_MOSI IOPORT_CREATE_PIN(PORTC, 5)
+#define SPIC_MISO IOPORT_CREATE_PIN(PORTC, 6)
+#define SPIC_SCK IOPORT_CREATE_PIN(PORTC, 7)
+//@}
+
+
+/*! \name Connections of the AT86RFX transceiver
+ */
+//! @{
+#define AT86RFX_SPI &SPIC
+#define AT86RFX_RST_PIN IOPORT_CREATE_PIN(PORTC, 0)
+#define AT86RFX_MISC_PIN IOPORT_CREATE_PIN(PORTC, 1)
+#define AT86RFX_IRQ_PIN IOPORT_CREATE_PIN(PORTC, 2)
+#define AT86RFX_SLP_PIN IOPORT_CREATE_PIN(PORTC, 3)
+#define AT86RFX_SPI_CS IOPORT_CREATE_PIN(PORTC, 4)
+#define AT86RFX_SPI_MOSI IOPORT_CREATE_PIN(PORTC, 5)
+#define AT86RFX_SPI_MISO IOPORT_CREATE_PIN(PORTC, 6)
+#define AT86RFX_SPI_SCK IOPORT_CREATE_PIN(PORTC, 7)
+
+#define AT86RFX_INTC_INIT() ioport_configure_pin(AT86RFX_IRQ_PIN, IOPORT_DIR_INPUT); \
+ PORTC.PIN2CTRL = PORT_ISC0_bm; \
+ PORTC.INT0MASK = PIN2_bm; \
+ PORTC.INTFLAGS = PORT_INT0IF_bm;
+
+#define AT86RFX_ISR() ISR(PORTC_INT0_vect)
+
+/** Enables the transceiver main interrupt. */
+#define ENABLE_TRX_IRQ() (PORTC.INTCTRL |= PORT_INT0LVL_gm)
+
+/** Disables the transceiver main interrupt. */
+#define DISABLE_TRX_IRQ() (PORTC.INTCTRL &= ~PORT_INT0LVL_gm)
+
+/** Clears the transceiver main interrupt. */
+#define CLEAR_TRX_IRQ() (PORTC.INTFLAGS = PORT_INT0IF_bm)
+
+/*
+ * This macro saves the trx interrupt status and disables the trx interrupt.
+ */
+#define ENTER_TRX_REGION() { uint8_t irq_mask = PORTC.INTCTRL; PORTC.INTCTRL &= ~PORT_INT0LVL_gm
+
+/*
+ * This macro restores the transceiver interrupt status
+ */
+#define LEAVE_TRX_REGION() PORTC.INTCTRL = irq_mask; }
+
+//! @}
+
+
+/**
+ * \name Pin connections on header J1
+ *
+ * The whole port C is directly connected to J1.
+ *
+ * \note For the TWI lines there are footprints for pull up resistors, which
+ * are by default not mounted on the board.
+ */
+//@{
+#define J1_PIN0 IOPORT_CREATE_PIN(PORTC, 0)
+#define J1_PIN1 IOPORT_CREATE_PIN(PORTC, 1)
+#define J1_PIN2 IOPORT_CREATE_PIN(PORTC, 2)
+#define J1_PIN3 IOPORT_CREATE_PIN(PORTC, 3)
+#define J1_PIN4 IOPORT_CREATE_PIN(PORTC, 4)
+#define J1_PIN5 IOPORT_CREATE_PIN(PORTC, 5)
+#define J1_PIN6 IOPORT_CREATE_PIN(PORTC, 6)
+#define J1_PIN7 IOPORT_CREATE_PIN(PORTC, 7)
+//@}
+
+/**
+ * \name Pin connections on header J2
+ *
+ * The lower half of port B is connected to the lower pins of J2 while the
+ * upper half of port A is connected to the upper pins of J2.
+ *
+ * The port pins are connected directly to this header and are not shared with
+ * any on-board functionality.
+ */
+//@{
+#define J2_PIN0 IOPORT_CREATE_PIN(PORTB, 0)
+#define J2_PIN1 IOPORT_CREATE_PIN(PORTB, 1)
+#define J2_PIN2 IOPORT_CREATE_PIN(PORTB, 2)
+#define J2_PIN3 IOPORT_CREATE_PIN(PORTB, 3)
+#define J2_PIN4 IOPORT_CREATE_PIN(PORTA, 4)
+#define J2_PIN5 IOPORT_CREATE_PIN(PORTA, 5)
+#define J2_PIN6 IOPORT_CREATE_PIN(PORTA, 6)
+#define J2_PIN7 IOPORT_CREATE_PIN(PORTA, 7)
+//@}
+
+/**
+ * \name Pin connections on header J3
+ *
+ * The lower half of port A is connected to the lower pins of J3 while the
+ * upper half of port B is connected to the upper pins of J3.
+ *
+ * Following pins are shared with on-board functionality:
+ * - J3_PIN0 Light sensor output (can be disconnected via scratch pad)
+ * - J3_PIN1 NTC sensor output (can be disconnected via scratch pad)
+ * - J3_PIN2 Filter output (can be disconnected via scratch pad)
+ * - J3_PIN3 Display reset input (can't be used when display is in use)
+ * - J3_PIN4 JTAG TMS (pin can't be used while JTAG device connected)
+ * - J3_PIN5 JTAG TDI (pin can't be used while JTAG device connected)
+ * - J3_PIN6 JTAG TCK (pin can't be used while JTAG device connected)
+ * - J3_PIN7 JTAG TDO & PID DATA (pin can't be used while JTAG/PDI device is
+ * connected)
+ */
+//@{
+#define J3_PIN0 IOPORT_CREATE_PIN(PORTA, 0)
+#define J3_PIN1 IOPORT_CREATE_PIN(PORTA, 1)
+#define J3_PIN2 IOPORT_CREATE_PIN(PORTA, 2)
+#define J3_PIN3 IOPORT_CREATE_PIN(PORTA, 3)
+#define J3_PIN4 IOPORT_CREATE_PIN(PORTB, 4)
+#define J3_PIN5 IOPORT_CREATE_PIN(PORTB, 5)
+#define J3_PIN6 IOPORT_CREATE_PIN(PORTB, 6)
+#define J3_PIN7 IOPORT_CREATE_PIN(PORTB, 7)
+//@}
+
+/**
+ * \name Pin connections on header J4
+ *
+ * The lower half of port E is connected to the lower pins of J4 and the lower
+ * half of port D is connected to the upper pins of J4.
+ */
+//@{
+#define J4_PIN0 IOPORT_CREATE_PIN(PORTE, 0)
+#define J4_PIN1 IOPORT_CREATE_PIN(PORTE, 1)
+#define J4_PIN2 IOPORT_CREATE_PIN(PORTE, 2)
+#define J4_PIN3 IOPORT_CREATE_PIN(PORTE, 3)
+#define J4_PIN4 IOPORT_CREATE_PIN(PORTD, 0)
+#define J4_PIN5 IOPORT_CREATE_PIN(PORTD, 3)
+#define J4_PIN6 IOPORT_CREATE_PIN(PORTD, 2)
+#define J4_PIN7 IOPORT_CREATE_PIN(PORTD, 1)
+//@}
+
+/**
+ * @}
+ */
+
+/**
+ * \defgroup xmega_a3bu_xplained_config_group Configuration options
+ * @{
+ */
+
+#if defined(__DOXYGEN__)
+
+/**
+ * \name Initialization
+ * \note Define these symbols in \ref conf_board.h to enable the corresponding
+ * features.
+ */
+//@{
+
+/**
+ * \def CONF_BOARD_C12832A1Z
+ * \brief Initialize SPI and control pins for C12832A1Z LCD controller
+ */
+# if !defined(CONF_BOARD_C12832A1Z)
+# define CONF_BOARD_C12832A1Z
+# endif
+
+/**
+ * \def CONF_BOARD_AT45DBX
+ * \brief Initialize SPI pins for AT45DBX DataFlash
+ */
+# if !defined(CONF_BOARD_AT45DBX)
+# define CONF_BOARD_AT45DBX
+# endif
+
+/**
+ * \def CONF_BOARD_ENABLE_AC_PINS
+ * \brief Initialize IO pins for Analog Comparator
+ *
+ * \note This initializes pins PA0, PA2 and PB1 as inputs.
+ */
+# if !defined(CONF_BOARD_ENABLE_AC_PINS)
+# define CONF_BOARD_ENABLE_AC_PINS
+# endif
+
+/**
+ * \def CONF_BOARD_ENABLE_USARTC0
+ * \brief Initialize IO pins for USART 0 on port C
+ */
+# if !defined(CONF_BOARD_ENABLE_USARTC0)
+# define CONF_BOARD_ENABLE_USARTC0
+# endif
+
+/**
+ * \def CONF_BOARD_ENABLE_USARTD0
+ * \brief Initialize IO pins for USART 0 on port D
+ */
+# if !defined(CONF_BOARD_ENABLE_USARTD0)
+# define CONF_BOARD_ENABLE_USARTD0
+# endif
+
+/**
+ * \def CONF_BOARD_ENABLE_USARTE0
+ * \brief Initialize IO pins for USART 0 on port E
+ */
+# if !defined(CONF_BOARD_ENABLE_USARTE0)
+# define CONF_BOARD_ENABLE_USARTE0
+# endif
+
+//@}
+
+#endif // __DOXYGEN__
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#endif /* _XMEGA_A3BU_XPLAINED_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/xmega_a3bu_xplained.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/xmega_a3bu_xplained.h.REMOVED.git-id
deleted file mode 100644
index 26826736..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/boards/xmega_a3bu_xplained/xmega_a3bu_xplained.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e81651885cd903ea6df1218a89ae12ec2b063f97
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.h
new file mode 100644
index 00000000..1e929a4d
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.h
@@ -0,0 +1,123 @@
+/**
+ * \file
+ *
+ * \brief Configuration Change Protection write functions
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CPU_CCP_H
+#define CPU_CCP_H
+#include
+
+/**
+ * \defgroup ccp_group Configuration Change Protection
+ *
+ * See \ref xmega_ccp_quickstart.
+ *
+ * Function for writing to protected IO registers.
+ * @{
+ */
+
+#if defined(__DOXYGEN__)
+//! \name IAR Memory Model defines.
+//@{
+
+/**
+ * \def CONFIG_MEMORY_MODEL_TINY
+ * \brief Configuration symbol to enable 8 bit pointers.
+ *
+ */
+# define CONFIG_MEMORY_MODEL_TINY
+
+/**
+ * \def CONFIG_MEMORY_MODEL_SMALL
+ * \brief Configuration symbol to enable 16 bit pointers.
+ * \note If no memory model is defined, SMALL is default.
+ *
+ */
+# define CONFIG_MEMORY_MODEL_SMALL
+
+
+/**
+ * \def CONFIG_MEMORY_MODEL_LARGE
+ * \brief Configuration symbol to enable 24 bit pointers.
+ *
+ */
+# define CONFIG_MEMORY_MODEL_LARGE
+
+//@}
+#endif
+
+
+/**
+ * \brief Write to a CCP-protected 8-bit I/O register
+ *
+ * \param addr Address of the I/O register
+ * \param value Value to be written
+ *
+ * \note Using IAR Embedded workbench, the choice of memory model has an impact
+ * on calling convention. The memory model is not visible to the
+ * preprocessor, so it must be defined in the Assembler preprocessor directives.
+ */
+extern void ccp_write_io(void *addr, uint8_t value);
+
+/** @} */
+
+/**
+ * \page xmega_ccp_quickstart Quick start guide for CCP driver
+ *
+ * This is the quick start guide for the \ref ccp_group
+ * "Configuration Change Protection (CCP) driver", with step-by-step
+ * instructions on how to use the driver.
+ *
+ * The use case contains a code fragment, and this can be copied into, e.g.,
+ * the main application function.
+ *
+ * \section ccp_basic_use_case Basic use case
+ * In this use case, the CCP is used to write to the protected XMEGA Clock
+ * Control register.
+ *
+ * \subsection ccp_basic_use_case_setup_flow Workflow
+ * -# call CCP write io to change system clock selection:
+ * - \code ccp_write_io((uint8_t *)&CLK.CTRL, CLK_SCLKSEL_RC32M_gc); \endcode
+ */
+
+#endif /* CPU_CCP_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.h.REMOVED.git-id
deleted file mode 100644
index eb519662..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1e929a4d4c2e69ef282a2f86e8509e8c259199eb
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.s b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.s
new file mode 100644
index 00000000..91f8fb02
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.s
@@ -0,0 +1,100 @@
+/**
+ * \file
+ *
+ * \brief Configuration Change Protection
+ *
+ * Copyright (c) 2009 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+#include
+
+//! Value to write to CCP for access to protected IO registers.
+#define CCP_IOREG 0xd8
+
+ /*
+ * GNU and IAR use different calling conventions. Since this is
+ * a very small and simple function to begin with, it's easier
+ * to implement it twice than to deal with the differences
+ * within a single implementation.
+ *
+ * Interrupts are disabled by hardware during the timed
+ * sequence, so there's no need to save/restore interrupt state.
+ */
+
+ PUBLIC_FUNCTION(ccp_write_io)
+
+#if defined(__GNUC__)
+
+ out RAMPZ, r1 // Reset bits 23:16 of Z
+ movw r30, r24 // Load addr into Z
+ ldi r18, CCP_IOREG // Load magic CCP value
+ out CCP, r18 // Start CCP handshake
+ st Z, r22 // Write value to I/O register
+ ret // Return to caller
+
+#elif defined(__IAR_SYSTEMS_ASM__)
+
+# if !defined(CONFIG_MEMORY_MODEL_TINY) && !defined(CONFIG_MEMORY_MODEL_SMALL) \
+ && !defined(CONFIG_MEMORY_MODEL_LARGE)
+# define CONFIG_MEMORY_MODEL_SMALL
+# endif
+ ldi r20, 0
+ out RAMPZ, r20 // Reset bits 23:16 of Z
+# if defined(CONFIG_MEMORY_MODEL_TINY)
+ mov r31, r20 // Reset bits 8:15 of Z
+ mov r30, r16 // Load addr into Z
+# else
+ movw r30, r16 // Load addr into Z
+# endif
+ ldi r21, CCP_IOREG // Load magic CCP value
+ out CCP, r21 // Start CCP handshake
+# if defined(CONFIG_MEMORY_MODEL_TINY)
+ st Z, r17 // Write value to I/O register
+# elif defined(CONFIG_MEMORY_MODEL_SMALL)
+ st Z, r18 // Write value to I/O register
+# elif defined(CONFIG_MEMORY_MODEL_LARGE)
+ st Z, r19 // Write value to I/O register
+# else
+# error Unknown memory model in use, no idea how registers should be accessed
+# endif
+ ret
+#else
+# error Unknown assembler
+#endif
+
+ END_FUNC(ccp_write_io)
+ END_FILE()
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.s.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.s.REMOVED.git-id
deleted file mode 100644
index b2a0c386..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/ccp.s.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-91f8fb02cea7897ca035b5aee8786df8b20b9ab4
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/xmega_reset_cause.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/xmega_reset_cause.h
new file mode 100644
index 00000000..ff6840a8
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/xmega_reset_cause.h
@@ -0,0 +1,108 @@
+/**
+ * \file
+ *
+ * \brief Chip-specific reset cause functions
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef XMEGA_DRIVERS_CPU_RESET_CAUSE_H
+#define XMEGA_DRIVERS_CPU_RESET_CAUSE_H
+
+#include "compiler.h"
+#include "ccp.h"
+
+/**
+ * \ingroup reset_cause_group
+ * \defgroup xmega_reset_cause_group XMEGA reset cause
+ *
+ * See \ref reset_cause_quickstart
+ *
+ * @{
+ */
+
+/**
+ * \brief Chip-specific reset cause type capable of holding all chip reset
+ * causes. Typically reflects the size of the reset cause register.
+ */
+typedef uint8_t reset_cause_t;
+
+//! \internal \name Chip-specific reset causes
+//@{
+//! \internal External reset cause
+#define CHIP_RESET_CAUSE_EXTRST RST_EXTRF_bm
+//! \internal brown-out detected reset cause, same as for CPU
+#define CHIP_RESET_CAUSE_BOD_IO RST_BORF_bm
+//! \internal Brown-out detected reset cause, same as for I/O
+#define CHIP_RESET_CAUSE_BOD_CPU RST_BORF_bm
+//! \internal On-chip debug system reset cause
+#define CHIP_RESET_CAUSE_OCD RST_PDIRF_bm
+//! \internal Power-on-reset reset cause
+#define CHIP_RESET_CAUSE_POR RST_PORF_bm
+//! \internal Software reset reset cause
+#define CHIP_RESET_CAUSE_SOFT RST_SRF_bm
+//! \internal Spike detected reset cause
+#define CHIP_RESET_CAUSE_SPIKE RST_SDRF_bm
+//! \internal Watchdog timeout reset cause
+#define CHIP_RESET_CAUSE_WDT RST_WDRF_bm
+//@}
+
+static inline reset_cause_t reset_cause_get_causes(void)
+{
+ return (reset_cause_t)RST.STATUS;
+}
+
+static inline void reset_cause_clear_causes(reset_cause_t causes)
+{
+ RST.STATUS = causes;
+}
+
+static inline void reset_do_soft_reset(void)
+{
+ ccp_write_io((void *)&RST.CTRL, RST_SWRST_bm);
+
+ while (1) {
+ /* Intentionally empty. */
+ }
+}
+
+//! @}
+
+#endif /* XMEGA_DRIVERS_CPU_RESET_CAUSE_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/xmega_reset_cause.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/xmega_reset_cause.h.REMOVED.git-id
deleted file mode 100644
index d00af4e6..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/cpu/xmega_reset_cause.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ff6840a8acaefc471367ba8fe3e39bba11aedeaf
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm.c b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm.c
new file mode 100644
index 00000000..61455202
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm.c
@@ -0,0 +1,710 @@
+/**
+ * \file
+ *
+ * \brief Non Volatile Memory controller driver
+ *
+ * Copyright (C) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include "compiler.h"
+#include "ccp.h"
+#include "nvm.h"
+#include
+
+/**
+ * \weakgroup nvm_signature_group
+ * @{
+ */
+
+/**
+ * \brief Read the device serial
+ *
+ * This function returns the device serial stored in the device.
+ *
+ * \note This function is modifying the NVM.CMD register.
+ * If the application are using program space access in interrupts
+ * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts
+ * needs to be disabled when running EEPROM access functions. If not
+ * the program space reads will be corrupted.
+ *
+ * \retval storage Pointer to the structure where to store the device serial
+ */
+void nvm_read_device_serial(struct nvm_device_serial *storage)
+{
+ storage->lotnum0 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(LOTNUM0));
+ storage->lotnum1 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(LOTNUM1));
+ storage->lotnum2 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(LOTNUM2));
+ storage->lotnum3 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(LOTNUM3));
+ storage->lotnum4 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(LOTNUM4));
+ storage->lotnum5 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(LOTNUM5));
+
+ storage->wafnum = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(WAFNUM));
+
+ storage->coordx0 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(COORDX0));
+ storage->coordx1 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(COORDX1));
+ storage->coordy0 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(COORDY0));
+ storage->coordy1 = nvm_read_production_signature_row(
+ nvm_get_production_signature_row_offset(COORDY1));
+}
+
+//! @}
+
+/**
+ * \weakgroup nvm_eeprom_group
+ * @{
+ */
+
+/**
+ * \brief Read one byte from EEPROM using mapped access.
+ *
+ * This function reads one byte from EEPROM using mapped access.
+ *
+ * \param addr EEPROM address, between 0 and EEPROM_SIZE
+ *
+ * \return Byte value read from EEPROM.
+ */
+uint8_t nvm_eeprom_read_byte(eeprom_addr_t addr)
+{
+ uint8_t data;
+ Assert(addr <= EEPROM_SIZE);
+
+ /* Wait until NVM is ready */
+ nvm_wait_until_ready();
+ eeprom_enable_mapping();
+ data = *(uint8_t*)(addr + MAPPED_EEPROM_START),
+ eeprom_disable_mapping();
+ return data;
+}
+
+/**
+ * \brief Read buffer within the eeprom
+ *
+ * \param address the address to where to read
+ * \param buf pointer to the data
+ * \param len the number of bytes to read
+ */
+void nvm_eeprom_read_buffer(eeprom_addr_t address, void *buf, uint16_t len)
+{
+ nvm_wait_until_ready();
+ eeprom_enable_mapping();
+ memcpy( buf,(void*)(address+MAPPED_EEPROM_START), len );
+ eeprom_disable_mapping();
+}
+
+
+/**
+ * \brief Write one byte to EEPROM using IO mapping.
+ *
+ * This function writes one byte to EEPROM using IO-mapped access.
+ * This function will cancel all ongoing EEPROM page buffer loading
+ * operations, if any.
+ *
+ * \param address EEPROM address (max EEPROM_SIZE)
+ * \param value Byte value to write to EEPROM.
+ */
+void nvm_eeprom_write_byte(eeprom_addr_t address, uint8_t value)
+{
+ uint8_t old_cmd;
+
+ Assert(address <= EEPROM_SIZE);
+ /* Flush buffer to make sure no unintentional data is written and load
+ * the "Page Load" command into the command register.
+ */
+ old_cmd = NVM.CMD;
+ nvm_eeprom_flush_buffer();
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+ nvm_eeprom_load_byte_to_buffer(address, value);
+
+ // Set address to write to
+ NVM.ADDR2 = 0x00;
+ NVM.ADDR1 = (address >> 8) & 0xFF;
+ NVM.ADDR0 = address & 0xFF;
+
+ /* Issue EEPROM Atomic Write (Erase&Write) command. Load command, write
+ * the protection signature and execute command.
+ */
+ NVM.CMD = NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc;
+ nvm_exec();
+ NVM.CMD = old_cmd;
+}
+
+/**
+ * \brief Write buffer within the eeprom
+ *
+ * \param address the address to where to write
+ * \param buf pointer to the data
+ * \param len the number of bytes to write
+ */
+void nvm_eeprom_erase_and_write_buffer(eeprom_addr_t address, const void *buf, uint16_t len)
+{
+ while (len) {
+ if (((address%EEPROM_PAGE_SIZE)==0) && (len>=EEPROM_PAGE_SIZE)) {
+ // A full page can be written
+ nvm_eeprom_load_page_to_buffer((uint8_t*)buf);
+ nvm_eeprom_atomic_write_page(address/EEPROM_PAGE_SIZE);
+ address += EEPROM_PAGE_SIZE;
+ buf = (uint8_t*)buf + EEPROM_PAGE_SIZE;
+ len -= EEPROM_PAGE_SIZE;
+ } else {
+ nvm_eeprom_write_byte(address++, *(uint8_t*)buf);
+ buf = (uint8_t*)buf + 1;
+ len--;
+ }
+ }
+}
+
+
+/**
+ * \brief Flush temporary EEPROM page buffer.
+ *
+ * This function flushes the EEPROM page buffers. This function will cancel
+ * any ongoing EEPROM page buffer loading operations, if any.
+ * This function also works for memory mapped EEPROM access.
+ *
+ * \note An EEPROM write operations will automatically flush the buffer for you.
+ * \note The function does not preserve the value of the NVM.CMD register
+ */
+void nvm_eeprom_flush_buffer(void)
+{
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+
+ // Flush EEPROM page buffer if necessary
+ if ((NVM.STATUS & NVM_EELOAD_bm) != 0) {
+ NVM.CMD = NVM_CMD_ERASE_EEPROM_BUFFER_gc;
+ nvm_exec();
+ }
+}
+
+/**
+ * \brief Load single byte into temporary page buffer.
+ *
+ * This function loads one byte into the temporary EEPROM page buffers.
+ * If memory mapped EEPROM is enabled, this function will not work.
+ * Make sure that the buffer is flushed before starting to load bytes.
+ * Also, if multiple bytes are loaded into the same location, they will
+ * be ANDed together, thus 0x55 and 0xAA will result in 0x00 in the buffer.
+ *
+ * \note Only one page buffer exist, thus only one page can be loaded with
+ * data and programmed into one page. If data needs to be written to
+ * different pages, the loading and writing needs to be repeated.
+ *
+ * \param byte_addr EEPROM Byte address, between 0 and EEPROM_PAGE_SIZE.
+ * \param value Byte value to write to buffer.
+ */
+void nvm_eeprom_load_byte_to_buffer(uint8_t byte_addr, uint8_t value)
+{
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+
+ eeprom_enable_mapping();
+ *(uint8_t*)(byte_addr + MAPPED_EEPROM_START) = value;
+ eeprom_disable_mapping();
+}
+
+
+/**
+ * \brief Load entire page into temporary EEPROM page buffer.
+ *
+ * This function loads an entire EEPROM page from an SRAM buffer to
+ * the EEPROM page buffers. If memory mapped EEPROM is enabled, this
+ * function will not work. Make sure that the buffer is flushed before
+ * starting to load bytes.
+ *
+ * \note Only the lower part of the address is used to address the buffer.
+ * Therefore, no address parameter is needed. In the end, the data
+ * is written to the EEPROM page given by the address parameter to the
+ * EEPROM write page operation.
+ *
+ * \param values Pointer to SRAM buffer containing an entire page.
+ */
+void nvm_eeprom_load_page_to_buffer(const uint8_t *values)
+{
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+
+ // Load multiple bytes into page buffer
+ uint8_t i;
+ for (i = 0; i < EEPROM_PAGE_SIZE; ++i) {
+ nvm_eeprom_load_byte_to_buffer(i, *values);
+ ++values;
+ }
+}
+
+/**
+ * \brief Erase and write bytes from page buffer into EEPROM.
+ *
+ * This function writes the contents of an already loaded EEPROM page
+ * buffer into EEPROM memory.
+ *
+ * As this is an atomic write, the page in EEPROM will be erased
+ * automatically before writing. Note that only the page buffer locations
+ * that have been loaded will be used when writing to EEPROM. Page buffer
+ * locations that have not been loaded will be left untouched in EEPROM.
+ *
+ * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE
+ */
+void nvm_eeprom_atomic_write_page(uint8_t page_addr)
+{
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+
+ // Calculate page address
+ uint16_t address = (uint16_t)(page_addr * EEPROM_PAGE_SIZE);
+
+ Assert(address <= EEPROM_SIZE);
+
+ // Set address
+ NVM.ADDR2 = 0x00;
+ NVM.ADDR1 = (address >> 8) & 0xFF;
+ NVM.ADDR0 = address & 0xFF;
+
+ // Issue EEPROM Atomic Write (Erase&Write) command
+ nvm_issue_command(NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc);
+}
+
+/**
+ * \brief Write (without erasing) EEPROM page.
+ *
+ * This function writes the contents of an already loaded EEPROM page
+ * buffer into EEPROM memory.
+ *
+ * As this is a split write, the page in EEPROM will _not_ be erased
+ * before writing.
+ *
+ * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE
+ */
+void nvm_eeprom_split_write_page(uint8_t page_addr)
+{
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+
+ // Calculate page address
+ uint16_t address = (uint16_t)(page_addr * EEPROM_PAGE_SIZE);
+
+ Assert(address <= EEPROM_SIZE);
+
+ // Set address
+ NVM.ADDR2 = 0x00;
+ NVM.ADDR1 = (address >> 8) & 0xFF;
+ NVM.ADDR0 = address & 0xFF;
+
+ // Issue EEPROM Split Write command
+ nvm_issue_command(NVM_CMD_WRITE_EEPROM_PAGE_gc);
+}
+
+/**
+ * \brief Fill temporary EEPROM page buffer with value.
+ *
+ * This fills the the EEPROM page buffers with a given value.
+ * If memory mapped EEPROM is enabled, this function will not work.
+ *
+ * \note Only the lower part of the address is used to address the buffer.
+ * Therefore, no address parameter is needed. In the end, the data
+ * is written to the EEPROM page given by the address parameter to the
+ * EEPROM write page operation.
+ *
+ * \param value Value to copy to the page buffer.
+ */
+void nvm_eeprom_fill_buffer_with_value(uint8_t value)
+{
+ nvm_eeprom_flush_buffer();
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+ // Load multiple bytes into page buffer
+ uint8_t i;
+ for (i = 0; i < EEPROM_PAGE_SIZE; ++i) {
+ nvm_eeprom_load_byte_to_buffer(i, value);
+ }
+}
+
+/**
+ * \brief Erase bytes from EEPROM page.
+ *
+ * This function erases bytes from one EEPROM page, so that every location
+ * written to in the page buffer reads 0xFF.
+ *
+ * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE
+ */
+void nvm_eeprom_erase_bytes_in_page(uint8_t page_addr)
+{
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+
+ // Calculate page address
+ uint16_t address = (uint16_t)(page_addr * EEPROM_PAGE_SIZE);
+
+ Assert(address <= EEPROM_SIZE);
+
+ // Set address
+ NVM.ADDR2 = 0x00;
+ NVM.ADDR1 = (address >> 8) & 0xFF;
+ NVM.ADDR0 = address & 0xFF;
+
+ // Issue EEPROM Erase command
+ nvm_issue_command(NVM_CMD_ERASE_EEPROM_PAGE_gc);
+}
+
+/**
+ * \brief Erase EEPROM page.
+ *
+ * This function erases one EEPROM page, so that every location reads 0xFF.
+ *
+ * \param page_addr EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE
+ */
+void nvm_eeprom_erase_page(uint8_t page_addr)
+{
+ // Mark all addresses to be deleted
+ nvm_eeprom_fill_buffer_with_value(0xff);
+ // Erase bytes
+ nvm_eeprom_erase_bytes_in_page(page_addr);
+}
+
+
+/**
+ * \brief Erase bytes from all EEPROM pages.
+ *
+ * This function erases bytes from all EEPROM pages, so that every location
+ * written to in the page buffer reads 0xFF.
+ */
+void nvm_eeprom_erase_bytes_in_all_pages(void)
+{
+ // Wait until NVM is ready
+ nvm_wait_until_ready();
+
+ // Issue EEPROM Erase All command
+ nvm_issue_command(NVM_CMD_ERASE_EEPROM_gc);
+}
+
+/**
+ * \brief Erase entire EEPROM memory.
+ *
+ * This function erases the entire EEPROM memory block to 0xFF.
+ */
+void nvm_eeprom_erase_all(void)
+{
+ // Mark all addresses to be deleted
+ nvm_eeprom_fill_buffer_with_value(0xff);
+ // Erase all pages
+ nvm_eeprom_erase_bytes_in_all_pages();
+}
+
+//! @}
+
+
+//! @}
+
+
+/**
+ * \weakgroup nvm_flash_group
+ * @{
+ */
+
+/**
+ * \brief Issue flash range CRC command
+ *
+ * This function sets the FLASH range CRC command in the NVM.CMD register.
+ * It then loads the start and end byte address of the part of FLASH to
+ * generate a CRC-32 for into the ADDR and DATA registers and finally performs
+ * the execute command.
+ *
+ * \note Should only be called from the CRC module. The function saves and
+ * restores the NVM.CMD register, but if this
+ * function is called from an interrupt, interrupts must be disabled
+ * before this function is called.
+ *
+ * \param start_addr end byte address
+ * \param end_addr start byte address
+ */
+void nvm_issue_flash_range_crc(flash_addr_t start_addr, flash_addr_t end_addr)
+{
+ uint8_t old_cmd;
+ // Save current nvm command
+ old_cmd = NVM.CMD;
+
+ // Load the NVM CMD register with the Flash Range CRC command
+ NVM.CMD = NVM_CMD_FLASH_RANGE_CRC_gc;
+
+ // Load the start byte address in the NVM Address Register
+ NVM.ADDR0 = start_addr & 0xFF;
+ NVM.ADDR1 = (start_addr >> 8) & 0xFF;
+#if (FLASH_SIZE >= 0x10000UL)
+ NVM.ADDR2 = (start_addr >> 16) & 0xFF;
+#endif
+
+ // Load the end byte address in NVM Data Register
+ NVM.DATA0 = end_addr & 0xFF;
+ NVM.DATA1 = (end_addr >> 8) & 0xFF;
+#if (FLASH_SIZE >= 0x10000UL)
+ NVM.DATA2 = (end_addr >> 16) & 0xFF;
+#endif
+
+ // Execute command
+ ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm);
+
+ // Restore command register
+ NVM.CMD = old_cmd;
+}
+
+/**
+ * \brief Read buffer within the application section
+ *
+ * \param address the address to where to read
+ * \param buf pointer to the data
+ * \param len the number of bytes to read
+ */
+void nvm_flash_read_buffer(flash_addr_t address, void *buf, uint16_t len)
+{
+#if (FLASH_SIZE>0x10000)
+ uint32_t opt_address = address;
+#else
+ uint16_t opt_address = (uint16_t)address;
+#endif
+ nvm_wait_until_ready();
+ while ( len ) {
+ *(uint8_t*)buf = nvm_flash_read_byte(opt_address);
+ buf=(uint8_t*)buf+1;
+ opt_address++;
+ len--;
+ }
+}
+
+/**
+ * \brief Read buffer within the user section
+ *
+ * \param address the address to where to read
+ * \param buf pointer to the data
+ * \param len the number of bytes to read
+ */
+void nvm_user_sig_read_buffer(flash_addr_t address, void *buf, uint16_t len)
+{
+ uint16_t opt_address = (uint16_t)address&(FLASH_PAGE_SIZE-1);
+ while ( len ) {
+ *(uint8_t*)buf = nvm_read_user_signature_row(opt_address);
+ buf=(uint8_t*)buf+1;
+ opt_address++;
+ len--;
+ }
+}
+
+/**
+ * \brief Write specific parts of user flash section
+ *
+ * \param address the address to where to write
+ * \param buf pointer to the data
+ * \param len the number of bytes to write
+ * \param b_blank_check if True then the page flash is checked before write
+ * to run or not the erase page command.
+ *
+ * Set b_blank_check to false if all application flash is erased before.
+ */
+void nvm_user_sig_write_buffer(flash_addr_t address, const void *buf,
+ uint16_t len, bool b_blank_check)
+{
+ uint16_t w_value;
+ uint16_t page_pos;
+ uint16_t opt_address = (uint16_t)address;
+ bool b_flag_erase = false;
+
+ while ( len ) {
+ for (page_pos=0; page_pos0x10000)
+ uint32_t page_address;
+ uint32_t opt_address = address;
+#else
+ uint16_t page_address;
+ uint16_t opt_address = (uint16_t)address;
+#endif
+
+ // Compute the start of the page to be modified
+ page_address = opt_address-(opt_address%FLASH_PAGE_SIZE);
+
+ // For each page
+ while ( len ) {
+ b_flag_erase = false;
+
+ nvm_wait_until_ready();
+ for (page_pos=0; page_posAtmel Support
+ */
+#ifndef NVM_H
+#define NVM_H
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup nvm_group NVM driver
+ *
+ * See \ref xmega_nvm_quickstart
+ *
+ * \brief Low-level driver implementation for the AVR XMEGA Non Volatile
+ * Memory Controller (NVM).
+ *
+ * The XMEGA NVM controller interfaces the internal non-volatile memories
+ * in the XMEGA devices. Program memory, EEPROM and signature row is can be
+ * interfaced by the module. See the documentation of each sub-module for
+ * more information.
+ *
+ * \note If using GCC and the flash sub-module, remember to configure
+ * the boot section in the make file. More information in the sub-module
+ * documentation.
+ *
+ * \section xmega_nvm_quickstart_section Quick Start Guide
+ * See \ref xmega_nvm_quickstart
+ */
+
+/**
+ * \defgroup nvm_generic_group NVM driver generic module handling
+ * \ingroup nvm_group
+ * \brief Support functions for the NVM driver.
+ *
+ * These functions are helper functions for the functions of the
+ * \ref nvm_group "NVM driver".
+ *
+ * @{
+ */
+
+/**
+ * \brief Wait for any NVM access to finish.
+ *
+ * This function is blocking and waits for any NVM access to finish.
+ * Use this function before any NVM accesses, if you are not certain that
+ * any previous operations are finished yet.
+ */
+static inline void nvm_wait_until_ready( void )
+{
+ do {
+ // Block execution while waiting for the NVM to be ready
+ } while ((NVM.STATUS & NVM_NVMBUSY_bm) == NVM_NVMBUSY_bm);
+}
+
+/**
+ * \brief Non-Volatile Memory Execute Command
+ *
+ * This function sets the CCP register before setting the CMDEX bit in the
+ * NVM.CTRLA register.
+ *
+ * \note The correct NVM command must be set in the NVM.CMD register before
+ * calling this function.
+ */
+static inline void nvm_exec(void)
+{
+ ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm);
+}
+
+/**
+ * \brief Non-Volatile Memory Execute Specific Command
+ *
+ * This function sets a command in the NVM.CMD register, then performs an
+ * execute command by writing the CMDEX bit to the NVM.CTRLA register.
+ *
+ * \note The function saves and restores the NVM.CMD register, but if this
+ * function is called from an interrupt, interrupts must be disabled
+ * before this function is called.
+ *
+ * \param nvm_command NVM Command to execute.
+ */
+static inline void nvm_issue_command(NVM_CMD_t nvm_command)
+{
+ uint8_t old_cmd;
+
+ old_cmd = NVM.CMD;
+ NVM.CMD = nvm_command;
+ ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm);
+ NVM.CMD = old_cmd;
+}
+
+/**
+ * \brief Read one byte using the LDI instruction
+ * \internal
+ *
+ * This function sets the specified NVM_CMD, reads one byte using at the
+ * specified byte address with the LPM instruction. NVM_CMD is restored after
+ * use.
+ *
+ * \note Interrupts should be disabled before running this function
+ * if program memory/NVM controller is accessed from ISRs.
+ *
+ * \param nvm_cmd NVM command to load before running LPM
+ * \param address Byte offset into the signature row
+ */
+uint8_t nvm_read_byte(uint8_t nvm_cmd, uint16_t address);
+
+
+/**
+ * \brief Perform SPM write
+ * \internal
+ *
+ * This function sets the specified NVM_CMD, sets CCP and then runs the SPM
+ * instruction to write to flash.
+ *
+ * \note Interrupts should be disabled before running this function
+ * if program memory/NVM controller is accessed from ISRs.
+ *
+ * \param addr Address to perform the SPM on.
+ * \param nvm_cmd NVM command to use in the NVM_CMD register
+ */
+void nvm_common_spm(uint32_t addr, uint8_t nvm_cmd);
+
+//! @}
+
+/**
+ * \defgroup nvm_signature_group NVM driver signature handling
+ * \ingroup nvm_group
+ * \brief Handling of signature rows
+ *
+ * Functions for handling signature rows. The following is supported:
+ * - Reading values from production and user signature row
+ * - Reading device id
+ * - Reading device revision
+ * - Reading device serial
+ *
+ * \note Some of these functions are modifying the NVM.CMD register.
+ * If the application are using program space access in interrupts
+ * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts
+ * needs to be disabled when running EEPROM access functions. If not,
+ * the program space reads will be corrupted. See documentation for
+ * each individual function.
+ * \note Do not use the functions of this module in an interrupt service
+ * routine (ISR), since the functions can take several milliseconds to
+ * complete and hence block the interrupt for several milliseconds.
+ * In addition the functions of this module are modifying the page buffer
+ * which will corrupt any ongoing EEPROM handing used outside an ISR.
+ * @{
+ */
+
+/**
+ * \brief Structure containing the device ID
+ *
+ * This structure can be used to store the device ID of a device.
+ */
+struct nvm_device_id {
+ union {
+ struct {
+ uint8_t devid0;
+ uint8_t devid1;
+ uint8_t devid2;
+ };
+ uint8_t byte[3];
+ };
+};
+
+/**
+ * \brief Structure containing the device serial
+ *
+ * This structure can be used to store the serial number of a device.
+ */
+struct nvm_device_serial {
+ union {
+ struct {
+ uint8_t lotnum0;
+ uint8_t lotnum1;
+ uint8_t lotnum2;
+ uint8_t lotnum3;
+ uint8_t lotnum4;
+ uint8_t lotnum5;
+ uint8_t wafnum;
+ uint8_t coordx0;
+ uint8_t coordx1;
+ uint8_t coordy0;
+ uint8_t coordy1;
+ };
+ uint8_t byte[11];
+ };
+};
+
+/**
+ * \brief Get offset of calibration bytes in the production signature row
+ *
+ * \param regname Name of register within the production signature row
+ * \retval Offset of register into the production signature row
+ */
+#if defined(__GNUC__)
+# define nvm_get_production_signature_row_offset(regname) \
+ offsetof(NVM_PROD_SIGNATURES_t, regname)
+#elif defined(__ICCAVR__)
+# define nvm_get_production_signature_row_offset(regname) (regname##_offset)
+#else
+# error Unknown compiler
+#endif
+
+
+/**
+ * \brief Read one byte from the production signature row
+ *
+ * This function reads one byte from the production signature row of the device
+ * at the given address.
+ *
+ * \note This function is modifying the NVM.CMD register.
+ * If the application are using program space access in interrupts
+ * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts
+ * needs to be disabled when running EEPROM access functions. If not
+ * the program space reads will be corrupted.
+ *
+ * \param address Byte offset into the signature row
+ */
+static inline uint8_t nvm_read_production_signature_row(uint8_t address)
+{
+ return nvm_read_byte(NVM_CMD_READ_CALIB_ROW_gc, address);
+}
+
+/**
+ * \brief Read one byte from the user signature row
+ *
+ * This function reads one byte from the user signature row of the device
+ * at the given address.
+ *
+ * \note This function is modifying the NVM.CMD register.
+ * If the application are using program space access in interrupts
+ * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts
+ * needs to be disabled when running EEPROM access functions. If not
+ * the program space reads will be corrupted.
+ *
+ * \param address Byte offset into the signature row
+ */
+static inline uint8_t nvm_read_user_signature_row(uint16_t address)
+{
+ return nvm_read_byte(NVM_CMD_READ_USER_SIG_ROW_gc, address);
+}
+
+/**
+ * \brief Read the device id
+ *
+ * This function returns the device ID stored in the device.
+ *
+ * \retval storage Pointer to the structure where to store the device id
+ */
+static inline void nvm_read_device_id(struct nvm_device_id *storage)
+{
+ storage->devid0 = MCU.DEVID0;
+ storage->devid1 = MCU.DEVID1;
+ storage->devid2 = MCU.DEVID2;
+}
+
+/**
+ * \brief Read the device revision
+ *
+ * This function returns the device revision stored in the device.
+ *
+ * \retval unsigned 8 bit value with the current device revision.
+ */
+static inline uint8_t nvm_read_device_rev(void)
+{
+ return MCU.REVID;
+}
+
+void nvm_read_device_serial(struct nvm_device_serial *storage);
+
+//! @}
+
+
+/**
+ * \defgroup nvm_eeprom_group NVM driver EEPROM handling
+ * \ingroup nvm_group
+ * \brief Functions for handling internal EEPROM memory.
+ *
+ * The internal EEPROM can be used to store data that will persist after
+ * power is removed. This can typically be used to store calibration data,
+ * application state, encryption keys or other data that need to be preserved
+ * when power is removed.
+ *
+ * The functions in this module uses IO register access to manipulate the
+ * EEPROM.
+ *
+ * \note The functions in this module are modifying the NVM.CMD register.
+ * If the application are using program space access in interrupts
+ * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts
+ * needs to be disabled when running EEPROM access functions. If not
+ * the program space reads will be corrupted.
+ * @{
+ */
+
+#ifndef EEPROM_PAGE_SIZE
+# if XMEGA_A || XMEGA_AU || XMEGA_B || XMEGA_C || XMEGA_D || XMEGA_E
+# define EEPROM_PAGE_SIZE 32
+# else
+# error Unknown EEPROM page size
+# endif
+#endif
+
+#ifndef CONFIG_NVM_IGNORE_XMEGA_A3_D3_REVB_ERRATA
+# if XMEGA_A3 || XMEGA_D3
+# error This NVM driver does not support rev B of XMEGA A3/D3 devices. \
+ Set CONFIG_NVM_IGNORE_XMEGA_A3_D3_REVB_ERRATA to disable this message
+# endif
+#endif
+
+/**
+ * Data type for holding eeprom memory addresses.
+ */
+typedef uint16_t eeprom_addr_t;
+
+
+/*! \brief Enable EEPROM mapping into data space.
+ *
+ * This macro enables mapping of EEPROM into data space.
+ * EEPROM starts at EEPROM_START in data memory. Read access
+ * can be done similar to ordinary SRAM access.
+ *
+ * \note This disables IO-mapped access to EEPROM, although page erase and
+ * write operations still needs to be done through IO register.
+ */
+static inline void eeprom_enable_mapping(void)
+{
+#if !XMEGA_E
+ NVM_CTRLB = NVM_CTRLB | NVM_EEMAPEN_bm;
+#endif
+}
+
+
+/*! \brief Disable EEPROM mapping into data space.
+ *
+ * This macro disables mapping of EEPROM into data space.
+ * IO mapped access is now enabled.
+ */
+static inline void eeprom_disable_mapping(void)
+{
+#if !XMEGA_E
+ NVM_CTRLB = NVM_CTRLB & ~NVM_EEMAPEN_bm;
+#endif
+}
+
+
+uint8_t nvm_eeprom_read_byte(eeprom_addr_t addr);
+void nvm_eeprom_write_byte(eeprom_addr_t address, uint8_t value);
+void nvm_eeprom_read_buffer(eeprom_addr_t address, void *buf, uint16_t len);
+void nvm_eeprom_erase_and_write_buffer(eeprom_addr_t address, const void *buf, uint16_t len);
+
+void nvm_eeprom_flush_buffer(void);
+void nvm_eeprom_load_byte_to_buffer(uint8_t byte_addr, uint8_t value);
+void nvm_eeprom_load_page_to_buffer(const uint8_t *values);
+void nvm_eeprom_atomic_write_page(uint8_t page_addr);
+void nvm_eeprom_split_write_page(uint8_t page_addr);
+void nvm_eeprom_fill_buffer_with_value(uint8_t value);
+void nvm_eeprom_erase_bytes_in_page(uint8_t page_addr);
+void nvm_eeprom_erase_page(uint8_t page_addr);
+void nvm_eeprom_erase_bytes_in_all_pages(void);
+void nvm_eeprom_erase_all(void);
+
+//! @}
+
+/**
+ * \defgroup nvm_flash_group NVM driver flash handling
+ * \ingroup nvm_group
+ * \brief Functions for handling internal flash memory.
+ *
+ * The internal flash memory on the XMEGA devices consists of the application
+ * section, the application table section and the bootloader section.
+ * All these sections can store program code for the MCU, but if there is
+ * available space, they can be used for storing other persistent data.
+ *
+ * Writing the flash memory can only be done one page at a time. It consists
+ * of loading the data to the internal page buffer and then running one of
+ * the write commands. If the page has not been erased before writing, the
+ * data will not be written correctly.
+ *
+ * In order to be able to write to flash memory the programming commands need
+ * to be run from the boot section.
+ * - When using IAR this is handled automatically by the linker script.
+ * - When using GCC this needs to be specified manually in the make files. For
+ * example the ATxmega128A1 has the boot section at the word address 0x10000
+ * the corresponding byte address of 0x20000 needs to be added to the
+ * config.mk makefile:
+ * LDFLAGS += -Wl,--section-start=.BOOT=0x20000
+ * See the device datasheet for the correct address for other devices.
+ *
+ * \note If using GCC and the flash sub-module, remember to configure
+ * the boot section in the make file.
+ *
+ * \note The functions in this module are modifying the NVM.CMD register.
+ * If the application are using program space access in interrupts
+ * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts
+ * needs to be disabled when running EEPROM access functions. If not
+ * the program space reads will be corrupted.
+ * @{
+ */
+
+/**
+ * \brief Size of a flash page in bytes
+ *
+ * The page size in bytes taken from the toolchain header files.
+ *
+ * \note Page size is currently missing from the IAR header files, so it needs
+ * to be defined in the driver until it is fixed.
+ */
+#ifdef __DOXYGEN__
+# define FLASH_SIZE
+# define FLASH_PAGE_SIZE
+#else
+
+// 8K devices
+# if AVR8_PART_IS_DEFINED(ATxmega8E5)
+# define FLASH_SIZE (8*1024L)
+# define FLASH_PAGE_SIZE (128)
+
+// 16K devices
+# elif AVR8_PART_IS_DEFINED(ATxmega16A4) | \
+ AVR8_PART_IS_DEFINED(ATxmega16A4U) | \
+ AVR8_PART_IS_DEFINED(ATxmega16D4) | \
+ AVR8_PART_IS_DEFINED(ATxmega16C4)
+# define FLASH_SIZE (16*1024L)
+# define FLASH_PAGE_SIZE (256)
+
+# elif AVR8_PART_IS_DEFINED(ATxmega16E5)
+# define FLASH_SIZE (16*1024L)
+# define FLASH_PAGE_SIZE (128)
+
+// 32K devices
+# elif AVR8_PART_IS_DEFINED(ATxmega32A4) | \
+ AVR8_PART_IS_DEFINED(ATxmega32A4U) | \
+ AVR8_PART_IS_DEFINED(ATxmega32D4) | \
+ AVR8_PART_IS_DEFINED(ATxmega32C4)
+# define FLASH_SIZE (32*1024L)
+# define FLASH_PAGE_SIZE (256)
+
+# elif AVR8_PART_IS_DEFINED(ATxmega32E5)
+# define FLASH_SIZE (32*1024L)
+# define FLASH_PAGE_SIZE (128)
+
+// 64K devices
+# elif AVR8_PART_IS_DEFINED(ATxmega64A1) | \
+ AVR8_PART_IS_DEFINED(ATxmega64A1U) | \
+ AVR8_PART_IS_DEFINED(ATxmega64A3) | \
+ AVR8_PART_IS_DEFINED(ATxmega64A3U) | \
+ AVR8_PART_IS_DEFINED(ATxmega64A4U) | \
+ AVR8_PART_IS_DEFINED(ATxmega64B1) | \
+ AVR8_PART_IS_DEFINED(ATxmega64B3) | \
+ AVR8_PART_IS_DEFINED(ATxmega64C3) | \
+ AVR8_PART_IS_DEFINED(ATxmega64D3) | \
+ AVR8_PART_IS_DEFINED(ATxmega64D4)
+# define FLASH_SIZE (64*1024L)
+# define FLASH_PAGE_SIZE (256)
+
+// 128K devices
+# elif AVR8_PART_IS_DEFINED(ATxmega128A1) | \
+ AVR8_PART_IS_DEFINED(ATxmega128A1U) | \
+ AVR8_PART_IS_DEFINED(ATxmega128A3) | \
+ AVR8_PART_IS_DEFINED(ATxmega128A3U) | \
+ AVR8_PART_IS_DEFINED(ATxmega128C3) | \
+ AVR8_PART_IS_DEFINED(ATxmega128D3) | \
+ AVR8_PART_IS_DEFINED(ATxmega128D4)
+# define FLASH_SIZE (128*1024L)
+# define FLASH_PAGE_SIZE (512)
+
+# elif AVR8_PART_IS_DEFINED(ATxmega128A4U) | \
+ AVR8_PART_IS_DEFINED(ATxmega128B1) | \
+ AVR8_PART_IS_DEFINED(ATxmega128B3)
+# define FLASH_SIZE (128*1024L)
+# define FLASH_PAGE_SIZE (256)
+
+// 192K devices
+# elif AVR8_PART_IS_DEFINED(ATxmega192A3U) | \
+ AVR8_PART_IS_DEFINED(ATxmega192C3) | \
+ AVR8_PART_IS_DEFINED(ATxmega192D3)
+# define FLASH_SIZE (192*1024L)
+# define FLASH_PAGE_SIZE (512)
+
+// 256K devices
+# elif AVR8_PART_IS_DEFINED(ATxmega256A3) | \
+ AVR8_PART_IS_DEFINED(ATxmega256A3U) | \
+ AVR8_PART_IS_DEFINED(ATxmega256A3B) | \
+ AVR8_PART_IS_DEFINED(ATxmega256A3BU) | \
+ AVR8_PART_IS_DEFINED(ATxmega256C3) | \
+ AVR8_PART_IS_DEFINED(ATxmega256D3)
+# define FLASH_SIZE (256*1024L)
+# define FLASH_PAGE_SIZE (512)
+
+// 384K devices
+# elif AVR8_PART_IS_DEFINED(ATxmega384C3)
+# define FLASH_SIZE (384*1024L)
+# define FLASH_PAGE_SIZE (512)
+# elif AVR8_PART_IS_DEFINED(ATxmega384D3)
+# define FLASH_SIZE (384*1024L)
+# define FLASH_PAGE_SIZE (512)
+# else
+# error Flash page size needs to be defined.
+# endif
+#endif
+
+/**
+ * Data type for holding flash memory addresses.
+ *
+ */
+#if (FLASH_SIZE >= 0x10000UL) // Note: Xmega with 64KB of flash have 4KB boot flash
+typedef uint32_t flash_addr_t;
+#else
+typedef uint16_t flash_addr_t;
+#endif
+
+/**
+ * Flash pointer type to use for accessing flash memory with IAR
+ */
+#if (FLASH_SIZE >= 0x10000UL) // Note: Xmega with 64KB of flash have 4KB boot flash
+# define IAR_FLASH_PTR __farflash
+#else
+# define IAR_FLASH_PTR __flash
+#endif
+
+/**
+ * \brief Load byte from flash memory
+ *
+ * Load one word of flash using byte addressing. IAR has __flash pointers
+ * and GCC have pgm_read_byte_xx functions which load data from flash memory.
+ * This function used for compatibility between the compilers.
+ *
+ * \param addr Byte address to load
+ * \return Byte from program memory
+ */
+static inline uint8_t nvm_flash_read_byte(flash_addr_t addr)
+{
+#if defined(__GNUC__)
+ return pgm_read_byte_far(addr);
+#elif defined(__ICCAVR__)
+ uint8_t IAR_FLASH_PTR *flashptr = (uint8_t IAR_FLASH_PTR *)addr;
+ return *flashptr;
+#else
+# error Unknown compiler
+#endif
+}
+
+/**
+ * \brief Load word from flash memory
+ *
+ * Load one word of flash using byte addressing. IAR has __flash pointers
+ * and GCC have pgm_read_byte_xx functions which load data from flash memory.
+ * This function used for compatibility between the compilers.
+ *
+ * \param addr Byte address to load (last bit is ignored)
+ * \return Word from program memory
+ */
+static inline uint16_t nvm_flash_read_word(flash_addr_t addr)
+{
+#if defined(__GNUC__)
+ return pgm_read_word_far(addr);
+#elif defined(__ICCAVR__)
+ uint16_t IAR_FLASH_PTR *flashptr = (uint16_t IAR_FLASH_PTR *)addr;
+ return *flashptr;
+#endif
+}
+
+
+/**
+ * \brief Flush flash page buffer
+ *
+ * Clear the NVM controller page buffer for flash. This needs to be called
+ * before using \ref nvm_flash_load_word_to_buffer if it has not already been
+ * cleared.
+ *
+ */
+static inline void nvm_flash_flush_buffer(void)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(0, NVM_CMD_ERASE_FLASH_BUFFER_gc);
+}
+
+
+/**
+ * \brief Load word into flash page buffer
+ *
+ * Clear the NVM controller page buffer for flash. This needs to be called
+ * before using \ref nvm_flash_load_word_to_buffer if it has not already been
+ * cleared.
+ *
+ * \param word_addr Address to store data. The upper bits beyond the page size
+ * is ignored. \ref FLASH_PAGE_SIZE
+ * \param data Data word to load into the page buffer
+ */
+void nvm_flash_load_word_to_buffer(uint32_t word_addr, uint16_t data);
+
+
+/**
+ * \brief Erase entire application section
+ *
+ * Erase all of the application section.
+ */
+static inline void nvm_flash_erase_app(void)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(0, NVM_CMD_ERASE_APP_gc);
+}
+
+/**
+ * \brief Erase a page within the application section
+ *
+ * Erase one page within the application section
+ *
+ * \param page_addr Byte address to the page to delete
+ */
+static inline void nvm_flash_erase_app_page(flash_addr_t page_addr)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(page_addr, NVM_CMD_ERASE_APP_PAGE_gc);
+}
+
+/**
+ * \brief Write a page within the application section
+ *
+ * Write a page within the application section with the data stored in the
+ * page buffer. The page needs to be erased before the write to avoid
+ * corruption of the data written.
+ *
+ * \param page_addr Byte address to the page to delete
+ */
+static inline void nvm_flash_split_write_app_page(flash_addr_t page_addr)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(page_addr, NVM_CMD_WRITE_APP_PAGE_gc);
+}
+
+/**
+ * \brief Erase and write a page within the application section
+ *
+ * Erase and the write a page within the application section with the data
+ * stored in the page buffer. Erase and write is done in an atomic operation.
+ *
+ * \param page_addr Byte address to the page to delete
+ */
+static inline void nvm_flash_atomic_write_app_page(flash_addr_t page_addr)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(page_addr, NVM_CMD_ERASE_WRITE_APP_PAGE_gc);
+}
+
+void nvm_issue_flash_range_crc(flash_addr_t start_addr, flash_addr_t end_addr);
+
+void nvm_flash_read_buffer(flash_addr_t address, void *buf, uint16_t len);
+
+void nvm_flash_erase_and_write_buffer(flash_addr_t address, const void *buf,
+ uint16_t len, bool b_blank_check);
+
+/**
+ * \brief Erase a page within the boot section
+ *
+ * Erase one page within the boot section
+ *
+ * \param page_addr Byte address to the page to delete
+ */
+static inline void nvm_flash_erase_boot_page(flash_addr_t page_addr)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(page_addr, NVM_CMD_ERASE_BOOT_PAGE_gc);
+}
+
+/**
+ * \brief Write a page within the boot section
+ *
+ * Write a page within the boot section with the data stored in the
+ * page buffer. The page needs to be erased before the write to avoid
+ * corruption of the data written.
+ *
+ * \param page_addr Byte address to the page to delete
+ */
+static inline void nvm_flash_split_write_boot_page(flash_addr_t page_addr)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(page_addr, NVM_CMD_WRITE_BOOT_PAGE_gc);
+}
+
+/**
+ * \brief Erase and write a page within the boot section
+ *
+ * Erase and the write a page within the boot section with the data
+ * stored in the page buffer. Erase and write is done in an atomic operation.
+ *
+ * \param page_addr Byte address to the page to delete
+ */
+static inline void nvm_flash_atomic_write_boot_page(flash_addr_t page_addr)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(page_addr, NVM_CMD_ERASE_WRITE_BOOT_PAGE_gc);
+}
+
+void nvm_user_sig_read_buffer(flash_addr_t address, void *buf, uint16_t len);
+void nvm_user_sig_write_buffer(flash_addr_t address, const void *buf,
+ uint16_t len, bool b_blank_check);
+
+/**
+ * \brief Erase the user calibration section page
+ *
+ * Erase the user calibration section page. There is only one page, so no
+ * parameters are needed.
+ */
+static inline void nvm_flash_erase_user_section(void)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(0, NVM_CMD_ERASE_USER_SIG_ROW_gc);
+}
+
+/**
+ * \brief Write the user calibration section page
+ *
+ * Write a the user calibration section page with the data stored in the
+ * page buffer. The page needs to be erased before the write to avoid
+ * corruption of the data written. There is only one page, so no
+ * parameters are needed.
+ */
+static inline void nvm_flash_write_user_page(void)
+{
+ nvm_wait_until_ready();
+ nvm_common_spm(0, NVM_CMD_WRITE_USER_SIG_ROW_gc);
+}
+
+//! @}
+
+/**
+ * \defgroup nvm_fuse_lock_group NVM driver fuse and lock bits handling
+ * \ingroup nvm_group
+ * \brief Functions for reading fuses and writing lock bits.
+ *
+ * The Fuses are used to set important system functions and can only be written
+ * from an external programming interface. The application software can read
+ * the fuses. The fuses are used to configure reset sources such as Brown-out
+ * Detector and Watchdog, Start-up configuration, JTAG enable and JTAG user ID.
+ *
+ * The Lock bits are used to set protection level on the different flash
+ * sections. They are used to block read and/or write on the different flash
+ * sections. Lock bits can be written from en external programmer and from the
+ * application software to set a more strict protection level, but not to set a
+ * less strict protection level. Chip erase is the only way to erase the lock
+ * bits. The lock bits are erased after the rest of the flash memory is erased.
+ * An unprogrammed fuse or lock bit will have the value one, while a programmed
+ * fuse or lock bit will have the value zero.
+ * Both fuses and lock bits are reprogrammable like the Flash Program memory.
+ *
+ * \note The functions in this module are modifying the NVM.CMD register.
+ * If the application are using program space access in interrupts
+ * (__flash pointers in IAR EW or pgm_read_byte in GCC) interrupts
+ * needs to be disabled when running EEPROM access functions. If not
+ * the program space reads will be corrupted.
+ * @{
+ */
+
+// The different fuse bytes
+enum fuse_byte_t {
+ FUSEBYTE0 = 0,
+ FUSEBYTE1 = 1,
+ FUSEBYTE2 = 2,
+ FUSEBYTE3 = 3, // not used on current devices
+ FUSEBYTE4 = 4,
+ FUSEBYTE5 = 5,
+};
+
+uint8_t nvm_fuses_read(enum fuse_byte_t fuse);
+
+/**
+ * \brief Program the lock bits.
+ *
+ * Program the lock bits to the given values. Lock bits can only be programmed
+ * to a more secure setting than previously programmed. To clear lock bits, a
+ * flash erase has to be issued.
+ *
+ * \param blbb_lock Boot loader section lock bits to program
+ * \param blba_lock Application section lock bits to program
+ * \param blbat_lock Application table section lock bits to program
+ * \param lb_lock Flash/eeprom lock bits to program
+ */
+static inline void nvm_lock_bits_write(enum NVM_BLBB_enum blbb_lock,
+ enum NVM_BLBA_enum blba_lock, enum NVM_BLBAT_enum blbat_lock,
+ enum NVM_LB_enum lb_lock)
+{
+ nvm_wait_until_ready();
+ NVM.DATA0 = (uint8_t)blbb_lock | (uint8_t)blba_lock | (uint8_t)blbat_lock |
+ (uint8_t)lb_lock;
+ nvm_issue_command(NVM_CMD_WRITE_LOCK_BITS_gc);
+}
+
+/**
+ * \brief Program the BLBB lock bits.
+ *
+ * Program the lock bits for the boot loader section (BLBB). Other lock bits
+ * (BLBA, BLBAT and LB) are not altered (ie. programmed to NOLOCK).
+ *
+ * \param blbb_lock Boot loader section lock bits to program
+ */
+static inline void nvm_blbb_lock_bits_write(enum NVM_BLBB_enum blbb_lock)
+{
+ nvm_lock_bits_write(blbb_lock, NVM_BLBA_NOLOCK_gc, NVM_BLBAT_NOLOCK_gc,
+ NVM_LB_NOLOCK_gc);
+}
+
+/**
+ * \brief Program the BLBA lock bits.
+ *
+ * Program the lock bits for the application section (BLBA). Other lock bits
+ * (BLBB, BLBAT and LB) are not altered (ie. programmed to NOLOCK).
+ *
+ * \param blba_lock Application section lock bits to program
+ */
+static inline void nvm_blba_lock_bits_write(enum NVM_BLBA_enum blba_lock)
+{
+ nvm_lock_bits_write(NVM_BLBB_NOLOCK_gc, blba_lock, NVM_BLBAT_NOLOCK_gc,
+ NVM_LB_NOLOCK_gc);
+}
+
+/**
+ * \brief Program the BLBAT lock bits.
+ *
+ * Program the lock bits for the application table section (BLBAT). Other lock
+ * bits (BLBB, BLBA and LB) are not altered (ie. programmed to NOLOCK).
+ *
+ * \param blbat_lock Application table section lock bits to program
+ */
+static inline void nvm_blbat_lock_bits_write(enum NVM_BLBAT_enum blbat_lock)
+{
+ nvm_lock_bits_write(NVM_BLBB_NOLOCK_gc, NVM_BLBA_NOLOCK_gc, blbat_lock,
+ NVM_LB_NOLOCK_gc);
+}
+
+/**
+ * \brief Program the LB lock bits.
+ *
+ * Program the lock bits for the flash and eeprom (LB). Other lock bits
+ * (BLBB, BLBA and BLBAT) are not altered (ie. programmed to NOLOCK).
+ *
+ * \param lb_lock Flash/eeprom lock bits to program
+ */
+static inline void nvm_lb_lock_bits_write(enum NVM_LB_enum lb_lock)
+{
+ nvm_lock_bits_write(NVM_BLBB_NOLOCK_gc, NVM_BLBA_NOLOCK_gc,
+ NVM_BLBAT_NOLOCK_gc, lb_lock);
+}
+
+//! @}
+
+/**
+ * \page xmega_nvm_quickstart Quick Start Guide for the XMEGA NVM Driver
+ *
+ * This is the quick start guide for the \ref nvm_group "NVM Driver", with
+ * step-by-step instructions on how to configure and use the driver for
+ * specific use cases.
+ *
+ * The section described below can be compiled into e.g. the main application
+ * loop or any other function that will need to interface non-volatile memory.
+ *
+ * \section xmega_nvm_quickstart_basic Basic usage of the NVM driver
+ * This section will present three use cases of the NVM driver. The first will
+ * write a page to EEPROM and verify that it has been written, the second will
+ * access the BOD-level fuse to verify that the level is correctly set, and the
+ * third will read a chunk from the user signature row.
+ *
+ * \section xmega_nvm_quickstart_eeprom_case Use case 1: EEPROM
+ *
+ * The NVM driver has functions for interfacing many types of non-volatile
+ * memory, including flash, EEPROM, fuses and lock bits. The example code
+ * below will write a page to the internal EEPROM, and read it back to verify,
+ * using memory mapped I/O.
+ *
+ * \section xmega_nvm_quickstart_eeprom_case_setup_steps Setup steps
+ * There are no setup steps required for this use case.
+ *
+ * \subsection nvm_quickstart_eeprom_case_example_code Example code
+ *
+ * \code
+ #define EXAMPLE_PAGE 2
+ #define EXAMPLE_ADDR EXAMPLE_PAGE * EEPROM_PAGE_SIZE
+
+ uint8_t write_page[EEPROM_PAGE_SIZE];
+ uint8_t read_page[EEPROM_PAGE_SIZE];
+
+ fill_page_with_known_data(write_page);
+ fill_page_with_zeroes(read_page);
+
+ nvm_eeprom_load_page_to_buffer(write_page);
+ nvm_eeprom_atomic_write_page(EXAMPLE_PAGE);
+
+ nvm_eeprom_read_buffer(EXAMPLE_ADDR,
+ read_page, EEPROM_PAGE_SIZE);
+
+ check_if_pages_are_equal(write_page, read_page);
+\endcode
+ *
+ * \subsection nvm_quickstart_eeprom_case_workflow Workflow
+ *
+ * -# We define where we would like to store our data, and we arbitrarily
+ * choose page 2 of EEPROM:
+ * - \code
+ #define EXAMPLE_PAGE 2
+ #define EXAMPLE_ADDR EXAMPLE_PAGE * EEPROM_PAGE_SIZE
+\endcode
+ * -# Define two tables, one which contains the data which we will write,
+ * and one which we will read the data into:
+ * - \code
+ uint8_t write_page[EEPROM_PAGE_SIZE];
+ uint8_t read_page[EEPROM_PAGE_SIZE];
+\endcode
+ * -# Fill the tables with our data, and zero out the read table:
+ * - \code
+ fill_page_with_known_data(write_page);
+ fill_page_with_zeroes(read_page);
+\endcode
+ * - \note These functions are undeclared, you should replace them with
+ * your own appropriate functions.
+ * -# We load our page into a temporary EEPROM page buffer:
+ * - \code
+ nvm_eeprom_load_page_to_buffer(write_page);
+\endcode
+ * - \attention The function used above will not work if memory mapping
+ * is enabled.
+ * -# Do an atomic write of the page from buffer into the specified page:
+ * - \code
+ nvm_eeprom_atomic_write_page(EXAMPLE_PAGE);
+\endcode
+ * - \note The function \ref nvm_eeprom_atomic_write_page() erases the
+ * page before writing the new one. For non-atomic (split)
+ * writing without deleting, see \ref nvm_eeprom_split_write_page()
+ * -# Read the page back into our read_page[] table:
+ * - \code
+ nvm_eeprom_read_buffer(EXAMPLE_ADDR,
+ read_page, EEPROM_PAGE_SIZE);
+\endcode
+ * -# Verify that the page is equal to the one that was written earlier:
+ * - \code
+ check_if_pages_are_equal(write_page, read_page);
+\endcode
+ * - \note This function is not declared, you should replace it with your
+ * own appropriate function.
+ *
+ * \section xmega_nvm_quickstart_fuse_case Use case 2: Fuses
+ *
+ * The NVM driver has functions for reading fuses.
+ * See \ref nvm_fuse_lock_group.
+ *
+ * We would like to check whether the Brown-out Detection level is set to
+ * 2.1V. This is set by programming the fuses when the chip is connected
+ * to a suitable programmer. The fuse is a part of FUSEBYTE5. If the BODLVL
+ * is correct, we turn on LED0.
+ *
+ * \section xmega_nvm_quickstart_fuse_case_setup_steps Setup steps
+ * There are no setup steps required for this use case.
+ *
+ * \subsection nvm_quickstart_fuse_case_example_code Example code
+ * \code
+ uint8_t fuse_value;
+ fuse_value = nvm_fuses_read(FUSEBYTE5);
+
+ if ((fuse_value & NVM_FUSES_BODLVL_gm) == BODLVL_2V1_gc) {
+ gpio_set_pin_low(LED0_GPIO);
+ }
+\endcode
+ *
+ * \subsection nvm_quickstart_fuse_case_workflow Workflow
+ *
+ * -# Create a variable to store the fuse contents:
+ * - \code
+ uint8_t fuse_value;
+\endcode
+ * -# The fuse value we are interested in, BODLVL, is stored in FUSEBYTE5.
+ * We call the function \ref nvm_fuses_read() to read the fuse into our
+ * variable:
+ * - \code
+ fuse_value = nvm_fuses_read(FUSEBYTE5);
+\endcode
+ * -# This ends the reading portion, but we would like to see whether the
+ * BOD-level is correct, and if it is, light up an LED:
+ * - \code
+ if ((fuse_value & NVM_FUSES_BODLVL_gm) == BODLVL_2V1_gc) {
+ gpio_set_pin_low(LED0_GPIO);
+ }
+\endcode
+ *
+ * \section xmega_nvm_quickstart_signature_case Use case 3: Signature row
+ *
+ * The NVM driver has functions for reading the signature row of the device.
+ * Here we will simply read 16 bytes from the user signature row, assuming
+ * we need what is stored there.
+ *
+ * \section xmega_nvm_quickstart_signature_row_setup_steps Setup steps
+ * There are no setup steps required for this use case.
+ *
+ * \subsection xmega_nvm_quickstart_signature_row_example_code Example code
+ *
+ * \code
+ #define START_ADDR 0x10
+ #define DATA_LENGTH 16
+
+ uint8_t values[LENGTH];
+ uint8_t i;
+
+ for (i = 0; i < DATA_LENGTH; i++) {
+ values[i] = nvm_read_user_signature_row(START_ADDR + i);
+ }
+\endcode
+ *
+ * \subsection nvm_quickstart_signature_case_workflow Workflow
+ *
+ * -# Define starting address and length of data segment, and create
+ * variables needed to store and process the data:
+ * - \code
+ #define START_ADDR 0x10
+ #define DATA_LENGTH 16
+
+ uint8_t values[LENGTH];
+ uint8_t i;
+\endcode
+ * -# Iterate through the user signature row, and store our desired data:
+ * - \code
+ for (i = 0; i < DATA_LENGTH; i++) {
+ values[i] = nvm_read_user_signature_row(START_ADDR + i);
+ }
+\endcode
+ *
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NVM_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm.h.REMOVED.git-id
deleted file mode 100644
index 968a6054..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1e52ffc957556eff30f0ad3fd285ee180a9bd1ec
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm_asm.s b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm_asm.s
new file mode 100644
index 00000000..6d74e08e
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm_asm.s
@@ -0,0 +1,197 @@
+/**
+ * \file
+ *
+ * \brief Non Volatile Memory controller driver
+ *
+ * Copyright (c) 2010 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+#include
+
+#if defined(__GNUC__)
+//! Value to write to CCP for access to protected IO registers.
+# define CCP_SPM_gc 0x9D
+
+//! NVM busy flag
+# define NVM_NVMBUSY_bp 7
+
+//! NVM command for loading flash buffer
+# define NVM_CMD_LOAD_FLASH_BUFFER_gc 0x23
+#elif defined(__IAR_SYSTEMS_ASM__)
+// All values are defined for IAR
+#else
+# error Unknown assembler
+#endif
+
+#ifndef __DOXYGEN__
+ PUBLIC_FUNCTION(nvm_read_byte)
+#if defined(__GNUC__)
+ lds r20, NVM_CMD ; Store NVM command register
+ mov ZL, r22 ; Load byte index into low byte of Z.
+ mov ZH, r23 ; Load high byte into Z.
+ sts NVM_CMD, r24 ; Load prepared command into NVM Command register.
+ lpm r24, Z ; Perform an LPM to read out byte
+ sts NVM_CMD, r20 ; Restore NVM command register
+#elif defined(__IAR_SYSTEMS_ASM__)
+ lds r20, NVM_CMD ; Store NVM command register
+ mov ZL, r18 ; Load byte index into low byte of Z.
+ mov ZH, r19 ; Load high byte into Z.
+ sts NVM_CMD, r16 ; Load prepared command into NVM Command register.
+ lpm r16, Z ; Perform an LPM to read out byte
+ sts NVM_CMD, r20 ; Restore NVM command register
+#endif
+
+ ret
+
+ END_FUNC(nvm_read_byte)
+
+// IAR forgets about include files after each module, so need to include again
+#if defined(__IAR_SYSTEMS_ASM__)
+# include
+#endif
+
+ /**
+ * \brief Perform SPM command
+ */
+ PUBLIC_FUNCTION_SEGMENT(nvm_common_spm, BOOT)
+
+#if defined(__GNUC__)
+ /**
+ * For GCC:
+ * \param address uint32_t r22:r25
+ * \param nvm_cmd uint8_t r20
+ */
+ in r25, RAMPZ ; Store RAMPZ. Highest address byte is ignored, so using that
+ out RAMPZ, r24 ; Load R24 into RAMPZ
+ movw ZL, r22 ; Load R22:R23 into Z.
+ lds r24, NVM_CMD ; Store NVM command register (r24 is no longer needed)
+ sts NVM_CMD, r20 ; Load prepared command into NVM Command register.
+ ldi r23, CCP_SPM_gc ; Prepare Protect SPM signature (r23 is no longer needed)
+ sts CCP, r23 ; Enable SPM operation (this disables interrupts for 4 cycles).
+ spm ; Self-program.
+ sts NVM_CMD, r24 ; Restore NVM command register
+ out RAMPZ, r25 ; Restore RAMPZ register.
+#elif defined(__IAR_SYSTEMS_ASM__)
+ /**
+ * For IAR:
+ * \param address uint32_t r16:r19
+ * \param nvm_cmd uint8_t r20
+ */
+ in r19, RAMPZ ; Store RAMPZ. Highest address byte is ignored, so using that
+ out RAMPZ, r18 ; Load R18 into RAMPZ
+ movw ZL, r16 ; Load R16:R17 into Z.
+ lds r18, NVM_CMD ; Store NVM command register (r18 is no longer needed)
+ sts NVM_CMD, r20 ; Load prepared command into NVM Command register.
+ ldi r19, CCP_SPM_gc ; Prepare Protect SPM signature (r19 is no longer needed)
+ sts CCP, r19 ; Enable SPM operation (this disables interrupts for 4 cycles).
+ spm ; Self-program.
+ sts NVM_CMD, r18 ; Restore NVM command register
+ out RAMPZ, r19 ; Restore RAMPZ register.
+#endif
+
+ ret
+
+ END_FUNC(nvm_common_spm)
+
+// IAR forgets about include files after each module, so need to include again
+#if defined(__IAR_SYSTEMS_ASM__)
+# include
+#endif
+
+ /**
+ * \brief Load byte to page buffer
+ *
+ */
+ PUBLIC_FUNCTION_SEGMENT(nvm_flash_load_word_to_buffer, BOOT)
+
+#if defined(__GNUC__)
+ /**
+ * For GCC:
+ * \param word_addr uint32_t r22:r25
+ * \param data uint16_t r20:r21
+ */
+wait_nvm:
+ lds r18, NVM_STATUS
+ sbrc r18, NVM_NVMBUSY_bp
+ rjmp wait_nvm
+
+ in r25, RAMPZ ; Store RAMPZ. Highest address byte is ignored, so using that
+ out RAMPZ, r24 ; Load R24 into RAMPZ
+ movw ZL, r22 ; Load R22:R23 into Z.
+
+ lds r24, NVM_CMD ; Store NVM command register (r24 is no longer needed)
+ ldi r18, NVM_CMD_LOAD_FLASH_BUFFER_gc
+ sts NVM_CMD, r18 ; Load prepared command into NVM Command register.
+
+ movw r0, r20 ; Load R20:R21 into R0:R1
+ spm ; Self-program.
+
+ clr r1 ; Clear R1 for GCC _zero_reg_ to function properly.
+ sts NVM_CMD, r24 ; Restore NVM command register
+ out RAMPZ, r25 ; Restore RAMPZ register.
+#elif defined(__IAR_SYSTEMS_ASM__)
+ /**
+ * For IAR:
+ * \param word_addr uint32_t r16:r19
+ * \param data uint16_t r20:r21
+ */
+wait_nvm:
+ lds r19, NVM_STATUS
+ sbrc r19, NVM_NVMBUSY_bp
+ rjmp wait_nvm
+
+ in r19, RAMPZ ; Store RAMPZ. Highest byte is ignored, so using that
+ out RAMPZ, r18 ; Load R18 into RAMPZ
+ movw ZL, r16 ; Load R16:R17 into Z.
+
+ lds r18, NVM_CMD ; Store NVM command register (r18 is no longer needed)
+ ldi r17, NVM_CMD_LOAD_FLASH_BUFFER_gc
+ sts NVM_CMD, r17 ; Load prepared command into NVM Command register.
+
+ movw r0, r20 ; Load R20:R21 into R0:R1
+ spm ; Self-program.
+
+ sts NVM_CMD, r18 ; Restore NVM command register
+ out RAMPZ, r19 ; Restore RAMPZ register.
+#endif
+
+ ret
+
+ END_FUNC(nvm_flash_load_word_to_buffer)
+
+ END_FILE()
+#endif // __DOXYGEN__
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm_asm.s.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm_asm.s.REMOVED.git-id
deleted file mode 100644
index 478f3b03..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/nvm/nvm_asm.s.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6d74e08e518a7172e2adf9a19654fbfe95d1c7af
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/pmic/pmic.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/pmic/pmic.h
new file mode 100644
index 00000000..81f56157
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/pmic/pmic.h
@@ -0,0 +1,352 @@
+/**
+ * \file
+ *
+ * \brief Programmable Multilevel Interrupt Controller driver
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef PMIC_H
+#define PMIC_H
+
+#include
+#include
+
+/**
+ * \defgroup pmic_group Programmable Multilevel Interrupt Controller
+ *
+ * See \ref xmega_pmic_quickstart.
+ *
+ * This is a low-level driver implementation for the AVR XMEGA Programmable
+ * Multilevel Interrupt Controller.
+ *
+ * \note If these functions are used in interrupt service routines (ISRs), any
+ * non-ISR code or ISR code for lower level interrupts must ensure that the
+ * operations are atomic, i.e., by disabling interrupts during the function
+ * calls.
+ * @{
+ */
+
+/**
+ * \brief Interrupt level bitmasks
+ *
+ * \note These may be OR'ed, e.g., if multiple levels are to be enabled or
+ * disabled.
+ */
+enum pmic_level {
+ PMIC_LVL_LOW = PMIC_LOLVLEN_bm, //!< Low-level interrupts
+ PMIC_LVL_MEDIUM = PMIC_MEDLVLEN_bm, //!< Medium-level interrupts
+ PMIC_LVL_HIGH = PMIC_HILVLEN_bm, //!< High-level interrupts
+ /**
+ * \brief Non-maskable interrupts
+ * \note These cannot be enabled nor disabled.
+ */
+ PMIC_LVL_NMI = PMIC_NMIEX_bp,
+};
+
+//! Interrupt vector locations
+enum pmic_vector {
+ PMIC_VEC_APPLICATION, //!< Application section
+ PMIC_VEC_BOOT, //!< Boot section
+ PMIC_NR_OF_VECTORS, //!< Number of interrupt vector locations
+};
+
+//! Interrupt scheduling schemes
+enum pmic_schedule {
+ PMIC_SCH_FIXED_PRIORITY, //!< Default, fixed priority scheduling
+ PMIC_SCH_ROUND_ROBIN, //!< Round-robin scheduling
+ PMIC_NR_OF_SCHEDULES, //!< Number of interrupt scheduling schemes
+};
+
+/**
+ * \brief Initialize the PMIC
+ *
+ * Enables all interrupt levels, with vectors located in the application section
+ * and fixed priority scheduling.
+ */
+static inline void pmic_init(void)
+{
+ PMIC.CTRL = PMIC_LVL_LOW | PMIC_LVL_MEDIUM |
+ PMIC_LVL_HIGH;
+}
+
+/**
+ * \brief Enable interrupts with specified \a level(s).
+ *
+ * \param level Interrupt level(s) to enable.
+ */
+static inline void pmic_enable_level(enum pmic_level level)
+{
+ Assert((level & PMIC_LVL_NMI));
+
+ PMIC.CTRL |= level;
+}
+
+/**
+ * \brief Disable interrupts with specified \a level(s).
+ *
+ * \param level Interrupt level(s) to disable.
+ */
+static inline void pmic_disable_level(enum pmic_level level)
+{
+ Assert((level & PMIC_LVL_NMI));
+
+ PMIC.CTRL &= ~level;
+}
+
+/**
+ * \brief Check if specified interrupt \a level(s) is enabled.
+ *
+ * \param level Interrupt level(s) to check.
+ *
+ * \return True if interrupt level(s) is enabled.
+ */
+static inline bool pmic_level_is_enabled(enum pmic_level level)
+{
+ Assert((level & PMIC_LVL_NMI));
+
+ return PMIC.CTRL & level;
+}
+
+/**
+ * \brief Get currently enabled level(s)
+ *
+ * \return Bitmask with currently enabled levels.
+ */
+static inline enum pmic_level pmic_get_enabled_levels(void)
+{
+ return (enum pmic_level)(PMIC.CTRL & (PMIC_LVL_LOW | PMIC_LVL_MEDIUM
+ | PMIC_LVL_HIGH));
+}
+
+/**
+ * \brief Check if an interrupt level(s) is currently executing.
+ *
+ * \param level Interrupt level(s) to check.
+ *
+ * \return True if interrupt level(s) is currently executing.
+ */
+static inline bool pmic_level_is_executing(enum pmic_level level)
+{
+ return PMIC.STATUS & level;
+}
+
+/**
+ * \brief Set interrupt scheduling for low-level interrupts.
+ *
+ * \param schedule Interrupt scheduling method to set.
+ *
+ * \note The low-priority vector, INTPRI, must be set to 0 when round-robin
+ * scheduling is disabled to return to default interrupt priority order.
+ */
+static inline void pmic_set_scheduling(enum pmic_schedule schedule)
+{
+ Assert(schedule < PMIC_NR_OF_SCHEDULES);
+
+ switch (schedule) {
+ case PMIC_SCH_FIXED_PRIORITY:
+ PMIC.CTRL &= ~PMIC_RREN_bm;
+ PMIC.INTPRI = 0;
+ break;
+
+ case PMIC_SCH_ROUND_ROBIN:
+ PMIC.CTRL |= PMIC_RREN_bm;
+ break;
+
+ default:
+ break;
+ };
+}
+
+/**
+ * \brief Set location of interrupt vectors.
+ *
+ * \param vector Location to use for interrupt vectors.
+ */
+static inline void pmic_set_vector_location(enum pmic_vector vector)
+{
+ uint8_t ctrl = PMIC.CTRL;
+
+ Assert(vector < PMIC_NR_OF_VECTORS);
+
+ switch (vector) {
+ case PMIC_VEC_APPLICATION:
+ ctrl &= ~PMIC_IVSEL_bm;
+ break;
+
+ case PMIC_VEC_BOOT:
+ ctrl |= PMIC_IVSEL_bm;
+ break;
+
+ default:
+ break;
+ }
+
+ ccp_write_io((uint8_t*)&PMIC.CTRL, ctrl);
+}
+
+//! @}
+
+/**
+ * \page xmega_pmic_quickstart Quick start guide for PMIC driver
+ *
+ * This is the quick start guide for the \ref pmic_group "PMIC driver" and
+ * the closely related \ref interrupt_group "global interrupt driver", with
+ * step-by-step instructions on how to configure and use the drivers in a
+ * selection of use cases.
+ *
+ * The use cases contain several code fragments. The code fragments in the
+ * steps for setup can be copied into a custom initialization function, while
+ * the steps for usage can be copied into, e.g., the main application function.
+ *
+ * \section pmic_basic_use_case Basic use case
+ * In this basic use case, the PMIC is configured for:
+ * - all interrupt levels enabled
+ * - round-robin scheduling
+ *
+ * This will allow for interrupts from other modules being used.
+ *
+ * \section pmic_basic_use_case_setup Setup steps
+ *
+ * \subsection pmic_basic_use_case_setup_prereq Prerequisites
+ * For the setup code of this use case to work, the following must
+ * be added to the project:
+ * -# Interrupts for the module requiring the PMIC module have to be
+ * enabled.
+ * -# An Interrupt Service Routine (ISR) for a given interrupt vector has to be
+ * defined, where the interrupt vectors available are defined by toolchain and
+ * listed in the subsection 'Interrupt Vector Summary' in the data sheet.
+ * \code
+ ISR(interrupt_vector){
+ //Interrupt Service Routine
+ }
+\endcode
+ *
+ * \subsection pmic_basic_use_case_setup_code Example code
+ * Add to the initialization code:
+ * \code
+ pmic_init();
+ pmic_set_scheduling(PMIC_SCH_ROUND_ROBIN);
+ cpu_irq_enable();
+\endcode
+ *
+ * \subsection pmic_basic_use_case_setup_flow Workflow
+ * -# call the PMIC driver's own init function to enable all interrupt levels:
+ * - \code pmic_init(); \endcode
+ * -# enable round-robin instead of fixed priority interrupt scheduling:
+ * - \code pmic_set_scheduling(PMIC_SCH_ROUND_ROBIN); \endcode
+ * -# enable interrupts globally:
+ * - \code cpu_irq_enable(); \endcode
+ * - \attention Interrupts will not trigger without this step.
+ *
+ * \section pmic_use_cases Advanced use cases
+ * For more advanced use of the PMIC driver, see the following use cases:
+ * - \subpage pmic_use_case_1 : atomic operations
+ */
+
+/**
+ * \page pmic_use_case_1 Use case #1
+ *
+ * In this use case, the PMIC is configured for:
+ * - all interrupt levels enabled
+ *
+ * This will allow for interrupts from other modules being used.
+ *
+ * This use case shows how to make an operation which consists of multiple
+ * instructions uninterruptible, i.e., into an atomic operation. This is often
+ * necessary if there is a risk that data can be accessed by interrupt handlers
+ * while other code is accessing it, and at least one of them modifies it.
+ *
+ * \section pmic_use_case_1_setup Setup steps
+ *
+ * \subsection pmic_basic_use_case_setup_prereq Prerequisites
+ * For the setup code of this use case to work, the following must
+ * be added to the project:
+ * -# Interrupts for the module requiring the PMIC module have to be
+ * enabled.
+ * -# An Interrupt Service Routine (ISR) for a given interrupt vector has to be
+ * defined, where the interrupt vectors available are defined by toolchain and
+ * listed in the subsection 'Interrupt Vector Summary' in the data sheet.
+ * \code
+ ISR(interrupt_vector){
+ //Interrupt Service Routine
+ }
+\endcode
+ *
+ * \subsection pmic_use_case_1_setup_code Example code
+ * Add to application initialization:
+ * \code
+ pmic_init();
+ cpu_irq_enable();
+\endcode
+ *
+ * \subsection pmic_use_case_1_setup_flow Workflow
+ * -# call the PMIC driver's own init function to enable all interrupt levels:
+ * - \code pmic_init(); \endcode
+ * -# set global interrupt enable flag:
+ * - \code cpu_irq_enable(); \endcode
+ *
+ * \section pmic_use_case_1_usage Usage steps
+ *
+ * \subsection pmic_use_case_1_usage_code Example code
+ * \code
+ Add to application:
+ void atomic_operation(void)
+ {
+ irqflags_t flags;
+
+ flags = cpu_irq_save();
+
+ // Uninterruptible block of code
+
+ cpu_irq_restore(flags);
+ }
+\endcode
+ *
+ * \subsection pmic_use_case_1_usage_flow Workflow
+ * -# allocate temporary storage for interrupt enable:
+ * - \code irqflags_t flags; \endcode
+ * -# clear global interrupt enable flag while saving its previous state:
+ * - \code flags = cpu_irq_save(); \endcode
+ * -# restore the previous state of global interrupt flag after operation:
+ * - \code cpu_irq_restore(flags); \endcode
+ */
+
+#endif /* PMIC_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/pmic/pmic.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/pmic/pmic.h.REMOVED.git-id
deleted file mode 100644
index caf8cb34..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/pmic/pmic.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-81f561576ef6063862e73b77d32c30cb53e766f6
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/sleep/sleep.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/sleep/sleep.h
new file mode 100644
index 00000000..8a218c41
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/sleep/sleep.h
@@ -0,0 +1,169 @@
+/**
+ * \file
+ *
+ * \brief Sleep controller driver
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef SLEEP_H
+#define SLEEP_H
+
+#include
+
+/**
+ * \defgroup sleep_group Sleep controller driver
+ *
+ * This is a low-level driver implementation for the AVR XMEGA sleep controller.
+ *
+ * \note To minimize the code overhead, these functions do not feature
+ * interrupt-protected access since they are likely to be called inside
+ * interrupt handlers or in applications where such protection is not
+ * necessary. If such protection is needed, it must be ensured by the calling
+ * code.
+ *
+ * \section xmega_sleep_quickstart_section Quick Start Guide
+ * See \ref xmega_sleep_quickstart
+ * @{
+ */
+
+#if defined(__ICCAVR__) || defined(__DOXYGEN__)
+# include
+//! Macro for issuing the sleep instruction.
+# define sleep_enter() __sleep()
+
+/**
+ * \brief Enable sleep
+ */
+static inline void sleep_enable(void)
+{
+ SLEEP.CTRL |= SLEEP_SEN_bm;
+}
+
+/**
+ * \brief Disable sleep
+ */
+static inline void sleep_disable(void)
+{
+ SLEEP.CTRL &= ~SLEEP_SEN_bm;
+}
+
+#elif defined(__GNUC__)
+# include
+# define sleep_enter() sleep_cpu()
+
+#else
+# error Unsupported compiler.
+#endif
+
+/**
+ * \brief Set new sleep mode
+ *
+ * \param mode Sleep mode, from the device IO header file.
+ */
+static inline void sleep_set_mode(enum SLEEP_SMODE_enum mode)
+{
+ SLEEP.CTRL = mode | (SLEEP.CTRL & ~SLEEP_SMODE_gm);
+}
+
+//! @}
+
+/**
+ * \page xmega_sleep_quickstart Quick Start Guide for the XMEGA Sleep Driver
+ *
+ * This is the quick start guide for the \ref sleep_group "Sleep Driver", with
+ * step-by-step instructions on how to configure and use the driver for a
+ * specific use case.
+ *
+ * The section described below can be copied into, e.g. the main application
+ * loop or any other function that will need to control and execute different
+ * sleep modes on the device.
+ *
+ * \section xmega_sleep_quickstart_basic Basic usage of the sleep driver
+ * This use case will prepare the device to enter the Power Down sleep mode and
+ * then enter the sleep mode. After waking up it will disable sleep.
+ *
+ * \section xmega_sleep_basic_usage Usage steps
+ * \subsection xmega_sleep_basic_usage_code Example code
+ * Add to, e.g., the main loop in the application C-file:
+ * \code
+ sleep_set_mode(SLEEP_SMODE_PDOWN_gc);
+ sleep_enable();
+ sleep_enter();
+ sleep_disable();
+\endcode
+ *
+ * \subsection xmega_sleep_basic_usage Workflow
+ * -# Set what sleep mode to use, the different sleep modes can be found in the
+ * device header file under the enum definition SLEEP_SMODE_enum:
+ * - \code sleep_set_mode(SLEEP_SMODE_PDOWN_gc); \endcode
+ * -# Enable that the device are allowed to go to sleep:
+ * - \code sleep_enable(); \endcode
+ * - \note This function has to be called in order for the device to go to
+ * sleep. This is a safety feature to stop the device to go to sleep
+ * unintentionally, even though it is possible to have this enabled at all times
+ * it is recommended to enable sleep mode only when you intend to go to sleep
+ * within a few clock cycles.
+ * -# Enter sleep mode:
+ * - \code sleep_enter(); \endcode
+ * - \attention Make sure to enable global interrupt and the interrupt you
+ * plan to use as wake-up source for your device, do also pay special
+ * attention to what wake-up sources are available for the different sleep
+ * modes. Failing to enable interrupts may result in indefinite sleep until
+ * power is cycled!
+ * -# When the device is woken from sleep it will execute the interrupt handler
+ * related to the wakeup-source (interrupt source) and continue on the next line
+ * of code after the \ref sleep_enter() call. Make sure to disable sleep when
+ * waking up.
+ * - \code sleep_disable(); \endcode
+ *
+ * \subsection xmega_sleep_basic_sleep_modes Sleep Modes
+ * Possible sleep modes depend on the device that is used. Please refer to the
+ * device datasheet and header file to find these definitions.
+ *
+ * As an example the ATxmega32A4U device has the following sleep modes:
+ * - Idle sleep: SLEEP_SMODE_IDLE_gc
+ * - Power Down: SLEEP_SMODE_PDOWN_gc
+ * - Power Save: SLEEP_SMODE_PSAVE_gc
+ * - Standby: SLEEP_SMODE_STDBY_gc
+ * - Extended standby: SLEEP_SMODE_ESTDBY_gc
+ */
+
+#endif /* SLEEP_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/sleep/sleep.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/sleep/sleep.h.REMOVED.git-id
deleted file mode 100644
index e3396990..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/sleep/sleep.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8a218c4125a7db6afbdb3f22235b7b8d33f74d09
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.c b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.c
new file mode 100644
index 00000000..37511077
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.c
@@ -0,0 +1,119 @@
+/*****************************************************************************
+ *
+ * \file
+ *
+ * \brief SPI software driver functions.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ *****************************************************************************/
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "spi.h"
+
+/*! \brief Calculates the SPI baudrate divider.
+ *
+ * \param baudrate The expected baudrate on the SPI.
+ * \param clkper_hz SPI module input clock frequency (Peripheral clock, Hz).
+ * \param spi The SPI module address
+ *
+ * \return Status of operation.
+ * \retval >=0 Success.
+ * \retval <0 Error.
+ */
+int8_t spi_xmega_set_baud_div(SPI_t *spi, uint32_t baudrate, uint32_t clkper_hz)
+{
+ uint32_t divisor;
+ uint8_t divisor_8bit;
+ uint8_t ctrl;
+
+ // Sanity check, requested baudrate is lower than system clock
+ Assert(clkper_hz > baudrate);
+
+ /*
+ * Get wanted divisor rounded up so we don't get speed higher than
+ * requested baudrate.
+ */
+ divisor = (clkper_hz + baudrate - 1) / baudrate;
+
+ if (divisor > 128) {
+ /*
+ * Highest possible divisor is 128 so fail since we can't get
+ * low enough baudrate.
+ */
+ return -1;
+ }
+
+ /*
+ * We now know that the divisor is 128 or lower so move it into a 8-bit
+ * variable to make sure the following comparison is more optimized.
+ */
+ divisor_8bit = divisor;
+
+ /*
+ * For divisor values between the possible ones round up to the closest
+ * higher one to avoid higher baudrate than requested.
+ */
+ if (divisor_8bit > 64) {
+ ctrl = SPI_PRESCALER_DIV128_gc;
+ }
+ else if (divisor_8bit > 32) {
+ ctrl = SPI_PRESCALER_DIV64_gc;
+ }
+ else if (divisor_8bit > 16) {
+ ctrl = SPI_CLK2X_bm | SPI_PRESCALER_DIV64_gc;
+ }
+ else if (divisor_8bit > 8) {
+ ctrl = SPI_PRESCALER_DIV16_gc;
+ }
+ else if (divisor_8bit > 4) {
+ ctrl = SPI_CLK2X_bm | SPI_PRESCALER_DIV16_gc;
+ }
+ else if (divisor_8bit > 2) {
+ ctrl = SPI_PRESCALER_DIV4_gc;
+ }
+ else {
+ ctrl = SPI_CLK2X_bm | SPI_PRESCALER_DIV4_gc;
+ }
+
+ // Update register and make sure to clear out any leftover bits
+ spi->CTRL = (spi->CTRL & ~(SPI_CLK2X_bm | SPI_PRESCALER_gm)) | ctrl;
+
+ return 1;
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.c.REMOVED.git-id
deleted file mode 100644
index 9addfaf2..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-37511077cee6a54bab360f1040f13599b55910b1
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.h
new file mode 100644
index 00000000..766f6329
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.h
@@ -0,0 +1,166 @@
+/*****************************************************************************
+ *
+ * \file
+ *
+ * \brief SPI driver for AVR.
+ *
+ * This file defines a useful set of functions for the SPI interface on AVR
+ * devices.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ ******************************************************************************/
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+
+#ifndef _SPI_H_
+#define _SPI_H_
+
+/**
+ * \defgroup group_xmega_drivers_spi SPI - Serial Peripheral Interface
+ *
+ * Driver for the Serial Peripheral Interface (SPI).
+ * Provides functions for configuring and using the SPI.
+ *
+ * \{
+ */
+
+#include "compiler.h"
+#include "status_codes.h"
+#include "ioport.h"
+
+/*! \brief Calculates the SPI baudrate divider.
+ *
+ * \param baudrate The expected baudrate on the SPI.
+ * \param clkper_hz SPI module input clock frequency (Peripheral clock, Hz).
+ * \param spi The SPI module address
+ *
+ * \return Divider or error code.
+ * \retval >=0 Success.
+ * \retval <0 Error.
+ */
+int8_t spi_xmega_set_baud_div(SPI_t *spi, uint32_t baudrate, uint32_t clkper_hz);
+
+/*! \brief Enables the SPI.
+ *
+ * \param spi Base address of the SPI instance.
+ */
+static inline void spi_enable(SPI_t *spi)
+{
+ spi->CTRL |= SPI_ENABLE_bm;
+}
+
+/*! \brief Disables the SPI.
+ *
+ * Ensures that nothing is transferred while setting up buffers.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \warning This may cause data loss if used on a slave SPI.
+ */
+static inline void spi_disable(SPI_t *spi)
+{
+ spi->CTRL &= ~SPI_ENABLE_bm;
+}
+
+/*! \brief Tests if the SPI is enabled.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \return \c 1 if the SPI is enabled, otherwise \c 0.
+ */
+static inline bool spi_is_enabled(SPI_t *spi)
+{
+ return spi->CTRL & SPI_ENABLE_bm ? true : false;
+}
+
+/*! \brief Put one data byte to a SPI peripheral.
+ *
+ * \param spi Base address of the SPI instance.
+ * \param data The data byte to be loaded
+ *
+ */
+static inline void spi_put(SPI_t *spi, uint8_t data)
+{
+ spi->DATA = data;
+}
+
+/*! \brief Get one data byte to a SPI peripheral.
+ *
+ * \param spi Base address of the SPI instance.
+ * \return The data byte
+ *
+ */
+static inline uint8_t spi_get(SPI_t *spi)
+{
+ return spi->DATA;
+}
+
+/*! \brief Tests if the SPI contains a received character.
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \return \c 1 if the SPI Receive Holding Register is full, otherwise \c 0.
+ */
+static inline bool spi_is_tx_ok(SPI_t *spi)
+{
+ return spi->STATUS & SPI_IF_bm ? true : false;
+}
+
+/*! \brief Activate SPI master mode of a SPI peripheral
+ *
+ * \param spi Base address of the SPI instance.
+ *
+ * \warning This may cause data loss if used on a slave SPI.
+ */
+static inline void spi_enable_master_mode(SPI_t *spi)
+{
+ spi->CTRL |= SPI_MASTER_bm;
+}
+
+/*! \name Part Specific SPI Driver
+ */
+//! @{
+//! @}
+
+/**
+ * \}
+ */
+
+#endif // _SPI_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.h.REMOVED.git-id
deleted file mode 100644
index 4f6d4ba3..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/spi/spi.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-766f6329505a0c34e22436ae8defc789672a8ffc
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.c b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.c
new file mode 100644
index 00000000..a4bc1421
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.c
@@ -0,0 +1,467 @@
+/**
+ * \file
+ *
+ * \brief USART driver for AVR XMEGA.
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#include
+#include "compiler.h"
+#include "usart.h"
+#include "sysclk.h"
+#include "ioport.h"
+#include "status_codes.h"
+
+/*
+ * Fix XMEGA header files
+ * USART.CTRLC bit masks and bit positions
+ */
+#ifndef USART_UCPHA_bm
+# define USART_UCPHA_bm 0x02
+#endif
+#ifndef USART_DORD_bm
+# define USART_DORD_bm 0x04
+#endif
+
+/**
+ * \brief Initialize USART in RS232 mode.
+ *
+ * This function initializes the USART module in RS232 mode using the
+ * usart_rs232_options_t configuration structure and CPU frequency.
+ *
+ * \param usart The USART module.
+ * \param opt The RS232 configuration option.
+ *
+ * \retval true if the initialization was successfull
+ * \retval false if the initialization failed (error in baud rate calculation)
+ */
+bool usart_init_rs232(USART_t *usart, const usart_rs232_options_t *opt)
+{
+ bool result;
+ sysclk_enable_peripheral_clock(usart);
+ usart_set_mode(usart, USART_CMODE_ASYNCHRONOUS_gc);
+ usart_format_set(usart, opt->charlength, opt->paritytype,
+ opt->stopbits);
+ result = usart_set_baudrate(usart, opt->baudrate, sysclk_get_per_hz());
+ usart_tx_enable(usart);
+ usart_rx_enable(usart);
+
+ return result;
+}
+
+/**
+ * \brief Initialize USART in SPI master mode.
+ *
+ * This function initializes the USART module in SPI master mode using the
+ * usart_spi_options_t configuration structure and CPU frequency.
+ *
+ * \param usart The USART module.
+ * \param opt The RS232 configuration option.
+ */
+void usart_init_spi(USART_t *usart, const usart_spi_options_t *opt)
+{
+ ioport_pin_t sck_pin;
+ bool invert_sck;
+
+ sysclk_enable_peripheral_clock(usart);
+
+ usart_rx_disable(usart);
+
+ /* configure Clock polarity using INVEN bit of the correct SCK I/O port **/
+ invert_sck = (opt->spimode == 2) || (opt->spimode == 3);
+ UNUSED(invert_sck);
+
+#ifdef USARTC0
+ if ((uint16_t)usart == (uint16_t)&USARTC0) {
+# ifdef PORT_USART0_bm
+ if (PORTC.REMAP & PORT_USART0_bm) {
+ sck_pin = IOPORT_CREATE_PIN(PORTC, 5);
+ } else {
+ sck_pin = IOPORT_CREATE_PIN(PORTC, 1);
+ }
+# else
+ sck_pin = IOPORT_CREATE_PIN(PORTC, 1);
+# endif
+ }
+#endif
+#ifdef USARTC1
+ if ((uint16_t)usart == (uint16_t)&USARTC1) {
+ sck_pin = IOPORT_CREATE_PIN(PORTC, 5);
+ }
+#endif
+#ifdef USARTD0
+ if ((uint16_t)usart == (uint16_t)&USARTD0) {
+# ifdef PORT_USART0_bm
+ if (PORTD.REMAP & PORT_USART0_bm) {
+ sck_pin = IOPORT_CREATE_PIN(PORTD, 5);
+ } else {
+ sck_pin = IOPORT_CREATE_PIN(PORTD, 1);
+ }
+# else
+ sck_pin = IOPORT_CREATE_PIN(PORTD, 1);
+# endif
+ }
+#endif
+#ifdef USARTD1
+ if ((uint16_t)usart == (uint16_t)&USARTD1) {
+ sck_pin = IOPORT_CREATE_PIN(PORTD, 5);
+ }
+#endif
+#ifdef USARTE0
+ if ((uint16_t)usart == (uint16_t)&USARTE0) {
+# ifdef PORT_USART0_bm
+ if(PORTE.REMAP & PORT_USART0_bm) {
+ sck_pin = IOPORT_CREATE_PIN(PORTE, 5);
+ } else {
+ sck_pin = IOPORT_CREATE_PIN(PORTE, 1);
+ }
+# else
+ sck_pin = IOPORT_CREATE_PIN(PORTE, 1);
+# endif
+ }
+#endif
+#ifdef USARTE1
+ if ((uint16_t)usart == (uint16_t)&USARTE1) {
+ sck_pin = IOPORT_CREATE_PIN(PORTE, 5);
+ }
+#endif
+#ifdef USARTF0
+ if ((uint16_t)usart == (uint16_t)&USARTF0) {
+# ifdef PORT_USART0_bm
+ if(PORTF.REMAP & PORT_USART0_bm) {
+ sck_pin = IOPORT_CREATE_PIN(PORTF, 5);
+ } else {
+ sck_pin = IOPORT_CREATE_PIN(PORTF, 1);
+ }
+# else
+ sck_pin = IOPORT_CREATE_PIN(PORTF, 1);
+# endif
+ }
+#endif
+#ifdef USARTF1
+ if ((uint16_t)usart == (uint16_t)&USARTF1) {
+ sck_pin = IOPORT_CREATE_PIN(PORTF, 5);
+ }
+#endif
+
+ /* Configure the USART output pin */
+ ioport_set_pin_dir(sck_pin, IOPORT_DIR_OUTPUT);
+ ioport_set_pin_mode(sck_pin,
+ IOPORT_MODE_TOTEM | (invert_sck? IOPORT_MODE_INVERT_PIN : 0));
+ ioport_set_pin_level(sck_pin, IOPORT_PIN_LEVEL_HIGH);
+
+ usart_set_mode(usart, USART_CMODE_MSPI_gc);
+
+ if (opt->spimode == 1 || opt->spimode == 3) {
+ usart->CTRLC |= USART_UCPHA_bm;
+ } else {
+ usart->CTRLC &= ~USART_UCPHA_bm;
+ }
+ if (opt->data_order) {
+ (usart)->CTRLC |= USART_DORD_bm;
+ } else {
+ (usart)->CTRLC &= ~USART_DORD_bm;
+ }
+
+ usart_spi_set_baudrate(usart, opt->baudrate, sysclk_get_per_hz());
+ usart_tx_enable(usart);
+ usart_rx_enable(usart);
+}
+
+/**
+ * \brief Send a data with the USART module
+ *
+ * This function outputs a data using the USART module.
+ *
+ * \param usart The USART module.
+ * \param c The data to send.
+ *
+ * \return STATUS_OK
+ */
+enum status_code usart_putchar(USART_t *usart, uint8_t c)
+{
+ while (usart_data_register_is_empty(usart) == false) {
+ }
+
+ (usart)->DATA = c;
+ return STATUS_OK;
+}
+
+/**
+ * \brief Receive a data with the USART module
+ *
+ * This function returns the received data from the USART module.
+ *
+ * \param usart The USART module.
+ *
+ * \return The received data.
+ */
+uint8_t usart_getchar(USART_t *usart)
+{
+ while (usart_rx_is_complete(usart) == false) {
+ }
+
+ return ((uint8_t)(usart)->DATA);
+}
+
+/**
+ * \brief Get the offset for lookup in the baudrate table
+ *
+ * \param baud The requested baudrate
+ *
+ * \return The baudrate offset in PROGMEM table
+ * \retval USART_BAUD_UNDEFINED for baudrates not in lookup table
+ */
+static uint8_t usart_get_baud_offset(uint32_t baud)
+{
+ switch (baud) {
+ case 1200:
+ return (uint8_t)USART_BAUD_1200;
+
+ case 2400:
+ return (uint8_t)USART_BAUD_2400;
+
+ case 4800:
+ return (uint8_t)USART_BAUD_4800;
+
+ case 9600:
+ return (uint8_t)USART_BAUD_9600;
+
+ case 19200:
+ return (uint8_t)USART_BAUD_19200;
+
+ case 38400:
+ return (uint8_t)USART_BAUD_38400;
+
+ case 57600:
+ return (uint8_t)USART_BAUD_57600;
+
+ default:
+ return (uint8_t)USART_BAUD_UNDEFINED;
+ }
+}
+
+/**
+ * \brief Set the baudrate by setting the BSEL and BSCALE values in the USART
+ *
+ * This function sets the selected BSEL and BSCALE value in the BAUDCTRL
+ * registers with BSCALE 0. For calculation options, see table 21-1 in XMEGA A
+ * manual.
+ *
+ * \param usart The USART module.
+ * \param bsel Calculated BSEL value.
+ * \param bscale Calculated BSEL value.
+ *
+ */
+void usart_set_bsel_bscale_value(USART_t *usart, uint16_t bsel, uint8_t bscale)
+{
+ (usart)->BAUDCTRLA = (uint8_t)(bsel);
+ (usart)->BAUDCTRLB = (uint8_t)(((bsel >> 8) & 0X0F) | (bscale << 4));
+}
+
+/**
+ * \brief Set the baudrate using precalculated BAUDCTRL values from PROGMEM
+ *
+ * \note This function only works for cpu_hz 2Mhz or 32Mhz and baudrate values
+ * 1200, 2400, 4800, 9600, 19200, 38400 and 57600.
+ *
+ * \param usart The USART module.
+ * \param baud The baudrate.
+ * \param cpu_hz The CPU frequency.
+ *
+ */
+void usart_set_baudrate_precalculated(USART_t *usart, uint32_t baud,
+ uint32_t cpu_hz)
+{
+ uint8_t baud_offset;
+ uint16_t baudctrl = 0;
+
+ baud_offset = usart_get_baud_offset(baud);
+
+ if (cpu_hz == 2000000UL) {
+ baudctrl = PROGMEM_READ_WORD(baudctrl_2mhz + baud_offset);
+ } else if (cpu_hz == 32000000UL) {
+ baudctrl = PROGMEM_READ_WORD(baudctrl_32mhz + baud_offset);
+ } else {
+ /* Error, system clock speed or USART baud rate is not supported
+ * by the look-up table */
+ Assert(false);
+ }
+
+ if (baud_offset != USART_BAUD_UNDEFINED) {
+ (usart)->BAUDCTRLB = (uint8_t)((uint16_t)baudctrl);
+ (usart)->BAUDCTRLA = (uint8_t)((uint16_t)baudctrl >> 8);
+ }
+}
+
+/**
+ * \brief Set the baudrate value in the USART module
+ *
+ * This function sets the baudrate register with scaling regarding the CPU
+ * frequency and makes sure the baud rate is supported by the hardware.
+ * The function can be used if you don't want to calculate the settings
+ * yourself or changes to baudrate at runtime is required.
+ *
+ * \param usart The USART module.
+ * \param baud The baudrate.
+ * \param cpu_hz The CPU frequency.
+ *
+ * \retval true if the hardware supports the baud rate
+ * \retval false if the hardware does not support the baud rate (i.e. it's
+ * either too high or too low.)
+ */
+bool usart_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz)
+{
+ int8_t exp;
+ uint32_t div;
+ uint32_t limit;
+ uint32_t ratio;
+ uint32_t min_rate;
+ uint32_t max_rate;
+
+ /*
+ * Check if the hardware supports the given baud rate
+ */
+ /* 8 = (2^0) * 8 * (2^0) = (2^BSCALE_MIN) * 8 * (BSEL_MIN) */
+ max_rate = cpu_hz / 8;
+ /* 4194304 = (2^7) * 8 * (2^12) = (2^BSCALE_MAX) * 8 * (BSEL_MAX+1) */
+ min_rate = cpu_hz / 4194304;
+
+ if (!((usart)->CTRLB & USART_CLK2X_bm)) {
+ max_rate /= 2;
+ min_rate /= 2;
+ }
+
+ if ((baud > max_rate) || (baud < min_rate)) {
+ return false;
+ }
+
+ /* Check if double speed is enabled. */
+ if (!((usart)->CTRLB & USART_CLK2X_bm)) {
+ baud *= 2;
+ }
+
+ /* Find the lowest possible exponent. */
+ limit = 0xfffU >> 4;
+ ratio = cpu_hz / baud;
+
+ for (exp = -7; exp < 7; exp++) {
+ if (ratio < limit) {
+ break;
+ }
+
+ limit <<= 1;
+
+ if (exp < -3) {
+ limit |= 1;
+ }
+ }
+
+ /*
+ * Depending on the value of exp, scale either the input frequency or
+ * the target baud rate. By always scaling upwards, we never introduce
+ * any additional inaccuracy.
+ *
+ * We are including the final divide-by-8 (aka. right-shift-by-3) in
+ * this operation as it ensures that we never exceeed 2**32 at any
+ * point.
+ *
+ * The formula for calculating BSEL is slightly different when exp is
+ * negative than it is when exp is positive.
+ */
+ if (exp < 0) {
+ /* We are supposed to subtract 1, then apply BSCALE. We want to
+ * apply BSCALE first, so we need to turn everything inside the
+ * parenthesis into a single fractional expression.
+ */
+ cpu_hz -= 8 * baud;
+
+ /* If we end up with a left-shift after taking the final
+ * divide-by-8 into account, do the shift before the divide.
+ * Otherwise, left-shift the denominator instead (effectively
+ * resulting in an overall right shift.)
+ */
+ if (exp <= -3) {
+ div = ((cpu_hz << (-exp - 3)) + baud / 2) / baud;
+ } else {
+ baud <<= exp + 3;
+ div = (cpu_hz + baud / 2) / baud;
+ }
+ } else {
+ /* We will always do a right shift in this case, but we need to
+ * shift three extra positions because of the divide-by-8.
+ */
+ baud <<= exp + 3;
+ div = (cpu_hz + baud / 2) / baud - 1;
+ }
+
+ (usart)->BAUDCTRLB = (uint8_t)(((div >> 8) & 0X0F) | (exp << 4));
+ (usart)->BAUDCTRLA = (uint8_t)div;
+
+ return true;
+}
+
+/**
+ * \brief Set the baudrate value in the USART_SPI module
+ *
+ * This function sets the baudrate register regarding the CPU frequency.
+ *
+ * \param usart The USART(SPI) module.
+ * \param baud The baudrate.
+ * \param cpu_hz The CPU frequency.
+ */
+void usart_spi_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz)
+{
+ uint16_t bsel_value;
+
+ /* Check if baudrate is less than the maximim limit specified in
+ * datasheet */
+ if (baud < (cpu_hz / 2)) {
+ bsel_value = (cpu_hz / (baud * 2)) - 1;
+ } else {
+ /* If baudrate is not within the specfication in datasheet,
+ * assign maximum baudrate possible for the current CPU frequency */
+ bsel_value = 0;
+ }
+
+ (usart)->BAUDCTRLB = (uint8_t)((~USART_BSCALE_gm) & (bsel_value >> 8));
+ (usart)->BAUDCTRLA = (uint8_t)(bsel_value);
+}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.c.REMOVED.git-id
deleted file mode 100644
index a106d2d3..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a4bc1421538c0809a45eafa36373c24a2deddb0e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.h
new file mode 100644
index 00000000..8a3cb986
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.h
@@ -0,0 +1,558 @@
+/**
+ * \file
+ *
+ * \brief USART driver for AVR XMEGA.
+ *
+ * This file contains basic functions for the AVR XMEGA USART, with support for all
+ * modes, settings and clock speeds.
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _USART_H_
+#define _USART_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "compiler.h"
+#include "pmic.h"
+
+/**
+ * \defgroup usart_group USART module (USART)
+ *
+ * See \ref xmega_usart_quickstart.
+ *
+ * This is a driver for configuring, enabling, disabling and use of the on-chip
+ * USART.
+ *
+ * \section dependencies Dependencies
+ *
+ * The USART module depends on the following modules:
+ * - \ref sysclk_group for peripheral clock control.
+ * - \ref port_driver_group for peripheral io port control.
+ *
+ * @{
+ */
+
+//! Offset in lookup table for baudrate 1200
+#define USART_BAUD_1200 0x00
+//! Offset in lookup table for baudrate 2400
+#define USART_BAUD_2400 0x01
+//! Offset in lookup table for baudrate 4800
+#define USART_BAUD_4800 0x02
+//! Offset in lookup table for baudrate 9600
+#define USART_BAUD_9600 0x03
+//! Offset in lookup table for baudrate 19200
+#define USART_BAUD_19200 0x04
+//! Offset in lookup table for baudrate 38400
+#define USART_BAUD_38400 0x05
+//! Offset in lookup table for baudrate 57600
+#define USART_BAUD_57600 0x06
+//! Baudrate not in lookup table
+#define USART_BAUD_UNDEFINED 0xFF
+
+//! Lookup table containing baudctrl values for CPU frequency 2 Mhz
+static PROGMEM_DECLARE(uint16_t, baudctrl_2mhz[]) = {
+ 0xE5BC, // Baud: 1200
+ 0xC5AC, // Baud: 2400
+ 0x859C, // Baud: 4800
+ 0x0396, // Baud: 9600
+ 0xC192, // Baud: 19200
+ 0x2191, // Baud: 38400
+ 0x9690, // Baud: 57600
+};
+
+//! Lookup table containing baudctrl values for CPU frequency 32 Mhz
+static PROGMEM_DECLARE(uint16_t, baudctrl_32mhz[]) = {
+ 0x031D, // Baud: 1200
+ 0x01ED, // Baud: 2400
+ 0xFDDC, // Baud: 4800
+ 0xF5CC, // Baud: 9600
+ 0xE5BC, // Baud: 19200
+ 0xC5AC, // Baud: 38400
+ 0x6EA8, // Baud: 57600
+};
+
+
+//! Input parameters when initializing RS232 and similar modes.
+typedef struct usart_rs232_options {
+ //! Set baud rate of the USART (unused in slave modes).
+ uint32_t baudrate;
+
+ //! Number of bits to transmit as a character (5 to 9).
+ USART_CHSIZE_t charlength;
+
+ //! Parity type: USART_PMODE_DISABLED_gc, USART_PMODE_EVEN_gc,
+ //! USART_PMODE_ODD_gc.
+ USART_PMODE_t paritytype;
+
+ //! Number of stop bits between two characters:
+ //! true: 2 stop bits
+ //! false: 1 stop bit
+ bool stopbits;
+
+} usart_rs232_options_t;
+
+//! Input parameters when initializing SPI master mode.
+typedef struct usart_spi_options {
+ //! Set baud rate of the USART in SPI mode.
+ uint32_t baudrate;
+
+ //! SPI transmission mode.
+ uint8_t spimode;
+
+ uint8_t data_order;
+} usart_spi_options_t;
+
+//! USART interrupt levels
+enum usart_int_level_t {
+ USART_INT_LVL_OFF = 0x00,
+ USART_INT_LVL_LO = 0x01,
+ USART_INT_LVL_MED = 0x02,
+ USART_INT_LVL_HI = 0x03,
+};
+
+/**
+ * \brief Enable USART receiver.
+ *
+ * \param usart Pointer to the USART module
+ */
+static inline void usart_rx_enable(USART_t *usart)
+{
+ (usart)->CTRLB |= USART_RXEN_bm;
+}
+
+/**
+ * \brief Disable USART receiver.
+ *
+ * \param usart Pointer to the USART module.
+ */
+static inline void usart_rx_disable(USART_t *usart)
+{
+ (usart)->CTRLB &= ~USART_RXEN_bm;
+}
+
+/**
+ * \brief Configure the USART frame format.
+ *
+ * Sets the frame format, Frame Size, parity mode and number of stop bits.
+ *
+ * \param usart Pointer to the USART module
+ * \param charSize The character size. Use USART_CHSIZE_t type.
+ * \param parityMode The parity Mode. Use USART_PMODE_t type.
+ * \param twoStopBits Enable two stop bit mode. Use bool type.
+ */
+static inline void usart_format_set(USART_t *usart, USART_CHSIZE_t charSize,
+ USART_PMODE_t parityMode, bool twoStopBits)
+{
+ (usart)->CTRLC = (uint8_t)charSize | parityMode
+ | (twoStopBits ? USART_SBMODE_bm : 0);
+}
+
+/**
+ * \brief Enable USART transmitter.
+ *
+ * \param usart Pointer to the USART module.
+ */
+static inline void usart_tx_enable(USART_t *usart)
+{
+ (usart)->CTRLB |= USART_TXEN_bm;
+}
+
+/**
+ * \brief Disable USART transmitter.
+ *
+ * \param usart Pointer to the USART module.
+ */
+static inline void usart_tx_disable(USART_t *usart)
+{
+ (usart)->CTRLB &= ~USART_TXEN_bm;
+}
+
+/**
+ * \brief Set USART RXD interrupt level.
+ *
+ * Sets the interrupt level on RX Complete interrupt.
+ *
+ * \param usart Pointer to the USART module.
+ * \param level Interrupt level of the RXD interrupt.
+ */
+static inline void usart_set_rx_interrupt_level(USART_t *usart,
+ enum usart_int_level_t level)
+{
+ (usart)->CTRLA = ((usart)->CTRLA & ~USART_RXCINTLVL_gm) |
+ (level << USART_RXCINTLVL_gp);
+}
+
+/**
+ * \brief Set USART TXD interrupt level.
+ *
+ * Sets the interrupt level on TX Complete interrupt.
+ *
+ * \param usart Pointer to the USART module.
+ * \param level Interrupt level of the TXD interrupt.
+ */
+static inline void usart_set_tx_interrupt_level(USART_t *usart,
+ enum usart_int_level_t level)
+{
+ (usart)->CTRLA = ((usart)->CTRLA & ~USART_TXCINTLVL_gm) |
+ (level << USART_TXCINTLVL_gp);
+}
+
+/**
+ * \brief Set USART DRE interrupt level.
+ *
+ * Sets the interrupt level on Data Register interrupt.
+ *
+ * \param usart Pointer to the USART module.
+ * \param level Interrupt level of the DRE interrupt.
+ * Use USART_DREINTLVL_t type.
+ */
+static inline void usart_set_dre_interrupt_level(USART_t *usart,
+ enum usart_int_level_t level)
+{
+ (usart)->CTRLA = ((usart)->CTRLA & ~USART_DREINTLVL_gm) |
+ (level << USART_DREINTLVL_gp);
+}
+
+/**
+ * \brief Set the mode the USART run in.
+ *
+ * Set the mode the USART run in. The default mode is asynchronous mode.
+ *
+ * \param usart Pointer to the USART module register section.
+ * \param usartmode Selects the USART mode. Use USART_CMODE_t type.
+ *
+ * USART modes:
+ * - 0x0 : Asynchronous mode.
+ * - 0x1 : Synchronous mode.
+ * - 0x2 : IrDA mode.
+ * - 0x3 : Master SPI mode.
+ */
+static inline void usart_set_mode(USART_t *usart, USART_CMODE_t usartmode)
+{
+ (usart)->CTRLC = ((usart)->CTRLC & (~USART_CMODE_gm)) | usartmode;
+}
+
+/**
+ * \brief Check if data register empty flag is set.
+ *
+ * \param usart The USART module.
+ */
+static inline bool usart_data_register_is_empty(USART_t * usart)
+{
+ return (usart)->STATUS & USART_DREIF_bm;
+}
+
+/**
+ * \brief Checks if the RX complete interrupt flag is set.
+ *
+ * Checks if the RX complete interrupt flag is set.
+ *
+ * \param usart The USART module.
+ */
+static inline bool usart_rx_is_complete(USART_t * usart)
+{
+ return (usart)->STATUS & USART_RXCIF_bm;
+}
+
+/**
+ * \brief Checks if the TX complete interrupt flag is set.
+ *
+ * Checks if the TX complete interrupt flag is set.
+ *
+ * \param usart The USART module.
+ */
+static inline bool usart_tx_is_complete(USART_t * usart)
+{
+ return (usart)->STATUS & USART_TXCIF_bm;
+}
+
+/**
+ * \brief Clear TX complete interrupt flag.
+ *
+ * \param usart The USART module.
+ */
+static inline void usart_clear_tx_complete(USART_t * usart)
+{
+ (usart)->STATUS = USART_TXCIF_bm;
+}
+
+/**
+ * \brief Clear RX complete interrupt flag.
+ *
+ * \param usart The USART module.
+ */
+static inline void usart_clear_rx_complete(USART_t *usart)
+{
+ (usart)->STATUS = USART_RXCIF_bm;
+}
+
+/**
+ * \brief Write a data to the USART data register.
+ *
+ * \param usart The USART module.
+ * \param txdata The data to be transmitted.
+ */
+static inline void usart_put(USART_t * usart, uint8_t txdata)
+{
+ (usart)->DATA = txdata;
+}
+
+/**
+ * \brief Read a data to the USART data register.
+ *
+ * \param usart The USART module.
+ *
+ * \return The received data
+ */
+static inline uint8_t usart_get(USART_t * usart)
+{
+ return (usart)->DATA;
+}
+
+/**
+ * \brief Performs a data transfer on the USART in SPI mode.
+ *
+ * \param usart The USART module.
+ * \param txdata The data to be transmitted.
+ *
+ * \return The received data
+ */
+static inline uint8_t usart_spi_transmit(USART_t * usart,
+ uint8_t txdata)
+{
+ while (usart_data_register_is_empty(usart) == false);
+ usart_put(usart, txdata);
+ while (!usart_tx_is_complete(usart));
+ usart_clear_tx_complete(usart);
+ return usart_get(usart);
+}
+
+bool usart_init_rs232(USART_t *usart, const usart_rs232_options_t *opt);
+void usart_init_spi(USART_t * usart, const usart_spi_options_t * opt);
+
+enum status_code usart_putchar(USART_t * usart, uint8_t c);
+uint8_t usart_getchar(USART_t * usart);
+
+void usart_set_bsel_bscale_value(USART_t *usart, uint16_t bsel, uint8_t bscale);
+void usart_set_baudrate_precalculated(USART_t *usart, uint32_t baud,
+ uint32_t cpu_hz);
+bool usart_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz);
+void usart_spi_set_baudrate(USART_t * usart, uint32_t baud, uint32_t cpu_hz);
+//! @}
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * \page xmega_usart_quickstart Quick start guide for USART module
+ *
+ * This is the quick start guide for the \ref usart_group "USART module", with
+ * step-by-step instructions on how to configure and use the driver in a
+ * selection of use cases.
+ *
+ * The use cases contain several code fragments. The code fragments in the
+ * steps for setup can be copied into a custom initialization function, while
+ * the steps for usage can be copied into, e.g., the main application function.
+ *
+ * \section usart_basic_use_case Basic use case
+ * \section usart_use_cases USART use cases
+ * - \ref usart_basic_use_case
+ * - \subpage usart_use_case_1
+ *
+ * \section usart_basic_use_case Basic use case - transmit a character
+ * In this use case, the USART module is configured for:
+ * - Using USARTD0
+ * - Baudrate: 9600
+ * - Character length: 8 bit
+ * - Parity mode: Disabled
+ * - Stop bit: None
+ * - RS232 mode
+ *
+ * \section usart_basic_use_case_setup Setup steps
+ *
+ * \subsection usart_basic_use_case_setup_prereq Prerequisites
+ * -# \ref sysclk_group
+ * \subsection usart_basic_use_case_setup_code Example code
+ * The following configuration must be added to the project (typically to a
+ * conf_usart.h file, but it can also be added to your main application file.)
+ * \code
+ #define USART_SERIAL &USARTD0
+ #define USART_SERIAL_BAUDRATE 9600
+ #define USART_SERIAL_CHAR_LENGTH USART_CHSIZE_8BIT_gc
+ #define USART_SERIAL_PARITY USART_PMODE_DISABLED_gc
+ #define USART_SERIAL_STOP_BIT false
+\endcode
+ *
+ * Add to application initialization:
+ * \code
+ sysclk_init();
+ static usart_rs232_options_t USART_SERIAL_OPTIONS = {
+ .baudrate = USART_SERIAL_BAUDRATE,
+ .charlength = USART_SERIAL_CHAR_LENGTH,
+ .paritytype = USART_SERIAL_PARITY,
+ .stopbits = USART_SERIAL_STOP_BIT
+ };
+ sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm);
+ usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS);
+\endcode
+ *
+ * \subsection usart_basic_use_case_setup_flow Workflow
+ * -# Initialize system clock:
+ * - \code sysclk_init(); \endcode
+ * - \note Not always required, but since the \ref usart_group driver is
+ * dependent on \ref sysclk_group it is good practise to initialize
+ * this module.
+ * -# Create USART options struct:
+ * - \code
+ static usart_rs232_options_t USART_SERIAL_OPTIONS = {
+ .baudrate = USART_SERIAL_BAUDRATE,
+ .charlength = USART_SERIAL_CHAR_LENGTH,
+ .paritytype = USART_SERIAL_PARITY,
+ .stopbits = USART_SERIAL_STOP_BIT
+ };
+\endcode
+ * -# Enable the clock for the USART module:
+ * - \code sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm); \endcode
+ * -# Initialize in RS232 mode:
+ * - \code usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS);
+\endcode
+ *
+ * \section usart_basic_use_case_usage Usage steps
+ *
+ * \subsection usart_basic_use_case_usage_code Example code
+ * Add to application C-file:
+ * \code
+ usart_putchar(USART_SERIAL, 'a');
+\endcode
+ *
+ * \subsection usart_basic_use_case_usage_flow Workflow
+ * -# Send an 'a' character via USART
+ * - \code usart_putchar(USART_SERIAL, 'a'); \endcode
+ */
+
+/**
+ * \page usart_use_case_1 USART receive character and echo back
+ *
+ * In this use case, the USART module is configured for:
+ * - Using USARTD0
+ * - Baudrate: 9600
+ * - Character length: 8 bit
+ * - Parity mode: Disabled
+ * - Stop bit: None
+ * - RS232 mode
+ *
+ * The use case waits for a received character on the configured USART and
+ * echoes the character back to the same USART.
+ *
+ * \section usart_use_case_1_setup Setup steps
+ *
+ * \subsection usart_use_case_1_setup_prereq Prerequisites
+ * -# \ref sysclk_group
+ *
+ * \subsection usart_use_case_1_setup_code Example code
+ * -# The following configuration must be added to the project (typically to a
+ * conf_usart.h file, but it can also be added to your main application file.):
+ * \code
+ #define USART_SERIAL &USARTD0
+ #define USART_SERIAL_BAUDRATE 9600
+ #define USART_SERIAL_CHAR_LENGTH USART_CHSIZE_8BIT_gc
+ #define USART_SERIAL_PARITY USART_PMODE_DISABLED_gc
+ #define USART_SERIAL_STOP_BIT false
+\endcode
+ *
+ * A variable for the received byte must be added:
+ * \code uint8_t received_byte; \endcode
+ *
+ * Add to application initialization:
+ * \code
+ sysclk_init();
+ static usart_rs232_options_t USART_SERIAL_OPTIONS = {
+ .baudrate = USART_SERIAL_BAUDRATE,
+ .charlength = USART_SERIAL_CHAR_LENGTH,
+ .paritytype = USART_SERIAL_PARITY,
+ .stopbits = USART_SERIAL_STOP_BIT
+ };
+ sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm);
+ usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS);
+\endcode
+ *
+ * \subsection usart_use_case_1_setup_flow Workflow
+ * -# Initialize system clock:
+ * - \code sysclk_init(); \endcode
+ * - \note Not always required, but since the \ref usart_group driver is
+ * dependent on \ref sysclk_group it is good practise to initialize
+ * this module.
+ * -# Create USART options struct:
+ * - \code
+ static usart_rs232_options_t USART_SERIAL_OPTIONS = {
+ .baudrate = USART_SERIAL_BAUDRATE,
+ .charlength = USART_SERIAL_CHAR_LENGTH,
+ .paritytype = USART_SERIAL_PARITY,
+ .stopbits = USART_SERIAL_STOP_BIT
+ };
+\endcode
+ * -# Enable the clock for the USART module:
+ * - \code sysclk_enable_module(SYSCLK_PORT_D, PR_USART0_bm); \endcode
+ * -# Initialize in RS232 mode:
+ * - \code usart_init_rs232(USART_SERIAL, &USART_SERIAL_OPTIONS);
+\endcode
+ *
+ * \section usart_use_case_1_usage Usage steps
+ *
+ * \subsection usart_use_case_1_usage_code Example code
+ * Add to, e.g., main loop in application C-file:
+ * \code
+ received_byte = usart_getchar(USART_SERIAL);
+ usart_putchar(USART_SERIAL, received_byte);
+\endcode
+ *
+ * \subsection usart_use_case_1_usage_flow Workflow
+ * -# Wait for reception of a character:
+ * - \code received_byte = usart_getchar(USART_SERIAL); \endcode
+ * -# Echo the character back:
+ * - \code usart_putchar(USART_SERIAL, received_byte); \endcode
+ */
+
+#endif // _USART_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.h.REMOVED.git-id
deleted file mode 100644
index 0dacd37d..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usart/usart.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8a3cb98638b9d0e769d90a18e60674f3aa3c2b49
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c
new file mode 100644
index 00000000..a0b77ded
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c
@@ -0,0 +1,1460 @@
+/**
+ * \file
+ *
+ * \brief USB Device driver
+ * Compliance with common driver UDD
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#include "conf_usb.h"
+
+// Read Modify Write opcode is implemented after IAR AVR 5.51
+#ifdef __ICCAVR__
+# if (__VER__ <= 551 || (__VER__ <= 611 && XMEGA_A1U) )
+# undef USB_WORKAROUND_DO_NOT_USE_RMW
+# define USB_WORKAROUND_DO_NOT_USE_RMW
+# endif
+#endif
+
+#include "sysclk.h"
+#include "udd.h"
+#include "usb_device.h"
+#include
+
+#ifndef UDD_NO_SLEEP_MGR
+#include "sleepmgr.h"
+#endif
+
+#ifndef UDD_USB_INT_LEVEL
+// By default USB interrupt have low priority
+# define UDD_USB_INT_LEVEL USB_INTLVL_MED_gc
+#endif
+
+
+
+#ifdef USB_DEVICE_HS_SUPPORT
+#error This product does not support high speed mode, please remove define USB_DEVICE_HS_SUPPORT in conf_usb.h
+#endif
+
+////////////////////////////////////////////////////
+// USBB Device low-level driver (UDD)
+////////////////////////////////////////////////////
+/**
+ * \ingroup udd_group
+ * \defgroup udd_xmega_usb_group Xmega USB Device Driver
+ *
+ * \section USBB_CONF USBB Custom configuration
+ * The following USBB driver configuration must be included in the conf_usb.h
+ * file of the application.
+ *
+ * UDD_USB_INT_LEVEL
+ * Option to change the interrupt priority (USB_INTLVL_x_gc)
+ * by default USB_INTLVL_LO_gc (recommended).
+ *
+ * \section Callbacks management
+ * The USB driver is fully managed by interrupt and does not request periodic
+ * task. Thereby, the USB events use callbacks to transfer the information.
+ * The callbacks are declared in static during compilation or in variable during
+ * code execution.
+ *
+ * Static declarations defined in conf_usb.h:
+ * - UDC_VBUS_EVENT(bool b_present)
+ * To signal Vbus level change
+ * - UDC_SUSPEND_EVENT()
+ * Called when USB bus enter in suspend mode
+ * - UDC_RESUME_EVENT()
+ * Called when USB bus is wakeup
+ * - UDC_SOF_EVENT()
+ * Called for each received SOF, Note: Each 1ms in HS/FS mode only.
+ *
+ * Dynamic callbacks, called "endpoint job" , are registered
+ * in udd_ep_job_t structure via the following functions:
+ * - udd_ep_run()
+ * To call it when a transfer is finish
+ * - udd_ep_wait_stall_clear()
+ * To call it when a endpoint halt is disabled
+ *
+ * \section Power mode management
+ * The Sleep modes authorized :
+ * - in USB IDLE state, the USB needs of USB clock and authorizes up to IDLE mode
+ * - in USB SUSPEND state, the USB no needs USB clock but requests a minimum
+ * clock restart timing. Thus, it authorizes up to POWER_DOWN or STANDBY mode.
+ *
+ * The USB_SLEEP_MODE_USB_IDLE equals SLEEPMGR_IDLE.
+ *
+ * The USB_SLEEP_MODE_USB_SUSPEND depends on USB clock startup timing:
+ * | Clock Startup | Sleep mode authorized |
+ * | >10ms | SLEEPMGR_STDBY |
+ * | <=10ms | SLEEPMGR_PDOWN |
+ *
+ * @{
+ */
+
+
+// Check USB Device configuration
+#ifndef USB_DEVICE_EP_CTRL_SIZE
+# error USB_DEVICE_EP_CTRL_SIZE not defined
+#endif
+#ifndef USB_DEVICE_MAX_EP
+# error USB_DEVICE_MAX_EP not defined
+#endif
+
+
+/**
+ * \name Power management routine.
+ */
+//@{
+
+
+#ifndef UDD_NO_SLEEP_MGR
+
+//! Definition of sleep levels
+#if ((defined USB_DEVICE_HS_SUPPORT) && (USBCLK_STARTUP_TIMEOUT>3000)) \
+ || ((!defined USB_DEVICE_HS_SUPPORT) && (USBCLK_STARTUP_TIMEOUT>10000))
+# define USBC_SLEEP_MODE_USB_SUSPEND SLEEPMGR_IDLE
+#else
+# define USBC_SLEEP_MODE_USB_SUSPEND SLEEPMGR_PDOWN
+#endif
+#define USBC_SLEEP_MODE_USB_IDLE SLEEPMGR_IDLE
+
+//! State of USB line
+static bool udd_b_idle;
+
+
+/*! \brief Authorize or not the CPU powerdown mode
+ *
+ * \param b_enable true to authorize powerdown mode
+ */
+static void udd_sleep_mode(bool b_idle)
+{
+ if (!b_idle && udd_b_idle) {
+ sleepmgr_unlock_mode(USBC_SLEEP_MODE_USB_IDLE);
+ }
+ if (b_idle && !udd_b_idle) {
+ sleepmgr_lock_mode(USBC_SLEEP_MODE_USB_IDLE);
+ }
+ udd_b_idle = b_idle;
+}
+#else
+
+static void udd_sleep_mode(bool b_idle) {
+}
+#endif // UDD_NO_SLEEP_MGR
+
+//@}
+
+/**
+ * \brief USB SRAM data about fifo, endpoint descriptor table and frame number
+ *
+ * The content of the USB SRAM can be:
+ * - modified by USB hardware by interface to signal endpoint status.
+ * Thereby, it is read by software.
+ * - modified by USB software to control endpoint.
+ * Thereby, it is read by hardware.
+ * This data section is volatile and the specific opcode read/modify/write must be used.
+ *
+ * @{
+ */
+struct udd_sram_data {
+#if XMEGA_A1U
+# if (0!=((USB_DEVICE_MAX_EP+1)%4))
+ uint8_t padding_align[16 - ((USB_DEVICE_MAX_EP + 1) *
+ sizeof(uint32_t)) % 16];
+# endif
+#endif
+ uint32_t fifo[USB_DEVICE_MAX_EP + 1];
+ USB_EP_t ep_ctrl[2 * (USB_DEVICE_MAX_EP + 1)];
+ uint16_t frame_number;
+};
+#if XMEGA_A1U
+COMPILER_ALIGNED(16)
+#else
+COMPILER_ALIGNED(4) //! Caution seems GCC does not handle 2 alignment properly
+#endif
+static volatile struct udd_sram_data udd_sram;
+#define UDD_EP_t USB_EP_t volatile
+
+// @}
+
+/**
+ * \name initialization of endpoint
+ */
+//@{
+/**
+ * \brief Configures and enables an endpoint
+ *
+ * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT).
+ * \param bmAttributes Attribute of endpoint declared in descriptor.
+ * \param MaxEndpointSize Endpoint size maximum
+ */
+static void udd_ep_init(udd_ep_id_t ep, uint8_t bmAttributes,
+ uint16_t MaxEndpointSize);
+
+/**
+ * \brief Returns a pointer on endpoint control SRAM corresponding at endpoint number
+ *
+ * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT).
+ *
+ * \return endpoint descriptor index
+ */
+static UDD_EP_t *udd_ep_get_ctrl(udd_ep_id_t ep);
+//@}
+
+
+/**
+ * \name Control endpoint low level management routine.
+ *
+ * This function performs control endpoint management.
+ * It handle the SETUP/DATA/HANDSHAKE phases of a control transaction.
+ */
+//@{
+
+//! Global variable to give and record information about setup request management
+udd_ctrl_request_t udd_g_ctrlreq;
+
+//! Bit definitions about endpoint control state machine for udd_ep_control_state
+typedef enum {
+ UDD_EPCTRL_SETUP = 0, //!< Wait a SETUP packet
+ UDD_EPCTRL_DATA_OUT = 1, //!< Wait a OUT data packet
+ UDD_EPCTRL_DATA_IN = 2, //!< Wait a IN data packet
+ UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP = 3, //!< Wait a IN ZLP packet
+ UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP = 4, //!< Wait a OUT ZLP packet
+ UDD_EPCTRL_STALL_REQ = 5, //!< STALL enabled on IN & OUT packet
+} udd_ctrl_ep_state_t;
+
+//! State of the endpoint control management
+static udd_ctrl_ep_state_t udd_ep_control_state;
+//! Total number of data received/sent during data packet phase with previous payload buffers
+static uint16_t udd_ctrl_prev_payload_nb_trans;
+//! Number of data received/sent to/from udd_g_ctrlreq.payload buffer
+static uint16_t udd_ctrl_payload_nb_trans;
+
+/**
+ * \brief Buffer to store the data received on control endpoint (SETUP/OUT endpoint 0)
+ *
+ * Used to avoid a RAM buffer overflow in case of the payload buffer
+ * is smaller than control endpoint size
+ */
+static uint8_t udd_ctrl_buffer[USB_DEVICE_EP_CTRL_SIZE];
+
+/**
+ * \brief Reset control endpoint management
+ *
+ * Called after a USB line reset or at the end of SETUP request (after ZLP)
+ */
+static void udd_ctrl_init(void);
+
+//! \brief Managed reception of SETUP packet on control endpoint
+static void udd_ctrl_setup_received(void);
+
+//! \brief Managed reception of IN packet on control endpoint
+static void udd_ctrl_in_sent(void);
+
+//! \brief Managed reception of OUT packet on control endpoint
+static void udd_ctrl_out_received(void);
+
+//! \brief Managed underflow event of IN packet on control endpoint
+//! It is used to detect a DATA phase stopped by the host via a ZLP request.
+//! This is mandatory for chapter 8 compliance
+static void udd_ctrl_underflow(void);
+
+//! \brief Managed overflow event of OUT packet on control endpoint
+//! It is used to detect a DATA phase stopped by the host via a ZLP request.
+//! This is mandatory for chapter 8 compliance
+static void udd_ctrl_overflow(void);
+
+//! \brief Managed stall event of IN/OUT packet on control endpoint
+static void udd_ctrl_stall_data(void);
+
+//! \brief Send a ZLP IN on control endpoint
+static void udd_ctrl_send_zlp_in(void);
+
+//! \brief Send a ZLP OUT on control endpoint
+static void udd_ctrl_send_zlp_out(void);
+
+//! \brief Call callback associated to setup request
+static void udd_ctrl_endofrequest(void);
+
+/**
+ * \brief Sub interrupt routine to manage error on control endpoint
+ *
+ * \return \c 1 if an error about control endpoint is occurred, otherwise \c 0.
+ */
+static bool udd_ctrl_interrupt_error(void);
+
+/**
+ * \brief Sub interrupt routine to manage a SETUP transfer complete on control endpoint
+ *
+ * \return \c 1 if an SETUP transfer complete about control endpoint is occurred,
+ * otherwise \c 0.
+ */
+static bool udd_ctrl_interrupt_tc_setup(void);
+
+//@}
+
+
+/**
+ * \name Management of bulk/interrupt/isochronous endpoints
+ *
+ * The UDD manages the data transfer on endpoints:
+ * - Start data transfer on endpoint with USB Device DMA
+ * - Send a ZLP packet if requested
+ * - Call callback registered to signal end of transfer
+ * The transfer abort and stall feature are supported.
+ */
+//@{
+#if (0!=USB_DEVICE_MAX_EP)
+
+//! Structure definition about job registered on an endpoint
+typedef struct {
+ //! A job is registered on this endpoint
+ uint8_t busy:1;
+ //! A short packet is requested for this job on endpoint IN
+ uint8_t b_shortpacket:1;
+ //! The cache buffer is currently used on endpoint OUT
+ uint8_t b_use_out_cache_buffer:1;
+ //! Buffer located in internal RAM to send or fill during job
+ uint8_t *buf;
+ //! Size of buffer to send or fill
+ iram_size_t buf_size;
+ //! Total number of data transfered on endpoint
+ iram_size_t nb_trans;
+ union {
+ //! Callback to call at the end of transfer
+ udd_callback_trans_t call_trans;
+ //! Callback to call when the endpoint halt is cleared
+ udd_callback_halt_cleared_t call_nohalt;
+ };
+} udd_ep_job_t;
+
+//! Array to register a job on bulk/interrupt/isochronous endpoint
+static udd_ep_job_t udd_ep_job[USB_DEVICE_MAX_EP * 2];
+
+/**
+ * \brief Buffer to store the data received on bulk/interrupt endpoints
+ *
+ * Used to avoid a RAM buffer overflow in case of the user buffer
+ * is smaller than endpoint size
+ *
+ * \warning The isochronous endpoint is not protected by this system
+ * and the user must always use a buffer corresponding at endpoint size
+ */
+#ifdef USB_DEVICE_LOW_SPEED
+static uint8_t udd_ep_out_cache_buffer[USB_DEVICE_MAX_EP][8];
+#else
+static uint8_t udd_ep_out_cache_buffer[USB_DEVICE_MAX_EP][64];
+#endif
+
+
+/**
+ * \brief Checks endpoint number
+ *
+ * \param ep endpoint number
+ */
+bool udd_ep_is_valid(udd_ep_id_t ep);
+
+/**
+ * \brief Manages transfer complete on bulk/interrupt/isochronous endpoints
+ *
+ * \param ep endpoint number to manage
+ */
+static void udd_ep_trans_complet(udd_ep_id_t ep);
+
+/**
+ * \brief Returns the size of endpoint
+ *
+ * \return the size of current selected endpoint
+ */
+static uint16_t udd_ep_get_size(UDD_EP_t * ep_ctrl);
+
+/**
+ * \brief Returns a pointer on endpoint job corresponding at endpoint number
+ *
+ * \param ep Endpoint number including direction (USB_EP_DIR_IN/USB_EP_DIR_OUT).
+ */
+static udd_ep_job_t *udd_ep_get_job(udd_ep_id_t ep);
+
+#endif // (0!=USB_DEVICE_MAX_EP)
+//@}
+
+
+void udd_enable(void)
+{
+ uint8_t i;
+ irqflags_t flags;
+
+ // Sanity check Silicon revision
+#if AVR8_PART_IS_DEFINED(ATxmega128A1U)
+ // The part ATxmega128A1U Rev. J is not supported, please use new silicon revision.
+ Assert(!(MCU_REVID < 0x0A));
+#endif
+
+#ifdef CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+# if CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC == OSC_ID_USBSOF
+ // RC oscillator calibration via USB Start Of Frame is not available
+ // in low speed mode.
+ // Thus, the calibration is disabled
+ // when USB interface start in low speed mode
+ DFLLRC32M.CTRL = 0;
+# endif
+#endif
+
+#ifdef USB_DEVICE_LOW_SPEED
+ // The USB hardware need of 6MHz in low speed mode
+ sysclk_enable_usb(6);
+ udd_set_low_speed();
+#else
+ // The USB hardware need of 48MHz in full speed mode
+ sysclk_enable_usb(48);
+ udd_set_full_speed();
+#endif
+
+// The XMEGA_A1U does not support the RC calibration through Keepalive (Low speed).
+#if (!defined USB_DEVICE_LOW_SPEED) || (!XMEGA_A1U)
+# ifdef CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC
+# if CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC == OSC_ID_USBSOF
+ // The SOF calibration can be enabled
+ DFLLRC32M.CTRL = DFLL_ENABLE_bm;
+# endif
+# endif
+#endif
+
+ flags = cpu_irq_save();
+
+ // Reset endpoints table
+ for (i = 0; i < ((USB_DEVICE_MAX_EP + 1) * 2); i++) {
+ udd_sram.ep_ctrl[i].CTRL = 0;
+ }
+#if (0!=USB_DEVICE_MAX_EP)
+ // Reset internal variables
+ for (i = 0; i < (USB_DEVICE_MAX_EP * 2); i++) {
+ udd_ep_job[i].busy = false;
+ }
+#endif
+
+ //** Enable USB hardware
+ usb_pad_init();
+ udd_set_nb_max_ep(USB_DEVICE_MAX_EP);
+ udd_enable_interface();
+ udd_enable_store_frame_number();
+#if XMEGA_A1U
+ Assert(((uint16_t)(&udd_sram) & 0x0F) == 0); /* check align on 16bit */
+#else
+ Assert(((uint16_t)(&udd_sram) & 0x01) == 0); /* check align on WORD */
+#endif
+ udd_set_ep_table_addr(udd_sram.ep_ctrl);
+ // Enable TC fifo management
+ udd_enable_fifo();
+ udd_reset_fifo();
+ // Enable Interrupt USB Device
+ udd_enable_interrupt(UDD_USB_INT_LEVEL);
+
+#ifndef UDD_NO_SLEEP_MGR
+ // Initialize the sleep mode authorized for the USB suspend mode
+ udd_b_idle = false;
+ sleepmgr_lock_mode(USBC_SLEEP_MODE_USB_SUSPEND);
+#endif
+
+#ifndef USB_DEVICE_ATTACH_AUTO_DISABLE
+ udd_attach();
+#endif
+ cpu_irq_restore(flags);
+}
+
+
+void udd_disable(void)
+{
+ irqflags_t flags;
+ flags = cpu_irq_save();
+ udd_detach_device();
+ // Disable interface
+ USB_CTRLA = 0;
+ USB_CTRLB = 0;
+ sysclk_disable_usb();
+ udd_sleep_mode(false);
+#ifndef UDD_NO_SLEEP_MGR
+ sleepmgr_unlock_mode(USBC_SLEEP_MODE_USB_SUSPEND);
+#endif
+ cpu_irq_restore(flags);
+}
+
+bool udd_include_vbus_monitoring(void)
+{
+ return false; // No Vbus monitoring
+}
+
+void udd_attach(void)
+{
+ irqflags_t flags;
+ flags = cpu_irq_save();
+
+ // At startup the USB bus state is unknown,
+ // therefore the state is considered IDLE to not miss any USB event
+ udd_sleep_mode(true);
+
+ udd_ack_suspend_event();
+ udd_ack_resume_event();
+ udd_attach_device();
+ // Enable main USB interrupts
+ udd_enable_tc_interrupt();
+ udd_enable_busevt_interrupt();
+ udd_enable_setup_interrupt();
+ udd_enable_start_of_frame_interrupt();
+
+ cpu_irq_restore(flags);
+}
+
+void udd_detach(void)
+{
+ // Detach device from the bus
+ udd_detach_device();
+}
+
+bool udd_is_high_speed(void)
+{
+ return false;
+}
+
+void udd_set_address(uint8_t address)
+{
+ udd_set_device_address(address);
+}
+
+uint8_t udd_getaddress(void)
+{
+ return udd_get_device_address();
+}
+
+uint16_t udd_get_frame_number(void)
+{
+ return udd_sram.frame_number;
+}
+
+uint16_t udd_get_micro_frame_number(void)
+{
+ return 0;
+}
+
+void udd_send_remotewakeup(void)
+{
+#ifndef UDD_NO_SLEEP_MGR
+ if (!udd_b_idle)
+#endif
+ {
+ udd_sleep_mode(true); // Enter in IDLE mode
+ udd_send_remote_wake_up();
+ }
+}
+
+void udd_set_setup_payload( uint8_t *payload, uint16_t payload_size )
+{
+ udd_g_ctrlreq.payload = payload;
+ udd_g_ctrlreq.payload_size = payload_size;
+}
+
+#if (0!=USB_DEVICE_MAX_EP)
+bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes,
+ uint16_t MaxEndpointSize)
+{
+ UDD_EP_t *ep_ctrl;
+ Assert(udd_ep_is_valid(ep));
+
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ if (udd_endpoint_is_enable(ep_ctrl)) {
+ return false; // Already allocated
+ }
+ udd_ep_init(ep, bmAttributes, MaxEndpointSize);
+
+/*
+ // Do not use multipacket mode with isochronous 1023 bytes endpoint
+ if (udd_endpoint_get_type(ep_ctrl)==USB_EP_TYPE_ISOCHRONOUS_gc
+ && (udd_endpoint_get_size_field(ep_ctrl)
+ ==USB_EP_BUFSIZE_1023_gc)) {
+ return true;
+ }*/
+
+ udd_endpoint_set_multipacket(ep_ctrl);
+ return true;
+}
+
+void udd_ep_free(udd_ep_id_t ep)
+{
+ UDD_EP_t *ep_ctrl;
+ Assert(udd_ep_is_valid(ep));
+
+ udd_ep_abort(ep);
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ udd_endpoint_disable(ep_ctrl);
+}
+
+bool udd_ep_is_halted(udd_ep_id_t ep)
+{
+ UDD_EP_t *ep_ctrl;
+ Assert(udd_ep_is_valid(ep));
+
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ return (udd_endpoint_is_stall(ep_ctrl));
+}
+
+bool udd_ep_set_halt(udd_ep_id_t ep)
+{
+ UDD_EP_t *ep_ctrl;
+ Assert(udd_ep_is_valid(ep));
+
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ udd_endpoint_enable_stall(ep_ctrl);
+ udd_endpoint_clear_dtgl(ep_ctrl);
+
+ udd_ep_abort(ep);
+ return true;
+}
+
+bool udd_ep_clear_halt(udd_ep_id_t ep)
+{
+ udd_ep_job_t *ptr_job;
+ UDD_EP_t *ep_ctrl;
+ Assert(udd_ep_is_valid(ep));
+
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ if (!udd_endpoint_is_stall(ep_ctrl)) {
+ return true; // No stall on going
+ }
+ udd_endpoint_disable_stall(ep_ctrl);
+
+ // If a job is register on clear halt action
+ // then execute callback
+ ptr_job = udd_ep_get_job(ep);
+ if (ptr_job->busy == true) {
+ ptr_job->busy = false;
+ ptr_job->call_nohalt();
+ }
+ return true;
+}
+
+bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t * buf,
+ iram_size_t buf_size, udd_callback_trans_t callback)
+{
+ udd_ep_job_t *ptr_job;
+ irqflags_t flags;
+ UDD_EP_t *ep_ctrl;
+
+ Assert(udd_ep_is_valid(ep));
+
+ // Get control & job about this endpoint
+ ptr_job = udd_ep_get_job(ep);
+ ep_ctrl = udd_ep_get_ctrl(ep);
+
+ if (!udd_endpoint_is_enable(ep_ctrl)) {
+ return false; // Endpoint not allocated
+ }
+ if (udd_endpoint_get_type(ep_ctrl)!=USB_EP_TYPE_ISOCHRONOUS_gc
+ && udd_endpoint_is_stall(ep_ctrl)) {
+ return false; // Endpoint is halted
+ }
+ flags = cpu_irq_save();
+ if (ptr_job->busy == true) {
+ cpu_irq_restore(flags);
+ return false; // Job already on going
+ }
+ ptr_job->busy = true;
+ cpu_irq_restore(flags);
+
+
+ // Update Job information
+ ptr_job->buf = buf;
+ ptr_job->buf_size = buf_size;
+ ptr_job->nb_trans = 0;
+ ptr_job->call_trans = callback;
+ // Need to enable shortpacket to send a ZLP (buf_size==0)
+ ptr_job->b_shortpacket = b_shortpacket || (buf_size==0);
+ ptr_job->b_use_out_cache_buffer = false;
+
+ // Initialize value to simulate a empty transfer
+ if (USB_EP_DIR_IN == (ep & USB_EP_DIR_IN)) {
+ udd_endpoint_in_reset_nb_sent(ep_ctrl);
+ }
+ else
+ {
+ if ((USB_EP_TYPE_ISOCHRONOUS_gc == udd_endpoint_get_type(ep_ctrl))
+ && (0 != (buf_size % udd_ep_get_size(ep_ctrl)))) {
+ // The user must use a buffer size modulo endpoint size
+ ptr_job->busy = false;
+ return false;
+ }
+ udd_endpoint_out_reset_nb_received(ep_ctrl);
+ udd_endpoint_out_set_nbbyte(ep_ctrl, 0);
+ }
+ // Request next transfer
+ udd_ep_trans_complet(ep);
+ return true;
+}
+
+void udd_ep_abort(udd_ep_id_t ep)
+{
+ UDD_EP_t *ep_ctrl;
+ udd_ep_job_t *ptr_job;
+ Assert(udd_ep_is_valid(ep));
+
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ ptr_job = udd_ep_get_job(ep);
+
+ // Stop transfer
+ udd_endpoint_set_NACK0(ep_ctrl);
+ if (ptr_job->busy == false) {
+ return; // No job on going
+ }
+ ptr_job->busy = false;
+ if (NULL != ptr_job->call_trans) {
+ ptr_job->call_trans(UDD_EP_TRANSFER_ABORT,
+ (ep & USB_EP_DIR_IN) ?
+ udd_endpoint_in_nb_sent(ep_ctrl)
+ : udd_endpoint_out_nb_receiv(ep_ctrl),
+ ep);
+ }
+}
+
+bool udd_ep_wait_stall_clear(udd_ep_id_t ep,
+ udd_callback_halt_cleared_t callback)
+{
+ udd_ep_job_t *ptr_job;
+ UDD_EP_t *ep_ctrl;
+ Assert(udd_ep_is_valid(ep));
+
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ ptr_job = udd_ep_get_job(ep);
+
+ if (udd_endpoint_is_stall(ep_ctrl)) {
+ // Wait clear halt endpoint
+ if (ptr_job->busy == true) {
+ return false; // Job already on going
+ }
+ ptr_job->busy = true;
+ ptr_job->call_nohalt = callback;
+ } else {
+ // endpoint not halted then call directly callback
+ callback();
+ }
+ return true;
+}
+#endif // (0!=USB_DEVICE_MAX_EP)
+
+//--------------------------------------------------------
+//--- INTERNAL ROUTINES TO MANAGED GLOBAL EVENTS
+
+/**
+ * \internal
+ * \brief Function called by USB bus event interrupt
+ *
+ * USB bus event interrupt includes :
+ * - USB line events SOF, reset, suspend, resume, wakeup
+ * - endpoint control errors underflow, overflow, stall
+ */
+ISR(USB_BUSEVENT_vect)
+{
+ if (udd_is_start_of_frame_event()) {
+ udd_ack_start_of_frame_event();
+ udc_sof_notify();
+#ifdef UDC_SOF_EVENT
+ UDC_SOF_EVENT();
+#endif
+ goto udd_interrupt_bus_event_end;
+ }
+
+ if (udd_ctrl_interrupt_error()) {
+ goto udd_interrupt_bus_event_end;
+ }
+ if (udd_is_reset_event()) {
+ udd_ack_reset_event();
+#if (0!=USB_DEVICE_MAX_EP)
+ // Abort all endpoint jobs on going
+ uint8_t i;
+ for (i = 1; i < USB_DEVICE_MAX_EP; i++) {
+ udd_ep_abort(i);
+ udd_ep_abort(i | USB_EP_DIR_IN);
+ }
+#endif
+ udc_reset();
+
+ // Reset USB address to 0
+ udd_set_device_address(0);
+ // Alloc and configure control endpoint
+ udd_ep_init(0, USB_EP_TYPE_CONTROL, USB_DEVICE_EP_CTRL_SIZE);
+ udd_ep_init(0 | USB_EP_DIR_IN, USB_EP_TYPE_CONTROL,
+ USB_DEVICE_EP_CTRL_SIZE);
+ udd_control_out_set_buf(&udd_ctrl_buffer);
+ // Reset endpoint control management
+ udd_ctrl_init();
+ goto udd_interrupt_bus_event_end;
+ }
+
+ if (udd_is_suspend_event()) {
+ udd_ack_suspend_event();
+ udd_sleep_mode(false); // Enter in SUSPEND mode
+#ifdef UDC_SUSPEND_EVENT
+ UDC_SUSPEND_EVENT();
+#endif
+ goto udd_interrupt_bus_event_end;
+ }
+
+ if (udd_is_resume_event()) {
+ udd_ack_resume_event();
+ udd_sleep_mode(true); // Enter in power reduction mode
+#ifdef UDC_RESUME_EVENT
+ UDC_RESUME_EVENT();
+#endif
+ goto udd_interrupt_bus_event_end;
+ }
+
+udd_interrupt_bus_event_end:
+ return;
+}
+
+/**
+ * \internal
+ * \brief Function called by USB transfer complete interrupt
+ *
+ * USB transfer complete interrupt includes events about endpoint transfer on all endpoints.
+ */
+ISR(USB_TRNCOMPL_vect)
+{
+#if (0!=USB_DEVICE_MAX_EP)
+ uint8_t ep_index;
+ uint8_t i_fifo;
+ uint16_t ad;
+ uint16_t *p_ad;
+ int8_t rp;
+ UDD_EP_t *ep_ctrl;
+ udd_ep_id_t ep;
+#endif
+
+ if (!udd_is_tc_event()) {
+ // If no other transfer complete
+ // then check reception of SETUP packet on control endpoint
+ if (udd_ctrl_interrupt_tc_setup()) {
+ // Interrupt acked by control endpoint managed
+ goto udd_interrupt_tc_end;
+ }
+ Assert(false);
+ }
+ // Check IN/OUT transfer complete on all endpoints
+ udd_ack_tc_event();
+
+#if (0!=USB_DEVICE_MAX_EP)
+ //** Decode TC FIFO
+ // Compute ep addr
+ rp = udd_get_fifo_rp();
+ i_fifo = 2 * (1 + ~rp);
+ ad = ((uint16_t) udd_sram.ep_ctrl) - i_fifo;
+ p_ad = (uint16_t *) ad;
+ // Compute ep
+ ep_index = (((uint16_t) * p_ad - ((uint16_t) udd_sram.ep_ctrl)) >> 3);
+ ep = (ep_index / 2) + ((ep_index & 1) ? USB_EP_DIR_IN : 0);
+ Assert(USB_DEVICE_MAX_EP >= (ep & USB_EP_ADDR_MASK));
+
+ // Ack IT TC of endpoint
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ if (!udd_endpoint_transfer_complete(ep_ctrl)) {
+ return; // Error, TC is generated by Multipacket transfer
+ }
+ udd_endpoint_ack_transfer_complete(ep_ctrl);
+
+ // Check status on control endpoint
+ if (ep == 0) {
+ udd_ctrl_out_received();
+ goto udd_interrupt_tc_end; // Interrupt acked by control endpoint managed
+ }
+ if (ep == (0 | USB_EP_DIR_IN)) {
+ udd_ctrl_in_sent();
+ goto udd_interrupt_tc_end; // Interrupt acked by control endpoint managed
+ }
+ Assert(udd_ep_is_valid(ep));
+ // Manage end of transfer on endpoint bulk/interrupt/isochronous
+ udd_ep_trans_complet(ep);
+
+#else
+
+ udd_get_fifo_rp();
+ if (udd_endpoint_transfer_complete(udd_ep_get_ctrl(0))) {
+ udd_endpoint_ack_transfer_complete(udd_ep_get_ctrl(0));
+ udd_ctrl_out_received();
+ }else{
+ udd_endpoint_ack_transfer_complete(udd_ep_get_ctrl(0 | USB_EP_DIR_IN));
+ udd_ctrl_in_sent();
+ }
+#endif
+
+udd_interrupt_tc_end:
+ return;
+}
+
+//--------------------------------------------------------
+//--- INTERNAL ROUTINES TO INITIALIZE ENDPOINT
+
+static void udd_ep_init(udd_ep_id_t ep, uint8_t bmAttributes,
+ uint16_t MaxEndpointSize)
+{
+ USB_EP_TYPE_t type;
+ USB_EP_BUFSIZE_t size;
+ UDD_EP_t *ep_ctrl;
+
+#if (0!=USB_DEVICE_MAX_EP)
+ // Translate USB attribute to hardware defines
+ switch (bmAttributes & USB_EP_TYPE_MASK) {
+ case USB_EP_TYPE_CONTROL:
+ type = USB_EP_TYPE_CONTROL_gc;
+ break;
+ case USB_EP_TYPE_ISOCHRONOUS:
+ type = USB_EP_TYPE_ISOCHRONOUS_gc;
+ break;
+ case USB_EP_TYPE_BULK:
+ case USB_EP_TYPE_INTERRUPT: //interrupt behaves as bulk
+ type = USB_EP_TYPE_BULK_gc;
+ break;
+ default:
+ Assert(false); // Wrong value
+ return;
+ }
+#else
+ type = USB_EP_TYPE_CONTROL_gc;
+#endif
+
+ // Translate USB endpoint size to hardware defines
+ switch (MaxEndpointSize) {
+ default:
+ Assert(false); // Wrong value
+ case 8:
+ size = USB_EP_BUFSIZE_8_gc;
+ break;
+ case 16:
+ size = USB_EP_BUFSIZE_16_gc;
+ break;
+ case 32:
+ size = USB_EP_BUFSIZE_32_gc;
+ break;
+ case 64:
+ size = USB_EP_BUFSIZE_64_gc;
+ break;
+#if (0!=USB_DEVICE_MAX_EP)
+ case 128:
+ size = USB_EP_BUFSIZE_128_gc;
+ break;
+ case 256:
+ size = USB_EP_BUFSIZE_256_gc;
+ break;
+ case 512:
+ size = USB_EP_BUFSIZE_512_gc;
+ break;
+ case 1023:
+ size =USB_EP_BUFSIZE_1023_gc;
+ break;
+#endif
+ }
+
+ // Enable endpoint
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ udd_endpoint_disable(ep_ctrl);
+ udd_endpoint_clear_status(ep_ctrl);
+ udd_endpoint_set_control(ep_ctrl, (uint8_t) type | (uint8_t) size);
+}
+
+static UDD_EP_t *udd_ep_get_ctrl(udd_ep_id_t ep)
+{
+ return &udd_sram.ep_ctrl[(2 * (ep & USB_EP_ADDR_MASK) +
+ ((ep & USB_EP_DIR_IN) ? 1 : 0))];
+}
+
+
+//--------------------------------------------------------
+//--- INTERNAL ROUTINES TO MANAGED THE CONTROL ENDPOINT
+
+static void udd_ctrl_init(void)
+{
+ udd_disable_overflow_interrupt();
+ udd_disable_underflow_interrupt();
+
+ // Clear status flag from control endpoints
+ // Mandatory for ATxmega128A1 Rev. K
+ udd_control_in_set_NACK0();
+ udd_control_in_set_bytecnt(0);
+ udd_control_in_ack_tc();
+ udd_control_ack_in_underflow();
+ udd_control_out_ack_tc();
+ udd_control_ack_out_overflow();
+
+ udd_g_ctrlreq.callback = NULL;
+ udd_g_ctrlreq.over_under_run = NULL;
+ udd_g_ctrlreq.payload_size = 0;
+ udd_ep_control_state = UDD_EPCTRL_SETUP;
+}
+
+static void udd_ctrl_setup_received(void)
+{
+ if (UDD_EPCTRL_SETUP != udd_ep_control_state) {
+ if ((UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP == udd_ep_control_state)
+ || (UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP == udd_ep_control_state)) {
+ // Accept that ZLP event can be hidden by setup packet event
+ // in case of setup packet sending quickly after a ZLP
+ udd_ctrl_endofrequest();
+ }
+ // Reinitializes control endpoint management
+ udd_ctrl_init();
+ }
+ // Fill setup request structure
+ if (8 != udd_control_out_get_bytecnt())
+ return; // Error data number don't correspond to SETUP packet
+ memcpy((uint8_t *) & udd_g_ctrlreq.req, udd_ctrl_buffer, 8);
+
+ // To detect a protocol error on setup, enable nak interrupt on IN/OUT of control endpoint
+ udd_enable_overflow_interrupt();
+ udd_enable_underflow_interrupt();
+
+ // Decode setup request
+ if (udc_process_setup() == false) {
+ // Setup request unknown then stall it
+ udd_ctrl_stall_data();
+ return;
+ }
+
+ if (Udd_setup_is_in()) {
+ udd_ctrl_prev_payload_nb_trans = 0;
+ udd_ctrl_payload_nb_trans = 0;
+ udd_ep_control_state = UDD_EPCTRL_DATA_IN;
+ udd_ctrl_in_sent(); // Send first data transfer
+ } else {
+ if (0 == udd_g_ctrlreq.req.wLength) {
+ // No data phase requested
+ // Send IN ZLP to ACK setup request
+ udd_ctrl_send_zlp_in();
+ return;
+ }
+ // OUT data phase requested
+ udd_ctrl_prev_payload_nb_trans = 0;
+ udd_ctrl_payload_nb_trans = 0;
+ udd_ep_control_state = UDD_EPCTRL_DATA_OUT;
+ // Clear packet to receive first packet
+ udd_control_out_clear_NACK0();
+ }
+}
+
+static void udd_ctrl_in_sent(void)
+{
+ static bool b_shortpacket = false;
+ uint16_t nb_remain;
+
+ if (UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP == udd_ep_control_state) {
+ // ZLP on IN is sent, then valid end of setup request
+ udd_ctrl_endofrequest();
+ // Reinitializes control endpoint management
+ udd_ctrl_init();
+ return;
+ }
+ Assert(udd_ep_control_state == UDD_EPCTRL_DATA_IN);
+
+ nb_remain = udd_g_ctrlreq.payload_size - udd_ctrl_payload_nb_trans;
+ if (0 == nb_remain) {
+ // Update number of total data sending by previous playload buffer
+ udd_ctrl_prev_payload_nb_trans += udd_ctrl_payload_nb_trans;
+ if ((udd_g_ctrlreq.req.wLength == udd_ctrl_prev_payload_nb_trans)
+ || b_shortpacket) {
+ // All data requested are transfered or a short packet has been sent
+ // then it is the end of data phase.
+ // Generate an OUT ZLP for handshake phase.
+ udd_ctrl_send_zlp_out();
+ return;
+ }
+ // Need of new buffer because the data phase is not complete
+ if ((!udd_g_ctrlreq.over_under_run)
+ || (!udd_g_ctrlreq.over_under_run())) {
+ // Underrun then send zlp on IN
+ // nb_remain == 0 allows to send a IN ZLP
+ } else {
+ // A new payload buffer is given
+ udd_ctrl_payload_nb_trans = 0;
+ nb_remain = udd_g_ctrlreq.payload_size;
+ }
+ }
+ // Continue transfer an send next data
+ if (nb_remain >= USB_DEVICE_EP_CTRL_SIZE) {
+ nb_remain = USB_DEVICE_EP_CTRL_SIZE;
+ b_shortpacket = false;
+ } else {
+ b_shortpacket = true;
+ }
+ udd_control_in_set_bytecnt(nb_remain);
+
+ // Link payload buffer directly on USB hardware
+ udd_control_in_set_buf(udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans);
+ udd_ctrl_payload_nb_trans += nb_remain;
+
+ // Valid and sent the data available in control endpoint buffer
+ udd_control_in_clear_NACK0();
+}
+
+static void udd_ctrl_out_received(void)
+{
+ uint16_t nb_data;
+
+ if (UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP == udd_ep_control_state) {
+ // Valid end of setup request
+ udd_ctrl_endofrequest();
+ // Reinitializes control endpoint management
+ udd_ctrl_init();
+ return;
+ }
+ Assert(udd_ep_control_state == UDD_EPCTRL_DATA_OUT);
+
+ // Read data received during OUT phase
+ nb_data = udd_control_out_get_bytecnt();
+
+ if (udd_g_ctrlreq.payload_size < (udd_ctrl_payload_nb_trans + nb_data)) {
+ // Payload buffer too small, ignore data remaining
+ nb_data = udd_g_ctrlreq.payload_size - udd_ctrl_payload_nb_trans;
+ }
+
+ memcpy((uint8_t *) (udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans),
+ udd_ctrl_buffer, nb_data);
+ udd_ctrl_payload_nb_trans += nb_data;
+
+ if ((USB_DEVICE_EP_CTRL_SIZE != nb_data) || (udd_g_ctrlreq.req.wLength
+ <= (udd_ctrl_prev_payload_nb_trans
+ + udd_ctrl_payload_nb_trans))) {
+ // End of reception because it is a short packet
+ // or all data are transfered
+
+ // Before send ZLP, call intermediate callback
+ // in case of data receive generate a stall
+ udd_g_ctrlreq.payload_size = udd_ctrl_payload_nb_trans;
+ if (NULL != udd_g_ctrlreq.over_under_run) {
+ if (!udd_g_ctrlreq.over_under_run()) {
+ // Stall ZLP
+ udd_ctrl_stall_data();
+ return;
+ }
+ }
+ // Send IN ZLP to ACK setup request
+ udd_ctrl_send_zlp_in();
+ return;
+ }
+
+ if (udd_g_ctrlreq.payload_size == udd_ctrl_payload_nb_trans) {
+ // Overrun then request a new payload buffer
+ if (!udd_g_ctrlreq.over_under_run) {
+ // No callback available to request a new payload buffer
+ udd_ctrl_stall_data();
+ return;
+ }
+ if (!udd_g_ctrlreq.over_under_run()) {
+ // No new payload buffer delivered
+ udd_ctrl_stall_data();
+ return;
+ }
+ // New payload buffer available
+ // Update number of total data received
+ udd_ctrl_prev_payload_nb_trans += udd_ctrl_payload_nb_trans;
+ // Reinit reception on payload buffer
+ udd_ctrl_payload_nb_trans = 0;
+ }
+ // Free buffer of OUT control endpoint to authorize next reception
+ udd_control_out_clear_NACK0();
+}
+
+static void udd_ctrl_underflow(void)
+{
+ if (udd_is_tc_event() || udd_ctrl_interrupt_tc_setup()) {
+ return; // underflow ignored if a transfer complete has been no processed
+ }
+ if (UDD_EPCTRL_DATA_OUT == udd_ep_control_state) {
+ // Host want to stop OUT transaction
+ // then stop to wait OUT data phase and wait IN ZLP handshake
+ udd_ctrl_send_zlp_in();
+ } else if (UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP == udd_ep_control_state) {
+ // A OUT handshake is waiting by device,
+ // but host want extra IN data then stall extra IN data and following status stage
+ udd_control_in_enable_stall();
+ udd_control_out_enable_stall();
+ }
+}
+
+static void udd_ctrl_overflow(void)
+{
+ if (udd_is_tc_event() || udd_ctrl_interrupt_tc_setup()) {
+ return; // overflow ignored if a transfer complete has been no processed
+ }
+ if (UDD_EPCTRL_DATA_IN == udd_ep_control_state) {
+ // Host want to stop IN transaction
+ // then stop to wait IN data phase and wait OUT ZLP handshake
+ udd_ctrl_send_zlp_out();
+ } else if (UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP == udd_ep_control_state) {
+ // A IN handshake is waiting by device,
+ // but host want extra OUT data then stall extra OUT data and following status stage
+ udd_control_in_enable_stall();
+ udd_control_out_enable_stall();
+ }
+}
+
+static void udd_ctrl_stall_data(void)
+{
+ // Stall all packets on IN & OUT control endpoint
+ udd_ep_control_state = UDD_EPCTRL_STALL_REQ;
+ udd_control_in_enable_stall();
+ udd_control_out_enable_stall();
+}
+
+static void udd_ctrl_send_zlp_in(void)
+{
+ udd_ep_control_state = UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP;
+ // Valid and sent empty IN packet on control endpoint
+ udd_control_in_set_bytecnt(0);
+ udd_control_in_clear_NACK0();
+}
+
+static void udd_ctrl_send_zlp_out(void)
+{
+ udd_ep_control_state = UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP;
+ // Valid reception of OUT packet on control endpoint
+ udd_control_out_clear_NACK0();
+}
+
+static void udd_ctrl_endofrequest(void)
+{
+ // If a callback is registered then call it
+ if (udd_g_ctrlreq.callback) {
+ udd_g_ctrlreq.callback();
+ }
+}
+
+static bool udd_ctrl_interrupt_error(void)
+{
+ // Underflow only managed for control endpoint
+ if (udd_is_underflow_event()) {
+ udd_ack_underflow_event();
+ if (udd_control_in_underflow()) {
+ udd_ctrl_underflow();
+ }
+ return true;
+ }
+ // Overflow only managed for control endpoint
+ if (udd_is_overflow_event()) {
+ udd_ack_overflow_event();
+ if (udd_control_out_overflow()) {
+ udd_ctrl_overflow();
+ }
+ return true;
+ }
+ return false;
+}
+
+static bool udd_ctrl_interrupt_tc_setup(void)
+{
+ if (!udd_is_setup_event()) {
+ return false;
+ }
+ udd_ack_setup_event();
+
+ // Clear eventually previous stall events
+ udd_control_out_ack_stall();
+ udd_control_in_ack_stall();
+ udd_ack_stall_event();
+
+ Assert(udd_control_setup()); // A setup must be received on control endpoint
+
+ // Ack SETUP packet and decode request
+ udd_control_ack_setup();
+ udd_ctrl_setup_received();
+ return true;
+}
+
+
+//--------------------------------------------------------
+//--- INTERNAL ROUTINES TO MANAGED THE BULK/INTERRUPT/ISOCHRONOUS ENDPOINTS
+
+#if (0!=USB_DEVICE_MAX_EP)
+
+static uint16_t udd_ep_get_size(UDD_EP_t * ep_ctrl)
+{
+ // Translate hardware defines to USB endpoint size
+ switch (udd_endpoint_get_size_field(ep_ctrl)) {
+ default:
+ case USB_EP_BUFSIZE_8_gc:
+ return 8;
+ case USB_EP_BUFSIZE_16_gc:
+ return 16;
+ case USB_EP_BUFSIZE_32_gc:
+ return 32;
+ case USB_EP_BUFSIZE_64_gc:
+ return 64;
+ case USB_EP_BUFSIZE_128_gc:
+ return 128;
+ case USB_EP_BUFSIZE_256_gc:
+ return 256;
+ case USB_EP_BUFSIZE_512_gc:
+ return 512;
+ case USB_EP_BUFSIZE_1023_gc:
+ return 1023;
+ }
+}
+
+static udd_ep_job_t *udd_ep_get_job(udd_ep_id_t ep)
+{
+ return &udd_ep_job[(2 * (ep & USB_EP_ADDR_MASK) +
+ ((ep & USB_EP_DIR_IN) ? 1 : 0)) - 2];
+}
+
+bool udd_ep_is_valid(udd_ep_id_t ep)
+{
+ ep &= USB_EP_ADDR_MASK;
+ if (ep == 0) {
+ return false;
+ }
+ return (USB_DEVICE_MAX_EP >= ep);
+}
+
+static void udd_ep_trans_complet(udd_ep_id_t ep)
+{
+ UDD_EP_t *ep_ctrl;
+ udd_ep_job_t *ptr_job;
+ uint16_t ep_size, nb_trans;
+ iram_size_t next_trans;
+
+ ptr_job = udd_ep_get_job(ep);
+ ep_ctrl = udd_ep_get_ctrl(ep);
+ ep_size = udd_ep_get_size(ep_ctrl);
+
+ if (USB_EP_DIR_IN == (ep & USB_EP_DIR_IN)) {
+ // Transfer complete on IN
+ nb_trans = udd_endpoint_in_nb_sent(ep_ctrl);
+
+ // Update number of data transfered
+ ptr_job->nb_trans += nb_trans;
+
+ // Need to send other data
+ if (ptr_job->nb_trans != ptr_job->buf_size) {
+ next_trans = ptr_job->buf_size - ptr_job->nb_trans;
+ if (UDD_ENDPOINT_MAX_TRANS < next_trans) {
+ // The USB hardware support a maximum
+ // transfer size of UDD_ENDPOINT_MAX_TRANS Bytes
+ next_trans = UDD_ENDPOINT_MAX_TRANS -
+ (UDD_ENDPOINT_MAX_TRANS % ep_size);
+ }
+ // Need ZLP, if requested and last packet is not a short packet
+ ptr_job->b_shortpacket = ptr_job->b_shortpacket
+ && (0==(next_trans % ep_size));
+ udd_endpoint_in_reset_nb_sent(ep_ctrl);
+ udd_endpoint_in_set_bytecnt(ep_ctrl, next_trans);
+ // Link the user buffer directly on USB hardware DMA
+ udd_endpoint_set_buf(ep_ctrl, &ptr_job->buf[ptr_job->nb_trans]);
+ udd_endpoint_clear_NACK0(ep_ctrl);
+ return;
+ }
+
+ // Need to send a ZLP after all data transfer
+ if (ptr_job->b_shortpacket) {
+ ptr_job->b_shortpacket = false;
+ udd_endpoint_in_reset_nb_sent(ep_ctrl);
+ udd_endpoint_in_set_bytecnt(ep_ctrl, 0);
+ udd_endpoint_clear_NACK0(ep_ctrl);
+ return;
+ }
+ }
+ else
+ {
+ // Transfer complete on OUT
+ nb_trans = udd_endpoint_out_nb_receiv(ep_ctrl);
+
+ // Can be necessary to copy data receive from cache buffer to user buffer
+ if (ptr_job->b_use_out_cache_buffer) {
+ memcpy(&ptr_job->buf[ptr_job->nb_trans]
+ , udd_ep_out_cache_buffer[ep - 1]
+ , ptr_job->buf_size % ep_size);
+ }
+
+ // Update number of data transfered
+ ptr_job->nb_trans += nb_trans;
+ if (ptr_job->nb_trans > ptr_job->buf_size) {
+ ptr_job->nb_trans = ptr_job->buf_size;
+ }
+
+ // If all previous data requested are received and user buffer not full
+ // then need to receive other data
+ if ((nb_trans == udd_endpoint_out_get_nbbyte_requested(ep_ctrl))
+ && (ptr_job->nb_trans != ptr_job->buf_size)) {
+ next_trans = ptr_job->buf_size - ptr_job->nb_trans;
+ if (UDD_ENDPOINT_MAX_TRANS < next_trans) {
+ // The USB hardware support a maximum transfer size
+ // of UDD_ENDPOINT_MAX_TRANS Bytes
+ next_trans = UDD_ENDPOINT_MAX_TRANS
+ - (UDD_ENDPOINT_MAX_TRANS % ep_size);
+ } else {
+ next_trans -= next_trans % ep_size;
+ }
+
+ udd_endpoint_out_reset_nb_received(ep_ctrl);
+ if (next_trans < ep_size) {
+ // Use the cache buffer for Bulk or Interrupt size endpoint
+ ptr_job->b_use_out_cache_buffer = true;
+ udd_endpoint_set_buf( ep_ctrl,
+ udd_ep_out_cache_buffer[ep - 1]);
+ udd_endpoint_out_set_nbbyte(ep_ctrl, ep_size);
+ } else {
+ // Link the user buffer directly on USB hardware DMA
+ udd_endpoint_set_buf(ep_ctrl, &ptr_job->buf[ptr_job->nb_trans]);
+ udd_endpoint_out_set_nbbyte(ep_ctrl, next_trans);
+ }
+ // Start transfer
+ udd_endpoint_clear_NACK0(ep_ctrl);
+ return;
+ }
+ }
+
+ // Job complete then call callback
+ if (ptr_job->busy) {
+ ptr_job->busy = false;
+ if (NULL != ptr_job->call_trans) {
+ ptr_job->call_trans(UDD_EP_TRANSFER_OK,
+ ptr_job->nb_trans,
+ ep);
+ }
+ }
+ return;
+}
+#endif // (0!=USB_DEVICE_MAX_EP)
+//@}
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c.REMOVED.git-id
deleted file mode 100644
index 84e5d494..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a0b77ded8fb44bf7d4eb8b300363c7eff6c5591e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.h
new file mode 100644
index 00000000..351c0ef9
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.h
@@ -0,0 +1,390 @@
+/**
+ * \file
+ *
+ * \brief USB Driver header file for XMEGA products including USB interface.
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _USB_DEVICE_H_
+#define _USB_DEVICE_H_
+
+#include
+
+/**
+ * \ingroup udd_group
+ * \defgroup udd_xmega_usb_group Xmega USB Device Driver
+ * USBC low-level driver for USB Device mode
+ *
+ *
+ * @{
+ */
+
+//! @name USB Device main management
+//! @{
+
+/**
+ * \brief Initializes the USB DP/DM buffers
+ *
+ * This functions initializes the USB buffer using the calibration value
+ * stored in production raw.
+ * If the calibration value is not found (0xFF) value, a default typical
+ * value is applied.
+ * Alternatively user can force calibration values using USB_PAD_USER_CAL0
+ * and USB_PAD_USER_CAL1
+ *
+ */
+static inline void usb_pad_init(void)
+{
+ uint8_t cal;
+
+#ifdef USB_PAD_USER_CAL0
+ USB_CAL0 = USB_PAD_USER_CAL0;
+#else
+ cal = nvm_read_production_signature_row
+ (nvm_get_production_signature_row_offset(USBCAL0));
+ if (cal != 0xFF) {
+ USB_CAL0 = cal;
+ } else {
+ USB_CAL0 = 0x1F;
+ }
+#endif
+
+#ifdef USB_PAD_USER_CAL1
+ USB_CAL1 = USB_PAD_USER_CAL1;
+#else
+ cal = nvm_read_production_signature_row
+ (nvm_get_production_signature_row_offset(USBCAL1));
+ if (cal != 0xFF) {
+ USB_CAL1 = cal;
+ } else {
+ USB_CAL1 = 0x1F;
+ }
+#endif
+}
+
+#define udd_enable_interface() (USB_CTRLA |= USB_ENABLE_bm)
+#define udd_disable_interface() (USB_CTRLA &= ~USB_ENABLE_bm)
+#define udd_attach_device() (USB_CTRLB |= USB_ATTACH_bm)
+#define udd_detach_device() (USB_CTRLB &= ~USB_ATTACH_bm)
+#define udd_gnak_disable() (USB_CTRLB &= ~USB_GNACK_bm)
+#define udd_gnak_enable() (USB_CTRLB |= USB_GNACK_bm)
+#define udd_gnak_is_enable() (USB_CTRLB & USB_GNACK_bm)
+#define udd_set_nb_max_ep(n) (USB_CTRLA |= n)
+#define udd_enable_store_frame_number() (USB_CTRLA |= USB_STFRNUM_bm)
+#define udd_disable_store_frame_number() (USB_CTRLA &= ~USB_STFRNUM_bm)
+#define udd_set_full_speed() (USB_CTRLA |= USB_SPEED_bm)
+#define udd_set_low_speed() (USB_CTRLA &= ~USB_SPEED_bm)
+#define udd_set_ep_table_addr(n) (USB.EPPTR = (uint16_t)n)
+#define udd_get_ep_table_addr() (USB.EPPTR)
+#define udd_get_fifo_rp() (USB_FIFORP)
+#define udd_reset_fifo() (USB_FIFORP=0xFF)
+#define udd_enable_interrupt(level) (USB_INTCTRLA |= level&(USB_INTLVL1_bm|USB_INTLVL0_bm))
+
+#define udd_set_device_address(n) (USB_ADDR=n)
+#define udd_get_device_address() (USB_ADDR)
+#define udd_enable_fifo() (USB_CTRLA |= USB_FIFOEN_bm)
+#define udd_disable_fifo() (USB_CTRLA &= ~USB_FIFOEN_bm)
+
+#define udd_send_remote_wake_up() (USB_CTRLB &= ~USB_RWAKEUP_bm, USB_CTRLB |= USB_RWAKEUP_bm)
+#define udd_set_global_nack() (USB_CTRLB |= USB_GNACK_bm)
+#define udd_is_crc_event() (USB_INTFLAGSASET & USB_CRCIF_bm ? true : false)
+#define udd_ack_crc_event() (USB_INTFLAGSACLR = USB_CRCIF_bm)
+#define udd_set_crc_event() (USB_INTFLAGSASET = USB_CRCIF_bm)
+#define udd_enable_crc_interrupt() (USB_INTCTRLA |= USB_CRCIE_bm)
+#define udd_disable_crc_interrupt() (USB_INTCTRLA &= ~USB_CRCIE_bm)
+
+#define udd_is_start_of_frame_event() (USB_INTFLAGSASET & USB_SOFIF_bm ? true : false)
+#define udd_ack_start_of_frame_event() (USB_INTFLAGSACLR = USB_SOFIF_bm)
+#define udd_set_start_of_frame_event() (USB_INTFLAGSASET = USB_SOFIF_bm)
+#define udd_enable_start_of_frame_interrupt() (USB_INTCTRLA |= USB_SOFIE_bm)
+#define udd_disable_start_of_frame_interrupt() (USB_INTCTRLA &= ~USB_SOFIE_bm)
+#define udd_is_enable_start_of_frame_interrupt() (0!=(USB_INTCTRLA|USB_SOFIE_bm))
+
+#define udd_is_reset_event() (USB_INTFLAGSASET & USB_RSTIF_bm ? true : false)
+#define udd_ack_reset_event() (USB_INTFLAGSACLR = USB_RSTIF_bm)
+#define udd_set_reset_event() (USB_INTFLAGSASET = USB_RSTIF_bm)
+
+#define udd_is_suspend_event() (USB_INTFLAGSASET & USB_SUSPENDIF_bm ? true : false)
+#define udd_ack_suspend_event() (USB_INTFLAGSACLR = USB_SUSPENDIF_bm)
+#define udd_set_suspend_event() (USB_INTFLAGSASET = USB_SUSPENDIF_bm)
+
+#define udd_is_resume_event() (USB_INTFLAGSASET & USB_RESUMEIF_bm ? true : false)
+#define udd_ack_resume_event() (USB_INTFLAGSACLR = USB_RESUMEIF_bm)
+#define udd_set_resume_event() (USB_INTFLAGSASET = USB_RESUMEIF_bm)
+
+#define udd_enable_busevt_interrupt() (USB_INTCTRLA |= USB_BUSEVIE_bm)
+#define udd_disable_busevt_interrupt() (USB_INTCTRLA &= ~USB_BUSEVIE_bm)
+
+#define udd_is_setup_event() (USB_INTFLAGSBCLR & USB_SETUPIF_bm ? true : false)
+#define udd_ack_setup_event() (USB_INTFLAGSBCLR = USB_SETUPIF_bm)
+#define udd_set_setup_event() (USB_INTFLAGSBSET = USB_SETUPIF_bm)
+#define udd_enable_setup_interrupt() (USB_INTCTRLB |= USB_SETUPIE_bm)
+#define udd_disable_setup_interrupt() (USB_INTCTRLB &= ~USB_SETUPIE_bm)
+
+#define udd_is_tc_event() (USB_INTFLAGSBCLR & USB_TRNIF_bm ? true : false)
+#define udd_ack_tc_event() (USB_INTFLAGSBCLR = USB_TRNIF_bm)
+#define udd_set_tc_event() (USB_INTFLAGSBSET = USB_TRNIF_bm)
+#define udd_enable_tc_interrupt() (USB_INTCTRLB |= USB_TRNIE_bm)
+#define udd_disable_tc_interrupt() (USB_INTCTRLB &= ~USB_TRNIE_bm)
+
+#define udd_is_overflow_event() (USB_INTFLAGSASET & USB_OVFIF_bm ? true : false)
+#define udd_ack_overflow_event() (USB_INTFLAGSACLR = USB_OVFIF_bm)
+#define udd_set_overflow_event() (USB_INTFLAGSASET = USB_OVFIF_bm)
+#define udd_enable_overflow_interrupt() (USB_INTCTRLA |= USB_BUSERRIE_bm)
+#define udd_disable_overflow_interrupt() (USB_INTCTRLA &= ~USB_BUSERRIE_bm)
+#define udd_is_enable_overflow_interrupt() (USB_INTCTRLA&USB_BUSERRIE_bm ? true : false)
+
+#define udd_is_underflow_event() (USB_INTFLAGSASET & USB_UNFIF_bm ? true : false)
+#define udd_ack_underflow_event() (USB_INTFLAGSACLR = USB_UNFIF_bm)
+#define udd_set_underflow_event() (USB_INTFLAGSASET = USB_UNFIF_bm)
+#define udd_enable_underflow_interrupt() (USB_INTCTRLA |= USB_BUSERRIE_bm)
+#define udd_disable_underflow_interrupt() (USB_INTCTRLA &= ~USB_BUSERRIE_bm)
+#define udd_is_enable_underflow_interrupt() (USB_INTCTRLA&USB_BUSERRIE_bm ? true : false)
+
+#define udd_is_stall_event() (USB_INTFLAGSASET & USB_STALLIF_bm ? true : false)
+#define udd_ack_stall_event() (USB_INTFLAGSACLR = USB_STALLIF_bm)
+#define udd_set_stall_event() (USB_INTFLAGSASET = USB_STALLIF_bm)
+#define udd_enable_stall_interrupt() (USB_INTCTRLA |= USB_STALLIE_bm)
+#define udd_disable_stall_interrupt() (USB_INTCTRLA &= ~USB_STALLIE_bm)
+#define udd_is_enable_stall_interrupt() (USB_INTCTRLA&USB_STALLIE_bm ? true : false)
+//! @}
+
+//! @name USB Device read/modify/write management
+//! @{
+#ifndef USB_WORKAROUND_DO_NOT_USE_RMW
+/*
+ * Read modify write new instructions for Xmega
+ * inline asm implementation with R16 register.
+ * This should be removed later on when the new instructions
+ * will be available within the compiler.
+ *
+ */
+// Load and Clear
+#ifdef __GNUC__
+#define LACR16(addr,msk) \
+ __asm__ __volatile__ ( \
+ "ldi r16, %1" "\n\t" \
+ ".dc.w 0x9306" "\n\t"\
+ ::"z" (addr), "M" (msk):"r16")
+#else
+#define LACR16(addr,msk) __lac((unsigned char)msk,(unsigned char*)addr)
+#endif
+
+// Load and Set
+#ifdef __GNUC__
+#define LASR16(addr,msk) \
+ __asm__ __volatile__ ( \
+ "ldi r16, %1" "\n\t" \
+ ".dc.w 0x9305" "\n\t"\
+ ::"z" (addr), "M" (msk):"r16")
+#else
+#define LASR16(addr,msk) __las((unsigned char)msk,(unsigned char*)addr)
+#endif
+
+// Exchange
+#ifdef __GNUC__
+#define XCHR16(addr,msk) \
+ __asm__ __volatile__ ( \
+ "ldi r16, %1" "\n\t" \
+ ".dc.w 0x9304" "\n\t"\
+ ::"z" (addr), "M" (msk):"r16")
+#else
+#define XCHR16(addr,msk) __xch(msk,addr)
+#endif
+
+// Load and toggle
+#ifdef __GNUC__
+#define LATR16(addr,msk) \
+ __asm__ __volatile__ ( \
+ "ldi r16, %1" "\n\t" \
+ ".dc.w 0x9307" "\n\t"\
+ ::"z" (addr), "M" (msk):"r16")
+#else
+#define LATR16(addr,msk) __lat(msk,addr)
+#endif
+
+#else
+
+// Load and Clear
+#define LACR16(addr,msk) (*addr &= ~msk)
+// Load and Set
+#define LASR16(addr,msk)(*addr |= msk)
+
+#endif
+//! @}
+
+
+//! @name USB Device endpoints table management
+//! @{
+
+#define udd_endpoint_set_control(ep_ctrl,val) (ep_ctrl->CTRL=val)
+#define udd_endpoint_get_control(ep_ctrl) (ep_ctrl->CTRL)
+
+#define udd_endpoint_disable(ep_ctrl) udd_endpoint_set_control(ep_ctrl,0)
+#define udd_endpoint_is_enable(ep_ctrl) (USB_EP_TYPE_DISABLE_gc!=udd_endpoint_get_type(ep_ctrl))
+
+
+#define udd_endpoint_enable_stall(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_STALL_bm)
+#define udd_endpoint_disable_stall(ep_ctrl) (ep_ctrl->CTRL &= ~USB_EP_STALL_bm)
+#define udd_endpoint_is_stall(ep_ctrl) (ep_ctrl->CTRL &USB_EP_STALL_bm ? true : false)
+#define udd_endpoint_set_multipacket(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_MULTIPKT_bm)
+#define udd_endpoint_TC_int_disable(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_INTDSBL_bm)
+#define udd_endpoint_set_pingpong(ep_ctrl) (ep_ctrl->CTRL |= USB_EP_PINGPONG_bm)
+#define udd_endpoint_get_size_field(ep_ctrl) (ep_ctrl->CTRL & USB_EP_BUFSIZE_gm)
+#define udd_endpoint_get_type(ep_ctrl) (ep_ctrl->CTRL & USB_EP_TYPE_gm)
+
+#define udd_endpoint_get_status(ep_ctrl) (ep_ctrl->STATUS)
+#define udd_endpoint_clear_status(ep_ctrl) (ep_ctrl->STATUS=USB_EP_BUSNACK0_bm|USB_EP_BUSNACK1_bm)
+
+#define udd_endpoint_setup_received(ep_ctrl) (ep_ctrl->STATUS&USB_EP_SETUP_bm ? true : false)
+#define udd_endpoint_ack_setup_received(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_SETUP_bm)
+
+#define udd_endpoint_transfer_complete(ep_ctrl) (ep_ctrl->STATUS&USB_EP_TRNCOMPL0_bm ? true : false)
+#define udd_endpoint_ack_transfer_complete(ep_ctrl) LACR16(&(ep_ctrl->STATUS), USB_EP_TRNCOMPL0_bm)
+#define udd_endpoint_transfer_complete_bank0(ep_ctrl) (ep_ctrl->STATUS&USB_EP_TRNCOMPL0_bm ? true : false)
+#define udd_endpoint_ack_transfer_complete_bankO(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_TRNCOMPL0_bm)
+#define udd_endpoint_transfer_complete_bank1(ep_ctrl) (ep_ctrl->STATUS&USB_EP_SETUP_bm ? true : false)
+#define udd_endpoint_ack_transfer_complete_bank1(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_SETUP_bm)
+
+#define udd_endpoint_get_bank(ep_ctrl) (ep_ctrl->STATUS & USB_EP_BANK_bm ? true : false)
+#define udd_endpoint_set_bank(ep_ctrl) LASR16(&ep_ctrl->STATUS, USB_EP_BANK_bm)
+#define udd_endpoint_clear_bank(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_BANK_bm)
+
+#define udd_endpoint_set_dtgl(ep_ctrl) LASR16(&ep_ctrl->STATUS,USB_EP_TOGGLE_bm)
+#define udd_endpoint_clear_dtgl(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_TOGGLE_bm )
+#define udd_endpoint_get_dtgl(ep_ctrl) ((ep_ctrl->STATUS)&USB_EP_TOGGLE_bm ? true : false)
+#define udd_endpoint_toggle_dtgl(ep_ctrl) LATR16(&ep_ctrl->STATUS, USB_EP_TOGGLE_bm)
+
+#define udd_endpoint_set_NACK0(ep_ctrl) LASR16(&ep_ctrl->STATUS,USB_EP_BUSNACK0_bm)
+#define udd_endpoint_set_NACK1(ep_ctrl) LASR16(&ep_ctrl->STATUS,USB_EP_BUSNACK1_bm)
+#define udd_endpoint_clear_NACK0(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_BUSNACK0_bm)
+#define udd_endpoint_clear_NACK1(ep_ctrl) LACR16(&ep_ctrl->STATUS, USB_EP_BUSNACK1_bm)
+#define udd_endpoint_get_NACK1(ep_ctrl) ((ep_ctrl->STATUS&USB_EP_BUSNACK1_bm) ? true : false)
+#define udd_endpoint_get_NACK0(ep_ctrl) ((ep_ctrl->STATUS&USB_EP_BUSNACK0_bm) ? true : false)
+#define udd_endpoint_overflow(ep_ctrl) (ep_ctrl->STATUS&USB_EP_OVF_bm ? true : false)
+#define udd_endpoint_underflow(ep_ctrl) (ep_ctrl->STATUS&USB_EP_UNF_bm ? true : false)
+
+#define UDD_ENDPOINT_MAX_TRANS (0x3FF)
+
+#define udd_endpoint_out_nb_receiv(ep_ctrl) (ep_ctrl->CNT)
+#define udd_endpoint_out_reset_nb_received(ep_ctrl) (ep_ctrl->CNT = 0)
+#define udd_endpoint_in_set_bytecnt(ep_ctrl,n) (ep_ctrl->CNT = n)
+#define udd_endpoint_set_azlp(ep_ctrl) (ep_ctrl->CNT |= 0x8000)
+#define udd_endpoint_clear_azlp(ep_ctrl) (ep_ctrl->CNT &= ~0x8000)
+
+#define udd_endpoint_set_buf(ep_ctrl,buf) (ep_ctrl->DATAPTR = (uint16_t) buf)
+
+#define udd_endpoint_in_nb_sent(ep_ctrl) (ep_ctrl->AUXDATA)
+#define udd_endpoint_in_reset_nb_sent(ep_ctrl) (ep_ctrl->AUXDATA = 0)
+#define udd_endpoint_out_set_nbbyte(ep_ctrl,nb) (ep_ctrl->AUXDATA = nb)
+#define udd_endpoint_out_get_nbbyte_requested(ep_ctrl) (ep_ctrl->AUXDATA)
+#define udd_endpoint_set_aux(ep_ctrl,buf) (ep_ctrl->AUXDATA = (uint16_t) buf)
+//! @}
+
+
+//! @name USB Device endpoint control field management
+//! @{
+
+//! @name USB Device endpoint control setup field management
+//! @{
+#define udd_control_setup() (udd_sram.ep_ctrl[0].STATUS&USB_EP_SETUP_bm ? true : false)
+#define udd_control_ack_setup() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_SETUP_bm)
+//! @}
+
+//! @name USB Device endpoint control OUT field management
+//! @{
+#define udd_control_out_is_enable_stall() (udd_sram.ep_ctrl[0].CTRL&USB_EP_STALL_bm ? true : false)
+#define udd_control_out_enable_stall() LASR16(&udd_sram.ep_ctrl[0].CTRL,USB_EP_STALL_bm)
+#define udd_control_out_disable_stall() LACR16(&udd_sram.ep_ctrl[0].CTRL,USB_EP_STALL_bm)
+#define udd_control_out_is_stalled() (udd_sram.ep_ctrl[0].STATUS&USB_EP_STALLF_bm ? true : false)
+#define udd_control_out_ack_stall() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_STALLF_bm)
+#define udd_control_out_set_NACK0() LASR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_BUSNACK0_bm)
+#define udd_control_out_clear_NACK0() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_BUSNACK0_bm)
+
+#define udd_control_out_overflow() (udd_sram.ep_ctrl[0].STATUS&USB_EP_OVF_bm ? true : false)
+#define udd_control_ack_out_overflow() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_OVF_bm)
+
+#define udd_control_out_tc() (udd_sram.ep_ctrl[0].STATUS&USB_EP_TRNCOMPL0_bm ? true : false)
+#define udd_control_out_ack_tc() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TRNCOMPL0_bm)
+#define udd_control_out_set_tc() LASR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TRNCOMPL0_bm)
+
+#define udd_control_out_dt_get() (udd_sram.ep_ctrl[0].STATUS&USB_EP_TOGGLE_bm ? true : false)
+#define udd_control_out_dt_set() LASR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TOGGLE_bm )
+#define udd_control_out_dt_clear() LACR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TOGGLE_bm )
+#define udd_control_out_dt_toggle() LATR16(&udd_sram.ep_ctrl[0].STATUS,USB_EP_TOGGLE_bm)
+
+#define udd_control_out_set_buf(buf) (udd_sram.ep_ctrl[0].DATAPTR = (uint16_t) buf)
+
+#define udd_control_out_get_bytecnt() (udd_sram.ep_ctrl[0].CNT)
+//! @}
+
+//! @name USB Device endpoint control IN field management
+//! @{
+#define udd_control_in_is_enable_stall() (udd_sram.ep_ctrl[1].CTRL&USB_EP_STALL_bm ? true : false)
+#define udd_control_in_enable_stall() LASR16(&udd_sram.ep_ctrl[1].CTRL,USB_EP_STALL_bm)
+#define udd_control_in_disable_stall() LACR16(&udd_sram.ep_ctrl[1].CTRL,USB_EP_STALL_bm)
+#define udd_control_in_is_stalled() (udd_sram.ep_ctrl[1].STATUS&USB_EP_STALLF_bm ? true : false)
+#define udd_control_in_ack_stall() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_STALLF_bm)
+#define udd_control_in_set_NACK0() LASR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_BUSNACK0_bm)
+#define udd_control_in_clear_NACK0() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_BUSNACK0_bm)
+
+#define udd_control_in_underflow() (udd_sram.ep_ctrl[1].STATUS&USB_EP_UNF_bm ? true : false)
+#define udd_control_ack_in_underflow() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_UNF_bm)
+
+#define udd_control_in_tc() (udd_sram.ep_ctrl[1].STATUS&USB_EP_TRNCOMPL0_bm ? true : false)
+#define udd_control_in_ack_tc() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TRNCOMPL0_bm)
+#define udd_control_in_set_tc() LASR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TRNCOMPL0_bm)
+
+#define udd_control_in_dt_get() (udd_sram.ep_ctrl[1].STATUS&USB_EP_TOGGLE_bm ? true : false)
+#define udd_control_in_dt_set() LASR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TOGGLE_bm )
+#define udd_control_in_dt_clear() LACR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TOGGLE_bm )
+#define udd_control_in_dt_toggle() LATR16(&udd_sram.ep_ctrl[1].STATUS,USB_EP_TOGGLE_bm)
+
+#define udd_control_in_set_buf(buf) (udd_sram.ep_ctrl[1].DATAPTR = (uint16_t) buf)
+
+#define udd_control_in_set_bytecnt(n) (udd_sram.ep_ctrl[1].CNT = n)
+//! @}
+//! @}
+
+//! @}
+
+#endif // _USB_DEVICE_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.h.REMOVED.git-id
deleted file mode 100644
index cdd1739c..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/drivers/usb/usb_device.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-351c0ef90a7248c47453ee14be11805dcf0546b1
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler.h
new file mode 100644
index 00000000..8a2dfca0
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler.h
@@ -0,0 +1,159 @@
+/**
+ * \file
+ *
+ * \brief Assembler abstraction layer and utilities
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef ASSEMBLER_H_INCLUDED
+#define ASSEMBLER_H_INCLUDED
+
+#if !defined(__ASSEMBLER__) && !defined(__IAR_SYSTEMS_ASM__) \
+ && !defined(__DOXYGEN__)
+# error This file may only be included from assembly files
+#endif
+
+#if defined(__ASSEMBLER__)
+# include "assembler/gas.h"
+# include
+#elif defined(__IAR_SYSTEMS_ASM__)
+# include "assembler/iar.h"
+# include
+#endif
+
+/**
+ * \ingroup group_xmega_utils
+ * \defgroup assembler_group Assembler Support
+ *
+ * This group provides a good handful of macros intended to smooth out
+ * the differences between various assemblers, similar to what compiler.h does
+ * for compilers, except that assemblers tend to be much less standardized than
+ * compilers.
+ *
+ * @{
+ */
+
+//! \name Control Statements
+//@{
+/**
+ * \def REPEAT(count)
+ * \brief Repeat the following statements \a count times
+ */
+/**
+ * \def END_REPEAT()
+ * \brief Mark the end of the statements to be repeated
+ */
+/**
+ * \def SET_LOC(offset)
+ * \brief Set the location counter to \a offset
+ */
+/**
+ * \def END_FILE()
+ * \brief Mark the end of the file
+ */
+//@}
+
+//! \name Data Objects
+//@{
+/**
+ * \def FILL_BYTES(count)
+ * \brief Allocate space for \a count bytes
+ */
+//@}
+
+//! \name Symbol Definition
+//@{
+/**
+ * \def L(name)
+ * \brief Turn \a name into a local symbol, if possible
+ */
+/**
+ * \def EXTERN_SYMBOL(name)
+ * \brief Declare \a name as an external symbol referenced by this file
+ */
+/**
+ * \def FUNCTION(name)
+ * \brief Define a file-local function called \a name
+ */
+/**
+ * \def PUBLIC_FUNCTION(name)
+ * \brief Define a globally visible function called \a name
+ */
+/**
+ * \def WEAK_FUNCTION(name)
+ * \brief Define a weak function called \a name
+ *
+ * Weak functions are only referenced if no strong definitions are found
+ */
+/**
+ * \def WEAK_FUNCTION_ALIAS(name, strong_name)
+ * \brief Define \a name as a weak alias for the function \a strong_name
+ * \sa WEAK_FUNCTION
+ */
+/**
+ * \def END_FUNC(name)
+ * \brief Mark the end of the function called \a name
+ */
+//@}
+
+//! \name Section Definition
+//@{
+/**
+ * \def TEXT_SECTION(name)
+ * \brief Start a new section containing executable code
+ */
+/**
+ * \def RODATA_SECTION(name)
+ * \brief Start a new section containing read-only data
+ */
+/**
+ * \def DATA_SECTION(name)
+ * \brief Start a new section containing writeable initialized data
+ */
+/**
+ * \def BSS_SECTION(name)
+ * \brief Start a new section containing writeable zero-initialized data
+ */
+//@}
+
+//! @}
+
+#endif /* ASSEMBLER_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler.h.REMOVED.git-id
deleted file mode 100644
index ebc2824d..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8a2dfca03d5632ebb51fd8ad51301019cb536b4c
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler/gas.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler/gas.h
new file mode 100644
index 00000000..58a54094
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler/gas.h
@@ -0,0 +1,124 @@
+/**
+ * \file
+ *
+ * \brief Assembler abstraction layer: GNU Assembler specifics
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef ASSEMBLER_GAS_H_INCLUDED
+#define ASSEMBLER_GAS_H_INCLUDED
+
+#ifndef __DOXYGEN__
+
+ /* IAR doesn't accept dots in macro names */
+ .macro ld_addr, reg, sym
+ lda.w \reg, \sym
+ .endm
+
+ /* Define a function \a name that is either globally visible or only
+ * file-local.
+ */
+ .macro gas_begin_func name, is_public
+ .if \is_public
+ .global \name
+ .endif
+ .section .text.\name, "ax", @progbits
+ .type \name, @function
+ \name :
+ .endm
+
+ /* Define a function \a name that is either globally visible or only
+ * file-local in a given segment.
+ */
+ .macro gas_begin_func_segm name, is_public, segment
+ .if \is_public
+ .global \name
+ .endif
+ .section .\segment, "ax", @progbits
+ .type \name, @function
+ \name :
+ .endm
+
+ /* Define \a name as a weak alias for the function \a strong_name */
+ .macro gas_weak_function_alias name, strong_name
+ .global \name
+ .weak \name
+ .type \name, @function
+ .set \name, \strong_name
+ .endm
+
+ /* Define a weak function called \a name */
+ .macro gas_weak_function name
+ .weak \name
+ gas_begin_func \name 1
+ .endm
+
+#define REPEAT(count) .rept count
+#define END_REPEAT() .endr
+#define FILL_BYTES(count) .fill count
+#define SET_LOC(offset) .org offset
+#define L(name) .L##name
+#define EXTERN_SYMBOL(name)
+
+#define TEXT_SECTION(name) \
+ .section name, "ax", @progbits
+#define RODATA_SECTION(name) \
+ .section name, "a", @progbits
+#define DATA_SECTION(name) \
+ .section name, "aw", @progbits
+#define BSS_SECTION(name) \
+ .section name, "aw", @nobits
+
+#define FUNCTION(name) gas_begin_func name 0
+#define PUBLIC_FUNCTION(name) gas_begin_func name 1
+#define PUBLIC_FUNCTION_SEGMENT(name, segment) \
+ gas_begin_func_segm name 1 segment
+#define WEAK_FUNCTION(name) gas_weak_function name
+#define WEAK_FUNCTION_ALIAS(name, strong_name) \
+ gas_weak_function_alias name strong_name
+#define END_FUNC(name) \
+ .size name, . - name
+
+#define END_FILE()
+
+#endif /* __DOXYGEN__ */
+
+#endif /* ASSEMBLER_GAS_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler/gas.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler/gas.h.REMOVED.git-id
deleted file mode 100644
index 84fc8f77..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/assembler/gas.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-58a54094680ba9292dd92b8a87f1bfe4a1ae7d7e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/bit_handling/clz_ctz.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/bit_handling/clz_ctz.h
new file mode 100644
index 00000000..a58f1f4e
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/bit_handling/clz_ctz.h
@@ -0,0 +1,215 @@
+/**
+ * \file
+ *
+ * \brief CLZ/CTZ C implementation.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CLZ_CTH_H
+#define CLZ_CTH_H
+
+/**
+ * \brief Count leading zeros in unsigned integer
+ *
+ * This macro takes unsigned integers of any size, and evaluates to a call to
+ * the clz-function for its size. These functions count the number of zeros,
+ * starting with the MSB, before a one occurs in the integer.
+ *
+ * \param x Unsigned integer to count the leading zeros in.
+ *
+ * \return The number of leading zeros in \a x.
+ */
+#define clz(x) compiler_demux_size(sizeof(x), clz, (x))
+
+/**
+ * \internal
+ * \brief Count leading zeros in unsigned, 8-bit integer
+ *
+ * \param x Unsigned byte to count the leading zeros in.
+ *
+ * \return The number of leading zeros in \a x.
+ */
+__always_inline static uint8_t clz8(uint8_t x)
+{
+ uint8_t bit = 0;
+
+ if (x & 0xf0) {
+ x >>= 4;
+ } else {
+ bit += 4;
+ }
+
+ if (x & 0x0c) {
+ x >>= 2;
+ } else {
+ bit += 2;
+ }
+
+ if (!(x & 0x02)) {
+ bit++;
+ }
+
+ return bit;
+
+}
+
+/**
+ * \internal
+ * \brief Count leading zeros in unsigned, 16-bit integer
+ *
+ * \param x Unsigned word to count the leading zeros in.
+ *
+ * \return The number of leading zeros in \a x.
+ */
+__always_inline static uint8_t clz16(uint16_t x)
+{
+ uint8_t bit = 0;
+
+ if (x & 0xff00) {
+ x >>= 8;
+ } else {
+ bit += 8;
+ }
+
+ return bit + clz8(x);
+}
+
+/**
+ * \internal
+ * \brief Count leading zeros in unsigned, 32-bit integer
+ *
+ * \param x Unsigned double word to count the leading zeros in.
+ *
+ * \return The number of leading zeros in \a x.
+ */
+__always_inline static uint8_t clz32(uint32_t x)
+{
+ uint8_t bit = 0;
+
+ if (x & 0xffff0000) {
+ x >>= 16;
+ } else {
+ bit += 16;
+ }
+
+ return bit + clz16(x);
+}
+
+/**
+ * \brief Count trailing zeros in unsigned integer
+ *
+ * This macro takes unsigned integers of any size, and evaluates to a call to
+ * the ctz-function for its size. These functions count the number of zeros,
+ * starting with the LSB, before a one occurs in the integer.
+ *
+ * \param x Unsigned integer to count the trailing zeros in.
+ *
+ * \return The number of trailing zeros in \a x.
+ */
+#define ctz(x) compiler_demux_size(sizeof(x), ctz, (x))
+
+/**
+ * \internal
+ * \brief Count trailing zeros in unsigned, 8-bit integer
+ *
+ * \param x Unsigned byte to count the trailing zeros in.
+ *
+ * \return The number of leading zeros in \a x.
+ */
+__always_inline static uint8_t ctz8(uint8_t x)
+{
+ uint8_t bit = 0;
+
+ if (!(x & 0x0f)) {
+ bit += 4;
+ x >>= 4;
+ }
+ if (!(x & 0x03)) {
+ bit += 2;
+ x >>= 2;
+ }
+ if (!(x & 0x01))
+ bit++;
+
+ return bit;
+}
+
+/**
+ * \internal
+ * \brief Count trailing zeros in unsigned, 16-bit integer
+ *
+ * \param x Unsigned word to count the trailing zeros in.
+ *
+ * \return The number of trailing zeros in \a x.
+ */
+__always_inline static uint8_t ctz16(uint16_t x)
+{
+ uint8_t bit = 0;
+
+ if (!(x & 0x00ff)) {
+ bit += 8;
+ x >>= 8;
+ }
+
+ return bit + ctz8(x);
+}
+
+/**
+ * \internal
+ * \brief Count trailing zeros in unsigned, 32-bit integer
+ *
+ * \param x Unsigned double word to count the trailing zeros in.
+ *
+ * \return The number of trailing zeros in \a x.
+ */
+__always_inline static uint8_t ctz32(uint32_t x)
+{
+ uint8_t bit = 0;
+
+ if (!(x & 0x0000ffff)) {
+ bit += 16;
+ x >>= 16;
+ }
+
+ return bit + ctz16(x);
+}
+
+#endif /* CLZ_CTZ_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/bit_handling/clz_ctz.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/bit_handling/clz_ctz.h.REMOVED.git-id
deleted file mode 100644
index 0db4f633..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/bit_handling/clz_ctz.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a58f1f4e289dc55b4a483bb50193d0f204d33bae
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/compiler.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/compiler.h
new file mode 100644
index 00000000..5e4f2c43
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/compiler.h
@@ -0,0 +1,1189 @@
+/**
+ * \file
+ *
+ * \brief Commonly used includes, types and macros.
+ *
+ * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef UTILS_COMPILER_H
+#define UTILS_COMPILER_H
+
+/**
+ * \defgroup group_xmega_utils XMEGA compiler driver
+ *
+ * Compiler abstraction layer and code utilities for 8-bit AVR.
+ * This module provides various abstraction layers and utilities to make code compatible between different compilers.
+ *
+ * \{
+ */
+
+#if defined(__GNUC__)
+# include
+# include
+#elif defined(__ICCAVR__)
+# include
+# include
+#else
+# error Unsupported compiler.
+#endif
+
+#include
+#include
+#include
+#include
+
+#include
+
+#ifdef __ICCAVR__
+/*! \name Compiler Keywords
+ *
+ * Port of some keywords from GCC to IAR Embedded Workbench.
+ */
+//! @{
+#define __asm__ asm
+#define __inline__ inline
+#define __volatile__
+//! @}
+#endif
+
+/**
+ * \def UNUSED
+ * \brief Marking \a v as a unused parameter or value.
+ */
+#define UNUSED(v) (void)(v)
+
+/**
+ * \def unused
+ * \brief Marking \a v as a unused parameter or value.
+ */
+#define unused(v) do { (void)(v); } while(0)
+
+/**
+ * \def barrier
+ * \brief Memory barrier
+ */
+#ifdef __GNUC__
+# define barrier() asm volatile("" ::: "memory")
+#else
+# define barrier() asm ("")
+#endif
+
+/**
+ * \brief Emit the compiler pragma \a arg.
+ *
+ * \param arg The pragma directive as it would appear after \e \#pragma
+ * (i.e. not stringified).
+ */
+#define COMPILER_PRAGMA(arg) _Pragma(#arg)
+
+/*
+ * AVR arch does not care about alignment anyway.
+ */
+#define COMPILER_PACK_RESET(alignment)
+#define COMPILER_PACK_SET(alignment)
+
+/**
+ * \brief Set aligned boundary.
+ */
+#if (defined __GNUC__)
+#define COMPILER_ALIGNED(a) __attribute__((__aligned__(a)))
+#elif (defined __ICCAVR__)
+#define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a)
+#endif
+
+/**
+ * \brief Set word-aligned boundary.
+ */
+#if (defined __GNUC__)
+#define COMPILER_WORD_ALIGNED __attribute__((__aligned__(2)))
+#elif (defined __ICCAVR__)
+#define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 2)
+#endif
+
+/**
+ * \name Tag functions as deprecated
+ *
+ * Tagging a function as deprecated will produce a warning when and only
+ * when the function is called.
+ *
+ * Usage is to add the __DEPRECATED__ symbol before the function definition.
+ * E.g.:
+ * __DEPRECATED__ uint8_t some_deprecated_function (void)
+ * {
+ * ...
+ * }
+ *
+ * \note Only supported by GCC 3.1 and above, no IAR support
+ * @{
+ */
+#if ((defined __GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >=1)))
+#define __DEPRECATED__ __attribute__((__deprecated__))
+#else
+#define __DEPRECATED__
+#endif
+//! @}
+
+/*! \name Usual Types
+ */
+//! @{
+typedef unsigned char Bool; //!< Boolean.
+#ifndef __cplusplus
+#if !defined(__bool_true_false_are_defined)
+typedef unsigned char bool; //!< Boolean.
+#endif
+#endif
+typedef int8_t S8 ; //!< 8-bit signed integer.
+typedef uint8_t U8 ; //!< 8-bit unsigned integer.
+typedef int16_t S16; //!< 16-bit signed integer.
+typedef uint16_t U16; //!< 16-bit unsigned integer.
+typedef uint16_t le16_t;
+typedef uint16_t be16_t;
+typedef int32_t S32; //!< 32-bit signed integer.
+typedef uint32_t U32; //!< 32-bit unsigned integer.
+typedef uint32_t le32_t;
+typedef uint32_t be32_t;
+typedef int64_t S64; //!< 64-bit signed integer.
+typedef uint64_t U64; //!< 64-bit unsigned integer.
+typedef float F32; //!< 32-bit floating-point number.
+typedef double F64; //!< 64-bit floating-point number.
+typedef uint16_t iram_size_t;
+//! @}
+
+
+/*! \name Status Types
+ */
+//! @{
+typedef Bool Status_bool_t; //!< Boolean status.
+typedef U8 Status_t; //!< 8-bit-coded status.
+//! @}
+
+
+/*! \name Aliasing Aggregate Types
+ */
+//! @{
+
+//! 16-bit union.
+typedef union
+{
+ S16 s16 ;
+ U16 u16 ;
+ S8 s8 [2];
+ U8 u8 [2];
+} Union16;
+
+//! 32-bit union.
+typedef union
+{
+ S32 s32 ;
+ U32 u32 ;
+ S16 s16[2];
+ U16 u16[2];
+ S8 s8 [4];
+ U8 u8 [4];
+} Union32;
+
+//! 64-bit union.
+typedef union
+{
+ S64 s64 ;
+ U64 u64 ;
+ S32 s32[2];
+ U32 u32[2];
+ S16 s16[4];
+ U16 u16[4];
+ S8 s8 [8];
+ U8 u8 [8];
+} Union64;
+
+//! Union of pointers to 64-, 32-, 16- and 8-bit unsigned integers.
+typedef union
+{
+ S64 *s64ptr;
+ U64 *u64ptr;
+ S32 *s32ptr;
+ U32 *u32ptr;
+ S16 *s16ptr;
+ U16 *u16ptr;
+ S8 *s8ptr ;
+ U8 *u8ptr ;
+} UnionPtr;
+
+//! Union of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers.
+typedef union
+{
+ volatile S64 *s64ptr;
+ volatile U64 *u64ptr;
+ volatile S32 *s32ptr;
+ volatile U32 *u32ptr;
+ volatile S16 *s16ptr;
+ volatile U16 *u16ptr;
+ volatile S8 *s8ptr ;
+ volatile U8 *u8ptr ;
+} UnionVPtr;
+
+//! Union of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers.
+typedef union
+{
+ const S64 *s64ptr;
+ const U64 *u64ptr;
+ const S32 *s32ptr;
+ const U32 *u32ptr;
+ const S16 *s16ptr;
+ const U16 *u16ptr;
+ const S8 *s8ptr ;
+ const U8 *u8ptr ;
+} UnionCPtr;
+
+//! Union of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers.
+typedef union
+{
+ const volatile S64 *s64ptr;
+ const volatile U64 *u64ptr;
+ const volatile S32 *s32ptr;
+ const volatile U32 *u32ptr;
+ const volatile S16 *s16ptr;
+ const volatile U16 *u16ptr;
+ const volatile S8 *s8ptr ;
+ const volatile U8 *u8ptr ;
+} UnionCVPtr;
+
+//! Structure of pointers to 64-, 32-, 16- and 8-bit unsigned integers.
+typedef struct
+{
+ S64 *s64ptr;
+ U64 *u64ptr;
+ S32 *s32ptr;
+ U32 *u32ptr;
+ S16 *s16ptr;
+ U16 *u16ptr;
+ S8 *s8ptr ;
+ U8 *u8ptr ;
+} StructPtr;
+
+//! Structure of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers.
+typedef struct
+{
+ volatile S64 *s64ptr;
+ volatile U64 *u64ptr;
+ volatile S32 *s32ptr;
+ volatile U32 *u32ptr;
+ volatile S16 *s16ptr;
+ volatile U16 *u16ptr;
+ volatile S8 *s8ptr ;
+ volatile U8 *u8ptr ;
+} StructVPtr;
+
+//! Structure of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers.
+typedef struct
+{
+ const S64 *s64ptr;
+ const U64 *u64ptr;
+ const S32 *s32ptr;
+ const U32 *u32ptr;
+ const S16 *s16ptr;
+ const U16 *u16ptr;
+ const S8 *s8ptr ;
+ const U8 *u8ptr ;
+} StructCPtr;
+
+//! Structure of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers.
+typedef struct
+{
+ const volatile S64 *s64ptr;
+ const volatile U64 *u64ptr;
+ const volatile S32 *s32ptr;
+ const volatile U32 *u32ptr;
+ const volatile S16 *s16ptr;
+ const volatile U16 *u16ptr;
+ const volatile S8 *s8ptr ;
+ const volatile U8 *u8ptr ;
+} StructCVPtr;
+
+//! @}
+
+
+//_____ M A C R O S ________________________________________________________
+
+/*! \name Usual Constants
+ */
+//! @{
+#define DISABLE 0
+#define ENABLE 1
+#ifndef __cplusplus
+#if !defined(__bool_true_false_are_defined)
+#define false 0
+#define true 1
+#endif
+#endif
+#define PASS 0
+#define FAIL 1
+#define LOW 0
+#define HIGH 1
+//! @}
+
+
+//! \name Compile time error handling
+//@{
+
+/**
+ * \internal
+ * \def ERROR_FUNC(name, msg)
+ * \brief Fail compilation if function call isn't eliminated
+ *
+ * If the compiler fails to optimize away all calls to the function \a
+ * name, terminate compilation and display \a msg to the user.
+ *
+ * \note Not all compilers support this, so this is best-effort only.
+ * Sometimes, there may be a linker error instead, and when optimization
+ * is disabled, this mechanism will be completely disabled.
+ */
+#ifndef ERROR_FUNC
+# define ERROR_FUNC(name, msg) \
+ extern int name(void)
+#endif
+
+//@}
+
+//! \name Function call demultiplexing
+//@{
+
+//! Error function for failed demultiplexing.
+ERROR_FUNC(compiler_demux_bad_size, "Invalid parameter size");
+
+/**
+ * \internal
+ * \brief Demultiplex function call based on size of datatype
+ *
+ * Evaluates to a function call to a function name with suffix 8, 16 or 32
+ * depending on the size of the datatype. Any number of parameters can be
+ * passed to the function.
+ *
+ * Usage:
+ * \code
+ void foo8(uint8_t a, void *b);
+ void foo16(uint16_t a, void *b);
+ void foo32(uint32_t a, void *b);
+
+ #define foo(x, y) compiler_demux_size(sizeof(x), foo, x, y)
+\endcode
+ *
+ * \param size Size of the datatype.
+ * \param func Base function name.
+ * \param ... List of parameters to pass to the function.
+ */
+#define compiler_demux_size(size, func, ...) \
+ (((size) == 1) ? func##8(__VA_ARGS__) : \
+ ((size) == 2) ? func##16(__VA_ARGS__) : \
+ ((size) == 4) ? func##32(__VA_ARGS__) : \
+ compiler_demux_bad_size())
+
+//@}
+
+/**
+ * \def __always_inline
+ * \brief The function should always be inlined.
+ *
+ * This annotation instructs the compiler to ignore its inlining
+ * heuristics and inline the function no matter how big it thinks it
+ * becomes.
+ */
+#if (defined __GNUC__)
+ #define __always_inline inline __attribute__((__always_inline__))
+#elif (defined __ICCAVR__)
+ #define __always_inline _Pragma("inline=forced")
+#endif
+
+//! \name Optimization Control
+//@{
+
+/**
+ * \def __always_optimize
+ * \brief The function should always be optimized.
+ *
+ * This annotation instructs the compiler to ignore global optimization
+ * settings and always compile the function with a high level of
+ * optimization.
+ */
+#if (defined __GNUC__)
+ #define __always_optimize __attribute__((optimize(3)))
+#elif (defined __ICCAVR__)
+ #define __always_optimize _Pragma("optimize=high")
+#endif
+
+/**
+ * \def likely(exp)
+ * \brief The expression \a exp is likely to be true
+ */
+#ifndef likely
+# define likely(exp) (exp)
+#endif
+
+/**
+ * \def unlikely(exp)
+ * \brief The expression \a exp is unlikely to be true
+ */
+#ifndef unlikely
+# define unlikely(exp) (exp)
+#endif
+
+/**
+ * \def is_constant(exp)
+ * \brief Determine if an expression evaluates to a constant value.
+ *
+ * \param exp Any expression
+ *
+ * \return true if \a exp is constant, false otherwise.
+ */
+#ifdef __GNUC__
+# define is_constant(exp) __builtin_constant_p(exp)
+#else
+# define is_constant(exp) (0)
+#endif
+
+//! @}
+
+/*! \name Bit-Field Handling
+ */
+#include "bit_handling/clz_ctz.h"
+//! @{
+
+/*! \brief Reads the bits of a value specified by a given bit-mask.
+ *
+ * \param value Value to read bits from.
+ * \param mask Bit-mask indicating bits to read.
+ *
+ * \return Read bits.
+ */
+#define Rd_bits( value, mask) ((value)&(mask))
+
+/*! \brief Writes the bits of a C lvalue specified by a given bit-mask.
+ *
+ * \param lvalue C lvalue to write bits to.
+ * \param mask Bit-mask indicating bits to write.
+ * \param bits Bits to write.
+ *
+ * \return Resulting value with written bits.
+ */
+#define Wr_bits(lvalue, mask, bits) ((lvalue) = ((lvalue) & ~(mask)) |\
+ ((bits ) & (mask)))
+
+/*! \brief Tests the bits of a value specified by a given bit-mask.
+ *
+ * \param value Value of which to test bits.
+ * \param mask Bit-mask indicating bits to test.
+ *
+ * \return \c 1 if at least one of the tested bits is set, else \c 0.
+ */
+#define Tst_bits( value, mask) (Rd_bits(value, mask) != 0)
+
+/*! \brief Clears the bits of a C lvalue specified by a given bit-mask.
+ *
+ * \param lvalue C lvalue of which to clear bits.
+ * \param mask Bit-mask indicating bits to clear.
+ *
+ * \return Resulting value with cleared bits.
+ */
+#define Clr_bits(lvalue, mask) ((lvalue) &= ~(mask))
+
+/*! \brief Sets the bits of a C lvalue specified by a given bit-mask.
+ *
+ * \param lvalue C lvalue of which to set bits.
+ * \param mask Bit-mask indicating bits to set.
+ *
+ * \return Resulting value with set bits.
+ */
+#define Set_bits(lvalue, mask) ((lvalue) |= (mask))
+
+/*! \brief Toggles the bits of a C lvalue specified by a given bit-mask.
+ *
+ * \param lvalue C lvalue of which to toggle bits.
+ * \param mask Bit-mask indicating bits to toggle.
+ *
+ * \return Resulting value with toggled bits.
+ */
+#define Tgl_bits(lvalue, mask) ((lvalue) ^= (mask))
+
+/*! \brief Reads the bit-field of a value specified by a given bit-mask.
+ *
+ * \param value Value to read a bit-field from.
+ * \param mask Bit-mask indicating the bit-field to read.
+ *
+ * \return Read bit-field.
+ */
+#define Rd_bitfield( value,mask) (Rd_bits( value, (uint32_t)mask) >> ctz(mask))
+
+/*! \brief Writes the bit-field of a C lvalue specified by a given bit-mask.
+ *
+ * \param lvalue C lvalue to write a bit-field to.
+ * \param mask Bit-mask indicating the bit-field to write.
+ * \param bitfield Bit-field to write.
+ *
+ * \return Resulting value with written bit-field.
+ */
+#define Wr_bitfield(lvalue, mask, bitfield) (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask)))
+
+//! @}
+
+
+/*! \brief This macro is used to test fatal errors.
+ *
+ * The macro tests if the expression is false. If it is, a fatal error is
+ * detected and the application hangs up. If TEST_SUITE_DEFINE_ASSERT_MACRO
+ * is defined, a unit test version of the macro is used, to allow execution
+ * of further tests after a false expression.
+ *
+ * \param expr Expression to evaluate and supposed to be nonzero.
+ */
+#if defined(_ASSERT_ENABLE_)
+# if defined(TEST_SUITE_DEFINE_ASSERT_MACRO)
+ // Assert() is defined in unit_test/suite.h
+# include "unit_test/suite.h"
+# else
+# define Assert(expr) \
+ {\
+ if (!(expr)) while (true);\
+ }
+# endif
+#else
+# define Assert(expr) ((void) 0)
+#endif
+
+/*! \name Bit Reversing
+ */
+//! @{
+
+/*! \brief Reverses the bits of \a u8.
+ *
+ * \param u8 U8 of which to reverse the bits.
+ *
+ * \return Value resulting from \a u8 with reversed bits.
+ */
+#define bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24))
+
+/*! \brief Reverses the bits of \a u16.
+ *
+ * \param u16 U16 of which to reverse the bits.
+ *
+ * \return Value resulting from \a u16 with reversed bits.
+ */
+#define bit_reverse16(u16) ((U16)(bit_reverse32((U16)(u16)) >> 16))
+
+/*! \brief Reverses the bits of \a u32.
+ *
+ * \param u32 U32 of which to reverse the bits.
+ *
+ * \return Value resulting from \a u32 with reversed bits.
+ */
+#if (defined __GNUC__)
+ #define bit_reverse32(u32) \
+ (\
+ {\
+ unsigned int __value = (U32)(u32);\
+ __asm__ ("brev\t%0" : "+r" (__value) : : "cc");\
+ (U32)__value;\
+ }\
+ )
+#elif (defined __ICCAVR__)
+ #define bit_reverse32(u32) ((U32)__bit_reverse((U32)(u32)))
+#endif
+
+/*! \brief Reverses the bits of \a u64.
+ *
+ * \param u64 U64 of which to reverse the bits.
+ *
+ * \return Value resulting from \a u64 with reversed bits.
+ */
+#define bit_reverse64(u64) ((U64)(((U64)bit_reverse32((U64)(u64) >> 32)) |\
+ ((U64)bit_reverse32((U64)(u64)) << 32)))
+
+//! @}
+
+//! \name Logarithmic functions
+//! @{
+
+/**
+ * \internal
+ * Undefined function. Will cause a link failure if ilog2() is called
+ * with an invalid constant value.
+ */
+int_fast8_t ilog2_undefined(void);
+
+/**
+ * \brief Calculate the base-2 logarithm of a number rounded down to
+ * the nearest integer.
+ *
+ * \param x A 32-bit value
+ * \return The base-2 logarithm of \a x, or -1 if \a x is 0.
+ */
+static inline int_fast8_t ilog2(uint32_t x)
+{
+ if (is_constant(x))
+ return ((x) & (1ULL << 31) ? 31 :
+ (x) & (1ULL << 30) ? 30 :
+ (x) & (1ULL << 29) ? 29 :
+ (x) & (1ULL << 28) ? 28 :
+ (x) & (1ULL << 27) ? 27 :
+ (x) & (1ULL << 26) ? 26 :
+ (x) & (1ULL << 25) ? 25 :
+ (x) & (1ULL << 24) ? 24 :
+ (x) & (1ULL << 23) ? 23 :
+ (x) & (1ULL << 22) ? 22 :
+ (x) & (1ULL << 21) ? 21 :
+ (x) & (1ULL << 20) ? 20 :
+ (x) & (1ULL << 19) ? 19 :
+ (x) & (1ULL << 18) ? 18 :
+ (x) & (1ULL << 17) ? 17 :
+ (x) & (1ULL << 16) ? 16 :
+ (x) & (1ULL << 15) ? 15 :
+ (x) & (1ULL << 14) ? 14 :
+ (x) & (1ULL << 13) ? 13 :
+ (x) & (1ULL << 12) ? 12 :
+ (x) & (1ULL << 11) ? 11 :
+ (x) & (1ULL << 10) ? 10 :
+ (x) & (1ULL << 9) ? 9 :
+ (x) & (1ULL << 8) ? 8 :
+ (x) & (1ULL << 7) ? 7 :
+ (x) & (1ULL << 6) ? 6 :
+ (x) & (1ULL << 5) ? 5 :
+ (x) & (1ULL << 4) ? 4 :
+ (x) & (1ULL << 3) ? 3 :
+ (x) & (1ULL << 2) ? 2 :
+ (x) & (1ULL << 1) ? 1 :
+ (x) & (1ULL << 0) ? 0 :
+ ilog2_undefined());
+
+ return 31 - clz(x);
+}
+
+//! @}
+
+/*! \name Alignment
+ */
+//! @{
+
+/*! \brief Tests alignment of the number \a val with the \a n boundary.
+ *
+ * \param val Input value.
+ * \param n Boundary.
+ *
+ * \return \c 1 if the number \a val is aligned with the \a n boundary, else \c 0.
+ */
+#define Test_align(val, n ) (!Tst_bits( val, (n) - 1 ) )
+
+/*! \brief Gets alignment of the number \a val with respect to the \a n boundary.
+ *
+ * \param val Input value.
+ * \param n Boundary.
+ *
+ * \return Alignment of the number \a val with respect to the \a n boundary.
+ */
+#define Get_align( val, n ) ( Rd_bits( val, (n) - 1 ) )
+
+/*! \brief Sets alignment of the lvalue number \a lval to \a alg with respect to the \a n boundary.
+ *
+ * \param lval Input/output lvalue.
+ * \param n Boundary.
+ * \param alg Alignment.
+ *
+ * \return New value of \a lval resulting from its alignment set to \a alg with respect to the \a n boundary.
+ */
+#define Set_align(lval, n, alg) ( Wr_bits(lval, (n) - 1, alg) )
+
+/*! \brief Aligns the number \a val with the upper \a n boundary.
+ *
+ * \param val Input value.
+ * \param n Boundary.
+ *
+ * \return Value resulting from the number \a val aligned with the upper \a n boundary.
+ */
+#define Align_up( val, n ) (((val) + ((n) - 1)) & ~((n) - 1))
+
+/*! \brief Aligns the number \a val with the lower \a n boundary.
+ *
+ * \param val Input value.
+ * \param n Boundary.
+ *
+ * \return Value resulting from the number \a val aligned with the lower \a n boundary.
+ */
+#define Align_down(val, n ) ( (val) & ~((n) - 1))
+
+//! @}
+
+
+/*! \name Mathematics
+ *
+ * Compiler optimization for non-constant expressions, only for abs under WinAVR
+ */
+//! @{
+
+/*! \brief Takes the absolute value of \a a.
+ *
+ * \param a Input value.
+ *
+ * \return Absolute value of \a a.
+ *
+ * \note More optimized if only used with values known at compile time.
+ */
+#define Abs(a) (((a) < 0 ) ? -(a) : (a))
+#ifndef abs
+#define abs(a) Abs(a)
+#endif
+
+/*! \brief Takes the minimal value of \a a and \a b.
+ *
+ * \param a Input value.
+ * \param b Input value.
+ *
+ * \return Minimal value of \a a and \a b.
+ *
+ * \note More optimized if only used with values known at compile time.
+ */
+#define Min(a, b) (((a) < (b)) ? (a) : (b))
+#define min(a, b) Min(a, b)
+
+/*! \brief Takes the maximal value of \a a and \a b.
+ *
+ * \param a Input value.
+ * \param b Input value.
+ *
+ * \return Maximal value of \a a and \a b.
+ *
+ * \note More optimized if only used with values known at compile time.
+ */
+#define Max(a, b) (((a) > (b)) ? (a) : (b))
+#define max(a, b) Max(a, b)
+
+//! @}
+
+
+/*! \brief Calls the routine at address \a addr.
+ *
+ * It generates a long call opcode.
+ *
+ * For example, `Long_call(0x80000000)' generates a software reset on a UC3 if
+ * it is invoked from the CPU supervisor mode.
+ *
+ * \param addr Address of the routine to call.
+ *
+ * \note It may be used as a long jump opcode in some special cases.
+ */
+#define Long_call(addr) ((*(void (*)(void))(addr))())
+
+/*! \name System Register Access
+ */
+//! @{
+
+/*! \brief Gets the value of the \a sysreg system register.
+ *
+ * \param sysreg Address of the system register of which to get the value.
+ *
+ * \return Value of the \a sysreg system register.
+ */
+#if (defined __GNUC__)
+ #define Get_system_register(sysreg) __builtin_mfsr(sysreg)
+#elif (defined __ICCAVR__)
+ #define Get_system_register(sysreg) __get_system_register(sysreg)
+#endif
+
+/*! \brief Sets the value of the \a sysreg system register to \a value.
+ *
+ * \param sysreg Address of the system register of which to set the value.
+ * \param value Value to set the \a sysreg system register to.
+ */
+#if (defined __GNUC__)
+ #define Set_system_register(sysreg, value) __builtin_mtsr(sysreg, value)
+#elif (defined __ICCAVR__)
+ #define Set_system_register(sysreg, value) __set_system_register(sysreg, value)
+#endif
+
+//! @}
+
+/*! \name Debug Register Access
+ */
+//! @{
+
+/*! \brief Gets the value of the \a dbgreg debug register.
+ *
+ * \param dbgreg Address of the debug register of which to get the value.
+ *
+ * \return Value of the \a dbgreg debug register.
+ */
+#if (defined __GNUC__)
+ #define Get_debug_register(dbgreg) __builtin_mfdr(dbgreg)
+#elif (defined __ICCAVR__)
+ #define Get_debug_register(dbgreg) __get_debug_register(dbgreg)
+#endif
+
+/*! \brief Sets the value of the \a dbgreg debug register to \a value.
+ *
+ * \param dbgreg Address of the debug register of which to set the value.
+ * \param value Value to set the \a dbgreg debug register to.
+ */
+#if (defined __GNUC__)
+ #define Set_debug_register(dbgreg, value) __builtin_mtdr(dbgreg, value)
+#elif (defined __ICCAVR__)
+ #define Set_debug_register(dbgreg, value) __set_debug_register(dbgreg, value)
+#endif
+
+//! @}
+
+
+/*! \name MCU Endianism Handling
+ * xmega is a MCU little endianism.
+ */
+//! @{
+#define MSB(u16) (((uint8_t* )&u16)[1])
+#define LSB(u16) (((uint8_t* )&u16)[0])
+
+#define MSW(u32) (((uint16_t*)&u32)[1])
+#define LSW(u32) (((uint16_t*)&u32)[0])
+#define MSB0W(u32) (((uint8_t*)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32.
+#define MSB1W(u32) (((uint8_t*)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32.
+#define MSB2W(u32) (((uint8_t*)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32.
+#define MSB3W(u32) (((uint8_t*)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32.
+#define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32.
+#define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32.
+#define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32.
+#define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32.
+
+#define MSB0(u32) (((uint8_t*)&u32)[3])
+#define MSB1(u32) (((uint8_t*)&u32)[2])
+#define MSB2(u32) (((uint8_t*)&u32)[1])
+#define MSB3(u32) (((uint8_t*)&u32)[0])
+#define LSB0(u32) MSB3(u32)
+#define LSB1(u32) MSB2(u32)
+#define LSB2(u32) MSB1(u32)
+#define LSB3(u32) MSB0(u32)
+
+#define LE16(x) (x)
+#define le16_to_cpu(x) (x)
+#define cpu_to_le16(x) (x)
+#define LE16_TO_CPU(x) (x)
+#define CPU_TO_LE16(x) (x)
+
+#define BE16(x) Swap16(x)
+#define be16_to_cpu(x) swap16(x)
+#define cpu_to_be16(x) swap16(x)
+#define BE16_TO_CPU(x) Swap16(x)
+#define CPU_TO_BE16(x) Swap16(x)
+
+#define LE32(x) (x)
+#define le32_to_cpu(x) (x)
+#define cpu_to_le32(x) (x)
+#define LE32_TO_CPU(x) (x)
+#define CPU_TO_LE32(x) (x)
+
+#define BE32(x) Swap32(x)
+#define be32_to_cpu(x) swap32(x)
+#define cpu_to_be32(x) swap32(x)
+#define BE32_TO_CPU(x) Swap32(x)
+#define CPU_TO_BE32(x) Swap32(x)
+
+
+
+//! @}
+
+
+/*! \name Endianism Conversion
+ *
+ * The same considerations as for clz and ctz apply here but AVR32-GCC's
+ * __builtin_bswap_16 and __builtin_bswap_32 do not behave like macros when
+ * applied to constant expressions, so two sets of macros are defined here:
+ * - Swap16, Swap32 and Swap64 to apply to constant expressions (values known
+ * at compile time);
+ * - swap16, swap32 and swap64 to apply to non-constant expressions (values
+ * unknown at compile time).
+ */
+//! @{
+
+/*! \brief Toggles the endianism of \a u16 (by swapping its bytes).
+ *
+ * \param u16 U16 of which to toggle the endianism.
+ *
+ * \return Value resulting from \a u16 with toggled endianism.
+ *
+ * \note More optimized if only used with values known at compile time.
+ */
+#define Swap16(u16) ((U16)(((U16)(u16) >> 8) |\
+ ((U16)(u16) << 8)))
+
+/*! \brief Toggles the endianism of \a u32 (by swapping its bytes).
+ *
+ * \param u32 U32 of which to toggle the endianism.
+ *
+ * \return Value resulting from \a u32 with toggled endianism.
+ *
+ * \note More optimized if only used with values known at compile time.
+ */
+#define Swap32(u32) ((U32)(((U32)Swap16((U32)(u32) >> 16)) |\
+ ((U32)Swap16((U32)(u32)) << 16)))
+
+/*! \brief Toggles the endianism of \a u64 (by swapping its bytes).
+ *
+ * \param u64 U64 of which to toggle the endianism.
+ *
+ * \return Value resulting from \a u64 with toggled endianism.
+ *
+ * \note More optimized if only used with values known at compile time.
+ */
+#define Swap64(u64) ((U64)(((U64)Swap32((U64)(u64) >> 32)) |\
+ ((U64)Swap32((U64)(u64)) << 32)))
+
+/*! \brief Toggles the endianism of \a u16 (by swapping its bytes).
+ *
+ * \param u16 U16 of which to toggle the endianism.
+ *
+ * \return Value resulting from \a u16 with toggled endianism.
+ *
+ * \note More optimized if only used with values unknown at compile time.
+ */
+#define swap16(u16) Swap16(u16)
+
+/*! \brief Toggles the endianism of \a u32 (by swapping its bytes).
+ *
+ * \param u32 U32 of which to toggle the endianism.
+ *
+ * \return Value resulting from \a u32 with toggled endianism.
+ *
+ * \note More optimized if only used with values unknown at compile time.
+ */
+#define swap32(u32) Swap32(u32)
+
+/*! \brief Toggles the endianism of \a u64 (by swapping its bytes).
+ *
+ * \param u64 U64 of which to toggle the endianism.
+ *
+ * \return Value resulting from \a u64 with toggled endianism.
+ *
+ * \note More optimized if only used with values unknown at compile time.
+ */
+#define swap64(u64) ((U64)(((U64)swap32((U64)(u64) >> 32)) |\
+ ((U64)swap32((U64)(u64)) << 32)))
+
+//! @}
+
+
+/*! \name Target Abstraction
+ */
+//! @{
+
+#define _GLOBEXT_ extern //!< extern storage-class specifier.
+#define _CONST_TYPE_ const //!< const type qualifier.
+#define _MEM_TYPE_SLOW_ //!< Slow memory type.
+#define _MEM_TYPE_MEDFAST_ //!< Fairly fast memory type.
+#define _MEM_TYPE_FAST_ //!< Fast memory type.
+
+typedef U8 Byte; //!< 8-bit unsigned integer.
+
+#define memcmp_ram2ram memcmp //!< Target-specific memcmp of RAM to RAM.
+#define memcmp_code2ram memcmp //!< Target-specific memcmp of RAM to NVRAM.
+#define memcpy_ram2ram memcpy //!< Target-specific memcpy from RAM to RAM.
+#define memcpy_code2ram memcpy //!< Target-specific memcpy from NVRAM to RAM.
+
+//! @}
+
+/**
+ * \brief Calculate \f$ \left\lceil \frac{a}{b} \right\rceil \f$ using
+ * integer arithmetic.
+ *
+ * \param a An integer
+ * \param b Another integer
+ *
+ * \return (\a a / \a b) rounded up to the nearest integer.
+ */
+#define div_ceil(a, b) (((a) + (b) - 1) / (b))
+
+#include "preprocessor.h"
+#include "progmem.h"
+#include "interrupt.h"
+
+
+#if (defined __GNUC__)
+ #define SHORTENUM __attribute__ ((packed))
+#elif (defined __ICCAVR__)
+ #define SHORTENUM /**/
+#endif
+
+#if (defined __GNUC__)
+ #define FUNC_PTR void *
+#elif (defined __ICCAVR__)
+#if (FLASHEND > 0x1FFFF) // Required for program code larger than 128K
+ #define FUNC_PTR void __farflash *
+#else
+ #define FUNC_PTR void *
+#endif /* ENABLE_FAR_FLASH */
+#endif
+
+
+#if (defined __GNUC__)
+ #define FLASH_DECLARE(x) const x __attribute__((__progmem__))
+#elif (defined __ICCAVR__)
+ #define FLASH_DECLARE(x) const __flash x
+#endif
+
+#if (defined __GNUC__)
+ #define FLASH_EXTERN(x) extern const x
+#elif (defined __ICCAVR__)
+ #define FLASH_EXTERN(x) extern const __flash x
+#endif
+
+
+/*Defines the Flash Storage for the request and response of MAC*/
+#define CMD_ID_OCTET (0)
+
+/* Converting of values from CPU endian to little endian. */
+#define CPU_ENDIAN_TO_LE16(x) (x)
+#define CPU_ENDIAN_TO_LE32(x) (x)
+#define CPU_ENDIAN_TO_LE64(x) (x)
+
+/* Converting of values from little endian to CPU endian. */
+#define LE16_TO_CPU_ENDIAN(x) (x)
+#define LE32_TO_CPU_ENDIAN(x) (x)
+#define LE64_TO_CPU_ENDIAN(x) (x)
+
+/* Converting of constants from little endian to CPU endian. */
+#define CLE16_TO_CPU_ENDIAN(x) (x)
+#define CLE32_TO_CPU_ENDIAN(x) (x)
+#define CLE64_TO_CPU_ENDIAN(x) (x)
+
+/* Converting of constants from CPU endian to little endian. */
+#define CCPU_ENDIAN_TO_LE16(x) (x)
+#define CCPU_ENDIAN_TO_LE32(x) (x)
+#define CCPU_ENDIAN_TO_LE64(x) (x)
+
+#if (defined __GNUC__)
+ #define ADDR_COPY_DST_SRC_16(dst, src) memcpy((&(dst)), (&(src)), sizeof(uint16_t))
+ #define ADDR_COPY_DST_SRC_64(dst, src) memcpy((&(dst)), (&(src)), sizeof(uint64_t))
+
+/* Converts a 2 Byte array into a 16-Bit value */
+#define convert_byte_array_to_16_bit(data) \
+ (*(uint16_t *)(data))
+
+/* Converts a 4 Byte array into a 32-Bit value */
+#define convert_byte_array_to_32_bit(data) \
+ (*(uint32_t *)(data))
+
+/* Converts a 8 Byte array into a 64-Bit value */
+#define convert_byte_array_to_64_bit(data) \
+ (*(uint64_t *)(data))
+
+/* Converts a 16-Bit value into a 2 Byte array */
+#define convert_16_bit_to_byte_array(value, data) \
+ ((*(uint16_t *)(data)) = (uint16_t)(value))
+
+/* Converts spec 16-Bit value into a 2 Byte array */
+#define convert_spec_16_bit_to_byte_array(value, data) \
+ ((*(uint16_t *)(data)) = (uint16_t)(value))
+
+/* Converts spec 16-Bit value into a 2 Byte array */
+#define convert_16_bit_to_byte_address(value, data) \
+ ((*(uint16_t *)(data)) = (uint16_t)(value))
+
+/* Converts a 32-Bit value into a 4 Byte array */
+#define convert_32_bit_to_byte_array(value, data) \
+ ((*(uint32_t *)(data)) = (uint32_t)(value))
+
+/* Converts a 64-Bit value into a 8 Byte array */
+/* Here memcpy requires much less footprint */
+#define convert_64_bit_to_byte_array(value, data) \
+ memcpy((data), (&(value)), sizeof(uint64_t))
+
+#elif (defined __ICCAVR__)
+ #define ADDR_COPY_DST_SRC_16(dst, src) ((dst) = (src))
+ #define ADDR_COPY_DST_SRC_64(dst, src) ((dst) = (src))
+
+/* Converts a 2 Byte array into a 16-Bit value */
+#define convert_byte_array_to_16_bit(data) \
+ (*(uint16_t *)(data))
+
+/* Converts a 4 Byte array into a 32-Bit value */
+#define convert_byte_array_to_32_bit(data) \
+ (*(uint32_t *)(data))
+
+/* Converts a 8 Byte array into a 64-Bit value */
+#define convert_byte_array_to_64_bit(data) \
+ (*(uint64_t *)(data))
+
+/* Converts a 16-Bit value into a 2 Byte array */
+#define convert_16_bit_to_byte_array(value, data) \
+ ((*(uint16_t *)(data)) = (uint16_t)(value))
+
+/* Converts spec 16-Bit value into a 2 Byte array */
+#define convert_spec_16_bit_to_byte_array(value, data) \
+ ((*(uint16_t *)(data)) = (uint16_t)(value))
+
+/* Converts spec 16-Bit value into a 2 Byte array */
+#define convert_16_bit_to_byte_address(value, data) \
+ ((*(uint16_t *)(data)) = (uint16_t)(value))
+
+/* Converts a 32-Bit value into a 4 Byte array */
+#define convert_32_bit_to_byte_array(value, data) \
+ ((*(uint32_t *)(data)) = (uint32_t)(value))
+
+/* Converts a 64-Bit value into a 8 Byte array */
+#define convert_64_bit_to_byte_array(value, data) \
+ ((*(uint64_t *)(data)) = (uint64_t)(value))
+#endif
+
+#define MEMCPY_ENDIAN memcpy
+#define PGM_READ_BLOCK(dst, src, len) memcpy_P((dst), (src), (len))
+
+#if (defined __GNUC__)
+ #define PGM_READ_BYTE(x) pgm_read_byte(x)
+ #define PGM_READ_WORD(x) pgm_read_word(x)
+#elif (defined __ICCAVR__)
+ #define PGM_READ_BYTE(x) *(x)
+ #define PGM_READ_WORD(x) *(x)
+#endif
+
+
+#if (defined __GNUC__)
+ #define nop() do { __asm__ __volatile__ ("nop"); } while (0)
+#elif (defined __ICCAVR__)
+ #define nop() __no_operation()
+#endif
+
+
+/**
+ * \}
+ */
+
+#endif // UTILS_COMPILER_H
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/compiler.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/compiler.h.REMOVED.git-id
deleted file mode 100644
index 72430898..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/compiler.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5e4f2c43a1c12e97919b724c2efe119508645411
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/mrepeat.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/mrepeat.h
new file mode 100644
index 00000000..f4f9c94c
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/mrepeat.h
@@ -0,0 +1,338 @@
+/**
+ * \file
+ *
+ * \brief Preprocessor macro repeating utils.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _MREPEAT_H_
+#define _MREPEAT_H_
+
+/**
+ * \defgroup group_xmega_utils_mrepeat Macro Repeat
+ *
+ * \ingroup group_xmega_utils
+ *
+ * \{
+ */
+
+#include "preprocessor.h"
+
+
+//! Maximal number of repetitions supported by MREPEAT.
+#define MREPEAT_LIMIT 256
+
+/*! \brief Macro repeat.
+ *
+ * This macro represents a horizontal repetition construct.
+ *
+ * \param count The number of repetitious calls to macro. Valid values range from 0 to MREPEAT_LIMIT.
+ * \param macro A binary operation of the form macro(n, data). This macro is expanded by MREPEAT with
+ * the current repetition number and the auxiliary data argument.
+ * \param data Auxiliary data passed to macro.
+ *
+ * \return macro(0, data) macro(1, data) ... macro(count - 1, data)
+ */
+#define MREPEAT(count, macro, data) TPASTE2(MREPEAT, count)(macro, data)
+
+#define MREPEAT0( macro, data)
+#define MREPEAT1( macro, data) MREPEAT0( macro, data) macro( 0, data)
+#define MREPEAT2( macro, data) MREPEAT1( macro, data) macro( 1, data)
+#define MREPEAT3( macro, data) MREPEAT2( macro, data) macro( 2, data)
+#define MREPEAT4( macro, data) MREPEAT3( macro, data) macro( 3, data)
+#define MREPEAT5( macro, data) MREPEAT4( macro, data) macro( 4, data)
+#define MREPEAT6( macro, data) MREPEAT5( macro, data) macro( 5, data)
+#define MREPEAT7( macro, data) MREPEAT6( macro, data) macro( 6, data)
+#define MREPEAT8( macro, data) MREPEAT7( macro, data) macro( 7, data)
+#define MREPEAT9( macro, data) MREPEAT8( macro, data) macro( 8, data)
+#define MREPEAT10( macro, data) MREPEAT9( macro, data) macro( 9, data)
+#define MREPEAT11( macro, data) MREPEAT10( macro, data) macro( 10, data)
+#define MREPEAT12( macro, data) MREPEAT11( macro, data) macro( 11, data)
+#define MREPEAT13( macro, data) MREPEAT12( macro, data) macro( 12, data)
+#define MREPEAT14( macro, data) MREPEAT13( macro, data) macro( 13, data)
+#define MREPEAT15( macro, data) MREPEAT14( macro, data) macro( 14, data)
+#define MREPEAT16( macro, data) MREPEAT15( macro, data) macro( 15, data)
+#define MREPEAT17( macro, data) MREPEAT16( macro, data) macro( 16, data)
+#define MREPEAT18( macro, data) MREPEAT17( macro, data) macro( 17, data)
+#define MREPEAT19( macro, data) MREPEAT18( macro, data) macro( 18, data)
+#define MREPEAT20( macro, data) MREPEAT19( macro, data) macro( 19, data)
+#define MREPEAT21( macro, data) MREPEAT20( macro, data) macro( 20, data)
+#define MREPEAT22( macro, data) MREPEAT21( macro, data) macro( 21, data)
+#define MREPEAT23( macro, data) MREPEAT22( macro, data) macro( 22, data)
+#define MREPEAT24( macro, data) MREPEAT23( macro, data) macro( 23, data)
+#define MREPEAT25( macro, data) MREPEAT24( macro, data) macro( 24, data)
+#define MREPEAT26( macro, data) MREPEAT25( macro, data) macro( 25, data)
+#define MREPEAT27( macro, data) MREPEAT26( macro, data) macro( 26, data)
+#define MREPEAT28( macro, data) MREPEAT27( macro, data) macro( 27, data)
+#define MREPEAT29( macro, data) MREPEAT28( macro, data) macro( 28, data)
+#define MREPEAT30( macro, data) MREPEAT29( macro, data) macro( 29, data)
+#define MREPEAT31( macro, data) MREPEAT30( macro, data) macro( 30, data)
+#define MREPEAT32( macro, data) MREPEAT31( macro, data) macro( 31, data)
+#define MREPEAT33( macro, data) MREPEAT32( macro, data) macro( 32, data)
+#define MREPEAT34( macro, data) MREPEAT33( macro, data) macro( 33, data)
+#define MREPEAT35( macro, data) MREPEAT34( macro, data) macro( 34, data)
+#define MREPEAT36( macro, data) MREPEAT35( macro, data) macro( 35, data)
+#define MREPEAT37( macro, data) MREPEAT36( macro, data) macro( 36, data)
+#define MREPEAT38( macro, data) MREPEAT37( macro, data) macro( 37, data)
+#define MREPEAT39( macro, data) MREPEAT38( macro, data) macro( 38, data)
+#define MREPEAT40( macro, data) MREPEAT39( macro, data) macro( 39, data)
+#define MREPEAT41( macro, data) MREPEAT40( macro, data) macro( 40, data)
+#define MREPEAT42( macro, data) MREPEAT41( macro, data) macro( 41, data)
+#define MREPEAT43( macro, data) MREPEAT42( macro, data) macro( 42, data)
+#define MREPEAT44( macro, data) MREPEAT43( macro, data) macro( 43, data)
+#define MREPEAT45( macro, data) MREPEAT44( macro, data) macro( 44, data)
+#define MREPEAT46( macro, data) MREPEAT45( macro, data) macro( 45, data)
+#define MREPEAT47( macro, data) MREPEAT46( macro, data) macro( 46, data)
+#define MREPEAT48( macro, data) MREPEAT47( macro, data) macro( 47, data)
+#define MREPEAT49( macro, data) MREPEAT48( macro, data) macro( 48, data)
+#define MREPEAT50( macro, data) MREPEAT49( macro, data) macro( 49, data)
+#define MREPEAT51( macro, data) MREPEAT50( macro, data) macro( 50, data)
+#define MREPEAT52( macro, data) MREPEAT51( macro, data) macro( 51, data)
+#define MREPEAT53( macro, data) MREPEAT52( macro, data) macro( 52, data)
+#define MREPEAT54( macro, data) MREPEAT53( macro, data) macro( 53, data)
+#define MREPEAT55( macro, data) MREPEAT54( macro, data) macro( 54, data)
+#define MREPEAT56( macro, data) MREPEAT55( macro, data) macro( 55, data)
+#define MREPEAT57( macro, data) MREPEAT56( macro, data) macro( 56, data)
+#define MREPEAT58( macro, data) MREPEAT57( macro, data) macro( 57, data)
+#define MREPEAT59( macro, data) MREPEAT58( macro, data) macro( 58, data)
+#define MREPEAT60( macro, data) MREPEAT59( macro, data) macro( 59, data)
+#define MREPEAT61( macro, data) MREPEAT60( macro, data) macro( 60, data)
+#define MREPEAT62( macro, data) MREPEAT61( macro, data) macro( 61, data)
+#define MREPEAT63( macro, data) MREPEAT62( macro, data) macro( 62, data)
+#define MREPEAT64( macro, data) MREPEAT63( macro, data) macro( 63, data)
+#define MREPEAT65( macro, data) MREPEAT64( macro, data) macro( 64, data)
+#define MREPEAT66( macro, data) MREPEAT65( macro, data) macro( 65, data)
+#define MREPEAT67( macro, data) MREPEAT66( macro, data) macro( 66, data)
+#define MREPEAT68( macro, data) MREPEAT67( macro, data) macro( 67, data)
+#define MREPEAT69( macro, data) MREPEAT68( macro, data) macro( 68, data)
+#define MREPEAT70( macro, data) MREPEAT69( macro, data) macro( 69, data)
+#define MREPEAT71( macro, data) MREPEAT70( macro, data) macro( 70, data)
+#define MREPEAT72( macro, data) MREPEAT71( macro, data) macro( 71, data)
+#define MREPEAT73( macro, data) MREPEAT72( macro, data) macro( 72, data)
+#define MREPEAT74( macro, data) MREPEAT73( macro, data) macro( 73, data)
+#define MREPEAT75( macro, data) MREPEAT74( macro, data) macro( 74, data)
+#define MREPEAT76( macro, data) MREPEAT75( macro, data) macro( 75, data)
+#define MREPEAT77( macro, data) MREPEAT76( macro, data) macro( 76, data)
+#define MREPEAT78( macro, data) MREPEAT77( macro, data) macro( 77, data)
+#define MREPEAT79( macro, data) MREPEAT78( macro, data) macro( 78, data)
+#define MREPEAT80( macro, data) MREPEAT79( macro, data) macro( 79, data)
+#define MREPEAT81( macro, data) MREPEAT80( macro, data) macro( 80, data)
+#define MREPEAT82( macro, data) MREPEAT81( macro, data) macro( 81, data)
+#define MREPEAT83( macro, data) MREPEAT82( macro, data) macro( 82, data)
+#define MREPEAT84( macro, data) MREPEAT83( macro, data) macro( 83, data)
+#define MREPEAT85( macro, data) MREPEAT84( macro, data) macro( 84, data)
+#define MREPEAT86( macro, data) MREPEAT85( macro, data) macro( 85, data)
+#define MREPEAT87( macro, data) MREPEAT86( macro, data) macro( 86, data)
+#define MREPEAT88( macro, data) MREPEAT87( macro, data) macro( 87, data)
+#define MREPEAT89( macro, data) MREPEAT88( macro, data) macro( 88, data)
+#define MREPEAT90( macro, data) MREPEAT89( macro, data) macro( 89, data)
+#define MREPEAT91( macro, data) MREPEAT90( macro, data) macro( 90, data)
+#define MREPEAT92( macro, data) MREPEAT91( macro, data) macro( 91, data)
+#define MREPEAT93( macro, data) MREPEAT92( macro, data) macro( 92, data)
+#define MREPEAT94( macro, data) MREPEAT93( macro, data) macro( 93, data)
+#define MREPEAT95( macro, data) MREPEAT94( macro, data) macro( 94, data)
+#define MREPEAT96( macro, data) MREPEAT95( macro, data) macro( 95, data)
+#define MREPEAT97( macro, data) MREPEAT96( macro, data) macro( 96, data)
+#define MREPEAT98( macro, data) MREPEAT97( macro, data) macro( 97, data)
+#define MREPEAT99( macro, data) MREPEAT98( macro, data) macro( 98, data)
+#define MREPEAT100(macro, data) MREPEAT99( macro, data) macro( 99, data)
+#define MREPEAT101(macro, data) MREPEAT100(macro, data) macro(100, data)
+#define MREPEAT102(macro, data) MREPEAT101(macro, data) macro(101, data)
+#define MREPEAT103(macro, data) MREPEAT102(macro, data) macro(102, data)
+#define MREPEAT104(macro, data) MREPEAT103(macro, data) macro(103, data)
+#define MREPEAT105(macro, data) MREPEAT104(macro, data) macro(104, data)
+#define MREPEAT106(macro, data) MREPEAT105(macro, data) macro(105, data)
+#define MREPEAT107(macro, data) MREPEAT106(macro, data) macro(106, data)
+#define MREPEAT108(macro, data) MREPEAT107(macro, data) macro(107, data)
+#define MREPEAT109(macro, data) MREPEAT108(macro, data) macro(108, data)
+#define MREPEAT110(macro, data) MREPEAT109(macro, data) macro(109, data)
+#define MREPEAT111(macro, data) MREPEAT110(macro, data) macro(110, data)
+#define MREPEAT112(macro, data) MREPEAT111(macro, data) macro(111, data)
+#define MREPEAT113(macro, data) MREPEAT112(macro, data) macro(112, data)
+#define MREPEAT114(macro, data) MREPEAT113(macro, data) macro(113, data)
+#define MREPEAT115(macro, data) MREPEAT114(macro, data) macro(114, data)
+#define MREPEAT116(macro, data) MREPEAT115(macro, data) macro(115, data)
+#define MREPEAT117(macro, data) MREPEAT116(macro, data) macro(116, data)
+#define MREPEAT118(macro, data) MREPEAT117(macro, data) macro(117, data)
+#define MREPEAT119(macro, data) MREPEAT118(macro, data) macro(118, data)
+#define MREPEAT120(macro, data) MREPEAT119(macro, data) macro(119, data)
+#define MREPEAT121(macro, data) MREPEAT120(macro, data) macro(120, data)
+#define MREPEAT122(macro, data) MREPEAT121(macro, data) macro(121, data)
+#define MREPEAT123(macro, data) MREPEAT122(macro, data) macro(122, data)
+#define MREPEAT124(macro, data) MREPEAT123(macro, data) macro(123, data)
+#define MREPEAT125(macro, data) MREPEAT124(macro, data) macro(124, data)
+#define MREPEAT126(macro, data) MREPEAT125(macro, data) macro(125, data)
+#define MREPEAT127(macro, data) MREPEAT126(macro, data) macro(126, data)
+#define MREPEAT128(macro, data) MREPEAT127(macro, data) macro(127, data)
+#define MREPEAT129(macro, data) MREPEAT128(macro, data) macro(128, data)
+#define MREPEAT130(macro, data) MREPEAT129(macro, data) macro(129, data)
+#define MREPEAT131(macro, data) MREPEAT130(macro, data) macro(130, data)
+#define MREPEAT132(macro, data) MREPEAT131(macro, data) macro(131, data)
+#define MREPEAT133(macro, data) MREPEAT132(macro, data) macro(132, data)
+#define MREPEAT134(macro, data) MREPEAT133(macro, data) macro(133, data)
+#define MREPEAT135(macro, data) MREPEAT134(macro, data) macro(134, data)
+#define MREPEAT136(macro, data) MREPEAT135(macro, data) macro(135, data)
+#define MREPEAT137(macro, data) MREPEAT136(macro, data) macro(136, data)
+#define MREPEAT138(macro, data) MREPEAT137(macro, data) macro(137, data)
+#define MREPEAT139(macro, data) MREPEAT138(macro, data) macro(138, data)
+#define MREPEAT140(macro, data) MREPEAT139(macro, data) macro(139, data)
+#define MREPEAT141(macro, data) MREPEAT140(macro, data) macro(140, data)
+#define MREPEAT142(macro, data) MREPEAT141(macro, data) macro(141, data)
+#define MREPEAT143(macro, data) MREPEAT142(macro, data) macro(142, data)
+#define MREPEAT144(macro, data) MREPEAT143(macro, data) macro(143, data)
+#define MREPEAT145(macro, data) MREPEAT144(macro, data) macro(144, data)
+#define MREPEAT146(macro, data) MREPEAT145(macro, data) macro(145, data)
+#define MREPEAT147(macro, data) MREPEAT146(macro, data) macro(146, data)
+#define MREPEAT148(macro, data) MREPEAT147(macro, data) macro(147, data)
+#define MREPEAT149(macro, data) MREPEAT148(macro, data) macro(148, data)
+#define MREPEAT150(macro, data) MREPEAT149(macro, data) macro(149, data)
+#define MREPEAT151(macro, data) MREPEAT150(macro, data) macro(150, data)
+#define MREPEAT152(macro, data) MREPEAT151(macro, data) macro(151, data)
+#define MREPEAT153(macro, data) MREPEAT152(macro, data) macro(152, data)
+#define MREPEAT154(macro, data) MREPEAT153(macro, data) macro(153, data)
+#define MREPEAT155(macro, data) MREPEAT154(macro, data) macro(154, data)
+#define MREPEAT156(macro, data) MREPEAT155(macro, data) macro(155, data)
+#define MREPEAT157(macro, data) MREPEAT156(macro, data) macro(156, data)
+#define MREPEAT158(macro, data) MREPEAT157(macro, data) macro(157, data)
+#define MREPEAT159(macro, data) MREPEAT158(macro, data) macro(158, data)
+#define MREPEAT160(macro, data) MREPEAT159(macro, data) macro(159, data)
+#define MREPEAT161(macro, data) MREPEAT160(macro, data) macro(160, data)
+#define MREPEAT162(macro, data) MREPEAT161(macro, data) macro(161, data)
+#define MREPEAT163(macro, data) MREPEAT162(macro, data) macro(162, data)
+#define MREPEAT164(macro, data) MREPEAT163(macro, data) macro(163, data)
+#define MREPEAT165(macro, data) MREPEAT164(macro, data) macro(164, data)
+#define MREPEAT166(macro, data) MREPEAT165(macro, data) macro(165, data)
+#define MREPEAT167(macro, data) MREPEAT166(macro, data) macro(166, data)
+#define MREPEAT168(macro, data) MREPEAT167(macro, data) macro(167, data)
+#define MREPEAT169(macro, data) MREPEAT168(macro, data) macro(168, data)
+#define MREPEAT170(macro, data) MREPEAT169(macro, data) macro(169, data)
+#define MREPEAT171(macro, data) MREPEAT170(macro, data) macro(170, data)
+#define MREPEAT172(macro, data) MREPEAT171(macro, data) macro(171, data)
+#define MREPEAT173(macro, data) MREPEAT172(macro, data) macro(172, data)
+#define MREPEAT174(macro, data) MREPEAT173(macro, data) macro(173, data)
+#define MREPEAT175(macro, data) MREPEAT174(macro, data) macro(174, data)
+#define MREPEAT176(macro, data) MREPEAT175(macro, data) macro(175, data)
+#define MREPEAT177(macro, data) MREPEAT176(macro, data) macro(176, data)
+#define MREPEAT178(macro, data) MREPEAT177(macro, data) macro(177, data)
+#define MREPEAT179(macro, data) MREPEAT178(macro, data) macro(178, data)
+#define MREPEAT180(macro, data) MREPEAT179(macro, data) macro(179, data)
+#define MREPEAT181(macro, data) MREPEAT180(macro, data) macro(180, data)
+#define MREPEAT182(macro, data) MREPEAT181(macro, data) macro(181, data)
+#define MREPEAT183(macro, data) MREPEAT182(macro, data) macro(182, data)
+#define MREPEAT184(macro, data) MREPEAT183(macro, data) macro(183, data)
+#define MREPEAT185(macro, data) MREPEAT184(macro, data) macro(184, data)
+#define MREPEAT186(macro, data) MREPEAT185(macro, data) macro(185, data)
+#define MREPEAT187(macro, data) MREPEAT186(macro, data) macro(186, data)
+#define MREPEAT188(macro, data) MREPEAT187(macro, data) macro(187, data)
+#define MREPEAT189(macro, data) MREPEAT188(macro, data) macro(188, data)
+#define MREPEAT190(macro, data) MREPEAT189(macro, data) macro(189, data)
+#define MREPEAT191(macro, data) MREPEAT190(macro, data) macro(190, data)
+#define MREPEAT192(macro, data) MREPEAT191(macro, data) macro(191, data)
+#define MREPEAT193(macro, data) MREPEAT192(macro, data) macro(192, data)
+#define MREPEAT194(macro, data) MREPEAT193(macro, data) macro(193, data)
+#define MREPEAT195(macro, data) MREPEAT194(macro, data) macro(194, data)
+#define MREPEAT196(macro, data) MREPEAT195(macro, data) macro(195, data)
+#define MREPEAT197(macro, data) MREPEAT196(macro, data) macro(196, data)
+#define MREPEAT198(macro, data) MREPEAT197(macro, data) macro(197, data)
+#define MREPEAT199(macro, data) MREPEAT198(macro, data) macro(198, data)
+#define MREPEAT200(macro, data) MREPEAT199(macro, data) macro(199, data)
+#define MREPEAT201(macro, data) MREPEAT200(macro, data) macro(200, data)
+#define MREPEAT202(macro, data) MREPEAT201(macro, data) macro(201, data)
+#define MREPEAT203(macro, data) MREPEAT202(macro, data) macro(202, data)
+#define MREPEAT204(macro, data) MREPEAT203(macro, data) macro(203, data)
+#define MREPEAT205(macro, data) MREPEAT204(macro, data) macro(204, data)
+#define MREPEAT206(macro, data) MREPEAT205(macro, data) macro(205, data)
+#define MREPEAT207(macro, data) MREPEAT206(macro, data) macro(206, data)
+#define MREPEAT208(macro, data) MREPEAT207(macro, data) macro(207, data)
+#define MREPEAT209(macro, data) MREPEAT208(macro, data) macro(208, data)
+#define MREPEAT210(macro, data) MREPEAT209(macro, data) macro(209, data)
+#define MREPEAT211(macro, data) MREPEAT210(macro, data) macro(210, data)
+#define MREPEAT212(macro, data) MREPEAT211(macro, data) macro(211, data)
+#define MREPEAT213(macro, data) MREPEAT212(macro, data) macro(212, data)
+#define MREPEAT214(macro, data) MREPEAT213(macro, data) macro(213, data)
+#define MREPEAT215(macro, data) MREPEAT214(macro, data) macro(214, data)
+#define MREPEAT216(macro, data) MREPEAT215(macro, data) macro(215, data)
+#define MREPEAT217(macro, data) MREPEAT216(macro, data) macro(216, data)
+#define MREPEAT218(macro, data) MREPEAT217(macro, data) macro(217, data)
+#define MREPEAT219(macro, data) MREPEAT218(macro, data) macro(218, data)
+#define MREPEAT220(macro, data) MREPEAT219(macro, data) macro(219, data)
+#define MREPEAT221(macro, data) MREPEAT220(macro, data) macro(220, data)
+#define MREPEAT222(macro, data) MREPEAT221(macro, data) macro(221, data)
+#define MREPEAT223(macro, data) MREPEAT222(macro, data) macro(222, data)
+#define MREPEAT224(macro, data) MREPEAT223(macro, data) macro(223, data)
+#define MREPEAT225(macro, data) MREPEAT224(macro, data) macro(224, data)
+#define MREPEAT226(macro, data) MREPEAT225(macro, data) macro(225, data)
+#define MREPEAT227(macro, data) MREPEAT226(macro, data) macro(226, data)
+#define MREPEAT228(macro, data) MREPEAT227(macro, data) macro(227, data)
+#define MREPEAT229(macro, data) MREPEAT228(macro, data) macro(228, data)
+#define MREPEAT230(macro, data) MREPEAT229(macro, data) macro(229, data)
+#define MREPEAT231(macro, data) MREPEAT230(macro, data) macro(230, data)
+#define MREPEAT232(macro, data) MREPEAT231(macro, data) macro(231, data)
+#define MREPEAT233(macro, data) MREPEAT232(macro, data) macro(232, data)
+#define MREPEAT234(macro, data) MREPEAT233(macro, data) macro(233, data)
+#define MREPEAT235(macro, data) MREPEAT234(macro, data) macro(234, data)
+#define MREPEAT236(macro, data) MREPEAT235(macro, data) macro(235, data)
+#define MREPEAT237(macro, data) MREPEAT236(macro, data) macro(236, data)
+#define MREPEAT238(macro, data) MREPEAT237(macro, data) macro(237, data)
+#define MREPEAT239(macro, data) MREPEAT238(macro, data) macro(238, data)
+#define MREPEAT240(macro, data) MREPEAT239(macro, data) macro(239, data)
+#define MREPEAT241(macro, data) MREPEAT240(macro, data) macro(240, data)
+#define MREPEAT242(macro, data) MREPEAT241(macro, data) macro(241, data)
+#define MREPEAT243(macro, data) MREPEAT242(macro, data) macro(242, data)
+#define MREPEAT244(macro, data) MREPEAT243(macro, data) macro(243, data)
+#define MREPEAT245(macro, data) MREPEAT244(macro, data) macro(244, data)
+#define MREPEAT246(macro, data) MREPEAT245(macro, data) macro(245, data)
+#define MREPEAT247(macro, data) MREPEAT246(macro, data) macro(246, data)
+#define MREPEAT248(macro, data) MREPEAT247(macro, data) macro(247, data)
+#define MREPEAT249(macro, data) MREPEAT248(macro, data) macro(248, data)
+#define MREPEAT250(macro, data) MREPEAT249(macro, data) macro(249, data)
+#define MREPEAT251(macro, data) MREPEAT250(macro, data) macro(250, data)
+#define MREPEAT252(macro, data) MREPEAT251(macro, data) macro(251, data)
+#define MREPEAT253(macro, data) MREPEAT252(macro, data) macro(252, data)
+#define MREPEAT254(macro, data) MREPEAT253(macro, data) macro(253, data)
+#define MREPEAT255(macro, data) MREPEAT254(macro, data) macro(254, data)
+#define MREPEAT256(macro, data) MREPEAT255(macro, data) macro(255, data)
+
+/**
+ * \}
+ */
+
+#endif // _MREPEAT_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/mrepeat.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/mrepeat.h.REMOVED.git-id
deleted file mode 100644
index f9331e0d..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/mrepeat.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f4f9c94c9c89585b7245ad9edb92738835dd1fc1
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/preprocessor.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/preprocessor.h
new file mode 100644
index 00000000..b597f58d
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/preprocessor.h
@@ -0,0 +1,54 @@
+/**
+ * \file
+ *
+ * \brief Preprocessor utils.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _PREPROCESSOR_H_
+#define _PREPROCESSOR_H_
+
+#include "tpaste.h"
+#include "stringz.h"
+#include "mrepeat.h"
+
+
+#endif // _PREPROCESSOR_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/preprocessor.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/preprocessor.h.REMOVED.git-id
deleted file mode 100644
index 25e05f8c..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/preprocessor.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b597f58dd14c82b72e1d5f7eac3d8c835631bc70
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/stringz.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/stringz.h
new file mode 100644
index 00000000..fcb3d93b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/stringz.h
@@ -0,0 +1,84 @@
+/**
+ * \file
+ *
+ * \brief Preprocessor stringizing utils.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _STRINGZ_H_
+#define _STRINGZ_H_
+
+/**
+ * \defgroup group_xmega_utils_stringz Stringize
+ *
+ * \ingroup group_xmega_utils
+ *
+ * \{
+ */
+
+/*! \brief Stringize.
+ *
+ * Stringize a preprocessing token, this token being allowed to be \#defined.
+ *
+ * May be used only within macros with the token passed as an argument if the token is \#defined.
+ *
+ * For example, writing STRINGZ(PIN) within a macro \#defined by PIN_NAME(PIN)
+ * and invoked as PIN_NAME(PIN0) with PIN0 \#defined as A0 is equivalent to
+ * writing "A0".
+ */
+#define STRINGZ(x) #x
+
+/*! \brief Absolute stringize.
+ *
+ * Stringize a preprocessing token, this token being allowed to be \#defined.
+ *
+ * No restriction of use if the token is \#defined.
+ *
+ * For example, writing ASTRINGZ(PIN0) anywhere with PIN0 \#defined as A0 is
+ * equivalent to writing "A0".
+ */
+#define ASTRINGZ(x) STRINGZ(x)
+
+/**
+ * \}
+ */
+
+#endif // _STRINGZ_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/stringz.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/stringz.h.REMOVED.git-id
deleted file mode 100644
index a69b597a..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/stringz.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fcb3d93b13d1247657f3c2a9ffe0835b11b5669c
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/tpaste.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/tpaste.h
new file mode 100644
index 00000000..168a0cf8
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/tpaste.h
@@ -0,0 +1,104 @@
+/**
+ * \file
+ *
+ * \brief Preprocessor token pasting utils.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef _TPASTE_H_
+#define _TPASTE_H_
+
+/**
+ * \defgroup group_xmega_utils_tpaste Token Paste
+ *
+ * \ingroup group_xmega_utils
+ *
+ * \{
+ */
+
+/*! \name Token Paste
+ *
+ * Paste N preprocessing tokens together, these tokens being allowed to be \#defined.
+ *
+ * May be used only within macros with the tokens passed as arguments if the tokens are \#defined.
+ *
+ * For example, writing TPASTE2(U, WIDTH) within a macro \#defined by
+ * UTYPE(WIDTH) and invoked as UTYPE(UL_WIDTH) with UL_WIDTH \#defined as 32 is
+ * equivalent to writing U32.
+ */
+//! @{
+#define TPASTE2( a, b) a##b
+#define TPASTE3( a, b, c) a##b##c
+#define TPASTE4( a, b, c, d) a##b##c##d
+#define TPASTE5( a, b, c, d, e) a##b##c##d##e
+#define TPASTE6( a, b, c, d, e, f) a##b##c##d##e##f
+#define TPASTE7( a, b, c, d, e, f, g) a##b##c##d##e##f##g
+#define TPASTE8( a, b, c, d, e, f, g, h) a##b##c##d##e##f##g##h
+#define TPASTE9( a, b, c, d, e, f, g, h, i) a##b##c##d##e##f##g##h##i
+#define TPASTE10(a, b, c, d, e, f, g, h, i, j) a##b##c##d##e##f##g##h##i##j
+//! @}
+
+/*! \name Absolute Token Paste
+ *
+ * Paste N preprocessing tokens together, these tokens being allowed to be \#defined.
+ *
+ * No restriction of use if the tokens are \#defined.
+ *
+ * For example, writing ATPASTE2(U, UL_WIDTH) anywhere with UL_WIDTH \#defined
+ * as 32 is equivalent to writing U32.
+ */
+//! @{
+#define ATPASTE2( a, b) TPASTE2( a, b)
+#define ATPASTE3( a, b, c) TPASTE3( a, b, c)
+#define ATPASTE4( a, b, c, d) TPASTE4( a, b, c, d)
+#define ATPASTE5( a, b, c, d, e) TPASTE5( a, b, c, d, e)
+#define ATPASTE6( a, b, c, d, e, f) TPASTE6( a, b, c, d, e, f)
+#define ATPASTE7( a, b, c, d, e, f, g) TPASTE7( a, b, c, d, e, f, g)
+#define ATPASTE8( a, b, c, d, e, f, g, h) TPASTE8( a, b, c, d, e, f, g, h)
+#define ATPASTE9( a, b, c, d, e, f, g, h, i) TPASTE9( a, b, c, d, e, f, g, h, i)
+#define ATPASTE10(a, b, c, d, e, f, g, h, i, j) TPASTE10(a, b, c, d, e, f, g, h, i, j)
+//! @}
+
+/**
+ * \}
+ */
+
+#endif // _TPASTE_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/tpaste.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/tpaste.h.REMOVED.git-id
deleted file mode 100644
index eb6c4ba4..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/preprocessor/tpaste.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-168a0cf82309dd9b4f277f284dc6d32b62f2b6f3
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/progmem.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/progmem.h
new file mode 100644
index 00000000..fcab5dbb
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/progmem.h
@@ -0,0 +1,102 @@
+/**
+ * \file
+ *
+ * \brief Program memory access
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef UTILS_PROGMEM_H
+#define UTILS_PROGMEM_H
+
+/**
+ * \defgroup group_xmega_utils_progmem Program memory
+ *
+ * \ingroup group_xmega_utils
+ *
+ * \{
+ */
+
+/*! \name Program memory
+ *
+ * Macros for locating and accessing data in program memory.
+ *
+ * @{
+ */
+#if defined(__GNUC__) || defined(__DOXYGEN__)
+# include
+# define PROGMEM_LOCATION(type, name, loc) \
+ type name __attribute__((section (#loc)))
+# define PROGMEM_DECLARE(type, name) const type name __attribute__((__progmem__))
+# define PROGMEM_STRING(x) PSTR(x)
+# define PROGMEM_STRING_T PGM_P
+# define PROGMEM_T const
+# define PROGMEM_PTR_T const *
+# define PROGMEM_BYTE_ARRAY_T uint8_t*
+# define PROGMEM_WORD_ARRAY_T uint16_t*
+# define PROGMEM_READ_BYTE(x) pgm_read_byte(x)
+# define PROGMEM_READ_WORD(x) pgm_read_word(x)
+
+#elif defined(__ICCAVR__)
+# include
+# ifndef __HAS_ELPM__
+# define _MEMATTR_ASF __flash
+# else /* __HAS_ELPM__ */
+# define _MEMATTR_ASF __hugeflash
+# endif /* __HAS_ELPM__ */
+# define PROGMEM_LOCATION(type, name, loc) const _MEMATTR_ASF type name @ loc
+# define PROGMEM_DECLARE(type, name) _MEMATTR_ASF type name
+# define PROGMEM_STRING(x) ((_MEMATTR_ASF const char *)(x))
+# define PROGMEM_STRING_T char const _MEMATTR_ASF *
+# define PROGMEM_T const _MEMATTR_ASF
+# define PROGMEM_PTR_T const _MEMATTR_ASF *
+# define PROGMEM_BYTE_ARRAY_T uint8_t const _MEMATTR_ASF *
+# define PROGMEM_WORD_ARRAY_T uint16_t const _MEMATTR_ASF *
+# define PROGMEM_READ_BYTE(x) *(x)
+# define PROGMEM_READ_WORD(x) *(x)
+#endif
+//! @}
+
+/**
+ * \}
+ */
+
+#endif /* UTILS_PROGMEM_H */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/progmem.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/progmem.h.REMOVED.git-id
deleted file mode 100644
index b0ce4725..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/progmem.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fcab5dbb70d87219e3b35449984a3aa7c4b77bdf
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/status_codes.h b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/status_codes.h
new file mode 100644
index 00000000..035e6963
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/status_codes.h
@@ -0,0 +1,121 @@
+/**
+ * \file
+ *
+ * \brief Status code definitions.
+ *
+ * This file defines various status codes returned by functions,
+ * indicating success or failure as well as what kind of failure.
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef STATUS_CODES_H_INCLUDED
+#define STATUS_CODES_H_INCLUDED
+
+/**
+ * \defgroup group_xmega_utils_status_codes Status Codes
+ *
+ * \ingroup group_xmega_utils
+ *
+ * \{
+ */
+
+/* Note: this is a local workaround to avoid a pre-processor clash due to the
+ * lwIP macro ERR_TIMEOUT. */
+#if defined(__LWIP_ERR_H__) && defined(ERR_TIMEOUT)
+#if (ERR_TIMEOUT != -3)
+
+/* Internal check to make sure that the later restore of lwIP's ERR_TIMEOUT
+ * macro is set to the correct value. Note that it is highly improbable that
+ * this value ever changes in lwIP. */
+#error ASF developers: check lwip err.h new value for ERR_TIMEOUT
+#endif
+#undef ERR_TIMEOUT
+#endif
+
+/**
+ * Status code that may be returned by shell commands and protocol
+ * implementations.
+ *
+ * \note Any change to these status codes and the corresponding
+ * message strings is strictly forbidden. New codes can be added,
+ * however, but make sure that any message string tables are updated
+ * at the same time.
+ */
+enum status_code {
+ STATUS_OK = 0, //!< Success
+ ERR_IO_ERROR = -1, //!< I/O error
+ ERR_FLUSHED = -2, //!< Request flushed from queue
+ ERR_TIMEOUT = -3, //!< Operation timed out
+ ERR_BAD_DATA = -4, //!< Data integrity check failed
+ ERR_PROTOCOL = -5, //!< Protocol error
+ ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device
+ ERR_NO_MEMORY = -7, //!< Insufficient memory
+ ERR_INVALID_ARG = -8, //!< Invalid argument
+ ERR_BAD_ADDRESS = -9, //!< Bad address
+ ERR_BUSY = -10, //!< Resource is busy
+ ERR_BAD_FORMAT = -11, //!< Data format not recognized
+ ERR_NO_TIMER = -12, //!< No timer available
+ ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running
+ ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running
+
+ /**
+ * \brief Operation in progress
+ *
+ * This status code is for driver-internal use when an operation
+ * is currently being performed.
+ *
+ * \note Drivers should never return this status code to any
+ * callers. It is strictly for internal use.
+ */
+ OPERATION_IN_PROGRESS = -128,
+};
+
+typedef enum status_code status_code_t;
+
+#if defined(__LWIP_ERR_H__)
+#define ERR_TIMEOUT -3
+#endif
+
+/**
+ * \}
+ */
+
+#endif /* STATUS_CODES_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/status_codes.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/status_codes.h.REMOVED.git-id
deleted file mode 100644
index 6e8a091c..00000000
--- a/AVR Code/USB_BULK_TEST/src/ASF/xmega/utils/status_codes.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-035e69630b977987030a42f7c1eefc64d6621210
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/asf.h b/AVR Code/USB_BULK_TEST/src/asf.h
new file mode 100644
index 00000000..cd3cf2f2
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/asf.h
@@ -0,0 +1,101 @@
+/**
+ * \file
+ *
+ * \brief Autogenerated API include file for the Atmel Software Framework (ASF)
+ *
+ * Copyright (c) 2012 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#ifndef ASF_H
+#define ASF_H
+
+/*
+ * This file includes all API header files for the selected drivers from ASF.
+ * Note: There might be duplicate includes required by more than one driver.
+ *
+ * The file is automatically generated and will be re-written when
+ * running the ASF driver selector tool. Any changes will be discarded.
+ */
+
+// From module: CPU specific features
+#include
+#include
+
+// From module: Common build items for user board support templates
+#include
+
+// From module: Generic board support
+#include
+
+// From module: IOPORT - General purpose I/O service
+#include
+
+// From module: Interrupt management - XMEGA implementation
+#include
+
+// From module: NVM - Non Volatile Memory
+#include
+
+// From module: Part identification macros
+#include
+
+// From module: Sleep Controller driver
+#include
+
+// From module: Sleep manager - XMEGA A/AU/B/D implementation
+#include
+#include
+
+// From module: System Clock Control - XMEGA A1U/A3U/A3BU/A4U/B/C implementation
+#include
+
+// From module: USB Device Stack Core (Common API)
+#include
+#include
+
+// From module: USB Device Vendor Class (Single Interface Device)
+#include
+
+// From module: USB Vendor Protocol
+#include
+
+// From module: XMEGA compiler driver
+#include
+#include
+
+#endif // ASF_H
diff --git a/AVR Code/USB_BULK_TEST/src/asf.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/asf.h.REMOVED.git-id
deleted file mode 100644
index a8c20c99..00000000
--- a/AVR Code/USB_BULK_TEST/src/asf.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cd3cf2f277241c139057b35e270bf82ee2775182
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_board.h b/AVR Code/USB_BULK_TEST/src/config/conf_board.h
new file mode 100644
index 00000000..7b88c97f
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_board.h
@@ -0,0 +1,14 @@
+/**
+ * \file
+ *
+ * \brief User board configuration template
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef CONF_BOARD_H
+#define CONF_BOARD_H
+
+#endif // CONF_BOARD_H
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_board.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_board.h.REMOVED.git-id
deleted file mode 100644
index 00b9cc05..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_board.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7b88c97fc205be08107659cf807daf0d37d718c8
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_clock.h b/AVR Code/USB_BULK_TEST/src/config/conf_clock.h
new file mode 100644
index 00000000..9f74e559
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_clock.h
@@ -0,0 +1,80 @@
+/**
+ * \file
+ *
+ * \brief Chip-specific system clock manager configuration
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CONF_CLOCK_H_INCLUDED
+#define CONF_CLOCK_H_INCLUDED
+
+//! Configuration using On-Chip RC oscillator at 48MHz
+//! The RC oscillator is calibrated via USB Start Of Frame
+//! Clk USB = 48MHz (used by USB)
+//! Clk sys = 48MHz
+//! Clk cpu/per = 24MHz
+#define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
+#define CONFIG_OSC_RC32_CAL 48000000UL
+
+#define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC OSC_ID_USBSOF
+
+#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC32MHZ
+#define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_2
+#define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1
+
+/*
+//! Use external board OSC (8MHz)
+//! Clk pll = 48MHz (used by USB)
+//! Clk sys = 48MHz
+//! Clk cpu/per = 12MHz
+
+#define CONFIG_PLL0_SOURCE PLL_SRC_XOSC
+#define CONFIG_PLL0_MUL 6
+#define CONFIG_PLL0_DIV 1
+
+#define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL
+
+#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL
+#define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_2
+#define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_2
+*/
+
+#endif /* CONF_CLOCK_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_clock.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_clock.h.REMOVED.git-id
deleted file mode 100644
index 706a9260..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_clock.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9f74e559e8d2e7c89ab41631170b7f1b369efac9
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_menu.h b/AVR Code/USB_BULK_TEST/src/config/conf_menu.h
new file mode 100644
index 00000000..5a765a77
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_menu.h
@@ -0,0 +1,72 @@
+/**
+ * \file
+ *
+ * \brief Default configurations for menu system
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef DEFAULT_MENU_H_INCLUDED
+#define DEFAULT_MENU_H_INCLUDED
+
+//! \name Indicator icon definitions
+//@{
+//! Bitmap data, row by row, MSB is leftmost pixel, one byte per row.
+#define GFX_MONO_MENU_INDICATOR_BITMAP 0xFF, 0x7E, 0x3C, 0x18
+//! Height in pixels of indicator icon
+#define GFX_MONO_MENU_INDICATOR_HEIGHT 8
+//! Width in pixels of indicator icon
+#define GFX_MONO_MENU_INDICATOR_WIDTH 4
+//@}
+
+//! \name Keyboard codes
+//@{
+//! Down
+#define GFX_MONO_MENU_KEYCODE_DOWN 40
+//! Up
+#define GFX_MONO_MENU_KEYCODE_UP 38
+//! Back/exit
+#define GFX_MONO_MENU_KEYCODE_BACK 8
+//! Enter/select
+#define GFX_MONO_MENU_KEYCODE_ENTER 13
+//@}
+
+#endif /* DEFAULT_MENU_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_menu.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_menu.h.REMOVED.git-id
deleted file mode 100644
index 5b16beb5..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_menu.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5a765a77128b27ea957fca0deea1c5e96f5cc230
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_sleepmgr.h b/AVR Code/USB_BULK_TEST/src/config/conf_sleepmgr.h
new file mode 100644
index 00000000..4c6708d9
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_sleepmgr.h
@@ -0,0 +1,51 @@
+/**
+ * \file
+ *
+ * \brief Sleep manager configuration
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CONF_SLEEPMGR_H
+#define CONF_SLEEPMGR_H
+
+#define CONFIG_SLEEPMGR_ENABLE
+
+#endif /* CONF_SLEEPMGR_H */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_sleepmgr.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_sleepmgr.h.REMOVED.git-id
deleted file mode 100644
index 6e44d28b..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_sleepmgr.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4c6708d91cf492b1e16b66206b02b75b505e62f0
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_spi_master.h b/AVR Code/USB_BULK_TEST/src/config/conf_spi_master.h
new file mode 100644
index 00000000..afdc02ed
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_spi_master.h
@@ -0,0 +1,52 @@
+/**
+ * \file *********************************************************************
+ *
+ * \brief Spi Master configuration for spi example
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CONF_SPI_MASTER_H_INCLUDED
+#define CONF_SPI_MASTER_H_INCLUDED
+
+//! Default Config Spi Master Dummy Field
+// #define CONFIG_SPI_MASTER_DUMMY 0xFF
+
+#endif /* CONF_SPI_MASTER_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_spi_master.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_spi_master.h.REMOVED.git-id
deleted file mode 100644
index d2541039..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_spi_master.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-afdc02ed596a36b1b938564535481dfbb40dacff
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_spinctrl.h b/AVR Code/USB_BULK_TEST/src/config/conf_spinctrl.h
new file mode 100644
index 00000000..2090b6a1
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_spinctrl.h
@@ -0,0 +1,75 @@
+/**
+ * \file
+ *
+ * \brief Default configurations for gfx_mono_spinctrl
+ *
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef DEFAULT_GFX_MONO_SPINCTRL_H_INCLUDED
+#define DEFAULT_GFX_MONO_SPINCTRL_H_INCLUDED
+
+//! Spinner value indicator
+/* Bitmap data, row by row, MSB is leftmost pixel, one byte per row. */
+#define GFX_MONO_SPINCTRL_SPIN_INDICATOR_BITMAP 0x18, 0x3C, 0x7E, 0xFF
+//! Height of spinner value indicator
+#define GFX_MONO_SPINCTRL_SPIN_INDICATOR_HEIGHT 8
+//! Width of spinner value indicator
+#define GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH 4
+
+//! Spinner indicator
+/* Bitmap data, row by row, MSB is leftmost pixel, one byte per row. */
+#define GFX_MONO_SPINCTRL_INDICATOR_BITMAP 0xFF, 0x7E, 0x3C, 0x18
+//! Height of spinner indicator
+#define GFX_MONO_SPINCTRL_INDICATOR_HEIGHT 8
+//! Width of spinner indicator
+#define GFX_MONO_SPINCTRL_INDICATOR_WIDTH 4
+
+//! Keyboard code down
+#define GFX_MONO_SPINCTRL_KEYCODE_DOWN 40
+//! Keyboard code up
+#define GFX_MONO_SPINCTRL_KEYCODE_UP 38
+//! Keyboard code back
+#define GFX_MONO_SPINCTRL_KEYCODE_BACK 8
+//! Keyboard code enter
+#define GFX_MONO_SPINCTRL_KEYCODE_ENTER 13
+
+#endif /* DEFAULT_GFX_MONO_SPINCTRL_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_spinctrl.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_spinctrl.h.REMOVED.git-id
deleted file mode 100644
index e8d8053d..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_spinctrl.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2090b6a1364618e0273dedc4eb85fca582e16518
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_st7565r.h b/AVR Code/USB_BULK_TEST/src/config/conf_st7565r.h
new file mode 100644
index 00000000..0dd67fd8
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_st7565r.h
@@ -0,0 +1,101 @@
+/**
+ * \file
+ *
+ * \brief ST7565R display controller driver configuration file.
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CONF_ST7565R_H_INCLUDED
+#define CONF_ST7565R_H_INCLUDED
+
+#include
+
+#if BOARD == XMEGA_A3BU_XPLAINED
+// Interface configuration for XMEGA-A3BU Xplained
+
+# define ST7565R_USART_SPI_INTERFACE
+# define ST7565R_USART_SPI &USARTD0
+
+# define ST7565R_A0_PIN NHD_C12832A1Z_REGISTER_SELECT
+# define ST7565R_CS_PIN NHD_C12832A1Z_CSN
+# define ST7565R_RESET_PIN NHD_C12832A1Z_RESETN
+
+#else
+// Interface configuration for other boards
+# warning ST7565R driver must be configured. Please see conf_st7565r.h.
+
+// Interface possibilities:
+// 1) Regular SPI interface
+// #define ST7565R_SPI_INTERFACE
+// #define ST7565R_SPI &SPID
+
+// 2) USART SPI interface
+// #define ST7565R_USART_SPI_INTERFACE
+// #define ST7565R_USART_SPI &USARTD0
+
+// Pin mapping:
+// - Register select
+// #define ST7565R_A0_PIN 0
+// - Chip select
+// #define ST7565R_CS_PIN 1
+// - Reset
+// #define ST7565R_RESET_PIN 2
+
+
+// Placeholder setup
+
+# define ST7565R_SPI_INTERFACE
+# define ST7565R_SPI 0
+
+# define ST7565R_A0_PIN 0
+# define ST7565R_CS_PIN 1
+# define ST7565R_RESET_PIN 2
+
+#endif // BOARD
+
+// Board independent configuration
+
+// Minimum clock period is 50ns@3.3V -> max frequency is 20MHz
+#define ST7565R_CLOCK_SPEED 1000000
+#define ST7565R_DISPLAY_CONTRAST_MAX 40
+#define ST7565R_DISPLAY_CONTRAST_MIN 30
+
+#endif /* CONF_ST7565R_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_st7565r.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_st7565r.h.REMOVED.git-id
deleted file mode 100644
index 8f062bdb..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_st7565r.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0dd67fd83472ee12fedbd3634f85a8c19224e06e
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_sysfont.h b/AVR Code/USB_BULK_TEST/src/config/conf_sysfont.h
new file mode 100644
index 00000000..05daa73b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_sysfont.h
@@ -0,0 +1,1170 @@
+/**
+ * \file
+ *
+ * \brief Default configurations for sysfont
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CONF_SYSFONT_H
+#define CONF_SYSFONT_H
+
+/**
+ * \weakgroup gfx_mono_sysfont
+ * @{
+ */
+
+#include
+
+/* #define USE_FONT_BPMONO_10x16 */
+/* #define USE_FONT_BPMONO_10x14 */
+/* #define USE_FONT_MONO_MMM_10x12 */
+#define USE_FONT_BASIC_6x7
+
+#if defined(USE_FONT_BPMONO_10x16)
+/** Width of each glyph, including spacer column. */
+# define SYSFONT_WIDTH 10
+/** Height of each glyph, excluding spacer line. */
+# define SYSFONT_HEIGHT 16
+/** Line height. */
+# define SYSFONT_LINESPACING 8
+/** First character defined. */
+# define SYSFONT_FIRSTCHAR ((uint8_t)' ')
+/** Last character defined. */
+# define SYSFONT_LASTCHAR ((uint8_t)'}')
+
+/** Define variable containing the font */
+# define SYSFONT_DEFINE_GLYPHS \
+ /* Glyph data, row by row, MSB is leftmost pixel, one byte per row. */ \
+ static PROGMEM_DECLARE(uint8_t, sysfont_glyphs[]) = { \
+ /* "BPmono" font (http://www.backpacker.gr) at size 10x16 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, \
+ 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, \
+ 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ! */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x6C, 0x00, \
+ 0x6C, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* " */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, \
+ 0x48, 0x00, 0xFC, 0x00, 0x48, 0x00, 0x48, 0x00, 0x48, 0x00, \
+ 0xFC, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* # */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x3C, 0x00, 0x40, 0x00, 0x30, 0x00, 0x08, 0x00, 0x04, 0x00, \
+ 0x78, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* $ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, \
+ 0xA4, 0x00, 0xA8, 0x00, 0x48, 0x00, 0x10, 0x00, 0x14, 0x00, \
+ 0x2A, 0x00, 0x4A, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* % */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, 0x88, 0x00, 0x8A, 0x00, \
+ 0x8A, 0x00, 0x8C, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* & */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ' */ \
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ( */ \
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ) */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x10, 0x00, \
+ 0x7C, 0x00, 0x10, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* * */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xFE, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* + */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x30, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, /* , */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* - */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* . */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* / */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x8C, 0x00, 0x94, 0x00, 0xA4, 0x00, 0xC4, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 0 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x30, 0x00, \
+ 0x50, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 1 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x40, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 2 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x30, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 3 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, \
+ 0x28, 0x00, 0x28, 0x00, 0x48, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0xFC, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 4 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xB8, 0x00, 0xC4, 0x00, 0x04, 0x00, 0x04, 0x00, \
+ 0x04, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 5 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x40, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0xB0, 0x00, 0xC8, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x48, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 6 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x04, 0x00, \
+ 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 7 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 8 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x8C, 0x00, 0x74, 0x00, 0x04, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* 9 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* : */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x80, 0x00, \
+ 0x00, 0x00, /* ; */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x04, 0x00, 0x18, 0x00, 0x60, 0x00, 0x80, 0x00, \
+ 0x60, 0x00, 0x18, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* < */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* = */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x40, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x02, 0x00, \
+ 0x0C, 0x00, 0x30, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* > */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ? */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x3C, 0x00, 0x42, 0x00, 0xBA, 0x00, 0xAA, 0x00, 0xAA, 0x00, \
+ 0xAA, 0x00, 0xBC, 0x00, 0x40, 0x00, 0x3C, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* @ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x44, 0x00, 0x7C, 0x00, \
+ 0x44, 0x00, 0x82, 0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* A */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* B */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x44, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x44, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* C */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x88, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* D */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x40, 0x00, 0x78, 0x00, 0x40, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x40, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* E */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x78, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* F */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x44, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x9C, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x44, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* G */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0xFC, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* H */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* I */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* J */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x88, 0x00, 0x90, 0x00, 0xA0, 0x00, 0xD0, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* K */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* L */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0xCC, 0x00, 0xCC, 0x00, 0xB4, 0x00, 0xB4, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* M */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0xC4, 0x00, \
+ 0xC4, 0x00, 0xA4, 0x00, 0xA4, 0x00, 0x94, 0x00, 0x94, 0x00, \
+ 0x8C, 0x00, 0x8C, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* N */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x48, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x48, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* O */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x88, 0x00, 0xF0, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* P */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x48, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x48, 0x00, 0x30, 0x00, 0x20, 0x00, 0x1C, 0x00, \
+ 0x00, 0x00, /* Q */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x88, 0x00, 0xF0, 0x00, 0x90, 0x00, \
+ 0x88, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* R */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, \
+ 0x80, 0x00, 0x40, 0x00, 0x30, 0x00, 0x08, 0x00, 0x04, 0x00, \
+ 0x04, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* S */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* T */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* U */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x82, 0x00, \
+ 0x44, 0x00, 0x44, 0x00, 0x44, 0x00, 0x44, 0x00, 0x28, 0x00, \
+ 0x28, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* V */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0xB4, 0x00, 0xB4, 0x00, 0xB4, 0x00, \
+ 0x78, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* W */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x44, 0x00, \
+ 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x10, 0x00, 0x28, 0x00, \
+ 0x44, 0x00, 0x44, 0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* X */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x44, 0x00, \
+ 0x44, 0x00, 0x28, 0x00, 0x28, 0x00, 0x28, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* Y */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x04, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x40, 0x00, 0x40, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* Z */ \
+ 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xE0, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* [ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* \ */ \
+ 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xE0, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ] */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x28, 0x00, \
+ 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ^ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* _ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, \
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* ` */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x78, 0x00, 0x04, 0x00, 0x04, 0x00, 0x7C, 0x00, \
+ 0x84, 0x00, 0x8C, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* a */ \
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xB8, 0x00, 0xC4, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x88, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* b */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x7C, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* c */ \
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, \
+ 0x02, 0x00, 0x3E, 0x00, 0x42, 0x00, 0x82, 0x00, 0x82, 0x00, \
+ 0x82, 0x00, 0x42, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* d */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x7C, 0x00, 0x82, 0x00, 0x82, 0x00, 0xFE, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* e */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0xFC, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* f */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x7C, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x8C, 0x00, 0x74, 0x00, 0x04, 0x00, 0x44, 0x00, \
+ 0x38, 0x00, /* g */ \
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xB8, 0x00, 0xC4, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* h */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x70, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* i */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x78, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, \
+ 0xE0, 0x00, /* j */ \
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x88, 0x00, 0x90, 0x00, 0xA0, 0x00, 0xE0, 0x00, \
+ 0x90, 0x00, 0x88, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* k */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* l */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0xAC, 0x00, 0xD4, 0x00, 0x94, 0x00, 0x94, 0x00, \
+ 0x94, 0x00, 0x94, 0x00, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* m */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0xB8, 0x00, 0xC4, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* n */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* o */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0xB8, 0x00, 0xC4, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0xF8, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, /* p */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x7C, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x7C, 0x00, 0x04, 0x00, 0x04, 0x00, \
+ 0x04, 0x00, /* q */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0xCC, 0x00, 0x30, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* r */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x7C, 0x00, 0x80, 0x00, 0x80, 0x00, 0x78, 0x00, \
+ 0x04, 0x00, 0x04, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* s */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x20, 0x00, 0xFC, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* t */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* u */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x82, 0x00, 0x44, 0x00, 0x44, 0x00, 0x28, 0x00, \
+ 0x28, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* v */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, 0xB4, 0x00, 0xB4, 0x00, \
+ 0x48, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* w */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x44, 0x00, 0x28, 0x00, 0x28, 0x00, 0x10, 0x00, \
+ 0x28, 0x00, 0x44, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* x */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x82, 0x00, 0x44, 0x00, 0x44, 0x00, 0x28, 0x00, \
+ 0x28, 0x00, 0x28, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, /* y */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0xFC, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, \
+ 0x20, 0x00, 0x40, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* z */ \
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* { */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* | */ \
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, /* } */ \
+ };
+#elif defined(USE_FONT_BPMONO_10x14)
+/** Width of each glyph, including spacer column. */
+# define SYSFONT_WIDTH 10
+/** Height of each glyph, excluding spacer line. */
+# define SYSFONT_HEIGHT 14
+/** Line height. */
+# define SYSFONT_LINESPACING 8
+/** First character defined. */
+# define SYSFONT_FIRSTCHAR ((uint8_t)' ')
+/** Last character defined. */
+# define SYSFONT_LASTCHAR ((uint8_t)'}')
+
+/** Define variable containing the font */
+# define SYSFONT_DEFINE_GLYPHS \
+ /* Glyph data, row by row, MSB is leftmost pixel, one byte per row. */ \
+ static PROGMEM_DECLARE(uint8_t, sysfont_glyphs[]) = { \
+ /* "BPmono" font (http://www.backpacker.gr) at size 10x14 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */ \
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, \
+ 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, \
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ! */ \
+ 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6C, 0x00, \
+ 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* " */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x28, 0x00, \
+ 0x7C, 0x00, 0x28, 0x00, 0x28, 0x00, 0x7C, 0x00, 0x28, 0x00, \
+ 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* # */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x3C, 0x00, 0x40, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x78, 0x00, \
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* $ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0xA4, 0x00, \
+ 0xA8, 0x00, 0x50, 0x00, 0x28, 0x00, 0x54, 0x00, 0x94, 0x00, \
+ 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* % */ \
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x90, 0x00, 0x90, 0x00, \
+ 0x90, 0x00, 0x60, 0x00, 0x94, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* & */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ' */ \
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, /* ( */ \
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, /* ) */ \
+ 0x00, 0x00, 0x28, 0x00, 0x10, 0x00, 0x7C, 0x00, 0x10, 0x00, \
+ 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* * */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* + */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x10, 0x00, 0x30, 0x00, 0x20, 0x00, 0x00, 0x00, /* , */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* - */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, \
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* . */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* / */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, \
+ 0x8C, 0x00, 0x94, 0x00, 0xA4, 0x00, 0xC4, 0x00, 0x84, 0x00, \
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x30, 0x00, \
+ 0x50, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x30, 0x00, 0x08, 0x00, 0x08, 0x00, 0x88, 0x00, \
+ 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, \
+ 0x28, 0x00, 0x48, 0x00, 0x88, 0x00, 0xFC, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xF0, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x40, 0x00, \
+ 0x80, 0x00, 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 6 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 7 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x70, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x78, 0x00, 0x08, 0x00, 0x10, 0x00, \
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, \
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* : */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, \
+ 0x30, 0x00, 0x60, 0x00, 0x40, 0x00, 0x00, 0x00, /* ; */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, \
+ 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, \
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* < */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* = */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* > */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x48, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ? */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, \
+ 0x42, 0x00, 0x9A, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0xBE, 0x00, \
+ 0x80, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, /* @ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x28, 0x00, \
+ 0x28, 0x00, 0x44, 0x00, 0x7C, 0x00, 0x44, 0x00, 0x44, 0x00, \
+ 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* A */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0xF8, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* B */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x40, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x00, \
+ 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x88, 0x00, \
+ 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* D */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xF0, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* E */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xF8, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* F */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x40, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x9C, 0x00, 0x84, 0x00, 0x44, 0x00, \
+ 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* G */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0xF8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* H */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* I */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* J */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x88, 0x00, \
+ 0x90, 0x00, 0xA0, 0x00, 0xD0, 0x00, 0x88, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* K */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* L */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0xCC, 0x00, \
+ 0xCC, 0x00, 0xB4, 0x00, 0xB4, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* M */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0xC4, 0x00, \
+ 0xC4, 0x00, 0xA4, 0x00, 0xA4, 0x00, 0x94, 0x00, 0x94, 0x00, \
+ 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* N */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* O */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0xF8, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* P */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x78, 0x00, 0x20, 0x00, 0x18, 0x00, 0x00, 0x00, /* Q */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0xF8, 0x00, 0x88, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x60, 0x00, 0x18, 0x00, 0x04, 0x00, 0x04, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* S */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* T */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* U */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x48, 0x00, 0x48, 0x00, 0x48, 0x00, 0x30, 0x00, \
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* V */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xA8, 0x00, \
+ 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0x50, 0x00, \
+ 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* W */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x50, 0x00, 0x20, 0x00, 0x20, 0x00, 0x50, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* X */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x50, 0x00, 0x50, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Y */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x04, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00, \
+ 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Z */ \
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x40, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, \
+ 0x40, 0x00, 0x40, 0x00, 0x70, 0x00, 0x00, 0x00, /* [ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, /* \ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x38, 0x00, 0x00, 0x00, /* ] */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x28, 0x00, 0x44, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* _ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ` */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x70, 0x00, 0x08, 0x00, 0x08, 0x00, 0x78, 0x00, 0x88, 0x00, \
+ 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ \
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0xF8, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x78, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ \
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, \
+ 0x7C, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x8C, 0x00, \
+ 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x78, 0x00, 0x84, 0x00, 0xFC, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e */ \
+ 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0xFC, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x7C, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x7C, 0x00, 0x04, 0x00, 0x78, 0x00, 0x00, 0x00, /* g */ \
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0xB8, 0x00, 0xC4, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* h */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, \
+ 0x70, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* i */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, \
+ 0x78, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x70, 0x00, /* j */ \
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x88, 0x00, 0x90, 0x00, 0xA0, 0x00, 0xD0, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* k */ \
+ 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* l */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xA4, 0x00, 0xFC, 0x00, 0xA4, 0x00, 0xA4, 0x00, 0xA4, 0x00, \
+ 0xA4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* m */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xB8, 0x00, 0xC4, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* n */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x78, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* o */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xB8, 0x00, 0xC4, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0xF8, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, /* p */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x7C, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, \
+ 0x7C, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, /* q */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xD8, 0x00, 0x60, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, \
+ 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x78, 0x00, 0x80, 0x00, 0x40, 0x00, 0x30, 0x00, 0x08, 0x00, \
+ 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* s */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, \
+ 0xFC, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* t */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* u */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x84, 0x00, 0x48, 0x00, 0x48, 0x00, \
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* v */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x88, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, \
+ 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* w */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x88, 0x00, 0x50, 0x00, 0x20, 0x00, 0x20, 0x00, 0x50, 0x00, \
+ 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* x */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x84, 0x00, 0x84, 0x00, 0x48, 0x00, 0x48, 0x00, 0x30, 0x00, \
+ 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, /* y */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF8, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* z */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, 0x10, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, /* { */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, /* | */ \
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, 0x10, 0x00, \
+ 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, /* } */ \
+ };
+#elif defined(USE_FONT_MONO_MMM_10x12)
+/** Width of each glyph, including spacer column. */
+# define SYSFONT_WIDTH 10
+/** Height of each glyph, excluding spacer line. */
+# define SYSFONT_HEIGHT 12
+/** Line height. */
+# define SYSFONT_LINESPACING 8
+/** First character defined. */
+# define SYSFONT_FIRSTCHAR ((uint8_t)' ')
+/** Last character defined. */
+# define SYSFONT_LASTCHAR ((uint8_t)'}')
+
+/** Define variable containing the font */
+# define SYSFONT_DEFINE_GLYPHS \
+ /* Glyph data, row by row, MSB is leftmost pixel, one byte per row. */ \
+ static PROGMEM_DECLARE(uint8_t, sysfont_glyphs[]) = { \
+ /* "MonoMMM" font (http://www.dafont.com/monommm-5.font) size 10x12 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* ! */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x50, 0x00, \
+ 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* " */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0xF8, 0x00, \
+ 0x50, 0x00, 0xF8, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* # */ \
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x70, 0x00, 0xA8, 0x00, \
+ 0xA0, 0x00, 0x70, 0x00, 0x28, 0x00, 0xA8, 0x00, 0x70, 0x00, \
+ 0x20, 0x00, 0x00, 0x00, /* $ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0xB0, 0x00, \
+ 0x50, 0x00, 0x20, 0x00, 0x50, 0x00, 0x68, 0x00, 0x98, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* % */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x90, 0x00, \
+ 0xA0, 0x00, 0x40, 0x00, 0xA8, 0x00, 0x90, 0x00, 0x68, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* & */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* ' */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x10, 0x00, 0x00, 0x00, /* ( */ \
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x40, 0x00, 0x00, 0x00, /* ) */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0xF8, 0x00, \
+ 0x70, 0x00, 0xF8, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* * */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0xF8, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* + */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x40, 0x00, /* , */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* - */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* . */ \
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x10, 0x00, 0x10, 0x00, 0x20, 0x00, 0x60, 0x00, 0x40, 0x00, \
+ 0xC0, 0x00, 0x00, 0x00, /* / */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x98, 0x00, 0xA8, 0x00, 0xC8, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 0 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0xE0, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 1 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 2 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x30, 0x00, 0x08, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 3 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x30, 0x00, \
+ 0x50, 0x00, 0x90, 0x00, 0xF8, 0x00, 0x10, 0x00, 0x10, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 4 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x80, 0x00, \
+ 0xF0, 0x00, 0x08, 0x00, 0x08, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 5 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 6 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 7 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x70, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 8 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x78, 0x00, 0x08, 0x00, 0x08, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* 9 */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* : */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x40, 0x00, /* ; */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, \
+ 0x20, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* < */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF8, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* = */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, \
+ 0x10, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* > */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* ? */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0xB8, 0x00, 0xA8, 0x00, 0xB8, 0x00, 0x80, 0x00, 0x78, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* @ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0xF8, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* A */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0xF0, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* B */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* C */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xF0, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* D */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xF0, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* E */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0xF0, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* F */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x80, 0x00, 0x98, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* G */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0xF8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* H */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* I */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* J */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0xB0, 0x00, \
+ 0xE0, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0xB0, 0x00, 0x98, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* K */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* L */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xD8, 0x00, \
+ 0xF8, 0x00, 0xA8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* M */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xC8, 0x00, \
+ 0xC8, 0x00, 0xA8, 0x00, 0x98, 0x00, 0x98, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* N */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* O */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0xF0, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* P */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xA8, 0x00, 0x70, 0x00, \
+ 0x08, 0x00, 0x00, 0x00, /* Q */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* R */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x00, \
+ 0x80, 0x00, 0x70, 0x00, 0x08, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* S */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* T */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* U */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* V */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x88, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0x50, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* W */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x50, 0x00, \
+ 0x70, 0x00, 0x20, 0x00, 0x70, 0x00, 0x50, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* X */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x50, 0x00, \
+ 0x70, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* Y */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x00, \
+ 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* Z */ \
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x30, 0x00, 0x00, 0x00, /* [ */ \
+ 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x40, 0x00, 0x60, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x04, 0x00, 0x00, 0x00, /* \ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x60, 0x00, 0x00, 0x00, /* ] */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x50, 0x00, \
+ 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* ^ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0xFC, 0x00, /* _ */ \
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* ` */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF0, 0x00, 0x08, 0x00, 0xF8, 0x00, 0x88, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* a */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xF0, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* b */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x70, 0x00, 0x88, 0x00, 0x80, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* c */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, \
+ 0x78, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x78, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* d */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x70, 0x00, 0x88, 0x00, 0xF8, 0x00, 0x80, 0x00, 0x78, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* e */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x20, 0x00, \
+ 0x70, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* f */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x78, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x78, 0x00, \
+ 0x08, 0x00, 0x70, 0x00, /* g */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* h */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, \
+ 0x60, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* i */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, \
+ 0xE0, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0xC0, 0x00, /* j */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x98, 0x00, 0xA0, 0x00, 0xE0, 0x00, 0x90, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* k */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* l */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* m */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* n */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x70, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* o */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF0, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xF0, 0x00, \
+ 0x80, 0x00, 0x80, 0x00, /* p */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x78, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x78, 0x00, \
+ 0x08, 0x00, 0x08, 0x00, /* q */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF8, 0x00, 0x88, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* r */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF8, 0x00, 0x80, 0x00, 0xF8, 0x00, 0x08, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* s */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x78, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x18, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* t */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x78, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* u */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x88, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x20, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* v */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0x50, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* w */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xD8, 0x00, 0x50, 0x00, 0x20, 0x00, 0x50, 0x00, 0xD8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* x */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x78, 0x00, \
+ 0x08, 0x00, 0x70, 0x00, /* y */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0xF8, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0xF8, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, /* z */ \
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x10, 0x00, 0x00, 0x00, /* { */ \
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x00, 0x00, /* | */ \
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x20, 0x00, 0x10, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, \
+ 0x40, 0x00, 0x00, 0x00, /* } */ \
+ };
+#elif defined(USE_FONT_BASIC_6x7)
+/** Width of each glyph, including spacer column. */
+# define SYSFONT_WIDTH 6
+/** Height of each glyph, excluding spacer line. */
+# define SYSFONT_HEIGHT 7
+/** Line height. */
+# define SYSFONT_LINESPACING 8
+/** First character defined. */
+# define SYSFONT_FIRSTCHAR ((uint8_t)' ')
+/** Last character defined. */
+# define SYSFONT_LASTCHAR ((uint8_t)'}')
+
+/** Define variable containing the font */
+# define SYSFONT_DEFINE_GLYPHS \
+ /* Glyph data, row by row, MSB is leftmost pixel, one byte per row. */ \
+ static PROGMEM_DECLARE(uint8_t, sysfont_glyphs[]) = { \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* " " */ \
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x20, /* "!" */ \
+ 0x50, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, /* """ */ \
+ 0x50, 0x50, 0xf8, 0x50, 0xf8, 0x50, 0x50, /* "#" */ \
+ 0x20, 0x78, 0xa0, 0x70, 0x28, 0xf0, 0x20, /* "$" */ \
+ 0xc0, 0xc8, 0x10, 0x20, 0x40, 0x98, 0x18, /* "%" */ \
+ 0x60, 0x90, 0xa0, 0x40, 0xa8, 0x90, 0x68, /* "&" */ \
+ 0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, /* "'" */ \
+ 0x10, 0x20, 0x40, 0x40, 0x40, 0x20, 0x10, /* "(" */ \
+ 0x40, 0x20, 0x10, 0x10, 0x10, 0x20, 0x40, /* ")" */ \
+ 0x00, 0x50, 0x20, 0xf8, 0x20, 0x50, 0x00, /* "*" */ \
+ 0x00, 0x20, 0x20, 0xf8, 0x20, 0x20, 0x00, /* "+" */ \
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x40, /* "," */ \
+ 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, /* "-" */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, /* "." */ \
+ 0x00, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, /* "/" */ \
+ 0x70, 0x88, 0x98, 0xa8, 0xc8, 0x88, 0x70, /* "0" */ \
+ 0x20, 0x60, 0x20, 0x20, 0x20, 0x20, 0x70, /* "1" */ \
+ 0x70, 0x88, 0x08, 0x10, 0x20, 0x40, 0xf8, /* "2" */ \
+ 0xf8, 0x10, 0x20, 0x10, 0x08, 0x88, 0x70, /* "3" */ \
+ 0x10, 0x30, 0x50, 0x90, 0xf8, 0x10, 0x10, /* "4" */ \
+ 0xf8, 0x80, 0xf0, 0x08, 0x08, 0x88, 0x70, /* "5" */ \
+ 0x30, 0x40, 0x80, 0xf0, 0x88, 0x88, 0x70, /* "6" */ \
+ 0xf8, 0x08, 0x10, 0x20, 0x40, 0x40, 0x40, /* "7" */ \
+ 0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70, /* "8" */ \
+ 0x70, 0x88, 0x88, 0x78, 0x08, 0x10, 0x60, /* "9" */ \
+ 0x00, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, /* ":" */ \
+ 0x00, 0x60, 0x60, 0x00, 0x60, 0x20, 0x40, /* ";" */ \
+ 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, /* "<" */ \
+ 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, /* "=" */ \
+ 0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80, /* ">" */ \
+ 0x70, 0x88, 0x08, 0x10, 0x20, 0x00, 0x20, /* "?" */ \
+ 0x70, 0x88, 0x08, 0x68, 0xa8, 0xa8, 0x70, /* "@" */ \
+ 0x70, 0x88, 0x88, 0x88, 0xf8, 0x88, 0x88, /* "A" */ \
+ 0xf0, 0x88, 0x88, 0xf0, 0x88, 0x88, 0xf0, /* "B" */ \
+ 0x70, 0x88, 0x80, 0x80, 0x80, 0x88, 0x70, /* "C" */ \
+ 0xe0, 0x90, 0x88, 0x88, 0x88, 0x90, 0xe0, /* "D" */ \
+ 0xf8, 0x80, 0x80, 0xf0, 0x80, 0x80, 0xf8, /* "E" */ \
+ 0xf8, 0x80, 0x80, 0xe0, 0x80, 0x80, 0x80, /* "F" */ \
+ 0x70, 0x88, 0x80, 0x80, 0x98, 0x88, 0x70, /* "G" */ \
+ 0x88, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x88, /* "H" */ \
+ 0x70, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, /* "I" */ \
+ 0x38, 0x10, 0x10, 0x10, 0x10, 0x90, 0x60, /* "J" */ \
+ 0x88, 0x90, 0xa0, 0xc0, 0xa0, 0x90, 0x88, /* "K" */ \
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf8, /* "L" */ \
+ 0x88, 0xd8, 0xa8, 0x88, 0x88, 0x88, 0x88, /* "M" */ \
+ 0x88, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x88, /* "N" */ \
+ 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, /* "O" */ \
+ 0xf0, 0x88, 0x88, 0xf0, 0x80, 0x80, 0x80, /* "P" */ \
+ 0x70, 0x88, 0x88, 0x88, 0xa8, 0x90, 0x68, /* "Q" */ \
+ 0xf0, 0x88, 0x88, 0xf0, 0xa0, 0x90, 0x88, /* "R" */ \
+ 0x78, 0x80, 0x80, 0x70, 0x08, 0x08, 0xf0, /* "S" */ \
+ 0xf8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, /* "T" */ \
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, /* "U" */ \
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x50, 0x20, /* "V" */ \
+ 0x88, 0x88, 0x88, 0xa8, 0xa8, 0xd8, 0x88, /* "W" */ \
+ 0x88, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88, /* "X" */ \
+ 0x88, 0x88, 0x50, 0x20, 0x20, 0x20, 0x20, /* "Y" */ \
+ 0xf8, 0x08, 0x10, 0x20, 0x40, 0x80, 0xf8, /* "Z" */ \
+ 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, /* "[" */ \
+ 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x00, /* "\" */ \
+ 0xe0, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe0, /* "]" */ \
+ 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, /* "^" */ \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, /* "_" */ \
+ 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, /* "`" */ \
+ 0x00, 0x00, 0x70, 0x08, 0x78, 0x88, 0x78, /* "a" */ \
+ 0x80, 0x80, 0xb0, 0xc8, 0x88, 0x88, 0xf0, /* "b" */ \
+ 0x00, 0x00, 0x70, 0x80, 0x80, 0x88, 0x70, /* "c" */ \
+ 0x08, 0x08, 0x68, 0x98, 0x88, 0x88, 0x78, /* "d" */ \
+ 0x00, 0x00, 0x70, 0x88, 0xf8, 0x80, 0x70, /* "e" */ \
+ 0x30, 0x48, 0x40, 0xe0, 0x40, 0x40, 0x40, /* "f" */ \
+ 0x00, 0x00, 0x78, 0x88, 0x78, 0x08, 0x30, /* "g" */ \
+ 0x80, 0x80, 0xb0, 0xc8, 0x88, 0x88, 0x88, /* "h" */ \
+ 0x20, 0x00, 0x60, 0x20, 0x20, 0x20, 0x70, /* "i" */ \
+ 0x10, 0x00, 0x30, 0x10, 0x10, 0x90, 0x60, /* "j" */ \
+ 0x40, 0x40, 0x48, 0x50, 0x60, 0x50, 0x48, /* "k" */ \
+ 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, /* "l" */ \
+ 0x00, 0x00, 0xd0, 0xa8, 0xa8, 0x88, 0x88, /* "m" */ \
+ 0x00, 0x00, 0xb0, 0xc8, 0x88, 0x88, 0x88, /* "n" */ \
+ 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70, /* "o" */ \
+ 0x00, 0x00, 0xf0, 0x88, 0xf0, 0x80, 0x80, /* "p" */ \
+ 0x00, 0x00, 0x68, 0x98, 0x78, 0x08, 0x08, /* "q" */ \
+ 0x00, 0x00, 0xb0, 0xc8, 0x80, 0x80, 0x80, /* "r" */ \
+ 0x00, 0x00, 0x70, 0x80, 0x70, 0x08, 0xf0, /* "s" */ \
+ 0x40, 0x40, 0xe0, 0x40, 0x40, 0x48, 0x30, /* "t" */ \
+ 0x00, 0x00, 0x88, 0x88, 0x88, 0x98, 0x68, /* "u" */ \
+ 0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, /* "v" */ \
+ 0x00, 0x00, 0x88, 0x88, 0xa8, 0xa8, 0x50, /* "w" */ \
+ 0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, /* "x" */ \
+ 0x00, 0x00, 0x88, 0x88, 0x78, 0x08, 0x70, /* "y" */ \
+ 0x00, 0x00, 0xf8, 0x10, 0x20, 0x40, 0xf8, /* "z" */ \
+ 0x10, 0x20, 0x20, 0x40, 0x20, 0x20, 0x10, /* "{" */ \
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, /* "|" */ \
+ 0x40, 0x20, 0x20, 0x10, 0x20, 0x20, 0x40, /* "}" */ \
+ };
+#endif
+
+/** @} */
+
+#endif /* CONF_SYSFONT_H */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_sysfont.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_sysfont.h.REMOVED.git-id
deleted file mode 100644
index cbe09eeb..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_sysfont.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-05daa73beef5eba6260cf530a89e846f6b95ddaf
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_usart_spi.h b/AVR Code/USB_BULK_TEST/src/config/conf_usart_spi.h
new file mode 100644
index 00000000..aa9a9718
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_usart_spi.h
@@ -0,0 +1,50 @@
+/**
+ * \file *********************************************************************
+ *
+ * \brief Spi Master configuration for spi example
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+#ifndef CONF_USART_SPI_H_INCLUDED
+#define CONF_USART_SPI_H_INCLUDED
+
+
+#endif /* CONF_USART_SPI_H_INCLUDED */
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_usart_spi.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_usart_spi.h.REMOVED.git-id
deleted file mode 100644
index 08b8157d..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_usart_spi.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-aa9a97184fe21ba5691e6a343e2032259d89fecb
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_usb.h b/AVR Code/USB_BULK_TEST/src/config/conf_usb.h
new file mode 100644
index 00000000..4e336bd2
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/config/conf_usb.h
@@ -0,0 +1,165 @@
+/**
+ * \file
+ *
+ * \brief USB configuration file
+ *
+ * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _CONF_USB_H_
+#define _CONF_USB_H_
+
+#include "compiler.h"
+#include "globals.h"
+
+
+/**
+ * USB Device Configuration
+ * @{
+ */
+
+//! Device definition (mandatory)
+#define USB_DEVICE_VENDOR_ID 0x03eb
+#define USB_DEVICE_PRODUCT_ID 0xba94
+#define USB_DEVICE_MAJOR_VERSION 2
+#define USB_DEVICE_MINOR_VERSION 0
+#define USB_DEVICE_POWER 500 // Consumption on Vbus line (mA)
+#define USB_DEVICE_ATTR \
+ (USB_CONFIG_ATTR_BUS_POWERED)
+// (USB_CONFIG_ATTR_SELF_POWERED)
+// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
+// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
+
+//! USB Device string definitions (Optional)
+#define USB_DEVICE_MANUFACTURE_NAME "EspoTek"
+#define USB_DEVICE_PRODUCT_NAME "Labrador"
+// #define USB_DEVICE_SERIAL_NAME "123123123123"
+
+/**
+ * Device speeds support
+ * Low speed not supported by this vendor class
+ * @{
+ */
+//! To authorize the High speed
+#if (UC3A3||UC3A4)
+# define USB_DEVICE_HS_SUPPORT
+#elif (SAM3XA||SAM3U)
+# define USB_DEVICE_HS_SUPPORT
+#endif
+//@}
+
+
+/**
+ * USB Device Callbacks definitions (Optional)
+ * @{
+ */
+#define UDC_VBUS_EVENT(b_vbus_high)
+#define UDC_SOF_EVENT() main_sof_action()
+#define UDC_SUSPEND_EVENT() main_suspend_action()
+#define UDC_RESUME_EVENT() main_resume_action()
+//! Mandatory when USB_DEVICE_ATTR authorizes remote wakeup feature
+// #define UDC_REMOTEWAKEUP_ENABLE() user_callback_remotewakeup_enable()
+// extern void user_callback_remotewakeup_enable(void);
+// #define UDC_REMOTEWAKEUP_DISABLE() user_callback_remotewakeup_disable()
+// extern void user_callback_remotewakeup_disable(void);
+//! When a extra string descriptor must be supported
+//! other than manufacturer, product and serial string
+// #define UDC_GET_EXTRA_STRING()
+//@}
+
+//@}
+
+
+/**
+ * USB Interface Configuration
+ * @{
+ */
+
+/**
+ * Configuration of vendor interface
+ * @{
+ */
+//! Interface callback definition
+#define UDI_VENDOR_ENABLE_EXT() main_vendor_enable()
+#define UDI_VENDOR_DISABLE_EXT() main_vendor_disable()
+#define UDI_VENDOR_SETUP_OUT_RECEIVED() main_setup_out_received()
+#define UDI_VENDOR_SETUP_IN_RECEIVED() main_setup_in_received()
+
+//! endpoints size for full speed
+//! Note: Disable the endpoints of a type, if size equal 0
+#define UDI_VENDOR_EPS_SIZE_INT_FS 0
+#define UDI_VENDOR_EPS_SIZE_BULK_FS 0
+#if SAMG55
+#define UDI_VENDOR_EPS_SIZE_ISO_FS 0
+#else
+ #ifdef SINGLE_ENDPOINT_INTERFACE
+ #define UDI_VENDOR_EPS_SIZE_ISO_FS 1023
+ #else
+ #define UDI_VENDOR_EPS_SIZE_ISO_FS 128
+ #endif
+#endif
+
+//! endpoints size for high speed
+#define UDI_VENDOR_EPS_SIZE_INT_HS 64
+#define UDI_VENDOR_EPS_SIZE_BULK_HS 512
+#define UDI_VENDOR_EPS_SIZE_ISO_HS 64
+
+//@}
+
+//@}
+
+
+/**
+ * USB Device Driver Configuration
+ * @{
+ */
+//! Limit the isochronous endpoint in singe bank mode for USBB driver
+//! to avoid exceeding USB DPRAM.
+#define UDD_ISOCHRONOUS_NB_BANK(ep) 1
+//@}
+
+//! The includes of classes and other headers must be done
+//! at the end of this file to avoid compile error
+#include "udi_vendor_conf.h"
+#include "ui.h"
+#include "main.h"
+
+#endif // _CONF_USB_H_
diff --git a/AVR Code/USB_BULK_TEST/src/config/conf_usb.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/config/conf_usb.h.REMOVED.git-id
deleted file mode 100644
index 290c77cd..00000000
--- a/AVR Code/USB_BULK_TEST/src/config/conf_usb.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4e336bd2e2cf9cc16fda2b3dd946da4d54b6a580
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/globals.h b/AVR Code/USB_BULK_TEST/src/globals.h
new file mode 100644
index 00000000..bbbb9509
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/globals.h
@@ -0,0 +1,73 @@
+/*
+ * globals.h
+ *
+ * Created: 18/04/2015 12:44:42 PM
+ * Author: Esposch
+ */
+
+
+#ifndef GLOBALS_H_
+#define GLOBALS_H_
+
+#define SINGLE_ENDPOINT_INTERFACE
+
+//#define VERO
+#define OVERCLOCK 48
+#define FIRMWARE_VERSION_ID 0x0003
+#define ATMEL_DFU_OFFSET 0x01fc
+
+#define TC_SPISLAVE TCD0
+#define TC_PSU TCD1
+#define TC_PSU_OVF TCD1_OVF_vect
+#define TC_DAC TCC0
+#define TCDAC_OVF EVSYS_CHMUX_TCC0_OVF_gc
+#define TC_AUXDAC TCC1
+#define TC_CALI TCE0
+#define TCDAC_AUX_OVF EVSYS_CHMUX_TCC1_OVF_gc
+#define HALFPACKET_SIZE 375
+#define PACKET_SIZE 750
+#define B2_START 1125
+#define BUFFER_SIZE (PACKET_SIZE*2)
+#define DACBUF_SIZE 512
+
+COMPILER_WORD_ALIGNED
+extern volatile unsigned char isoBuf[BUFFER_SIZE];
+COMPILER_WORD_ALIGNED
+extern volatile unsigned char dacBuf_CH1[DACBUF_SIZE];
+extern volatile unsigned char dacBuf_CH2[DACBUF_SIZE];
+
+extern volatile unsigned char b1_state;
+extern volatile unsigned char b2_state;
+extern volatile unsigned char usb_state;
+
+extern volatile bool main_b_vendor_enable;
+
+extern volatile uint16_t dacBuf_len;
+extern volatile uint16_t auxDacBufLen;
+
+extern volatile unsigned char dummy;
+
+extern volatile unsigned char global_mode;
+
+extern volatile char PSU_target;
+
+extern volatile unsigned char test_byte;
+
+extern volatile unsigned char debugOnNextEnd;
+
+extern volatile unsigned int median_TRFCNT;
+
+extern volatile unsigned short dma_ch0_ran;
+extern volatile unsigned short dma_ch1_ran;
+
+extern volatile unsigned char futureMode;
+extern volatile unsigned char modeChanged;
+
+COMPILER_WORD_ALIGNED
+extern const unsigned short firmver;
+extern const unsigned char variant;
+
+#include "unified_debug_structure.h"
+extern unified_debug uds;
+
+#endif /* GLOBALS_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/globals.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/globals.h.REMOVED.git-id
deleted file mode 100644
index 2d59b167..00000000
--- a/AVR Code/USB_BULK_TEST/src/globals.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-bbbb9509622e1e73eb9f61bc994c9eb96602327b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/main.c b/AVR Code/USB_BULK_TEST/src/main.c
new file mode 100644
index 00000000..2a31dc93
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/main.c
@@ -0,0 +1,306 @@
+//Include the ASF Licence!
+
+#include
+#include
+#include
+
+#include "ui.h"
+#include "globals.h"
+#include "tiny_adc.h"
+#include "tiny_dma.h"
+#include "tiny_timer.h"
+#include "tiny_dac.h"
+#include "tiny_uart.h"
+#include "tiny_dig.h"
+#include "tiny_calibration.h"
+#include "tiny_eeprom.h"
+
+volatile bool main_b_vendor_enable = false;
+
+COMPILER_WORD_ALIGNED
+volatile unsigned char isoBuf[BUFFER_SIZE];
+COMPILER_WORD_ALIGNED
+volatile unsigned char dacBuf_CH1[DACBUF_SIZE];
+volatile unsigned char dacBuf_CH2[DACBUF_SIZE];
+
+volatile unsigned char b1_state = 0;
+volatile unsigned char b2_state = 0;
+volatile unsigned char usb_state = 0;
+
+volatile uint16_t dacBuf_len = 128;
+volatile uint16_t auxDacBufLen = 128;
+volatile unsigned char dummy = 0x55;
+volatile unsigned char global_mode = 255;
+
+volatile char PSU_target = 0;
+
+volatile unsigned char test_byte = 123;
+
+uint32_t debug_counter;
+
+unsigned char tripleUsbSuccess = 0;
+
+volatile unsigned char firstFrame = 0;
+volatile unsigned char tcinit = 0;
+
+volatile unsigned int currentTrfcnt;
+volatile unsigned char debugOnNextEnd = 0;
+
+/*
+#define CNT_CNT_MAX 256
+volatile unsigned short cntCnt[CNT_CNT_MAX];
+volatile unsigned short cntCntCnt = 0;
+#define DEBUG_DIVISION 0
+volatile unsigned char debug_divider = 0;
+*/
+volatile unsigned int median_TRFCNT = 65535;
+
+volatile char debug_data[8] = "DEBUG123";
+
+volatile unsigned short dma_ch0_ran;
+volatile unsigned short dma_ch1_ran;
+
+volatile unsigned char futureMode;
+volatile unsigned char modeChanged = 0;
+
+unified_debug uds;
+
+const unsigned short firmver = FIRMWARE_VERSION_ID;
+
+#ifdef SINGLE_ENDPOINT_INTERFACE
+ const unsigned char variant = 0x02;
+#else
+ const unsigned char variant = 0x01;
+#endif
+
+volatile unsigned char eeprom_buffer_write[EEPROM_PAGE_SIZE];
+volatile unsigned char eeprom_buffer_read[EEPROM_PAGE_SIZE];
+
+void jump_to_bootloader(){
+ void(* start_bootloader)(void) = (void (*)(void))((BOOT_SECTION_START + ATMEL_DFU_OFFSET)>>1);
+ EIND = BOOT_SECTION_START>>17;
+ start_bootloader();
+}
+
+int main(void){
+ eeprom_safe_read();
+ if(eeprom_buffer_read[0]){
+ memcpy(eeprom_buffer_write, eeprom_buffer_read, EEPROM_PAGE_SIZE);
+ eeprom_buffer_write[0] = 0;
+ eeprom_safe_write();
+ //eeprom_safe_read();
+ jump_to_bootloader();
+ }
+
+ irq_initialize_vectors();
+ cpu_irq_enable();
+// sysclk_init();
+ tiny_calibration_init();
+
+ board_init();
+ udc_start();
+ tiny_dac_setup();
+ tiny_dma_setup();
+ tiny_adc_setup(0, 0);
+ tiny_adc_pid_setup();
+ tiny_adc_ch1setup(12);
+ tiny_timer_setup();
+ tiny_uart_setup();
+ tiny_spi_setup();
+ tiny_dig_setup();
+
+ //USARTC0.DATA = 0x55;
+ //asm("nop");
+
+
+
+ strcpy(uds.header, "debug123");
+
+ while (true) {
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ if(modeChanged){
+ switch(futureMode){
+ case 0:
+ tiny_dma_set_mode_0();
+ break;
+ case 1:
+ tiny_dma_set_mode_1();
+ break;
+ case 2:
+ tiny_dma_set_mode_2();
+ break;
+ case 3:
+ tiny_dma_set_mode_3();
+ break;
+ case 4:
+ tiny_dma_set_mode_4();
+ break;
+ case 5:
+ tiny_dma_set_mode_5();
+ break;
+ case 6:
+ tiny_dma_set_mode_6();
+ break;
+ case 7:
+ tiny_dma_set_mode_7();
+ break;
+ }
+ modeChanged = 0;
+ }
+ }
+}
+
+//! Global variable to give and record information about setup request management
+udd_ctrl_request_t udd_g_ctrlreq;
+
+//CALLBACKS:
+void main_suspend_action(void)
+{
+ return;
+}
+
+void main_resume_action(void)
+{
+ return;
+}
+
+void main_sof_action(void)
+{
+ #ifdef SINGLE_ENDPOINT_INTERFACE
+ switch(global_mode){
+ case 0:
+ tiny_dma_loop_mode_0();
+ break;
+ case 1:
+ tiny_dma_loop_mode_1();
+ break;
+ case 2:
+ tiny_dma_loop_mode_2();
+ break;
+ case 3:
+ tiny_dma_loop_mode_3();
+ break;
+ case 4:
+ tiny_dma_loop_mode_4();
+ break;
+ case 6:
+ tiny_dma_loop_mode_6();
+ break;
+ case 7:
+ tiny_dma_loop_mode_7();
+ break;
+ default:
+ break;
+ }
+ #endif
+
+ uds.trfcntL0 = DMA.CH0.TRFCNTL;
+ uds.trfcntH0 = DMA.CH0.TRFCNTH;
+ uds.trfcntL1 = DMA.CH1.TRFCNTL;
+ uds.trfcntH1 = DMA.CH1.TRFCNTH;
+ uds.counterL = TC_CALI.CNTL;
+ uds.counterH = TC_CALI.CNTH;
+ if((DMA.CH0.TRFCNT > 325) && (DMA.CH0.TRFCNT < 425)){
+ currentTrfcnt = DMA.CH0.TRFCNT;
+ asm("nop");
+ }
+ if(firstFrame){
+ tiny_calibration_first_sof();
+ firstFrame = 0;
+ tcinit = 1;
+ return;
+ }
+ else{
+ if(tcinit){
+ if(calibration_values_found == 0x03){
+ tiny_calibration_maintain();
+ tiny_calibration_layer2();
+ } else tiny_calibration_find_values();
+ /*if(debug_divider == DEBUG_DIVISION){
+ debug_divider = 0;
+ cntCnt[cntCntCnt] = DMA.CH0.TRFCNT;
+ if(cntCntCnt == (CNT_CNT_MAX - 1)){
+ cntCntCnt = 0;
+ }
+ else cntCntCnt++;
+ }
+ else debug_divider++;*/
+ }
+ }
+
+ if(debugOnNextEnd){
+ currentTrfcnt = DMA.CH0.TRFCNT;
+ debugOnNextEnd = 0;
+ }
+ #ifndef SINGLE_ENDPOINT_INTERFACE
+ if(global_mode < 5){
+ usb_state = (DMA.CH0.TRFCNT < 375) ? 1 : 0;
+ }
+ else{
+ usb_state = (DMA.CH0.TRFCNT < 750) ? 1 : 0;
+ }
+ #else
+ usb_state = !usb_state;
+ #endif
+
+ return;
+}
+
+bool main_vendor_enable(void)
+{
+ main_b_vendor_enable = true;
+ firstFrame = 1;
+ udd_ep_run(0x81, false, (uint8_t *)&isoBuf[0], 125, iso_callback);
+ #ifndef SINGLE_ENDPOINT_INTERFACE
+ udd_ep_run(0x82, false, (uint8_t *)&isoBuf[125], 125, iso_callback);
+ udd_ep_run(0x83, false, (uint8_t *)&isoBuf[250], 125, iso_callback);
+ udd_ep_run(0x84, false, (uint8_t *)&isoBuf[375], 125, iso_callback);
+ udd_ep_run(0x85, false, (uint8_t *)&isoBuf[500], 125, iso_callback);
+ udd_ep_run(0x86, false, (uint8_t *)&isoBuf[625], 125, iso_callback);
+ #endif
+ return true;
+}
+
+void main_vendor_disable(void)
+{
+ main_b_vendor_enable = false;
+}
+
+bool main_setup_out_received(void)
+{
+ return 1;
+}
+
+bool main_setup_in_received(void)
+{
+ return true;
+}
+
+void iso_callback(udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep){
+ #ifndef SINGLE_ENDPOINT_INTERFACE
+ unsigned short offset = (ep - 0x81) * 125;
+ if (global_mode < 5){
+ if(ep > 0x83) offset += 375; //Shift from range [375, 750] to [750, 1125] Don't do this in modes 6 and 7 because they use 750 byte long sub-buffers.
+ udd_ep_run(ep, false, (uint8_t *)&isoBuf[usb_state * HALFPACKET_SIZE + offset], 125, iso_callback);
+ }
+ else{
+ udd_ep_run(ep, false, (uint8_t *)&isoBuf[usb_state * PACKET_SIZE + offset], 125, iso_callback);
+ }
+ return;
+ #else
+ udd_ep_run(0x81, false, (uint8_t *)&isoBuf[usb_state * PACKET_SIZE], PACKET_SIZE, iso_callback);
+ #endif
+}
diff --git a/AVR Code/USB_BULK_TEST/src/main.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/main.c.REMOVED.git-id
deleted file mode 100644
index 8e8a14a8..00000000
--- a/AVR Code/USB_BULK_TEST/src/main.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2a31dc9369acc7c6f86a75250d5c254e9911b845
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/main.h b/AVR Code/USB_BULK_TEST/src/main.h
new file mode 100644
index 00000000..7b7817ed
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/main.h
@@ -0,0 +1,91 @@
+/**
+ * \file
+ *
+ * \brief Declaration of main function used by example
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _MAIN_H_
+#define _MAIN_H_
+
+/*! \brief Notify via user interface that enumeration is ok
+ * This is called by vendor interface when USB Host enable it.
+ *
+ * \retval true if vendor startup is successfully done
+ */
+bool main_vendor_enable(void);
+
+/*! \brief Notify via user interface that enumeration is disabled
+ * This is called by vendor interface when USB Host disable it.
+ */
+void main_vendor_disable(void);
+
+/*! \brief Manages the leds behaviors
+ * Called when a start of frame is received on USB line each 1ms.
+ */
+void main_sof_action(void);
+
+/*! \brief Enters the application in low power mode
+ * Callback called when USB host sets USB line in suspend state
+ */
+void main_suspend_action(void);
+
+/*! \brief Turn on a led to notify active mode
+ * Called when the USB line is resumed from the suspend state
+ */
+void main_resume_action(void);
+
+/*! \brief Manage the reception of setup request OUT
+ *
+ * \retval true if request accepted
+ */
+bool main_setup_out_received(void);
+
+/*! \brief Manage the reception of setup request IN
+ *
+ * \retval true if request accepted
+ */
+bool main_setup_in_received(void);
+
+void iso_callback(udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep);
+
+#endif // _MAIN_H_
diff --git a/AVR Code/USB_BULK_TEST/src/main.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/main.h.REMOVED.git-id
deleted file mode 100644
index a0eed466..00000000
--- a/AVR Code/USB_BULK_TEST/src/main.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7b7817ed83496915a3709403c6a8e46c194596fe
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_adc.c b/AVR Code/USB_BULK_TEST/src/tiny_adc.c
new file mode 100644
index 00000000..171dc4b0
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_adc.c
@@ -0,0 +1,93 @@
+/*
+ * tiny_adc.c
+ *
+ * Created: 19/06/2015 7:17:23 PM
+ * Author: Esposch
+ */
+
+#include "tiny_adc.h"
+#include "globals.h"
+#include "string.h"
+#include
+#include
+#include
+
+// These 2 files need to be included in order to read
+// the production calibration values from EEPROM
+#include
+#include
+
+void tiny_adc_setup(unsigned char ch2_enable, unsigned char seven_fiddy_ksps){
+ PR.PRPA &=0b11111101;
+
+ ADCA.CTRLA = 0x00; //Turn off
+ ADCA.CTRLB = ADC_FREERUN_bm | (seven_fiddy_ksps == 2 ? ADC_RESOLUTION_LEFT12BIT_gc : ADC_RESOLUTION_8BIT_gc) | ADC_CONMODE_bm ;
+ ADCA.REFCTRL = ADC_REFSEL_INTVCC2_gc;
+ ADCA.EVCTRL = ch2_enable ? ADC_SWEEP_0123_gc : ADC_SWEEP_01_gc; //Non-zero causes issues with interrupts! ;.;
+
+ #if OVERCLOCK == 48
+ ADCA.PRESCALER = seven_fiddy_ksps == 1 ? ADC_PRESCALER_DIV32_gc : ADC_PRESCALER_DIV64_gc; //ADC Clock = Sysclock/128
+ #else
+ ADCA.PRESCALER = seven_fiddy_ksps == 1 ? ADC_PRESCALER_DIV16_gc : ADC_PRESCALER_DIV32_gc; //ADC Clock = Sysclock/128
+ #endif
+ ADCA.CALL = ReadCalibrationByte(offsetof(NVM_PROD_SIGNATURES_t, ADCACAL0)); //Load calibration bytes from production row.
+ ADCA.CALH = ReadCalibrationByte(offsetof(NVM_PROD_SIGNATURES_t, ADCACAL1)); //Load calibration bytes from production row.
+ ADCA.CMP = 0x0000; //No compare used
+
+ ADCA.CTRLA = ADC_ENABLE_bm;
+
+ tiny_adc_pid_setup();
+
+ return;
+}
+
+void tiny_adc_ch0setup(unsigned char gain_mask){
+ ADCA.CH0.CTRL = 0x00; //Reset
+ ADCA.CH0.CTRL = ADC_CH_START_bm | (gain_mask&0x1c) | ADC_CH_INPUTMODE_DIFFWGAIN_gc;
+ #ifdef VERO
+ ADCA.CH0.MUXCTRL = ADC_CH_MUXPOS_PIN0_gc | ((gain_mask&0x80) ? ADC_CH_MUXNEG_PIN6_gc : ADC_CH_MUXNEG_PIN4_gc);
+ #else
+ ADCA.CH0.MUXCTRL = ((gain_mask&0x80) ? ADC_CH_MUXPOS_PIN2_gc : ADC_CH_MUXPOS_PIN0_gc) | ((gain_mask&0x80) ? ADC_CH_MUXNEG_PIN6_gc : ADC_CH_MUXNEG_PIN4_gc);
+ #endif
+ ADCA.CH0.INTCTRL = ADC_CH_INTLVL_OFF_gc;
+ ADCA.CH0.SCAN = 0x00; //Disable scanning
+}
+
+void tiny_adc_ch1setup(unsigned char gain_mask){
+ ADCA.CH2.CTRL = 0x00; //Reset
+ ADCA.CH2.CTRL = ADC_CH_START_bm | gain_mask | ADC_CH_INPUTMODE_DIFFWGAIN_gc;
+ ADCA.CH2.MUXCTRL = ADC_CH_MUXPOS_PIN2_gc | ADC_CH_MUXNEG_PIN4_gc;
+ ADCA.CH2.INTCTRL = ADC_CH_INTLVL_OFF_gc;
+ ADCA.CH2.SCAN = 0x00; //Disable scanning
+}
+
+void tiny_adc_pid_setup(void){
+ ADCA.CH1.CTRL = 0x00; //Reset
+ ADCA.CH1.CTRL = ADC_CH_START_bm | ADC_CH_GAIN_1X_gc | ADC_CH_INPUTMODE_DIFFWGAIN_gc;
+ ADCA.CH1.MUXCTRL = ADC_CH_MUXPOS_PIN5_gc | 0b00000111;
+ ADCA.CH1.INTCTRL = ADC_CH_INTLVL_OFF_gc;
+ ADCA.CH1.SCAN = 0x00; //Disable scanning
+}
+
+
+//FROM: http://www.avrfreaks.net/forum/xmega-production-signature-row
+uint8_t ReadCalibrationByte(uint8_t index){
+ uint8_t result;
+
+ /* Load the NVM Command register to read the calibration row. */
+ NVM_CMD = NVM_CMD_READ_CALIB_ROW_gc;
+ result = pgm_read_byte(index);
+
+ /* Clean up NVM Command register. */
+ NVM_CMD = NVM_CMD_NO_OPERATION_gc;
+
+ return( result );
+}
+
+ISR(ADCA_CH0_vect){
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ asm("nop");
+ ADCA.CH0.INTFLAGS = 0x01;
+}
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_adc.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_adc.c.REMOVED.git-id
deleted file mode 100644
index 21af6a73..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_adc.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-171dc4b0f37dfd979963ec77a6558585adb11de7
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_adc.h b/AVR Code/USB_BULK_TEST/src/tiny_adc.h
new file mode 100644
index 00000000..d2b00170
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_adc.h
@@ -0,0 +1,23 @@
+/*
+ * tiny_adc.h
+ *
+ * Created: 19/06/2015 7:15:32 PM
+ * Author: Esposch
+ */
+
+
+#ifndef TINY_ADC_H_
+#define TINY_ADC_H_
+
+#include
+#include
+
+void tiny_adc_setup(unsigned char ch2_enable, unsigned char seven_fiddy_ksps);
+void tiny_adc_ch0setup(unsigned char gain_mask);
+void tiny_adc_ch1setup(unsigned char gain_mask);
+uint8_t ReadCalibrationByte(uint8_t index); //FROM: http://www.avrfreaks.net/forum/xmega-production-signature-row
+void tiny_adc_pid_setup(void);
+
+
+
+#endif /* TINY_ADC_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_adc.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_adc.h.REMOVED.git-id
deleted file mode 100644
index 62c20ad5..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_adc.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d2b001702e4bd32b1331e4ff7dfa73635a833247
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_calibration.c b/AVR Code/USB_BULK_TEST/src/tiny_calibration.c
new file mode 100644
index 00000000..a1ac1c4c
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_calibration.c
@@ -0,0 +1,222 @@
+/*
+ * tiny_calibration.c
+ *
+ * Created: 9/01/2017 4:20:59 PM
+ * Author: Esposch
+ */
+
+#include "tiny_calibration.h"
+#include "globals.h"
+#include "tiny_adc.h"
+
+volatile unsigned char median_TRFCNT_delay = 255;
+
+void tiny_calibration_init(){
+ //Set up 48MHz DFLL for USB.
+ OSC.DFLLCTRL = OSC_RC32MCREF_USBSOF_gc;
+ DFLLRC32M.CALB = ReadCalibrationByte(offsetof(NVM_PROD_SIGNATURES_t, USBRCOSC)); //THIS is the val for 48MHz. RCOSC32M is for a 32MHz calibration. That makes a lot of sense now...
+ DFLLRC32M.COMP2 = 0xBB;
+ DFLLRC32M.COMP1= 0x80; //0xBB80 = 48,000.
+ DFLLRC32M.CTRL = 0x01; //Enable
+
+ //Turn on the 48MHz clock and scale it down to 24MHz
+ CCP = CCP_IOREG_gc;
+ #if OVERCLOCK == 48
+ CLK.PSCTRL = CLK_PSADIV_1_gc | CLK_PSBCDIV_1_1_gc; //All peripheral clocks = CLKsys / 2.
+ #else
+ CLK.PSCTRL = CLK_PSADIV_2_gc | CLK_PSBCDIV_1_1_gc; //All peripheral clocks = CLKsys / 2.
+ #endif
+ //CLK.USBCTRL handled by udc
+ OSC.CTRL = OSC_RC32MEN_bm | OSC_RC2MEN_bm; //Enable 32MHz reference. Keep 2MHz on.
+ while(OSC.STATUS != (OSC_RC32MRDY_bm | OSC_RC2MRDY_bm)); //Wait for it to be ready before continuing
+
+ //4 step process from ASF manual. Puts a 48MHz clock on the PLL output
+ OSC.CTRL |= OSC_RC2MEN_bm; //1. Enable reference clock source.
+ OSC.PLLCTRL = OSC_PLLSRC_RC2M_gc | 24; //2. Set the multiplication factor and select the clock reference for the PLL.
+ while(!(OSC.STATUS & OSC_RC2MRDY_bm)); //3. Wait until the clock reference source is stable.
+ OSC.CTRL |= OSC_PLLEN_bm; //4. Enable the PLL
+
+ //Move CPU + Peripherals to 48MHz PLLL clock.
+ while(!(OSC.STATUS & OSC_PLLRDY_bm));
+ CCP = CCP_IOREG_gc;
+ CLK.CTRL = CLK_SCLKSEL_PLL_gc;
+
+ //DFLLRC2M.CALB -= 1;
+ //DFLLRC2M.CALA -= 21;
+ return;
+}
+
+tiny_calibration_first_sof(){
+ PR.PRPE &= 0b11111110;
+ TC_CALI.PER = 23999;
+ TC_CALI.CNT = 12000;
+ #if OVERCLOCK == 48
+ TC_CALI.CTRLA = TC_CLKSEL_DIV2_gc;
+ #else
+ TC_CALI.CTRLA = TC_CLKSEL_DIV1_gc;
+ #endif
+ return;
+}
+
+unsigned char deadTime = 0;
+volatile unsigned long outOfRange = 0;
+
+volatile unsigned char warmup = 10;
+void tiny_calibration_maintain(){
+ unsigned int cnt = TC_CALI.CNT;
+
+ if(cnt > 12000){
+ DFLLRC2M.CALA = cali_value_negative_gradient;
+ }
+ if(cnt < 12000){
+ DFLLRC2M.CALA = cali_value_positive_gradient;
+ }
+ if(warmup){
+ warmup--; //There's a warmup period in case tiny_calibration_find_values returns outside range; it won't record out of range until this period is over.
+ }
+ else if((cnt<11000) || (cnt>13000)){
+ //This is an untested, last-ditch effort to hopefully prevent runaway if there's significant drift over time.
+ calibration_values_found = 0x00;
+ outOfRange++;
+ uds.outOfRangeH = (outOfRange >> 8) & 0xff;
+ uds.outOfRangeL = outOfRange & 0xff;
+ warmup = 6;
+ }
+
+ if((median_TRFCNT == 65535) && (global_mode != 255)){
+ if(!median_TRFCNT_delay){
+ median_TRFCNT_delay--;
+ } else median_TRFCNT = DMA.CH0.TRFCNT;
+ }
+ return;
+}
+
+volatile unsigned int calTemp;
+void tiny_calibration_safe_add(int rawValue){
+ unsigned int addValue;
+ unsigned char subtract;
+ if(rawValue == 0){
+ return;
+ }
+ if(rawValue > 0){
+ addValue = (unsigned int) rawValue;
+ subtract = 0;
+ }
+ if(rawValue < 0){
+ rawValue = -rawValue;
+ addValue = rawValue;
+ subtract = 1;
+ }
+ calTemp = DFLLRC2M.CALB;
+ calTemp = calTemp << 7;
+ calTemp += DFLLRC2M.CALA;
+ asm("nop");
+ if(calTemp < addValue){
+ calTemp=0;
+ return;
+ }
+ if((calTemp + addValue) > 0x1fff){
+ calTemp = 0x1fff;
+ return;
+ }
+ if(subtract){
+ calTemp -= addValue;
+ }
+ else{
+ calTemp += addValue;
+ }
+ DFLLRC2M.CALA = calTemp & 0x7f;
+ //DFLLRC2M.CALB = calTemp >> 7;
+ }
+
+int tiny_distance_from_centre(unsigned int point){
+ int midVal = point-12000;
+ return midVal < 0 ? -midVal : midVal;
+}
+
+volatile unsigned char calibration_values_found = 0x00;
+volatile unsigned int last_val = 12000;
+volatile int gradient;
+volatile unsigned int calChange;
+#define NUM_INAROW 12
+volatile unsigned char inarow = NUM_INAROW;
+
+void tiny_calibration_find_values(){
+ unsigned int cnt = TC_CALI.CNT;
+ gradient = cnt - last_val;
+
+ //Find the negative value first.
+ if(calibration_values_found == 0x00){
+ if((gradient < -50) && (gradient > -150)){
+ if(inarow){
+ inarow--;
+ }else{
+ cali_value_negative_gradient = DFLLRC2M.CALA;
+ calibration_values_found = 0x01;
+ inarow = NUM_INAROW;
+ }
+ }
+ else{
+ inarow = NUM_INAROW;
+ calChange = gradient < -150 ? 1 : -1;
+ calChange -= gradient / 48;
+ tiny_calibration_safe_add(calChange);
+ }
+ }
+
+ //Search for the positive gradient
+ if(calibration_values_found == 0x01){
+ if(gradient > 50){
+ if(inarow){
+ inarow--;
+ } else{
+ cali_value_positive_gradient = DFLLRC2M.CALA;
+ calibration_values_found = 0x03;
+ }
+ }
+ else tiny_calibration_safe_add((gradient > 150 ? -1 : 1));
+ }
+ last_val = cnt;
+}
+
+#define LAYER2_INTERVAL 64
+#define MAXIMUM_DEVIATION 1
+volatile unsigned int layer2_counter = LAYER2_INTERVAL;
+void tiny_calibration_layer2(){
+ //Run only once every LAYER2_INTERVAL milliseconds.
+ if(layer2_counter){
+ layer2_counter--;
+ return;
+ }
+ layer2_counter = LAYER2_INTERVAL;
+
+ //Return if a median TRFCNT hasn't been set yet.
+ if(median_TRFCNT == 65535){
+ return;
+ }
+ unsigned int TRFCNT_temp = DMA.CH0.TRFCNT;
+ TRFCNT_temp = TRFCNT_temp % (global_mode > 5 ? PACKET_SIZE : HALFPACKET_SIZE);
+
+ if((TRFCNT_temp > median_TRFCNT) && (magnitude_difference(TRFCNT_temp, median_TRFCNT) > MAXIMUM_DEVIATION)){
+ TC_CALI.PERBUF = 24000;
+ return;
+ }
+ if((TRFCNT_temp < median_TRFCNT) && (magnitude_difference(TRFCNT_temp, median_TRFCNT) > MAXIMUM_DEVIATION)){
+ TC_CALI.PERBUF = 23999;
+ return;
+ }
+}
+
+unsigned int magnitude_difference(unsigned int a, unsigned int b){
+ if(a==b) return 0;
+ if(a>b) return a - b;
+ if(b>a) return b - a;
+}
+
+void tiny_calibration_synchronise_phase(unsigned int phase, unsigned int precision){
+ //Wait for the calibration timer to roughly equal a phase value, then return.
+ unsigned int maxVal = phase + precision;
+ unsigned int minVal = phase - precision;
+ while (!((TC_CALI.CNT < maxVal) && (TC_CALI.CNT > minVal)));
+ return;
+}
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_calibration.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_calibration.c.REMOVED.git-id
deleted file mode 100644
index 36a3188d..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_calibration.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a1ac1c4c9f3a360b441e163d1b4064484b587ee0
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_calibration.h b/AVR Code/USB_BULK_TEST/src/tiny_calibration.h
new file mode 100644
index 00000000..edd9e0f3
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_calibration.h
@@ -0,0 +1,32 @@
+/*
+ * tiny_calibration.h
+ *
+ * Created: 9/01/2017 4:21:09 PM
+ * Author: Esposch
+ */
+
+
+#ifndef TINY_CALIBRATION_H_
+#define TINY_CALIBRATION_H_
+
+#include
+#include
+
+void tiny_calibration_init();
+void tiny_calibration_first_sof();
+void tiny_calibration_maintain();
+void tiny_calibration_safe_add(int rawValue);
+int tiny_distance_from_centre(unsigned int point);
+void tiny_calibration_find_values();
+void tiny_calibration_layer2();
+unsigned int magnitude_difference(unsigned int a, unsigned int b);
+void tiny_calibration_synchronise_phase(unsigned int phase, unsigned int precision);
+
+extern volatile unsigned char calibration_values_found;
+extern volatile unsigned char median_TRFCNT_delay;
+
+volatile unsigned char cali_value_negative_gradient;
+volatile unsigned char cali_value_positive_gradient;
+
+
+#endif /* TINY_CALIBRATION_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_calibration.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_calibration.h.REMOVED.git-id
deleted file mode 100644
index ac5a7c18..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_calibration.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-edd9e0f3523c962a265a54b7abb1d5893c7cf047
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dac.c b/AVR Code/USB_BULK_TEST/src/tiny_dac.c
new file mode 100644
index 00000000..122a33c2
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_dac.c
@@ -0,0 +1,35 @@
+/*
+ * tiny_dac.c
+ *
+ * Created: 3/07/2015 1:06:44 PM
+ * Author: Esposch
+ */
+
+#include "tiny_dac.h"
+#include "tiny_adc.h"
+
+#include
+#include
+
+void tiny_dac_setup(void){
+
+ //Turn on in PR
+ PR.PRPB &=0b11111011;
+
+ DACB.CTRLA = DAC_CH1EN_bm | DAC_CH0EN_bm | DAC_ENABLE_bm;
+ DACB.CTRLB = DAC_CHSEL_DUAL_gc;
+ DACB.CTRLC = DAC_REFSEL_AVCC_gc | DAC_LEFTADJ_bm;
+ //EVCTRL unset
+ //DACB.CH0DATAH = 127;//contains (8-bit) sample, assuming left adjust!
+
+ //TODO: Calibrate
+ DACB.CH0GAINCAL = ReadCalibrationByte(offsetof(NVM_PROD_SIGNATURES_t, DACB0GAINCAL)); //Load calibration bytes from production row.
+ DACB.CH0OFFSETCAL = ReadCalibrationByte(offsetof(NVM_PROD_SIGNATURES_t, DACB0OFFCAL)); //Load calibration bytes from production row.
+
+ DACB.CH1GAINCAL = ReadCalibrationByte(offsetof(NVM_PROD_SIGNATURES_t, DACB1GAINCAL)); //Load calibration bytes from production row.
+ DACB.CH1OFFSETCAL = ReadCalibrationByte(offsetof(NVM_PROD_SIGNATURES_t, DACB1OFFCAL)); //Load calibration bytes from production row.
+
+ //Set up for triple mode!
+ PORTB.DIR |= 0x03;
+ PORTB.OUT = 0x00;
+}
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dac.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_dac.c.REMOVED.git-id
deleted file mode 100644
index dc5f4ee9..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_dac.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-122a33c20c7086677c72cafb4451a012afa752b6
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dac.h b/AVR Code/USB_BULK_TEST/src/tiny_dac.h
new file mode 100644
index 00000000..59894c9f
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_dac.h
@@ -0,0 +1,18 @@
+/*
+ * tiny_dac.h
+ *
+ * Created: 3/07/2015 1:06:53 PM
+ * Author: Esposch
+ */
+
+#include
+#include
+
+#ifndef TINY_DAC_H_
+#define TINY_DAC_H_
+
+void tiny_dac_setup(void);
+
+
+
+#endif /* TINY_DAC_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dac.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_dac.h.REMOVED.git-id
deleted file mode 100644
index c3b4ac45..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_dac.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-59894c9f7a76761b2d52d7d20c4d8bda6356d2f3
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dig.c b/AVR Code/USB_BULK_TEST/src/tiny_dig.c
new file mode 100644
index 00000000..8063205e
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_dig.c
@@ -0,0 +1,16 @@
+/*
+ * tiny_dig_out.c
+ *
+ * Created: 14/10/2015 4:51:19 PM
+ * Author: Esposch
+ */
+
+#include "tiny_dig.h"
+#include "globals.h"
+
+
+void tiny_dig_setup(void){
+ PORTE.DIR = 0x0f;
+ PORTE.OUT = 0x05;
+ return;
+}
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dig.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_dig.c.REMOVED.git-id
deleted file mode 100644
index 3f59bf87..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_dig.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8063205ed352dc6a6c9f1a29655c05325b1aef2b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dig.h b/AVR Code/USB_BULK_TEST/src/tiny_dig.h
new file mode 100644
index 00000000..57af7a9f
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_dig.h
@@ -0,0 +1,18 @@
+/*
+ * tiny_dig_out.h
+ *
+ * Created: 14/10/2015 4:51:29 PM
+ * Author: Esposch
+ */
+
+
+#ifndef TINY_DIG_OUT_H_
+#define TINY_DIG_OUT_H_
+
+#include
+
+void tiny_dig_setup(void);
+
+
+
+#endif /* TINY_DIG_OUT_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dig.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_dig.h.REMOVED.git-id
deleted file mode 100644
index 22be5126..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_dig.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-57af7a9f665ceda2796be1e346373374b2d9ba68
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dma.c b/AVR Code/USB_BULK_TEST/src/tiny_dma.c
new file mode 100644
index 00000000..50e1baf0
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_dma.c
@@ -0,0 +1,674 @@
+/*
+ * tiny_dma.c
+ *
+ * Created: 25/06/2015 9:00:42 AM
+ * Author: Esposch
+ */
+
+#include "tiny_dma.h"
+#include "tiny_adc.h"
+#include "tiny_uart.h"
+#include "tiny_calibration.h"
+#include "globals.h"
+#include "util/delay.h"
+
+#ifndef SINGLE_ENDPOINT_INTERFACE
+ #define DMA_STANDARD_INTERRUPT (0x00)
+ #define DMA_STANDARD_CTRLA (DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm)
+ #define DMA_STANDARD_TRANSFER_LENGTH (PACKET_SIZE)
+#else
+ #define DMA_STANDARD_INTERRUPT (0x03)
+ #define DMA_STANDARD_CTRLA (DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm)
+ #define DMA_STANDARD_TRANSFER_LENGTH (HALFPACKET_SIZE)
+#endif
+
+void tiny_dma_setup(void){
+ //Turn on DMA
+ PR.PRGEN &=0b111111110; //Turn on DMA clk
+ #ifndef SINGLE_ENDPOINT_INTERFACE
+ DMA.CTRL = DMA_ENABLE_bm | DMA_PRIMODE_CH0123_gc;
+ #else
+ DMA.CTRL = DMA_ENABLE_bm | DMA_PRIMODE_RR0123_gc;
+ #warning "Round Robin on DMA"
+ #endif
+
+}
+void tiny_dma_flush(void){
+ DMA.CH0.CTRLA = 0x00;
+ DMA.CH0.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH1.CTRLA = 0x00;
+ DMA.CH1.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH2.CTRLA = 0x00;
+ DMA.CH2.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH3.CTRLA = 0x00;
+ DMA.CH3.CTRLA = DMA_CH_RESET_bm;
+
+ b1_state = 0;
+ b2_state = 0;
+ usb_state = 0;
+
+ dma_ch0_ran = 0;
+ dma_ch1_ran = 0;
+}
+void tiny_dma_delayed_set(unsigned char mode){
+ futureMode = mode;
+ modeChanged = 1;
+}
+void tiny_dma_set_mode_0(void){
+
+ global_mode = 0;
+
+ tiny_dma_flush();
+
+ DMA.CH2.REPCNT = 0; //Repeat forever!
+ DMA.CH2.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH2.CTRLB = 0x00; //No interrupt for DacBuf!!
+ DMA.CH2.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH2.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH1_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH2.TRFCNT = auxDacBufLen;
+
+ DMA.CH2.SRCADDR0 = (( (uint16_t) &dacBuf_CH2[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH2.SRCADDR1 = (( (uint16_t) &dacBuf_CH2[0]) >> 8) & 0xFF;
+ DMA.CH2.SRCADDR2 = 0x00;
+
+ DMA.CH2.DESTADDR0 = (( (uint16_t) &DACB.CH1DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH2.DESTADDR1 = (( (uint16_t) &DACB.CH1DATAH) >> 8) & 0xFF;
+ DMA.CH2.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH2.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH3.REPCNT = 0; //Repeat forever!
+ DMA.CH3.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH3.CTRLB = 0x00; //Hi interrupt on block complete
+ DMA.CH3.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH3.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH2_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH3.TRFCNT = dacBuf_len;
+
+ DMA.CH3.SRCADDR0 = (( (uint16_t) &dacBuf_CH1[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH3.SRCADDR1 = (( (uint16_t) &dacBuf_CH1[0]) >> 8) & 0xFF;
+ DMA.CH3.SRCADDR2 = 0x00;
+
+ DMA.CH3.DESTADDR0 = (( (uint16_t) &DACB.CH0DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH3.DESTADDR1 = (( (uint16_t) &DACB.CH0DATAH) >> 8) & 0xFF;
+ DMA.CH3.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH3.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH0.CTRLA = 0x00;
+ DMA.CH0.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH0.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH0.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc; //Triggered from ADCA channel 0
+ DMA.CH0.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH0.SRCADDR0 = (( (uint16_t) &ADCA.CH0.RESL) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH0.SRCADDR1 = (( (uint16_t) &ADCA.CH0.RESL) >> 8) & 0xFF;
+ DMA.CH0.SRCADDR2 = 0x00;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[0]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[0]) >> 8) & 0xFF;
+ DMA.CH0.DESTADDR2 = 0x00;
+
+ tiny_calibration_synchronise_phase(500, 200);
+ median_TRFCNT = 200;
+ median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+}
+
+void tiny_dma_loop_mode_0(void){
+ return;
+}
+
+void tiny_dma_set_mode_1(void){
+ global_mode = 1;
+
+ tiny_dma_flush();
+
+ //AUX channel (to keep it tx, therefore always rx)
+ DMA.CH2.CTRLA = 0x00;
+ DMA.CH2.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH2.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm; //Do not repeat!
+ DMA.CH2.CTRLB = 0x00; //No int
+ DMA.CH2.ADDRCTRL = DMA_CH_SRCDIR_FIXED_gc | DMA_CH_DESTDIR_FIXED_gc; //Source and address fixed.
+ DMA.CH2.TRIGSRC = DMA_CH_TRIGSRC_USARTC0_RXC_gc;
+ DMA.CH2.TRFCNT = 0;
+ DMA.CH2.REPCNT = 0;
+
+ DMA.CH2.SRCADDR0 = (( (uint16_t) &dummy) >> 0) & 0xFF;
+ DMA.CH2.SRCADDR1 = (( (uint16_t) &dummy) >> 8) & 0xFF;
+ DMA.CH2.SRCADDR2 = 0x00;
+
+ DMA.CH2.DESTADDR0 = (( (uint16_t) &USARTC0.DATA) >> 0) & 0xFF;
+ DMA.CH2.DESTADDR1 = (( (uint16_t) &USARTC0.DATA) >> 8) & 0xFF;
+ DMA.CH2.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH2.CTRLA |= DMA_CH_REPEAT_bm | DMA_CH_ENABLE_bm; //Enable!
+
+ USARTC0.DATA = 0x55;
+ USARTC0.DATA = 0x55;
+
+ DMA.CH3.REPCNT = 0; //Repeat forever!
+ DMA.CH3.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH3.CTRLB = 0x00; //No interrupt for DacBuf!!
+ DMA.CH3.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH3.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH1_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH3.TRFCNT = auxDacBufLen;
+
+ DMA.CH3.SRCADDR0 = (( (uint16_t) &dacBuf_CH2[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH3.SRCADDR1 = (( (uint16_t) &dacBuf_CH2[0]) >> 8) & 0xFF;
+ DMA.CH3.SRCADDR2 = 0x00;
+
+ DMA.CH3.DESTADDR0 = (( (uint16_t) &DACB.CH1DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH3.DESTADDR1 = (( (uint16_t) &DACB.CH1DATAH) >> 8) & 0xFF;
+ DMA.CH3.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH3.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH1.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH1.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH1.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH1.TRIGSRC = DMA_CH_TRIGSRC_USARTC0_RXC_gc;
+ DMA.CH1.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH1.SRCADDR0 = (( (uint16_t) &USARTC0.DATA) >> 0) & 0xFF;
+ DMA.CH1.SRCADDR1 = (( (uint16_t) &USARTC0.DATA) >> 8) & 0xFF;
+ DMA.CH1.SRCADDR2 = 0x00;
+
+ DMA.CH1.DESTADDR0 = (( (uint16_t) &isoBuf[PACKET_SIZE]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH1.DESTADDR1 = (( (uint16_t) &isoBuf[PACKET_SIZE]) >> 8) & 0xFF;
+ DMA.CH1.DESTADDR2 = 0x00;
+
+ DMA.CH0.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH0.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc; //Triggered from ADCA channel 0
+ DMA.CH0.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH0.SRCADDR0 = (( (uint16_t) &ADCA.CH0.RESL) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH0.SRCADDR1 = (( (uint16_t) &ADCA.CH0.RESL) >> 8) & 0xFF;
+ DMA.CH0.SRCADDR2 = 0x00;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[0]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[0]) >> 8) & 0xFF;
+ DMA.CH0.DESTADDR2 = 0x00;
+
+ tiny_calibration_synchronise_phase(500, 200);
+ median_TRFCNT = 200;
+ median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
+ DMA.CH1.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+}
+
+void tiny_dma_loop_mode_1(void){
+ return;
+}
+
+void tiny_dma_set_mode_2(void){
+
+ global_mode = 2;
+
+ tiny_dma_flush();
+
+ DMA.CH2.REPCNT = 0; //Repeat forever!
+ DMA.CH2.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH2.CTRLB = 0x00; //No interrupt for DacBuf!!
+ DMA.CH2.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH2.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH1_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH2.TRFCNT = auxDacBufLen;
+
+ DMA.CH2.SRCADDR0 = (( (uint16_t) &dacBuf_CH2[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH2.SRCADDR1 = (( (uint16_t) &dacBuf_CH2[0]) >> 8) & 0xFF;
+ DMA.CH2.SRCADDR2 = 0x00;
+
+ DMA.CH2.DESTADDR0 = (( (uint16_t) &DACB.CH1DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH2.DESTADDR1 = (( (uint16_t) &DACB.CH1DATAH) >> 8) & 0xFF;
+ DMA.CH2.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH2.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH3.REPCNT = 0; //Repeat forever!
+ DMA.CH3.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH3.CTRLB = 0x00; //Hi interrupt on block complete
+ DMA.CH3.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH3.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH2_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH3.TRFCNT = dacBuf_len;
+
+ DMA.CH3.SRCADDR0 = (( (uint16_t) &dacBuf_CH1[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH3.SRCADDR1 = (( (uint16_t) &dacBuf_CH1[0]) >> 8) & 0xFF;
+ DMA.CH3.SRCADDR2 = 0x00;
+
+ DMA.CH3.DESTADDR0 = (( (uint16_t) &DACB.CH0DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH3.DESTADDR1 = (( (uint16_t) &DACB.CH0DATAH) >> 8) & 0xFF;
+ DMA.CH3.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH3.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH0.CTRLA = 0x00;
+ DMA.CH0.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH0.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH0.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc; //Triggered from ADCA channel 0
+ DMA.CH0.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH0.SRCADDR0 = (( (uint16_t) &ADCA.CH0.RESL) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH0.SRCADDR1 = (( (uint16_t) &ADCA.CH0.RESL) >> 8) & 0xFF;
+ DMA.CH0.SRCADDR2 = 0x00;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[0]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[0]) >> 8) & 0xFF;
+ DMA.CH0.DESTADDR2 = 0x00;
+
+
+ DMA.CH1.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH1.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH1.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH1.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc; //Triggered from ADCA channel 0
+ DMA.CH1.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH1.SRCADDR0 = (( (uint16_t) &ADCA.CH2.RESL) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH1.SRCADDR1 = (( (uint16_t) &ADCA.CH2.RESL) >> 8) & 0xFF;
+ DMA.CH1.SRCADDR2 = 0x00;
+
+ DMA.CH1.DESTADDR0 = (( (uint16_t) &isoBuf[PACKET_SIZE]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH1.DESTADDR1 = (( (uint16_t) &isoBuf[PACKET_SIZE]) >> 8) & 0xFF;
+ DMA.CH1.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+
+ tiny_calibration_synchronise_phase(500, 200);
+ median_TRFCNT = 200;
+ median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+ DMA.CH1.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+}
+
+void tiny_dma_loop_mode_2(void){
+ return;
+}
+
+
+
+void tiny_dma_set_mode_3(void){
+ global_mode = 3;
+ tiny_dma_flush();
+
+ DMA.CH3.REPCNT = 0; //Repeat forever!
+ DMA.CH3.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH3.CTRLB = 0x00; //No interrupt for DacBuf!!
+ DMA.CH3.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH3.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH1_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH3.TRFCNT = auxDacBufLen;
+
+ DMA.CH3.SRCADDR0 = (( (uint16_t) &dacBuf_CH2[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH3.SRCADDR1 = (( (uint16_t) &dacBuf_CH2[0]) >> 8) & 0xFF;
+ DMA.CH3.SRCADDR2 = 0x00;
+
+ DMA.CH3.DESTADDR0 = (( (uint16_t) &DACB.CH1DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH3.DESTADDR1 = (( (uint16_t) &DACB.CH1DATAH) >> 8) & 0xFF;
+ DMA.CH3.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH3.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH2.REPCNT = 0; //Repeat forever!
+ DMA.CH2.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH2.CTRLB = 0x00; //Hi interrupt on block complete
+ DMA.CH2.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH2.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH2_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH2.TRFCNT = dacBuf_len;
+
+ DMA.CH2.SRCADDR0 = (( (uint16_t) &dacBuf_CH1[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH2.SRCADDR1 = (( (uint16_t) &dacBuf_CH1[0]) >> 8) & 0xFF;
+ DMA.CH2.SRCADDR2 = 0x00;
+
+ DMA.CH2.DESTADDR0 = (( (uint16_t) &DACB.CH0DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH2.DESTADDR1 = (( (uint16_t) &DACB.CH0DATAH) >> 8) & 0xFF;
+ DMA.CH2.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH2.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+
+ //AUX channel (to keep it tx, therefore always rx)
+ DMA.CH1.CTRLA = 0x00;
+ DMA.CH1.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH1.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm; //Do not repeat!
+ DMA.CH1.CTRLB = 0x00; //No int
+ DMA.CH1.ADDRCTRL = DMA_CH_SRCDIR_FIXED_gc | DMA_CH_DESTDIR_FIXED_gc; //Source and address fixed.
+ DMA.CH1.TRIGSRC = DMA_CH_TRIGSRC_USARTC0_RXC_gc;
+ DMA.CH1.TRFCNT = 0;
+ DMA.CH1.REPCNT = 0;
+
+ DMA.CH1.SRCADDR0 = (( (uint16_t) &dummy) >> 0) & 0xFF;
+ DMA.CH1.SRCADDR1 = (( (uint16_t) &dummy) >> 8) & 0xFF;
+ DMA.CH1.SRCADDR2 = 0x00;
+
+ DMA.CH1.DESTADDR0 = (( (uint16_t) &USARTC0.DATA) >> 0) & 0xFF;
+ DMA.CH1.DESTADDR1 = (( (uint16_t) &USARTC0.DATA) >> 8) & 0xFF;
+ DMA.CH1.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH1.CTRLA |= DMA_CH_REPEAT_bm | DMA_CH_ENABLE_bm; //Enable!
+
+ USARTC0.DATA = 0x55;
+
+ //Actual data being transferred
+ DMA.CH0.CTRLA = 0x00;
+ DMA.CH0.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH0.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH0.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_USARTC0_RXC_gc;
+ DMA.CH0.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH0.SRCADDR0 = (( (uint16_t) &USARTC0.DATA) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH0.SRCADDR1 = (( (uint16_t) &USARTC0.DATA) >> 8) & 0xFF;
+ DMA.CH0.SRCADDR2 = 0x00;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[0]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[0]) >> 8) & 0xFF;
+ DMA.CH0.DESTADDR2 = 0x00;
+
+ tiny_calibration_synchronise_phase(500, 200);
+ median_TRFCNT = 200;
+ median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+}
+
+void tiny_dma_loop_mode_3(void){
+ return;
+}
+
+void tiny_dma_set_mode_4(void){
+
+ global_mode = 4;
+
+ tiny_dma_flush();
+
+ //AUX channel (to keep it tx, therefore always rx)
+ DMA.CH2.CTRLA = 0x00;
+ DMA.CH2.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH2.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm; //Do not repeat!
+ DMA.CH2.CTRLB = 0x00; //No int
+ DMA.CH2.ADDRCTRL = DMA_CH_SRCDIR_FIXED_gc | DMA_CH_DESTDIR_FIXED_gc; //Source and address fixed.
+ DMA.CH2.TRIGSRC = DMA_CH_TRIGSRC_USARTC0_RXC_gc;
+ DMA.CH2.TRFCNT = 0;
+ DMA.CH2.REPCNT = 0;
+
+ DMA.CH2.SRCADDR0 = (( (uint16_t) &dummy) >> 0) & 0xFF;
+ DMA.CH2.SRCADDR1 = (( (uint16_t) &dummy) >> 8) & 0xFF;
+ DMA.CH2.SRCADDR2 = 0x00;
+
+ DMA.CH2.DESTADDR0 = (( (uint16_t) &USARTC0.DATA) >> 0) & 0xFF;
+ DMA.CH2.DESTADDR1 = (( (uint16_t) &USARTC0.DATA) >> 8) & 0xFF;
+ DMA.CH2.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH2.CTRLA |= DMA_CH_REPEAT_bm | DMA_CH_ENABLE_bm; //Enable!
+
+ USARTC0.DATA = 0x55;
+
+ DMA.CH3.REPCNT = 0; //Repeat forever!
+ DMA.CH3.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH3.CTRLB = 0x00; //No interrupt for DacBuf!!
+ DMA.CH3.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH3.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH1_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH3.TRFCNT = auxDacBufLen;
+
+ DMA.CH3.SRCADDR0 = (( (uint16_t) &dacBuf_CH2[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH3.SRCADDR1 = (( (uint16_t) &dacBuf_CH2[0]) >> 8) & 0xFF;
+ DMA.CH3.SRCADDR2 = 0x00;
+
+ DMA.CH3.DESTADDR0 = (( (uint16_t) &DACB.CH1DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH3.DESTADDR1 = (( (uint16_t) &DACB.CH1DATAH) >> 8) & 0xFF;
+ DMA.CH3.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH3.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ //Actual data being transferred
+ DMA.CH0.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH0.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_USARTC0_RXC_gc;
+ DMA.CH0.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH0.SRCADDR0 = (( (uint16_t) &USARTC0.DATA) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH0.SRCADDR1 = (( (uint16_t) &USARTC0.DATA) >> 8) & 0xFF;
+ DMA.CH0.SRCADDR2 = 0x00;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[0]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[0]) >> 8) & 0xFF;
+ DMA.CH0.DESTADDR2 = 0x00;
+
+
+ DMA.CH1.CTRLA = DMA_STANDARD_CTRLA;
+ DMA.CH1.CTRLB = DMA_STANDARD_INTERRUPT;
+ DMA.CH1.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH1.TRIGSRC = DMA_CH_TRIGSRC_SPIC_gc;
+ DMA.CH1.TRFCNT = DMA_STANDARD_TRANSFER_LENGTH;
+
+ DMA.CH1.SRCADDR0 = (( (uint16_t) &SPIC.DATA) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH1.SRCADDR1 = (( (uint16_t) &SPIC.DATA) >> 8) & 0xFF;
+ DMA.CH1.SRCADDR2 = 0x00;
+
+ DMA.CH1.DESTADDR0 = (( (uint16_t) &isoBuf[PACKET_SIZE]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH1.DESTADDR1 = (( (uint16_t) &isoBuf[PACKET_SIZE]) >> 8) & 0xFF;
+ DMA.CH1.DESTADDR2 = 0x00;
+
+ tiny_calibration_synchronise_phase(500, 200);
+ median_TRFCNT = 200;
+ median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+ DMA.CH1.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+}
+
+void tiny_dma_loop_mode_4(void){
+return;
+}
+
+
+void tiny_dma_set_mode_5(void){
+ while(1); //Deliberate Crash! Mode 5 should be invalid.
+}
+
+void tiny_dma_set_mode_6(void){
+
+ global_mode = 6;
+
+ tiny_dma_flush();
+
+ DMA.CH2.REPCNT = 0; //Repeat forever!
+ DMA.CH2.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH2.CTRLB = 0x00; //Hi interrupt on block complete
+ DMA.CH2.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH2.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH2_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH2.TRFCNT = dacBuf_len;
+
+ DMA.CH2.SRCADDR0 = (( (uint16_t) &dacBuf_CH1[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH2.SRCADDR1 = (( (uint16_t) &dacBuf_CH1[0]) >> 8) & 0xFF;
+ DMA.CH2.SRCADDR2 = 0x00;
+
+ DMA.CH2.DESTADDR0 = (( (uint16_t) &DACB.CH0DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH2.DESTADDR1 = (( (uint16_t) &DACB.CH0DATAH) >> 8) & 0xFF;
+ DMA.CH2.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH2.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH3.REPCNT = 0; //Repeat forever!
+ DMA.CH3.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH3.CTRLB = 0x00; //No interrupt for DacBuf!!
+ DMA.CH3.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH3.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH1_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH3.TRFCNT = auxDacBufLen;
+
+ DMA.CH3.SRCADDR0 = (( (uint16_t) &dacBuf_CH2[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH3.SRCADDR1 = (( (uint16_t) &dacBuf_CH2[0]) >> 8) & 0xFF;
+ DMA.CH3.SRCADDR2 = 0x00;
+
+ DMA.CH3.DESTADDR0 = (( (uint16_t) &DACB.CH1DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH3.DESTADDR1 = (( (uint16_t) &DACB.CH1DATAH) >> 8) & 0xFF;
+ DMA.CH3.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH3.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH0.CTRLA = 0x00;
+ DMA.CH0.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH0.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH0.CTRLB = 0x00; //No interrupt!
+ DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc; //Triggered from ADCA channel 0
+ DMA.CH0.TRFCNT = BUFFER_SIZE;
+
+ DMA.CH0.SRCADDR0 = (( (uint16_t) &ADCA.CH0.RESL) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH0.SRCADDR1 = (( (uint16_t) &ADCA.CH0.RESL) >> 8) & 0xFF;
+ DMA.CH0.SRCADDR2 = 0x00;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[0]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[0]) >> 8) & 0xFF;
+ DMA.CH0.DESTADDR2 = 0x00;
+
+ tiny_calibration_synchronise_phase(500, 200);
+ median_TRFCNT = 400;
+ median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+
+}
+
+void tiny_dma_loop_mode_6(void){
+ return;
+}
+
+void tiny_dma_set_mode_7(void){
+
+ global_mode = 7;
+
+ tiny_dma_flush();
+
+ DMA.CH2.REPCNT = 0; //Repeat forever!
+ DMA.CH2.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH2.CTRLB = 0x00; //Hi interrupt on block complete
+ DMA.CH2.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH2.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH2_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH2.TRFCNT = dacBuf_len;
+
+ DMA.CH2.SRCADDR0 = (( (uint16_t) &dacBuf_CH1[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH2.SRCADDR1 = (( (uint16_t) &dacBuf_CH1[0]) >> 8) & 0xFF;
+ DMA.CH2.SRCADDR2 = 0x00;
+
+ DMA.CH2.DESTADDR0 = (( (uint16_t) &DACB.CH0DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH2.DESTADDR1 = (( (uint16_t) &DACB.CH0DATAH) >> 8) & 0xFF;
+ DMA.CH2.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH2.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH3.REPCNT = 0; //Repeat forever!
+ DMA.CH3.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm;
+ DMA.CH3.CTRLB = 0x00; //No interrupt for DacBuf!!
+ DMA.CH3.ADDRCTRL = DMA_CH_DESTRELOAD_BURST_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_SRCRELOAD_BLOCK_gc | DMA_CH_SRCDIR_INC_gc; //Dest reloads after each burst, with byte incrementing. Src reloads at end of block, also incrementing address.
+ DMA.CH3.TRIGSRC = DMA_CH_TRIGSRC_EVSYS_CH1_gc; //Triggered from TCC0 when it hits PER
+ DMA.CH3.TRFCNT = auxDacBufLen;
+
+ DMA.CH3.SRCADDR0 = (( (uint16_t) &dacBuf_CH2[0]) >> 0) & 0xFF; //Source address is dacbuf
+ DMA.CH3.SRCADDR1 = (( (uint16_t) &dacBuf_CH2[0]) >> 8) & 0xFF;
+ DMA.CH3.SRCADDR2 = 0x00;
+
+ DMA.CH3.DESTADDR0 = (( (uint16_t) &DACB.CH1DATAH) >> 0) & 0xFF; //Dest address is high byte of DAC register
+ DMA.CH3.DESTADDR1 = (( (uint16_t) &DACB.CH1DATAH) >> 8) & 0xFF;
+ DMA.CH3.DESTADDR2 = 0x00;
+
+ //Must enable last for REPCNT won't work!
+ DMA.CH3.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+ DMA.CH0.CTRLA = 0x00;
+ DMA.CH0.CTRLA = DMA_CH_RESET_bm;
+
+ DMA.CH0.CTRLA = DMA_CH_BURSTLEN_2BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm; //Do not repeat!
+ DMA.CH0.CTRLB = 0x00; //No interrupt!
+ DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | DMA_CH_DESTDIR_INC_gc | DMA_CH_DESTRELOAD_BLOCK_gc; //Source reloads after each burst, with byte incrementing. Dest does not reload, but does increment address.
+ DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc; //Triggered from ADCA channel 0
+ DMA.CH0.TRFCNT = BUFFER_SIZE;
+
+ DMA.CH0.SRCADDR0 = (( (uint16_t) &ADCA.CH0.RESL) >> 0) & 0xFF; //Source address is ADC
+ DMA.CH0.SRCADDR1 = (( (uint16_t) &ADCA.CH0.RESL) >> 8) & 0xFF;
+ DMA.CH0.SRCADDR2 = 0x00;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[0]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[0]) >> 8) & 0xFF;
+ DMA.CH0.DESTADDR2 = 0x00;
+
+ tiny_calibration_synchronise_phase(500, 200);
+ median_TRFCNT = 400;
+ median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
+
+}
+
+void tiny_dma_loop_mode_7(void){
+}
+
+ISR(DMA_CH0_vect){
+ DMA.INTFLAGS = 0x01;
+ //dma_ch0_ran++;
+ //uds.dma_ch0_cntL = dma_ch0_ran & 0xff;
+ //uds.dma_ch0_cntH = (dma_ch0_ran >> 8) & 0xff;
+
+ #ifdef SINGLE_ENDPOINT_INTERFACE
+ DMA.CH0.CTRLA = 0x00;
+ DMA.CH0.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm; //Do not repeat!
+ DMA.CH0.TRFCNT = HALFPACKET_SIZE;
+
+ short ptr = usb_state ? 0 : PACKET_SIZE;
+
+ DMA.CH0.DESTADDR0 = (( (uint16_t) &isoBuf[ptr]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH0.DESTADDR1 = (( (uint16_t) &isoBuf[ptr]) >> 8) & 0xFF;
+
+ DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm;
+ #endif
+}
+
+ISR(DMA_CH1_vect){
+ DMA.INTFLAGS = 0x02;
+ //dma_ch1_ran++;
+ //uds.dma_ch1_cntL = dma_ch1_ran & 0xff;
+ //uds.dma_ch1_cntH = (dma_ch1_ran >> 8) & 0xff;
+
+#ifdef SINGLE_ENDPOINT_INTERFACE
+ DMA.CH1.CTRLA = 0x00;
+ DMA.CH1.CTRLA = DMA_CH_BURSTLEN_1BYTE_gc | DMA_CH_SINGLE_bm; //Do not repeat!
+ DMA.CH1.TRFCNT = HALFPACKET_SIZE;
+
+ short ptr = usb_state ? HALFPACKET_SIZE : PACKET_SIZE + HALFPACKET_SIZE;
+
+ DMA.CH1.DESTADDR0 = (( (uint16_t) &isoBuf[ptr]) >> 0) & 0xFF; //Dest address is isoBuf
+ DMA.CH1.DESTADDR1 = (( (uint16_t) &isoBuf[ptr]) >> 8) & 0xFF;
+
+ DMA.CH1.CTRLA |= DMA_CH_ENABLE_bm;
+ #endif
+}
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dma.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_dma.c.REMOVED.git-id
deleted file mode 100644
index 95849edc..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_dma.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-50e1baf0e521d270b1e897f86c32924d1deb9f60
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dma.h b/AVR Code/USB_BULK_TEST/src/tiny_dma.h
new file mode 100644
index 00000000..a0f8885b
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_dma.h
@@ -0,0 +1,45 @@
+/*
+ * tiny_dma.h
+ *
+ * Created: 25/06/2015 9:01:15 AM
+ * Author: Esposch
+ */
+
+
+#ifndef TINY_DMA_H_
+#define TINY_DMA_H_
+
+#include
+#include
+#include "globals.h"
+
+void tiny_dma_setup(void);
+void tiny_dma_flush(void);
+
+void tiny_dma_set_mode_0(void);
+void tiny_dma_loop_mode_0(void);
+
+void tiny_dma_set_mode_1(void);
+void tiny_dma_loop_mode_1(void);
+
+void tiny_dma_set_mode_2(void);
+void tiny_dma_loop_mode_2(void);
+
+void tiny_dma_set_mode_3(void);
+void tiny_dma_loop_mode_3(void);
+
+void tiny_dma_set_mode_4(void);
+void tiny_dma_loop_mode_4(void);
+
+void tiny_dma_set_mode_5(void);
+
+void tiny_dma_set_mode_6(void);
+void tiny_dma_loop_mode_6(void);
+
+void tiny_dma_set_mode_7(void);
+void tiny_dma_loop_mode_7(void);
+
+void tiny_dma_delayed_set(unsigned char mode);
+
+
+#endif /* TINY_DMA_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_dma.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_dma.h.REMOVED.git-id
deleted file mode 100644
index 73ec9a55..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_dma.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a0f8885b223d04a6b4d9cef5a8fe0b1226e34e8d
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_eeprom.c b/AVR Code/USB_BULK_TEST/src/tiny_eeprom.c
new file mode 100644
index 00000000..0d909f8f
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_eeprom.c
@@ -0,0 +1,25 @@
+/*
+ * tiny_eeprom.c
+ *
+ * Created: 22/04/2017 12:37:21 PM
+ * Author: Esposch
+ */
+#include
+#include "tiny_eeprom.h"
+
+void eeprom_safe_read(){
+ unsigned char previous_clk_settings = CLK.PSCTRL;
+ CLK.PSCTRL = CLK_PSADIV4_bm; //Slow down the clock to prevent EEPROM misses
+ nvm_eeprom_read_buffer(EEPROM_CURRENT_PAGE*EEPROM_PAGE_SIZE, eeprom_buffer_read, EEPROM_PAGE_SIZE);
+ CLK.PSCTRL = previous_clk_settings;
+ return;
+}
+
+void eeprom_safe_write(){
+ unsigned char previous_clk_settings = CLK.PSCTRL;
+ CLK.PSCTRL = CLK_PSADIV4_bm; //Slow down the clock to prevent EEPROM misses
+ nvm_eeprom_load_page_to_buffer(eeprom_buffer_write);
+ nvm_eeprom_atomic_write_page(EEPROM_CURRENT_PAGE);
+ CLK.PSCTRL = previous_clk_settings;
+ return;
+}
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_eeprom.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_eeprom.c.REMOVED.git-id
deleted file mode 100644
index 79f29699..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_eeprom.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0d909f8fdcd02d8cd8c9a24ddab57ac01ff9af46
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_eeprom.h b/AVR Code/USB_BULK_TEST/src/tiny_eeprom.h
new file mode 100644
index 00000000..013c633c
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_eeprom.h
@@ -0,0 +1,20 @@
+/*
+ * tiny_eeprom.h
+ *
+ * Created: 22/04/2017 12:37:34 PM
+ * Author: Esposch
+ */
+
+
+#ifndef TINY_EEPROM_H_
+#define TINY_EEPROM_H_
+
+#define EEPROM_CURRENT_PAGE 1
+
+void eeprom_safe_read();
+void eeprom_safe_write();
+extern volatile unsigned char eeprom_buffer_write[EEPROM_PAGE_SIZE];
+extern volatile unsigned char eeprom_buffer_read[EEPROM_PAGE_SIZE];
+
+
+#endif /* TINY_EEPROM_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_eeprom.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_eeprom.h.REMOVED.git-id
deleted file mode 100644
index 3e527679..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_eeprom.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-013c633cbe8894ab8d5cab1e70d618f077048e21
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_timer.c b/AVR Code/USB_BULK_TEST/src/tiny_timer.c
new file mode 100644
index 00000000..95c8a9df
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_timer.c
@@ -0,0 +1,80 @@
+/*
+ * tiny_timercounter.c
+ *
+ * Created: 2/07/2015 10:50:11 AM
+ * Author: Esposch
+ */
+
+#include "tiny_timer.h"
+#include "globals.h"
+
+#define PSU_PER 2048
+#define jump 6
+
+void tiny_timer_setup(void){
+ //Turn everything on!
+ PR.PRPC &= 0b11111100; //Enable TCC0, TCC1
+ PR.PRPD &= 0b11111100; //Enable TCD0, TCD1
+ PR.PRGEN &= 0b11111101; //Enable EVSYS
+
+ //Set up EVSYS
+ EVSYS.CH2MUX = TCDAC_OVF;
+ EVSYS.CH2CTRL = 0x00; //No filtering or Quadrature stuff
+
+ EVSYS.CH1MUX = TCDAC_AUX_OVF;
+ EVSYS.CH1CTRL = 0x00; //No filtering or Quadrature stuff
+
+ //Waveform (50Hz sin wave)
+ TC_DAC.CTRLA = 0x04; //Some clk setting - not 100% sure since it was SW generated
+ TC_DAC.CTRLB = TC_WGMODE_SINGLESLOPE_gc; //No enable is set
+ TC_DAC.CTRLE = TC_BYTEM_NORMAL_gc;
+ TC_DAC.PER = 469;
+ TC_DAC.INTCTRLA = 0x00;
+ //Aux channel (blank 50Hz)
+ TC_AUXDAC.CTRLA = 0x04; //Some clk setting - not 100% sure since it was SW generated
+ TC_AUXDAC.CTRLB = TC_WGMODE_SINGLESLOPE_gc; //No enable is set
+ TC_AUXDAC.CTRLE = TC_BYTEM_NORMAL_gc;
+ TC_AUXDAC.PER = 469;
+ TC_AUXDAC.INTCTRLA = 0x00;
+
+ //PSU
+ PORTD.DIR |= 0b00010000;
+ TC_PSU.CTRLB = 0x10 | TC_WGMODE_SINGLESLOPE_gc; //CCAEN is set
+ TC_PSU.CTRLE = TC_BYTEM_NORMAL_gc;
+ TC_PSU.INTCTRLA = TC_OVFINTLVL_MED_gc;
+ TC_PSU.PER = PSU_PER; // Max value of CNT
+ TC_PSU.CCA = 0; //Initial Duty cycle of 0%
+ TC_PSU.CTRLA = TC_CLKSEL_DIV1_gc;
+ /*
+ //PSU "PID"loop
+ TCC1.CTRLB = 0x00 | TC_WGMODE_SINGLESLOPE_gc;
+ TCC1.INTCTRLA = TC_OVFINTLVL_LO_gc;
+ TCC1.CTRLE = TC_BYTEM_NORMAL_gc;
+ TCC1.PER = 1800; // Max value of CNT
+ TCC1.CTRLA = TC_CLKSEL_DIV1_gc;
+ */
+}
+
+ISR(TC_PSU_OVF){
+ char tempvar;
+ char err;
+ volatile char nothing;
+ TC_PSU.INTFLAGS = 0xff;
+ if (global_mode == 7){
+ nothing = ADCA.CH1.RESL;
+ tempvar = ADCA.CH1.RESH;
+ }
+ else{
+ tempvar = ADCA.CH1.RESL;
+ }
+ //tempvar = (global_mode == 7 ? (char) ADCA.CH1.RESH : (char) ADCA.CH1.RESL);
+ //test_byte = tempvar;
+
+ err = (char) (PSU_target - tempvar);
+ if ((err > 1) & ((unsigned short) TC_PSU.CCA < PSU_PER - jump) ){
+ TC_PSU.CCABUF = TC_PSU.CCA + ((err > 8) ? jump : 1);
+ }
+ else if ((err < -1) & ((unsigned short) TC_PSU.CCA > jump)){
+ TC_PSU.CCABUF = TC_PSU.CCA - ((err < -8) ? jump : 1);
+ }
+}
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_timer.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_timer.c.REMOVED.git-id
deleted file mode 100644
index 6589a994..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_timer.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-95c8a9df507735073bcbdc1688858b9a52c38def
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_timer.h b/AVR Code/USB_BULK_TEST/src/tiny_timer.h
new file mode 100644
index 00000000..ed5a0ab5
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_timer.h
@@ -0,0 +1,19 @@
+/*
+ * tiny_timercounter.h
+ *
+ * Created: 2/07/2015 10:49:59 AM
+ * Author: Esposch
+ */
+
+#include
+#include
+
+#ifndef TINY_TIMER_H_
+#define TINY_TIMER_H_
+
+void tiny_timer_setup(void);
+void tiny_spi_setup(void);
+
+
+
+#endif /* TINY_TIMERCOUNTER_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_timer.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_timer.h.REMOVED.git-id
deleted file mode 100644
index bcbc4ad9..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_timer.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ed5a0ab56eb78ad59979793688a6bdc872248b18
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_uart.c b/AVR Code/USB_BULK_TEST/src/tiny_uart.c
new file mode 100644
index 00000000..a30ce551
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_uart.c
@@ -0,0 +1,59 @@
+/*
+ * tiny_uart.c
+ *
+ * Created: 16/07/2015 6:32:52 PM
+ * Author: Esposch
+ */
+
+#include "tiny_uart.h"
+#include "globals.h"
+
+
+void tiny_uart_setup(void){
+ PR.PRPC &= 0b11101111;
+ //PR.PRPE &= 0b11111110; ???
+
+ PORTC.DIR |= 0b10101010;
+ PORTC.OUT = 0xff;
+ PORTC.PIN2CTRL = PORT_INVEN_bm | PORT_OPC_PULLUP_gc;
+ //PORTC.REMAP = 0x10; //Remap USART to [7:4]
+ //#ifndef VERO
+// PORTC.REMAP = 0x20; //Swap MOSI and SCK - for small boards only!!!
+ //#endif
+
+ USARTC0.CTRLA = USART_RXCINTLVL_HI_gc;
+ USARTC0.CTRLC = USART_CMODE_MSPI_gc | 0b00000100; //LSB received first, UPCHA disabled
+ #if OVERCLOCK == 48
+ USARTC0.BAUDCTRLA = 7; //BSEL = fper/(2fbaud) -1; 48/(2*3) - 1 = 7
+ #else
+ USARTC0.BAUDCTRLA = 3; //BSEL = fper/(2fbaud) -1; 24/(2*3) - 1 = 3
+ #endif
+ USARTC0.BAUDCTRLB = 0x00;// USART_BSCALE0_bm goes to 1.5MHz for some reason;
+ USARTC0.CTRLB = USART_RXEN_bm | USART_TXEN_bm;
+}
+
+
+void tiny_spi_setup(void){
+ //Power Reduction disable
+ PR.PRPC &= 0b11110111;
+
+ //SPI enable
+ SPIC.CTRL = SPI_ENABLE_bm; //Slave mode
+ SPIC.INTCTRL = SPI_INTLVL_OFF_gc;
+ //#ifdef VERO
+ PORTC.PIN5CTRL = PORT_INVEN_bm | PORT_OPC_PULLUP_gc;
+ //#else
+ // PORTC.PIN7CTRL = PORT_INVEN_bm | PORT_OPC_PULLUP_gc; //Pin5 if not swapped
+ //#endif
+
+ return;
+}
+
+ISR(SPIC_INT_vect){
+ asm("nop");
+}
+
+ISR(USARTC0_RXC_vect){
+ unsigned char temp = USARTC0.DATA;
+ USARTC0.DATA = temp;
+}
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_uart.c.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_uart.c.REMOVED.git-id
deleted file mode 100644
index ec2fe3f4..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_uart.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a30ce5517475366f225d4c5e018dfa23dda19da2
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_uart.h b/AVR Code/USB_BULK_TEST/src/tiny_uart.h
new file mode 100644
index 00000000..ec38ec38
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/tiny_uart.h
@@ -0,0 +1,19 @@
+/*
+ * tiny_uart.h
+ *
+ * Created: 16/07/2015 6:33:02 PM
+ * Author: Esposch
+ */
+
+
+#ifndef TINY_UART_H_
+#define TINY_UART_H_
+
+#include
+#include
+
+void tiny_uart_setup(void);
+void tiny_spi_setup(void);
+
+
+#endif /* TINY_UART_H_ */
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/tiny_uart.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/tiny_uart.h.REMOVED.git-id
deleted file mode 100644
index 7f717ff3..00000000
--- a/AVR Code/USB_BULK_TEST/src/tiny_uart.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ec38ec3811d5f02be20c85db9df6bcceb96da92f
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/ui.h b/AVR Code/USB_BULK_TEST/src/ui.h
new file mode 100644
index 00000000..2ac4dfa3
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/ui.h
@@ -0,0 +1,73 @@
+/**
+ * \file
+ *
+ * \brief Common User Interface for USB vendor class application
+ *
+ * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The name of Atmel may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel microcontroller product.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit Atmel Support
+ */
+
+#ifndef _UI_H_
+#define _UI_H_
+
+//! \brief Initializes the user interface
+void ui_init(void);
+
+//! \brief Enters the user interface in power down mode
+void ui_powerdown(void);
+
+//! \brief Exits the user interface of power down mode
+void ui_wakeup(void);
+
+/*! \brief Notify the state of loopback
+ * It is called when a the loopback is started and stopped.
+ *
+ * \param b_started loopback started if true, else stopped
+ */
+void ui_loop_back_state(bool b_started);
+
+/*! \brief This process is called each 1ms
+ * It is called only if the USB interface is enabled.
+ *
+ * \param framenumber Current frame number
+ */
+void ui_process(uint16_t framenumber);
+
+#endif // _UI_H_
diff --git a/AVR Code/USB_BULK_TEST/src/ui.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/ui.h.REMOVED.git-id
deleted file mode 100644
index c0347c79..00000000
--- a/AVR Code/USB_BULK_TEST/src/ui.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2ac4dfa3221a08ea881ed695eb9b61bde1c5ca5b
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST/src/unified_debug_structure.h b/AVR Code/USB_BULK_TEST/src/unified_debug_structure.h
new file mode 100644
index 00000000..199e4a91
--- /dev/null
+++ b/AVR Code/USB_BULK_TEST/src/unified_debug_structure.h
@@ -0,0 +1,38 @@
+/*
+ * unified_debug_structure.h
+ *
+ * Created: 1/02/2017 9:38:31 AM
+ * Author: Esposch
+ */
+
+
+#ifndef UNIFIED_DEBUG_STRUCTURE_H_
+#define UNIFIED_DEBUG_STRUCTURE_H_
+
+#include
+
+//EVERYTHING MUST BE SENT ONE BYTE AT A TIME, HIGH AND LOW BYTES SEPARATE, IN ORDER TO AVOID ISSUES WITH ENDIANNESS.
+typedef struct uds{
+ volatile char header[9];
+ volatile uint8_t trfcntL0;
+ volatile uint8_t trfcntH0;
+ volatile uint8_t trfcntL1;
+ volatile uint8_t trfcntH1;
+ volatile uint8_t medianTrfcntL;
+ volatile uint8_t medianTrfcntH;
+ volatile uint8_t calValNeg;
+ volatile uint8_t calValPos;
+ volatile uint8_t CALA;
+ volatile uint8_t CALB;
+ volatile uint8_t outOfRangeL;
+ volatile uint8_t outOfRangeH;
+ volatile uint8_t counterL;
+ volatile uint8_t counterH;
+ volatile uint8_t dma_ch0_cntL;
+ volatile uint8_t dma_ch0_cntH;
+ volatile uint8_t dma_ch1_cntL;
+ volatile uint8_t dma_ch1_cntH;
+
+} unified_debug;
+
+#endif /* UNIFIED_DEBUG_STRUCTURE_H_ */
diff --git a/AVR Code/USB_BULK_TEST/src/unified_debug_structure.h.REMOVED.git-id b/AVR Code/USB_BULK_TEST/src/unified_debug_structure.h.REMOVED.git-id
deleted file mode 100644
index 3bd55b8a..00000000
--- a/AVR Code/USB_BULK_TEST/src/unified_debug_structure.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-199e4a916b325ca33358adcf8f2fc63f67fe04ae
\ No newline at end of file
diff --git a/AVR Code/USB_BULK_TEST_6_2.atsln.REMOVED.git-id b/AVR Code/USB_BULK_TEST_6_2.atsln.REMOVED.git-id
deleted file mode 100644
index 36bcbc42..00000000
--- a/AVR Code/USB_BULK_TEST_6_2.atsln.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2f780e8c37a5793d6957573a02eb53faa5e20ad7
\ No newline at end of file
diff --git a/Desktop_Interface/.DS_Store.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/.DS_Store.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 1ce1bea2..00000000
--- a/Desktop_Interface/.DS_Store.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0043d09029c61620757ad386a48686e338c9dbaf
\ No newline at end of file
diff --git a/Desktop_Interface/._.DS_Store.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/._.DS_Store.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 95175ab4..00000000
--- a/Desktop_Interface/._.DS_Store.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-301d01b13096dca1cd26a9b8830a99612aa2553b
\ No newline at end of file
diff --git a/Desktop_Interface/.qmake.stash.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/.qmake.stash.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 4b390d9e..00000000
--- a/Desktop_Interface/.qmake.stash.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4a612239348db9cc466ad5e3f8783ebe3b7bc25b
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro b/Desktop_Interface/Labrador.pro
new file mode 100644
index 00000000..e99908ce
--- /dev/null
+++ b/Desktop_Interface/Labrador.pro
@@ -0,0 +1,276 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2016-03-30T13:27:52
+#
+#-------------------------------------------------
+
+
+############################################################################
+######CLEAN->RUN QMAKE->BUILD after changing anything on this page!!!######
+##########################################################################
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
+
+TARGET = Labrador
+TEMPLATE = app
+
+QCP_VER = 1
+DEFINES += "QCP_VER=$${QCP_VER}"
+equals(QCP_VER,"2"){
+ DEFINES += QCUSTOMPLOT_USE_OPENGL
+ message("Using QCP2 with OpenGL support")
+}
+
+include(ui_elements.pri)
+
+MOC_DIR = $$PWD/moc
+
+SOURCES += main.cpp\
+ mainwindow.cpp \
+ functiongencontrol.cpp \
+ isodriver.cpp \
+ isobuffer.cpp \
+ desktop_settings.cpp \
+ scoperangeenterdialog.cpp \
+ genericusbdriver.cpp \
+ isobufferbuffer.cpp
+
+HEADERS += mainwindow.h \
+ functiongencontrol.h \
+ xmega.h \
+ isodriver.h \
+ isobuffer.h \
+ desktop_settings.h \
+ scoperangeenterdialog.h \
+ genericusbdriver.h \
+ isobufferbuffer.h \
+ q_debugstream.h \
+ unified_debug_structure.h
+
+android:{
+FORMS += ui_files_mobile/mainwindow.ui \
+ ui_files_mobile/scoperangeenterdialog.ui
+}
+
+!android:{
+FORMS += ui_files_desktop/mainwindow.ui \
+ ui_files_desktop/scoperangeenterdialog.ui
+}
+
+
+RESOURCES += \
+ resources.qrc
+
+DESTDIR = bin
+
+RC_ICONS = appicon.ico
+
+INCLUDEPATH += $$PWD/ui_elements
+DEPENDPATH += $$PWD/ui_elements
+
+
+###########################################################
+################ WINDOWS BUILD ONLY ################
+#########################################################
+
+win32{
+ INCLUDEPATH += $$PWD/build_win
+ SOURCES += winusbdriver.cpp
+ HEADERS += winusbdriver.h
+
+ #libusbk include
+ contains(QT_ARCH, i386) {
+ message("Building for Windows (x86)")
+ CONFIG(release, debug|release): LIBS += -L$$PWD/build_win/libusbk/bin/lib/x86/ -llibusbK
+ else:CONFIG(debug, debug|release): LIBS += -L$$PWD/build_win/libusbk/bin/lib/x86/ -llibusbK
+ } else {
+ message("Building for Windows (x64)")
+ CONFIG(release, debug|release): LIBS += -L$$PWD/build_win/libusbk/bin/lib/amd64/ -llibusbK
+ else:CONFIG(debug, debug|release): LIBS += -L$$PWD/build_win/libusbk/bin/lib/amd64/ -llibusbK
+ }
+ INCLUDEPATH += $$PWD/build_win/libusbk/includes
+ DEPENDPATH += $$PWD/build/win/libusbk/includes
+ DEFINES += PLATFORM_WINDOWS
+}
+
+#############################################################
+################ GNU/LINUX BUILD ONLY ################
+###########################################################
+
+unix:!android:!macx{
+ INCLUDEPATH += $$PWD/build_linux
+ contains(QT_ARCH, arm) {
+ message("Building for Raspberry Pi")
+ #libusb include
+ unix:!android:!macx:LIBS += -lusb-1.0 ##make sure you have the libusb-1.0-0-dev package!
+ unix:!android:!macx:INCLUDEPATH += build_linux/libusb
+ unix:!android:!macx:DEPENDPATH += build_linux/libusb
+
+ #libdfuprog include
+ unix:!android:!macx:LIBS += -L$$PWD/build_linux/libdfuprog/lib/arm -ldfuprog-0.9
+ unix:!android:!macx:INCLUDEPATH += $$PWD/build_linux/libdfuprog/include
+ unix:!android:!macx:DEPENDPATH += $$PWD/build_linux/libdfuprog/include
+ QMAKE_CFLAGS += -fsigned-char
+ QMAKE_CXXFLAGS += -fsigned-char
+ DEFINES += "PLATFORM_RASPBERRY_PI"
+ #All ARM-Linux GCC treats char as unsigned by default???
+ } else {
+ contains(QT_ARCH, i386) {
+ message("Building for Linux (x86)")
+ unix:!android:!macx:LIBS += -lusb-1.0 ##make sure you have the libusb-1.0-0-dev package!
+ unix:!android:!macx:INCLUDEPATH += build_linux/libusb
+ unix:!android:!macx:DEPENDPATH += build_linux/libusb
+
+ #libdfuprog include
+ unix:!android:!macx:LIBS += -L$$PWD/build_linux/libdfuprog/lib/x86 -ldfuprog-0.9
+ unix:!android:!macx:INCLUDEPATH += $$PWD/build_linux/libdfuprog/include
+ unix:!android:!macx:DEPENDPATH += $$PWD/build_linux/libdfuprog/include
+ } else {
+ message("Building for Linux (x64)")
+ #libusb include
+ unix:!android:!macx:LIBS += -Lbuild_linux/libusb -lusb-1.0 ##I suspect the -L here does nothing!
+ unix:!android:!macx:INCLUDEPATH += build_linux/libusb
+ unix:!android:!macx:DEPENDPATH += build_linux/libusb
+
+ #libdfuprog include
+ unix:!android:!macx:LIBS += -L$$PWD/build_linux/libdfuprog/lib/x64 -ldfuprog-0.9
+ unix:!android:!macx:INCLUDEPATH += $$PWD/build_linux/libdfuprog/include
+ unix:!android:!macx:DEPENDPATH += $$PWD/build_linux/libdfuprog/include
+ }
+ }
+}
+
+
+
+#############################################################
+################ MAC OSX BUILD ONLY ##################
+###########################################################
+
+macx:INCLUDEPATH += $$PWD/build_mac
+
+#libusb dylib include
+macx:LIBS += -L$$PWD/build_mac/libusb/lib -lusb-1.0
+macx:INCLUDEPATH += $$PWD/build_mac/libusb/include/libusb-1.0
+macx:DEPENDPATH += $$PWD/build_mac/libusb/include/libusb-1.0
+
+#libdfuprog dylib include
+macx:LIBS += -L$$PWD/build_mac/libdfuprog/lib -ldfuprog-0.9
+macx:INCLUDEPATH += $$PWD/build_mac/libdfuprog/include
+macx:DEPENDPATH += $$PWD/build_mac/libdfuprog/include
+
+macx:QMAKE_LFLAGS += "-undefined dynamic_lookup"
+
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
+
+
+
+
+#############################################################
+######## SHARED UNIX-LIKE BUILDS (MAC + LINUX) #########
+###########################################################
+
+unix:SOURCES += unixusbdriver.cpp
+unix:HEADERS += unixusbdriver.h
+
+#############################################################
+######## SHARED ANDROID/LINUX GCC FLAGS #########
+###########################################################
+
+unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O0
+unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O1
+unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O2
+unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O3
+
+android: QMAKE_CXXFLAGS_RELEASE -= -O0
+android: QMAKE_CXXFLAGS_RELEASE -= -O1
+android: QMAKE_CXXFLAGS_RELEASE -= -O2
+android: QMAKE_CXXFLAGS_RELEASE -= -O3
+android: QMAKE_CXXFLAGS_RELEASE -= -Os
+
+
+android: QMAKE_CFLAGS_RELEASE -= -O0
+android: QMAKE_CFLAGS_RELEASE -= -O1
+android: QMAKE_CFLAGS_RELEASE -= -O2
+android: QMAKE_CFLAGS_RELEASE -= -O3
+android: QMAKE_CFLAGS_RELEASE -= -Os
+
+
+#############################################################
+################# ANDROID BUILD ONLY #################
+###########################################################
+
+android:{
+ QMAKE_CFLAGS += -fsigned-char
+ QMAKE_CXXFLAGS += -fsigned-char
+ #Android treats char as unsigned by default (why???)
+
+ QT += androidextras
+ CONFIG += mobility
+ MOBILITY =
+
+ INCLUDEPATH += $$PWD/build_android
+ SOURCES += androidusbdriver.cpp
+ HEADERS += androidusbdriver.h
+ INCLUDEPATH += $$PWD/build_android/libusb-martin-kuldeep
+ DEPENDPATH += $$PWD/build_android/libusb-martin-kuldeep
+
+ ANDROID_PACKAGE_SOURCE_DIR = $$PWD/build_android/package_source
+ assets_deploy.files=$$files($$PWD/build_android/package_source/assets/*)
+ assets_deploy.path=/assets
+ INSTALLS += asssets_deploy
+
+ #libdfuprog include
+ LIBS += -L$$PWD/build_android/libdfuprog/lib -ldfuprog-0.9
+ INCLUDEPATH += $$PWD/build_android/libdfuprog/include
+ DEPENDPATH += $$PWD/build_android/libdfuprog/include
+ ANDROID_EXTRA_LIBS += $${PWD}/build_android/libdfuprog/lib/libdfuprog-0.9.so
+
+ #liblog include
+ LIBS += -L$$PWD/build_android/liblog/lib -llog
+ ANDROID_EXTRA_LIBS += $${PWD}/build_android/liblog/lib/liblog.so
+
+
+
+ DISTFILES += \
+ build_android/package_source/AndroidManifest.xml \
+ build_android/package_source/gradle/wrapper/gradle-wrapper.jar \
+ build_android/package_source/gradlew \
+ build_android/package_source/res/values/libs.xml \
+ build_android/package_source/build.gradle \
+ build_android/package_source/gradle/wrapper/gradle-wrapper.properties \
+ build_android/package_source/gradlew.bat \
+ build_android/package_source/AndroidManifest.xml \
+ build_android/package_source/res/values/libs.xml \
+ build_android/package_source/build.gradle \
+ build_android/package_source/src/androidInterface.java
+
+ equals(ANDROID_TARGET_ARCH, armeabi-v7a){
+ message("qmake building for Android (ARM) platform")
+ LIBS += -L$${PWD}\build_android\libusb-martin-kuldeep\android\armeabi-v7a -lusb1.0
+ ANDROID_EXTRA_LIBS += $${PWD}\build_android\libusb-martin-kuldeep\android\armeabi-v7a/libusb1.0.so
+ }
+ equals(ANDROID_TARGET_ARCH, x86){
+ message("qmake building for Android (x86) platform")
+ LIBS += -L$$PWD/build_android/libusb-martin-kuldeep/android/x86 -lusb1.0
+ ANDROID_EXTRA_LIBS += $$PWD/build_android/libusb-martin-kuldeep/android/x86/libusb1.0.so
+ }
+}
+
+DISTFILES += \
+ build_android/package_source/AndroidManifest.xml \
+ build_android/package_source/gradle/wrapper/gradle-wrapper.jar \
+ build_android/package_source/gradlew \
+ build_android/package_source/res/values/libs.xml \
+ build_android/package_source/build.gradle \
+ build_android/package_source/gradle/wrapper/gradle-wrapper.properties \
+ build_android/package_source/gradlew.bat \
+ build_android/package_source/AndroidManifest.xml \
+ build_android/package_source/gradle/wrapper/gradle-wrapper.jar \
+ build_android/package_source/gradlew \
+ build_android/package_source/res/values/libs.xml \
+ build_android/package_source/build.gradle \
+ build_android/package_source/gradle/wrapper/gradle-wrapper.properties \
+ build_android/package_source/gradlew.bat \
+ build_android/package_source/res/xml/device_filter.xml
diff --git a/Desktop_Interface/Labrador.pro.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index aa9d46cb..00000000
--- a/Desktop_Interface/Labrador.pro.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b0fee96cf5a3b98a61d3849fa6acffc95a176d4e
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro.user.1aedbdd.18.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.user.1aedbdd.18.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index ed2ee8fc..00000000
--- a/Desktop_Interface/Labrador.pro.user.1aedbdd.18.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-07ecd6b63a55eb91ce8776f509cced90074280ed
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro.user.269d77a.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.user.269d77a.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 701d84f3..00000000
--- a/Desktop_Interface/Labrador.pro.user.269d77a.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b7ef363dd913a43e6a4d2f3206bd61cab0bf38eb
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro.user.418854c.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.user.418854c.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index e519b90d..00000000
--- a/Desktop_Interface/Labrador.pro.user.418854c.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-87d1314a1a7c0db5e976aa5d42ec8868380c32f9
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro.user.4395d92.3.3-pre1.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.user.4395d92.3.3-pre1.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 95ad4626..00000000
--- a/Desktop_Interface/Labrador.pro.user.4395d92.3.3-pre1.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5d394806324a52cc05a5e80ab9929284abafcba0
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro.user.5435f0c.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.user.5435f0c.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 5b692515..00000000
--- a/Desktop_Interface/Labrador.pro.user.5435f0c.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-22d2b5e3656787cb3f7132eb6ace5d838a3dc73c
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro.user.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.user.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 12a46d39..00000000
--- a/Desktop_Interface/Labrador.pro.user.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-97e2213c5b31ce16553ad120b2ea00c1680ea04f
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador.pro.user.ab2277d.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador.pro.user.ab2277d.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 89f034a0..00000000
--- a/Desktop_Interface/Labrador.pro.user.ab2277d.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-20ae345c1e6dcac2457a19eee35d23a053399588
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador_libusbk_resource.rc.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador_libusbk_resource.rc.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 41c2fcc6..00000000
--- a/Desktop_Interface/Labrador_libusbk_resource.rc.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6a92256e38b1cb81f1ff87ea7ed966f2a89856d5
\ No newline at end of file
diff --git a/Desktop_Interface/Labrador_resource.rc.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Labrador_resource.rc.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index f68edbac..00000000
--- a/Desktop_Interface/Labrador_resource.rc.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-71c620008a1a6cddb196a905bfb807f7bebef968
\ No newline at end of file
diff --git a/Desktop_Interface/Makefile.Debug.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Makefile.Debug.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 0e3c32b0..00000000
--- a/Desktop_Interface/Makefile.Debug.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c75ee697a063e11b91c63f140e0b9dc404a7b66e
\ No newline at end of file
diff --git a/Desktop_Interface/Makefile.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Makefile.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 4568c91b..00000000
--- a/Desktop_Interface/Makefile.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-209df9bf45c202a9c19d146b81f75787cfcf3baa
\ No newline at end of file
diff --git a/Desktop_Interface/Makefile.Release.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Makefile.Release.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index b71618a9..00000000
--- a/Desktop_Interface/Makefile.Release.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6c9e5bb2fa306d9e51a9d6c8ea2304c19dc96186
\ No newline at end of file
diff --git a/Desktop_Interface/Thumbs.db.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/Thumbs.db.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 69431f67..00000000
--- a/Desktop_Interface/Thumbs.db.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3fd92c0ddb2cf412720f6d7c5904f499dbe4459d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/cache.properties.REMOVED.git-id b/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/cache.properties.REMOVED.git-id
deleted file mode 100644
index 184e36c6..00000000
--- a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/cache.properties.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-19631cf2dc406a2d9bb9a71bac354fa2eaf75c8c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/cache.properties.lock.REMOVED.git-id b/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/cache.properties.lock.REMOVED.git-id
deleted file mode 100644
index ef4d288a..00000000
--- a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/cache.properties.lock.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-65acfb186c410095c763735cfb3200a0d1119a4e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/fileHashes.bin.REMOVED.git-id b/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/fileHashes.bin.REMOVED.git-id
deleted file mode 100644
index de7db0a2..00000000
--- a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/fileHashes.bin.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4c67a17651306a71849c9db6c4519ebd32f57cce
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin.REMOVED.git-id b/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin.REMOVED.git-id
deleted file mode 100644
index 67b90f21..00000000
--- a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2cc6b5c5eea20cde3dbb0a305b2cdd2e01b1944b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/outputFileStates.bin.REMOVED.git-id b/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/outputFileStates.bin.REMOVED.git-id
deleted file mode 100644
index 75bca3d0..00000000
--- a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/outputFileStates.bin.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f056a292c5f3a349b3265e1cbb313604e5082473
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin.REMOVED.git-id b/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin.REMOVED.git-id
deleted file mode 100644
index 3e57985d..00000000
--- a/Desktop_Interface/android-build/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-44c1e42e6f1e3979f94516adf1b0ec593e3a6418
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/AndroidManifest.xml.REMOVED.git-id b/Desktop_Interface/android-build/AndroidManifest.xml.REMOVED.git-id
deleted file mode 100644
index 9d610b79..00000000
--- a/Desktop_Interface/android-build/AndroidManifest.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-778be5ebea55e51b0cdd65420f001794548fa0a5
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/AndroidManifest.xml.autosave.REMOVED.git-id b/Desktop_Interface/android-build/AndroidManifest.xml.autosave.REMOVED.git-id
deleted file mode 100644
index 81d1a2ec..00000000
--- a/Desktop_Interface/android-build/AndroidManifest.xml.autosave.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-45804aa388539188d4d2df6fde2d841edd5f2bf6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id b/Desktop_Interface/android-build/assets/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id
deleted file mode 100644
index c936d71a..00000000
--- a/Desktop_Interface/android-build/assets/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3668bf657139054c49a4692fa32094510495a915
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/firmware/labrafirm_0003_01.hex.REMOVED.git-id b/Desktop_Interface/android-build/assets/firmware/labrafirm_0003_01.hex.REMOVED.git-id
deleted file mode 100644
index b3667a22..00000000
--- a/Desktop_Interface/android-build/assets/firmware/labrafirm_0003_01.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f7946fd762c2bf7eaa4b76d5eb68948870244c19
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/firmware/labrafirm_0003_02.hex.REMOVED.git-id b/Desktop_Interface/android-build/assets/firmware/labrafirm_0003_02.hex.REMOVED.git-id
deleted file mode 100644
index 42c42b45..00000000
--- a/Desktop_Interface/android-build/assets/firmware/labrafirm_0003_02.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-879125a9685d89a7f05bd38994079919338f49b6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/waveforms/DC.tlw.REMOVED.git-id b/Desktop_Interface/android-build/assets/waveforms/DC.tlw.REMOVED.git-id
deleted file mode 100644
index e3326948..00000000
--- a/Desktop_Interface/android-build/assets/waveforms/DC.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-69f322d2c3c6452561c8232b20784828fc438399
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/waveforms/Sawtooth.tlw.REMOVED.git-id b/Desktop_Interface/android-build/assets/waveforms/Sawtooth.tlw.REMOVED.git-id
deleted file mode 100644
index 87e86502..00000000
--- a/Desktop_Interface/android-build/assets/waveforms/Sawtooth.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e989a81be4fb7a2d79495ce7e96db776b0366a94
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/waveforms/Sin.tlw.REMOVED.git-id b/Desktop_Interface/android-build/assets/waveforms/Sin.tlw.REMOVED.git-id
deleted file mode 100644
index ceeb1ad1..00000000
--- a/Desktop_Interface/android-build/assets/waveforms/Sin.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e376c35388394ccfa4a86cb5bc6f9961e00fef20
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/waveforms/Square.tlw.REMOVED.git-id b/Desktop_Interface/android-build/assets/waveforms/Square.tlw.REMOVED.git-id
deleted file mode 100644
index 25d85bc6..00000000
--- a/Desktop_Interface/android-build/assets/waveforms/Square.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7bdd30bee84b15cc3fe88dd02751316a2016060c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/waveforms/Triangle.tlw.REMOVED.git-id b/Desktop_Interface/android-build/assets/waveforms/Triangle.tlw.REMOVED.git-id
deleted file mode 100644
index 768d2ac7..00000000
--- a/Desktop_Interface/android-build/assets/waveforms/Triangle.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-420ac92c2c292688434b3987874cc98a9180e336
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/assets/waveforms/_list.wfl.REMOVED.git-id b/Desktop_Interface/android-build/assets/waveforms/_list.wfl.REMOVED.git-id
deleted file mode 100644
index 2b3bbd46..00000000
--- a/Desktop_Interface/android-build/assets/waveforms/_list.wfl.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d9c5ca2b7e1352538debad0a17885fc4355864fc
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build.gradle.REMOVED.git-id b/Desktop_Interface/android-build/build.gradle.REMOVED.git-id
deleted file mode 100644
index 6af3117a..00000000
--- a/Desktop_Interface/android-build/build.gradle.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ef416b0b88c1420d7bed0975240c678198aa73c2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/aidl/debug/org/kde/necessitas/ministro/IMinistro.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/aidl/debug/org/kde/necessitas/ministro/IMinistro.java.REMOVED.git-id
deleted file mode 100644
index c6e5527d..00000000
--- a/Desktop_Interface/android-build/build/generated/source/aidl/debug/org/kde/necessitas/ministro/IMinistro.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d785f4828fe4913e69b02e4a0d42ec2a6563739b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/aidl/debug/org/kde/necessitas/ministro/IMinistroCallback.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/aidl/debug/org/kde/necessitas/ministro/IMinistroCallback.java.REMOVED.git-id
deleted file mode 100644
index 3f9f2761..00000000
--- a/Desktop_Interface/android-build/build/generated/source/aidl/debug/org/kde/necessitas/ministro/IMinistroCallback.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6e6c51a0fb96b523dc2571e16e0aa19ae7088db8
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/aidl/release/org/kde/necessitas/ministro/IMinistro.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/aidl/release/org/kde/necessitas/ministro/IMinistro.java.REMOVED.git-id
deleted file mode 100644
index c6e5527d..00000000
--- a/Desktop_Interface/android-build/build/generated/source/aidl/release/org/kde/necessitas/ministro/IMinistro.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d785f4828fe4913e69b02e4a0d42ec2a6563739b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/aidl/release/org/kde/necessitas/ministro/IMinistroCallback.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/aidl/release/org/kde/necessitas/ministro/IMinistroCallback.java.REMOVED.git-id
deleted file mode 100644
index 3f9f2761..00000000
--- a/Desktop_Interface/android-build/build/generated/source/aidl/release/org/kde/necessitas/ministro/IMinistroCallback.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6e6c51a0fb96b523dc2571e16e0aa19ae7088db8
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/buildConfig/debug/org/qtproject/example/Labrador/BuildConfig.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/buildConfig/debug/org/qtproject/example/Labrador/BuildConfig.java.REMOVED.git-id
deleted file mode 100644
index 7f600589..00000000
--- a/Desktop_Interface/android-build/build/generated/source/buildConfig/debug/org/qtproject/example/Labrador/BuildConfig.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2b12c8cfdd4caa39909c3b2ff8fd07a42fffb96c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/buildConfig/release/org/qtproject/example/Labrador/BuildConfig.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/buildConfig/release/org/qtproject/example/Labrador/BuildConfig.java.REMOVED.git-id
deleted file mode 100644
index cf0e18fa..00000000
--- a/Desktop_Interface/android-build/build/generated/source/buildConfig/release/org/qtproject/example/Labrador/BuildConfig.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1f0d52f57d5e59f5dfac1b86502f41696bfc5e8c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/r/debug/org/qtproject/example/Labrador/R.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/r/debug/org/qtproject/example/Labrador/R.java.REMOVED.git-id
deleted file mode 100644
index 2f0f66ed..00000000
--- a/Desktop_Interface/android-build/build/generated/source/r/debug/org/qtproject/example/Labrador/R.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3091d16f76ce6ad7c805578686958d95896e840e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/generated/source/r/release/org/qtproject/example/Labrador/R.java.REMOVED.git-id b/Desktop_Interface/android-build/build/generated/source/r/release/org/qtproject/example/Labrador/R.java.REMOVED.git-id
deleted file mode 100644
index 2f0f66ed..00000000
--- a/Desktop_Interface/android-build/build/generated/source/r/release/org/qtproject/example/Labrador/R.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3091d16f76ce6ad7c805578686958d95896e840e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id
deleted file mode 100644
index c936d71a..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3668bf657139054c49a4692fa32094510495a915
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/firmware/labrafirm_0003_01.hex.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/firmware/labrafirm_0003_01.hex.REMOVED.git-id
deleted file mode 100644
index b3667a22..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/firmware/labrafirm_0003_01.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f7946fd762c2bf7eaa4b76d5eb68948870244c19
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/firmware/labrafirm_0003_02.hex.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/firmware/labrafirm_0003_02.hex.REMOVED.git-id
deleted file mode 100644
index 42c42b45..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/firmware/labrafirm_0003_02.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-879125a9685d89a7f05bd38994079919338f49b6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/DC.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/DC.tlw.REMOVED.git-id
deleted file mode 100644
index e3326948..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/DC.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-69f322d2c3c6452561c8232b20784828fc438399
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Sawtooth.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Sawtooth.tlw.REMOVED.git-id
deleted file mode 100644
index 87e86502..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Sawtooth.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e989a81be4fb7a2d79495ce7e96db776b0366a94
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Sin.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Sin.tlw.REMOVED.git-id
deleted file mode 100644
index ceeb1ad1..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Sin.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e376c35388394ccfa4a86cb5bc6f9961e00fef20
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Square.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Square.tlw.REMOVED.git-id
deleted file mode 100644
index 25d85bc6..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Square.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7bdd30bee84b15cc3fe88dd02751316a2016060c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Triangle.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Triangle.tlw.REMOVED.git-id
deleted file mode 100644
index 768d2ac7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/Triangle.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-420ac92c2c292688434b3987874cc98a9180e336
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/_list.wfl.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/_list.wfl.REMOVED.git-id
deleted file mode 100644
index 2b3bbd46..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/debug/waveforms/_list.wfl.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d9c5ca2b7e1352538debad0a17885fc4355864fc
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id
deleted file mode 100644
index c936d71a..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3668bf657139054c49a4692fa32094510495a915
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/firmware/labrafirm_0003_01.hex.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/firmware/labrafirm_0003_01.hex.REMOVED.git-id
deleted file mode 100644
index b3667a22..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/firmware/labrafirm_0003_01.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f7946fd762c2bf7eaa4b76d5eb68948870244c19
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/firmware/labrafirm_0003_02.hex.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/firmware/labrafirm_0003_02.hex.REMOVED.git-id
deleted file mode 100644
index 42c42b45..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/firmware/labrafirm_0003_02.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-879125a9685d89a7f05bd38994079919338f49b6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/DC.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/DC.tlw.REMOVED.git-id
deleted file mode 100644
index e3326948..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/DC.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-69f322d2c3c6452561c8232b20784828fc438399
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Sawtooth.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Sawtooth.tlw.REMOVED.git-id
deleted file mode 100644
index 87e86502..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Sawtooth.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e989a81be4fb7a2d79495ce7e96db776b0366a94
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Sin.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Sin.tlw.REMOVED.git-id
deleted file mode 100644
index ceeb1ad1..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Sin.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e376c35388394ccfa4a86cb5bc6f9961e00fef20
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Square.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Square.tlw.REMOVED.git-id
deleted file mode 100644
index 25d85bc6..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Square.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7bdd30bee84b15cc3fe88dd02751316a2016060c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Triangle.tlw.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Triangle.tlw.REMOVED.git-id
deleted file mode 100644
index 768d2ac7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/Triangle.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-420ac92c2c292688434b3987874cc98a9180e336
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/_list.wfl.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/_list.wfl.REMOVED.git-id
deleted file mode 100644
index 2b3bbd46..00000000
--- a/Desktop_Interface/android-build/build/intermediates/assets/release/waveforms/_list.wfl.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d9c5ca2b7e1352538debad0a17885fc4355864fc
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/com/EspoTek/Labrador/Java/androidInterface.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/com/EspoTek/Labrador/Java/androidInterface.class.REMOVED.git-id
deleted file mode 100644
index 0ef4b563..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/com/EspoTek/Labrador/Java/androidInterface.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-40cb400b3181a4e1d498c578fcf7896d83cb9474
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro$Stub$Proxy.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro$Stub$Proxy.class.REMOVED.git-id
deleted file mode 100644
index bd53c92b..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro$Stub$Proxy.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d967fe87f176c6c13995a3d0d586790192d1a6bd
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro$Stub.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro$Stub.class.REMOVED.git-id
deleted file mode 100644
index b146a8df..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro$Stub.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2de2f483640913f8c6a265f32207f34228898fd5
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro.class.REMOVED.git-id
deleted file mode 100644
index 59dbc7a6..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistro.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9b984325131098a100ec1237936d4d5fc219f4a7
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback$Stub$Proxy.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback$Stub$Proxy.class.REMOVED.git-id
deleted file mode 100644
index ef3d6048..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback$Stub$Proxy.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2ab52eddb035f944b0cb2a279a9bd1cc0dd1ffd2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback$Stub.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback$Stub.class.REMOVED.git-id
deleted file mode 100644
index 1ffeba6c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback$Stub.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-139d566283e991dd3e8d8456c614763300ca1737
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback.class.REMOVED.git-id
deleted file mode 100644
index c056c893..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/kde/necessitas/ministro/IMinistroCallback.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-61c0129078b6e1714f4dc75ee7838d9789051146
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/BuildConfig.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/BuildConfig.class.REMOVED.git-id
deleted file mode 100644
index 5f91f8c4..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/BuildConfig.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a702990e597b33d8880be60d40dd0712115d03ca
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$array.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$array.class.REMOVED.git-id
deleted file mode 100644
index ae7ac54c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$array.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ee588922229197e056655f15253143cd727985e0
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$attr.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$attr.class.REMOVED.git-id
deleted file mode 100644
index 7c87f38e..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$attr.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b8079837ab299e64673bab5b0983db23a79a17ce
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$layout.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$layout.class.REMOVED.git-id
deleted file mode 100644
index 70885ed9..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$layout.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fdd228d281a582362f520b9948e530c1a673046b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$mipmap.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$mipmap.class.REMOVED.git-id
deleted file mode 100644
index 3d16956a..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$mipmap.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-69e4741e408a36d0ba20802932365f709a5a6794
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$string.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$string.class.REMOVED.git-id
deleted file mode 100644
index 0061ced7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$string.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6f131c3f47e5060faedfc805fa986f1affff079f
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$xml.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$xml.class.REMOVED.git-id
deleted file mode 100644
index 4d1a8b46..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R$xml.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cb33f62bc902185d43659da6d2985401319c08fa
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R.class.REMOVED.git-id
deleted file mode 100644
index d2fa7515..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/example/Labrador/R.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-79b9abc21964201e35c8814c22150042650528fb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivity.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivity.class.REMOVED.git-id
deleted file mode 100644
index eec5e578..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivity.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-912eec8a6c967bfa68e0753277daa422f72a64fb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$1.class.REMOVED.git-id
deleted file mode 100644
index d95fa5e0..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-41c0bd4cc2f13e55388bf3b6acb775be142a535e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$2.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$2.class.REMOVED.git-id
deleted file mode 100644
index 7b8b3a6c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$2.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-22007d6acebdc831bbfcca73024276d91b1317a0
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$3.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$3.class.REMOVED.git-id
deleted file mode 100644
index e0d284fc..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader$3.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-99174636267ae4ab39f9a5089517e031a5f933f6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader.class.REMOVED.git-id
deleted file mode 100644
index 70e1ab38..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtActivityLoader.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5bb20c93533cd6c05ae79b58ef4720fc5b8deec8
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtApplication$InvokeResult.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtApplication$InvokeResult.class.REMOVED.git-id
deleted file mode 100644
index 3358f8c8..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtApplication$InvokeResult.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b674dee3041cca0891a0683f1e9be3e46aa238c2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtApplication.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtApplication.class.REMOVED.git-id
deleted file mode 100644
index de4f8c71..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtApplication.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4f90a6b9ee29832c3ef0756fa6ba82bf332da2ca
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$1.class.REMOVED.git-id
deleted file mode 100644
index 3f08db71..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2b2abc0e9fec80ab2f2f6c5f1bbf0fc757a920cb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$2.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$2.class.REMOVED.git-id
deleted file mode 100644
index 84195c6e..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$2.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ca085bea1eac1a6572ec4acfdf49938f9ba9a9fb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3$1$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3$1$1.class.REMOVED.git-id
deleted file mode 100644
index 290d19fd..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3$1$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-feb1da444f93e4ff96e598cdabfb13645a8bb29b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3$1.class.REMOVED.git-id
deleted file mode 100644
index c2d25d77..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1e9ef9840393874d20a43e89426f167581589297
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3.class.REMOVED.git-id
deleted file mode 100644
index b82bec7c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$3.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f74c0e4e3b6231cb52a04d2c2c03063c5b947267
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$4.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$4.class.REMOVED.git-id
deleted file mode 100644
index 790d0a02..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader$4.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-73525e6cc5251cef7c51dee5300db5536df7edd7
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader.class.REMOVED.git-id
deleted file mode 100644
index cc1d8e75..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtLoader.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-407bed74afd06263dea279117ae0396e0cef2f3a
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtService.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtService.class.REMOVED.git-id
deleted file mode 100644
index e8c13d28..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtService.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f3c0b5ccbff0ec989f58f042a5b513426cbb2ab7
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtServiceLoader.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtServiceLoader.class.REMOVED.git-id
deleted file mode 100644
index 56ce0451..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/debug/org/qtproject/qt5/android/bindings/QtServiceLoader.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-baaa8fa744cb749bdb53b2cf16205f3e7899da8c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/com/EspoTek/Labrador/Java/androidInterface.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/com/EspoTek/Labrador/Java/androidInterface.class.REMOVED.git-id
deleted file mode 100644
index 0ef4b563..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/com/EspoTek/Labrador/Java/androidInterface.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-40cb400b3181a4e1d498c578fcf7896d83cb9474
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro$Stub$Proxy.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro$Stub$Proxy.class.REMOVED.git-id
deleted file mode 100644
index bd53c92b..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro$Stub$Proxy.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d967fe87f176c6c13995a3d0d586790192d1a6bd
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro$Stub.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro$Stub.class.REMOVED.git-id
deleted file mode 100644
index b146a8df..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro$Stub.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2de2f483640913f8c6a265f32207f34228898fd5
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro.class.REMOVED.git-id
deleted file mode 100644
index 59dbc7a6..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistro.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9b984325131098a100ec1237936d4d5fc219f4a7
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback$Stub$Proxy.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback$Stub$Proxy.class.REMOVED.git-id
deleted file mode 100644
index ef3d6048..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback$Stub$Proxy.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2ab52eddb035f944b0cb2a279a9bd1cc0dd1ffd2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback$Stub.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback$Stub.class.REMOVED.git-id
deleted file mode 100644
index 1ffeba6c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback$Stub.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-139d566283e991dd3e8d8456c614763300ca1737
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback.class.REMOVED.git-id
deleted file mode 100644
index c056c893..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/kde/necessitas/ministro/IMinistroCallback.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-61c0129078b6e1714f4dc75ee7838d9789051146
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/BuildConfig.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/BuildConfig.class.REMOVED.git-id
deleted file mode 100644
index 46daf341..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/BuildConfig.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4bed2ddbb0c9e00f7d48e0baee1529ed6ead0563
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$array.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$array.class.REMOVED.git-id
deleted file mode 100644
index ae7ac54c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$array.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ee588922229197e056655f15253143cd727985e0
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$attr.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$attr.class.REMOVED.git-id
deleted file mode 100644
index 7c87f38e..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$attr.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b8079837ab299e64673bab5b0983db23a79a17ce
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$layout.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$layout.class.REMOVED.git-id
deleted file mode 100644
index 70885ed9..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$layout.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fdd228d281a582362f520b9948e530c1a673046b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$mipmap.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$mipmap.class.REMOVED.git-id
deleted file mode 100644
index 3d16956a..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$mipmap.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-69e4741e408a36d0ba20802932365f709a5a6794
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$string.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$string.class.REMOVED.git-id
deleted file mode 100644
index 0061ced7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$string.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6f131c3f47e5060faedfc805fa986f1affff079f
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$xml.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$xml.class.REMOVED.git-id
deleted file mode 100644
index 4d1a8b46..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R$xml.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cb33f62bc902185d43659da6d2985401319c08fa
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R.class.REMOVED.git-id
deleted file mode 100644
index d2fa7515..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/example/Labrador/R.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-79b9abc21964201e35c8814c22150042650528fb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivity.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivity.class.REMOVED.git-id
deleted file mode 100644
index eec5e578..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivity.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-912eec8a6c967bfa68e0753277daa422f72a64fb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$1.class.REMOVED.git-id
deleted file mode 100644
index d95fa5e0..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-41c0bd4cc2f13e55388bf3b6acb775be142a535e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$2.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$2.class.REMOVED.git-id
deleted file mode 100644
index 7b8b3a6c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$2.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-22007d6acebdc831bbfcca73024276d91b1317a0
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$3.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$3.class.REMOVED.git-id
deleted file mode 100644
index e0d284fc..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader$3.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-99174636267ae4ab39f9a5089517e031a5f933f6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader.class.REMOVED.git-id
deleted file mode 100644
index 70e1ab38..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtActivityLoader.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5bb20c93533cd6c05ae79b58ef4720fc5b8deec8
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtApplication$InvokeResult.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtApplication$InvokeResult.class.REMOVED.git-id
deleted file mode 100644
index 3358f8c8..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtApplication$InvokeResult.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b674dee3041cca0891a0683f1e9be3e46aa238c2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtApplication.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtApplication.class.REMOVED.git-id
deleted file mode 100644
index de4f8c71..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtApplication.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4f90a6b9ee29832c3ef0756fa6ba82bf332da2ca
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$1.class.REMOVED.git-id
deleted file mode 100644
index 3f08db71..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2b2abc0e9fec80ab2f2f6c5f1bbf0fc757a920cb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$2.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$2.class.REMOVED.git-id
deleted file mode 100644
index 84195c6e..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$2.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ca085bea1eac1a6572ec4acfdf49938f9ba9a9fb
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3$1$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3$1$1.class.REMOVED.git-id
deleted file mode 100644
index 290d19fd..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3$1$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-feb1da444f93e4ff96e598cdabfb13645a8bb29b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3$1.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3$1.class.REMOVED.git-id
deleted file mode 100644
index c2d25d77..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3$1.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1e9ef9840393874d20a43e89426f167581589297
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3.class.REMOVED.git-id
deleted file mode 100644
index b82bec7c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$3.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f74c0e4e3b6231cb52a04d2c2c03063c5b947267
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$4.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$4.class.REMOVED.git-id
deleted file mode 100644
index 790d0a02..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader$4.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-73525e6cc5251cef7c51dee5300db5536df7edd7
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader.class.REMOVED.git-id
deleted file mode 100644
index cc1d8e75..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtLoader.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-407bed74afd06263dea279117ae0396e0cef2f3a
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtService.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtService.class.REMOVED.git-id
deleted file mode 100644
index e8c13d28..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtService.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f3c0b5ccbff0ec989f58f042a5b513426cbb2ab7
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtServiceLoader.class.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtServiceLoader.class.REMOVED.git-id
deleted file mode 100644
index 56ce0451..00000000
--- a/Desktop_Interface/android-build/build/intermediates/classes/release/org/qtproject/qt5/android/bindings/QtServiceLoader.class.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-baaa8fa744cb749bdb53b2cf16205f3e7899da8c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/dex-cache/cache.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/dex-cache/cache.xml.REMOVED.git-id
deleted file mode 100644
index bfb3ec55..00000000
--- a/Desktop_Interface/android-build/build/intermediates/dex-cache/cache.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9902f3c9aa0db74396ef8f20d161f3b67b044065
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/dex/debug/classes.dex.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/dex/debug/classes.dex.REMOVED.git-id
deleted file mode 100644
index d7898283..00000000
--- a/Desktop_Interface/android-build/build/intermediates/dex/debug/classes.dex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c46860bfbc6ebf6922abc1ea9e4862b5d24d2c81
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/dex/release/classes.dex.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/dex/release/classes.dex.REMOVED.git-id
deleted file mode 100644
index 72aef77e..00000000
--- a/Desktop_Interface/android-build/build/intermediates/dex/release/classes.dex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e88580a8e13bdde2aa5dc5fa28dc28a4079bb94f
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/incremental/aidl/debug/dependency.store.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/incremental/aidl/debug/dependency.store.REMOVED.git-id
deleted file mode 100644
index 0c7a7bf4..00000000
--- a/Desktop_Interface/android-build/build/intermediates/incremental/aidl/debug/dependency.store.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9b36a1d84ab9847f5eb192858b8ae91118cd4786
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/incremental/aidl/release/dependency.store.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/incremental/aidl/release/dependency.store.REMOVED.git-id
deleted file mode 100644
index 19140ac6..00000000
--- a/Desktop_Interface/android-build/build/intermediates/incremental/aidl/release/dependency.store.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-27bf3a92b9bdede03ca3b7cda1eab194aee55049
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/incremental/mergeAssets/debug/merger.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/incremental/mergeAssets/debug/merger.xml.REMOVED.git-id
deleted file mode 100644
index b20ebae1..00000000
--- a/Desktop_Interface/android-build/build/intermediates/incremental/mergeAssets/debug/merger.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1f23bacbf0053cae88d8fccec13833426b40d820
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/incremental/mergeAssets/release/merger.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/incremental/mergeAssets/release/merger.xml.REMOVED.git-id
deleted file mode 100644
index 7867290c..00000000
--- a/Desktop_Interface/android-build/build/intermediates/incremental/mergeAssets/release/merger.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9e342ac1cc19a2e35d715ff7e6e9af09ed871669
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/incremental/mergeResources/debug/merger.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/incremental/mergeResources/debug/merger.xml.REMOVED.git-id
deleted file mode 100644
index 51b18c7d..00000000
--- a/Desktop_Interface/android-build/build/intermediates/incremental/mergeResources/debug/merger.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-891d7434b3364e9c02ecc72fae0aeecce6d00a52
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/incremental/mergeResources/release/merger.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/incremental/mergeResources/release/merger.xml.REMOVED.git-id
deleted file mode 100644
index 9cd1f528..00000000
--- a/Desktop_Interface/android-build/build/intermediates/incremental/mergeResources/release/merger.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-631cf9235bc0c89991a133bce19bb3a19a59f85b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/javaResources/debug/androidInterface.java.bak.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/javaResources/debug/androidInterface.java.bak.REMOVED.git-id
deleted file mode 100644
index eef66601..00000000
--- a/Desktop_Interface/android-build/build/intermediates/javaResources/debug/androidInterface.java.bak.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d480bb2df3c38016e18106ba7afcf4d4bfb6c05c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/javaResources/release/androidInterface.java.bak.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/javaResources/release/androidInterface.java.bak.REMOVED.git-id
deleted file mode 100644
index eef66601..00000000
--- a/Desktop_Interface/android-build/build/intermediates/javaResources/release/androidInterface.java.bak.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d480bb2df3c38016e18106ba7afcf4d4bfb6c05c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/manifests/full/debug/AndroidManifest.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/manifests/full/debug/AndroidManifest.xml.REMOVED.git-id
deleted file mode 100644
index 32f9d769..00000000
--- a/Desktop_Interface/android-build/build/intermediates/manifests/full/debug/AndroidManifest.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2102faad13c502de1a54217210497edc0e0ea5ce
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/manifests/full/release/AndroidManifest.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/manifests/full/release/AndroidManifest.xml.REMOVED.git-id
deleted file mode 100644
index 8e59b3e2..00000000
--- a/Desktop_Interface/android-build/build/intermediates/manifests/full/release/AndroidManifest.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0838648bc861807d54426955e39a5449c956cfc0
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/pre-dexed/debug/QtAndroid-bundled-b9c529ec9bda4b335b762db89d9dac573a70dd33.jar.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/pre-dexed/debug/QtAndroid-bundled-b9c529ec9bda4b335b762db89d9dac573a70dd33.jar.REMOVED.git-id
deleted file mode 100644
index 8c5fdbdf..00000000
--- a/Desktop_Interface/android-build/build/intermediates/pre-dexed/debug/QtAndroid-bundled-b9c529ec9bda4b335b762db89d9dac573a70dd33.jar.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cc29800de5ea48f5fa34e36e9969a9ebca59d651
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/pre-dexed/release/QtAndroid-bundled-b9c529ec9bda4b335b762db89d9dac573a70dd33.jar.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/pre-dexed/release/QtAndroid-bundled-b9c529ec9bda4b335b762db89d9dac573a70dd33.jar.REMOVED.git-id
deleted file mode 100644
index 8c5fdbdf..00000000
--- a/Desktop_Interface/android-build/build/intermediates/pre-dexed/release/QtAndroid-bundled-b9c529ec9bda4b335b762db89d9dac573a70dd33.jar.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cc29800de5ea48f5fa34e36e9969a9ebca59d651
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/layout/splash.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/layout/splash.xml.REMOVED.git-id
deleted file mode 100644
index d47d8329..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/layout/splash.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-bbcdbcf9358d098f5b0654e5f03311c51106b206
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-hdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-hdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index c7daa9fd..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-hdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a5ce000735148378b67ee4c30bf1cea0cccc4349
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-mdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-mdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 3f83a048..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-mdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3855f30983948e1bfaa6b34521df2f1e22d2f59a
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xhdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xhdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 7a745930..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xhdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2ad602aba497cefd0198b575eec95333ce69d260
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xxhdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xxhdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 52799fdc..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xxhdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fc64d1478f59df3ba65a30ef59a75d68135d1f87
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xxxhdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xxxhdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 684875ff..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/mipmap-xxxhdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3865922c76aecd53a7915d3b10c1d5bc10d6ce79
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-de/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-de/values.xml.REMOVED.git-id
deleted file mode 100644
index 46777659..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-de/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-23012317b98823932eddddff8a304d892c6f045d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-el/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-el/values.xml.REMOVED.git-id
deleted file mode 100644
index 744f44d5..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-el/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6acb6e1fbce3c6173ae4f6c067f2f9faf4bad9ea
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-es/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-es/values.xml.REMOVED.git-id
deleted file mode 100644
index 1470a9ac..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-es/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-02950f8544454faa3262264fdd63deec71d655b4
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-et/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-et/values.xml.REMOVED.git-id
deleted file mode 100644
index 42c117ac..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-et/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0e2a304fd69848f0ae0fb146757c7fcc46c71d89
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-fa/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-fa/values.xml.REMOVED.git-id
deleted file mode 100644
index 89f1abe0..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-fa/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0392c5e0e9384af0750c1afc4b2cddf0cda9c235
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-fr/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-fr/values.xml.REMOVED.git-id
deleted file mode 100644
index 4c183faf..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-fr/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e9de8fde48d871953060d775cd682be29ec4e678
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-id/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-id/values.xml.REMOVED.git-id
deleted file mode 100644
index fa6bd918..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-id/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9db35bd36e22de1ddc48264fcd1f5680f4c14d9d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-it/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-it/values.xml.REMOVED.git-id
deleted file mode 100644
index b543c196..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-it/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-baa4c911a5312301560b002ceac7c08fdeb40f34
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ja/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-ja/values.xml.REMOVED.git-id
deleted file mode 100644
index b38675e7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ja/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-126bb19db5fa10567349895c78ce89e2d8961a9e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ms/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-ms/values.xml.REMOVED.git-id
deleted file mode 100644
index 26b9b2be..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ms/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f9998e728aa896c9e30e04fb152fd7f04eef4661
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-nb/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-nb/values.xml.REMOVED.git-id
deleted file mode 100644
index 6224fc7a..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-nb/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9ac6fd4f55f9895291cc98a2c5ccbdfe03801cd6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-nl/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-nl/values.xml.REMOVED.git-id
deleted file mode 100644
index 16601f39..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-nl/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0309e2f2cfc7788ec0fd4ed460188906f19a598c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-pl/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-pl/values.xml.REMOVED.git-id
deleted file mode 100644
index c71cead8..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-pl/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-71c05dcb9f5788ca9e802ecb7159398a2876da28
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-pt-rBR/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-pt-rBR/values.xml.REMOVED.git-id
deleted file mode 100644
index f94b530e..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-pt-rBR/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b4e81cb1110bf993c9385c24d0eb8f758eb3e4ef
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ro/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-ro/values.xml.REMOVED.git-id
deleted file mode 100644
index fe9479bf..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ro/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d362fe441f759508f0bff2f7836e438385922ce3
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-rs/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-rs/values.xml.REMOVED.git-id
deleted file mode 100644
index 011ee155..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-rs/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-76081f051c22c5ef954bc3a9f25300a26ca9c0c6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ru/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-ru/values.xml.REMOVED.git-id
deleted file mode 100644
index 90e72ed7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-ru/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-278b97a1dc4010aab6d1ac8ae222ea5cd7d8e9d1
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-zh-rCN/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-zh-rCN/values.xml.REMOVED.git-id
deleted file mode 100644
index e63e4f38..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-zh-rCN/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-70e8c5714c6300eea0aab665436f9a5cd54a5863
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values-zh-rTW/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values-zh-rTW/values.xml.REMOVED.git-id
deleted file mode 100644
index 63e6fa59..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values-zh-rTW/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae0cfff5840ecb70fe8b34f7986def541b7d31b2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/values/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/values/values.xml.REMOVED.git-id
deleted file mode 100644
index ae1d6054..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/values/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d2b9d11feacc6e7a2a5d4c1015a29f19d56df850
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/debug/xml/device_filter.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/debug/xml/device_filter.xml.REMOVED.git-id
deleted file mode 100644
index 4c8913bb..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/debug/xml/device_filter.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a8c50fdce6cf3cfcfadf2c44cbef9579ee10b9c4
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/layout/splash.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/layout/splash.xml.REMOVED.git-id
deleted file mode 100644
index d47d8329..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/layout/splash.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-bbcdbcf9358d098f5b0654e5f03311c51106b206
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-hdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-hdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index c7daa9fd..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-hdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a5ce000735148378b67ee4c30bf1cea0cccc4349
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-mdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-mdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 3f83a048..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-mdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3855f30983948e1bfaa6b34521df2f1e22d2f59a
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xhdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xhdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 7a745930..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xhdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2ad602aba497cefd0198b575eec95333ce69d260
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xxhdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xxhdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 52799fdc..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xxhdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fc64d1478f59df3ba65a30ef59a75d68135d1f87
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xxxhdpi-v4/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xxxhdpi-v4/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 684875ff..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/mipmap-xxxhdpi-v4/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3865922c76aecd53a7915d3b10c1d5bc10d6ce79
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-de/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-de/values.xml.REMOVED.git-id
deleted file mode 100644
index 46777659..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-de/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-23012317b98823932eddddff8a304d892c6f045d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-el/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-el/values.xml.REMOVED.git-id
deleted file mode 100644
index 744f44d5..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-el/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6acb6e1fbce3c6173ae4f6c067f2f9faf4bad9ea
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-es/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-es/values.xml.REMOVED.git-id
deleted file mode 100644
index 1470a9ac..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-es/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-02950f8544454faa3262264fdd63deec71d655b4
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-et/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-et/values.xml.REMOVED.git-id
deleted file mode 100644
index 42c117ac..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-et/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0e2a304fd69848f0ae0fb146757c7fcc46c71d89
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-fa/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-fa/values.xml.REMOVED.git-id
deleted file mode 100644
index 89f1abe0..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-fa/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0392c5e0e9384af0750c1afc4b2cddf0cda9c235
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-fr/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-fr/values.xml.REMOVED.git-id
deleted file mode 100644
index 4c183faf..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-fr/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e9de8fde48d871953060d775cd682be29ec4e678
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-id/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-id/values.xml.REMOVED.git-id
deleted file mode 100644
index fa6bd918..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-id/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9db35bd36e22de1ddc48264fcd1f5680f4c14d9d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-it/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-it/values.xml.REMOVED.git-id
deleted file mode 100644
index b543c196..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-it/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-baa4c911a5312301560b002ceac7c08fdeb40f34
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-ja/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-ja/values.xml.REMOVED.git-id
deleted file mode 100644
index b38675e7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-ja/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-126bb19db5fa10567349895c78ce89e2d8961a9e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-ms/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-ms/values.xml.REMOVED.git-id
deleted file mode 100644
index 26b9b2be..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-ms/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f9998e728aa896c9e30e04fb152fd7f04eef4661
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-nb/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-nb/values.xml.REMOVED.git-id
deleted file mode 100644
index 6224fc7a..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-nb/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9ac6fd4f55f9895291cc98a2c5ccbdfe03801cd6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-nl/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-nl/values.xml.REMOVED.git-id
deleted file mode 100644
index 16601f39..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-nl/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0309e2f2cfc7788ec0fd4ed460188906f19a598c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-pl/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-pl/values.xml.REMOVED.git-id
deleted file mode 100644
index c71cead8..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-pl/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-71c05dcb9f5788ca9e802ecb7159398a2876da28
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-pt-rBR/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-pt-rBR/values.xml.REMOVED.git-id
deleted file mode 100644
index f94b530e..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-pt-rBR/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b4e81cb1110bf993c9385c24d0eb8f758eb3e4ef
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-ro/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-ro/values.xml.REMOVED.git-id
deleted file mode 100644
index fe9479bf..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-ro/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d362fe441f759508f0bff2f7836e438385922ce3
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-rs/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-rs/values.xml.REMOVED.git-id
deleted file mode 100644
index 011ee155..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-rs/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-76081f051c22c5ef954bc3a9f25300a26ca9c0c6
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-ru/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-ru/values.xml.REMOVED.git-id
deleted file mode 100644
index 90e72ed7..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-ru/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-278b97a1dc4010aab6d1ac8ae222ea5cd7d8e9d1
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-zh-rCN/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-zh-rCN/values.xml.REMOVED.git-id
deleted file mode 100644
index e63e4f38..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-zh-rCN/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-70e8c5714c6300eea0aab665436f9a5cd54a5863
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values-zh-rTW/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values-zh-rTW/values.xml.REMOVED.git-id
deleted file mode 100644
index 63e6fa59..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values-zh-rTW/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae0cfff5840ecb70fe8b34f7986def541b7d31b2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/values/values.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/values/values.xml.REMOVED.git-id
deleted file mode 100644
index ae1d6054..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/values/values.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d2b9d11feacc6e7a2a5d4c1015a29f19d56df850
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/res/release/xml/device_filter.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/res/release/xml/device_filter.xml.REMOVED.git-id
deleted file mode 100644
index 4c8913bb..00000000
--- a/Desktop_Interface/android-build/build/intermediates/res/release/xml/device_filter.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a8c50fdce6cf3cfcfadf2c44cbef9579ee10b9c4
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/resources/resources-debug.ap_.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/resources/resources-debug.ap_.REMOVED.git-id
deleted file mode 100644
index 2e1fd371..00000000
--- a/Desktop_Interface/android-build/build/intermediates/resources/resources-debug.ap_.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-45f660b83b38ec4bcc075f84a6d17299182ce316
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/intermediates/resources/resources-release.ap_.REMOVED.git-id b/Desktop_Interface/android-build/build/intermediates/resources/resources-release.ap_.REMOVED.git-id
deleted file mode 100644
index 764372d4..00000000
--- a/Desktop_Interface/android-build/build/intermediates/resources/resources-release.ap_.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f27a42edad0dd0ced364750ff9ea93ef1263eaf3
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/apk/android-build-debug-unaligned.apk.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/apk/android-build-debug-unaligned.apk.REMOVED.git-id
deleted file mode 100644
index 0281b941..00000000
--- a/Desktop_Interface/android-build/build/outputs/apk/android-build-debug-unaligned.apk.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2064c69c7e6cf71ccd20533871ae9bba46f75aa7
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/apk/android-build-debug.apk.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/apk/android-build-debug.apk.REMOVED.git-id
deleted file mode 100644
index ad52c304..00000000
--- a/Desktop_Interface/android-build/build/outputs/apk/android-build-debug.apk.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8cd0ffc74763728b9e4d6e3b37105af093c85828
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/apk/android-build-release-signed - Copy.zip.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/apk/android-build-release-signed - Copy.zip.REMOVED.git-id
deleted file mode 100644
index ae828676..00000000
--- a/Desktop_Interface/android-build/build/outputs/apk/android-build-release-signed - Copy.zip.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2d3de438c39797d9b7f8e60b17d789965c280de1
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/apk/android-build-release-signed.apk.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/apk/android-build-release-signed.apk.REMOVED.git-id
deleted file mode 100644
index 68a04e99..00000000
--- a/Desktop_Interface/android-build/build/outputs/apk/android-build-release-signed.apk.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-86f5990ef19030f71c42e2d7ac55f080967ec1d9
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal.html.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal.html.REMOVED.git-id
deleted file mode 100644
index 3630ae82..00000000
--- a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal.html.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ac09e7b2e66b85cac37a4e2ae02b3eadfd0fe32d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal.xml.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal.xml.REMOVED.git-id
deleted file mode 100644
index 5b2a5ea2..00000000
--- a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1eb416706f2416b63c412ed2ae392ab7b9c118ea
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/Thumbs.db.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/Thumbs.db.REMOVED.git-id
deleted file mode 100644
index 496c6cda..00000000
--- a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/Thumbs.db.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-aae6e4d0c2d79d8add15d0557a4a3f80e516822b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/hololike.css.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/hololike.css.REMOVED.git-id
deleted file mode 100644
index e14ea2cf..00000000
--- a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/hololike.css.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-09645da18f6aec634b5a71a22e7bc48ae9eea89d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-error.png.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-error.png.REMOVED.git-id
deleted file mode 100644
index 27f53071..00000000
--- a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-error.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fb4c982a3856185b9ec75ac1427237bb195c983f
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-run.png.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-run.png.REMOVED.git-id
deleted file mode 100644
index 5131f946..00000000
--- a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-run.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d1a074b005303ef1202e023c9fda99b8bca2b591
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-warning.png.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-warning.png.REMOVED.git-id
deleted file mode 100644
index b4c17955..00000000
--- a/Desktop_Interface/android-build/build/outputs/lint-results-release-fatal_files/lint-warning.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3960cddb508b0947d0bb2c46cfd42f23b4f7e432
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/logs/manifest-merger-debug-report.txt.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/logs/manifest-merger-debug-report.txt.REMOVED.git-id
deleted file mode 100644
index bd05791e..00000000
--- a/Desktop_Interface/android-build/build/outputs/logs/manifest-merger-debug-report.txt.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cd8ce92fc8d247842915acfbb589338627f11e52
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/build/outputs/logs/manifest-merger-release-report.txt.REMOVED.git-id b/Desktop_Interface/android-build/build/outputs/logs/manifest-merger-release-report.txt.REMOVED.git-id
deleted file mode 100644
index bd05791e..00000000
--- a/Desktop_Interface/android-build/build/outputs/logs/manifest-merger-release-report.txt.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cd8ce92fc8d247842915acfbb589338627f11e52
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/gradle.properties.REMOVED.git-id b/Desktop_Interface/android-build/gradle.properties.REMOVED.git-id
deleted file mode 100644
index 66711434..00000000
--- a/Desktop_Interface/android-build/gradle.properties.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-63ee31e483c9f8872d9b74af50307d1c6e294f74
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/gradle.properties~.REMOVED.git-id b/Desktop_Interface/android-build/gradle.properties~.REMOVED.git-id
deleted file mode 100644
index 9341d3fd..00000000
--- a/Desktop_Interface/android-build/gradle.properties~.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9079463055754018dedc3bb1863c806547f78eac
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.jar.REMOVED.git-id b/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.jar.REMOVED.git-id
deleted file mode 100644
index 382c51d0..00000000
--- a/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.jar.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8c0fb64a8698b08ecc4158d828ca593c4928e9dd
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.properties.REMOVED.git-id b/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.properties.REMOVED.git-id
deleted file mode 100644
index 6ea1c853..00000000
--- a/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.properties.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0c71e760dc93830dd3411fe50d6f5c86bf0a8f4d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.properties~.REMOVED.git-id b/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.properties~.REMOVED.git-id
deleted file mode 100644
index ba902396..00000000
--- a/Desktop_Interface/android-build/gradle/wrapper/gradle-wrapper.properties~.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1e61d1fd3a9bc5be8381127e4d6457cf08e7c473
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/gradlew.REMOVED.git-id b/Desktop_Interface/android-build/gradlew.REMOVED.git-id
deleted file mode 100644
index 48aa526b..00000000
--- a/Desktop_Interface/android-build/gradlew.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-91a7e269e19dfc62e27137a0b57ef3e430cee4fd
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/gradlew.bat.REMOVED.git-id b/Desktop_Interface/android-build/gradlew.bat.REMOVED.git-id
deleted file mode 100644
index c1b45adf..00000000
--- a/Desktop_Interface/android-build/gradlew.bat.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8a0b282aa6885fb573c106b3551f7275c5f17e8e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/QtAndroid-bundled.jar.REMOVED.git-id b/Desktop_Interface/android-build/libs/QtAndroid-bundled.jar.REMOVED.git-id
deleted file mode 100644
index 79b00782..00000000
--- a/Desktop_Interface/android-build/libs/QtAndroid-bundled.jar.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-be92d82794019f435865611424791d4dca681797
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libLabrador.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libLabrador.so.REMOVED.git-id
deleted file mode 100644
index 2e1d1875..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libLabrador.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ad4f4cc72bdeaa9d80fb039f73c04e82c79d6603
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5AndroidExtras.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5AndroidExtras.so.REMOVED.git-id
deleted file mode 100644
index bc3c58f3..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5AndroidExtras.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4bb9403e79d99fd2f28a974e5627ca37efc25d59
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Core.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Core.so.REMOVED.git-id
deleted file mode 100644
index 6d44bd4b..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Core.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6efb1e6ff77edf436adaa6a74b0ccf76a1c8f4b8
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Gui.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Gui.so.REMOVED.git-id
deleted file mode 100644
index 8671ea52..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Gui.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4389f212f89439e7bdf7f7a9960350e5cc698560
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5PrintSupport.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5PrintSupport.so.REMOVED.git-id
deleted file mode 100644
index d5469bcc..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5PrintSupport.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-dc1e1fc88e8330ccfc916be0f6037caee74fc94b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Widgets.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Widgets.so.REMOVED.git-id
deleted file mode 100644
index c9c17e17..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libQt5Widgets.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a02508dfea1044de0c75d3b512be7e6f1e4b6489
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libdfuprog-0.9.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libdfuprog-0.9.so.REMOVED.git-id
deleted file mode 100644
index 3c7825a1..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libdfuprog-0.9.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e94f13a61a2e935d741e43fd3a461fb5d3f3fb02
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libgnustl_shared.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libgnustl_shared.so.REMOVED.git-id
deleted file mode 100644
index 9f4e0a74..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libgnustl_shared.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c57710f8e86044362042bd1106a4f57c0eb18106
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/liblog.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/liblog.so.REMOVED.git-id
deleted file mode 100644
index 27f455e0..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/liblog.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e21eb593c8f46df7d5a411f18f292dbb096a9253
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqdds.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqdds.so.REMOVED.git-id
deleted file mode 100644
index 3fec4522..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqdds.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7f98aef83e6d5130830e863fb77ec1e14f4c7d28
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqgif.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqgif.so.REMOVED.git-id
deleted file mode 100644
index 669b75dd..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqgif.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-77831a8d03848d2daa6beda012b761115dc6e9bc
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqicns.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqicns.so.REMOVED.git-id
deleted file mode 100644
index f4e02606..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqicns.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2de8c1a72233512477ba8a20688736da6a3449c3
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqico.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqico.so.REMOVED.git-id
deleted file mode 100644
index 7857e3f6..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqico.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6d6a9c78842828078439fdedbb8ca58149e579b2
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqjpeg.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqjpeg.so.REMOVED.git-id
deleted file mode 100644
index a67dce5c..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqjpeg.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-03fb41aeef0113868a97d6acedaaddb1eaf85916
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqtga.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqtga.so.REMOVED.git-id
deleted file mode 100644
index 4bb1790d..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqtga.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-067f95f26b8f4cced9c25c459e283ecf9a47a935
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqtiff.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqtiff.so.REMOVED.git-id
deleted file mode 100644
index ce970fec..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqtiff.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-de3e06b102027089ed7ab5626ead99023b9715fa
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqwbmp.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqwbmp.so.REMOVED.git-id
deleted file mode 100644
index 2dfa6e4a..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqwbmp.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8a245fbb98c669162514cd668d4a65968b288e52
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqwebp.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqwebp.so.REMOVED.git-id
deleted file mode 100644
index 59ea6210..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_imageformats_libqwebp.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3afd7ce0688807897026e3ffa9844ba3cdc47c4b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_platforms_android_libqtforandroid.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_platforms_android_libqtforandroid.so.REMOVED.git-id
deleted file mode 100644
index 51f9cd97..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libplugins_platforms_android_libqtforandroid.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-58a5e10bd6820c57c22a4ffaec83e43c86862f75
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/libs/armeabi-v7a/libusb1.0.so.REMOVED.git-id b/Desktop_Interface/android-build/libs/armeabi-v7a/libusb1.0.so.REMOVED.git-id
deleted file mode 100644
index 2e8bcfd7..00000000
--- a/Desktop_Interface/android-build/libs/armeabi-v7a/libusb1.0.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ffddb4b3cece1f758e4971f6932f19562175acd1
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/local.properties.REMOVED.git-id b/Desktop_Interface/android-build/local.properties.REMOVED.git-id
deleted file mode 100644
index 295a42d1..00000000
--- a/Desktop_Interface/android-build/local.properties.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-bb31d8d515c7d6398acf79ecbf1057851497d820
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/local.properties~.REMOVED.git-id b/Desktop_Interface/android-build/local.properties~.REMOVED.git-id
deleted file mode 100644
index 22db0449..00000000
--- a/Desktop_Interface/android-build/local.properties~.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-342f07a9359a44af35a48bdb989ab7d640378c5e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/Thumbs.db.REMOVED.git-id b/Desktop_Interface/android-build/res/Thumbs.db.REMOVED.git-id
deleted file mode 100644
index cc424b7a..00000000
--- a/Desktop_Interface/android-build/res/Thumbs.db.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-728c7c09f66a1c1c54ac921895b5bda14a21d55b
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/mipmap-hdpi/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/res/mipmap-hdpi/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 7b387687..00000000
--- a/Desktop_Interface/android-build/res/mipmap-hdpi/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b77d2db15ac66d272f411892fef5dc78f1a334ec
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/mipmap-mdpi/Thumbs.db.REMOVED.git-id b/Desktop_Interface/android-build/res/mipmap-mdpi/Thumbs.db.REMOVED.git-id
deleted file mode 100644
index 770c6a93..00000000
--- a/Desktop_Interface/android-build/res/mipmap-mdpi/Thumbs.db.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9ce77f46f29740353189bbb1961626c4a537455a
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/mipmap-mdpi/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/res/mipmap-mdpi/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 45e1c039..00000000
--- a/Desktop_Interface/android-build/res/mipmap-mdpi/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-85c704a8fa459a34d512155668563e8eb7986ea8
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/mipmap-xhdpi/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/res/mipmap-xhdpi/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 8673d8db..00000000
--- a/Desktop_Interface/android-build/res/mipmap-xhdpi/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-872eabdbf53fbc6155a1f08711874f0a4e343b16
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/mipmap-xxhdpi/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/res/mipmap-xxhdpi/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index c5041fc2..00000000
--- a/Desktop_Interface/android-build/res/mipmap-xxhdpi/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e6058385db5d994fcc73681590faa55bcce4119e
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/mipmap-xxxhdpi/Thumbs.db.REMOVED.git-id b/Desktop_Interface/android-build/res/mipmap-xxxhdpi/Thumbs.db.REMOVED.git-id
deleted file mode 100644
index 5e30c8cf..00000000
--- a/Desktop_Interface/android-build/res/mipmap-xxxhdpi/Thumbs.db.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6678b8f4b15e3a0c94fa71d1445d9a6641827f95
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/mipmap-xxxhdpi/ic_launcher.png.REMOVED.git-id b/Desktop_Interface/android-build/res/mipmap-xxxhdpi/ic_launcher.png.REMOVED.git-id
deleted file mode 100644
index 50284b7d..00000000
--- a/Desktop_Interface/android-build/res/mipmap-xxxhdpi/ic_launcher.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2b287a9164a0e2f7e7914bf9abbdbcd17f217513
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/values/libs.xml.REMOVED.git-id b/Desktop_Interface/android-build/res/values/libs.xml.REMOVED.git-id
deleted file mode 100644
index 3cb9f097..00000000
--- a/Desktop_Interface/android-build/res/values/libs.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-65185e735aa589e7ff5f51c8b231a72b7151d14c
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/web_hi_res_512.png.REMOVED.git-id b/Desktop_Interface/android-build/res/web_hi_res_512.png.REMOVED.git-id
deleted file mode 100644
index 0abefa4f..00000000
--- a/Desktop_Interface/android-build/res/web_hi_res_512.png.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-893eebc776c2d6f520d41af0b4d8075a9c99716d
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/res/xml/device_filter.xml.REMOVED.git-id b/Desktop_Interface/android-build/res/xml/device_filter.xml.REMOVED.git-id
deleted file mode 100644
index 436375a5..00000000
--- a/Desktop_Interface/android-build/res/xml/device_filter.xml.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-5d9a80593045cdda9d8316eba096bb3c5823100a
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/src/androidInterface.java.REMOVED.git-id b/Desktop_Interface/android-build/src/androidInterface.java.REMOVED.git-id
deleted file mode 100644
index 86600d3e..00000000
--- a/Desktop_Interface/android-build/src/androidInterface.java.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7caea66ab4cc45a43869b1c24c948cc768c57811
\ No newline at end of file
diff --git a/Desktop_Interface/android-build/src/androidInterface.java.bak.REMOVED.git-id b/Desktop_Interface/android-build/src/androidInterface.java.bak.REMOVED.git-id
deleted file mode 100644
index eef66601..00000000
--- a/Desktop_Interface/android-build/src/androidInterface.java.bak.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d480bb2df3c38016e18106ba7afcf4d4bfb6c05c
\ No newline at end of file
diff --git a/Desktop_Interface/android-libLabrador.so-deployment-settings.json.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/android-libLabrador.so-deployment-settings.json.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index bbc01add..00000000
--- a/Desktop_Interface/android-libLabrador.so-deployment-settings.json.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9bd7b7cc07c06a8eb01b5c18940597965f1d10ef
\ No newline at end of file
diff --git a/Desktop_Interface/androidusbdriver.cpp b/Desktop_Interface/androidusbdriver.cpp
new file mode 100644
index 00000000..ef7ea3b8
--- /dev/null
+++ b/Desktop_Interface/androidusbdriver.cpp
@@ -0,0 +1,274 @@
+#include "androidusbdriver.h"
+#include "QStandardPaths"
+
+androidUsbDriver::androidUsbDriver(QWidget *parent) : unixUsbDriver(parent)
+{
+ qDebug() << "androidUsbDriver object created!";
+ mainActivity = QtAndroid::androidActivity();
+}
+
+androidUsbDriver::~androidUsbDriver(void){
+ qDebug() << "\n\nandroidUsbDriver destructor ran!";
+ mainActivity.callMethod("closeDevice");
+}
+
+unsigned char androidUsbDriver::usbInit(unsigned long VIDin, unsigned long PIDin){
+ qDebug() << "Entering androidUsbDriver::usbInit";
+
+ mainActivity.callMethod("nonStaticTest");
+
+ qDebug() << "If you cannot see 'nonStaticTest' above, then the _______JAVA CLASS DOES NOT EXIST____";
+
+
+ mainActivity.callMethod("findDevice");
+
+ //QAndroidJniObject usbfs_path_java = mainActivity.getObjectField("usbfs_path");
+ //QString usbfs_path_qstring = usbfs_path_java.toString();
+ //char *usbfs_path = usbfs_path_qstring.toUtf8().data();
+
+ QAndroidJniObject usbfs_path_java = mainActivity.getObjectField("usbfs_path");
+ QString usbfs_path_qstring = usbfs_path_java.toString();
+ std::string usbfs_path_stdstr = usbfs_path_qstring.toStdString();
+ char usbfs_path[128];
+ strcpy(usbfs_path, usbfs_path_stdstr.c_str());
+
+ jint file_descriptor_java = mainActivity.getField("file_descriptor");
+ int file_descriptor = (int)file_descriptor_java;
+
+ qDebug() << "usbfs path = " << usbfs_path;
+ qDebug() << "file descriptor = " << file_descriptor;
+
+ if(file_descriptor == -69){
+ qDebug() << "DEVICE NOT DETECTED";
+ return -69;
+ }
+
+ int error = libusb_init(&ctx);
+ if(error){
+ qDebug() << "libusb_init FAILED";
+ return error;
+ } else qDebug() << "Libusb context initialised";
+
+ libusb_set_debug(ctx, 3);
+
+ qDebug() << "Opening Device!";
+ libusb_device * device_ptr = libusb_get_device2(ctx, usbfs_path);
+ error = libusb_open2(device_ptr, &handle, file_descriptor);
+ if(error){
+ qDebug() << "ERROR OPENING DEVICE";
+ return error;
+ }
+ qDebug() << "Device Found!!";
+ /*qDebug("Looking for device %x:%x", VIDin, PIDin);
+ handle = libusb_open_device_with_vid_pid(ctx, VIDin, PIDin);
+ if(handle==NULL){
+ qDebug() << "DEVICE NOT FOUND";
+ return -1;
+ }
+ qDebug() << "Device found!!";
+*/
+ qDebug() << (libusb_kernel_driver_active(handle, 0) ? "KERNEL DRIVER ACTIVE" : "KERNEL DRIVER INACTIVE");
+ if(libusb_kernel_driver_active(handle, 0)){
+ libusb_detach_kernel_driver(handle, 0);
+ }
+ error = libusb_claim_interface(handle, 0);
+ if(error){
+ qDebug() << "libusb_claim_interface FAILED";
+ qDebug() << "ERROR" << error << libusb_error_name(error);
+ return error;
+ } else qDebug() << "Interface claimed!";
+
+ return 0;
+}
+
+int androidUsbDriver::get_new_bootloader_ctx(libusb_device **device_ptr, libusb_device_handle **handle, libusb_context **ctx){
+
+ *(ctx) = NULL;
+ *(handle) = NULL;
+ *(device_ptr) = NULL;
+
+ mainActivity.callMethod("closeDevice");
+ //Find device in Java
+ mainActivity.callMethod("findDevice_bootloader");
+ QAndroidJniObject usbfs_path_java = mainActivity.getObjectField("usbfs_path");
+ QString usbfs_path_qstring = usbfs_path_java.toString();
+ std::string usbfs_path_stdstr = usbfs_path_qstring.toStdString();
+ char usbfs_path[128];
+ strcpy(usbfs_path, usbfs_path_stdstr.c_str());
+ jint file_descriptor_java = mainActivity.getField("file_descriptor");
+ int file_descriptor = (int)file_descriptor_java;
+
+ qDebug() << "usbfs path = " << usbfs_path;
+ qDebug() << "file descriptor = " << file_descriptor;
+
+ //Initialise libusb-martin-kuldeep
+ int error = libusb_init(ctx);
+ if(error){
+ qDebug() << "libusb_init FAILED";
+ return error;
+ } else qDebug() << "Libusb context initialised";
+
+ libusb_set_debug(*(ctx), 3);
+
+ qDebug() << "Opening Device!";
+ *(device_ptr) = libusb_get_device2(*(ctx), usbfs_path);
+
+ error = libusb_open2(*(device_ptr), handle, file_descriptor);
+ if(error){
+ qDebug() << "ERROR OPENING DEVICE";
+ return error;
+ }
+ qDebug() << "Device Found!!";
+ /*qDebug("Looking for device %x:%x", VIDin, PIDin);
+ handle = libusb_open_device_with_vid_pid(ctx, VIDin, PIDin);
+ if(handle==NULL){
+ qDebug() << "DEVICE NOT FOUND";
+ return -1;
+ }
+ qDebug() << "Device found!!";
+*/
+ qDebug() << (libusb_kernel_driver_active(*(handle), 0) ? "KERNEL DRIVER ACTIVE" : "KERNEL DRIVER INACTIVE");
+ if(libusb_kernel_driver_active(*(handle), 0)){
+ libusb_detach_kernel_driver(*(handle), 0);
+ }
+ error = libusb_claim_interface(*(handle), 0);
+ if(error){
+ qDebug() << "libusb_claim_interface FAILED";
+ qDebug() << "ERROR" << error << libusb_error_name(error);
+ return error;
+ } else qDebug() << "Interface claimed!";
+
+ return 0;
+}
+
+int androidUsbDriver::flashFirmware(void){
+
+ //File name
+ char fname[128];
+ qDebug() << "\n\n\n\n\n\n\n\nFIRMWARE MISMATCH!!!! FLASHING....\n\n\n\n\n\n\n";
+ sprintf(fname, "assets:/firmware/labrafirm_%04x_%02x.hex", EXPECTED_FIRMWARE_VERSION, DEFINED_EXPECTED_VARIANT);
+ qDebug() << "FLASHING " << fname;
+
+ //Copy to somewhere that fopen can access
+ QFile asset_file(fname);
+ qDebug() << "asset_file.exists()" << asset_file.exists();
+ QString filePath = QStandardPaths::writableLocation( QStandardPaths::StandardLocation::AppLocalDataLocation );
+ filePath.append( "/firmware.hex");
+ if (asset_file.exists()) {
+ if( QFile::exists( filePath ) )
+ QFile::remove( filePath );
+
+ if( asset_file.copy( filePath ) ){
+ QFile::setPermissions( filePath, QFile::WriteOwner | QFile::ReadOwner );
+ qDebug() << "firmware temp file copied to" << filePath;
+ }
+ } else qDebug() << "File not found in assets";
+
+ std::string filePath_stdstr = filePath.toStdString();
+ char filePath_cstring[256];
+ strcpy(filePath_cstring, filePath_stdstr.c_str());
+
+ qDebug() << "File path is" << "filePath_cstring";
+
+ //Switch modes
+ bootloaderJump();
+ mainActivity.callMethod("closeDevice");
+ libusb_release_interface(handle, 0);
+ libusb_close(handle);
+ libusb_exit(ctx);
+
+ qDebug() << "BA94 closed";
+
+ QThread::msleep(2000);
+
+ //Initialise libusb-martin-kuldeep
+ libusb_context *ctx;
+ libusb_device * device_ptr;
+ libusb_device_handle *handle;
+ int error = get_new_bootloader_ctx(&device_ptr, &handle, &ctx);
+ if(error){
+ qDebug() << "get_new_bootloader_ctx FAILED";
+ return 69;
+ }
+
+ /*
+ //Extract bus/device number
+ usbfs_path[16] = NULL;
+ char *busNumber = &usbfs_path[13];
+ char *devNumber = &usbfs_path[17];
+
+ qDebug() << "Thingo thinks it's octal!!";
+ qDebug() << busNumber;
+ qDebug() << devNumber;
+
+ qDebug() << "Remove those leading zeros";
+
+ for (int i=0; i<3; i++){
+ if(busNumber[0] == '0') busNumber++;
+ if(devNumber[0] == '0') devNumber++;
+ }
+
+ qDebug() << "Here we go!";
+
+ qDebug() << busNumber;
+ qDebug() << devNumber;
+*/
+
+ //Set up interface to dfuprog
+ int exit_code;
+ char command1[256];
+ sprintf(command1, "dfu-programmer atxmega32a4u erase --force --debug 300");
+ char command2[256];
+ sprintf(command2, "dfu-programmer atxmega32a4u flash %s --debug 300", filePath_cstring);
+ char command3[256];
+ sprintf(command3, "dfu-programmer atxmega32a4u launch");
+ char command4[256];
+ sprintf(command4, "dfu-programmer atxmega32a4u launch");
+
+ //Run stage 1
+ exit_code = dfuprog_virtual_cmd(command1, device_ptr, handle, ctx, 0);
+ if(exit_code){
+ //return exit_code+100;
+ }
+
+ error = get_new_bootloader_ctx(&device_ptr, &handle, &ctx);
+ if(error){
+ qDebug() << "get_new_bootloader_ctx FAILED";
+ return 169;
+ }
+
+
+ //Run stage 2
+ exit_code = dfuprog_virtual_cmd(command2, device_ptr, handle, ctx, 0);
+ if(exit_code){
+ //return exit_code+200;
+ }
+
+ error = get_new_bootloader_ctx(&device_ptr, &handle, &ctx);
+ if(error){
+ qDebug() << "get_new_bootloader_ctx FAILED";
+ return 269;
+ }
+
+
+ //Run stage 3
+ exit_code = dfuprog_virtual_cmd(command3, device_ptr, handle, ctx, 0);
+ if(exit_code){
+ //return exit_code+300;
+ }
+
+ QThread::msleep(2000);
+
+ error = get_new_bootloader_ctx(&device_ptr, &handle, &ctx);
+ if(error){
+ qDebug() << "get_new_bootloader_ctx FAILED";
+ return 369;
+ }
+
+ //Run stage 4 - double launch to clear the eeprom flag from bootloaderJump.
+ exit_code = dfuprog_virtual_cmd(command4, device_ptr, handle, ctx, 0);
+
+ mainActivity.callMethod("closeDevice");
+ return 0;
+}
+
diff --git a/Desktop_Interface/androidusbdriver.cpp.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/androidusbdriver.cpp.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index de663998..00000000
--- a/Desktop_Interface/androidusbdriver.cpp.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1f4be55624983686164e79e2b9a2524d6656eedf
\ No newline at end of file
diff --git a/Desktop_Interface/androidusbdriver.h b/Desktop_Interface/androidusbdriver.h
new file mode 100644
index 00000000..a69f99a1
--- /dev/null
+++ b/Desktop_Interface/androidusbdriver.h
@@ -0,0 +1,29 @@
+#ifndef androidUsbDriver_H
+#define androidUsbDriver_H
+
+#include
+#include
+#include
+#include
+
+#include "unixusbdriver.h"
+#include "libusb.h"
+#include
+#include
+
+
+class androidUsbDriver : public unixUsbDriver
+{
+ Q_OBJECT
+public:
+ explicit androidUsbDriver(QWidget *parent = 0);
+ ~androidUsbDriver();
+private:
+ //Generic Functions
+ QAndroidJniObject mainActivity;
+ unsigned char usbInit(unsigned long VIDin, unsigned long PIDin);
+ int flashFirmware(void);
+ int get_new_bootloader_ctx(libusb_device **device_ptr, libusb_device_handle **handle, libusb_context **ctx);
+};
+
+#endif // unixUsbDriver_H
diff --git a/Desktop_Interface/androidusbdriver.h.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/androidusbdriver.h.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index ba4f439e..00000000
--- a/Desktop_Interface/androidusbdriver.h.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9a76518896b9b64e6af26f6e41aca8fb5effa38b
\ No newline at end of file
diff --git a/Desktop_Interface/androidusbdriver.obj.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/androidusbdriver.obj.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 1e3a7894..00000000
--- a/Desktop_Interface/androidusbdriver.obj.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-09cdf7f60c1e5e6b6afad6b7dc2c33b9cfc0b0c8
\ No newline at end of file
diff --git a/Desktop_Interface/app_process.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/app_process.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 51bac273..00000000
--- a/Desktop_Interface/app_process.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-24a7bc12faa22343244c90568e4747040d9d0a13
\ No newline at end of file
diff --git a/Desktop_Interface/appicon.ico b/Desktop_Interface/appicon.ico
new file mode 100644
index 00000000..3ed6f07a
Binary files /dev/null and b/Desktop_Interface/appicon.ico differ
diff --git a/Desktop_Interface/appicon.ico.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/appicon.ico.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index a02b83c5..00000000
--- a/Desktop_Interface/appicon.ico.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7ea9674d8203107793447a028a37ede045e69a88
\ No newline at end of file
diff --git a/Desktop_Interface/bin/.DS_Store.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/.DS_Store.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 112bc444..00000000
--- a/Desktop_Interface/bin/.DS_Store.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f943b7ad9e3830a17d37ea9ac811ed6806ba3a4f
\ No newline at end of file
diff --git a/Desktop_Interface/bin/._.DS_Store.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/._.DS_Store.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 95175ab4..00000000
--- a/Desktop_Interface/bin/._.DS_Store.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-301d01b13096dca1cd26a9b8830a99612aa2553b
\ No newline at end of file
diff --git a/Desktop_Interface/bin/._labrador.dmg.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/._labrador.dmg.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index cb425707..00000000
--- a/Desktop_Interface/bin/._labrador.dmg.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4f7ad2642812f34dbd1eee02076639d9e1ea816d
\ No newline at end of file
diff --git a/Desktop_Interface/bin/Labrador.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/Labrador.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 3854b919..00000000
--- a/Desktop_Interface/bin/Labrador.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-40a0a3d9532598c8bd011e89f03c85c922e9bedf
\ No newline at end of file
diff --git a/Desktop_Interface/bin/Labrador.exe.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/Labrador.exe.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index ad185ea3..00000000
--- a/Desktop_Interface/bin/Labrador.exe.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-19302fea035bc752b0f9f020d0a0edca0c7f6d87
\ No newline at end of file
diff --git a/Desktop_Interface/bin/Labrador.pdb.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/Labrador.pdb.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 06b5d03c..00000000
--- a/Desktop_Interface/bin/Labrador.pdb.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2792c117745b6ae65ed60b0ad7b0509483e44755
\ No newline at end of file
diff --git a/Desktop_Interface/bin/Labrador_goed.exe.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/Labrador_goed.exe.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index ee01e436..00000000
--- a/Desktop_Interface/bin/Labrador_goed.exe.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-135640b475285d976c0a56bfccf1790d7b478dd2
\ No newline at end of file
diff --git a/Desktop_Interface/bin/Labrador_libusbk.exe.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/Labrador_libusbk.exe.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 5adb94d9..00000000
--- a/Desktop_Interface/bin/Labrador_libusbk.exe.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3ed8274777c08ce8fd30e74c20e542cbfb81ca80
\ No newline at end of file
diff --git a/Desktop_Interface/bin/firmware/dfu-programmer.exe.REMOVED.git-id b/Desktop_Interface/bin/firmware/dfu-programmer.exe.REMOVED.git-id
deleted file mode 100644
index b819c11c..00000000
--- a/Desktop_Interface/bin/firmware/dfu-programmer.exe.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b27d99e3b1bb4ec243a6f22881053dd6e6e94334
\ No newline at end of file
diff --git a/Desktop_Interface/bin/firmware/flash.bat.REMOVED.git-id b/Desktop_Interface/bin/firmware/flash.bat.REMOVED.git-id
deleted file mode 100644
index c0361a58..00000000
--- a/Desktop_Interface/bin/firmware/flash.bat.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-33b4424dfe12584fb5dffb5e26758a13d7b57b57
\ No newline at end of file
diff --git a/Desktop_Interface/bin/firmware/labrafirm_0001_01.hex b/Desktop_Interface/bin/firmware/labrafirm_0001_01.hex
new file mode 100644
index 00000000..044f2051
--- /dev/null
+++ b/Desktop_Interface/bin/firmware/labrafirm_0001_01.hex
@@ -0,0 +1,715 @@
+:1000000017C1000031C100002FC100002DC1000048
+:100010002BC1000029C100000C9414090C94230981
+:1000200023C1000021C100001FC100001DC100004C
+:100030001BC1000019C1000017C1000015C100005C
+:1000400013C1000011C100000FC100000DC100006C
+:100050000BC1000009C1000007C1000005C100007C
+:100060000C94FF090C940A0AFFC00000FDC00000B8
+:10007000FBC00000F9C00000F7C00000F5C00000A0
+:10008000F3C00000F1C00000EFC00000EDC00000B0
+:10009000EBC00000E9C00000E7C00000E5C00000C0
+:1000A000E3C00000E1C00000DFC00000DDC00000D0
+:1000B000DBC00000D9C00000D7C00000D5C00000E0
+:1000C000D3C00000D1C00000CFC00000CDC00000F0
+:1000D000CBC00000C9C00000C7C00000C5C0000000
+:1000E000C3C00000C1C00000BFC00000BDC0000010
+:1000F000BBC00000B9C00000B7C00000B5C0000020
+:10010000B3C00000B1C00000AFC00000ADC000002F
+:10011000ABC00000A9C00000A7C00000A3C400003D
+:10012000A3C00000A1C000009FC000009DC000004F
+:100130009BC0000099C0000097C0000095C000005F
+:1001400093C0000091C000008FC000000C9474099F
+:100150008BC0000089C0000087C0000085C000007F
+:1001600083C0000081C000007FC000007DC000008F
+:100170007BC0000079C0000077C0000075C000009F
+:1001800073C0000071C000006FC000006DC00000AF
+:100190006BC0000069C0000067C0000065C00000BF
+:1001A00063C0000061C000005FC000005DC00000CF
+:1001B0005BC0000059C0000057C0000055C00000DF
+:1001C00053C0000051C000004FC000004DC00000EF
+:1001D0004BC0000049C0000047C0000045C00000FF
+:1001E00043C0000041C000003FC000003DC000000F
+:1001F0003BC000000C9420140C94D8140F0411047C
+:1002000013041504170419041B041D04DB0B010C53
+:10021000280C510C5A0C5F0CA40CA90CC80CCF0C68
+:100220006B0C730C7B0C860C880C8A0C920C9A0C51
+:1002300011241FBECFEFCDBFDFE2DEBF10E2A0E092
+:10024000B0E2E2EDFBE202C005900D92AA3BB107DD
+:10025000D9F72DE2AAEBB0E201C01D92AC3FB20784
+:10026000E1F794D20C94E715CBCE84E0809356004E
+:100270008CE1C0D3809363008BEB8093660080E8B1
+:100280008093650081E08093600088ED84BF1092C8
+:10029000410083E080935000809151008330E1F76A
+:1002A0008091500081608093500088E180935500D8
+:1002B0008091510080FFFCCF80915000806180933D
+:1002C00050008091510084FFFCCF88ED84BF84E012
+:1002D000809340000895E0E7F0E085818E7F85837C
+:1002E000E0E0FAE08FEB9DE586A397A380EE9EE227
+:1002F00080A391A382E0808308958091200A909149
+:10030000210A813E2EE2920718F020919E2306C01A
+:10031000803E2EE2920721F020919B2320936A00D9
+:1003200020910520222321F080910520815033C0A7
+:10033000885F9A42813D974080F11092BA20809167
+:10034000BB209091BC20A091BD20B091BE20019611
+:10035000A11DB11D8093BB209093BC20A093BD2014
+:10036000B093BE208091BB209091BC20A091BD2075
+:10037000B091BE20892F9A2FAB2FBB278093BE232D
+:100380008091BB209091BC20A091BD20B091BE2057
+:100390008093BD2386E08093052080910720909173
+:1003A00008200196B1F4809109208F3F91F080914F
+:1003B0000620811106C0809106208150809306207E
+:1003C00008958091140190911501809307209093D6
+:1003D00008200895009709F45EC00CF457C040E06F
+:1003E00020916B0030E020939C2330939D2320913B
+:1003F0009C2330919D233695322F222737952795C0
+:1004000020939C2330939D2350916A0020919C233C
+:1004100030919D23250F311D20939C2330939D23E4
+:10042000000020919C2330919D232817390728F440
+:1004300010929C2310929D23089520919C2330912B
+:100440009D23280F391F2115304238F08FEF9FE18F
+:1004500080939C2390939D23089520919C23309119
+:100460009D23442329F0A901481B590BCA0102C04E
+:10047000820F931F80939C2390939D2380919C23B4
+:1004800090919D238F7780936A000895919581952F
+:10049000910941E0A5CF0895CF93DF93C091200A41
+:1004A000D091210A80910320909104209E01281B65
+:1004B000390B20939F233093A0238091BA20811180
+:1004C0004BC080919F239091A0238E3C9F4FD4F4EA
+:1004D00080919F239091A0238B369F4F9CF0809119
+:1004E0000220882321F080910220815008C0809151
+:1004F0006A0080939E2381E08093BA208CE08093F1
+:1005000002202AC08CE08093022080919F2390914A
+:10051000A0238A369F4F1CF08FEF9FEF02C081E02F
+:1005200090E08093992390939A2380919F239091B8
+:10053000A0232091992330919A2360E370E00E94D8
+:10054000BE15261B370B2093992330939A23809155
+:10055000992390919A233EDF8091BA20813029F52A
+:1005600080919F239091A023C39794F080910220C3
+:10057000882331F08091022081508093022015C0A1
+:1005800080916A0080939B2383E08093BA200DC002
+:1005900080919F239091A023873991051CF481E0DD
+:1005A00090E002C08FEF9FEF15DFC0930320D09340
+:1005B0000420DF91CF9108958617970779F0681787
+:1005C000790728F49C01261B370BB90109C086174F
+:1005D000970718F4681B790B03C0089560E070E07A
+:1005E000CB010895CF93DF9380910020909101205B
+:1005F000892B51F0809100209091012001978093E8
+:1006000000209093012043C080E490E0809300207C
+:100610009093012080910720909108200196B9F1D4
+:10062000809114019091150120910920263018F431
+:1006300067E771E002C06EEE72E00E94AA15EC015D
+:1006400080910720909108208C179D0758F46091A5
+:10065000072070910820CE01AFDF029718F080ECE0
+:100660009DE511C08091072090910820C817D907F7
+:1006700070F46091072070910820CE019DDF0297F1
+:1006800030F08FEB9DE58093360A9093370ADF9127
+:10069000CF910895AC01460F571F861B970B2091F1
+:1006A000200A3091210A24173507C8F72091200A23
+:1006B0003091210A8217930790F70895E0E8F6E059
+:1006C0008FE0808385E0848308951F93CF93DF9329
+:1006D000C0E4D0E0198180E4898340E250E064ED19
+:1006E0007DE280E290E00E94390F1983DF91CF9183
+:1006F0001F9108951F93CF93DF93C0E4D0E0198139
+:1007000080E4898387ED97E20E94810F81E00E9457
+:10071000930F1983DF91CF911F91089508950F933F
+:100720001F93842F242F30E0215831099DE7929F99
+:10073000A001939F500D112490910920953048F409
+:10074000843810F049585E4F9091C42027E731E07B
+:1007500004C09091C4202EEE32E0929FB001939F8E
+:10076000700D11249A01260F371FA9014850584DCA
+:100770000FE813E02DE730E060E00E944B131F917B
+:100780000F9108951CBEEEEFF0E409949EDF809176
+:10079000D42D882369F080E2E4EDFDE2A7EDB7E215
+:1007A00001900D928A95E1F71092D727A3DFEADF37
+:1007B00087E08093A200789458DDB0DF86D765D1BA
+:1007C00088D160E080E01FD10BD18CE0FFD04AD50A
+:1007D000EED507D673DF60EA70E28AEA93E20E9400
+:1007E000E015000000000000000000000000000014
+:1007F00000000000000000000000000000008091E8
+:10080000BF20882371F3E091D6258E2F90E08830A9
+:100810009105A0F4FC01E250FF4F0C94D11585D155
+:100820000DC0F5D10BC07CD209C000D307C08CD35A
+:1008300005C012D403C011D401C082D41092BF20CD
+:10084000D0CF08950895809114018093B3238091AF
+:1008500015018093B423809124018093B523809166
+:1008600025018093B6238091200A8093BF23809135
+:10087000210A8093C0238091140190911501863440
+:10088000914080F08091140190911501893A914036
+:1008900048F480911401909115018093F42D909368
+:1008A000F52D00008091C220882339F014DD1092CC
+:1008B000C22081E08093C12008958091C1208823C7
+:1008C00041F08091BA20833019F417DD8BDE01C02E
+:1008D000E3DD8091C020882351F080911401909134
+:1008E00015018093F42D9093F52D1092C0208091E6
+:1008F00009202091140130911501853028F481E000
+:100900002737314030F004C081E02E3E324008F0FD
+:1009100080E08093C42008950F931F9381E080931B
+:10092000C7208093C2200FE813E02DE730E048EFA6
+:1009300057E260E081E80E944B132DE730E045E785
+:1009400058E260E082E80E944B132DE730E042EF6E
+:1009500058E260E083E80E944B132DE730E04FE659
+:1009600059E260E084E80E944B132DE730E04CEE42
+:1009700059E260E085E80E944B132DE730E049E63C
+:100980005AE260E086E80E944B1381E01F910F91CC
+:1009900008951092C720089581E0089581E0089598
+:1009A00010922002982F9C7193689093200287FFE9
+:1009B00003C090E182E002C090E080E0892B809348
+:1009C000210210922202109226020895E0E0F2E045
+:1009D00010AA836880AB80E181AB12AA16AA0895A1
+:1009E000E0E0F2E010A683E880A78FE281A712A6DC
+:1009F00016A60895AAECB1E092E09C93E82FF0E0EF
+:100A000084911C920895909171009D7F9093710044
+:100A100010920002623011F09CE101C09EE19093BF
+:100A2000010290E490930202811102C080E401C0AF
+:100A300080EC80930302613011F084E001C083E018
+:100A40008093040280E2D6DF80930C0281E2D2DF41
+:100A500080930D02109218021092190281E0809387
+:100A60000002BECF1F920F920FB60F9211248F93E8
+:100A7000000000000000000081E0809323028F91BD
+:100A80000F900FBE0F901F901895CF93DF93E0E764
+:100A9000F0E082818B7F8283C0E2D3E08DE08883A7
+:100AA00080E4898389E08A8383E3A4DF888782E303
+:100AB000A1DF898787E39EDF8A8786E39BDF8B87B9
+:100AC000E0E2F6E08081836080831482DF91CF9141
+:100AD0000895E0E7F0E080818E7F808383E8809353
+:100AE00000010895E0E0F1E0108A80E4808B10A21C
+:100AF00080A310AA80ABE0E4F1E010828083109222
+:100B0000C6201092C52081E08093C4201092A823B3
+:100B10001092A9231092A6231092A72308958093E0
+:100B2000D62581E08093BF200895CF93DF93109264
+:100B30000920D8DFC0E0D1E01EAA84E288AB19AA60
+:100B400049E54AAB32E03BAB60910B2070910C2041
+:100B50006CAB7DAB67ED75E268AF79AF1AAE9BE326
+:100B60009CAF93E090933D0110923E0128A920682C
+:100B700028AB10924601E0E4F1E08083109241013D
+:100B8000409342019093430140910D2050910E20DB
+:100B9000409344015093450146EC53E24093480191
+:100BA0005093490110924A0129E320934C019093FC
+:100BB0004D0110924E01908190689083188A90E4C4
+:100BC000988B888B198A95E99A8B90E19B8B4EEED6
+:100BD00052E04C8B5D8B888F398F1A8E88EF97E2AD
+:100BE0008C8F9D8F1E8E68EC70E084EF91E052DD5B
+:100BF00088EC90E0809307209093082081E0809318
+:100C0000062088898068888BDF91CF9108951F9393
+:100C1000CF93DF9311E01093092064DFC0E0D1E0AF
+:100C200018AA80E488AB84E088AB19AA1AAA4BE41E
+:100C30004BAB1CAA1DAA1EAA8AE090E288AF99AF0E
+:100C40001AAE60EA6CAF38E030933D0110923E017D
+:100C500088A9806A88ABE0EAF8E085E58083808334
+:100C600010924601E0E4F1E084E2808310924101B9
+:100C700099E59093420122E020934301A0910B203B
+:100C8000B0910C20A0934401B0934501A7EDB5E2CB
+:100C9000A0934801B093490110924A019BE39093BD
+:100CA0004C0193E090934D0110924E019081906819
+:100CB000908388A319A295E99AA34BA34EEE52E024
+:100CC0004CA35DA368A739A71AA666EE7AE26CA7C3
+:100CD0007DA71EA6888B198A9A8B90E19B8B4C8BE3
+:100CE0005D8B888F298F1A8E88EF97E28C8F9D8F6E
+:100CF0001E8E68EC70E084EF91E0CCDC88EC90E034
+:100D000080930720909308201093062088A1806884
+:100D100088A388898068888BDF91CF911F9108957F
+:100D20001F93CF93DF9312E010930920DBDEC0E026
+:100D3000D1E01EAA84E288AB19AA39E53AAB1BAB15
+:100D400040910B2050910C204CAB5DAB47ED55E230
+:100D500048AF59AF1AAE9BE39CAF93E090933D012F
+:100D600010923E0128A9206828AB10924601E0E4C9
+:100D7000F1E080831092410130934201909343014E
+:100D800020910D2030910E20209344013093450195
+:100D900026EC33E2209348013093490110924A0136
+:100DA00029E320934C0190934D0110924E019081C4
+:100DB00090689083188A90E4988B888B198A45E90B
+:100DC0004A8B90E19B8B2EEE32E02C8B3D8B888FF3
+:100DD000198F1A8E68EF77E26C8F7D8F1E8E88A335
+:100DE00019A24AA39BA32CA33DA384E388A719A718
+:100DF0001AA686EE9AE28CA79DA71EA668EC70E064
+:100E000084EF91E047DC88EC90E08093072090939A
+:100E1000082081E08093062088898068888B88A1DB
+:100E2000806888A3DF91CF911F9108951F93CF937E
+:100E3000DF9313E01093092055DEC0E0D1E010925B
+:100E40004601E0E4F1E084E280831092410129E56B
+:100E50002093420192E09093430140910B205091E6
+:100E60000C20409344015093450147ED55E24093D7
+:100E700048015093490110924A019BE390934C0121
+:100E800010934D0110924E019081906890831EAA9C
+:100E900088AB19AA2AAB1BAB20910D2030910E20F4
+:100EA0002CAB3DAB26EC33E228AF39AF1AAE99E359
+:100EB0009CAF10933D0110923E0198A9906898ABA9
+:100EC00018A250E458A394E098A319A21AA24BE4E4
+:100ED0004BA31CA21DA21EA22AE030E228A739A71C
+:100EE0001AA630EA3CA728E02DA71EA698A1906A72
+:100EF00098A395E59093A008188A588B888B198A37
+:100F000085E98A8B4B8B8EEE92E08C8B9D8B388F94
+:100F1000298F1A8E88EF97E28C8F9D8F1E8E68EC3A
+:100F200070E084EF91E0B6DB88EC90E080930720DE
+:100F30009093082081E08093062088898068888BC0
+:100F4000DF91CF911F9108951F93CF93DF9314E00A
+:100F500010930920C7DDC0E0D1E018AA80E488AB77
+:100F600018AB19AA1AAA3BE43BAB1CAA1DAA1EAADD
+:100F70008AE090E288AF99AF1AAE50EA5CAF88E0A1
+:100F800080933D0110923E0198A9906A98AB95E537
+:100F90009093A00810924601E0E4F1E094E290837F
+:100FA0001092410129E52093420122E02093430160
+:100FB00060910B2070910C20609344017093450167
+:100FC00067ED75E2609348017093490110924A0100
+:100FD0002BE320934C0123E020934D0110924E010E
+:100FE000208120682083988B198A45E94A8B3B8BA6
+:100FF0002EEE32E02C8B3D8B588F898F1A8E68EF46
+:1010000077E26C8F7D8F1E8E98A319A24AA39AE473
+:101010009BA32CA33DA393EC98A789A71AA686EEC1
+:101020009AE28CA79DA71EA668EC70E084EF91E081
+:1010300031DB88EC90E0809307209093082081E0DA
+:101040008093062088898068888B88A1806888A31F
+:10105000DF91CF911F910895FFCFCF93DF9386E06B
+:10106000809309203FDDC0E0D1E01EAA84E288AB76
+:1010700019AA39E53AAB93E09BAB40910D20509112
+:101080000E204CAB5DAB46EC53E248AF59AF1AAE05
+:1010900029E32CAF90933D0110923E0128A92068CE
+:1010A00028AB10924601E0E4F1E080831092410108
+:1010B0003093420122E02093430140910B20509154
+:1010C0000C20409344015093450147ED55E2409375
+:1010D00048015093490110924A013BE330934C017F
+:1010E00090934D0110924E01908190689083188AE0
+:1010F00090E4988B888B198A95E99A8B90E19B8B69
+:101100004CED55E04C8B5D8B888F298F1A8E88EFC4
+:1011100097E28C8F9D8F1E8E68EC70E084EF91E0DB
+:10112000B9DA80E991E0809307209093082081E06C
+:101130008093062088898068888BDF91CF910895FD
+:10114000CF93DF9387E080930920CCDCC0E0D1E02F
+:101150001EAA84E288AB19AA39E53AAB93E09BABAF
+:1011600040910D2050910E204CAB5DAB46EC53E20C
+:1011700048AF59AF1AAE29E32CAF90933D011092BE
+:101180003E0128A9206828AB10924601E0E4F1E076
+:101190008083109241013093420122E02093430169
+:1011A00040910B2050910C204093440150934501F5
+:1011B00047ED55E2409348015093490110924A018E
+:1011C0003BE330934C0190934D0110924E0190817E
+:1011D00090689083188A90E4988B95E2988B198A8E
+:1011E00095E99A8B90E19B8B4CED55E04C8B5D8B98
+:1011F000888F298F1A8E88EF97E28C8F9D8F1E8E95
+:1012000068EC70E084EF91E045DA80E991E080934A
+:1012100007209093082081E08093062088898068C9
+:10122000888BDF91CF9108951F920F920FB60F9286
+:1012300011248F9381E0809303018F910F900FBE53
+:101240000F901F9018951F920F920FB60F921124B6
+:101250008F9382E0809303018F910F900FBE0F90C8
+:101260001F901895E0E7F0E083818C7F8383848171
+:101270008C7F848380818D7F8083E0E8F1E080EC47
+:101280008283128688EC81831186A0E0B8E034E086
+:101290003C9323E011962C93119714961C9214976B
+:1012A00085ED91E096968D939C93979716961C9258
+:1012B0001697E0E4F8E030832183148286A397A395
+:1012C0001682E0E6F6E0808180618083E0E4F9E068
+:1012D00083E18183148282E08683A6A3B7A310A64C
+:1012E00011A681E0808308951F920F920FB60F928E
+:1012F00011242F933F934F935F938F939F93CF939B
+:10130000DF931F92CDB7DEB78FEF80934C098091AA
+:101310000920873031F480912C02898390912D022D
+:1013200002C090912C028091C320891B20916809F2
+:101330003091690982308CF02A3F374070F4209157
+:1013400068093091690989301CF481E090E002C09D
+:1013500086E090E0820F931F18C0209168093091B9
+:1013600069098F3FB4F42730310598F0209168095E
+:1013700030916909883F1CF081E090E002C086E06E
+:1013800090E0A901481B590BCA01809378099093FA
+:1013900079090F90DF91CF919F918F915F914F913C
+:1013A0003F912F910F900FBE0F901F901895E0E77F
+:1013B000F0E083818F7E8383E0E4F6E080818A6AB7
+:1013C00080838FEF848388E5828BE0EAF8E080E316
+:1013D000838384EC858387E08683178288E1848316
+:1013E0000895E0E7F0E08381877F8383E0ECF8E015
+:1013F00080E48083118288E58093550608951F92CA
+:101400000F920FB60F92112400000F900FBE0F9095
+:101410001F9018951F920F920FB60F9211248F9361
+:10142000EF93FF93E0EAF8E080818083FF91EF91F2
+:101430008F910F900FBE0F901F9018959FB7F89443
+:10144000A0E5B0E016968C911697897F16968C933E
+:101450001697E0E6F0E080E885838BEB86831696AE
+:101460008C911697846016968C938081816080831E
+:101470009FBF08959FB7F894E82FF0E0E059FF4F21
+:1014800060958081682360839FBF0895CF938630E5
+:1014900011F0C0E001C0C8E18091510081FD0DC094
+:1014A0009FB7F894809150008260809350009FBF56
+:1014B0008091510081FFFCCFC1DF6C2F636084E419
+:1014C00090E0BCD460E480E0CF91D4CF8091C8207C
+:1014D00008958091C820813009F45BCA0895F0D046
+:1014E000FC0183818093C820811101C015CA81E06D
+:1014F00008959091C625892F807697FF07C0803484
+:1015000091F48091C72581110EC048CA803459F4E6
+:101510008091C725811107C08091CC259091CD2560
+:10152000892B09F039CA80E008958091C8258F770A
+:101530000C94CD129091D020911102C080E00895BA
+:10154000E091CD20F091CE200190F081E02D9481AA
+:101550008917A0F7E093CB20F093CC202281338130
+:101560002E0F3F1FE217F30798F49181943061F436
+:101570009281891309C09381691306C0E093CB203F
+:10158000F093CC2081E008959081E90FF11DEACF1E
+:10159000E093CB20F093CC20D1CFE091CD20F091FF
+:1015A000CE200190F081E02D228133812E0F3F1F4C
+:1015B000FC014081E40FF11DE217F30748F481813B
+:1015C000843031F0853039F08081E80FF11DF4CF9F
+:1015D00080E090E00895CF0108951F93CF93DF93AB
+:1015E000182FA8DF882339F1C091CB20D091CC20CF
+:1015F000CE01D3DFEC01892B41F04C815D816B8101
+:101600008A81D8D78111F4CF16C0E091CD20F09116
+:10161000CE2092818381E92FF82FE10FF11DE10F98
+:10162000F11D0190F081E02D0190F081E02DDF911E
+:10163000CF911F91099480E0DF91CF911F91089580
+:10164000EF92FF921F93CF93DF93C82F60E072DF7A
+:10165000811102C010E02DC0E091CD20F091CE208C
+:1016600092818381E92FF82FEC0FF11DEC0FF11D12
+:10167000E080F180D7011696ED91FC9117970995BE
+:10168000682F8C2F57DF182F882321F3C091CB2090
+:10169000D091CC20CE0181DFEC01892B21F08A8111
+:1016A0000E940714F7CFD7011296ED91FC91139782
+:1016B0000995812FDF91CF911F91FF90EF900895B1
+:1016C0008091CB209091CC200895FBC6CF93809140
+:1016D000D020811108C01092D0201092D4201092F6
+:1016E000D520CF910895C0E0E091CD20F091CE209B
+:1016F0000190F081E02D8481C81768F78C2FA0DF5E
+:10170000CF5FF2CFCF938091D0208823F1F0C0E05B
+:10171000E091CD20F091CE20A081B18114968C91E2
+:10172000C81798F492818381E92FF82FEC0FF11DEF
+:10173000EC0FF11D0190F081E02D0084F185E02D8A
+:10174000309709F00995CF5FE3CFCF910895EF92DD
+:10175000FF920F931F93CF93DF931F92CDB7DEB706
+:101760001092D0251092D1251092D2251092D32517
+:101770001092D4251092D5258091C62587FF07C0E9
+:101780002091CC253091CD25232B09F44EC3982FE1
+:101790009076903409F00BC1E091C7258E2F90E030
+:1017A000FC01E05AF109EA30F10508F0CDC2EA5F28
+:1017B000FE4F0C94D11581E08093C02080910720CA
+:1017C000909108208093B723809107209091082062
+:1017D0009093B82380919E238093B92380919B237B
+:1017E0008093BA2380916A008093BB2380916B0021
+:1017F0008093BC236091CC257091CD258AEA93E239
+:10180000D4C0109200088091C8259091C92580937A
+:101810003608909337088091CA258F70809300080E
+:101820006091CC257091CD2586EC93E2BCD62091B9
+:101830000D2030910E208091CC259091CD25281738
+:10184000390709F4F0C280930D2090930E2026C032
+:10185000109240088091C8259091C9258093760800
+:10186000909377088091CA258F708093400860918B
+:10187000CC257091CD2587ED95E295D620910B2052
+:1018800030910C208091CC259091CD2528173907D7
+:1018900009F4C9C280930B2090930C2080910920F9
+:1018A00051C010926809109269098091C8258093EF
+:1018B000C320B9C28091C82580932406B4C2E091A8
+:1018C000C825F091C925E830F10508F03DC2E05F78
+:1018D000FE4F0C94D11560E080E095D88091CA2528
+:1018E0005FD880E02FC060E080E08DD88091CA256D
+:1018F00057D881E027C061E081E085D88091CA2572
+:101900004FD88091CB2562D882E01CC083E01AC0FA
+:1019100084E018C060E080E076D88091CA2540D885
+:1019200085E010C061E080E06ED88091CA2538D88B
+:1019300086E008C062E080E066D88091CA258068B1
+:101940002FD887E0ECD86FC28091C8258093840699
+:101950006AC28091C8259091C925892B91F00E9477
+:10196000650380E2E4EDFDE2A7EDB7E201900D92A0
+:101970008A95E1F781E08093D7270E947A030E943D
+:101980006503E9E7F0E091E088EDF89484BF908387
+:101990006091CC257091CD258AEA90E206C06091D5
+:1019A000CC257091CD2589EA90E2FDD53CC29111FC
+:1019B000CBC187FFFCC02091CC253091CD252115CE
+:1019C000310509F4C1C18F7109F09EC08091C7250E
+:1019D000863071F0883009F48EC08111B5C1223093
+:1019E000310509F0B1C162E070E084ED90E2DDCF35
+:1019F0008091C8259091C925292F332722303105A0
+:101A0000A1F064F42130310509F09EC180911920C4
+:101A100090911A20DC016C9170E05BC0233031059D
+:101A200089F12F30310509F18FC1E0911920F09132
+:101A30001A202189821708F087C19927880F991FDA
+:101A4000880F991FE0911B20F0911C20E80FF91FCF
+:101A500080819181FC0162817381A5D5E091CE25C1
+:101A6000F091CF2582E0818335C080911D20909137
+:101A70001E20009709F468C1DC0112966D917C91DB
+:101A8000139727C099278130910569F038F00297A4
+:101A900009F05AC168E08AE890E208C064E070E0AA
+:101AA0008CE990E216C067E083E990E2282FAAE76C
+:101AB000B0E2FC01819190E08D939D938E2F821B6B
+:101AC0008617C0F3660F6E5F6093782070E088E73A
+:101AD00090E269D58091CC259091CD252091D0259B
+:101AE0003091D1258217930708F09DC18093D025AE
+:101AF0009093D12598C12130310509F025C161E0CD
+:101B000070E080ED90E251CF8130C9F58091C7251A
+:101B10008A3009F019C12130310509F015C18091D1
+:101B2000D020882309F410C1E090CA25F090CB257D
+:101B30000091CD201091CE20D801ED91FC918481AF
+:101B4000E81608F001C160E08E2DF4DC882309F46A
+:101B5000FBC0FF24EE0CFF1CF801828193818E0DE7
+:101B60009F1DDC01ED91FC910680F781E02D099528
+:101B70008093D22061E070E082ED90E216CF823057
+:101B800009F0E2C08091C7258111DEC02230310505
+:101B900009F0DAC08091CA255ED590E08093C92013
+:101BA0009093CA2062E070E089EC90E2FECE8F71E3
+:101BB00009F07DC08091C725833009F4C5C018F4B1
+:101BC0008130A1F0C1C0853019F0893039F1BCC035
+:101BD0008091CC259091CD25892B09F0B5C085E960
+:101BE0009AE08093D2259093D3251DC18091CC2576
+:101BF0009091CD25892B09F0A7C08091C82590919F
+:101C0000C925019709F0A0C08091D4209091D520DA
+:101C10008D7F8093D4209093D52005C18091CC25D1
+:101C20009091CD25892B09F08FC0BAD4882309F46F
+:101C30008BC02091C8253091C9253327E091192008
+:101C4000F0911A20818990E08217930708F47CC0F4
+:101C50003DDD8091C8259091C9258093D0208823AF
+:101C600009F4E1C099278150904C880F991F880F83
+:101C7000991F20911B2030911C20820F931F80936D
+:101C8000CD209093CE2010E0E091CD20F091CE2099
+:101C90000190F081E02D8481181708F0C4C060E045
+:101CA000812F9BDC882309F44FC01F5FEDCF81306B
+:101CB000F1F48091C7258B3009F046C08091CC2586
+:101CC0009091CD25892B09F03FC08091D0208823A9
+:101CD00009F43AC01091CA256091C825812F698303
+:101CE000AFDC6981882381F1812F77DC2BC08230C2
+:101CF00059F58091C725813019F0833089F024C0CF
+:101D00008091CC259091CD25892BF1F48091C82527
+:101D10009091C925892BC1F48091CA25A3D412C002
+:101D20008091CC259091CD25892B71F48091C82587
+:101D30009091C925892B41F48091CA2538D580918D
+:101D4000CA256ED581116FC08091C6258F718130F3
+:101D5000B9F58091D020882399F1E090CA25F090C0
+:101D6000CB250091CD201091CE20D801ED91FC9192
+:101D70008481E81628F560E08E2DDCDB882301F1F4
+:101D8000F701FF27EE0FFF1FD80112968D919C914E
+:101D90001397E80FF91F00811181D8011696ED9174
+:101DA000FC9117970995682F8E2DC4DB882341F08D
+:101DB000D8011496ED91FC9115970995811133C0C6
+:101DC0008091C6258F71823081F58091D020882343
+:101DD00061F1F12CE091CD20F091CE20A081B18174
+:101DE00014968C91F81608F592818381E92FF82FCB
+:101DF000EF0DF11DEF0DF11D00811181D801169637
+:101E0000ED91FC9117970995682F8F2D93DB88230F
+:101E100061F0D8011496ED91FC9115970995811107
+:101E200002C0F394D7CF81E001C080E00F90DF9132
+:101E3000CF911F910F91FF90EF9008951BBEFC0171
+:101E400028ED24BF608308958091CF0187FDFCCFEA
+:101E500008951F93CF93DF93C0ECD1E01A858A8752
+:101E600061E08BEC91E0EADF1A87DF91CF911F915F
+:101E70000895CF92DF92EF92FF920F931F93CF932B
+:101E8000DF9300D0CDB7DEB78C017B0149835A8345
+:101E9000DBDF8CECC82EDD24D394F60190819860B2
+:101EA0009083B801705F49815A81C70180D6F601DD
+:101EB0008081877F80830F900F90DF91CF911F915A
+:101EC0000F91FF90EF90DF90CF900895CF93DF9325
+:101ED00000D0CDB7DEB76A838983B6DFACECB1E062
+:101EE0009C9198609C938981E82FF0E0F05F6A8173
+:101EF00060838C91877F8C930F900F90DF91CF91AF
+:101F000008950F931F93CF938C019EDFC0E0F801DB
+:101F100061918F018C2FDADFCF5FC032C1F7CF9193
+:101F20001F910F910895CF93DF931F92CDB7DEB726
+:101F300089838ADF898120E2829FC0011124E0EC3D
+:101F4000F1E012829183808385E30F90DF91CF913E
+:101F500080CF4091CA01E62FF72F8093CA01849168
+:101F60004093CA010895E82FF0E0EA50F24D8081D5
+:101F70008F3F09F4FFCF9FB7F89480818F5F8083F4
+:101F80009FBF0895E82FF0E0EA50F24D8081811163
+:101F900001C0FFCF9FB7F8948081815080839FBF9D
+:101FA0000895CF93C82F80919823C11105C088232D
+:101FB00039F081E0E7DF04C0811102C081E0D3DFA6
+:101FC000C0939823CF910895282F2F70082E000CCE
+:101FD000990B392F331F3327331F832F90E0820F44
+:101FE000911D820F911D23E0880F991F2A95E1F71B
+:101FF0008C5D9C4D08950F93E8ECF4E080818F7D1B
+:10200000808380818F7D8083ECE2F3E202E00593A0
+:1020100010922E2310922F2300E2069300E40693E1
+:10202000E4E2F3E200E2069300E40693E6ECF5E274
+:102030001486158616861786128613861092072335
+:102040000F9108950F9385E080930723EDE2F3E26B
+:1020500004E00593E5E2F3E204E005930F910895AF
+:102060000F9383E08093072310922E2310922F2347
+:10207000ECE2F3E202E006930F910895E091D2259D
+:10208000F091D325309709F009940895282F2F70E7
+:10209000082E000C990B392F331F3327331F832F42
+:1020A00090E0820F911D820F911D029749E0489F99
+:1020B0009001499F300D1124C901895A9D4D089501
+:1020C0008F929F92AF92BF92DF92EF92FF920F9307
+:1020D0001F93CF93DF93D82ED9DFEC018D2D74DFC2
+:1020E0007C01DC011196EC91E770E150E73040F49F
+:1020F000F0E0EE0FFF1FE455FF4D0081118102C09B
+:1021000008E010E0ED81FE812B813C814881D70100
+:10211000D7FE48C016968D919C9117978E0F9F1FE2
+:102120008D839E838217930761F1281B390B21153C
+:10213000B4E03B0738F02FEF33E0C901B8010AD50E
+:10214000281B390B41FF0AC0C901B80103D5AC01F6
+:1021500091E0452B09F090E0892F01C080E0988143
+:1021600080FB91F99883F7011682178222833383CB
+:1021700029813A818D819E81820F931F848395836B
+:102180000EC041FF71C04D7F4883D70116961D9246
+:102190001C92179712961D921C921397F70102E05A
+:1021A00006937BC01296AD90BC90139742FF10C06F
+:1021B00089809A80C901B801CDD4B0E4DB9EB0011A
+:1021C000112469567F4DAC01C4018E0F9F1FEFD4BF
+:1021D0008D819E818A0D9B1D8D839E832B813C81E9
+:1021E0002817390710F42D833E83F70186819781E4
+:1021F000A816B906C9F58D819E8182179307A1F1B2
+:10220000281B390B2115F4E03F0710F02FEF33E0C6
+:10221000C901B8019FD4281B390BD70112961D9212
+:102220001C9213972017310778F488818460888383
+:10223000B0E4DB9EC001112489569F4DF7018483D1
+:10224000958306831783AACF49815A818D819E8108
+:10225000840F951FD70114968D939C93159716960E
+:102260002D933C9317979ACF888180FF16C08E7F5D
+:102270008883EF81F885309781F06D817E814D2DC7
+:1022800080E0DF91CF911F910F91FF90EF90DF9051
+:10229000BF90AF909F908F900994DF91CF911F9145
+:1022A0000F91FF90EF90DF90BF90AF909F908F9035
+:1022B00008950F93CF93DF9380910723833029F400
+:1022C000DDDEDF91CF910F9196CE209103233091E7
+:1022D0000423C091D025D091D125C21BD30B61F529
+:1022E0008091052390910623820F931F80930523ED
+:1022F000909306232091CC253091CD2528173907BE
+:1023000021F08091D620882331F084E08093072348
+:10231000E4E2F3E236C0E091D425F091D525309780
+:1023200099F00995882381F01092032310920423D9
+:10233000C091D025D091D125C034D10528F010927C
+:10234000D620C0E4D0E003C081E08093D620C093C3
+:102350002E23D0932F238091032390910423209147
+:10236000CE253091CF25280F391F2093302330936D
+:102370003123C80FD91FC0930323D0930423ECE269
+:10238000F3E202E00693DF91CF910F9108950F934E
+:10239000CF93DF931F92CDB7DEB78091CC0480FF3F
+:1023A00065C021E02093CC0484E293E2FC0100E8C4
+:1023B0000693ECE2F3E200E806932093CA04FC01E2
+:1023C00000E1069380910723882329F0835082300F
+:1023D00008F454DE10DE809126239091272308977D
+:1023E00009F046C088E0E3ECF2E2A6ECB5E2019029
+:1023F0000D928A95E1F78091C80480628093C804A9
+:102400008091C80480628093C804A1D9811102C060
+:1024100019DE2EC09091C62597FF0EC0109205239D
+:1024200010920623109203231092042392E09093BB
+:10243000072389833EDF08C02091CC253091CD252C
+:10244000232B21F489830CDE898113C0109205238C
+:1024500010920623109203231092042391E090938C
+:102460000723E4E2F3E202E0069303C080E001C048
+:1024700081E00F90DF91CF910F910895CF93CFB767
+:10248000F89481E08EDDEAECF4E080E4808380E281
+:102490008083E1ECF4E0808181608083A9ECB4E08A
+:1024A0008C9182608C93E8ECF4E08081806480837E
+:1024B0008C9181608C93808180688083CFBFCF9125
+:1024C0000895CF931092600080E30E94460A8091A5
+:1024D000C00480648093C00481E080936000CFB723
+:1024E000F89480E090E0FC0123E0EE0FFF1F2A95B6
+:1024F000E1F7E85FFC4D158E01968E30910599F756
+:1025000080E090E039E0389FF001399FF00D112410
+:10251000E95AFD4D20812E7F208301968C30910554
+:1025200091F76AE170E082E014DD8F3F09F48FE1FA
+:102530008093FA046BE170E082E00BDD8F3F09F4D9
+:102540008FE18093FB048091C00486608093C00477
+:102550008091C00480688093C0048091C004806131
+:102560008093C00484E293E28093C6049093C704EE
+:102570008091C00480628093C0048FEF8093C50473
+:102580008091C80482608093C8041092982385E0EB
+:10259000EADC74DFCFBFCF9108958093C304089520
+:1025A0008091C3040895E6ECF5E280879187628705
+:1025B000738708950F931F93CF93DF931F92CDB727
+:1025C000DEB78A01698300DDFC018181807C69813D
+:1025D00081113AC06370613019F020F080E803C0C7
+:1025E00080EC01C080E400381105E9F058F40032B5
+:1025F0001105A9F000341105A1F000311105C9F44D
+:1026000091E018C0011592E0190779F00F3F93E0AF
+:10261000190769F00115114061F495E00BC092E0D3
+:1026200009C093E007C094E005C096E003C097E0BE
+:1026300001C090E0118226E02083982B9183818154
+:102640008062818381E001C080E00F90DF91CF91B3
+:102650001F910F910895B8DCFC01818182FB8827CE
+:1026600080F90895CF93C82FAFDCFC01818182FFF0
+:102670000FC091819B7F91838C2F08DDFC0190819D
+:1026800090FF06C09E7F90830780F085E02D09951E
+:1026900081E0CF9108958F929F92AF92BF92DF9287
+:1026A000EF92FF920F931F93CF93DF931F92CDB7BB
+:1026B000DEB7D82E5A0179016983E8DC4C018D2DF3
+:1026C00083DC9C01DC0111968C911197807C6981DF
+:1026D000882309F45EC011968C911197807C803C10
+:1026E00021F011968C9182FD54C09FB7F894F401AB
+:1026F000808180FF02C09FBF4CC0816080839FBFEC
+:10270000F401A182B282E382F482158216820783E9
+:10271000108791E0611104C0E114F10409F090E028
+:10272000D4018C9190FB81F98B7F8C93D7FE04C0F0
+:10273000F9011682178229C0D90111968C9111973F
+:10274000807C803CC9F41196EC91E770E150E73051
+:1027500040F4F0E0EE0FFF1FE455FF4D6081718102
+:1027600002C068E070E0C701F5D1892B29F0F401BF
+:1027700080818E7F80830DC0D90112961D921C929C
+:10278000139716961D921C9217978D2D99DC81E058
+:1027900001C080E00F90DF91CF911F910F91FF90CA
+:1027A000EF90DF90BF90AF909F908F900895EF9241
+:1027B000FF920F93CF93C82F07DC7C018C2F66DC30
+:1027C000DC01F70102E005939C9190FF1BC09E7F06
+:1027D0009C931796ED91FC911897309799F0D7013B
+:1027E000C7FF05C016966D917C91179704C012968D
+:1027F0006D917C9113974C2F81E0CF910F91FF90B9
+:10280000EF900994CF910F91FF90EF900895CF939F
+:10281000C82FCDDF8C2FD8DBFC011182CF9108951A
+:102820000F93CF93C82FD0DBFC01918194609183EB
+:1028300001E006938C2FBBDF81E0CF910F910895CB
+:102840001F920F920FB60F9211240F932F933F9365
+:102850004F935F936F937F938F939F93AF93BF93A8
+:10286000CF93EF93FF938091CB0487FF08C080E85C
+:102870008093CA040E94820B0E94230486C0809128
+:10288000CB0482FF18C084E08093CA0480912C237B
+:1028900086FF7BC08091CC0481FD77C078DD8111FB
+:1028A00074C080910723813011F4DADB6EC084306C
+:1028B00009F06BC021C08091CB0481FF26C082E06B
+:1028C0008093CA048091242386FF5FC08091CC044A
+:1028D00081FD5BC05CDD811158C08091072382308F
+:1028E00041F484E080930723E4E2F3E202E00693FC
+:1028F0004CC0833009F049C0EDE2F3E204E00593F7
+:10290000E5E2F3E204E0059340C08091CB0484FF4C
+:1029100025C080E18093CA04C1E08C2F48DF8C2F52
+:10292000806845DFCF5FC630C1F70E94660B10920A
+:10293000C30410922523C093242383E4809325238A
+:1029400010922D23C0932C2380932D2383EC92E2AD
+:1029500080932823909329234EDB17C08091CB04CA
+:1029600086FF08C080E48093CA0480E01ADB0E94DE
+:1029700021040BC08091CB0485FF07C080E28093C7
+:10298000CA0481E00EDB0E942204FF91EF91CF91F7
+:10299000BF91AF919F918F917F916F915F914F9177
+:1029A0003F912F910F910F900FBE0F901F90189590
+:1029B0001F920F920FB60F9211240F931F932F9314
+:1029C0003F934F935F936F937F938F939F93AF93B7
+:1029D000BF93CF93DF93EF93FF938091CC0481FF5C
+:1029E0001AC082E08093CC048091C5048195880F41
+:1029F000E4E2F3E2E81BF109208131812452334201
+:102A000083E0369527958A95E1F7822F869520FDFC
+:102A100006C0C0E005C0BBDC882319F386C0C0E84F
+:102A2000C80F8C2FD1DAFC01208125FF7EC000E287
+:102A30000693C11174C080910723843019F41EDB02
+:102A4000DADA73C000912623109127238091D025D4
+:102A50009091D125C0910323D09104239E01200F92
+:102A6000311F8217930718F48C010C1B1D0B8091EA
+:102A7000CE259091CF25A80163EC72E28C0F9D1FAB
+:102A800096D0C00FD11FC0930323D09304230034EA
+:102A9000110569F480910523909106238C0F9D1FE9
+:102AA0002091CC253091CD258217930788F0C093D3
+:102AB000D025D093D125E091D425F091D52530971C
+:102AC00029F00995811102C0BDDA2FC0C9DA2DC0E5
+:102AD0008091D0259091D1258C179D07D9F4E09154
+:102AE000D425F091D525309779F30995882361F3A2
+:102AF0002091052330910623809103239091042394
+:102B0000820F931F80930523909306231092032333
+:102B100010920423E4E2F3E202E0069306C0C03818
+:102B200011F4C7DB02C08C2FCBDAFF91EF91DF915C
+:102B3000CF91BF91AF919F918F917F916F915F9155
+:102B40004F913F912F911F910F910F900FBE0F90BA
+:102B50001F901895AA1BBB1B51E107C0AA1FBB1FE2
+:102B6000A617B70710F0A61BB70B881F991F5A9519
+:102B7000A9F780959095BC01CD01089597FB072E8C
+:102B800016F4009406D077FD08D0E4DF07FC05D0EA
+:102B90003EF4909581959F4F0895709561957F4F74
+:102BA0000895EE0FFF1F0590F491E02D0994FB01AD
+:102BB000DC0102C001900D9241505040D8F70895B9
+:102BC000FB01DC0101900D920020E1F70895F894DB
+:022BD000FFCF35
+:102BD20040000CE02E0AFFFFFFFF55800080006FCF
+:102BE2000A690A790A660A000064201F2000002888
+:102BF2002023200F2000000009023C000101008078
+:102C0200FA0904000006FFFFFF00070581018000AA
+:102C12000107058201800001070583018000010789
+:102C220005840180000107058501800001070586F2
+:102C3200018000011201000200000040EB0394BA7F
+:102C42000002010200010000000300000000000079
+:102C5200000000000000000000004C61627261642C
+:102C62006F72004573706F54656B000004030904B2
+:102C72006465627567313233000101001000200083
+:0A2C82004000800000010002FF0383
+:00000001FF
diff --git a/Desktop_Interface/bin/firmware/labrafirm_0001_01.hex.REMOVED.git-id b/Desktop_Interface/bin/firmware/labrafirm_0001_01.hex.REMOVED.git-id
deleted file mode 100644
index 07d97bdc..00000000
--- a/Desktop_Interface/bin/firmware/labrafirm_0001_01.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-044f2051fdfc79136bee11c6968cf73fa30eb572
\ No newline at end of file
diff --git a/Desktop_Interface/bin/firmware/labrafirm_0003_01.hex b/Desktop_Interface/bin/firmware/labrafirm_0003_01.hex
new file mode 100644
index 00000000..f7946fd7
--- /dev/null
+++ b/Desktop_Interface/bin/firmware/labrafirm_0003_01.hex
@@ -0,0 +1,715 @@
+:1000000017C1000031C100002FC100002DC1000048
+:100010002BC1000029C100000C9414090C94230981
+:1000200023C1000021C100001FC100001DC100004C
+:100030001BC1000019C1000017C1000015C100005C
+:1000400013C1000011C100000FC100000DC100006C
+:100050000BC1000009C1000007C1000005C100007C
+:100060000C94FF090C940A0AFFC00000FDC00000B8
+:10007000FBC00000F9C00000F7C00000F5C00000A0
+:10008000F3C00000F1C00000EFC00000EDC00000B0
+:10009000EBC00000E9C00000E7C00000E5C00000C0
+:1000A000E3C00000E1C00000DFC00000DDC00000D0
+:1000B000DBC00000D9C00000D7C00000D5C00000E0
+:1000C000D3C00000D1C00000CFC00000CDC00000F0
+:1000D000CBC00000C9C00000C7C00000C5C0000000
+:1000E000C3C00000C1C00000BFC00000BDC0000010
+:1000F000BBC00000B9C00000B7C00000B5C0000020
+:10010000B3C00000B1C00000AFC00000ADC000002F
+:10011000ABC00000A9C00000A7C00000A3C400003D
+:10012000A3C00000A1C000009FC000009DC000004F
+:100130009BC0000099C0000097C0000095C000005F
+:1001400093C0000091C000008FC000000C9474099F
+:100150008BC0000089C0000087C0000085C000007F
+:1001600083C0000081C000007FC000007DC000008F
+:100170007BC0000079C0000077C0000075C000009F
+:1001800073C0000071C000006FC000006DC00000AF
+:100190006BC0000069C0000067C0000065C00000BF
+:1001A00063C0000061C000005FC000005DC00000CF
+:1001B0005BC0000059C0000057C0000055C00000DF
+:1001C00053C0000051C000004FC000004DC00000EF
+:1001D0004BC0000049C0000047C0000045C00000FF
+:1001E00043C0000041C000003FC000003DC000000F
+:1001F0003BC000000C9420140C94D8140F0411047C
+:1002000013041504170419041B041D04DB0B010C53
+:10021000280C510C5A0C5F0CA40CA90CC80CCF0C68
+:100220006B0C730C7B0C860C880C8A0C920C9A0C51
+:1002300011241FBECFEFCDBFDFE2DEBF10E2A0E092
+:10024000B0E2E2EDFBE202C005900D92AA3BB107DD
+:10025000D9F72DE2AAEBB0E201C01D92AC3FB20784
+:10026000E1F794D20C94E715CBCE84E0809356004E
+:100270008CE1C0D3809363008BEB8093660080E8B1
+:100280008093650081E08093600088ED84BF1092C8
+:10029000410083E080935000809151008330E1F76A
+:1002A0008091500081608093500088E180935500D8
+:1002B0008091510080FFFCCF80915000806180933D
+:1002C00050008091510084FFFCCF88ED84BF84E012
+:1002D000809340000895E0E7F0E085818E7F85837C
+:1002E000E0E0FAE08FEB9DE586A397A380EE9EE227
+:1002F00080A391A382E0808308958091200A909149
+:10030000210A813E2EE2920718F020919E2306C01A
+:10031000803E2EE2920721F020919B2320936A00D9
+:1003200020910520222321F080910520815033C0A7
+:10033000885F9A42813D974080F11092BA20809167
+:10034000BB209091BC20A091BD20B091BE20019611
+:10035000A11DB11D8093BB209093BC20A093BD2014
+:10036000B093BE208091BB209091BC20A091BD2075
+:10037000B091BE20892F9A2FAB2FBB278093BE232D
+:100380008091BB209091BC20A091BD20B091BE2057
+:100390008093BD2386E08093052080910720909173
+:1003A00008200196B1F4809109208F3F91F080914F
+:1003B0000620811106C0809106208150809306207E
+:1003C00008958091140190911501809307209093D6
+:1003D00008200895009709F45EC00CF457C040E06F
+:1003E00020916B0030E020939C2330939D2320913B
+:1003F0009C2330919D233695322F222737952795C0
+:1004000020939C2330939D2350916A0020919C233C
+:1004100030919D23250F311D20939C2330939D23E4
+:10042000000020919C2330919D232817390728F440
+:1004300010929C2310929D23089520919C2330912B
+:100440009D23280F391F2115304238F08FEF9FE18F
+:1004500080939C2390939D23089520919C23309119
+:100460009D23442329F0A901481B590BCA0102C04E
+:10047000820F931F80939C2390939D2380919C23B4
+:1004800090919D238F7780936A000895919581952F
+:10049000910941E0A5CF0895CF93DF93C091200A41
+:1004A000D091210A80910320909104209E01281B65
+:1004B000390B20939F233093A0238091BA20811180
+:1004C0004BC080919F239091A0238E3C9F4FD4F4EA
+:1004D00080919F239091A0238B369F4F9CF0809119
+:1004E0000220882321F080910220815008C0809151
+:1004F0006A0080939E2381E08093BA208CE08093F1
+:1005000002202AC08CE08093022080919F2390914A
+:10051000A0238A369F4F1CF08FEF9FEF02C081E02F
+:1005200090E08093992390939A2380919F239091B8
+:10053000A0232091992330919A2360E370E00E94D8
+:10054000BE15261B370B2093992330939A23809155
+:10055000992390919A233EDF8091BA20813029F52A
+:1005600080919F239091A023C39794F080910220C3
+:10057000882331F08091022081508093022015C0A1
+:1005800080916A0080939B2383E08093BA200DC002
+:1005900080919F239091A023873991051CF481E0DD
+:1005A00090E002C08FEF9FEF15DFC0930320D09340
+:1005B0000420DF91CF9108958617970779F0681787
+:1005C000790728F49C01261B370BB90109C086174F
+:1005D000970718F4681B790B03C0089560E070E07A
+:1005E000CB010895CF93DF9380910020909101205B
+:1005F000892B51F0809100209091012001978093E8
+:1006000000209093012043C080E490E0809300207C
+:100610009093012080910720909108200196B9F1D4
+:10062000809114019091150120910920263018F431
+:1006300067E771E002C06EEE72E00E94AA15EC015D
+:1006400080910720909108208C179D0758F46091A5
+:10065000072070910820CE01AFDF029718F080ECE0
+:100660009DE511C08091072090910820C817D907F7
+:1006700070F46091072070910820CE019DDF0297F1
+:1006800030F08FEB9DE58093360A9093370ADF9127
+:10069000CF910895AC01460F571F861B970B2091F1
+:1006A000200A3091210A24173507C8F72091200A23
+:1006B0003091210A8217930790F70895E0E8F6E059
+:1006C0008FE0808385E0848308951F93CF93DF9329
+:1006D000C0E4D0E0198180E4898340E250E064ED19
+:1006E0007DE280E290E00E94390F1983DF91CF9183
+:1006F0001F9108951F93CF93DF93C0E4D0E0198139
+:1007000080E4898387ED97E20E94810F81E00E9457
+:10071000930F1983DF91CF911F91089508950F933F
+:100720001F93842F242F30E0215831099DE7929F99
+:10073000A001939F500D112490910920953048F409
+:10074000843810F049585E4F9091C42027E731E07B
+:1007500004C09091C4202EEE32E0929FB001939F8E
+:10076000700D11249A01260F371FA9014850584DCA
+:100770000FE813E02DE730E060E00E944B131F917B
+:100780000F9108951CBEEEEFF0E409949EDF809176
+:10079000D42D882369F080E2E4EDFDE2A7EDB7E215
+:1007A00001900D928A95E1F71092D727A3DFEADF37
+:1007B00087E08093A200789458DDB0DF86D765D1BA
+:1007C00088D160E080E01FD10BD18CE0FFD04AD50A
+:1007D000EED507D673DF60EA70E28AEA93E20E9400
+:1007E000E015000000000000000000000000000014
+:1007F00000000000000000000000000000008091E8
+:10080000BF20882371F3E091D6258E2F90E08830A9
+:100810009105A0F4FC01E250FF4F0C94D11585D155
+:100820000DC0F5D10BC07CD209C000D307C08CD35A
+:1008300005C012D403C011D401C082D41092BF20CD
+:10084000D0CF08950895809114018093B3238091AF
+:1008500015018093B423809124018093B523809166
+:1008600025018093B6238091200A8093BF23809135
+:10087000210A8093C0238091140190911501863440
+:10088000914080F08091140190911501893A914036
+:1008900048F480911401909115018093F42D909368
+:1008A000F52D00008091C220882339F014DD1092CC
+:1008B000C22081E08093C12008958091C1208823C7
+:1008C00041F08091BA20833019F417DD8BDE01C02E
+:1008D000E3DD8091C020882351F080911401909134
+:1008E00015018093F42D9093F52D1092C0208091E6
+:1008F00009202091140130911501853028F481E000
+:100900002737314030F004C081E02E3E324008F0FD
+:1009100080E08093C42008950F931F9381E080931B
+:10092000C7208093C2200FE813E02DE730E048EFA6
+:1009300057E260E081E80E944B132DE730E045E785
+:1009400058E260E082E80E944B132DE730E042EF6E
+:1009500058E260E083E80E944B132DE730E04FE659
+:1009600059E260E084E80E944B132DE730E04CEE42
+:1009700059E260E085E80E944B132DE730E049E63C
+:100980005AE260E086E80E944B1381E01F910F91CC
+:1009900008951092C720089581E0089581E0089598
+:1009A00010922002982F9C7193689093200287FFE9
+:1009B00003C090E182E002C090E080E0892B809348
+:1009C000210210922202109226020895E0E0F2E045
+:1009D00010AA836880AB80E181AB12AA16AA0895A1
+:1009E000E0E0F2E010A683E880A78FE281A712A6DC
+:1009F00016A60895AAECB1E092E09C93E82FF0E0EF
+:100A000084911C920895909171009D7F9093710044
+:100A100010920002623011F09CE101C09EE19093BF
+:100A2000010290E490930202811102C080E401C0AF
+:100A300080EC80930302613011F084E001C083E018
+:100A40008093040280E2D6DF80930C0281E2D2DF41
+:100A500080930D02109218021092190281E0809387
+:100A60000002BECF1F920F920FB60F9211248F93E8
+:100A7000000000000000000081E0809323028F91BD
+:100A80000F900FBE0F901F901895CF93DF93E0E764
+:100A9000F0E082818B7F8283C0E2D3E08DE08883A7
+:100AA00080E4898389E08A8383E3A4DF888782E303
+:100AB000A1DF898787E39EDF8A8786E39BDF8B87B9
+:100AC000E0E2F6E08081836080831482DF91CF9141
+:100AD0000895E0E7F0E080818E7F808383E8809353
+:100AE00000010895E0E0F1E0108A80E4808B10A21C
+:100AF00080A310AA80ABE0E4F1E010828083109222
+:100B0000C6201092C52081E08093C4201092A823B3
+:100B10001092A9231092A6231092A72308958093E0
+:100B2000D62581E08093BF200895CF93DF93109264
+:100B30000920D8DFC0E0D1E01EAA84E288AB19AA60
+:100B400049E54AAB32E03BAB60910B2070910C2041
+:100B50006CAB7DAB67ED75E268AF79AF1AAE9BE326
+:100B60009CAF93E090933D0110923E0128A920682C
+:100B700028AB10924601E0E4F1E08083109241013D
+:100B8000409342019093430140910D2050910E20DB
+:100B9000409344015093450146EC53E24093480191
+:100BA0005093490110924A0129E320934C019093FC
+:100BB0004D0110924E01908190689083188A90E4C4
+:100BC000988B888B198A95E99A8B90E19B8B4EEED6
+:100BD00052E04C8B5D8B888F398F1A8E88EF97E2AD
+:100BE0008C8F9D8F1E8E68EC70E084EF91E052DD5B
+:100BF00088EC90E0809307209093082081E0809318
+:100C0000062088898068888BDF91CF9108951F9393
+:100C1000CF93DF9311E01093092064DFC0E0D1E0AF
+:100C200018AA80E488AB84E088AB19AA1AAA4BE41E
+:100C30004BAB1CAA1DAA1EAA8AE090E288AF99AF0E
+:100C40001AAE60EA6CAF38E030933D0110923E017D
+:100C500088A9806A88ABE0EAF8E085E58083808334
+:100C600010924601E0E4F1E084E2808310924101B9
+:100C700099E59093420122E020934301A0910B203B
+:100C8000B0910C20A0934401B0934501A7EDB5E2CB
+:100C9000A0934801B093490110924A019BE39093BD
+:100CA0004C0193E090934D0110924E019081906819
+:100CB000908388A319A295E99AA34BA34EEE52E024
+:100CC0004CA35DA368A739A71AA666EE7AE26CA7C3
+:100CD0007DA71EA6888B198A9A8B90E19B8B4C8BE3
+:100CE0005D8B888F298F1A8E88EF97E28C8F9D8F6E
+:100CF0001E8E68EC70E084EF91E0CCDC88EC90E034
+:100D000080930720909308201093062088A1806884
+:100D100088A388898068888BDF91CF911F9108957F
+:100D20001F93CF93DF9312E010930920DBDEC0E026
+:100D3000D1E01EAA84E288AB19AA39E53AAB1BAB15
+:100D400040910B2050910C204CAB5DAB47ED55E230
+:100D500048AF59AF1AAE9BE39CAF93E090933D012F
+:100D600010923E0128A9206828AB10924601E0E4C9
+:100D7000F1E080831092410130934201909343014E
+:100D800020910D2030910E20209344013093450195
+:100D900026EC33E2209348013093490110924A0136
+:100DA00029E320934C0190934D0110924E019081C4
+:100DB00090689083188A90E4988B888B198A45E90B
+:100DC0004A8B90E19B8B2EEE32E02C8B3D8B888FF3
+:100DD000198F1A8E68EF77E26C8F7D8F1E8E88A335
+:100DE00019A24AA39BA32CA33DA384E388A719A718
+:100DF0001AA686EE9AE28CA79DA71EA668EC70E064
+:100E000084EF91E047DC88EC90E08093072090939A
+:100E1000082081E08093062088898068888B88A1DB
+:100E2000806888A3DF91CF911F9108951F93CF937E
+:100E3000DF9313E01093092055DEC0E0D1E010925B
+:100E40004601E0E4F1E084E280831092410129E56B
+:100E50002093420192E09093430140910B205091E6
+:100E60000C20409344015093450147ED55E24093D7
+:100E700048015093490110924A019BE390934C0121
+:100E800010934D0110924E019081906890831EAA9C
+:100E900088AB19AA2AAB1BAB20910D2030910E20F4
+:100EA0002CAB3DAB26EC33E228AF39AF1AAE99E359
+:100EB0009CAF10933D0110923E0198A9906898ABA9
+:100EC00018A250E458A394E098A319A21AA24BE4E4
+:100ED0004BA31CA21DA21EA22AE030E228A739A71C
+:100EE0001AA630EA3CA728E02DA71EA698A1906A72
+:100EF00098A395E59093A008188A588B888B198A37
+:100F000085E98A8B4B8B8EEE92E08C8B9D8B388F94
+:100F1000298F1A8E88EF97E28C8F9D8F1E8E68EC3A
+:100F200070E084EF91E0B6DB88EC90E080930720DE
+:100F30009093082081E08093062088898068888BC0
+:100F4000DF91CF911F9108951F93CF93DF9314E00A
+:100F500010930920C7DDC0E0D1E018AA80E488AB77
+:100F600018AB19AA1AAA3BE43BAB1CAA1DAA1EAADD
+:100F70008AE090E288AF99AF1AAE50EA5CAF88E0A1
+:100F800080933D0110923E0198A9906A98AB95E537
+:100F90009093A00810924601E0E4F1E094E290837F
+:100FA0001092410129E52093420122E02093430160
+:100FB00060910B2070910C20609344017093450167
+:100FC00067ED75E2609348017093490110924A0100
+:100FD0002BE320934C0123E020934D0110924E010E
+:100FE000208120682083988B198A45E94A8B3B8BA6
+:100FF0002EEE32E02C8B3D8B588F898F1A8E68EF46
+:1010000077E26C8F7D8F1E8E98A319A24AA39AE473
+:101010009BA32CA33DA393EC98A789A71AA686EEC1
+:101020009AE28CA79DA71EA668EC70E084EF91E081
+:1010300031DB88EC90E0809307209093082081E0DA
+:101040008093062088898068888B88A1806888A31F
+:10105000DF91CF911F910895FFCFCF93DF9386E06B
+:10106000809309203FDDC0E0D1E01EAA84E288AB76
+:1010700019AA39E53AAB93E09BAB40910D20509112
+:101080000E204CAB5DAB46EC53E248AF59AF1AAE05
+:1010900029E32CAF90933D0110923E0128A92068CE
+:1010A00028AB10924601E0E4F1E080831092410108
+:1010B0003093420122E02093430140910B20509154
+:1010C0000C20409344015093450147ED55E2409375
+:1010D00048015093490110924A013BE330934C017F
+:1010E00090934D0110924E01908190689083188AE0
+:1010F00090E4988B888B198A95E99A8B90E19B8B69
+:101100004CED55E04C8B5D8B888F298F1A8E88EFC4
+:1011100097E28C8F9D8F1E8E68EC70E084EF91E0DB
+:10112000B9DA80E991E0809307209093082081E06C
+:101130008093062088898068888BDF91CF910895FD
+:10114000CF93DF9387E080930920CCDCC0E0D1E02F
+:101150001EAA84E288AB19AA39E53AAB93E09BABAF
+:1011600040910D2050910E204CAB5DAB46EC53E20C
+:1011700048AF59AF1AAE29E32CAF90933D011092BE
+:101180003E0128A9206828AB10924601E0E4F1E076
+:101190008083109241013093420122E02093430169
+:1011A00040910B2050910C204093440150934501F5
+:1011B00047ED55E2409348015093490110924A018E
+:1011C0003BE330934C0190934D0110924E0190817E
+:1011D00090689083188A90E4988B95E2988B198A8E
+:1011E00095E99A8B90E19B8B4CED55E04C8B5D8B98
+:1011F000888F298F1A8E88EF97E28C8F9D8F1E8E95
+:1012000068EC70E084EF91E045DA80E991E080934A
+:1012100007209093082081E08093062088898068C9
+:10122000888BDF91CF9108951F920F920FB60F9286
+:1012300011248F9381E0809303018F910F900FBE53
+:101240000F901F9018951F920F920FB60F921124B6
+:101250008F9382E0809303018F910F900FBE0F90C8
+:101260001F901895E0E7F0E083818C7F8383848171
+:101270008C7F848380818D7F8083E0E8F1E080EC47
+:101280008283128688EC81831186A0E0B8E034E086
+:101290003C9323E011962C93119714961C9214976B
+:1012A00085ED91E096968D939C93979716961C9258
+:1012B0001697E0E4F8E030832183148286A397A395
+:1012C0001682E0E6F6E0808180618083E0E4F9E068
+:1012D00083E18183148282E08683A6A3B7A310A64C
+:1012E00011A681E0808308951F920F920FB60F928E
+:1012F00011242F933F934F935F938F939F93CF939B
+:10130000DF931F92CDB7DEB78FEF80934C098091AA
+:101310000920873031F480912C02898390912D022D
+:1013200002C090912C028091C320891B20916809F2
+:101330003091690982308CF02A3F374070F4209157
+:1013400068093091690989301CF481E090E002C09D
+:1013500086E090E0820F931F18C0209168093091B9
+:1013600069098F3FB4F42730310598F0209168095E
+:1013700030916909883F1CF081E090E002C086E06E
+:1013800090E0A901481B590BCA01809378099093FA
+:1013900079090F90DF91CF919F918F915F914F913C
+:1013A0003F912F910F900FBE0F901F901895E0E77F
+:1013B000F0E083818F7E8383E0E4F6E080818A6AB7
+:1013C00080838FEF848388E5828BE0EAF8E080E316
+:1013D000838384EC858387E08683178288E1848316
+:1013E0000895E0E7F0E08381877F8383E0ECF8E015
+:1013F00080E48083118288E58093550608951F92CA
+:101400000F920FB60F92112400000F900FBE0F9095
+:101410001F9018951F920F920FB60F9211248F9361
+:10142000EF93FF93E0EAF8E080818083FF91EF91F2
+:101430008F910F900FBE0F901F9018959FB7F89443
+:10144000A0E5B0E016968C911697897F16968C933E
+:101450001697E0E6F0E080E885838BEB86831696AE
+:101460008C911697846016968C938081816080831E
+:101470009FBF08959FB7F894E82FF0E0E059FF4F21
+:1014800060958081682360839FBF0895CF938630E5
+:1014900011F0C0E001C0C8E18091510081FD0DC094
+:1014A0009FB7F894809150008260809350009FBF56
+:1014B0008091510081FFFCCFC1DF6C2F636084E419
+:1014C00090E0BCD460E480E0CF91D4CF8091C8207C
+:1014D00008958091C820813009F45BCA0895F0D046
+:1014E000FC0183818093C820811101C015CA81E06D
+:1014F00008959091C625892F807697FF07C0803484
+:1015000091F48091C72581110EC048CA803459F4E6
+:101510008091C725811107C08091CC259091CD2560
+:10152000892B09F039CA80E008958091C8258F770A
+:101530000C94CD129091D020911102C080E00895BA
+:10154000E091CD20F091CE200190F081E02D9481AA
+:101550008917A0F7E093CB20F093CC202281338130
+:101560002E0F3F1FE217F30798F49181943061F436
+:101570009281891309C09381691306C0E093CB203F
+:10158000F093CC2081E008959081E90FF11DEACF1E
+:10159000E093CB20F093CC20D1CFE091CD20F091FF
+:1015A000CE200190F081E02D228133812E0F3F1F4C
+:1015B000FC014081E40FF11DE217F30748F481813B
+:1015C000843031F0853039F08081E80FF11DF4CF9F
+:1015D00080E090E00895CF0108951F93CF93DF93AB
+:1015E000182FA8DF882339F1C091CB20D091CC20CF
+:1015F000CE01D3DFEC01892B41F04C815D816B8101
+:101600008A81D8D78111F4CF16C0E091CD20F09116
+:10161000CE2092818381E92FF82FE10FF11DE10F98
+:10162000F11D0190F081E02D0190F081E02DDF911E
+:10163000CF911F91099480E0DF91CF911F91089580
+:10164000EF92FF921F93CF93DF93C82F60E072DF7A
+:10165000811102C010E02DC0E091CD20F091CE208C
+:1016600092818381E92FF82FEC0FF11DEC0FF11D12
+:10167000E080F180D7011696ED91FC9117970995BE
+:10168000682F8C2F57DF182F882321F3C091CB2090
+:10169000D091CC20CE0181DFEC01892B21F08A8111
+:1016A0000E940714F7CFD7011296ED91FC91139782
+:1016B0000995812FDF91CF911F91FF90EF900895B1
+:1016C0008091CB209091CC200895FBC6CF93809140
+:1016D000D020811108C01092D0201092D4201092F6
+:1016E000D520CF910895C0E0E091CD20F091CE209B
+:1016F0000190F081E02D8481C81768F78C2FA0DF5E
+:10170000CF5FF2CFCF938091D0208823F1F0C0E05B
+:10171000E091CD20F091CE20A081B18114968C91E2
+:10172000C81798F492818381E92FF82FEC0FF11DEF
+:10173000EC0FF11D0190F081E02D0084F185E02D8A
+:10174000309709F00995CF5FE3CFCF910895EF92DD
+:10175000FF920F931F93CF93DF931F92CDB7DEB706
+:101760001092D0251092D1251092D2251092D32517
+:101770001092D4251092D5258091C62587FF07C0E9
+:101780002091CC253091CD25232B09F44EC3982FE1
+:101790009076903409F00BC1E091C7258E2F90E030
+:1017A000FC01E05AF109EA30F10508F0CDC2EA5F28
+:1017B000FE4F0C94D11581E08093C02080910720CA
+:1017C000909108208093B723809107209091082062
+:1017D0009093B82380919E238093B92380919B237B
+:1017E0008093BA2380916A008093BB2380916B0021
+:1017F0008093BC236091CC257091CD258AEA93E239
+:10180000D4C0109200088091C8259091C92580937A
+:101810003608909337088091CA258F70809300080E
+:101820006091CC257091CD2586EC93E2BCD62091B9
+:101830000D2030910E208091CC259091CD25281738
+:10184000390709F4F0C280930D2090930E2026C032
+:10185000109240088091C8259091C9258093760800
+:10186000909377088091CA258F708093400860918B
+:10187000CC257091CD2587ED95E295D620910B2052
+:1018800030910C208091CC259091CD2528173907D7
+:1018900009F4C9C280930B2090930C2080910920F9
+:1018A00051C010926809109269098091C8258093EF
+:1018B000C320B9C28091C82580932406B4C2E091A8
+:1018C000C825F091C925E830F10508F03DC2E05F78
+:1018D000FE4F0C94D11560E080E095D88091CA2528
+:1018E0005FD880E02FC060E080E08DD88091CA256D
+:1018F00057D881E027C061E081E085D88091CA2572
+:101900004FD88091CB2562D882E01CC083E01AC0FA
+:1019100084E018C060E080E076D88091CA2540D885
+:1019200085E010C061E080E06ED88091CA2538D88B
+:1019300086E008C062E080E066D88091CA258068B1
+:101940002FD887E0ECD86FC28091C8258093840699
+:101950006AC28091C8259091C925892B91F00E9477
+:10196000650380E2E4EDFDE2A7EDB7E201900D92A0
+:101970008A95E1F781E08093D7270E947A030E943D
+:101980006503E9E7F0E091E088EDF89484BF908387
+:101990006091CC257091CD258AEA90E206C06091D5
+:1019A000CC257091CD2589EA90E2FDD53CC29111FC
+:1019B000CBC187FFFCC02091CC253091CD252115CE
+:1019C000310509F4C1C18F7109F09EC08091C7250E
+:1019D000863071F0883009F48EC08111B5C1223093
+:1019E000310509F0B1C162E070E084ED90E2DDCF35
+:1019F0008091C8259091C925292F332722303105A0
+:101A0000A1F064F42130310509F09EC180911920C4
+:101A100090911A20DC016C9170E05BC0233031059D
+:101A200089F12F30310509F18FC1E0911920F09132
+:101A30001A202189821708F087C19927880F991FDA
+:101A4000880F991FE0911B20F0911C20E80FF91FCF
+:101A500080819181FC0162817381A5D5E091CE25C1
+:101A6000F091CF2582E0818335C080911D20909137
+:101A70001E20009709F468C1DC0112966D917C91DB
+:101A8000139727C099278130910569F038F00297A4
+:101A900009F05AC168E08AE890E208C064E070E0AA
+:101AA0008CE990E216C067E083E990E2282FAAE76C
+:101AB000B0E2FC01819190E08D939D938E2F821B6B
+:101AC0008617C0F3660F6E5F6093782070E088E73A
+:101AD00090E269D58091CC259091CD252091D0259B
+:101AE0003091D1258217930708F09DC18093D025AE
+:101AF0009093D12598C12130310509F025C161E0CD
+:101B000070E080ED90E251CF8130C9F58091C7251A
+:101B10008A3009F019C12130310509F015C18091D1
+:101B2000D020882309F410C1E090CA25F090CB257D
+:101B30000091CD201091CE20D801ED91FC918481AF
+:101B4000E81608F001C160E08E2DF4DC882309F46A
+:101B5000FBC0FF24EE0CFF1CF801828193818E0DE7
+:101B60009F1DDC01ED91FC910680F781E02D099528
+:101B70008093D22061E070E082ED90E216CF823057
+:101B800009F0E2C08091C7258111DEC02230310505
+:101B900009F0DAC08091CA255ED590E08093C92013
+:101BA0009093CA2062E070E089EC90E2FECE8F71E3
+:101BB00009F07DC08091C725833009F4C5C018F4B1
+:101BC0008130A1F0C1C0853019F0893039F1BCC035
+:101BD0008091CC259091CD25892B09F0B5C085E960
+:101BE0009AE08093D2259093D3251DC18091CC2576
+:101BF0009091CD25892B09F0A7C08091C82590919F
+:101C0000C925019709F0A0C08091D4209091D520DA
+:101C10008D7F8093D4209093D52005C18091CC25D1
+:101C20009091CD25892B09F08FC0BAD4882309F46F
+:101C30008BC02091C8253091C9253327E091192008
+:101C4000F0911A20818990E08217930708F47CC0F4
+:101C50003DDD8091C8259091C9258093D0208823AF
+:101C600009F4E1C099278150904C880F991F880F83
+:101C7000991F20911B2030911C20820F931F80936D
+:101C8000CD209093CE2010E0E091CD20F091CE2099
+:101C90000190F081E02D8481181708F0C4C060E045
+:101CA000812F9BDC882309F44FC01F5FEDCF81306B
+:101CB000F1F48091C7258B3009F046C08091CC2586
+:101CC0009091CD25892B09F03FC08091D0208823A9
+:101CD00009F43AC01091CA256091C825812F698303
+:101CE000AFDC6981882381F1812F77DC2BC08230C2
+:101CF00059F58091C725813019F0833089F024C0CF
+:101D00008091CC259091CD25892BF1F48091C82527
+:101D10009091C925892BC1F48091CA25A3D412C002
+:101D20008091CC259091CD25892B71F48091C82587
+:101D30009091C925892B41F48091CA2538D580918D
+:101D4000CA256ED581116FC08091C6258F718130F3
+:101D5000B9F58091D020882399F1E090CA25F090C0
+:101D6000CB250091CD201091CE20D801ED91FC9192
+:101D70008481E81628F560E08E2DDCDB882301F1F4
+:101D8000F701FF27EE0FFF1FD80112968D919C914E
+:101D90001397E80FF91F00811181D8011696ED9174
+:101DA000FC9117970995682F8E2DC4DB882341F08D
+:101DB000D8011496ED91FC9115970995811133C0C6
+:101DC0008091C6258F71823081F58091D020882343
+:101DD00061F1F12CE091CD20F091CE20A081B18174
+:101DE00014968C91F81608F592818381E92FF82FCB
+:101DF000EF0DF11DEF0DF11D00811181D801169637
+:101E0000ED91FC9117970995682F8F2D93DB88230F
+:101E100061F0D8011496ED91FC9115970995811107
+:101E200002C0F394D7CF81E001C080E00F90DF9132
+:101E3000CF911F910F91FF90EF9008951BBEFC0171
+:101E400028ED24BF608308958091CF0187FDFCCFEA
+:101E500008951F93CF93DF93C0ECD1E01A858A8752
+:101E600061E08BEC91E0EADF1A87DF91CF911F915F
+:101E70000895CF92DF92EF92FF920F931F93CF932B
+:101E8000DF9300D0CDB7DEB78C017B0149835A8345
+:101E9000DBDF8CECC82EDD24D394F60190819860B2
+:101EA0009083B801705F49815A81C70180D6F601DD
+:101EB0008081877F80830F900F90DF91CF911F915A
+:101EC0000F91FF90EF90DF90CF900895CF93DF9325
+:101ED00000D0CDB7DEB76A838983B6DFACECB1E062
+:101EE0009C9198609C938981E82FF0E0F05F6A8173
+:101EF00060838C91877F8C930F900F90DF91CF91AF
+:101F000008950F931F93CF938C019EDFC0E0F801DB
+:101F100061918F018C2FDADFCF5FC032C1F7CF9193
+:101F20001F910F910895CF93DF931F92CDB7DEB726
+:101F300089838ADF898120E2829FC0011124E0EC3D
+:101F4000F1E012829183808385E30F90DF91CF913E
+:101F500080CF4091CA01E62FF72F8093CA01849168
+:101F60004093CA010895E82FF0E0EA50F24D8081D5
+:101F70008F3F09F4FFCF9FB7F89480818F5F8083F4
+:101F80009FBF0895E82FF0E0EA50F24D8081811163
+:101F900001C0FFCF9FB7F8948081815080839FBF9D
+:101FA0000895CF93C82F80919823C11105C088232D
+:101FB00039F081E0E7DF04C0811102C081E0D3DFA6
+:101FC000C0939823CF910895282F2F70082E000CCE
+:101FD000990B392F331F3327331F832F90E0820F44
+:101FE000911D820F911D23E0880F991F2A95E1F71B
+:101FF0008C5D9C4D08950F93E8ECF4E080818F7D1B
+:10200000808380818F7D8083ECE2F3E202E00593A0
+:1020100010922E2310922F2300E2069300E40693E1
+:10202000E4E2F3E200E2069300E40693E6ECF5E274
+:102030001486158616861786128613861092072335
+:102040000F9108950F9385E080930723EDE2F3E26B
+:1020500004E00593E5E2F3E204E005930F910895AF
+:102060000F9383E08093072310922E2310922F2347
+:10207000ECE2F3E202E006930F910895E091D2259D
+:10208000F091D325309709F009940895282F2F70E7
+:10209000082E000C990B392F331F3327331F832F42
+:1020A00090E0820F911D820F911D029749E0489F99
+:1020B0009001499F300D1124C901895A9D4D089501
+:1020C0008F929F92AF92BF92DF92EF92FF920F9307
+:1020D0001F93CF93DF93D82ED9DFEC018D2D74DFC2
+:1020E0007C01DC011196EC91E770E150E73040F49F
+:1020F000F0E0EE0FFF1FE455FF4D0081118102C09B
+:1021000008E010E0ED81FE812B813C814881D70100
+:10211000D7FE48C016968D919C9117978E0F9F1FE2
+:102120008D839E838217930761F1281B390B21153C
+:10213000B4E03B0738F02FEF33E0C901B8010AD50E
+:10214000281B390B41FF0AC0C901B80103D5AC01F6
+:1021500091E0452B09F090E0892F01C080E0988143
+:1021600080FB91F99883F7011682178222833383CB
+:1021700029813A818D819E81820F931F848395836B
+:102180000EC041FF71C04D7F4883D70116961D9246
+:102190001C92179712961D921C921397F70102E05A
+:1021A00006937BC01296AD90BC90139742FF10C06F
+:1021B00089809A80C901B801CDD4B0E4DB9EB0011A
+:1021C000112469567F4DAC01C4018E0F9F1FEFD4BF
+:1021D0008D819E818A0D9B1D8D839E832B813C81E9
+:1021E0002817390710F42D833E83F70186819781E4
+:1021F000A816B906C9F58D819E8182179307A1F1B2
+:10220000281B390B2115F4E03F0710F02FEF33E0C6
+:10221000C901B8019FD4281B390BD70112961D9212
+:102220001C9213972017310778F488818460888383
+:10223000B0E4DB9EC001112489569F4DF7018483D1
+:10224000958306831783AACF49815A818D819E8108
+:10225000840F951FD70114968D939C93159716960E
+:102260002D933C9317979ACF888180FF16C08E7F5D
+:102270008883EF81F885309781F06D817E814D2DC7
+:1022800080E0DF91CF911F910F91FF90EF90DF9051
+:10229000BF90AF909F908F900994DF91CF911F9145
+:1022A0000F91FF90EF90DF90BF90AF909F908F9035
+:1022B00008950F93CF93DF9380910723833029F400
+:1022C000DDDEDF91CF910F9196CE209103233091E7
+:1022D0000423C091D025D091D125C21BD30B61F529
+:1022E0008091052390910623820F931F80930523ED
+:1022F000909306232091CC253091CD2528173907BE
+:1023000021F08091D620882331F084E08093072348
+:10231000E4E2F3E236C0E091D425F091D525309780
+:1023200099F00995882381F01092032310920423D9
+:10233000C091D025D091D125C034D10528F010927C
+:10234000D620C0E4D0E003C081E08093D620C093C3
+:102350002E23D0932F238091032390910423209147
+:10236000CE253091CF25280F391F2093302330936D
+:102370003123C80FD91FC0930323D0930423ECE269
+:10238000F3E202E00693DF91CF910F9108950F934E
+:10239000CF93DF931F92CDB7DEB78091CC0480FF3F
+:1023A00065C021E02093CC0484E293E2FC0100E8C4
+:1023B0000693ECE2F3E200E806932093CA04FC01E2
+:1023C00000E1069380910723882329F0835082300F
+:1023D00008F454DE10DE809126239091272308977D
+:1023E00009F046C088E0E3ECF2E2A6ECB5E2019029
+:1023F0000D928A95E1F78091C80480628093C804A9
+:102400008091C80480628093C804A1D9811102C060
+:1024100019DE2EC09091C62597FF0EC0109205239D
+:1024200010920623109203231092042392E09093BB
+:10243000072389833EDF08C02091CC253091CD252C
+:10244000232B21F489830CDE898113C0109205238C
+:1024500010920623109203231092042391E090938C
+:102460000723E4E2F3E202E0069303C080E001C048
+:1024700081E00F90DF91CF910F910895CF93CFB767
+:10248000F89481E08EDDEAECF4E080E4808380E281
+:102490008083E1ECF4E0808181608083A9ECB4E08A
+:1024A0008C9182608C93E8ECF4E08081806480837E
+:1024B0008C9181608C93808180688083CFBFCF9125
+:1024C0000895CF931092600080E30E94460A8091A5
+:1024D000C00480648093C00481E080936000CFB723
+:1024E000F89480E090E0FC0123E0EE0FFF1F2A95B6
+:1024F000E1F7E85FFC4D158E01968E30910599F756
+:1025000080E090E039E0389FF001399FF00D112410
+:10251000E95AFD4D20812E7F208301968C30910554
+:1025200091F76AE170E082E014DD8F3F09F48FE1FA
+:102530008093FA046BE170E082E00BDD8F3F09F4D9
+:102540008FE18093FB048091C00486608093C00477
+:102550008091C00480688093C0048091C004806131
+:102560008093C00484E293E28093C6049093C704EE
+:102570008091C00480628093C0048FEF8093C50473
+:102580008091C80482608093C8041092982385E0EB
+:10259000EADC74DFCFBFCF9108958093C304089520
+:1025A0008091C3040895E6ECF5E280879187628705
+:1025B000738708950F931F93CF93DF931F92CDB727
+:1025C000DEB78A01698300DDFC018181807C69813D
+:1025D00081113AC06370613019F020F080E803C0C7
+:1025E00080EC01C080E400381105E9F058F40032B5
+:1025F0001105A9F000341105A1F000311105C9F44D
+:1026000091E018C0011592E0190779F00F3F93E0AF
+:10261000190769F00115114061F495E00BC092E0D3
+:1026200009C093E007C094E005C096E003C097E0BE
+:1026300001C090E0118226E02083982B9183818154
+:102640008062818381E001C080E00F90DF91CF91B3
+:102650001F910F910895B8DCFC01818182FB8827CE
+:1026600080F90895CF93C82FAFDCFC01818182FFF0
+:102670000FC091819B7F91838C2F08DDFC0190819D
+:1026800090FF06C09E7F90830780F085E02D09951E
+:1026900081E0CF9108958F929F92AF92BF92DF9287
+:1026A000EF92FF920F931F93CF93DF931F92CDB7BB
+:1026B000DEB7D82E5A0179016983E8DC4C018D2DF3
+:1026C00083DC9C01DC0111968C911197807C6981DF
+:1026D000882309F45EC011968C911197807C803C10
+:1026E00021F011968C9182FD54C09FB7F894F401AB
+:1026F000808180FF02C09FBF4CC0816080839FBFEC
+:10270000F401A182B282E382F482158216820783E9
+:10271000108791E0611104C0E114F10409F090E028
+:10272000D4018C9190FB81F98B7F8C93D7FE04C0F0
+:10273000F9011682178229C0D90111968C9111973F
+:10274000807C803CC9F41196EC91E770E150E73051
+:1027500040F4F0E0EE0FFF1FE455FF4D6081718102
+:1027600002C068E070E0C701F5D1892B29F0F401BF
+:1027700080818E7F80830DC0D90112961D921C929C
+:10278000139716961D921C9217978D2D99DC81E058
+:1027900001C080E00F90DF91CF911F910F91FF90CA
+:1027A000EF90DF90BF90AF909F908F900895EF9241
+:1027B000FF920F93CF93C82F07DC7C018C2F66DC30
+:1027C000DC01F70102E005939C9190FF1BC09E7F06
+:1027D0009C931796ED91FC911897309799F0D7013B
+:1027E000C7FF05C016966D917C91179704C012968D
+:1027F0006D917C9113974C2F81E0CF910F91FF90B9
+:10280000EF900994CF910F91FF90EF900895CF939F
+:10281000C82FCDDF8C2FD8DBFC011182CF9108951A
+:102820000F93CF93C82FD0DBFC01918194609183EB
+:1028300001E006938C2FBBDF81E0CF910F910895CB
+:102840001F920F920FB60F9211240F932F933F9365
+:102850004F935F936F937F938F939F93AF93BF93A8
+:10286000CF93EF93FF938091CB0487FF08C080E85C
+:102870008093CA040E94820B0E94230486C0809128
+:10288000CB0482FF18C084E08093CA0480912C237B
+:1028900086FF7BC08091CC0481FD77C078DD8111FB
+:1028A00074C080910723813011F4DADB6EC084306C
+:1028B00009F06BC021C08091CB0481FF26C082E06B
+:1028C0008093CA048091242386FF5FC08091CC044A
+:1028D00081FD5BC05CDD811158C08091072382308F
+:1028E00041F484E080930723E4E2F3E202E00693FC
+:1028F0004CC0833009F049C0EDE2F3E204E00593F7
+:10290000E5E2F3E204E0059340C08091CB0484FF4C
+:1029100025C080E18093CA04C1E08C2F48DF8C2F52
+:10292000806845DFCF5FC630C1F70E94660B10920A
+:10293000C30410922523C093242383E4809325238A
+:1029400010922D23C0932C2380932D2383EC92E2AD
+:1029500080932823909329234EDB17C08091CB04CA
+:1029600086FF08C080E48093CA0480E01ADB0E94DE
+:1029700021040BC08091CB0485FF07C080E28093C7
+:10298000CA0481E00EDB0E942204FF91EF91CF91F7
+:10299000BF91AF919F918F917F916F915F914F9177
+:1029A0003F912F910F910F900FBE0F901F90189590
+:1029B0001F920F920FB60F9211240F931F932F9314
+:1029C0003F934F935F936F937F938F939F93AF93B7
+:1029D000BF93CF93DF93EF93FF938091CC0481FF5C
+:1029E0001AC082E08093CC048091C5048195880F41
+:1029F000E4E2F3E2E81BF109208131812452334201
+:102A000083E0369527958A95E1F7822F869520FDFC
+:102A100006C0C0E005C0BBDC882319F386C0C0E84F
+:102A2000C80F8C2FD1DAFC01208125FF7EC000E287
+:102A30000693C11174C080910723843019F41EDB02
+:102A4000DADA73C000912623109127238091D025D4
+:102A50009091D125C0910323D09104239E01200F92
+:102A6000311F8217930718F48C010C1B1D0B8091EA
+:102A7000CE259091CF25A80163EC72E28C0F9D1FAB
+:102A800096D0C00FD11FC0930323D09304230034EA
+:102A9000110569F480910523909106238C0F9D1FE9
+:102AA0002091CC253091CD258217930788F0C093D3
+:102AB000D025D093D125E091D425F091D52530971C
+:102AC00029F00995811102C0BDDA2FC0C9DA2DC0E5
+:102AD0008091D0259091D1258C179D07D9F4E09154
+:102AE000D425F091D525309779F30995882361F3A2
+:102AF0002091052330910623809103239091042394
+:102B0000820F931F80930523909306231092032333
+:102B100010920423E4E2F3E202E0069306C0C03818
+:102B200011F4C7DB02C08C2FCBDAFF91EF91DF915C
+:102B3000CF91BF91AF919F918F917F916F915F9155
+:102B40004F913F912F911F910F910F900FBE0F90BA
+:102B50001F901895AA1BBB1B51E107C0AA1FBB1FE2
+:102B6000A617B70710F0A61BB70B881F991F5A9519
+:102B7000A9F780959095BC01CD01089597FB072E8C
+:102B800016F4009406D077FD08D0E4DF07FC05D0EA
+:102B90003EF4909581959F4F0895709561957F4F74
+:102BA0000895EE0FFF1F0590F491E02D0994FB01AD
+:102BB000DC0102C001900D9241505040D8F70895B9
+:102BC000FB01DC0101900D920020E1F70895F894DB
+:022BD000FFCF35
+:102BD20040000CE02E0AFFFFFFFF55800080006FCF
+:102BE2000A690A790A660A000064201F2000002888
+:102BF2002023200F2000000009023C000101008078
+:102C0200FA0904000006FFFFFF00070581018000AA
+:102C12000107058201800001070583018000010789
+:102C220005840180000107058501800001070586F2
+:102C3200018000011201000200000040EB0394BA7F
+:102C42000002010200010000000300000000000079
+:102C5200000000000000000000004C61627261642C
+:102C62006F72004573706F54656B000004030904B2
+:102C72006465627567313233000103001000200081
+:0A2C82004000800000010002FF0383
+:00000001FF
diff --git a/Desktop_Interface/bin/firmware/labrafirm_0003_01.hex.REMOVED.git-id b/Desktop_Interface/bin/firmware/labrafirm_0003_01.hex.REMOVED.git-id
deleted file mode 100644
index b3667a22..00000000
--- a/Desktop_Interface/bin/firmware/labrafirm_0003_01.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f7946fd762c2bf7eaa4b76d5eb68948870244c19
\ No newline at end of file
diff --git a/Desktop_Interface/bin/firmware/labrafirm_0003_02.hex b/Desktop_Interface/bin/firmware/labrafirm_0003_02.hex
new file mode 100644
index 00000000..879125a9
--- /dev/null
+++ b/Desktop_Interface/bin/firmware/labrafirm_0003_02.hex
@@ -0,0 +1,714 @@
+:100000001FC1000039C1000037C1000035C1000028
+:1000100033C1000031C100000C94F3080C94230993
+:100020002BC1000029C1000027C1000025C100002C
+:1000300023C1000021C100001FC100001DC100003C
+:100040001BC1000019C1000017C1000015C100004C
+:1000500013C1000011C100000FC100000DC100005C
+:100060000C94200A0C942B0A07C1000005C1000063
+:1000700003C1000001C10000FFC00000FDC000007E
+:10008000FBC00000F9C00000F7C00000F5C0000090
+:10009000F3C00000F1C00000EFC00000EDC00000A0
+:1000A000EBC00000E9C00000E7C00000E5C00000B0
+:1000B000E3C00000E1C00000DFC00000DDC00000C0
+:1000C000DBC00000D9C00000D7C00000D5C00000D0
+:1000D000D3C00000D1C00000CFC00000CDC00000E0
+:1000E000CBC00000C9C00000C7C00000C5C00000F0
+:1000F000C3C00000C1C00000BFC00000BDC0000000
+:10010000BBC00000B9C00000B7C00000B5C000000F
+:10011000B3C00000B1C00000AFC0000074C4000054
+:10012000ABC00000A9C00000A7C00000A5C000002F
+:10013000A3C00000A1C000009FC000009DC000003F
+:100140009BC0000099C0000097C000000C94950966
+:1001500093C0000091C000008FC000008DC000005F
+:100160008BC0000089C0000087C0000085C000006F
+:1001700083C0000081C000007FC000007DC000007F
+:100180007BC0000079C0000077C0000075C000008F
+:1001900073C0000071C000006FC000006DC000009F
+:1001A0006BC0000069C0000067C0000065C00000AF
+:1001B00063C0000061C000005FC000005DC00000BF
+:1001C0005BC0000059C0000057C0000055C00000CF
+:1001D00053C0000051C000004FC000004DC00000DF
+:1001E0004BC0000049C0000047C0000045C00000EF
+:1001F00043C000000C9437140C94E514FC03FE0378
+:10020000000402040404060408040A041C041E0476
+:10021000200422042404290426042804FC0B220CB4
+:10022000490C720C7B0C800CC90CCE0CED0CF40C40
+:100230008C0C940C9C0CA80CAA0CAC0CB50CBE0C31
+:1002400011241FBECFEFCDBFDFE2DEBF10E2A0E082
+:10025000B0E2ECEEFBE202C005900D92AA39B107C4
+:10026000D9F72BE2AAE9B0E201C01D92A03EB20785
+:10027000E1F779D20C94F415C3CE84E08093560054
+:100280008CE189D3809363008BEB8093660080E8D8
+:100290008093650081E08093600088ED84BF1092B8
+:1002A000410083E080935000809151008330E1F75A
+:1002B0008091500081608093500088E180935500C8
+:1002C0008091510080FFFCCF80915000806180932D
+:1002D00050008091510084FFFCCF88ED84BF84E002
+:1002E000809340000895E0E7F0E085818E7F85836C
+:1002F000E0E0FAE08FEB9DE586A397A380EE9EE217
+:1003000080A391A382E0808308958091200A909138
+:10031000210A813E2EE2920718F02091822106C028
+:10032000803E2EE2920721F020917F2120936A00E7
+:1003300020910520222321F080910520815033C097
+:10034000885F9A42813D974080F110929A20809177
+:100350009B2090919C20A0919D20B0919E20019681
+:10036000A11DB11D80939B2090939C20A0939D2064
+:10037000B0939E2080919B2090919C20A0919D20E5
+:10038000B0919E20892F9A2FAB2FBB278093A2215B
+:1003900080919B2090919C20A0919D20B0919E20C7
+:1003A0008093A12186E08093052080910720909181
+:1003B00008200196B1F4809109208F3F91F080913F
+:1003C0000620811106C0809106208150809306206E
+:1003D00008958091140190911501809307209093C6
+:1003E00008200895009709F45EC00CF457C040E05F
+:1003F00020916B0030E02093802130938121209167
+:100400008021309181213695322F222737952795EB
+:10041000209380213093812150916A002091802186
+:1004200030918121250F311D20938021309381212E
+:10043000000020918021309181212817390728F46C
+:100440001092802110928121089520918021309175
+:100450008121280F391F2115304238F08FEF9FE19D
+:100460008093802190938121089520918021309163
+:100470008121442329F0A901481B590BCA0102C05C
+:10048000820F931F809380219093812180918021FE
+:10049000909181218F7780936A000895919581953D
+:1004A000910941E0A5CF0895CF93DF93C091200A31
+:1004B000D091210A80910320909104209E01281B55
+:1004C000390B209383213093842180919A208111CC
+:1004D0004BC080918321909184218E3C9F4FD4F416
+:1004E00080918321909184218B369F4F9CF0809145
+:1004F0000220882321F080910220815008C0809141
+:100500006A008093822181E080939A208CE080931E
+:1005100002202AC08CE08093022080918321909158
+:1005200084218A369F4F1CF08FEF9FEF02C081E03D
+:1005300090E080937D2190937E2180918321909102
+:10054000842120917D2130917E2160E370E00E9422
+:10055000CB15261B370B20937D2130937E21809174
+:100560007D2190917E213EDF80919A20813029F576
+:100570008091832190918421C39794F080910220EF
+:10058000882331F08091022081508093022015C091
+:1005900080916A0080937F2183E080939A200DC030
+:1005A0008091832190918421873991051CF481E009
+:1005B00090E002C08FEF9FEF15DFC0930320D09330
+:1005C0000420DF91CF9108958617970779F0681777
+:1005D000790728F49C01261B370BB90109C086173F
+:1005E000970718F4681B790B03C0089560E070E06A
+:1005F000CB010895CF93DF9380910020909101204B
+:10060000892B51F0809100209091012001978093D7
+:1006100000209093012043C080E490E0809300206C
+:100620009093012080910720909108200196B9F1C4
+:10063000809114019091150120910920263018F421
+:1006400067E771E002C06EEE72E00E94B715EC0140
+:1006500080910720909108208C179D0758F4609195
+:10066000072070910820CE01AFDF029718F080ECD0
+:100670009DE511C08091072090910820C817D907E7
+:1006800070F46091072070910820CE019DDF0297E1
+:1006900030F08FEB9DE58093360A9093370ADF9117
+:1006A000CF910895AC01460F571F861B970B2091E1
+:1006B000200A3091210A24173507C8F72091200A13
+:1006C0003091210A8217930790F70895E0E8F6E049
+:1006D0008FE0808385E0848308951F93CF93DF9319
+:1006E000C0E4D0E0198180E4898340E250E068EB07
+:1006F0007BE280E290E00E945E0F1983DF91CF9150
+:100700001F9108951F93CF93DF93C0E4D0E0198128
+:1007100080E489838BEB95E20E94A60F81E00E9422
+:10072000B80F1983DF91CF911F91089508950F930A
+:100730001F932091A4208EEE92E0289FA001299F74
+:10074000500D112444525A4D07E913E02EEE32E0C9
+:1007500060E081E80E9462131F910F9108951CBE12
+:10076000EEEFF0E40994B9DF8091B82B882369F0AB
+:1007700080E2E8EBFBE2ABEBB5E201900D928A95EB
+:10078000E1F71092BB25BEDFEADF87E08093A2008D
+:10079000789473DDCBDFBAD749D16CD160E080E0CB
+:1007A00003D1EFD08CE0E3D07ED522D63BD68EDFCE
+:1007B00060E870E28EE891E20E94ED150000000012
+:1007C0000000000000000000000000000000000029
+:1007D000000000000000000080919F20882371F33A
+:1007E000E091BA238E2F90E088309105A0F4FC01AF
+:1007F000E250FF4F0C94DE1568D10DC0DAD10BC06A
+:1008000068D209C0EED207C07BD305C002D403C0B2
+:1008100001D401C073D410929F20D0CF08950895C1
+:10082000E09109208E2F90E08830910590F4FC0132
+:10083000EA5FFE4F0C94DE15BBD10BC049D209C054
+:10084000CFD207C05CD305C0E3D303C056D401C0E8
+:10085000C9D48091140180939721809115018093D0
+:100860009821809124018093992180912501809382
+:100870009A218091200A8093A3218091210A80935C
+:10088000A42180911401909115018634914080F04B
+:100890008091140190911501893A914048F480911A
+:1008A0001401909115018093D82B9093D92B0000BF
+:1008B0008091A220882339F016DD1092A22081E0D9
+:1008C0008093A12008958091A120882341F08091F8
+:1008D0009A20833019F419DD8DDE01C0E5DD8091A9
+:1008E000A020882351F080911401909115018093EC
+:1008F000D82B9093D92B1092A0209091A42081E026
+:10090000911180E08093A42008950F931F9381E0BC
+:100910008093A7208093A22007E913E02DE730E021
+:100920004CED55E260E081E80E94621381E01F9186
+:100930000F9108951092A720089581E0089581E015
+:10094000089510922002982F9C7193689093200232
+:1009500087FF03C090E182E002C090E080E0892B35
+:100960008093210210922202109226020895E0E064
+:10097000F2E010AA836880AB80E181AB12AA16AACC
+:100980000895E0E0F2E010A683E880A78FE281A757
+:1009900012A616A60895AAECB1E092E09C93E82F67
+:1009A000F0E084911C920895909171009D7F909346
+:1009B000710010920002623011F09CE101C09EE1D2
+:1009C0009093010290E490930202811102C080E4AE
+:1009D00001C080EC80930302613011F084E001C01B
+:1009E00083E08093040280E2D6DF80930C0281E2F0
+:1009F000D2DF80930D02109218021092190281E04A
+:100A000080930002BECF1F920F920FB60F92112457
+:100A10008F93000000000000000081E0809323021B
+:100A20008F910F900FBE0F901F901895CF93DF936B
+:100A3000E0E7F0E082818B7F8283C0E2D3E08DE04B
+:100A4000888380E4898389E08A8383E3A4DF8887BD
+:100A500082E3A1DF898787E39EDF8A8786E39BDFC6
+:100A60008B87E0E2F6E08081836080831482DF91EF
+:100A7000CF910895E0E7F0E080818E7F808380E869
+:100A8000809300010895E0E0F1E0108A80E4808B1B
+:100A900010A280A310AA80ABE0E4F1E01082808372
+:100AA0001092A6201092A5201092A42010928C21C2
+:100AB00010928D2110928A2110928B21089580939B
+:100AC000BA2381E080939F200895CF93DF93109203
+:100AD0000920D9DFC0E0D1E01EAA94E298AB19AAA0
+:100AE00049E54AAB32E03BAB60910B2070910C20A2
+:100AF0006CAB7DAB6BEB73E268AF79AF1AAE8BE397
+:100B00008CAF83E080933D0110923E0128A92068BC
+:100B100028AB10924601E0E4F1E09083109241018D
+:100B2000409342018093430140910D2050910E204B
+:100B300040934401509345014AEA51E240934801F1
+:100B40005093490110924A0129E320934C0180936C
+:100B50004D0110924E01208120682083188A20E4E4
+:100B6000288B24E0288B898B85E98A8B80E18B8B0D
+:100B700047E751E04C8B5D8B988F398F1A8E8CED47
+:100B800095E28C8F9D8F1E8E68EC70E084EF91E073
+:100B900089DD88EC90E0809307209093082081E025
+:100BA0008093062088898068888BDF91CF91089593
+:100BB0000895EF92FF921F93CF93DF9311E010936C
+:100BC000092061DFC0E0D1E018AA80E488AB94E09E
+:100BD00098AB19AA1AAA6BE46BAB1CAA1DAA1EAA91
+:100BE0002AE030E228AF39AF1AAEA0EAACAF58E045
+:100BF00050933D0110923E0188A9806A88ABE0EADB
+:100C0000F8E085E58083808310924601E0E4F1E01E
+:100C100044E240831092410189E58093420132E031
+:100C200030934301E0900B20F0900C20E0924401BF
+:100C3000F09245018BEBE82E83E2F82EE09248011A
+:100C4000F092490110924A018BE380934C0183E0BA
+:100C500080934D0110924E0120812068208398A33B
+:100C600089A325E92AA36BA367E771E06CA37DA3A1
+:100C7000A8A759A71AA6EAECF8E2ECA7FDA71EA6BA
+:100C8000988B898B2A8B80E18B8B6C8B7D8B488F2B
+:100C9000398F1A8E8CED95E28C8F9D8F1E8E68ECAD
+:100CA00070E084EF91E0FEDC88EC90E08093072018
+:100CB000909308201093062088A1806888A38889D3
+:100CC0008068888BDF91CF911F91FF90EF900895FE
+:100CD00008951F93CF93DF9312E010930920D3DE82
+:100CE000C0E0D1E01EAA94E298AB19AA39E53AAB6C
+:100CF0001BAB40910B2050910C204CAB5DAB4BEBF0
+:100D000053E248AF59AF1AAE8BE38CAF83E08093C8
+:100D10003D0110923E0128A9206828AB109246019F
+:100D2000E0E4F1E09083109241013093420180931E
+:100D3000430120910D2030910E20209344013093E7
+:100D400045012AEA31E2209348013093490110928B
+:100D50004A0129E320934C0180934D0110924E01EA
+:100D6000208120682083188A20E4288B64E0688B27
+:100D7000898B55E95A8B40E14B8B27E731E02C8B6F
+:100D80003D8B988F198F1A8EECEDF5E2EC8FFD8F6D
+:100D90001E8E68A389A35AA34BA32CA33DA384E36F
+:100DA00088A719A71AA68AEC98E28CA79DA71EA669
+:100DB00068EC70E084EF91E075DC88EC90E0809363
+:100DC00007209093082081E080930620888980681E
+:100DD000888B88A1806888A3DF91CF911F910895A7
+:100DE00008951F93CF93DF9313E0109309204BDEF8
+:100DF000C0E0D1E010924601E0E4F1E024E220837B
+:100E00001092410199E59093420182E08093430161
+:100E100040910B2050910C20409344015093450188
+:100E20004BEB53E2409348015093490110924A0121
+:100E30008BE380934C0110934D0110924E01808101
+:100E4000806880831EAA28AB19AA9AAB1BAB80913D
+:100E50000D2090910E208CAB9DAB8AEA91E288AF79
+:100E600099AF1AAE89E38CAF10933D0110923E0109
+:100E700088A9806888AB18A250E458A344E048A32E
+:100E800019A21AA23BE43BA31CA21DA21EA28AE047
+:100E900090E288A799A71AA620EA2CA798E09DA718
+:100EA0001EA688A1806A88A385E58093A008188A79
+:100EB000588B488B198B85E98A8B3B8B47E751E030
+:100EC0004C8B5D8B288F998F1A8E8CED95E28C8FD1
+:100ED0009D8F1E8E68EC70E084EF91E0E3DB88EC80
+:100EE00090E0809307209093082081E08093062073
+:100EF00088898068888BDF91CF911F91089508952C
+:100F00001F93CF93DF9314E010930920BCDDC0E062
+:100F1000D1E018AA80E488AB18AB19AA1AAA3BE45E
+:100F20003BAB1CAA1DAA1EAA8AE090E288AF99AF2B
+:100F30001AAE50EA5CAF88E080933D0110923E010A
+:100F400098A9906A98AB95E59093A00810924601F5
+:100F5000E0E4F1E094E290831092410199E59093EE
+:100F6000420192E09093430160910B2070910C201C
+:100F700060934401709345016BEB73E26093480109
+:100F80007093490110924A019BE390934C0193E0C6
+:100F900090934D0110924E01208120682083188B80
+:100FA000998B45E94A8B3B8B27E731E02C8B3D8BB6
+:100FB000588F898F1A8E6CED75E26C8F7D8F1E8E27
+:100FC00018A399A34AA39AE49BA32CA33DA393EC53
+:100FD00098A789A71AA68AEC98E28CA79DA71EA6B7
+:100FE00068EC70E084EF91E05DDB88EC90E080934A
+:100FF00007209093082081E08093062088898068EC
+:10100000888B88A1806888A3DF91CF911F91089574
+:101010000895FFCFCF93DF9386E08093092033DDDF
+:10102000C0E0D1E01EAA84E288AB19AA39E53AAB48
+:1010300093E09BAB40910D2050910E204CAB5DABEB
+:101040004AEA51E248AF59AF1AAE29E32CAF909368
+:101050003D0110923E0128A9206828AB109246015C
+:10106000E0E4F1E08083109241013093420122E0FC
+:101070002093430140910B2050910C204093440158
+:10108000509345014BEB53E2409348015093490183
+:1010900010924A013BE330934C0190934D01109222
+:1010A0004E01908190689083188A90E4988B888B89
+:1010B000198A95E99A8B90E19B8B4CED55E04C8B0E
+:1010C0005D8B888F298F1A8E8CED95E28C8F9D8F8A
+:1010D0001E8E68EC70E084EF91E0E4DA80E991E044
+:1010E000809307209093082081E0809306208889D0
+:1010F0008068888BDF91CF9108950895CF93DF9317
+:1011000087E080930920BFDCC0E0D1E01EAA84E222
+:1011100088AB19AA39E53AAB93E09BAB40910D201F
+:1011200050910E204CAB5DAB4AEA51E248AF59AF4B
+:101130001AAE29E32CAF90933D0110923E0128A9ED
+:10114000206828AB10924601E0E4F1E08083109221
+:1011500041013093420122E02093430140910B2052
+:1011600050910C2040934401509345014BEB53E2C6
+:10117000409348015093490110924A013BE3309358
+:101180004C0190934D0110924E0190819068908394
+:10119000188A90E4988B95E2988B198A95E99A8B36
+:1011A00090E19B8B4CED55E04C8B5D8B888F298FAC
+:1011B0001A8E8CED95E28C8F9D8F1E8E68EC70E000
+:1011C00084EF91E06FDA80E991E0809307209093BB
+:1011D000082081E08093062088898068888BDF91D1
+:1011E000CF91089508951F920F920FB60F92112478
+:1011F0008F939F9381E0809303011092100184E00C
+:101200008093100187E791E080931401909315017A
+:101210008091A420811103C08EEE92E002C080E094
+:1012200090E084529A4D80931C0190931D0180910F
+:1012300010018068809310019F918F910F900FBED5
+:101240000F901F9018951F920F920FB60F921124B6
+:101250008F939F9382E0809303011092200184E09A
+:101260008093200187E791E08093240190932501EA
+:101270008091A420811103C085E694E002C087E735
+:1012800091E084529A4D80932C0190932D0180918E
+:1012900020018068809320019F918F910F900FBE55
+:1012A0000F901F901895E0E7F0E083818C7F838397
+:1012B00084818C7F848380818D7F8083E0E8F1E06E
+:1012C00080EC8283128688EC81831186A0E0B8E0EE
+:1012D00034E03C9323E011962C93119714961C92C2
+:1012E000149785ED91E096968D939C93979716961B
+:1012F0001C921697E0E4F8E030832183148286A3E1
+:1013000097A31682E0E6F6E0808180618083E0E4C6
+:10131000F9E083E18183148282E08683A6A3B7A3E8
+:1013200010A611A681E0808308951F920F920FB638
+:101330000F9211242F933F934F935F938F939F931B
+:10134000CF93DF931F92CDB7DEB78FEF80934C0919
+:1013500080910920873031F480912C02898390910B
+:101360002D0202C090912C028091A320891B209114
+:1013700068093091690982308CF02A3F374070F457
+:10138000209168093091690989301CF481E090E06E
+:1013900002C086E090E0820F931F18C02091680978
+:1013A000309169098F3FB4F42730310598F02091CE
+:1013B000680930916909883F1CF081E090E002C023
+:1013C00086E090E0A901481B590BCA018093780977
+:1013D000909379090F90DF91CF919F918F915F91B9
+:1013E0004F913F912F910F900FBE0F901F90189526
+:1013F000E0E7F0E083818F7E8383E0E4F6E08081A4
+:101400008A6A80838FEF848388E5828BE0EAF8E044
+:1014100080E3838384EC858387E08683178288E179
+:1014200084830895E0E7F0E08381877F8383E0ECA5
+:10143000F8E080E48083118288E580935506089562
+:101440001F920F920FB60F92112400000F900FBE43
+:101450000F901F9018951F920F920FB60F921124A4
+:101460008F93EF93FF93E0EAF8E080818083FF9110
+:10147000EF918F910F900FBE0F901F9018959FB70F
+:10148000F894A0E5B0E016968C911697897F169691
+:101490008C931697E0E6F0E080E885838BEB8683FB
+:1014A00016968C911697846016968C938081816035
+:1014B00080839FBF08959FB7F894E82FF0E0E0592C
+:1014C000FF4F60958081682360839FBF0895CF930D
+:1014D000863011F0C0E001C0C8E18091510081FD6B
+:1014E0000DC09FB7F89480915000826080935000A7
+:1014F0009FBF8091510081FFFCCFC1DF6C2F6360E3
+:1015000084E490E0C0D460E480E0CF91D4CF8091B7
+:10151000A82008958091A820813009F40BCA08956D
+:10152000F0D0FC0183818093A820811101C0EDC916
+:1015300081E008959091AA23892F807697FF07C0B4
+:10154000803491F48091AB2381110EC0F8C98034AE
+:1015500059F48091AB23811107C08091B023909101
+:10156000B123892B09F0E9C980E008958091AC236B
+:101570008F770C94E4129091B020911102C080E01A
+:101580000895E091AD20F091AE200190F081E02D22
+:1015900094818917A0F7E093AB20F093AC202281CF
+:1015A00033812E0F3F1FE217F30798F49181943097
+:1015B00061F49281891309C09381691306C0E09395
+:1015C000AB20F093AC2081E008959081E90FF11DEC
+:1015D000EACFE093AB20F093AC20D1CFE091AD20E7
+:1015E000F091AE200190F081E02D228133812E0F09
+:1015F0003F1FFC014081E40FF11DE217F30748F49F
+:101600008181843031F0853039F08081E80FF11D1F
+:10161000F4CF80E090E00895CF0108951F93CF9319
+:10162000DF93182FA8DF882339F1C091AB20D09128
+:10163000AC20CE01D3DFEC01892B41F04C815D81E0
+:101640006B818A81CED78111F4CF16C0E091AD2095
+:10165000F091AE2092818381E92FF82FE10FF11DE7
+:10166000E10FF11D0190F081E02D0190F081E02D5E
+:10167000DF91CF911F91099480E0DF91CF911F916D
+:101680000895EF92FF921F93CF93DF93C82F60E0EE
+:1016900072DF811102C010E02DC0E091AD20F09109
+:1016A000AE2092818381E92FF82FEC0FF11DEC0F12
+:1016B000F11DE080F180D7011696ED91FC9117970E
+:1016C0000995682F8C2F57DF182F882321F3C0919D
+:1016D000AB20D091AC20CE0181DFEC01892B21F031
+:1016E0008A810E941E14F7CFD7011296ED91FC91CA
+:1016F00013970995812FDF91CF911F91FF90EF9064
+:1017000008958091AB209091AC200895FFC6CF93AF
+:101710008091B020811108C01092B0201092B420A6
+:101720001092B520CF910895C0E0E091AD20F091E6
+:10173000AE200190F081E02D8481C81768F78C2FCE
+:10174000A0DFCF5FF2CFCF938091B0208823F1F05C
+:10175000C0E0E091AD20F091AE20A081B18114965F
+:101760008C91C81798F492818381E92FF82FEC0FA0
+:10177000F11DEC0FF11D0190F081E02D0084F18549
+:10178000E02D309709F00995CF5FE3CFCF91089511
+:10179000EF92FF920F931F93CF93DF931F92CDB7DA
+:1017A000DEB71092B4231092B5231092B623109294
+:1017B000B7231092B8231092B9238091AA2387FFF0
+:1017C00007C02091B0233091B123232B09F452C3D9
+:1017D000982F9076903409F00FC1E091AB238E2FB3
+:1017E00090E0FC01E05AF109EA30F10508F0D1C2BD
+:1017F000E25FFE4F0C94DE1581E08093A020809183
+:1018000007209091082080939B2180910720909140
+:10181000082090939C218091822180939D2180912A
+:101820007F2180939E2180916A0080939F218091E7
+:101830006B008093A0216091B0237091B1238EE85A
+:1018400091E2D8C0109200088091AC239091AD2312
+:1018500080933608909337088091AE238F708093E1
+:1018600000086091B0237091B1238AEA91E2B2D668
+:1018700020910D2030910E208091B0239091B123C2
+:101880002817390709F4F4C280930D2090930E2095
+:1018900026C0109240088091AC239091AD23809394
+:1018A0007608909377088091AE238F7080934008DC
+:1018B0006091B0237091B1238BEB93E28BD6209192
+:1018C0000B2030910C208091B0239091B1232817E8
+:1018D000390709F4CDC280930B2090930C2080919E
+:1018E000092055C010926809109269098091AC23B3
+:1018F0008093A320BDC28091AC2380932406B8C2FC
+:10190000E091AC23F091AD23E830F10508F041C23D
+:10191000E85EFE4F0C94DE1560E080E045D88091D3
+:10192000AE230FD880E033C060E080E03DD88091E6
+:10193000AE2307D881E02BC061E081E035D88091EB
+:10194000AE230E94A1048091AF2311D882E01FC072
+:1019500083E01DC084E01BC060E080E025D880915A
+:10196000AE230E94A10485E012C061E080E01CD893
+:101970008091AE230E94A10486E009C062E080E06D
+:1019800013D88091AE2380680E94A10487E097D885
+:101990006FC28091AC23809384066AC28091AC238D
+:1019A0009091AD23892B91F00E946D0380E2E8EBCA
+:1019B000FBE2ABEBB5E201900D928A95E1F781E095
+:1019C0008093BB250E9482030E946D03E9E7F0E04B
+:1019D00091E088EDF89484BF90836091B02370917A
+:1019E000B1238AE890E206C06091B0237091B123E0
+:1019F00089E890E2EFD53CC29111CBC187FFFCC0D2
+:101A00002091B0233091B1232115310509F4C1C1D2
+:101A10008F7109F09EC08091AB23863071F08830C1
+:101A200009F48EC08111B5C12230310509F0B1C170
+:101A300062E070E084EB90E2DDCF8091AC23909186
+:101A4000AD23292F332722303105A1F064F4213052
+:101A5000310509F09EC18091192090911A20DC0176
+:101A60006C9170E05BC02330310589F12F30310576
+:101A700009F18FC1E0911920F0911A202189821774
+:101A800008F087C19927880F991F880F991FE09147
+:101A90001B20F0911C20E80FF91F80819181FC012F
+:101AA0006281738197D5E091B223F091B32382E0F4
+:101AB000818335C080911D2090911E20009709F4EC
+:101AC00068C1DC0112966D917C91139727C099270C
+:101AD0008130910569F038F0029709F05AC168E049
+:101AE0008AE690E208C064E070E08CE790E216C0FD
+:101AF00067E083E790E2282FAAE5B0E2FC0181913C
+:101B000090E08D939D938E2F821B8617C0F3660FF6
+:101B10006E5F6093582070E088E590E25BD580911D
+:101B2000B0239091B1232091B4233091B523821733
+:101B3000930708F09DC18093B4239093B52398C177
+:101B40002130310509F025C161E070E080EB90E2C1
+:101B500051CF8130C9F58091AB238A3009F019C18A
+:101B60002130310509F015C18091B020882309F496
+:101B700010C1E090AE23F090AF230091AD20109102
+:101B8000AE20D801ED91FC918481E81608F001C1E6
+:101B900060E08E2DF0DC882309F4FBC0FF24EE0CFE
+:101BA000FF1CF801828193818E0D9F1DDC01ED9158
+:101BB000FC910680F781E02D09958093B22061E0C9
+:101BC00070E082EB90E216CF823009F0E2C08091A3
+:101BD000AB238111DEC02230310509F0DAC08091DB
+:101BE000AE2350D590E08093A9209093AA2062E084
+:101BF00070E089EA90E2FECE8F7109F07DC080919D
+:101C0000AB23833009F4C5C018F48130A1F0C1C002
+:101C1000853019F0893039F1BCC08091B0239091A2
+:101C2000B123892B09F0B5C086EB9AE08093B623E7
+:101C30009093B7231DC18091B0239091B123892B3C
+:101C400009F0A7C08091AC239091AD23019709F0D2
+:101C5000A0C08091B4209091B5208D7F8093B42056
+:101C60009093B52005C18091B0239091B123892B29
+:101C700009F08FC0ACD4882309F48BC02091AC2329
+:101C80003091AD233327E0911920F0911A208189FA
+:101C900090E08217930708F47CC039DD8091AC2373
+:101CA0009091AD238093B020882309F4E1C0992757
+:101CB0008150904C880F991F880F991F20911B20ED
+:101CC00030911C20820F931F8093AD209093AE2003
+:101CD00010E0E091AD20F091AE200190F081E02D78
+:101CE0008481181708F0C4C060E0812F97DC882336
+:101CF00009F44FC01F5FEDCF8130F1F48091AB2329
+:101D00008B3009F046C08091B0239091B123892B8C
+:101D100009F03FC08091B020882309F43AC01091A7
+:101D2000AE236091AC23812F6983ABDC698188236A
+:101D300081F1812F73DC2BC0823059F58091AB2368
+:101D4000813019F0833089F024C08091B0239091C4
+:101D5000B123892BF1F48091AC239091AD23892B91
+:101D6000C1F48091AE2395D412C08091B02390919C
+:101D7000B123892B71F48091AC239091AD23892BF1
+:101D800041F48091AE232AD58091AE2360D5811194
+:101D90006FC08091AA238F718130B9F58091B020F6
+:101DA000882399F1E090AE23F090AF230091AD200D
+:101DB0001091AE20D801ED91FC918481E81628F5B0
+:101DC00060E08E2DD8DB882301F1F701FF27EE0FAD
+:101DD000FF1FD80112968D919C911397E80FF91F60
+:101DE00000811181D8011696ED91FC911797099504
+:101DF000682F8E2DC0DB882341F0D8011496ED9119
+:101E0000FC9115970995811133C08091AA238F7198
+:101E1000823081F58091B020882361F1F12CE0912E
+:101E2000AD20F091AE20A081B18114968C91F8166E
+:101E300008F592818381E92FF82FEF0DF11DEF0D49
+:101E4000F11D00811181D8011696ED91FC91179733
+:101E50000995682F8F2D8FDB882361F0D8011496A8
+:101E6000ED91FC9115970995811102C0F394D7CF9C
+:101E700081E001C080E00F90DF91CF911F910F9121
+:101E8000FF90EF9008951BBEFC0128ED24BF6083F6
+:101E900008958091CF0187FDFCCF08951F93CF93C4
+:101EA000DF93C0ECD1E01A858A8761E08BEC91E08A
+:101EB000EADF1A87DF91CF911F910895CF92DF92C9
+:101EC000EF92FF920F931F93CF93DF9300D0CDB784
+:101ED000DEB78C017B0149835A83DBDF8CECC82E93
+:101EE000DD24D394F601908198609083B801705FEF
+:101EF00049815A81C70168D6F6018081877F808336
+:101F00000F900F90DF91CF911F910F91FF90EF9065
+:101F1000DF90CF900895CF93DF9300D0CDB7DEB799
+:101F20006A838983B6DFACECB1E09C9198609C93A6
+:101F30008981E82FF0E0F05F6A8160838C91877F70
+:101F40008C930F900F90DF91CF9108950F931F9373
+:101F5000CF938C019EDFC0E0F80161918F018C2F3F
+:101F6000DADFCF5FC032C1F7CF911F910F91089593
+:101F7000CF93DF931F92CDB7DEB789838ADF898144
+:101F800020E2829FC0011124E0ECF1E012829183F3
+:101F9000808385E30F90DF91CF9180CF4091CA017C
+:101FA000E62FF72F8093CA0184914093CA010895C8
+:101FB000E82FF0E0E652F44D80818F3F09F4FFCF27
+:101FC0009FB7F89480818F5F80839FBF0895E82F2B
+:101FD000F0E0E652F44D8081811101C0FFCF9FB740
+:101FE000F8948081815080839FBF0895CF93C82F3C
+:101FF00080917C21C11105C0882339F081E0E7DFA1
+:1020000004C0811102C081E0D3DFC0937C21CF9155
+:102010000895282F2F70082E000C990B392F331F8D
+:102020003327331F832F90E0820F911D820F911D64
+:1020300023E0880F991F2A95E1F7885A9E4D08954D
+:102040000F93E8ECF4E080818F7D808380818F7D29
+:102050008083E0E6F1E202E00593109262211092A3
+:10206000632100E2069300E40693E8E5F1E200E272
+:10207000069300E40693EAEAF3E2148615861686D0
+:1020800017861286138610924D210F9108950F9393
+:1020900085E080934D21E1E6F1E204E00593E9E576
+:1020A000F1E204E005930F9108950F9383E080938C
+:1020B0004D211092622110926321E0E6F1E202E0EC
+:1020C00006930F910895E091B623F091B7233097CE
+:1020D00009F009940895282F2F70082E000C990BF1
+:1020E000392F331F3327331F832F90E0820F911D29
+:1020F000820F911D029749E0489F9001499F300D42
+:102100001124C90189509F4D08958F929F92AF92DB
+:10211000BF92DF92EF92FF920F931F93CF93DF93C3
+:10212000D82ED9DFEC018D2D74DF7C01DC011196F6
+:10213000EC91E770E150E73040F4F0E0EE0FFF1F64
+:10214000E457FF4D0081118102C008E010E0ED81ED
+:10215000FE812B813C814881D701D7FE48C016966D
+:102160008D919C9117978E0F9F1F8D839E83821751
+:10217000930761F1281B390B2115B4E03B0738F0B8
+:102180002FEF33E0C901B801F2D4281B390B41FF0E
+:102190000AC0C901B801EBD4AC0191E0452B09F0AC
+:1021A00090E0892F01C080E0988180FB91F99883AD
+:1021B000F701168217822283338329813A818D8128
+:1021C0009E81820F931F848395830EC041FF71C04F
+:1021D0004D7F4883D70116961D921C921797129631
+:1021E0001D921C921397F70102E006937BC0129692
+:1021F000AD90BC90139742FF10C089809A80C901AE
+:10220000B801B5D4B0E4DB9EB001112469587F4D0C
+:10221000AC01C4018E0F9F1FD7D48D819E818A0D82
+:102220009B1D8D839E832B813C812817390710F4D9
+:102230002D833E83F70186819781A816B906C9F5DB
+:102240008D819E8182179307A1F1281B390B2115DF
+:10225000F4E03F0710F02FEF33E0C901B80187D455
+:10226000281B390BD70112961D921C921397201729
+:10227000310778F4888184608883B0E4DB9EC001F4
+:10228000112489589F4DF701848395830683178312
+:10229000AACF49815A818D819E81840F951FD701D4
+:1022A00014968D939C93159716962D933C931797A0
+:1022B0009ACF888180FF16C08E7F8883EF81F88552
+:1022C000309781F06D817E814D2D80E0DF91CF913F
+:1022D0001F910F91FF90EF90DF90BF90AF909F9074
+:1022E0008F900994DF91CF911F910F91FF90EF9004
+:1022F000DF90BF90AF909F908F9008950F93CF93F2
+:10230000DF9380914D21833029F4DDDEDF91CF9181
+:102310000F9196CE2091492130914A21C091B4234A
+:10232000D091B523C21BD30B61F580914B219091C5
+:102330004C21820F931F80934B2190934C2120912D
+:10234000B0233091B1232817390721F08091B620AE
+:10235000882331F084E080934D21E8E5F1E236C036
+:10236000E091B823F091B923309799F0099588232B
+:1023700081F01092492110924A21C091B423D0914A
+:10238000B523C034D10528F01092B620C0E4D0E0C7
+:1023900003C081E08093B620C0936221D093632173
+:1023A0008091492190914A212091B2233091B32309
+:1023B000280F391F2093642130936521C80FD91F3E
+:1023C000C0934921D0934A21E0E6F1E202E006936E
+:1023D000DF91CF910F9108950F93CF93DF931F92C9
+:1023E000CDB7DEB78091CC0480FF65C021E020939B
+:1023F000CC0488E591E2FC0100E80693E0E6F1E216
+:1024000000E806932093CA04FC0100E10693809142
+:102410004D21882329F08350823008F454DE10DEE9
+:1024200080915A2190915B21089709F046C088E07D
+:10243000E9E0F1E2AAEAB3E201900D928A95E1F7B0
+:102440008091C80480628093C8048091C80480622F
+:102450008093C8049DD9811102C019DE2EC09091CD
+:10246000AA2397FF0EC010924B2110924C2110927C
+:10247000492110924A2192E090934D2189833EDFB9
+:1024800008C02091B0233091B123232B21F48983FC
+:102490000CDE898113C010924B2110924C211092B6
+:1024A000492110924A2191E090934D21E8E5F1E213
+:1024B00002E0069303C080E001C081E00F90DF914D
+:1024C000CF910F910895CF93CFB7F89481E08EDD2F
+:1024D000EAECF4E080E4808380E28083E1ECF4E0E5
+:1024E000808181608083A9ECB4E08C9182608C93C0
+:1024F000E8ECF4E08081806480838C9181608C932F
+:10250000808180688083CFBFCF910895CF93109250
+:10251000600080E30E94670A8091C0048064809319
+:10252000C00481E080936000CFB7F89410925921E5
+:102530001092612110926921109271218091F720EF
+:102540008E7F8093F720809100218E7F80930021E1
+:102550006AE170E082E022DD8F3F09F48FE1809331
+:10256000FA046BE170E082E019DD8F3F09F48FE13E
+:102570008093FB048091C00481608093C0048091AB
+:10258000C00480688093C0048091C00480618093FF
+:10259000C00488E591E28093C6049093C7048091BB
+:1025A000C00480628093C0048FEF8093C504809143
+:1025B000C80482608093C80410927C2185E0F8DC16
+:1025C00082DFCFBFCF9108958093C3040895809197
+:1025D000C3040895EAEAF3E28087918762877387EC
+:1025E00008950F931F93CF93DF931F92CDB7DEB75C
+:1025F0008A0169830EDDFC018181807C6981811102
+:102600003AC06370613019F020F080E803C080ECBC
+:1026100001C080E400381105E9F058F400321105DA
+:10262000A9F000341105A1F000311105C9F491E0C1
+:1026300018C0011592E0190779F00F3F93E01907D0
+:1026400069F00115114061F495E00BC092E009C0FA
+:1026500093E007C094E005C096E003C097E001C096
+:1026600090E0118226E02083982B91838181806203
+:10267000818381E001C080E00F90DF91CF911F91B5
+:102680000F910895C6DCFC01818182FB882780F9C7
+:102690000895CF93C82FBDDCFC01818182FF0FC05C
+:1026A00091819B7F91838C2F16DDFC01908190FF9F
+:1026B00006C09E7F90830780F085E02D099581E01C
+:1026C000CF9108958F929F92AF92BF92DF92EF9237
+:1026D000FF920F931F93CF93DF931F92CDB7DEB777
+:1026E000D82E5A0179016983F6DC4C018D2D91DCDD
+:1026F0009C01DC0111968C911197807C6981882363
+:1027000009F45EC011968C911197807C803C21F079
+:1027100011968C9182FD54C09FB7F894F40180818A
+:1027200080FF02C09FBF4CC0816080839FBFF401C7
+:10273000A182B282E382F482158216820783108717
+:1027400091E0611104C0E114F10409F090E0D401BA
+:102750008C9190FB81F98B7F8C93D7FE04C0F9019B
+:102760001682178229C0D90111968C911197807C0D
+:10277000803CC9F41196EC91E770E150E73040F4E9
+:10278000F0E0EE0FFF1FE457FF4D6081718102C042
+:1027900068E070E0C701EBD1892B29F0F40180815A
+:1027A0008E7F80830DC0D90112961D921C921397C3
+:1027B00016961D921C9217978D2DA7DC81E001C003
+:1027C00080E00F90DF91CF911F910F91FF90EF90DC
+:1027D000DF90BF90AF909F908F900895EF92FF92FF
+:1027E0000F93CF93C82F15DC7C018C2F74DCDC0198
+:1027F000F70102E005939C9190FF1BC09E7F9C9384
+:102800001796ED91FC911897309799F0D701C7FF73
+:1028100005C016966D917C91179704C012966D9124
+:102820007C9113974C2F81E0CF910F91FF90EF9007
+:102830000994CF910F91FF90EF900895CF93C82FF7
+:10284000CDDF8C2FE6DBFC011182CF9108950F9331
+:10285000CF93C82FDEDBFC0191819460918301E06E
+:1028600006938C2FBBDF81E0CF910F9108951F92CB
+:102870000F920FB60F9211240F932F933F934F9304
+:102880005F936F937F938F939F93AF93BF93EF93D8
+:10289000FF938091CB0487FF08C080E88093CA042F
+:1028A0000E94A30B0E9410047EC08091CB0482FF83
+:1028B00018C084E08093CA048091602186FF73C0B1
+:1028C0008091CC0481FD6FC087DD81116CC0809147
+:1028D0004D21813011F4E9DB66C0843009F063C01A
+:1028E00021C08091CB0481FF26C082E08093CA047E
+:1028F0008091582186FF57C08091CC0481FD53C040
+:102900006BDD811150C080914D21823041F484E013
+:1029100080934D21E8E5F1E202E0069344C0833064
+:1029200009F041C0E1E6F1E204E00593E9E5F1E2F6
+:1029300004E0059338C08091CB0484FF1DC080E182
+:102940008093CA040E94870B1092C30410925921ED
+:1029500096E09093582183E480935921109261214D
+:10296000909360218093612189E091E280935C21C2
+:1029700090935D2165DB17C08091CB0486FF08C072
+:1029800080E48093CA0480E031DB0E940E040BC017
+:102990008091CB0485FF07C080E28093CA0481E068
+:1029A00025DB0E940F04FF91EF91BF91AF919F91A2
+:1029B0008F917F916F915F914F913F912F910F91E7
+:1029C0000F900FBE0F901F9018951F920F920FB689
+:1029D0000F9211240F931F932F933F934F935F9365
+:1029E0006F937F938F939F93AF93BF93CF93DF9317
+:1029F000EF93FF938091CC0481FF1AC082E0809313
+:102A0000CC048091C5048195880FE8E5F1E2E81BCC
+:102A1000F109208131812855314283E0369527958F
+:102A20008A95E1F7822F869520FD06C0C0E005C09B
+:102A3000D3DC882319F386C0C0E8C80F8C2FE9DAED
+:102A4000FC01208125FF7EC000E20693C11174C005
+:102A500080914D21843019F436DBF2DA73C0009195
+:102A60005A2110915B218091B4239091B523C0919C
+:102A70004921D0914A219E01200F311F82179307CF
+:102A800018F48C010C1B1D0B8091B2239091B32381
+:102A9000A80169E071E28C0F9D1F96D0C00FD11F75
+:102AA000C0934921D0934A210034110569F48091E3
+:102AB0004B2190914C218C0F9D1F2091B023309180
+:102AC000B1238217930788F0C093B423D093B52322
+:102AD000E091B823F091B923309729F0099581113D
+:102AE00002C0D5DA2FC0E1DA2DC08091B4239091D5
+:102AF000B5238C179D07D9F4E091B823F091B92341
+:102B0000309779F30995882361F320914B21309117
+:102B10004C218091492190914A21820F931F8093EB
+:102B20004B2190934C211092492110924A21E8E5C3
+:102B3000F1E202E0069306C0C03811F4DFDB02C008
+:102B40008C2FE3DAFF91EF91DF91CF91BF91AF919D
+:102B50009F918F917F916F915F914F913F912F91B5
+:102B60001F910F910F900FBE0F901F901895AA1BE9
+:102B7000BB1B51E107C0AA1FBB1FA617B70710F068
+:102B8000A61BB70B881F991F5A95A9F7809590959A
+:102B9000BC01CD01089597FB072E16F4009406D0D2
+:102BA00077FD08D0E4DF07FC05D03EF490958195D1
+:102BB0009F4F0895709561957F4F0895EE0FFF1F09
+:102BC0000590F491E02D0994FB01DC0102C0019015
+:102BD0000D9241505040D8F70895FB01DC0101905F
+:0C2BE0000D920020E1F70895F894FFCF5B
+:102BEC0040000CE02E0AFFFFFFFF55800080009094
+:102BFC000A8A0A9A0A870A000044201F200000282B
+:102C0C002023200F20000000090219000101008080
+:102C1C00FA0904000001FFFFFF0007058101FF0313
+:102C2C00010000001201000200000040EB0394BA06
+:102C3C00000201020001000000030000000000007F
+:102C4C00000000000000000000004C616272616432
+:102C5C006F72004573706F54656B000004030904B8
+:102C6C006465627567313233000203001000200086
+:0A2C7C004000800000010002FF0389
+:00000001FF
diff --git a/Desktop_Interface/bin/firmware/labrafirm_0003_02.hex.REMOVED.git-id b/Desktop_Interface/bin/firmware/labrafirm_0003_02.hex.REMOVED.git-id
deleted file mode 100644
index 42c42b45..00000000
--- a/Desktop_Interface/bin/firmware/labrafirm_0003_02.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-879125a9685d89a7f05bd38994079919338f49b6
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/QtCore.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/QtCore.REMOVED.git-id
deleted file mode 100644
index b2c04bb6..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/QtCore.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4e97581784c6d56b5004ece88c211f6eaa629cf2
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Resources.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Resources.REMOVED.git-id
deleted file mode 100644
index bcf4bd23..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Resources.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae77f62d81117de42e136af77f502ad195f40c8c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore.REMOVED.git-id
deleted file mode 100644
index efb907b5..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3c83c4b4bda97bc27a5fcdc74c0486761f044941
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/Info.plist.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
deleted file mode 100644
index 0ae9073b..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-200ded4f26d05ba79b78a0ccbd85fe1383d52531
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/Current.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/Current.REMOVED.git-id
deleted file mode 100644
index 28fe224a..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtCore.framework/Versions/Current.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e2414360b5d614e7aa142f7afec0e641250ad76e
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/QtDBus.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/QtDBus.REMOVED.git-id
deleted file mode 100644
index 46800d3e..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/QtDBus.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0bc3bf862127fa45dfd8a960ff95edc2e6b68f2a
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Resources.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Resources.REMOVED.git-id
deleted file mode 100644
index bcf4bd23..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Resources.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae77f62d81117de42e136af77f502ad195f40c8c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus.REMOVED.git-id
deleted file mode 100644
index 4a9f15c9..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f0139f680d289ba0330ff86a9af03cdcaa732e8d
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/Info.plist.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
deleted file mode 100644
index 38f4cfb6..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c16610f29f104c9b9cba2251d7b3421a81b96b65
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/Current.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/Current.REMOVED.git-id
deleted file mode 100644
index 28fe224a..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtDBus.framework/Versions/Current.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e2414360b5d614e7aa142f7afec0e641250ad76e
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/QtGui.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/QtGui.REMOVED.git-id
deleted file mode 100644
index ce1cd079..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/QtGui.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2c8183e63c528e766abb75d5266660a02b637506
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Resources.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Resources.REMOVED.git-id
deleted file mode 100644
index bcf4bd23..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Resources.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae77f62d81117de42e136af77f502ad195f40c8c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui.REMOVED.git-id
deleted file mode 100644
index d148d854..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1212997f96a7998a5d07a5e69f3ee641deca2b21
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/Info.plist.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
deleted file mode 100644
index dc968a59..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-8cc6edbfc275e203fc18ee59193c0675d49da836
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/Current.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/Current.REMOVED.git-id
deleted file mode 100644
index 28fe224a..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtGui.framework/Versions/Current.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e2414360b5d614e7aa142f7afec0e641250ad76e
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/QtPrintSupport.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/QtPrintSupport.REMOVED.git-id
deleted file mode 100644
index f563bb21..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/QtPrintSupport.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d04c873ffe1192b07f10735c98f0ef154907dbb0
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Resources.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Resources.REMOVED.git-id
deleted file mode 100644
index bcf4bd23..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Resources.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae77f62d81117de42e136af77f502ad195f40c8c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport.REMOVED.git-id
deleted file mode 100644
index 808f9d49..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6d73790b3479fb873f6a5a82d30d5cfc157bde03
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/Info.plist.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
deleted file mode 100644
index b03b5296..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3ef8098ab9fe3b4a25345c44e249de8bb7a08614
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/Current.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/Current.REMOVED.git-id
deleted file mode 100644
index 28fe224a..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtPrintSupport.framework/Versions/Current.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e2414360b5d614e7aa142f7afec0e641250ad76e
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/QtWidgets.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/QtWidgets.REMOVED.git-id
deleted file mode 100644
index 1867fb43..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/QtWidgets.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-da28f76975d83c8487c95b17f6a4d2e409fb24ca
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Resources.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Resources.REMOVED.git-id
deleted file mode 100644
index bcf4bd23..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Resources.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ae77f62d81117de42e136af77f502ad195f40c8c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets.REMOVED.git-id
deleted file mode 100644
index de116611..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9c627dec33d2a24cb7aca78d8db8c641ad16f391
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/Info.plist.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
deleted file mode 100644
index facf7bd9..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/Info.plist.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4bf529155850e8fb0aca883e52d551c9edd10c76
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/Current.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/Current.REMOVED.git-id
deleted file mode 100644
index 28fe224a..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/QtWidgets.framework/Versions/Current.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e2414360b5d614e7aa142f7afec0e641250ad76e
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libdfuprog-0.9.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libdfuprog-0.9.dylib.REMOVED.git-id
deleted file mode 100644
index 086e2d46..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libdfuprog-0.9.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-af43fdf3d1e1d18f6ad80f3f6abae64315d673b2
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libgcc_s.1.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libgcc_s.1.dylib.REMOVED.git-id
deleted file mode 100644
index 5d331b06..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libgcc_s.1.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-da5320ffb129abfe60b570a632ee76ade361190a
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libusb-1.0.0.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libusb-1.0.0.dylib.REMOVED.git-id
deleted file mode 100644
index f9a549a4..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Frameworks/libusb-1.0.0.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9dfcb90a4e84af3c8f9da32a40a2fa3e50e057fc
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Info.plist.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Info.plist.REMOVED.git-id
deleted file mode 100644
index 90d5ce92..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Info.plist.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4c69e89c9374b98c16829b05c52a2e48d9c75e60
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/Labrador.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/Labrador.REMOVED.git-id
deleted file mode 100644
index 07d63776..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/Labrador.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-93eea4b26dfb3fa7cccb657b0ce6c6b2309dadb9
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/dfu-programmer.exe.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/dfu-programmer.exe.REMOVED.git-id
deleted file mode 100644
index b819c11c..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/dfu-programmer.exe.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b27d99e3b1bb4ec243a6f22881053dd6e6e94334
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/flash.bat.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/flash.bat.REMOVED.git-id
deleted file mode 100644
index c0361a58..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/flash.bat.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-33b4424dfe12584fb5dffb5e26758a13d7b57b57
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0001_01.hex.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0001_01.hex.REMOVED.git-id
deleted file mode 100644
index 07d97bdc..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0001_01.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-044f2051fdfc79136bee11c6968cf73fa30eb572
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0003_01.hex.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0003_01.hex.REMOVED.git-id
deleted file mode 100644
index b3667a22..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0003_01.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f7946fd762c2bf7eaa4b76d5eb68948870244c19
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0003_02.hex.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0003_02.hex.REMOVED.git-id
deleted file mode 100644
index 42c42b45..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/firmware/labrafirm_0003_02.hex.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-879125a9685d89a7f05bd38994079919338f49b6
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/settings.set.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/settings.set.REMOVED.git-id
deleted file mode 100644
index b3c06306..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/settings.set.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-816d01be5ca04d952ce4d347befefed997133065
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Sawtooth.tlw.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Sawtooth.tlw.REMOVED.git-id
deleted file mode 100644
index 87e86502..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Sawtooth.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e989a81be4fb7a2d79495ce7e96db776b0366a94
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Sin.tlw.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Sin.tlw.REMOVED.git-id
deleted file mode 100644
index ceeb1ad1..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Sin.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e376c35388394ccfa4a86cb5bc6f9961e00fef20
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Square.tlw.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Square.tlw.REMOVED.git-id
deleted file mode 100644
index 25d85bc6..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Square.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7bdd30bee84b15cc3fe88dd02751316a2016060c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Triangle.tlw.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Triangle.tlw.REMOVED.git-id
deleted file mode 100644
index 768d2ac7..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/Triangle.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-420ac92c2c292688434b3987874cc98a9180e336
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/_list.wfl.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/_list.wfl.REMOVED.git-id
deleted file mode 100644
index 91e06b43..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/MacOS/waveforms/_list.wfl.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-488a0133badf9d48927f82bcc9fcf039e36d2065
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PkgInfo.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PkgInfo.REMOVED.git-id
deleted file mode 100644
index 70df2297..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PkgInfo.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6f749b0f376443ea266383322cc2d934f791bbee
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqdds.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqdds.dylib.REMOVED.git-id
deleted file mode 100644
index ca811a6f..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqdds.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9d40ddc8a41872996ef2c3102528c88798d0434c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqgif.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqgif.dylib.REMOVED.git-id
deleted file mode 100644
index 065e0b85..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqgif.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6320e6ed60ccdffbe9e129c9614ca5742defc37c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqicns.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqicns.dylib.REMOVED.git-id
deleted file mode 100644
index 9c5d1364..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqicns.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e5699a7b7690f41d9e658b42317e40ba372107f4
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqico.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqico.dylib.REMOVED.git-id
deleted file mode 100644
index 42eace8c..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqico.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-a91d2c59441590a6e195611820af0a59837cb30e
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqjpeg.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqjpeg.dylib.REMOVED.git-id
deleted file mode 100644
index 93f9a36e..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqjpeg.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4c742a0d77ec8512f6c0c5d29dbf5c0c05ce910d
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqmacjp2.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqmacjp2.dylib.REMOVED.git-id
deleted file mode 100644
index 49f796ea..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqmacjp2.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4a8ffbc7131321ed725899999aba5fc17e91f074
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqtga.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqtga.dylib.REMOVED.git-id
deleted file mode 100644
index 1fd14664..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqtga.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ddb2b7983af07df97147948be39f34392dac815f
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqtiff.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqtiff.dylib.REMOVED.git-id
deleted file mode 100644
index de7be742..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqtiff.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-836dece992c8a4bed4752b9d364bd058c17b43e4
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqwbmp.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqwbmp.dylib.REMOVED.git-id
deleted file mode 100644
index ac65ea9b..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqwbmp.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-df30a4b465f360b8b8f4e0a18c3f04d2f4d260b7
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqwebp.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqwebp.dylib.REMOVED.git-id
deleted file mode 100644
index ac96f986..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/imageformats/libqwebp.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-295982f5ae94be523dca5f5cde09722383277127
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/platforms/libqcocoa.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/platforms/libqcocoa.dylib.REMOVED.git-id
deleted file mode 100644
index 910b8d29..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/platforms/libqcocoa.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-4b2eb691b56dcb687c21ee3a9bace4ce95dce8c1
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib.REMOVED.git-id
deleted file mode 100644
index fc881011..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-95d66968b46f5f12329a8d5314d3366d7d756a9e
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Resources/empty.lproj b/Desktop_Interface/bin/labrador.app/Contents/Resources/empty.lproj
deleted file mode 100644
index e69de29b..00000000
diff --git a/Desktop_Interface/bin/labrador.app/Contents/Resources/qt.conf.REMOVED.git-id b/Desktop_Interface/bin/labrador.app/Contents/Resources/qt.conf.REMOVED.git-id
deleted file mode 100644
index 85ec01ac..00000000
--- a/Desktop_Interface/bin/labrador.app/Contents/Resources/qt.conf.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-02408febaa4e6b8e05e99a75bffff4da23e38bf2
\ No newline at end of file
diff --git a/Desktop_Interface/bin/labrador.dmg.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/labrador.dmg.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index a2a26c34..00000000
--- a/Desktop_Interface/bin/labrador.dmg.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-238d8bcf3f37f4a5b4188aa25d3683859eb7adc4
\ No newline at end of file
diff --git a/Desktop_Interface/bin/libLabrador.so.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/libLabrador.so.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 4db4cc14..00000000
--- a/Desktop_Interface/bin/libLabrador.so.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-23e225605ce39e3c104bb47eeaadecac22c40841
\ No newline at end of file
diff --git a/Desktop_Interface/bin/libdfuprog-0.9.so.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/libdfuprog-0.9.so.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index f1ae5942..00000000
--- a/Desktop_Interface/bin/libdfuprog-0.9.so.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2f86926facec11998ed268298507e49cd380a706
\ No newline at end of file
diff --git a/Desktop_Interface/bin/libusbK.dll.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/libusbK.dll.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index d32da3ad..00000000
--- a/Desktop_Interface/bin/libusbK.dll.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-14163cc73c3d3ad6821a58dc4653522543fb7532
\ No newline at end of file
diff --git a/Desktop_Interface/bin/settings.ini.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/settings.ini.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 5a068e8f..00000000
--- a/Desktop_Interface/bin/settings.ini.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-3d8b3b0054ce4bdfcad1bb468f00c91184f5307f
\ No newline at end of file
diff --git a/Desktop_Interface/bin/settings.set.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/bin/settings.set.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 0392c099..00000000
--- a/Desktop_Interface/bin/settings.set.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-b3c0630690de19fac3e0f05664149163f8a25913
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/DC.tlw b/Desktop_Interface/bin/waveforms/DC.tlw
new file mode 100644
index 00000000..69f322d2
--- /dev/null
+++ b/Desktop_Interface/bin/waveforms/DC.tlw
@@ -0,0 +1,3 @@
+1
+1
+255
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/DC.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms/DC.tlw.REMOVED.git-id
deleted file mode 100644
index e3326948..00000000
--- a/Desktop_Interface/bin/waveforms/DC.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-69f322d2c3c6452561c8232b20784828fc438399
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/Sawtooth.tlw b/Desktop_Interface/bin/waveforms/Sawtooth.tlw
new file mode 100644
index 00000000..e989a81b
--- /dev/null
+++ b/Desktop_Interface/bin/waveforms/Sawtooth.tlw
@@ -0,0 +1,3 @@
+128
+3
+0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255
diff --git a/Desktop_Interface/bin/waveforms/Sawtooth.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms/Sawtooth.tlw.REMOVED.git-id
deleted file mode 100644
index 87e86502..00000000
--- a/Desktop_Interface/bin/waveforms/Sawtooth.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e989a81be4fb7a2d79495ce7e96db776b0366a94
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/Sin.tlw b/Desktop_Interface/bin/waveforms/Sin.tlw
new file mode 100644
index 00000000..e376c353
--- /dev/null
+++ b/Desktop_Interface/bin/waveforms/Sin.tlw
@@ -0,0 +1,3 @@
+128
+4
+128 134 140 146 153 159 165 171 177 182 188 194 199 204 209 214 218 223 227 230 234 237 240 243 246 248 250 251 253 254 255 255 255 255 254 253 252 251 249 247 245 242 239 236 232 229 225 220 216 211 206 201 196 191 185 180 174 168 162 156 149 143 137 131 124 118 112 106 99 93 87 81 75 70 64 59 54 49 44 39 35 30 26 23 19 16 13 10 8 6 4 3 2 1 0 0 0 0 1 2 4 5 7 9 12 15 18 21 25 28 32 37 41 46 51 56 61 67 73 78 84 90 96 102 109 115 121 127
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/Sin.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms/Sin.tlw.REMOVED.git-id
deleted file mode 100644
index ceeb1ad1..00000000
--- a/Desktop_Interface/bin/waveforms/Sin.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e376c35388394ccfa4a86cb5bc6f9961e00fef20
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/Square.tlw b/Desktop_Interface/bin/waveforms/Square.tlw
new file mode 100644
index 00000000..7bdd30be
--- /dev/null
+++ b/Desktop_Interface/bin/waveforms/Square.tlw
@@ -0,0 +1,3 @@
+128
+5
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
diff --git a/Desktop_Interface/bin/waveforms/Square.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms/Square.tlw.REMOVED.git-id
deleted file mode 100644
index 25d85bc6..00000000
--- a/Desktop_Interface/bin/waveforms/Square.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7bdd30bee84b15cc3fe88dd02751316a2016060c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/Triangle.tlw b/Desktop_Interface/bin/waveforms/Triangle.tlw
new file mode 100644
index 00000000..420ac92c
--- /dev/null
+++ b/Desktop_Interface/bin/waveforms/Triangle.tlw
@@ -0,0 +1,3 @@
+128
+4
+0 4 8 12 16 20 24 28 32 36 40 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 125 130 134 138 142 146 150 154 158 162 166 170 174 178 182 186 190 194 198 202 206 210 215 219 223 227 231 235 239 243 247 251 255 255 251 247 243 239 235 231 227 223 219 215 210 206 202 198 194 190 186 182 178 174 170 166 162 158 154 150 146 142 138 134 130 125 121 117 113 109 105 101 97 93 89 85 81 77 73 69 65 61 57 53 49 45 40 36 32 28 24 20 16 12 8 4 0
diff --git a/Desktop_Interface/bin/waveforms/Triangle.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms/Triangle.tlw.REMOVED.git-id
deleted file mode 100644
index 768d2ac7..00000000
--- a/Desktop_Interface/bin/waveforms/Triangle.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-420ac92c2c292688434b3987874cc98a9180e336
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/_list.wfl b/Desktop_Interface/bin/waveforms/_list.wfl
new file mode 100644
index 00000000..d9c5ca2b
--- /dev/null
+++ b/Desktop_Interface/bin/waveforms/_list.wfl
@@ -0,0 +1,5 @@
+Sin
+Square
+Triangle
+Sawtooth
+DC
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms/_list.wfl.REMOVED.git-id b/Desktop_Interface/bin/waveforms/_list.wfl.REMOVED.git-id
deleted file mode 100644
index 2b3bbd46..00000000
--- a/Desktop_Interface/bin/waveforms/_list.wfl.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-d9c5ca2b7e1352538debad0a17885fc4355864fc
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms_OLD_20170628/Sawtooth.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms_OLD_20170628/Sawtooth.tlw.REMOVED.git-id
deleted file mode 100644
index 87e86502..00000000
--- a/Desktop_Interface/bin/waveforms_OLD_20170628/Sawtooth.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e989a81be4fb7a2d79495ce7e96db776b0366a94
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms_OLD_20170628/Sin.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms_OLD_20170628/Sin.tlw.REMOVED.git-id
deleted file mode 100644
index ceeb1ad1..00000000
--- a/Desktop_Interface/bin/waveforms_OLD_20170628/Sin.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e376c35388394ccfa4a86cb5bc6f9961e00fef20
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms_OLD_20170628/Square.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms_OLD_20170628/Square.tlw.REMOVED.git-id
deleted file mode 100644
index 25d85bc6..00000000
--- a/Desktop_Interface/bin/waveforms_OLD_20170628/Square.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7bdd30bee84b15cc3fe88dd02751316a2016060c
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms_OLD_20170628/Triangle.tlw.REMOVED.git-id b/Desktop_Interface/bin/waveforms_OLD_20170628/Triangle.tlw.REMOVED.git-id
deleted file mode 100644
index 768d2ac7..00000000
--- a/Desktop_Interface/bin/waveforms_OLD_20170628/Triangle.tlw.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-420ac92c2c292688434b3987874cc98a9180e336
\ No newline at end of file
diff --git a/Desktop_Interface/bin/waveforms_OLD_20170628/_list.wfl.REMOVED.git-id b/Desktop_Interface/bin/waveforms_OLD_20170628/_list.wfl.REMOVED.git-id
deleted file mode 100644
index 91e06b43..00000000
--- a/Desktop_Interface/bin/waveforms_OLD_20170628/_list.wfl.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-488a0133badf9d48927f82bcc9fcf039e36d2065
\ No newline at end of file
diff --git a/Desktop_Interface/buffer_0.bmp b/Desktop_Interface/buffer_0.bmp
new file mode 100644
index 00000000..8d8e3b91
Binary files /dev/null and b/Desktop_Interface/buffer_0.bmp differ
diff --git a/Desktop_Interface/buffer_0.bmp.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/buffer_0.bmp.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 2e64c63d..00000000
--- a/Desktop_Interface/buffer_0.bmp.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-66befbdd3be8426d02c58c9a939ecd4c1507469a
\ No newline at end of file
diff --git a/Desktop_Interface/buffer_1.bmp b/Desktop_Interface/buffer_1.bmp
new file mode 100644
index 00000000..7d348291
Binary files /dev/null and b/Desktop_Interface/buffer_1.bmp differ
diff --git a/Desktop_Interface/buffer_1.bmp.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/buffer_1.bmp.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index b54a2424..00000000
--- a/Desktop_Interface/buffer_1.bmp.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-aafbeff0370e10df86165b544f441ccc80163fac
\ No newline at end of file
diff --git a/Desktop_Interface/buffer_2.bmp b/Desktop_Interface/buffer_2.bmp
new file mode 100644
index 00000000..b47a9187
Binary files /dev/null and b/Desktop_Interface/buffer_2.bmp differ
diff --git a/Desktop_Interface/buffer_2.bmp.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/buffer_2.bmp.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index af9d95af..00000000
--- a/Desktop_Interface/buffer_2.bmp.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f582bc8fdcd1dbe7fb84dab90f1b6737e1c67198
\ No newline at end of file
diff --git a/Desktop_Interface/buffercontrol.o.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/buffercontrol.o.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index c2804307..00000000
--- a/Desktop_Interface/buffercontrol.o.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-45c975654e008f3df8e9d5baaedbcd8d212e8056
\ No newline at end of file
diff --git a/Desktop_Interface/buffercontrol.obj.REMOVED.git-id.REMOVED.git-id b/Desktop_Interface/buffercontrol.obj.REMOVED.git-id.REMOVED.git-id
deleted file mode 100644
index 4be5c9a8..00000000
--- a/Desktop_Interface/buffercontrol.obj.REMOVED.git-id.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7d90edecf26e58c77144365ffaf74b43d759bc6e
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libdfuprog/include/libdfuprog.h b/Desktop_Interface/build_android/libdfuprog/include/libdfuprog.h
new file mode 100644
index 00000000..44aec9df
--- /dev/null
+++ b/Desktop_Interface/build_android/libdfuprog/include/libdfuprog.h
@@ -0,0 +1 @@
+int dfuprog_virtual_cmd(char* commandLine, libusb_device *device, libusb_device_handle *handle, libusb_context *parentContext, int32_t interface);
diff --git a/Desktop_Interface/build_android/libdfuprog/include/libdfuprog.h.REMOVED.git-id b/Desktop_Interface/build_android/libdfuprog/include/libdfuprog.h.REMOVED.git-id
deleted file mode 100644
index 7a325fd8..00000000
--- a/Desktop_Interface/build_android/libdfuprog/include/libdfuprog.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-44aec9df35696b724c717b0854724fc39fbdfde9
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so b/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so
new file mode 100644
index 00000000..fade7ac0
Binary files /dev/null and b/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so differ
diff --git a/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.REMOVED.git-id b/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.REMOVED.git-id
deleted file mode 100644
index bbe29cd9..00000000
--- a/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-fade7ac08a64af9903c0cc5d5186308fb5f0948d
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.old b/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.old
new file mode 100644
index 00000000..cf8f9482
Binary files /dev/null and b/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.old differ
diff --git a/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.old.REMOVED.git-id b/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.old.REMOVED.git-id
deleted file mode 100644
index 0e744381..00000000
--- a/Desktop_Interface/build_android/libdfuprog/lib/libdfuprog-0.9.so.old.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-cf8f948208f14e3593004fad5e1d0a1a089f307e
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/liblog/lib/liblog.so b/Desktop_Interface/build_android/liblog/lib/liblog.so
new file mode 100644
index 00000000..1f34f47d
Binary files /dev/null and b/Desktop_Interface/build_android/liblog/lib/liblog.so differ
diff --git a/Desktop_Interface/build_android/liblog/lib/liblog.so.REMOVED.git-id b/Desktop_Interface/build_android/liblog/lib/liblog.so.REMOVED.git-id
deleted file mode 100644
index c625b882..00000000
--- a/Desktop_Interface/build_android/liblog/lib/liblog.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-1f34f47d01e4892db5afd11c918afc6ebb912367
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp
new file mode 100644
index 00000000..c41ac9e6
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp.REMOVED.git-id
deleted file mode 100644
index 3d816425..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-c41ac9e6eccd40af7a4ea35bd3cbcd54fcf15cbb
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp_threaded b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp_threaded
new file mode 100644
index 00000000..7494d657
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp_threaded differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp_threaded.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp_threaded.REMOVED.git-id
deleted file mode 100644
index f8e55484..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/dpfp_threaded.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-7494d657a9a98577dad4dfae606b616e1513eae8
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/fxload b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/fxload
new file mode 100644
index 00000000..e80ac646
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/fxload differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/fxload.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/fxload.REMOVED.git-id
deleted file mode 100644
index ca6df357..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/fxload.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-e80ac64681d58d2ebbd6be21feb5119eff32ad00
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/hotplugtest b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/hotplugtest
new file mode 100644
index 00000000..f1711b9b
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/hotplugtest differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/hotplugtest.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/hotplugtest.REMOVED.git-id
deleted file mode 100644
index 756eaec7..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/hotplugtest.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f1711b9b72b221653e43e30028470c9e5a445096
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/libusb1.0.so b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/libusb1.0.so
new file mode 100644
index 00000000..ffddb4b3
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/libusb1.0.so differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/libusb1.0.so.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/libusb1.0.so.REMOVED.git-id
deleted file mode 100644
index 2e8bcfd7..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/libusb1.0.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ffddb4b3cece1f758e4971f6932f19562175acd1
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/listdevs b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/listdevs
new file mode 100644
index 00000000..f45a3376
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/listdevs differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/listdevs.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/listdevs.REMOVED.git-id
deleted file mode 100644
index d22bea97..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/listdevs.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-f45a337631dd40ff8f705d9afdebcbff9e1e6923
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/sam3u_benchmark b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/sam3u_benchmark
new file mode 100644
index 00000000..ed99e422
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/sam3u_benchmark differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/sam3u_benchmark.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/sam3u_benchmark.REMOVED.git-id
deleted file mode 100644
index eacc6c65..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/sam3u_benchmark.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ed99e4227659aa9fa9797446770f4f7b8a9194ef
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/stress b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/stress
new file mode 100644
index 00000000..62fd1740
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/stress differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/stress.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/stress.REMOVED.git-id
deleted file mode 100644
index 39884c52..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/stress.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-62fd17409539184ac769d7e5e13049cd902763d3
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/xusb b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/xusb
new file mode 100644
index 00000000..9aa2e139
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/xusb differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/xusb.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/xusb.REMOVED.git-id
deleted file mode 100644
index 73e7f267..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/armeabi-v7a/xusb.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9aa2e1391c0ed3e1ec85e2685b77d7e94ff843a7
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp
new file mode 100644
index 00000000..871f4b09
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp.REMOVED.git-id
deleted file mode 100644
index 2387815f..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-871f4b09faa7afadda34454ab915859b55bde181
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp_threaded b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp_threaded
new file mode 100644
index 00000000..ad75cbb7
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp_threaded differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp_threaded.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp_threaded.REMOVED.git-id
deleted file mode 100644
index a71b58f8..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/dpfp_threaded.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ad75cbb7d231b86ed3a6160084fdd7e951680096
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/fxload b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/fxload
new file mode 100644
index 00000000..2ee317a9
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/fxload differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/fxload.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/fxload.REMOVED.git-id
deleted file mode 100644
index 04fa9d7d..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/fxload.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2ee317a989de944816d54ac6820e4c99f99f9e91
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/hotplugtest b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/hotplugtest
new file mode 100644
index 00000000..0985c7c1
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/hotplugtest differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/hotplugtest.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/hotplugtest.REMOVED.git-id
deleted file mode 100644
index d721c244..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/hotplugtest.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-0985c7c1a6610e5d6ed241e088587a33a77a2e00
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/libusb1.0.so b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/libusb1.0.so
new file mode 100644
index 00000000..968deb85
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/libusb1.0.so differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/libusb1.0.so.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/libusb1.0.so.REMOVED.git-id
deleted file mode 100644
index e0be131d..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/libusb1.0.so.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-968deb8584d1ff4e5e8a8c5fd07db5c7eccd5b2f
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/listdevs b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/listdevs
new file mode 100644
index 00000000..995b86ed
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/listdevs differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/listdevs.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/listdevs.REMOVED.git-id
deleted file mode 100644
index f13f3306..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/listdevs.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-995b86edead37fd0f45031df2bf1ed72e131a267
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/sam3u_benchmark b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/sam3u_benchmark
new file mode 100644
index 00000000..69b2ede1
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/sam3u_benchmark differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/sam3u_benchmark.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/sam3u_benchmark.REMOVED.git-id
deleted file mode 100644
index 32679334..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/sam3u_benchmark.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-69b2ede1e75decf0af6dde11bbe5e19984a3dd21
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/stress b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/stress
new file mode 100644
index 00000000..966bfe28
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/stress differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/stress.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/stress.REMOVED.git-id
deleted file mode 100644
index d3f6bca2..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/stress.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-966bfe28ade447584ad600e02cb44a5734dfd7a3
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/xusb b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/xusb
new file mode 100644
index 00000000..9b931875
Binary files /dev/null and b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/xusb differ
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/xusb.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/xusb.REMOVED.git-id
deleted file mode 100644
index 85b02144..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/android/x86/xusb.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-9b931875ab18fe1cc791d1327611b4b06fdd1acb
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/core.c b/Desktop_Interface/build_android/libusb-martin-kuldeep/core.c
new file mode 100644
index 00000000..38fb55aa
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/core.c
@@ -0,0 +1,2517 @@
+/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
+/*
+ * Core functions for libusb
+ * Copyright © 2013-2016 Martin Marinov
+ * Copyright © 2012-2013 Nathan Hjelm
+ * Copyright © 2007-2008 Daniel Drake
+ * Copyright © 2001 Johannes Erdfelt
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include
+#include
+#include
+#include
+#include
+#ifdef HAVE_SYS_TYPES_H
+#include
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include
+#endif
+#ifdef HAVE_SYSLOG_H
+#include
+#endif
+
+#ifdef __ANDROID__
+#include
+#endif
+
+#include "libusbi.h"
+#include "hotplug.h"
+
+#if defined(OS_LINUX)
+const struct usbi_os_backend * const usbi_backend = &linux_usbfs_backend;
+#elif defined(OS_DARWIN)
+const struct usbi_os_backend * const usbi_backend = &darwin_backend;
+#elif defined(OS_OPENBSD)
+const struct usbi_os_backend * const usbi_backend = &openbsd_backend;
+#elif defined(OS_NETBSD)
+const struct usbi_os_backend * const usbi_backend = &netbsd_backend;
+#elif defined(OS_WINDOWS)
+const struct usbi_os_backend * const usbi_backend = &windows_backend;
+#elif defined(OS_WINCE)
+const struct usbi_os_backend * const usbi_backend = &wince_backend;
+#elif defined(OS_HAIKU)
+const struct usbi_os_backend * const usbi_backend = &haiku_usb_raw_backend;
+#else
+#error "Unsupported OS"
+#endif
+
+struct libusb_context *usbi_default_context = NULL;
+static const struct libusb_version libusb_version_internal =
+ { LIBUSB_MAJOR, LIBUSB_MINOR, LIBUSB_MICRO, LIBUSB_NANO,
+ LIBUSB_RC, "http://libusb.info" };
+static int default_context_refcnt = 0;
+static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER;
+static struct timeval timestamp_origin = { 0, 0 };
+
+usbi_mutex_static_t active_contexts_lock = USBI_MUTEX_INITIALIZER;
+struct list_head active_contexts_list;
+
+/**
+ * \mainpage libusb-1.0 API Reference
+ *
+ * \section intro Introduction
+ *
+ * libusb is an open source library that allows you to communicate with USB
+ * devices from userspace. For more info, see the
+ * libusb homepage.
+ *
+ * This documentation is aimed at application developers wishing to
+ * communicate with USB peripherals from their own software. After reviewing
+ * this documentation, feedback and questions can be sent to the
+ * libusb-devel mailing list.
+ *
+ * This documentation assumes knowledge of how to operate USB devices from
+ * a software standpoint (descriptors, configurations, interfaces, endpoints,
+ * control/bulk/interrupt/isochronous transfers, etc). Full information
+ * can be found in the USB 3.0
+ * Specification which is available for free download. You can probably
+ * find less verbose introductions by searching the web.
+ *
+ * \section API Application Programming Interface (API)
+ *
+ * See the \ref api page for a complete list of the libusb functions.
+ *
+ * \section features Library features
+ *
+ * - All transfer types supported (control/bulk/interrupt/isochronous)
+ * - 2 transfer interfaces:
+ * -# Synchronous (simple)
+ * -# Asynchronous (more complicated, but more powerful)
+ * - Thread safe (although the asynchronous interface means that you
+ * usually won't need to thread)
+ * - Lightweight with lean API
+ * - Compatible with libusb-0.1 through the libusb-compat-0.1 translation layer
+ * - Hotplug support (on some platforms). See \ref hotplug.
+ *
+ * \section gettingstarted Getting Started
+ *
+ * To begin reading the API documentation, start with the Modules page which
+ * links to the different categories of libusb's functionality.
+ *
+ * One decision you will have to make is whether to use the synchronous
+ * or the asynchronous data transfer interface. The \ref io documentation
+ * provides some insight into this topic.
+ *
+ * Some example programs can be found in the libusb source distribution under
+ * the "examples" subdirectory. The libusb homepage includes a list of
+ * real-life project examples which use libusb.
+ *
+ * \section errorhandling Error handling
+ *
+ * libusb functions typically return 0 on success or a negative error code
+ * on failure. These negative error codes relate to LIBUSB_ERROR constants
+ * which are listed on the \ref misc "miscellaneous" documentation page.
+ *
+ * \section msglog Debug message logging
+ *
+ * libusb uses stderr for all logging. By default, logging is set to NONE,
+ * which means that no output will be produced. However, unless the library
+ * has been compiled with logging disabled, then any application calls to
+ * libusb_set_debug(), or the setting of the environmental variable
+ * LIBUSB_DEBUG outside of the application, can result in logging being
+ * produced. Your application should therefore not close stderr, but instead
+ * direct it to the null device if its output is undesireable.
+ *
+ * The libusb_set_debug() function can be used to enable logging of certain
+ * messages. Under standard configuration, libusb doesn't really log much
+ * so you are advised to use this function to enable all error/warning/
+ * informational messages. It will help debug problems with your software.
+ *
+ * The logged messages are unstructured. There is no one-to-one correspondence
+ * between messages being logged and success or failure return codes from
+ * libusb functions. There is no format to the messages, so you should not
+ * try to capture or parse them. They are not and will not be localized.
+ * These messages are not intended to being passed to your application user;
+ * instead, you should interpret the error codes returned from libusb functions
+ * and provide appropriate notification to the user. The messages are simply
+ * there to aid you as a programmer, and if you're confused because you're
+ * getting a strange error code from a libusb function, enabling message
+ * logging may give you a suitable explanation.
+ *
+ * The LIBUSB_DEBUG environment variable can be used to enable message logging
+ * at run-time. This environment variable should be set to a log level number,
+ * which is interpreted the same as the libusb_set_debug() parameter. When this
+ * environment variable is set, the message logging verbosity level is fixed
+ * and libusb_set_debug() effectively does nothing.
+ *
+ * libusb can be compiled without any logging functions, useful for embedded
+ * systems. In this case, libusb_set_debug() and the LIBUSB_DEBUG environment
+ * variable have no effects.
+ *
+ * libusb can also be compiled with verbose debugging messages always. When
+ * the library is compiled in this way, all messages of all verbosities are
+ * always logged. libusb_set_debug() and the LIBUSB_DEBUG environment variable
+ * have no effects.
+ *
+ * \section remarks Other remarks
+ *
+ * libusb does have imperfections. The \ref caveats "caveats" page attempts
+ * to document these.
+ */
+
+/**
+ * \page caveats Caveats
+ *
+ * \section devresets Device resets
+ *
+ * The libusb_reset_device() function allows you to reset a device. If your
+ * program has to call such a function, it should obviously be aware that
+ * the reset will cause device state to change (e.g. register values may be
+ * reset).
+ *
+ * The problem is that any other program could reset the device your program
+ * is working with, at any time. libusb does not offer a mechanism to inform
+ * you when this has happened, so if someone else resets your device it will
+ * not be clear to your own program why the device state has changed.
+ *
+ * Ultimately, this is a limitation of writing drivers in userspace.
+ * Separation from the USB stack in the underlying kernel makes it difficult
+ * for the operating system to deliver such notifications to your program.
+ * The Linux kernel USB stack allows such reset notifications to be delivered
+ * to in-kernel USB drivers, but it is not clear how such notifications could
+ * be delivered to second-class drivers that live in userspace.
+ *
+ * \section blockonly Blocking-only functionality
+ *
+ * The functionality listed below is only available through synchronous,
+ * blocking functions. There are no asynchronous/non-blocking alternatives,
+ * and no clear ways of implementing these.
+ *
+ * - Configuration activation (libusb_set_configuration())
+ * - Interface/alternate setting activation (libusb_set_interface_alt_setting())
+ * - Releasing of interfaces (libusb_release_interface())
+ * - Clearing of halt/stall condition (libusb_clear_halt())
+ * - Device resets (libusb_reset_device())
+ *
+ * \section configsel Configuration selection and handling
+ *
+ * When libusb presents a device handle to an application, there is a chance
+ * that the corresponding device may be in unconfigured state. For devices
+ * with multiple configurations, there is also a chance that the configuration
+ * currently selected is not the one that the application wants to use.
+ *
+ * The obvious solution is to add a call to libusb_set_configuration() early
+ * on during your device initialization routines, but there are caveats to
+ * be aware of:
+ * -# If the device is already in the desired configuration, calling
+ * libusb_set_configuration() using the same configuration value will cause
+ * a lightweight device reset. This may not be desirable behaviour.
+ * -# In the case where the desired configuration is already active, libusb
+ * may not even be able to perform a lightweight device reset. For example,
+ * take my USB keyboard with fingerprint reader: I'm interested in driving
+ * the fingerprint reader interface through libusb, but the kernel's
+ * USB-HID driver will almost always have claimed the keyboard interface.
+ * Because the kernel has claimed an interface, it is not even possible to
+ * perform the lightweight device reset, so libusb_set_configuration() will
+ * fail. (Luckily the device in question only has a single configuration.)
+ * -# libusb will be unable to set a configuration if other programs or
+ * drivers have claimed interfaces. In particular, this means that kernel
+ * drivers must be detached from all the interfaces before
+ * libusb_set_configuration() may succeed.
+ *
+ * One solution to some of the above problems is to consider the currently
+ * active configuration. If the configuration we want is already active, then
+ * we don't have to select any configuration:
+\code
+cfg = -1;
+libusb_get_configuration(dev, &cfg);
+if (cfg != desired)
+ libusb_set_configuration(dev, desired);
+\endcode
+ *
+ * This is probably suitable for most scenarios, but is inherently racy:
+ * another application or driver may change the selected configuration
+ * after the libusb_get_configuration() call.
+ *
+ * Even in cases where libusb_set_configuration() succeeds, consider that other
+ * applications or drivers may change configuration after your application
+ * calls libusb_set_configuration().
+ *
+ * One possible way to lock your device into a specific configuration is as
+ * follows:
+ * -# Set the desired configuration (or use the logic above to realise that
+ * it is already in the desired configuration)
+ * -# Claim the interface that you wish to use
+ * -# Check that the currently active configuration is the one that you want
+ * to use.
+ *
+ * The above method works because once an interface is claimed, no application
+ * or driver is able to select another configuration.
+ *
+ * \section earlycomp Early transfer completion
+ *
+ * NOTE: This section is currently Linux-centric. I am not sure if any of these
+ * considerations apply to Darwin or other platforms.
+ *
+ * When a transfer completes early (i.e. when less data is received/sent in
+ * any one packet than the transfer buffer allows for) then libusb is designed
+ * to terminate the transfer immediately, not transferring or receiving any
+ * more data unless other transfers have been queued by the user.
+ *
+ * On legacy platforms, libusb is unable to do this in all situations. After
+ * the incomplete packet occurs, "surplus" data may be transferred. For recent
+ * versions of libusb, this information is kept (the data length of the
+ * transfer is updated) and, for device-to-host transfers, any surplus data was
+ * added to the buffer. Still, this is not a nice solution because it loses the
+ * information about the end of the short packet, and the user probably wanted
+ * that surplus data to arrive in the next logical transfer.
+ *
+ *
+ * \section zlp Zero length packets
+ *
+ * - libusb is able to send a packet of zero length to an endpoint simply by
+ * submitting a transfer of zero length.
+ * - The \ref libusb_transfer_flags::LIBUSB_TRANSFER_ADD_ZERO_PACKET
+ * "LIBUSB_TRANSFER_ADD_ZERO_PACKET" flag is currently only supported on Linux.
+ */
+
+/**
+ * \page contexts Contexts
+ *
+ * It is possible that libusb may be used simultaneously from two independent
+ * libraries linked into the same executable. For example, if your application
+ * has a plugin-like system which allows the user to dynamically load a range
+ * of modules into your program, it is feasible that two independently
+ * developed modules may both use libusb.
+ *
+ * libusb is written to allow for these multiple user scenarios. The two
+ * "instances" of libusb will not interfere: libusb_set_debug() calls
+ * from one user will not affect the same settings for other users, other
+ * users can continue using libusb after one of them calls libusb_exit(), etc.
+ *
+ * This is made possible through libusb's context concept. When you
+ * call libusb_init(), you are (optionally) given a context. You can then pass
+ * this context pointer back into future libusb functions.
+ *
+ * In order to keep things simple for more simplistic applications, it is
+ * legal to pass NULL to all functions requiring a context pointer (as long as
+ * you're sure no other code will attempt to use libusb from the same process).
+ * When you pass NULL, the default context will be used. The default context
+ * is created the first time a process calls libusb_init() when no other
+ * context is alive. Contexts are destroyed during libusb_exit().
+ *
+ * The default context is reference-counted and can be shared. That means that
+ * if libusb_init(NULL) is called twice within the same process, the two
+ * users end up sharing the same context. The deinitialization and freeing of
+ * the default context will only happen when the last user calls libusb_exit().
+ * In other words, the default context is created and initialized when its
+ * reference count goes from 0 to 1, and is deinitialized and destroyed when
+ * its reference count goes from 1 to 0.
+ *
+ * You may be wondering why only a subset of libusb functions require a
+ * context pointer in their function definition. Internally, libusb stores
+ * context pointers in other objects (e.g. libusb_device instances) and hence
+ * can infer the context from those objects.
+ */
+
+ /**
+ * \page api Application Programming Interface
+ *
+ * This is the complete list of libusb functions, structures and
+ * enumerations in alphabetical order.
+ *
+ * \section Functions
+ * - libusb_alloc_streams()
+ * - libusb_alloc_transfer()
+ * - libusb_attach_kernel_driver()
+ * - libusb_bulk_transfer()
+ * - libusb_cancel_transfer()
+ * - libusb_claim_interface()
+ * - libusb_clear_halt()
+ * - libusb_close()
+ * - libusb_control_transfer()
+ * - libusb_control_transfer_get_data()
+ * - libusb_control_transfer_get_setup()
+ * - libusb_cpu_to_le16()
+ * - libusb_detach_kernel_driver()
+ * - libusb_error_name()
+ * - libusb_event_handler_active()
+ * - libusb_event_handling_ok()
+ * - libusb_exit()
+ * - libusb_fill_bulk_stream_transfer()
+ * - libusb_fill_bulk_transfer()
+ * - libusb_fill_control_setup()
+ * - libusb_fill_control_transfer()
+ * - libusb_fill_interrupt_transfer()
+ * - libusb_fill_iso_transfer()
+ * - libusb_free_bos_descriptor()
+ * - libusb_free_config_descriptor()
+ * - libusb_free_container_id_descriptor()
+ * - libusb_free_device_list()
+ * - libusb_free_pollfds()
+ * - libusb_free_ss_endpoint_companion_descriptor()
+ * - libusb_free_ss_usb_device_capability_descriptor()
+ * - libusb_free_streams()
+ * - libusb_free_transfer()
+ * - libusb_free_usb_2_0_extension_descriptor()
+ * - libusb_get_active_config_descriptor()
+ * - libusb_get_bos_descriptor()
+ * - libusb_get_bus_number()
+ * - libusb_get_config_descriptor()
+ * - libusb_get_config_descriptor_by_value()
+ * - libusb_get_configuration()
+ * - libusb_get_container_id_descriptor()
+ * - libusb_get_descriptor()
+ * - libusb_get_device()
+ * - libusb_get_device_address()
+ * - libusb_get_device_descriptor()
+ * - libusb_get_device_list()
+ * - libusb_get_device_speed()
+ * - libusb_get_iso_packet_buffer()
+ * - libusb_get_iso_packet_buffer_simple()
+ * - libusb_get_max_iso_packet_size()
+ * - libusb_get_max_packet_size()
+ * - libusb_get_next_timeout()
+ * - libusb_get_parent()
+ * - libusb_get_pollfds()
+ * - libusb_get_port_number()
+ * - libusb_get_port_numbers()
+ * - libusb_get_port_path()
+ * - libusb_get_ss_endpoint_companion_descriptor()
+ * - libusb_get_ss_usb_device_capability_descriptor()
+ * - libusb_get_string_descriptor()
+ * - libusb_get_string_descriptor_ascii()
+ * - libusb_get_usb_2_0_extension_descriptor()
+ * - libusb_get_version()
+ * - libusb_handle_events()
+ * - libusb_handle_events_completed()
+ * - libusb_handle_events_locked()
+ * - libusb_handle_events_timeout()
+ * - libusb_handle_events_timeout_completed()
+ * - libusb_has_capability()
+ * - libusb_hotplug_deregister_callback()
+ * - libusb_hotplug_register_callback()
+ * - libusb_init()
+ * - libusb_interrupt_transfer()
+ * - libusb_kernel_driver_active()
+ * - libusb_lock_events()
+ * - libusb_lock_event_waiters()
+ * - libusb_open()
+ * - libusb_open_device_with_vid_pid()
+ * - libusb_pollfds_handle_timeouts()
+ * - libusb_ref_device()
+ * - libusb_release_interface()
+ * - libusb_reset_device()
+ * - libusb_set_auto_detach_kernel_driver()
+ * - libusb_set_configuration()
+ * - libusb_set_debug()
+ * - libusb_set_interface_alt_setting()
+ * - libusb_set_iso_packet_lengths()
+ * - libusb_setlocale()
+ * - libusb_set_pollfd_notifiers()
+ * - libusb_strerror()
+ * - libusb_submit_transfer()
+ * - libusb_transfer_get_stream_id()
+ * - libusb_transfer_set_stream_id()
+ * - libusb_try_lock_events()
+ * - libusb_unlock_events()
+ * - libusb_unlock_event_waiters()
+ * - libusb_unref_device()
+ * - libusb_wait_for_event()
+ *
+ * \section Structures
+ * - libusb_bos_descriptor
+ * - libusb_bos_dev_capability_descriptor
+ * - libusb_config_descriptor
+ * - libusb_container_id_descriptor
+ * - \ref libusb_context
+ * - libusb_control_setup
+ * - \ref libusb_device
+ * - libusb_device_descriptor
+ * - \ref libusb_device_handle
+ * - libusb_endpoint_descriptor
+ * - libusb_interface
+ * - libusb_interface_descriptor
+ * - libusb_iso_packet_descriptor
+ * - libusb_pollfd
+ * - libusb_ss_endpoint_companion_descriptor
+ * - libusb_ss_usb_device_capability_descriptor
+ * - libusb_transfer
+ * - libusb_usb_2_0_extension_descriptor
+ * - libusb_version
+ *
+ * \section Enums
+ * - \ref libusb_bos_type
+ * - \ref libusb_capability
+ * - \ref libusb_class_code
+ * - \ref libusb_descriptor_type
+ * - \ref libusb_endpoint_direction
+ * - \ref libusb_error
+ * - \ref libusb_iso_sync_type
+ * - \ref libusb_iso_usage_type
+ * - \ref libusb_log_level
+ * - \ref libusb_request_recipient
+ * - \ref libusb_request_type
+ * - \ref libusb_speed
+ * - \ref libusb_ss_usb_device_capability_attributes
+ * - \ref libusb_standard_request
+ * - \ref libusb_supported_speed
+ * - \ref libusb_transfer_flags
+ * - \ref libusb_transfer_status
+ * - \ref libusb_transfer_type
+ * - \ref libusb_usb_2_0_extension_attributes
+ */
+
+/**
+ * @defgroup lib Library initialization/deinitialization
+ * This page details how to initialize and deinitialize libusb. Initialization
+ * must be performed before using any libusb functionality, and similarly you
+ * must not call any libusb functions after deinitialization.
+ */
+
+/**
+ * @defgroup dev Device handling and enumeration
+ * The functionality documented below is designed to help with the following
+ * operations:
+ * - Enumerating the USB devices currently attached to the system
+ * - Choosing a device to operate from your software
+ * - Opening and closing the chosen device
+ *
+ * \section nutshell In a nutshell...
+ *
+ * The description below really makes things sound more complicated than they
+ * actually are. The following sequence of function calls will be suitable
+ * for almost all scenarios and does not require you to have such a deep
+ * understanding of the resource management issues:
+ * \code
+// discover devices
+libusb_device **list;
+libusb_device *found = NULL;
+ssize_t cnt = libusb_get_device_list(NULL, &list);
+ssize_t i = 0;
+int err = 0;
+if (cnt < 0)
+ error();
+
+for (i = 0; i < cnt; i++) {
+ libusb_device *device = list[i];
+ if (is_interesting(device)) {
+ found = device;
+ break;
+ }
+}
+
+if (found) {
+ libusb_device_handle *handle;
+
+ err = libusb_open(found, &handle);
+ if (err)
+ error();
+ // etc
+}
+
+libusb_free_device_list(list, 1);
+\endcode
+ *
+ * The two important points:
+ * - You asked libusb_free_device_list() to unreference the devices (2nd
+ * parameter)
+ * - You opened the device before freeing the list and unreferencing the
+ * devices
+ *
+ * If you ended up with a handle, you can now proceed to perform I/O on the
+ * device.
+ *
+ * \section devshandles Devices and device handles
+ * libusb has a concept of a USB device, represented by the
+ * \ref libusb_device opaque type. A device represents a USB device that
+ * is currently or was previously connected to the system. Using a reference
+ * to a device, you can determine certain information about the device (e.g.
+ * you can read the descriptor data).
+ *
+ * The libusb_get_device_list() function can be used to obtain a list of
+ * devices currently connected to the system. This is known as device
+ * discovery.
+ *
+ * Just because you have a reference to a device does not mean it is
+ * necessarily usable. The device may have been unplugged, you may not have
+ * permission to operate such device, or another program or driver may be
+ * using the device.
+ *
+ * When you've found a device that you'd like to operate, you must ask
+ * libusb to open the device using the libusb_open() function. Assuming
+ * success, libusb then returns you a device handle
+ * (a \ref libusb_device_handle pointer). All "real" I/O operations then
+ * operate on the handle rather than the original device pointer.
+ *
+ * \section devref Device discovery and reference counting
+ *
+ * Device discovery (i.e. calling libusb_get_device_list()) returns a
+ * freshly-allocated list of devices. The list itself must be freed when
+ * you are done with it. libusb also needs to know when it is OK to free
+ * the contents of the list - the devices themselves.
+ *
+ * To handle these issues, libusb provides you with two separate items:
+ * - A function to free the list itself
+ * - A reference counting system for the devices inside
+ *
+ * New devices presented by the libusb_get_device_list() function all have a
+ * reference count of 1. You can increase and decrease reference count using
+ * libusb_ref_device() and libusb_unref_device(). A device is destroyed when
+ * its reference count reaches 0.
+ *
+ * With the above information in mind, the process of opening a device can
+ * be viewed as follows:
+ * -# Discover devices using libusb_get_device_list().
+ * -# Choose the device that you want to operate, and call libusb_open().
+ * -# Unref all devices in the discovered device list.
+ * -# Free the discovered device list.
+ *
+ * The order is important - you must not unreference the device before
+ * attempting to open it, because unreferencing it may destroy the device.
+ *
+ * For convenience, the libusb_free_device_list() function includes a
+ * parameter to optionally unreference all the devices in the list before
+ * freeing the list itself. This combines steps 3 and 4 above.
+ *
+ * As an implementation detail, libusb_open() actually adds a reference to
+ * the device in question. This is because the device remains available
+ * through the handle via libusb_get_device(). The reference is deleted during
+ * libusb_close().
+ */
+
+/** @defgroup misc Miscellaneous */
+
+/* we traverse usbfs without knowing how many devices we are going to find.
+ * so we create this discovered_devs model which is similar to a linked-list
+ * which grows when required. it can be freed once discovery has completed,
+ * eliminating the need for a list node in the libusb_device structure
+ * itself. */
+#define DISCOVERED_DEVICES_SIZE_STEP 8
+
+static struct discovered_devs *discovered_devs_alloc(void)
+{
+ struct discovered_devs *ret =
+ malloc(sizeof(*ret) + (sizeof(void *) * DISCOVERED_DEVICES_SIZE_STEP));
+
+ if (ret) {
+ ret->len = 0;
+ ret->capacity = DISCOVERED_DEVICES_SIZE_STEP;
+ }
+ return ret;
+}
+
+/* append a device to the discovered devices collection. may realloc itself,
+ * returning new discdevs. returns NULL on realloc failure. */
+struct discovered_devs *discovered_devs_append(
+ struct discovered_devs *discdevs, struct libusb_device *dev)
+{
+ size_t len = discdevs->len;
+ size_t capacity;
+
+ /* if there is space, just append the device */
+ if (len < discdevs->capacity) {
+ discdevs->devices[len] = libusb_ref_device(dev);
+ discdevs->len++;
+ return discdevs;
+ }
+
+ /* exceeded capacity, need to grow */
+ usbi_dbg("need to increase capacity");
+ capacity = discdevs->capacity + DISCOVERED_DEVICES_SIZE_STEP;
+ discdevs = usbi_reallocf(discdevs,
+ sizeof(*discdevs) + (sizeof(void *) * capacity));
+ if (discdevs) {
+ discdevs->capacity = capacity;
+ discdevs->devices[len] = libusb_ref_device(dev);
+ discdevs->len++;
+ }
+
+ return discdevs;
+}
+
+static void discovered_devs_free(struct discovered_devs *discdevs)
+{
+ size_t i;
+
+ for (i = 0; i < discdevs->len; i++)
+ libusb_unref_device(discdevs->devices[i]);
+
+ free(discdevs);
+}
+
+/* Allocate a new device with a specific session ID. The returned device has
+ * a reference count of 1. */
+struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
+ unsigned long session_id)
+{
+ size_t priv_size = usbi_backend->device_priv_size;
+ struct libusb_device *dev = calloc(1, sizeof(*dev) + priv_size);
+ int r;
+
+ if (!dev)
+ return NULL;
+
+ r = usbi_mutex_init(&dev->lock, NULL);
+ if (r) {
+ free(dev);
+ return NULL;
+ }
+
+ dev->ctx = ctx;
+ dev->refcnt = 1;
+ dev->session_data = session_id;
+ dev->speed = LIBUSB_SPEED_UNKNOWN;
+
+ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
+ usbi_connect_device (dev);
+ }
+
+ return dev;
+}
+
+void usbi_connect_device(struct libusb_device *dev)
+{
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+
+ dev->attached = 1;
+
+ usbi_mutex_lock(&dev->ctx->usb_devs_lock);
+ list_add(&dev->list, &dev->ctx->usb_devs);
+ usbi_mutex_unlock(&dev->ctx->usb_devs_lock);
+
+ /* Signal that an event has occurred for this device if we support hotplug AND
+ * the hotplug message list is ready. This prevents an event from getting raised
+ * during initial enumeration. */
+ if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG) && dev->ctx->hotplug_msgs.next) {
+ usbi_hotplug_notification(ctx, dev, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED);
+ }
+}
+
+void usbi_disconnect_device(struct libusb_device *dev)
+{
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+
+ usbi_mutex_lock(&dev->lock);
+ dev->attached = 0;
+ usbi_mutex_unlock(&dev->lock);
+
+ usbi_mutex_lock(&ctx->usb_devs_lock);
+ list_del(&dev->list);
+ usbi_mutex_unlock(&ctx->usb_devs_lock);
+
+ /* Signal that an event has occurred for this device if we support hotplug AND
+ * the hotplug message list is ready. This prevents an event from getting raised
+ * during initial enumeration. libusb_handle_events will take care of dereferencing
+ * the device. */
+ if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG) && dev->ctx->hotplug_msgs.next) {
+ usbi_hotplug_notification(ctx, dev, LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT);
+ }
+}
+
+/* Perform some final sanity checks on a newly discovered device. If this
+ * function fails (negative return code), the device should not be added
+ * to the discovered device list. */
+int usbi_sanitize_device(struct libusb_device *dev)
+{
+ int r;
+ uint8_t num_configurations;
+
+ r = usbi_device_cache_descriptor(dev);
+ if (r < 0)
+ return r;
+
+ num_configurations = dev->device_descriptor.bNumConfigurations;
+ if (num_configurations > USB_MAXCONFIG) {
+ usbi_err(DEVICE_CTX(dev), "too many configurations");
+ return LIBUSB_ERROR_IO;
+ } else if (0 == num_configurations)
+ usbi_dbg("zero configurations, maybe an unauthorized device");
+
+ dev->num_configurations = num_configurations;
+ return 0;
+}
+
+/* Examine libusb's internal list of known devices, looking for one with
+ * a specific session ID. Returns the matching device if it was found, and
+ * NULL otherwise. */
+struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
+ unsigned long session_id)
+{
+ struct libusb_device *dev;
+ struct libusb_device *ret = NULL;
+
+ usbi_mutex_lock(&ctx->usb_devs_lock);
+ list_for_each_entry(dev, &ctx->usb_devs, list, struct libusb_device)
+ if (dev->session_data == session_id) {
+ ret = libusb_ref_device(dev);
+ break;
+ }
+ usbi_mutex_unlock(&ctx->usb_devs_lock);
+
+ return ret;
+}
+
+/** @ingroup dev
+ * Returns a list of USB devices currently attached to the system. This is
+ * your entry point into finding a USB device to operate.
+ *
+ * You are expected to unreference all the devices when you are done with
+ * them, and then free the list with libusb_free_device_list(). Note that
+ * libusb_free_device_list() can unref all the devices for you. Be careful
+ * not to unreference a device you are about to open until after you have
+ * opened it.
+ *
+ * This return value of this function indicates the number of devices in
+ * the resultant list. The list is actually one element larger, as it is
+ * NULL-terminated.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param list output location for a list of devices. Must be later freed with
+ * libusb_free_device_list().
+ * \returns the number of devices in the outputted list, or any
+ * \ref libusb_error according to errors encountered by the backend.
+ */
+ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx,
+ libusb_device ***list)
+{
+ struct discovered_devs *discdevs = discovered_devs_alloc();
+ struct libusb_device **ret;
+ int r = 0;
+ ssize_t i, len;
+ USBI_GET_CONTEXT(ctx);
+ usbi_dbg("");
+
+ if (!discdevs)
+ return LIBUSB_ERROR_NO_MEM;
+
+ if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
+ /* backend provides hotplug support */
+ struct libusb_device *dev;
+
+ if (usbi_backend->hotplug_poll)
+ usbi_backend->hotplug_poll();
+
+ usbi_mutex_lock(&ctx->usb_devs_lock);
+ list_for_each_entry(dev, &ctx->usb_devs, list, struct libusb_device) {
+ discdevs = discovered_devs_append(discdevs, dev);
+
+ if (!discdevs) {
+ r = LIBUSB_ERROR_NO_MEM;
+ break;
+ }
+ }
+ usbi_mutex_unlock(&ctx->usb_devs_lock);
+ } else {
+ /* backend does not provide hotplug support */
+ r = usbi_backend->get_device_list(ctx, &discdevs);
+ }
+
+ if (r < 0) {
+ len = r;
+ goto out;
+ }
+
+ /* convert discovered_devs into a list */
+ len = discdevs->len;
+ ret = calloc(len + 1, sizeof(struct libusb_device *));
+ if (!ret) {
+ len = LIBUSB_ERROR_NO_MEM;
+ goto out;
+ }
+
+ ret[len] = NULL;
+ for (i = 0; i < len; i++) {
+ struct libusb_device *dev = discdevs->devices[i];
+ ret[i] = libusb_ref_device(dev);
+ }
+ *list = ret;
+
+out:
+ discovered_devs_free(discdevs);
+ return len;
+}
+
+/** \ingroup dev
+ * Frees a list of devices previously discovered using
+ * libusb_get_device_list(). If the unref_devices parameter is set, the
+ * reference count of each device in the list is decremented by 1.
+ * \param list the list to free
+ * \param unref_devices whether to unref the devices in the list
+ */
+void API_EXPORTED libusb_free_device_list(libusb_device **list,
+ int unref_devices)
+{
+ if (!list)
+ return;
+
+ if (unref_devices) {
+ int i = 0;
+ struct libusb_device *dev;
+
+ while ((dev = list[i++]) != NULL)
+ libusb_unref_device(dev);
+ }
+ free(list);
+}
+
+/** \ingroup dev
+ * Get the number of the bus that a device is connected to.
+ * \param dev a device
+ * \returns the bus number
+ */
+uint8_t API_EXPORTED libusb_get_bus_number(libusb_device *dev)
+{
+ return dev->bus_number;
+}
+
+/** \ingroup dev
+ * Get the number of the port that a device is connected to.
+ * Unless the OS does something funky, or you are hot-plugging USB extension cards,
+ * the port number returned by this call is usually guaranteed to be uniquely tied
+ * to a physical port, meaning that different devices plugged on the same physical
+ * port should return the same port number.
+ *
+ * But outside of this, there is no guarantee that the port number returned by this
+ * call will remain the same, or even match the order in which ports have been
+ * numbered by the HUB/HCD manufacturer.
+ *
+ * \param dev a device
+ * \returns the port number (0 if not available)
+ */
+uint8_t API_EXPORTED libusb_get_port_number(libusb_device *dev)
+{
+ return dev->port_number;
+}
+
+/** \ingroup dev
+ * Get the list of all port numbers from root for the specified device
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ * \param dev a device
+ * \param port_numbers the array that should contain the port numbers
+ * \param port_numbers_len the maximum length of the array. As per the USB 3.0
+ * specs, the current maximum limit for the depth is 7.
+ * \returns the number of elements filled
+ * \returns LIBUSB_ERROR_OVERFLOW if the array is too small
+ */
+int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
+ uint8_t* port_numbers, int port_numbers_len)
+{
+ int i = port_numbers_len;
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+
+ if (port_numbers_len <= 0)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
+ // HCDs can be listed as devices with port #0
+ while((dev) && (dev->port_number != 0)) {
+ if (--i < 0) {
+ usbi_warn(ctx, "port numbers array is too small");
+ return LIBUSB_ERROR_OVERFLOW;
+ }
+ port_numbers[i] = dev->port_number;
+ dev = dev->parent_dev;
+ }
+ if (i < port_numbers_len)
+ memmove(port_numbers, &port_numbers[i], port_numbers_len - i);
+ return port_numbers_len - i;
+}
+
+/** \ingroup dev
+ * Deprecated please use libusb_get_port_numbers instead.
+ */
+int API_EXPORTED libusb_get_port_path(libusb_context *ctx, libusb_device *dev,
+ uint8_t* port_numbers, uint8_t port_numbers_len)
+{
+ UNUSED(ctx);
+
+ return libusb_get_port_numbers(dev, port_numbers, port_numbers_len);
+}
+
+/** \ingroup dev
+ * Get the the parent from the specified device.
+ * \param dev a device
+ * \returns the device parent or NULL if not available
+ * You should issue a \ref libusb_get_device_list() before calling this
+ * function and make sure that you only access the parent before issuing
+ * \ref libusb_free_device_list(). The reason is that libusb currently does
+ * not maintain a permanent list of device instances, and therefore can
+ * only guarantee that parents are fully instantiated within a
+ * libusb_get_device_list() - libusb_free_device_list() block.
+ */
+DEFAULT_VISIBILITY
+libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev)
+{
+ return dev->parent_dev;
+}
+
+/** \ingroup dev
+ * Get the address of the device on the bus it is connected to.
+ * \param dev a device
+ * \returns the device address
+ */
+uint8_t API_EXPORTED libusb_get_device_address(libusb_device *dev)
+{
+ return dev->device_address;
+}
+
+/** \ingroup dev
+ * Get the negotiated connection speed for a device.
+ * \param dev a device
+ * \returns a \ref libusb_speed code, where LIBUSB_SPEED_UNKNOWN means that
+ * the OS doesn't know or doesn't support returning the negotiated speed.
+ */
+int API_EXPORTED libusb_get_device_speed(libusb_device *dev)
+{
+ return dev->speed;
+}
+
+static const struct libusb_endpoint_descriptor *find_endpoint(
+ struct libusb_config_descriptor *config, unsigned char endpoint)
+{
+ int iface_idx;
+ for (iface_idx = 0; iface_idx < config->bNumInterfaces; iface_idx++) {
+ const struct libusb_interface *iface = &config->interface[iface_idx];
+ int altsetting_idx;
+
+ for (altsetting_idx = 0; altsetting_idx < iface->num_altsetting;
+ altsetting_idx++) {
+ const struct libusb_interface_descriptor *altsetting
+ = &iface->altsetting[altsetting_idx];
+ int ep_idx;
+
+ for (ep_idx = 0; ep_idx < altsetting->bNumEndpoints; ep_idx++) {
+ const struct libusb_endpoint_descriptor *ep =
+ &altsetting->endpoint[ep_idx];
+ if (ep->bEndpointAddress == endpoint)
+ return ep;
+ }
+ }
+ }
+ return NULL;
+}
+
+/** \ingroup dev
+ * Convenience function to retrieve the wMaxPacketSize value for a particular
+ * endpoint in the active device configuration.
+ *
+ * This function was originally intended to be of assistance when setting up
+ * isochronous transfers, but a design mistake resulted in this function
+ * instead. It simply returns the wMaxPacketSize value without considering
+ * its contents. If you're dealing with isochronous transfers, you probably
+ * want libusb_get_max_iso_packet_size() instead.
+ *
+ * \param dev a device
+ * \param endpoint address of the endpoint in question
+ * \returns the wMaxPacketSize value
+ * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist
+ * \returns LIBUSB_ERROR_OTHER on other failure
+ */
+int API_EXPORTED libusb_get_max_packet_size(libusb_device *dev,
+ unsigned char endpoint)
+{
+ struct libusb_config_descriptor *config;
+ const struct libusb_endpoint_descriptor *ep;
+ int r;
+
+ r = libusb_get_active_config_descriptor(dev, &config);
+ if (r < 0) {
+ usbi_err(DEVICE_CTX(dev),
+ "could not retrieve active config descriptor");
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ ep = find_endpoint(config, endpoint);
+ if (!ep) {
+ r = LIBUSB_ERROR_NOT_FOUND;
+ goto out;
+ }
+
+ r = ep->wMaxPacketSize;
+
+out:
+ libusb_free_config_descriptor(config);
+ return r;
+}
+
+/** \ingroup dev
+ * Calculate the maximum packet size which a specific endpoint is capable is
+ * sending or receiving in the duration of 1 microframe
+ *
+ * Only the active configuration is examined. The calculation is based on the
+ * wMaxPacketSize field in the endpoint descriptor as described in section
+ * 9.6.6 in the USB 2.0 specifications.
+ *
+ * If acting on an isochronous or interrupt endpoint, this function will
+ * multiply the value found in bits 0:10 by the number of transactions per
+ * microframe (determined by bits 11:12). Otherwise, this function just
+ * returns the numeric value found in bits 0:10.
+ *
+ * This function is useful for setting up isochronous transfers, for example
+ * you might pass the return value from this function to
+ * libusb_set_iso_packet_lengths() in order to set the length field of every
+ * isochronous packet in a transfer.
+ *
+ * Since v1.0.3.
+ *
+ * \param dev a device
+ * \param endpoint address of the endpoint in question
+ * \returns the maximum packet size which can be sent/received on this endpoint
+ * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist
+ * \returns LIBUSB_ERROR_OTHER on other failure
+ */
+int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
+ unsigned char endpoint)
+{
+ struct libusb_config_descriptor *config;
+ const struct libusb_endpoint_descriptor *ep;
+ enum libusb_transfer_type ep_type;
+ uint16_t val;
+ int r;
+
+ r = libusb_get_active_config_descriptor(dev, &config);
+ if (r < 0) {
+ usbi_err(DEVICE_CTX(dev),
+ "could not retrieve active config descriptor");
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ ep = find_endpoint(config, endpoint);
+ if (!ep) {
+ r = LIBUSB_ERROR_NOT_FOUND;
+ goto out;
+ }
+
+ val = ep->wMaxPacketSize;
+ ep_type = (enum libusb_transfer_type) (ep->bmAttributes & 0x3);
+
+ r = val & 0x07ff;
+ if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
+ || ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT)
+ r *= (1 + ((val >> 11) & 3));
+
+out:
+ libusb_free_config_descriptor(config);
+ return r;
+}
+
+/** \ingroup dev
+ * Increment the reference count of a device.
+ * \param dev the device to reference
+ * \returns the same device
+ */
+DEFAULT_VISIBILITY
+libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev)
+{
+ usbi_mutex_lock(&dev->lock);
+ dev->refcnt++;
+ usbi_mutex_unlock(&dev->lock);
+ return dev;
+}
+
+/** \ingroup dev
+ * Decrement the reference count of a device. If the decrement operation
+ * causes the reference count to reach zero, the device shall be destroyed.
+ * \param dev the device to unreference
+ */
+void API_EXPORTED libusb_unref_device(libusb_device *dev)
+{
+ int refcnt;
+
+ if (!dev)
+ return;
+
+ usbi_mutex_lock(&dev->lock);
+ refcnt = --dev->refcnt;
+ usbi_mutex_unlock(&dev->lock);
+
+ if (refcnt == 0) {
+ usbi_dbg("destroy device %d.%d", dev->bus_number, dev->device_address);
+
+ libusb_unref_device(dev->parent_dev);
+
+ if (usbi_backend->destroy_device)
+ usbi_backend->destroy_device(dev);
+
+ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
+ /* backend does not support hotplug */
+ usbi_disconnect_device(dev);
+ }
+
+ usbi_mutex_destroy(&dev->lock);
+ free(dev);
+ }
+}
+
+/*
+ * Signal the event pipe so that the event handling thread will be
+ * interrupted to process an internal event.
+ */
+int usbi_signal_event(struct libusb_context *ctx)
+{
+ unsigned char dummy = 1;
+ ssize_t r;
+
+ /* write some data on event pipe to interrupt event handlers */
+ r = usbi_write(ctx->event_pipe[1], &dummy, sizeof(dummy));
+ if (r != sizeof(dummy)) {
+ usbi_warn(ctx, "internal signalling write failed");
+ return LIBUSB_ERROR_IO;
+ }
+
+ return 0;
+}
+
+/*
+ * Clear the event pipe so that the event handling will no longer be
+ * interrupted.
+ */
+int usbi_clear_event(struct libusb_context *ctx)
+{
+ unsigned char dummy;
+ ssize_t r;
+
+ /* read some data on event pipe to clear it */
+ r = usbi_read(ctx->event_pipe[0], &dummy, sizeof(dummy));
+ if (r != sizeof(dummy)) {
+ usbi_warn(ctx, "internal signalling read failed");
+ return LIBUSB_ERROR_IO;
+ }
+
+ return 0;
+}
+
+/** \ingroup dev
+ * Open a device and obtain a device handle. A handle allows you to perform
+ * I/O on the device in question.
+ *
+ * Internally, this function adds a reference to the device and makes it
+ * available to you through libusb_get_device(). This reference is removed
+ * during libusb_close().
+ *
+ * This is a non-blocking function; no requests are sent over the bus.
+ *
+ * \param dev the device to open
+ * \param handle output location for the returned device handle pointer. Only
+ * populated when the return code is 0.
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NO_MEM on memory allocation failure
+ * \returns LIBUSB_ERROR_ACCESS if the user has insufficient permissions
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns another LIBUSB_ERROR code on other failure
+ */
+int API_EXPORTED libusb_open(libusb_device *dev,
+ libusb_device_handle **handle)
+{
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+ struct libusb_device_handle *_handle;
+ size_t priv_size = usbi_backend->device_handle_priv_size;
+ int r;
+ usbi_dbg("open %d.%d", dev->bus_number, dev->device_address);
+
+ if (!dev->attached) {
+ return LIBUSB_ERROR_NO_DEVICE;
+ }
+
+ _handle = malloc(sizeof(*_handle) + priv_size);
+ if (!_handle)
+ return LIBUSB_ERROR_NO_MEM;
+
+ r = usbi_mutex_init(&_handle->lock, NULL);
+ if (r) {
+ free(_handle);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ _handle->dev = libusb_ref_device(dev);
+ _handle->auto_detach_kernel_driver = 0;
+ _handle->claimed_interfaces = 0;
+ memset(&_handle->os_priv, 0, priv_size);
+
+ r = usbi_backend->open(_handle);
+ if (r < 0) {
+ usbi_dbg("open %d.%d returns %d", dev->bus_number, dev->device_address, r);
+ libusb_unref_device(dev);
+ usbi_mutex_destroy(&_handle->lock);
+ free(_handle);
+ return r;
+ }
+
+ usbi_mutex_lock(&ctx->open_devs_lock);
+ list_add(&_handle->list, &ctx->open_devs);
+ usbi_mutex_unlock(&ctx->open_devs_lock);
+ *handle = _handle;
+
+ return 0;
+}
+
+/** \ingroup dev
+ * Construct a libusb device from fd.
+ * UseCase: Android, after permission granted from Android Device
+ * Manager, using Java device fd can be extracted and pass on to NDK.
+ */
+int API_EXPORTED libusb_open2(libusb_device *dev, libusb_device_handle **handle, int fd)
+{
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+ struct libusb_device_handle *_handle;
+ size_t priv_size = usbi_backend->device_handle_priv_size;
+ int r;
+ usbi_dbg("open %d.%d", dev->bus_number, dev->device_address);
+
+ _handle = malloc(sizeof(*_handle) + priv_size);
+ if (!_handle)
+ return LIBUSB_ERROR_NO_MEM;
+
+ r = usbi_mutex_init(&_handle->lock, NULL);
+ if (r) {
+ free(_handle);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ _handle->dev = libusb_ref_device(dev);
+ _handle->claimed_interfaces = 0;
+ memset(&_handle->os_priv, 0, priv_size);
+
+ r = usbi_backend->open2(_handle, fd);
+ if (r < 0) {
+ usbi_dbg("open %d.%d returns %d", dev->bus_number, dev->device_address, r);
+ libusb_unref_device(dev);
+ usbi_mutex_destroy(&_handle->lock);
+ free(_handle);
+ return r;
+ }
+
+ usbi_mutex_lock(&ctx->open_devs_lock);
+ list_add(&_handle->list, &ctx->open_devs);
+ usbi_mutex_unlock(&ctx->open_devs_lock);
+ *handle = _handle;
+
+ return 0;
+}
+
+/** \ingroup dev
+ * Convenience function for finding a device with a particular
+ * idVendor/idProduct combination. This function is intended
+ * for those scenarios where you are using libusb to knock up a quick test
+ * application - it allows you to avoid calling libusb_get_device_list() and
+ * worrying about traversing/freeing the list.
+ *
+ * This function has limitations and is hence not intended for use in real
+ * applications: if multiple devices have the same IDs it will only
+ * give you the first one, etc.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param vendor_id the idVendor value to search for
+ * \param product_id the idProduct value to search for
+ * \returns a handle for the first found device, or NULL on error or if the
+ * device could not be found. */
+DEFAULT_VISIBILITY
+libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
+ libusb_context *ctx, uint16_t vendor_id, uint16_t product_id)
+{
+ struct libusb_device **devs;
+ struct libusb_device *found = NULL;
+ struct libusb_device *dev;
+ struct libusb_device_handle *handle = NULL;
+ size_t i = 0;
+ int r;
+
+ if (libusb_get_device_list(ctx, &devs) < 0)
+ return NULL;
+
+ while ((dev = devs[i++]) != NULL) {
+ struct libusb_device_descriptor desc;
+ r = libusb_get_device_descriptor(dev, &desc);
+ if (r < 0)
+ goto out;
+ if (desc.idVendor == vendor_id && desc.idProduct == product_id) {
+ found = dev;
+ break;
+ }
+ }
+
+ if (found) {
+ r = libusb_open(found, &handle);
+ if (r < 0)
+ handle = NULL;
+ }
+
+out:
+ libusb_free_device_list(devs, 1);
+ return handle;
+}
+
+static void do_close(struct libusb_context *ctx,
+ struct libusb_device_handle *dev_handle)
+{
+ struct usbi_transfer *itransfer;
+ struct usbi_transfer *tmp;
+
+ libusb_lock_events(ctx);
+
+ /* remove any transfers in flight that are for this device */
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
+
+ /* safe iteration because transfers may be being deleted */
+ list_for_each_entry_safe(itransfer, tmp, &ctx->flying_transfers, list, struct usbi_transfer) {
+ struct libusb_transfer *transfer =
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
+
+ if (transfer->dev_handle != dev_handle)
+ continue;
+
+ if (!(itransfer->flags & USBI_TRANSFER_DEVICE_DISAPPEARED)) {
+ usbi_err(ctx, "Device handle closed while transfer was still being processed, but the device is still connected as far as we know");
+
+ if (itransfer->flags & USBI_TRANSFER_CANCELLING)
+ usbi_warn(ctx, "A cancellation for an in-flight transfer hasn't completed but closing the device handle");
+ else
+ usbi_err(ctx, "A cancellation hasn't even been scheduled on the transfer for which the device is closing");
+ }
+
+ /* remove from the list of in-flight transfers and make sure
+ * we don't accidentally use the device handle in the future
+ * (or that such accesses will be easily caught and identified as a crash)
+ */
+ usbi_mutex_lock(&itransfer->lock);
+ list_del(&itransfer->list);
+ transfer->dev_handle = NULL;
+ usbi_mutex_unlock(&itransfer->lock);
+
+ /* it is up to the user to free up the actual transfer struct. this is
+ * just making sure that we don't attempt to process the transfer after
+ * the device handle is invalid
+ */
+ usbi_dbg("Removed transfer %p from the in-flight list because device handle %p closed",
+ transfer, dev_handle);
+ }
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
+
+ libusb_unlock_events(ctx);
+
+ usbi_mutex_lock(&ctx->open_devs_lock);
+ list_del(&dev_handle->list);
+ usbi_mutex_unlock(&ctx->open_devs_lock);
+
+ usbi_backend->close(dev_handle);
+ libusb_unref_device(dev_handle->dev);
+ usbi_mutex_destroy(&dev_handle->lock);
+ free(dev_handle);
+}
+
+/** \ingroup dev
+ * Close a device handle. Should be called on all open handles before your
+ * application exits.
+ *
+ * Internally, this function destroys the reference that was added by
+ * libusb_open() on the given device.
+ *
+ * This is a non-blocking function; no requests are sent over the bus.
+ *
+ * \param dev_handle the handle to close
+ */
+void API_EXPORTED libusb_close(libusb_device_handle *dev_handle)
+{
+ struct libusb_context *ctx;
+ int pending_events;
+
+ if (!dev_handle)
+ return;
+ usbi_dbg("");
+
+ ctx = HANDLE_CTX(dev_handle);
+
+ /* Similarly to libusb_open(), we want to interrupt all event handlers
+ * at this point. More importantly, we want to perform the actual close of
+ * the device while holding the event handling lock (preventing any other
+ * thread from doing event handling) because we will be removing a file
+ * descriptor from the polling loop. */
+
+ /* Record that we are closing a device.
+ * Only signal an event if there are no prior pending events. */
+ usbi_mutex_lock(&ctx->event_data_lock);
+ pending_events = usbi_pending_events(ctx);
+ ctx->device_close++;
+ if (!pending_events)
+ usbi_signal_event(ctx);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ /* take event handling lock */
+ libusb_lock_events(ctx);
+
+ /* Close the device */
+ do_close(ctx, dev_handle);
+
+ /* We're done with closing this device.
+ * Clear the event pipe if there are no further pending events. */
+ usbi_mutex_lock(&ctx->event_data_lock);
+ ctx->device_close--;
+ pending_events = usbi_pending_events(ctx);
+ if (!pending_events)
+ usbi_clear_event(ctx);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ /* Release event handling lock and wake up event waiters */
+ libusb_unlock_events(ctx);
+}
+
+/** \ingroup dev
+ * Get the underlying device for a handle. This function does not modify
+ * the reference count of the returned device, so do not feel compelled to
+ * unreference it when you are done.
+ * \param dev_handle a device handle
+ * \returns the underlying device
+ */
+DEFAULT_VISIBILITY
+libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle)
+{
+ return dev_handle->dev;
+}
+
+/** \ingroup dev
+ * Get the underlying device for a \a dev_node.
+ * UseCase: Android
+ * \param \a dev_node device path
+ * \returns allocate a device from \a dev_node
+ */
+DEFAULT_VISIBILITY
+libusb_device * LIBUSB_CALL libusb_get_device2(libusb_context *ctx, const char *dev_node)
+{
+ if(usbi_backend->device2 == NULL) {
+ /* Not supported on this platform */
+ return NULL;
+ }
+
+ return usbi_backend->device2(ctx, dev_node);
+}
+
+/** \ingroup dev
+ * Determine the bConfigurationValue of the currently active configuration.
+ *
+ * You could formulate your own control request to obtain this information,
+ * but this function has the advantage that it may be able to retrieve the
+ * information from operating system caches (no I/O involved).
+ *
+ * If the OS does not cache this information, then this function will block
+ * while a control transfer is submitted to retrieve the information.
+ *
+ * This function will return a value of 0 in the config output
+ * parameter if the device is in unconfigured state.
+ *
+ * \param dev a device handle
+ * \param config output location for the bConfigurationValue of the active
+ * configuration (only valid for return code 0)
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns another LIBUSB_ERROR code on other failure
+ */
+int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev,
+ int *config)
+{
+ int r = LIBUSB_ERROR_NOT_SUPPORTED;
+
+ usbi_dbg("");
+ if (usbi_backend->get_configuration)
+ r = usbi_backend->get_configuration(dev, config);
+
+ if (r == LIBUSB_ERROR_NOT_SUPPORTED) {
+ uint8_t tmp = 0;
+ usbi_dbg("falling back to control message");
+ r = libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
+ LIBUSB_REQUEST_GET_CONFIGURATION, 0, 0, &tmp, 1, 1000);
+ if (r == 0) {
+ usbi_err(HANDLE_CTX(dev), "zero bytes returned in ctrl transfer?");
+ r = LIBUSB_ERROR_IO;
+ } else if (r == 1) {
+ r = 0;
+ *config = tmp;
+ } else {
+ usbi_dbg("control failed, error %d", r);
+ }
+ }
+
+ if (r == 0)
+ usbi_dbg("active config %d", *config);
+
+ return r;
+}
+
+/** \ingroup dev
+ * Set the active configuration for a device.
+ *
+ * The operating system may or may not have already set an active
+ * configuration on the device. It is up to your application to ensure the
+ * correct configuration is selected before you attempt to claim interfaces
+ * and perform other operations.
+ *
+ * If you call this function on a device already configured with the selected
+ * configuration, then this function will act as a lightweight device reset:
+ * it will issue a SET_CONFIGURATION request using the current configuration,
+ * causing most USB-related device state to be reset (altsetting reset to zero,
+ * endpoint halts cleared, toggles reset).
+ *
+ * You cannot change/reset configuration if your application has claimed
+ * interfaces. It is advised to set the desired configuration before claiming
+ * interfaces.
+ *
+ * Alternatively you can call libusb_release_interface() first. Note if you
+ * do things this way you must ensure that auto_detach_kernel_driver for
+ * dev is 0, otherwise the kernel driver will be re-attached when you
+ * release the interface(s).
+ *
+ * You cannot change/reset configuration if other applications or drivers have
+ * claimed interfaces.
+ *
+ * A configuration value of -1 will put the device in unconfigured state.
+ * The USB specifications state that a configuration value of 0 does this,
+ * however buggy devices exist which actually have a configuration 0.
+ *
+ * You should always use this function rather than formulating your own
+ * SET_CONFIGURATION control request. This is because the underlying operating
+ * system needs to know when such changes happen.
+ *
+ * This is a blocking function.
+ *
+ * \param dev a device handle
+ * \param configuration the bConfigurationValue of the configuration you
+ * wish to activate, or -1 if you wish to put the device in an unconfigured
+ * state
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the requested configuration does not exist
+ * \returns LIBUSB_ERROR_BUSY if interfaces are currently claimed
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns another LIBUSB_ERROR code on other failure
+ * \see libusb_set_auto_detach_kernel_driver()
+ */
+int API_EXPORTED libusb_set_configuration(libusb_device_handle *dev,
+ int configuration)
+{
+ usbi_dbg("configuration %d", configuration);
+ return usbi_backend->set_configuration(dev, configuration);
+}
+
+/** \ingroup dev
+ * Claim an interface on a given device handle. You must claim the interface
+ * you wish to use before you can perform I/O on any of its endpoints.
+ *
+ * It is legal to attempt to claim an already-claimed interface, in which
+ * case libusb just returns 0 without doing anything.
+ *
+ * If auto_detach_kernel_driver is set to 1 for dev, the kernel driver
+ * will be detached if necessary, on failure the detach error is returned.
+ *
+ * Claiming of interfaces is a purely logical operation; it does not cause
+ * any requests to be sent over the bus. Interface claiming is used to
+ * instruct the underlying operating system that your application wishes
+ * to take ownership of the interface.
+ *
+ * This is a non-blocking function.
+ *
+ * \param dev a device handle
+ * \param interface_number the bInterfaceNumber of the interface you
+ * wish to claim
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the requested interface does not exist
+ * \returns LIBUSB_ERROR_BUSY if another program or driver has claimed the
+ * interface
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns a LIBUSB_ERROR code on other failure
+ * \see libusb_set_auto_detach_kernel_driver()
+ */
+int API_EXPORTED libusb_claim_interface(libusb_device_handle *dev,
+ int interface_number)
+{
+ int r = 0;
+
+ usbi_dbg("interface %d", interface_number);
+ if (interface_number >= USB_MAXINTERFACES)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ usbi_mutex_lock(&dev->lock);
+ if (dev->claimed_interfaces & (1 << interface_number))
+ goto out;
+
+ r = usbi_backend->claim_interface(dev, interface_number);
+ if (r == 0)
+ dev->claimed_interfaces |= 1 << interface_number;
+
+out:
+ usbi_mutex_unlock(&dev->lock);
+ return r;
+}
+
+/** \ingroup dev
+ * Release an interface previously claimed with libusb_claim_interface(). You
+ * should release all claimed interfaces before closing a device handle.
+ *
+ * This is a blocking function. A SET_INTERFACE control request will be sent
+ * to the device, resetting interface state to the first alternate setting.
+ *
+ * If auto_detach_kernel_driver is set to 1 for dev, the kernel
+ * driver will be re-attached after releasing the interface.
+ *
+ * \param dev a device handle
+ * \param interface_number the bInterfaceNumber of the
+ * previously-claimed interface
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the interface was not claimed
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns another LIBUSB_ERROR code on other failure
+ * \see libusb_set_auto_detach_kernel_driver()
+ */
+int API_EXPORTED libusb_release_interface(libusb_device_handle *dev,
+ int interface_number)
+{
+ int r;
+
+ usbi_dbg("interface %d", interface_number);
+ if (interface_number >= USB_MAXINTERFACES)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
+ usbi_mutex_lock(&dev->lock);
+ if (!(dev->claimed_interfaces & (1 << interface_number))) {
+ r = LIBUSB_ERROR_NOT_FOUND;
+ goto out;
+ }
+
+ r = usbi_backend->release_interface(dev, interface_number);
+ if (r == 0)
+ dev->claimed_interfaces &= ~(1 << interface_number);
+
+out:
+ usbi_mutex_unlock(&dev->lock);
+ return r;
+}
+
+/** \ingroup dev
+ * Activate an alternate setting for an interface. The interface must have
+ * been previously claimed with libusb_claim_interface().
+ *
+ * You should always use this function rather than formulating your own
+ * SET_INTERFACE control request. This is because the underlying operating
+ * system needs to know when such changes happen.
+ *
+ * This is a blocking function.
+ *
+ * \param dev a device handle
+ * \param interface_number the bInterfaceNumber of the
+ * previously-claimed interface
+ * \param alternate_setting the bAlternateSetting of the alternate
+ * setting to activate
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the interface was not claimed, or the
+ * requested alternate setting does not exist
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns another LIBUSB_ERROR code on other failure
+ */
+int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev,
+ int interface_number, int alternate_setting)
+{
+ usbi_dbg("interface %d altsetting %d",
+ interface_number, alternate_setting);
+ if (interface_number >= USB_MAXINTERFACES)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
+ usbi_mutex_lock(&dev->lock);
+ if (!dev->dev->attached) {
+ usbi_mutex_unlock(&dev->lock);
+ return LIBUSB_ERROR_NO_DEVICE;
+ }
+
+ if (!(dev->claimed_interfaces & (1 << interface_number))) {
+ usbi_mutex_unlock(&dev->lock);
+ return LIBUSB_ERROR_NOT_FOUND;
+ }
+ usbi_mutex_unlock(&dev->lock);
+
+ return usbi_backend->set_interface_altsetting(dev, interface_number,
+ alternate_setting);
+}
+
+/** \ingroup dev
+ * Clear the halt/stall condition for an endpoint. Endpoints with halt status
+ * are unable to receive or transmit data until the halt condition is stalled.
+ *
+ * You should cancel all pending transfers before attempting to clear the halt
+ * condition.
+ *
+ * This is a blocking function.
+ *
+ * \param dev a device handle
+ * \param endpoint the endpoint to clear halt status
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns another LIBUSB_ERROR code on other failure
+ */
+int API_EXPORTED libusb_clear_halt(libusb_device_handle *dev,
+ unsigned char endpoint)
+{
+ usbi_dbg("endpoint %x", endpoint);
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ return usbi_backend->clear_halt(dev, endpoint);
+}
+
+/** \ingroup dev
+ * Perform a USB port reset to reinitialize a device. The system will attempt
+ * to restore the previous configuration and alternate settings after the
+ * reset has completed.
+ *
+ * If the reset fails, the descriptors change, or the previous state cannot be
+ * restored, the device will appear to be disconnected and reconnected. This
+ * means that the device handle is no longer valid (you should close it) and
+ * rediscover the device. A return code of LIBUSB_ERROR_NOT_FOUND indicates
+ * when this is the case.
+ *
+ * This is a blocking function which usually incurs a noticeable delay.
+ *
+ * \param dev a handle of the device to reset
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the
+ * device has been disconnected
+ * \returns another LIBUSB_ERROR code on other failure
+ */
+int API_EXPORTED libusb_reset_device(libusb_device_handle *dev)
+{
+ usbi_dbg("");
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ return usbi_backend->reset_device(dev);
+}
+
+/** \ingroup asyncio
+ * Allocate up to num_streams usb bulk streams on the specified endpoints. This
+ * function takes an array of endpoints rather then a single endpoint because
+ * some protocols require that endpoints are setup with similar stream ids.
+ * All endpoints passed in must belong to the same interface.
+ *
+ * Note this function may return less streams then requested. Also note that the
+ * same number of streams are allocated for each endpoint in the endpoint array.
+ *
+ * Stream id 0 is reserved, and should not be used to communicate with devices.
+ * If libusb_alloc_streams() returns with a value of N, you may use stream ids
+ * 1 to N.
+ *
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
+ *
+ * \param dev a device handle
+ * \param num_streams number of streams to try to allocate
+ * \param endpoints array of endpoints to allocate streams on
+ * \param num_endpoints length of the endpoints array
+ * \returns number of streams allocated, or a LIBUSB_ERROR code on failure
+ */
+int API_EXPORTED libusb_alloc_streams(libusb_device_handle *dev,
+ uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
+{
+ usbi_dbg("streams %u eps %d", (unsigned) num_streams, num_endpoints);
+
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ if (usbi_backend->alloc_streams)
+ return usbi_backend->alloc_streams(dev, num_streams, endpoints,
+ num_endpoints);
+ else
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+/** \ingroup asyncio
+ * Free usb bulk streams allocated with libusb_alloc_streams().
+ *
+ * Note streams are automatically free-ed when releasing an interface.
+ *
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
+ *
+ * \param dev a device handle
+ * \param endpoints array of endpoints to free streams on
+ * \param num_endpoints length of the endpoints array
+ * \returns LIBUSB_SUCCESS, or a LIBUSB_ERROR code on failure
+ */
+int API_EXPORTED libusb_free_streams(libusb_device_handle *dev,
+ unsigned char *endpoints, int num_endpoints)
+{
+ usbi_dbg("eps %d", num_endpoints);
+
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ if (usbi_backend->free_streams)
+ return usbi_backend->free_streams(dev, endpoints,
+ num_endpoints);
+ else
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+/** \ingroup dev
+ * Determine if a kernel driver is active on an interface. If a kernel driver
+ * is active, you cannot claim the interface, and libusb will be unable to
+ * perform I/O.
+ *
+ * This functionality is not available on Windows.
+ *
+ * \param dev a device handle
+ * \param interface_number the interface to check
+ * \returns 0 if no kernel driver is active
+ * \returns 1 if a kernel driver is active
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality
+ * is not available
+ * \returns another LIBUSB_ERROR code on other failure
+ * \see libusb_detach_kernel_driver()
+ */
+int API_EXPORTED libusb_kernel_driver_active(libusb_device_handle *dev,
+ int interface_number)
+{
+ usbi_dbg("interface %d", interface_number);
+
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ if (usbi_backend->kernel_driver_active)
+ return usbi_backend->kernel_driver_active(dev, interface_number);
+ else
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+/** \ingroup dev
+ * Detach a kernel driver from an interface. If successful, you will then be
+ * able to claim the interface and perform I/O.
+ *
+ * This functionality is not available on Darwin or Windows.
+ *
+ * Note that libusb itself also talks to the device through a special kernel
+ * driver, if this driver is already attached to the device, this call will
+ * not detach it and return LIBUSB_ERROR_NOT_FOUND.
+ *
+ * \param dev a device handle
+ * \param interface_number the interface to detach the driver from
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
+ * \returns LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality
+ * is not available
+ * \returns another LIBUSB_ERROR code on other failure
+ * \see libusb_kernel_driver_active()
+ */
+int API_EXPORTED libusb_detach_kernel_driver(libusb_device_handle *dev,
+ int interface_number)
+{
+ usbi_dbg("interface %d", interface_number);
+
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ if (usbi_backend->detach_kernel_driver)
+ return usbi_backend->detach_kernel_driver(dev, interface_number);
+ else
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+/** \ingroup dev
+ * Re-attach an interface's kernel driver, which was previously detached
+ * using libusb_detach_kernel_driver(). This call is only effective on
+ * Linux and returns LIBUSB_ERROR_NOT_SUPPORTED on all other platforms.
+ *
+ * This functionality is not available on Darwin or Windows.
+ *
+ * \param dev a device handle
+ * \param interface_number the interface to attach the driver from
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
+ * \returns LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality
+ * is not available
+ * \returns LIBUSB_ERROR_BUSY if the driver cannot be attached because the
+ * interface is claimed by a program or driver
+ * \returns another LIBUSB_ERROR code on other failure
+ * \see libusb_kernel_driver_active()
+ */
+int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev,
+ int interface_number)
+{
+ usbi_dbg("interface %d", interface_number);
+
+ if (!dev->dev->attached)
+ return LIBUSB_ERROR_NO_DEVICE;
+
+ if (usbi_backend->attach_kernel_driver)
+ return usbi_backend->attach_kernel_driver(dev, interface_number);
+ else
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+/** \ingroup dev
+ * Enable/disable libusb's automatic kernel driver detachment. When this is
+ * enabled libusb will automatically detach the kernel driver on an interface
+ * when claiming the interface, and attach it when releasing the interface.
+ *
+ * Automatic kernel driver detachment is disabled on newly opened device
+ * handles by default.
+ *
+ * On platforms which do not have LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER
+ * this function will return LIBUSB_ERROR_NOT_SUPPORTED, and libusb will
+ * continue as if this function was never called.
+ *
+ * \param dev a device handle
+ * \param enable whether to enable or disable auto kernel driver detachment
+ *
+ * \returns LIBUSB_SUCCESS on success
+ * \returns LIBUSB_ERROR_NOT_SUPPORTED on platforms where the functionality
+ * is not available
+ * \see libusb_claim_interface()
+ * \see libusb_release_interface()
+ * \see libusb_set_configuration()
+ */
+int API_EXPORTED libusb_set_auto_detach_kernel_driver(
+ libusb_device_handle *dev, int enable)
+{
+ if (!(usbi_backend->caps & USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER))
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+
+ dev->auto_detach_kernel_driver = enable;
+ return LIBUSB_SUCCESS;
+}
+
+/** \ingroup lib
+ * Set log message verbosity.
+ *
+ * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
+ * printed. If you choose to increase the message verbosity level, ensure
+ * that your application does not close the stdout/stderr file descriptors.
+ *
+ * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative
+ * with its message logging and most of the time, will only log messages that
+ * explain error conditions and other oddities. This will help you debug
+ * your software.
+ *
+ * If the LIBUSB_DEBUG environment variable was set when libusb was
+ * initialized, this function does nothing: the message verbosity is fixed
+ * to the value in the environment variable.
+ *
+ * If libusb was compiled without any message logging, this function does
+ * nothing: you'll never get any messages.
+ *
+ * If libusb was compiled with verbose debug message logging, this function
+ * does nothing: you'll always get messages from all levels.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param level debug level to set
+ */
+void API_EXPORTED libusb_set_debug(libusb_context *ctx, int level)
+{
+ USBI_GET_CONTEXT(ctx);
+ if (!ctx->debug_fixed)
+ ctx->debug = level;
+}
+
+/** \ingroup lib
+ * Initialize libusb. This function must be called before calling any other
+ * libusb function.
+ *
+ * If you do not provide an output location for a context pointer, a default
+ * context will be created. If there was already a default context, it will
+ * be reused (and nothing will be initialized/reinitialized).
+ *
+ * \param context Optional output location for context pointer.
+ * Only valid on return code 0.
+ * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ * \see contexts
+ */
+int API_EXPORTED libusb_init(libusb_context **context)
+{
+ struct libusb_device *dev, *next;
+ char *dbg = getenv("LIBUSB_DEBUG");
+ struct libusb_context *ctx;
+ static int first_init = 1;
+ int r = 0;
+
+ usbi_mutex_static_lock(&default_context_lock);
+
+ if (!timestamp_origin.tv_sec) {
+ usbi_gettimeofday(×tamp_origin, NULL);
+ }
+
+ if (!context && usbi_default_context) {
+ usbi_dbg("reusing default context");
+ default_context_refcnt++;
+ usbi_mutex_static_unlock(&default_context_lock);
+ return 0;
+ }
+
+ ctx = calloc(1, sizeof(*ctx));
+ if (!ctx) {
+ r = LIBUSB_ERROR_NO_MEM;
+ goto err_unlock;
+ }
+
+#ifdef ENABLE_DEBUG_LOGGING
+ ctx->debug = LIBUSB_LOG_LEVEL_DEBUG;
+#endif
+
+ if (dbg) {
+ ctx->debug = atoi(dbg);
+ if (ctx->debug)
+ ctx->debug_fixed = 1;
+ }
+
+ /* default context should be initialized before calling usbi_dbg */
+ if (!usbi_default_context) {
+ usbi_default_context = ctx;
+ default_context_refcnt++;
+ usbi_dbg("created default context");
+ }
+
+ usbi_dbg("libusb v%u.%u.%u.%u%s", libusb_version_internal.major, libusb_version_internal.minor,
+ libusb_version_internal.micro, libusb_version_internal.nano, libusb_version_internal.rc);
+
+ usbi_mutex_init(&ctx->usb_devs_lock, NULL);
+ usbi_mutex_init(&ctx->open_devs_lock, NULL);
+ usbi_mutex_init(&ctx->hotplug_cbs_lock, NULL);
+ list_init(&ctx->usb_devs);
+ list_init(&ctx->open_devs);
+ list_init(&ctx->hotplug_cbs);
+
+ usbi_mutex_static_lock(&active_contexts_lock);
+ if (first_init) {
+ first_init = 0;
+ list_init (&active_contexts_list);
+ }
+ list_add (&ctx->list, &active_contexts_list);
+ usbi_mutex_static_unlock(&active_contexts_lock);
+
+ if (usbi_backend->init) {
+ r = usbi_backend->init(ctx);
+ if (r)
+ goto err_free_ctx;
+ }
+
+ r = usbi_io_init(ctx);
+ if (r < 0)
+ goto err_backend_exit;
+
+ usbi_mutex_static_unlock(&default_context_lock);
+
+ if (context)
+ *context = ctx;
+
+ return 0;
+
+err_backend_exit:
+ if (usbi_backend->exit)
+ usbi_backend->exit();
+err_free_ctx:
+ if (ctx == usbi_default_context) {
+ usbi_default_context = NULL;
+ default_context_refcnt--;
+ }
+
+ usbi_mutex_static_lock(&active_contexts_lock);
+ list_del (&ctx->list);
+ usbi_mutex_static_unlock(&active_contexts_lock);
+
+ usbi_mutex_lock(&ctx->usb_devs_lock);
+ list_for_each_entry_safe(dev, next, &ctx->usb_devs, list, struct libusb_device) {
+ list_del(&dev->list);
+ libusb_unref_device(dev);
+ }
+ usbi_mutex_unlock(&ctx->usb_devs_lock);
+
+ usbi_mutex_destroy(&ctx->open_devs_lock);
+ usbi_mutex_destroy(&ctx->usb_devs_lock);
+ usbi_mutex_destroy(&ctx->hotplug_cbs_lock);
+
+ free(ctx);
+err_unlock:
+ usbi_mutex_static_unlock(&default_context_lock);
+ return r;
+}
+
+/** \ingroup lib
+ * Deinitialize libusb. Should be called after closing all open devices and
+ * before your application terminates.
+ * \param ctx the context to deinitialize, or NULL for the default context
+ */
+void API_EXPORTED libusb_exit(struct libusb_context *ctx)
+{
+ struct libusb_device *dev, *next;
+ struct timeval tv = { 0, 0 };
+
+ usbi_dbg("");
+ USBI_GET_CONTEXT(ctx);
+
+ /* if working with default context, only actually do the deinitialization
+ * if we're the last user */
+ usbi_mutex_static_lock(&default_context_lock);
+ if (ctx == usbi_default_context) {
+ if (--default_context_refcnt > 0) {
+ usbi_dbg("not destroying default context");
+ usbi_mutex_static_unlock(&default_context_lock);
+ return;
+ }
+ usbi_dbg("destroying default context");
+ usbi_default_context = NULL;
+ }
+ usbi_mutex_static_unlock(&default_context_lock);
+
+ usbi_mutex_static_lock(&active_contexts_lock);
+ list_del (&ctx->list);
+ usbi_mutex_static_unlock(&active_contexts_lock);
+
+ if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
+ usbi_hotplug_deregister_all(ctx);
+
+ /*
+ * Ensure any pending unplug events are read from the hotplug
+ * pipe. The usb_device-s hold in the events are no longer part
+ * of usb_devs, but the events still hold a reference!
+ *
+ * Note we don't do this if the application has left devices
+ * open (which implies a buggy app) to avoid packet completion
+ * handlers running when the app does not expect them to run.
+ */
+ if (list_empty(&ctx->open_devs))
+ libusb_handle_events_timeout(ctx, &tv);
+
+ usbi_mutex_lock(&ctx->usb_devs_lock);
+ list_for_each_entry_safe(dev, next, &ctx->usb_devs, list, struct libusb_device) {
+ list_del(&dev->list);
+ libusb_unref_device(dev);
+ }
+ usbi_mutex_unlock(&ctx->usb_devs_lock);
+ }
+
+ /* a few sanity checks. don't bother with locking because unless
+ * there is an application bug, nobody will be accessing these. */
+ if (!list_empty(&ctx->usb_devs))
+ usbi_warn(ctx, "some libusb_devices were leaked");
+ if (!list_empty(&ctx->open_devs))
+ usbi_warn(ctx, "application left some devices open");
+
+ usbi_io_exit(ctx);
+ if (usbi_backend->exit)
+ usbi_backend->exit();
+
+ usbi_mutex_destroy(&ctx->open_devs_lock);
+ usbi_mutex_destroy(&ctx->usb_devs_lock);
+ usbi_mutex_destroy(&ctx->hotplug_cbs_lock);
+ free(ctx);
+}
+
+/** \ingroup misc
+ * Check at runtime if the loaded library has a given capability.
+ * This call should be performed after \ref libusb_init(), to ensure the
+ * backend has updated its capability set.
+ *
+ * \param capability the \ref libusb_capability to check for
+ * \returns nonzero if the running library has the capability, 0 otherwise
+ */
+int API_EXPORTED libusb_has_capability(uint32_t capability)
+{
+ switch (capability) {
+ case LIBUSB_CAP_HAS_CAPABILITY:
+ return 1;
+ case LIBUSB_CAP_HAS_HOTPLUG:
+ return !(usbi_backend->get_device_list);
+ case LIBUSB_CAP_HAS_HID_ACCESS:
+ return (usbi_backend->caps & USBI_CAP_HAS_HID_ACCESS);
+ case LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER:
+ return (usbi_backend->caps & USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER);
+ }
+ return 0;
+}
+
+/* this is defined in libusbi.h if needed */
+#ifdef LIBUSB_GETTIMEOFDAY_WIN32
+/*
+ * gettimeofday
+ * Implementation according to:
+ * The Open Group Base Specifications Issue 6
+ * IEEE Std 1003.1, 2004 Edition
+ */
+
+/*
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAIMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Contributed by:
+ * Danny Smith
+ */
+
+/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
+#define _W32_FT_OFFSET (116444736000000000)
+
+int usbi_gettimeofday(struct timeval *tp, void *tzp)
+{
+ union {
+ unsigned __int64 ns100; /* Time since 1 Jan 1601, in 100ns units */
+ FILETIME ft;
+ } _now;
+ UNUSED(tzp);
+
+ if(tp) {
+#if defined(OS_WINCE)
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &_now.ft);
+#else
+ GetSystemTimeAsFileTime (&_now.ft);
+#endif
+ tp->tv_usec=(long)((_now.ns100 / 10) % 1000000 );
+ tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000);
+ }
+ /* Always return 0 as per Open Group Base Specifications Issue 6.
+ Do not set errno on error. */
+ return 0;
+}
+#endif
+
+static void usbi_log_str(struct libusb_context *ctx,
+ enum libusb_log_level level, const char * str)
+{
+#if defined(USE_SYSTEM_LOGGING_FACILITY)
+#if defined(OS_WINDOWS) || defined(OS_WINCE)
+ /* Windows CE only supports the Unicode version of OutputDebugString. */
+ WCHAR wbuf[USBI_MAX_LOG_LEN];
+ MultiByteToWideChar(CP_UTF8, 0, str, -1, wbuf, sizeof(wbuf));
+ OutputDebugStringW(wbuf);
+#elif defined(__ANDROID__)
+ int priority = ANDROID_LOG_UNKNOWN;
+ switch (level) {
+ case LIBUSB_LOG_LEVEL_INFO: priority = ANDROID_LOG_INFO; break;
+ case LIBUSB_LOG_LEVEL_WARNING: priority = ANDROID_LOG_WARN; break;
+ case LIBUSB_LOG_LEVEL_ERROR: priority = ANDROID_LOG_ERROR; break;
+ case LIBUSB_LOG_LEVEL_DEBUG: priority = ANDROID_LOG_DEBUG; break;
+ }
+ __android_log_write(priority, "libusb", str);
+#elif defined(HAVE_SYSLOG_FUNC)
+ int syslog_level = LOG_INFO;
+ switch (level) {
+ case LIBUSB_LOG_LEVEL_INFO: syslog_level = LOG_INFO; break;
+ case LIBUSB_LOG_LEVEL_WARNING: syslog_level = LOG_WARNING; break;
+ case LIBUSB_LOG_LEVEL_ERROR: syslog_level = LOG_ERR; break;
+ case LIBUSB_LOG_LEVEL_DEBUG: syslog_level = LOG_DEBUG; break;
+ }
+ syslog(syslog_level, "%s", str);
+#else /* All of gcc, Clang, XCode seem to use #warning */
+#warning System logging is not supported on this platform. Logging to stderr will be used instead.
+ fputs(str, stderr);
+#endif
+#else
+ fputs(str, stderr);
+#endif /* USE_SYSTEM_LOGGING_FACILITY */
+ UNUSED(ctx);
+ UNUSED(level);
+}
+
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
+ const char *function, const char *format, va_list args)
+{
+ const char *prefix = "";
+ char buf[USBI_MAX_LOG_LEN];
+ struct timeval now;
+ int global_debug, header_len, text_len;
+ static int has_debug_header_been_displayed = 0;
+
+#ifdef ENABLE_DEBUG_LOGGING
+ global_debug = 1;
+ UNUSED(ctx);
+#else
+ int ctx_level = 0;
+
+ USBI_GET_CONTEXT(ctx);
+ if (ctx) {
+ ctx_level = ctx->debug;
+ } else {
+ char *dbg = getenv("LIBUSB_DEBUG");
+ if (dbg)
+ ctx_level = atoi(dbg);
+ }
+ global_debug = (ctx_level == LIBUSB_LOG_LEVEL_DEBUG);
+ if (!ctx_level)
+ return;
+ if (level == LIBUSB_LOG_LEVEL_WARNING && ctx_level < LIBUSB_LOG_LEVEL_WARNING)
+ return;
+ if (level == LIBUSB_LOG_LEVEL_INFO && ctx_level < LIBUSB_LOG_LEVEL_INFO)
+ return;
+ if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx_level < LIBUSB_LOG_LEVEL_DEBUG)
+ return;
+#endif
+
+ usbi_gettimeofday(&now, NULL);
+ if ((global_debug) && (!has_debug_header_been_displayed)) {
+ has_debug_header_been_displayed = 1;
+ usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "[timestamp] [threadID] facility level [function call] " USBI_LOG_LINE_END);
+ usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "--------------------------------------------------------------------------------" USBI_LOG_LINE_END);
+ }
+ if (now.tv_usec < timestamp_origin.tv_usec) {
+ now.tv_sec--;
+ now.tv_usec += 1000000;
+ }
+ now.tv_sec -= timestamp_origin.tv_sec;
+ now.tv_usec -= timestamp_origin.tv_usec;
+
+ switch (level) {
+ case LIBUSB_LOG_LEVEL_INFO:
+ prefix = "info";
+ break;
+ case LIBUSB_LOG_LEVEL_WARNING:
+ prefix = "warning";
+ break;
+ case LIBUSB_LOG_LEVEL_ERROR:
+ prefix = "error";
+ break;
+ case LIBUSB_LOG_LEVEL_DEBUG:
+ prefix = "debug";
+ break;
+ case LIBUSB_LOG_LEVEL_NONE:
+ return;
+ default:
+ prefix = "unknown";
+ break;
+ }
+
+ if (global_debug) {
+ header_len = snprintf(buf, sizeof(buf),
+ "[%2d.%06d] [%08x] libusb: %s [%s] ",
+ (int)now.tv_sec, (int)now.tv_usec, usbi_get_tid(), prefix, function);
+ } else {
+ header_len = snprintf(buf, sizeof(buf),
+ "libusb: %s [%s] ", prefix, function);
+ }
+
+ if (header_len < 0 || header_len >= sizeof(buf)) {
+ /* Somehow snprintf failed to write to the buffer,
+ * remove the header so something useful is output. */
+ header_len = 0;
+ }
+ /* Make sure buffer is NUL terminated */
+ buf[header_len] = '\0';
+ text_len = vsnprintf(buf + header_len, sizeof(buf) - header_len,
+ format, args);
+ if (text_len < 0 || text_len + header_len >= sizeof(buf)) {
+ /* Truncated log output. On some platforms a -1 return value means
+ * that the output was truncated. */
+ text_len = sizeof(buf) - header_len;
+ }
+ if (header_len + text_len + sizeof(USBI_LOG_LINE_END) >= sizeof(buf)) {
+ /* Need to truncate the text slightly to fit on the terminator. */
+ text_len -= (header_len + text_len + sizeof(USBI_LOG_LINE_END)) - sizeof(buf);
+ }
+ strcpy(buf + header_len + text_len, USBI_LOG_LINE_END);
+
+ usbi_log_str(ctx, level, buf);
+}
+
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
+ const char *function, const char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ usbi_log_v(ctx, level, function, format, args);
+ va_end (args);
+}
+
+/** \ingroup misc
+ * Returns a constant NULL-terminated string with the ASCII name of a libusb
+ * error or transfer status code. The caller must not free() the returned
+ * string.
+ *
+ * \param error_code The \ref libusb_error or libusb_transfer_status code to
+ * return the name of.
+ * \returns The error name, or the string **UNKNOWN** if the value of
+ * error_code is not a known error / status code.
+ */
+DEFAULT_VISIBILITY const char * LIBUSB_CALL libusb_error_name(int error_code)
+{
+ switch (error_code) {
+ case LIBUSB_ERROR_IO:
+ return "LIBUSB_ERROR_IO";
+ case LIBUSB_ERROR_INVALID_PARAM:
+ return "LIBUSB_ERROR_INVALID_PARAM";
+ case LIBUSB_ERROR_ACCESS:
+ return "LIBUSB_ERROR_ACCESS";
+ case LIBUSB_ERROR_NO_DEVICE:
+ return "LIBUSB_ERROR_NO_DEVICE";
+ case LIBUSB_ERROR_NOT_FOUND:
+ return "LIBUSB_ERROR_NOT_FOUND";
+ case LIBUSB_ERROR_BUSY:
+ return "LIBUSB_ERROR_BUSY";
+ case LIBUSB_ERROR_TIMEOUT:
+ return "LIBUSB_ERROR_TIMEOUT";
+ case LIBUSB_ERROR_OVERFLOW:
+ return "LIBUSB_ERROR_OVERFLOW";
+ case LIBUSB_ERROR_PIPE:
+ return "LIBUSB_ERROR_PIPE";
+ case LIBUSB_ERROR_INTERRUPTED:
+ return "LIBUSB_ERROR_INTERRUPTED";
+ case LIBUSB_ERROR_NO_MEM:
+ return "LIBUSB_ERROR_NO_MEM";
+ case LIBUSB_ERROR_NOT_SUPPORTED:
+ return "LIBUSB_ERROR_NOT_SUPPORTED";
+ case LIBUSB_ERROR_OTHER:
+ return "LIBUSB_ERROR_OTHER";
+
+ case LIBUSB_TRANSFER_ERROR:
+ return "LIBUSB_TRANSFER_ERROR";
+ case LIBUSB_TRANSFER_TIMED_OUT:
+ return "LIBUSB_TRANSFER_TIMED_OUT";
+ case LIBUSB_TRANSFER_CANCELLED:
+ return "LIBUSB_TRANSFER_CANCELLED";
+ case LIBUSB_TRANSFER_STALL:
+ return "LIBUSB_TRANSFER_STALL";
+ case LIBUSB_TRANSFER_NO_DEVICE:
+ return "LIBUSB_TRANSFER_NO_DEVICE";
+ case LIBUSB_TRANSFER_OVERFLOW:
+ return "LIBUSB_TRANSFER_OVERFLOW";
+
+ case 0:
+ return "LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED";
+ default:
+ return "**UNKNOWN**";
+ }
+}
+
+/** \ingroup misc
+ * Returns a pointer to const struct libusb_version with the version
+ * (major, minor, micro, nano and rc) of the running library.
+ */
+DEFAULT_VISIBILITY
+const struct libusb_version * LIBUSB_CALL libusb_get_version(void)
+{
+ return &libusb_version_internal;
+}
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/core.c.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/core.c.REMOVED.git-id
deleted file mode 100644
index 6e95beaa..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/core.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-38fb55aac6a528da207efdd8aea0c405d0903307
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/descriptor.c b/Desktop_Interface/build_android/libusb-martin-kuldeep/descriptor.c
new file mode 100644
index 00000000..defcacb1
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/descriptor.c
@@ -0,0 +1,1195 @@
+/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
+/*
+ * USB descriptor handling functions for libusb
+ * Copyright © 2007 Daniel Drake
+ * Copyright © 2001 Johannes Erdfelt
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "libusbi.h"
+
+#define DESC_HEADER_LENGTH 2
+#define DEVICE_DESC_LENGTH 18
+#define CONFIG_DESC_LENGTH 9
+#define INTERFACE_DESC_LENGTH 9
+#define ENDPOINT_DESC_LENGTH 7
+#define ENDPOINT_AUDIO_DESC_LENGTH 9
+
+/** @defgroup desc USB descriptors
+ * This page details how to examine the various standard USB descriptors
+ * for detected devices
+ */
+
+/* set host_endian if the w values are already in host endian format,
+ * as opposed to bus endian. */
+int usbi_parse_descriptor(const unsigned char *source, const char *descriptor,
+ void *dest, int host_endian)
+{
+ const unsigned char *sp = source;
+ unsigned char *dp = dest;
+ uint16_t w;
+ const char *cp;
+ uint32_t d;
+
+ for (cp = descriptor; *cp; cp++) {
+ switch (*cp) {
+ case 'b': /* 8-bit byte */
+ *dp++ = *sp++;
+ break;
+ case 'w': /* 16-bit word, convert from little endian to CPU */
+ dp += ((uintptr_t)dp & 1); /* Align to word boundary */
+
+ if (host_endian) {
+ memcpy(dp, sp, 2);
+ } else {
+ w = (sp[1] << 8) | sp[0];
+ *((uint16_t *)dp) = w;
+ }
+ sp += 2;
+ dp += 2;
+ break;
+ case 'd': /* 32-bit word, convert from little endian to CPU */
+ dp += ((uintptr_t)dp & 1); /* Align to word boundary */
+
+ if (host_endian) {
+ memcpy(dp, sp, 4);
+ } else {
+ d = (sp[3] << 24) | (sp[2] << 16) |
+ (sp[1] << 8) | sp[0];
+ *((uint32_t *)dp) = d;
+ }
+ sp += 4;
+ dp += 4;
+ break;
+ case 'u': /* 16 byte UUID */
+ memcpy(dp, sp, 16);
+ sp += 16;
+ dp += 16;
+ break;
+ }
+ }
+
+ return (int) (sp - source);
+}
+
+static void clear_endpoint(struct libusb_endpoint_descriptor *endpoint)
+{
+ if (endpoint->extra)
+ free((unsigned char *) endpoint->extra);
+}
+
+static int parse_endpoint(struct libusb_context *ctx,
+ struct libusb_endpoint_descriptor *endpoint, unsigned char *buffer,
+ int size, int host_endian)
+{
+ struct usb_descriptor_header header;
+ unsigned char *extra;
+ unsigned char *begin;
+ int parsed = 0;
+ int len;
+
+ if (size < DESC_HEADER_LENGTH) {
+ usbi_err(ctx, "short endpoint descriptor read %d/%d",
+ size, DESC_HEADER_LENGTH);
+ return LIBUSB_ERROR_IO;
+ }
+
+ usbi_parse_descriptor(buffer, "bb", &header, 0);
+ if (header.bDescriptorType != LIBUSB_DT_ENDPOINT) {
+ usbi_err(ctx, "unexpected descriptor %x (expected %x)",
+ header.bDescriptorType, LIBUSB_DT_ENDPOINT);
+ return parsed;
+ }
+ if (header.bLength > size) {
+ usbi_warn(ctx, "short endpoint descriptor read %d/%d",
+ size, header.bLength);
+ return parsed;
+ }
+ if (header.bLength >= ENDPOINT_AUDIO_DESC_LENGTH)
+ usbi_parse_descriptor(buffer, "bbbbwbbb", endpoint, host_endian);
+ else if (header.bLength >= ENDPOINT_DESC_LENGTH)
+ usbi_parse_descriptor(buffer, "bbbbwb", endpoint, host_endian);
+ else {
+ usbi_err(ctx, "invalid endpoint bLength (%d)", header.bLength);
+ return LIBUSB_ERROR_IO;
+ }
+
+ buffer += header.bLength;
+ size -= header.bLength;
+ parsed += header.bLength;
+
+ /* Skip over the rest of the Class Specific or Vendor Specific */
+ /* descriptors */
+ begin = buffer;
+ while (size >= DESC_HEADER_LENGTH) {
+ usbi_parse_descriptor(buffer, "bb", &header, 0);
+ if (header.bLength < DESC_HEADER_LENGTH) {
+ usbi_err(ctx, "invalid extra ep desc len (%d)",
+ header.bLength);
+ return LIBUSB_ERROR_IO;
+ } else if (header.bLength > size) {
+ usbi_warn(ctx, "short extra ep desc read %d/%d",
+ size, header.bLength);
+ return parsed;
+ }
+
+ /* If we find another "proper" descriptor then we're done */
+ if ((header.bDescriptorType == LIBUSB_DT_ENDPOINT) ||
+ (header.bDescriptorType == LIBUSB_DT_INTERFACE) ||
+ (header.bDescriptorType == LIBUSB_DT_CONFIG) ||
+ (header.bDescriptorType == LIBUSB_DT_DEVICE))
+ break;
+
+ usbi_dbg("skipping descriptor %x", header.bDescriptorType);
+ buffer += header.bLength;
+ size -= header.bLength;
+ parsed += header.bLength;
+ }
+
+ /* Copy any unknown descriptors into a storage area for drivers */
+ /* to later parse */
+ len = (int)(buffer - begin);
+ if (!len) {
+ endpoint->extra = NULL;
+ endpoint->extra_length = 0;
+ return parsed;
+ }
+
+ extra = malloc(len);
+ endpoint->extra = extra;
+ if (!extra) {
+ endpoint->extra_length = 0;
+ return LIBUSB_ERROR_NO_MEM;
+ }
+
+ memcpy(extra, begin, len);
+ endpoint->extra_length = len;
+
+ return parsed;
+}
+
+static void clear_interface(struct libusb_interface *usb_interface)
+{
+ int i;
+ int j;
+
+ if (usb_interface->altsetting) {
+ for (i = 0; i < usb_interface->num_altsetting; i++) {
+ struct libusb_interface_descriptor *ifp =
+ (struct libusb_interface_descriptor *)
+ usb_interface->altsetting + i;
+ if (ifp->extra)
+ free((void *) ifp->extra);
+ if (ifp->endpoint) {
+ for (j = 0; j < ifp->bNumEndpoints; j++)
+ clear_endpoint((struct libusb_endpoint_descriptor *)
+ ifp->endpoint + j);
+ free((void *) ifp->endpoint);
+ }
+ }
+ free((void *) usb_interface->altsetting);
+ usb_interface->altsetting = NULL;
+ }
+
+}
+
+static int parse_interface(libusb_context *ctx,
+ struct libusb_interface *usb_interface, unsigned char *buffer, int size,
+ int host_endian)
+{
+ int i;
+ int len;
+ int r;
+ int parsed = 0;
+ int interface_number = -1;
+ struct usb_descriptor_header header;
+ struct libusb_interface_descriptor *ifp;
+ unsigned char *begin;
+
+ usb_interface->num_altsetting = 0;
+
+ while (size >= INTERFACE_DESC_LENGTH) {
+ struct libusb_interface_descriptor *altsetting =
+ (struct libusb_interface_descriptor *) usb_interface->altsetting;
+ altsetting = usbi_reallocf(altsetting,
+ sizeof(struct libusb_interface_descriptor) *
+ (usb_interface->num_altsetting + 1));
+ if (!altsetting) {
+ r = LIBUSB_ERROR_NO_MEM;
+ goto err;
+ }
+ usb_interface->altsetting = altsetting;
+
+ ifp = altsetting + usb_interface->num_altsetting;
+ usbi_parse_descriptor(buffer, "bbbbbbbbb", ifp, 0);
+ if (ifp->bDescriptorType != LIBUSB_DT_INTERFACE) {
+ usbi_err(ctx, "unexpected descriptor %x (expected %x)",
+ ifp->bDescriptorType, LIBUSB_DT_INTERFACE);
+ return parsed;
+ }
+ if (ifp->bLength < INTERFACE_DESC_LENGTH) {
+ usbi_err(ctx, "invalid interface bLength (%d)",
+ ifp->bLength);
+ r = LIBUSB_ERROR_IO;
+ goto err;
+ }
+ if (ifp->bLength > size) {
+ usbi_warn(ctx, "short intf descriptor read %d/%d",
+ size, ifp->bLength);
+ return parsed;
+ }
+ if (ifp->bNumEndpoints > USB_MAXENDPOINTS) {
+ usbi_err(ctx, "too many endpoints (%d)", ifp->bNumEndpoints);
+ r = LIBUSB_ERROR_IO;
+ goto err;
+ }
+
+ usb_interface->num_altsetting++;
+ ifp->extra = NULL;
+ ifp->extra_length = 0;
+ ifp->endpoint = NULL;
+
+ if (interface_number == -1)
+ interface_number = ifp->bInterfaceNumber;
+
+ /* Skip over the interface */
+ buffer += ifp->bLength;
+ parsed += ifp->bLength;
+ size -= ifp->bLength;
+
+ begin = buffer;
+
+ /* Skip over any interface, class or vendor descriptors */
+ while (size >= DESC_HEADER_LENGTH) {
+ usbi_parse_descriptor(buffer, "bb", &header, 0);
+ if (header.bLength < DESC_HEADER_LENGTH) {
+ usbi_err(ctx,
+ "invalid extra intf desc len (%d)",
+ header.bLength);
+ r = LIBUSB_ERROR_IO;
+ goto err;
+ } else if (header.bLength > size) {
+ usbi_warn(ctx,
+ "short extra intf desc read %d/%d",
+ size, header.bLength);
+ return parsed;
+ }
+
+ /* If we find another "proper" descriptor then we're done */
+ if ((header.bDescriptorType == LIBUSB_DT_INTERFACE) ||
+ (header.bDescriptorType == LIBUSB_DT_ENDPOINT) ||
+ (header.bDescriptorType == LIBUSB_DT_CONFIG) ||
+ (header.bDescriptorType == LIBUSB_DT_DEVICE))
+ break;
+
+ buffer += header.bLength;
+ parsed += header.bLength;
+ size -= header.bLength;
+ }
+
+ /* Copy any unknown descriptors into a storage area for */
+ /* drivers to later parse */
+ len = (int)(buffer - begin);
+ if (len) {
+ ifp->extra = malloc(len);
+ if (!ifp->extra) {
+ r = LIBUSB_ERROR_NO_MEM;
+ goto err;
+ }
+ memcpy((unsigned char *) ifp->extra, begin, len);
+ ifp->extra_length = len;
+ }
+
+ if (ifp->bNumEndpoints > 0) {
+ struct libusb_endpoint_descriptor *endpoint;
+ endpoint = calloc(ifp->bNumEndpoints, sizeof(struct libusb_endpoint_descriptor));
+ ifp->endpoint = endpoint;
+ if (!endpoint) {
+ r = LIBUSB_ERROR_NO_MEM;
+ goto err;
+ }
+
+ for (i = 0; i < ifp->bNumEndpoints; i++) {
+ r = parse_endpoint(ctx, endpoint + i, buffer, size,
+ host_endian);
+ if (r < 0)
+ goto err;
+ if (r == 0) {
+ ifp->bNumEndpoints = (uint8_t)i;
+ break;;
+ }
+
+ buffer += r;
+ parsed += r;
+ size -= r;
+ }
+ }
+
+ /* We check to see if it's an alternate to this one */
+ ifp = (struct libusb_interface_descriptor *) buffer;
+ if (size < LIBUSB_DT_INTERFACE_SIZE ||
+ ifp->bDescriptorType != LIBUSB_DT_INTERFACE ||
+ ifp->bInterfaceNumber != interface_number)
+ return parsed;
+ }
+
+ return parsed;
+err:
+ clear_interface(usb_interface);
+ return r;
+}
+
+static void clear_configuration(struct libusb_config_descriptor *config)
+{
+ if (config->interface) {
+ int i;
+ for (i = 0; i < config->bNumInterfaces; i++)
+ clear_interface((struct libusb_interface *)
+ config->interface + i);
+ free((void *) config->interface);
+ }
+ if (config->extra)
+ free((void *) config->extra);
+}
+
+static int parse_configuration(struct libusb_context *ctx,
+ struct libusb_config_descriptor *config, unsigned char *buffer,
+ int size, int host_endian)
+{
+ int i;
+ int r;
+ struct usb_descriptor_header header;
+ struct libusb_interface *usb_interface;
+
+ if (size < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(ctx, "short config descriptor read %d/%d",
+ size, LIBUSB_DT_CONFIG_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ usbi_parse_descriptor(buffer, "bbwbbbbb", config, host_endian);
+ if (config->bDescriptorType != LIBUSB_DT_CONFIG) {
+ usbi_err(ctx, "unexpected descriptor %x (expected %x)",
+ config->bDescriptorType, LIBUSB_DT_CONFIG);
+ return LIBUSB_ERROR_IO;
+ }
+ if (config->bLength < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(ctx, "invalid config bLength (%d)", config->bLength);
+ return LIBUSB_ERROR_IO;
+ }
+ if (config->bLength > size) {
+ usbi_err(ctx, "short config descriptor read %d/%d",
+ size, config->bLength);
+ return LIBUSB_ERROR_IO;
+ }
+ if (config->bNumInterfaces > USB_MAXINTERFACES) {
+ usbi_err(ctx, "too many interfaces (%d)", config->bNumInterfaces);
+ return LIBUSB_ERROR_IO;
+ }
+
+ usb_interface = calloc(config->bNumInterfaces, sizeof(struct libusb_interface));
+ config->interface = usb_interface;
+ if (!usb_interface)
+ return LIBUSB_ERROR_NO_MEM;
+
+ buffer += config->bLength;
+ size -= config->bLength;
+
+ config->extra = NULL;
+ config->extra_length = 0;
+
+ for (i = 0; i < config->bNumInterfaces; i++) {
+ int len;
+ unsigned char *begin;
+
+ /* Skip over the rest of the Class Specific or Vendor */
+ /* Specific descriptors */
+ begin = buffer;
+ while (size >= DESC_HEADER_LENGTH) {
+ usbi_parse_descriptor(buffer, "bb", &header, 0);
+
+ if (header.bLength < DESC_HEADER_LENGTH) {
+ usbi_err(ctx,
+ "invalid extra config desc len (%d)",
+ header.bLength);
+ r = LIBUSB_ERROR_IO;
+ goto err;
+ } else if (header.bLength > size) {
+ usbi_warn(ctx,
+ "short extra config desc read %d/%d",
+ size, header.bLength);
+ config->bNumInterfaces = (uint8_t)i;
+ return size;
+ }
+
+ /* If we find another "proper" descriptor then we're done */
+ if ((header.bDescriptorType == LIBUSB_DT_ENDPOINT) ||
+ (header.bDescriptorType == LIBUSB_DT_INTERFACE) ||
+ (header.bDescriptorType == LIBUSB_DT_CONFIG) ||
+ (header.bDescriptorType == LIBUSB_DT_DEVICE))
+ break;
+
+ usbi_dbg("skipping descriptor 0x%x", header.bDescriptorType);
+ buffer += header.bLength;
+ size -= header.bLength;
+ }
+
+ /* Copy any unknown descriptors into a storage area for */
+ /* drivers to later parse */
+ len = (int)(buffer - begin);
+ if (len) {
+ /* FIXME: We should realloc and append here */
+ if (!config->extra_length) {
+ config->extra = malloc(len);
+ if (!config->extra) {
+ r = LIBUSB_ERROR_NO_MEM;
+ goto err;
+ }
+
+ memcpy((unsigned char *) config->extra, begin, len);
+ config->extra_length = len;
+ }
+ }
+
+ r = parse_interface(ctx, usb_interface + i, buffer, size, host_endian);
+ if (r < 0)
+ goto err;
+ if (r == 0) {
+ config->bNumInterfaces = (uint8_t)i;
+ break;
+ }
+
+ buffer += r;
+ size -= r;
+ }
+
+ return size;
+
+err:
+ clear_configuration(config);
+ return r;
+}
+
+static int raw_desc_to_config(struct libusb_context *ctx,
+ unsigned char *buf, int size, int host_endian,
+ struct libusb_config_descriptor **config)
+{
+ struct libusb_config_descriptor *_config = malloc(sizeof(*_config));
+ int r;
+
+ if (!_config)
+ return LIBUSB_ERROR_NO_MEM;
+
+ r = parse_configuration(ctx, _config, buf, size, host_endian);
+ if (r < 0) {
+ usbi_err(ctx, "parse_configuration failed with error %d", r);
+ free(_config);
+ return r;
+ } else if (r > 0) {
+ usbi_warn(ctx, "still %d bytes of descriptor data left", r);
+ }
+
+ *config = _config;
+ return LIBUSB_SUCCESS;
+}
+
+int usbi_device_cache_descriptor(libusb_device *dev)
+{
+ int r, host_endian = 0;
+
+ r = usbi_backend->get_device_descriptor(dev, (unsigned char *) &dev->device_descriptor,
+ &host_endian);
+ if (r < 0)
+ return r;
+
+ if (!host_endian) {
+ dev->device_descriptor.bcdUSB = libusb_le16_to_cpu(dev->device_descriptor.bcdUSB);
+ dev->device_descriptor.idVendor = libusb_le16_to_cpu(dev->device_descriptor.idVendor);
+ dev->device_descriptor.idProduct = libusb_le16_to_cpu(dev->device_descriptor.idProduct);
+ dev->device_descriptor.bcdDevice = libusb_le16_to_cpu(dev->device_descriptor.bcdDevice);
+ }
+
+ return LIBUSB_SUCCESS;
+}
+
+/** \ingroup desc
+ * Get the USB device descriptor for a given device.
+ *
+ * This is a non-blocking function; the device descriptor is cached in memory.
+ *
+ * Note since libusb-1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102, this
+ * function always succeeds.
+ *
+ * \param dev the device
+ * \param desc output location for the descriptor data
+ * \returns 0 on success or a LIBUSB_ERROR code on failure
+ */
+int API_EXPORTED libusb_get_device_descriptor(libusb_device *dev,
+ struct libusb_device_descriptor *desc)
+{
+ usbi_dbg("");
+ memcpy((unsigned char *) desc, (unsigned char *) &dev->device_descriptor,
+ sizeof (dev->device_descriptor));
+ return 0;
+}
+
+/** \ingroup desc
+ * Get the USB configuration descriptor for the currently active configuration.
+ * This is a non-blocking function which does not involve any requests being
+ * sent to the device.
+ *
+ * \param dev a device
+ * \param config output location for the USB configuration descriptor. Only
+ * valid if 0 was returned. Must be freed with libusb_free_config_descriptor()
+ * after use.
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state
+ * \returns another LIBUSB_ERROR code on error
+ * \see libusb_get_config_descriptor
+ */
+int API_EXPORTED libusb_get_active_config_descriptor(libusb_device *dev,
+ struct libusb_config_descriptor **config)
+{
+ struct libusb_config_descriptor _config;
+ unsigned char tmp[LIBUSB_DT_CONFIG_SIZE];
+ unsigned char *buf = NULL;
+ int host_endian = 0;
+ int r;
+
+ r = usbi_backend->get_active_config_descriptor(dev, tmp,
+ LIBUSB_DT_CONFIG_SIZE, &host_endian);
+ if (r < 0)
+ return r;
+ if (r < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(dev->ctx, "short config descriptor read %d/%d",
+ r, LIBUSB_DT_CONFIG_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ usbi_parse_descriptor(tmp, "bbw", &_config, host_endian);
+ buf = malloc(_config.wTotalLength);
+ if (!buf)
+ return LIBUSB_ERROR_NO_MEM;
+
+ r = usbi_backend->get_active_config_descriptor(dev, buf,
+ _config.wTotalLength, &host_endian);
+ if (r >= 0)
+ r = raw_desc_to_config(dev->ctx, buf, r, host_endian, config);
+
+ free(buf);
+ return r;
+}
+
+/** \ingroup desc
+ * Get a USB configuration descriptor based on its index.
+ * This is a non-blocking function which does not involve any requests being
+ * sent to the device.
+ *
+ * \param dev a device
+ * \param config_index the index of the configuration you wish to retrieve
+ * \param config output location for the USB configuration descriptor. Only
+ * valid if 0 was returned. Must be freed with libusb_free_config_descriptor()
+ * after use.
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
+ * \returns another LIBUSB_ERROR code on error
+ * \see libusb_get_active_config_descriptor()
+ * \see libusb_get_config_descriptor_by_value()
+ */
+int API_EXPORTED libusb_get_config_descriptor(libusb_device *dev,
+ uint8_t config_index, struct libusb_config_descriptor **config)
+{
+ struct libusb_config_descriptor _config;
+ unsigned char tmp[LIBUSB_DT_CONFIG_SIZE];
+ unsigned char *buf = NULL;
+ int host_endian = 0;
+ int r;
+
+ usbi_dbg("index %d", config_index);
+ if (config_index >= dev->num_configurations)
+ return LIBUSB_ERROR_NOT_FOUND;
+
+ r = usbi_backend->get_config_descriptor(dev, config_index, tmp,
+ LIBUSB_DT_CONFIG_SIZE, &host_endian);
+ if (r < 0)
+ return r;
+ if (r < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(dev->ctx, "short config descriptor read %d/%d",
+ r, LIBUSB_DT_CONFIG_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ usbi_parse_descriptor(tmp, "bbw", &_config, host_endian);
+ buf = malloc(_config.wTotalLength);
+ if (!buf)
+ return LIBUSB_ERROR_NO_MEM;
+
+ r = usbi_backend->get_config_descriptor(dev, config_index, buf,
+ _config.wTotalLength, &host_endian);
+ if (r >= 0)
+ r = raw_desc_to_config(dev->ctx, buf, r, host_endian, config);
+
+ free(buf);
+ return r;
+}
+
+/* iterate through all configurations, returning the index of the configuration
+ * matching a specific bConfigurationValue in the idx output parameter, or -1
+ * if the config was not found.
+ * returns 0 on success or a LIBUSB_ERROR code
+ */
+int usbi_get_config_index_by_value(struct libusb_device *dev,
+ uint8_t bConfigurationValue, int *idx)
+{
+ uint8_t i;
+
+ usbi_dbg("value %d", bConfigurationValue);
+ for (i = 0; i < dev->num_configurations; i++) {
+ unsigned char tmp[6];
+ int host_endian;
+ int r = usbi_backend->get_config_descriptor(dev, i, tmp, sizeof(tmp),
+ &host_endian);
+ if (r < 0) {
+ *idx = -1;
+ return r;
+ }
+ if (tmp[5] == bConfigurationValue) {
+ *idx = i;
+ return 0;
+ }
+ }
+
+ *idx = -1;
+ return 0;
+}
+
+/** \ingroup desc
+ * Get a USB configuration descriptor with a specific bConfigurationValue.
+ * This is a non-blocking function which does not involve any requests being
+ * sent to the device.
+ *
+ * \param dev a device
+ * \param bConfigurationValue the bConfigurationValue of the configuration you
+ * wish to retrieve
+ * \param config output location for the USB configuration descriptor. Only
+ * valid if 0 was returned. Must be freed with libusb_free_config_descriptor()
+ * after use.
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
+ * \returns another LIBUSB_ERROR code on error
+ * \see libusb_get_active_config_descriptor()
+ * \see libusb_get_config_descriptor()
+ */
+int API_EXPORTED libusb_get_config_descriptor_by_value(libusb_device *dev,
+ uint8_t bConfigurationValue, struct libusb_config_descriptor **config)
+{
+ int r, idx, host_endian;
+ unsigned char *buf = NULL;
+
+ if (usbi_backend->get_config_descriptor_by_value) {
+ r = usbi_backend->get_config_descriptor_by_value(dev,
+ bConfigurationValue, &buf, &host_endian);
+ if (r < 0)
+ return r;
+ return raw_desc_to_config(dev->ctx, buf, r, host_endian, config);
+ }
+
+ r = usbi_get_config_index_by_value(dev, bConfigurationValue, &idx);
+ if (r < 0)
+ return r;
+ else if (idx == -1)
+ return LIBUSB_ERROR_NOT_FOUND;
+ else
+ return libusb_get_config_descriptor(dev, (uint8_t) idx, config);
+}
+
+/** \ingroup desc
+ * Free a configuration descriptor obtained from
+ * libusb_get_active_config_descriptor() or libusb_get_config_descriptor().
+ * It is safe to call this function with a NULL config parameter, in which
+ * case the function simply returns.
+ *
+ * \param config the configuration descriptor to free
+ */
+void API_EXPORTED libusb_free_config_descriptor(
+ struct libusb_config_descriptor *config)
+{
+ if (!config)
+ return;
+
+ clear_configuration(config);
+ free(config);
+}
+
+/** \ingroup desc
+ * Get an endpoints superspeed endpoint companion descriptor (if any)
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param endpoint endpoint descriptor from which to get the superspeed
+ * endpoint companion descriptor
+ * \param ep_comp output location for the superspeed endpoint companion
+ * descriptor. Only valid if 0 was returned. Must be freed with
+ * libusb_free_ss_endpoint_companion_descriptor() after use.
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
+ * \returns another LIBUSB_ERROR code on error
+ */
+int API_EXPORTED libusb_get_ss_endpoint_companion_descriptor(
+ struct libusb_context *ctx,
+ const struct libusb_endpoint_descriptor *endpoint,
+ struct libusb_ss_endpoint_companion_descriptor **ep_comp)
+{
+ struct usb_descriptor_header header;
+ int size = endpoint->extra_length;
+ const unsigned char *buffer = endpoint->extra;
+
+ *ep_comp = NULL;
+
+ while (size >= DESC_HEADER_LENGTH) {
+ usbi_parse_descriptor(buffer, "bb", &header, 0);
+ if (header.bLength < 2 || header.bLength > size) {
+ usbi_err(ctx, "invalid descriptor length %d",
+ header.bLength);
+ return LIBUSB_ERROR_IO;
+ }
+ if (header.bDescriptorType != LIBUSB_DT_SS_ENDPOINT_COMPANION) {
+ buffer += header.bLength;
+ size -= header.bLength;
+ continue;
+ }
+ if (header.bLength < LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE) {
+ usbi_err(ctx, "invalid ss-ep-comp-desc length %d",
+ header.bLength);
+ return LIBUSB_ERROR_IO;
+ }
+ *ep_comp = malloc(sizeof(**ep_comp));
+ if (*ep_comp == NULL)
+ return LIBUSB_ERROR_NO_MEM;
+ usbi_parse_descriptor(buffer, "bbbbw", *ep_comp, 0);
+ return LIBUSB_SUCCESS;
+ }
+ return LIBUSB_ERROR_NOT_FOUND;
+}
+
+/** \ingroup desc
+ * Free a superspeed endpoint companion descriptor obtained from
+ * libusb_get_ss_endpoint_companion_descriptor().
+ * It is safe to call this function with a NULL ep_comp parameter, in which
+ * case the function simply returns.
+ *
+ * \param ep_comp the superspeed endpoint companion descriptor to free
+ */
+void API_EXPORTED libusb_free_ss_endpoint_companion_descriptor(
+ struct libusb_ss_endpoint_companion_descriptor *ep_comp)
+{
+ free(ep_comp);
+}
+
+static int parse_bos(struct libusb_context *ctx,
+ struct libusb_bos_descriptor **bos,
+ unsigned char *buffer, int size, int host_endian)
+{
+ struct libusb_bos_descriptor bos_header, *_bos;
+ struct libusb_bos_dev_capability_descriptor dev_cap;
+ int i;
+
+ if (size < LIBUSB_DT_BOS_SIZE) {
+ usbi_err(ctx, "short bos descriptor read %d/%d",
+ size, LIBUSB_DT_BOS_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ usbi_parse_descriptor(buffer, "bbwb", &bos_header, host_endian);
+ if (bos_header.bDescriptorType != LIBUSB_DT_BOS) {
+ usbi_err(ctx, "unexpected descriptor %x (expected %x)",
+ bos_header.bDescriptorType, LIBUSB_DT_BOS);
+ return LIBUSB_ERROR_IO;
+ }
+ if (bos_header.bLength < LIBUSB_DT_BOS_SIZE) {
+ usbi_err(ctx, "invalid bos bLength (%d)", bos_header.bLength);
+ return LIBUSB_ERROR_IO;
+ }
+ if (bos_header.bLength > size) {
+ usbi_err(ctx, "short bos descriptor read %d/%d",
+ size, bos_header.bLength);
+ return LIBUSB_ERROR_IO;
+ }
+
+ _bos = calloc (1,
+ sizeof(*_bos) + bos_header.bNumDeviceCaps * sizeof(void *));
+ if (!_bos)
+ return LIBUSB_ERROR_NO_MEM;
+
+ usbi_parse_descriptor(buffer, "bbwb", _bos, host_endian);
+ buffer += bos_header.bLength;
+ size -= bos_header.bLength;
+
+ /* Get the device capability descriptors */
+ for (i = 0; i < bos_header.bNumDeviceCaps; i++) {
+ if (size < LIBUSB_DT_DEVICE_CAPABILITY_SIZE) {
+ usbi_warn(ctx, "short dev-cap descriptor read %d/%d",
+ size, LIBUSB_DT_DEVICE_CAPABILITY_SIZE);
+ break;
+ }
+ usbi_parse_descriptor(buffer, "bbb", &dev_cap, host_endian);
+ if (dev_cap.bDescriptorType != LIBUSB_DT_DEVICE_CAPABILITY) {
+ usbi_warn(ctx, "unexpected descriptor %x (expected %x)",
+ dev_cap.bDescriptorType, LIBUSB_DT_DEVICE_CAPABILITY);
+ break;
+ }
+ if (dev_cap.bLength < LIBUSB_DT_DEVICE_CAPABILITY_SIZE) {
+ usbi_err(ctx, "invalid dev-cap bLength (%d)",
+ dev_cap.bLength);
+ libusb_free_bos_descriptor(_bos);
+ return LIBUSB_ERROR_IO;
+ }
+ if (dev_cap.bLength > size) {
+ usbi_warn(ctx, "short dev-cap descriptor read %d/%d",
+ size, dev_cap.bLength);
+ break;
+ }
+
+ _bos->dev_capability[i] = malloc(dev_cap.bLength);
+ if (!_bos->dev_capability[i]) {
+ libusb_free_bos_descriptor(_bos);
+ return LIBUSB_ERROR_NO_MEM;
+ }
+ memcpy(_bos->dev_capability[i], buffer, dev_cap.bLength);
+ buffer += dev_cap.bLength;
+ size -= dev_cap.bLength;
+ }
+ _bos->bNumDeviceCaps = (uint8_t)i;
+ *bos = _bos;
+
+ return LIBUSB_SUCCESS;
+}
+
+/** \ingroup desc
+ * Get a Binary Object Store (BOS) descriptor
+ * This is a BLOCKING function, which will send requests to the device.
+ *
+ * \param handle the handle of an open libusb device
+ * \param bos output location for the BOS descriptor. Only valid if 0 was returned.
+ * Must be freed with \ref libusb_free_bos_descriptor() after use.
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the device doesn't have a BOS descriptor
+ * \returns another LIBUSB_ERROR code on error
+ */
+int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *handle,
+ struct libusb_bos_descriptor **bos)
+{
+ struct libusb_bos_descriptor _bos;
+ uint8_t bos_header[LIBUSB_DT_BOS_SIZE] = {0};
+ unsigned char *bos_data = NULL;
+ const int host_endian = 0;
+ int r;
+
+ /* Read the BOS. This generates 2 requests on the bus,
+ * one for the header, and one for the full BOS */
+ r = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0, bos_header,
+ LIBUSB_DT_BOS_SIZE);
+ if (r < 0) {
+ if (r != LIBUSB_ERROR_PIPE)
+ usbi_err(handle->dev->ctx, "failed to read BOS (%d)", r);
+ return r;
+ }
+ if (r < LIBUSB_DT_BOS_SIZE) {
+ usbi_err(handle->dev->ctx, "short BOS read %d/%d",
+ r, LIBUSB_DT_BOS_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ usbi_parse_descriptor(bos_header, "bbwb", &_bos, host_endian);
+ usbi_dbg("found BOS descriptor: size %d bytes, %d capabilities",
+ _bos.wTotalLength, _bos.bNumDeviceCaps);
+ bos_data = calloc(_bos.wTotalLength, 1);
+ if (bos_data == NULL)
+ return LIBUSB_ERROR_NO_MEM;
+
+ r = libusb_get_descriptor(handle, LIBUSB_DT_BOS, 0, bos_data,
+ _bos.wTotalLength);
+ if (r >= 0)
+ r = parse_bos(handle->dev->ctx, bos, bos_data, r, host_endian);
+ else
+ usbi_err(handle->dev->ctx, "failed to read BOS (%d)", r);
+
+ free(bos_data);
+ return r;
+}
+
+/** \ingroup desc
+ * Free a BOS descriptor obtained from libusb_get_bos_descriptor().
+ * It is safe to call this function with a NULL bos parameter, in which
+ * case the function simply returns.
+ *
+ * \param bos the BOS descriptor to free
+ */
+void API_EXPORTED libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
+{
+ int i;
+
+ if (!bos)
+ return;
+
+ for (i = 0; i < bos->bNumDeviceCaps; i++)
+ free(bos->dev_capability[i]);
+ free(bos);
+}
+
+/** \ingroup desc
+ * Get an USB 2.0 Extension descriptor
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param dev_cap Device Capability descriptor with a bDevCapabilityType of
+ * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION
+ * LIBUSB_BT_USB_2_0_EXTENSION
+ * \param usb_2_0_extension output location for the USB 2.0 Extension
+ * descriptor. Only valid if 0 was returned. Must be freed with
+ * libusb_free_usb_2_0_extension_descriptor() after use.
+ * \returns 0 on success
+ * \returns a LIBUSB_ERROR code on error
+ */
+int API_EXPORTED libusb_get_usb_2_0_extension_descriptor(
+ struct libusb_context *ctx,
+ struct libusb_bos_dev_capability_descriptor *dev_cap,
+ struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
+{
+ struct libusb_usb_2_0_extension_descriptor *_usb_2_0_extension;
+ const int host_endian = 0;
+
+ if (dev_cap->bDevCapabilityType != LIBUSB_BT_USB_2_0_EXTENSION) {
+ usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)",
+ dev_cap->bDevCapabilityType,
+ LIBUSB_BT_USB_2_0_EXTENSION);
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+ if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE) {
+ usbi_err(ctx, "short dev-cap descriptor read %d/%d",
+ dev_cap->bLength, LIBUSB_BT_USB_2_0_EXTENSION_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ _usb_2_0_extension = malloc(sizeof(*_usb_2_0_extension));
+ if (!_usb_2_0_extension)
+ return LIBUSB_ERROR_NO_MEM;
+
+ usbi_parse_descriptor((unsigned char *)dev_cap, "bbbd",
+ _usb_2_0_extension, host_endian);
+
+ *usb_2_0_extension = _usb_2_0_extension;
+ return LIBUSB_SUCCESS;
+}
+
+/** \ingroup desc
+ * Free a USB 2.0 Extension descriptor obtained from
+ * libusb_get_usb_2_0_extension_descriptor().
+ * It is safe to call this function with a NULL usb_2_0_extension parameter,
+ * in which case the function simply returns.
+ *
+ * \param usb_2_0_extension the USB 2.0 Extension descriptor to free
+ */
+void API_EXPORTED libusb_free_usb_2_0_extension_descriptor(
+ struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension)
+{
+ free(usb_2_0_extension);
+}
+
+/** \ingroup desc
+ * Get a SuperSpeed USB Device Capability descriptor
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param dev_cap Device Capability descriptor with a bDevCapabilityType of
+ * \ref libusb_capability_type::LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
+ * LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
+ * \param ss_usb_device_cap output location for the SuperSpeed USB Device
+ * Capability descriptor. Only valid if 0 was returned. Must be freed with
+ * libusb_free_ss_usb_device_capability_descriptor() after use.
+ * \returns 0 on success
+ * \returns a LIBUSB_ERROR code on error
+ */
+int API_EXPORTED libusb_get_ss_usb_device_capability_descriptor(
+ struct libusb_context *ctx,
+ struct libusb_bos_dev_capability_descriptor *dev_cap,
+ struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap)
+{
+ struct libusb_ss_usb_device_capability_descriptor *_ss_usb_device_cap;
+ const int host_endian = 0;
+
+ if (dev_cap->bDevCapabilityType != LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) {
+ usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)",
+ dev_cap->bDevCapabilityType,
+ LIBUSB_BT_SS_USB_DEVICE_CAPABILITY);
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+ if (dev_cap->bLength < LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) {
+ usbi_err(ctx, "short dev-cap descriptor read %d/%d",
+ dev_cap->bLength, LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ _ss_usb_device_cap = malloc(sizeof(*_ss_usb_device_cap));
+ if (!_ss_usb_device_cap)
+ return LIBUSB_ERROR_NO_MEM;
+
+ usbi_parse_descriptor((unsigned char *)dev_cap, "bbbbwbbw",
+ _ss_usb_device_cap, host_endian);
+
+ *ss_usb_device_cap = _ss_usb_device_cap;
+ return LIBUSB_SUCCESS;
+}
+
+/** \ingroup desc
+ * Free a SuperSpeed USB Device Capability descriptor obtained from
+ * libusb_get_ss_usb_device_capability_descriptor().
+ * It is safe to call this function with a NULL ss_usb_device_cap
+ * parameter, in which case the function simply returns.
+ *
+ * \param ss_usb_device_cap the USB 2.0 Extension descriptor to free
+ */
+void API_EXPORTED libusb_free_ss_usb_device_capability_descriptor(
+ struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap)
+{
+ free(ss_usb_device_cap);
+}
+
+/** \ingroup desc
+ * Get a Container ID descriptor
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param dev_cap Device Capability descriptor with a bDevCapabilityType of
+ * \ref libusb_capability_type::LIBUSB_BT_CONTAINER_ID
+ * LIBUSB_BT_CONTAINER_ID
+ * \param container_id output location for the Container ID descriptor.
+ * Only valid if 0 was returned. Must be freed with
+ * libusb_free_container_id_descriptor() after use.
+ * \returns 0 on success
+ * \returns a LIBUSB_ERROR code on error
+ */
+int API_EXPORTED libusb_get_container_id_descriptor(struct libusb_context *ctx,
+ struct libusb_bos_dev_capability_descriptor *dev_cap,
+ struct libusb_container_id_descriptor **container_id)
+{
+ struct libusb_container_id_descriptor *_container_id;
+ const int host_endian = 0;
+
+ if (dev_cap->bDevCapabilityType != LIBUSB_BT_CONTAINER_ID) {
+ usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)",
+ dev_cap->bDevCapabilityType,
+ LIBUSB_BT_CONTAINER_ID);
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+ if (dev_cap->bLength < LIBUSB_BT_CONTAINER_ID_SIZE) {
+ usbi_err(ctx, "short dev-cap descriptor read %d/%d",
+ dev_cap->bLength, LIBUSB_BT_CONTAINER_ID_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ _container_id = malloc(sizeof(*_container_id));
+ if (!_container_id)
+ return LIBUSB_ERROR_NO_MEM;
+
+ usbi_parse_descriptor((unsigned char *)dev_cap, "bbbbu",
+ _container_id, host_endian);
+
+ *container_id = _container_id;
+ return LIBUSB_SUCCESS;
+}
+
+/** \ingroup desc
+ * Free a Container ID descriptor obtained from
+ * libusb_get_container_id_descriptor().
+ * It is safe to call this function with a NULL container_id parameter,
+ * in which case the function simply returns.
+ *
+ * \param container_id the USB 2.0 Extension descriptor to free
+ */
+void API_EXPORTED libusb_free_container_id_descriptor(
+ struct libusb_container_id_descriptor *container_id)
+{
+ free(container_id);
+}
+
+/** \ingroup desc
+ * Retrieve a string descriptor in C style ASCII.
+ *
+ * Wrapper around libusb_get_string_descriptor(). Uses the first language
+ * supported by the device.
+ *
+ * \param dev a device handle
+ * \param desc_index the index of the descriptor to retrieve
+ * \param data output buffer for ASCII string descriptor
+ * \param length size of data buffer
+ * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
+ */
+int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
+ uint8_t desc_index, unsigned char *data, int length)
+{
+ unsigned char tbuf[255]; /* Some devices choke on size > 255 */
+ int r, si, di;
+ uint16_t langid;
+
+ /* Asking for the zero'th index is special - it returns a string
+ * descriptor that contains all the language IDs supported by the
+ * device. Typically there aren't many - often only one. Language
+ * IDs are 16 bit numbers, and they start at the third byte in the
+ * descriptor. There's also no point in trying to read descriptor 0
+ * with this function. See USB 2.0 specification section 9.6.7 for
+ * more information.
+ */
+
+ if (desc_index == 0)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
+ r = libusb_get_string_descriptor(dev, 0, 0, tbuf, sizeof(tbuf));
+ if (r < 0)
+ return r;
+
+ if (r < 4)
+ return LIBUSB_ERROR_IO;
+
+ langid = tbuf[2] | (tbuf[3] << 8);
+
+ r = libusb_get_string_descriptor(dev, desc_index, langid, tbuf,
+ sizeof(tbuf));
+ if (r < 0)
+ return r;
+
+ if (tbuf[1] != LIBUSB_DT_STRING)
+ return LIBUSB_ERROR_IO;
+
+ if (tbuf[0] > r)
+ return LIBUSB_ERROR_IO;
+
+ for (di = 0, si = 2; si < tbuf[0]; si += 2) {
+ if (di >= (length - 1))
+ break;
+
+ if ((tbuf[si] & 0x80) || (tbuf[si + 1])) /* non-ASCII */
+ data[di++] = '?';
+ else
+ data[di++] = tbuf[si];
+ }
+
+ data[di] = 0;
+ return di;
+}
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/descriptor.c.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/descriptor.c.REMOVED.git-id
deleted file mode 100644
index 9f8a2167..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/descriptor.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-defcacb1fcaa82a0396e79dc2cb68dc5e908a681
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.c b/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.c
new file mode 100644
index 00000000..779cb6b3
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.c
@@ -0,0 +1,350 @@
+/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
+/*
+ * Hotplug functions for libusb
+ * Copyright © 2012-2013 Nathan Hjelm
+ * Copyright © 2012-2013 Peter Stuge
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#ifdef HAVE_SYS_TYPES_H
+#include
+#endif
+#include
+
+#include "libusbi.h"
+#include "hotplug.h"
+
+/**
+ * @defgroup hotplug Device hotplug event notification
+ * This page details how to use the libusb hotplug interface, where available.
+ *
+ * Be mindful that not all platforms currently implement hotplug notification and
+ * that you should first call on \ref libusb_has_capability() with parameter
+ * \ref LIBUSB_CAP_HAS_HOTPLUG to confirm that hotplug support is available.
+ *
+ * \page hotplug Device hotplug event notification
+ *
+ * \section hotplug_intro Introduction
+ *
+ * Version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102, has added support
+ * for hotplug events on some platforms (you should test if your platform
+ * supports hotplug notification by calling \ref libusb_has_capability() with
+ * parameter \ref LIBUSB_CAP_HAS_HOTPLUG).
+ *
+ * This interface allows you to request notification for the arrival and departure
+ * of matching USB devices.
+ *
+ * To receive hotplug notification you register a callback by calling
+ * \ref libusb_hotplug_register_callback(). This function will optionally return
+ * a handle that can be passed to \ref libusb_hotplug_deregister_callback().
+ *
+ * A callback function must return an int (0 or 1) indicating whether the callback is
+ * expecting additional events. Returning 0 will rearm the callback and 1 will cause
+ * the callback to be deregistered. Note that when callbacks are called from
+ * libusb_hotplug_register_callback() because of the \ref LIBUSB_HOTPLUG_ENUMERATE
+ * flag, the callback return value is ignored, iow you cannot cause a callback
+ * to be deregistered by returning 1 when it is called from
+ * libusb_hotplug_register_callback().
+ *
+ * Callbacks for a particular context are automatically deregistered by libusb_exit().
+ *
+ * As of 1.0.16 there are two supported hotplug events:
+ * - LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED: A device has arrived and is ready to use
+ * - LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT: A device has left and is no longer available
+ *
+ * A hotplug event can listen for either or both of these events.
+ *
+ * Note: If you receive notification that a device has left and you have any
+ * a libusb_device_handles for the device it is up to you to call libusb_close()
+ * on each handle to free up any remaining resources associated with the device.
+ * Once a device has left any libusb_device_handle associated with the device
+ * are invalid and will remain so even if the device comes back.
+ *
+ * When handling a LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED event it is considered
+ * safe to call any libusb function that takes a libusb_device. It also safe to
+ * open a device and submit asynchronous transfers. However, most other functions
+ * that take a libusb_device_handle are not safe to call. Examples of such
+ * functions are any of the \ref syncio "synchronous API" functions or the blocking
+ * functions that retrieve various \ref desc "USB descriptors". These functions must
+ * be used outside of the context of the hotplug callback.
+ *
+ * When handling a LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT event the only safe function
+ * is libusb_get_device_descriptor().
+ *
+ * The following code provides an example of the usage of the hotplug interface:
+\code
+#include
+#include
+#include
+
+static int count = 0;
+
+int hotplug_callback(struct libusb_context *ctx, struct libusb_device *dev,
+ libusb_hotplug_event event, void *user_data) {
+ static libusb_device_handle *handle = NULL;
+ struct libusb_device_descriptor desc;
+ int rc;
+
+ (void)libusb_get_device_descriptor(dev, &desc);
+
+ if (LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED == event) {
+ rc = libusb_open(dev, &handle);
+ if (LIBUSB_SUCCESS != rc) {
+ printf("Could not open USB device\n");
+ }
+ } else if (LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT == event) {
+ if (handle) {
+ libusb_close(handle);
+ handle = NULL;
+ }
+ } else {
+ printf("Unhandled event %d\n", event);
+ }
+ count++;
+
+ return 0;
+}
+
+int main (void) {
+ libusb_hotplug_callback_handle handle;
+ int rc;
+
+ libusb_init(NULL);
+
+ rc = libusb_hotplug_register_callback(NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED |
+ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, 0, 0x045a, 0x5005,
+ LIBUSB_HOTPLUG_MATCH_ANY, hotplug_callback, NULL,
+ &handle);
+ if (LIBUSB_SUCCESS != rc) {
+ printf("Error creating a hotplug callback\n");
+ libusb_exit(NULL);
+ return EXIT_FAILURE;
+ }
+
+ while (count < 2) {
+ libusb_handle_events_completed(NULL, NULL);
+ usleep(10000);
+ }
+
+ libusb_hotplug_deregister_callback(NULL, handle);
+ libusb_exit(NULL);
+
+ return 0;
+}
+\endcode
+ */
+
+static int usbi_hotplug_match_cb (struct libusb_context *ctx,
+ struct libusb_device *dev, libusb_hotplug_event event,
+ struct libusb_hotplug_callback *hotplug_cb)
+{
+ /* Handle lazy deregistration of callback */
+ if (hotplug_cb->needs_free) {
+ /* Free callback */
+ return 1;
+ }
+
+ if (!(hotplug_cb->events & event)) {
+ return 0;
+ }
+
+ if (LIBUSB_HOTPLUG_MATCH_ANY != hotplug_cb->vendor_id &&
+ hotplug_cb->vendor_id != dev->device_descriptor.idVendor) {
+ return 0;
+ }
+
+ if (LIBUSB_HOTPLUG_MATCH_ANY != hotplug_cb->product_id &&
+ hotplug_cb->product_id != dev->device_descriptor.idProduct) {
+ return 0;
+ }
+
+ if (LIBUSB_HOTPLUG_MATCH_ANY != hotplug_cb->dev_class &&
+ hotplug_cb->dev_class != dev->device_descriptor.bDeviceClass) {
+ return 0;
+ }
+
+ return hotplug_cb->cb (ctx, dev, event, hotplug_cb->user_data);
+}
+
+void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
+ libusb_hotplug_event event)
+{
+ struct libusb_hotplug_callback *hotplug_cb, *next;
+ int ret;
+
+ usbi_mutex_lock(&ctx->hotplug_cbs_lock);
+
+ list_for_each_entry_safe(hotplug_cb, next, &ctx->hotplug_cbs, list, struct libusb_hotplug_callback) {
+ usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
+ ret = usbi_hotplug_match_cb (ctx, dev, event, hotplug_cb);
+ usbi_mutex_lock(&ctx->hotplug_cbs_lock);
+
+ if (ret) {
+ list_del(&hotplug_cb->list);
+ free(hotplug_cb);
+ }
+ }
+
+ usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
+
+ /* the backend is expected to call the callback for each active transfer */
+}
+
+void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device *dev,
+ libusb_hotplug_event event)
+{
+ int pending_events;
+ libusb_hotplug_message *message = calloc(1, sizeof(*message));
+
+ if (!message) {
+ usbi_err(ctx, "error allocating hotplug message");
+ return;
+ }
+
+ message->event = event;
+ message->device = dev;
+
+ /* Take the event data lock and add this message to the list.
+ * Only signal an event if there are no prior pending events. */
+ usbi_mutex_lock(&ctx->event_data_lock);
+ pending_events = usbi_pending_events(ctx);
+ list_add_tail(&message->list, &ctx->hotplug_msgs);
+ if (!pending_events)
+ usbi_signal_event(ctx);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+}
+
+int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
+ libusb_hotplug_event events, libusb_hotplug_flag flags,
+ int vendor_id, int product_id, int dev_class,
+ libusb_hotplug_callback_fn cb_fn, void *user_data,
+ libusb_hotplug_callback_handle *handle)
+{
+ libusb_hotplug_callback *new_callback;
+ static int handle_id = 1;
+
+ /* check for hotplug support */
+ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+ }
+
+ /* check for sane values */
+ if ((LIBUSB_HOTPLUG_MATCH_ANY != vendor_id && (~0xffff & vendor_id)) ||
+ (LIBUSB_HOTPLUG_MATCH_ANY != product_id && (~0xffff & product_id)) ||
+ (LIBUSB_HOTPLUG_MATCH_ANY != dev_class && (~0xff & dev_class)) ||
+ !cb_fn) {
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+
+ USBI_GET_CONTEXT(ctx);
+
+ new_callback = (libusb_hotplug_callback *)calloc(1, sizeof (*new_callback));
+ if (!new_callback) {
+ return LIBUSB_ERROR_NO_MEM;
+ }
+
+ new_callback->ctx = ctx;
+ new_callback->vendor_id = vendor_id;
+ new_callback->product_id = product_id;
+ new_callback->dev_class = dev_class;
+ new_callback->flags = flags;
+ new_callback->events = events;
+ new_callback->cb = cb_fn;
+ new_callback->user_data = user_data;
+ new_callback->needs_free = 0;
+
+ usbi_mutex_lock(&ctx->hotplug_cbs_lock);
+
+ /* protect the handle by the context hotplug lock. it doesn't matter if the same handle
+ * is used for different contexts only that the handle is unique for this context */
+ new_callback->handle = handle_id++;
+
+ list_add(&new_callback->list, &ctx->hotplug_cbs);
+
+ usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
+
+
+ if (flags & LIBUSB_HOTPLUG_ENUMERATE) {
+ int i, len;
+ struct libusb_device **devs;
+
+ len = (int) libusb_get_device_list(ctx, &devs);
+ if (len < 0) {
+ libusb_hotplug_deregister_callback(ctx,
+ new_callback->handle);
+ return len;
+ }
+
+ for (i = 0; i < len; i++) {
+ usbi_hotplug_match_cb(ctx, devs[i],
+ LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED,
+ new_callback);
+ }
+
+ libusb_free_device_list(devs, 1);
+ }
+
+
+ if (handle) {
+ *handle = new_callback->handle;
+ }
+
+ return LIBUSB_SUCCESS;
+}
+
+void API_EXPORTED libusb_hotplug_deregister_callback (struct libusb_context *ctx,
+ libusb_hotplug_callback_handle handle)
+{
+ struct libusb_hotplug_callback *hotplug_cb;
+
+ /* check for hotplug support */
+ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
+ return;
+ }
+
+ USBI_GET_CONTEXT(ctx);
+
+ usbi_mutex_lock(&ctx->hotplug_cbs_lock);
+ list_for_each_entry(hotplug_cb, &ctx->hotplug_cbs, list,
+ struct libusb_hotplug_callback) {
+ if (handle == hotplug_cb->handle) {
+ /* Mark this callback for deregistration */
+ hotplug_cb->needs_free = 1;
+ }
+ }
+ usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
+
+ usbi_hotplug_notification(ctx, NULL, 0);
+}
+
+void usbi_hotplug_deregister_all(struct libusb_context *ctx) {
+ struct libusb_hotplug_callback *hotplug_cb, *next;
+
+ usbi_mutex_lock(&ctx->hotplug_cbs_lock);
+ list_for_each_entry_safe(hotplug_cb, next, &ctx->hotplug_cbs, list,
+ struct libusb_hotplug_callback) {
+ list_del(&hotplug_cb->list);
+ free(hotplug_cb);
+ }
+
+ usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
+}
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.c.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.c.REMOVED.git-id
deleted file mode 100644
index cdf82b55..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-779cb6b3249990ea0142232a58a73b1bf0a0233a
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.h b/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.h
new file mode 100644
index 00000000..2bec81b0
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.h
@@ -0,0 +1,90 @@
+/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
+/*
+ * Hotplug support for libusb
+ * Copyright © 2012-2013 Nathan Hjelm
+ * Copyright © 2012-2013 Peter Stuge
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined(USBI_HOTPLUG_H)
+#define USBI_HOTPLUG_H
+
+#ifndef LIBUSBI_H
+#include "libusbi.h"
+#endif
+
+/** \ingroup hotplug
+ * The hotplug callback structure. The user populates this structure with
+ * libusb_hotplug_prepare_callback() and then calls libusb_hotplug_register_callback()
+ * to receive notification of hotplug events.
+ */
+struct libusb_hotplug_callback {
+ /** Context this callback is associated with */
+ struct libusb_context *ctx;
+
+ /** Vendor ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
+ int vendor_id;
+
+ /** Product ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
+ int product_id;
+
+ /** Device class to match or LIBUSB_HOTPLUG_MATCH_ANY */
+ int dev_class;
+
+ /** Hotplug callback flags */
+ libusb_hotplug_flag flags;
+
+ /** Event(s) that will trigger this callback */
+ libusb_hotplug_event events;
+
+ /** Callback function to invoke for matching event/device */
+ libusb_hotplug_callback_fn cb;
+
+ /** Handle for this callback (used to match on deregister) */
+ libusb_hotplug_callback_handle handle;
+
+ /** User data that will be passed to the callback function */
+ void *user_data;
+
+ /** Callback is marked for deletion */
+ int needs_free;
+
+ /** List this callback is registered in (ctx->hotplug_cbs) */
+ struct list_head list;
+};
+
+typedef struct libusb_hotplug_callback libusb_hotplug_callback;
+
+struct libusb_hotplug_message {
+ /** The hotplug event that occurred */
+ libusb_hotplug_event event;
+
+ /** The device for which this hotplug event occurred */
+ struct libusb_device *device;
+
+ /** List this message is contained in (ctx->hotplug_msgs) */
+ struct list_head list;
+};
+
+typedef struct libusb_hotplug_message libusb_hotplug_message;
+
+void usbi_hotplug_deregister_all(struct libusb_context *ctx);
+void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
+ libusb_hotplug_event event);
+void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device *dev,
+ libusb_hotplug_event event);
+
+#endif
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.h.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.h.REMOVED.git-id
deleted file mode 100644
index 60b9ff15..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/hotplug.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-2bec81b06c4275c332e76a2fa8acde12b91e7aac
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/io.c b/Desktop_Interface/build_android/libusb-martin-kuldeep/io.c
new file mode 100644
index 00000000..01cf5bec
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/io.c
@@ -0,0 +1,2783 @@
+/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
+/*
+ * I/O functions for libusb
+ * Copyright © 2007-2009 Daniel Drake
+ * Copyright © 2001 Johannes Erdfelt
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#ifdef HAVE_SIGNAL_H
+#include
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include
+#endif
+#ifdef USBI_TIMERFD_AVAILABLE
+#include
+#endif
+
+#include "libusbi.h"
+#include "hotplug.h"
+
+/**
+ * \page io Synchronous and asynchronous device I/O
+ *
+ * \section io_intro Introduction
+ *
+ * If you're using libusb in your application, you're probably wanting to
+ * perform I/O with devices - you want to perform USB data transfers.
+ *
+ * libusb offers two separate interfaces for device I/O. This page aims to
+ * introduce the two in order to help you decide which one is more suitable
+ * for your application. You can also choose to use both interfaces in your
+ * application by considering each transfer on a case-by-case basis.
+ *
+ * Once you have read through the following discussion, you should consult the
+ * detailed API documentation pages for the details:
+ * - \ref syncio
+ * - \ref asyncio
+ *
+ * \section theory Transfers at a logical level
+ *
+ * At a logical level, USB transfers typically happen in two parts. For
+ * example, when reading data from a endpoint:
+ * -# A request for data is sent to the device
+ * -# Some time later, the incoming data is received by the host
+ *
+ * or when writing data to an endpoint:
+ *
+ * -# The data is sent to the device
+ * -# Some time later, the host receives acknowledgement from the device that
+ * the data has been transferred.
+ *
+ * There may be an indefinite delay between the two steps. Consider a
+ * fictional USB input device with a button that the user can press. In order
+ * to determine when the button is pressed, you would likely submit a request
+ * to read data on a bulk or interrupt endpoint and wait for data to arrive.
+ * Data will arrive when the button is pressed by the user, which is
+ * potentially hours later.
+ *
+ * libusb offers both a synchronous and an asynchronous interface to performing
+ * USB transfers. The main difference is that the synchronous interface
+ * combines both steps indicated above into a single function call, whereas
+ * the asynchronous interface separates them.
+ *
+ * \section sync The synchronous interface
+ *
+ * The synchronous I/O interface allows you to perform a USB transfer with
+ * a single function call. When the function call returns, the transfer has
+ * completed and you can parse the results.
+ *
+ * If you have used the libusb-0.1 before, this I/O style will seem familar to
+ * you. libusb-0.1 only offered a synchronous interface.
+ *
+ * In our input device example, to read button presses you might write code
+ * in the following style:
+\code
+unsigned char data[4];
+int actual_length;
+int r = libusb_bulk_transfer(handle, LIBUSB_ENDPOINT_IN, data, sizeof(data), &actual_length, 0);
+if (r == 0 && actual_length == sizeof(data)) {
+ // results of the transaction can now be found in the data buffer
+ // parse them here and report button press
+} else {
+ error();
+}
+\endcode
+ *
+ * The main advantage of this model is simplicity: you did everything with
+ * a single simple function call.
+ *
+ * However, this interface has its limitations. Your application will sleep
+ * inside libusb_bulk_transfer() until the transaction has completed. If it
+ * takes the user 3 hours to press the button, your application will be
+ * sleeping for that long. Execution will be tied up inside the library -
+ * the entire thread will be useless for that duration.
+ *
+ * Another issue is that by tieing up the thread with that single transaction
+ * there is no possibility of performing I/O with multiple endpoints and/or
+ * multiple devices simultaneously, unless you resort to creating one thread
+ * per transaction.
+ *
+ * Additionally, there is no opportunity to cancel the transfer after the
+ * request has been submitted.
+ *
+ * For details on how to use the synchronous API, see the
+ * \ref syncio "synchronous I/O API documentation" pages.
+ *
+ * \section async The asynchronous interface
+ *
+ * Asynchronous I/O is the most significant new feature in libusb-1.0.
+ * Although it is a more complex interface, it solves all the issues detailed
+ * above.
+ *
+ * Instead of providing which functions that block until the I/O has complete,
+ * libusb's asynchronous interface presents non-blocking functions which
+ * begin a transfer and then return immediately. Your application passes a
+ * callback function pointer to this non-blocking function, which libusb will
+ * call with the results of the transaction when it has completed.
+ *
+ * Transfers which have been submitted through the non-blocking functions
+ * can be cancelled with a separate function call.
+ *
+ * The non-blocking nature of this interface allows you to be simultaneously
+ * performing I/O to multiple endpoints on multiple devices, without having
+ * to use threads.
+ *
+ * This added flexibility does come with some complications though:
+ * - In the interest of being a lightweight library, libusb does not create
+ * threads and can only operate when your application is calling into it. Your
+ * application must call into libusb from it's main loop when events are ready
+ * to be handled, or you must use some other scheme to allow libusb to
+ * undertake whatever work needs to be done.
+ * - libusb also needs to be called into at certain fixed points in time in
+ * order to accurately handle transfer timeouts.
+ * - Memory handling becomes more complex. You cannot use stack memory unless
+ * the function with that stack is guaranteed not to return until the transfer
+ * callback has finished executing.
+ * - You generally lose some linearity from your code flow because submitting
+ * the transfer request is done in a separate function from where the transfer
+ * results are handled. This becomes particularly obvious when you want to
+ * submit a second transfer based on the results of an earlier transfer.
+ *
+ * Internally, libusb's synchronous interface is expressed in terms of function
+ * calls to the asynchronous interface.
+ *
+ * For details on how to use the asynchronous API, see the
+ * \ref asyncio "asynchronous I/O API" documentation pages.
+ */
+
+
+/**
+ * \page packetoverflow Packets and overflows
+ *
+ * \section packets Packet abstraction
+ *
+ * The USB specifications describe how data is transmitted in packets, with
+ * constraints on packet size defined by endpoint descriptors. The host must
+ * not send data payloads larger than the endpoint's maximum packet size.
+ *
+ * libusb and the underlying OS abstract out the packet concept, allowing you
+ * to request transfers of any size. Internally, the request will be divided
+ * up into correctly-sized packets. You do not have to be concerned with
+ * packet sizes, but there is one exception when considering overflows.
+ *
+ * \section overflow Bulk/interrupt transfer overflows
+ *
+ * When requesting data on a bulk endpoint, libusb requires you to supply a
+ * buffer and the maximum number of bytes of data that libusb can put in that
+ * buffer. However, the size of the buffer is not communicated to the device -
+ * the device is just asked to send any amount of data.
+ *
+ * There is no problem if the device sends an amount of data that is less than
+ * or equal to the buffer size. libusb reports this condition to you through
+ * the \ref libusb_transfer::actual_length "libusb_transfer.actual_length"
+ * field.
+ *
+ * Problems may occur if the device attempts to send more data than can fit in
+ * the buffer. libusb reports LIBUSB_TRANSFER_OVERFLOW for this condition but
+ * other behaviour is largely undefined: actual_length may or may not be
+ * accurate, the chunk of data that can fit in the buffer (before overflow)
+ * may or may not have been transferred.
+ *
+ * Overflows are nasty, but can be avoided. Even though you were told to
+ * ignore packets above, think about the lower level details: each transfer is
+ * split into packets (typically small, with a maximum size of 512 bytes).
+ * Overflows can only happen if the final packet in an incoming data transfer
+ * is smaller than the actual packet that the device wants to transfer.
+ * Therefore, you will never see an overflow if your transfer buffer size is a
+ * multiple of the endpoint's packet size: the final packet will either
+ * fill up completely or will be only partially filled.
+ */
+
+/**
+ * @defgroup asyncio Asynchronous device I/O
+ *
+ * This page details libusb's asynchronous (non-blocking) API for USB device
+ * I/O. This interface is very powerful but is also quite complex - you will
+ * need to read this page carefully to understand the necessary considerations
+ * and issues surrounding use of this interface. Simplistic applications
+ * may wish to consider the \ref syncio "synchronous I/O API" instead.
+ *
+ * The asynchronous interface is built around the idea of separating transfer
+ * submission and handling of transfer completion (the synchronous model
+ * combines both of these into one). There may be a long delay between
+ * submission and completion, however the asynchronous submission function
+ * is non-blocking so will return control to your application during that
+ * potentially long delay.
+ *
+ * \section asyncabstraction Transfer abstraction
+ *
+ * For the asynchronous I/O, libusb implements the concept of a generic
+ * transfer entity for all types of I/O (control, bulk, interrupt,
+ * isochronous). The generic transfer object must be treated slightly
+ * differently depending on which type of I/O you are performing with it.
+ *
+ * This is represented by the public libusb_transfer structure type.
+ *
+ * \section asynctrf Asynchronous transfers
+ *
+ * We can view asynchronous I/O as a 5 step process:
+ * -# Allocation: allocate a libusb_transfer
+ * -# Filling: populate the libusb_transfer instance with information
+ * about the transfer you wish to perform
+ * -# Submission: ask libusb to submit the transfer
+ * -# Completion handling: examine transfer results in the
+ * libusb_transfer structure
+ * -# Deallocation: clean up resources
+ *
+ *
+ * \subsection asyncalloc Allocation
+ *
+ * This step involves allocating memory for a USB transfer. This is the
+ * generic transfer object mentioned above. At this stage, the transfer
+ * is "blank" with no details about what type of I/O it will be used for.
+ *
+ * Allocation is done with the libusb_alloc_transfer() function. You must use
+ * this function rather than allocating your own transfers.
+ *
+ * \subsection asyncfill Filling
+ *
+ * This step is where you take a previously allocated transfer and fill it
+ * with information to determine the message type and direction, data buffer,
+ * callback function, etc.
+ *
+ * You can either fill the required fields yourself or you can use the
+ * helper functions: libusb_fill_control_transfer(), libusb_fill_bulk_transfer()
+ * and libusb_fill_interrupt_transfer().
+ *
+ * \subsection asyncsubmit Submission
+ *
+ * When you have allocated a transfer and filled it, you can submit it using
+ * libusb_submit_transfer(). This function returns immediately but can be
+ * regarded as firing off the I/O request in the background.
+ *
+ * \subsection asynccomplete Completion handling
+ *
+ * After a transfer has been submitted, one of four things can happen to it:
+ *
+ * - The transfer completes (i.e. some data was transferred)
+ * - The transfer has a timeout and the timeout expires before all data is
+ * transferred
+ * - The transfer fails due to an error
+ * - The transfer is cancelled
+ *
+ * Each of these will cause the user-specified transfer callback function to
+ * be invoked. It is up to the callback function to determine which of the
+ * above actually happened and to act accordingly.
+ *
+ * The user-specified callback is passed a pointer to the libusb_transfer
+ * structure which was used to setup and submit the transfer. At completion
+ * time, libusb has populated this structure with results of the transfer:
+ * success or failure reason, number of bytes of data transferred, etc. See
+ * the libusb_transfer structure documentation for more information.
+ *
+ * Important Note: The user-specified callback is called from an event
+ * handling context. It is therefore important that no calls are made into
+ * libusb that will attempt to perform any event handling. Examples of such
+ * functions are any listed in the \ref syncio "synchronous API" and any of
+ * the blocking functions that retrieve \ref desc "USB descriptors".
+ *
+ * \subsection Deallocation
+ *
+ * When a transfer has completed (i.e. the callback function has been invoked),
+ * you are advised to free the transfer (unless you wish to resubmit it, see
+ * below). Transfers are deallocated with libusb_free_transfer().
+ *
+ * It is undefined behaviour to free a transfer which has not completed.
+ *
+ * \section asyncresubmit Resubmission
+ *
+ * You may be wondering why allocation, filling, and submission are all
+ * separated above where they could reasonably be combined into a single
+ * operation.
+ *
+ * The reason for separation is to allow you to resubmit transfers without
+ * having to allocate new ones every time. This is especially useful for
+ * common situations dealing with interrupt endpoints - you allocate one
+ * transfer, fill and submit it, and when it returns with results you just
+ * resubmit it for the next interrupt.
+ *
+ * \section asynccancel Cancellation
+ *
+ * Another advantage of using the asynchronous interface is that you have
+ * the ability to cancel transfers which have not yet completed. This is
+ * done by calling the libusb_cancel_transfer() function.
+ *
+ * libusb_cancel_transfer() is asynchronous/non-blocking in itself. When the
+ * cancellation actually completes, the transfer's callback function will
+ * be invoked, and the callback function should check the transfer status to
+ * determine that it was cancelled.
+ *
+ * Freeing the transfer after it has been cancelled but before cancellation
+ * has completed will result in undefined behaviour.
+ *
+ * When a transfer is cancelled, some of the data may have been transferred.
+ * libusb will communicate this to you in the transfer callback. Do not assume
+ * that no data was transferred.
+ *
+ * \section bulk_overflows Overflows on device-to-host bulk/interrupt endpoints
+ *
+ * If your device does not have predictable transfer sizes (or it misbehaves),
+ * your application may submit a request for data on an IN endpoint which is
+ * smaller than the data that the device wishes to send. In some circumstances
+ * this will cause an overflow, which is a nasty condition to deal with. See
+ * the \ref packetoverflow page for discussion.
+ *
+ * \section asyncctrl Considerations for control transfers
+ *
+ * The libusb_transfer structure is generic and hence does not
+ * include specific fields for the control-specific setup packet structure.
+ *
+ * In order to perform a control transfer, you must place the 8-byte setup
+ * packet at the start of the data buffer. To simplify this, you could
+ * cast the buffer pointer to type struct libusb_control_setup, or you can
+ * use the helper function libusb_fill_control_setup().
+ *
+ * The wLength field placed in the setup packet must be the length you would
+ * expect to be sent in the setup packet: the length of the payload that
+ * follows (or the expected maximum number of bytes to receive). However,
+ * the length field of the libusb_transfer object must be the length of
+ * the data buffer - i.e. it should be wLength plus the size of
+ * the setup packet (LIBUSB_CONTROL_SETUP_SIZE).
+ *
+ * If you use the helper functions, this is simplified for you:
+ * -# Allocate a buffer of size LIBUSB_CONTROL_SETUP_SIZE plus the size of the
+ * data you are sending/requesting.
+ * -# Call libusb_fill_control_setup() on the data buffer, using the transfer
+ * request size as the wLength value (i.e. do not include the extra space you
+ * allocated for the control setup).
+ * -# If this is a host-to-device transfer, place the data to be transferred
+ * in the data buffer, starting at offset LIBUSB_CONTROL_SETUP_SIZE.
+ * -# Call libusb_fill_control_transfer() to associate the data buffer with
+ * the transfer (and to set the remaining details such as callback and timeout).
+ * - Note that there is no parameter to set the length field of the transfer.
+ * The length is automatically inferred from the wLength field of the setup
+ * packet.
+ * -# Submit the transfer.
+ *
+ * The multi-byte control setup fields (wValue, wIndex and wLength) must
+ * be given in little-endian byte order (the endianness of the USB bus).
+ * Endianness conversion is transparently handled by
+ * libusb_fill_control_setup() which is documented to accept host-endian
+ * values.
+ *
+ * Further considerations are needed when handling transfer completion in
+ * your callback function:
+ * - As you might expect, the setup packet will still be sitting at the start
+ * of the data buffer.
+ * - If this was a device-to-host transfer, the received data will be sitting
+ * at offset LIBUSB_CONTROL_SETUP_SIZE into the buffer.
+ * - The actual_length field of the transfer structure is relative to the
+ * wLength of the setup packet, rather than the size of the data buffer. So,
+ * if your wLength was 4, your transfer's length was 12, then you
+ * should expect an actual_length of 4 to indicate that the data was
+ * transferred in entirity.
+ *
+ * To simplify parsing of setup packets and obtaining the data from the
+ * correct offset, you may wish to use the libusb_control_transfer_get_data()
+ * and libusb_control_transfer_get_setup() functions within your transfer
+ * callback.
+ *
+ * Even though control endpoints do not halt, a completed control transfer
+ * may have a LIBUSB_TRANSFER_STALL status code. This indicates the control
+ * request was not supported.
+ *
+ * \section asyncintr Considerations for interrupt transfers
+ *
+ * All interrupt transfers are performed using the polling interval presented
+ * by the bInterval value of the endpoint descriptor.
+ *
+ * \section asynciso Considerations for isochronous transfers
+ *
+ * Isochronous transfers are more complicated than transfers to
+ * non-isochronous endpoints.
+ *
+ * To perform I/O to an isochronous endpoint, allocate the transfer by calling
+ * libusb_alloc_transfer() with an appropriate number of isochronous packets.
+ *
+ * During filling, set \ref libusb_transfer::type "type" to
+ * \ref libusb_transfer_type::LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
+ * "LIBUSB_TRANSFER_TYPE_ISOCHRONOUS", and set
+ * \ref libusb_transfer::num_iso_packets "num_iso_packets" to a value less than
+ * or equal to the number of packets you requested during allocation.
+ * libusb_alloc_transfer() does not set either of these fields for you, given
+ * that you might not even use the transfer on an isochronous endpoint.
+ *
+ * Next, populate the length field for the first num_iso_packets entries in
+ * the \ref libusb_transfer::iso_packet_desc "iso_packet_desc" array. Section
+ * 5.6.3 of the USB2 specifications describe how the maximum isochronous
+ * packet length is determined by the wMaxPacketSize field in the endpoint
+ * descriptor.
+ * Two functions can help you here:
+ *
+ * - libusb_get_max_iso_packet_size() is an easy way to determine the max
+ * packet size for an isochronous endpoint. Note that the maximum packet
+ * size is actually the maximum number of bytes that can be transmitted in
+ * a single microframe, therefore this function multiplies the maximum number
+ * of bytes per transaction by the number of transaction opportunities per
+ * microframe.
+ * - libusb_set_iso_packet_lengths() assigns the same length to all packets
+ * within a transfer, which is usually what you want.
+ *
+ * For outgoing transfers, you'll obviously fill the buffer and populate the
+ * packet descriptors in hope that all the data gets transferred. For incoming
+ * transfers, you must ensure the buffer has sufficient capacity for
+ * the situation where all packets transfer the full amount of requested data.
+ *
+ * Completion handling requires some extra consideration. The
+ * \ref libusb_transfer::actual_length "actual_length" field of the transfer
+ * is meaningless and should not be examined; instead you must refer to the
+ * \ref libusb_iso_packet_descriptor::actual_length "actual_length" field of
+ * each individual packet.
+ *
+ * The \ref libusb_transfer::status "status" field of the transfer is also a
+ * little misleading:
+ * - If the packets were submitted and the isochronous data microframes
+ * completed normally, status will have value
+ * \ref libusb_transfer_status::LIBUSB_TRANSFER_COMPLETED
+ * "LIBUSB_TRANSFER_COMPLETED". Note that bus errors and software-incurred
+ * delays are not counted as transfer errors; the transfer.status field may
+ * indicate COMPLETED even if some or all of the packets failed. Refer to
+ * the \ref libusb_iso_packet_descriptor::status "status" field of each
+ * individual packet to determine packet failures.
+ * - The status field will have value
+ * \ref libusb_transfer_status::LIBUSB_TRANSFER_ERROR
+ * "LIBUSB_TRANSFER_ERROR" only when serious errors were encountered.
+ * - Other transfer status codes occur with normal behaviour.
+ *
+ * The data for each packet will be found at an offset into the buffer that
+ * can be calculated as if each prior packet completed in full. The
+ * libusb_get_iso_packet_buffer() and libusb_get_iso_packet_buffer_simple()
+ * functions may help you here.
+ *
+ * Note: Some operating systems (e.g. Linux) may impose limits on the
+ * length of individual isochronous packets and/or the total length of the
+ * isochronous transfer. Such limits can be difficult for libusb to detect,
+ * so the library will simply try and submit the transfer as set up by you.
+ * If the transfer fails to submit because it is too large,
+ * libusb_submit_transfer() will return
+ * \ref libusb_error::LIBUSB_ERROR_INVALID_PARAM "LIBUSB_ERROR_INVALID_PARAM".
+ *
+ * \section asyncmem Memory caveats
+ *
+ * In most circumstances, it is not safe to use stack memory for transfer
+ * buffers. This is because the function that fired off the asynchronous
+ * transfer may return before libusb has finished using the buffer, and when
+ * the function returns it's stack gets destroyed. This is true for both
+ * host-to-device and device-to-host transfers.
+ *
+ * The only case in which it is safe to use stack memory is where you can
+ * guarantee that the function owning the stack space for the buffer does not
+ * return until after the transfer's callback function has completed. In every
+ * other case, you need to use heap memory instead.
+ *
+ * \section asyncflags Fine control
+ *
+ * Through using this asynchronous interface, you may find yourself repeating
+ * a few simple operations many times. You can apply a bitwise OR of certain
+ * flags to a transfer to simplify certain things:
+ * - \ref libusb_transfer_flags::LIBUSB_TRANSFER_SHORT_NOT_OK
+ * "LIBUSB_TRANSFER_SHORT_NOT_OK" results in transfers which transferred
+ * less than the requested amount of data being marked with status
+ * \ref libusb_transfer_status::LIBUSB_TRANSFER_ERROR "LIBUSB_TRANSFER_ERROR"
+ * (they would normally be regarded as COMPLETED)
+ * - \ref libusb_transfer_flags::LIBUSB_TRANSFER_FREE_BUFFER
+ * "LIBUSB_TRANSFER_FREE_BUFFER" allows you to ask libusb to free the transfer
+ * buffer when freeing the transfer.
+ * - \ref libusb_transfer_flags::LIBUSB_TRANSFER_FREE_TRANSFER
+ * "LIBUSB_TRANSFER_FREE_TRANSFER" causes libusb to automatically free the
+ * transfer after the transfer callback returns.
+ *
+ * \section asyncevent Event handling
+ *
+ * An asynchronous model requires that libusb perform work at various
+ * points in time - namely processing the results of previously-submitted
+ * transfers and invoking the user-supplied callback function.
+ *
+ * This gives rise to the libusb_handle_events() function which your
+ * application must call into when libusb has work do to. This gives libusb
+ * the opportunity to reap pending transfers, invoke callbacks, etc.
+ *
+ * There are 2 different approaches to dealing with libusb_handle_events:
+ *
+ * -# Repeatedly call libusb_handle_events() in blocking mode from a dedicated
+ * thread.
+ * -# Integrate libusb with your application's main event loop. libusb
+ * exposes a set of file descriptors which allow you to do this.
+ *
+ * The first approach has the big advantage that it will also work on Windows
+ * were libusb' poll API for select / poll integration is not available. So
+ * if you want to support Windows and use the async API, you must use this
+ * approach, see the \ref eventthread "Using an event handling thread" section
+ * below for details.
+ *
+ * If you prefer a single threaded approach with a single central event loop,
+ * see the \ref poll "polling and timing" section for how to integrate libusb
+ * into your application's main event loop.
+ *
+ * \section eventthread Using an event handling thread
+ *
+ * Lets begin with stating the obvious: If you're going to use a separate
+ * thread for libusb event handling, your callback functions MUST be
+ * threadsafe.
+ *
+ * Other then that doing event handling from a separate thread, is mostly
+ * simple. You can use an event thread function as follows:
+\code
+void *event_thread_func(void *ctx)
+{
+ while (event_thread_run)
+ libusb_handle_events(ctx);
+
+ return NULL;
+}
+\endcode
+ *
+ * There is one caveat though, stopping this thread requires setting the
+ * event_thread_run variable to 0, and after that libusb_handle_events() needs
+ * to return control to event_thread_func. But unless some event happens,
+ * libusb_handle_events() will not return.
+ *
+ * There are 2 different ways of dealing with this, depending on if your
+ * application uses libusb' \ref hotplug "hotplug" support or not.
+ *
+ * Applications which do not use hotplug support, should not start the event
+ * thread until after their first call to libusb_open(), and should stop the
+ * thread when closing the last open device as follows:
+\code
+void my_close_handle(libusb_device_handle *handle)
+{
+ if (open_devs == 1)
+ event_thread_run = 0;
+
+ libusb_close(handle); // This wakes up libusb_handle_events()
+
+ if (open_devs == 1)
+ pthread_join(event_thread);
+
+ open_devs--;
+}
+\endcode
+ *
+ * Applications using hotplug support should start the thread at program init,
+ * after having successfully called libusb_hotplug_register_callback(), and
+ * should stop the thread at program exit as follows:
+\code
+void my_libusb_exit(void)
+{
+ event_thread_run = 0;
+ libusb_hotplug_deregister_callback(ctx, hotplug_cb_handle); // This wakes up libusb_handle_events()
+ pthread_join(event_thread);
+ libusb_exit(ctx);
+}
+\endcode
+ */
+
+/**
+ * @defgroup poll Polling and timing
+ *
+ * This page documents libusb's functions for polling events and timing.
+ * These functions are only necessary for users of the
+ * \ref asyncio "asynchronous API". If you are only using the simpler
+ * \ref syncio "synchronous API" then you do not need to ever call these
+ * functions.
+ *
+ * The justification for the functionality described here has already been
+ * discussed in the \ref asyncevent "event handling" section of the
+ * asynchronous API documentation. In summary, libusb does not create internal
+ * threads for event processing and hence relies on your application calling
+ * into libusb at certain points in time so that pending events can be handled.
+ *
+ * Your main loop is probably already calling poll() or select() or a
+ * variant on a set of file descriptors for other event sources (e.g. keyboard
+ * button presses, mouse movements, network sockets, etc). You then add
+ * libusb's file descriptors to your poll()/select() calls, and when activity
+ * is detected on such descriptors you know it is time to call
+ * libusb_handle_events().
+ *
+ * There is one final event handling complication. libusb supports
+ * asynchronous transfers which time out after a specified time period.
+ *
+ * On some platforms a timerfd is used, so the timeout handling is just another
+ * fd, on other platforms this requires that libusb is called into at or after
+ * the timeout to handle it. So, in addition to considering libusb's file
+ * descriptors in your main event loop, you must also consider that libusb
+ * sometimes needs to be called into at fixed points in time even when there
+ * is no file descriptor activity, see \ref polltime details.
+ *
+ * In order to know precisely when libusb needs to be called into, libusb
+ * offers you a set of pollable file descriptors and information about when
+ * the next timeout expires.
+ *
+ * If you are using the asynchronous I/O API, you must take one of the two
+ * following options, otherwise your I/O will not complete.
+ *
+ * \section pollsimple The simple option
+ *
+ * If your application revolves solely around libusb and does not need to
+ * handle other event sources, you can have a program structure as follows:
+\code
+// initialize libusb
+// find and open device
+// maybe fire off some initial async I/O
+
+while (user_has_not_requested_exit)
+ libusb_handle_events(ctx);
+
+// clean up and exit
+\endcode
+ *
+ * With such a simple main loop, you do not have to worry about managing
+ * sets of file descriptors or handling timeouts. libusb_handle_events() will
+ * handle those details internally.
+ *
+ * \section pollmain The more advanced option
+ *
+ * \note This functionality is currently only available on Unix-like platforms.
+ * On Windows, libusb_get_pollfds() simply returns NULL. Applications which
+ * want to support Windows are advised to use an \ref eventthread
+ * "event handling thread" instead.
+ *
+ * In more advanced applications, you will already have a main loop which
+ * is monitoring other event sources: network sockets, X11 events, mouse
+ * movements, etc. Through exposing a set of file descriptors, libusb is
+ * designed to cleanly integrate into such main loops.
+ *
+ * In addition to polling file descriptors for the other event sources, you
+ * take a set of file descriptors from libusb and monitor those too. When you
+ * detect activity on libusb's file descriptors, you call
+ * libusb_handle_events_timeout() in non-blocking mode.
+ *
+ * What's more, libusb may also need to handle events at specific moments in
+ * time. No file descriptor activity is generated at these times, so your
+ * own application needs to be continually aware of when the next one of these
+ * moments occurs (through calling libusb_get_next_timeout()), and then it
+ * needs to call libusb_handle_events_timeout() in non-blocking mode when
+ * these moments occur. This means that you need to adjust your
+ * poll()/select() timeout accordingly.
+ *
+ * libusb provides you with a set of file descriptors to poll and expects you
+ * to poll all of them, treating them as a single entity. The meaning of each
+ * file descriptor in the set is an internal implementation detail,
+ * platform-dependent and may vary from release to release. Don't try and
+ * interpret the meaning of the file descriptors, just do as libusb indicates,
+ * polling all of them at once.
+ *
+ * In pseudo-code, you want something that looks like:
+\code
+// initialise libusb
+
+libusb_get_pollfds(ctx)
+while (user has not requested application exit) {
+ libusb_get_next_timeout(ctx);
+ poll(on libusb file descriptors plus any other event sources of interest,
+ using a timeout no larger than the value libusb just suggested)
+ if (poll() indicated activity on libusb file descriptors)
+ libusb_handle_events_timeout(ctx, &zero_tv);
+ if (time has elapsed to or beyond the libusb timeout)
+ libusb_handle_events_timeout(ctx, &zero_tv);
+ // handle events from other sources here
+}
+
+// clean up and exit
+\endcode
+ *
+ * \subsection polltime Notes on time-based events
+ *
+ * The above complication with having to track time and call into libusb at
+ * specific moments is a bit of a headache. For maximum compatibility, you do
+ * need to write your main loop as above, but you may decide that you can
+ * restrict the supported platforms of your application and get away with
+ * a more simplistic scheme.
+ *
+ * These time-based event complications are \b not required on the following
+ * platforms:
+ * - Darwin
+ * - Linux, provided that the following version requirements are satisfied:
+ * - Linux v2.6.27 or newer, compiled with timerfd support
+ * - glibc v2.9 or newer
+ * - libusb v1.0.5 or newer
+ *
+ * Under these configurations, libusb_get_next_timeout() will \em always return
+ * 0, so your main loop can be simplified to:
+\code
+// initialise libusb
+
+libusb_get_pollfds(ctx)
+while (user has not requested application exit) {
+ poll(on libusb file descriptors plus any other event sources of interest,
+ using any timeout that you like)
+ if (poll() indicated activity on libusb file descriptors)
+ libusb_handle_events_timeout(ctx, &zero_tv);
+ // handle events from other sources here
+}
+
+// clean up and exit
+\endcode
+ *
+ * Do remember that if you simplify your main loop to the above, you will
+ * lose compatibility with some platforms (including legacy Linux platforms,
+ * and any future platforms supported by libusb which may have time-based
+ * event requirements). The resultant problems will likely appear as
+ * strange bugs in your application.
+ *
+ * You can use the libusb_pollfds_handle_timeouts() function to do a runtime
+ * check to see if it is safe to ignore the time-based event complications.
+ * If your application has taken the shortcut of ignoring libusb's next timeout
+ * in your main loop, then you are advised to check the return value of
+ * libusb_pollfds_handle_timeouts() during application startup, and to abort
+ * if the platform does suffer from these timing complications.
+ *
+ * \subsection fdsetchange Changes in the file descriptor set
+ *
+ * The set of file descriptors that libusb uses as event sources may change
+ * during the life of your application. Rather than having to repeatedly
+ * call libusb_get_pollfds(), you can set up notification functions for when
+ * the file descriptor set changes using libusb_set_pollfd_notifiers().
+ *
+ * \subsection mtissues Multi-threaded considerations
+ *
+ * Unfortunately, the situation is complicated further when multiple threads
+ * come into play. If two threads are monitoring the same file descriptors,
+ * the fact that only one thread will be woken up when an event occurs causes
+ * some headaches.
+ *
+ * The events lock, event waiters lock, and libusb_handle_events_locked()
+ * entities are added to solve these problems. You do not need to be concerned
+ * with these entities otherwise.
+ *
+ * See the extra documentation: \ref mtasync
+ */
+
+/** \page mtasync Multi-threaded applications and asynchronous I/O
+ *
+ * libusb is a thread-safe library, but extra considerations must be applied
+ * to applications which interact with libusb from multiple threads.
+ *
+ * The underlying issue that must be addressed is that all libusb I/O
+ * revolves around monitoring file descriptors through the poll()/select()
+ * system calls. This is directly exposed at the
+ * \ref asyncio "asynchronous interface" but it is important to note that the
+ * \ref syncio "synchronous interface" is implemented on top of the
+ * asynchonrous interface, therefore the same considerations apply.
+ *
+ * The issue is that if two or more threads are concurrently calling poll()
+ * or select() on libusb's file descriptors then only one of those threads
+ * will be woken up when an event arrives. The others will be completely
+ * oblivious that anything has happened.
+ *
+ * Consider the following pseudo-code, which submits an asynchronous transfer
+ * then waits for its completion. This style is one way you could implement a
+ * synchronous interface on top of the asynchronous interface (and libusb
+ * does something similar, albeit more advanced due to the complications
+ * explained on this page).
+ *
+\code
+void cb(struct libusb_transfer *transfer)
+{
+ int *completed = transfer->user_data;
+ *completed = 1;
+}
+
+void myfunc() {
+ struct libusb_transfer *transfer;
+ unsigned char buffer[LIBUSB_CONTROL_SETUP_SIZE] __attribute__ ((aligned (2)));
+ int completed = 0;
+
+ transfer = libusb_alloc_transfer(0);
+ libusb_fill_control_setup(buffer,
+ LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, 0x04, 0x01, 0, 0);
+ libusb_fill_control_transfer(transfer, dev, buffer, cb, &completed, 1000);
+ libusb_submit_transfer(transfer);
+
+ while (!completed) {
+ poll(libusb file descriptors, 120*1000);
+ if (poll indicates activity)
+ libusb_handle_events_timeout(ctx, &zero_tv);
+ }
+ printf("completed!");
+ // other code here
+}
+\endcode
+ *
+ * Here we are serializing completion of an asynchronous event
+ * against a condition - the condition being completion of a specific transfer.
+ * The poll() loop has a long timeout to minimize CPU usage during situations
+ * when nothing is happening (it could reasonably be unlimited).
+ *
+ * If this is the only thread that is polling libusb's file descriptors, there
+ * is no problem: there is no danger that another thread will swallow up the
+ * event that we are interested in. On the other hand, if there is another
+ * thread polling the same descriptors, there is a chance that it will receive
+ * the event that we were interested in. In this situation, myfunc()
+ * will only realise that the transfer has completed on the next iteration of
+ * the loop, up to 120 seconds later. Clearly a two-minute delay is
+ * undesirable, and don't even think about using short timeouts to circumvent
+ * this issue!
+ *
+ * The solution here is to ensure that no two threads are ever polling the
+ * file descriptors at the same time. A naive implementation of this would
+ * impact the capabilities of the library, so libusb offers the scheme
+ * documented below to ensure no loss of functionality.
+ *
+ * Before we go any further, it is worth mentioning that all libusb-wrapped
+ * event handling procedures fully adhere to the scheme documented below.
+ * This includes libusb_handle_events() and its variants, and all the
+ * synchronous I/O functions - libusb hides this headache from you.
+ *
+ * \section Using libusb_handle_events() from multiple threads
+ *
+ * Even when only using libusb_handle_events() and synchronous I/O functions,
+ * you can still have a race condition. You might be tempted to solve the
+ * above with libusb_handle_events() like so:
+ *
+\code
+ libusb_submit_transfer(transfer);
+
+ while (!completed) {
+ libusb_handle_events(ctx);
+ }
+ printf("completed!");
+\endcode
+ *
+ * This however has a race between the checking of completed and
+ * libusb_handle_events() acquiring the events lock, so another thread
+ * could have completed the transfer, resulting in this thread hanging
+ * until either a timeout or another event occurs. See also commit
+ * 6696512aade99bb15d6792af90ae329af270eba6 which fixes this in the
+ * synchronous API implementation of libusb.
+ *
+ * Fixing this race requires checking the variable completed only after
+ * taking the event lock, which defeats the concept of just calling
+ * libusb_handle_events() without worrying about locking. This is why
+ * libusb-1.0.9 introduces the new libusb_handle_events_timeout_completed()
+ * and libusb_handle_events_completed() functions, which handles doing the
+ * completion check for you after they have acquired the lock:
+ *
+\code
+ libusb_submit_transfer(transfer);
+
+ while (!completed) {
+ libusb_handle_events_completed(ctx, &completed);
+ }
+ printf("completed!");
+\endcode
+ *
+ * This nicely fixes the race in our example. Note that if all you want to
+ * do is submit a single transfer and wait for its completion, then using
+ * one of the synchronous I/O functions is much easier.
+ *
+ * \section eventlock The events lock
+ *
+ * The problem is when we consider the fact that libusb exposes file
+ * descriptors to allow for you to integrate asynchronous USB I/O into
+ * existing main loops, effectively allowing you to do some work behind
+ * libusb's back. If you do take libusb's file descriptors and pass them to
+ * poll()/select() yourself, you need to be aware of the associated issues.
+ *
+ * The first concept to be introduced is the events lock. The events lock
+ * is used to serialize threads that want to handle events, such that only
+ * one thread is handling events at any one time.
+ *
+ * You must take the events lock before polling libusb file descriptors,
+ * using libusb_lock_events(). You must release the lock as soon as you have
+ * aborted your poll()/select() loop, using libusb_unlock_events().
+ *
+ * \section threadwait Letting other threads do the work for you
+ *
+ * Although the events lock is a critical part of the solution, it is not
+ * enough on it's own. You might wonder if the following is sufficient...
+\code
+ libusb_lock_events(ctx);
+ while (!completed) {
+ poll(libusb file descriptors, 120*1000);
+ if (poll indicates activity)
+ libusb_handle_events_timeout(ctx, &zero_tv);
+ }
+ libusb_unlock_events(ctx);
+\endcode
+ * ...and the answer is that it is not. This is because the transfer in the
+ * code shown above may take a long time (say 30 seconds) to complete, and
+ * the lock is not released until the transfer is completed.
+ *
+ * Another thread with similar code that wants to do event handling may be
+ * working with a transfer that completes after a few milliseconds. Despite
+ * having such a quick completion time, the other thread cannot check that
+ * status of its transfer until the code above has finished (30 seconds later)
+ * due to contention on the lock.
+ *
+ * To solve this, libusb offers you a mechanism to determine when another
+ * thread is handling events. It also offers a mechanism to block your thread
+ * until the event handling thread has completed an event (and this mechanism
+ * does not involve polling of file descriptors).
+ *
+ * After determining that another thread is currently handling events, you
+ * obtain the event waiters lock using libusb_lock_event_waiters().
+ * You then re-check that some other thread is still handling events, and if
+ * so, you call libusb_wait_for_event().
+ *
+ * libusb_wait_for_event() puts your application to sleep until an event
+ * occurs, or until a thread releases the events lock. When either of these
+ * things happen, your thread is woken up, and should re-check the condition
+ * it was waiting on. It should also re-check that another thread is handling
+ * events, and if not, it should start handling events itself.
+ *
+ * This looks like the following, as pseudo-code:
+\code
+retry:
+if (libusb_try_lock_events(ctx) == 0) {
+ // we obtained the event lock: do our own event handling
+ while (!completed) {
+ if (!libusb_event_handling_ok(ctx)) {
+ libusb_unlock_events(ctx);
+ goto retry;
+ }
+ poll(libusb file descriptors, 120*1000);
+ if (poll indicates activity)
+ libusb_handle_events_locked(ctx, 0);
+ }
+ libusb_unlock_events(ctx);
+} else {
+ // another thread is doing event handling. wait for it to signal us that
+ // an event has completed
+ libusb_lock_event_waiters(ctx);
+
+ while (!completed) {
+ // now that we have the event waiters lock, double check that another
+ // thread is still handling events for us. (it may have ceased handling
+ // events in the time it took us to reach this point)
+ if (!libusb_event_handler_active(ctx)) {
+ // whoever was handling events is no longer doing so, try again
+ libusb_unlock_event_waiters(ctx);
+ goto retry;
+ }
+
+ libusb_wait_for_event(ctx, NULL);
+ }
+ libusb_unlock_event_waiters(ctx);
+}
+printf("completed!\n");
+\endcode
+ *
+ * A naive look at the above code may suggest that this can only support
+ * one event waiter (hence a total of 2 competing threads, the other doing
+ * event handling), because the event waiter seems to have taken the event
+ * waiters lock while waiting for an event. However, the system does support
+ * multiple event waiters, because libusb_wait_for_event() actually drops
+ * the lock while waiting, and reaquires it before continuing.
+ *
+ * We have now implemented code which can dynamically handle situations where
+ * nobody is handling events (so we should do it ourselves), and it can also
+ * handle situations where another thread is doing event handling (so we can
+ * piggyback onto them). It is also equipped to handle a combination of
+ * the two, for example, another thread is doing event handling, but for
+ * whatever reason it stops doing so before our condition is met, so we take
+ * over the event handling.
+ *
+ * Four functions were introduced in the above pseudo-code. Their importance
+ * should be apparent from the code shown above.
+ * -# libusb_try_lock_events() is a non-blocking function which attempts
+ * to acquire the events lock but returns a failure code if it is contended.
+ * -# libusb_event_handling_ok() checks that libusb is still happy for your
+ * thread to be performing event handling. Sometimes, libusb needs to
+ * interrupt the event handler, and this is how you can check if you have
+ * been interrupted. If this function returns 0, the correct behaviour is
+ * for you to give up the event handling lock, and then to repeat the cycle.
+ * The following libusb_try_lock_events() will fail, so you will become an
+ * events waiter. For more information on this, read \ref fullstory below.
+ * -# libusb_handle_events_locked() is a variant of
+ * libusb_handle_events_timeout() that you can call while holding the
+ * events lock. libusb_handle_events_timeout() itself implements similar
+ * logic to the above, so be sure not to call it when you are
+ * "working behind libusb's back", as is the case here.
+ * -# libusb_event_handler_active() determines if someone is currently
+ * holding the events lock
+ *
+ * You might be wondering why there is no function to wake up all threads
+ * blocked on libusb_wait_for_event(). This is because libusb can do this
+ * internally: it will wake up all such threads when someone calls
+ * libusb_unlock_events() or when a transfer completes (at the point after its
+ * callback has returned).
+ *
+ * \subsection fullstory The full story
+ *
+ * The above explanation should be enough to get you going, but if you're
+ * really thinking through the issues then you may be left with some more
+ * questions regarding libusb's internals. If you're curious, read on, and if
+ * not, skip to the next section to avoid confusing yourself!
+ *
+ * The immediate question that may spring to mind is: what if one thread
+ * modifies the set of file descriptors that need to be polled while another
+ * thread is doing event handling?
+ *
+ * There are 2 situations in which this may happen.
+ * -# libusb_open() will add another file descriptor to the poll set,
+ * therefore it is desirable to interrupt the event handler so that it
+ * restarts, picking up the new descriptor.
+ * -# libusb_close() will remove a file descriptor from the poll set. There
+ * are all kinds of race conditions that could arise here, so it is
+ * important that nobody is doing event handling at this time.
+ *
+ * libusb handles these issues internally, so application developers do not
+ * have to stop their event handlers while opening/closing devices. Here's how
+ * it works, focusing on the libusb_close() situation first:
+ *
+ * -# During initialization, libusb opens an internal pipe, and it adds the read
+ * end of this pipe to the set of file descriptors to be polled.
+ * -# During libusb_close(), libusb writes some dummy data on this event pipe.
+ * This immediately interrupts the event handler. libusb also records
+ * internally that it is trying to interrupt event handlers for this
+ * high-priority event.
+ * -# At this point, some of the functions described above start behaving
+ * differently:
+ * - libusb_event_handling_ok() starts returning 1, indicating that it is NOT
+ * OK for event handling to continue.
+ * - libusb_try_lock_events() starts returning 1, indicating that another
+ * thread holds the event handling lock, even if the lock is uncontended.
+ * - libusb_event_handler_active() starts returning 1, indicating that
+ * another thread is doing event handling, even if that is not true.
+ * -# The above changes in behaviour result in the event handler stopping and
+ * giving up the events lock very quickly, giving the high-priority
+ * libusb_close() operation a "free ride" to acquire the events lock. All
+ * threads that are competing to do event handling become event waiters.
+ * -# With the events lock held inside libusb_close(), libusb can safely remove
+ * a file descriptor from the poll set, in the safety of knowledge that
+ * nobody is polling those descriptors or trying to access the poll set.
+ * -# After obtaining the events lock, the close operation completes very
+ * quickly (usually a matter of milliseconds) and then immediately releases
+ * the events lock.
+ * -# At the same time, the behaviour of libusb_event_handling_ok() and friends
+ * reverts to the original, documented behaviour.
+ * -# The release of the events lock causes the threads that are waiting for
+ * events to be woken up and to start competing to become event handlers
+ * again. One of them will succeed; it will then re-obtain the list of poll
+ * descriptors, and USB I/O will then continue as normal.
+ *
+ * libusb_open() is similar, and is actually a more simplistic case. Upon a
+ * call to libusb_open():
+ *
+ * -# The device is opened and a file descriptor is added to the poll set.
+ * -# libusb sends some dummy data on the event pipe, and records that it
+ * is trying to modify the poll descriptor set.
+ * -# The event handler is interrupted, and the same behaviour change as for
+ * libusb_close() takes effect, causing all event handling threads to become
+ * event waiters.
+ * -# The libusb_open() implementation takes its free ride to the events lock.
+ * -# Happy that it has successfully paused the events handler, libusb_open()
+ * releases the events lock.
+ * -# The event waiter threads are all woken up and compete to become event
+ * handlers again. The one that succeeds will obtain the list of poll
+ * descriptors again, which will include the addition of the new device.
+ *
+ * \subsection concl Closing remarks
+ *
+ * The above may seem a little complicated, but hopefully I have made it clear
+ * why such complications are necessary. Also, do not forget that this only
+ * applies to applications that take libusb's file descriptors and integrate
+ * them into their own polling loops.
+ *
+ * You may decide that it is OK for your multi-threaded application to ignore
+ * some of the rules and locks detailed above, because you don't think that
+ * two threads can ever be polling the descriptors at the same time. If that
+ * is the case, then that's good news for you because you don't have to worry.
+ * But be careful here; remember that the synchronous I/O functions do event
+ * handling internally. If you have one thread doing event handling in a loop
+ * (without implementing the rules and locking semantics documented above)
+ * and another trying to send a synchronous USB transfer, you will end up with
+ * two threads monitoring the same descriptors, and the above-described
+ * undesirable behaviour occuring. The solution is for your polling thread to
+ * play by the rules; the synchronous I/O functions do so, and this will result
+ * in them getting along in perfect harmony.
+ *
+ * If you do have a dedicated thread doing event handling, it is perfectly
+ * legal for it to take the event handling lock for long periods of time. Any
+ * synchronous I/O functions you call from other threads will transparently
+ * fall back to the "event waiters" mechanism detailed above. The only
+ * consideration that your event handling thread must apply is the one related
+ * to libusb_event_handling_ok(): you must call this before every poll(), and
+ * give up the events lock if instructed.
+ */
+
+int usbi_io_init(struct libusb_context *ctx)
+{
+ int r;
+
+ usbi_mutex_init(&ctx->flying_transfers_lock, NULL);
+ usbi_mutex_init_recursive(&ctx->events_lock, NULL);
+ usbi_mutex_init(&ctx->event_waiters_lock, NULL);
+ usbi_cond_init(&ctx->event_waiters_cond, NULL);
+ usbi_mutex_init(&ctx->event_data_lock, NULL);
+ usbi_tls_key_create(&ctx->event_handling_key, NULL);
+ list_init(&ctx->flying_transfers);
+ list_init(&ctx->ipollfds);
+ list_init(&ctx->hotplug_msgs);
+ list_init(&ctx->completed_transfers);
+
+ /* FIXME should use an eventfd on kernels that support it */
+ r = usbi_pipe(ctx->event_pipe);
+ if (r < 0) {
+ r = LIBUSB_ERROR_OTHER;
+ goto err;
+ }
+
+ r = usbi_add_pollfd(ctx, ctx->event_pipe[0], POLLIN);
+ if (r < 0)
+ goto err_close_pipe;
+
+#ifdef USBI_TIMERFD_AVAILABLE
+ ctx->timerfd = timerfd_create(usbi_backend->get_timerfd_clockid(),
+ TFD_NONBLOCK);
+ if (ctx->timerfd >= 0) {
+ usbi_dbg("using timerfd for timeouts");
+ r = usbi_add_pollfd(ctx, ctx->timerfd, POLLIN);
+ if (r < 0)
+ goto err_close_timerfd;
+ } else {
+ usbi_dbg("timerfd not available (code %d error %d)", ctx->timerfd, errno);
+ ctx->timerfd = -1;
+ }
+#endif
+
+ return 0;
+
+#ifdef USBI_TIMERFD_AVAILABLE
+err_close_timerfd:
+ close(ctx->timerfd);
+ usbi_remove_pollfd(ctx, ctx->event_pipe[0]);
+#endif
+err_close_pipe:
+ usbi_close(ctx->event_pipe[0]);
+ usbi_close(ctx->event_pipe[1]);
+err:
+ usbi_mutex_destroy(&ctx->flying_transfers_lock);
+ usbi_mutex_destroy(&ctx->events_lock);
+ usbi_mutex_destroy(&ctx->event_waiters_lock);
+ usbi_cond_destroy(&ctx->event_waiters_cond);
+ usbi_mutex_destroy(&ctx->event_data_lock);
+ usbi_tls_key_delete(ctx->event_handling_key);
+ return r;
+}
+
+void usbi_io_exit(struct libusb_context *ctx)
+{
+ usbi_remove_pollfd(ctx, ctx->event_pipe[0]);
+ usbi_close(ctx->event_pipe[0]);
+ usbi_close(ctx->event_pipe[1]);
+#ifdef USBI_TIMERFD_AVAILABLE
+ if (usbi_using_timerfd(ctx)) {
+ usbi_remove_pollfd(ctx, ctx->timerfd);
+ close(ctx->timerfd);
+ }
+#endif
+ usbi_mutex_destroy(&ctx->flying_transfers_lock);
+ usbi_mutex_destroy(&ctx->events_lock);
+ usbi_mutex_destroy(&ctx->event_waiters_lock);
+ usbi_cond_destroy(&ctx->event_waiters_cond);
+ usbi_mutex_destroy(&ctx->event_data_lock);
+ usbi_tls_key_delete(ctx->event_handling_key);
+ if (ctx->pollfds)
+ free(ctx->pollfds);
+}
+
+static int calculate_timeout(struct usbi_transfer *transfer)
+{
+ int r;
+ struct timespec current_time;
+ unsigned int timeout =
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->timeout;
+
+ if (!timeout)
+ return 0;
+
+ r = usbi_backend->clock_gettime(USBI_CLOCK_MONOTONIC, ¤t_time);
+ if (r < 0) {
+ usbi_err(ITRANSFER_CTX(transfer),
+ "failed to read monotonic clock, errno=%d", errno);
+ return r;
+ }
+
+ current_time.tv_sec += timeout / 1000;
+ current_time.tv_nsec += (timeout % 1000) * 1000000;
+
+ while (current_time.tv_nsec >= 1000000000) {
+ current_time.tv_nsec -= 1000000000;
+ current_time.tv_sec++;
+ }
+
+ TIMESPEC_TO_TIMEVAL(&transfer->timeout, ¤t_time);
+ return 0;
+}
+
+/** \ingroup asyncio
+ * Allocate a libusb transfer with a specified number of isochronous packet
+ * descriptors. The returned transfer is pre-initialized for you. When the new
+ * transfer is no longer needed, it should be freed with
+ * libusb_free_transfer().
+ *
+ * Transfers intended for non-isochronous endpoints (e.g. control, bulk,
+ * interrupt) should specify an iso_packets count of zero.
+ *
+ * For transfers intended for isochronous endpoints, specify an appropriate
+ * number of packet descriptors to be allocated as part of the transfer.
+ * The returned transfer is not specially initialized for isochronous I/O;
+ * you are still required to set the
+ * \ref libusb_transfer::num_iso_packets "num_iso_packets" and
+ * \ref libusb_transfer::type "type" fields accordingly.
+ *
+ * It is safe to allocate a transfer with some isochronous packets and then
+ * use it on a non-isochronous endpoint. If you do this, ensure that at time
+ * of submission, num_iso_packets is 0 and that type is set appropriately.
+ *
+ * \param iso_packets number of isochronous packet descriptors to allocate
+ * \returns a newly allocated transfer, or NULL on error
+ */
+DEFAULT_VISIBILITY
+struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(
+ int iso_packets)
+{
+ struct libusb_transfer *transfer;
+ size_t os_alloc_size = usbi_backend->transfer_priv_size;
+ size_t alloc_size = sizeof(struct usbi_transfer)
+ + sizeof(struct libusb_transfer)
+ + (sizeof(struct libusb_iso_packet_descriptor) * iso_packets)
+ + os_alloc_size;
+ struct usbi_transfer *itransfer = calloc(1, alloc_size);
+ if (!itransfer)
+ return NULL;
+
+ itransfer->num_iso_packets = iso_packets;
+ usbi_mutex_init(&itransfer->lock, NULL);
+ usbi_mutex_init(&itransfer->flags_lock, NULL);
+ transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
+ usbi_dbg("transfer %p", transfer);
+ return transfer;
+}
+
+/** \ingroup asyncio
+ * Free a transfer structure. This should be called for all transfers
+ * allocated with libusb_alloc_transfer().
+ *
+ * If the \ref libusb_transfer_flags::LIBUSB_TRANSFER_FREE_BUFFER
+ * "LIBUSB_TRANSFER_FREE_BUFFER" flag is set and the transfer buffer is
+ * non-NULL, this function will also free the transfer buffer using the
+ * standard system memory allocator (e.g. free()).
+ *
+ * It is legal to call this function with a NULL transfer. In this case,
+ * the function will simply return safely.
+ *
+ * It is not legal to free an active transfer (one which has been submitted
+ * and has not yet completed).
+ *
+ * \param transfer the transfer to free
+ */
+void API_EXPORTED libusb_free_transfer(struct libusb_transfer *transfer)
+{
+ struct usbi_transfer *itransfer;
+ if (!transfer)
+ return;
+
+ usbi_dbg("transfer %p", transfer);
+ if (transfer->flags & LIBUSB_TRANSFER_FREE_BUFFER && transfer->buffer)
+ free(transfer->buffer);
+
+ itransfer = LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
+ usbi_mutex_destroy(&itransfer->lock);
+ usbi_mutex_destroy(&itransfer->flags_lock);
+ free(itransfer);
+}
+
+#ifdef USBI_TIMERFD_AVAILABLE
+static int disarm_timerfd(struct libusb_context *ctx)
+{
+ const struct itimerspec disarm_timer = { { 0, 0 }, { 0, 0 } };
+ int r;
+
+ usbi_dbg("");
+ r = timerfd_settime(ctx->timerfd, 0, &disarm_timer, NULL);
+ if (r < 0)
+ return LIBUSB_ERROR_OTHER;
+ else
+ return 0;
+}
+
+/* iterates through the flying transfers, and rearms the timerfd based on the
+ * next upcoming timeout.
+ * must be called with flying_list locked.
+ * returns 0 on success or a LIBUSB_ERROR code on failure.
+ */
+static int arm_timerfd_for_next_timeout(struct libusb_context *ctx)
+{
+ struct usbi_transfer *transfer;
+
+ list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
+ struct timeval *cur_tv = &transfer->timeout;
+
+ /* if we've reached transfers of infinite timeout, then we have no
+ * arming to do */
+ if (!timerisset(cur_tv))
+ goto disarm;
+
+ /* act on first transfer that is not already cancelled */
+ if (!(transfer->flags & USBI_TRANSFER_TIMEOUT_HANDLED)) {
+ int r;
+ const struct itimerspec it = { {0, 0},
+ { cur_tv->tv_sec, cur_tv->tv_usec * 1000 } };
+ usbi_dbg("next timeout originally %dms", USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->timeout);
+ r = timerfd_settime(ctx->timerfd, TFD_TIMER_ABSTIME, &it, NULL);
+ if (r < 0)
+ return LIBUSB_ERROR_OTHER;
+ return 0;
+ }
+ }
+
+disarm:
+ return disarm_timerfd(ctx);
+}
+#else
+static int arm_timerfd_for_next_timeout(struct libusb_context *ctx)
+{
+ UNUSED(ctx);
+ return 0;
+}
+#endif
+
+/* add a transfer to the (timeout-sorted) active transfers list.
+ * This function will return non 0 if fails to update the timer,
+ * in which case the transfer is *not* on the flying_transfers list. */
+static int add_to_flying_list(struct usbi_transfer *transfer)
+{
+ struct usbi_transfer *cur;
+ struct timeval *timeout = &transfer->timeout;
+ struct libusb_context *ctx = ITRANSFER_CTX(transfer);
+ int r = 0;
+ int first = 1;
+
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
+
+ /* if we have no other flying transfers, start the list with this one */
+ if (list_empty(&ctx->flying_transfers)) {
+ list_add(&transfer->list, &ctx->flying_transfers);
+ goto out;
+ }
+
+ /* if we have infinite timeout, append to end of list */
+ if (!timerisset(timeout)) {
+ list_add_tail(&transfer->list, &ctx->flying_transfers);
+ /* first is irrelevant in this case */
+ goto out;
+ }
+
+ /* otherwise, find appropriate place in list */
+ list_for_each_entry(cur, &ctx->flying_transfers, list, struct usbi_transfer) {
+ /* find first timeout that occurs after the transfer in question */
+ struct timeval *cur_tv = &cur->timeout;
+
+ if (!timerisset(cur_tv) || (cur_tv->tv_sec > timeout->tv_sec) ||
+ (cur_tv->tv_sec == timeout->tv_sec &&
+ cur_tv->tv_usec > timeout->tv_usec)) {
+ list_add_tail(&transfer->list, &cur->list);
+ goto out;
+ }
+ first = 0;
+ }
+ /* first is 0 at this stage (list not empty) */
+
+ /* otherwise we need to be inserted at the end */
+ list_add_tail(&transfer->list, &ctx->flying_transfers);
+out:
+#ifdef USBI_TIMERFD_AVAILABLE
+ if (first && usbi_using_timerfd(ctx) && timerisset(timeout)) {
+ /* if this transfer has the lowest timeout of all active transfers,
+ * rearm the timerfd with this transfer's timeout */
+ const struct itimerspec it = { {0, 0},
+ { timeout->tv_sec, timeout->tv_usec * 1000 } };
+ usbi_dbg("arm timerfd for timeout in %dms (first in line)",
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->timeout);
+ r = timerfd_settime(ctx->timerfd, TFD_TIMER_ABSTIME, &it, NULL);
+ if (r < 0) {
+ usbi_warn(ctx, "failed to arm first timerfd (errno %d)", errno);
+ r = LIBUSB_ERROR_OTHER;
+ }
+ }
+#else
+ UNUSED(first);
+#endif
+
+ if (r)
+ list_del(&transfer->list);
+
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
+ return r;
+}
+
+/* remove a transfer from the active transfers list.
+ * This function will *always* remove the transfer from the
+ * flying_transfers list. It will return a LIBUSB_ERROR code
+ * if it fails to update the timer for the next timeout. */
+static int remove_from_flying_list(struct usbi_transfer *transfer)
+{
+ struct libusb_context *ctx = ITRANSFER_CTX(transfer);
+ int rearm_timerfd;
+ int r = 0;
+
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
+ rearm_timerfd = (timerisset(&transfer->timeout) &&
+ list_first_entry(&ctx->flying_transfers, struct usbi_transfer, list) == transfer);
+ list_del(&transfer->list);
+ if (usbi_using_timerfd(ctx) && rearm_timerfd)
+ r = arm_timerfd_for_next_timeout(ctx);
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
+
+ return r;
+}
+
+/** \ingroup asyncio
+ * Submit a transfer. This function will fire off the USB transfer and then
+ * return immediately.
+ *
+ * \param transfer the transfer to submit
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * \returns LIBUSB_ERROR_BUSY if the transfer has already been submitted.
+ * \returns LIBUSB_ERROR_NOT_SUPPORTED if the transfer flags are not supported
+ * by the operating system.
+ * \returns another LIBUSB_ERROR code on other failure
+ */
+int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
+{
+ struct usbi_transfer *itransfer =
+ LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
+ int remove = 0;
+ int r;
+
+ usbi_dbg("transfer %p", transfer);
+ usbi_mutex_lock(&itransfer->lock);
+ usbi_mutex_lock(&itransfer->flags_lock);
+ if (itransfer->flags & USBI_TRANSFER_IN_FLIGHT) {
+ r = LIBUSB_ERROR_BUSY;
+ goto out;
+ }
+ itransfer->transferred = 0;
+ itransfer->flags = 0;
+ r = calculate_timeout(itransfer);
+ if (r < 0) {
+ r = LIBUSB_ERROR_OTHER;
+ goto out;
+ }
+ itransfer->flags |= USBI_TRANSFER_SUBMITTING;
+ usbi_mutex_unlock(&itransfer->flags_lock);
+
+ r = add_to_flying_list(itransfer);
+ if (r) {
+ usbi_mutex_lock(&itransfer->flags_lock);
+ itransfer->flags = 0;
+ goto out;
+ }
+
+ /* keep a reference to this device */
+ libusb_ref_device(transfer->dev_handle->dev);
+ r = usbi_backend->submit_transfer(itransfer);
+
+ usbi_mutex_lock(&itransfer->flags_lock);
+ itransfer->flags &= ~USBI_TRANSFER_SUBMITTING;
+ if (r == LIBUSB_SUCCESS) {
+ /* check for two possible special conditions:
+ * 1) device disconnect occurred immediately after submission
+ * 2) transfer completed before we got here to update the flags
+ */
+ if (itransfer->flags & USBI_TRANSFER_DEVICE_DISAPPEARED) {
+ usbi_backend->clear_transfer_priv(itransfer);
+ remove = 1;
+ r = LIBUSB_ERROR_NO_DEVICE;
+ }
+ else if (!(itransfer->flags & USBI_TRANSFER_COMPLETED)) {
+ itransfer->flags |= USBI_TRANSFER_IN_FLIGHT;
+ }
+ } else {
+ remove = 1;
+ }
+out:
+ usbi_mutex_unlock(&itransfer->flags_lock);
+ if (remove) {
+ libusb_unref_device(transfer->dev_handle->dev);
+ remove_from_flying_list(itransfer);
+ }
+ usbi_mutex_unlock(&itransfer->lock);
+ return r;
+}
+
+/** \ingroup asyncio
+ * Asynchronously cancel a previously submitted transfer.
+ * This function returns immediately, but this does not indicate cancellation
+ * is complete. Your callback function will be invoked at some later time
+ * with a transfer status of
+ * \ref libusb_transfer_status::LIBUSB_TRANSFER_CANCELLED
+ * "LIBUSB_TRANSFER_CANCELLED."
+ *
+ * \param transfer the transfer to cancel
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_NOT_FOUND if the transfer is not in progress,
+ * already complete, or already cancelled.
+ * \returns a LIBUSB_ERROR code on failure
+ */
+int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer)
+{
+ struct usbi_transfer *itransfer =
+ LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
+ int r;
+
+ usbi_dbg("transfer %p", transfer );
+ usbi_mutex_lock(&itransfer->lock);
+ usbi_mutex_lock(&itransfer->flags_lock);
+ if (!(itransfer->flags & USBI_TRANSFER_IN_FLIGHT)
+ || (itransfer->flags & USBI_TRANSFER_CANCELLING)) {
+ r = LIBUSB_ERROR_NOT_FOUND;
+ goto out;
+ }
+ r = usbi_backend->cancel_transfer(itransfer);
+ if (r < 0) {
+ if (r != LIBUSB_ERROR_NOT_FOUND &&
+ r != LIBUSB_ERROR_NO_DEVICE)
+ usbi_err(TRANSFER_CTX(transfer),
+ "cancel transfer failed error %d", r);
+ else
+ usbi_dbg("cancel transfer failed error %d", r);
+
+ if (r == LIBUSB_ERROR_NO_DEVICE)
+ itransfer->flags |= USBI_TRANSFER_DEVICE_DISAPPEARED;
+ }
+
+ itransfer->flags |= USBI_TRANSFER_CANCELLING;
+
+out:
+ usbi_mutex_unlock(&itransfer->flags_lock);
+ usbi_mutex_unlock(&itransfer->lock);
+ return r;
+}
+
+/** \ingroup asyncio
+ * Set a transfers bulk stream id. Note users are advised to use
+ * libusb_fill_bulk_stream_transfer() instead of calling this function
+ * directly.
+ *
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
+ *
+ * \param transfer the transfer to set the stream id for
+ * \param stream_id the stream id to set
+ * \see libusb_alloc_streams()
+ */
+void API_EXPORTED libusb_transfer_set_stream_id(
+ struct libusb_transfer *transfer, uint32_t stream_id)
+{
+ struct usbi_transfer *itransfer =
+ LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
+
+ itransfer->stream_id = stream_id;
+}
+
+/** \ingroup asyncio
+ * Get a transfers bulk stream id.
+ *
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
+ *
+ * \param transfer the transfer to get the stream id for
+ * \returns the stream id for the transfer
+ */
+uint32_t API_EXPORTED libusb_transfer_get_stream_id(
+ struct libusb_transfer *transfer)
+{
+ struct usbi_transfer *itransfer =
+ LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
+
+ return itransfer->stream_id;
+}
+
+/* Handle completion of a transfer (completion might be an error condition).
+ * This will invoke the user-supplied callback function, which may end up
+ * freeing the transfer. Therefore you cannot use the transfer structure
+ * after calling this function, and you should free all backend-specific
+ * data before calling it.
+ * Do not call this function with the usbi_transfer lock held. User-specified
+ * callback functions may attempt to directly resubmit the transfer, which
+ * will attempt to take the lock. */
+int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
+ enum libusb_transfer_status status)
+{
+ struct libusb_transfer *transfer =
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
+ struct libusb_device_handle *handle = transfer->dev_handle;
+ uint8_t flags;
+ int r;
+
+ r = remove_from_flying_list(itransfer);
+ if (r < 0)
+ usbi_err(ITRANSFER_CTX(itransfer), "failed to set timer for next timeout, errno=%d", errno);
+
+ usbi_mutex_lock(&itransfer->flags_lock);
+ itransfer->flags &= ~USBI_TRANSFER_IN_FLIGHT;
+ itransfer->flags |= USBI_TRANSFER_COMPLETED;
+ usbi_mutex_unlock(&itransfer->flags_lock);
+
+ if (status == LIBUSB_TRANSFER_COMPLETED
+ && transfer->flags & LIBUSB_TRANSFER_SHORT_NOT_OK) {
+ int rqlen = transfer->length;
+ if (transfer->type == LIBUSB_TRANSFER_TYPE_CONTROL)
+ rqlen -= LIBUSB_CONTROL_SETUP_SIZE;
+ if (rqlen != itransfer->transferred) {
+ usbi_dbg("interpreting short transfer as error");
+ status = LIBUSB_TRANSFER_ERROR;
+ }
+ }
+
+ flags = transfer->flags;
+ transfer->status = status;
+ transfer->actual_length = itransfer->transferred;
+ usbi_dbg("transfer %p has callback %p", transfer, transfer->callback);
+ if (transfer->callback)
+ transfer->callback(transfer);
+ /* transfer might have been freed by the above call, do not use from
+ * this point. */
+ if (flags & LIBUSB_TRANSFER_FREE_TRANSFER)
+ libusb_free_transfer(transfer);
+ libusb_unref_device(handle->dev);
+ return r;
+}
+
+/* Similar to usbi_handle_transfer_completion() but exclusively for transfers
+ * that were asynchronously cancelled. The same concerns w.r.t. freeing of
+ * transfers exist here.
+ * Do not call this function with the usbi_transfer lock held. User-specified
+ * callback functions may attempt to directly resubmit the transfer, which
+ * will attempt to take the lock. */
+int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer)
+{
+ /* if the URB was cancelled due to timeout, report timeout to the user */
+ if (transfer->flags & USBI_TRANSFER_TIMED_OUT) {
+ usbi_dbg("detected timeout cancellation");
+ return usbi_handle_transfer_completion(transfer, LIBUSB_TRANSFER_TIMED_OUT);
+ }
+
+ /* otherwise its a normal async cancel */
+ return usbi_handle_transfer_completion(transfer, LIBUSB_TRANSFER_CANCELLED);
+}
+
+/* Add a completed transfer to the completed_transfers list of the
+ * context and signal the event. The backend's handle_transfer_completion()
+ * function will be called the next time an event handler runs. */
+void usbi_signal_transfer_completion(struct usbi_transfer *transfer)
+{
+ struct libusb_context *ctx = ITRANSFER_CTX(transfer);
+ int pending_events;
+
+ usbi_mutex_lock(&ctx->event_data_lock);
+ pending_events = usbi_pending_events(ctx);
+ list_add_tail(&transfer->completed_list, &ctx->completed_transfers);
+ if (!pending_events)
+ usbi_signal_event(ctx);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+}
+
+/** \ingroup poll
+ * Attempt to acquire the event handling lock. This lock is used to ensure that
+ * only one thread is monitoring libusb event sources at any one time.
+ *
+ * You only need to use this lock if you are developing an application
+ * which calls poll() or select() on libusb's file descriptors directly.
+ * If you stick to libusb's event handling loop functions (e.g.
+ * libusb_handle_events()) then you do not need to be concerned with this
+ * locking.
+ *
+ * While holding this lock, you are trusted to actually be handling events.
+ * If you are no longer handling events, you must call libusb_unlock_events()
+ * as soon as possible.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \returns 0 if the lock was obtained successfully
+ * \returns 1 if the lock was not obtained (i.e. another thread holds the lock)
+ * \ref mtasync
+ */
+int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
+{
+ int r;
+ unsigned int ru;
+ USBI_GET_CONTEXT(ctx);
+
+ /* is someone else waiting to close a device? if so, don't let this thread
+ * start event handling */
+ usbi_mutex_lock(&ctx->event_data_lock);
+ ru = ctx->device_close;
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ if (ru) {
+ usbi_dbg("someone else is closing a device");
+ return 1;
+ }
+
+ r = usbi_mutex_trylock(&ctx->events_lock);
+ if (r)
+ return 1;
+
+ ctx->event_handler_active = 1;
+ return 0;
+}
+
+/** \ingroup poll
+ * Acquire the event handling lock, blocking until successful acquisition if
+ * it is contended. This lock is used to ensure that only one thread is
+ * monitoring libusb event sources at any one time.
+ *
+ * You only need to use this lock if you are developing an application
+ * which calls poll() or select() on libusb's file descriptors directly.
+ * If you stick to libusb's event handling loop functions (e.g.
+ * libusb_handle_events()) then you do not need to be concerned with this
+ * locking.
+ *
+ * While holding this lock, you are trusted to actually be handling events.
+ * If you are no longer handling events, you must call libusb_unlock_events()
+ * as soon as possible.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \ref mtasync
+ */
+void API_EXPORTED libusb_lock_events(libusb_context *ctx)
+{
+ USBI_GET_CONTEXT(ctx);
+ usbi_mutex_lock(&ctx->events_lock);
+ ctx->event_handler_active = 1;
+}
+
+/** \ingroup poll
+ * Release the lock previously acquired with libusb_try_lock_events() or
+ * libusb_lock_events(). Releasing this lock will wake up any threads blocked
+ * on libusb_wait_for_event().
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \ref mtasync
+ */
+void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
+{
+ USBI_GET_CONTEXT(ctx);
+ ctx->event_handler_active = 0;
+ usbi_mutex_unlock(&ctx->events_lock);
+
+ /* FIXME: perhaps we should be a bit more efficient by not broadcasting
+ * the availability of the events lock when we are modifying pollfds
+ * (check ctx->device_close)? */
+ usbi_mutex_lock(&ctx->event_waiters_lock);
+ usbi_cond_broadcast(&ctx->event_waiters_cond);
+ usbi_mutex_unlock(&ctx->event_waiters_lock);
+}
+
+/** \ingroup poll
+ * Determine if it is still OK for this thread to be doing event handling.
+ *
+ * Sometimes, libusb needs to temporarily pause all event handlers, and this
+ * is the function you should use before polling file descriptors to see if
+ * this is the case.
+ *
+ * If this function instructs your thread to give up the events lock, you
+ * should just continue the usual logic that is documented in \ref mtasync.
+ * On the next iteration, your thread will fail to obtain the events lock,
+ * and will hence become an event waiter.
+ *
+ * This function should be called while the events lock is held: you don't
+ * need to worry about the results of this function if your thread is not
+ * the current event handler.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \returns 1 if event handling can start or continue
+ * \returns 0 if this thread must give up the events lock
+ * \ref fullstory "Multi-threaded I/O: the full story"
+ */
+int API_EXPORTED libusb_event_handling_ok(libusb_context *ctx)
+{
+ unsigned int r;
+ USBI_GET_CONTEXT(ctx);
+
+ /* is someone else waiting to close a device? if so, don't let this thread
+ * continue event handling */
+ usbi_mutex_lock(&ctx->event_data_lock);
+ r = ctx->device_close;
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ if (r) {
+ usbi_dbg("someone else is closing a device");
+ return 0;
+ }
+
+ return 1;
+}
+
+
+/** \ingroup poll
+ * Determine if an active thread is handling events (i.e. if anyone is holding
+ * the event handling lock).
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \returns 1 if a thread is handling events
+ * \returns 0 if there are no threads currently handling events
+ * \ref mtasync
+ */
+int API_EXPORTED libusb_event_handler_active(libusb_context *ctx)
+{
+ unsigned int r;
+ USBI_GET_CONTEXT(ctx);
+
+ /* is someone else waiting to close a device? if so, don't let this thread
+ * start event handling -- indicate that event handling is happening */
+ usbi_mutex_lock(&ctx->event_data_lock);
+ r = ctx->device_close;
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ if (r) {
+ usbi_dbg("someone else is closing a device");
+ return 1;
+ }
+
+ return ctx->event_handler_active;
+}
+
+/** \ingroup poll
+ * Acquire the event waiters lock. This lock is designed to be obtained under
+ * the situation where you want to be aware when events are completed, but
+ * some other thread is event handling so calling libusb_handle_events() is not
+ * allowed.
+ *
+ * You then obtain this lock, re-check that another thread is still handling
+ * events, then call libusb_wait_for_event().
+ *
+ * You only need to use this lock if you are developing an application
+ * which calls poll() or select() on libusb's file descriptors directly,
+ * and may potentially be handling events from 2 threads simultaenously.
+ * If you stick to libusb's event handling loop functions (e.g.
+ * libusb_handle_events()) then you do not need to be concerned with this
+ * locking.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \ref mtasync
+ */
+void API_EXPORTED libusb_lock_event_waiters(libusb_context *ctx)
+{
+ USBI_GET_CONTEXT(ctx);
+ usbi_mutex_lock(&ctx->event_waiters_lock);
+}
+
+/** \ingroup poll
+ * Release the event waiters lock.
+ * \param ctx the context to operate on, or NULL for the default context
+ * \ref mtasync
+ */
+void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
+{
+ USBI_GET_CONTEXT(ctx);
+ usbi_mutex_unlock(&ctx->event_waiters_lock);
+}
+
+/** \ingroup poll
+ * Wait for another thread to signal completion of an event. Must be called
+ * with the event waiters lock held, see libusb_lock_event_waiters().
+ *
+ * This function will block until any of the following conditions are met:
+ * -# The timeout expires
+ * -# A transfer completes
+ * -# A thread releases the event handling lock through libusb_unlock_events()
+ *
+ * Condition 1 is obvious. Condition 2 unblocks your thread after
+ * the callback for the transfer has completed. Condition 3 is important
+ * because it means that the thread that was previously handling events is no
+ * longer doing so, so if any events are to complete, another thread needs to
+ * step up and start event handling.
+ *
+ * This function releases the event waiters lock before putting your thread
+ * to sleep, and reacquires the lock as it is being woken up.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param tv maximum timeout for this blocking function. A NULL value
+ * indicates unlimited timeout.
+ * \returns 0 after a transfer completes or another thread stops event handling
+ * \returns 1 if the timeout expired
+ * \ref mtasync
+ */
+int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
+{
+ struct timespec timeout;
+ int r;
+
+ USBI_GET_CONTEXT(ctx);
+ if (tv == NULL) {
+ usbi_cond_wait(&ctx->event_waiters_cond, &ctx->event_waiters_lock);
+ return 0;
+ }
+
+ r = usbi_backend->clock_gettime(USBI_CLOCK_REALTIME, &timeout);
+ if (r < 0) {
+ usbi_err(ctx, "failed to read realtime clock, error %d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ timeout.tv_sec += tv->tv_sec;
+ timeout.tv_nsec += tv->tv_usec * 1000;
+ while (timeout.tv_nsec >= 1000000000) {
+ timeout.tv_nsec -= 1000000000;
+ timeout.tv_sec++;
+ }
+
+ r = usbi_cond_timedwait(&ctx->event_waiters_cond,
+ &ctx->event_waiters_lock, &timeout);
+ return (r == ETIMEDOUT);
+}
+
+static void handle_timeout(struct usbi_transfer *itransfer)
+{
+ struct libusb_transfer *transfer =
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
+ int r;
+
+ itransfer->flags |= USBI_TRANSFER_TIMEOUT_HANDLED;
+ r = libusb_cancel_transfer(transfer);
+ if (r == 0)
+ itransfer->flags |= USBI_TRANSFER_TIMED_OUT;
+ else
+ usbi_warn(TRANSFER_CTX(transfer),
+ "async cancel failed %d errno=%d", r, errno);
+}
+
+static int handle_timeouts_locked(struct libusb_context *ctx)
+{
+ int r;
+ struct timespec systime_ts;
+ struct timeval systime;
+ struct usbi_transfer *transfer;
+
+ if (list_empty(&ctx->flying_transfers))
+ return 0;
+
+ /* get current time */
+ r = usbi_backend->clock_gettime(USBI_CLOCK_MONOTONIC, &systime_ts);
+ if (r < 0)
+ return r;
+
+ TIMESPEC_TO_TIMEVAL(&systime, &systime_ts);
+
+ /* iterate through flying transfers list, finding all transfers that
+ * have expired timeouts */
+ list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
+ struct timeval *cur_tv = &transfer->timeout;
+
+ /* if we've reached transfers of infinite timeout, we're all done */
+ if (!timerisset(cur_tv))
+ return 0;
+
+ /* ignore timeouts we've already handled */
+ if (transfer->flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))
+ continue;
+
+ /* if transfer has non-expired timeout, nothing more to do */
+ if ((cur_tv->tv_sec > systime.tv_sec) ||
+ (cur_tv->tv_sec == systime.tv_sec &&
+ cur_tv->tv_usec > systime.tv_usec))
+ return 0;
+
+ /* otherwise, we've got an expired timeout to handle */
+ handle_timeout(transfer);
+ }
+ return 0;
+}
+
+static int handle_timeouts(struct libusb_context *ctx)
+{
+ int r;
+ USBI_GET_CONTEXT(ctx);
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
+ r = handle_timeouts_locked(ctx);
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
+ return r;
+}
+
+#ifdef USBI_TIMERFD_AVAILABLE
+static int handle_timerfd_trigger(struct libusb_context *ctx)
+{
+ int r;
+
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
+
+ /* process the timeout that just happened */
+ r = handle_timeouts_locked(ctx);
+ if (r < 0)
+ goto out;
+
+ /* arm for next timeout*/
+ r = arm_timerfd_for_next_timeout(ctx);
+
+out:
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
+ return r;
+}
+#endif
+
+/* do the actual event handling. assumes that no other thread is concurrently
+ * doing the same thing. */
+static int handle_events(struct libusb_context *ctx, struct timeval *tv)
+{
+ int r;
+ struct usbi_pollfd *ipollfd;
+ POLL_NFDS_TYPE nfds = 0;
+ POLL_NFDS_TYPE internal_nfds;
+ struct pollfd *fds = NULL;
+ int i = -1;
+ int timeout_ms;
+ int special_event;
+
+ /* prevent attempts to recursively handle events (e.g. calling into
+ * libusb_handle_events() from within a hotplug or transfer callback) */
+ if (usbi_handling_events(ctx))
+ return LIBUSB_ERROR_BUSY;
+ usbi_start_event_handling(ctx);
+
+ /* there are certain fds that libusb uses internally, currently:
+ *
+ * 1) event pipe
+ * 2) timerfd
+ *
+ * the backend will never need to attempt to handle events on these fds, so
+ * we determine how many fds are in use internally for this context and when
+ * handle_events() is called in the backend, the pollfd list and count will
+ * be adjusted to skip over these internal fds */
+ if (usbi_using_timerfd(ctx))
+ internal_nfds = 2;
+ else
+ internal_nfds = 1;
+
+ /* only reallocate the poll fds when the list of poll fds has been modified
+ * since the last poll, otherwise reuse them to save the additional overhead */
+ usbi_mutex_lock(&ctx->event_data_lock);
+ if (ctx->pollfds_modified) {
+ usbi_dbg("poll fds modified, reallocating");
+
+ if (ctx->pollfds) {
+ free(ctx->pollfds);
+ ctx->pollfds = NULL;
+ }
+
+ /* sanity check - it is invalid for a context to have fewer than the
+ * required internal fds (memory corruption?) */
+ assert(ctx->pollfds_cnt >= internal_nfds);
+
+ ctx->pollfds = calloc(ctx->pollfds_cnt, sizeof(*ctx->pollfds));
+ if (!ctx->pollfds) {
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ r = LIBUSB_ERROR_NO_MEM;
+ goto done;
+ }
+
+ list_for_each_entry(ipollfd, &ctx->ipollfds, list, struct usbi_pollfd) {
+ struct libusb_pollfd *pollfd = &ipollfd->pollfd;
+ i++;
+ ctx->pollfds[i].fd = pollfd->fd;
+ ctx->pollfds[i].events = pollfd->events;
+ }
+
+ /* reset the flag now that we have the updated list */
+ ctx->pollfds_modified = 0;
+
+ /* if no further pending events, clear the event pipe so that we do
+ * not immediately return from poll */
+ if (!usbi_pending_events(ctx))
+ usbi_clear_event(ctx);
+ }
+ fds = ctx->pollfds;
+ nfds = ctx->pollfds_cnt;
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ timeout_ms = (int)(tv->tv_sec * 1000) + (tv->tv_usec / 1000);
+
+ /* round up to next millisecond */
+ if (tv->tv_usec % 1000)
+ timeout_ms++;
+
+redo_poll:
+ usbi_dbg("poll() %d fds with timeout in %dms", nfds, timeout_ms);
+ r = usbi_poll(fds, nfds, timeout_ms);
+ usbi_dbg("poll() returned %d", r);
+ if (r == 0) {
+ r = handle_timeouts(ctx);
+ goto done;
+ }
+ else if (r == -1 && errno == EINTR) {
+ r = LIBUSB_ERROR_INTERRUPTED;
+ goto done;
+ }
+ else if (r < 0) {
+ usbi_err(ctx, "poll failed %d err=%d", r, errno);
+ r = LIBUSB_ERROR_IO;
+ goto done;
+ }
+
+ special_event = 0;
+
+ /* fds[0] is always the event pipe */
+ if (fds[0].revents) {
+ libusb_hotplug_message *message = NULL;
+ struct usbi_transfer *itransfer;
+ int ret = 0;
+
+ usbi_dbg("caught a fish on the event pipe");
+
+ /* take the the event data lock while processing events */
+ usbi_mutex_lock(&ctx->event_data_lock);
+
+ /* check if someone added a new poll fd */
+ if (ctx->pollfds_modified)
+ usbi_dbg("someone updated the poll fds");
+
+ /* check if someone is closing a device */
+ if (ctx->device_close)
+ usbi_dbg("someone is closing a device");
+
+ /* check for any pending hotplug messages */
+ if (!list_empty(&ctx->hotplug_msgs)) {
+ usbi_dbg("hotplug message received");
+ special_event = 1;
+ message = list_first_entry(&ctx->hotplug_msgs, libusb_hotplug_message, list);
+ list_del(&message->list);
+ }
+
+ /* complete any pending transfers */
+ while (ret == 0 && !list_empty(&ctx->completed_transfers)) {
+ itransfer = list_first_entry(&ctx->completed_transfers, struct usbi_transfer, completed_list);
+ list_del(&itransfer->completed_list);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ ret = usbi_backend->handle_transfer_completion(itransfer);
+ if (ret)
+ usbi_err(ctx, "backend handle_transfer_completion failed with error %d", ret);
+ usbi_mutex_lock(&ctx->event_data_lock);
+ }
+
+ /* if no further pending events, clear the event pipe */
+ if (!usbi_pending_events(ctx))
+ usbi_clear_event(ctx);
+
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ /* process the hotplug message, if any */
+ if (message) {
+ usbi_hotplug_match(ctx, message->device, message->event);
+
+ /* the device left, dereference the device */
+ if (LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT == message->event)
+ libusb_unref_device(message->device);
+
+ free(message);
+ }
+
+ if (ret) {
+ /* return error code */
+ r = ret;
+ goto done;
+ }
+
+ if (0 == --r)
+ goto handled;
+ }
+
+#ifdef USBI_TIMERFD_AVAILABLE
+ /* on timerfd configurations, fds[1] is the timerfd */
+ if (usbi_using_timerfd(ctx) && fds[1].revents) {
+ /* timerfd indicates that a timeout has expired */
+ int ret;
+ usbi_dbg("timerfd triggered");
+ special_event = 1;
+
+ ret = handle_timerfd_trigger(ctx);
+ if (ret < 0) {
+ /* return error code */
+ r = ret;
+ goto done;
+ }
+
+ if (0 == --r)
+ goto handled;
+ }
+#endif
+
+ r = usbi_backend->handle_events(ctx, fds + internal_nfds, nfds - internal_nfds, r);
+ if (r)
+ usbi_err(ctx, "backend handle_events failed with error %d", r);
+
+handled:
+ if (r == 0 && special_event) {
+ timeout_ms = 0;
+ goto redo_poll;
+ }
+
+done:
+ usbi_end_event_handling(ctx);
+ return r;
+}
+
+/* returns the smallest of:
+ * 1. timeout of next URB
+ * 2. user-supplied timeout
+ * returns 1 if there is an already-expired timeout, otherwise returns 0
+ * and populates out
+ */
+static int get_next_timeout(libusb_context *ctx, struct timeval *tv,
+ struct timeval *out)
+{
+ struct timeval timeout;
+ int r = libusb_get_next_timeout(ctx, &timeout);
+ if (r) {
+ /* timeout already expired? */
+ if (!timerisset(&timeout))
+ return 1;
+
+ /* choose the smallest of next URB timeout or user specified timeout */
+ if (timercmp(&timeout, tv, <))
+ *out = timeout;
+ else
+ *out = *tv;
+ } else {
+ *out = *tv;
+ }
+ return 0;
+}
+
+/** \ingroup poll
+ * Handle any pending events.
+ *
+ * libusb determines "pending events" by checking if any timeouts have expired
+ * and by checking the set of file descriptors for activity.
+ *
+ * If a zero timeval is passed, this function will handle any already-pending
+ * events and then immediately return in non-blocking style.
+ *
+ * If a non-zero timeval is passed and no events are currently pending, this
+ * function will block waiting for events to handle up until the specified
+ * timeout. If an event arrives or a signal is raised, this function will
+ * return early.
+ *
+ * If the parameter completed is not NULL then after obtaining the event
+ * handling lock this function will return immediately if the integer
+ * pointed to is not 0. This allows for race free waiting for the completion
+ * of a specific transfer.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param tv the maximum time to block waiting for events, or an all zero
+ * timeval struct for non-blocking mode
+ * \param completed pointer to completion integer to check, or NULL
+ * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ * \ref mtasync
+ */
+int API_EXPORTED libusb_handle_events_timeout_completed(libusb_context *ctx,
+ struct timeval *tv, int *completed)
+{
+ int r;
+ struct timeval poll_timeout;
+
+ USBI_GET_CONTEXT(ctx);
+ r = get_next_timeout(ctx, tv, &poll_timeout);
+ if (r) {
+ /* timeout already expired */
+ return handle_timeouts(ctx);
+ }
+
+retry:
+ if (libusb_try_lock_events(ctx) == 0) {
+ if (completed == NULL || !*completed) {
+ /* we obtained the event lock: do our own event handling */
+ usbi_dbg("doing our own event handling");
+ r = handle_events(ctx, &poll_timeout);
+ }
+ libusb_unlock_events(ctx);
+ return r;
+ }
+
+ /* another thread is doing event handling. wait for thread events that
+ * notify event completion. */
+ libusb_lock_event_waiters(ctx);
+
+ if (completed && *completed)
+ goto already_done;
+
+ if (!libusb_event_handler_active(ctx)) {
+ /* we hit a race: whoever was event handling earlier finished in the
+ * time it took us to reach this point. try the cycle again. */
+ libusb_unlock_event_waiters(ctx);
+ usbi_dbg("event handler was active but went away, retrying");
+ goto retry;
+ }
+
+ usbi_dbg("another thread is doing event handling");
+ r = libusb_wait_for_event(ctx, &poll_timeout);
+
+already_done:
+ libusb_unlock_event_waiters(ctx);
+
+ if (r < 0)
+ return r;
+ else if (r == 1)
+ return handle_timeouts(ctx);
+ else
+ return 0;
+}
+
+/** \ingroup poll
+ * Handle any pending events
+ *
+ * Like libusb_handle_events_timeout_completed(), but without the completed
+ * parameter, calling this function is equivalent to calling
+ * libusb_handle_events_timeout_completed() with a NULL completed parameter.
+ *
+ * This function is kept primarily for backwards compatibility.
+ * All new code should call libusb_handle_events_completed() or
+ * libusb_handle_events_timeout_completed() to avoid race conditions.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param tv the maximum time to block waiting for events, or an all zero
+ * timeval struct for non-blocking mode
+ * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ */
+int API_EXPORTED libusb_handle_events_timeout(libusb_context *ctx,
+ struct timeval *tv)
+{
+ return libusb_handle_events_timeout_completed(ctx, tv, NULL);
+}
+
+/** \ingroup poll
+ * Handle any pending events in blocking mode. There is currently a timeout
+ * hardcoded at 60 seconds but we plan to make it unlimited in future. For
+ * finer control over whether this function is blocking or non-blocking, or
+ * for control over the timeout, use libusb_handle_events_timeout_completed()
+ * instead.
+ *
+ * This function is kept primarily for backwards compatibility.
+ * All new code should call libusb_handle_events_completed() or
+ * libusb_handle_events_timeout_completed() to avoid race conditions.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ */
+int API_EXPORTED libusb_handle_events(libusb_context *ctx)
+{
+ struct timeval tv;
+ tv.tv_sec = 60;
+ tv.tv_usec = 0;
+ return libusb_handle_events_timeout_completed(ctx, &tv, NULL);
+}
+
+/** \ingroup poll
+ * Handle any pending events in blocking mode.
+ *
+ * Like libusb_handle_events(), with the addition of a completed parameter
+ * to allow for race free waiting for the completion of a specific transfer.
+ *
+ * See libusb_handle_events_timeout_completed() for details on the completed
+ * parameter.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param completed pointer to completion integer to check, or NULL
+ * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ * \ref mtasync
+ */
+int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx,
+ int *completed)
+{
+ struct timeval tv;
+ tv.tv_sec = 60;
+ tv.tv_usec = 0;
+ return libusb_handle_events_timeout_completed(ctx, &tv, completed);
+}
+
+/** \ingroup poll
+ * Handle any pending events by polling file descriptors, without checking if
+ * any other threads are already doing so. Must be called with the event lock
+ * held, see libusb_lock_events().
+ *
+ * This function is designed to be called under the situation where you have
+ * taken the event lock and are calling poll()/select() directly on libusb's
+ * file descriptors (as opposed to using libusb_handle_events() or similar).
+ * You detect events on libusb's descriptors, so you then call this function
+ * with a zero timeout value (while still holding the event lock).
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param tv the maximum time to block waiting for events, or zero for
+ * non-blocking mode
+ * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ * \ref mtasync
+ */
+int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
+ struct timeval *tv)
+{
+ int r;
+ struct timeval poll_timeout;
+
+ USBI_GET_CONTEXT(ctx);
+ r = get_next_timeout(ctx, tv, &poll_timeout);
+ if (r) {
+ /* timeout already expired */
+ return handle_timeouts(ctx);
+ }
+
+ return handle_events(ctx, &poll_timeout);
+}
+
+/** \ingroup poll
+ * Determines whether your application must apply special timing considerations
+ * when monitoring libusb's file descriptors.
+ *
+ * This function is only useful for applications which retrieve and poll
+ * libusb's file descriptors in their own main loop (\ref pollmain).
+ *
+ * Ordinarily, libusb's event handler needs to be called into at specific
+ * moments in time (in addition to times when there is activity on the file
+ * descriptor set). The usual approach is to use libusb_get_next_timeout()
+ * to learn about when the next timeout occurs, and to adjust your
+ * poll()/select() timeout accordingly so that you can make a call into the
+ * library at that time.
+ *
+ * Some platforms supported by libusb do not come with this baggage - any
+ * events relevant to timing will be represented by activity on the file
+ * descriptor set, and libusb_get_next_timeout() will always return 0.
+ * This function allows you to detect whether you are running on such a
+ * platform.
+ *
+ * Since v1.0.5.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \returns 0 if you must call into libusb at times determined by
+ * libusb_get_next_timeout(), or 1 if all timeout events are handled internally
+ * or through regular activity on the file descriptors.
+ * \ref pollmain "Polling libusb file descriptors for event handling"
+ */
+int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
+{
+#if defined(USBI_TIMERFD_AVAILABLE)
+ USBI_GET_CONTEXT(ctx);
+ return usbi_using_timerfd(ctx);
+#else
+ UNUSED(ctx);
+ return 0;
+#endif
+}
+
+/** \ingroup poll
+ * Determine the next internal timeout that libusb needs to handle. You only
+ * need to use this function if you are calling poll() or select() or similar
+ * on libusb's file descriptors yourself - you do not need to use it if you
+ * are calling libusb_handle_events() or a variant directly.
+ *
+ * You should call this function in your main loop in order to determine how
+ * long to wait for select() or poll() to return results. libusb needs to be
+ * called into at this timeout, so you should use it as an upper bound on
+ * your select() or poll() call.
+ *
+ * When the timeout has expired, call into libusb_handle_events_timeout()
+ * (perhaps in non-blocking mode) so that libusb can handle the timeout.
+ *
+ * This function may return 1 (success) and an all-zero timeval. If this is
+ * the case, it indicates that libusb has a timeout that has already expired
+ * so you should call libusb_handle_events_timeout() or similar immediately.
+ * A return code of 0 indicates that there are no pending timeouts.
+ *
+ * On some platforms, this function will always returns 0 (no pending
+ * timeouts). See \ref polltime.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param tv output location for a relative time against the current
+ * clock in which libusb must be called into in order to process timeout events
+ * \returns 0 if there are no pending timeouts, 1 if a timeout was returned,
+ * or LIBUSB_ERROR_OTHER on failure
+ */
+int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx,
+ struct timeval *tv)
+{
+ struct usbi_transfer *transfer;
+ struct timespec cur_ts;
+ struct timeval cur_tv;
+ struct timeval next_timeout = { 0, 0 };
+ int r;
+
+ USBI_GET_CONTEXT(ctx);
+ if (usbi_using_timerfd(ctx))
+ return 0;
+
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
+ if (list_empty(&ctx->flying_transfers)) {
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
+ usbi_dbg("no URBs, no timeout!");
+ return 0;
+ }
+
+ /* find next transfer which hasn't already been processed as timed out */
+ list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
+ if (transfer->flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))
+ continue;
+
+ /* if we've reached transfers of infinte timeout, we're done looking */
+ if (!timerisset(&transfer->timeout))
+ break;
+
+ next_timeout = transfer->timeout;
+ break;
+ }
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
+
+ if (!timerisset(&next_timeout)) {
+ usbi_dbg("no URB with timeout or all handled by OS; no timeout!");
+ return 0;
+ }
+
+ r = usbi_backend->clock_gettime(USBI_CLOCK_MONOTONIC, &cur_ts);
+ if (r < 0) {
+ usbi_err(ctx, "failed to read monotonic clock, errno=%d", errno);
+ return 0;
+ }
+ TIMESPEC_TO_TIMEVAL(&cur_tv, &cur_ts);
+
+ if (!timercmp(&cur_tv, &next_timeout, <)) {
+ usbi_dbg("first timeout already expired");
+ timerclear(tv);
+ } else {
+ timersub(&next_timeout, &cur_tv, tv);
+ usbi_dbg("next timeout in %d.%06ds", tv->tv_sec, tv->tv_usec);
+ }
+
+ return 1;
+}
+
+/** \ingroup poll
+ * Register notification functions for file descriptor additions/removals.
+ * These functions will be invoked for every new or removed file descriptor
+ * that libusb uses as an event source.
+ *
+ * To remove notifiers, pass NULL values for the function pointers.
+ *
+ * Note that file descriptors may have been added even before you register
+ * these notifiers (e.g. at libusb_init() time).
+ *
+ * Additionally, note that the removal notifier may be called during
+ * libusb_exit() (e.g. when it is closing file descriptors that were opened
+ * and added to the poll set at libusb_init() time). If you don't want this,
+ * remove the notifiers immediately before calling libusb_exit().
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \param added_cb pointer to function for addition notifications
+ * \param removed_cb pointer to function for removal notifications
+ * \param user_data User data to be passed back to callbacks (useful for
+ * passing context information)
+ */
+void API_EXPORTED libusb_set_pollfd_notifiers(libusb_context *ctx,
+ libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
+ void *user_data)
+{
+ USBI_GET_CONTEXT(ctx);
+ ctx->fd_added_cb = added_cb;
+ ctx->fd_removed_cb = removed_cb;
+ ctx->fd_cb_user_data = user_data;
+}
+
+/*
+ * Interrupt the iteration of the event handling thread, so that it picks
+ * up the fd change. Callers of this function must hold the event_data_lock.
+ */
+static void usbi_fd_notification(struct libusb_context *ctx)
+{
+ int pending_events;
+
+ /* Record that there is a new poll fd.
+ * Only signal an event if there are no prior pending events. */
+ pending_events = usbi_pending_events(ctx);
+ ctx->pollfds_modified = 1;
+ if (!pending_events)
+ usbi_signal_event(ctx);
+}
+
+/* Add a file descriptor to the list of file descriptors to be monitored.
+ * events should be specified as a bitmask of events passed to poll(), e.g.
+ * POLLIN and/or POLLOUT. */
+int usbi_add_pollfd(struct libusb_context *ctx, int fd, short events)
+{
+ struct usbi_pollfd *ipollfd = malloc(sizeof(*ipollfd));
+ if (!ipollfd)
+ return LIBUSB_ERROR_NO_MEM;
+
+ usbi_dbg("add fd %d events %d", fd, events);
+ ipollfd->pollfd.fd = fd;
+ ipollfd->pollfd.events = events;
+ usbi_mutex_lock(&ctx->event_data_lock);
+ list_add_tail(&ipollfd->list, &ctx->ipollfds);
+ ctx->pollfds_cnt++;
+ usbi_fd_notification(ctx);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ if (ctx->fd_added_cb)
+ ctx->fd_added_cb(fd, events, ctx->fd_cb_user_data);
+ return 0;
+}
+
+/* Remove a file descriptor from the list of file descriptors to be polled. */
+void usbi_remove_pollfd(struct libusb_context *ctx, int fd)
+{
+ struct usbi_pollfd *ipollfd;
+ int found = 0;
+
+ usbi_dbg("remove fd %d", fd);
+ usbi_mutex_lock(&ctx->event_data_lock);
+ list_for_each_entry(ipollfd, &ctx->ipollfds, list, struct usbi_pollfd)
+ if (ipollfd->pollfd.fd == fd) {
+ found = 1;
+ break;
+ }
+
+ if (!found) {
+ usbi_dbg("couldn't find fd %d to remove", fd);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ return;
+ }
+
+ list_del(&ipollfd->list);
+ ctx->pollfds_cnt--;
+ usbi_fd_notification(ctx);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ free(ipollfd);
+ if (ctx->fd_removed_cb)
+ ctx->fd_removed_cb(fd, ctx->fd_cb_user_data);
+}
+
+/** \ingroup poll
+ * Retrieve a list of file descriptors that should be polled by your main loop
+ * as libusb event sources.
+ *
+ * The returned list is NULL-terminated and should be freed with libusb_free_pollfds()
+ * when done. The actual list contents must not be touched.
+ *
+ * As file descriptors are a Unix-specific concept, this function is not
+ * available on Windows and will always return NULL.
+ *
+ * \param ctx the context to operate on, or NULL for the default context
+ * \returns a NULL-terminated list of libusb_pollfd structures
+ * \returns NULL on error
+ * \returns NULL on platforms where the functionality is not available
+ */
+DEFAULT_VISIBILITY
+const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
+ libusb_context *ctx)
+{
+#ifndef OS_WINDOWS
+ struct libusb_pollfd **ret = NULL;
+ struct usbi_pollfd *ipollfd;
+ size_t i = 0;
+ USBI_GET_CONTEXT(ctx);
+
+ usbi_mutex_lock(&ctx->event_data_lock);
+
+ ret = calloc(ctx->pollfds_cnt + 1, sizeof(struct libusb_pollfd *));
+ if (!ret)
+ goto out;
+
+ list_for_each_entry(ipollfd, &ctx->ipollfds, list, struct usbi_pollfd)
+ ret[i++] = (struct libusb_pollfd *) ipollfd;
+ ret[ctx->pollfds_cnt] = NULL;
+
+out:
+ usbi_mutex_unlock(&ctx->event_data_lock);
+ return (const struct libusb_pollfd **) ret;
+#else
+ usbi_err(ctx, "external polling of libusb's internal descriptors "\
+ "is not yet supported on Windows platforms");
+ return NULL;
+#endif
+}
+
+/** \ingroup poll
+ * Free a list of libusb_pollfd structures. This should be called for all
+ * pollfd lists allocated with libusb_get_pollfds().
+ *
+ * Since version 1.0.20, \ref LIBUSB_API_VERSION >= 0x01000104
+ *
+ * It is legal to call this function with a NULL pollfd list. In this case,
+ * the function will simply return safely.
+ *
+ * \param pollfds the list of libusb_pollfd structures to free
+ */
+void API_EXPORTED libusb_free_pollfds(const struct libusb_pollfd **pollfds)
+{
+ if (!pollfds)
+ return;
+
+ free((void *)pollfds);
+}
+
+/* Backends may call this from handle_events to report disconnection of a
+ * device. This function ensures transfers get cancelled appropriately.
+ * Callers of this function must hold the events_lock.
+ */
+void usbi_handle_disconnect(struct libusb_device_handle *handle)
+{
+ struct usbi_transfer *cur;
+ struct usbi_transfer *to_cancel;
+
+ usbi_dbg("device %d.%d",
+ handle->dev->bus_number, handle->dev->device_address);
+
+ /* terminate all pending transfers with the LIBUSB_TRANSFER_NO_DEVICE
+ * status code.
+ *
+ * when we find a transfer for this device on the list, there are two
+ * possible scenarios:
+ * 1. the transfer is currently in-flight, in which case we terminate the
+ * transfer here
+ * 2. the transfer is not in-flight (or is but hasn't been marked as such),
+ * in which case we record that the device disappeared and this will be
+ * handled by libusb_submit_transfer()
+ */
+
+ while (1) {
+ to_cancel = NULL;
+ usbi_mutex_lock(&HANDLE_CTX(handle)->flying_transfers_lock);
+ list_for_each_entry(cur, &HANDLE_CTX(handle)->flying_transfers, list, struct usbi_transfer)
+ if (USBI_TRANSFER_TO_LIBUSB_TRANSFER(cur)->dev_handle == handle) {
+ usbi_mutex_lock(&cur->flags_lock);
+ if (cur->flags & USBI_TRANSFER_IN_FLIGHT)
+ to_cancel = cur;
+ else
+ cur->flags |= USBI_TRANSFER_DEVICE_DISAPPEARED;
+ usbi_mutex_unlock(&cur->flags_lock);
+
+ if (to_cancel)
+ break;
+ }
+ usbi_mutex_unlock(&HANDLE_CTX(handle)->flying_transfers_lock);
+
+ if (!to_cancel)
+ break;
+
+ usbi_dbg("cancelling transfer %p from disconnect",
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(to_cancel));
+
+ usbi_mutex_lock(&to_cancel->lock);
+ usbi_backend->clear_transfer_priv(to_cancel);
+ usbi_mutex_unlock(&to_cancel->lock);
+ usbi_handle_transfer_completion(to_cancel, LIBUSB_TRANSFER_NO_DEVICE);
+ }
+
+}
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/io.c.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/io.c.REMOVED.git-id
deleted file mode 100644
index b3de3e70..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/io.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-01cf5bec2acd5b66fa8a0e5055c1f058c71ca9a1
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/libusb.h b/Desktop_Interface/build_android/libusb-martin-kuldeep/libusb.h
new file mode 100644
index 00000000..6549d2eb
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/libusb.h
@@ -0,0 +1,2002 @@
+/*
+ * Public libusb header file
+ * Copyright © 2001 Johannes Erdfelt
+ * Copyright © 2007-2008 Daniel Drake
+ * Copyright © 2012 Pete Batard
+ * Copyright © 2012 Nathan Hjelm
+ * Copyright © 2013-2016 Martin Marinov
+ * For more information, please visit: http://libusb.info
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LIBUSB_H
+#define LIBUSB_H
+
+#ifdef _MSC_VER
+/* on MS environments, the inline keyword is available in C++ only */
+#if !defined(__cplusplus)
+#define inline __inline
+#endif
+/* ssize_t is also not available (copy/paste from MinGW) */
+#ifndef _SSIZE_T_DEFINED
+#define _SSIZE_T_DEFINED
+#undef ssize_t
+#ifdef _WIN64
+ typedef __int64 ssize_t;
+#else
+ typedef int ssize_t;
+#endif /* _WIN64 */
+#endif /* _SSIZE_T_DEFINED */
+#endif /* _MSC_VER */
+
+/* stdint.h is not available on older MSVC */
+#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+#else
+#include
+#endif
+
+#if !defined(_WIN32_WCE)
+#include
+#endif
+
+#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__HAIKU__)
+#include
+#endif
+
+#include
+#include
+
+/* 'interface' might be defined as a macro on Windows, so we need to
+ * undefine it so as not to break the current libusb API, because
+ * libusb_config_descriptor has an 'interface' member
+ * As this can be problematic if you include windows.h after libusb.h
+ * in your sources, we force windows.h to be included first. */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+#include
+#if defined(interface)
+#undef interface
+#endif
+#if !defined(__CYGWIN__)
+#include
+#endif
+#endif
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define LIBUSB_DEPRECATED_FOR(f) \
+ __attribute__((deprecated("Use " #f " instead")))
+#else
+#define LIBUSB_DEPRECATED_FOR(f)
+#endif /* __GNUC__ */
+
+/** \def LIBUSB_CALL
+ * \ingroup misc
+ * libusb's Windows calling convention.
+ *
+ * Under Windows, the selection of available compilers and configurations
+ * means that, unlike other platforms, there is not one true calling
+ * convention (calling convention: the manner in which parameters are
+ * passed to functions in the generated assembly code).
+ *
+ * Matching the Windows API itself, libusb uses the WINAPI convention (which
+ * translates to the stdcall convention) and guarantees that the
+ * library is compiled in this way. The public header file also includes
+ * appropriate annotations so that your own software will use the right
+ * convention, even if another convention is being used by default within
+ * your codebase.
+ *
+ * The one consideration that you must apply in your software is to mark
+ * all functions which you use as libusb callbacks with this LIBUSB_CALL
+ * annotation, so that they too get compiled for the correct calling
+ * convention.
+ *
+ * On non-Windows operating systems, this macro is defined as nothing. This
+ * means that you can apply it to your code without worrying about
+ * cross-platform compatibility.
+ */
+/* LIBUSB_CALL must be defined on both definition and declaration of libusb
+ * functions. You'd think that declaration would be enough, but cygwin will
+ * complain about conflicting types unless both are marked this way.
+ * The placement of this macro is important too; it must appear after the
+ * return type, before the function name. See internal documentation for
+ * API_EXPORTED.
+ */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+#define LIBUSB_CALL WINAPI
+#else
+#define LIBUSB_CALL
+#endif
+
+/** \def LIBUSB_API_VERSION
+ * \ingroup misc
+ * libusb's API version.
+ *
+ * Since version 1.0.13, to help with feature detection, libusb defines
+ * a LIBUSB_API_VERSION macro that gets increased every time there is a
+ * significant change to the API, such as the introduction of a new call,
+ * the definition of a new macro/enum member, or any other element that
+ * libusb applications may want to detect at compilation time.
+ *
+ * The macro is typically used in an application as follows:
+ * \code
+ * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234)
+ * // Use one of the newer features from the libusb API
+ * #endif
+ * \endcode
+ *
+ * Internally, LIBUSB_API_VERSION is defined as follows:
+ * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
+ */
+#define LIBUSB_API_VERSION 0x01000104
+
+/* The following is kept for compatibility, but will be deprecated in the future */
+#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup misc
+ * Convert a 16-bit value from host-endian to little-endian format. On
+ * little endian systems, this function does nothing. On big endian systems,
+ * the bytes are swapped.
+ * \param x the host-endian value to convert
+ * \returns the value in little-endian byte order
+ */
+static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
+{
+ union {
+ uint8_t b8[2];
+ uint16_t b16;
+ } _tmp;
+ _tmp.b8[1] = (uint8_t) (x >> 8);
+ _tmp.b8[0] = (uint8_t) (x & 0xff);
+ return _tmp.b16;
+}
+
+/** \def libusb_le16_to_cpu
+ * \ingroup misc
+ * Convert a 16-bit value from little-endian to host-endian format. On
+ * little endian systems, this function does nothing. On big endian systems,
+ * the bytes are swapped.
+ * \param x the little-endian value to convert
+ * \returns the value in host-endian byte order
+ */
+#define libusb_le16_to_cpu libusb_cpu_to_le16
+
+/* standard USB stuff */
+
+/** \ingroup desc
+ * Device and/or Interface Class codes */
+enum libusb_class_code {
+ /** In the context of a \ref libusb_device_descriptor "device descriptor",
+ * this bDeviceClass value indicates that each interface specifies its
+ * own class information and all interfaces operate independently.
+ */
+ LIBUSB_CLASS_PER_INTERFACE = 0,
+
+ /** Audio class */
+ LIBUSB_CLASS_AUDIO = 1,
+
+ /** Communications class */
+ LIBUSB_CLASS_COMM = 2,
+
+ /** Human Interface Device class */
+ LIBUSB_CLASS_HID = 3,
+
+ /** Physical */
+ LIBUSB_CLASS_PHYSICAL = 5,
+
+ /** Printer class */
+ LIBUSB_CLASS_PRINTER = 7,
+
+ /** Image class */
+ LIBUSB_CLASS_PTP = 6, /* legacy name from libusb-0.1 usb.h */
+ LIBUSB_CLASS_IMAGE = 6,
+
+ /** Mass storage class */
+ LIBUSB_CLASS_MASS_STORAGE = 8,
+
+ /** Hub class */
+ LIBUSB_CLASS_HUB = 9,
+
+ /** Data class */
+ LIBUSB_CLASS_DATA = 10,
+
+ /** Smart Card */
+ LIBUSB_CLASS_SMART_CARD = 0x0b,
+
+ /** Content Security */
+ LIBUSB_CLASS_CONTENT_SECURITY = 0x0d,
+
+ /** Video */
+ LIBUSB_CLASS_VIDEO = 0x0e,
+
+ /** Personal Healthcare */
+ LIBUSB_CLASS_PERSONAL_HEALTHCARE = 0x0f,
+
+ /** Diagnostic Device */
+ LIBUSB_CLASS_DIAGNOSTIC_DEVICE = 0xdc,
+
+ /** Wireless class */
+ LIBUSB_CLASS_WIRELESS = 0xe0,
+
+ /** Application class */
+ LIBUSB_CLASS_APPLICATION = 0xfe,
+
+ /** Class is vendor-specific */
+ LIBUSB_CLASS_VENDOR_SPEC = 0xff
+};
+
+/** \ingroup desc
+ * Descriptor types as defined by the USB specification. */
+enum libusb_descriptor_type {
+ /** Device descriptor. See libusb_device_descriptor. */
+ LIBUSB_DT_DEVICE = 0x01,
+
+ /** Configuration descriptor. See libusb_config_descriptor. */
+ LIBUSB_DT_CONFIG = 0x02,
+
+ /** String descriptor */
+ LIBUSB_DT_STRING = 0x03,
+
+ /** Interface descriptor. See libusb_interface_descriptor. */
+ LIBUSB_DT_INTERFACE = 0x04,
+
+ /** Endpoint descriptor. See libusb_endpoint_descriptor. */
+ LIBUSB_DT_ENDPOINT = 0x05,
+
+ /** BOS descriptor */
+ LIBUSB_DT_BOS = 0x0f,
+
+ /** Device Capability descriptor */
+ LIBUSB_DT_DEVICE_CAPABILITY = 0x10,
+
+ /** HID descriptor */
+ LIBUSB_DT_HID = 0x21,
+
+ /** HID report descriptor */
+ LIBUSB_DT_REPORT = 0x22,
+
+ /** Physical descriptor */
+ LIBUSB_DT_PHYSICAL = 0x23,
+
+ /** Hub descriptor */
+ LIBUSB_DT_HUB = 0x29,
+
+ /** SuperSpeed Hub descriptor */
+ LIBUSB_DT_SUPERSPEED_HUB = 0x2a,
+
+ /** SuperSpeed Endpoint Companion descriptor */
+ LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30
+};
+
+/* Descriptor sizes per descriptor type */
+#define LIBUSB_DT_DEVICE_SIZE 18
+#define LIBUSB_DT_CONFIG_SIZE 9
+#define LIBUSB_DT_INTERFACE_SIZE 9
+#define LIBUSB_DT_ENDPOINT_SIZE 7
+#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
+#define LIBUSB_DT_HUB_NONVAR_SIZE 7
+#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6
+#define LIBUSB_DT_BOS_SIZE 5
+#define LIBUSB_DT_DEVICE_CAPABILITY_SIZE 3
+
+/* BOS descriptor sizes */
+#define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7
+#define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10
+#define LIBUSB_BT_CONTAINER_ID_SIZE 20
+
+/* We unwrap the BOS => define its max size */
+#define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) +\
+ (LIBUSB_BT_USB_2_0_EXTENSION_SIZE) +\
+ (LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) +\
+ (LIBUSB_BT_CONTAINER_ID_SIZE))
+
+#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
+#define LIBUSB_ENDPOINT_DIR_MASK 0x80
+
+/** \ingroup desc
+ * Endpoint direction. Values for bit 7 of the
+ * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme.
+ */
+enum libusb_endpoint_direction {
+ /** In: device-to-host */
+ LIBUSB_ENDPOINT_IN = 0x80,
+
+ /** Out: host-to-device */
+ LIBUSB_ENDPOINT_OUT = 0x00
+};
+
+#define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
+
+/** \ingroup desc
+ * Endpoint transfer type. Values for bits 0:1 of the
+ * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field.
+ */
+enum libusb_transfer_type {
+ /** Control endpoint */
+ LIBUSB_TRANSFER_TYPE_CONTROL = 0,
+
+ /** Isochronous endpoint */
+ LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
+
+ /** Bulk endpoint */
+ LIBUSB_TRANSFER_TYPE_BULK = 2,
+
+ /** Interrupt endpoint */
+ LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
+
+ /** Stream endpoint */
+ LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
+};
+
+/** \ingroup misc
+ * Standard requests, as defined in table 9-5 of the USB 3.0 specifications */
+enum libusb_standard_request {
+ /** Request status of the specific recipient */
+ LIBUSB_REQUEST_GET_STATUS = 0x00,
+
+ /** Clear or disable a specific feature */
+ LIBUSB_REQUEST_CLEAR_FEATURE = 0x01,
+
+ /* 0x02 is reserved */
+
+ /** Set or enable a specific feature */
+ LIBUSB_REQUEST_SET_FEATURE = 0x03,
+
+ /* 0x04 is reserved */
+
+ /** Set device address for all future accesses */
+ LIBUSB_REQUEST_SET_ADDRESS = 0x05,
+
+ /** Get the specified descriptor */
+ LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06,
+
+ /** Used to update existing descriptors or add new descriptors */
+ LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07,
+
+ /** Get the current device configuration value */
+ LIBUSB_REQUEST_GET_CONFIGURATION = 0x08,
+
+ /** Set device configuration */
+ LIBUSB_REQUEST_SET_CONFIGURATION = 0x09,
+
+ /** Return the selected alternate setting for the specified interface */
+ LIBUSB_REQUEST_GET_INTERFACE = 0x0A,
+
+ /** Select an alternate interface for the specified interface */
+ LIBUSB_REQUEST_SET_INTERFACE = 0x0B,
+
+ /** Set then report an endpoint's synchronization frame */
+ LIBUSB_REQUEST_SYNCH_FRAME = 0x0C,
+
+ /** Sets both the U1 and U2 Exit Latency */
+ LIBUSB_REQUEST_SET_SEL = 0x30,
+
+ /** Delay from the time a host transmits a packet to the time it is
+ * received by the device. */
+ LIBUSB_SET_ISOCH_DELAY = 0x31,
+};
+
+/** \ingroup misc
+ * Request type bits of the
+ * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
+ * transfers. */
+enum libusb_request_type {
+ /** Standard */
+ LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5),
+
+ /** Class */
+ LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5),
+
+ /** Vendor */
+ LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5),
+
+ /** Reserved */
+ LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5)
+};
+
+/** \ingroup misc
+ * Recipient bits of the
+ * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
+ * transfers. Values 4 through 31 are reserved. */
+enum libusb_request_recipient {
+ /** Device */
+ LIBUSB_RECIPIENT_DEVICE = 0x00,
+
+ /** Interface */
+ LIBUSB_RECIPIENT_INTERFACE = 0x01,
+
+ /** Endpoint */
+ LIBUSB_RECIPIENT_ENDPOINT = 0x02,
+
+ /** Other */
+ LIBUSB_RECIPIENT_OTHER = 0x03,
+};
+
+#define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C
+
+/** \ingroup desc
+ * Synchronization type for isochronous endpoints. Values for bits 2:3 of the
+ * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
+ * libusb_endpoint_descriptor.
+ */
+enum libusb_iso_sync_type {
+ /** No synchronization */
+ LIBUSB_ISO_SYNC_TYPE_NONE = 0,
+
+ /** Asynchronous */
+ LIBUSB_ISO_SYNC_TYPE_ASYNC = 1,
+
+ /** Adaptive */
+ LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2,
+
+ /** Synchronous */
+ LIBUSB_ISO_SYNC_TYPE_SYNC = 3
+};
+
+#define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
+
+/** \ingroup desc
+ * Usage type for isochronous endpoints. Values for bits 4:5 of the
+ * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
+ * libusb_endpoint_descriptor.
+ */
+enum libusb_iso_usage_type {
+ /** Data endpoint */
+ LIBUSB_ISO_USAGE_TYPE_DATA = 0,
+
+ /** Feedback endpoint */
+ LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1,
+
+ /** Implicit feedback Data endpoint */
+ LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
+};
+
+/** \ingroup desc
+ * A structure representing the standard USB device descriptor. This
+ * descriptor is documented in section 9.6.1 of the USB 3.0 specification.
+ * All multiple-byte fields are represented in host-endian format.
+ */
+struct libusb_device_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE LIBUSB_DT_DEVICE in this
+ * context. */
+ uint8_t bDescriptorType;
+
+ /** USB specification release number in binary-coded decimal. A value of
+ * 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc. */
+ uint16_t bcdUSB;
+
+ /** USB-IF class code for the device. See \ref libusb_class_code. */
+ uint8_t bDeviceClass;
+
+ /** USB-IF subclass code for the device, qualified by the bDeviceClass
+ * value */
+ uint8_t bDeviceSubClass;
+
+ /** USB-IF protocol code for the device, qualified by the bDeviceClass and
+ * bDeviceSubClass values */
+ uint8_t bDeviceProtocol;
+
+ /** Maximum packet size for endpoint 0 */
+ uint8_t bMaxPacketSize0;
+
+ /** USB-IF vendor ID */
+ uint16_t idVendor;
+
+ /** USB-IF product ID */
+ uint16_t idProduct;
+
+ /** Device release number in binary-coded decimal */
+ uint16_t bcdDevice;
+
+ /** Index of string descriptor describing manufacturer */
+ uint8_t iManufacturer;
+
+ /** Index of string descriptor describing product */
+ uint8_t iProduct;
+
+ /** Index of string descriptor containing device serial number */
+ uint8_t iSerialNumber;
+
+ /** Number of possible configurations */
+ uint8_t bNumConfigurations;
+};
+
+/** \ingroup desc
+ * A structure representing the standard USB endpoint descriptor. This
+ * descriptor is documented in section 9.6.6 of the USB 3.0 specification.
+ * All multiple-byte fields are represented in host-endian format.
+ */
+struct libusb_endpoint_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_ENDPOINT LIBUSB_DT_ENDPOINT in
+ * this context. */
+ uint8_t bDescriptorType;
+
+ /** The address of the endpoint described by this descriptor. Bits 0:3 are
+ * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction,
+ * see \ref libusb_endpoint_direction.
+ */
+ uint8_t bEndpointAddress;
+
+ /** Attributes which apply to the endpoint when it is configured using
+ * the bConfigurationValue. Bits 0:1 determine the transfer type and
+ * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for
+ * isochronous endpoints and correspond to \ref libusb_iso_sync_type.
+ * Bits 4:5 are also only used for isochronous endpoints and correspond to
+ * \ref libusb_iso_usage_type. Bits 6:7 are reserved.
+ */
+ uint8_t bmAttributes;
+
+ /** Maximum packet size this endpoint is capable of sending/receiving. */
+ uint16_t wMaxPacketSize;
+
+ /** Interval for polling endpoint for data transfers. */
+ uint8_t bInterval;
+
+ /** For audio devices only: the rate at which synchronization feedback
+ * is provided. */
+ uint8_t bRefresh;
+
+ /** For audio devices only: the address if the synch endpoint */
+ uint8_t bSynchAddress;
+
+ /** Extra descriptors. If libusb encounters unknown endpoint descriptors,
+ * it will store them here, should you wish to parse them. */
+ const unsigned char *extra;
+
+ /** Length of the extra descriptors, in bytes. */
+ int extra_length;
+};
+
+/** \ingroup desc
+ * A structure representing the standard USB interface descriptor. This
+ * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
+ * All multiple-byte fields are represented in host-endian format.
+ */
+struct libusb_interface_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERFACE
+ * in this context. */
+ uint8_t bDescriptorType;
+
+ /** Number of this interface */
+ uint8_t bInterfaceNumber;
+
+ /** Value used to select this alternate setting for this interface */
+ uint8_t bAlternateSetting;
+
+ /** Number of endpoints used by this interface (excluding the control
+ * endpoint). */
+ uint8_t bNumEndpoints;
+
+ /** USB-IF class code for this interface. See \ref libusb_class_code. */
+ uint8_t bInterfaceClass;
+
+ /** USB-IF subclass code for this interface, qualified by the
+ * bInterfaceClass value */
+ uint8_t bInterfaceSubClass;
+
+ /** USB-IF protocol code for this interface, qualified by the
+ * bInterfaceClass and bInterfaceSubClass values */
+ uint8_t bInterfaceProtocol;
+
+ /** Index of string descriptor describing this interface */
+ uint8_t iInterface;
+
+ /** Array of endpoint descriptors. This length of this array is determined
+ * by the bNumEndpoints field. */
+ const struct libusb_endpoint_descriptor *endpoint;
+
+ /** Extra descriptors. If libusb encounters unknown interface descriptors,
+ * it will store them here, should you wish to parse them. */
+ const unsigned char *extra;
+
+ /** Length of the extra descriptors, in bytes. */
+ int extra_length;
+};
+
+/** \ingroup desc
+ * A collection of alternate settings for a particular USB interface.
+ */
+struct libusb_interface {
+ /** Array of interface descriptors. The length of this array is determined
+ * by the num_altsetting field. */
+ const struct libusb_interface_descriptor *altsetting;
+
+ /** The number of alternate settings that belong to this interface */
+ int num_altsetting;
+};
+
+/** \ingroup desc
+ * A structure representing the standard USB configuration descriptor. This
+ * descriptor is documented in section 9.6.3 of the USB 3.0 specification.
+ * All multiple-byte fields are represented in host-endian format.
+ */
+struct libusb_config_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG
+ * in this context. */
+ uint8_t bDescriptorType;
+
+ /** Total length of data returned for this configuration */
+ uint16_t wTotalLength;
+
+ /** Number of interfaces supported by this configuration */
+ uint8_t bNumInterfaces;
+
+ /** Identifier value for this configuration */
+ uint8_t bConfigurationValue;
+
+ /** Index of string descriptor describing this configuration */
+ uint8_t iConfiguration;
+
+ /** Configuration characteristics */
+ uint8_t bmAttributes;
+
+ /** Maximum power consumption of the USB device from this bus in this
+ * configuration when the device is fully operation. Expressed in units
+ * of 2 mA when the device is operating in high-speed mode and in units
+ * of 8 mA when the device is operating in super-speed mode. */
+ uint8_t MaxPower;
+
+ /** Array of interfaces supported by this configuration. The length of
+ * this array is determined by the bNumInterfaces field. */
+ const struct libusb_interface *interface;
+
+ /** Extra descriptors. If libusb encounters unknown configuration
+ * descriptors, it will store them here, should you wish to parse them. */
+ const unsigned char *extra;
+
+ /** Length of the extra descriptors, in bytes. */
+ int extra_length;
+};
+
+/** \ingroup desc
+ * A structure representing the superspeed endpoint companion
+ * descriptor. This descriptor is documented in section 9.6.7 of
+ * the USB 3.0 specification. All multiple-byte fields are represented in
+ * host-endian format.
+ */
+struct libusb_ss_endpoint_companion_descriptor {
+
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_SS_ENDPOINT_COMPANION in
+ * this context. */
+ uint8_t bDescriptorType;
+
+
+ /** The maximum number of packets the endpoint can send or
+ * recieve as part of a burst. */
+ uint8_t bMaxBurst;
+
+ /** In bulk EP: bits 4:0 represents the maximum number of
+ * streams the EP supports. In isochronous EP: bits 1:0
+ * represents the Mult - a zero based value that determines
+ * the maximum number of packets within a service interval */
+ uint8_t bmAttributes;
+
+ /** The total number of bytes this EP will transfer every
+ * service interval. valid only for periodic EPs. */
+ uint16_t wBytesPerInterval;
+};
+
+/** \ingroup desc
+ * A generic representation of a BOS Device Capability descriptor. It is
+ * advised to check bDevCapabilityType and call the matching
+ * libusb_get_*_descriptor function to get a structure fully matching the type.
+ */
+struct libusb_bos_dev_capability_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+ * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
+ uint8_t bDescriptorType;
+ /** Device Capability type */
+ uint8_t bDevCapabilityType;
+ /** Device Capability data (bLength - 3 bytes) */
+ uint8_t dev_capability_data
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ [] /* valid C99 code */
+#else
+ [0] /* non-standard, but usually working code */
+#endif
+ ;
+};
+
+/** \ingroup desc
+ * A structure representing the Binary Device Object Store (BOS) descriptor.
+ * This descriptor is documented in section 9.6.2 of the USB 3.0 specification.
+ * All multiple-byte fields are represented in host-endian format.
+ */
+struct libusb_bos_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_BOS LIBUSB_DT_BOS
+ * in this context. */
+ uint8_t bDescriptorType;
+
+ /** Length of this descriptor and all of its sub descriptors */
+ uint16_t wTotalLength;
+
+ /** The number of separate device capability descriptors in
+ * the BOS */
+ uint8_t bNumDeviceCaps;
+
+ /** bNumDeviceCap Device Capability Descriptors */
+ struct libusb_bos_dev_capability_descriptor *dev_capability
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ [] /* valid C99 code */
+#else
+ [0] /* non-standard, but usually working code */
+#endif
+ ;
+};
+
+/** \ingroup desc
+ * A structure representing the USB 2.0 Extension descriptor
+ * This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification.
+ * All multiple-byte fields are represented in host-endian format.
+ */
+struct libusb_usb_2_0_extension_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+ * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
+ uint8_t bDescriptorType;
+
+ /** Capability type. Will have value
+ * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION
+ * LIBUSB_BT_USB_2_0_EXTENSION in this context. */
+ uint8_t bDevCapabilityType;
+
+ /** Bitmap encoding of supported device level features.
+ * A value of one in a bit location indicates a feature is
+ * supported; a value of zero indicates it is not supported.
+ * See \ref libusb_usb_2_0_extension_attributes. */
+ uint32_t bmAttributes;
+};
+
+/** \ingroup desc
+ * A structure representing the SuperSpeed USB Device Capability descriptor
+ * This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification.
+ * All multiple-byte fields are represented in host-endian format.
+ */
+struct libusb_ss_usb_device_capability_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+ * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
+ uint8_t bDescriptorType;
+
+ /** Capability type. Will have value
+ * \ref libusb_capability_type::LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
+ * LIBUSB_BT_SS_USB_DEVICE_CAPABILITY in this context. */
+ uint8_t bDevCapabilityType;
+
+ /** Bitmap encoding of supported device level features.
+ * A value of one in a bit location indicates a feature is
+ * supported; a value of zero indicates it is not supported.
+ * See \ref libusb_ss_usb_device_capability_attributes. */
+ uint8_t bmAttributes;
+
+ /** Bitmap encoding of the speed supported by this device when
+ * operating in SuperSpeed mode. See \ref libusb_supported_speed. */
+ uint16_t wSpeedSupported;
+
+ /** The lowest speed at which all the functionality supported
+ * by the device is available to the user. For example if the
+ * device supports all its functionality when connected at
+ * full speed and above then it sets this value to 1. */
+ uint8_t bFunctionalitySupport;
+
+ /** U1 Device Exit Latency. */
+ uint8_t bU1DevExitLat;
+
+ /** U2 Device Exit Latency. */
+ uint16_t bU2DevExitLat;
+};
+
+/** \ingroup desc
+ * A structure representing the Container ID descriptor.
+ * This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification.
+ * All multiple-byte fields, except UUIDs, are represented in host-endian format.
+ */
+struct libusb_container_id_descriptor {
+ /** Size of this descriptor (in bytes) */
+ uint8_t bLength;
+
+ /** Descriptor type. Will have value
+ * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+ * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
+ uint8_t bDescriptorType;
+
+ /** Capability type. Will have value
+ * \ref libusb_capability_type::LIBUSB_BT_CONTAINER_ID
+ * LIBUSB_BT_CONTAINER_ID in this context. */
+ uint8_t bDevCapabilityType;
+
+ /** Reserved field */
+ uint8_t bReserved;
+
+ /** 128 bit UUID */
+ uint8_t ContainerID[16];
+};
+
+/** \ingroup asyncio
+ * Setup packet for control transfers. */
+struct libusb_control_setup {
+ /** Request type. Bits 0:4 determine recipient, see
+ * \ref libusb_request_recipient. Bits 5:6 determine type, see
+ * \ref libusb_request_type. Bit 7 determines data transfer direction, see
+ * \ref libusb_endpoint_direction.
+ */
+ uint8_t bmRequestType;
+
+ /** Request. If the type bits of bmRequestType are equal to
+ * \ref libusb_request_type::LIBUSB_REQUEST_TYPE_STANDARD
+ * "LIBUSB_REQUEST_TYPE_STANDARD" then this field refers to
+ * \ref libusb_standard_request. For other cases, use of this field is
+ * application-specific. */
+ uint8_t bRequest;
+
+ /** Value. Varies according to request */
+ uint16_t wValue;
+
+ /** Index. Varies according to request, typically used to pass an index
+ * or offset */
+ uint16_t wIndex;
+
+ /** Number of bytes to transfer */
+ uint16_t wLength;
+};
+
+#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
+
+/* libusb */
+
+struct libusb_context;
+struct libusb_device;
+struct libusb_device_handle;
+
+/** \ingroup lib
+ * Structure providing the version of the libusb runtime
+ */
+struct libusb_version {
+ /** Library major version. */
+ const uint16_t major;
+
+ /** Library minor version. */
+ const uint16_t minor;
+
+ /** Library micro version. */
+ const uint16_t micro;
+
+ /** Library nano version. */
+ const uint16_t nano;
+
+ /** Library release candidate suffix string, e.g. "-rc4". */
+ const char *rc;
+
+ /** For ABI compatibility only. */
+ const char* describe;
+};
+
+/** \ingroup lib
+ * Structure representing a libusb session. The concept of individual libusb
+ * sessions allows for your program to use two libraries (or dynamically
+ * load two modules) which both independently use libusb. This will prevent
+ * interference between the individual libusb users - for example
+ * libusb_set_debug() will not affect the other user of the library, and
+ * libusb_exit() will not destroy resources that the other user is still
+ * using.
+ *
+ * Sessions are created by libusb_init() and destroyed through libusb_exit().
+ * If your application is guaranteed to only ever include a single libusb
+ * user (i.e. you), you do not have to worry about contexts: pass NULL in
+ * every function call where a context is required. The default context
+ * will be used.
+ *
+ * For more information, see \ref contexts.
+ */
+typedef struct libusb_context libusb_context;
+
+/** \ingroup dev
+ * Structure representing a USB device detected on the system. This is an
+ * opaque type for which you are only ever provided with a pointer, usually
+ * originating from libusb_get_device_list().
+ *
+ * Certain operations can be performed on a device, but in order to do any
+ * I/O you will have to first obtain a device handle using libusb_open().
+ *
+ * Devices are reference counted with libusb_ref_device() and
+ * libusb_unref_device(), and are freed when the reference count reaches 0.
+ * New devices presented by libusb_get_device_list() have a reference count of
+ * 1, and libusb_free_device_list() can optionally decrease the reference count
+ * on all devices in the list. libusb_open() adds another reference which is
+ * later destroyed by libusb_close().
+ */
+typedef struct libusb_device libusb_device;
+
+
+/** \ingroup dev
+ * Structure representing a handle on a USB device. This is an opaque type for
+ * which you are only ever provided with a pointer, usually originating from
+ * libusb_open().
+ *
+ * A device handle is used to perform I/O and other operations. When finished
+ * with a device handle, you should call libusb_close().
+ */
+typedef struct libusb_device_handle libusb_device_handle;
+
+/** \ingroup dev
+ * Speed codes. Indicates the speed at which the device is operating.
+ */
+enum libusb_speed {
+ /** The OS doesn't report or know the device speed. */
+ LIBUSB_SPEED_UNKNOWN = 0,
+
+ /** The device is operating at low speed (1.5MBit/s). */
+ LIBUSB_SPEED_LOW = 1,
+
+ /** The device is operating at full speed (12MBit/s). */
+ LIBUSB_SPEED_FULL = 2,
+
+ /** The device is operating at high speed (480MBit/s). */
+ LIBUSB_SPEED_HIGH = 3,
+
+ /** The device is operating at super speed (5000MBit/s). */
+ LIBUSB_SPEED_SUPER = 4,
+};
+
+/** \ingroup dev
+ * Supported speeds (wSpeedSupported) bitfield. Indicates what
+ * speeds the device supports.
+ */
+enum libusb_supported_speed {
+ /** Low speed operation supported (1.5MBit/s). */
+ LIBUSB_LOW_SPEED_OPERATION = 1,
+
+ /** Full speed operation supported (12MBit/s). */
+ LIBUSB_FULL_SPEED_OPERATION = 2,
+
+ /** High speed operation supported (480MBit/s). */
+ LIBUSB_HIGH_SPEED_OPERATION = 4,
+
+ /** Superspeed operation supported (5000MBit/s). */
+ LIBUSB_SUPER_SPEED_OPERATION = 8,
+};
+
+/** \ingroup dev
+ * Masks for the bits of the
+ * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
+ * of the USB 2.0 Extension descriptor.
+ */
+enum libusb_usb_2_0_extension_attributes {
+ /** Supports Link Power Management (LPM) */
+ LIBUSB_BM_LPM_SUPPORT = 2,
+};
+
+/** \ingroup dev
+ * Masks for the bits of the
+ * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
+ * field of the SuperSpeed USB Device Capability descriptor.
+ */
+enum libusb_ss_usb_device_capability_attributes {
+ /** Supports Latency Tolerance Messages (LTM) */
+ LIBUSB_BM_LTM_SUPPORT = 2,
+};
+
+/** \ingroup dev
+ * USB capability types
+ */
+enum libusb_bos_type {
+ /** Wireless USB device capability */
+ LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1,
+
+ /** USB 2.0 extensions */
+ LIBUSB_BT_USB_2_0_EXTENSION = 2,
+
+ /** SuperSpeed USB device capability */
+ LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3,
+
+ /** Container ID type */
+ LIBUSB_BT_CONTAINER_ID = 4,
+};
+
+/** \ingroup misc
+ * Error codes. Most libusb functions return 0 on success or one of these
+ * codes on failure.
+ * You can call libusb_error_name() to retrieve a string representation of an
+ * error code or libusb_strerror() to get an end-user suitable description of
+ * an error code.
+ */
+enum libusb_error {
+ /** Success (no error) */
+ LIBUSB_SUCCESS = 0,
+
+ /** Input/output error */
+ LIBUSB_ERROR_IO = -1,
+
+ /** Invalid parameter */
+ LIBUSB_ERROR_INVALID_PARAM = -2,
+
+ /** Access denied (insufficient permissions) */
+ LIBUSB_ERROR_ACCESS = -3,
+
+ /** No such device (it may have been disconnected) */
+ LIBUSB_ERROR_NO_DEVICE = -4,
+
+ /** Entity not found */
+ LIBUSB_ERROR_NOT_FOUND = -5,
+
+ /** Resource busy */
+ LIBUSB_ERROR_BUSY = -6,
+
+ /** Operation timed out */
+ LIBUSB_ERROR_TIMEOUT = -7,
+
+ /** Overflow */
+ LIBUSB_ERROR_OVERFLOW = -8,
+
+ /** Pipe error */
+ LIBUSB_ERROR_PIPE = -9,
+
+ /** System call interrupted (perhaps due to signal) */
+ LIBUSB_ERROR_INTERRUPTED = -10,
+
+ /** Insufficient memory */
+ LIBUSB_ERROR_NO_MEM = -11,
+
+ /** Operation not supported or unimplemented on this platform */
+ LIBUSB_ERROR_NOT_SUPPORTED = -12,
+
+ /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
+ message strings in strerror.c when adding new error codes here. */
+
+ /** Other error */
+ LIBUSB_ERROR_OTHER = -99,
+};
+
+/* Total number of error codes in enum libusb_error */
+#define LIBUSB_ERROR_COUNT 14
+
+/** \ingroup asyncio
+ * Transfer status codes */
+enum libusb_transfer_status {
+ /** Transfer completed without error. Note that this does not indicate
+ * that the entire amount of requested data was transferred. */
+ LIBUSB_TRANSFER_COMPLETED,
+
+ /** Transfer failed */
+ LIBUSB_TRANSFER_ERROR,
+
+ /** Transfer timed out */
+ LIBUSB_TRANSFER_TIMED_OUT,
+
+ /** Transfer was cancelled */
+ LIBUSB_TRANSFER_CANCELLED,
+
+ /** For bulk/interrupt endpoints: halt condition detected (endpoint
+ * stalled). For control endpoints: control request not supported. */
+ LIBUSB_TRANSFER_STALL,
+
+ /** Device was disconnected */
+ LIBUSB_TRANSFER_NO_DEVICE,
+
+ /** Device sent more data than requested */
+ LIBUSB_TRANSFER_OVERFLOW,
+
+ /* NB! Remember to update libusb_error_name()
+ when adding new status codes here. */
+};
+
+/** \ingroup asyncio
+ * libusb_transfer.flags values */
+enum libusb_transfer_flags {
+ /** Report short frames as errors */
+ LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0,
+
+ /** Automatically free() transfer buffer during libusb_free_transfer() */
+ LIBUSB_TRANSFER_FREE_BUFFER = 1<<1,
+
+ /** Automatically call libusb_free_transfer() after callback returns.
+ * If this flag is set, it is illegal to call libusb_free_transfer()
+ * from your transfer callback, as this will result in a double-free
+ * when this flag is acted upon. */
+ LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2,
+
+ /** Terminate transfers that are a multiple of the endpoint's
+ * wMaxPacketSize with an extra zero length packet. This is useful
+ * when a device protocol mandates that each logical request is
+ * terminated by an incomplete packet (i.e. the logical requests are
+ * not separated by other means).
+ *
+ * This flag only affects host-to-device transfers to bulk and interrupt
+ * endpoints. In other situations, it is ignored.
+ *
+ * This flag only affects transfers with a length that is a multiple of
+ * the endpoint's wMaxPacketSize. On transfers of other lengths, this
+ * flag has no effect. Therefore, if you are working with a device that
+ * needs a ZLP whenever the end of the logical request falls on a packet
+ * boundary, then it is sensible to set this flag on every
+ * transfer (you do not have to worry about only setting it on transfers
+ * that end on the boundary).
+ *
+ * This flag is currently only supported on Linux.
+ * On other systems, libusb_submit_transfer() will return
+ * LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is set.
+ *
+ * Available since libusb-1.0.9.
+ */
+ LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 << 3,
+};
+
+/** \ingroup asyncio
+ * Isochronous packet descriptor. */
+struct libusb_iso_packet_descriptor {
+ /** Length of data to request in this packet */
+ unsigned int length;
+
+ /** Amount of data that was actually transferred */
+ unsigned int actual_length;
+
+ /** Status code for this packet */
+ enum libusb_transfer_status status;
+};
+
+struct libusb_transfer;
+
+/** \ingroup asyncio
+ * Asynchronous transfer callback function type. When submitting asynchronous
+ * transfers, you pass a pointer to a callback function of this type via the
+ * \ref libusb_transfer::callback "callback" member of the libusb_transfer
+ * structure. libusb will call this function later, when the transfer has
+ * completed or failed. See \ref asyncio for more information.
+ * \param transfer The libusb_transfer struct the callback function is being
+ * notified about.
+ */
+typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
+
+/** \ingroup asyncio
+ * The generic USB transfer structure. The user populates this structure and
+ * then submits it in order to request a transfer. After the transfer has
+ * completed, the library populates the transfer with the results and passes
+ * it back to the user.
+ */
+struct libusb_transfer {
+ /** Handle of the device that this transfer will be submitted to */
+ libusb_device_handle *dev_handle;
+
+ /** A bitwise OR combination of \ref libusb_transfer_flags. */
+ uint8_t flags;
+
+ /** Address of the endpoint where this transfer will be sent. */
+ unsigned char endpoint;
+
+ /** Type of the endpoint from \ref libusb_transfer_type */
+ unsigned char type;
+
+ /** Timeout for this transfer in millseconds. A value of 0 indicates no
+ * timeout. */
+ unsigned int timeout;
+
+ /** The status of the transfer. Read-only, and only for use within
+ * transfer callback function.
+ *
+ * If this is an isochronous transfer, this field may read COMPLETED even
+ * if there were errors in the frames. Use the
+ * \ref libusb_iso_packet_descriptor::status "status" field in each packet
+ * to determine if errors occurred. */
+ enum libusb_transfer_status status;
+
+ /** Length of the data buffer */
+ int length;
+
+ /** Actual length of data that was transferred. Read-only, and only for
+ * use within transfer callback function. Not valid for isochronous
+ * endpoint transfers. */
+ int actual_length;
+
+ /** Callback function. This will be invoked when the transfer completes,
+ * fails, or is cancelled. */
+ libusb_transfer_cb_fn callback;
+
+ /** User context data to pass to the callback function. */
+ void *user_data;
+
+ /** Data buffer */
+ unsigned char *buffer;
+
+ /** Number of isochronous packets. Only used for I/O with isochronous
+ * endpoints. */
+ int num_iso_packets;
+
+ /** Isochronous packet descriptors, for isochronous transfers only. */
+ struct libusb_iso_packet_descriptor iso_packet_desc
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ [] /* valid C99 code */
+#else
+ [0] /* non-standard, but usually working code */
+#endif
+ ;
+};
+
+/** \ingroup misc
+ * Capabilities supported by an instance of libusb on the current running
+ * platform. Test if the loaded library supports a given capability by calling
+ * \ref libusb_has_capability().
+ */
+enum libusb_capability {
+ /** The libusb_has_capability() API is available. */
+ LIBUSB_CAP_HAS_CAPABILITY = 0x0000,
+ /** Hotplug support is available on this platform. */
+ LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
+ /** The library can access HID devices without requiring user intervention.
+ * Note that before being able to actually access an HID device, you may
+ * still have to call additional libusb functions such as
+ * \ref libusb_detach_kernel_driver(). */
+ LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
+ /** The library supports detaching of the default USB driver, using
+ * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */
+ LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
+};
+
+/** \ingroup lib
+ * Log message levels.
+ * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
+ * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
+ * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
+ * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
+ * and error messages are printed to stderr
+ * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
+ * warnings and errors to stderr
+ */
+enum libusb_log_level {
+ LIBUSB_LOG_LEVEL_NONE = 0,
+ LIBUSB_LOG_LEVEL_ERROR,
+ LIBUSB_LOG_LEVEL_WARNING,
+ LIBUSB_LOG_LEVEL_INFO,
+ LIBUSB_LOG_LEVEL_DEBUG,
+};
+
+int LIBUSB_CALL libusb_init(libusb_context **ctx);
+void LIBUSB_CALL libusb_exit(libusb_context *ctx);
+void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
+const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
+int LIBUSB_CALL libusb_has_capability(uint32_t capability);
+const char * LIBUSB_CALL libusb_error_name(int errcode);
+int LIBUSB_CALL libusb_setlocale(const char *locale);
+const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode);
+
+ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
+ libusb_device ***list);
+void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
+ int unref_devices);
+libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
+void LIBUSB_CALL libusb_unref_device(libusb_device *dev);
+
+int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
+ int *config);
+int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
+ struct libusb_device_descriptor *desc);
+int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
+ struct libusb_config_descriptor **config);
+int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
+ uint8_t config_index, struct libusb_config_descriptor **config);
+int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
+ uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
+void LIBUSB_CALL libusb_free_config_descriptor(
+ struct libusb_config_descriptor *config);
+int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
+ struct libusb_context *ctx,
+ const struct libusb_endpoint_descriptor *endpoint,
+ struct libusb_ss_endpoint_companion_descriptor **ep_comp);
+void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
+ struct libusb_ss_endpoint_companion_descriptor *ep_comp);
+int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *handle,
+ struct libusb_bos_descriptor **bos);
+void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
+int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
+ struct libusb_context *ctx,
+ struct libusb_bos_dev_capability_descriptor *dev_cap,
+ struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
+void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor(
+ struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
+int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor(
+ struct libusb_context *ctx,
+ struct libusb_bos_dev_capability_descriptor *dev_cap,
+ struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
+void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor(
+ struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
+int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *ctx,
+ struct libusb_bos_dev_capability_descriptor *dev_cap,
+ struct libusb_container_id_descriptor **container_id);
+void LIBUSB_CALL libusb_free_container_id_descriptor(
+ struct libusb_container_id_descriptor *container_id);
+uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
+uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
+int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
+LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
+int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
+libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev);
+uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
+int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
+int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
+ unsigned char endpoint);
+int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
+ unsigned char endpoint);
+
+int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **handle);
+int LIBUSB_CALL libusb_open2(libusb_device *dev, libusb_device_handle **handle, int fd);
+void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
+libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);
+libusb_device * LIBUSB_CALL libusb_get_device2(libusb_context *ctx, const char *dev_node);
+
+int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev,
+ int configuration);
+int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev,
+ int interface_number);
+int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev,
+ int interface_number);
+
+libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
+ libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
+
+int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev,
+ int interface_number, int alternate_setting);
+int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev,
+ unsigned char endpoint);
+int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev);
+
+int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev,
+ uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
+int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev,
+ unsigned char *endpoints, int num_endpoints);
+
+int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev,
+ int interface_number);
+int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev,
+ int interface_number);
+int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev,
+ int interface_number);
+int LIBUSB_CALL libusb_set_auto_detach_kernel_driver(
+ libusb_device_handle *dev, int enable);
+
+/* async I/O */
+
+/** \ingroup asyncio
+ * Get the data section of a control transfer. This convenience function is here
+ * to remind you that the data does not start until 8 bytes into the actual
+ * buffer, as the setup packet comes first.
+ *
+ * Calling this function only makes sense from a transfer callback function,
+ * or situations where you have already allocated a suitably sized buffer at
+ * transfer->buffer.
+ *
+ * \param transfer a transfer
+ * \returns pointer to the first byte of the data section
+ */
+static inline unsigned char *libusb_control_transfer_get_data(
+ struct libusb_transfer *transfer)
+{
+ return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
+}
+
+/** \ingroup asyncio
+ * Get the control setup packet of a control transfer. This convenience
+ * function is here to remind you that the control setup occupies the first
+ * 8 bytes of the transfer data buffer.
+ *
+ * Calling this function only makes sense from a transfer callback function,
+ * or situations where you have already allocated a suitably sized buffer at
+ * transfer->buffer.
+ *
+ * \param transfer a transfer
+ * \returns a casted pointer to the start of the transfer data buffer
+ */
+static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
+ struct libusb_transfer *transfer)
+{
+ return (struct libusb_control_setup *)(void *) transfer->buffer;
+}
+
+/** \ingroup asyncio
+ * Helper function to populate the setup packet (first 8 bytes of the data
+ * buffer) for a control transfer. The wIndex, wValue and wLength values should
+ * be given in host-endian byte order.
+ *
+ * \param buffer buffer to output the setup packet into
+ * This pointer must be aligned to at least 2 bytes boundary.
+ * \param bmRequestType see the
+ * \ref libusb_control_setup::bmRequestType "bmRequestType" field of
+ * \ref libusb_control_setup
+ * \param bRequest see the
+ * \ref libusb_control_setup::bRequest "bRequest" field of
+ * \ref libusb_control_setup
+ * \param wValue see the
+ * \ref libusb_control_setup::wValue "wValue" field of
+ * \ref libusb_control_setup
+ * \param wIndex see the
+ * \ref libusb_control_setup::wIndex "wIndex" field of
+ * \ref libusb_control_setup
+ * \param wLength see the
+ * \ref libusb_control_setup::wLength "wLength" field of
+ * \ref libusb_control_setup
+ */
+static inline void libusb_fill_control_setup(unsigned char *buffer,
+ uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
+ uint16_t wLength)
+{
+ struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
+ setup->bmRequestType = bmRequestType;
+ setup->bRequest = bRequest;
+ setup->wValue = libusb_cpu_to_le16(wValue);
+ setup->wIndex = libusb_cpu_to_le16(wIndex);
+ setup->wLength = libusb_cpu_to_le16(wLength);
+}
+
+struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
+int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
+int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
+void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
+void LIBUSB_CALL libusb_transfer_set_stream_id(
+ struct libusb_transfer *transfer, uint32_t stream_id);
+uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
+ struct libusb_transfer *transfer);
+
+/** \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for a control transfer.
+ *
+ * If you pass a transfer buffer to this function, the first 8 bytes will
+ * be interpreted as a control setup packet, and the wLength field will be
+ * used to automatically populate the \ref libusb_transfer::length "length"
+ * field of the transfer. Therefore the recommended approach is:
+ * -# Allocate a suitably sized data buffer (including space for control setup)
+ * -# Call libusb_fill_control_setup()
+ * -# If this is a host-to-device transfer with a data stage, put the data
+ * in place after the setup packet
+ * -# Call this function
+ * -# Call libusb_submit_transfer()
+ *
+ * It is also legal to pass a NULL buffer to this function, in which case this
+ * function will not attempt to populate the length field. Remember that you
+ * must then populate the buffer and length fields later.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param buffer data buffer. If provided, this function will interpret the
+ * first 8 bytes as a setup packet and infer the transfer length from that.
+ * This pointer must be aligned to at least 2 bytes boundary.
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+ */
+static inline void libusb_fill_control_transfer(
+ struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
+ unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
+ unsigned int timeout)
+{
+ struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
+ transfer->dev_handle = dev_handle;
+ transfer->endpoint = 0;
+ transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
+ transfer->timeout = timeout;
+ transfer->buffer = buffer;
+ if (setup)
+ transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE
+ + libusb_le16_to_cpu(setup->wLength));
+ transfer->user_data = user_data;
+ transfer->callback = callback;
+}
+
+/** \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for a bulk transfer.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+ */
+static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
+ libusb_device_handle *dev_handle, unsigned char endpoint,
+ unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
+ void *user_data, unsigned int timeout)
+{
+ transfer->dev_handle = dev_handle;
+ transfer->endpoint = endpoint;
+ transfer->type = LIBUSB_TRANSFER_TYPE_BULK;
+ transfer->timeout = timeout;
+ transfer->buffer = buffer;
+ transfer->length = length;
+ transfer->user_data = user_data;
+ transfer->callback = callback;
+}
+
+/** \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for a bulk transfer using bulk streams.
+ *
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param stream_id bulk stream id for this transfer
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+ */
+static inline void libusb_fill_bulk_stream_transfer(
+ struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
+ unsigned char endpoint, uint32_t stream_id,
+ unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
+ void *user_data, unsigned int timeout)
+{
+ libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
+ length, callback, user_data, timeout);
+ transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
+ libusb_transfer_set_stream_id(transfer, stream_id);
+}
+
+/** \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for an interrupt transfer.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+ */
+static inline void libusb_fill_interrupt_transfer(
+ struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
+ unsigned char endpoint, unsigned char *buffer, int length,
+ libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
+{
+ transfer->dev_handle = dev_handle;
+ transfer->endpoint = endpoint;
+ transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT;
+ transfer->timeout = timeout;
+ transfer->buffer = buffer;
+ transfer->length = length;
+ transfer->user_data = user_data;
+ transfer->callback = callback;
+}
+
+/** \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for an isochronous transfer.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param num_iso_packets the number of isochronous packets
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+ */
+static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
+ libusb_device_handle *dev_handle, unsigned char endpoint,
+ unsigned char *buffer, int length, int num_iso_packets,
+ libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
+{
+ transfer->dev_handle = dev_handle;
+ transfer->endpoint = endpoint;
+ transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
+ transfer->timeout = timeout;
+ transfer->buffer = buffer;
+ transfer->length = length;
+ transfer->num_iso_packets = num_iso_packets;
+ transfer->user_data = user_data;
+ transfer->callback = callback;
+}
+
+/** \ingroup asyncio
+ * Convenience function to set the length of all packets in an isochronous
+ * transfer, based on the num_iso_packets field in the transfer structure.
+ *
+ * \param transfer a transfer
+ * \param length the length to set in each isochronous packet descriptor
+ * \see libusb_get_max_packet_size()
+ */
+static inline void libusb_set_iso_packet_lengths(
+ struct libusb_transfer *transfer, unsigned int length)
+{
+ int i;
+ for (i = 0; i < transfer->num_iso_packets; i++)
+ transfer->iso_packet_desc[i].length = length;
+}
+
+/** \ingroup asyncio
+ * Convenience function to locate the position of an isochronous packet
+ * within the buffer of an isochronous transfer.
+ *
+ * This is a thorough function which loops through all preceding packets,
+ * accumulating their lengths to find the position of the specified packet.
+ * Typically you will assign equal lengths to each packet in the transfer,
+ * and hence the above method is sub-optimal. You may wish to use
+ * libusb_get_iso_packet_buffer_simple() instead.
+ *
+ * \param transfer a transfer
+ * \param packet the packet to return the address of
+ * \returns the base address of the packet buffer inside the transfer buffer,
+ * or NULL if the packet does not exist.
+ * \see libusb_get_iso_packet_buffer_simple()
+ */
+static inline unsigned char *libusb_get_iso_packet_buffer(
+ struct libusb_transfer *transfer, unsigned int packet)
+{
+ int i;
+ size_t offset = 0;
+ int _packet;
+
+ /* oops..slight bug in the API. packet is an unsigned int, but we use
+ * signed integers almost everywhere else. range-check and convert to
+ * signed to avoid compiler warnings. FIXME for libusb-2. */
+ if (packet > INT_MAX)
+ return NULL;
+ _packet = (int) packet;
+
+ if (_packet >= transfer->num_iso_packets)
+ return NULL;
+
+ for (i = 0; i < _packet; i++)
+ offset += transfer->iso_packet_desc[i].length;
+
+ return transfer->buffer + offset;
+}
+
+/** \ingroup asyncio
+ * Convenience function to locate the position of an isochronous packet
+ * within the buffer of an isochronous transfer, for transfers where each
+ * packet is of identical size.
+ *
+ * This function relies on the assumption that every packet within the transfer
+ * is of identical size to the first packet. Calculating the location of
+ * the packet buffer is then just a simple calculation:
+ * buffer + (packet_size * packet)
+ *
+ * Do not use this function on transfers other than those that have identical
+ * packet lengths for each packet.
+ *
+ * \param transfer a transfer
+ * \param packet the packet to return the address of
+ * \returns the base address of the packet buffer inside the transfer buffer,
+ * or NULL if the packet does not exist.
+ * \see libusb_get_iso_packet_buffer()
+ */
+static inline unsigned char *libusb_get_iso_packet_buffer_simple(
+ struct libusb_transfer *transfer, unsigned int packet)
+{
+ int _packet;
+
+ /* oops..slight bug in the API. packet is an unsigned int, but we use
+ * signed integers almost everywhere else. range-check and convert to
+ * signed to avoid compiler warnings. FIXME for libusb-2. */
+ if (packet > INT_MAX)
+ return NULL;
+ _packet = (int) packet;
+
+ if (_packet >= transfer->num_iso_packets)
+ return NULL;
+
+ return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet);
+}
+
+/* sync I/O */
+
+int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle,
+ uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
+ unsigned char *data, uint16_t wLength, unsigned int timeout);
+
+int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle,
+ unsigned char endpoint, unsigned char *data, int length,
+ int *actual_length, unsigned int timeout);
+
+int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
+ unsigned char endpoint, unsigned char *data, int length,
+ int *actual_length, unsigned int timeout);
+
+/** \ingroup desc
+ * Retrieve a descriptor from the default control pipe.
+ * This is a convenience function which formulates the appropriate control
+ * message to retrieve the descriptor.
+ *
+ * \param dev a device handle
+ * \param desc_type the descriptor type, see \ref libusb_descriptor_type
+ * \param desc_index the index of the descriptor to retrieve
+ * \param data output buffer for descriptor
+ * \param length size of data buffer
+ * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
+ */
+static inline int libusb_get_descriptor(libusb_device_handle *dev,
+ uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
+{
+ return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
+ LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index),
+ 0, data, (uint16_t) length, 1000);
+}
+
+/** \ingroup desc
+ * Retrieve a descriptor from a device.
+ * This is a convenience function which formulates the appropriate control
+ * message to retrieve the descriptor. The string returned is Unicode, as
+ * detailed in the USB specifications.
+ *
+ * \param dev a device handle
+ * \param desc_index the index of the descriptor to retrieve
+ * \param langid the language ID for the string descriptor
+ * \param data output buffer for descriptor
+ * \param length size of data buffer
+ * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
+ * \see libusb_get_string_descriptor_ascii()
+ */
+static inline int libusb_get_string_descriptor(libusb_device_handle *dev,
+ uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
+{
+ return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
+ LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING << 8) | desc_index),
+ langid, data, (uint16_t) length, 1000);
+}
+
+int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
+ uint8_t desc_index, unsigned char *data, int length);
+
+/* polling and timeouts */
+
+int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx);
+void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
+void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
+int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
+int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
+void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
+void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
+int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
+
+int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
+ struct timeval *tv);
+int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
+ struct timeval *tv, int *completed);
+int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
+int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *completed);
+int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
+ struct timeval *tv);
+int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
+int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
+ struct timeval *tv);
+
+/** \ingroup poll
+ * File descriptor for polling
+ */
+struct libusb_pollfd {
+ /** Numeric file descriptor */
+ int fd;
+
+ /** Event flags to poll for from . POLLIN indicates that you
+ * should monitor this file descriptor for becoming ready to read from,
+ * and POLLOUT indicates that you should monitor this file descriptor for
+ * nonblocking write readiness. */
+ short events;
+};
+
+/** \ingroup poll
+ * Callback function, invoked when a new file descriptor should be added
+ * to the set of file descriptors monitored for events.
+ * \param fd the new file descriptor
+ * \param events events to monitor for, see \ref libusb_pollfd for a
+ * description
+ * \param user_data User data pointer specified in
+ * libusb_set_pollfd_notifiers() call
+ * \see libusb_set_pollfd_notifiers()
+ */
+typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
+ void *user_data);
+
+/** \ingroup poll
+ * Callback function, invoked when a file descriptor should be removed from
+ * the set of file descriptors being monitored for events. After returning
+ * from this callback, do not use that file descriptor again.
+ * \param fd the file descriptor to stop monitoring
+ * \param user_data User data pointer specified in
+ * libusb_set_pollfd_notifiers() call
+ * \see libusb_set_pollfd_notifiers()
+ */
+typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
+
+const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
+ libusb_context *ctx);
+void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
+void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
+ libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
+ void *user_data);
+
+/** \ingroup hotplug
+ * Callback handle.
+ *
+ * Callbacks handles are generated by libusb_hotplug_register_callback()
+ * and can be used to deregister callbacks. Callback handles are unique
+ * per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
+ * on an already deregisted callback.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * For more information, see \ref hotplug.
+ */
+typedef int libusb_hotplug_callback_handle;
+
+/** \ingroup hotplug
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * Flags for hotplug events */
+typedef enum {
+ /** Default value when not using any flags. */
+ LIBUSB_HOTPLUG_NO_FLAGS = 0,
+
+ /** Arm the callback and fire it for all matching currently attached devices. */
+ LIBUSB_HOTPLUG_ENUMERATE = 1<<0,
+} libusb_hotplug_flag;
+
+/** \ingroup hotplug
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * Hotplug events */
+typedef enum {
+ /** A device has been plugged in and is ready to use */
+ LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01,
+
+ /** A device has left and is no longer available.
+ * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
+ * It is safe to call libusb_get_device_descriptor on a device that has left */
+ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02,
+} libusb_hotplug_event;
+
+/** \ingroup hotplug
+ * Wildcard matching for hotplug events */
+#define LIBUSB_HOTPLUG_MATCH_ANY -1
+
+/** \ingroup hotplug
+ * Hotplug callback function type. When requesting hotplug event notifications,
+ * you pass a pointer to a callback function of this type.
+ *
+ * This callback may be called by an internal event thread and as such it is
+ * recommended the callback do minimal processing before returning.
+ *
+ * libusb will call this function later, when a matching event had happened on
+ * a matching device. See \ref hotplug for more information.
+ *
+ * It is safe to call either libusb_hotplug_register_callback() or
+ * libusb_hotplug_deregister_callback() from within a callback function.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * \param ctx context of this notification
+ * \param device libusb_device this event occurred on
+ * \param event event that occurred
+ * \param user_data user data provided when this callback was registered
+ * \returns bool whether this callback is finished processing events.
+ * returning 1 will cause this callback to be deregistered
+ */
+typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
+ libusb_device *device,
+ libusb_hotplug_event event,
+ void *user_data);
+
+/** \ingroup hotplug
+ * Register a hotplug callback function
+ *
+ * Register a callback with the libusb_context. The callback will fire
+ * when a matching event occurs on a matching device. The callback is
+ * armed until either it is deregistered with libusb_hotplug_deregister_callback()
+ * or the supplied callback returns 1 to indicate it is finished processing events.
+ *
+ * If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be
+ * called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices
+ * already plugged into the machine. Note that libusb modifies its internal
+ * device list from a separate thread, while calling hotplug callbacks from
+ * libusb_handle_events(), so it is possible for a device to already be present
+ * on, or removed from, its internal device list, while the hotplug callbacks
+ * still need to be dispatched. This means that when using \ref
+ * LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arrival
+ * of the same device, once from libusb_hotplug_register_callback() and once
+ * from libusb_handle_events(); and/or your callback may be called for the
+ * removal of a device for which an arrived call was never made.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * \param[in] ctx context to register this callback with
+ * \param[in] events bitwise or of events that will trigger this callback. See \ref
+ * libusb_hotplug_event
+ * \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag
+ * \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
+ * \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
+ * \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
+ * \param[in] cb_fn the function to be invoked on a matching event/device
+ * \param[in] user_data user data to pass to the callback function
+ * \param[out] handle pointer to store the handle of the allocated callback (can be NULL)
+ * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
+ */
+int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
+ libusb_hotplug_event events,
+ libusb_hotplug_flag flags,
+ int vendor_id, int product_id,
+ int dev_class,
+ libusb_hotplug_callback_fn cb_fn,
+ void *user_data,
+ libusb_hotplug_callback_handle *handle);
+
+/** \ingroup hotplug
+ * Deregisters a hotplug callback.
+ *
+ * Deregister a callback from a libusb_context. This function is safe to call from within
+ * a hotplug callback.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * \param[in] ctx context this callback is registered with
+ * \param[in] handle the handle of the callback to deregister
+ */
+void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
+ libusb_hotplug_callback_handle handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/libusb.h.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/libusb.h.REMOVED.git-id
deleted file mode 100644
index 12ee5e49..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/libusb.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-6549d2eb4ca85f75d155f24946e9615663b90980
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/libusbi.h b/Desktop_Interface/build_android/libusb-martin-kuldeep/libusbi.h
new file mode 100644
index 00000000..447ad045
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/libusbi.h
@@ -0,0 +1,1120 @@
+/*
+ * Internal header for libusb
+ * Copyright © 2007-2009 Daniel Drake
+ * Copyright © 2001 Johannes Erdfelt
+ * Copyright © 2013-2016 Martin Marinov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LIBUSBI_H
+#define LIBUSBI_H
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#ifdef HAVE_POLL_H
+#include
+#endif
+#ifdef HAVE_MISSING_H
+#include
+#endif
+
+#include "libusb.h"
+#include "version.h"
+
+/* Inside the libusb code, mark all public functions as follows:
+ * return_type API_EXPORTED function_name(params) { ... }
+ * But if the function returns a pointer, mark it as follows:
+ * DEFAULT_VISIBILITY return_type * LIBUSB_CALL function_name(params) { ... }
+ * In the libusb public header, mark all declarations as:
+ * return_type LIBUSB_CALL function_name(params);
+ */
+#define API_EXPORTED LIBUSB_CALL DEFAULT_VISIBILITY
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DEVICE_DESC_LENGTH 18
+
+#define USB_MAXENDPOINTS 32
+#define USB_MAXINTERFACES 32
+#define USB_MAXCONFIG 8
+
+/* Backend specific capabilities */
+#define USBI_CAP_HAS_HID_ACCESS 0x00010000
+#define USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER 0x00020000
+
+/* Maximum number of bytes in a log line */
+#define USBI_MAX_LOG_LEN 1024
+/* Terminator for log lines */
+#define USBI_LOG_LINE_END "\n"
+
+/* The following is used to silence warnings for unused variables */
+#define UNUSED(var) do { (void)(var); } while(0)
+
+#if !defined(ARRAYSIZE)
+#define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
+#endif
+
+struct list_head {
+ struct list_head *prev, *next;
+};
+
+/* Get an entry from the list
+ * ptr - the address of this list_head element in "type"
+ * type - the data type that contains "member"
+ * member - the list_head element in "type"
+ */
+#define list_entry(ptr, type, member) \
+ ((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member)))
+
+#define list_first_entry(ptr, type, member) \
+ list_entry((ptr)->next, type, member)
+
+/* Get each entry from a list
+ * pos - A structure pointer has a "member" element
+ * head - list head
+ * member - the list_head element in "pos"
+ * type - the type of the first parameter
+ */
+#define list_for_each_entry(pos, head, member, type) \
+ for (pos = list_entry((head)->next, type, member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, type, member))
+
+#define list_for_each_entry_safe(pos, n, head, member, type) \
+ for (pos = list_entry((head)->next, type, member), \
+ n = list_entry(pos->member.next, type, member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, type, member))
+
+#define list_empty(entry) ((entry)->next == (entry))
+
+static inline void list_init(struct list_head *entry)
+{
+ entry->prev = entry->next = entry;
+}
+
+static inline void list_add(struct list_head *entry, struct list_head *head)
+{
+ entry->next = head->next;
+ entry->prev = head;
+
+ head->next->prev = entry;
+ head->next = entry;
+}
+
+static inline void list_add_tail(struct list_head *entry,
+ struct list_head *head)
+{
+ entry->next = head;
+ entry->prev = head->prev;
+
+ head->prev->next = entry;
+ head->prev = entry;
+}
+
+static inline void list_del(struct list_head *entry)
+{
+ entry->next->prev = entry->prev;
+ entry->prev->next = entry->next;
+ entry->next = entry->prev = NULL;
+}
+
+static inline void *usbi_reallocf(void *ptr, size_t size)
+{
+ void *ret = realloc(ptr, size);
+ if (!ret)
+ free(ptr);
+ return ret;
+}
+
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *mptr = (ptr); \
+ (type *)( (char *)mptr - offsetof(type,member) );})
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
+
+/* Some platforms don't have this define */
+#ifndef TIMESPEC_TO_TIMEVAL
+#define TIMESPEC_TO_TIMEVAL(tv, ts) \
+ do { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+ } while (0)
+#endif
+
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
+ const char *function, const char *format, ...);
+
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
+ const char *function, const char *format, va_list args);
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1400
+
+#ifdef ENABLE_LOGGING
+#define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
+#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
+#else
+#define _usbi_log(ctx, level, ...) do { (void)(ctx); } while(0)
+#define usbi_dbg(...) do {} while(0)
+#endif
+
+#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
+#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
+#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
+
+#else /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
+
+#ifdef ENABLE_LOGGING
+#define LOG_BODY(ctxt, level) \
+{ \
+ va_list args; \
+ va_start (args, format); \
+ usbi_log_v(ctxt, level, "", format, args); \
+ va_end(args); \
+}
+#else
+#define LOG_BODY(ctxt, level) do { (void)(ctxt); } while(0)
+#endif
+
+static inline void usbi_info(struct libusb_context *ctx, const char *format,
+ ...)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_INFO)
+static inline void usbi_warn(struct libusb_context *ctx, const char *format,
+ ...)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_WARNING)
+static inline void usbi_err( struct libusb_context *ctx, const char *format,
+ ...)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_ERROR)
+
+static inline void usbi_dbg(const char *format, ...)
+ LOG_BODY(NULL,LIBUSB_LOG_LEVEL_DEBUG)
+
+#endif /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
+
+#define USBI_GET_CONTEXT(ctx) if (!(ctx)) (ctx) = usbi_default_context
+#define DEVICE_CTX(dev) ((dev)->ctx)
+#define HANDLE_CTX(handle) (DEVICE_CTX((handle)->dev))
+#define TRANSFER_CTX(transfer) (HANDLE_CTX((transfer)->dev_handle))
+#define ITRANSFER_CTX(transfer) \
+ (TRANSFER_CTX(USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)))
+
+#define IS_EPIN(ep) (0 != ((ep) & LIBUSB_ENDPOINT_IN))
+#define IS_EPOUT(ep) (!IS_EPIN(ep))
+#define IS_XFERIN(xfer) (0 != ((xfer)->endpoint & LIBUSB_ENDPOINT_IN))
+#define IS_XFEROUT(xfer) (!IS_XFERIN(xfer))
+
+/* Internal abstraction for thread synchronization */
+#if defined(THREADS_POSIX)
+#include "os/threads_posix.h"
+#elif defined(OS_WINDOWS) || defined(OS_WINCE)
+#include
+#endif
+
+extern struct libusb_context *usbi_default_context;
+
+/* Forward declaration for use in context (fully defined inside poll abstraction) */
+struct pollfd;
+
+struct libusb_context {
+ int debug;
+ int debug_fixed;
+
+ /* internal event pipe, used for signalling occurrence of an internal event. */
+ int event_pipe[2];
+
+ struct list_head usb_devs;
+ usbi_mutex_t usb_devs_lock;
+
+ /* A list of open handles. Backends are free to traverse this if required.
+ */
+ struct list_head open_devs;
+ usbi_mutex_t open_devs_lock;
+
+ /* A list of registered hotplug callbacks */
+ struct list_head hotplug_cbs;
+ usbi_mutex_t hotplug_cbs_lock;
+
+ /* this is a list of in-flight transfer handles, sorted by timeout
+ * expiration. URBs to timeout the soonest are placed at the beginning of
+ * the list, URBs that will time out later are placed after, and urbs with
+ * infinite timeout are always placed at the very end. */
+ struct list_head flying_transfers;
+ usbi_mutex_t flying_transfers_lock;
+
+ /* user callbacks for pollfd changes */
+ libusb_pollfd_added_cb fd_added_cb;
+ libusb_pollfd_removed_cb fd_removed_cb;
+ void *fd_cb_user_data;
+
+ /* ensures that only one thread is handling events at any one time */
+ usbi_mutex_t events_lock;
+
+ /* used to see if there is an active thread doing event handling */
+ int event_handler_active;
+
+ /* A thread-local storage key to track which thread is performing event
+ * handling */
+ usbi_tls_key_t event_handling_key;
+
+ /* used to wait for event completion in threads other than the one that is
+ * event handling */
+ usbi_mutex_t event_waiters_lock;
+ usbi_cond_t event_waiters_cond;
+
+ /* A lock to protect internal context event data. */
+ usbi_mutex_t event_data_lock;
+
+ /* A counter that is set when we want to interrupt and prevent event handling,
+ * in order to safely close a device. Protected by event_data_lock. */
+ unsigned int device_close;
+
+ /* list and count of poll fds and an array of poll fd structures that is
+ * (re)allocated as necessary prior to polling, and a flag to indicate
+ * when the list of poll fds has changed since the last poll.
+ * Protected by event_data_lock. */
+ struct list_head ipollfds;
+ struct pollfd *pollfds;
+ POLL_NFDS_TYPE pollfds_cnt;
+ unsigned int pollfds_modified;
+
+ /* A list of pending hotplug messages. Protected by event_data_lock. */
+ struct list_head hotplug_msgs;
+
+ /* A list of pending completed transfers. Protected by event_data_lock. */
+ struct list_head completed_transfers;
+
+#ifdef USBI_TIMERFD_AVAILABLE
+ /* used for timeout handling, if supported by OS.
+ * this timerfd is maintained to trigger on the next pending timeout */
+ int timerfd;
+#endif
+
+ struct list_head list;
+};
+
+/* Macros for managing event handling state */
+#define usbi_handling_events(ctx) \
+ (usbi_tls_key_get((ctx)->event_handling_key) != NULL)
+
+#define usbi_start_event_handling(ctx) \
+ usbi_tls_key_set((ctx)->event_handling_key, ctx)
+
+#define usbi_end_event_handling(ctx) \
+ usbi_tls_key_set((ctx)->event_handling_key, NULL)
+
+/* Update the following macro if new event sources are added */
+#define usbi_pending_events(ctx) \
+ ((ctx)->device_close || (ctx)->pollfds_modified \
+ || !list_empty(&(ctx)->hotplug_msgs) || !list_empty(&(ctx)->completed_transfers))
+
+#ifdef USBI_TIMERFD_AVAILABLE
+#define usbi_using_timerfd(ctx) ((ctx)->timerfd >= 0)
+#else
+#define usbi_using_timerfd(ctx) (0)
+#endif
+
+struct libusb_device {
+ /* lock protects refcnt, everything else is finalized at initialization
+ * time */
+ usbi_mutex_t lock;
+ int refcnt;
+
+ struct libusb_context *ctx;
+
+ uint8_t bus_number;
+ uint8_t port_number;
+ struct libusb_device* parent_dev;
+ uint8_t device_address;
+ uint8_t num_configurations;
+ enum libusb_speed speed;
+
+ struct list_head list;
+ unsigned long session_data;
+
+ struct libusb_device_descriptor device_descriptor;
+ int attached;
+
+ unsigned char os_priv
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ [] /* valid C99 code */
+#else
+ [0] /* non-standard, but usually working code */
+#endif
+ ;
+};
+
+struct libusb_device_handle {
+ /* lock protects claimed_interfaces */
+ usbi_mutex_t lock;
+ unsigned long claimed_interfaces;
+
+ struct list_head list;
+ struct libusb_device *dev;
+ int auto_detach_kernel_driver;
+ unsigned char os_priv
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ [] /* valid C99 code */
+#else
+ [0] /* non-standard, but usually working code */
+#endif
+ ;
+};
+
+enum {
+ USBI_CLOCK_MONOTONIC,
+ USBI_CLOCK_REALTIME
+};
+
+/* in-memory transfer layout:
+ *
+ * 1. struct usbi_transfer
+ * 2. struct libusb_transfer (which includes iso packets) [variable size]
+ * 3. os private data [variable size]
+ *
+ * from a libusb_transfer, you can get the usbi_transfer by rewinding the
+ * appropriate number of bytes.
+ * the usbi_transfer includes the number of allocated packets, so you can
+ * determine the size of the transfer and hence the start and length of the
+ * OS-private data.
+ */
+
+struct usbi_transfer {
+ int num_iso_packets;
+ struct list_head list;
+ struct list_head completed_list;
+ struct timeval timeout;
+ int transferred;
+ uint32_t stream_id;
+ uint8_t flags;
+
+ /* this lock is held during libusb_submit_transfer() and
+ * libusb_cancel_transfer() (allowing the OS backend to prevent duplicate
+ * cancellation, submission-during-cancellation, etc). the OS backend
+ * should also take this lock in the handle_events path, to prevent the user
+ * cancelling the transfer from another thread while you are processing
+ * its completion (presumably there would be races within your OS backend
+ * if this were possible). */
+ usbi_mutex_t lock;
+
+ /* this lock should be held whenever viewing or modifying flags
+ * relating to the transfer state */
+ usbi_mutex_t flags_lock;
+};
+
+enum usbi_transfer_flags {
+ /* The transfer has timed out */
+ USBI_TRANSFER_TIMED_OUT = 1 << 0,
+
+ /* Set by backend submit_transfer() if the OS handles timeout */
+ USBI_TRANSFER_OS_HANDLES_TIMEOUT = 1 << 1,
+
+ /* Cancellation was requested via libusb_cancel_transfer() */
+ USBI_TRANSFER_CANCELLING = 1 << 2,
+
+ /* Operation on the transfer failed because the device disappeared */
+ USBI_TRANSFER_DEVICE_DISAPPEARED = 1 << 3,
+
+ /* Transfer is currently being submitted */
+ USBI_TRANSFER_SUBMITTING = 1 << 4,
+
+ /* Transfer successfully submitted by backend */
+ USBI_TRANSFER_IN_FLIGHT = 1 << 5,
+
+ /* Completion handler has run */
+ USBI_TRANSFER_COMPLETED = 1 << 6,
+
+ /* The transfer timeout has been handled */
+ USBI_TRANSFER_TIMEOUT_HANDLED = 1 << 7,
+};
+
+#define USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer) \
+ ((struct libusb_transfer *)(((unsigned char *)(transfer)) \
+ + sizeof(struct usbi_transfer)))
+#define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer) \
+ ((struct usbi_transfer *)(((unsigned char *)(transfer)) \
+ - sizeof(struct usbi_transfer)))
+
+static inline void *usbi_transfer_get_os_priv(struct usbi_transfer *transfer)
+{
+ return ((unsigned char *)transfer) + sizeof(struct usbi_transfer)
+ + sizeof(struct libusb_transfer)
+ + (transfer->num_iso_packets
+ * sizeof(struct libusb_iso_packet_descriptor));
+}
+
+/* bus structures */
+
+/* All standard descriptors have these 2 fields in common */
+struct usb_descriptor_header {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+};
+
+/* shared data and functions */
+
+int usbi_io_init(struct libusb_context *ctx);
+void usbi_io_exit(struct libusb_context *ctx);
+
+struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
+ unsigned long session_id);
+struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
+ unsigned long session_id);
+int usbi_sanitize_device(struct libusb_device *dev);
+void usbi_handle_disconnect(struct libusb_device_handle *handle);
+
+int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
+ enum libusb_transfer_status status);
+int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer);
+void usbi_signal_transfer_completion(struct usbi_transfer *transfer);
+
+int usbi_parse_descriptor(const unsigned char *source, const char *descriptor,
+ void *dest, int host_endian);
+int usbi_device_cache_descriptor(libusb_device *dev);
+int usbi_get_config_index_by_value(struct libusb_device *dev,
+ uint8_t bConfigurationValue, int *idx);
+
+void usbi_connect_device (struct libusb_device *dev);
+void usbi_disconnect_device (struct libusb_device *dev);
+
+int usbi_signal_event(struct libusb_context *ctx);
+int usbi_clear_event(struct libusb_context *ctx);
+
+/* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
+#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_HAIKU)
+#include
+#include "os/poll_posix.h"
+#elif defined(OS_WINDOWS) || defined(OS_WINCE)
+#include "os/poll_windows.h"
+#endif
+
+#if (defined(OS_WINDOWS) || defined(OS_WINCE)) && !defined(__GNUC__)
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+int usbi_gettimeofday(struct timeval *tp, void *tzp);
+#define LIBUSB_GETTIMEOFDAY_WIN32
+#define HAVE_USBI_GETTIMEOFDAY
+#else
+#ifdef HAVE_GETTIMEOFDAY
+#define usbi_gettimeofday(tv, tz) gettimeofday((tv), (tz))
+#define HAVE_USBI_GETTIMEOFDAY
+#endif
+#endif
+
+struct usbi_pollfd {
+ /* must come first */
+ struct libusb_pollfd pollfd;
+
+ struct list_head list;
+};
+
+int usbi_add_pollfd(struct libusb_context *ctx, int fd, short events);
+void usbi_remove_pollfd(struct libusb_context *ctx, int fd);
+
+/* device discovery */
+
+/* we traverse usbfs without knowing how many devices we are going to find.
+ * so we create this discovered_devs model which is similar to a linked-list
+ * which grows when required. it can be freed once discovery has completed,
+ * eliminating the need for a list node in the libusb_device structure
+ * itself. */
+struct discovered_devs {
+ size_t len;
+ size_t capacity;
+ struct libusb_device *devices
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ [] /* valid C99 code */
+#else
+ [0] /* non-standard, but usually working code */
+#endif
+ ;
+};
+
+struct discovered_devs *discovered_devs_append(
+ struct discovered_devs *discdevs, struct libusb_device *dev);
+
+/* OS abstraction */
+
+/* This is the interface that OS backends need to implement.
+ * All fields are mandatory, except ones explicitly noted as optional. */
+struct usbi_os_backend {
+ /* A human-readable name for your backend, e.g. "Linux usbfs" */
+ const char *name;
+
+ /* Binary mask for backend specific capabilities */
+ uint32_t caps;
+
+ /* Perform initialization of your backend. You might use this function
+ * to determine specific capabilities of the system, allocate required
+ * data structures for later, etc.
+ *
+ * This function is called when a libusb user initializes the library
+ * prior to use.
+ *
+ * Return 0 on success, or a LIBUSB_ERROR code on failure.
+ */
+ int (*init)(struct libusb_context *ctx);
+
+ /* Deinitialization. Optional. This function should destroy anything
+ * that was set up by init.
+ *
+ * This function is called when the user deinitializes the library.
+ */
+ void (*exit)(void);
+
+ /* Enumerate all the USB devices on the system, returning them in a list
+ * of discovered devices.
+ *
+ * Your implementation should enumerate all devices on the system,
+ * regardless of whether they have been seen before or not.
+ *
+ * When you have found a device, compute a session ID for it. The session
+ * ID should uniquely represent that particular device for that particular
+ * connection session since boot (i.e. if you disconnect and reconnect a
+ * device immediately after, it should be assigned a different session ID).
+ * If your OS cannot provide a unique session ID as described above,
+ * presenting a session ID of (bus_number << 8 | device_address) should
+ * be sufficient. Bus numbers and device addresses wrap and get reused,
+ * but that is an unlikely case.
+ *
+ * After computing a session ID for a device, call
+ * usbi_get_device_by_session_id(). This function checks if libusb already
+ * knows about the device, and if so, it provides you with a reference
+ * to a libusb_device structure for it.
+ *
+ * If usbi_get_device_by_session_id() returns NULL, it is time to allocate
+ * a new device structure for the device. Call usbi_alloc_device() to
+ * obtain a new libusb_device structure with reference count 1. Populate
+ * the bus_number and device_address attributes of the new device, and
+ * perform any other internal backend initialization you need to do. At
+ * this point, you should be ready to provide device descriptors and so
+ * on through the get_*_descriptor functions. Finally, call
+ * usbi_sanitize_device() to perform some final sanity checks on the
+ * device. Assuming all of the above succeeded, we can now continue.
+ * If any of the above failed, remember to unreference the device that
+ * was returned by usbi_alloc_device().
+ *
+ * At this stage we have a populated libusb_device structure (either one
+ * that was found earlier, or one that we have just allocated and
+ * populated). This can now be added to the discovered devices list
+ * using discovered_devs_append(). Note that discovered_devs_append()
+ * may reallocate the list, returning a new location for it, and also
+ * note that reallocation can fail. Your backend should handle these
+ * error conditions appropriately.
+ *
+ * This function should not generate any bus I/O and should not block.
+ * If I/O is required (e.g. reading the active configuration value), it is
+ * OK to ignore these suggestions :)
+ *
+ * This function is executed when the user wishes to retrieve a list
+ * of USB devices connected to the system.
+ *
+ * If the backend has hotplug support, this function is not used!
+ *
+ * Return 0 on success, or a LIBUSB_ERROR code on failure.
+ */
+ int (*get_device_list)(struct libusb_context *ctx,
+ struct discovered_devs **discdevs);
+
+ /* Apps which were written before hotplug support, may listen for
+ * hotplug events on their own and call libusb_get_device_list on
+ * device addition. In this case libusb_get_device_list will likely
+ * return a list without the new device in there, as the hotplug
+ * event thread will still be busy enumerating the device, which may
+ * take a while, or may not even have seen the event yet.
+ *
+ * To avoid this libusb_get_device_list will call this optional
+ * function for backends with hotplug support before copying
+ * ctx->usb_devs to the user. In this function the backend should
+ * ensure any pending hotplug events are fully processed before
+ * returning.
+ *
+ * Optional, should be implemented by backends with hotplug support.
+ */
+ void (*hotplug_poll)(void);
+
+ /* Open a device for I/O and other USB operations. The device handle
+ * is preallocated for you, you can retrieve the device in question
+ * through handle->dev.
+ *
+ * Your backend should allocate any internal resources required for I/O
+ * and other operations so that those operations can happen (hopefully)
+ * without hiccup. This is also a good place to inform libusb that it
+ * should monitor certain file descriptors related to this device -
+ * see the usbi_add_pollfd() function.
+ *
+ * This function should not generate any bus I/O and should not block.
+ *
+ * This function is called when the user attempts to obtain a device
+ * handle for a device.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_ACCESS if the user has insufficient permissions
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since
+ * discovery
+ * - another LIBUSB_ERROR code on other failure
+ *
+ * Do not worry about freeing the handle on failed open, the upper layers
+ * do this for you.
+ */
+ int (*open)(struct libusb_device_handle *handle);
+
+ int (*open2)(struct libusb_device_handle *handle, int fd);
+ struct libusb_device* (*device2)(struct libusb_context *ctx, const char *dev_node);
+
+ /* Close a device such that the handle cannot be used again. Your backend
+ * should destroy any resources that were allocated in the open path.
+ * This may also be a good place to call usbi_remove_pollfd() to inform
+ * libusb of any file descriptors associated with this device that should
+ * no longer be monitored.
+ *
+ * This function is called when the user closes a device handle.
+ */
+ void (*close)(struct libusb_device_handle *handle);
+
+ /* Retrieve the device descriptor from a device.
+ *
+ * The descriptor should be retrieved from memory, NOT via bus I/O to the
+ * device. This means that you may have to cache it in a private structure
+ * during get_device_list enumeration. Alternatively, you may be able
+ * to retrieve it from a kernel interface (some Linux setups can do this)
+ * still without generating bus I/O.
+ *
+ * This function is expected to write DEVICE_DESC_LENGTH (18) bytes into
+ * buffer, which is guaranteed to be big enough.
+ *
+ * This function is called when sanity-checking a device before adding
+ * it to the list of discovered devices, and also when the user requests
+ * to read the device descriptor.
+ *
+ * This function is expected to return the descriptor in bus-endian format
+ * (LE). If it returns the multi-byte values in host-endian format,
+ * set the host_endian output parameter to "1".
+ *
+ * Return 0 on success or a LIBUSB_ERROR code on failure.
+ */
+ int (*get_device_descriptor)(struct libusb_device *device,
+ unsigned char *buffer, int *host_endian);
+
+ /* Get the ACTIVE configuration descriptor for a device.
+ *
+ * The descriptor should be retrieved from memory, NOT via bus I/O to the
+ * device. This means that you may have to cache it in a private structure
+ * during get_device_list enumeration. You may also have to keep track
+ * of which configuration is active when the user changes it.
+ *
+ * This function is expected to write len bytes of data into buffer, which
+ * is guaranteed to be big enough. If you can only do a partial write,
+ * return an error code.
+ *
+ * This function is expected to return the descriptor in bus-endian format
+ * (LE). If it returns the multi-byte values in host-endian format,
+ * set the host_endian output parameter to "1".
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*get_active_config_descriptor)(struct libusb_device *device,
+ unsigned char *buffer, size_t len, int *host_endian);
+
+ /* Get a specific configuration descriptor for a device.
+ *
+ * The descriptor should be retrieved from memory, NOT via bus I/O to the
+ * device. This means that you may have to cache it in a private structure
+ * during get_device_list enumeration.
+ *
+ * The requested descriptor is expressed as a zero-based index (i.e. 0
+ * indicates that we are requesting the first descriptor). The index does
+ * not (necessarily) equal the bConfigurationValue of the configuration
+ * being requested.
+ *
+ * This function is expected to write len bytes of data into buffer, which
+ * is guaranteed to be big enough. If you can only do a partial write,
+ * return an error code.
+ *
+ * This function is expected to return the descriptor in bus-endian format
+ * (LE). If it returns the multi-byte values in host-endian format,
+ * set the host_endian output parameter to "1".
+ *
+ * Return the length read on success or a LIBUSB_ERROR code on failure.
+ */
+ int (*get_config_descriptor)(struct libusb_device *device,
+ uint8_t config_index, unsigned char *buffer, size_t len,
+ int *host_endian);
+
+ /* Like get_config_descriptor but then by bConfigurationValue instead
+ * of by index.
+ *
+ * Optional, if not present the core will call get_config_descriptor
+ * for all configs until it finds the desired bConfigurationValue.
+ *
+ * Returns a pointer to the raw-descriptor in *buffer, this memory
+ * is valid as long as device is valid.
+ *
+ * Returns the length of the returned raw-descriptor on success,
+ * or a LIBUSB_ERROR code on failure.
+ */
+ int (*get_config_descriptor_by_value)(struct libusb_device *device,
+ uint8_t bConfigurationValue, unsigned char **buffer,
+ int *host_endian);
+
+ /* Get the bConfigurationValue for the active configuration for a device.
+ * Optional. This should only be implemented if you can retrieve it from
+ * cache (don't generate I/O).
+ *
+ * If you cannot retrieve this from cache, either do not implement this
+ * function, or return LIBUSB_ERROR_NOT_SUPPORTED. This will cause
+ * libusb to retrieve the information through a standard control transfer.
+ *
+ * This function must be non-blocking.
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - LIBUSB_ERROR_NOT_SUPPORTED if the value cannot be retrieved without
+ * blocking
+ * - another LIBUSB_ERROR code on other failure.
+ */
+ int (*get_configuration)(struct libusb_device_handle *handle, int *config);
+
+ /* Set the active configuration for a device.
+ *
+ * A configuration value of -1 should put the device in unconfigured state.
+ *
+ * This function can block.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
+ * - LIBUSB_ERROR_BUSY if interfaces are currently claimed (and hence
+ * configuration cannot be changed)
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - another LIBUSB_ERROR code on other failure.
+ */
+ int (*set_configuration)(struct libusb_device_handle *handle, int config);
+
+ /* Claim an interface. When claimed, the application can then perform
+ * I/O to an interface's endpoints.
+ *
+ * This function should not generate any bus I/O and should not block.
+ * Interface claiming is a logical operation that simply ensures that
+ * no other drivers/applications are using the interface, and after
+ * claiming, no other drivers/applications can use the interface because
+ * we now "own" it.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if the interface does not exist
+ * - LIBUSB_ERROR_BUSY if the interface is in use by another driver/app
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*claim_interface)(struct libusb_device_handle *handle, int interface_number);
+
+ /* Release a previously claimed interface.
+ *
+ * This function should also generate a SET_INTERFACE control request,
+ * resetting the alternate setting of that interface to 0. It's OK for
+ * this function to block as a result.
+ *
+ * You will only ever be asked to release an interface which was
+ * successfully claimed earlier.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*release_interface)(struct libusb_device_handle *handle, int interface_number);
+
+ /* Set the alternate setting for an interface.
+ *
+ * You will only ever be asked to set the alternate setting for an
+ * interface which was successfully claimed earlier.
+ *
+ * It's OK for this function to block.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if the alternate setting does not exist
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*set_interface_altsetting)(struct libusb_device_handle *handle,
+ int interface_number, int altsetting);
+
+ /* Clear a halt/stall condition on an endpoint.
+ *
+ * It's OK for this function to block.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*clear_halt)(struct libusb_device_handle *handle,
+ unsigned char endpoint);
+
+ /* Perform a USB port reset to reinitialize a device.
+ *
+ * If possible, the handle should still be usable after the reset
+ * completes, assuming that the device descriptors did not change during
+ * reset and all previous interface state can be restored.
+ *
+ * If something changes, or you cannot easily locate/verify the resetted
+ * device, return LIBUSB_ERROR_NOT_FOUND. This prompts the application
+ * to close the old handle and re-enumerate the device.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the device
+ * has been disconnected since it was opened
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*reset_device)(struct libusb_device_handle *handle);
+
+ /* Alloc num_streams usb3 bulk streams on the passed in endpoints */
+ int (*alloc_streams)(struct libusb_device_handle *handle,
+ uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
+
+ /* Free usb3 bulk streams allocated with alloc_streams */
+ int (*free_streams)(struct libusb_device_handle *handle,
+ unsigned char *endpoints, int num_endpoints);
+
+ /* Determine if a kernel driver is active on an interface. Optional.
+ *
+ * The presence of a kernel driver on an interface indicates that any
+ * calls to claim_interface would fail with the LIBUSB_ERROR_BUSY code.
+ *
+ * Return:
+ * - 0 if no driver is active
+ * - 1 if a driver is active
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*kernel_driver_active)(struct libusb_device_handle *handle,
+ int interface_number);
+
+ /* Detach a kernel driver from an interface. Optional.
+ *
+ * After detaching a kernel driver, the interface should be available
+ * for claim.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
+ * - LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*detach_kernel_driver)(struct libusb_device_handle *handle,
+ int interface_number);
+
+ /* Attach a kernel driver to an interface. Optional.
+ *
+ * Reattach a kernel driver to the device.
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
+ * - LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
+ * was opened
+ * - LIBUSB_ERROR_BUSY if a program or driver has claimed the interface,
+ * preventing reattachment
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*attach_kernel_driver)(struct libusb_device_handle *handle,
+ int interface_number);
+
+ /* Destroy a device. Optional.
+ *
+ * This function is called when the last reference to a device is
+ * destroyed. It should free any resources allocated in the get_device_list
+ * path.
+ */
+ void (*destroy_device)(struct libusb_device *dev);
+
+ /* Submit a transfer. Your implementation should take the transfer,
+ * morph it into whatever form your platform requires, and submit it
+ * asynchronously.
+ *
+ * This function must not block.
+ *
+ * This function gets called with the flying_transfers_lock locked!
+ *
+ * Return:
+ * - 0 on success
+ * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
+ * - another LIBUSB_ERROR code on other failure
+ */
+ int (*submit_transfer)(struct usbi_transfer *itransfer);
+
+ /* Cancel a previously submitted transfer.
+ *
+ * This function must not block. The transfer cancellation must complete
+ * later, resulting in a call to usbi_handle_transfer_cancellation()
+ * from the context of handle_events.
+ */
+ int (*cancel_transfer)(struct usbi_transfer *itransfer);
+
+ /* Clear a transfer as if it has completed or cancelled, but do not
+ * report any completion/cancellation to the library. You should free
+ * all private data from the transfer as if you were just about to report
+ * completion or cancellation.
+ *
+ * This function might seem a bit out of place. It is used when libusb
+ * detects a disconnected device - it calls this function for all pending
+ * transfers before reporting completion (with the disconnect code) to
+ * the user. Maybe we can improve upon this internal interface in future.
+ */
+ void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
+
+ /* Handle any pending events on file descriptors. Optional.
+ *
+ * Provide this function when file descriptors directly indicate device
+ * or transfer activity. If your backend does not have such file descriptors,
+ * implement the handle_transfer_completion function below.
+ *
+ * This involves monitoring any active transfers and processing their
+ * completion or cancellation.
+ *
+ * The function is passed an array of pollfd structures (size nfds)
+ * as a result of the poll() system call. The num_ready parameter
+ * indicates the number of file descriptors that have reported events
+ * (i.e. the poll() return value). This should be enough information
+ * for you to determine which actions need to be taken on the currently
+ * active transfers.
+ *
+ * For any cancelled transfers, call usbi_handle_transfer_cancellation().
+ * For completed transfers, call usbi_handle_transfer_completion().
+ * For control/bulk/interrupt transfers, populate the "transferred"
+ * element of the appropriate usbi_transfer structure before calling the
+ * above functions. For isochronous transfers, populate the status and
+ * transferred fields of the iso packet descriptors of the transfer.
+ *
+ * This function should also be able to detect disconnection of the
+ * device, reporting that situation with usbi_handle_disconnect().
+ *
+ * When processing an event related to a transfer, you probably want to
+ * take usbi_transfer.lock to prevent races. See the documentation for
+ * the usbi_transfer structure.
+ *
+ * Return 0 on success, or a LIBUSB_ERROR code on failure.
+ */
+ int (*handle_events)(struct libusb_context *ctx,
+ struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready);
+
+ /* Handle transfer completion. Optional.
+ *
+ * Provide this function when there are no file descriptors available
+ * that directly indicate device or transfer activity. If your backend does
+ * have such file descriptors, implement the handle_events function above.
+ *
+ * Your backend must tell the library when a transfer has completed by
+ * calling usbi_signal_transfer_completion(). You should store any private
+ * information about the transfer and its completion status in the transfer's
+ * private backend data.
+ *
+ * During event handling, this function will be called on each transfer for
+ * which usbi_signal_transfer_completion() was called.
+ *
+ * For any cancelled transfers, call usbi_handle_transfer_cancellation().
+ * For completed transfers, call usbi_handle_transfer_completion().
+ * For control/bulk/interrupt transfers, populate the "transferred"
+ * element of the appropriate usbi_transfer structure before calling the
+ * above functions. For isochronous transfers, populate the status and
+ * transferred fields of the iso packet descriptors of the transfer.
+ *
+ * Return 0 on success, or a LIBUSB_ERROR code on failure.
+ */
+ int (*handle_transfer_completion)(struct usbi_transfer *itransfer);
+
+ /* Get time from specified clock. At least two clocks must be implemented
+ by the backend: USBI_CLOCK_REALTIME, and USBI_CLOCK_MONOTONIC.
+
+ Description of clocks:
+ USBI_CLOCK_REALTIME : clock returns time since system epoch.
+ USBI_CLOCK_MONOTONIC: clock returns time since unspecified start
+ time (usually boot).
+ */
+ int (*clock_gettime)(int clkid, struct timespec *tp);
+
+#ifdef USBI_TIMERFD_AVAILABLE
+ /* clock ID of the clock that should be used for timerfd */
+ clockid_t (*get_timerfd_clockid)(void);
+#endif
+
+ /* Number of bytes to reserve for per-device private backend data.
+ * This private data area is accessible through the "os_priv" field of
+ * struct libusb_device. */
+ size_t device_priv_size;
+
+ /* Number of bytes to reserve for per-handle private backend data.
+ * This private data area is accessible through the "os_priv" field of
+ * struct libusb_device. */
+ size_t device_handle_priv_size;
+
+ /* Number of bytes to reserve for per-transfer private backend data.
+ * This private data area is accessible by calling
+ * usbi_transfer_get_os_priv() on the appropriate usbi_transfer instance.
+ */
+ size_t transfer_priv_size;
+};
+
+extern const struct usbi_os_backend * const usbi_backend;
+
+extern const struct usbi_os_backend linux_usbfs_backend;
+extern const struct usbi_os_backend darwin_backend;
+extern const struct usbi_os_backend openbsd_backend;
+extern const struct usbi_os_backend netbsd_backend;
+extern const struct usbi_os_backend windows_backend;
+extern const struct usbi_os_backend wince_backend;
+extern const struct usbi_os_backend haiku_usb_raw_backend;
+
+extern struct list_head active_contexts_list;
+extern usbi_mutex_static_t active_contexts_lock;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/libusbi.h.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/libusbi.h.REMOVED.git-id
deleted file mode 100644
index 4e246480..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/libusbi.h.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-447ad045f8135dffc3b13c6393d3c0851594dceb
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_netlink.c b/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_netlink.c
new file mode 100644
index 00000000..96deeac7
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_netlink.c
@@ -0,0 +1,375 @@
+/* -*- Mode: C; c-basic-offset:8 ; indent-tabs-mode:t -*- */
+/*
+ * Linux usbfs backend for libusb
+ * Copyright (C) 2007-2009 Daniel Drake
+ * Copyright (c) 2001 Johannes Erdfelt
+ * Copyright (c) 2013 Nathan Hjelm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef HAVE_ASM_TYPES_H
+#include
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+
+#include
+
+#ifdef HAVE_LINUX_NETLINK_H
+#include
+#endif
+
+#ifdef HAVE_LINUX_FILTER_H
+#include
+#endif
+
+#include "libusbi.h"
+#include "linux_usbfs.h"
+
+#define KERNEL 1
+
+static int linux_netlink_socket = -1;
+static int netlink_control_pipe[2] = { -1, -1 };
+static pthread_t libusb_linux_event_thread;
+
+static void *linux_netlink_event_thread_main(void *arg);
+
+static struct sockaddr_nl snl = { .nl_family=AF_NETLINK, .nl_groups=KERNEL };
+
+static int set_fd_cloexec_nb(int fd)
+{
+ int flags;
+
+#if defined(FD_CLOEXEC)
+ flags = fcntl(fd, F_GETFD);
+ if (0 > flags) {
+ return -1;
+ }
+
+ if (!(flags & FD_CLOEXEC)) {
+ fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+ }
+#endif
+
+ flags = fcntl(fd, F_GETFL);
+ if (0 > flags) {
+ return -1;
+ }
+
+ if (!(flags & O_NONBLOCK)) {
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+ }
+
+ return 0;
+}
+
+int linux_netlink_start_event_monitor(void)
+{
+ int socktype = SOCK_RAW;
+ int ret;
+
+ snl.nl_groups = KERNEL;
+
+#if defined(SOCK_CLOEXEC)
+ socktype |= SOCK_CLOEXEC;
+#endif
+#if defined(SOCK_NONBLOCK)
+ socktype |= SOCK_NONBLOCK;
+#endif
+
+ linux_netlink_socket = socket(PF_NETLINK, socktype, NETLINK_KOBJECT_UEVENT);
+ if (-1 == linux_netlink_socket && EINVAL == errno) {
+ linux_netlink_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);
+ }
+
+ if (-1 == linux_netlink_socket) {
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ ret = set_fd_cloexec_nb (linux_netlink_socket);
+ if (0 != ret) {
+ close (linux_netlink_socket);
+ linux_netlink_socket = -1;
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ ret = bind(linux_netlink_socket, (struct sockaddr *) &snl, sizeof(snl));
+ if (0 != ret) {
+ close(linux_netlink_socket);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ /* TODO -- add authentication */
+ /* setsockopt(linux_netlink_socket, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)); */
+
+ ret = usbi_pipe(netlink_control_pipe);
+ if (ret) {
+ usbi_err(NULL, "could not create netlink control pipe");
+ close(linux_netlink_socket);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ ret = pthread_create(&libusb_linux_event_thread, NULL, linux_netlink_event_thread_main, NULL);
+ if (0 != ret) {
+ close(netlink_control_pipe[0]);
+ close(netlink_control_pipe[1]);
+ close(linux_netlink_socket);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return LIBUSB_SUCCESS;
+}
+
+int linux_netlink_stop_event_monitor(void)
+{
+ int r;
+ char dummy = 1;
+
+ if (-1 == linux_netlink_socket) {
+ /* already closed. nothing to do */
+ return LIBUSB_SUCCESS;
+ }
+
+ /* Write some dummy data to the control pipe and
+ * wait for the thread to exit */
+ r = usbi_write(netlink_control_pipe[1], &dummy, sizeof(dummy));
+ if (r <= 0) {
+ usbi_warn(NULL, "netlink control pipe signal failed");
+ }
+ pthread_join(libusb_linux_event_thread, NULL);
+
+ close(linux_netlink_socket);
+ linux_netlink_socket = -1;
+
+ /* close and reset control pipe */
+ close(netlink_control_pipe[0]);
+ close(netlink_control_pipe[1]);
+ netlink_control_pipe[0] = -1;
+ netlink_control_pipe[1] = -1;
+
+ return LIBUSB_SUCCESS;
+}
+
+static const char *netlink_message_parse (const char *buffer, size_t len, const char *key)
+{
+ size_t keylen = strlen(key);
+ size_t offset;
+
+ for (offset = 0 ; offset < len && '\0' != buffer[offset] ; offset += strlen(buffer + offset) + 1) {
+ if (0 == strncmp(buffer + offset, key, keylen) &&
+ '=' == buffer[offset + keylen]) {
+ return buffer + offset + keylen + 1;
+ }
+ }
+
+ return NULL;
+}
+
+/* parse parts of netlink message common to both libudev and the kernel */
+static int linux_netlink_parse(char *buffer, size_t len, int *detached, const char **sys_name,
+ uint8_t *busnum, uint8_t *devaddr) {
+ const char *tmp;
+ int i;
+
+ errno = 0;
+
+ *sys_name = NULL;
+ *detached = 0;
+ *busnum = 0;
+ *devaddr = 0;
+
+ tmp = netlink_message_parse((const char *) buffer, len, "ACTION");
+ if (tmp == NULL)
+ return -1;
+ if (0 == strcmp(tmp, "remove")) {
+ *detached = 1;
+ } else if (0 != strcmp(tmp, "add")) {
+ usbi_dbg("unknown device action %s", tmp);
+ return -1;
+ }
+
+ /* check that this is a usb message */
+ tmp = netlink_message_parse(buffer, len, "SUBSYSTEM");
+ if (NULL == tmp || 0 != strcmp(tmp, "usb")) {
+ /* not usb. ignore */
+ return -1;
+ }
+
+ /* check that this is an actual usb device */
+ tmp = netlink_message_parse(buffer, len, "DEVTYPE");
+ if (NULL == tmp || 0 != strcmp(tmp, "usb_device")) {
+ /* not usb. ignore */
+ return -1;
+ }
+
+ tmp = netlink_message_parse(buffer, len, "BUSNUM");
+ if (NULL == tmp) {
+ /* no bus number. try "DEVICE" */
+ tmp = netlink_message_parse(buffer, len, "DEVICE");
+ if (NULL == tmp) {
+ /* not usb. ignore */
+ return -1;
+ }
+
+ /* Parse a device path such as /dev/bus/usb/003/004 */
+ char *pLastSlash = (char*)strrchr(tmp,'/');
+ if(NULL == pLastSlash) {
+ return -1;
+ }
+
+ *devaddr = strtoul(pLastSlash + 1, NULL, 10);
+ if (errno) {
+ errno = 0;
+ return -1;
+ }
+
+ *busnum = strtoul(pLastSlash - 3, NULL, 10);
+ if (errno) {
+ errno = 0;
+ return -1;
+ }
+
+ return 0;
+ }
+
+ *busnum = (uint8_t)(strtoul(tmp, NULL, 10) & 0xff);
+ if (errno) {
+ errno = 0;
+ return -1;
+ }
+
+ tmp = netlink_message_parse(buffer, len, "DEVNUM");
+ if (NULL == tmp) {
+ return -1;
+ }
+
+ *devaddr = (uint8_t)(strtoul(tmp, NULL, 10) & 0xff);
+ if (errno) {
+ errno = 0;
+ return -1;
+ }
+
+ tmp = netlink_message_parse(buffer, len, "DEVPATH");
+ if (NULL == tmp) {
+ return -1;
+ }
+
+ for (i = strlen(tmp) - 1 ; i ; --i) {
+ if ('/' ==tmp[i]) {
+ *sys_name = tmp + i + 1;
+ break;
+ }
+ }
+
+ /* found a usb device */
+ return 0;
+}
+
+static int linux_netlink_read_message(void)
+{
+ unsigned char buffer[1024];
+ struct iovec iov = {.iov_base = buffer, .iov_len = sizeof(buffer)};
+ struct msghdr meh = { .msg_iov=&iov, .msg_iovlen=1,
+ .msg_name=&snl, .msg_namelen=sizeof(snl) };
+ const char *sys_name = NULL;
+ uint8_t busnum, devaddr;
+ int detached, r;
+ size_t len;
+
+ /* read netlink message */
+ memset(buffer, 0, sizeof(buffer));
+ len = recvmsg(linux_netlink_socket, &meh, 0);
+ if (len < 32) {
+ if (errno != EAGAIN)
+ usbi_dbg("error recieving message from netlink");
+ return -1;
+ }
+
+ /* TODO -- authenticate this message is from the kernel or udevd */
+
+ r = linux_netlink_parse(buffer, len, &detached, &sys_name,
+ &busnum, &devaddr);
+ if (r)
+ return r;
+
+ usbi_dbg("netlink hotplug found device busnum: %hhu, devaddr: %hhu, sys_name: %s, removed: %s",
+ busnum, devaddr, sys_name, detached ? "yes" : "no");
+
+ /* signal device is available (or not) to all contexts */
+ if (detached)
+ linux_device_disconnected(busnum, devaddr);
+ else
+ linux_hotplug_enumerate(busnum, devaddr, sys_name);
+
+ return 0;
+}
+
+static void *linux_netlink_event_thread_main(void *arg)
+{
+ char dummy;
+ int r;
+ struct pollfd fds[] = {
+ { .fd = netlink_control_pipe[0],
+ .events = POLLIN },
+ { .fd = linux_netlink_socket,
+ .events = POLLIN },
+ };
+
+ UNUSED(arg);
+
+ while (poll(fds, 2, -1) >= 0) {
+ if (fds[0].revents & POLLIN) {
+ /* activity on control pipe, read the byte and exit */
+ r = usbi_read(netlink_control_pipe[0], &dummy, sizeof(dummy));
+ if (r <= 0) {
+ usbi_warn(NULL, "netlink control pipe read failed");
+ }
+ break;
+ }
+ if (fds[1].revents & POLLIN) {
+ usbi_mutex_static_lock(&linux_hotplug_lock);
+ linux_netlink_read_message();
+ usbi_mutex_static_unlock(&linux_hotplug_lock);
+ }
+ }
+
+ return NULL;
+}
+
+void linux_netlink_hotplug_poll(void)
+{
+ int r;
+
+ usbi_mutex_static_lock(&linux_hotplug_lock);
+ do {
+ r = linux_netlink_read_message();
+ } while (r == 0);
+ usbi_mutex_static_unlock(&linux_hotplug_lock);
+}
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_netlink.c.REMOVED.git-id b/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_netlink.c.REMOVED.git-id
deleted file mode 100644
index 465b38a5..00000000
--- a/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_netlink.c.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-96deeac762bf98ea7c35ffd6c1facd197142b0f2
\ No newline at end of file
diff --git a/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_usbfs.c b/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_usbfs.c
new file mode 100644
index 00000000..6b43770a
--- /dev/null
+++ b/Desktop_Interface/build_android/libusb-martin-kuldeep/os/linux_usbfs.c
@@ -0,0 +1,2795 @@
+/* -*- Mode: C; c-basic-offset:8 ; indent-tabs-mode:t -*- */
+/*
+ * Linux usbfs backend for libusb
+ * Copyright © 2007-2009 Daniel Drake
+ * Copyright © 2001 Johannes Erdfelt
+ * Copyright © 2013 Nathan Hjelm
+ * Copyright © 2012-2013 Hans de Goede
+ * Copyright © 2013-2016 Martin Marinov
+ * Copyright © 2015 Kuldeep Singh Dhaka
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include