From 013c3ac2f802784553e6f05c416955c571ba3590 Mon Sep 17 00:00:00 2001 From: dak664 Date: Wed, 22 Dec 2010 17:09:03 +0000 Subject: [PATCH] Remove contitional on clock updating, it should always be done after a sleep! --- cpu/avr/dev/clock-avr.h | 2 ++ cpu/avr/dev/clock.c | 12 ++++++------ .../avr-raven/apps/raven-lcd-interface/raven-lcd.c | 9 +++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cpu/avr/dev/clock-avr.h b/cpu/avr/dev/clock-avr.h index 02505919a..9cf38d09e 100644 --- a/cpu/avr/dev/clock-avr.h +++ b/cpu/avr/dev/clock-avr.h @@ -41,6 +41,8 @@ The Raven has a 32768Hz watch crystal that can be used to clock the timer while the 1284p is sleeping. The Jackdaw has pads for a crystal. The crystal can be used to clock the 8 bit timer2. + The 1284p routine also uses TIMER2 to sleep a variable number of seconds. + It restores the values here after a wake. */ #if AVR_CONF_USE32KCRYSTAL #define AVR_OUTPUT_COMPARE_INT TIMER2_COMPA_vect diff --git a/cpu/avr/dev/clock.c b/cpu/avr/dev/clock.c index 03243d761..0c1b2637a 100644 --- a/cpu/avr/dev/clock.c +++ b/cpu/avr/dev/clock.c @@ -31,19 +31,19 @@ extern uint8_t RF230_receive_on; For longer intervals a 32 bit global is incremented every second. clock-avr.h contains the specific setup code for each mcu. - - The 1284p can use TIMER2 with external 32768 Hz clock at 125 ticks/sec. - The 1284p routine also uses TIMER2 to sleep a variable number of seconds. - It calls this routine to adjust the clock after a sleep. + */ -#if AVR_CONF_USE32KCRYSTAL +/*---------------------------------------------------------------------------*/ +/* This routine can be called to add seconds to the clock after a sleep + * of an integral number of seconds. + * TODO:keep separate track of elapsed time, cpu ontime, and radioontime + */ void clock_adjust_seconds(uint8_t howmany) { seconds += howmany; #if RADIOSTATS if (RF230_receive_on) radioontime += howmany; #endif } -#endif /*---------------------------------------------------------------------------*/ //SIGNAL(SIG_OUTPUT_COMPARE0) ISR(AVR_OUTPUT_COMPARE_INT) diff --git a/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c b/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c index fd392e24a..e31943345 100644 --- a/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c +++ b/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c @@ -28,7 +28,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: raven-lcd.c,v 1.10 2010/12/22 16:50:31 dak664 Exp $ + * $Id: raven-lcd.c,v 1.11 2010/12/22 17:09:03 dak664 Exp $ */ /** @@ -163,10 +163,12 @@ char serial_char_received; /* Sleep for howlong seconds, or until UART interrupt if howlong==0. * Uses TIMER2 with external 32768 Hz crystal to sleep in 1 second multiples. * TIMER2 may have already been set up for 125 ticks/second in clock.c - * If so the clock is adjusted to reflect the sleep time + * * Until someone figures out how to get UART to wake from powerdown, * a three second powersave cycle is used with exit based on any character received. + + * The system clock is adjusted to reflect the sleep time. */ void micro_sleep(uint8_t howlong) @@ -209,8 +211,7 @@ void micro_sleep(uint8_t howlong) serial_char_received=0; // Set when chars received by UART sleep_mode(); // Sleep -/* Adjust clock.c for the time sleeping */ -/* TODO:keep track of realtime, ontime, and radioontime */ + /* Adjust clock.c for the time spent sleeping */ extern void clock_adjust_seconds(uint8_t howmany); clock_adjust_seconds(howlong);