1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #11698 from bergzand/pr/usb/nrfusb_suspend

nrf52: Add suspend/resume detection to usbdev
This commit is contained in:
Alexandre Abadie 2019-06-25 16:12:27 +02:00 committed by GitHub
commit 56085b10a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -275,7 +275,9 @@ static void _init(usbdev_t *dev)
usbdev->sstate = NRFUSB_SETUP_READY;
/* Enable a set of interrupts */
usbdev->device->INTEN = USBD_INTEN_USBRESET_Msk | USBD_INTEN_EPDATA_Msk;
usbdev->device->INTEN = USBD_INTEN_USBRESET_Msk |
USBD_INTEN_EPDATA_Msk |
USBD_INTEN_USBEVENT_Msk;
NVIC_EnableIRQ(USBD_IRQn);
}
@ -539,6 +541,19 @@ static void _esr(usbdev_t *dev)
usbdev->usbdev.cb(&usbdev->usbdev, USBDEV_EVENT_RESET);
usbdev->device->INTENSET = USBD_INTENSET_USBRESET_Msk;
}
else if (usbdev->device->EVENTS_USBEVENT) {
uint32_t events = usbdev->device->EVENTCAUSE;
if (events & USBD_EVENTCAUSE_SUSPEND_Msk) {
usbdev->usbdev.cb(&usbdev->usbdev, USBDEV_EVENT_SUSPEND);
}
if (events & USBD_EVENTCAUSE_RESUME_Msk) {
usbdev->usbdev.cb(&usbdev->usbdev, USBDEV_EVENT_RESUME);
}
usbdev->device->EVENTS_USBEVENT = 0;
/* Clear eventcause register */
usbdev->device->EVENTCAUSE = 0x0f01;
usbdev->device->INTENSET = USBD_INTENSET_USBEVENT_Msk;
}
}
static signed _ep0_esr(usbdev_ep_t *ep)
@ -616,6 +631,11 @@ void isr_usbd(void)
usbdev->device->INTENCLR = USBD_INTENCLR_USBRESET_Msk;
usbdev->usbdev.cb(&usbdev->usbdev, USBDEV_EVENT_ESR);
}
else if (usbdev->device->EVENTS_USBEVENT &&
(usbdev->device->INTEN & USBD_INTEN_USBEVENT_Msk)) {
usbdev->device->INTENCLR = USBD_INTENCLR_USBEVENT_Msk;
usbdev->usbdev.cb(&usbdev->usbdev, USBDEV_EVENT_ESR);
}
else {
/* Endpoint specific isr handling*/
/* Endpoint 0 SETUP data received requests */