From 27fc0a0e2c83942d6b88a093d6b2d1f90386dfec Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 23 Jun 2011 09:41:40 -0300 Subject: [PATCH] atusb/fw/: aggregate interrupts while waiting - board_app.c (INT0_vect): always read IRQ_STATUS, even if an interrupt is already enqueued - board_app.c (INT0_vect): if an interrupt is enqueued, accumulate the interrupts signaled since - board_app.c (irqs_more): when a pending transfer completes, send interrupts accumulated since (if any) --- atusb/fw/board_app.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/atusb/fw/board_app.c b/atusb/fw/board_app.c index 17859f8..4a83e7e 100644 --- a/atusb/fw/board_app.c +++ b/atusb/fw/board_app.c @@ -144,17 +144,29 @@ void gpio_cleanup(void) } +static uint8_t irqs = 0; + + +static void irqs_more(void *user) +{ + static uint8_t buf; + + if (!irqs) + return; + buf = irqs; + usb_send(&eps[1], &buf, 1, irqs_more, NULL); + irqs = 0; +} + + ISR(INT0_vect) { - static uint8_t irq; - - if (eps[1].state != EP_IDLE) - return; spi_begin(); spi_send(AT86RF230_REG_READ | REG_IRQ_STATUS); - irq = spi_recv(); + irqs |= spi_recv(); spi_end(); - usb_send(&eps[1], &irq, 1, NULL, NULL); + if (eps[1].state == EP_IDLE) + irqs_more(NULL); }