summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/device/hid_composite_freertos/src/tusb_config.h5
-rw-r--r--src/common/tusb_common.h2
-rw-r--r--src/portable/espressif/esp32sx/dcd_esp32sx.c33
3 files changed, 23 insertions, 17 deletions
diff --git a/examples/device/hid_composite_freertos/src/tusb_config.h b/examples/device/hid_composite_freertos/src/tusb_config.h
index 4b0458ef0..4fbccc294 100644
--- a/examples/device/hid_composite_freertos/src/tusb_config.h
+++ b/examples/device/hid_composite_freertos/src/tusb_config.h
@@ -67,8 +67,9 @@
// This examples use FreeRTOS
#define CFG_TUSB_OS OPT_OS_FREERTOS
-// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
-// #define CFG_TUSB_DEBUG 0
+#ifndef CFG_TUSB_DEBUG
+#define CFG_TUSB_DEBUG 0
+#endif
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index d0cc41285..1899b35cc 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -380,7 +380,7 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
}
// not found return the key value in hex
- sprintf(not_found, "0x%08lX", key);
+ sprintf(not_found, "0x%08lX", (unsigned long) key);
return not_found;
}
diff --git a/src/portable/espressif/esp32sx/dcd_esp32sx.c b/src/portable/espressif/esp32sx/dcd_esp32sx.c
index 541f7d586..cfbbab233 100644
--- a/src/portable/espressif/esp32sx/dcd_esp32sx.c
+++ b/src/portable/espressif/esp32sx/dcd_esp32sx.c
@@ -42,10 +42,6 @@
#include "device/dcd.h"
-// Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval)
-// We disable SOF for now until needed later on
-#define USE_SOF 0
-
// Max number of bi-directional endpoints including EP0
// Note: ESP32S2 specs say there are only up to 5 IN active endpoints include EP0
// We should probably prohibit enabling Endpoint IN > 4 (not done yet)
@@ -194,9 +190,6 @@ void dcd_init(uint8_t rhport)
USB0.gintsts = ~0U; //clear pending ints
USB0.gintmsk = USB_OTGINTMSK_M |
USB_MODEMISMSK_M |
- #if USE_SOF
- USB_SOFMSK_M |
- #endif
USB_RXFLVIMSK_M |
USB_ERLYSUSPMSK_M |
USB_USBSUSPMSK_M |
@@ -221,8 +214,17 @@ void dcd_remote_wakeup(uint8_t rhport)
{
(void)rhport;
- // TODO must manually clear this bit after 1-15 ms
- // USB0.DCTL |= USB_RMTWKUPSIG_M;
+ // set remote wakeup
+ USB0.dctl |= USB_RMTWKUPSIG_M;
+
+ // enable SOF to detect bus resume
+ USB0.gintsts = USB_SOF_M;
+ USB0.gintmsk |= USB_SOFMSK_M;
+
+ // Per specs: remote wakeup signal bit must be clear within 1-15ms
+ vTaskDelay(pdMS_TO_TICKS(1));
+
+ USB0.dctl &= ~USB_RMTWKUPSIG_M;
}
// connect by enabling internal pull-up resistor on D+/D-
@@ -731,8 +733,8 @@ 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;
+ const uint32_t int_msk = USB0.gintmsk;
+ const uint32_t int_status = USB0.gintsts & int_msk;
if (int_status & USB_USBRST_M) {
// start of reset
@@ -785,12 +787,15 @@ static void _dcd_int_handler(void* arg)
USB0.gotgint = otg_int;
}
-#if USE_SOF
if (int_status & USB_SOF_M) {
USB0.gintsts = USB_SOF_M;
- dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true); // do nothing actually
+
+ // Disable SOF interrupt since currently only used for remote wakeup detection
+ USB0.gintmsk &= ~USB_SOFMSK_M;
+
+ dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true);
}
-#endif
+
if (int_status & USB_RXFLVI_M) {
// RXFLVL bit is read-only