USB device stack (USBDevice::connect non-blocking)

Fork of USBDevice by mbed official

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Sun Oct 14 12:38:56 2012 +0000
Parent:
2:34856a6adb5b
Child:
4:eaa07ce86d49
Commit message:
move EnableIRQ to connect() - add MEDIA_REMOVAL handling

Changed in this revision

USBDevice/USBHAL_LPC11U.cpp Show annotated file Show diff for this revision Revisions of this file
USBDevice/USBHAL_LPC17.cpp Show annotated file Show diff for this revision Revisions of this file
USBMSD/USBMSD.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/USBDevice/USBHAL_LPC11U.cpp	Tue Jul 17 14:35:40 2012 +0000
+++ b/USBDevice/USBHAL_LPC11U.cpp	Sun Oct 14 12:38:56 2012 +0000
@@ -176,7 +176,6 @@
 
     //attach IRQ handler and enable interrupts
     NVIC_SetVector(USB_IRQn, (uint32_t)&_usbisr);
-    NVIC_EnableIRQ(USB_IRQn);
 }
 
 USBHAL::~USBHAL(void) {
@@ -188,11 +187,13 @@
 }
 
 void USBHAL::connect(void) {
+    NVIC_EnableIRQ(USB_IRQn);
     devCmdStat |= DCON;
     LPC_USB->DEVCMDSTAT = devCmdStat;
 }
 
 void USBHAL::disconnect(void) {
+    NVIC_DisableIRQ(USB_IRQn);
     devCmdStat &= ~DCON;
     LPC_USB->DEVCMDSTAT = devCmdStat;
 }
--- a/USBDevice/USBHAL_LPC17.cpp	Tue Jul 17 14:35:40 2012 +0000
+++ b/USBDevice/USBHAL_LPC17.cpp	Sun Oct 14 12:38:56 2012 +0000
@@ -371,7 +371,6 @@
     // Attach IRQ
     instance = this;
     NVIC_SetVector(USB_IRQn, (uint32_t)&_usbisr);
-    NVIC_EnableIRQ(USB_IRQn);
 
     // Enable interrupts for device events and EP0
     LPC_USB->USBDevIntEn = EP_SLOW | DEV_STAT | FRAME;
@@ -388,11 +387,13 @@
 }
 
 void USBHAL::connect(void) {
+    NVIC_EnableIRQ(USB_IRQn);
     // Connect USB device
     SIEconnect();
 }
 
 void USBHAL::disconnect(void) {
+    NVIC_DisableIRQ(USB_IRQn);
     // Disconnect USB device
     SIEdisconnect();
 }
--- a/USBMSD/USBMSD.cpp	Tue Jul 17 14:35:40 2012 +0000
+++ b/USBMSD/USBMSD.cpp	Sun Oct 14 12:38:56 2012 +0000
@@ -452,6 +452,10 @@
                             }
                         }
                         break;
+                    case MEDIA_REMOVAL:
+                        csw.Status = CSW_PASSED;
+                        sendCSW();
+                        break;
                     default:
                         fail();
                         break;