diff options
author | Michael Sparmann <theseven@rockbox.org> | 2009-10-05 20:21:33 +0000 |
---|---|---|
committer | Michael Sparmann <theseven@rockbox.org> | 2009-10-05 20:21:33 +0000 |
commit | be25469b9b481d8f40aeb12aa6de84e1efdc0e68 (patch) | |
tree | 34ebc185287296bce7a3901a1c2a5bd3b1354bb2 /firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c | |
parent | 6b8a78f7939b2eaccce578b68fd5831fc79f0a71 (diff) | |
download | rockbox-be25469b9b481d8f40aeb12aa6de84e1efdc0e68.tar.gz rockbox-be25469b9b481d8f40aeb12aa6de84e1efdc0e68.zip |
Reworked iPod Nano 2G PMU code, added RTC and battery ADC.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22967 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c')
-rw-r--r-- | firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.c new file mode 100644 index 0000000000..f0975efb9f --- /dev/null +++ b/firmware/target/arm/s5l8700/ipodnano2g/rtc-nano2g.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, Uwe Freese, Laurent Baum | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "rtc.h" | ||
23 | #include "kernel.h" | ||
24 | #include "system.h" | ||
25 | #include "pmu-target.h" | ||
26 | |||
27 | void rtc_init(void) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | int rtc_read_datetime(struct tm *tm) | ||
32 | { | ||
33 | unsigned int i; | ||
34 | unsigned char buf[7]; | ||
35 | |||
36 | pmu_read_multiple(0x59, sizeof(buf), buf); | ||
37 | |||
38 | for (i = 0; i < sizeof(buf); i++) | ||
39 | buf[i] = BCD2DEC(buf[i]); | ||
40 | |||
41 | tm->tm_sec = buf[0]; | ||
42 | tm->tm_min = buf[1]; | ||
43 | tm->tm_hour = buf[2]; | ||
44 | tm->tm_wday = buf[3]; | ||
45 | tm->tm_mday = buf[4]; | ||
46 | tm->tm_mon = buf[5] - 1; | ||
47 | tm->tm_year = buf[6] + 100; | ||
48 | |||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | int rtc_write_datetime(const struct tm *tm) | ||
53 | { | ||
54 | unsigned int i; | ||
55 | int rc, oldlevel; | ||
56 | unsigned char buf[7]; | ||
57 | |||
58 | buf[0] = tm->tm_sec; | ||
59 | buf[1] = tm->tm_min; | ||
60 | buf[2] = tm->tm_hour; | ||
61 | buf[3] = tm->tm_wday; | ||
62 | buf[4] = tm->tm_mday; | ||
63 | buf[5] = tm->tm_mon + 1; | ||
64 | buf[6] = tm->tm_year - 100; | ||
65 | |||
66 | for (i = 0; i < sizeof(buf); i++) | ||
67 | buf[i] = DEC2BCD(buf[i]); | ||
68 | |||
69 | pmu_write_multiple(0x59, sizeof(buf), buf); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||