From 7d7c1d55483b4d1252651925b6a111c49f5a8e73 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 2 Jun 2014 10:39:24 -0400 Subject: [PATCH 01/35] Update heads --- examples/testusbhostFAT/RTClib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index 7fd6a306..31e9226c 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b +Subproject commit 31e9226c2098f9d516c4fe05befe07f542ee5740 From 26cb553f54ad451d88a6b51aba6c9ddcba2e0c48 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 06:12:11 -0400 Subject: [PATCH 02/35] Merge in RTClib changes --- examples/testusbhostFAT/RTClib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index 31e9226c..7fd6a306 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit 31e9226c2098f9d516c4fe05befe07f542ee5740 +Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b From b53c809eaadcfef9504fcc4df86c0a1704e41b27 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 06:13:07 -0400 Subject: [PATCH 03/35] Move ftdi to new early enumeration --- cdcftdi.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cdcftdi.h b/cdcftdi.h index 866e2d7d..692ec6b0 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -128,6 +128,11 @@ public: // UsbConfigXtracter implementation virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + + virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + return (vid == FTDI_VID && pid == FTDI_PID); + } + }; #endif // __CDCFTDI_H__ From 900af96c9c710bb4561a7913f840697eaef5d503 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 06:15:19 -0400 Subject: [PATCH 04/35] Merge master --- examples/testusbhostFAT/Arduino_Makefile_master | 2 +- examples/testusbhostFAT/RTClib | 2 +- examples/testusbhostFAT/generic_storage | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/testusbhostFAT/Arduino_Makefile_master b/examples/testusbhostFAT/Arduino_Makefile_master index 7ada91a9..d35bb955 160000 --- a/examples/testusbhostFAT/Arduino_Makefile_master +++ b/examples/testusbhostFAT/Arduino_Makefile_master @@ -1 +1 @@ -Subproject commit 7ada91a90027ccb7558b74087fb68d3940ecf64d +Subproject commit d35bb955e3818f0c14e47c8a1998003da8dc1b5a diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index b119b97e..7fd6a306 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit b119b97e1484a08aebcf24e070113d78c82fb023 +Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b diff --git a/examples/testusbhostFAT/generic_storage b/examples/testusbhostFAT/generic_storage index 72b5bf46..0b8e3076 160000 --- a/examples/testusbhostFAT/generic_storage +++ b/examples/testusbhostFAT/generic_storage @@ -1 +1 @@ -Subproject commit 72b5bf467a1c2479ba7354ee4d864e382c167425 +Subproject commit 0b8e3076b5a072251e01cfc6e6333b364d4e71e7 From a58c6db5806f5938f739b3d01b0ea82c68da8bbc Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 08:46:40 -0400 Subject: [PATCH 05/35] Check subclasses during enumeration --- Usb.cpp | 11 +++++++---- UsbCore.h | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Usb.cpp b/Usb.cpp index ca81cf99..15047946 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -698,17 +698,20 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { // Allocate new address according to device class //bAddress = addrPool.AllocAddress(parent, false, port); - //if (!bAddress) - // return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; uint16_t vid = udd->idVendor; uint16_t pid = udd->idProduct; uint8_t klass = udd->bDeviceClass; - + uint8_t subklass = udd->bDeviceSubClass; // Attempt to configure if VID/PID or device class matches with a driver + // Qualify with subclass too. + // + // VID/PID & class tests default to false for drivers not yet ported + // subclass defaults to true, so you don't have to define it if you don't have to. + // for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { if(!devConfig[devConfigIndex]) continue; // no driver if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) { + if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) { rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); if(rcode != USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED) break; diff --git a/UsbCore.h b/UsbCore.h index 76d9d5ee..f514195c 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -150,6 +150,11 @@ public: virtual boolean DEVCLASSOK(uint8_t klass) { return false; } + + virtual boolean DEVSUBCLASSOK(uint8_t subklass) { + return true; + } + }; /* USB Setup Packet Structure */ From f2bfe0671e530dca358adc51dad0bd3173bc0731 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 08:47:03 -0400 Subject: [PATCH 06/35] Check subclasses during enumeration --- hidboot.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hidboot.h b/hidboot.h index 0326bf25..b35df7cb 100644 --- a/hidboot.h +++ b/hidboot.h @@ -214,6 +214,14 @@ public: // UsbConfigXtracter implementation virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + + virtual boolean DEVCLASSOK(uint8_t klass) { + return (klass == USB_CLASS_HID); + } + + virtual boolean DEVSUBCLASSOK(uint8_t subklass) { + return (subklass == BOOT_PROTOCOL); + } }; template From 2224dd96cbf64f1184b3d74649e0a5679f398c59 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 4 Aug 2014 08:47:15 -0400 Subject: [PATCH 07/35] Check subclasses during enumeration --- cdcftdi.cpp | 2 +- cdcftdi.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cdcftdi.cpp b/cdcftdi.cpp index 13ca683f..8f07b358 100644 --- a/cdcftdi.cpp +++ b/cdcftdi.cpp @@ -246,7 +246,7 @@ uint8_t FTDI::Release() { bNumEP = 1; qNextPollTime = 0; bPollEnable = false; - return 0; + return pAsync->OnRelease(this); } uint8_t FTDI::Poll() { diff --git a/cdcftdi.h b/cdcftdi.h index 692ec6b0..fbb7396d 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -79,6 +79,7 @@ class FTDI; class FTDIAsyncOper { public: virtual uint8_t OnInit(FTDI *pftdi) = 0; + virtual uint8_t OnRelease(FTDI *pftdi) = 0; }; From 69fa08d141931f9d91737a86551b0d1b47e8e182 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Wed, 10 Sep 2014 00:21:01 -0700 Subject: [PATCH 08/35] Check DEVSUBCLASSOK as well when blindly attempt to configure --- Usb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Usb.cpp b/Usb.cpp index 15047946..37914046 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -727,7 +727,7 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { if(!devConfig[devConfigIndex]) continue; if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above + if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); //printf("ERROR ENUMERATING %2.2x\r\n", rcode); From 961bf1c4aea41db27085251ce4e67f8f1fb34714 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Wed, 10 Sep 2014 00:27:55 -0700 Subject: [PATCH 09/35] Update submodules --- examples/testusbhostFAT/Arduino_Makefile_master | 2 +- examples/testusbhostFAT/RTClib | 2 +- examples/testusbhostFAT/generic_storage | 2 +- examples/testusbhostFAT/xmem2 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/testusbhostFAT/Arduino_Makefile_master b/examples/testusbhostFAT/Arduino_Makefile_master index d35bb955..1edd5f46 160000 --- a/examples/testusbhostFAT/Arduino_Makefile_master +++ b/examples/testusbhostFAT/Arduino_Makefile_master @@ -1 +1 @@ -Subproject commit d35bb955e3818f0c14e47c8a1998003da8dc1b5a +Subproject commit 1edd5f46188a6c4b68d6f9120fa72359a12e38f1 diff --git a/examples/testusbhostFAT/RTClib b/examples/testusbhostFAT/RTClib index 7fd6a306..b119b97e 160000 --- a/examples/testusbhostFAT/RTClib +++ b/examples/testusbhostFAT/RTClib @@ -1 +1 @@ -Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b +Subproject commit b119b97e1484a08aebcf24e070113d78c82fb023 diff --git a/examples/testusbhostFAT/generic_storage b/examples/testusbhostFAT/generic_storage index 0b8e3076..72b5bf46 160000 --- a/examples/testusbhostFAT/generic_storage +++ b/examples/testusbhostFAT/generic_storage @@ -1 +1 @@ -Subproject commit 0b8e3076b5a072251e01cfc6e6333b364d4e71e7 +Subproject commit 72b5bf467a1c2479ba7354ee4d864e382c167425 diff --git a/examples/testusbhostFAT/xmem2 b/examples/testusbhostFAT/xmem2 index 2bf8f633..3b5455a2 160000 --- a/examples/testusbhostFAT/xmem2 +++ b/examples/testusbhostFAT/xmem2 @@ -1 +1 @@ -Subproject commit 2bf8f633e7f9bc5a7bf4c00f3f45c7b79484198e +Subproject commit 3b5455a20526208ad84215dcb40a51c8e000b507 From 64e3f92700ed6bbd739f5ab7a75f0695cd950046 Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Mon, 22 Sep 2014 17:03:16 -0600 Subject: [PATCH 10/35] gh sync --- examples/testusbhostFAT/Arduino_Makefile_master | 2 +- examples/testusbhostFAT/generic_storage | 2 +- examples/testusbhostFAT/xmem2 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/testusbhostFAT/Arduino_Makefile_master b/examples/testusbhostFAT/Arduino_Makefile_master index 1edd5f46..f379bae0 160000 --- a/examples/testusbhostFAT/Arduino_Makefile_master +++ b/examples/testusbhostFAT/Arduino_Makefile_master @@ -1 +1 @@ -Subproject commit 1edd5f46188a6c4b68d6f9120fa72359a12e38f1 +Subproject commit f379bae02aa3d9c3da558ba2041558b88db95bbb diff --git a/examples/testusbhostFAT/generic_storage b/examples/testusbhostFAT/generic_storage index 72b5bf46..071b65b9 160000 --- a/examples/testusbhostFAT/generic_storage +++ b/examples/testusbhostFAT/generic_storage @@ -1 +1 @@ -Subproject commit 72b5bf467a1c2479ba7354ee4d864e382c167425 +Subproject commit 071b65b923b2656bb1e1b622de5272b4ed9a4996 diff --git a/examples/testusbhostFAT/xmem2 b/examples/testusbhostFAT/xmem2 index 3b5455a2..8bcf5f90 160000 --- a/examples/testusbhostFAT/xmem2 +++ b/examples/testusbhostFAT/xmem2 @@ -1 +1 @@ -Subproject commit 3b5455a20526208ad84215dcb40a51c8e000b507 +Subproject commit 8bcf5f90f8bd967378b6eeebd7fd943f125fbc18 From 4ccbea7f36c8dc562d3607a4218db390e6fbe55b Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Mon, 22 Sep 2014 17:48:40 -0600 Subject: [PATCH 11/35] Send Report added to hiduniversal --- hiduniversal.cpp | 6 ++++++ hiduniversal.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/hiduniversal.cpp b/hiduniversal.cpp index e7a65e39..3cca8cfb 100644 --- a/hiduniversal.cpp +++ b/hiduniversal.cpp @@ -418,3 +418,9 @@ uint8_t HIDUniversal::Poll() { } return rcode; } + + +//Send a report to interrupt out endpoint. This is NOT SetReport() request! +uint8_t HIDUniversal::SndRpt(uint16_t nbytes, uint8_t *dataptr) { + return pUsb->outTransfer(bAddress, epInfo[epInterruptOutIndex].epAddr, nbytes, dataptr); +} \ No newline at end of file diff --git a/hiduniversal.h b/hiduniversal.h index 3e090aa7..5fd7e6b7 100644 --- a/hiduniversal.h +++ b/hiduniversal.h @@ -100,6 +100,9 @@ public: // UsbConfigXtracter implementation virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + + //Send report - do not mix with SetReport()! + uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr); }; #endif // __HIDUNIVERSAL_H__ From 740fa097e67dc9e7695150539398b7b18411561b Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 22 Sep 2014 22:53:11 -0400 Subject: [PATCH 12/35] Add support for MIPS uC (PIC32X) and the ancient mpide "IDE" used for it --- avrpins.h | 45 ++++++++++ settings.h | 18 ++-- usbhost.h | 16 ++-- version_helper.h | 222 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 284 insertions(+), 17 deletions(-) create mode 100644 version_helper.h diff --git a/avrpins.h b/avrpins.h index c59e9c52..afdf0b85 100644 --- a/avrpins.h +++ b/avrpins.h @@ -952,4 +952,49 @@ MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected #endif // __arm__ +#if defined(__MIPSEL__) +// MIPSEL (MIPS architecture using a little endian byte order) + +// MIPS size_t = 4 +#define pgm_read_pointer(p) pgm_read_dword(p) + +#define MAKE_PIN(className, pin) \ +class className { \ +public: \ + static void Set() { \ + digitalWrite(pin, HIGH);\ + } \ + static void Clear() { \ + digitalWrite(pin, LOW); \ + } \ + static void SetDirRead() { \ + pinMode(pin, INPUT); \ + } \ + static void SetDirWrite() { \ + pinMode(pin, OUTPUT); \ + } \ + static uint8_t IsSet() { \ + return digitalRead(pin); \ + } \ +}; + +// 0 .. 13 - Digital pins +MAKE_PIN(P0, 0); // RX +MAKE_PIN(P1, 1); // TX +MAKE_PIN(P2, 2); // +MAKE_PIN(P3, 3); // +MAKE_PIN(P4, 4); // +MAKE_PIN(P5, 5); // +MAKE_PIN(P6, 6); // +MAKE_PIN(P7, 7); // +MAKE_PIN(P8, 8); // +MAKE_PIN(P9, 9); // +MAKE_PIN(P10, 10); // +MAKE_PIN(P11, 11); // +MAKE_PIN(P12, 12); // +MAKE_PIN(P13, 13); // + +#undef MAKE_PIN +#endif + #endif //_avrpins_h_ diff --git a/settings.h b/settings.h index e3d0ed1d..82c07036 100644 --- a/settings.h +++ b/settings.h @@ -78,15 +78,7 @@ e-mail : support@circuitsathome.com // No user serviceable parts below this line. // DO NOT change anything below here unless you are a developer! -#if defined(ARDUINO) && ARDUINO >=100 -#include -#else -#include -#include -#include -#include -#define F(str) (str) -#endif +#include "version_helper.h" #if defined(__GNUC__) && defined(__AVR__) #ifndef GCC_VERSION @@ -137,8 +129,10 @@ e-mail : support@circuitsathome.com #define USING_SPI4TEENSY3 0 #endif -#if defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) -#include // Use the Arduino SPI library for the Arduino Due +#if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) +#include // Use the Arduino SPI library +#endif +#if defined(__PIC32MX__) || defined(__PIC32MZ__) +#include <../../libraries/SPI/SPI.h> // Hack to use the SPI library #endif - #endif /* SETTINGS_H */ diff --git a/usbhost.h b/usbhost.h index cf26c1f0..f0a6962e 100644 --- a/usbhost.h +++ b/usbhost.h @@ -39,12 +39,16 @@ public: SPI_SS::SetDirWrite(); SPI_SS::Set(); } -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) static void init() { SPI_SS::SetDirWrite(); SPI_SS::Set(); SPI.begin(); +#if defined(__MIPSEL__) + SPI.setClockDivider(2); +#else SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz +#endif } #else static void init() { @@ -74,6 +78,8 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi; typedef SPi< P13, P11, P12, P10 > spi; #elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) typedef SPi< P76, P75, P74, P10 > spi; +#elif defined(__MIPSEL__) +typedef SPi< P13, P11, P12, P10 > spi; #else #error "No SPI entry in usbhost.h" #endif @@ -135,7 +141,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) { c[0] = reg | 0x02; c[1] = data; spi4teensy3::send(c, 2); -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg | 0x02); SPI.transfer(data); #else @@ -159,7 +165,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* spi4teensy3::send(reg | 0x02); spi4teensy3::send(data_p, nbytes); data_p += nbytes; -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg | 0x02); while(nbytes) { SPI.transfer(*data_p); @@ -201,7 +207,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) { spi4teensy3::send(reg); uint8_t rv = spi4teensy3::receive(); SPI_SS::Set(); -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg); uint8_t rv = SPI.transfer(0); SPI_SS::Set(); @@ -227,7 +233,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* spi4teensy3::send(reg); spi4teensy3::receive(data_p, nbytes); data_p += nbytes; -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif !defined(SPDR) SPI.transfer(reg); while(nbytes) { *data_p++ = SPI.transfer(0); diff --git a/version_helper.h b/version_helper.h new file mode 100644 index 00000000..b018000e --- /dev/null +++ b/version_helper.h @@ -0,0 +1,222 @@ +/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + +This software may be distributed and modified under the terms of the GNU +General Public License version 2 (GPL2) as published by the Free Software +Foundation and appearing in the file GPL2.TXT included in the packaging of +this file. Please note that GPL2 Section 2[b] requires that all works based +on this software must also be made publicly available under the terms of +the GPL2 ("Copyleft"). + +Contact information +------------------- + +Circuits At Home, LTD +Web : http://www.circuitsathome.com +e-mail : support@circuitsathome.com + */ + +/* + * Universal Arduino(tm) "IDE" fixups. + * Includes fixes for versions as low as 0023, used by Digilent. + */ + +#if defined(ARDUINO) && ARDUINO >=100 +#include +#else +#include +#include +#ifdef __AVR__ +#include +#include +#else +#endif +#endif + +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#ifndef PROGMEM +#define PROGMEM +#endif +#ifndef PGM_P +#define PGM_P const char * +#endif +#ifndef PSTR +#define PSTR(str) (str) +#endif +#ifndef F +#define F(str) (str) +#endif +#ifndef _SFR_BYTE +#define _SFR_BYTE(n) (n) +#endif + +#ifndef prog_void +typedef void prog_void; +#endif +#ifndef prog_char +typedef char prog_char; +#endif +#ifndef prog_uchar +typedef unsigned char prog_uchar; +#endif +#ifndef prog_int8_t +typedef int8_t prog_int8_t; +#endif +#ifndef prog_uint8_t +typedef uint8_t prog_uint8_t; +#endif +#ifndef prog_int16_t +typedef int16_t prog_int16_t; +#endif +#ifndef prog_uint16_t +typedef uint16_t prog_uint16_t; +#endif +#ifndef prog_int32_t +typedef int32_t prog_int32_t; +#endif +#ifndef prog_uint32_t +typedef uint32_t prog_uint32_t; +#endif + +#ifndef memchr_P +#define memchr_P(str, c, len) memchr((str), (c), (len)) +#endif +#ifndef memcmp_P +#define memcmp_P(a, b, n) memcmp((a), (b), (n)) +#endif +#ifndef memcpy_P +#define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) +#endif +#ifndef memmem_P +#define memmem_P(a, alen, b, blen) memmem((a), (alen), (b), (blen)) +#endif +#ifndef memrchr_P +#define memrchr_P(str, val, len) memrchr((str), (val), (len)) +#endif +#ifndef strcat_P +#define strcat_P(dest, src) strcat((dest), (src)) +#endif +#ifndef strchr_P +#define strchr_P(str, c) strchr((str), (c)) +#endif +#ifndef strchrnul_P +#define strchrnul_P(str, c) strchrnul((str), (c)) +#endif +#ifndef strcmp_P +#define strcmp_P(a, b) strcmp((a), (b)) +#endif +#ifndef strcpy_P +#define strcpy_P(dest, src) strcpy((dest), (src)) +#endif +#ifndef strcasecmp_P +#define strcasecmp_P(a, b) strcasecmp((a), (b)) +#endif +#ifndef strcasestr_P +#define strcasestr_P(a, b) strcasestr((a), (b)) +#endif +#ifndef strlcat_P +#define strlcat_P(dest, src, len) strlcat((dest), (src), (len)) +#endif +#ifndef strlcpy_P +#define strlcpy_P(dest, src, len) strlcpy((dest), (src), (len)) +#endif +#ifndef strlen_P +#define strlen_P(s) strlen((const char *)(s)) +#endif +#ifndef strnlen_P +#define strnlen_P(str, len) strnlen((str), (len)) +#endif +#ifndef strncmp_P +#define strncmp_P(a, b, n) strncmp((a), (b), (n)) +#endif +#ifndef strncasecmp_P +#define strncasecmp_P(a, b, n) strncasecmp((a), (b), (n)) +#endif +#ifndef strncat_P +#define strncat_P(a, b, n) strncat((a), (b), (n)) +#endif +#ifndef strncpy_P +#define strncpy_P(a, b, n) strncmp((a), (b), (n)) +#endif +#ifndef strpbrk_P +#define strpbrk_P(str, chrs) strpbrk((str), (chrs)) +#endif +#ifndef strrchr_P +#define strrchr_P(str, c) strrchr((str), (c)) +#endif +#ifndef strsep_P +#define strsep_P(strp, delim) strsep((strp), (delim)) +#endif +#ifndef strspn_P +#define strspn_P(str, chrs) strspn((str), (chrs)) +#endif +#ifndef strstr_P +#define strstr_P(a, b) strstr((a), (b)) +#endif +#ifndef sprintf_P +#define sprintf_P(s, ...) sprintf((s), __VA_ARGS__) +#endif +#ifndef vfprintf_P +#define vfprintf_P(s, ...) vfprintf((s), __VA_ARGS__) +#endif +#ifndef printf_P +#define printf_P(...) printf(__VA_ARGS__) +#endif +#ifndef snprintf_P +#define snprintf_P(s, n, ...) ((s), (n), __VA_ARGS__) +#endif +#ifndef vsprintf_P +#define vsprintf_P(s, ...) ((s),__VA_ARGS__) +#endif +#ifndef vsnprintf_P +#define vsnprintf_P(s, n, ...) ((s), (n),__VA_ARGS__) +#endif +#ifndef fprintf_P +#define fprintf_P(s, ...) ((s), __VA_ARGS__) +#endif + +#ifndef pgm_read_byte +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#endif +#ifndef pgm_read_word +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#endif +#ifndef pgm_read_dword +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#endif +#ifndef pgm_read_float +#define pgm_read_float(addr) (*(const float *)(addr)) +#endif + +#ifndef pgm_read_byte_near +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#endif +#ifndef pgm_read_word_near +#define pgm_read_word_near(addr) pgm_read_word(addr) +#endif +#ifndef pgm_read_dword_near +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#endif +#ifndef pgm_read_float_near +#define pgm_read_float_near(addr) pgm_read_float(addr) +#endif +#ifndef pgm_read_byte_far +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#endif +#ifndef pgm_read_word_far +#define pgm_read_word_far(addr) pgm_read_word(addr) +#endif +#ifndef pgm_read_dword_far +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#endif +#ifndef pgm_read_float_far +#define pgm_read_float_far(addr) pgm_read_float(addr) +#endif + +#ifndef pgm_read_pointer +#define pgm_read_pointer +#endif +#endif From f2f57d71a33987ff451d3d848ce5c094681ba7d9 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Thu, 25 Sep 2014 23:14:04 -0400 Subject: [PATCH 13/35] Speedup SPI, fix PIC32 corner case for include --- settings.h | 2 +- usbhost.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.h b/settings.h index 82c07036..d5f4a4eb 100644 --- a/settings.h +++ b/settings.h @@ -133,6 +133,6 @@ e-mail : support@circuitsathome.com #include // Use the Arduino SPI library #endif #if defined(__PIC32MX__) || defined(__PIC32MZ__) -#include <../../libraries/SPI/SPI.h> // Hack to use the SPI library +#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library #endif #endif /* SETTINGS_H */ diff --git a/usbhost.h b/usbhost.h index f0a6962e..c4b8bb3d 100644 --- a/usbhost.h +++ b/usbhost.h @@ -45,7 +45,7 @@ public: SPI_SS::Set(); SPI.begin(); #if defined(__MIPSEL__) - SPI.setClockDivider(2); + SPI.setClockDivider(1); #else SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz #endif From b51131750d80746a035fa0e396557dcc4634d8d7 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Thu, 25 Sep 2014 23:17:18 -0400 Subject: [PATCH 14/35] fix board_qc for MIPS --- examples/board_qc/board_qc.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/board_qc/board_qc.ino b/examples/board_qc/board_qc.ino index 94df16cf..23e90cae 100644 --- a/examples/board_qc/board_qc.ino +++ b/examples/board_qc/board_qc.ino @@ -23,7 +23,9 @@ USB Usb; void setup() { laststate = 0; Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif E_Notify(PSTR("\r\nCircuits At Home 2011"), 0x80); E_Notify(PSTR("\r\nUSB Host Shield Quality Control Routine"), 0x80); /* SPI quick test - check revision register */ From 80230570cce7566c79aa4579d13a3b1fb9531236 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Thu, 25 Sep 2014 23:23:10 -0400 Subject: [PATCH 15/35] fix board_qc for MIPS so that it includes the correct SPI library first --- examples/board_qc/board_qc.ino | 48 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/examples/board_qc/board_qc.ino b/examples/board_qc/board_qc.ino index 23e90cae..ddd1c5a6 100644 --- a/examples/board_qc/board_qc.ino +++ b/examples/board_qc/board_qc.ino @@ -7,6 +7,8 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library +#include // Hack to use the SPI library #endif /* variables */ @@ -24,7 +26,7 @@ void setup() { laststate = 0; Serial.begin(115200); #if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection + while(!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #endif E_Notify(PSTR("\r\nCircuits At Home 2011"), 0x80); E_Notify(PSTR("\r\nUSB Host Shield Quality Control Routine"), 0x80); @@ -33,7 +35,7 @@ void setup() { Usb.Init(); // Initializes SPI, we don't care about the return value here { uint8_t tmpbyte = Usb.regRd(rREVISION); - switch (tmpbyte) { + switch(tmpbyte) { case( 0x01): //rev.01 E_Notify(PSTR("01"), 0x80); break; @@ -56,11 +58,11 @@ void setup() { uint8_t sample_wr = 0; uint8_t sample_rd = 0; uint8_t gpinpol_copy = Usb.regRd(rGPINPOL); - for (uint8_t i = 0; i < 16; i++) { - for (uint16_t j = 0; j < 65535; j++) { + for(uint8_t i = 0; i < 16; i++) { + for(uint16_t j = 0; j < 65535; j++) { Usb.regWr(rGPINPOL, sample_wr); sample_rd = Usb.regRd(rGPINPOL); - if (sample_rd != sample_wr) { + if(sample_rd != sample_wr) { E_Notify(PSTR("\r\nTest failed. "), 0x80); E_Notify(PSTR("Value written: "), 0x80); print_hex(sample_wr, 8); @@ -81,12 +83,12 @@ void setup() { { uint8_t tmpbyte; E_Notify(PSTR("\r\nGPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on"), 0x80); - for (uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) { + for(uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) { Usb.gpioWr(sample_gpio); tmpbyte = Usb.gpioRd(); /* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */ tmpbyte = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; - if (sample_gpio != tmpbyte) { + if(sample_gpio != tmpbyte) { E_Notify(PSTR("\r\nTest failed. Value written: "), 0x80); print_hex(sample_gpio, 8); E_Notify(PSTR(" Value read: "), 0x80); @@ -102,31 +104,31 @@ void setup() { { E_Notify(PSTR("\r\nPLL test. 100 chip resets will be performed"), 0x80); /* check current state of the oscillator */ - if (!(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ)) { //wrong state - should be on + if(!(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ)) { //wrong state - should be on E_Notify(PSTR("\r\nCurrent oscillator state unexpected."), 0x80); press_any_key(); } /* Restart oscillator */ E_Notify(PSTR("\r\nResetting oscillator\r\n"), 0x80); - for (uint16_t i = 0; i < 100; i++) { + for(uint16_t i = 0; i < 100; i++) { E_Notify(PSTR("\rReset number "), 0x80); Serial.print(i, DEC); Usb.regWr(rUSBCTL, bmCHIPRES); //reset - if (Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { //wrong state - should be off + if(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { //wrong state - should be off E_Notify(PSTR("\r\nCurrent oscillator state unexpected."), 0x80); halt55(); } Usb.regWr(rUSBCTL, 0x00); //release from reset uint16_t j = 0; - for (j = 0; j < 65535; j++) { //tracking off to on time - if (Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { + for(j = 0; j < 65535; j++) { //tracking off to on time + if(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { E_Notify(PSTR(" Time to stabilize - "), 0x80); Serial.print(j, DEC); E_Notify(PSTR(" cycles\r\n"), 0x80); break; } }//for( uint16_t j = 0; j < 65535; j++ - if (j == 0) { + if(j == 0) { E_Notify(PSTR("PLL failed to stabilize"), 0x80); press_any_key(); } @@ -134,7 +136,7 @@ void setup() { }//PLL test /* initializing USB stack */ - if (Usb.Init() == -1) { + if(Usb.Init() == -1) { E_Notify(PSTR("\r\nOSCOKIRQ failed to assert"), 0x80); halt55(); } @@ -145,10 +147,10 @@ void loop() { delay(200); Usb.Task(); usbstate = Usb.getUsbTaskState(); - if (usbstate != laststate) { + if(usbstate != laststate) { laststate = usbstate; /**/ - switch (usbstate) { + switch(usbstate) { case( USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE): E_Notify(PSTR("\r\nWaiting for device..."), 0x80); break; @@ -168,7 +170,7 @@ void loop() { E_Notify(PSTR("\r\nGetting device descriptor"), 0x80); rcode = Usb.getDevDescr(1, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*) & buf); - if (rcode) { + if(rcode) { E_Notify(PSTR("\r\nError reading device descriptor. Error code "), 0x80); print_hex(rcode, 8); } else { @@ -203,7 +205,7 @@ void loop() { print_hex(buf.bNumConfigurations, 8); /**/ E_Notify(PSTR("\r\n\nAll tests passed. Press RESET to restart test"), 0x80); - while (1); + while(1); } break; case( USB_STATE_ERROR): @@ -223,7 +225,7 @@ void halt55() { E_Notify(PSTR("\r\n0x55 pattern is transmitted via SPI"), 0x80); E_Notify(PSTR("\r\nPress RESET to restart test"), 0x80); - while (1) { + while(1) { Usb.regWr(0x55, 0x55); } } @@ -232,25 +234,25 @@ void halt55() { void print_hex(int v, int num_places) { int mask = 0, n, num_nibbles, digit; - for (n = 1; n <= num_places; n++) { + for(n = 1; n <= num_places; n++) { mask = (mask << 1) | 0x0001; } v = v & mask; // truncate v to specified number of places num_nibbles = num_places / 4; - if ((num_places % 4) != 0) { + if((num_places % 4) != 0) { ++num_nibbles; } do { digit = ((v >> (num_nibbles - 1) * 4)) & 0x0f; Serial.print(digit, HEX); - } while (--num_nibbles); + } while(--num_nibbles); } /* prints "Press any key" and returns when key is pressed */ void press_any_key() { E_Notify(PSTR("\r\nPress any key to continue..."), 0x80); - while (Serial.available() <= 0); //wait for input + while(Serial.available() <= 0); //wait for input Serial.read(); //empty input buffer return; } From 37d87903fa9dd1e66936b7a5e3d4e2e4cbb6404e Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Mon, 29 Sep 2014 16:50:02 -0700 Subject: [PATCH 16/35] Updated USBFTDILoopback example to compile after 2224dd96cbf64f1184b3d74649e0a5679f398c59 --- examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino b/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino index 26b5624d..49c8b483 100644 --- a/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino +++ b/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino @@ -11,6 +11,7 @@ class FTDIAsync : public FTDIAsyncOper { public: virtual uint8_t OnInit(FTDI *pftdi); + virtual uint8_t OnRelease(FTDI *pftdi) {}; }; uint8_t FTDIAsync::OnInit(FTDI *pftdi) From 6e31789f7f4a8a5eeb645a9cc2dcb9b99c9cd38f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 1 Oct 2014 23:26:56 +0300 Subject: [PATCH 17/35] PlatformIO-based manifest file Web: http://platformio.ikravets.com/#!/lib/show/Arduino-USBHostShield20 Docs: http://docs.platformio.ikravets.com/en/latest/librarymanager/index.html --- library.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 library.json diff --git a/library.json b/library.json new file mode 100644 index 00000000..50a25857 --- /dev/null +++ b/library.json @@ -0,0 +1,15 @@ +{ + "name": "Arduino-USBHostShield20", + "keywords": "usb, hid", + "description": "Revision 2.0 of MAX3421E-based USB Host Shield Library for AVR's", + "repository": + { + "type": "git", + "url": "https://github.com/felis/USB_Host_Shield_2.0.git" + }, + "examples": + [ + "examples/*/*.ino", + "examples/*/*/*.ino" + ] +} From 8222d047f57149850386290b40d61d54344dc46d Mon Sep 17 00:00:00 2001 From: David Kemp Date: Thu, 23 Oct 2014 21:51:48 +1100 Subject: [PATCH 18/35] Make the right shift key work in OemToAscii (only the left shift key was working) --- hidboot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hidboot.cpp b/hidboot.cpp index c32443bb..09290a4f 100644 --- a/hidboot.cpp +++ b/hidboot.cpp @@ -189,8 +189,8 @@ uint8_t KeyboardReportParser::OemToAscii(uint8_t mod, uint8_t key) { // [a-z] if (VALUE_WITHIN(key, 0x04, 0x1d)) { // Upper case letters - if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && (mod & 2)) || - (kbdLockingKeys.kbdLeds.bmCapsLock == 1 && (mod & 2) == 0)) + if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && shift) || + (kbdLockingKeys.kbdLeds.bmCapsLock == 1 && shift == 0)) return (key - 4 + 'A'); // Lower case letters From 65e85678c0421676c6fe44ad5e5ab7188b989879 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 23 Oct 2014 19:08:04 +0300 Subject: [PATCH 19/35] Avoid trademark issues with library name Added authors, frameworks and platforms fields Updated Library Registry: http://platformio.ikravets.com/#!/lib/show/59/USB-Host-Shield-20 --- library.json | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 50a25857..77f75346 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,29 @@ { - "name": "Arduino-USBHostShield20", + "name": "USB-Host-Shield-20", "keywords": "usb, hid", - "description": "Revision 2.0 of MAX3421E-based USB Host Shield Library for AVR's", + "description": "Revision 2.0 of MAX3421E-based USB Host Shield Library", + "authors": + [ + { + "name": "Oleg Mazurov", + "email": "mazurov@circuitsathome.com", + "url": "http://www.circuitsathome.com", + "maintainer": true + }, + { + "name": "Alexei Glushchenko", + "email": "alex-gl@mail.ru" + }, + { + "name": "Kristian Lauszus", + "email": "kristianl@tkjelectronics.com", + "url": "http://tkjelectronics.com" + }, + { + "name": "Andrew Kroll", + "email": "xxxajk@gmail.com" + } + ], "repository": { "type": "git", @@ -11,5 +33,7 @@ [ "examples/*/*.ino", "examples/*/*/*.ino" - ] + ], + "frameworks": "arduino", + "platforms": "atmelavr" } From 6b096bf6ae3eaf2317ff78a5c3126d8195007a89 Mon Sep 17 00:00:00 2001 From: Lauszus Date: Sun, 26 Oct 2014 13:48:19 -0700 Subject: [PATCH 20/35] Added more keywords to library.json and set maintainer field for me and Andrew --- library.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library.json b/library.json index 77f75346..b48643ec 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "USB-Host-Shield-20", - "keywords": "usb, hid", + "keywords": "usb, host, ftdi, adk, acm, pl2303, hid, bluetooth, spp, ps3, ps4, buzz, xbox, wii, mass storage", "description": "Revision 2.0 of MAX3421E-based USB Host Shield Library", "authors": [ @@ -17,12 +17,14 @@ { "name": "Kristian Lauszus", "email": "kristianl@tkjelectronics.com", - "url": "http://tkjelectronics.com" + "url": "http://tkjelectronics.com", + "maintainer": true }, { "name": "Andrew Kroll", - "email": "xxxajk@gmail.com" - } + "email": "xxxajk@gmail.com", + "maintainer": true + } ], "repository": { From 9806b7073b83afeec1fdc68be73e47c6185b945e Mon Sep 17 00:00:00 2001 From: Lauszus Date: Sun, 26 Oct 2014 14:33:45 -0700 Subject: [PATCH 21/35] Added teensy and atmelsam platforms --- library.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library.json b/library.json index b48643ec..6f7c5753 100644 --- a/library.json +++ b/library.json @@ -37,5 +37,10 @@ "examples/*/*/*.ino" ], "frameworks": "arduino", - "platforms": "atmelavr" + "platforms": + [ + "atmelavr", + "teensy", + "atmelsam" + ] } From 46dd720b8f6dde5d36c0635362e22c2251c70a13 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Wed, 29 Oct 2014 14:28:45 -0700 Subject: [PATCH 22/35] Added a link to Adafruit's library guide --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 58599d42..1a3163b3 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Now quit the Arduino IDE and reopen it. Now you should be able to go open all the examples codes by navigating to "File>Examples>USB\_Host\_Shield\_20" and then select the example you will like to open. -For more information visit the following site: . +For more information visit the following sites: and . # How to use the library From d5e900f8339979bfecbbd8dbd5380815087dd142 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Fri, 31 Oct 2014 15:57:39 -0700 Subject: [PATCH 23/35] Added isReady function to HIDBoot Fixes #103 --- hidboot.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hidboot.h b/hidboot.h index b35df7cb..c5a46891 100644 --- a/hidboot.h +++ b/hidboot.h @@ -212,6 +212,10 @@ public: return bAddress; }; + virtual bool isReady() { + return bPollEnable; + }; + // UsbConfigXtracter implementation virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); From 196a0b69be5fae76c78086f33c710bfa2f51e1de Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 10 Nov 2014 01:35:13 -0500 Subject: [PATCH 24/35] Fix all demos, fix all wrong uses of virtual keyword, some spacing cleanup. --- BTD.h | 18 +-- BTHID.h | 8 +- PS3BT.h | 8 +- PS3USB.h | 6 +- PSBuzz.h | 4 +- SPP.h | 22 ++-- Wii.h | 8 +- XBOXOLD.h | 6 +- XBOXRECV.h | 8 +- XBOXUSB.h | 6 +- adk.h | 8 +- cdcacm.h | 12 +- cdcftdi.h | 16 ++- cdcprolific.h | 111 +++++++++--------- confdescparser.h | 6 +- examples/Bluetooth/BTHID/BTHID.ino | 3 + examples/Bluetooth/PS3BT/PS3BT.ino | 3 + examples/Bluetooth/PS3Multi/PS3Multi.ino | 3 + examples/Bluetooth/PS3SPP/PS3SPP.ino | 3 + examples/Bluetooth/PS4BT/PS4BT.ino | 3 + examples/Bluetooth/SPP/SPP.ino | 3 + examples/Bluetooth/SPPMulti/SPPMulti.ino | 5 +- examples/Bluetooth/Wii/Wii.ino | 3 + .../Bluetooth/WiiIRCamera/WiiIRCamera.ino | 3 + examples/Bluetooth/WiiMulti/WiiMulti.ino | 3 + .../WiiUProController/WiiUProController.ino | 3 + examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino | 13 +- .../USBHIDBootKbdAndMouse.ino | 30 +++-- .../HID/USBHIDBootMouse/USBHIDBootMouse.ino | 17 +-- .../HID/USBHIDJoystick/USBHIDJoystick.ino | 7 ++ examples/HID/USBHID_desc/USBHID_desc.ino | 5 +- examples/HID/le3dp/le3dp.ino | 3 + examples/HID/scale/scale.ino | 3 + examples/HID/scale/scale_rptparser.h | 14 +-- examples/PS3USB/PS3USB.ino | 3 + examples/PS4USB/PS4USB.ino | 3 + examples/PSBuzz/PSBuzz.ino | 3 + examples/USB_desc/USB_desc.ino | 5 +- examples/Xbox/XBOXOLD/XBOXOLD.ino | 3 + examples/Xbox/XBOXRECV/XBOXRECV.ino | 3 + examples/Xbox/XBOXUSB/XBOXUSB.ino | 3 + examples/acm/acm_terminal/acm_terminal.ino | 5 +- .../adk/ArduinoBlinkLED/ArduinoBlinkLED.ino | 25 +++- examples/adk/adk_barcode/adk_barcode.ino | 45 ++++--- examples/adk/demokit_20/demokit_20.ino | 26 ++-- examples/adk/term_test/term_test.ino | 27 +++-- examples/adk/term_time/term_time.ino | 21 ++-- .../ftdi/USBFTDILoopback/USBFTDILoopback.ino | 5 +- examples/hub_demo/hub_demo.ino | 5 +- examples/max_LCD/max_LCD.ino | 5 + .../pl2303_gprs_terminal.ino | 5 +- examples/pl2303/pl2303_gps/pl2303_gps.ino | 7 +- .../pl2303/pl2303_tinygps/pl2303_tinygps.ino | 5 +- .../pl2303_xbee_terminal.ino | 5 +- hexdump.h | 2 +- hid.h | 5 +- hidboot.cpp | 21 ---- hidboot.h | 33 +++++- hidescriptorparser.h | 5 +- hiduniversal.h | 12 +- masstorage.h | 10 +- max_LCD.h | 4 +- usbhub.h | 8 +- 63 files changed, 425 insertions(+), 258 deletions(-) diff --git a/BTD.h b/BTD.h index 3a639abb..c992b935 100755 --- a/BTD.h +++ b/BTD.h @@ -214,13 +214,13 @@ public: * Used to pass acldata to the Bluetooth service. * @param ACLData Pointer to the incoming acldata. */ - virtual void ACLData(uint8_t* ACLData); + virtual void ACLData(uint8_t* ACLData){}; /** Used to run the different state machines in the Bluetooth service. */ - virtual void Run(); + virtual void Run(){}; /** Used to reset the Bluetooth service. */ - virtual void Reset(); + virtual void Reset(){}; /** Used to disconnect both the L2CAP Channel and the HCI Connection for the Bluetooth service. */ - virtual void disconnect(); + virtual void disconnect(){}; }; /** @@ -243,7 +243,7 @@ public: * @param lowspeed Speed of the device. * @return 0 on success. */ - virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); /** * Initialize the Bluetooth dongle. * @param parent Hub number. @@ -251,17 +251,17 @@ public: * @param lowspeed Speed of the device. * @return 0 on success. */ - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); /** * Release the USB device. * @return 0 on success. */ - virtual uint8_t Release(); + uint8_t Release(); /** * Poll the USB Input endpoints and run the state machines. * @return 0 on success. */ - virtual uint8_t Poll(); + uint8_t Poll(); /** * Get the device address. @@ -315,7 +315,7 @@ public: * @param proto Interface Protocol. * @param ep Endpoint Descriptor. */ - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); /**@}*/ /** Disconnects both the L2CAP Channel and the HCI Connection for all Bluetooth services. */ diff --git a/BTHID.h b/BTHID.h index 2419e58b..9ca67665 100644 --- a/BTHID.h +++ b/BTHID.h @@ -41,13 +41,13 @@ public: * Used to pass acldata to the services. * @param ACLData Incoming acldata. */ - virtual void ACLData(uint8_t* ACLData); + void ACLData(uint8_t* ACLData); /** Used to run part of the state machine. */ - virtual void Run(); + void Run(); /** Use this to reset the service. */ - virtual void Reset(); + void Reset(); /** Used this to disconnect the devices. */ - virtual void disconnect(); + void disconnect(); /**@}*/ /** diff --git a/PS3BT.h b/PS3BT.h index d07a4577..537bf47e 100644 --- a/PS3BT.h +++ b/PS3BT.h @@ -45,13 +45,13 @@ public: * Used to pass acldata to the services. * @param ACLData Incoming acldata. */ - virtual void ACLData(uint8_t* ACLData); + void ACLData(uint8_t* ACLData); /** Used to run part of the state machine. */ - virtual void Run(); + void Run(); /** Use this to reset the service. */ - virtual void Reset(); + void Reset(); /** Used this to disconnect any of the controllers. */ - virtual void disconnect(); + void disconnect(); /**@}*/ /** @name PS3 Controller functions */ diff --git a/PS3USB.h b/PS3USB.h index 5bbbdf2e..35604f0c 100644 --- a/PS3USB.h +++ b/PS3USB.h @@ -74,17 +74,17 @@ public: * @param lowspeed Speed of the device. * @return 0 on success. */ - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); /** * Release the USB device. * @return 0 on success. */ - virtual uint8_t Release(); + uint8_t Release(); /** * Poll the USB Input endpoins and run the state machines. * @return 0 on success. */ - virtual uint8_t Poll(); + uint8_t Poll(); /** * Get the device address. diff --git a/PSBuzz.h b/PSBuzz.h index 1d7859d2..13456e5c 100644 --- a/PSBuzz.h +++ b/PSBuzz.h @@ -143,14 +143,14 @@ protected: * @param len The length of the incoming data. * @param buf Pointer to the data buffer. */ - virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); + void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); /** * Called when a device is successfully initialized. * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. * This is useful for instance if you want to set the LEDs in a specific way. */ - virtual uint8_t OnInitSuccessful(); + uint8_t OnInitSuccessful(); /**@}*/ /** Used to reset the different buffers to their default values */ diff --git a/SPP.h b/SPP.h index d9f6761c..b9c55dbe 100644 --- a/SPP.h +++ b/SPP.h @@ -83,13 +83,13 @@ public: * Used to pass acldata to the services. * @param ACLData Incoming acldata. */ - virtual void ACLData(uint8_t* ACLData); + void ACLData(uint8_t* ACLData); /** Used to establish the connection automatically. */ - virtual void Run(); + void Run(); /** Use this to reset the service. */ - virtual void Reset(); + void Reset(); /** Used this to disconnect the virtual serial port. */ - virtual void disconnect(); + void disconnect(); /**@}*/ /** @name Serial port profile (SPP) Print functions */ @@ -97,7 +97,7 @@ public: * Get number of bytes waiting to be read. * @return Return the number of bytes ready to be read. */ - virtual int available(void); + int available(void); /** Send out all bytes in the buffer. */ virtual void flush(void) { @@ -107,12 +107,12 @@ public: * Used to read the next value in the buffer without advancing to the next one. * @return Return the byte. Will return -1 if no bytes are available. */ - virtual int peek(void); + int peek(void); /** * Used to read the buffer. * @return Return the byte. Will return -1 if no bytes are available. */ - virtual int read(void); + int read(void); #if defined(ARDUINO) && ARDUINO >=100 /** @@ -120,14 +120,14 @@ public: * @param data The byte to write. * @return Return the number of bytes written. */ - virtual size_t write(uint8_t data); + size_t write(uint8_t data); /** * Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called. * @param data The data array to send. * @param size Size of the data. * @return Return the number of bytes written. */ - virtual size_t write(const uint8_t* data, size_t size); + size_t write(const uint8_t* data, size_t size); /** Pull in write(const char *str) from Print */ using Print::write; #else @@ -135,13 +135,13 @@ public: * Writes the byte to send to a buffer. The message is send when either send() or after Usb.Task() is called. * @param data The byte to write. */ - virtual void write(uint8_t data); + void write(uint8_t data); /** * Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called. * @param data The data array to send. * @param size Size of the data. */ - virtual void write(const uint8_t* data, size_t size); + void write(const uint8_t* data, size_t size); #endif /** Discard all the bytes in the buffer. */ diff --git a/Wii.h b/Wii.h index 848dec93..d37a6da3 100755 --- a/Wii.h +++ b/Wii.h @@ -59,13 +59,13 @@ public: * Used to pass acldata to the services. * @param ACLData Incoming acldata. */ - virtual void ACLData(uint8_t* ACLData); + void ACLData(uint8_t* ACLData); /** Used to run part of the state machine. */ - virtual void Run(); + void Run(); /** Use this to reset the service. */ - virtual void Reset(); + void Reset(); /** Used this to disconnect any of the controllers. */ - virtual void disconnect(); + void disconnect(); /**@}*/ /** @name Wii Controller functions */ diff --git a/XBOXOLD.h b/XBOXOLD.h index b3c0ccb2..5ea237d9 100644 --- a/XBOXOLD.h +++ b/XBOXOLD.h @@ -65,17 +65,17 @@ public: * @param lowspeed Speed of the device. * @return 0 on success. */ - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); /** * Release the USB device. * @return 0 on success. */ - virtual uint8_t Release(); + uint8_t Release(); /** * Poll the USB Input endpoins and run the state machines. * @return 0 on success. */ - virtual uint8_t Poll(); + uint8_t Poll(); /** * Get the device address. diff --git a/XBOXRECV.h b/XBOXRECV.h index c3964991..32bd6e7a 100644 --- a/XBOXRECV.h +++ b/XBOXRECV.h @@ -71,7 +71,7 @@ public: * @param lowspeed Speed of the device. * @return 0 on success. */ - virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); /** * Initialize the Xbox wireless receiver. * @param parent Hub number. @@ -79,17 +79,17 @@ public: * @param lowspeed Speed of the device. * @return 0 on success. */ - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); /** * Release the USB device. * @return 0 on success. */ - virtual uint8_t Release(); + uint8_t Release(); /** * Poll the USB Input endpoins and run the state machines. * @return 0 on success. */ - virtual uint8_t Poll(); + uint8_t Poll(); /** * Get the device address. diff --git a/XBOXUSB.h b/XBOXUSB.h index aed330a2..fc3fdc8f 100644 --- a/XBOXUSB.h +++ b/XBOXUSB.h @@ -71,17 +71,17 @@ public: * @param lowspeed Speed of the device. * @return 0 on success. */ - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); /** * Release the USB device. * @return 0 on success. */ - virtual uint8_t Release(); + uint8_t Release(); /** * Poll the USB Input endpoins and run the state machines. * @return 0 on success. */ - virtual uint8_t Poll(); + uint8_t Poll(); /** * Get the device address. diff --git a/adk.h b/adk.h index 542078bb..aa9a7ebb 100644 --- a/adk.h +++ b/adk.h @@ -96,9 +96,9 @@ public: // USBDeviceConfig implementation - virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Release(); + uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Release(); virtual uint8_t Poll() { return 0; @@ -117,7 +117,7 @@ public: }; //UsbConfigXtracter implementation - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); }; //class ADK : public USBDeviceConfig ... /* get ADK protocol version */ diff --git a/cdcacm.h b/cdcacm.h index 4a2a1362..c0b6fd07 100644 --- a/cdcacm.h +++ b/cdcacm.h @@ -127,7 +127,9 @@ class ACM; class CDCAsyncOper { public: - virtual uint8_t OnInit(ACM *pacm) = 0; + + virtual uint8_t OnInit(ACM *pacm) { + }; //virtual void OnDataRcvd(ACM *pacm, uint8_t nbytes, uint8_t *dataptr) = 0; //virtual void OnDisconnected(ACM *pacm) = 0; }; @@ -173,9 +175,9 @@ public: uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); // USBDeviceConfig implementation - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Release(); - virtual uint8_t Poll(); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Release(); + uint8_t Poll(); virtual uint8_t GetAddress() { return bAddress; @@ -186,7 +188,7 @@ public: }; // UsbConfigXtracter implementation - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); }; #endif // __CDCACM_H__ diff --git a/cdcftdi.h b/cdcftdi.h index fbb7396d..0bb1008c 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -78,8 +78,12 @@ class FTDI; class FTDIAsyncOper { public: - virtual uint8_t OnInit(FTDI *pftdi) = 0; - virtual uint8_t OnRelease(FTDI *pftdi) = 0; + + virtual uint8_t OnInit(FTDI *pftdi) { + }; + + virtual uint8_t OnRelease(FTDI *pftdi) { + }; }; @@ -119,16 +123,16 @@ public: uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); // USBDeviceConfig implementation - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Release(); - virtual uint8_t Poll(); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Release(); + uint8_t Poll(); virtual uint8_t GetAddress() { return bAddress; }; // UsbConfigXtracter implementation - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { return (vid == FTDI_VID && pid == FTDI_PID); diff --git a/cdcprolific.h b/cdcprolific.h index bfa92fe3..ce203fbe 100644 --- a/cdcprolific.h +++ b/cdcprolific.h @@ -19,69 +19,61 @@ e-mail : support@circuitsathome.com #include "cdcacm.h" -#define PL_VID 0x067B -#define PL_PID ( 0x2303 || 0x0609 ) +#define PL_VID 0x067B +#define PL_PID ( 0x2303 || 0x0609 ) -//#define PL_PID 0x0609 +//#define PL_PID 0x0609 -#define PROLIFIC_REV_H 0x0202 -#define PROLIFIC_REV_X 0x0300 -#define PROLIFIC_REV_HX_CHIP_D 0x0400 -#define PROLIFIC_REV_1 0x0001 +#define PROLIFIC_REV_H 0x0202 +#define PROLIFIC_REV_X 0x0300 +#define PROLIFIC_REV_HX_CHIP_D 0x0400 +#define PROLIFIC_REV_1 0x0001 -#define kXOnChar '\x11' -#define kXOffChar '\x13' +#define kXOnChar '\x11' +#define kXOffChar '\x13' -#define SPECIAL_SHIFT (5) -#define SPECIAL_MASK ((1< diff --git a/examples/Bluetooth/BTHID/BTHID.ino b/examples/Bluetooth/BTHID/BTHID.ino index fcfd686a..7f083321 100644 --- a/examples/Bluetooth/BTHID/BTHID.ino +++ b/examples/Bluetooth/BTHID/BTHID.ino @@ -11,6 +11,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -30,7 +31,9 @@ MouseRptParser mousePrs; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); // Halt diff --git a/examples/Bluetooth/PS3BT/PS3BT.ino b/examples/Bluetooth/PS3BT/PS3BT.ino index 982eb384..47e7d3fe 100644 --- a/examples/Bluetooth/PS3BT/PS3BT.ino +++ b/examples/Bluetooth/PS3BT/PS3BT.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -24,7 +25,9 @@ boolean printAngle; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Bluetooth/PS3Multi/PS3Multi.ino b/examples/Bluetooth/PS3Multi/PS3Multi.ino index 23e8cd9a..a630640a 100644 --- a/examples/Bluetooth/PS3Multi/PS3Multi.ino +++ b/examples/Bluetooth/PS3Multi/PS3Multi.ino @@ -10,6 +10,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -28,7 +29,9 @@ void setup() { } Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Bluetooth/PS3SPP/PS3SPP.ino b/examples/Bluetooth/PS3SPP/PS3SPP.ino index 440ea79e..40c23ea1 100644 --- a/examples/Bluetooth/PS3SPP/PS3SPP.ino +++ b/examples/Bluetooth/PS3SPP/PS3SPP.ino @@ -15,6 +15,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -33,7 +34,9 @@ String output = ""; // We will store the data in this string void setup() { Serial.begin(115200); // This wil lprint the debugging from the libraries +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Bluetooth/PS4BT/PS4BT.ino b/examples/Bluetooth/PS4BT/PS4BT.ino index e47cfae0..b6ee3b1d 100644 --- a/examples/Bluetooth/PS4BT/PS4BT.ino +++ b/examples/Bluetooth/PS4BT/PS4BT.ino @@ -10,6 +10,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -29,7 +30,9 @@ uint8_t oldL2Value, oldR2Value; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); // Halt diff --git a/examples/Bluetooth/SPP/SPP.ino b/examples/Bluetooth/SPP/SPP.ino index d8276b7b..90cf94ba 100644 --- a/examples/Bluetooth/SPP/SPP.ino +++ b/examples/Bluetooth/SPP/SPP.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -23,7 +24,9 @@ boolean firstMessage = true; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Bluetooth/SPPMulti/SPPMulti.ino b/examples/Bluetooth/SPPMulti/SPPMulti.ino index 0304257e..e4cf16f5 100644 --- a/examples/Bluetooth/SPPMulti/SPPMulti.ino +++ b/examples/Bluetooth/SPPMulti/SPPMulti.ino @@ -6,9 +6,10 @@ #include #include -// Satisfy IDE, which only needs to see the include statement in the ino. +// Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -26,7 +27,9 @@ void setup() { SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "0000" for all connections Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); // Halt diff --git a/examples/Bluetooth/Wii/Wii.ino b/examples/Bluetooth/Wii/Wii.ino index f4d68a62..1f9fa020 100644 --- a/examples/Bluetooth/Wii/Wii.ino +++ b/examples/Bluetooth/Wii/Wii.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -23,7 +24,9 @@ bool printAngle; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino b/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino index e7ca456b..4eadbc95 100644 --- a/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino +++ b/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino @@ -16,6 +16,7 @@ Otherwise, wire up a IR LED yourself. // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif #ifndef WIICAMERA // Used to check if WIICAMERA is defined @@ -35,7 +36,9 @@ uint8_t printObjects; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Bluetooth/WiiMulti/WiiMulti.ino b/examples/Bluetooth/WiiMulti/WiiMulti.ino index 08444f10..d3f15fca 100644 --- a/examples/Bluetooth/WiiMulti/WiiMulti.ino +++ b/examples/Bluetooth/WiiMulti/WiiMulti.ino @@ -10,6 +10,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -28,7 +29,9 @@ void setup() { } Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Bluetooth/WiiUProController/WiiUProController.ino b/examples/Bluetooth/WiiUProController/WiiUProController.ino index 59c4f1dc..870cd13b 100644 --- a/examples/Bluetooth/WiiUProController/WiiUProController.ino +++ b/examples/Bluetooth/WiiUProController/WiiUProController.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -21,7 +22,9 @@ WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimo void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino b/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino index b5944f0a..0c0a0fca 100644 --- a/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino +++ b/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino @@ -3,6 +3,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class KbdRptParser : public KeyboardReportParser @@ -10,11 +11,11 @@ class KbdRptParser : public KeyboardReportParser void PrintKey(uint8_t mod, uint8_t key); protected: - virtual void OnControlKeysChanged(uint8_t before, uint8_t after); + void OnControlKeysChanged(uint8_t before, uint8_t after); - virtual void OnKeyDown (uint8_t mod, uint8_t key); - virtual void OnKeyUp (uint8_t mod, uint8_t key); - virtual void OnKeyPressed(uint8_t key); + void OnKeyDown (uint8_t mod, uint8_t key); + void OnKeyUp (uint8_t mod, uint8_t key); + void OnKeyPressed(uint8_t key); }; void KbdRptParser::PrintKey(uint8_t m, uint8_t key) @@ -105,7 +106,9 @@ KbdRptParser Prs; void setup() { Serial.begin( 115200 ); - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#if !defined(__MIPSEL__) + while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino b/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino index 92dc226b..a664b4b5 100644 --- a/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino +++ b/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino @@ -1,16 +1,21 @@ #include #include +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif class MouseRptParser : public MouseReportParser { protected: - virtual void OnMouseMove (MOUSEINFO *mi); - virtual void OnLeftButtonUp (MOUSEINFO *mi); - virtual void OnLeftButtonDown (MOUSEINFO *mi); - virtual void OnRightButtonUp (MOUSEINFO *mi); - virtual void OnRightButtonDown (MOUSEINFO *mi); - virtual void OnMiddleButtonUp (MOUSEINFO *mi); - virtual void OnMiddleButtonDown (MOUSEINFO *mi); + void OnMouseMove(MOUSEINFO *mi); + void OnLeftButtonUp(MOUSEINFO *mi); + void OnLeftButtonDown(MOUSEINFO *mi); + void OnRightButtonUp(MOUSEINFO *mi); + void OnRightButtonDown(MOUSEINFO *mi); + void OnMiddleButtonUp(MOUSEINFO *mi); + void OnMiddleButtonDown(MOUSEINFO *mi); }; void MouseRptParser::OnMouseMove(MOUSEINFO *mi) { @@ -49,11 +54,10 @@ class KbdRptParser : public KeyboardReportParser void PrintKey(uint8_t mod, uint8_t key); protected: - virtual void OnControlKeysChanged(uint8_t before, uint8_t after); - - virtual void OnKeyDown (uint8_t mod, uint8_t key); - virtual void OnKeyUp (uint8_t mod, uint8_t key); - virtual void OnKeyPressed(uint8_t key); + void OnControlKeysChanged(uint8_t before, uint8_t after); + void OnKeyDown (uint8_t mod, uint8_t key); + void OnKeyUp (uint8_t mod, uint8_t key); + void OnKeyPressed(uint8_t key); }; void KbdRptParser::PrintKey(uint8_t m, uint8_t key) @@ -148,7 +152,9 @@ MouseRptParser MousePrs; void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino b/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino index aa2e3b34..ede71bdd 100644 --- a/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino +++ b/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino @@ -3,18 +3,19 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class MouseRptParser : public MouseReportParser { protected: - virtual void OnMouseMove (MOUSEINFO *mi); - virtual void OnLeftButtonUp (MOUSEINFO *mi); - virtual void OnLeftButtonDown (MOUSEINFO *mi); - virtual void OnRightButtonUp (MOUSEINFO *mi); - virtual void OnRightButtonDown (MOUSEINFO *mi); - virtual void OnMiddleButtonUp (MOUSEINFO *mi); - virtual void OnMiddleButtonDown (MOUSEINFO *mi); + void OnMouseMove (MOUSEINFO *mi); + void OnLeftButtonUp (MOUSEINFO *mi); + void OnLeftButtonDown (MOUSEINFO *mi); + void OnRightButtonUp (MOUSEINFO *mi); + void OnRightButtonDown (MOUSEINFO *mi); + void OnMiddleButtonUp (MOUSEINFO *mi); + void OnMiddleButtonDown (MOUSEINFO *mi); }; void MouseRptParser::OnMouseMove(MOUSEINFO *mi) { @@ -59,7 +60,9 @@ MouseRptParser Prs; void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/HID/USBHIDJoystick/USBHIDJoystick.ino b/examples/HID/USBHIDJoystick/USBHIDJoystick.ino index d0106e1a..70e5dc6c 100644 --- a/examples/HID/USBHIDJoystick/USBHIDJoystick.ino +++ b/examples/HID/USBHIDJoystick/USBHIDJoystick.ino @@ -1,6 +1,11 @@ #include #include #include +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif #include "hidjoystickrptparser.h" @@ -12,7 +17,9 @@ JoystickReportParser Joy(&JoyEvents); void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/HID/USBHID_desc/USBHID_desc.ino b/examples/HID/USBHID_desc/USBHID_desc.ino index 806936f9..a3056ae1 100644 --- a/examples/HID/USBHID_desc/USBHID_desc.ino +++ b/examples/HID/USBHID_desc/USBHID_desc.ino @@ -6,6 +6,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class HIDUniversal2 : public HIDUniversal @@ -14,7 +15,7 @@ public: HIDUniversal2(USB *usb) : HIDUniversal(usb) {}; protected: - virtual uint8_t OnInitSuccessful(); + uint8_t OnInitSuccessful(); }; uint8_t HIDUniversal2::OnInitSuccessful() @@ -54,7 +55,9 @@ UniversalReportParser Uni; void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/HID/le3dp/le3dp.ino b/examples/HID/le3dp/le3dp.ino index fbf07b2f..df9cbf17 100644 --- a/examples/HID/le3dp/le3dp.ino +++ b/examples/HID/le3dp/le3dp.ino @@ -8,6 +8,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -19,7 +20,9 @@ JoystickReportParser Joy(&JoyEvents); void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/HID/scale/scale.ino b/examples/HID/scale/scale.ino index c790cb1c..e335aef3 100644 --- a/examples/HID/scale/scale.ino +++ b/examples/HID/scale/scale.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -21,7 +22,9 @@ ScaleReportParser Scale(&ScaleEvents); void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/HID/scale/scale_rptparser.h b/examples/HID/scale/scale_rptparser.h index db69e656..57fbb033 100644 --- a/examples/HID/scale/scale_rptparser.h +++ b/examples/HID/scale/scale_rptparser.h @@ -1,7 +1,7 @@ #if !defined(__SCALERPTPARSER_H__) #define __SCALERPTPARSER_H__ -#include +#include #include /* Scale status constants */ @@ -19,22 +19,22 @@ struct ScaleEventData { uint8_t reportID; //must be 3 uint8_t status; - uint8_t unit; + uint8_t unit; int8_t exp; //scale factor for the weight uint16_t weight; // }; class ScaleEvents { - + Max_LCD* pLcd; - + void LcdPrint( const char* str ); - + public: - + ScaleEvents( Max_LCD* pLCD ); - + virtual void OnScaleChanged(const ScaleEventData *evt); }; diff --git a/examples/PS3USB/PS3USB.ino b/examples/PS3USB/PS3USB.ino index 2db3afd5..8db150bf 100644 --- a/examples/PS3USB/PS3USB.ino +++ b/examples/PS3USB/PS3USB.ino @@ -8,6 +8,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -20,7 +21,9 @@ uint8_t state = 0; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/PS4USB/PS4USB.ino b/examples/PS4USB/PS4USB.ino index b3a2436b..5f7860c5 100644 --- a/examples/PS4USB/PS4USB.ino +++ b/examples/PS4USB/PS4USB.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -19,7 +20,9 @@ uint8_t oldL2Value, oldR2Value; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); // Halt diff --git a/examples/PSBuzz/PSBuzz.ino b/examples/PSBuzz/PSBuzz.ino index 6944cb6b..60271f42 100644 --- a/examples/PSBuzz/PSBuzz.ino +++ b/examples/PSBuzz/PSBuzz.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -16,7 +17,9 @@ PSBuzz Buzz(&Usb); void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); // Halt diff --git a/examples/USB_desc/USB_desc.ino b/examples/USB_desc/USB_desc.ino index b0013914..e6596494 100644 --- a/examples/USB_desc/USB_desc.ino +++ b/examples/USB_desc/USB_desc.ino @@ -4,6 +4,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -49,7 +50,9 @@ void PrintAddress(uint8_t addr) void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) @@ -336,7 +339,7 @@ void printunkdescr( uint8_t* descr_ptr ) /* Print a string from Program Memory directly to save RAM */ -void printProgStr(const prog_char str[]) +void printProgStr(prog_char str[]) { char c; if(!str) return; diff --git a/examples/Xbox/XBOXOLD/XBOXOLD.ino b/examples/Xbox/XBOXOLD/XBOXOLD.ino index 968c8df7..c9ecaed4 100644 --- a/examples/Xbox/XBOXOLD/XBOXOLD.ino +++ b/examples/Xbox/XBOXOLD/XBOXOLD.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -17,7 +18,9 @@ XBOXOLD Xbox(&Usb); void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); // halt diff --git a/examples/Xbox/XBOXRECV/XBOXRECV.ino b/examples/Xbox/XBOXRECV/XBOXRECV.ino index 1f43b912..a39ddbbf 100644 --- a/examples/Xbox/XBOXRECV/XBOXRECV.ino +++ b/examples/Xbox/XBOXRECV/XBOXRECV.ino @@ -9,6 +9,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -16,7 +17,9 @@ XBOXRECV Xbox(&Usb); void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/Xbox/XBOXUSB/XBOXUSB.ino b/examples/Xbox/XBOXUSB/XBOXUSB.ino index 89161d24..a4e14f1a 100644 --- a/examples/Xbox/XBOXUSB/XBOXUSB.ino +++ b/examples/Xbox/XBOXUSB/XBOXUSB.ino @@ -8,6 +8,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -15,7 +16,9 @@ XBOXUSB Xbox(&Usb); void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); //halt diff --git a/examples/acm/acm_terminal/acm_terminal.ino b/examples/acm/acm_terminal/acm_terminal.ino index 5e4d152c..696b4d02 100644 --- a/examples/acm/acm_terminal/acm_terminal.ino +++ b/examples/acm/acm_terminal/acm_terminal.ino @@ -6,12 +6,13 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class ACMAsyncOper : public CDCAsyncOper { public: - virtual uint8_t OnInit(ACM *pacm); + uint8_t OnInit(ACM *pacm); }; uint8_t ACMAsyncOper::OnInit(ACM *pacm) @@ -48,7 +49,9 @@ ACM Acm(&Usb, &AsyncOper); void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino b/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino index dc6ab92c..2cc1fbe6 100644 --- a/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino +++ b/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino @@ -2,6 +2,27 @@ // The code for the Android application is heavily based on this guide: http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ by Miguel #include +// +// CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ! +// +// Pin 13 is occupied by the SCK pin on various Arduino boards, +// including Uno, Duemilanove, etc., so use a different pin for those boards. +// +// CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ! +// +#if defined(LED_BUILTIN) +#define LED LED_BUILTIN // Use built in LED +#else +#define LED 9 // Set to something here that makes sense for your board. +#endif + + +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif + USB Usb; ADK adk(&Usb, "TKJElectronics", // Manufacturer Name "ArduinoBlinkLED", // Model Name @@ -10,14 +31,14 @@ ADK adk(&Usb, "TKJElectronics", // Manufacturer Name "http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory) "123456789"); // Serial Number (optional) -#define LED LED_BUILTIN // Use built in LED - note that pin 13 is occupied by the SCK pin on a normal Arduino (Uno, Duemilanove etc.), so use a different pin - uint32_t timer; boolean connected; void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif if (Usb.Init() == -1) { Serial.print("\r\nOSCOKIRQ failed to assert"); while (1); // halt diff --git a/examples/adk/adk_barcode/adk_barcode.ino b/examples/adk/adk_barcode/adk_barcode.ino index b410572a..c529700c 100644 --- a/examples/adk/adk_barcode/adk_barcode.ino +++ b/examples/adk/adk_barcode/adk_barcode.ino @@ -4,10 +4,15 @@ #include #include #include +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif USB Usb; USBHub Hub1(&Usb); -USBHub Hub2(&Usb); +USBHub Hub2(&Usb); HIDBoot Keyboard(&Usb); ADK adk(&Usb,"Circuits@Home, ltd.", @@ -20,22 +25,22 @@ ADK adk(&Usb,"Circuits@Home, ltd.", class KbdRptParser : public KeyboardReportParser { - + protected: - virtual void OnKeyDown (uint8_t mod, uint8_t key); - virtual void OnKeyPressed(uint8_t key); + void OnKeyDown (uint8_t mod, uint8_t key); + void OnKeyPressed(uint8_t key); }; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) + +void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) { uint8_t c = OemToAscii(mod, key); - + if (c) OnKeyPressed(c); } - + /* what to do when symbol arrives */ -void KbdRptParser::OnKeyPressed(uint8_t key) +void KbdRptParser::OnKeyPressed(uint8_t key) { const char* new_line = "\n"; uint8_t rcode; @@ -44,36 +49,38 @@ uint8_t keylcl; if( adk.isReady() == false ) { return; } - + keylcl = key; - + if( keylcl == 0x13 ) { rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line ); } else { rcode = adk.SndData( 1, &keylcl ); - } - + } + Serial.print((char) keylcl ); - Serial.print(" : "); + Serial.print(" : "); Serial.println( keylcl, HEX ); }; - + KbdRptParser Prs; - + void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("\r\nADK demo start"); - + if (Usb.Init() == -1) { Serial.println("OSCOKIRQ failed to assert"); while(1); //halt }//if (Usb.Init() == -1... - + Keyboard.SetReportParser(0, (HIDReportParser*)&Prs); - + delay( 200 ); } diff --git a/examples/adk/demokit_20/demokit_20.ino b/examples/adk/demokit_20/demokit_20.ino index 87662297..fbbe1c73 100644 --- a/examples/adk/demokit_20/demokit_20.ino +++ b/examples/adk/demokit_20/demokit_20.ino @@ -1,5 +1,10 @@ #include #include +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif USB Usb; USBHub hub0(&Usb); @@ -16,9 +21,6 @@ uint8_t b, b1; #define LED1_RED 3 #define BUTTON1 2 -void setup(); -void loop(); - void init_buttons() { pinMode(BUTTON1, INPUT); @@ -37,9 +39,11 @@ void init_leds() void setup() { Serial.begin(115200); - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#if !defined(__MIPSEL__) + while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("\r\nADK demo start"); - + if (Usb.Init() == -1) { Serial.println("OSCOKIRQ failed to assert"); while(1); //halt @@ -56,17 +60,17 @@ void loop() uint8_t rcode; uint8_t msg[3] = { 0x00 }; Usb.Task(); - + if( adk.isReady() == false ) { analogWrite(LED1_RED, 255); return; } uint16_t len = sizeof(msg); - + rcode = adk.RcvData(&len, msg); if( rcode ) { USBTRACE2("Data rcv. :", rcode ); - } + } if(len > 0) { USBTRACE("\r\nData Packet."); // assumes only one command per packet @@ -75,10 +79,10 @@ void loop() case 0: analogWrite(LED1_RED, 255 - msg[2]); break; - }//switch( msg[1]... + }//switch( msg[1]... }//if (msg[0] == 0x2... }//if( len > 0... - + msg[0] = 0x1; b = digitalRead(BUTTON1); @@ -94,5 +98,5 @@ void loop() }//if (b != b1... - delay( 10 ); + delay( 10 ); } diff --git a/examples/adk/term_test/term_test.ino b/examples/adk/term_test/term_test.ino index dea6533f..8bc3ce56 100644 --- a/examples/adk/term_test/term_test.ino +++ b/examples/adk/term_test/term_test.ino @@ -1,5 +1,10 @@ #include #include +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif USB Usb; //USBHub Hub(&Usb); @@ -14,9 +19,11 @@ ADK adk(&Usb,"Circuits@Home, ltd.", void setup() { Serial.begin(115200); - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#if !defined(__MIPSEL__) + while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("\r\nADK demo start"); - + if (Usb.Init() == -1) { Serial.println("OSCOKIRQ failed to assert"); while(1); //halt @@ -27,31 +34,31 @@ void loop() { uint8_t rcode; uint8_t msg[64] = { 0x00 }; - const char* recv = "Received: "; - + const char* recv = "Received: "; + Usb.Task(); - + if( adk.isReady() == false ) { return; } uint16_t len = 64; - + rcode = adk.RcvData(&len, msg); if( rcode & ( rcode != hrNAK )) { USBTRACE2("Data rcv. :", rcode ); - } + } if(len > 0) { USBTRACE("\r\nData Packet."); for( uint8_t i = 0; i < len; i++ ) { Serial.print((char)msg[i]); } - /* sending back what was received */ - rcode = adk.SndData( strlen( recv ), (uint8_t *)recv ); + /* sending back what was received */ + rcode = adk.SndData( strlen( recv ), (uint8_t *)recv ); rcode = adk.SndData( strlen(( char * )msg ), msg ); }//if( len > 0 )... - delay( 1000 ); + delay( 1000 ); } diff --git a/examples/adk/term_time/term_time.ino b/examples/adk/term_time/term_time.ino index 39fe3a49..a79bac47 100644 --- a/examples/adk/term_time/term_time.ino +++ b/examples/adk/term_time/term_time.ino @@ -1,5 +1,10 @@ #include #include +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif USB Usb; @@ -13,9 +18,11 @@ ADK adk(&Usb,"Circuits@Home, ltd.", void setup() { Serial.begin(115200); - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#if !defined(__MIPSEL__) + while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("\r\nADK demo start"); - + if (Usb.Init() == -1) { Serial.println("OSCOKIRQ failed to assert"); while(1); //halt @@ -27,16 +34,16 @@ void loop() uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII const char* sec_ela = " seconds elapsed\r"; uint8_t rcode; - + Usb.Task(); if( adk.isReady() == false ) { return; } - + ultoa( millis()/1000, (char *)buf, 10 ); - + rcode = adk.SndData( strlen((char *)buf), buf ); rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela ); - - delay( 1000 ); + + delay( 1000 ); } diff --git a/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino b/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino index 26b5624d..b1dd1fdb 100644 --- a/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino +++ b/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino @@ -5,12 +5,13 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class FTDIAsync : public FTDIAsyncOper { public: - virtual uint8_t OnInit(FTDI *pftdi); + uint8_t OnInit(FTDI *pftdi); }; uint8_t FTDIAsync::OnInit(FTDI *pftdi) @@ -42,7 +43,9 @@ uint32_t next_time; void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/hub_demo/hub_demo.ino b/examples/hub_demo/hub_demo.ino index 329c6230..6f6cbaf2 100644 --- a/examples/hub_demo/hub_demo.ino +++ b/examples/hub_demo/hub_demo.ino @@ -3,6 +3,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif USB Usb; @@ -45,7 +46,9 @@ void PrintAddress(uint8_t addr) void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) @@ -332,7 +335,7 @@ void printunkdescr( uint8_t* descr_ptr ) /* Print a string from Program Memory directly to save RAM */ -void printProgStr(const prog_char str[]) +void printProgStr(prog_char str[]) { char c; if(!str) return; diff --git a/examples/max_LCD/max_LCD.ino b/examples/max_LCD/max_LCD.ino index f60ed4d5..82a09672 100644 --- a/examples/max_LCD/max_LCD.ino +++ b/examples/max_LCD/max_LCD.ino @@ -4,6 +4,11 @@ // pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3] #include +// Satisfy IDE, which only needs to see the include statment in the ino. +#ifdef dobogusinclude +#include +#include +#endif USB Usb; Max_LCD lcd(&Usb); diff --git a/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino b/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino index 4770809d..ae94a810 100644 --- a/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino +++ b/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino @@ -7,12 +7,13 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class PLAsyncOper : public CDCAsyncOper { public: - virtual uint8_t OnInit(ACM *pacm); + uint8_t OnInit(ACM *pacm); }; uint8_t PLAsyncOper::OnInit(ACM *pacm) @@ -50,7 +51,9 @@ PL2303 Pl(&Usb, &AsyncOper); void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/examples/pl2303/pl2303_gps/pl2303_gps.ino b/examples/pl2303/pl2303_gps/pl2303_gps.ino index 908763c4..4ca6eea6 100644 --- a/examples/pl2303/pl2303_gps/pl2303_gps.ino +++ b/examples/pl2303/pl2303_gps/pl2303_gps.ino @@ -8,11 +8,12 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class PLAsyncOper : public CDCAsyncOper { public: - virtual uint8_t OnInit(ACM *pacm); + uint8_t OnInit(ACM *pacm); }; uint8_t PLAsyncOper::OnInit(ACM *pacm) { @@ -49,7 +50,9 @@ uint32_t read_delay; void setup() { Serial.begin(115200); - while(!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#if !defined(__MIPSEL__) + while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if(Usb.Init() == -1) diff --git a/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino b/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino index db25e42a..6184360c 100644 --- a/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino +++ b/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino @@ -14,6 +14,7 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif /* This sample code demonstrates the normal use of a TinyGPS object. @@ -24,7 +25,7 @@ class PLAsyncOper : public CDCAsyncOper { public: - virtual uint8_t OnInit(ACM *pacm); + uint8_t OnInit(ACM *pacm); }; uint8_t PLAsyncOper::OnInit(ACM *pacm) @@ -68,7 +69,9 @@ void setup() { Serial.begin(115200); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version()); Serial.println("by Mikal Hart"); diff --git a/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino b/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino index 9e17d3cf..9a35fc23 100644 --- a/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino +++ b/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino @@ -8,12 +8,13 @@ // Satisfy IDE, which only needs to see the include statment in the ino. #ifdef dobogusinclude #include +#include #endif class PLAsyncOper : public CDCAsyncOper { public: - virtual uint8_t OnInit(ACM *pacm); + uint8_t OnInit(ACM *pacm); }; uint8_t PLAsyncOper::OnInit(ACM *pacm) @@ -50,7 +51,9 @@ PL2303 Pl(&Usb, &AsyncOper); void setup() { Serial.begin( 115200 ); +#if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection +#endif Serial.println("Start"); if (Usb.Init() == -1) diff --git a/hexdump.h b/hexdump.h index 3818d850..ffa7248b 100644 --- a/hexdump.h +++ b/hexdump.h @@ -36,7 +36,7 @@ public: byteTotal = 0; }; - virtual void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); + void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); }; template diff --git a/hid.h b/hid.h index a61cfb90..b49f5c5d 100644 --- a/hid.h +++ b/hid.h @@ -156,7 +156,7 @@ protected: void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); - virtual HIDReportParser* GetReportParser(uint8_t id); + virtual HIDReportParser* GetReportParser(uint8_t id) {}; public: @@ -166,7 +166,8 @@ public: const USB* GetUsb() { return pUsb; }; - virtual bool SetReportParser(uint8_t id, HIDReportParser *prs); + + virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) {}; uint8_t SetProtocol(uint8_t iface, uint8_t protocol); uint8_t GetProtocol(uint8_t iface, uint8_t* dataptr); diff --git a/hidboot.cpp b/hidboot.cpp index c32443bb..09f27a3a 100644 --- a/hidboot.cpp +++ b/hidboot.cpp @@ -157,27 +157,6 @@ void KeyboardReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t prevState.bInfo[i] = buf[i]; }; -uint8_t KeyboardReportParser::HandleLockingKeys(HID *hid, uint8_t key) { - uint8_t old_keys = kbdLockingKeys.bLeds; - - switch (key) { - case UHS_HID_BOOT_KEY_NUM_LOCK: - kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock; - break; - case UHS_HID_BOOT_KEY_CAPS_LOCK: - kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock; - break; - case UHS_HID_BOOT_KEY_SCROLL_LOCK: - kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock; - break; - } - - if (old_keys != kbdLockingKeys.bLeds && hid) - return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &kbdLockingKeys.bLeds)); - - return 0; -} - const uint8_t KeyboardReportParser::numKeys[10] PROGMEM = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')'}; const uint8_t KeyboardReportParser::symKeysUp[12] PROGMEM = {'_', '+', '{', '}', '|', '~', ':', '"', '~', '<', '>', '?'}; const uint8_t KeyboardReportParser::symKeysLo[12] PROGMEM = {'-', '=', '[', ']', '\\', ' ', ';', '\'', '`', ',', '.', '/'}; diff --git a/hidboot.h b/hidboot.h index b35df7cb..6046b39d 100644 --- a/hidboot.h +++ b/hidboot.h @@ -56,7 +56,7 @@ class MouseReportParser : public HIDReportParser { } prevState; public: - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); + void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); protected: @@ -144,10 +144,30 @@ public: kbdLockingKeys.bLeds = 0; }; - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); + void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); protected: - virtual uint8_t HandleLockingKeys(HID* hid, uint8_t key); + + virtual uint8_t HandleLockingKeys(HID* hid, uint8_t key) { + uint8_t old_keys = kbdLockingKeys.bLeds; + + switch(key) { + case UHS_HID_BOOT_KEY_NUM_LOCK: + kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock; + break; + case UHS_HID_BOOT_KEY_CAPS_LOCK: + kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock; + break; + case UHS_HID_BOOT_KEY_SCROLL_LOCK: + kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock; + break; + } + + if(old_keys != kbdLockingKeys.bLeds && hid) + return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &kbdLockingKeys.bLeds)); + + return 0; + }; virtual void OnControlKeysChanged(uint8_t before, uint8_t after) { }; @@ -204,15 +224,16 @@ public: }; // USBDeviceConfig implementation - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Release(); - virtual uint8_t Poll(); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Release(); + uint8_t Poll(); virtual uint8_t GetAddress() { return bAddress; }; // UsbConfigXtracter implementation + // Method should be defined here if virtual. virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); virtual boolean DEVCLASSOK(uint8_t klass) { diff --git a/hidescriptorparser.h b/hidescriptorparser.h index c43aaaea..e5fd17d8 100644 --- a/hidescriptorparser.h +++ b/hidescriptorparser.h @@ -111,6 +111,7 @@ protected: uint16_t totalSize; // Report size in bits + // Method should be defined here if virtual. virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); UsagePageFunc pfUsage; @@ -132,7 +133,7 @@ public: theSkipper.Initialize(&theBuffer); }; - virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); + void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); enum { enErrorSuccess = 0 @@ -156,6 +157,7 @@ class ReportDescParser2 : public ReportDescParserBase { uint8_t bLen; // Report length protected: + // Method should be defined here if virtual. virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); public: @@ -167,6 +169,7 @@ public: class UniversalReportParser : public HIDReportParser { public: + // Method should be defined here if virtual. virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); }; diff --git a/hiduniversal.h b/hiduniversal.h index 3e090aa7..4e03d4fc 100644 --- a/hiduniversal.h +++ b/hiduniversal.h @@ -69,7 +69,7 @@ protected: uint16_t PID, VID; // PID and VID of connected device // HID implementation - virtual HIDReportParser* GetReportParser(uint8_t id); + HIDReportParser* GetReportParser(uint8_t id); virtual uint8_t OnInitSuccessful() { return 0; @@ -83,12 +83,12 @@ public: HIDUniversal(USB *p); // HID implementation - virtual bool SetReportParser(uint8_t id, HIDReportParser *prs); + bool SetReportParser(uint8_t id, HIDReportParser *prs); // USBDeviceConfig implementation - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Release(); - virtual uint8_t Poll(); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Release(); + uint8_t Poll(); virtual uint8_t GetAddress() { return bAddress; @@ -99,7 +99,7 @@ public: }; // UsbConfigXtracter implementation - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); }; #endif // __HIDUNIVERSAL_H__ diff --git a/masstorage.h b/masstorage.h index 176752fc..e1f5a7ef 100644 --- a/masstorage.h +++ b/masstorage.h @@ -519,18 +519,18 @@ public: uint16_t GetSectorSize(uint8_t lun); // USBDeviceConfig implementation - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Release(); - virtual uint8_t Poll(); + uint8_t Release(); + uint8_t Poll(); virtual uint8_t GetAddress() { return bAddress; }; // UsbConfigXtracter implementation - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); + void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); virtual boolean DEVCLASSOK(uint8_t klass) { return (klass == USB_CLASS_MASS_STORAGE); diff --git a/max_LCD.h b/max_LCD.h index 48946a1f..7ca70e59 100644 --- a/max_LCD.h +++ b/max_LCD.h @@ -88,10 +88,10 @@ public: void command(uint8_t); #if defined(ARDUINO) && ARDUINO >=100 - virtual size_t write(uint8_t); + size_t write(uint8_t); using Print::write; #else - virtual void write(uint8_t); + void write(uint8_t); #endif private: diff --git a/usbhub.h b/usbhub.h index aa1281b2..931f8d88 100644 --- a/usbhub.h +++ b/usbhub.h @@ -191,10 +191,10 @@ public: void PrintHubStatus(); - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - virtual uint8_t Release(); - virtual uint8_t Poll(); - virtual void ResetHubPort(uint8_t port); + uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); + uint8_t Release(); + uint8_t Poll(); + void ResetHubPort(uint8_t port); virtual uint8_t GetAddress() { return bAddress; From eb424a07acd3a5860576a0b3eefd2993c8422b93 Mon Sep 17 00:00:00 2001 From: Matt Sieren Date: Fri, 21 Nov 2014 22:45:57 +0100 Subject: [PATCH 25/35] nRF51822 Pins Creating pins for the RBL nRF51822 Board --- avrpins.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/avrpins.h b/avrpins.h index da80349d..262bb6e2 100644 --- a/avrpins.h +++ b/avrpins.h @@ -961,6 +961,58 @@ MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected #undef MAKE_PIN +#elif defined(RBL_NRF51822) + +#define MAKE_PIN(className, pin) \ +class className { \ +public: \ + static void Set() { \ + nrf_gpio_pin_set(pin); \ + } \ + static void Clear() { \ + nrf_gpio_pin_clear(pin); \ + } \ + static void SetDirRead() { \ + nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL); \ + } \ + static void SetDirWrite() { \ + nrf_gpio_cfg_output(pin); \ + } \ + static uint8_t IsSet() { \ + return (uint8_t)nrf_gpio_pin_read(pin); \ + } \ +}; + +// See: pin_transform.c in RBL nRF51822 SDK +MAKE_PIN(P0, Pin_nRF51822_to_Arduino(D0)); +MAKE_PIN(P1, Pin_nRF51822_to_Arduino(D1)); +MAKE_PIN(P2, Pin_nRF51822_to_Arduino(D2)); +MAKE_PIN(P3, Pin_nRF51822_to_Arduino(D3)); +MAKE_PIN(P4, Pin_nRF51822_to_Arduino(D4)); +MAKE_PIN(P5, Pin_nRF51822_to_Arduino(D5)); +MAKE_PIN(P6, Pin_nRF51822_to_Arduino(D6)); +MAKE_PIN(P7, Pin_nRF51822_to_Arduino(D7)); +MAKE_PIN(P8, Pin_nRF51822_to_Arduino(D8)); +MAKE_PIN(P9, Pin_nRF51822_to_Arduino(D9)); // INT +MAKE_PIN(P10, Pin_nRF51822_to_Arduino(D10)); // SS +MAKE_PIN(P11, Pin_nRF51822_to_Arduino(D11)); +MAKE_PIN(P12, Pin_nRF51822_to_Arduino(D12)); +MAKE_PIN(P13, Pin_nRF51822_to_Arduino(D13)); +MAKE_PIN(P14, Pin_nRF51822_to_Arduino(D14)); +MAKE_PIN(P15, Pin_nRF51822_to_Arduino(D15)); +MAKE_PIN(P17, Pin_nRF51822_to_Arduino(D17)); // MISO +MAKE_PIN(P18, Pin_nRF51822_to_Arduino(D18)); // MOSI +MAKE_PIN(P16, Pin_nRF51822_to_Arduino(D16)); // CLK +MAKE_PIN(P19, Pin_nRF51822_to_Arduino(D19)); +MAKE_PIN(P20, Pin_nRF51822_to_Arduino(D20)); +MAKE_PIN(P21, Pin_nRF51822_to_Arduino(D21)); +MAKE_PIN(P22, Pin_nRF51822_to_Arduino(D22)); +MAKE_PIN(P23, Pin_nRF51822_to_Arduino(D23)); +MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24)); + +#undef MAKE_PIN + + #else #error "Please define board in avrpins.h" From 3646c650b6cd67fa4b17eaec10900e08abd3250e Mon Sep 17 00:00:00 2001 From: Matt Sieren Date: Fri, 21 Nov 2014 22:58:54 +0100 Subject: [PATCH 26/35] Added RBL nRF51822 Support Added support for the nRF51822 Board by RedBearLab. --- usbhost.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/usbhost.h b/usbhost.h index cf26c1f0..46ef1346 100644 --- a/usbhost.h +++ b/usbhost.h @@ -27,6 +27,9 @@ e-mail : support@circuitsathome.com #include #endif +#if defined(RBL_NRF51822) +#include "SPI.H" +#endif /* SPI initialization */ template< typename SPI_CLK, typename SPI_MOSI, typename SPI_MISO, typename SPI_SS > class SPi { public: @@ -46,6 +49,13 @@ public: SPI.begin(); SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz } +#elif defined(RBL_NRF51822) + static void init() { + SPI_SS::SetDirWrite(); + SPI_SS::Set(); + SPI.begin(); + // SPI.setFrequency(SPI_FREQUENCY_8M); + } #else static void init() { //uint8_t tmp; @@ -74,6 +84,8 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi; typedef SPi< P13, P11, P12, P10 > spi; #elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) typedef SPi< P76, P75, P74, P10 > spi; +#elif defined(RBL_NRF51822) +typedef SPi< P16, P18, P17, P10 > spi; #else #error "No SPI entry in usbhost.h" #endif @@ -135,7 +147,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) { c[0] = reg | 0x02; c[1] = data; spi4teensy3::send(c, 2); -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) SPI.transfer(reg | 0x02); SPI.transfer(data); #else @@ -159,7 +171,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* spi4teensy3::send(reg | 0x02); spi4teensy3::send(data_p, nbytes); data_p += nbytes; -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) SPI.transfer(reg | 0x02); while(nbytes) { SPI.transfer(*data_p); @@ -201,7 +213,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) { spi4teensy3::send(reg); uint8_t rv = spi4teensy3::receive(); SPI_SS::Set(); -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) SPI.transfer(reg); uint8_t rv = SPI.transfer(0); SPI_SS::Set(); @@ -227,7 +239,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* spi4teensy3::send(reg); spi4teensy3::receive(data_p, nbytes); data_p += nbytes; -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) SPI.transfer(reg); while(nbytes) { *data_p++ = SPI.transfer(0); From 4cf9f34228904acb4ebfae98fb34cf6bc17295a8 Mon Sep 17 00:00:00 2001 From: Matt Sieren Date: Sat, 22 Nov 2014 09:53:59 +0100 Subject: [PATCH 27/35] Moved include for nRF51822 Moved the include into the right file. --- settings.h | 2 +- usbhost.h | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/settings.h b/settings.h index e3d0ed1d..e6ed5cf1 100644 --- a/settings.h +++ b/settings.h @@ -137,7 +137,7 @@ e-mail : support@circuitsathome.com #define USING_SPI4TEENSY3 0 #endif -#if defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) +#if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) #include // Use the Arduino SPI library for the Arduino Due #endif diff --git a/usbhost.h b/usbhost.h index 46ef1346..f35bc0f4 100644 --- a/usbhost.h +++ b/usbhost.h @@ -27,9 +27,7 @@ e-mail : support@circuitsathome.com #include #endif -#if defined(RBL_NRF51822) -#include "SPI.H" -#endif + /* SPI initialization */ template< typename SPI_CLK, typename SPI_MOSI, typename SPI_MISO, typename SPI_SS > class SPi { public: From a88e9b44e7402fcab292f37703756aa864e6f174 Mon Sep 17 00:00:00 2001 From: Matt Sieren Date: Sat, 22 Nov 2014 09:56:15 +0100 Subject: [PATCH 28/35] Added Board Added RedBearLab nRF51822 and instructions to the readme. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1a3163b3..4d84061f 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,8 @@ Currently the following boards are supported by the library: * Balanduino * Sanguino * Black Widdow +* RedBearLab nRF51822 + * If you are using the RedBearLab nRF51822, then you must include the RedBearLab SPI library like so: ```#include ``` in your .ino file. The following boards need to be activated manually in [settings.h](settings.h): From 904569278d10d717a177dfc8eab1f6b385b96629 Mon Sep 17 00:00:00 2001 From: Matt Sieren Date: Sat, 22 Nov 2014 11:02:36 +0100 Subject: [PATCH 29/35] Updated instructions Added information about including SPI.h --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d84061f..6d40b833 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,8 @@ Now quit the Arduino IDE and reopen it. Now you should be able to go open all the examples codes by navigating to "File>Examples>USB\_Host\_Shield\_20" and then select the example you will like to open. +Please make sure to include the SPI library like so: ```#include ``` in your .ino file. + For more information visit the following sites: and . # How to use the library @@ -93,14 +95,12 @@ Currently the following boards are supported by the library: * All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.) * Arduino Due - * If you are using the Arduino Due, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. * Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x) * Note if you are using the Teensy 3.x you should download this SPI library as well: . You should then add ```#include ``` to your .ino file. * Balanduino * Sanguino * Black Widdow * RedBearLab nRF51822 - * If you are using the RedBearLab nRF51822, then you must include the RedBearLab SPI library like so: ```#include ``` in your .ino file. The following boards need to be activated manually in [settings.h](settings.h): From e0ac4eedaddad62166f0d87bbd29886c7f927aa5 Mon Sep 17 00:00:00 2001 From: Matt Sieren Date: Mon, 24 Nov 2014 08:22:19 +0100 Subject: [PATCH 30/35] Revert "Updated instructions" This reverts commit 904569278d10d717a177dfc8eab1f6b385b96629. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d40b833..4d84061f 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,6 @@ Now quit the Arduino IDE and reopen it. Now you should be able to go open all the examples codes by navigating to "File>Examples>USB\_Host\_Shield\_20" and then select the example you will like to open. -Please make sure to include the SPI library like so: ```#include ``` in your .ino file. - For more information visit the following sites: and . # How to use the library @@ -95,12 +93,14 @@ Currently the following boards are supported by the library: * All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.) * Arduino Due + * If you are using the Arduino Due, then you must include the Arduino SPI library like so: ```#include ``` in your .ino file. * Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x) * Note if you are using the Teensy 3.x you should download this SPI library as well: . You should then add ```#include ``` to your .ino file. * Balanduino * Sanguino * Black Widdow * RedBearLab nRF51822 + * If you are using the RedBearLab nRF51822, then you must include the RedBearLab SPI library like so: ```#include ``` in your .ino file. The following boards need to be activated manually in [settings.h](settings.h): From 585e6b9df503374d625bcdbd23c3e5285693102a Mon Sep 17 00:00:00 2001 From: Matt Sieren Date: Mon, 24 Nov 2014 08:23:41 +0100 Subject: [PATCH 31/35] Updated comment Updated comment to reflect including SPI.h on the RBL nRF as well. --- settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.h b/settings.h index e6ed5cf1..cc02f583 100644 --- a/settings.h +++ b/settings.h @@ -138,7 +138,7 @@ e-mail : support@circuitsathome.com #endif #if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) -#include // Use the Arduino SPI library for the Arduino Due +#include // Use the Arduino SPI library for the Arduino Due and RedBearLab nRF51822 #endif #endif /* SETTINGS_H */ From 2b4a56de3d090686f62d25ea34042759dc4352d6 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 2 Dec 2014 17:46:05 -0800 Subject: [PATCH 32/35] Added note about SPI pins used on Arduino Uno --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4d84061f..e7f4ed56 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,8 @@ More information about the controller can be found at the following sites: The shield is using SPI for communicating with the MAX3421E USB host controller. It uses the SCK, MISO and MOSI pins via the ICSP on your board. +Note this means that it uses pin 13, 12, 11 on an Arduino Uno, so these pins can not be used for anything else! + Furthermore it uses one pin as SS and one INT pin. These are by default located on pin 10 and 9 respectively. They can easily be reconfigured in case you need to use them for something else by cutting the jumper on the shield and then solder a wire from the pad to the new pin. After that you need modify the following entry in [UsbCore.h](UsbCore.h): From 96dfd7e37d395a70d3d8c1bf211eaa8323b2d857 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sat, 3 Jan 2015 10:52:17 +0100 Subject: [PATCH 33/35] Added support for Joytech wired controller See: https://github.com/felis/USB_Host_Shield_2.0/issues/128 --- XBOXUSB.cpp | 2 +- XBOXUSB.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/XBOXUSB.cpp b/XBOXUSB.cpp index 3cd9cde9..ddece21b 100644 --- a/XBOXUSB.cpp +++ b/XBOXUSB.cpp @@ -105,7 +105,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"), 0x80); #endif goto FailUnknownDevice; - } else if(PID != XBOX_WIRED_PID && PID != MADCATZ_WIRED_PID && PID != GAMESTOP_WIRED_PID && PID != AFTERGLOW_WIRED_PID) // Check PID + } else if(PID != XBOX_WIRED_PID && PID != MADCATZ_WIRED_PID && PID != GAMESTOP_WIRED_PID && PID != AFTERGLOW_WIRED_PID && PID != JOYTECH_WIRED_PID) // Check PID goto FailUnknownDevice; // Allocate new address according to device class diff --git a/XBOXUSB.h b/XBOXUSB.h index 8d5ecb2a..f7a657ba 100644 --- a/XBOXUSB.h +++ b/XBOXUSB.h @@ -40,6 +40,7 @@ #define XBOX_WIRELESS_RECEIVER_PID 0x0719 // Microsoft Wireless Gaming Receiver #define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID 0x0291 // Third party Wireless Gaming Receiver #define MADCATZ_WIRED_PID 0xF016 // Mad Catz wired controller +#define JOYTECH_WIRED_PID 0xBEEF // For Joytech wired controller #define GAMESTOP_WIRED_PID 0x0401 // Gamestop wired controller #define AFTERGLOW_WIRED_PID 0x0213 // Afterglow wired controller - it uses the same VID as a Gamestop controller @@ -103,7 +104,7 @@ public: * @return Returns true if the device's VID and PID matches this driver. */ virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { - return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID || vid == GAMESTOP_VID) && (pid == XBOX_WIRED_PID || pid == MADCATZ_WIRED_PID || pid == GAMESTOP_WIRED_PID || pid == AFTERGLOW_WIRED_PID)); + return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID || vid == GAMESTOP_VID) && (pid == XBOX_WIRED_PID || pid == MADCATZ_WIRED_PID || pid == GAMESTOP_WIRED_PID || pid == AFTERGLOW_WIRED_PID || pid == JOYTECH_WIRED_PID)); }; /**@}*/ From bd8c8e740419095f3c1d8875d199e16858058899 Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Thu, 19 Feb 2015 03:14:39 -0500 Subject: [PATCH 34/35] Fix use of "bool" so ARM compiles correctly --- BTD.h | 4 +-- PS3USB.h | 2 +- PS4USB.h | 2 +- PSBuzz.h | 2 +- UsbCore.h | 10 +++---- XBOXOLD.h | 2 +- XBOXRECV.h | 2 +- XBOXUSB.h | 2 +- adk.h | 2 +- cdcftdi.h | 2 +- examples/Bluetooth/PS3BT/PS3BT.ino | 4 +-- examples/Bluetooth/PS3Multi/PS3Multi.ino | 4 +-- examples/Bluetooth/PS3SPP/PS3SPP.ino | 2 +- examples/Bluetooth/PS4BT/PS4BT.ino | 2 +- examples/Bluetooth/SPP/SPP.ino | 2 +- examples/Bluetooth/SPPMulti/SPPMulti.ino | 2 +- examples/Bluetooth/WiiMulti/WiiMulti.ino | 4 +-- examples/PS3USB/PS3USB.ino | 2 +- examples/PS4USB/PS4USB.ino | 2 +- .../adk/ArduinoBlinkLED/ArduinoBlinkLED.ino | 2 +- examples/testusbhostFAT/testusbhostFAT.ino | 28 +++++++++---------- hidboot.h | 4 +-- masstorage.cpp | 8 +++--- masstorage.h | 6 ++-- usbhub.h | 2 +- 25 files changed, 52 insertions(+), 52 deletions(-) diff --git a/BTD.h b/BTD.h index c992b935..567e9fab 100755 --- a/BTD.h +++ b/BTD.h @@ -284,7 +284,7 @@ public: * @param klass The device's USB class. * @return Returns true if the device's USB class matches this driver. */ - virtual boolean DEVCLASSOK(uint8_t klass) { + virtual bool DEVCLASSOK(uint8_t klass) { return (klass == USB_CLASS_WIRELESS_CTRL); }; @@ -295,7 +295,7 @@ public: * @param pid The device's PID. * @return Returns true if the device's VID and PID matches this driver. */ - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { if(vid == IOGEAR_GBU521_VID && pid == IOGEAR_GBU521_PID) return true; if(my_bdaddr[0] != 0x00 || my_bdaddr[1] != 0x00 || my_bdaddr[2] != 0x00 || my_bdaddr[3] != 0x00 || my_bdaddr[4] != 0x00 || my_bdaddr[5] != 0x00) { // Check if Bluetooth address is set diff --git a/PS3USB.h b/PS3USB.h index 35604f0c..a6e5b14f 100644 --- a/PS3USB.h +++ b/PS3USB.h @@ -108,7 +108,7 @@ public: * @param pid The device's PID. * @return Returns true if the device's VID and PID matches this driver. */ - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return (vid == PS3_VID && (pid == PS3_PID || pid == PS3NAVIGATION_PID || pid == PS3MOVE_PID)); }; /**@}*/ diff --git a/PS4USB.h b/PS4USB.h index 16dabad4..8a9e12fa 100644 --- a/PS4USB.h +++ b/PS4USB.h @@ -119,7 +119,7 @@ protected: * @param pid The device's PID. * @return Returns true if the device's VID and PID matches this driver. */ - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return (vid == PS4_VID && pid == PS4_PID); }; /**@}*/ diff --git a/PSBuzz.h b/PSBuzz.h index 13456e5c..5043a086 100644 --- a/PSBuzz.h +++ b/PSBuzz.h @@ -169,7 +169,7 @@ protected: * @param pid The device's PID. * @return Returns true if the device's VID and PID matches this driver. */ - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return (vid == PSBUZZ_VID && pid == PSBUZZ_PID); }; /**@}*/ diff --git a/UsbCore.h b/UsbCore.h index f514195c..993329f5 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -143,15 +143,15 @@ public: return; } // Note used for hubs only! - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return false; } - virtual boolean DEVCLASSOK(uint8_t klass) { + virtual bool DEVCLASSOK(uint8_t klass) { return false; } - virtual boolean DEVSUBCLASSOK(uint8_t subklass) { + virtual bool DEVSUBCLASSOK(uint8_t subklass) { return true; } @@ -241,8 +241,8 @@ public: uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr); uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value); /**/ - uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, boolean direction); - uint8_t ctrlStatus(uint8_t ep, boolean direction, uint16_t nak_limit); + uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, bool direction); + uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit); uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data); uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data); uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit); diff --git a/XBOXOLD.h b/XBOXOLD.h index 5ea237d9..d3ac5be9 100644 --- a/XBOXOLD.h +++ b/XBOXOLD.h @@ -99,7 +99,7 @@ public: * @param pid The device's PID. * @return Returns true if the device's VID and PID matches this driver. */ - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID) && (pid == XBOX_OLD_PID1 || pid == XBOX_OLD_PID2 || pid == XBOX_OLD_PID3 || pid == XBOX_OLD_PID4)); }; /**@}*/ diff --git a/XBOXRECV.h b/XBOXRECV.h index 32bd6e7a..e27b0c5e 100644 --- a/XBOXRECV.h +++ b/XBOXRECV.h @@ -113,7 +113,7 @@ public: * @param pid The device's PID. * @return Returns true if the device's VID and PID matches this driver. */ - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID) && (pid == XBOX_WIRELESS_RECEIVER_PID || pid == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID)); }; /**@}*/ diff --git a/XBOXUSB.h b/XBOXUSB.h index fc3fdc8f..05ec1ed1 100644 --- a/XBOXUSB.h +++ b/XBOXUSB.h @@ -105,7 +105,7 @@ public: * @param pid The device's PID. * @return Returns true if the device's VID and PID matches this driver. */ - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID || vid == GAMESTOP_VID) && (pid == XBOX_WIRED_PID || pid == MADCATZ_WIRED_PID || pid == GAMESTOP_WIRED_PID || pid == AFTERGLOW_WIRED_PID)); }; /**@}*/ diff --git a/adk.h b/adk.h index aa9a7ebb..a167f425 100644 --- a/adk.h +++ b/adk.h @@ -112,7 +112,7 @@ public: return ready; }; - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return (vid == ADK_VID && (pid == ADK_PID || pid == ADB_PID)); }; diff --git a/cdcftdi.h b/cdcftdi.h index 0bb1008c..d45d2389 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -134,7 +134,7 @@ public: // UsbConfigXtracter implementation void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { + virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return (vid == FTDI_VID && pid == FTDI_PID); } diff --git a/examples/Bluetooth/PS3BT/PS3BT.ino b/examples/Bluetooth/PS3BT/PS3BT.ino index 47e7d3fe..227cfd75 100644 --- a/examples/Bluetooth/PS3BT/PS3BT.ino +++ b/examples/Bluetooth/PS3BT/PS3BT.ino @@ -20,8 +20,8 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so PS3BT PS3(&Btd); // This will just create the instance //PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch -boolean printTemperature; -boolean printAngle; +bool printTemperature; +bool printAngle; void setup() { Serial.begin(115200); diff --git a/examples/Bluetooth/PS3Multi/PS3Multi.ino b/examples/Bluetooth/PS3Multi/PS3Multi.ino index a630640a..2d35b059 100644 --- a/examples/Bluetooth/PS3Multi/PS3Multi.ino +++ b/examples/Bluetooth/PS3Multi/PS3Multi.ino @@ -19,8 +19,8 @@ USB Usb; BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so PS3BT *PS3[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! const uint8_t length = sizeof(PS3) / sizeof(PS3[0]); // Get the lenght of the array -boolean printAngle[length]; -boolean oldControllerState[length]; +bool printAngle[length]; +bool oldControllerState[length]; void setup() { for (uint8_t i = 0; i < length; i++) { diff --git a/examples/Bluetooth/PS3SPP/PS3SPP.ino b/examples/Bluetooth/PS3SPP/PS3SPP.ino index 40c23ea1..a9d7876a 100644 --- a/examples/Bluetooth/PS3SPP/PS3SPP.ino +++ b/examples/Bluetooth/PS3SPP/PS3SPP.ino @@ -29,7 +29,7 @@ SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the PS3BT PS3(&Btd); // This will just create the instance //PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch -boolean firstMessage = true; +bool firstMessage = true; String output = ""; // We will store the data in this string void setup() { diff --git a/examples/Bluetooth/PS4BT/PS4BT.ino b/examples/Bluetooth/PS4BT/PS4BT.ino index b6ee3b1d..8547e0ff 100644 --- a/examples/Bluetooth/PS4BT/PS4BT.ino +++ b/examples/Bluetooth/PS4BT/PS4BT.ino @@ -25,7 +25,7 @@ PS4BT PS4(&Btd, PAIR); // After that you can simply create the instance like so and then press the PS button on the device //PS4BT PS4(&Btd); -boolean printAngle, printTouch; +bool printAngle, printTouch; uint8_t oldL2Value, oldR2Value; void setup() { diff --git a/examples/Bluetooth/SPP/SPP.ino b/examples/Bluetooth/SPP/SPP.ino index 90cf94ba..fb0dda7a 100644 --- a/examples/Bluetooth/SPP/SPP.ino +++ b/examples/Bluetooth/SPP/SPP.ino @@ -20,7 +20,7 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000" //SPP SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so -boolean firstMessage = true; +bool firstMessage = true; void setup() { Serial.begin(115200); diff --git a/examples/Bluetooth/SPPMulti/SPPMulti.ino b/examples/Bluetooth/SPPMulti/SPPMulti.ino index e4cf16f5..41090fe9 100644 --- a/examples/Bluetooth/SPPMulti/SPPMulti.ino +++ b/examples/Bluetooth/SPPMulti/SPPMulti.ino @@ -20,7 +20,7 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so const uint8_t length = 2; // Set the number of instances here SPP *SerialBT[length]; // We will use this pointer to store the instances, you can easily make it larger if you like, but it will use a lot of RAM! -boolean firstMessage[length] = { true }; // Set all to true +bool firstMessage[length] = { true }; // Set all to true void setup() { for (uint8_t i = 0; i < length; i++) diff --git a/examples/Bluetooth/WiiMulti/WiiMulti.ino b/examples/Bluetooth/WiiMulti/WiiMulti.ino index d3f15fca..898d467f 100644 --- a/examples/Bluetooth/WiiMulti/WiiMulti.ino +++ b/examples/Bluetooth/WiiMulti/WiiMulti.ino @@ -19,8 +19,8 @@ USB Usb; BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so WII *Wii[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! const uint8_t length = sizeof(Wii) / sizeof(Wii[0]); // Get the lenght of the array -boolean printAngle[length]; -boolean oldControllerState[length]; +bool printAngle[length]; +bool oldControllerState[length]; void setup() { for (uint8_t i = 0; i < length; i++) { diff --git a/examples/PS3USB/PS3USB.ino b/examples/PS3USB/PS3USB.ino index 8db150bf..ca5684da 100644 --- a/examples/PS3USB/PS3USB.ino +++ b/examples/PS3USB/PS3USB.ino @@ -16,7 +16,7 @@ USB Usb; PS3USB PS3(&Usb); // This will just create the instance //PS3USB PS3(&Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch -boolean printAngle; +bool printAngle; uint8_t state = 0; void setup() { diff --git a/examples/PS4USB/PS4USB.ino b/examples/PS4USB/PS4USB.ino index 5f7860c5..5d49f234 100644 --- a/examples/PS4USB/PS4USB.ino +++ b/examples/PS4USB/PS4USB.ino @@ -15,7 +15,7 @@ USB Usb; PS4USB PS4(&Usb); -boolean printAngle, printTouch; +bool printAngle, printTouch; uint8_t oldL2Value, oldR2Value; void setup() { diff --git a/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino b/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino index 2cc1fbe6..d59b9bb3 100644 --- a/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino +++ b/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino @@ -32,7 +32,7 @@ ADK adk(&Usb, "TKJElectronics", // Manufacturer Name "123456789"); // Serial Number (optional) uint32_t timer; -boolean connected; +bool connected; void setup() { Serial.begin(115200); diff --git a/examples/testusbhostFAT/testusbhostFAT.ino b/examples/testusbhostFAT/testusbhostFAT.ino index 70107963..3854b74f 100755 --- a/examples/testusbhostFAT/testusbhostFAT.ino +++ b/examples/testusbhostFAT/testusbhostFAT.ino @@ -80,14 +80,14 @@ USB Usb; volatile uint8_t current_state = 1; volatile uint8_t last_state = 0; -volatile boolean fatready = false; -volatile boolean partsready = false; -volatile boolean notified = false; -volatile boolean runtest = false; -volatile boolean usbon = false; +volatile bool fatready = false; +volatile bool partsready = false; +volatile bool notified = false; +volatile bool runtest = false; +volatile bool usbon = false; volatile uint32_t usbon_time; -volatile boolean change = false; -volatile boolean reportlvl = false; +volatile bool change = false; +volatile bool reportlvl = false; int cpart = 0; PCPartition *PT; @@ -178,7 +178,7 @@ extern "C" { #endif void setup() { - boolean serr = false; + bool serr = false; for(int i = 0; i < _VOLUMES; i++) { Fats[i] = NULL; sto[i].private_data = new pvt_t; @@ -454,14 +454,14 @@ void loop() { } // This is horrible, and needs to be moved elsewhere! for(int B = 0; B < MAX_USB_MS_DRIVERS; B++) { - if(!partsready && (UHS_USB_BulkOnly[B]->GetAddress() != NULL)) { + if(!partsready && (UHS_USB_Storage[B]->GetAddress() != NULL)) { // Build a list. - int ML = UHS_USB_BulkOnly[B]->GetbMaxLUN(); + int ML = UHS_USB_Storage[B]->GetbMaxLUN(); //printf("MAXLUN = %i\r\n", ML); ML++; for(int i = 0; i < ML; i++) { - if(UHS_USB_BulkOnly[B]->LUNIsGood(i)) { + if(UHS_USB_Storage[B]->LUNIsGood(i)) { partsready = true; ((pvt_t *)(sto[i].private_data))->lun = i; ((pvt_t *)(sto[i].private_data))->B = B; @@ -470,8 +470,8 @@ void loop() { sto[i].Status = *UHS_USB_BulkOnly_Status; sto[i].Initialize = *UHS_USB_BulkOnly_Initialize; sto[i].Commit = *UHS_USB_BulkOnly_Commit; - sto[i].TotalSectors = UHS_USB_BulkOnly[B]->GetCapacity(i); - sto[i].SectorSize = UHS_USB_BulkOnly[B]->GetSectorSize(i); + sto[i].TotalSectors = UHS_USB_Storage[B]->GetCapacity(i); + sto[i].SectorSize = UHS_USB_Storage[B]->GetSectorSize(i); printf_P(PSTR("LUN:\t\t%u\r\n"), i); printf_P(PSTR("Total Sectors:\t%08lx\t%lu\r\n"), sto[i].TotalSectors, sto[i].TotalSectors); printf_P(PSTR("Sector Size:\t%04x\t\t%u\r\n"), sto[i].SectorSize, sto[i].SectorSize); @@ -524,7 +524,7 @@ void loop() { if(Fats[0] != NULL) { struct Pvt * p; p = ((struct Pvt *)(Fats[0]->storage->private_data)); - if(!UHS_USB_BulkOnly[p->B]->LUNIsGood(p->lun)) { + if(!UHS_USB_Storage[p->B]->LUNIsGood(p->lun)) { // media change #if !defined(CORE_TEENSY) && defined(__AVR__) fadeAmount = 80; diff --git a/hidboot.h b/hidboot.h index 6046b39d..0694a0be 100644 --- a/hidboot.h +++ b/hidboot.h @@ -236,11 +236,11 @@ public: // Method should be defined here if virtual. virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - virtual boolean DEVCLASSOK(uint8_t klass) { + virtual bool DEVCLASSOK(uint8_t klass) { return (klass == USB_CLASS_HID); } - virtual boolean DEVSUBCLASSOK(uint8_t subklass) { + virtual bool DEVSUBCLASSOK(uint8_t subklass) { return (subklass == BOOT_PROTOCOL); } }; diff --git a/masstorage.cpp b/masstorage.cpp index ab9ad4ff..351a2cb3 100644 --- a/masstorage.cpp +++ b/masstorage.cpp @@ -67,7 +67,7 @@ bool BulkOnly::LUNIsGood(uint8_t lun) { * @param lun Logical Unit Number * @return cached status of write protect switch */ -boolean BulkOnly::WriteProtected(uint8_t lun) { +bool BulkOnly::WriteProtected(uint8_t lun) { return WriteOk[lun]; } @@ -599,7 +599,7 @@ uint8_t BulkOnly::Release() { * @param lun Logical Unit Number * @return true if LUN is ready for use. */ -boolean BulkOnly::CheckLUN(uint8_t lun) { +bool BulkOnly::CheckLUN(uint8_t lun) { uint8_t rcode; Capacity capacity; for(uint8_t i = 0; i < 8; i++) capacity.data[i] = 0; @@ -1020,11 +1020,11 @@ uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void printf("Transfersize %i\r\n", bytes); delay(1000); - boolean callback = (flags & MASS_TRANS_FLG_CALLBACK) == MASS_TRANS_FLG_CALLBACK; + bool callback = (flags & MASS_TRANS_FLG_CALLBACK) == MASS_TRANS_FLG_CALLBACK; #else uint16_t bytes = buf_size; #endif - boolean write = (pcbw->bmCBWFlags & MASS_CMD_DIR_IN) != MASS_CMD_DIR_IN; + bool write = (pcbw->bmCBWFlags & MASS_CMD_DIR_IN) != MASS_CMD_DIR_IN; uint8_t ret = 0; uint8_t usberr; CommandStatusWrapper csw; // up here, we allocate ahead to save cpu cycles. diff --git a/masstorage.h b/masstorage.h index e1f5a7ef..330826c4 100644 --- a/masstorage.h +++ b/masstorage.h @@ -507,7 +507,7 @@ public: return bTheLUN; // Active LUN } - boolean WriteProtected(uint8_t lun); + bool WriteProtected(uint8_t lun); uint8_t MediaCTL(uint8_t lun, uint8_t ctl); uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf); uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, USBReadParser *prs); @@ -532,7 +532,7 @@ public: // UsbConfigXtracter implementation void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - virtual boolean DEVCLASSOK(uint8_t klass) { + virtual bool DEVCLASSOK(uint8_t klass) { return (klass == USB_CLASS_MASS_STORAGE); } @@ -551,7 +551,7 @@ private: uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf); void ClearAllEP(); void CheckMedia(); - boolean CheckLUN(uint8_t lun); + bool CheckLUN(uint8_t lun); uint8_t Page3F(uint8_t lun); bool IsValidCBW(uint8_t size, uint8_t *pcbw); bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw); diff --git a/usbhub.h b/usbhub.h index 931f8d88..e86e89fe 100644 --- a/usbhub.h +++ b/usbhub.h @@ -200,7 +200,7 @@ public: return bAddress; }; - virtual boolean DEVCLASSOK(uint8_t klass) { + virtual bool DEVCLASSOK(uint8_t klass) { return (klass == 0x09); } From 86cb7f38abcffc1e5f1df9495291ecebc87aa206 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sun, 22 Feb 2015 18:27:30 +0100 Subject: [PATCH 35/35] Fixed some formatting --- examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino | 128 ++++++------- .../USBHIDBootKbdAndMouse.ino | 174 +++++++++--------- 2 files changed, 151 insertions(+), 151 deletions(-) diff --git a/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino b/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino index 0c0a0fca..0dea99e9 100644 --- a/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino +++ b/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino @@ -8,91 +8,91 @@ class KbdRptParser : public KeyboardReportParser { - void PrintKey(uint8_t mod, uint8_t key); + void PrintKey(uint8_t mod, uint8_t key); -protected: - void OnControlKeysChanged(uint8_t before, uint8_t after); + protected: + void OnControlKeysChanged(uint8_t before, uint8_t after); - void OnKeyDown (uint8_t mod, uint8_t key); - void OnKeyUp (uint8_t mod, uint8_t key); - void OnKeyPressed(uint8_t key); + void OnKeyDown (uint8_t mod, uint8_t key); + void OnKeyUp (uint8_t mod, uint8_t key); + void OnKeyPressed(uint8_t key); }; void KbdRptParser::PrintKey(uint8_t m, uint8_t key) { - MODIFIERKEYS mod; - *((uint8_t*)&mod) = m; - Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); - Serial.print((mod.bmLeftShift == 1) ? "S" : " "); - Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); - Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); + MODIFIERKEYS mod; + *((uint8_t*)&mod) = m; + Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); + Serial.print((mod.bmLeftShift == 1) ? "S" : " "); + Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); + Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); - Serial.print(" >"); - PrintHex(key, 0x80); - Serial.print("< "); + Serial.print(" >"); + PrintHex(key, 0x80); + Serial.print("< "); - Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); - Serial.print((mod.bmRightShift == 1) ? "S" : " "); - Serial.print((mod.bmRightAlt == 1) ? "A" : " "); - Serial.println((mod.bmRightGUI == 1) ? "G" : " "); + Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); + Serial.print((mod.bmRightShift == 1) ? "S" : " "); + Serial.print((mod.bmRightAlt == 1) ? "A" : " "); + Serial.println((mod.bmRightGUI == 1) ? "G" : " "); }; void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) { - Serial.print("DN "); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); + Serial.print("DN "); + PrintKey(mod, key); + uint8_t c = OemToAscii(mod, key); - if (c) - OnKeyPressed(c); + if (c) + OnKeyPressed(c); } void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { - MODIFIERKEYS beforeMod; - *((uint8_t*)&beforeMod) = before; + MODIFIERKEYS beforeMod; + *((uint8_t*)&beforeMod) = before; - MODIFIERKEYS afterMod; - *((uint8_t*)&afterMod) = after; + MODIFIERKEYS afterMod; + *((uint8_t*)&afterMod) = after; - if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { - Serial.println("LeftCtrl changed"); - } - if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { - Serial.println("LeftShift changed"); - } - if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { - Serial.println("LeftAlt changed"); - } - if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { - Serial.println("LeftGUI changed"); - } + if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { + Serial.println("LeftCtrl changed"); + } + if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { + Serial.println("LeftShift changed"); + } + if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { + Serial.println("LeftAlt changed"); + } + if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { + Serial.println("LeftGUI changed"); + } - if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { - Serial.println("RightCtrl changed"); - } - if (beforeMod.bmRightShift != afterMod.bmRightShift) { - Serial.println("RightShift changed"); - } - if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { - Serial.println("RightAlt changed"); - } - if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { - Serial.println("RightGUI changed"); - } + if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { + Serial.println("RightCtrl changed"); + } + if (beforeMod.bmRightShift != afterMod.bmRightShift) { + Serial.println("RightShift changed"); + } + if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { + Serial.println("RightAlt changed"); + } + if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { + Serial.println("RightGUI changed"); + } } void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) { - Serial.print("UP "); - PrintKey(mod, key); + Serial.print("UP "); + PrintKey(mod, key); } void KbdRptParser::OnKeyPressed(uint8_t key) { - Serial.print("ASCII: "); - Serial.println((char)key); + Serial.print("ASCII: "); + Serial.println((char)key); }; USB Usb; @@ -105,24 +105,24 @@ KbdRptParser Prs; void setup() { - Serial.begin( 115200 ); + Serial.begin( 115200 ); #if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #endif - Serial.println("Start"); + Serial.println("Start"); - if (Usb.Init() == -1) - Serial.println("OSC did not start."); + if (Usb.Init() == -1) + Serial.println("OSC did not start."); - delay( 200 ); + delay( 200 ); - next_time = millis() + 5000; + next_time = millis() + 5000; - HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs); + HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs); } void loop() { - Usb.Task(); + Usb.Task(); } diff --git a/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino b/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino index a664b4b5..848dac85 100644 --- a/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino +++ b/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino @@ -8,139 +8,139 @@ class MouseRptParser : public MouseReportParser { -protected: - void OnMouseMove(MOUSEINFO *mi); - void OnLeftButtonUp(MOUSEINFO *mi); - void OnLeftButtonDown(MOUSEINFO *mi); - void OnRightButtonUp(MOUSEINFO *mi); - void OnRightButtonDown(MOUSEINFO *mi); - void OnMiddleButtonUp(MOUSEINFO *mi); - void OnMiddleButtonDown(MOUSEINFO *mi); + protected: + void OnMouseMove(MOUSEINFO *mi); + void OnLeftButtonUp(MOUSEINFO *mi); + void OnLeftButtonDown(MOUSEINFO *mi); + void OnRightButtonUp(MOUSEINFO *mi); + void OnRightButtonDown(MOUSEINFO *mi); + void OnMiddleButtonUp(MOUSEINFO *mi); + void OnMiddleButtonDown(MOUSEINFO *mi); }; void MouseRptParser::OnMouseMove(MOUSEINFO *mi) { - Serial.print("dx="); - Serial.print(mi->dX, DEC); - Serial.print(" dy="); - Serial.println(mi->dY, DEC); + Serial.print("dx="); + Serial.print(mi->dX, DEC); + Serial.print(" dy="); + Serial.println(mi->dY, DEC); }; void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) { - Serial.println("L Butt Up"); + Serial.println("L Butt Up"); }; void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) { - Serial.println("L Butt Dn"); + Serial.println("L Butt Dn"); }; void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) { - Serial.println("R Butt Up"); + Serial.println("R Butt Up"); }; void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) { - Serial.println("R Butt Dn"); + Serial.println("R Butt Dn"); }; void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) { - Serial.println("M Butt Up"); + Serial.println("M Butt Up"); }; void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) { - Serial.println("M Butt Dn"); + Serial.println("M Butt Dn"); }; class KbdRptParser : public KeyboardReportParser { - void PrintKey(uint8_t mod, uint8_t key); + void PrintKey(uint8_t mod, uint8_t key); -protected: - void OnControlKeysChanged(uint8_t before, uint8_t after); - void OnKeyDown (uint8_t mod, uint8_t key); - void OnKeyUp (uint8_t mod, uint8_t key); - void OnKeyPressed(uint8_t key); + protected: + void OnControlKeysChanged(uint8_t before, uint8_t after); + void OnKeyDown (uint8_t mod, uint8_t key); + void OnKeyUp (uint8_t mod, uint8_t key); + void OnKeyPressed(uint8_t key); }; void KbdRptParser::PrintKey(uint8_t m, uint8_t key) { - MODIFIERKEYS mod; - *((uint8_t*)&mod) = m; - Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); - Serial.print((mod.bmLeftShift == 1) ? "S" : " "); - Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); - Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); + MODIFIERKEYS mod; + *((uint8_t*)&mod) = m; + Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); + Serial.print((mod.bmLeftShift == 1) ? "S" : " "); + Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); + Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); - Serial.print(" >"); - PrintHex(key, 0x80); - Serial.print("< "); + Serial.print(" >"); + PrintHex(key, 0x80); + Serial.print("< "); - Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); - Serial.print((mod.bmRightShift == 1) ? "S" : " "); - Serial.print((mod.bmRightAlt == 1) ? "A" : " "); - Serial.println((mod.bmRightGUI == 1) ? "G" : " "); + Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); + Serial.print((mod.bmRightShift == 1) ? "S" : " "); + Serial.print((mod.bmRightAlt == 1) ? "A" : " "); + Serial.println((mod.bmRightGUI == 1) ? "G" : " "); }; void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) { - Serial.print("DN "); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); + Serial.print("DN "); + PrintKey(mod, key); + uint8_t c = OemToAscii(mod, key); - if (c) - OnKeyPressed(c); + if (c) + OnKeyPressed(c); } void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { - MODIFIERKEYS beforeMod; - *((uint8_t*)&beforeMod) = before; + MODIFIERKEYS beforeMod; + *((uint8_t*)&beforeMod) = before; - MODIFIERKEYS afterMod; - *((uint8_t*)&afterMod) = after; + MODIFIERKEYS afterMod; + *((uint8_t*)&afterMod) = after; - if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { - Serial.println("LeftCtrl changed"); - } - if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { - Serial.println("LeftShift changed"); - } - if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { - Serial.println("LeftAlt changed"); - } - if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { - Serial.println("LeftGUI changed"); - } + if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { + Serial.println("LeftCtrl changed"); + } + if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { + Serial.println("LeftShift changed"); + } + if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { + Serial.println("LeftAlt changed"); + } + if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { + Serial.println("LeftGUI changed"); + } - if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { - Serial.println("RightCtrl changed"); - } - if (beforeMod.bmRightShift != afterMod.bmRightShift) { - Serial.println("RightShift changed"); - } - if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { - Serial.println("RightAlt changed"); - } - if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { - Serial.println("RightGUI changed"); - } + if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { + Serial.println("RightCtrl changed"); + } + if (beforeMod.bmRightShift != afterMod.bmRightShift) { + Serial.println("RightShift changed"); + } + if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { + Serial.println("RightAlt changed"); + } + if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { + Serial.println("RightGUI changed"); + } } void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) { - Serial.print("UP "); - PrintKey(mod, key); + Serial.print("UP "); + PrintKey(mod, key); } void KbdRptParser::OnKeyPressed(uint8_t key) { - Serial.print("ASCII: "); - Serial.println((char)key); + Serial.print("ASCII: "); + Serial.println((char)key); }; USB Usb; USBHub Hub(&Usb); -HIDBoot HidComposite(&Usb); +HIDBoot < HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE > HidComposite(&Usb); HIDBoot HidKeyboard(&Usb); HIDBoot HidMouse(&Usb); @@ -151,27 +151,27 @@ MouseRptParser MousePrs; void setup() { - Serial.begin( 115200 ); + Serial.begin( 115200 ); #if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection + while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #endif - Serial.println("Start"); + Serial.println("Start"); - if (Usb.Init() == -1) - Serial.println("OSC did not start."); + if (Usb.Init() == -1) + Serial.println("OSC did not start."); - delay( 200 ); + delay( 200 ); - //next_time = millis() + 5000; + //next_time = millis() + 5000; - HidComposite.SetReportParser(0, (HIDReportParser*)&KbdPrs); - HidComposite.SetReportParser(1,(HIDReportParser*)&MousePrs); - HidKeyboard.SetReportParser(0, (HIDReportParser*)&KbdPrs); - HidMouse.SetReportParser(0,(HIDReportParser*)&MousePrs); + HidComposite.SetReportParser(0, (HIDReportParser*)&KbdPrs); + HidComposite.SetReportParser(1, (HIDReportParser*)&MousePrs); + HidKeyboard.SetReportParser(0, (HIDReportParser*)&KbdPrs); + HidMouse.SetReportParser(0, (HIDReportParser*)&MousePrs); } void loop() { - Usb.Task(); + Usb.Task(); }