blob: 50df5a1f95b222d9959d110d525938b5a96ef77f [file] [log] [blame]
Marcoen Hirschberga45e6322006-11-27 09:44:56 +00001/***************************************************************************
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 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Marcoen Hirschberga45e6322006-11-27 09:44:56 +000016 *
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 "i2c.h"
23#include "rtc.h"
24#include "kernel.h"
25#include "system.h"
26#include "pcf50606.h"
27#include <stdbool.h>
28
29void rtc_init(void)
30{
31}
32
33int rtc_read_datetime(unsigned char* buf) {
34 int rc;
Michael Sevakisaf395f42008-03-26 01:50:41 +000035 int oldlevel = disable_irq_save();
Marcoen Hirschberga45e6322006-11-27 09:44:56 +000036
37 rc = pcf50606_read_multiple(0x0a, buf, 7);
38
Michael Sevakisaf395f42008-03-26 01:50:41 +000039 restore_irq(oldlevel);
Marcoen Hirschberga45e6322006-11-27 09:44:56 +000040 return rc;
41}
42
43int rtc_write_datetime(unsigned char* buf) {
44 int rc;
Michael Sevakisaf395f42008-03-26 01:50:41 +000045 int oldlevel = disable_irq_save();
Marcoen Hirschberga45e6322006-11-27 09:44:56 +000046
47 rc = pcf50606_write_multiple(0x0a, buf, 7);
48
Michael Sevakisaf395f42008-03-26 01:50:41 +000049 restore_irq(oldlevel);
Marcoen Hirschberga45e6322006-11-27 09:44:56 +000050
51 return rc;
52}
53