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 committed Oct 8, 2020
1 parent b1d3f2b commit 38fe9bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 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
3 changes: 3 additions & 0 deletions source/usb/usb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,8 @@ void USBD_Reset_Event(void)
#endif
#endif /* ((USBD_CDC_ACM_ENABLE)) */

__weak void board_usb_sof_event(void) {}

#if ((USBD_HID_ENABLE) || (USBD_ADC_ENABLE) || (USBD_CDC_ACM_ENABLE) || (USBD_CLS_ENABLE))
#ifndef __RTX
void USBD_SOF_Event(void)
Expand All @@ -1081,6 +1083,7 @@ 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_CLS_ENABLE)) */
Expand Down

0 comments on commit 38fe9bc

Please sign in to comment.