diff --git a/tools/include/misctxrx.h b/tools/include/misctxrx.h index 9d258bb..7e531ad 100644 --- a/tools/include/misctxrx.h +++ b/tools/include/misctxrx.h @@ -19,6 +19,14 @@ void flush_interrupts(struct atrf_dsc *dsc); + +/* + * timeout_ms: + * > 0: time out after that many milliseconds + * == 0: wait forever + * < 0: wait forever and eliminate poll delays (for high-speed capture) + */ + uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for, uint8_t ignore, int timeout_ms); diff --git a/tools/lib/atben.c b/tools/lib/atben.c index 4230633..22abecc 100644 --- a/tools/lib/atben.c +++ b/tools/lib/atben.c @@ -1,8 +1,8 @@ /* * lib/atben.c - ATRF access functions library (Ben 8:10 card version) * - * Written 2010-2011 by Werner Almesberger - * Copyright 2010-2011 Werner Almesberger + * Written 2010-2011, 2013 by Werner Almesberger + * Copyright 2010-2011, 2013 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -439,10 +439,10 @@ int atben_interrupt_wait(void *handle, int timeout_ms) int timedout = 0; uint8_t irq; - if (timeout_ms) + if (timeout_ms > 0) timeout_start(&to, timeout_ms); while (1) { - if (timeout_ms) + if (timeout_ms > 0) timedout = timeout_reached(&to); if (atben_interrupt(handle)) { irq = atben_reg_read(handle, REG_IRQ_STATUS); @@ -452,7 +452,8 @@ int atben_interrupt_wait(void *handle, int timeout_ms) } if (timedout) return 0; - usleep(1000); + if (timeout_ms >= 0) + usleep(1000); } return 0; diff --git a/tools/lib/atusb-common.c b/tools/lib/atusb-common.c index d43a168..2d9b15a 100644 --- a/tools/lib/atusb-common.c +++ b/tools/lib/atusb-common.c @@ -221,7 +221,7 @@ int atusb_interrupt_wait(void *handle, int timeout_ms) return 0; res = usb_bulk_read(dsc->dev, 1, - (char *) &buf, sizeof(buf), timeout_ms); + (char *) &buf, sizeof(buf), timeout_ms < 0 : 0 : timeout_ms); if (res == -ETIMEDOUT) return 0; if (res < 0) { diff --git a/tools/lib/misctxrx.c b/tools/lib/misctxrx.c index 2b46e9a..820ad00 100644 --- a/tools/lib/misctxrx.c +++ b/tools/lib/misctxrx.c @@ -62,14 +62,14 @@ uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for, sigint = 0; old_sig = signal(SIGINT, die); - if (timeout_ms) { + if (timeout_ms > 0) { if (timeout_ms < MIN_TIMEOUT_MS) timeout_ms = MIN_TIMEOUT_MS; timeout_start(&to, timeout_ms); } while (!sigint && !timedout) { while (!sigint && !timedout) { - if (timeout_ms) { + if (timeout_ms > 0) { ms = timeout_left_ms(&to); if (ms <= 0) { timedout = 1; @@ -78,7 +78,8 @@ uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for, } else { ms = 0; } - irq = atrf_interrupt_wait(dsc, ms); + irq = atrf_interrupt_wait(dsc, + timeout_ms < 0 ? -1 : ms); if (irq) break; }