summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/config-recorder.h3
-rw-r--r--firmware/drivers/rtc.c73
-rw-r--r--firmware/drivers/rtc.h27
3 files changed, 103 insertions, 0 deletions
diff --git a/firmware/config-recorder.h b/firmware/config-recorder.h
index 6231172ec3..a5ae8554a0 100644
--- a/firmware/config-recorder.h
+++ b/firmware/config-recorder.h
@@ -6,3 +6,6 @@
6 6
7/* define this if you have the Recorder's 10-key keyboard */ 7/* define this if you have the Recorder's 10-key keyboard */
8#define HAVE_RECORDER_KEYPAD 1 8#define HAVE_RECORDER_KEYPAD 1
9
10/* define this if you have a real-time clock */
11#define HAVE_RTC 1
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc.c
new file mode 100644
index 0000000000..66b37fccb7
--- /dev/null
+++ b/firmware/drivers/rtc.c
@@ -0,0 +1,73 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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#ifdef HAVE_RTC
21#include "i2c.h"
22#include "rtc.h"
23
24#define RTC_ADR 0xd0
25#define RTC_DEV_WRITE (RTC_ADR | 0x00)
26#define RTC_DEV_READ (RTC_ADR | 0x01)
27
28int rtc_write(unsigned char address, unsigned char value)
29{
30 int ret = 0;
31 unsigned char buf[2];
32
33 i2c_begin();
34
35 buf[0] = address;
36 buf[1] = value;
37
38 /* send run command */
39 if (i2c_write(RTC_DEV_WRITE,buf,2))
40 {
41 ret = -1;
42 }
43
44 i2c_end();
45 return ret;
46}
47
48
49int rtc_read(unsigned char address)
50{
51 int value = -1;
52 unsigned char buf[1];
53
54 i2c_begin();
55
56 buf[0] = address;
57
58 /* send run command */
59 if (i2c_write(RTC_DEV_READ,buf,1) >= 0)
60 {
61 i2c_start();
62 i2c_outb(RTC_DEV_READ);
63 if (i2c_getack())
64 {
65 value = i2c_inb(1);
66 }
67 }
68
69 i2c_end();
70 return value;
71}
72
73#endif
diff --git a/firmware/drivers/rtc.h b/firmware/drivers/rtc.h
new file mode 100644
index 0000000000..00b4db5596
--- /dev/null
+++ b/firmware/drivers/rtc.h
@@ -0,0 +1,27 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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#ifndef _RTC_H_
20#define _RTC_H_
21
22#ifdef HAVE_RTC
23int rtc_read(unsigned char address);
24int rtc_write(unsigned char address, unsigned char value);
25#endif
26
27#endif