summaryrefslogtreecommitdiff
path: root/ports/stm32/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/stm32/main.c')
-rw-r--r--ports/stm32/main.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 9ac2b4490..2d97adb1d 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -88,6 +88,11 @@
#include "pyb_can.h"
#include "subghz.h"
+#if MICROPY_HW_TINYUSB_STACK
+#include "usbd_conf.h"
+#include "shared/tinyusb/mp_usbd.h"
+#endif
+
#if MICROPY_PY_THREAD
static pyb_thread_t pyb_thread_main;
#endif
@@ -275,14 +280,12 @@ static bool init_sdcard_fs(void) {
}
}
- #if MICROPY_HW_ENABLE_USB
+ #if MICROPY_HW_USB_MSC
if (pyb_usb_storage_medium == PYB_USB_STORAGE_MEDIUM_NONE) {
// if no USB MSC medium is selected then use the SD card
pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_SDCARD;
}
- #endif
- #if MICROPY_HW_ENABLE_USB
// only use SD card as current directory if that's what the USB medium is
if (pyb_usb_storage_medium == PYB_USB_STORAGE_MEDIUM_SDCARD)
#endif
@@ -502,7 +505,7 @@ void stm32_main(uint32_t reset_mode) {
pyb_uart_repl_obj.is_static = true;
pyb_uart_repl_obj.timeout = 0;
pyb_uart_repl_obj.timeout_char = 2;
- uart_init(&pyb_uart_repl_obj, MICROPY_HW_UART_REPL_BAUD, UART_WORDLENGTH_8B, UART_PARITY_NONE, UART_STOPBITS_1, 0);
+ uart_init(&pyb_uart_repl_obj, MICROPY_HW_UART_REPL_BAUD, UART_WORDLENGTH_8B, UART_PARITY_NONE, UART_STOPBITS_1, 0, 0);
uart_set_rxbuf(&pyb_uart_repl_obj, sizeof(pyb_uart_repl_rxbuf), pyb_uart_repl_rxbuf);
uart_attach_to_repl(&pyb_uart_repl_obj, true);
MP_STATE_PORT(machine_uart_obj_all)[MICROPY_HW_UART_REPL - 1] = &pyb_uart_repl_obj;
@@ -606,8 +609,13 @@ soft_reset:
#endif
#if MICROPY_HW_ENABLE_USB
+ #if MICROPY_HW_TINYUSB_STACK
+ pyb_usbd_init();
+ mp_usbd_init();
+ #else
pyb_usb_init0();
#endif
+ #endif
#if MICROPY_PY_MACHINE_I2S
machine_i2s_init0();
@@ -631,7 +639,7 @@ soft_reset:
}
#endif
- #if MICROPY_HW_ENABLE_USB
+ #if MICROPY_HW_USB_MSC
// if the SD card isn't used as the USB MSC medium then use the internal flash
if (pyb_usb_storage_medium == PYB_USB_STORAGE_MEDIUM_NONE) {
pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_FLASH;
@@ -665,7 +673,7 @@ soft_reset:
// or whose initialisation can be safely deferred until after running
// boot.py.
- #if MICROPY_HW_ENABLE_USB
+ #if MICROPY_HW_STM_USB_STACK
// init USB device to default setting if it was not already configured
if (!(pyb_usb_flags & PYB_USB_FLAG_USB_MODE_CALLED)) {
#if MICROPY_HW_USB_MSC
@@ -770,6 +778,9 @@ soft_reset_exit:
#else
MP_STATE_PORT(pyb_stdio_uart) = NULL;
#endif
+ #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE && MICROPY_HW_TINYUSB_STACK
+ mp_usbd_deinit();
+ #endif
MICROPY_BOARD_END_SOFT_RESET(&state);