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_001.h
Go to the documentation of this file.
1
/*
2
* @brief Real Time Clock registers and control functions
3
*
4
* @note
5
* Copyright(C) NXP Semiconductors, 2012
6
* All rights reserved.
7
*
8
* @par
9
* Software that is described herein is for illustrative purposes only
10
* which provides customers with programming information regarding the
11
* LPC products. This software is supplied "AS IS" without any warranties of
12
* any kind, and NXP Semiconductors and its licensor disclaim any and
13
* all warranties, express or implied, including all implied warranties of
14
* merchantability, fitness for a particular purpose and non-infringement of
15
* intellectual property rights. NXP Semiconductors assumes no responsibility
16
* or liability for the use of the software, conveys no license or rights under any
17
* patent, copyright, mask work right, or any other intellectual property rights in
18
* or to any products. NXP Semiconductors reserves the right to make changes
19
* in the software without notification. NXP Semiconductors also makes no
20
* representation or warranty that such application will be suitable for the
21
* specified use without further testing or modification.
22
*
23
* @par
24
* Permission to use, copy, modify, and distribute this software and its
25
* documentation is hereby granted, under NXP Semiconductors' and its
26
* licensor's relevant copyrights in the software, without fee, provided that it
27
* is used in conjunction with NXP Semiconductors microcontrollers. This
28
* copyright, permission, and disclaimer notice must appear in all copies of
29
* this code.
30
*/
31
32
#ifndef __RTC_001_H_
33
#define __RTC_001_H_
34
35
#include "sys_config.h"
36
#include "
cmsis.h
"
37
38
#ifdef __cplusplus
39
extern
"C"
{
40
#endif
41
51
typedef
enum
{
52
RTC_TIMETYPE_SECOND
,
53
RTC_TIMETYPE_MINUTE
,
54
RTC_TIMETYPE_HOUR
,
55
RTC_TIMETYPE_DAYOFMONTH
,
56
RTC_TIMETYPE_DAYOFWEEK
,
57
RTC_TIMETYPE_DAYOFYEAR
,
58
RTC_TIMETYPE_MONTH
,
59
RTC_TIMETYPE_YEAR
,
60
RTC_TIMETYPE_LAST
61
}
IP_RTC_TIMEINDEX_T
;
62
66
typedef
struct
{
67
__O
uint32_t
ILR
;
68
__I
uint32_t
RESERVED0
;
69
__IO
uint32_t
CCR
;
70
__IO
uint32_t
CIIR
;
71
__IO
uint32_t
AMR
;
72
__I
uint32_t
CTIME[3];
73
__IO
uint32_t
TIME[
RTC_TIMETYPE_LAST
];
74
__IO
uint32_t
CALIBRATION
;
75
#if defined(CHIP_LPC177X_8X)
76
__IO
uint32_t
GPREG[5];
77
__IO
uint32_t
RTC_AUXEN;
78
__IO
uint32_t
RTC_AUX;
79
#else
80
__I
uint32_t
RESERVED1[7];
81
#endif
82
__IO
uint32_t
ALRM[
RTC_TIMETYPE_LAST
];
83
#if defined(CHIP_LPC177X_8X)
84
__IO
uint32_t
ERSTATUS;
85
#endif
86
}
IP_RTC_001_T
;
87
92
#define RTC_ILR_BITMASK ((0x00000003))
93
94
#define RTC_IRL_RTCCIF ((1 << 0))
95
96
#define RTC_IRL_RTCALF ((1 << 1))
97
102
#define RTC_CCR_BITMASK ((0x00000013))
103
104
#define RTC_CCR_CLKEN ((1 << 0))
105
106
#define RTC_CCR_CTCRST ((1 << 1))
107
108
#define RTC_CCR_CCALEN ((1 << 4))
109
114
#define RTC_AMR_CIIR_IMSEC ((1 << 0))
115
116
#define RTC_AMR_CIIR_IMMIN ((1 << 1))
117
118
#define RTC_AMR_CIIR_IMHOUR ((1 << 2))
119
120
#define RTC_AMR_CIIR_IMDOM ((1 << 3))
121
122
#define RTC_AMR_CIIR_IMDOW ((1 << 4))
123
124
#define RTC_AMR_CIIR_IMDOY ((1 << 5))
125
126
#define RTC_AMR_CIIR_IMMON ((1 << 6))
127
128
#define RTC_AMR_CIIR_IMYEAR ((1 << 7))
129
130
#define RTC_AMR_CIIR_BITMASK ((0xFF))
131
136
#define RTC_AUX_RTC_OSCF ((1 << 4))
137
142
#define RTC_AUXEN_RTC_OSCFEN ((1 << 4))
143
147
#define RTC_CTIME0_SECONDS_MASK ((0x3F))
148
#define RTC_CTIME0_MINUTES_MASK ((0x3F00))
149
#define RTC_CTIME0_HOURS_MASK ((0x1F0000))
150
#define RTC_CTIME0_DOW_MASK ((0x7000000))
151
155
#define RTC_CTIME1_DOM_MASK ((0x1F))
156
#define RTC_CTIME1_MONTH_MASK ((0xF00))
157
#define RTC_CTIME1_YEAR_MASK ((0xFFF0000))
158
162
#define RTC_CTIME2_DOY_MASK ((0xFFF))
163
168
#define RTC_SEC_MASK (0x0000003F)
169
170
#define RTC_MIN_MASK (0x0000003F)
171
172
#define RTC_HOUR_MASK (0x0000001F)
173
174
#define RTC_DOM_MASK (0x0000001F)
175
176
#define RTC_DOW_MASK (0x00000007)
177
178
#define RTC_DOY_MASK (0x000001FF)
179
180
#define RTC_MONTH_MASK (0x0000000F)
181
182
#define RTC_YEAR_MASK (0x00000FFF)
183
184
#define RTC_SECOND_MAX 59
185
#define RTC_MINUTE_MAX 59
186
#define RTC_HOUR_MAX 23
187
#define RTC_MONTH_MIN 1
188
#define RTC_MONTH_MAX 12
189
#define RTC_DAYOFMONTH_MIN 1
190
#define RTC_DAYOFMONTH_MAX 31
191
#define RTC_DAYOFWEEK_MAX 6
192
#define RTC_DAYOFYEAR_MIN 1
193
#define RTC_DAYOFYEAR_MAX 366
194
#define RTC_YEAR_MAX 4095
200
#define RTC_CALIBRATION_CALVAL_MASK ((0x1FFFF))
201
202
#define RTC_CALIBRATION_LIBDIR ((1 << 17))
203
204
#define RTC_CALIBRATION_MAX ((0x20000))
205
206
#define RTC_CALIB_DIR_FORWARD ((uint8_t) (0))
207
#define RTC_CALIB_DIR_BACKWARD ((uint8_t) (1))
208
209
/* Check Parameter Definitions */
211
#define PARAM_pRTC(x) (((uint32_t *) x) == ((uint32_t *) LPC_RTC))
212
213
/* Macro check RTC interrupt type */
214
#define PARAM_RTC_INT(n) ((n == RTC_INT_COUNTER_INCREASE) || (n == RTC_INT_ALARM))
215
216
/* Macro check RTC calibration type */
217
#define PARAM_RTC_CALIB_DIR(n) ((n == RTC_CALIB_DIR_FORWARD) || (n == RTC_CALIB_DIR_BACKWARD))
218
224
typedef
enum
{
225
RTC_INT_COUNTER_INCREASE
=
RTC_IRL_RTCCIF
,
226
RTC_INT_ALARM
=
RTC_IRL_RTCALF
227
}
IP_RTC_INT_OPT
;
228
229
typedef
struct
{
230
uint32_t
time[
RTC_TIMETYPE_LAST
];
231
}
IP_RTC_TIME_T
;
232
238
void
IP_RTC_Init
(
IP_RTC_001_T
*pRTC);
239
245
STATIC
INLINE
void
IP_RTC_DeInit
(
IP_RTC_001_T
*pRTC)
246
{
247
pRTC->
CCR
= 0x00;
248
}
249
255
void
IP_RTC_ResetClockTickCounter
(
IP_RTC_001_T
*pRTC);
256
263
void
IP_RTC_Enable
(
IP_RTC_001_T
*pRTC,
FunctionalState
NewState);
264
272
void
IP_RTC_CntIncrIntConfig
(
IP_RTC_001_T
*pRTC,
uint32_t
cntrMask,
FunctionalState
NewState);
273
281
void
IP_RTC_AlarmIntConfig
(
IP_RTC_001_T
*pRTC,
uint32_t
alarmMask,
FunctionalState
NewState);
282
290
void
IP_RTC_SetTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIMEINDEX_T
Timetype,
uint32_t
TimeValue);
291
298
uint32_t
IP_RTC_GetTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIMEINDEX_T
Timetype);
299
306
void
IP_RTC_SetFullTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIME_T
*pFullTime);
307
314
void
IP_RTC_GetFullTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIME_T
*pFullTime);
315
323
void
IP_RTC_SetAlarmTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIMEINDEX_T
Timetype,
uint32_t
ALValue);
324
331
uint32_t
IP_RTC_GetAlarmTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIMEINDEX_T
Timetype);
332
339
void
IP_RTC_SetFullAlarmTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIME_T
*pFullTime);
340
347
void
IP_RTC_GetFullAlarmTime
(
IP_RTC_001_T
*pRTC,
IP_RTC_TIME_T
*pFullTime);
348
357
void
IP_RTC_CalibCounterCmd
(
IP_RTC_001_T
*pRTC,
FunctionalState
NewState);
358
368
void
IP_RTC_CalibConfig
(
IP_RTC_001_T
*pRTC,
uint32_t
CalibValue, uint8_t CalibDir);
369
378
STATIC
INLINE
void
IP_RTC_ClearIntPending
(
IP_RTC_001_T
*pRTC,
uint32_t
IntType)
379
{
380
pRTC->
ILR
= IntType;
381
}
382
392
STATIC
INLINE
IntStatus
IP_RTC_GetIntPending
(
IP_RTC_001_T
*pRTC,
uint32_t
IntType)
393
{
394
return
(pRTC->
ILR
& IntType) ?
SET
:
RESET
;
395
}
396
401
#ifdef __cplusplus
402
}
403
#endif
404
405
#endif
/* __RTC_001_H_ */
software
lpc_core
lpc_ip
rtc_001.h
Generated on Fri Nov 16 2012 13:36:43 for LPCOpen Platform by
1.8.2