aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-14 06:58:24 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-14 06:58:24 +0000
commit56dafb82951a5e587e3b1398d99d85f6dbd67370 (patch)
tree1546c59b1c08d4a8d445a36acbec62ab1c450055 /os
parent55f4744930ce753eeb04ae939baa6de885972c8d (diff)
downloadChibiOS-56dafb82951a5e587e3b1398d99d85f6dbd67370.tar.gz
ChibiOS-56dafb82951a5e587e3b1398d99d85f6dbd67370.tar.bz2
ChibiOS-56dafb82951a5e587e3b1398d99d85f6dbd67370.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4565 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/platforms/STM32/OTGv1/usb_lld.c17
1 files changed, 13 insertions, 4 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);
}
}