callback fix

This commit is contained in:
Olaf Rempel 2008-03-04 00:42:28 +01:00
parent 0be9113381
commit 2a57bfea62
1 changed files with 7 additions and 11 deletions

View File

@ -472,6 +472,8 @@ static void udp_handle_ep(uint32_t ep)
ep_handle_ctrlrequest(&req); ep_handle_ctrlrequest(&req);
} }
void (* transfer_cb)(void) = NULL;
/* transmit complete? */ /* transmit complete? */
if (*csr & AT91C_UDP_TXCOMP) { if (*csr & AT91C_UDP_TXCOMP) {
struct ep_ctx *ctx = &ep_ctx[ep]; struct ep_ctx *ctx = &ep_ctx[ep];
@ -497,9 +499,7 @@ static void udp_handle_ep(uint32_t ep)
/* transfer complete, execute callback */ /* transfer complete, execute callback */
} else { } else {
ctx->flags &= ~CTX_IN; ctx->flags &= ~CTX_IN;
transfer_cb = transfer->complete_cb;
if (transfer->complete_cb)
transfer->complete_cb();
} }
} }
@ -520,8 +520,6 @@ static void udp_handle_ep(uint32_t ep)
ctx->transfer->curpos = 0; ctx->transfer->curpos = 0;
} }
void *exec_cb = NULL;
if (ctx->flags & CTX_FIFO) { if (ctx->flags & CTX_FIFO) {
fifo_rxudp(ctx->fifo, ep, len); fifo_rxudp(ctx->fifo, ep, len);
@ -538,9 +536,7 @@ static void udp_handle_ep(uint32_t ep)
/* test again */ /* test again */
if (transfer->length == transfer->curpos) { if (transfer->length == transfer->curpos) {
ctx->flags &= ~CTX_OUT; ctx->flags &= ~CTX_OUT;
transfer_cb = transfer->complete_cb;
/* exec callback after rxbank ack */
exec_cb = transfer->complete_cb;
} }
} }
@ -558,10 +554,10 @@ static void udp_handle_ep(uint32_t ep)
ctx->flags = (ctx->flags & ~CTX_RXBANK1) | CTX_RXBANK0; ctx->flags = (ctx->flags & ~CTX_RXBANK1) | CTX_RXBANK0;
} }
if (exec_cb)
ctx->transfer->complete_cb();
} }
if (transfer_cb)
transfer_cb();
} }
static void udp_isr(void) static void udp_isr(void)