NUC123 USB driver potential stability fixes

This commit is contained in:
Alex Lewontin 2020-12-30 18:53:28 -05:00
parent 75cbc08156
commit 8c16b4ff9e
No known key found for this signature in database
GPG Key ID: 52A3855FC3BB8CD7
1 changed files with 5 additions and 0 deletions

View File

@ -423,6 +423,7 @@ void usb_lld_init(void)
*/
void usb_lld_start(USBDriver* usbp)
{
uint32_t delay;
if (usbp->state == USB_STOP) {
/* Enables the peripheral.*/
@ -437,6 +438,8 @@ void usb_lld_start(USBDriver* usbp)
/* Reset procedure enforced on driver start.*/
SYS->IPRSTC2 |= SYS_IPRSTC2_USBD_RST_Msk;
for (delay = 0; delay < 0x800; ++delay)
;
SYS->IPRSTC2 &= ~(SYS_IPRSTC2_USBD_RST_Msk);
/* Post reset initialization.*/
@ -455,6 +458,8 @@ void usb_lld_start(USBDriver* usbp)
nvicEnableVector(USBD_IRQn, NUC123_USB_IRQ_PRIORITY);
for (delay = 0; delay < 0x800; ++delay)
;
usb_lld_reset(usbp);
}