File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
src/portable/microchip/pic Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -532,8 +532,25 @@ void dcd_remote_wakeup(uint8_t rhport)
532532#else
533533 U1CONbits .RESUME = 1 ;
534534#endif
535- unsigned cnt = 25000000 / 1000 ;
535+
536+ // FIXME: Assert RESUME signal correctly, requires device-specific handling
537+ // For now we use a hardcoded cycle-based delay which attempts to delay 10ms
538+ // at the most common CPU frequencies. On PIC32s we assume the loop body
539+ // takes 3 cycles. On 16-bit PICs we assume the XC16 compiler is in use and
540+ // use its `__delay_ms' function.
541+
542+ #if CFG_TUSB_MCU == OPT_MCU_PIC32MM
543+ uint32_t cnt = 24000000 / 1000 / 3 ;
544+ while (cnt -- ) asm volatile ("nop" );
545+ #elif CFG_TUSB_MCU == OPT_MCU_PIC32MX
546+ uint32_t cnt = 40000000 / 1000 / 3 ;
536547 while (cnt -- ) asm volatile ("nop" );
548+ #elif CFG_TUSB_MCU == OPT_MCU_PIC32MK
549+ uint32_t cnt = 120000000 / 1000 / 3 ;
550+ while (cnt -- ) asm volatile ("nop" );
551+ #else
552+ __delay_ms (10 );
553+ #endif
537554
538555#if TU_PIC_INT_SIZE == 4
539556 U1CONCLR = _U1CON_RESUME_MASK ;
You can’t perform that action at this time.
0 commit comments