1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
33 int rtc_read_datetime(unsigned char* buf
)
38 buf
[3] = BCDDAY
-1; /* timefuncs wants 0..6 for wday */
46 int rtc_write_datetime(unsigned char* buf
)
51 BCDDAY
= buf
[3]+1; /* chip wants 1..7 for wday */
60 /* This alarm code works with a flashed bootloader. This will not work with
64 /* Check whether the unit has been started by the RTC alarm function */
65 bool rtc_check_alarm_started(bool release_alarm
)
69 GSTATUS3
&= ~release_alarm
;
78 /* Check to see if the alarm has flaged since the last it was checked */
79 bool rtc_check_alarm_flag(void)
81 bool ret
=SRCPND
& 0x40000000;
88 /* set alarm time registers to the given time (repeat once per day) */
89 void rtc_set_alarm(int h
, int m
)
91 ALMMIN
=(((m
/ 10) << 4) | (m
% 10)) & 0x7f; /* minutes */
92 ALMHOUR
=(((h
/ 10) << 4) | (h
% 10)) & 0x3f; /* hour */
95 /* read out the current alarm time */
96 void rtc_get_alarm(int *h
, int *m
)
98 *m
=((ALMMIN
& 0x70) >> 4) * 10 + (ALMMIN
& 0x0f);
99 *h
=((ALMHOUR
& 0x30) >> 4) * 10 + (ALMHOUR
& 0x0f);
102 /* turn alarm on or off by setting the alarm flag enable
103 * returns false if alarm was set and alarm flag (output) is off
105 bool rtc_enable_alarm(bool enable
)
116 return false; /* all ok */