summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/usb.c')
-rw-r--r--stmhal/usb.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/stmhal/usb.c b/stmhal/usb.c
index c14a5ad688..aa006b8b8f 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -2,9 +2,8 @@
#include "usbd_core.h"
#include "usbd_desc.h"
-#include "usbd_cdc.h"
+#include "usbd_cdc_msc.h"
#include "usbd_cdc_interface.h"
-#include "usbd_msc.h"
#include "usbd_msc_storage.h"
#include "misc.h"
@@ -18,7 +17,6 @@ USBD_HandleTypeDef hUSBDDevice;
#endif
static int dev_is_enabled = 0;
-uint32_t APP_dev_is_connected = 0; /* used by usbd_cdc_vcp */
mp_obj_t mp_const_vcp_interrupt = MP_OBJ_NULL;
void pyb_usb_dev_init(usbd_device_kind_t device_kind, usbd_storage_medium_kind_t medium_kind) {
@@ -26,21 +24,10 @@ void pyb_usb_dev_init(usbd_device_kind_t device_kind, usbd_storage_medium_kind_t
if (!dev_is_enabled) {
// only init USB once in the device's power-lifetime
switch (device_kind) {
- case USBD_DEVICE_CDC:
- // XXX USBD_CDC_Init (called by one of these functions below) uses malloc,
- // so the memory is invalid after a soft reset (which resets the GC).
+ case USBD_DEVICE_CDC_MSC:
USBD_Init(&hUSBDDevice, &VCP_Desc, 0);
- USBD_RegisterClass(&hUSBDDevice, &USBD_CDC);
+ USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC);
USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops);
- USBD_Start(&hUSBDDevice);
- //USBD_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_PYB_cb, &USR_cb);
- break;
-
- case USBD_DEVICE_MSC:
- // XXX USBD_CDC_Init (called by one of these functions below) uses malloc,
- // so the memory is invalid after a soft reset (which resets the GC).
- USBD_Init(&hUSBDDevice, &MSC_Desc, 0);
- USBD_RegisterClass(&hUSBDDevice, &USBD_MSC);
if (medium_kind == USBD_STORAGE_MEDIUM_FLASH) {
USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
} else {
@@ -67,7 +54,7 @@ bool usb_vcp_is_enabled(void) {
}
bool usb_vcp_is_connected(void) {
- return APP_dev_is_connected;
+ return USBD_CDC_IsConnected();
}
void usb_vcp_set_interrupt_char(int c) {