diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2013-04-26 12:49:55 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2013-04-26 12:49:55 -0400 |
commit | 4b5085272759b4fa78c28a5db4b6050da56c35b3 (patch) | |
tree | 43978fff9fe864e022b35a187c8eccc84246023a /libmaple/usb/stm32f1 | |
parent | 4361c610124fb6e5030631b7625c14f245fe1743 (diff) | |
parent | 47d911dc5b675958f554491b7d750899db2c943c (diff) | |
download | librambutan-4b5085272759b4fa78c28a5db4b6050da56c35b3.tar.gz librambutan-4b5085272759b4fa78c28a5db4b6050da56c35b3.zip |
Merge remote-tracking branch 'wesen/bug/usb-resume'
Diffstat (limited to 'libmaple/usb/stm32f1')
-rw-r--r-- | libmaple/usb/stm32f1/usb.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libmaple/usb/stm32f1/usb.c b/libmaple/usb/stm32f1/usb.c index c20cc71..b19ce33 100644 --- a/libmaple/usb/stm32f1/usb.c +++ b/libmaple/usb/stm32f1/usb.c @@ -76,6 +76,7 @@ struct { static usblib_dev usblib = { .irq_mask = USB_ISR_MSK, .state = USB_UNCONNECTED, + .prevState = USB_UNCONNECTED, .clk_id = RCC_USB, }; usblib_dev *USBLIB = &usblib; @@ -115,6 +116,7 @@ static void usb_suspend(void) { cntr |= USB_CNTR_LP_MODE; USB_BASE->CNTR = cntr; + USBLIB->prevState = USBLIB->state; USBLIB->state = USB_SUSPENDED; } @@ -132,14 +134,15 @@ static void usb_resume_init(void) { static void usb_resume(RESUME_STATE eResumeSetVal) { uint16 cntr; - if (eResumeSetVal != RESUME_ESOF) - ResumeS.eState = eResumeSetVal; + if (eResumeSetVal != RESUME_ESOF) { + ResumeS.eState = eResumeSetVal + } - switch (ResumeS.eState) - { + switch (ResumeS.eState) { case RESUME_EXTERNAL: usb_resume_init(); ResumeS.eState = RESUME_OFF; + USBLIB->state = USBLIB->prevState; break; case RESUME_INTERNAL: usb_resume_init(); @@ -151,8 +154,9 @@ static void usb_resume(RESUME_STATE eResumeSetVal) { break; case RESUME_WAIT: ResumeS.bESOFcnt--; - if (ResumeS.bESOFcnt == 0) + if (ResumeS.bESOFcnt == 0) { ResumeS.eState = RESUME_START; + } break; case RESUME_START: cntr = USB_BASE->CNTR; @@ -167,6 +171,7 @@ static void usb_resume(RESUME_STATE eResumeSetVal) { cntr = USB_BASE->CNTR; cntr &= ~USB_CNTR_RESUME; USB_BASE->CNTR = cntr; + USBLIB->state = USBLIB->prevState; ResumeS.eState = RESUME_OFF; } break; @@ -175,7 +180,7 @@ static void usb_resume(RESUME_STATE eResumeSetVal) { default: ResumeS.eState = RESUME_OFF; break; - } + } } #define SUSPEND_ENABLED 1 @@ -274,8 +279,9 @@ static void dispatch_ctr_lp() { * once we're done serving endpoint zero, but not okay if * there are multiple nonzero endpoint transfers to * handle. */ - if (dispatch_endpt_zero(istr & USB_ISTR_DIR)) + if (dispatch_endpt_zero(istr & USB_ISTR_DIR)) { return; + } } else { dispatch_endpt(ep_id); } |