diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-06-13 16:13:00 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-06-13 16:13:00 +0000 |
commit | f620f29e0a803ed942134ac8a801d5204cebe034 (patch) | |
tree | b2085f49e6b84e76ecc122a521c65a442381213f /os/hal/src/serial_usb.c | |
parent | 93ed653e57fb9947feadf43d36442658e00d4339 (diff) | |
download | ChibiOS-f620f29e0a803ed942134ac8a801d5204cebe034.tar.gz ChibiOS-f620f29e0a803ed942134ac8a801d5204cebe034.tar.bz2 ChibiOS-f620f29e0a803ed942134ac8a801d5204cebe034.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4273 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/serial_usb.c')
-rw-r--r-- | os/hal/src/serial_usb.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c index 52be6e975..2b02ae02f 100644 --- a/os/hal/src/serial_usb.c +++ b/os/hal/src/serial_usb.c @@ -120,6 +120,11 @@ static void inotify(GenericQueue *qp) { size_t n, maxsize;
SerialUSBDriver *sdup = chQGetLink(qp);
+ /* If the USB driver is not in the appropriate state then transactions
+ must not be started.*/
+ if (usbGetDriverStateI(sdup->config->usbp) != USB_ACTIVE)
+ return;
+
/* If there is in the queue enough space to hold at least one packet and
a transaction is not yet started then a new transaction is started for
the available space.*/
@@ -145,6 +150,11 @@ static void onotify(GenericQueue *qp) { size_t n;
SerialUSBDriver *sdup = chQGetLink(qp);
+ /* If the USB driver is not in the appropriate state then transactions
+ must not be started.*/
+ if (usbGetDriverStateI(sdup->config->usbp) != USB_ACTIVE)
+ return;
+
/* If there is not an ongoing transaction and the output queue contains
data then a new transaction is started.*/
if (!usbGetTransmitStatusI(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP) &&
@@ -239,6 +249,22 @@ void sduStop(SerialUSBDriver *sdup) { }
/**
+ * @brief USB device configured handler.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ *
+ * @iclass
+ */
+void sduConfigureHookI(USBDriver *usbp) {
+ SerialUSBDriver *sdup = usbp->param;
+
+ sdup->flags = CHN_NO_ERROR;
+ chIQResetI(&sdup->iqueue);
+ chOQResetI(&sdup->oqueue);
+ chnAddFlagsI(sdup, CHN_CONNECTED);
+}
+
+/**
* @brief Default requests hook.
* @details Applications wanting to use the Serial over USB driver can use
* this function as requests hook in the USB configuration.
|