diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-08-17 12:40:48 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-08-17 12:40:48 +0000 |
commit | e372aabda9da9309671e058839d668ec38c7e8c1 (patch) | |
tree | 2bc1ca8877673afe588ddd76237b2613e1f0a0b8 /os/hal/src/serial_usb.c | |
parent | 0969ab51e5b002d49b0805556e9ff8365d7fa89a (diff) | |
download | ChibiOS-e372aabda9da9309671e058839d668ec38c7e8c1.tar.gz ChibiOS-e372aabda9da9309671e058839d668ec38c7e8c1.tar.bz2 ChibiOS-e372aabda9da9309671e058839d668ec38c7e8c1.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4575 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/serial_usb.c')
-rw-r--r-- | os/hal/src/serial_usb.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c index fc082b56b..f05c341fc 100644 --- a/os/hal/src/serial_usb.c +++ b/os/hal/src/serial_usb.c @@ -223,7 +223,6 @@ void sduStart(SerialUSBDriver *sdup, const SerialUSBConfig *config) { config->usbp->param = sdup;
sdup->state = SDU_READY;
chSysUnlock();
- usbStart(config->usbp, &config->usb_config);
}
/**
@@ -245,7 +244,6 @@ void sduStop(SerialUSBDriver *sdup) { "invalid state");
sdup->state = SDU_STOP;
chSysUnlock();
- usbStop(sdup->config->usbp);
}
/**
@@ -322,12 +320,23 @@ void sduDataTransmitted(USBDriver *usbp, usbep_t ep) { so it is safe to transmit without a check.*/
chSysUnlockFromIsr();
- usbPrepareQueuedTransmit(usbp,
- USB_CDC_DATA_REQUEST_EP,
- &sdup->oqueue, n);
+ usbPrepareQueuedTransmit(usbp, ep, &sdup->oqueue, n);
+
+ chSysLockFromIsr();
+ usbStartTransmitI(usbp, ep);
+ }
+ else if (!(usbp->epc[ep]->in_state->txsize &
+ (usbp->epc[ep]->in_maxsize - 1))) {
+ /* Transmit zero sized packet in case the last one has maximum allowed
+ size. Otherwise the recipient may expect more data coming soon and
+ not return buffered data to app. See section 5.8.3 Bulk Transfer
+ Packet Size Constraints of the USB Specification document.*/
+ chSysUnlockFromIsr();
+
+ usbPrepareQueuedTransmit(usbp, ep, &sdup->oqueue, 0);
chSysLockFromIsr();
- usbStartTransmitI(usbp, USB_CDC_DATA_REQUEST_EP);
+ usbStartTransmitI(usbp, ep);
}
chSysUnlockFromIsr();
|