From 238c6c3c0ac40dcdef82c430fae52cad34ed5a10 Mon Sep 17 00:00:00 2001 From: laforge Date: Fri, 22 Sep 2006 21:21:28 +0000 Subject: fix completely broken logic of processing pending outbound packets. We now do all the req_ctx state changes from within pcd_handler.c and only expose the refill_ep() functions. It's questionable whether we need to keep calling those functions all the time either. Once kicked off, the tx completion interrupts of the UDC will refill the pipe as long as there is data available. So realistically speaking, we'd only need to trigger tx once (and keep triggering until no EBUSY or other error is signalled anymore). Some form of state machine would be fine for doing this, one that registers a timer with the core OS timer (once we have something equivalent to 'struct timer_list'. git-svn-id: https://svn.openpcd.org:2342/trunk@217 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- firmware/src/os/usb_handler.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'firmware') diff --git a/firmware/src/os/usb_handler.c b/firmware/src/os/usb_handler.c index c3d4cfa..1754805 100644 --- a/firmware/src/os/usb_handler.c +++ b/firmware/src/os/usb_handler.c @@ -79,21 +79,9 @@ static int usb_in(struct req_ctx *rctx) * IN or INTERRUPT endpoint */ void usb_out_process(void) { - struct req_ctx *rctx; - - while (rctx = req_ctx_find_get(0, RCTX_STATE_UDP_EP3_PENDING, - RCTX_STATE_UDP_EP3_BUSY)) { - DEBUGPCRF("EP3_BUSY for ctx %u", req_ctx_num(rctx)); - if (udp_refill_ep(3) < 0) - req_ctx_set_state(rctx, RCTX_STATE_UDP_EP3_PENDING); - } - - while (rctx = req_ctx_find_get(0, RCTX_STATE_UDP_EP2_PENDING, - RCTX_STATE_UDP_EP2_BUSY)) { - DEBUGPCRF("EP2_BUSY for ctx %u", req_ctx_num(rctx)); - if (udp_refill_ep(2) < 0) - req_ctx_set_state(rctx, RCTX_STATE_UDP_EP2_PENDING); - } + /* interrupts are likely to be more urgent than bulk */ + udp_refill_ep(3); + udp_refill_ep(2); } /* process incoming USB packets (OUT pipe) that have already been @@ -104,8 +92,8 @@ void usb_in_process(void) while (rctx = req_ctx_find_get(0, RCTX_STATE_UDP_RCV_DONE, RCTX_STATE_MAIN_PROCESSING)) { - DEBUGPCRF("found used ctx %u: len=%u", - req_ctx_num(rctx), rctx->tot_len); + DEBUGPCRF("found used ctx %u: len=%u", + req_ctx_num(rctx), rctx->tot_len); usb_in(rctx); } udp_unthrottle(); -- cgit v1.2.3