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
This commit is contained in:
Christi Scarborough 2005-02-05 19:57:19 +00:00
parent c3c26262f4
commit eeed057b8b
3 changed files with 33 additions and 3 deletions

View File

@ -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();

View File

@ -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 */

View File

@ -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 */