diff options
author | Cristian Maglie <c.maglie@bug.st> | 2012-05-23 09:22:52 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2012-05-23 09:22:52 +0200 |
commit | a3dbb49c078176fca1610f4a61b0d1b23e3f37c9 (patch) | |
tree | 97c6f70b3f54da526db9acf93ed0b4ef24248b4e /cores/arduino/USBCore.cpp | |
parent | 3786e337e0211ca1ef94b37b03e891adfb3b5f9a (diff) | |
parent | 810803c6d3ab33a4496a89f41ef7e1dda15e8680 (diff) |
Merge of arduino-1.0.1. Work in progress...
Diffstat (limited to 'cores/arduino/USBCore.cpp')
-rw-r--r-- | cores/arduino/USBCore.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 4c71b34..6766be6 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -51,16 +51,20 @@ const u16 STRING_LANGUAGE[2] = { const u16 STRING_IPRODUCT[17] = { (3<<8) | (2+2*16), -#if USB_PID == USB_PID_LEONARDO +#if USB_PID == 0x8036 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o' -#elif USB_PID == USB_PID_MICRO - 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' ' +#else + 'U','S','B',' ','I','O',' ','B','o','a','r','d',' ',' ',' ',' ' #endif }; const u16 STRING_IMANUFACTURER[12] = { (3<<8) | (2+2*11), +#if USB_VID == 0x2341 'A','r','d','u','i','n','o',' ','L','L','C' +#else + 'U','n','k','n','o','w','n',' ',' ',' ',' ' +#endif }; #ifdef CDC_ENABLED @@ -230,7 +234,7 @@ int USB_Recv(u8 ep, void* d, int len) n = len; u8* dst = (u8*)d; while (n--) - *dst++ = USBD_Recv8(); + *dst++ = Recv8(); if (len && !FifoByteCount()) // release empty buffer ReleaseRX(); @@ -599,6 +603,8 @@ ISR(USB_GEN_vect) { #ifdef CDC_ENABLED USB_Flush(CDC_TX); // Send a tx frame if found + while (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 @@ -621,13 +627,13 @@ u8 USBConnected() //======================================================================= //======================================================================= -USB_ USB; +USBDevice_ USBDevice; -USB_::USB_() +USBDevice_::USBDevice_() { } -void USB_::attach() +void USBDevice_::attach() { _usbConfiguration = 0; UHWCON = 0x01; // power internal reg @@ -635,6 +641,12 @@ void USB_::attach() PLLCSR = 0x12; // Need 16 MHz xtal while (!(PLLCSR & (1<<PLOCK))) // wait for lock pll ; + + // Some tests on specific versions of macosx (10.7.3), reported some + // strange behaviuors when the board is reset using the serial + // port touch at 1200 bps. This delay fixes this behaviour. + delay(1); + USBCON = ((1<<USBE)|(1<<OTGPADE)); // start USB clock UDIEN = (1<<EORSTE)|(1<<SOFE); // Enable interrupts for EOR (End of Reset) and SOF (start of frame) UDCON = 0; // enable attach resistor @@ -642,19 +654,19 @@ void USB_::attach() TX_RX_LED_INIT; } -void USB_::detach() +void USBDevice_::detach() { } // Check for interrupts // TODO: VBUS detection -bool USB_::configured() +bool USBDevice_::configured() { return _usbConfiguration; } -void USB_::poll() +void USBDevice_::poll() { } -#endif /* if defined(USBCON) */
\ No newline at end of file +#endif /* if defined(USBCON) */ |