diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-05-20 07:29:52 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-05-20 07:29:52 +0000 |
commit | 3cfb4077fb27e9ab51bc33d67def962ae68f26c7 (patch) | |
tree | ebaee94560e32733f20f654c2c57895d539bbabe /os/hal | |
parent | 6b6790350e7861f2a15b308d84bc052681d1d150 (diff) | |
download | ChibiOS-3cfb4077fb27e9ab51bc33d67def962ae68f26c7.tar.gz ChibiOS-3cfb4077fb27e9ab51bc33d67def962ae68f26c7.tar.bz2 ChibiOS-3cfb4077fb27e9ab51bc33d67def962ae68f26c7.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2982 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/src/serial_usb.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c index bc2c39426..7fecd5f30 100644 --- a/os/hal/src/serial_usb.c +++ b/os/hal/src/serial_usb.c @@ -123,9 +123,12 @@ static void inotify(GenericQueue *qp) { n = usbReadPacketI(sdup->config->usbp, DATA_AVAILABLE_EP,
sdup->iqueue.q_buffer, SERIAL_USB_BUFFERS_SIZE);
if (n != USB_ENDPOINT_BUSY) {
- sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer;
- chSemAddCounterI(&sdup->iqueue.q_sem, n);
chIOAddFlagsI(sdup, IO_INPUT_AVAILABLE);
+ sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer;
+ sdup->iqueue.q_counter = n;
+ if (notempty(&sdup->iqueue.q_waiting))
+ chSchReadyI(fifo_remove(&sdup->iqueue.q_waiting))->p_u.rdymsg = Q_OK;
+ chSchRescheduleS();
}
}
}
@@ -143,9 +146,12 @@ static void onotify(GenericQueue *qp) { w = usbWritePacketI(sdup->config->usbp, DATA_REQUEST_EP,
sdup->oqueue.q_buffer, n);
if (w != USB_ENDPOINT_BUSY) {
- sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer;
- chSemAddCounterI(&sdup->oqueue.q_sem, n);
chIOAddFlagsI(sdup, IO_OUTPUT_EMPTY);
+ sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer;
+ sdup->oqueue.q_counter = n;
+ if (notempty(&sdup->oqueue.q_waiting))
+ chSchReadyI(fifo_remove(&sdup->oqueue.q_waiting))->p_u.rdymsg = Q_OK;
+ chSchRescheduleS();
}
}
@@ -286,9 +292,11 @@ void sduDataTransmitted(USBDriver *usbp, usbep_t ep) { if (n > 0) {
w = usbWritePacketI(usbp, ep, sdup->oqueue.q_buffer, n);
if (w != USB_ENDPOINT_BUSY) {
- sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer;
- chSemAddCounterI(&sdup->oqueue.q_sem, n);
chIOAddFlagsI(sdup, IO_OUTPUT_EMPTY);
+ sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer;
+ sdup->oqueue.q_counter = n;
+ if (notempty(&sdup->oqueue.q_waiting))
+ chSchReadyI(fifo_remove(&sdup->oqueue.q_waiting))->p_u.rdymsg = Q_OK;
}
}
chSysUnlockFromIsr();
@@ -314,9 +322,11 @@ void sduDataReceived(USBDriver *usbp, usbep_t ep) { n = usbReadPacketI(usbp, ep, sdup->iqueue.q_buffer,
SERIAL_USB_BUFFERS_SIZE);
if (n != USB_ENDPOINT_BUSY) {
- sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer;
- chSemAddCounterI(&sdup->iqueue.q_sem, n);
chIOAddFlagsI(sdup, IO_INPUT_AVAILABLE);
+ sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer;
+ sdup->iqueue.q_counter = n;
+ if (notempty(&sdup->iqueue.q_waiting))
+ chSchReadyI(fifo_remove(&sdup->iqueue.q_waiting))->p_u.rdymsg = Q_OK;
}
}
chSysUnlockFromIsr();
|