summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-05-05 12:53:03 +0000
committerNils Wallménius <nils@rockbox.org>2008-05-05 12:53:03 +0000
commit680bf86fce3f717dbda0d5235f49fcb8aa7aebc7 (patch)
treedfe5a883bef17841ec0d316c35187055b30a72ee /firmware
parent90a4a434308aa4c4303c09ee36812dcf7c43df6a (diff)
Oops, forgot one file
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17377 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/rtc/rtc_mc13783.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/firmware/drivers/rtc/rtc_mc13783.c b/firmware/drivers/rtc/rtc_mc13783.c
index 2494e5ece5..3031e9971e 100644
--- a/firmware/drivers/rtc/rtc_mc13783.c
+++ b/firmware/drivers/rtc/rtc_mc13783.c
@@ -64,6 +64,14 @@ enum rtc_registers_indexes
RTC_NUM_REGS,
};
+/* was it an alarm that triggered power on ? */
+static bool alarm_start;
+
+void mc1378_alarm_start(void)
+{
+ alarm_start = true;
+}
+
static const unsigned char rtc_registers[RTC_NUM_REGS] =
{
[RTC_REG_TIME] = MC13783_RTC_TIME,
@@ -236,3 +244,47 @@ int rtc_write_datetime(unsigned char* buf)
return 0;
}
+
+bool rtc_check_alarm_flag(void)
+{
+ /* We don't need to do anything special if it has already fired */
+ return false;
+}
+
+bool rtc_enable_alarm(bool enable)
+{
+ if (enable)
+ mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_TODA);
+ else
+ mc13783_set(MC13783_INTERRUPT_MASK1, MC13783_TODA);
+
+ return false;
+}
+
+bool rtc_check_alarm_started(bool release_alarm)
+{
+ bool rc = alarm_start;
+ alarm_start &= ~release_alarm;
+
+ return rc;
+}
+
+void rtc_set_alarm(int h, int m)
+{
+ int day = mc13783_read(MC13783_RTC_DAY);
+ int tod = mc13783_read(MC13783_RTC_TIME);
+
+ if (h*3600 + m*60 < tod)
+ day++;
+
+ mc13783_write(MC13783_RTC_DAY_ALARM, day);
+ mc13783_write(MC13783_RTC_ALARM, h*3600 + m*60);
+}
+
+void rtc_get_alarm(int *h, int *m)
+{
+ int tod = mc13783_read(MC13783_RTC_ALARM);
+ *h = tod / 3600;
+ *m = tod % 3600 / 60;
+}
+