dcd_pic: check USBBUSY bit on PIC32s

This commit is contained in:
Reimu NotMoe
2024-12-27 04:17:26 +08:00
parent a4169114ec
commit 655092d568

View File

@@ -492,6 +492,9 @@ bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
tu_memclr(&_dcd, sizeof(_dcd));
#if TU_PIC_INT_SIZE == 4
// The USBBUSY bit is present on PIC32s and we're required to check it
// prior to powering on the USB peripheral (see DS61126F page 27)
while (U1PWRCbits.USBBUSY);
U1PWRCSET = _U1PWRC_USBPWR_MASK;
#else
U1PWRCbits.USBPWR = 1;