aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2018-02-03 12:41:23 +0200
committerFred Sundvik <fsundvik@gmail.com>2018-02-03 17:25:31 +0200
commit432bc1762f17eb7b506e8fbca8ec30a3d61629b8 (patch)
tree6f3399b5c8be2b8329c979f2d61ef52b1b132531 /os/hal
parentf2f4ed8ca46e836f1742ff9bb4da7acf07e83537 (diff)
downloadChibiOS-Contrib-432bc1762f17eb7b506e8fbca8ec30a3d61629b8.tar.gz
ChibiOS-Contrib-432bc1762f17eb7b506e8fbca8ec30a3d61629b8.tar.bz2
ChibiOS-Contrib-432bc1762f17eb7b506e8fbca8ec30a3d61629b8.zip
Add usb_lld_wakeup_host for Kinetis
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/ports/KINETIS/LLD/hal_usb_lld.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/os/hal/ports/KINETIS/LLD/hal_usb_lld.h b/os/hal/ports/KINETIS/LLD/hal_usb_lld.h
index 961490e..bd4eb39 100644
--- a/os/hal/ports/KINETIS/LLD/hal_usb_lld.h
+++ b/os/hal/ports/KINETIS/LLD/hal_usb_lld.h
@@ -76,6 +76,13 @@
#define KINETIS_USB_ENDPOINTS USB_MAX_ENDPOINTS+1
#endif
+/**
+ * @brief Host wake-up procedure duration.
+ */
+#if !defined(USB_HOST_WAKEUP_DURATION) || defined(__DOXYGEN__)
+#define USB_HOST_WAKEUP_DURATION 2
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@@ -97,6 +104,10 @@
#error "KINETIS_USB_IRQ_VECTOR not defined"
#endif
+#if (USB_HOST_WAKEUP_DURATION < 2) || (USB_HOST_WAKEUP_DURATION > 15)
+#error "invalid USB_HOST_WAKEUP_DURATION setting, it must be between 2 and 15"
+#endif
+
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -394,6 +405,18 @@ struct USBDriver {
#endif /* KINETIS_USB0_IS_USBOTG */
#endif
+/**
+ * @brief Start of host wake-up procedure.
+ *
+ * @notapi
+ */
+#define usb_lld_wakeup_host(usbp) \
+ do{ \
+ USB0->CTL |= USBx_CTL_RESUME; \
+ osalThreadSleepMilliseconds(USB_HOST_WAKEUP_DURATION); \
+ USB0->CTL &= ~USBx_CTL_RESUME; \
+ } while (false)
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/