diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-24 13:23:01 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-24 13:23:01 +0000 |
commit | 740eb36c10dd43b2307767f6101833d960399438 (patch) | |
tree | 690b13f3369024e3ce878e85a21868edfe5d4fdb /firmware | |
parent | c7fee9bcb26f01d7d483f3b5776eeb59838902c0 (diff) | |
download | rockbox-740eb36c10dd43b2307767f6101833d960399438.tar.gz rockbox-740eb36c10dd43b2307767f6101833d960399438.zip |
Added first RTC functions
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1151 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/config-recorder.h | 3 | ||||
-rw-r--r-- | firmware/drivers/rtc.c | 73 | ||||
-rw-r--r-- | firmware/drivers/rtc.h | 27 |
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 | |||
28 | int 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 | |||
49 | int 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 | ||
23 | int rtc_read(unsigned char address); | ||
24 | int rtc_write(unsigned char address, unsigned char value); | ||
25 | #endif | ||
26 | |||
27 | #endif | ||