From 56dafb82951a5e587e3b1398d99d85f6dbd67370 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 14 Aug 2012 06:58:24 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4565 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/OTGv1/usb_lld.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'os') diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c index c0785a2e6..85b35d829 100644 --- a/os/hal/platforms/STM32/OTGv1/usb_lld.c +++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c @@ -138,6 +138,7 @@ static void otg_disable_ep(void) { OTG->oe[i].DOEPTSIZ = 0; OTG->oe[i].DOEPINT = 0xFFFFFFFF; } + OTG->DAINTMSK = DAINTMSK_OEPM(0) | DAINTMSK_IEPM(0); } static void otg_rxfifo_flush(void) { @@ -699,7 +700,10 @@ void usb_lld_start(USBDriver *usbp) { void usb_lld_stop(USBDriver *usbp) { /* If in ready state then disables the USB clock.*/ - if (usbp->state == USB_STOP) { + if (usbp->state != USB_STOP) { + OTG->DAINTMSK = 0; + OTG->GCCFG = 0; + #if STM32_USB_USE_USB1 if (&USBD1 == usbp) { nvicDisableVector(STM32_OTG1_NUMBER); @@ -707,7 +711,6 @@ void usb_lld_stop(USBDriver *usbp) { } #endif } - OTG->GCCFG = 0; } /** @@ -809,10 +812,14 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) { /* OUT endpoint activation or deactivation.*/ OTG->oe[ep].DOEPTSIZ = 0; - if (usbp->epc[ep]->out_cb != NULL) + if (usbp->epc[ep]->out_cb != NULL) { OTG->oe[ep].DOEPCTL = ctl | DOEPCTL_MPSIZ(usbp->epc[ep]->out_maxsize); - else + OTG->DAINTMSK |= DAINTMSK_OEPM(ep); + } + else { OTG->oe[ep].DOEPCTL &= ~DOEPCTL_USBAEP; + OTG->DAINTMSK &= ~DAINTMSK_OEPM(ep); + } /* IN endpoint activation or deactivation.*/ OTG->ie[ep].DIEPTSIZ = 0; @@ -828,11 +835,13 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) { OTG->ie[ep].DIEPCTL = ctl | DIEPCTL_TXFNUM(ep) | DIEPCTL_MPSIZ(usbp->epc[ep]->in_maxsize); + OTG->DAINTMSK |= DAINTMSK_IEPM(ep); } else { OTG->DIEPTXF[ep - 1] = 0x02000400; /* Reset value.*/ otg_txfifo_flush(ep); OTG->ie[ep].DIEPCTL &= ~DIEPCTL_USBAEP; + OTG->DAINTMSK &= ~DAINTMSK_IEPM(ep); } } -- cgit v1.2.3