2 * @brief Real Time Clock registers and control functions
\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_001_H_
\r
33 #define __RTC_001_H_
\r
35 #include "sys_config.h"
\r
42 /** @defgroup IP_RTC_001 IP: RTC register block and driver
\r
43 * @ingroup IP_Drivers
\r
48 #if defined(CHIP_LPC177X_8X) || defined(CHIP_LPC407X_8X) || defined(CHIP_LPC18XX) || defined(CHIP_LPC43XX)
\r
49 #define RTC_EV_SUPPORT 1 /* Event Monitor/Recorder support */
\r
52 * @brief RTC time type option
\r
54 typedef enum IP_RTC_TIMEINDEX {
\r
55 RTC_TIMETYPE_SECOND, /*!< Second */
\r
56 RTC_TIMETYPE_MINUTE, /*!< Month */
\r
57 RTC_TIMETYPE_HOUR, /*!< Hour */
\r
58 RTC_TIMETYPE_DAYOFMONTH, /*!< Day of month */
\r
59 RTC_TIMETYPE_DAYOFWEEK, /*!< Day of week */
\r
60 RTC_TIMETYPE_DAYOFYEAR, /*!< Day of year */
\r
61 RTC_TIMETYPE_MONTH, /*!< Month */
\r
62 RTC_TIMETYPE_YEAR, /*!< Year */
\r
64 } IP_RTC_TIMEINDEX_T;
\r
68 * @brief Event Channel Identifier definitions
\r
70 typedef enum IP_RTC_EV_CHANNEL {
\r
71 RTC_EV_CHANNEL_1 = 0,
\r
75 } IP_RTC_EV_CHANNEL_T;
\r
76 #endif /*RTC_EV_SUPPORT*/
\r
79 * @brief Real Time Clock register block structure
\r
81 typedef struct { /*!< RTC Structure */
\r
82 __IO uint32_t ILR; /*!< Interrupt Location Register */
\r
83 __I uint32_t RESERVED0;
\r
84 __IO uint32_t CCR; /*!< Clock Control Register */
\r
85 __IO uint32_t CIIR; /*!< Counter Increment Interrupt Register */
\r
86 __IO uint32_t AMR; /*!< Alarm Mask Register */
\r
87 __I uint32_t CTIME[3]; /*!< Consolidated Time Register 0,1,2 */
\r
88 __IO uint32_t TIME[RTC_TIMETYPE_LAST]; /*!< Timer field registers */
\r
89 __IO uint32_t CALIBRATION; /*!< Calibration Value Register */
\r
90 #if defined(CHIP_LPC177X_8X) || defined(CHIP_LPC407X_8X) || defined(CHIP_LPC175X_6X)
\r
91 __IO uint32_t GPREG[5]; /*!< General Purpose Storage Registers */
\r
92 __IO uint32_t RTC_AUXEN; /*!< RTC Auxiliary Enable register */
\r
93 __IO uint32_t RTC_AUX; /*!< RTC Auxiliary control register*/
\r
95 __I uint32_t RESERVED1[7];
\r
97 __IO uint32_t ALRM[RTC_TIMETYPE_LAST]; /*!< Alarm field registers */
\r
99 __IO uint32_t ERSTATUS; /*!< Event Monitor/Recorder Status register*/
\r
100 __IO uint32_t ERCONTROL; /*!< Event Monitor/Recorder Control register*/
\r
101 __I uint32_t ERCOUNTERS; /*!< Event Monitor/Recorder Counters register*/
\r
102 __I uint32_t RESERVED2;
\r
103 __I uint32_t ERFIRSTSTAMP[RTC_EV_CHANNEL_NUM]; /*!<Event Monitor/Recorder First Stamp registers*/
\r
104 __I uint32_t RESERVED3;
\r
105 __I uint32_t ERLASTSTAMP[RTC_EV_CHANNEL_NUM]; /*!<Event Monitor/Recorder Last Stamp registers*/
\r
106 #endif /*RTC_EV_SUPPORT*/
\r
110 * @brief ILR register definitions
\r
112 /** ILR register mask */
\r
113 #define RTC_ILR_BITMASK ((0x00000003))
\r
114 /** Bit inform the source interrupt is counter increment*/
\r
115 #define RTC_IRL_RTCCIF ((1 << 0))
\r
116 /** Bit inform the source interrupt is alarm match*/
\r
117 #define RTC_IRL_RTCALF ((1 << 1))
\r
120 * @brief CCR register definitions
\r
122 /** CCR register mask */
\r
123 #define RTC_CCR_BITMASK ((0x00000013))
\r
124 /** Clock enable */
\r
125 #define RTC_CCR_CLKEN ((1 << 0))
\r
127 #define RTC_CCR_CTCRST ((1 << 1))
\r
128 /** Calibration counter enable */
\r
129 #define RTC_CCR_CCALEN ((1 << 4))
\r
132 * @brief CIIR and AMR register definitions
\r
134 /** Counter Increment Interrupt bit for second */
\r
135 #define RTC_AMR_CIIR_IMSEC ((1 << 0))
\r
136 /** Counter Increment Interrupt bit for minute */
\r
137 #define RTC_AMR_CIIR_IMMIN ((1 << 1))
\r
138 /** Counter Increment Interrupt bit for hour */
\r
139 #define RTC_AMR_CIIR_IMHOUR ((1 << 2))
\r
140 /** Counter Increment Interrupt bit for day of month */
\r
141 #define RTC_AMR_CIIR_IMDOM ((1 << 3))
\r
142 /** Counter Increment Interrupt bit for day of week */
\r
143 #define RTC_AMR_CIIR_IMDOW ((1 << 4))
\r
144 /** Counter Increment Interrupt bit for day of year */
\r
145 #define RTC_AMR_CIIR_IMDOY ((1 << 5))
\r
146 /** Counter Increment Interrupt bit for month */
\r
147 #define RTC_AMR_CIIR_IMMON ((1 << 6))
\r
148 /** Counter Increment Interrupt bit for year */
\r
149 #define RTC_AMR_CIIR_IMYEAR ((1 << 7))
\r
150 /** CIIR bit mask */
\r
151 #define RTC_AMR_CIIR_BITMASK ((0xFF))
\r
154 * @brief RTC_AUX register definitions
\r
156 /** RTC Oscillator Fail detect flag */
\r
157 #define RTC_AUX_RTC_OSCF ((1 << 4))
\r
158 #if defined(CHIP_LPC177X_8X) || defined(CHIP_LPC407X_8X)
\r
159 /** RTC_ALARM pin control flag */
\r
160 #define RTC_AUX_RTC_PDOUT ((1 << 6))
\r
164 * @brief RTC_AUXEN register definitions
\r
166 /** Oscillator Fail Detect interrupt enable*/
\r
167 #define RTC_AUXEN_RTC_OSCFEN ((1 << 4))
\r
170 * @brief Consolidated Time Register 0 definitions
\r
172 #define RTC_CTIME0_SECONDS_MASK ((0x3F))
\r
173 #define RTC_CTIME0_MINUTES_MASK ((0x3F00))
\r
174 #define RTC_CTIME0_HOURS_MASK ((0x1F0000))
\r
175 #define RTC_CTIME0_DOW_MASK ((0x7000000))
\r
178 * @brief Consolidated Time Register 1 definitions
\r
180 #define RTC_CTIME1_DOM_MASK ((0x1F))
\r
181 #define RTC_CTIME1_MONTH_MASK ((0xF00))
\r
182 #define RTC_CTIME1_YEAR_MASK ((0xFFF0000))
\r
185 * @brief Consolidated Time Register 2 definitions
\r
187 #define RTC_CTIME2_DOY_MASK ((0xFFF))
\r
190 * @brief Time Counter Group and Alarm register group
\r
192 /** SEC register mask */
\r
193 #define RTC_SEC_MASK (0x0000003F)
\r
194 /** MIN register mask */
\r
195 #define RTC_MIN_MASK (0x0000003F)
\r
196 /** HOUR register mask */
\r
197 #define RTC_HOUR_MASK (0x0000001F)
\r
198 /** DOM register mask */
\r
199 #define RTC_DOM_MASK (0x0000001F)
\r
200 /** DOW register mask */
\r
201 #define RTC_DOW_MASK (0x00000007)
\r
202 /** DOY register mask */
\r
203 #define RTC_DOY_MASK (0x000001FF)
\r
204 /** MONTH register mask */
\r
205 #define RTC_MONTH_MASK (0x0000000F)
\r
206 /** YEAR register mask */
\r
207 #define RTC_YEAR_MASK (0x00000FFF)
\r
209 #define RTC_SECOND_MAX 59 /*!< Maximum value of second */
\r
210 #define RTC_MINUTE_MAX 59 /*!< Maximum value of minute*/
\r
211 #define RTC_HOUR_MAX 23 /*!< Maximum value of hour*/
\r
212 #define RTC_MONTH_MIN 1 /*!< Minimum value of month*/
\r
213 #define RTC_MONTH_MAX 12 /*!< Maximum value of month*/
\r
214 #define RTC_DAYOFMONTH_MIN 1 /*!< Minimum value of day of month*/
\r
215 #define RTC_DAYOFMONTH_MAX 31 /*!< Maximum value of day of month*/
\r
216 #define RTC_DAYOFWEEK_MAX 6 /*!< Maximum value of day of week*/
\r
217 #define RTC_DAYOFYEAR_MIN 1 /*!< Minimum value of day of year*/
\r
218 #define RTC_DAYOFYEAR_MAX 366 /*!< Maximum value of day of year*/
\r
219 #define RTC_YEAR_MAX 4095/*!< Maximum value of year*/
\r
222 * @brief Calibration register
\r
224 /** Calibration value */
\r
225 #define RTC_CALIBRATION_CALVAL_MASK ((0x1FFFF))
\r
226 /** Calibration direction */
\r
227 #define RTC_CALIBRATION_LIBDIR ((1 << 17))
\r
228 /** Calibration max value */
\r
229 #define RTC_CALIBRATION_MAX ((0x20000))
\r
230 /** Calibration definitions */
\r
231 #define RTC_CALIB_DIR_FORWARD ((uint8_t) (0))
\r
232 #define RTC_CALIB_DIR_BACKWARD ((uint8_t) (1))
\r
236 * @brief Event Monitor/Recorder Control register
\r
238 /** Event Monitor/Recorder Control register mask */
\r
239 #define RTC_ERCTRL_BITMASK ((uint32_t) 0xC0F03C0F)
\r
240 /** Enable event interrupt and wakeup */
\r
241 #define RTC_ERCTRL_INTWAKE_EN ((uint32_t) (1 << 0))
\r
242 /** Enables automatically clearing the RTC general purpose registers when an event occurs*/
\r
243 #define RTC_ERCTRL_GPCLEAR_EN ((uint32_t) (1 << 1))
\r
244 /** Select polarity for a channel event on the input pin.*/
\r
245 #define RTC_ERCTRL_POL_NEGATIVE (0) /* Event as positive edge */
\r
246 #define RTC_ERCTRL_POL_POSITIVE ((uint32_t) (1 << 2)) /* Event as negative edge */
\r
247 /** Enable event input.*/
\r
248 #define RTC_ERCTRL_INPUT_EN ((uint32_t) (1 << 3))
\r
249 /** Configure a specific channel */
\r
250 #define RTC_ERCTRL_CHANNEL_CONFIG_BITMASK(ch) ((uint32_t) (0x0F << (10 * ch)))
\r
251 #define RTC_ERCTRL_CHANNEL_CONFIG(ch, flag) ((uint32_t) (flag << (10 * ch)))
\r
253 /** Enable Event Monitor/Recorder and select its operating frequency.*/
\r
254 #define RTC_ERCTRL_MODE_MASK (((uint32_t) 3) << 30)
\r
255 #define RTC_ERCTRL_MODE_CLK_DISABLE (((uint32_t) 0) << 30)
\r
256 #define RTC_ERCTRL_MODE_16HZ (((uint32_t) 1) << 30)
\r
257 #define RTC_ERCTRL_MODE_64HZ (((uint32_t) 2) << 30)
\r
258 #define RTC_ERCTRL_MODE_1KHZ (((uint32_t) 3) << 30)
\r
259 #define RTC_ERCTRL_MODE(n) (((uint32_t) n) << 30)
\r
262 * @brief Event Monitor/Recorder Status register
\r
264 /** Event Flag for a specific channel */
\r
265 #define RTC_ERSTATUS_CHANNEL_EV(ch) ((uint32_t) (1 << ch)) /* At least 1 event has occurred on a specific channel */
\r
266 /** General purpose registers have been asynchronous cleared. */
\r
267 #define RTC_ERSTATUS_GPCLEARED ((uint32_t) (1 << 3))
\r
268 /** An interrupt/wakeup request is pending.*/
\r
269 #define RTC_ERSTATUS_WAKEUP ((uint32_t) (((uint32_t) 1) << 31))
\r
272 * @brief Event Monitor/Recorder Counter register
\r
274 /** Value of the counter for Events occurred on a specific channel */
\r
275 #define RTC_ER_COUNTER(ch, n) ((uint32_t) ((n >> (8 * ch)) & 0x07))
\r
278 * @brief Event Monitor/Recorder TimeStamp register
\r
280 #define RTC_ER_TIMESTAMP_SEC(n) ((uint32_t) (n & 0x3F))
\r
281 #define RTC_ER_TIMESTAMP_MIN(n) ((uint32_t) ((n >> 6) & 0x3F))
\r
282 #define RTC_ER_TIMESTAMP_HOUR(n) ((uint32_t) ((n >> 12) & 0x1F))
\r
283 #define RTC_ER_TIMESTAMP_DOY(n) ((uint32_t) ((n >> 17) & 0x1FF))
\r
286 * @brief Event Monitor/Recorder Mode definition
\r
288 typedef enum IP_RTC_EV_MODE {
\r
289 RTC_EV_MODE_DISABLE = 0, /*!< Event Monitor/Recoder is disabled */
\r
290 RTC_EV_MODE_ENABLE_16HZ = 1, /*!< Event Monitor/Recoder is enabled and use 16Hz sample clock for event input */
\r
291 RTC_EV_MODE_ENABLE_64HZ = 2, /*!< Event Monitor/Recoder is enabled and use 64Hz sample clock for event input */
\r
292 RTC_EV_MODE_ENABLE_1KHZ = 3, /*!< Event Monitor/Recoder is enabled and use 1kHz sample clock for event input */
\r
294 } IP_RTC_EV_MODE_T;
\r
297 * @brief Event Monitor/Recorder Timestamp structure
\r
300 uint8_t sec; /*!< Second */
\r
301 uint8_t min; /*!< Minute */
\r
302 uint8_t hour; /*!< Hour */
\r
303 uint16_t dayofyear; /*!< Day of year */
\r
304 } IP_RTC_EV_TIMESTAMP_T;
\r
306 #endif /*RTC_EV_SUPPORT*/
\r
309 * @brief RTC enumeration
\r
312 /** @brief RTC interrupt source */
\r
313 typedef enum IP_RTC_INT_OPT {
\r
314 RTC_INT_COUNTER_INCREASE = RTC_IRL_RTCCIF, /*!< Counter Increment Interrupt */
\r
315 RTC_INT_ALARM = RTC_IRL_RTCALF /*!< The alarm interrupt */
\r
316 } IP_RTC_INT_OPT_T;
\r
319 uint32_t time[RTC_TIMETYPE_LAST];
\r
323 * @brief Initialize the RTC peripheral
\r
324 * @param pRTC : pointer to RTC peripheral block
\r
327 void IP_RTC_Init(IP_RTC_001_T *pRTC);
\r
330 * @brief De-initialize the RTC peripheral
\r
331 * @param pRTC : pointer to RTC peripheral block
\r
334 STATIC INLINE void IP_RTC_DeInit(IP_RTC_001_T *pRTC)
\r
340 * @brief Reset clock tick counter in the RTC peripheral
\r
341 * @param pRTC : pointer to RTC peripheral block
\r
344 void IP_RTC_ResetClockTickCounter(IP_RTC_001_T *pRTC);
\r
347 * @brief Start/Stop RTC peripheral
\r
348 * @param pRTC : pointer to RTC peripheral block
\r
349 * @param NewState : ENABLE or DISABLE
\r
352 void IP_RTC_Enable(IP_RTC_001_T *pRTC, FunctionalState NewState);
\r
355 * @brief Enable/Disable Counter increment interrupt for a time type in the RTC peripheral
\r
356 * @param pRTC : pointer to RTC peripheral block
\r
357 * @param cntrMask : Or'ed bit values for time types (RTC_AMR_CIIR_IM*)
\r
358 * @param NewState : ENABLE or DISABLE
\r
361 void IP_RTC_CntIncrIntConfig(IP_RTC_001_T *pRTC, uint32_t cntrMask, FunctionalState NewState);
\r
364 * @brief Enable/Disable Alarm interrupt for a time type in the RTC peripheral
\r
365 * @param pRTC : pointer to RTC peripheral block
\r
366 * @param alarmMask : Or'ed bit values for ALARM types (RTC_AMR_CIIR_IM*)
\r
367 * @param NewState : ENABLE or DISABLE
\r
370 void IP_RTC_AlarmIntConfig(IP_RTC_001_T *pRTC, uint32_t alarmMask, FunctionalState NewState);
\r
373 * @brief Set current time value for a time type in the RTC peripheral
\r
374 * @param pRTC : pointer to RTC peripheral block
\r
375 * @param Timetype : time field index type to set
\r
376 * @param TimeValue : Value to palce in time field
\r
379 void IP_RTC_SetTime(IP_RTC_001_T *pRTC, IP_RTC_TIMEINDEX_T Timetype, uint32_t TimeValue);
\r
382 * @brief Get current time value for a type time type
\r
383 * @param pRTC : pointer to RTC peripheral block
\r
384 * @param Timetype : Time field index type to get
\r
385 * @return Value of time field according to specified time type
\r
387 uint32_t IP_RTC_GetTime(IP_RTC_001_T *pRTC, IP_RTC_TIMEINDEX_T Timetype);
\r
390 * @brief Set full time in the RTC peripheral
\r
391 * @param pRTC : pointer to RTC peripheral block
\r
392 * @param pFullTime : Pointer to full time data
\r
395 void IP_RTC_SetFullTime(IP_RTC_001_T *pRTC, IP_RTC_TIME_T *pFullTime);
\r
398 * @brief Get full time from the RTC peripheral
\r
399 * @param pRTC : pointer to RTC peripheral block
\r
400 * @param pFullTime : Pointer to full time record to fill
\r
403 void IP_RTC_GetFullTime(IP_RTC_001_T *pRTC, IP_RTC_TIME_T *pFullTime);
\r
406 * @brief Set alarm time value for a time type
\r
407 * @param pRTC : pointer to RTC peripheral block
\r
408 * @param Timetype : Time index field to set
\r
409 * @param ALValue : Alarm time value to set
\r
412 void IP_RTC_SetAlarmTime(IP_RTC_001_T *pRTC, IP_RTC_TIMEINDEX_T Timetype, uint32_t ALValue);
\r
415 * @brief Get alarm time value for a time type
\r
416 * @param pRTC : pointer to RTC peripheral block
\r
417 * @param Timetype : Time index field to get
\r
418 * @return Value of Alarm time according to specified time type
\r
420 uint32_t IP_RTC_GetAlarmTime(IP_RTC_001_T *pRTC, IP_RTC_TIMEINDEX_T Timetype);
\r
423 * @brief Set full alarm time in the RTC peripheral
\r
424 * @param pRTC : pointer to RTC peripheral block
\r
425 * @param pFullTime : Pointer to full time record to set alarm
\r
428 void IP_RTC_SetFullAlarmTime(IP_RTC_001_T *pRTC, IP_RTC_TIME_T *pFullTime);
\r
431 * @brief Get full alarm time in the RTC peripheral
\r
432 * @param pRTC : pointer to RTC peripheral block
\r
433 * @param pFullTime : Pointer to full time record to fill
\r
436 void IP_RTC_GetFullAlarmTime(IP_RTC_001_T *pRTC, IP_RTC_TIME_T *pFullTime);
\r
439 * @brief Enable/Disable calibration counter in the RTC peripheral
\r
440 * @param pRTC : pointer to RTC peripheral block
\r
441 * @param NewState : New State of this function, should be:
\r
442 * - ENABLE :The calibration counter is enabled and counting
\r
443 * - DISABLE :The calibration counter is disabled and reset to zero
\r
446 void IP_RTC_CalibCounterCmd(IP_RTC_001_T *pRTC, FunctionalState NewState);
\r
449 * @brief Configures Calibration in the RTC peripheral
\r
450 * @param pRTC : pointer to RTC peripheral block
\r
451 * @param CalibValue : Calibration value, should be in range from 0 to 131,072
\r
452 * @param CalibDir : Calibration Direction, should be:
\r
453 * - RTC_CALIB_DIR_FORWARD :Forward calibration
\r
454 * - RTC_CALIB_DIR_BACKWARD :Backward calibration
\r
457 void IP_RTC_CalibConfig(IP_RTC_001_T *pRTC, uint32_t CalibValue, uint8_t CalibDir);
\r
460 * @brief Clear specified Location interrupt pending in the RTC peripheral
\r
461 * @param pRTC : pointer to RTC peripheral block
\r
462 * @param IntType : Interrupt location type, should be:
\r
463 * - RTC_INT_COUNTER_INCREASE :Clear Counter Increment Interrupt pending.
\r
464 * - RTC_INT_ALARM :Clear alarm interrupt pending
\r
467 STATIC INLINE void IP_RTC_ClearIntPending(IP_RTC_001_T *pRTC, uint32_t IntType)
\r
469 pRTC->ILR = IntType;
\r
473 * @brief Check whether if specified location interrupt in the
\r
474 * RTC peripheral is set or not
\r
475 * @param pRTC : pointer to RTC peripheral block
\r
476 * @param IntType : Interrupt location type, should be:
\r
477 * - RTC_INT_COUNTER_INCREASE: Counter Increment Interrupt block generated an interrupt.
\r
478 * - RTC_INT_ALARM: Alarm generated an interrupt.
\r
479 * @return Current state of specified interrupt in RTC peripheral, SET or RESET
\r
481 STATIC INLINE IntStatus IP_RTC_GetIntPending(IP_RTC_001_T *pRTC, uint32_t IntType)
\r
483 return (pRTC->ILR & IntType) ? SET : RESET;
\r
489 * @brief Configure a specific event channel
\r
490 * @param pRTC : pointer to RTC peripheral block
\r
491 * @param ch : channel number
\r
492 * @param flag : configuration flag
\r
494 * @note Flags is or-ed bit values of RTC_ERCTRL_INTWAKE_EN,RTC_ERCTRL_GPCLEAR_EN,
\r
495 * RTC_ERCTRL_POL_POSITIVE and RTC_ERCTRL_INPUT_EN.
\r
497 STATIC INLINE void IP_RTC_EV_Config(IP_RTC_001_T *pRTC, IP_RTC_EV_CHANNEL_T ch, uint32_t flag)
\r
501 temp = pRTC->ERCONTROL & (~(RTC_ERCTRL_CHANNEL_CONFIG_BITMASK(ch))) & RTC_ERCTRL_BITMASK;
\r
502 pRTC->ERCONTROL = temp | (RTC_ERCTRL_CHANNEL_CONFIG(ch, flag) & RTC_ERCTRL_BITMASK);
\r
506 * @brief Enable/Disable Event Monitor/Recorder and select its operating clock
\r
507 * @param pRTC : pointer to RTC peripheral block
\r
508 * @param mode : selected mode
\r
511 STATIC INLINE void IP_RTC_EV_SetMode(IP_RTC_001_T *pRTC, IP_RTC_EV_MODE_T mode)
\r
515 temp = pRTC->ERCONTROL & (~RTC_ERCTRL_MODE_MASK) & RTC_ERCTRL_BITMASK;
\r
516 pRTC->ERCONTROL = temp | RTC_ERCTRL_MODE(mode);
\r
520 * @brief Get Event Monitor/Recorder Status
\r
521 * @param pRTC : pointer to RTC peripheral block
\r
522 * @return Or-ed bit value of RTC_ERSTATUS_GPCLEARED and RTC_ERSTATUS_WAKEUP
\r
524 STATIC INLINE uint32_t IP_RTC_EV_GetStatus(IP_RTC_001_T *pRTC)
\r
526 return pRTC->ERSTATUS & (RTC_ERSTATUS_GPCLEARED | RTC_ERSTATUS_WAKEUP);
\r
530 * @brief Clear Event Monitor/Recorder Status
\r
531 * @param pRTC : pointer to RTC peripheral block
\r
532 * @param flag : Or-ed bit value of RTC_ERSTATUS_GPCLEARED and RTC_ERSTATUS_WAKEUP
\r
535 STATIC INLINE void IP_RTC_EV_ClearStatus(IP_RTC_001_T *pRTC, uint32_t flag)
\r
537 pRTC->ERSTATUS = flag & (RTC_ERSTATUS_GPCLEARED | RTC_ERSTATUS_WAKEUP);
\r
541 * @brief Get status of a specific event channel
\r
542 * @param pRTC : pointer to RTC peripheral block
\r
543 * @param ch : channel number
\r
544 * @return SET (At least 1 event occurred on the channel), RESET: no event occured.
\r
546 STATIC INLINE FlagStatus IP_RTC_EV_GetChannelStatus(IP_RTC_001_T *pRTC, IP_RTC_EV_CHANNEL_T ch)
\r
548 return (pRTC->ERSTATUS & RTC_ERSTATUS_CHANNEL_EV(ch)) ? SET : RESET;
\r
552 * @brief Clear status of a specific event channel
\r
553 * @param pRTC : pointer to RTC peripheral block
\r
554 * @param ch : channel number
\r
557 STATIC INLINE void IP_RTC_EV_ClearChannelStatus(IP_RTC_001_T *pRTC, IP_RTC_EV_CHANNEL_T ch)
\r
559 pRTC->ERSTATUS = RTC_ERSTATUS_CHANNEL_EV(ch);
\r
563 * @brief Get counter value of a specific event channel
\r
564 * @param pRTC : pointer to RTC peripheral block
\r
565 * @param ch : channel number
\r
566 * @return counter value
\r
568 STATIC INLINE uint8_t IP_RTC_EV_GetCounter(IP_RTC_001_T *pRTC, IP_RTC_EV_CHANNEL_T ch)
\r
570 return RTC_ER_COUNTER(ch, pRTC->ERCOUNTERS);
\r
574 * @brief Get first time stamp of a specific event channel
\r
575 * @param pRTC : pointer to RTC peripheral block
\r
576 * @param ch : channel number
\r
577 * @param pTimeStamp : pointer to Timestamp buffer
\r
580 void IP_RTC_EV_GetFirstTimeStamp(IP_RTC_001_T *pRTC, IP_RTC_EV_CHANNEL_T ch, IP_RTC_EV_TIMESTAMP_T *pTimeStamp);
\r
583 * @brief Get last time stamp of a specific event channel
\r
584 * @param pRTC : pointer to RTC peripheral block
\r
585 * @param ch : channel number
\r
586 * @param pTimeStamp : pointer to Timestamp buffer
\r
589 void IP_RTC_EV_GetLastTimeStamp(IP_RTC_001_T *pRTC, IP_RTC_EV_CHANNEL_T ch, IP_RTC_EV_TIMESTAMP_T *pTimeStamp);
\r
591 #endif /*RTC_EV_SUPPORT*/
\r
600 #endif /* __RTC_001_H_ */
\r