From 55354c7f915d667b729ad5aaa410ccc1c78582e6 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 20 Jun 2011 19:03:03 -0300 Subject: [PATCH] tools/lib/atben.c: added support for interrupt_wait (polled) - atben.c (atben_interrupt_wait): loop until either the timeout has been reached or an interrupt has occurred - atben.c (atben_driver): added atben_interrupt_wait --- tools/lib/atben.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/lib/atben.c b/tools/lib/atben.c index f11bb74..ce7bd34 100644 --- a/tools/lib/atben.c +++ b/tools/lib/atben.c @@ -19,6 +19,7 @@ #include #include "at86rf230.h" +#include "timeout.h" #include "driver.h" @@ -383,6 +384,25 @@ static int atben_interrupt(void *handle) } +int atben_interrupt_wait(void *handle, int timeout_ms) +{ + struct timeout to; + int timedout; + + timeout_start(&to, timeout_ms); + while (1) { + timedout = timeout_reached(&to); + if (atben_interrupt(handle)) + return atben_reg_read(handle, REG_IRQ_STATUS); + if (timedout) + return 0; + usleep(1000); + } + + return 0; +} + + /* ----- Driver-specific hacks --------------------------------------------- */ @@ -412,4 +432,5 @@ struct atrf_driver atben_driver = { .sram_write = atben_sram_write, .sram_read = atben_sram_read, .interrupt = atben_interrupt, + .interrupt_wait = atben_interrupt_wait, };