LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
rtc.c
Go to the documentation of this file.
1
/*------------------------------------------------------------------------/
2
/RTC control module
3
/-------------------------------------------------------------------------/
4
/
5
/ Copyright (C) 2011, ChaN, all right reserved.
6
/
7
/ * This software is a free software and there is NO WARRANTY.
8
/ * No restriction on use. You can use, modify and redistribute it for
9
/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
10
/ * Redistributions of source code must retain the above copyright notice.
11
/
12
/-------------------------------------------------------------------------*/
13
15
#ifdef CFG_SDCARD
16
#include "
chip.h
"
17
#include "board.h"
18
#include "
rtc.h
"
19
20
21
int
rtc_initialize
(
void
)
22
{
23
IP_RTC_TIME_T
rtcTime;
24
/* RTC Block section ------------------------------------------------------ */
25
// Init RTC module
26
Chip_RTC_Init
();
27
28
/* Set current time for RTC */
29
// Current time is 8:00:00PM, 2012-08-02
30
rtcTime.
time
[
RTC_TIMETYPE_SECOND
] = 0;
31
rtcTime.
time
[
RTC_TIMETYPE_MINUTE
] = 0;
32
rtcTime.
time
[
RTC_TIMETYPE_HOUR
] = 20;
33
rtcTime.
time
[
RTC_TIMETYPE_DAYOFMONTH
] = 2;
34
rtcTime.
time
[
RTC_TIMETYPE_MONTH
] = 8;
35
rtcTime.
time
[
RTC_TIMETYPE_YEAR
] = 2012;
36
Chip_RTC_SetFullAlarmTime
(&rtcTime);
37
// Chip_RTC_SetTime (LPC_RTC, RTC_TIMETYPE_SECOND, 0);
38
// Chip_RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MINUTE, 0);
39
// Chip_RTC_SetTime (LPC_RTC, RTC_TIMETYPE_HOUR, 20);
40
// Chip_RTC_SetTime (LPC_RTC, RTC_TIMETYPE_MONTH, 8);
41
// Chip_RTC_SetTime (LPC_RTC, RTC_TIMETYPE_YEAR, 2012);
42
// Chip_RTC_SetTime (LPC_RTC, RTC_TIMETYPE_DAYOFMONTH, 2);
43
/* Enable rtc (starts increase the tick counter and second counter register) */
44
Chip_RTC_Enable
(
ENABLE
);
45
46
return
1;
47
}
48
49
int
rtc_gettime
(
RTC
*rtc)
50
{
51
IP_RTC_TIME_T
rtcTime;
52
53
Chip_RTC_GetFullTime
(&rtcTime);
54
55
rtc->
sec
= rtcTime.
time
[
RTC_TIMETYPE_SECOND
];
56
rtc->
min
= rtcTime.
time
[
RTC_TIMETYPE_MINUTE
];
57
rtc->
hour
= rtcTime.
time
[
RTC_TIMETYPE_HOUR
];
58
rtc->
wday
= rtcTime.
time
[
RTC_TIMETYPE_DAYOFWEEK
];
59
rtc->
mday
= rtcTime.
time
[
RTC_TIMETYPE_DAYOFMONTH
];
60
rtc->
month
= rtcTime.
time
[
RTC_TIMETYPE_MONTH
];
61
rtc->
year
= rtcTime.
time
[
RTC_TIMETYPE_YEAR
];
62
return
1;
63
}
64
65
int
rtc_settime
(
const
RTC
*rtc)
66
{
67
IP_RTC_TIME_T
rtcTime;
68
69
rtcTime.
time
[
RTC_TIMETYPE_SECOND
] = rtc->
sec
;
70
rtcTime.
time
[
RTC_TIMETYPE_MINUTE
] = rtc->
min
;
71
rtcTime.
time
[
RTC_TIMETYPE_HOUR
] = rtc->
hour
;
72
rtcTime.
time
[
RTC_TIMETYPE_DAYOFMONTH
] = rtc->
wday
;
73
rtcTime.
time
[
RTC_TIMETYPE_DAYOFMONTH
] = rtc->
mday
;
74
rtcTime.
time
[
RTC_TIMETYPE_MONTH
] = rtc->
month
;
75
rtcTime.
time
[
RTC_TIMETYPE_YEAR
] = rtc->
year
;
76
77
Chip_RTC_GetFullTime
(&rtcTime);
78
79
return
1;
80
}
81
#endif
/*CFG_SDCARD*/
applications
lpc18xx_43xx
examples
LPCUSBlib
lpcusblib_MassStorageDevice
sdmmc
rtc.c
Generated on Fri Nov 16 2012 13:36:39 for LPCOpen Platform by
1.8.2