summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristi Scarborough <christi@coraline.org>2005-02-05 19:57:19 +0000
committerChristi Scarborough <christi@coraline.org>2005-02-05 19:57:19 +0000
commiteeed057b8b1478cd863d36089b4a21dc4a95d6aa (patch)
tree610e884315e2efa0eeff9a9ed5501dd4a5cbbdb6
parentc3c26262f45548ad9e920d0d635a745d6829227b (diff)
downloadrockbox-eeed057b8b1478cd863d36089b4a21dc4a95d6aa.zip
rockbox-eeed057b8b1478cd863d36089b4a21dc4a95d6aa.tar.gz
rockbox-eeed057b8b1478cd863d36089b4a21dc4a95d6aa.tar.bz2
rockbox-eeed057b8b1478cd863d36089b4a21dc4a95d6aa.tar.xz
Bugfix: Resume does not prompt if the unit has woken due to the RTC alarm
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5799 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/tree.c6
-rw-r--r--firmware/drivers/rtc.c29
-rw-r--r--firmware/export/rtc.h1
3 files changed, 33 insertions, 3 deletions
diff --git a/apps/tree.c b/apps/tree.c
index d59101f..02899f8 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -60,6 +60,7 @@
#include "filetree.h"
#include "dbtree.h"
#include "recorder/recording.h"
+#include "rtc.h"
#ifdef HAVE_LCD_BITMAP
#include "widgets.h"
@@ -434,8 +435,11 @@ static bool ask_resume(bool ask_once)
return false;
}
+ if ( rtc_check_alarm_started(true) )
+ return true;
+
/* always resume? */
- if ( global_settings.resume == RESUME_ON )
+ if ( global_settings.resume == RESUME_ON)
return true;
lcd_clear_display();
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc.c
index d5b6c2f..5f60c23 100644
--- a/firmware/drivers/rtc.c
+++ b/firmware/drivers/rtc.c
@@ -28,7 +28,13 @@
void rtc_init(void)
{
- unsigned char data;
+ unsigned char data;
+
+#ifdef HAVE_ALARM_MOD
+ /* Check + save alarm bit first, since something in rtc_init resets AF */
+ rtc_check_alarm_started(false);
+#endif
+
rtc_write(0x13, 0x10); /* 32 kHz square wave */
/* Clear the Stop bit if it is set */
@@ -67,6 +73,25 @@ void rtc_init(void)
#ifdef HAVE_ALARM_MOD
+/* check whether the unit has been started by the RTC alarm function */
+/* (check for AF, which => started using wakeup alarm) */
+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_read(0x0f) & 0x40) != 0);
+ run_before = true;
+ }
+
+ return rc;
+}
+
/* set alarm time registers to the given time (repeat once per day) */
void rtc_set_alarm(int h, int m)
{
@@ -114,7 +139,7 @@ bool rtc_enable_alarm(bool enable)
data &= 0x5f; /* turn bit d7=AFE and d5=ABE off */
rtc_write(0x0a, data);
- /* check if alarm flag AF is off (as it sould be) */
+ /* check if alarm flag AF is off (as it should be) */
if ((rtc_read(0x0f) & 0x40) != 0) /* on */
{
data &= 0x5f; /* turn bit d7=AFE and d5=ABE off */
diff --git a/firmware/export/rtc.h b/firmware/export/rtc.h
index fd1cd50..7c2bd94 100644
--- a/firmware/export/rtc.h
+++ b/firmware/export/rtc.h
@@ -31,6 +31,7 @@ int rtc_write(unsigned char address, unsigned char value);
void rtc_set_alarm(int h, int m);
void rtc_get_alarm(int *h, int *m);
bool rtc_enable_alarm(bool enable);
+bool rtc_check_alarm_started(bool release_alarm);
#endif /* HAVE_ALARM_MOD */
#endif /* HAVE_RTC */