summaryrefslogtreecommitdiff
path: root/firmware/drivers/rtc/rtc_e8564.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/rtc/rtc_e8564.c')
-rw-r--r--firmware/drivers/rtc/rtc_e8564.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/firmware/drivers/rtc/rtc_e8564.c b/firmware/drivers/rtc/rtc_e8564.c
new file mode 100644
index 0000000000..233168c303
--- /dev/null
+++ b/firmware/drivers/rtc/rtc_e8564.c
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "i2c.h"
21#include "rtc.h"
22#include "kernel.h"
23#include "system.h"
24#include "i2c-pp5020.h"
25#include <stdbool.h>
26
27void rtc_init(void)
28{
29}
30
31int rtc_read_datetime(unsigned char* buf)
32{
33 unsigned char tmp;
34 int read;
35
36 /*RTC_E8564's slave address is 0x51*/
37 read = i2c_readbytes(0x51,0x02,7,buf);
38
39 /* swap wday and mday to be compatible with
40 * get_time() from firmware/common/timefuncs.c */
41 tmp=buf[3];
42 buf[3]=buf[4];
43 buf[4]=tmp;
44
45 return read;
46}
47
48int rtc_write_datetime(unsigned char* buf)
49{
50 int i;
51 unsigned char tmp;
52
53 /* swap wday and mday to be compatible with
54 * set_time() in firmware/common/timefuncs.c */
55 tmp=buf[3];
56 buf[3]=buf[4];
57 buf[4]=tmp;
58
59 for (i=0;i<7;i++){
60 pp_i2c_send(0x51, 0x02+i,buf[i]);
61 }
62 return 1;
63}
64