From 68c686957b1b62671d727116e5c167cd8f080148 Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Wed, 12 Nov 2008 03:52:33 +0000 Subject: Make the wakeup alarm code work (Needs the flashed bootloader) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19093 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/rtc/rtc_s3c2440.c | 45 +++++++++++++++----------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/firmware/drivers/rtc/rtc_s3c2440.c b/firmware/drivers/rtc/rtc_s3c2440.c index 70178efc49..d39b50a2ca 100644 --- a/firmware/drivers/rtc/rtc_s3c2440.c +++ b/firmware/drivers/rtc/rtc_s3c2440.c @@ -57,39 +57,32 @@ int rtc_write_datetime(unsigned char* buf) } #ifdef HAVE_RTC_ALARM -/* This alarm code works in that it at least triggers INT_RTC. I am guessing - * that the OF bootloader for the Gigabeat detects the startup by alarm and shuts down. - * This code is available for use once the OF bootloader is no longer required. - */ - -/* check whether the unit has been started by the RTC alarm function - * This code has not been written/checked for the gigabeat +/* This alarm code works with a flashed bootloader. This will not work with + * the OF bootloader. */ + +/* Check whether the unit has been started by the RTC alarm function */ bool rtc_check_alarm_started(bool release_alarm) { - static bool alarm_state, run_before; - bool rc; - - if (run_before) { - rc = alarm_state; - alarm_state &= ~release_alarm; - } else { - /* This call resets AF, so we store the state for later recall */ - rc = alarm_state = rtc_check_alarm_flag(); - run_before = true; + if (GSTATUS3) + { + GSTATUS3 &= ~release_alarm; + return true; + } + else + { + return false; } - - return rc; } -/* - * I don't think this matters on the gigabeat, it seems designed to shut off the alarm in the - * event one happens while the player is running. This does not cause any problems on the - * gigabeat as the interupt is recieved (if not masked) and ignored. - */ +/* Check to see if the alarm has flaged since the last it was checked */ bool rtc_check_alarm_flag(void) { - return false; + bool ret=SRCPND & 0x40000000; + + SRCPND=RTC_MASK; + + return ret; } /* set alarm time registers to the given time (repeat once per day) */ @@ -114,12 +107,10 @@ bool rtc_enable_alarm(bool enable) if (enable) { RTCALM=0x46; - INTMSK&=~(1<<30); } else { RTCALM=0x00; - INTMSK|=(1<<30); } return false; /* all ok */ -- cgit v1.2.3