diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-09-09 16:45:34 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-09-09 16:45:34 +0000 |
commit | 67ac09b2f3e66f2a59261d189a0128644918727c (patch) | |
tree | 53fd13b1694d37a842cb933bf467c7f1c032a9c4 /os | |
parent | 8204b9ce59da09605a144503221516c8de0b856a (diff) | |
download | ChibiOS-67ac09b2f3e66f2a59261d189a0128644918727c.tar.gz ChibiOS-67ac09b2f3e66f2a59261d189a0128644918727c.tar.bz2 ChibiOS-67ac09b2f3e66f2a59261d189a0128644918727c.zip |
Moved wakeup logic in LLD.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10572 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/include/hal_usb.h | 11 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h | 25 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/USBv1/hal_usb_lld.h | 25 | ||||
-rw-r--r-- | os/hal/src/hal_usb.c | 8 |
4 files changed, 35 insertions, 34 deletions
diff --git a/os/hal/include/hal_usb.h b/os/hal/include/hal_usb.h index 653a058ae..3d2e32ad9 100644 --- a/os/hal/include/hal_usb.h +++ b/os/hal/include/hal_usb.h @@ -245,21 +245,10 @@ #define USB_USE_WAIT FALSE
#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. */
/*===========================================================================*/
-#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. */
/*===========================================================================*/
diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h index 4c4177133..ba5e4fc2f 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h +++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h @@ -142,6 +142,13 @@ #define STM32_USB_OTGFIFO_FILL_BASEPRI 0
#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. */
/*===========================================================================*/
@@ -242,6 +249,10 @@ #error "the USB OTG driver requires a 48MHz clock"
#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. */
/*===========================================================================*/
@@ -565,14 +576,12 @@ struct USBDriver { *
* @notapi
*/
-#define usb_lld_start_wakeup_host(usbp) ((usbp)->otg->DCTL |= DCTL_RWUSIG)
-
-/**
- * @brief Stop of host wake-up procedure.
- *
- * @notapi
- */
-#define usb_lld_stop_wakeup_host(usbp) ((usbp)->otg->DCTL &= ~DCTL_RWUSIG)
+#define usb_lld_wakeup_host(usbp) \
+ do{ \
+ (usbp)->otg->DCTL |= DCTL_RWUSIG; \
+ osalThreadSleepMilliseconds(USB_HOST_WAKEUP_DURATION); \
+ (usbp)->otg->DCTL &= ~DCTL_RWUSIG; \
+ } while (false)
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/ports/STM32/LLD/USBv1/hal_usb_lld.h b/os/hal/ports/STM32/LLD/USBv1/hal_usb_lld.h index db199e33d..b1073acf9 100644 --- a/os/hal/ports/STM32/LLD/USBv1/hal_usb_lld.h +++ b/os/hal/ports/STM32/LLD/USBv1/hal_usb_lld.h @@ -105,6 +105,13 @@ #define STM32_USB_USE_FAST_COPY FALSE
#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. */
/*===========================================================================*/
@@ -148,6 +155,10 @@ #error "STM32_USB1_LP_NUMBER 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. */
/*===========================================================================*/
@@ -453,14 +464,12 @@ struct USBDriver { *
* @notapi
*/
-#define usb_lld_start_wakeup_host(usbp) (STM32_USB->CNTR |= USB_CNTR_RESUME)
-
-/**
- * @brief Stop of host wake-up procedure.
- *
- * @notapi
- */
-#define usb_lld_stop_wakeup_host(usbp) (STM32_USB->CNTR &= ~USB_CNTR_RESUME)
+#define usb_lld_wakeup_host(usbp) \
+ do{ \
+ STM32_USB->CNTR |= USB_CNTR_RESUME; \
+ osalThreadSleepMilliseconds(USB_HOST_WAKEUP_DURATION); \
+ STM32_USB->CNTR &= ~USB_CNTR_RESUME; \
+ } while (false)
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/src/hal_usb.c b/os/hal/src/hal_usb.c index 61f03d832..314473f89 100644 --- a/os/hal/src/hal_usb.c +++ b/os/hal/src/hal_usb.c @@ -644,13 +644,7 @@ void usbWakeupHost(USBDriver *usbp) { if (usbp->state == USB_SUSPENDED) {
/* Starting host wakeup procedure.*/
- usb_lld_start_wakeup_host(usbp);
-
- /* Holding it for the configured time, it must be 2..15 msecs.*/
- osalThreadSleepMilliseconds(USB_HOST_WAKEUP_DURATION);
-
- /* Stopping host wake up procedure.*/
- usb_lld_stop_wakeup_host(usbp);
+ usb_lld_wakeup_host(usbp);
}
}
|