From 620709a20a3396e776c8caf08c65a059bfb80df3 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 20 Jun 2011 17:21:40 -0300 Subject: [PATCH] libatrf: new function to reliably flush interrupts - misctxrx.h (flush_interrupts), misctxrx.c: reliably flush interrupts on all drivers (with the exception of atnet talking to an atusb) --- tools/include/misctxrx.h | 1 + tools/lib/misctxrx.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/tools/include/misctxrx.h b/tools/include/misctxrx.h index 95c6bff..7a9eff4 100644 --- a/tools/include/misctxrx.h +++ b/tools/include/misctxrx.h @@ -18,6 +18,7 @@ #include "atrf.h" +void flush_interrupts(struct atrf_dsc *dsc); uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for, uint8_t ignore, int sleep_us, int timeout); diff --git a/tools/lib/misctxrx.c b/tools/lib/misctxrx.c index 30184be..4f6460c 100644 --- a/tools/lib/misctxrx.c +++ b/tools/lib/misctxrx.c @@ -35,6 +35,17 @@ static void die(int sig) } +void flush_interrupts(struct atrf_dsc *dsc) +{ + /* + * If the driver doesn't support atrf_interrupt_wait, we use + * atrf_reg_read. + */ + if (atrf_interrupt_wait(dsc, 1) < 0) + atrf_reg_read(dsc, REG_IRQ_STATUS); +} + + uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for, uint8_t ignore, int sleep_us, int timeout) {