aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-04-27 10:06:06 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-04-27 10:06:06 +0000
commit4434fed8d81d9bc3a41a02a645bfd719ff941f73 (patch)
tree0cb7212b530b88875e1d25b0b2ebb633cf5ac800
parent6d4cee3b28ab9446fa8f567bdd0199c16561bad8 (diff)
downloadChibiOS-4434fed8d81d9bc3a41a02a645bfd719ff941f73.tar.gz
ChibiOS-4434fed8d81d9bc3a41a02a645bfd719ff941f73.tar.bz2
ChibiOS-4434fed8d81d9bc3a41a02a645bfd719ff941f73.zip
Fixed stop procedure in the USB driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5634 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/dox/usb.dox24
-rw-r--r--os/hal/platforms/STM32/OTGv1/usb_lld.c4
-rw-r--r--os/hal/src/usb.c3
-rw-r--r--os/ports/GCC/PPC/SPC564Axx/bam.s4
-rw-r--r--os/ports/GCC/PPC/SPC564Axx/core.s2
-rw-r--r--testhal/STM32F4xx/USB_CDC/.project2
-rw-r--r--testhal/STM32F4xx/USB_CDC/main.c9
7 files changed, 32 insertions, 16 deletions
diff --git a/os/hal/dox/usb.dox b/os/hal/dox/usb.dox
index c31a8f274..b71a75186 100644
--- a/os/hal/dox/usb.dox
+++ b/os/hal/dox/usb.dox
@@ -44,7 +44,7 @@
uninit [label="USB_UNINIT", style="bold"];
ready [label="USB_READY\nClock Enabled"];
selected [label="\nUSB_SELECTED\naddress\nassigned"];
- configured [label="\nUSB_ACTIVE\nconfiguration\nselected"];
+ active [label="\nUSB_ACTIVE\nconfiguration\nselected"];
uninit -> stop [label=" usbInit()", constraint=false];
stop -> stop [label="\nusbStop()"];
@@ -53,12 +53,14 @@
ready -> ready [label="\n\nusbStart()"];
ready -> ready [label="\nSUSPEND/WAKEUP\n>event_cb<"];
ready -> selected [label="\nSET_ADDRESS\n>event_cb<"];
+ selected -> stop [label="\nusbStop()"];
selected -> ready [label="\nUSB RESET\n>event_cb<"];
selected -> selected [label="\nSUSPEND/WAKEUP\n>event_cb<\n\nValid EP0 Message\n>requests_hook_cb<\n\nGET DESCRIPTOR\n>get_descriptor_cb<"];
- selected -> configured [label="\nSET_CONF(n)\n>event_cb<"];
- configured -> selected [label="\nSET_CONF(0)\n>event_cb<"];
- configured -> configured [label="\nSUSPEND/WAKEUP\n>event_cb<\n\nValid EP0 Message\n>requests_hook_cb<\n\nGET DESCRIPTOR\n>get_descriptor_cb<\n\nEndpoints Activity\n >in_cb< or >out_cb<"];
- configured -> ready [label="\nUSB RESET\n>event_cb<"];
+ selected -> active [label="\nSET_CONF(n)\n>event_cb<"];
+ active -> stop [label="\nusbStop()"];
+ active -> selected [label="\nSET_CONF(0)\n>event_cb<"];
+ active -> active [label="\nSUSPEND/WAKEUP\n>event_cb<\n\nValid EP0 Message\n>requests_hook_cb<\n\nGET DESCRIPTOR\n>get_descriptor_cb<\n\nEndpoints Activity\n >in_cb< or >out_cb<"];
+ active -> ready [label="\nUSB RESET\n>event_cb<"];
}
* @enddot
* @else
@@ -73,7 +75,7 @@
uninit [label="USB_UNINIT", style="bold"];
ready [label="USB_READY\nClock Enabled"];
selected [label="\nUSB_SELECTED\naddress\nassigned"];
- configured [label="\nUSB_ACTIVE\nconfiguration\nselected"];
+ active [label="\nUSB_ACTIVE\nconfiguration\nselected"];
uninit -> stop [label=" usbInit()", constraint=false];
stop -> stop [label="\nusbStop()"];
@@ -82,12 +84,14 @@
ready -> ready [label="\n\nusbStart()"];
ready -> ready [label="\nSUSPEND/WAKEUP\n>event_cb<"];
ready -> selected [label="\nSET_ADDRESS\n>event_cb<"];
+ selected -> stop [label="\nusbStop()"];
selected -> ready [label="\nUSB RESET\n>event_cb<"];
selected -> selected [label="\nSUSPEND/WAKEUP\n>event_cb<\n\nValid EP0 Message\n>requests_hook_cb<\n\nGET DESCRIPTOR\n>get_descriptor_cb<"];
- selected -> configured [label="\nSET_CONF(n)\n>event_cb<"];
- configured -> selected [label="\nSET_CONF(0)\n>event_cb<"];
- configured -> configured [label="\nSUSPEND/WAKEUP\n>event_cb<\n\nValid EP0 Message\n>requests_hook_cb<\n\nGET DESCRIPTOR\n>get_descriptor_cb<\n\nEndpoints Activity\n >in_cb< >out_cb< >setup_cb<"];
- configured -> ready [label="\nUSB RESET\n>event_cb<"];
+ selected -> active [label="\nSET_CONF(n)\n>event_cb<"];
+ active -> stop [label="\nusbStop()"];
+ active -> selected [label="\nSET_CONF(0)\n>event_cb<"];
+ active -> active [label="\nSUSPEND/WAKEUP\n>event_cb<\n\nValid EP0 Message\n>requests_hook_cb<\n\nGET DESCRIPTOR\n>get_descriptor_cb<\n\nEndpoints Activity\n >in_cb< or >out_cb<"];
+ active -> ready [label="\nUSB RESET\n>event_cb<"];
}
* @enddot
* @endif
diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c
index 3e50ccfe5..f6287a49c 100644
--- a/os/hal/platforms/STM32/OTGv1/usb_lld.c
+++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c
@@ -927,6 +927,10 @@ void usb_lld_stop(USBDriver *usbp) {
/* If in ready state then disables the USB clock.*/
if (usbp->state != USB_STOP) {
+ /* Disabling all endpoints in case the driver has been stopped while
+ active.*/
+ otg_disable_ep(usbp);
+
usbp->txpending = 0;
otgp->DAINTMSK = 0;
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c
index 1e7c35121..9c3825910 100644
--- a/os/hal/src/usb.c
+++ b/os/hal/src/usb.c
@@ -282,7 +282,8 @@ void usbStop(USBDriver *usbp) {
chDbgCheck(usbp != NULL, "usbStop");
chSysLock();
- chDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY),
+ chDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY) ||
+ (usbp->state == USB_SELECTED) || (usbp->state == USB_ACTIVE),
"usbStop(), #1", "invalid state");
usb_lld_stop(usbp);
usbp->state = USB_STOP;
diff --git a/os/ports/GCC/PPC/SPC564Axx/bam.s b/os/ports/GCC/PPC/SPC564Axx/bam.s
index 2955cea2f..316724abf 100644
--- a/os/ports/GCC/PPC/SPC564Axx/bam.s
+++ b/os/ports/GCC/PPC/SPC564Axx/bam.s
@@ -19,8 +19,8 @@
*/
/**
- * @file SPC563Axx/bam.s
- * @brief SPC563Axx boot assistant record.
+ * @file SPC564Axx/bam.s
+ * @brief SPC564Axx boot assistant record.
*
* @addtogroup PPC_CORE
* @{
diff --git a/os/ports/GCC/PPC/SPC564Axx/core.s b/os/ports/GCC/PPC/SPC564Axx/core.s
index 074675c46..10ea5ffaf 100644
--- a/os/ports/GCC/PPC/SPC564Axx/core.s
+++ b/os/ports/GCC/PPC/SPC564Axx/core.s
@@ -19,7 +19,7 @@
*/
/**
- * @file SPC563Axx/core.s
+ * @file SPC564Axx/core.s
* @brief e200z4 core configuration.
*
* @addtogroup PPC_CORE
diff --git a/testhal/STM32F4xx/USB_CDC/.project b/testhal/STM32F4xx/USB_CDC/.project
index 6ef66d3aa..135abc544 100644
--- a/testhal/STM32F4xx/USB_CDC/.project
+++ b/testhal/STM32F4xx/USB_CDC/.project
@@ -27,7 +27,7 @@
<link>
<name>board</name>
<type>2</type>
- <locationURI>CHIBIOS/boards/ST_STM32F4_DISCOVERY</locationURI>
+ <locationURI>CHIBIOS/boards/OLIMEX_STM32_E407</locationURI>
</link>
<link>
<name>os</name>
diff --git a/testhal/STM32F4xx/USB_CDC/main.c b/testhal/STM32F4xx/USB_CDC/main.c
index 4a109aac4..0d38a7b20 100644
--- a/testhal/STM32F4xx/USB_CDC/main.c
+++ b/testhal/STM32F4xx/USB_CDC/main.c
@@ -472,7 +472,14 @@ int main(void) {
* after a reset.
*/
usbDisconnectBus(serusbcfg.usbp);
- chThdSleepMilliseconds(1000);
+ chThdSleepMilliseconds(1500);
+ usbStart(serusbcfg.usbp, &usbcfg);
+ usbConnectBus(serusbcfg.usbp);
+
+ chThdSleepMilliseconds(3000);
+ usbDisconnectBus(serusbcfg.usbp);
+ usbStop(serusbcfg.usbp);
+ chThdSleepMilliseconds(1500);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);