diff options
author | Keith Packard <keithp@keithp.com> | 2011-05-20 01:40:27 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-05-20 01:42:14 -0700 |
commit | b5331e625843a50f215660446fb2378d5a7bbe76 (patch) | |
tree | d0e487efa09701d30557356c7bb0c3d912cc967b | |
parent | d67df9a6dc76ba52f32fa4c0b141825b97a2fbc8 (diff) |
src-avr: Attempt to leave IN interrupts disabled most of the time
-rw-r--r-- | src-avr/ao_usb_avr.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src-avr/ao_usb_avr.c b/src-avr/ao_usb_avr.c index bc6d1d38..18d5aa75 100644 --- a/src-avr/ao_usb_avr.c +++ b/src-avr/ao_usb_avr.c @@ -105,7 +105,9 @@ ao_usb_set_configuration(void) (1 << EPBK0) | /* Double bank */ (1 << ALLOC)); /* Allocate */ +#if 0 UEIENX = ((1 << TXINE)); /* Enable IN complete interrupt */ +#endif ao_usb_dump_ep(AO_USB_IN_EP); @@ -419,15 +421,18 @@ ao_usb_in_wait(void) if (UEINTX & (1 << RWAL)) break; + cli(); /* Wait for an IN buffer to be ready */ for (;;) { UENUM = AO_USB_IN_EP; if ((UEINTX & (1 << TXINI))) break; + UEIENX = (1 << TXINE); ao_sleep(&ao_usb_in_flushed); } /* Ack the interrupt */ UEINTX &= ~(1 << TXINI); + sei(); } } @@ -533,21 +538,35 @@ ao_usb_getchar(void) __critical return c; } +uint16_t control_count; +uint16_t in_count; +uint16_t out_count; + /* Endpoint interrupt */ ISR(USB_COM_vect) { + uint8_t old_num = UENUM; uint8_t i = UEINT; #ifdef AO_LED_RED ao_led_toggle(AO_LED_RED); #endif UEINT = 0; - if (i & (1 << 0)) + if (i & (1 << 0)) { ao_wakeup(&ao_usb_task); - if (i & (1 << AO_USB_IN_EP)) + ++control_count; + } + if (i & (1 << AO_USB_IN_EP)) { + UENUM = AO_USB_IN_EP; + UEIENX = 0; ao_wakeup(&ao_usb_in_flushed); - if (i & (1 << AO_USB_OUT_EP)) + in_count++; + } + if (i & (1 << AO_USB_OUT_EP)) { ao_wakeup(&ao_stdin_ready); + ++out_count; + } + UENUM = old_num; } #if AVR_VCC_5V |