USB device stack for NUCLEO-F042K6, NUCLEO-L152RE and NUCLEO-F103RB.

Dependents:   LPE-SEM01

Fork of L152RE_USBDevice by Norimasa Okamoto

I tried USB device using HAL_PCD.

/media/uploads/va009039/f042k6_usbdevice_vin.jpg

Nucleo-F042K6USB
PA11 (CN3-13)DM  (2 WHITE)
PA12 (CN3-5)DP  (3 GREEN)
GND (CN3-4)GND (5 BLACK)
VIN (CN4-1)VBUS(1 RED)

Examples

Import programF042K6_USBDevice_example

NUCLEO-F042K6 USBDevice example code

Import programL152RE_USBDevice_example

L152RE_USBDevice example code

Import programF042K6_Simple-CMSIS-DAP

cmsis-dap debug adapter

Import programL152RE_Simple-CMSIS-DAP

cmsis-dap debug adapter

Revision:
25:7c72828865f3
Parent:
12:6030a12b6c62
Child:
41:0ca6eeb54b97
--- a/USBDevice/USBHAL_LPC40.cpp	Fri May 16 09:00:39 2014 +0100
+++ b/USBDevice/USBHAL_LPC40.cpp	Tue Jun 03 11:30:32 2014 +0100
@@ -280,7 +280,7 @@
         SIEselectEndpoint(endpoint);
         SIEclearBuffer();
     }
-    
+
     return size;
 }
 
@@ -328,7 +328,7 @@
 USBHAL::USBHAL(void) {
     // Disable IRQ
     NVIC_DisableIRQ(USB_IRQn);
-    
+
     // fill in callback array
     epCallback[0] = &USBHAL::EP1_OUT_callback;
     epCallback[1] = &USBHAL::EP1_IN_callback;
@@ -367,7 +367,7 @@
     // Enable USB clocks
     LPC_USB->USBClkCtrl |= DEV_CLK_EN | AHB_CLK_EN | PORT_CLK_EN;
     while ((LPC_USB->USBClkSt & (DEV_CLK_EN | AHB_CLK_EN | PORT_CLK_EN)) != (DEV_CLK_ON | AHB_CLK_ON | PORT_CLK_EN));
-    
+
     // Select port USB2
     LPC_USB->StCtrl |= 3;
 
@@ -375,13 +375,13 @@
     // Configure pin P0.31 to be USB2
     LPC_IOCON->P0_31 &= ~0x07;
     LPC_IOCON->P0_31 |= 0x01;
-    
+
     // Disconnect USB device
     SIEdisconnect();
 
     // Configure pin P0.14 to be Connect
     LPC_IOCON->P0_14 &= ~0x07;
-    LPC_IOCON->P0_14 |= 0x03;    
+    LPC_IOCON->P0_14 |= 0x03;
 
     // Connect must be low for at least 2.5uS
     wait(0.3);
@@ -471,7 +471,7 @@
         if (!(epComplete & EP(endpoint)))
             return EP_PENDING;
     }
-    
+
     *bytesRead = endpointReadcore(endpoint, buffer);
     epComplete &= ~EP(endpoint);
     return EP_COMPLETED;
@@ -611,7 +611,7 @@
             LPC_USB->DevIntClr = EP_SLOW;
             EP0in();
         }
-        
+
         for (uint8_t num = 2; num < 16*2; num++) {
             if (LPC_USB->EpIntSt & EP(num)) {
                 selectEndpointClearInterrupt(num);