| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,46 @@ |
| 1 |
+/* |
|
| 2 |
+ * Author: Pawel Jablonski |
|
| 3 |
+ * E-mail: pj@xirx.net |
|
| 4 |
+ * WWW: xirx.net |
|
| 5 |
+ * GIT: git.xirx.net |
|
| 6 |
+ * |
|
| 7 |
+ * License: You can use this code however you like |
|
| 8 |
+ * but leave information about the original author. |
|
| 9 |
+ * Code is free for non-commercial and commercial use. |
|
| 10 |
+ */ |
|
| 11 |
+ |
|
| 12 |
+#include <stm32f0xx.h> |
|
| 13 |
+#include <stm32f0xx_hal.h> |
|
| 14 |
+#include <stm32f0xx_hal_gpio.h> |
|
| 15 |
+#include <stm32f0xx_hal_pcd.h> |
|
| 16 |
+#include <system_stm32f0xx.h> |
|
| 17 |
+ |
|
| 18 |
+#include "usbd/usbd_desc.h" |
|
| 19 |
+#include "usbd/usbd_msc.h" |
|
| 20 |
+#include "usbd/usbd_storage_if.h" |
|
| 21 |
+ |
|
| 22 |
+#include "usb.h" |
|
| 23 |
+ |
|
| 24 |
+extern USBD_StorageTypeDef USBD_MSC_Fops; //!< USB MSC function handlers |
|
| 25 |
+extern PCD_HandleTypeDef USBD_PCD_Handle; //!< USB PCD function handlers |
|
| 26 |
+ |
|
| 27 |
+static USBD_HandleTypeDef usbHandle; //!< USB handle |
|
| 28 |
+ |
|
| 29 |
+//! Init USB and set up USB MSC |
|
| 30 |
+void usbInit(void) |
|
| 31 |
+{
|
|
| 32 |
+ __HAL_RCC_GPIOA_CLK_ENABLE(); |
|
| 33 |
+ |
|
| 34 |
+ USBD_Init(&usbHandle, &USBD_MSC_Desc, 0); |
|
| 35 |
+ |
|
| 36 |
+ USBD_RegisterClass(&usbHandle, &USBD_MSC); |
|
| 37 |
+ USBD_MSC_RegisterStorage(&usbHandle, &USBD_MSC_Fops); |
|
| 38 |
+ |
|
| 39 |
+ USBD_Start(&usbHandle); |
|
| 40 |
+} |
|
| 41 |
+ |
|
| 42 |
+//! Take care of the USB IRQ event |
|
| 43 |
+void USB_IRQHandler(void) |
|
| 44 |
+{
|
|
| 45 |
+ HAL_PCD_IRQHandler(&USBD_PCD_Handle); |
|
| 46 |
+} |