[riot-notifications] [RIOT-OS/RIOT] nrf52: Add suspend/resume detection to usbdev (#11698)

Alexandre Abadie notifications at github.com
Mon Jun 24 08:02:53 CEST 2019


aabadie requested changes on this pull request.

Tested this PR on nrf52840-mdk and  confirm that it works following the testing procedure.

I have minor code comments. You can squash them immediately.

> @@ -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;

```suggestion
        usbdev->device->EVENTCAUSE = (USBD_EVENTCAUSE_READY_Msk |
                                      USBD_EVENTCAUSE_USBWUALLOWED_Msk |
                                      USBD_EVENTCAUSE_RESUME_Msk |
                                      USBD_EVENTCAUSE_SUSPEND_Msk |
                                      USBD_EVENTCAUSE_ISOOUTCRC_Msk);
```

> @@ -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 |

it's better if you put parenthesis around mask values:
```suggestion
    usbdev->device->INTEN = (USBD_INTEN_USBRESET_Msk |
                             USBD_INTEN_EPDATA_Msk |
                             USBD_INTEN_USBEVENT_Msk);
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11698#pullrequestreview-253211157
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190623/409d9e5f/attachment-0001.html>


More information about the notifications mailing list