Skip to content

Commit

Permalink
hosted/platform: Ensure we maintain the reset condition for detach fo…
Browse files Browse the repository at this point in the history
…r at least 10ms
  • Loading branch information
dragonmux committed Mar 8, 2024
1 parent 7ff9eca commit a6c4fca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/platforms/native/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <libopencm3/stm32/spi.h>
#include <libopencm3/stm32/flash.h>
#include <libopencm3/stm32/timer.h>
#include <libopencm3/cm3/systick.h>

static void adc_init(void);
static void setup_vbus_irq(void);
Expand Down Expand Up @@ -415,6 +416,13 @@ void platform_request_boot(void)
gpio_set_mode(USB_PU_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, USB_PU_PIN);
gpio_set_mode(USB_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, USB_DP_PIN | USB_DM_PIN);
gpio_clear(USB_PORT, USB_DP_PIN | USB_DM_PIN);
/* Make sure we drive the USB reset condition for at least 10ms */
while (!(STK_CSR & STK_CSR_COUNTFLAG))
continue;
for (size_t count = 0U; count < 10U * SYSTICKMS; ++count) {
while (!(STK_CSR & STK_CSR_COUNTFLAG))
continue;
}

/* Drive boot request pin */
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
Expand Down

0 comments on commit a6c4fca

Please sign in to comment.