src-avr: Reduce control connection interrupts
authorKeith Packard <keithp@keithp.com>
Fri, 20 May 2011 09:47:20 +0000 (02:47 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 20 May 2011 09:47:20 +0000 (02:47 -0700)
Leave these disabled while processing stuff; otherwise we receive a
steady stream of them.

Signed-off-by: Keith Packard <keithp@keithp.com>
src-avr/ao_usb_avr.c

index 47a1487fa01584923b633ee6f565b3684076be4c..74bdea23ef8d5eb630dde4c59d390eaf276672ec 100644 (file)
@@ -48,6 +48,7 @@ static __xdata uint8_t *__xdata ao_usb_ep0_out_data;
 static __xdata uint8_t ao_usb_in_flushed;
 static __xdata uint8_t ao_usb_running;
 static __xdata uint8_t ao_usb_configuration;
+static __xdata uint8_t ueienx_0;
 
 void
 ao_usb_set_address(uint8_t address)
@@ -84,8 +85,8 @@ ao_usb_set_ep0(void)
                   (0 << EPBK0) |                               /* Single bank */
                   (1 << ALLOC));
 
-       UEIENX = ((1 << RXSTPE) |                               /* Enable SETUP interrupt */
-                 (1 << RXOUTE));                               /* Enable OUT interrupt */
+       ueienx_0 = ((1 << RXSTPE) |                             /* Enable SETUP interrupt */
+                   (1 << RXOUTE));                             /* Enable OUT interrupt */
 
 //     ao_usb_dump_ep(0);
        ao_usb_addr_pending = 0;
@@ -164,10 +165,8 @@ ao_usb_ep0_set_in_pending(uint8_t in_pending)
 {
        ao_usb_ep0_in_pending = in_pending;
 
-       if (in_pending) {
-               UENUM = 0;
-               UEIENX = ((1 << RXSTPE) | (1 << RXOUTE) | (1 << TXINE));        /* Enable IN interrupt */
-       }
+       if (in_pending)
+               ueienx_0 = ((1 << RXSTPE) | (1 << RXOUTE) | (1 << TXINE));      /* Enable IN interrupt */
 }
 
 /* Send an IN data packet */
@@ -389,10 +388,12 @@ ao_usb_ep0(void)
                                                UDADDR |= (1 << ADDEN);
                                                ao_usb_addr_pending = 0;
                                        }
-                                       UEIENX = ((1 << RXSTPE) | (1 << RXOUTE));       /* Disable IN interrupt */
+                                       ueienx_0 = ((1 << RXSTPE) | (1 << RXOUTE));     /* Disable IN interrupt */
                                }
                        }
 //                     debug ("usb task sleeping...\n");
+                       UENUM = 0;
+                       UEIENX = ueienx_0;
                        ao_sleep(&ao_usb_task);
                }
                sei();
@@ -556,6 +557,8 @@ ISR(USB_COM_vect)
 #endif
        UEINT = 0;
        if (i & (1 << 0)) {
+               UENUM = 0;
+               UEIENX = 0;
                ao_wakeup(&ao_usb_task);
                ++control_count;
        }