diff options
Diffstat (limited to 'cores/arduino/USBCore.cpp')
-rw-r--r-- | cores/arduino/USBCore.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index c46c75f..b4f7bed 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -16,9 +16,7 @@ ** SOFTWARE. */ -#include "Platform.h" #include "USBAPI.h" -#include "USBDesc.h" #if defined(USBCON) @@ -57,12 +55,18 @@ const u16 STRING_LANGUAGE[2] = { const u8 STRING_PRODUCT[] PROGMEM = USB_PRODUCT; #if USB_VID == 0x2341 -#define USB_MANUFACTURER "Arduino LLC" +# if defined(USB_MANUFACTURER) +# undef USB_MANUFACTURER +# endif +# define USB_MANUFACTURER "Arduino LLC" #elif USB_VID == 0x1b4f -#define USB_MANUFACTURER "SparkFun" +# if defined(USB_MANUFACTURER) +# undef USB_MANUFACTURER +# endif +# define USB_MANUFACTURER "SparkFun" #elif !defined(USB_MANUFACTURER) // Fall through to unknown if no manufacturer name was provided in a macro -#define USB_MANUFACTURER "Unknown" +# define USB_MANUFACTURER "Unknown" #endif const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER; @@ -88,7 +92,8 @@ volatile u8 _usbConfiguration = 0; static inline void WaitIN(void) { - while (!(UEINTX & (1<<TXINI))); + while (!(UEINTX & (1<<TXINI))) + ; } static inline void ClearIN(void) @@ -268,7 +273,6 @@ int USB_Send(u8 ep, const void* d, int len) int r = len; const u8* data = (const u8*)d; - u8 zero = ep & TRANSFER_ZERO; u8 timeout = 250; // 250ms timeout on send? TODO while (len) { @@ -283,9 +287,12 @@ int USB_Send(u8 ep, const void* d, int len) if (n > len) n = len; - len -= n; { LockEP lock(ep); + // Frame may have been released by the SOF interrupt handler + if (!ReadWriteAllowed()) + continue; + len -= n; if (ep & TRANSFER_ZERO) { while (n--) @@ -621,8 +628,6 @@ ISR(USB_GEN_vect) { #ifdef CDC_ENABLED USB_Flush(CDC_TX); // Send a tx frame if found - if (USB_Available(CDC_RX)) // Handle received bytes (if any) - Serial.accept(); #endif // check whether the one-shot period has elapsed. if so, turn off the LED |