From 7ce8d3920a978549831368bbec796c16782659be Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 3 Apr 2007 19:05:44 +0000 Subject: [PATCH] Added radio_on() and radio_off() functions --- core/dev/simple-cc2420.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/core/dev/simple-cc2420.c b/core/dev/simple-cc2420.c index b427efe44..6942c8ed2 100644 --- a/core/dev/simple-cc2420.c +++ b/core/dev/simple-cc2420.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: simple-cc2420.c,v 1.4 2007/03/25 17:15:30 adamdunkels Exp $ + * @(#)$Id: simple-cc2420.c,v 1.5 2007/04/03 19:05:44 adamdunkels Exp $ */ /* * This code is almost device independent and should be easy to port. @@ -269,8 +269,9 @@ simple_cc2420_off(void) { u8_t spiStatusByte; - if (receive_on == 0) + if(receive_on == 0) { return; + } receive_on = 0; /* Wait for transmission to end before turning radio off. */ do { @@ -328,7 +329,23 @@ simple_cc2420_set_chan_pan_addr(unsigned channel, /* 11 - 26 */ } /*---------------------------------------------------------------------------*/ static volatile u8_t rx_fifo_remaining_bytes; - +/*---------------------------------------------------------------------------*/ +void +radio_on(void) +{ + simple_cc2420_on(); +} +/*---------------------------------------------------------------------------*/ +void +radio_off(void) +{ + /* Turn the receiver off, but only if we have not recently received + a packet. */ + if(rx_fifo_remaining_bytes == 0) { + simple_cc2420_off(); + } +} +/*---------------------------------------------------------------------------*/ /* * Interrupt either leaves frame intact in FIFO or reads *only* the * MAC header and sets rx_fifo_remaining_bytes.