USBDevice with support for STM32F3

Fork of F042K6_USBDevice by Norimasa Okamoto

Revision:
71:b17ecdbfb0ce
Parent:
69:f8305faf7917
Child:
75:a394ea726048
--- a/USBDevice/USBHAL_STM32L1.cpp	Tue Dec 13 13:32:10 2016 +0000
+++ b/USBDevice/USBHAL_STM32L1.cpp	Wed Dec 21 11:27:46 2016 +0000
@@ -48,7 +48,8 @@
 }
 
 #elif defined(TARGET_STM32F3)
-#define USB_LP_IRQn USB_LP_CAN_RX0_IRQn
+// use remapped USB interrupts, so that CAN peripheral can also be used if needed
+//#define USB_LP_IRQn USB_LP_CAN_RX0_IRQn
 #endif
 
 static PCD_HandleTypeDef hpcd_USB_FS;
@@ -72,6 +73,10 @@
     hpcd_USB_FS.Init.Sof_enable = DISABLE;
     hpcd_USB_FS.Init.low_power_enable = DISABLE;
     hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
+#if defined(TARGET_STM32F3)
+    __HAL_RCC_SYSCFG_CLK_ENABLE();
+    __HAL_REMAPINTERRUPT_USB_ENABLE();
+#endif
     NVIC_SetVector(USB_LP_IRQn, (uint32_t)&_usbisr);
     HAL_PCD_Init(&hpcd_USB_FS);
     HAL_PCD_Start(&hpcd_USB_FS);