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 +++++++++++++---- testhal/STM32F4xx/USB_CDC/main.c | 6 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) 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); } } diff --git a/testhal/STM32F4xx/USB_CDC/main.c b/testhal/STM32F4xx/USB_CDC/main.c index 4777f5c2a..7bbdfd870 100644 --- a/testhal/STM32F4xx/USB_CDC/main.c +++ b/testhal/STM32F4xx/USB_CDC/main.c @@ -394,7 +394,7 @@ static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) { chThdWait(tp); } -static void cmd_usbblast(BaseSequentialStream *chp, int argc, char *argv[]) { +static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) { static uint8_t buf[] = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" @@ -431,7 +431,7 @@ static void cmd_usbblast(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { - chprintf(chp, "Usage: usbblast\r\n"); + chprintf(chp, "Usage: write\r\n"); return; } @@ -445,7 +445,7 @@ static const ShellCommand commands[] = { {"mem", cmd_mem}, {"threads", cmd_threads}, {"test", cmd_test}, - {"usbblast", cmd_usbblast}, + {"write", cmd_write}, {NULL, NULL} }; -- cgit v1.2.3