Skip to content

Commit 52a6912

Browse files
committed
stm32/usb: Add support for using TinyUSB stack by default.
Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent 7f3f7e0 commit 52a6912

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

ports/stm32/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ SRC_C += \
258258
usbd.c \
259259
usbd_conf.c \
260260
usb.c \
261+
usbd_desc.c \
262+
usbd_cdc_interface.c \
263+
usbd_hid_interface.c \
264+
usbd_msc_interface.c \
261265
mphalport.c \
262266
mpnetworkport.c \
263267
mpthreadport.c \
@@ -432,6 +436,15 @@ HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_,\
432436
)
433437
endif
434438

439+
USBDEV_SRC_C += $(addprefix $(USBDEV_DIR)/,\
440+
core/src/usbd_core.c \
441+
core/src/usbd_ctlreq.c \
442+
core/src/usbd_ioreq.c \
443+
class/src/usbd_cdc_msc_hid.c \
444+
class/src/usbd_msc_bot.c \
445+
class/src/usbd_msc_scsi.c \
446+
)
447+
435448
ifeq ($(MICROPY_SSL_MBEDTLS),1)
436449
LIB_SRC_C += mbedtls/mbedtls_port.c
437450
endif

ports/stm32/mpconfigboard_common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
#define MICROPY_HW_USB_FS (1)
112112

113113
#ifndef MICROPY_HW_TINYUSB_STACK
114-
#define MICROPY_HW_TINYUSB_STACK (MICROPY_HW_ENABLE_USB)
114+
#define MICROPY_HW_TINYUSB_STACK (0)
115115
#endif
116116

117117
// Whether to enable the PA0-PA3 servo driver, exposed as pyb.Servo
@@ -677,10 +677,10 @@
677677
#define MICROPY_HW_USB_CDC_NUM (1)
678678
#endif
679679
#ifndef MICROPY_HW_USB_MSC
680-
#define MICROPY_HW_USB_MSC (0)
680+
#define MICROPY_HW_USB_MSC (MICROPY_HW_ENABLE_USB && !MICROPY_HW_TINYUSB_STACK)
681681
#endif
682682
#ifndef MICROPY_HW_USB_HID
683-
#define MICROPY_HW_USB_HID (0)
683+
#define MICROPY_HW_USB_HID (MICROPY_HW_ENABLE_USB && !MICROPY_HW_TINYUSB_STACK)
684684
#endif
685685

686686
// Pin definition header file

ports/stm32/usb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#ifndef MICROPY_INCLUDED_STM32_USB_H
2727
#define MICROPY_INCLUDED_STM32_USB_H
2828

29-
// #include "usbd_cdc_msc_hid0.h"
29+
#include "usbd_cdc_msc_hid0.h"
3030

3131
#define PYB_USB_FLAG_USB_MODE_CALLED (0x0002)
3232

@@ -56,7 +56,7 @@ MP_DECLARE_CONST_FUN_OBJ_1(pyb_hid_send_report_obj); // deprecated
5656

5757
void pyb_usb_init0(void);
5858
int pyb_usb_dev_detect(void);
59-
// bool pyb_usb_dev_init(int dev_id, uint16_t vid, uint16_t pid, uint8_t mode, size_t msc_n, const void *msc_unit, USBD_HID_ModeInfoTypeDef *hid_info);
59+
bool pyb_usb_dev_init(int dev_id, uint16_t vid, uint16_t pid, uint8_t mode, size_t msc_n, const void *msc_unit, USBD_HID_ModeInfoTypeDef *hid_info);
6060
void pyb_usb_dev_deinit(void);
6161
bool usb_vcp_is_enabled(void);
6262
int usb_vcp_recv_byte(uint8_t *c); // if a byte is available, return 1 and put the byte in *c, else return 0

0 commit comments

Comments
 (0)