Skip to content

Commit

Permalink
ARMmbed#64 Assume "PC connected" at the start of USB communication in…
Browse files Browse the repository at this point in the history
…stead of waiting for the whole enumeration process to be finished.
  • Loading branch information
gerargz authored and gaborcsapo committed Jun 29, 2022
1 parent f398799 commit 8757c99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions source/board/microbitv2/microbitv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,6 @@ void board_30ms_hook()
static uint8_t blink_in_progress = 0;

if (usb_state == USB_CONNECTED) {
/* Set usb_pc_connected to true to prevent entering sleep mode when host does re-enumeration.
* Will be set to false when the USB cable is detached. */
usb_pc_connected = true;
// configure pin as GPIO
PIN_HID_LED_PORT->PCR[PIN_HID_LED_BIT] = PORT_PCR_MUX(1);
power_led_max_duty_cycle = PWR_LED_ON_MAX_BRIGHTNESS;
Expand Down Expand Up @@ -508,6 +505,13 @@ void board_handle_powerdown()
}
}

void board_usb_sof_event(void)
{
/* Set usb_pc_connected to true to prevent entering sleep mode when host does re-enumeration.
* Will be set to false when the USB cable is detached. */
usb_pc_connected = true;
}

void vfs_user_build_filesystem_hook() {
uint32_t file_size;
error_t status;
Expand Down
5 changes: 4 additions & 1 deletion source/usb/usb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,9 @@ __WEAK void USBD_Reset_Event(void)
#endif
#endif /* ((USBD_CDC_ACM_ENABLE) || (USBD_CDCB_ACM_ENABLE)) */

#if ((USBD_HID_ENABLE) || (USBD_ADC_ENABLE) || (USBD_CDC_ACM_ENABLE) || (USBD_CDCB_ACM_ENABLE) || (USBD_CLS_ENABLE))
__WEAK void board_usb_sof_event(void) {}

#if ((USBD_HID_ENABLE) || (USBD_ADC_ENABLE) || (USBD_CDC_ACM_ENABLE) || (USBD_CLS_ENABLE))
#ifndef __RTX
__WEAK void USBD_SOF_Event(void)
{
Expand All @@ -1388,6 +1390,7 @@ __WEAK void USBD_SOF_Event(void)
#if (USBD_CLS_ENABLE)
USBD_CLS_SOF_Event();
#endif
board_usb_sof_event();
}
#endif
#endif /* ((USBD_HID_ENABLE) || (USBD_ADC_ENABLE) || (USBD_CDC_ACM_ENABLE) || (USBD_CDCB_ACM_ENABLE) || (USBD_CLS_ENABLE)) */
Expand Down

0 comments on commit 8757c99

Please sign in to comment.