aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/USBCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino/USBCore.cpp')
-rw-r--r--cores/arduino/USBCore.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp
index c46c75f..39a9530 100644
--- a/cores/arduino/USBCore.cpp
+++ b/cores/arduino/USBCore.cpp
@@ -57,12 +57,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 +94,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 +275,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 +289,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 +630,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