2 * @brief LPC18xx/43xx RTC driver
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __RTC_18XX_43XX_H_
\r
33 #define __RTC_18XX_43XX_H_
\r
39 /** @defgroup RTC_18XX_43XX CHIP: LPC18xx/43xx RTC driver
\r
40 * @ingroup CHIP_18XX_43XX_Drivers
\r
45 * @brief Initialize the RTC peripheral
\r
46 * @param pRTC : RTC peripheral selected
\r
49 void Chip_RTC_Init(LPC_RTC_T *pRTC);
\r
52 * @brief De-initialize the RTC peripheral
\r
53 * @param pRTC : RTC peripheral selected
\r
56 STATIC INLINE void Chip_RTC_DeInit(LPC_RTC_T *pRTC)
\r
58 IP_RTC_DeInit(LPC_RTC);
\r
62 * @brief Reset clock tick counter in the RTC peripheral
\r
63 * @param pRTC : RTC peripheral selected
\r
66 STATIC INLINE void Chip_RTC_ResetClockTickCounter(LPC_RTC_T *pRTC)
\r
68 IP_RTC_ResetClockTickCounter(LPC_RTC);
\r
72 * @brief Start/Stop RTC peripheral
\r
73 * @param pRTC : RTC peripheral selected
\r
74 * @param NewState : New State of this function, should be:
\r
75 * - ENABLE :The time counters are enabled
\r
76 * - DISABLE :The time counters are disabled
\r
79 STATIC INLINE void Chip_RTC_Enable(LPC_RTC_T *pRTC, FunctionalState NewState)
\r
81 IP_RTC_Enable(LPC_RTC, NewState);
\r
85 * @brief Enable/Disable Counter increment interrupt for a time type
\r
86 * in the RTC peripheral
\r
87 * @param pRTC : RTC peripheral selected
\r
88 * @param cntrMask : Or'ed bit values for time types (RTC_AMR_CIIR_IM*)
\r
89 * @param NewState : ENABLE or DISABLE
\r
92 STATIC INLINE void Chip_RTC_CntIncrIntConfig(LPC_RTC_T *pRTC, uint32_t cntrMask, FunctionalState NewState)
\r
94 IP_RTC_CntIncrIntConfig(LPC_RTC, cntrMask, NewState);
\r
98 * @brief Enable/Disable Alarm interrupt for a time type
\r
99 * in the RTC peripheral
\r
100 * @param pRTC : RTC peripheral selected
\r
101 * @param alarmMask : Or'ed bit values for ALARM types (RTC_AMR_CIIR_IM*)
\r
102 * @param NewState : ENABLE or DISABLE
\r
105 STATIC INLINE void Chip_RTC_AlarmIntConfig(LPC_RTC_T *pRTC, uint32_t alarmMask, FunctionalState NewState)
\r
107 IP_RTC_AlarmIntConfig(LPC_RTC, alarmMask, NewState);
\r
111 * @brief Set current time value for a time type in the RTC peripheral
\r
112 * @param pRTC : RTC peripheral selected
\r
113 * @param Timetype : time field index type to set
\r
114 * @param TimeValue : Value to palce in time field
\r
117 STATIC INLINE void Chip_RTC_SetTime(LPC_RTC_T *pRTC, IP_RTC_TIMEINDEX_T Timetype, uint32_t TimeValue)
\r
119 IP_RTC_SetTime(LPC_RTC, Timetype, TimeValue);
\r
123 * @brief Get current time value for a type time type
\r
124 * @param pRTC : RTC peripheral selected
\r
125 * @param Timetype : Time field index type to get
\r
126 * @return Value of time field according to specified time type
\r
128 STATIC INLINE uint32_t Chip_RTC_GetTime(LPC_RTC_T *pRTC, IP_RTC_TIMEINDEX_T Timetype)
\r
130 return IP_RTC_GetTime(LPC_RTC, Timetype);
\r
134 * @brief Set full time in the RTC peripheral
\r
135 * @param pRTC : RTC peripheral selected
\r
136 * @param pFullTime : Pointer to full time data
\r
139 STATIC INLINE void Chip_RTC_SetFullTime(LPC_RTC_T *pRTC, IP_RTC_TIME_T *pFullTime)
\r
141 IP_RTC_SetFullTime(LPC_RTC, pFullTime);
\r
145 * @brief Get full time from the RTC peripheral
\r
146 * @param pRTC : RTC peripheral selected
\r
147 * @param pFullTime : Pointer to full time record to fill
\r
150 STATIC INLINE void Chip_RTC_GetFullTime(LPC_RTC_T *pRTC, IP_RTC_TIME_T *pFullTime)
\r
152 IP_RTC_GetFullTime(LPC_RTC, pFullTime);
\r
156 * @brief Set alarm time value for a time type
\r
157 * @param pRTC : RTC peripheral selected
\r
158 * @param Timetype : Time index field to set
\r
159 * @param ALValue : Alarm time value to set
\r
162 STATIC INLINE void Chip_RTC_SetAlarmTime(LPC_RTC_T *pRTC, IP_RTC_TIMEINDEX_T Timetype, uint32_t ALValue)
\r
164 IP_RTC_SetAlarmTime(LPC_RTC, Timetype, ALValue);
\r
168 * @brief Get alarm time value for a time type
\r
169 * @param pRTC : RTC peripheral selected
\r
170 * @param Timetype : Time index field to get
\r
171 * @return Value of Alarm time according to specified time type
\r
173 STATIC INLINE uint32_t Chip_RTC_GetAlarmTime(LPC_RTC_T *pRTC, IP_RTC_TIMEINDEX_T Timetype)
\r
175 return IP_RTC_GetAlarmTime(LPC_RTC, Timetype);
\r
179 * @brief Set full alarm time in the RTC peripheral
\r
180 * @param pRTC : RTC peripheral selected
\r
181 * @param pFullTime : Pointer to full time record to set alarm
\r
184 STATIC INLINE void Chip_RTC_SetFullAlarmTime(LPC_RTC_T *pRTC, IP_RTC_TIME_T *pFullTime)
\r
186 IP_RTC_SetFullAlarmTime(LPC_RTC, pFullTime);
\r
190 * @brief Get full alarm time in the RTC peripheral
\r
191 * @param pRTC : RTC peripheral selected
\r
192 * @param pFullTime : Pointer to full time record to fill
\r
195 STATIC INLINE void Chip_RTC_GetFullAlarmTime(LPC_RTC_T *pRTC, IP_RTC_TIME_T *pFullTime)
\r
197 IP_RTC_GetFullAlarmTime(LPC_RTC, pFullTime);
\r
201 * @brief Write value to General purpose registers
\r
202 * @param pRegFile : RegFile peripheral selected
\r
203 * @param index : General purpose register index
\r
204 * @param Value : Value to write
\r
206 * @note These General purpose registers can be used to store important
\r
207 * information when the main power supply is off. The value in these
\r
208 * registers is not affected by chip reset. These registers are
\r
209 * powered in the RTC power domain.
\r
211 STATIC INLINE void Chip_REGFILE_Write(LPC_REGFILE_T *pRegFile, uint8_t index, uint32_t Value)
\r
213 IP_REGFILE_Write(pRegFile, index, Value);
\r
217 * @brief Read value from General purpose registers
\r
218 * @param pRegFile : RegFile peripheral selected
\r
219 * @param index : General purpose register index
\r
220 * @return Read Value
\r
221 * @note TheseGeneral purpose registers can be used to store important
\r
222 * information when the main power supply is off. The value in these
\r
223 * registers is not affected by chip reset. These registers are
\r
224 * powered in the RTC power domain.
\r
226 STATIC INLINE uint32_t Chip_REGFILE_Read(LPC_REGFILE_T *pRegFile, uint8_t index)
\r
228 return IP_REGFILE_Read(pRegFile, index);
\r
232 * @brief Enable/Disable calibration counter in the RTC peripheral
\r
233 * @param pRTC : RTC peripheral selected
\r
234 * @param NewState : New State of this function, should be:
\r
235 * - ENABLE :The calibration counter is enabled and counting
\r
236 * - DISABLE :The calibration counter is disabled and reset to zero
\r
239 STATIC INLINE void Chip_RTC_CalibCounterCmd(LPC_RTC_T *pRTC, FunctionalState NewState)
\r
241 IP_RTC_CalibCounterCmd(LPC_RTC, NewState);
\r
245 * @brief Configures Calibration in the RTC peripheral
\r
246 * @param pRTC : RTC peripheral selected
\r
247 * @param CalibValue : Calibration value, should be in range from 0 to 131,072
\r
248 * @param CalibDir : Calibration Direction, should be:
\r
249 * - RTC_CALIB_DIR_FORWARD :Forward calibration
\r
250 * - RTC_CALIB_DIR_BACKWARD :Backward calibration
\r
253 STATIC INLINE void Chip_RTC_CalibConfig(LPC_RTC_T *pRTC, uint32_t CalibValue, uint8_t CalibDir)
\r
255 IP_RTC_CalibConfig(LPC_RTC, CalibValue, CalibDir);
\r
259 * @brief Clear specified Location interrupt pending in the RTC peripheral
\r
260 * @param pRTC : RTC peripheral selected
\r
261 * @param IntType : Interrupt location type, should be:
\r
262 * - RTC_INT_COUNTER_INCREASE :Clear Counter Increment Interrupt pending.
\r
263 * - RTC_INT_ALARM :Clear alarm interrupt pending
\r
266 STATIC INLINE void Chip_RTC_ClearIntPending(LPC_RTC_T *pRTC, uint32_t IntType)
\r
268 IP_RTC_ClearIntPending(LPC_RTC, IntType);
\r
272 * @brief Check whether if specified location interrupt in the RTC peripheral is set or not
\r
273 * @param pRTC : RTC peripheral selected
\r
274 * @param IntType : Interrupt location type, should be:
\r
275 * - RTC_INT_COUNTER_INCREASE: Counter Increment Interrupt block generated an interrupt.
\r
276 * - RTC_INT_ALARM: Alarm generated an interrupt.
\r
277 * @return New state of specified Location interrupt in RTC peripheral, SET OR RESET
\r
279 STATIC INLINE IntStatus Chip_RTC_GetIntPending(LPC_RTC_T *pRTC, uint32_t IntType)
\r
281 return IP_RTC_GetIntPending(LPC_RTC, IntType);
\r
292 #endif /* __RTC_18XX_43XX_H_ */
\r