From 376236949bddfab48aa5a633bf707b7c418ab1e4 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 11 Jun 2011 14:17:44 -0300 Subject: [PATCH] atusb/fw/usb/: we were busy-looping on TXINI. Mask the interrupt when idle. - usb/usb.h (usb_ep_change), usb/atu2.c (usb_ep_change): new function called by the USB stack to notify the hardware-specific driver of an endpoint state change (EP_TX or EP_RX) - usb/usb.c (usb_io): call usb_ep_change - usb/atu2.c (handle_ep): mask TXINI if we have nothing to send --- atusb/fw/usb/atu2.c | 11 +++++++++++ atusb/fw/usb/usb.c | 1 + atusb/fw/usb/usb.h | 1 + 3 files changed, 13 insertions(+) diff --git a/atusb/fw/usb/atu2.c b/atusb/fw/usb/atu2.c index abb6de8..d587983 100644 --- a/atusb/fw/usb/atu2.c +++ b/atusb/fw/usb/atu2.c @@ -70,6 +70,15 @@ int set_addr(uint8_t addr) } +void usb_ep_change(struct ep_descr *ep) +{ + if (ep->state == EP_TX) { + UENUM = ep-eps; + UEIENX |= 1 << TXINE; + } +} + + static int ep_setup(void) { struct setup_request setup; @@ -157,6 +166,8 @@ static void handle_ep(int n) UEINTX = ~(1 << TXINI); if (ep->state == EP_IDLE && ep->callback) ep->callback(ep->user); + } else { + UEIENX &= ~(1 << TXINE); } } return; diff --git a/atusb/fw/usb/usb.c b/atusb/fw/usb/usb.c index 8239735..afed4c6 100644 --- a/atusb/fw/usb/usb.c +++ b/atusb/fw/usb/usb.c @@ -51,6 +51,7 @@ void usb_io(struct ep_descr *ep, enum ep_state state, uint8_t *buf, ep->end = buf+size; ep->callback = callback; ep->user = user; + usb_ep_change(ep); } diff --git a/atusb/fw/usb/usb.h b/atusb/fw/usb/usb.h index f6e7655..f508091 100644 --- a/atusb/fw/usb/usb.h +++ b/atusb/fw/usb/usb.h @@ -150,6 +150,7 @@ void usb_io(struct ep_descr *ep, enum ep_state state, uint8_t *buf, int handle_setup(const struct setup_request *setup); int set_addr(uint8_t addr); +void usb_ep_change(struct ep_descr *ep); void usb_reset(void); void usb_init(void);