Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
763 user890104 1
//
2
//
3
//    Copyright 2011 TheSeven, user890104
4
//
5
//
6
//    This file is part of emCORE.
7
//
8
//    emCORE is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emCORE is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "global.h"
25
#include "pmu.h"
26
#include "rtc.h"
27
 
28
 
29
void rtc_read_datetime(struct rtc_datetime* dt)
30
{
31
    pmu_read_rtc((unsigned char *)dt);
32
 
33
    dt->second = BCD2DEC(dt->second);
34
    dt->minute = BCD2DEC(dt->minute);
35
    dt->hour = BCD2DEC(dt->hour);
36
    dt->day = BCD2DEC(dt->day);
37
    dt->month = BCD2DEC(dt->month);
38
    dt->year = BCD2DEC(dt->year);
39
}
40
 
41
void rtc_write_datetime(const struct rtc_datetime* dt)
42
{
43
    unsigned char buf[7];
44
 
45
    buf[0] = DEC2BCD(dt->second);
46
    buf[1] = DEC2BCD(dt->minute);
47
    buf[2] = DEC2BCD(dt->hour);
48
    buf[3] = dt->weekday;
49
    buf[4] = DEC2BCD(dt->day);
50
    buf[5] = DEC2BCD(dt->month);
51
    buf[6] = DEC2BCD(dt->year);
52
 
53
    pmu_write_rtc(buf);
54
}