summaryrefslogtreecommitdiff
path: root/firmware/common/timefuncs.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-11-20 00:00:25 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-11-20 00:00:25 +0000
commit85969853d5533b8b70192590274c5d63f31735ec (patch)
treeabe57ef5a6b1a11f9b94fc6e032da34796bb373b /firmware/common/timefuncs.c
parentd703389780f5c7a627bff3f6daf6d72e4547a9db (diff)
downloadrockbox-85969853d5533b8b70192590274c5d63f31735ec.tar.gz
rockbox-85969853d5533b8b70192590274c5d63f31735ec.zip
New time functions
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2861 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/timefuncs.c')
-rw-r--r--firmware/common/timefuncs.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
new file mode 100644
index 0000000000..0371762465
--- /dev/null
+++ b/firmware/common/timefuncs.c
@@ -0,0 +1,53 @@
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
20#include "config.h"
21
22#include "rtc.h"
23#include "time.h"
24#include "debug.h"
25
26static struct tm tm;
27
28struct tm *get_time(void)
29{
30 char rtcbuf[8];
31 int i;
32
33 /* We don't need the first byte, but we want the indexes in the
34 buffer to match the data sheet */
35 rtc_read_multiple(1, &rtcbuf[1], 7);
36
37 for(i = 0;i < 7;i++)
38 {
39 DEBUGF("%02x ", rtcbuf[i]);
40 }
41 DEBUGF("\n");
42
43 tm.tm_sec = ((rtcbuf[1] & 0x70) >> 4) * 10 + (rtcbuf[1] & 0x0f);
44 tm.tm_min = ((rtcbuf[2] & 0x70) >> 4) * 10 + (rtcbuf[2] & 0x0f);
45 tm.tm_hour = ((rtcbuf[3] & 0x30) >> 4) * 10 + (rtcbuf[3] & 0x0f);
46 tm.tm_mday = ((rtcbuf[5] & 0x30) >> 4) * 10 + (rtcbuf[5] & 0x0f);
47 tm.tm_mon = ((rtcbuf[6] & 0x10) >> 4) * 10 + (rtcbuf[6] & 0x0f);
48 tm.tm_year = ((rtcbuf[7] & 0xf0) >> 4) * 10 + (rtcbuf[7] & 0x0f) + 2000;
49 tm.tm_wday = rtcbuf[4] & 0x07;
50 tm.tm_yday = 0; /* Not implemented for now */
51 tm.tm_isdst = -1; /* Not implemented for now */
52 return &tm;
53}