summaryrefslogtreecommitdiff
path: root/src/cc1111/ao_radio.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-28 23:02:12 -0700
committerKeith Packard <keithp@keithp.com>2013-05-07 20:07:52 -0700
commitf677a83348a9568679240ee9d731ab454f289831 (patch)
tree8a8bd51ae7cce01fac472fb33a653f0489e74f0d /src/cc1111/ao_radio.c
parent0488cd9cffc837e99490a0761216bbc5847ff400 (diff)
altos: Provide timeout value to ao_radio_recv
Instead of using ao_alarm around calls to ao_radio_recv, provide an explicit timeout value as needed by radio functions with more complicated system interaction than the cc1111. The timeout is 8 bits of clock ticks. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/cc1111/ao_radio.c')
-rw-r--r--src/cc1111/ao_radio.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cc1111/ao_radio.c b/src/cc1111/ao_radio.c
index cb2c2fdd..07b0d1b5 100644
--- a/src/cc1111/ao_radio.c
+++ b/src/cc1111/ao_radio.c
@@ -322,7 +322,7 @@ ao_radio_send(__xdata void *packet, uint8_t size) __reentrant
}
uint8_t
-ao_radio_recv(__xdata void *packet, uint8_t size) __reentrant
+ao_radio_recv(__xdata void *packet, uint8_t size, uint8_t timeout) __reentrant
{
ao_radio_abort = 0;
ao_radio_get(size - 2);
@@ -342,9 +342,13 @@ ao_radio_recv(__xdata void *packet, uint8_t size) __reentrant
/* Wait for DMA to be done, for the radio receive process to
* get aborted or for a receive timeout to fire
*/
+ if (timeout)
+ ao_alarm(timeout);
__critical while (!ao_radio_dma_done && !ao_radio_abort)
if (ao_sleep(&ao_radio_dma_done))
break;
+ if (timeout)
+ ao_clear_alarm();
/* If recv was aborted, clean up by stopping the DMA engine
* and idling the radio