Tentative implementation of USB host wake-up API.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10570 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
66cf5195f9
commit
7da97fec6a
|
@ -245,10 +245,21 @@
|
|||
#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. */
|
||||
/*===========================================================================*/
|
||||
|
@ -620,6 +631,7 @@ extern "C" {
|
|||
#endif
|
||||
bool usbStallReceiveI(USBDriver *usbp, usbep_t ep);
|
||||
bool usbStallTransmitI(USBDriver *usbp, usbep_t ep);
|
||||
void usbWakeupHost(USBDriver *usbp);
|
||||
void _usb_reset(USBDriver *usbp);
|
||||
void _usb_suspend(USBDriver *usbp);
|
||||
void _usb_wakeup(USBDriver *usbp);
|
||||
|
|
|
@ -556,9 +556,6 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
|
|||
otgp->PCGCCTL &= ~(PCGCCTL_STPPCLK | PCGCCTL_GATEHCLK);
|
||||
}
|
||||
|
||||
/* Clear the Remote Wake-up Signaling.*/
|
||||
otgp->DCTL |= DCTL_RWUSIG;
|
||||
|
||||
_usb_wakeup(usbp);
|
||||
}
|
||||
|
||||
|
|
|
@ -541,7 +541,7 @@ struct USBDriver {
|
|||
/**
|
||||
* @brief Connects the USB device.
|
||||
*
|
||||
* @api
|
||||
* @notapi
|
||||
*/
|
||||
#if (STM32_OTG_STEPPING == 1) || defined(__DOXYGEN__)
|
||||
#define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_VBUSBSEN)
|
||||
|
@ -552,7 +552,7 @@ struct USBDriver {
|
|||
/**
|
||||
* @brief Disconnect the USB device.
|
||||
*
|
||||
* @api
|
||||
* @notapi
|
||||
*/
|
||||
#if (STM32_OTG_STEPPING == 1) || defined(__DOXYGEN__)
|
||||
#define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_VBUSBSEN)
|
||||
|
@ -560,6 +560,20 @@ struct USBDriver {
|
|||
#define usb_lld_disconnect_bus(usbp) ((usbp)->otg->DCTL |= DCTL_SDIS)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Start of host wake-up procedure.
|
||||
*
|
||||
* @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)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -422,7 +422,7 @@ struct USBDriver {
|
|||
/**
|
||||
* @brief Connects the USB device.
|
||||
*
|
||||
* @api
|
||||
* @notapi
|
||||
*/
|
||||
#if !defined(usb_lld_connect_bus)
|
||||
#define usb_lld_connect_bus(usbp) (STM32_USB->BCDR |= USB_BCDR_DPPU)
|
||||
|
@ -431,7 +431,7 @@ struct USBDriver {
|
|||
/**
|
||||
* @brief Disconnect the USB device.
|
||||
*
|
||||
* @api
|
||||
* @notapi
|
||||
*/
|
||||
#if !defined(usb_lld_disconnect_bus)
|
||||
#define usb_lld_disconnect_bus(usbp) (STM32_USB->BCDR &= ~USB_BCDR_DPPU)
|
||||
|
@ -448,6 +448,20 @@ struct USBDriver {
|
|||
#endif
|
||||
#endif /* STM32L1XX */
|
||||
|
||||
/**
|
||||
* @brief Start of host wake-up procedure.
|
||||
*
|
||||
* @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)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -631,6 +631,29 @@ bool usbStallTransmitI(USBDriver *usbp, usbep_t ep) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Host wake-up procedure.
|
||||
* @note It is silently ignored if the USB device is not in the
|
||||
* @p USB_SUSPENDED state.
|
||||
*
|
||||
* @param[in] usbp pointer to the @p USBDriver object
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USB reset routine.
|
||||
* @details This function must be invoked when an USB bus reset condition is
|
||||
|
|
Loading…
Reference in New Issue