summaryrefslogtreecommitdiff
path: root/firmware/drivers/rtc.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/rtc.c')
-rw-r--r--firmware/drivers/rtc.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc.c
index 6015f46026..c911dabbb1 100644
--- a/firmware/drivers/rtc.c
+++ b/firmware/drivers/rtc.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese 10 * Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 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. 13 * See the file COPYING in the source tree root for full license agreement.
@@ -24,13 +24,55 @@
24#include "system.h" 24#include "system.h"
25#include "pcf50606.h" 25#include "pcf50606.h"
26#include "pcf50605.h" 26#include "pcf50605.h"
27#include <stdbool.h> 27#if CONFIG_RTC == RTC_E8564
28#include "i2c-pp5020.h"
29#endif /*CONFIG_RTC == RTC_E8564*/
30#include <stdbool.h>
28 31
29#define RTC_ADR 0xd0 32#define RTC_ADR 0xd0
30#define RTC_DEV_WRITE (RTC_ADR | 0x00) 33#define RTC_DEV_WRITE (RTC_ADR | 0x00)
31#define RTC_DEV_READ (RTC_ADR | 0x01) 34#define RTC_DEV_READ (RTC_ADR | 0x01)
32 35
33#if CONFIG_RTC == RTC_PCF50605 36#if CONFIG_RTC == RTC_E8564
37void rtc_init(void)
38{
39}
40
41int rtc_read_datetime(unsigned char* buf)
42{
43 unsigned char tmp;
44 int read;
45
46 /*RTC_E8564's slave address is 0x51*/
47 read = i2c_readbytes(0x51,0x02,7,buf);
48
49 /* swap wday and mday to be compatible with
50 * get_time() from firmware/common/timefuncs.c */
51 tmp=buf[3];
52 buf[3]=buf[4];
53 buf[4]=tmp;
54
55 return read;
56}
57
58int rtc_write_datetime(unsigned char* buf)
59{
60 int i;
61 unsigned char tmp;
62
63 /* swap wday and mday to be compatible with
64 * set_time() in firmware/common/timefuncs.c */
65 tmp=buf[3];
66 buf[3]=buf[4];
67 buf[4]=tmp;
68
69 for (i=0;i<7;i++){
70 ipod_i2c_send(0x51, 0x02+i,buf[i]);
71 }
72 return 1;
73}
74
75#elif CONFIG_RTC == RTC_PCF50605
34void rtc_init(void) 76void rtc_init(void)
35{ 77{
36} 78}