aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-11 19:21:25 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-11 19:21:25 +0000
commitaed1b78c87e45112a1e84baa502a0057199dae1c (patch)
treeeb3c1094a210c62d09a438371195f5be3815d0bf /os/hal
parentf183c0aa6df9bbf16b9fb594bf8142adfc1e5d1b (diff)
downloadChibiOS-aed1b78c87e45112a1e84baa502a0057199dae1c.tar.gz
ChibiOS-aed1b78c87e45112a1e84baa502a0057199dae1c.tar.bz2
ChibiOS-aed1b78c87e45112a1e84baa502a0057199dae1c.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4268 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/platforms/STM32/OTGv1/usb_lld.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c
index 0f927cd85..fbc95b405 100644
--- a/os/hal/platforms/STM32/OTGv1/usb_lld.c
+++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c
@@ -300,14 +300,44 @@ static void otg_fifo_read_to_buffer(uint8_t *buf, size_t n, size_t max) {
* @notapi
*/
static void otg_fifo_read_to_queue(InputQueue *iqp, size_t n) {
- size_t nw;
+ size_t nw, nb;
volatile uint32_t *fifop;
fifop = OTG_FIFO(0);
+ nb = n;
nw = (n + 3) / 4;
do {
uint32_t dw = *fifop;
- } while (--n > 0);
+ *iqp->q_wrptr++ = (uint8_t)dw;
+ if (iqp->q_wrptr >= iqp->q_top)
+ iqp->q_wrptr = iqp->q_buffer;
+ if (--nb > 0) {
+ *iqp->q_wrptr++ = (uint8_t)(dw >> 8);
+ if (iqp->q_wrptr >= iqp->q_top)
+ iqp->q_wrptr = iqp->q_buffer;
+ }
+ else if (--nb > 0) {
+ *iqp->q_wrptr++ = (uint8_t)(dw >> 16);
+ if (iqp->q_wrptr >= iqp->q_top)
+ iqp->q_wrptr = iqp->q_buffer;
+ }
+ else if (--nb > 0) {
+ *iqp->q_wrptr++ = (uint8_t)(dw >> 24);
+ if (iqp->q_wrptr >= iqp->q_top)
+ iqp->q_wrptr = iqp->q_buffer;
+ }
+ --nb;
+ } while (--nw > 0);
+
+ /* Updating queue.*/
+ chSysLockFromIsr();
+ iqp->q_wrptr += n;
+ if (iqp->q_wrptr >= iqp->q_top)
+ iqp->q_wrptr = iqp->q_buffer;
+ iqp->q_counter += n;
+ while (notempty(&iqp->q_waiting))
+ chSchReadyI(fifo_remove(&iqp->q_waiting))->p_u.rdymsg = Q_OK;
+ chSysUnlockFromIsr();
}
/**
@@ -334,6 +364,8 @@ static void otg_rxfifo_handler(USBDriver *usbp) {
ep = (sts & GRXSTSP_EPNUM_MASK) >> GRXSTSP_EPNUM_OFF;
if (usbp->epc[ep]->out_state->rxqueued) {
/* Queue associated.*/
+ otg_fifo_read_to_queue(usbp->epc[ep]->out_state->mode.queue.rxqueue,
+ cnt);
}
else {
otg_fifo_read_to_buffer(usbp->epc[ep]->out_state->mode.linear.rxbuf,