diff options
author | Martino Facchin <m.facchin@arduino.cc> | 2015-08-13 09:39:21 +0200 |
---|---|---|
committer | Martino Facchin <m.facchin@arduino.cc> | 2015-08-13 09:39:21 +0200 |
commit | b3197c6ef83253d712f4b7b30a0763f18f6d3ddc (patch) | |
tree | c1c11380a35613e3ab8e9264bfb84251a91d5db8 /cores/arduino/CDC.cpp | |
parent | 98f7ab15884119b1c9f1f58f96a8302200c1e2a3 (diff) | |
parent | 98301ba23a1f7c60b4590330da2ee1c260da7aa6 (diff) |
Merge pull request #3640 from NicoHood/USB-Core-Fixes
Usb core fixes
Diffstat (limited to 'cores/arduino/CDC.cpp')
-rw-r--r-- | cores/arduino/CDC.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index d694a2d..7c7eacf 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -49,8 +49,8 @@ const CDCDescriptor _cdcInterface = // CDC data interface D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0), - D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0), - D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0) + D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0), + D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0) }; int CDC_GetInterface(u8* interfaceNum) @@ -92,11 +92,24 @@ bool CDC_Setup(USBSetup& setup) // with a relatively long period so it can finish housekeeping tasks // like servicing endpoints before the sketch ends +#ifndef MAGIC_KEY +#define MAGIC_KEY 0x7777 +#endif +#ifndef MAGIC_KEY_POS +#define MAGIC_KEY_POS 0x0800 +#endif + // We check DTR state to determine if host port is open (bit 0 of lineState). if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0) { - *(uint16_t *)(RAMEND-1) = *(uint16_t *)0x0800; - *(uint16_t *)0x0800 = 0x7777; +#if MAGIC_KEY_POS != (RAMEND-1) + *(uint16_t *)(RAMEND-1) = *(uint16_t *)MAGIC_KEY_POS; + *(uint16_t *)MAGIC_KEY_POS = MAGIC_KEY; +#else + // for future boards save the key in the inproblematic RAMEND + // which is reserved for the main() return value (which will never return) + *(uint16_t *)MAGIC_KEY_POS = MAGIC_KEY; +#endif wdt_enable(WDTO_120MS); } else @@ -108,7 +121,11 @@ bool CDC_Setup(USBSetup& setup) wdt_disable(); wdt_reset(); - *(uint16_t *)0x0800 = *(uint16_t *)(RAMEND-1); +#if MAGIC_KEY_POS != (RAMEND-1) + *(uint16_t *)MAGIC_KEY_POS = *(uint16_t *)(RAMEND-1); +#else + *(uint16_t *)MAGIC_KEY_POS = 0x0000; +#endif } } return true; |