summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2007-04-09 06:27:35 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2007-04-09 06:27:35 +0000
commit84789c6f6dceb47fdfd30f325b1c2cd50e535238 (patch)
tree180531fe06149816cac0412bdc71f665105dd7bb
parent5b7d21f0921023ceac4100fbf46dd23109e4a61a (diff)
downloadrockbox-84789c6f6dceb47fdfd30f325b1c2cd50e535238.tar.gz
rockbox-84789c6f6dceb47fdfd30f325b1c2cd50e535238.zip
RTC alarm for Gigabeat. Will be useful one the OF bootloader is no longer required.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13077 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/rtc/rtc_s3c2440.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/firmware/drivers/rtc/rtc_s3c2440.c b/firmware/drivers/rtc/rtc_s3c2440.c
index c7a6f24490..ae422ffc2d 100644
--- a/firmware/drivers/rtc/rtc_s3c2440.c
+++ b/firmware/drivers/rtc/rtc_s3c2440.c
@@ -55,3 +55,69 @@ int rtc_write_datetime(unsigned char* buf)
55 return 1; 55 return 1;
56} 56}
57 57
58#ifdef HAVE_RTC_ALARM
59/* This alarm code works in that it at least triggers INT_RTC. I am guessing
60 * that the OF bootloader for the Gigabeat detects the startup by alarm and shuts down.
61 * This code is available for use once the OF bootloader is no longer required.
62 */
63
64/* check whether the unit has been started by the RTC alarm function
65 * This code has not been written/checked for the gigabeat
66 */
67bool rtc_check_alarm_started(bool release_alarm)
68{
69 static bool alarm_state, run_before;
70 bool rc;
71
72 if (run_before) {
73 rc = alarm_state;
74 alarm_state &= ~release_alarm;
75 } else {
76 /* This call resets AF, so we store the state for later recall */
77 rc = alarm_state = rtc_check_alarm_flag();
78 run_before = true;
79 }
80
81 return rc;
82}
83
84/*
85 * I don't think this matters on the gigabeat, it seems designed to shut off the alarm in the
86 * event one happens while the player is running. This does not cause any problems on the
87 * gigabeat as the interupt is recieved (if not masked) and ignored.
88 */
89bool rtc_check_alarm_flag(void)
90{
91 return false;
92}
93
94/* set alarm time registers to the given time (repeat once per day) */
95void rtc_set_alarm(int h, int m)
96{
97 ALMMIN=(((m / 10) << 4) | (m % 10)) & 0x7f; /* minutes */
98 ALMHOUR=(((h / 10) << 4) | (h % 10)) & 0x3f; /* hour */
99}
100
101/* read out the current alarm time */
102void rtc_get_alarm(int *h, int *m)
103{
104 *m=((ALMMIN & 0x70) >> 4) * 10 + (ALMMIN & 0x0f);
105 *h=((ALMHOUR & 0x30) >> 4) * 10 + (ALMHOUR & 0x0f);
106}
107
108/* turn alarm on or off by setting the alarm flag enable
109 * returns false if alarm was set and alarm flag (output) is off
110 */
111bool rtc_enable_alarm(bool enable)
112{
113 /* Note: The interupt for the alarm is normally masked. May want to enable ( INTMSK&=~(1<<30); )
114 * it here if an alarm handler is desired (while the unit is not in sleep).
115 */
116 if (enable)
117 RTCALM=0x46;
118 else
119 RTCALM=0x00;
120
121 return false; /* all ok */
122}
123#endif