esp32sx implement dcd_remote_wakeup(), fully compliance to chapter9 test suite

This commit is contained in:
hathach 2021-09-13 16:49:38 +07:00
parent e64bfb9ff5
commit cdc63459eb
3 changed files with 23 additions and 17 deletions

View File

@ -67,8 +67,9 @@
// This examples use FreeRTOS // This examples use FreeRTOS
#define CFG_TUSB_OS OPT_OS_FREERTOS #define CFG_TUSB_OS OPT_OS_FREERTOS
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build #ifndef CFG_TUSB_DEBUG
// #define CFG_TUSB_DEBUG 0 #define CFG_TUSB_DEBUG 0
#endif
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. /* 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 * Tinyusb use follows macros to declare transferring memory so that they can be put

View File

@ -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 // 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; return not_found;
} }

View File

@ -42,10 +42,6 @@
#include "device/dcd.h" #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 // Max number of bi-directional endpoints including EP0
// Note: ESP32S2 specs say there are only up to 5 IN active endpoints include 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) // 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.gintsts = ~0U; //clear pending ints
USB0.gintmsk = USB_OTGINTMSK_M | USB0.gintmsk = USB_OTGINTMSK_M |
USB_MODEMISMSK_M | USB_MODEMISMSK_M |
#if USE_SOF
USB_SOFMSK_M |
#endif
USB_RXFLVIMSK_M | USB_RXFLVIMSK_M |
USB_ERLYSUSPMSK_M | USB_ERLYSUSPMSK_M |
USB_USBSUSPMSK_M | USB_USBSUSPMSK_M |
@ -221,8 +214,17 @@ void dcd_remote_wakeup(uint8_t rhport)
{ {
(void)rhport; (void)rhport;
// TODO must manually clear this bit after 1-15 ms // set remote wakeup
// USB0.DCTL |= USB_RMTWKUPSIG_M; 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- // connect by enabling internal pull-up resistor on D+/D-
@ -731,8 +733,8 @@ static void _dcd_int_handler(void* arg)
(void) arg; (void) arg;
uint8_t const rhport = 0; 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) { if (int_status & USB_USBRST_M) {
// start of reset // start of reset
@ -785,12 +787,15 @@ static void _dcd_int_handler(void* arg)
USB0.gotgint = otg_int; USB0.gotgint = otg_int;
} }
#if USE_SOF
if (int_status & USB_SOF_M) { if (int_status & USB_SOF_M) {
USB0.gintsts = 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) { if (int_status & USB_RXFLVI_M) {
// RXFLVL bit is read-only // RXFLVL bit is read-only