diff --git a/examples/device/hid_composite_freertos/src/main.c b/examples/device/hid_composite_freertos/src/main.c index de065ee64..83c68b515 100644 --- a/examples/device/hid_composite_freertos/src/main.c +++ b/examples/device/hid_composite_freertos/src/main.c @@ -58,7 +58,12 @@ StaticTimer_t blinky_tmdef; TimerHandle_t blinky_tm; // static task for usbd -#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) +#if CFG_TUSB_DEBUG + #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE) +#else + #define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) +#endif + StackType_t usb_device_stack[USBD_STACK_SIZE]; StaticTask_t usb_device_taskdef; diff --git a/src/portable/espressif/esp32s2/dcd_esp32s2.c b/src/portable/espressif/esp32s2/dcd_esp32s2.c index 58d92e728..cd66af805 100644 --- a/src/portable/espressif/esp32s2/dcd_esp32s2.c +++ b/src/portable/espressif/esp32s2/dcd_esp32s2.c @@ -218,6 +218,9 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr) void dcd_remote_wakeup(uint8_t rhport) { (void)rhport; + + // TODO must manually clear this bit after 1-15 ms + // USB0.DCTL |= USB_RMTWKUPSIG_M; } // connect by enabling internal pull-up resistor on D+/D- @@ -670,6 +673,7 @@ static void handle_epin_ints(void) static void _dcd_int_handler(void* arg) { (void) arg; + uint8_t const rhport = 0; const uint32_t int_status = USB0.gintsts; //const uint32_t int_msk = USB0.gintmsk; @@ -695,7 +699,19 @@ static void _dcd_int_handler(void* arg) // the end of reset. USB0.gintsts = USB_ENUMDONE_M; enum_done_processing(); - dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true); + dcd_event_bus_reset(rhport, TUSB_SPEED_FULL, true); + } + + if(int_status & USB_USBSUSP_M) + { + USB0.gintsts = USB_USBSUSP_M; + dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true); + } + + if(int_status & USB_WKUPINT_M) + { + USB0.gintsts = USB_WKUPINT_M; + dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true); } if (int_status & USB_OTGINT_M) @@ -707,7 +723,7 @@ static void _dcd_int_handler(void* arg) if (otg_int & USB_SESENDDET_M) { - dcd_event_bus_signal(0, DCD_EVENT_UNPLUGGED, true); + dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true); } USB0.gotgint = otg_int; @@ -716,7 +732,7 @@ static void _dcd_int_handler(void* arg) #if USE_SOF if (int_status & USB_SOF_M) { USB0.gintsts = USB_SOF_M; - dcd_event_bus_signal(0, DCD_EVENT_SOF, true); // do nothing actually + dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true); // do nothing actually } #endif diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c index 9aeec79e6..35c814460 100644 --- a/src/portable/st/synopsys/dcd_synopsys.c +++ b/src/portable/st/synopsys/dcd_synopsys.c @@ -507,13 +507,16 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr) void dcd_remote_wakeup(uint8_t rhport) { (void) rhport; + + // TODO must manually clear this bit after 1-15 ms + // USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport); + // dev->DCTL |= USB_OTG_DCTL_RWUSIG; } void dcd_connect(uint8_t rhport) { (void) rhport; USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport); - dev->DCTL &= ~USB_OTG_DCTL_SDIS; } @@ -521,7 +524,6 @@ void dcd_disconnect(uint8_t rhport) { (void) rhport; USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport); - dev->DCTL |= USB_OTG_DCTL_SDIS; }