You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2022/03/07 18:41:21 UTC

[mynewt-core] 01/02: tinyusb: Fix USB D+ external pull-up for bootloader

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 76765e78de75bd045b226d68d1caa5d3cb2bb86d
Author: Jerzy Kasenberg <je...@apache.org>
AuthorDate: Sat Mar 5 11:56:57 2022 +0100

    tinyusb: Fix USB D+ external pull-up for bootloader
    
    stm32_fsdev for STM32F1 requires external pull-up on D+.
    Later other ST products with same USB IP core may not need it
    but it happens that boards do have those solder in.
    
    for synopsys external pull-up is not needed but some boards do
    have them for no real reason.
    
    Mynewt code can handle those external pull-ups if reset
    is performed to notify host about reset.
    
    While code was OK for application running in OS os_time_delay()
    used for keeping D+ line down is not working in bootloader.
    Now for bootloader os_cput_time_delay is used.
---
 hw/usb/tinyusb/stm32_fsdev/src/stm32_fsdev.c | 4 ++++
 hw/usb/tinyusb/synopsys/src/synopsys.c       | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/hw/usb/tinyusb/stm32_fsdev/src/stm32_fsdev.c b/hw/usb/tinyusb/stm32_fsdev/src/stm32_fsdev.c
index a0f82af..593ee75 100755
--- a/hw/usb/tinyusb/stm32_fsdev/src/stm32_fsdev.c
+++ b/hw/usb/tinyusb/stm32_fsdev/src/stm32_fsdev.c
@@ -55,8 +55,12 @@ tinyusb_hardware_init(void)
      */
 #if MYNEWT_VAL(USB_DP_HAS_EXTERNAL_PULL_UP)
     hal_gpio_init_out(MCU_GPIO_PORTA(12), 0);
+#if MYNEWT_VAL(BOOT_LOADER)
+    os_cputime_delay_usecs(1000);
+#else
     os_time_delay(1);
 #endif
+#endif
     hal_gpio_init_af(MCU_GPIO_PORTA(12), 0, GPIO_NOPULL, GPIO_MODE_AF_PP);
 
     /*
diff --git a/hw/usb/tinyusb/synopsys/src/synopsys.c b/hw/usb/tinyusb/synopsys/src/synopsys.c
index 6bcaf1e..69ce4ee 100755
--- a/hw/usb/tinyusb/synopsys/src/synopsys.c
+++ b/hw/usb/tinyusb/synopsys/src/synopsys.c
@@ -44,8 +44,12 @@ tinyusb_hardware_init(void)
     hal_gpio_init_af(MCU_GPIO_PORTA(11), GPIO_AF10_OTG_FS, GPIO_NOPULL, GPIO_MODE_AF_PP);
 #if MYNEWT_VAL(USB_DP_HAS_EXTERNAL_PULL_UP)
     hal_gpio_init_out(MCU_GPIO_PORTA(12), 0);
+#if MYNEWT_VAL(BOOT_LOADER)
+    os_cputime_delay_usecs(1000);
+#else
     os_time_delay(1);
 #endif
+#endif
     hal_gpio_init_af(MCU_GPIO_PORTA(12), GPIO_AF10_OTG_FS, GPIO_NOPULL, GPIO_MODE_AF_PP);
 
     /*