From 21e5f576630b40574167acba2967a5030e34957b Mon Sep 17 00:00:00 2001 From: funman Date: Thu, 17 Jun 2010 05:28:38 +0000 Subject: [PATCH] AMSv2 RTC: no need to write to RTC_WAKEUP register MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The wakeup alarm will be disabled when powering off anyway OF database refresh of µSD now only happens if the wakeup was explicitely enabled There still seems to be a freeze problem when powering off (sometimes) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26875 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/rtc/rtc_as3514.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/firmware/drivers/rtc/rtc_as3514.c b/firmware/drivers/rtc/rtc_as3514.c index 837806d2e..f2716e52e 100644 --- a/firmware/drivers/rtc/rtc_as3514.c +++ b/firmware/drivers/rtc/rtc_as3514.c @@ -122,36 +122,21 @@ bool rtc_check_alarm_started(bool release_alarm) { (void) release_alarm; - /* was it an alarm that triggered power on ? */ - bool alarm_start = false; - /* 3 first reads give the 23 bits counter and enable bit */ ascodec_read(AS3543_WAKEUP); /* bits 7:0 */ ascodec_read(AS3543_WAKEUP); /* bits 15:8 */ - if(ascodec_read(AS3543_WAKEUP) & (1<<7)) /* enable bit */ - { -#if 0 /* we could have a persistent setting for wake-up time */ - alarm_enabled = true; -#endif - - /* subsequent reads give the 16 bytes static SRAM */ - wakeup_h = ascodec_read(AS3543_WAKEUP); - wakeup_m = ascodec_read(AS3543_WAKEUP); - - struct tm tm; - rtc_read_datetime(&tm); + if(!(ascodec_read(AS3543_WAKEUP) & (1<<7))) /* enable bit */ + return false; - /* do we wake up at the programmed time, or for another reason ? */ - if(wakeup_h == tm.tm_hour && wakeup_m == tm.tm_min) - alarm_start = true; - } + /* subsequent reads give the 16 bytes static SRAM */ + wakeup_h = ascodec_read(AS3543_WAKEUP); + wakeup_m = ascodec_read(AS3543_WAKEUP); - /* disable alarm */ - ascodec_write(AS3543_WAKEUP, 0); /* bits 7:0 */ - ascodec_write(AS3543_WAKEUP, 0); /* bits 15:8 */ - ascodec_write(AS3543_WAKEUP, 0); /* bits 22:16 + enable bit */ + struct tm tm; + rtc_read_datetime(&tm); - return alarm_start; + /* were we powered up at the programmed time ? */ + return wakeup_h == tm.tm_hour && wakeup_m == tm.tm_min; } bool rtc_check_alarm_flag(void) -- 2.11.4.GIT