Skip to content

Commit 655092d

Browse files
committed
dcd_pic: check USBBUSY bit on PIC32s
1 parent a416911 commit 655092d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/portable/microchip/pic/dcd_pic.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@ bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
492492
tu_memclr(&_dcd, sizeof(_dcd));
493493

494494
#if TU_PIC_INT_SIZE == 4
495+
// The USBBUSY bit is present on PIC32s and we're required to check it
496+
// prior to powering on the USB peripheral (see DS61126F page 27)
497+
while (U1PWRCbits.USBBUSY);
495498
U1PWRCSET = _U1PWRC_USBPWR_MASK;
496499
#else
497500
U1PWRCbits.USBPWR = 1;

0 commit comments

Comments
 (0)