aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-09-08 10:43:31 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-09-08 10:43:31 +0000
commitaa7557a5f206124dc232343be2010f7d9b82e267 (patch)
tree0a84f3ded31ee0ad2d63d283af0ea7ce8b0fdab6 /os/hal/src
parent4376041f33960189d088ac3d87b7cab178269484 (diff)
downloadChibiOS-aa7557a5f206124dc232343be2010f7d9b82e267.tar.gz
ChibiOS-aa7557a5f206124dc232343be2010f7d9b82e267.tar.bz2
ChibiOS-aa7557a5f206124dc232343be2010f7d9b82e267.zip
USB suspend mode.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8286 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r--os/hal/src/usb.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c
index c563d5fea..c4f612d0f 100644
--- a/os/hal/src/usb.c
+++ b/os/hal/src/usb.c
@@ -314,7 +314,8 @@ void usbStop(USBDriver *usbp) {
osalSysLock();
osalDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY) ||
- (usbp->state == USB_SELECTED) || (usbp->state == USB_ACTIVE),
+ (usbp->state == USB_SELECTED) || (usbp->state == USB_ACTIVE) ||
+ (usbp->state == USB_SUSPENDED),
"invalid state");
usb_lld_stop(usbp);
usbp->state = USB_STOP;
@@ -607,7 +608,10 @@ bool usbStallTransmitI(USBDriver *usbp, usbep_t ep) {
void _usb_reset(USBDriver *usbp) {
unsigned i;
+ /* State transition.*/
usbp->state = USB_READY;
+
+ /* Resetting internal state.*/
usbp->status = 0;
usbp->address = 0;
usbp->configuration = 0;
@@ -624,6 +628,45 @@ void _usb_reset(USBDriver *usbp) {
/* Low level reset.*/
usb_lld_reset(usbp);
+
+ /* Notification of reset event.*/
+ _usb_isr_invoke_event_cb(usbp, USB_EVENT_RESET);
+}
+
+/**
+ * @brief USB suspend routine.
+ * @details This function must be invoked when an USB bus suspend condition is
+ * detected.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ *
+ * @notapi
+ */
+void _usb_suspend(USBDriver *usbp) {
+
+ /* State transition.*/
+ usbp->state = USB_SUSPENDED;
+
+ /* Notification of suspend event.*/
+ _usb_isr_invoke_event_cb(usbp, USB_EVENT_SUSPEND);
+}
+
+/**
+ * @brief USB wake-up routine.
+ * @details This function must be invoked when an USB bus wake-up condition is
+ * detected.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ *
+ * @notapi
+ */
+void _usb_wakeup(USBDriver *usbp) {
+
+ /* State transition.*/
+ usbp->state = USB_ACTIVE;
+
+ /* Notification of suspend event.*/
+ _usb_isr_invoke_event_cb(usbp, USB_EVENT_WAKEUP);
}
/**