]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/rtc/fsl_rtc_hal.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_Freescale / TARGET_KPSDK_MCUS / TARGET_KPSDK_CODE / hal / rtc / fsl_rtc_hal.h
1 /*
2  * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  *   of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  *   list of conditions and the following disclaimer in the documentation and/or
13  *   other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  *   contributors may be used to endorse or promote products derived from this
17  *   software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(__FSL_RTC_HAL_H__)
31 #define __FSL_RTC_HAL_H__
32
33 #include <assert.h>
34 #include <stdint.h>
35 #include <stdbool.h>
36 #include "fsl_rtc_features.h"
37 #include "fsl_device_registers.h"
38
39 /*!
40  * @addtogroup rtc_hal
41  * @{
42  */
43
44 /*******************************************************************************
45  * Definitions
46  ******************************************************************************/
47
48 /*!
49  * @brief Structure is used to hold the time in a simple "date" format.
50  */
51 typedef struct RtcDatetime
52 {
53    uint16_t year;    /*!< Range from 1970 to 2099.*/
54    uint16_t month;   /*!< Range from 1 to 12.*/
55    uint16_t day;     /*!< Range from 1 to 31 (depending on month).*/
56    uint16_t hour;    /*!< Range from 0 to 23.*/
57    uint16_t minute;  /*!< Range from 0 to 59.*/
58    uint8_t second;   /*!< Range from 0 to 59.*/
59 } rtc_datetime_t;
60
61 /*******************************************************************************
62  * API
63  ******************************************************************************/
64
65 #if defined(__cplusplus)
66 extern "C" {
67 #endif
68
69 /*!
70  * @name RTC HAL API Functions
71  * @{
72  */
73
74 /*!
75  * @brief  Initializes the RTC module.
76  *
77  * This function enables the RTC oscillator.
78  *
79  * @param  rtcBaseAddr The RTC base address.
80  */
81 void RTC_HAL_Enable(uint32_t rtcBaseAddr);
82
83 /*!
84  * @brief  Disables the RTC module.
85  *
86  * This function disablesS the RTC counter and oscillator.
87  *
88  * @param  rtcBaseAddr The RTC base address.
89  */
90 void RTC_HAL_Disable(uint32_t rtcBaseAddr);
91
92 /*!
93  * @brief  Resets the RTC module.
94  *
95  * This function initiates a soft-reset of the RTC module to reset
96  * the RTC registers.
97  *
98  * @param  rtcBaseAddr The RTC base address..
99  */
100 void RTC_HAL_Init(uint32_t rtcBaseAddr);
101
102 /*!
103  * @brief  Converts seconds to date time format data structure.
104  *
105  * @param  seconds holds the date and time information in seconds
106  * @param  datetime holds the converted information from seconds in date and time format
107  */
108 void RTC_HAL_ConvertSecsToDatetime(const uint32_t * seconds, rtc_datetime_t * datetime);
109
110 /*!
111  * @brief  Checks whether the date time structure elements have the information that is within the range.
112  *
113  * @param  datetime holds the date and time information that needs to be converted to seconds
114  */
115 bool RTC_HAL_IsDatetimeCorrectFormat(const rtc_datetime_t * datetime);
116
117 /*!
118  * @brief  Converts the date time format data structure to seconds.
119  *
120  * @param  datetime holds the date and time information that needs to be converted to seconds
121  * @param  seconds holds the converted date and time in seconds
122  */
123 void RTC_HAL_ConvertDatetimeToSecs(const rtc_datetime_t * datetime, uint32_t * seconds);
124
125 /*!
126  * @brief  Sets the RTC date and time according to the given time structure.
127  *
128  * The function converts the data from the time structure to seconds and writes the seconds
129  * value to the RTC register. The RTC counter is started after setting the time.
130  *
131  * @param  rtcBaseAddr The RTC base address
132  * @param  datetime [in] Pointer to structure where the date and time
133  *         details to set are stored.
134  */
135 void RTC_HAL_SetDatetime(uint32_t rtcBaseAddr, const rtc_datetime_t * datetime);
136
137 /*!
138  * @brief  Sets the RTC date and time according to the given time provided in seconds.
139  *
140  * The RTC counter is started after setting the time.
141  *
142  * @param  rtcBaseAddr The RTC base address
143  * @param  seconds [in] Time in seconds
144  */
145 void RTC_HAL_SetDatetimeInsecs(uint32_t rtcBaseAddr, const uint32_t seconds);
146
147 /*!
148  * @brief  Gets the RTC time and stores it in the given time structure.
149  *
150  * The function reads the value in seconds from the RTC register. It then converts to the
151  * time structure which provides the time in date, hour, minutes and seconds.
152  *
153  * @param  rtcBaseAddr The RTC base address
154  * @param  datetime [out] pointer to a structure where the date and time details are
155  *         stored.
156  */
157 void RTC_HAL_GetDatetime(uint32_t rtcBaseAddr, rtc_datetime_t * datetime);
158
159 /*!
160  * @brief  Gets the RTC time and returns it in seconds.
161  *
162  * @param  rtcBaseAddr The RTC base address
163  * @param  datetime [out] pointer to variable where the RTC time is stored in seconds
164  */
165 void RTC_HAL_GetDatetimeInSecs(uint32_t rtcBaseAddr, uint32_t * seconds);
166
167 /*!
168  * @brief  Reads the value of the time alarm.
169  *
170  * @param  rtcBaseAddr The RTC base address
171  * @param  date [out] pointer to a variable where the alarm date and time
172  *         details are stored.
173  */
174 void RTC_HAL_GetAlarm(uint32_t rtcBaseAddr, rtc_datetime_t * date);
175
176 /*!
177  * @brief  Sets the RTC alarm time and enables the alarm interrupt.
178  *
179  * The function checks whether the specified alarm time is greater than the present
180  * time. If not, the function does not set the alarm and returns an error.
181  *
182  * @param  rtcBaseAddr The RTC base address..
183  * @param  date [in] pointer to structure where the alarm date and time
184  *         details will be stored at.
185  * @return  true: success in setting the RTC alarm\n
186  *          false: error in setting the RTC alarm.
187  */
188 bool RTC_HAL_SetAlarm(uint32_t rtcBaseAddr, const rtc_datetime_t * date);
189
190 #if FSL_FEATURE_RTC_HAS_MONOTONIC
191 /*-------------------------------------------------------------------------------------------*/
192 /* RTC Monotonic Counter*/
193 /*-------------------------------------------------------------------------------------------*/
194
195 /*!
196  * @brief  Reads the values of the Monotonic Counter High and Monotonic Counter Low and returns
197  *         them as a single value.
198  *
199  * @param  rtcBaseAddr The RTC base address
200  * @param  counter [out] pointer to variable where the value is  stored.
201  */
202 void RTC_HAL_GetMonotonicCounter(uint32_t rtcBaseAddr, uint64_t * counter);
203
204 /*!
205  * @brief  Writes values Monotonic Counter High and Monotonic Counter Low by decomposing
206  *         the given single value.
207  *
208  * @param  rtcBaseAddr The RTC base address
209  * @param  counter [in] pointer to variable where the value is stored.
210  */
211 void RTC_HAL_SetMonotonicCounter(uint32_t rtcBaseAddr, const uint64_t * counter);
212
213 /*!
214  * @brief  Increments the Monotonic Counter by one.
215  *
216  * Increments the Monotonic Counter (registers RTC_MCLR and RTC_MCHR accordingly) by setting
217  * the monotonic counter enable (MER[MCE]) and then writing to the RTC_MCLR register. A write to the
218  * monotonic counter low that causes it to overflow also increments the monotonic counter high.
219  *
220  * @param  rtcBaseAddr The RTC base address
221  *
222  * @return  true: success\n
223  *          false: error occurred, either time invalid or monotonic overflow flag was found
224  */
225 bool RTC_HAL_IncrementMonotonicCounter(uint32_t rtcBaseAddr);
226 #endif
227 /*! @}*/
228
229 /*!
230  * @name RTC register access functions
231  * @{
232  */
233
234 /*!
235  * @brief  Reads the value of the time seconds counter.
236  *
237  * The time counter reads as zero if either the SR[TOF] or the SR[TIF] is set.
238  *
239  * @param  rtcBaseAddr The RTC base address..
240  *
241  * @return contents of the seconds register.
242  */
243 static inline uint32_t RTC_HAL_GetSecsReg(uint32_t rtcBaseAddr)
244 {
245     return BR_RTC_TSR_TSR(rtcBaseAddr);
246 }
247
248 /*!
249  * @brief  Writes to the time seconds counter.
250  *
251  * When the time counter is enabled, the TSR is read only and increments
252  * once every second provided the SR[TOF] or SR[TIF] is not set. When the time counter
253  * is disabled, the TSR can be read or written. Writing to the TSR when the
254  * time counter is disabled clears the SR[TOF] and/or the SR[TIF]. Writing
255  * to the TSR register with zero is supported, but not recommended, since the TSR
256  * reads as zero when either the SR[TIF] or the SR[TOF] is set (indicating the time is
257  * invalid).
258  *
259  * @param  rtcBaseAddr The RTC base address..
260  * @param  seconds [in] seconds value.
261  *
262  */
263 static inline void RTC_HAL_SetSecsReg(uint32_t rtcBaseAddr, const uint32_t seconds)
264 {
265     HW_RTC_TPR_WR(rtcBaseAddr, (uint32_t)0x00000000U);
266     BW_RTC_TSR_TSR(rtcBaseAddr, seconds);
267 }
268
269 /*!
270  * @brief  Sets the time alarm and clears the time alarm flag.
271  *
272  * When the time counter is enabled, the SR[TAF] is set whenever the TAR[TAR]
273  * equals the TSR[TSR] and the TSR[TSR] increments. Writing to the TAR
274  * clears the SR[TAF].
275  *
276  * @param  rtcBaseAddr The RTC base address..
277  * @param  seconds [in] alarm value in seconds.
278  */
279 static inline void RTC_HAL_SetAlarmReg(uint32_t rtcBaseAddr, const uint32_t seconds)
280 {
281     BW_RTC_TAR_TAR(rtcBaseAddr, seconds);
282 }
283
284 /*!
285  * @brief  Gets the time alarm register contents.
286  *
287  * @param  rtcBaseAddr The RTC base address
288  *
289  * @return  contents of the alarm register.
290  */
291 static inline uint32_t RTC_HAL_GetAlarmReg(uint32_t rtcBaseAddr)
292 {
293     return BR_RTC_TAR_TAR(rtcBaseAddr);
294 }
295
296
297 /*!
298  * @brief  Reads the value of the time prescaler.
299  *
300  * The time counter reads as zero when either the SR[TOF] or the SR[TIF] is set.
301  *
302  * @param  rtcBaseAddr The RTC base address
303  *
304  * @return  contents of the time prescaler register.
305  */
306 static inline uint16_t RTC_HAL_GetPrescaler(uint32_t rtcBaseAddr)
307 {
308     return BR_RTC_TPR_TPR(rtcBaseAddr);
309 }
310
311 /*!
312  * @brief  Sets the time prescaler.
313  *
314  * When the time counter is enabled, the TPR is read only and increments
315  * every 32.768 kHz clock cycle. When the time counter is disabled, the TPR
316  * can be read or written. The TSR[TSR] increments when bit 14 of the TPR
317  * transitions from a logic one to a logic zero.
318  *
319  * @param  rtcBaseAddr The RTC base address
320  * @param  prescale Prescaler value
321  */
322 static inline void RTC_HAL_SetPrescaler(uint32_t rtcBaseAddr, const uint16_t prescale)
323 {
324     BW_RTC_TPR_TPR(rtcBaseAddr, prescale);
325 }
326
327 /*-------------------------------------------------------------------------------------------*/
328 /* RTC Time Compensation*/
329 /*-------------------------------------------------------------------------------------------*/
330
331 /*!
332  * @brief  Reads the time compensation register contents.
333  *
334  * @param  rtcBaseAddr The RTC base address
335  *
336  * @return time compensation register contents.
337  */
338 static inline uint32_t RTC_HAL_GetCompensationReg(uint32_t rtcBaseAddr)
339 {
340     return HW_RTC_TCR_RD(rtcBaseAddr);
341 }
342
343 /*!
344  * @brief  Writes the value to the RTC TCR register.
345  *
346  * @param  rtcBaseAddr The RTC base address
347  * @param  compValue value to be written to the compensation register.
348  */
349 static inline void RTC_HAL_SetCompensationReg(uint32_t rtcBaseAddr, const uint32_t compValue)
350 {
351     HW_RTC_TCR_WR(rtcBaseAddr, compValue);
352 }
353
354 /*!
355  * @brief  Reads the current value of the compensation interval counter, which is the field CIC in the RTC TCR register.
356  *
357  * @param  rtcBaseAddr The RTC base address..
358  *
359  * @return  compensation interval value.
360  */
361 static inline uint8_t RTC_HAL_GetCompensationIntervalCounter(uint32_t rtcBaseAddr)
362 {
363     return BR_RTC_TCR_CIC(rtcBaseAddr);
364 }
365
366 /*!
367  * @brief  Reads the current value used by the compensation logic for the present second interval.
368  *
369  * @param  rtcBaseAddr The RTC base address
370  *
371  * @return  time compensation value
372  */
373 static inline uint8_t RTC_HAL_GetTimeCompensationValue(uint32_t rtcBaseAddr)
374 {
375     return BR_RTC_TCR_TCV(rtcBaseAddr);
376 }
377
378 /*!
379  * @brief  Reads the compensation interval register.
380
381  * The value is the configured compensation interval in seconds from 1 to 256 to control
382  * how frequently the time compensation register  should adjust the
383  * number of 32.768 kHz cycles in each second. The value is one
384  * less than the number of seconds (for example, zero means a
385  * configuration for a compensation interval of one second).
386  *
387  * @param  rtcBaseAddr The RTC base address..
388  *
389  * @return compensation interval in seconds.
390  */
391 static inline uint8_t RTC_HAL_GetCompensationIntervalRegister(uint32_t rtcBaseAddr)
392 {
393     return BR_RTC_TCR_CIR(rtcBaseAddr);
394 }
395
396 /*!
397  * @brief  Writes the compensation interval.
398  *
399  * This configures the compensation interval in seconds from 1 to 256 to control
400  * how frequently the TCR should adjust the number of 32.768 kHz
401  * cycles in each second. The value written should be one less than
402  * the number of seconds (for example, write zero to configure for
403  * a compensation interval of one second). This register is double
404  * buffered and writes do not take affect until the end of the
405  * current compensation interval.
406  *
407  * @param  rtcBaseAddr The RTC base address..
408  * @param  value the compensation interval value.
409  */
410 static inline void RTC_HAL_SetCompensationIntervalRegister(uint32_t rtcBaseAddr, const uint8_t value)
411 {
412     BW_RTC_TCR_CIR(rtcBaseAddr, value);
413 }
414
415 /*!
416  * @brief  Reads the time compensation value which is the configured number
417  *         of 32.768 kHz clock cycles in each second.
418  *
419  * @param  rtcBaseAddr The RTC base address
420  *
421  * @return  time compensation value.
422  */
423 static inline uint8_t RTC_HAL_GetTimeCompensationRegister(uint32_t rtcBaseAddr)
424 {
425     return BR_RTC_TCR_TCR(rtcBaseAddr);
426 }
427
428 /*!
429  * @brief  Writes to the field Time Compensation Register (TCR) of the RTC Time Compensation Register (RTC_TCR).
430  *
431  * Configures the number of 32.768 kHz clock cycles in each second. This register is double
432  * buffered and writes do not take affect until the end of the
433  * current compensation interval.
434  * 80h Time prescaler register overflows every 32896 clock cycles.
435  * .. ...\n
436  * FFh Time prescaler register overflows every 32769 clock cycles.\n
437  * 00h Time prescaler register overflows every 32768 clock cycles.\n
438  * 01h Time prescaler register overflows every 32767 clock cycles.\n
439  * ... ...\n
440  * 7Fh Time prescaler register overflows every 32641 clock cycles.\n
441  *
442  * @param  rtcBaseAddr The RTC base address
443  * @param  comp_value value of the time compensation.
444  */
445 static inline void RTC_HAL_SetTimeCompensationRegister(uint32_t rtcBaseAddr, const uint8_t compValue)
446 {
447     BW_RTC_TCR_TCR(rtcBaseAddr, compValue);
448 }
449
450 /*-------------------------------------------------------------------------------------------*/
451 /* RTC Control*/
452 /*-------------------------------------------------------------------------------------------*/
453
454 /*!
455  * @brief  Enables/disables the oscillator configuration for the 2pF load.
456  *
457  * @param  rtcBaseAddr The RTC base address
458  * @param  enable can be true or false\n
459  *         true: enables load\n
460  *         false: disables load.
461  */
462 static inline void RTC_HAL_SetOsc2pfLoadCmd(uint32_t rtcBaseAddr, bool enable)
463 {
464     BW_RTC_CR_SC2P(rtcBaseAddr, enable);
465 }
466
467 /*!
468  * @brief  Reads the oscillator 2pF load configure bit.
469  *
470  * @param  rtcBaseAddr The RTC base address
471  *
472  * @return true: 2pF additional load enabled.\n
473  *         false: 2pF additional load disabled.
474  */
475 static inline bool RTC_HAL_GetOsc2pfLoad(uint32_t rtcBaseAddr)
476 {
477     return (bool)BR_RTC_CR_SC2P(rtcBaseAddr);
478 }
479
480 /*!
481  * @brief  Enables/disables the oscillator configuration for the 4pF load.
482  *
483  * @param  rtcBaseAddr The RTC base address
484  * @param  enable can be true or false\n
485  *         true: enables load.\n
486  *         false: disables load
487  */
488 static inline void RTC_HAL_SetOsc4pfLoadCmd(uint32_t rtcBaseAddr, bool enable)
489 {
490     BW_RTC_CR_SC4P(rtcBaseAddr, enable);
491 }
492
493 /*!
494  * @brief  Reads the oscillator 4pF load configure bit.
495  *
496  * @param  rtcBaseAddr The RTC base address
497  *
498  * @return true: 4pF additional load enabled.\n
499  *         false: 4pF additional load disabled.
500  */
501 static inline bool RTC_HAL_GetOsc4pfLoad(uint32_t rtcBaseAddr)
502 {
503     return (bool)BR_RTC_CR_SC4P(rtcBaseAddr);
504 }
505
506 /*!
507  * @brief  Enables/disables the oscillator configuration for the 8pF load.
508  *
509  * @param  rtcBaseAddr The RTC base address
510  * @param  enable can be true or false\n
511  *         true: enables load.\n
512  *         false: disables load.
513  */
514 static inline void RTC_HAL_SetOsc8pfLoadCmd(uint32_t rtcBaseAddr, bool enable)
515 {
516     BW_RTC_CR_SC8P(rtcBaseAddr, enable);
517 }
518
519 /*!
520  * @brief  Reads the oscillator 8pF load configure bit.
521  *
522  * @param  rtcBaseAddr The RTC base address
523  *
524  * @return true: 8pF additional load enabled.\n
525  *         false: 8pF additional load disabled.
526  */
527 static inline bool RTC_HAL_GetOsc8pfLoad(uint32_t rtcBaseAddr)
528 {
529     return (bool)BR_RTC_CR_SC8P(rtcBaseAddr);
530 }
531
532 /*!
533  * @brief  Enables/disables the oscillator configuration for the 16pF load.
534  *
535  * @param  rtcBaseAddr The RTC base address
536  * @param  enable can be true or false\n
537  *         true: enables load.\n
538  *         false: disables load.
539  */
540 static inline void RTC_HAL_SetOsc16pfLoadCmd(uint32_t rtcBaseAddr, bool enable)
541 {
542     BW_RTC_CR_SC16P(rtcBaseAddr, enable);
543 }
544
545 /*!
546  * @brief  Reads the oscillator 16pF load configure bit.
547  *
548  * @param  rtcBaseAddr The RTC base address
549  *
550  * @return true: 16pF additional load enabled.\n
551  *         false: 16pF additional load disabled.
552  */
553 static inline bool RTC_HAL_GetOsc16pfLoad(uint32_t rtcBaseAddr)
554 {
555     return (bool)BR_RTC_CR_SC16P(rtcBaseAddr);
556 }
557
558 /*!
559  * @brief  Enables/disables the 32 kHz clock output to other peripherals.
560  *
561  * @param  rtcBaseAddr The RTC base address
562  * @param  enable can be true or false\n
563  *         true: enables clock out.\n
564  *         false: disables clock out.
565  */
566 static inline void RTC_HAL_SetClockOutCmd(uint32_t rtcBaseAddr, bool enable)
567 {
568     BW_RTC_CR_CLKO(rtcBaseAddr, !enable);
569 }
570
571 /*!
572  * @brief  Reads the RTC_CR CLKO bit.
573  *
574  * @param  rtcBaseAddr The RTC base address
575  *
576  * @return true: 32 kHz clock is not output to other peripherals.\n
577  *         false: 32 kHz clock is output to other peripherals.
578  */
579 static inline bool RTC_HAL_GetClockOutCmd(uint32_t rtcBaseAddr)
580 {
581     return (bool)BR_RTC_CR_CLKO(rtcBaseAddr);
582 }
583
584 /*!
585  * @brief  Enables/disables the oscillator.
586  *
587  * After enabling, waits for the oscillator startup time before enabling the
588  * time counter to allow the 32.768 kHz clock time to stabilize.
589  *
590  * @param  rtcBaseAddr The RTC base address
591  * @param  enable can be true or false\n
592  *         true: enables oscillator.\n
593  *         false: disables oscillator.
594  */
595 static inline void RTC_HAL_SetOscillatorCmd(uint32_t rtcBaseAddr, bool enable)
596 {
597     BW_RTC_CR_OSCE(rtcBaseAddr, enable);
598 /* TODO: Wait for oscillator startup period if enabling the oscillator
599     if (enable)
600 */
601
602 }
603
604 /*!
605  * @brief  Reads the RTC_CR OSCE bit.
606  *
607  * @param  rtcBaseAddr The RTC base address
608  *
609  * @return true: 32.768 kHz oscillator is enabled
610  *         false: 32.768 kHz oscillator is disabled.
611  */
612 static inline bool RTC_HAL_IsOscillatorEnabled(uint32_t rtcBaseAddr)
613 {
614     return (bool)BR_RTC_CR_OSCE(rtcBaseAddr);
615 }
616
617 /*!
618  * @brief  Enables/disables the update mode.
619  *
620  * This mode allows the time counter enable bit in the SR to be written
621  * even when the status register is locked.
622  * When set, the time counter enable, can always be written if the
623  * TIF (Time Invalid Flag) or TOF (Time Overflow Flag) are set or
624  * if the time counter enable is clear. For devices with the
625  * monotonic counter it allows the monotonic enable to be written
626  * when it is locked. When set, the monotonic enable can always be
627  * written if the TIF (Time Invalid Flag) or TOF (Time Overflow Flag)
628  * are set or if the montonic counter enable is clear.
629  * For devices with tamper detect it allows the it to be written
630  * when it is locked. When set, the tamper detect can always be
631  * written if the TIF (Time Invalid Flag) is clear.
632  * Note: Tamper and Monotonic features are not available in all MCUs.
633  *
634  * @param  rtcBaseAddr The RTC base address
635  * @param  lock can be true or false\n
636  *         true: registers can be written when locked under limited conditions\n
637  *         false: registers cannot be written when locked
638  */
639 static inline void RTC_HAL_SetUpdateModeCmd(uint32_t rtcBaseAddr, bool lock)
640 {
641     BW_RTC_CR_UM(rtcBaseAddr, lock);
642 }
643
644 /*!
645  * @brief  Reads the RTC_CR update mode bit.
646  *
647  * @param  rtcBaseAddr The RTC base address
648  *
649  * @return true: Registers can be written when locked under limited conditions.
650  *         false: Registers cannot be written when locked.
651  */
652 static inline bool RTC_HAL_GetUpdateMode(uint32_t rtcBaseAddr)
653 {
654     return (bool)BR_RTC_CR_UM(rtcBaseAddr);
655 }
656
657 /*!
658  * @brief  Enables/disables the supervisor access.
659  *
660  * This configures non-supervisor mode write access to all RTC registers and
661  * non-supervisor mode read access to RTC tamper/monotonic registers.
662  * Note: Tamper and Monotonic features are NOT available in all MCUs.
663  *
664  * @param  rtcBaseAddr The RTC base address..
665  * @param  enableRegWrite can be true or false\n
666  *         true: non-supervisor mode write accesses are supported.\n
667  *         false: non-supervisor mode write accesses are not supported and generate a bus error.
668  */
669 static inline void RTC_HAL_SetSupervisorAccessCmd(uint32_t rtcBaseAddr, bool enableRegWrite)
670 {
671     BW_RTC_CR_SUP(rtcBaseAddr, enableRegWrite);
672 }
673
674 /*!
675  * @brief  Reads the RTC_CR SUP bit.
676  *
677  * @param  rtcBaseAddr The RTC base address
678  *
679  * @return true: Non-supervisor mode write accesses are supported
680  *         false: Non-supervisor mode write accesses are not supported.
681  */
682 static inline bool RTC_HAL_GetSupervisorAccess(uint32_t rtcBaseAddr)
683 {
684     return (bool)BR_RTC_CR_SUP(rtcBaseAddr);
685 }
686
687 #if FSL_FEATURE_RTC_HAS_WAKEUP_PIN
688 /*!
689  * @brief  Enables/disables the wakeup pin.
690  *
691  * Note: The wakeup pin is optional and not available on all devices.
692  *
693  * @param  rtcBaseAddr The RTC base address
694  * @param  enable_wp can be true or false\n
695  *         true: enables wakeup-pin, wakeup pin asserts if the
696  *               RTC interrupt asserts and the chip is powered down.\n
697  *         false: disables wakeup-pin.
698  */
699 static inline void RTC_HAL_SetWakeupPinCmd(uint32_t rtcBaseAddr, bool enableWp)
700 {
701     BW_RTC_CR_WPE(rtcBaseAddr, enableWp);
702 }
703
704 /*!
705  * @brief  Reads the RTC_CR WPE bit.
706  *
707  * @param  rtcBaseAddr The RTC base address
708  *
709  * @return true: Wakeup pin is enabled.
710  *         false: Wakeup pin is disabled.
711  */
712 static inline bool RTC_HAL_GetWakeupPin(uint32_t rtcBaseAddr)
713 {
714     return (bool)BR_RTC_CR_WPE(rtcBaseAddr);
715 }
716 #endif
717
718 /*!
719  * @brief  Performs a software reset on the RTC module.
720  *
721  * This resets all RTC registers except for the SWR bit and the RTC_WAR and RTC_RAR
722  * registers. The SWR bit is cleared after VBAT POR and by software
723  * explicitly clearing it.
724  * Note: access control features (RTC_WAR and RTC_RAR registers)
725  * are not available in all MCUs.
726  *
727  * @param  rtcBaseAddr The RTC base address
728  */
729 static inline void RTC_HAL_SoftwareReset(uint32_t rtcBaseAddr)
730 {
731     BW_RTC_CR_SWR(rtcBaseAddr, 1u);
732 }
733
734 /*!
735  * @brief  Clears the software reset flag.
736  *
737  * @param  rtcBaseAddr The RTC base address
738  */
739 static inline void RTC_HAL_SoftwareResetFlagClear(uint32_t rtcBaseAddr)
740 {
741     BW_RTC_CR_SWR(rtcBaseAddr, 0u);
742 }
743
744 /*!
745  * @brief  Reads the RTC_CR SWR bit.
746  *
747  * @param  rtcBaseAddr The RTC base address
748  *
749  * @return true: SWR is set.
750  *         false: SWR is cleared.
751  */
752 static inline bool RTC_HAL_ReadSoftwareResetStatus(uint32_t rtcBaseAddr)
753 {
754     return (bool)BR_RTC_CR_SWR(rtcBaseAddr);
755 }
756
757 /*-------------------------------------------------------------------------------------------*/
758 /* RTC Status*/
759 /*-------------------------------------------------------------------------------------------*/
760
761 /*!
762  * @brief  Reads the time counter status (enabled/disabled).
763  *
764  * @param  rtcBaseAddr The RTC base address
765  *
766  * @return  true: time counter is enabled, time seconds register and time
767  *                prescaler register are not writeable, but increment.\n
768  *          false: time counter is disabled, time seconds register and
769  *                 time prescaler register are writeable, but do not increment.
770  */
771 static inline bool RTC_HAL_IsCounterEnabled(uint32_t rtcBaseAddr)
772 {
773     return (bool)BR_RTC_SR_TCE(rtcBaseAddr);
774 }
775
776 /*!
777  * @brief  Changes the time counter status.
778  *
779  * @param  rtcBaseAddr The RTC base address
780  * @param  enable can be true or false\n
781  *         true: enables the time counter\n
782  *         false: disables the time counter.
783  */
784 static inline void RTC_HAL_EnableCounter(uint32_t rtcBaseAddr, bool enable)
785 {
786     BW_RTC_SR_TCE(rtcBaseAddr, enable);
787 }
788
789 #if FSL_FEATURE_RTC_HAS_MONOTONIC
790 /*!
791  * @brief  Reads the value of the Monotonic Overflow Flag (MOF).
792  *
793  * This flag is set when the monotonic counter is enabled and the monotonic
794  * counter high overflows. The monotonic counter does not increment and 
795  * reads as zero when this bit is set. This bit is cleared by writing the monotonic
796  * counter high register when the monotonic counter is disabled.
797  *
798  * @param  rtcBaseAddr The RTC base address..
799  *
800  * @return  true: monotonic counter overflow has occurred and monotonic
801  *                counter is read as zero.\n
802  *          false: No monotonic counter overflow has occurred.
803  */
804 static inline bool RTC_HAL_IsMonotonicCounterOverflow(uint32_t rtcBaseAddr)
805 {
806     return (bool)BR_RTC_SR_MOF(rtcBaseAddr);
807 }
808 #endif
809
810 /*!
811  * @brief  Checks whether the configured time alarm has occurred.
812  *
813  * Reads time alarm flag (TAF). This flag is set when the time
814  * alarm register (TAR) equals the time seconds register (TSR) and
815  * the TSR increments. This flag is cleared by writing the TAR register.
816  *
817  * @param  rtcBaseAddr The RTC base address..
818  *
819  * @return  true: time alarm has occurred.\n
820  *          false: no time alarm occurred.
821  */
822 static inline bool RTC_HAL_HasAlarmOccured(uint32_t rtcBaseAddr)
823 {
824     return (bool)BR_RTC_SR_TAF(rtcBaseAddr);
825 }
826
827 /*!
828  * @brief  Checks whether a counter overflow has occurred.
829  *
830  * Reads the value of RTC Status Register (RTC_SR), field Time
831  * Overflow Flag (TOF). This flag is set when the time counter is
832  * enabled and overflows. The TSR and TPR do not increment and read
833  * as zero when this bit is set. This flag is cleared by writing the
834  * TSR register when the time counter is disabled.
835  *
836  * @param  rtcBaseAddr The RTC base address..
837  *
838  * @return  true: time overflow occurred and time counter is zero.\n
839  *          false: no time overflow occurred.
840  */
841 static inline bool RTC_HAL_HasCounterOverflowed(uint32_t rtcBaseAddr)
842 {
843     return (bool)BR_RTC_SR_TOF(rtcBaseAddr);
844 }
845
846 /*!
847  * @brief  Checks whether the time has been marked as invalid.
848  *
849  * Reads the value of RTC Status Register (RTC_SR), field Time
850  * Invalid Flag (TIF). This flag is set on VBAT POR or software
851  * reset. The TSR and TPR do not increment and read as zero when
852  * this bit is set. This flag is cleared by writing the TSR
853  * register when the time counter is disabled.
854  *
855  * @param  rtcBaseAddr The RTC base address..
856  *
857  * @return  true: time is INVALID and time counter is zero.\n
858  *          false: time is valid.
859  */
860 static inline bool RTC_HAL_IsTimeInvalid(uint32_t rtcBaseAddr)
861 {
862     return (bool)BR_RTC_SR_TIF(rtcBaseAddr);
863 }
864
865 /*-------------------------------------------------------------------------------------------*/
866 /* RTC Lock*/
867 /*-------------------------------------------------------------------------------------------*/
868
869 /*!
870  * @brief  Configures the register lock to other module fields.
871  *
872  * @param  rtcBaseAddr The RTC base address..
873  * @param  bitfields [in] configuration flags:\n
874  *  Valid bitfields:\n
875  *    LRL: Lock Register Lock \n
876  *    SRL: Status Register Lock \n
877  *    CRL: Control Register Lock \n
878  *    TCL: Time Compensation Lock \n
879  *
880  * For MCUs that have the Tamper Detect only: \n
881  *    TIL: Tamper Interrupt Lock \n
882  *    TTL: Tamper Trim Lock \n
883  *    TDL: Tamper Detect Lock \n
884  *    TEL: Tamper Enable Lock \n
885  *    TTSL: Tamper Time Seconds Lock \n
886  *
887  * For MCUs that have the Monotonic Counter only: \n
888  *    MCHL: Monotonic Counter High Lock \n
889  *    MCLL: Monotonic Counter Low Lock \n
890  *    MEL: Monotonic Enable Lock \n
891  */
892 static inline void RTC_HAL_SetLockRegistersCmd(uint32_t rtcBaseAddr, hw_rtc_lr_t bitfields)
893 {
894     uint32_t valid_flags = 0;
895
896     valid_flags |= (BM_RTC_LR_LRL | BM_RTC_LR_SRL | BM_RTC_LR_CRL |
897                     BM_RTC_LR_TCL);
898
899 #if FSL_FEATURE_RTC_HAS_MONOTONIC
900     valid_flags |= (BM_RTC_LR_MCHL | BM_RTC_LR_MCLL | BM_RTC_LR_MEL);
901 #endif
902     HW_RTC_LR_WR(rtcBaseAddr, (bitfields.U) & valid_flags);
903 }
904
905 /*!
906  * @brief  Obtains the lock status of the lock register.
907  *
908  * Reads the value of the field Lock Register Lock (LRL) of the  RTC Lock Register (RTC_LR).
909  *
910  * @param  rtcBaseAddr The RTC base address
911  *
912  * @return  true: lock register is not locked and writes complete as normal.\n
913  *          false: lock register is locked and writes are ignored.
914  */
915 static inline bool RTC_HAL_GetLockRegLock(uint32_t rtcBaseAddr)
916 {
917     return (bool)BR_RTC_LR_LRL(rtcBaseAddr);
918 }
919
920 /*!
921  * @brief  Changes the lock status of the lock register.
922  *
923  * Writes to the field Lock Register Lock (LRL) of the RTC Lock Register (RTC_LR).
924  * Once cleared, this can only be set by VBAT POR or software reset.
925  *
926  * @param  rtcBaseAddr The RTC base address
927  * @param  lock can be true or false\n
928  *         true: Lock register is not locked and writes complete as normal.\n
929  *         false: Lock register is locked and writes are ignored.
930  */
931 static inline void RTC_HAL_SetLockRegLock(uint32_t rtcBaseAddr, bool lock)
932 {
933     BW_RTC_LR_LRL(rtcBaseAddr, (uint32_t) lock);
934 }
935
936 /*!
937  * @brief  Obtains the state of the status register lock.
938  *
939  * Reads the value of field Status Register Lock (SRL) of the RTC Lock Register (RTC_LR), which is the field Status Register.
940  *
941  * @param  rtcBaseAddr The RTC base address
942  *
943  * @return  true: Status register is not locked and writes complete as
944  *                normal.\n
945  *          false: Status register is locked and writes are ignored.
946  */
947 static inline bool RTC_HAL_GetStatusRegLock(uint32_t rtcBaseAddr)
948 {
949     return (bool)BR_RTC_LR_SRL(rtcBaseAddr);
950 }
951
952 /*!
953  * @brief Changes the state of the status register lock.
954  *
955  * Writes to the field Status Register Lock (SRL) of the RTC Lock Register (RTC_LR).
956  * Once cleared, this can only be set by VBAT POR or software reset.
957  *
958  * @param  rtcBaseAddr The RTC base address
959  * @param  lock can be true or false\n
960  *         true: Status register is not locked and writes complete as
961  *               normal.\n
962  *         false: Status register is locked and writes are ignored.
963  */
964 static inline void RTC_HAL_SetStatusRegLock(uint32_t rtcBaseAddr, bool lock)
965 {
966     BW_RTC_LR_SRL(rtcBaseAddr, (uint32_t) lock);
967 }
968
969 /*!
970  * @brief  Obtains the state of the control register lock.
971  *
972  * Reads the field Control Register Lock (CRL)value of the RTC Lock Register (RTC_LR).
973  *
974  * @param  rtcBaseAddr The RTC base address
975  *
976  * @return  true: Control register is not locked and writes complete as
977  *                 normal.\n
978  *          false: Control register is locked and writes are ignored.
979  */
980 static inline bool RTC_HAL_GetControlRegLock(uint32_t rtcBaseAddr)
981 {
982     return (bool)BR_RTC_LR_CRL(rtcBaseAddr);
983 }
984
985 /*!
986  * @brief  Changes the state of the control register lock.
987  *
988  * Writes to the field Control Register Lock (CRL) of the RTC Lock Register (RTC_LR).
989  * Once cleared, this can only be set by VBAT POR or software reset.
990  *
991  * @param  rtcBaseAddr The RTC base address
992  * @param  lock can be true or false\n
993  *         true: Control register is not locked and writes complete
994  *               as normal.\n
995  *         false: Control register is locked and writes are ignored.
996  */
997 static inline void RTC_HAL_SetControlRegLock(uint32_t rtcBaseAddr, bool lock)
998 {
999     BW_RTC_LR_CRL(rtcBaseAddr, (uint32_t) lock);
1000 }
1001
1002 /*!
1003  * @brief  Obtains the state of the time compensation lock.
1004  *
1005  * Reads the field Time Compensation Lock (TCL) value of the RTC Lock Register (RTC_LR).
1006  *
1007  * @param  rtcBaseAddr The RTC base address
1008  *
1009  * @return  true: Time compensation register is not locked and writes
1010  *                complete as normal.\n
1011  *          false: Time compensation register is locked and writes are
1012  *                 ignored.
1013  */
1014 static inline bool RTC_HAL_GetTimeCompLock(uint32_t rtcBaseAddr)
1015 {
1016     return (bool)BR_RTC_LR_TCL(rtcBaseAddr);
1017 }
1018
1019 /*!
1020  * @brief  Changes the state of the time compensation lock.
1021  *
1022  * Writes to the field Time Compensation Lock (TCL) of the RTC Lock Register (RTC_LR).
1023  * Once cleared, this can only be set by VBAT POR or software reset.
1024  *
1025  * @param  rtcBaseAddr The RTC base address
1026  * @param  lock can be true or false\n
1027  *         true: Time compensation register is not locked and writes
1028  *               complete as normal.\n
1029  *         false: Time compensation register is locked and writes are
1030  *                ignored.
1031  */
1032 static inline void RTC_HAL_SetTimeCompLock(uint32_t rtcBaseAddr, bool lock)
1033 {
1034     BW_RTC_LR_TCL(rtcBaseAddr, (uint32_t) lock);
1035 }
1036
1037 #if FSL_FEATURE_RTC_HAS_MONOTONIC
1038 /*!
1039  * @brief  Reads the value of the Monotonic Counter High Lock.
1040  *
1041  * @param  rtcBaseAddr The RTC base address
1042  *
1043  * @return  true: Monotonic counter high register is not locked and writes
1044  *                complete as normal.\n
1045  *          false: Monotonic counter high register is locked and writes are
1046  *                 ignored.
1047  */
1048 static inline bool RTC_HAL_ReadMonotonicHcounterLock(uint32_t rtcBaseAddr)
1049 {
1050     return (bool)BR_RTC_LR_MCHL(rtcBaseAddr);
1051 }
1052
1053 /*!
1054  * @brief  Writes 0 to the field Monotonic Counter High Lock (MCHL) of the RTC Lock Register (RTC_LR).
1055  *
1056  * Once done, this flag can only be set by VBAT POR or software reset.
1057  *
1058  * @param  rtcBaseAddr The RTC base address
1059  */
1060 static inline void RTC_HAL_ClearMonotonicHcounterLock(uint32_t rtcBaseAddr)
1061 {
1062     BW_RTC_LR_MCHL(rtcBaseAddr, 0U);
1063 }
1064
1065 /*!
1066  * @brief  Reads the value of the Monotonic Counter Low Lock.
1067  *
1068  * @param  rtcBaseAddr The RTC base address
1069  *
1070  * @return  true: Monotonic counter low register is not locked and writes
1071  *                complete as normal.\n
1072  *          false: Monotonic counter low register is locked and writes are
1073  *                 ignored.
1074  */
1075 static inline bool RTC_HAL_ReadMonotonicLcounterLock(uint32_t rtcBaseAddr)
1076 {
1077     return (bool)BR_RTC_LR_MCLL(rtcBaseAddr);
1078 }
1079
1080 /*!
1081  * @brief  Writes 0 to the field Monotonic Counter Low Lock (MCLL) of the RTC Lock Register (RTC_LR).
1082  *
1083  * Once done, this flag can only be set by VBAT POR or software reset.
1084  *
1085  * @param  rtcBaseAddr The RTC base address
1086  */
1087 static inline void RTC_HAL_ClearMonotonicLcounterLock(uint32_t rtcBaseAddr)
1088 {
1089     BW_RTC_LR_MCLL(rtcBaseAddr, 0U);
1090 }
1091
1092 /*!
1093  * @brief  Reads the value of the Monotonic Enable Lock.
1094  *
1095  * @param  rtcBaseAddr The RTC base address
1096  *
1097  * @return  true: Monotonic enable register is not locked and writes
1098  *                complete as normal.\n
1099  *          false: Monotonic enable register is locked and writes are
1100  *                 ignored.
1101  */
1102 static inline bool RTC_HAL_ReadMonotonicEnableLock(uint32_t rtcBaseAddr)
1103 {
1104     return (bool)BR_RTC_LR_MEL(rtcBaseAddr);
1105 }
1106
1107 /*!
1108  * @brief  Writes 0 to the Monotonic Enable Lock field of the RTC Lock Register (RTC_LR).
1109  *
1110  * Once done, this flag can only be set by VBAT POR or software reset.
1111  *
1112  * @param  rtcBaseAddr The RTC base address
1113  */
1114 static inline void RTC_HAL_ClearMonotonicEnableLock(uint32_t rtcBaseAddr)
1115 {
1116     BW_RTC_LR_MEL(rtcBaseAddr, 0U);
1117 }
1118 #endif
1119
1120 /*-------------------------------------------------------------------------------------------*/
1121 /* RTC Interrupt Enable*/
1122 /*-------------------------------------------------------------------------------------------*/
1123
1124 /*!
1125  * @brief  Checks whether the Time Seconds Interrupt is enabled/disabled.
1126  *
1127  * Reads the value of field Time Seconds Interrupt Enable (TSIE)of the RTC Interrupt Enable Register (RTC_IER). 
1128  * The seconds interrupt is an edge-sensitive
1129  * interrupt with a dedicated interrupt vector. It is generated once a second
1130  * and requires no software overhead (there is no corresponding status flag to
1131  * clear).
1132  *
1133  * @param  rtcBaseAddr The RTC base address
1134  *
1135  * @return  true: Seconds interrupt is enabled.\n
1136  *          false: Seconds interrupt is disabled.
1137  */
1138 static inline bool RTC_HAL_IsSecsIntEnabled(uint32_t rtcBaseAddr)
1139 {
1140     return (bool)BR_RTC_IER_TSIE(rtcBaseAddr);
1141 }
1142
1143 /*!
1144  * @brief  Enables/disables the Time Seconds Interrupt.
1145  *
1146  * Writes to the field Time Seconds
1147  * Interrupt Enable (TSIE) of the RTC Interrupt Enable Register (RTC_IER).
1148  * Note: The seconds interrupt is an edge-sensitive interrupt with a
1149  * dedicated interrupt vector. It is generated once a second and
1150  * requires no software overhead (there is no corresponding status
1151  * flag to clear).
1152  *
1153  * @param  rtcBaseAddr The RTC base address
1154  * @param  enable can be true or false\n
1155  *         true: Seconds interrupt is enabled.\n
1156  *         false: Seconds interrupt is disabled.
1157  */
1158 static inline void RTC_HAL_SetSecsIntCmd(uint32_t rtcBaseAddr, bool enable)
1159 {
1160     BW_RTC_IER_TSIE(rtcBaseAddr, (uint32_t) enable);
1161 }
1162
1163 #if FSL_FEATURE_RTC_HAS_MONOTONIC
1164
1165 /*!
1166  * @brief  Checks whether the Monotonic Overflow Interrupt is enabled/disabled.
1167  *
1168  * Reads the value of the RTC Interrupt Enable Register (RTC_IER), field
1169  * Monotonic Overflow Interrupt Enable (MOIE).
1170  *
1171  * @param  rtcBaseAddr The RTC base address
1172  *
1173  * @return  true: Monotonic overflow flag does generate an interrupt.\n
1174  *          false: Monotonic overflow flag does not generate an interrupt.
1175  */
1176 static inline bool RTC_HAL_ReadMonotonicOverflowInt(uint32_t rtcBaseAddr)
1177 {
1178     return (bool)BR_RTC_IER_MOIE(rtcBaseAddr);
1179 }
1180
1181 /*!
1182  * @brief  Enables/disables the Monotonic Overflow Interrupt Enable.
1183  *
1184  * @param  rtcBaseAddr The RTC base address
1185  * @param  enable can be true or false\n
1186  *         true: Monotonic overflow flag does generate an interrupt.\n
1187  *         false: Monotonic overflow flag does not generate an interrupt.
1188  */
1189 static inline void RTC_HAL_SetMonotonicOverflowIntCmd(uint32_t rtcBaseAddr, bool enable)
1190 {
1191     BW_RTC_IER_MOIE(rtcBaseAddr, (uint32_t)enable);
1192 }
1193
1194 #endif
1195
1196 /*!
1197  * @brief  Checks whether the Time Alarm Interrupt is enabled/disabled.
1198  *
1199  * Reads the field Time Alarm Interrupt Enable (TAIE) value of the RTC Interrupt Enable Register (RTC_IER).
1200  *
1201  * @param  rtcBaseAddr The RTC base address
1202  *
1203  * @return  true: Time alarm flag does generate an interrupt.\n
1204  *          false: Time alarm flag does not generate an interrupt.
1205  */
1206 static inline bool RTC_HAL_ReadAlarmInt(uint32_t rtcBaseAddr)
1207 {
1208     return (bool)BR_RTC_IER_TAIE(rtcBaseAddr);
1209 }
1210
1211 /*!
1212  * @brief  Enables/disables the Time Alarm Interrupt.
1213  *
1214  * Writes to the field Time Alarm
1215  * Interrupt Enable (TAIE) of the RTC Interrupt Enable Register (RTC_IER).
1216  *
1217  * @param  rtcBaseAddr The RTC base address
1218  * @param  enable can be true or false\n
1219  *         true: Time alarm flag does generate an interrupt.\n
1220  *         false: Time alarm flag does not generate an interrupt.
1221  */
1222 static inline void RTC_HAL_SetAlarmIntCmd(uint32_t rtcBaseAddr, bool enable)
1223 {
1224     BW_RTC_IER_TAIE(rtcBaseAddr, (uint32_t) enable);
1225 }
1226
1227 /*!
1228  * @brief  Checks whether the Time Overflow Interrupt is enabled/disabled.
1229  *
1230  * Reads the field
1231  * Time Overflow Interrupt Enable (TOIE) of the value of the RTC Interrupt Enable Register (RTC_IER).
1232  *
1233  * @param  rtcBaseAddr The RTC base address..
1234  *
1235  * @return  true: Time overflow flag does generate an interrupt.\n
1236  *          false: Time overflow flag does not generate an interrupt.
1237  */
1238 static inline bool RTC_HAL_ReadTimeOverflowInt(uint32_t rtcBaseAddr)
1239 {
1240     return (bool)BR_RTC_IER_TOIE(rtcBaseAddr);
1241 }
1242
1243 /*!
1244  * @brief  Enables/disables the Time Overflow Interrupt.
1245  *
1246  * Writes to the field Time Overflow Interrupt Enable (TOIE) of the RTC Interrupt Enable Register (RTC_IER).
1247  *
1248  * @param  rtcBaseAddr The RTC base address
1249  * @param  enable can be true or false\n
1250  *         true: Time overflow flag does generate an interrupt.\n
1251  *         false: Time overflow flag does not generate an interrupt.
1252  */
1253 static inline void RTC_HAL_SetTimeOverflowIntCmd(uint32_t rtcBaseAddr, bool enable)
1254 {
1255     BW_RTC_IER_TOIE(rtcBaseAddr, (uint32_t) enable);
1256 }
1257
1258 /*!
1259  * @brief  Checks whether the Time Invalid Interrupt is enabled/disabled.
1260  *
1261  * Reads the value of the field Time
1262  * Invalid Interrupt Enable (TIIE)of the RTC Interrupt Enable Register (RTC_IER).
1263  *
1264  * @param  rtcBaseAddr The RTC base address
1265  *
1266  * @return  true: Time invalid flag does generate an interrupt.\n
1267  *          false: Time invalid flag does not generate an interrupt.
1268  */
1269 static inline bool RTC_HAL_ReadTimeInvalidInt(uint32_t rtcBaseAddr)
1270 {
1271     return (bool)BR_RTC_IER_TIIE(rtcBaseAddr);
1272 }
1273
1274 /*!
1275  * @brief  Enables/disables the Time Invalid Interrupt.
1276  *
1277  * Writes to the field Time Invalid
1278  * Interrupt Enable (TIIE) of the RTC Interrupt Enable Register (RTC_IER).
1279  *
1280  * @param  rtcBaseAddr The RTC base address
1281  * @param  enable can be true or false\n
1282  *         true: Time invalid flag does generate an interrupt.\n
1283  *         false: Time invalid flag does not generate an interrupt.
1284  */
1285 static inline void RTC_HAL_SetTimeInvalidIntCmd(uint32_t rtcBaseAddr, bool enable)
1286 {
1287     BW_RTC_IER_TIIE(rtcBaseAddr, (uint32_t) enable);
1288 }
1289
1290 #if FSL_FEATURE_RTC_HAS_MONOTONIC
1291
1292 /*-------------------------------------------------------------------------------------------*/
1293 /* RTC Monotonic Enable*/
1294 /*-------------------------------------------------------------------------------------------*/
1295
1296 /*!
1297  * @brief  Reads the Monotonic Counter Enable bit.
1298  *
1299  * @param  rtcBaseAddr The RTC base address
1300  *
1301  * @return true: This means writing to the monotonic counter increments the counter by one and
1302  *               the value written is ignored.\n
1303  *         false: This means writing to the monotonic counter loads the counter with the
1304  *                value written.
1305  */
1306 static inline bool RTC_HAL_ReadMonotonicEnable(uint32_t rtcBaseAddr)
1307 {
1308     /* Reads value of the RTC_MER register, field Monotonic Counter Enable (MCE). */
1309     return (bool)BR_RTC_MER_MCE(rtcBaseAddr);
1310 }
1311
1312 /*!
1313  * @brief  Changes the state of Monotonic Counter Enable bit.
1314  *
1315  * @param  rtcBaseAddr The RTC base address
1316  * @param  enable value to be written to the MER[MCE] bit\n
1317  *         true: Set the bit to 1 which means writing to the monotonic counter will increment
1318  *               the counter by one and the value written will be ignored.\n
1319  *         false: Set the bit to 0 which means writing to the monotonic counter loads the counter
1320  *                with the value written.
1321  */
1322 static inline void RTC_HAL_SetMonotonicEnableCmd(uint32_t rtcBaseAddr, bool enable)
1323 {
1324     /* Writes to the RTC_MER registers Monotonic Counter Enable (MCE) bit.*/
1325     BW_RTC_MER_MCE(rtcBaseAddr, (uint32_t) enable);
1326 }
1327
1328 /*!
1329  * @brief  Reads the values of the Monotonic Counter Low register.
1330  *
1331  * @param  rtcBaseAddr The RTC base address
1332  *
1333  * @return  Monotonic Counter Low value.
1334  */
1335 static inline uint32_t RTC_HAL_GetMonotonicCounterLow(uint32_t rtcBaseAddr)
1336 {
1337     return BR_RTC_MCLR_MCL(rtcBaseAddr);
1338 }
1339
1340 /*!
1341  * @brief  Reads the values of the Monotonic Counter High register.
1342  *
1343  * @param  rtcBaseAddr The RTC base address
1344  *
1345  * @return  Monotonic Counter High value.
1346  */
1347 static inline uint32_t RTC_HAL_GetMonotonicCounterHigh(uint32_t rtcBaseAddr)
1348 {
1349     return BR_RTC_MCHR_MCH(rtcBaseAddr);
1350 }
1351
1352 /*!
1353  * @brief  Writes values of the Monotonic Counter Low register.
1354  *
1355  * @param  rtcBaseAddr The RTC base address
1356  * @param  counter [in] Monotonic Counter Low value to be stored.
1357  */
1358 static inline void RTC_HAL_SetMonotonicCounterLow(uint32_t rtcBaseAddr, const uint32_t counter)
1359 {
1360     /* enable writing to the counter*/
1361     BW_RTC_MER_MCE(rtcBaseAddr, 0U);
1362     BW_RTC_MCLR_MCL(rtcBaseAddr, counter);
1363 }
1364
1365 /*!
1366  * @brief  Writes values of the Monotonic Counter High register.
1367  *
1368  * @param  rtcBaseAddr The RTC base address
1369  * @param  counter [in] Monotonic Counter High value to be stored.
1370  */
1371 static inline void RTC_HAL_SetMonotonicCounterHigh(uint32_t rtcBaseAddr, const uint32_t counter)
1372 {
1373     /* enable writing to the counter*/
1374     BW_RTC_MER_MCE(rtcBaseAddr, 0U);
1375     BW_RTC_MCHR_MCH(rtcBaseAddr, counter);
1376 }
1377
1378 #endif /* FSL_FEATURE_RTC_HAS_MONOTONIC */
1379
1380 #if FSL_FEATURE_RTC_HAS_ACCESS_CONTROL
1381
1382 #if FSL_FEATURE_RTC_HAS_MONOTONIC
1383 /*!
1384  * @brief  Reads the field Monotonic Counter High Write (MCHW) value of the register RTC_WAR.
1385  *
1386  * @param  rtcBaseAddr The RTC base address
1387  *
1388  * @return  true: Writes to the monotonic counter high register will complete as normal.\n
1389  *          false: Writes to the monotonic counter high register are ignored.
1390  */
1391 static inline bool RTC_HAL_GetMonotonicHcountWreg(uint32_t rtcBaseAddr)
1392 {
1393     return (bool)BR_RTC_WAR_MCHW(rtcBaseAddr);
1394 }
1395
1396 /*!
1397  * @brief  Writes 0 to the field Monotonic Counter High Write (MCHW) of the RTC_WAR register.
1398  *
1399  * Once cleared, this bit is only set by system reset. It is not affected by
1400  * VBAT POR or software reset.
1401  *
1402  * @param  rtcBaseAddr The RTC base address
1403  */
1404 static inline void RTC_HAL_ClearMonotonicHcountWreg(uint32_t rtcBaseAddr)
1405 {
1406     BW_RTC_WAR_MCHW(rtcBaseAddr, 0U);
1407 }
1408
1409 /*!
1410  * @brief  Reads the field Monotonic Counter Low Write (MCLW) value of the register RTC_WAR.
1411  *
1412  * @param  rtcBaseAddr The RTC base address
1413  *
1414  * @return  true: Writes to the monotonic counter low register will complete as normal.\n
1415  *          false: Writes to the monotonic counter low register are ignored.
1416  */
1417 static inline bool RTC_HAL_GetMonotonicLcountWreg(uint32_t rtcBaseAddr)
1418 {
1419     return (bool)BR_RTC_WAR_MCLW(rtcBaseAddr);
1420 }
1421
1422 /*!
1423  * @brief  Writes 0 to the field Monotonic Counter High Write (MCLW) of the RTC_WAR register.
1424  *
1425  * Once cleared, this bit is only set by  the system reset. It is not affected by
1426  * VBAT POR or software reset.
1427  *
1428  * @param  rtcBaseAddr The RTC base address..
1429  */
1430 static inline void RTC_HAL_ClearMonotonicLcountWreg(uint32_t rtcBaseAddr)
1431 {
1432     BW_RTC_WAR_MCLW(rtcBaseAddr, 0U);
1433 }
1434
1435 /*!
1436  * @brief  Reads the field Monotonic Enable Register Write (MERW) value of the register RTC_WAR.
1437  *
1438  * @param  rtcBaseAddr The RTC base address
1439  *
1440  * @return  true: Writes to the monotonic enable register will complete as normal.\n
1441  *          false: Writes to the monotonic enable register are ignored.
1442  */
1443 static inline bool RTC_HAL_GetMonotonicEnableWreg(uint32_t rtcBaseAddr)
1444 {
1445     return (bool)BR_RTC_WAR_MERW(rtcBaseAddr);
1446 }
1447
1448 /*!
1449  * @brief  Writes 0 to the field Monotonic Counter High Write (MERW) of the RTC_WAR register.
1450  *
1451  * Once cleared, this bit is only set by system reset. It is not affected by
1452  * VBAT POR or software reset.
1453  *
1454  * @param  rtcBaseAddr The RTC base address
1455  */
1456 static inline void RTC_HAL_ClearMonotonicEnableWreg(uint32_t rtcBaseAddr)
1457 {
1458     BW_RTC_WAR_MERW(rtcBaseAddr, 0U);
1459 }
1460 #endif
1461
1462 /*!
1463  * @brief Reads the field Interrupt Enable Register Write (IERW) value of the register RTC_WAR.
1464  *
1465  * @param  rtcBaseAddr The RTC base address
1466  *
1467  * @return true: Writes to the interrupt enable register will complete as normal.\n
1468  *         false: Writes to the interrupt enable register are ignored.
1469  */
1470 static inline bool RTC_HAL_GetIntEnableWreg(uint32_t rtcBaseAddr)
1471 {
1472     return (bool)BR_RTC_WAR_IERW(rtcBaseAddr);
1473 }
1474
1475 /*!
1476  * @brief  Writes 0 to the field Interrupt Enable Register Write (IERW) of the RTC_WAR register.
1477  *
1478  * Once cleared, this bit is only set by system reset. It is not affected by
1479  * VBAT POR or software reset.
1480  *
1481  * @param  rtcBaseAddr The RTC base address
1482  */
1483 static inline void RTC_HAL_ClearIntEnableWreg(uint32_t rtcBaseAddr)
1484 {
1485     BW_RTC_WAR_IERW(rtcBaseAddr, 0U);
1486 }
1487
1488 /*!
1489  * @brief  Reads the field Lock Register Write (LRW) value of the register RTC_WAR.
1490  *
1491  * @param  rtcBaseAddr The RTC base address
1492  *
1493  * @return  true: Writes to the lock register will complete as normal.\n
1494  *          false: Writes to the lock register are ignored.
1495  */
1496 static inline bool RTC_HAL_GetLockWreg(uint32_t rtcBaseAddr)
1497 {
1498     return (bool)BR_RTC_WAR_LRW(rtcBaseAddr);
1499 }
1500
1501 /*!
1502  * @brief  Writes 0 to the field Lock Register Write (LRW) of the RTC_WAR register.
1503  *
1504  * Once cleared, this bit is only set by system reset. It is not affected by
1505  * VBAT POR or software reset.
1506  *
1507  * @param  rtcBaseAddr The RTC base address
1508  */
1509 static inline void RTC_HAL_ClearLockWreg(uint32_t rtcBaseAddr)
1510 {
1511     BW_RTC_WAR_LRW(rtcBaseAddr, 0U);
1512 }
1513
1514 /*!
1515  * @brief  Reads the field Status Register Write (SRW) value of the register RTC_WAR.
1516  *
1517  * @param  rtcBaseAddr The RTC base address
1518  *
1519  * @return  true: Writes to the status register completes as normal.\n
1520  *          false: Writes to the status register are ignored.
1521  */
1522 static inline bool RTC_HAL_GetStatusWreg(uint32_t rtcBaseAddr)
1523 {
1524     return (bool)BR_RTC_WAR_SRW(rtcBaseAddr);
1525 }
1526
1527 /*!
1528  * @brief  Writes 0 to the field Status Register Write (SRW) of the RTC_WAR register.
1529  *
1530  * Once cleared, this bit is only set by system reset. It is not affected by
1531  * VBAT POR or software reset.
1532  *
1533  * @param  rtcBaseAddr The RTC base address
1534  */
1535 static inline void RTC_HAL_ClearStatusWreg(uint32_t rtcBaseAddr)
1536 {
1537     BW_RTC_WAR_SRW(rtcBaseAddr, 0U);
1538 }
1539
1540 /*!
1541  * @brief  Reads the field Control Register Write (CRW) value of the register RTC_WAR.
1542  *
1543  * @param  rtcBaseAddr The RTC base address
1544  *
1545  * @return  true: Writes to the control register will complete as normal.\n
1546  *          false: Writes to the control register are ignored.
1547  */
1548 static inline bool RTC_HAL_GetControlWreg(uint32_t rtcBaseAddr)
1549 {
1550     return (bool)BR_RTC_WAR_CRW(rtcBaseAddr);
1551 }
1552
1553 /*!
1554  * @brief  Writes 0 to the field Control Register Write (CRW) of the RTC_WAR register.
1555  *
1556  * Once cleared, this bit is only set by system reset. It is not affected by
1557  * VBAT POR or software reset.
1558  *
1559  * @param  rtcBaseAddr The RTC base address
1560  */
1561 static inline void RTC_HAL_ClearControlWreg(uint32_t rtcBaseAddr)
1562 {
1563     BW_RTC_WAR_CRW(rtcBaseAddr, 0U);
1564 }
1565
1566 /*!
1567  * @brief  Reads the field Time Compensation Register Write (TCRW) value of the register RTC_WAR.
1568  *
1569  * @param  rtcBaseAddr The RTC base address
1570  *
1571  * @return  true: Writes to the time compensation register will complete as normal.\n
1572  *          false: Writes to the time compensation register are ignored.
1573  */
1574 static inline bool RTC_HAL_GetCompensationWreg(uint32_t rtcBaseAddr)
1575 {
1576     return (bool)BR_RTC_WAR_TCRW(rtcBaseAddr);
1577 }
1578
1579 /*!
1580  * @brief  Writes 0 to the field Time Compensation Register Write (TCRW) of the RTC_WAR register.
1581  *
1582  * Once cleared, this bit is only set by system reset. It is not affected by
1583  * VBAT POR or software reset.
1584  *
1585  * @param  rtcBaseAddr The RTC base address
1586  */
1587 static inline void RTC_HAL_ClearCompensationWreg(uint32_t rtcBaseAddr)
1588 {
1589     BW_RTC_WAR_TCRW(rtcBaseAddr, 0U);
1590 }
1591
1592 /*!
1593  * @brief  Reads the field Time Alarm Register Write (TARW) value of the register RTC_WAR.
1594  *
1595  * @param  rtcBaseAddr The RTC base address
1596  *
1597  * @return  true: Writes to the time alarm register will complete as normal.\n
1598  *          false: Writes to the time alarm register are ignored.
1599  */
1600 static inline bool RTC_HAL_GetAlarmWreg(uint32_t rtcBaseAddr)
1601 {
1602     return (bool)BR_RTC_WAR_TARW(rtcBaseAddr);
1603 }
1604
1605 /*!
1606  * @brief  Writes 0 to the field Time Alarm Register Write (TARW) of the RTC_WAR register.
1607  *
1608  * Once cleared, this bit is only set by system reset. It is not affected by
1609  * VBAT POR or software reset.
1610  *
1611  * @param  rtcBaseAddr The RTC base address
1612  */
1613 static inline void RTC_HAL_ClearAlarmWreg(uint32_t rtcBaseAddr)
1614 {
1615     BW_RTC_WAR_TARW(rtcBaseAddr, 0U);
1616 }
1617
1618 /*!
1619  * @brief  Reads the field Time Prescaler Register Write (TPRW) value of the register RTC_WAR.
1620  *
1621  * @param  rtcBaseAddr The RTC base address
1622  *
1623  * @return  true: Writes to the time prescaler register will complete as normal.\n
1624  *          false: Writes to the time prescaler register are ignored.
1625  */
1626 static inline bool RTC_HAL_GetPrescalerWreg(uint32_t rtcBaseAddr)
1627 {
1628     return (bool)BR_RTC_WAR_TPRW(rtcBaseAddr);
1629 }
1630
1631 /*!
1632  * @brief  Writes 0 to the field Time Prescaler Register Write (TPRW) of the RTC_WAR register.
1633  *
1634  * Once cleared, this bit is only set by system reset. It is not affected by
1635  * VBAT POR or software reset.
1636  *
1637  * @param  rtcBaseAddr The RTC base address
1638  */
1639 static inline void RTC_HAL_ClearPrescalerWreg(uint32_t rtcBaseAddr)
1640 {
1641     BW_RTC_WAR_TPRW(rtcBaseAddr, 0U);
1642 }
1643
1644 /*!
1645  * @brief  Reads the field Time Seconds Register Write (TSRW) value of the register RTC_WAR.
1646  *
1647  * @param  rtcBaseAddr The RTC base address
1648  *
1649  * @return  true: Writes to the time seconds register will complete as normal.\n
1650  *          false: Writes to the time seconds register are ignored.
1651  */
1652 static inline bool RTC_HAL_GetSecsWreg(uint32_t rtcBaseAddr)
1653 {
1654     return (bool)BR_RTC_WAR_TSRW(rtcBaseAddr);
1655 }
1656
1657 /*!
1658  * @brief  Writes 0 to the field Time Seconds Register Write (TSRW) of the RTC_WAR register.
1659  *
1660  * Once cleared, this bit is only set by system reset. It is not affected by
1661  * VBAT POR or software reset.
1662  *
1663  * @param  rtcBaseAddr The RTC base address
1664  */
1665 static inline void RTC_HAL_ClearSecsWreg(uint32_t rtcBaseAddr)
1666 {
1667     BW_RTC_WAR_TSRW(rtcBaseAddr, 0U);
1668 }
1669
1670 #if FSL_FEATURE_RTC_HAS_MONOTONIC
1671
1672 /*!
1673  * @brief  Reads the field Monotonic Counter High Read (MCHR) value of the register RTC_RAR.
1674  *
1675  * @param  rtcBaseAddr The RTC base address
1676  *
1677  * @return true: Reads to the monotonic counter high register completes as normal.\n
1678  *         false: Reads to the monotonic counter high register are ignored.
1679  */
1680 static inline bool RTC_HAL_GetMonotonicHcountRreg(uint32_t rtcBaseAddr)
1681 {
1682     return (bool)BR_RTC_RAR_MCHR(rtcBaseAddr);
1683 }
1684
1685 /*!
1686  * @brief  Writes 0 to the field Monotonic Counter High Read (MCHR) of the RTC_RAR register.
1687  *
1688  * Once cleared, this bit is only set by system reset. It is not affected by
1689  * VBAT POR or software reset.
1690  *
1691  * @param  rtcBaseAddr The RTC base address
1692  */
1693 static inline void RTC_HAL_ClearMonotonicHcountRreg(uint32_t rtcBaseAddr)
1694 {
1695     BW_RTC_RAR_MCHR(rtcBaseAddr, 0U);
1696 }
1697
1698 /*!
1699  * @brief  Reads the field Monotonic Counter Low Read (MCLR) value of the register RTC_RAR.
1700  *
1701  * @param  rtcBaseAddr The RTC base address
1702  *
1703  * @return  true: Reads to the monotonic counter low register will complete as normal.\n
1704  *          false: Reads to the monotonic counter low register are ignored.
1705  */
1706 static inline bool RTC_HAL_GetMonotonicLcountRreg(uint32_t rtcBaseAddr)
1707 {
1708     return (bool)BR_RTC_RAR_MCLR(rtcBaseAddr);
1709 }
1710
1711 /*!
1712  * @brief  Writes 0 to the field Monotonic Counter Low Read (MCLR) of the RTC_RAR register.
1713  *
1714  * Once cleared, this bit is only set by system reset. It is not affected by
1715  * VBAT POR or software reset.
1716  *
1717  * @param  rtcBaseAddr The RTC base address
1718  */
1719 static inline void RTC_HAL_ClearMonotonicLcountRreg(uint32_t rtcBaseAddr)
1720 {
1721     BW_RTC_RAR_MCLR(rtcBaseAddr, 0U);
1722 }
1723
1724 /*!
1725  * @brief  Reads the field Monotonic Enable Register Read (MERR) value of the register RTC_RAR.
1726  *
1727  * @param  rtcBaseAddr The RTC base address
1728  *
1729  * @return  true: Reads to the monotonic enable register  completes as normal.\n
1730  *          false: Reads to the monotonic enable register are ignored.
1731  */
1732 static inline bool RTC_HAL_GetMonotonicEnableRreg(uint32_t rtcBaseAddr)
1733 {
1734     return (bool)BR_RTC_RAR_MERR(rtcBaseAddr);
1735 }
1736
1737 /*!
1738  * @brief  Writes 0 to the field Monotonic Enable Register Read (MERR) of the RTC_RAR register.
1739  *
1740  * Once cleared, this bit is only set by system reset. It is not affected by
1741  * VBAT POR or software reset.
1742  *
1743  * @param  rtcBaseAddr The RTC base address
1744  */
1745 static inline void RTC_HAL_ClearMonotonicEnableRreg(uint32_t rtcBaseAddr)
1746 {
1747     BW_RTC_RAR_MERR(rtcBaseAddr, 0U);
1748 }
1749
1750 #endif
1751
1752 /*!
1753  * @brief  Reads the field Interrupt Enable Register Read (IERR) value of the register RTC_RAR.
1754  *
1755  * @param  rtcBaseAddr The RTC base address
1756  *
1757  * @return  true: Reads to the interrupt enable register  completes as normal.\n
1758  *          false: Reads to the interrupt enable register are ignored.
1759  */
1760 static inline bool RTC_HAL_GetIntEnableRreg(uint32_t rtcBaseAddr)
1761 {
1762     return (bool)BR_RTC_RAR_IERR(rtcBaseAddr);
1763 }
1764
1765 /*!
1766  * @brief  Writes 0 to the field Interrupt Enable Register Read (IERR) of the RTC_RAR register.
1767  *
1768  * Once cleared, this bit is only set by system reset. It is not affected by
1769  * VBAT POR or software reset.
1770  *
1771  * @param  rtcBaseAddr The RTC base address
1772  */
1773 static inline void RTC_HAL_ClearIntEnableRreg(uint32_t rtcBaseAddr)
1774 {
1775     BW_RTC_RAR_IERR(rtcBaseAddr, 0U);
1776 }
1777
1778 /*!
1779  * @brief  Reads the field Lock Register Read (LRR) value of the RTC_RAR register.
1780  *
1781  * @param  rtcBaseAddr The RTC base address
1782  *
1783  * @return  true: Reads to the lock register will complete as normal.\n
1784  *          false: Reads to the lock register are ignored.
1785  */
1786 static inline bool RTC_HAL_GetLockRreg(uint32_t rtcBaseAddr)
1787 {
1788   return (bool)BR_RTC_RAR_LRR(rtcBaseAddr);
1789 }
1790
1791 /*!
1792  * @brief  Writes 0 to the field Lock Register Read (LRR) of the RTC_RAR register.
1793  *
1794  * Once cleared, this bit is only set by system reset. It is not affected by
1795  * VBAT POR or software reset.
1796  *
1797  * @param  rtcBaseAddr The RTC base address
1798  */
1799 static inline void RTC_HAL_ClearLockRreg(uint32_t rtcBaseAddr)
1800 {
1801     BW_RTC_RAR_LRR(rtcBaseAddr, 0U);
1802 }
1803
1804 /*!
1805  * @brief  Reads the field Status Register Read (SRR) value of the RTC_RAR register.
1806  *
1807  * @param  rtcBaseAddr The RTC base address
1808  *
1809  * @return  true: Reads to the status register  completes as normal.\n
1810  *          false: Reads to the status register are ignored.
1811  */
1812 static inline bool RTC_HAL_GetStatusRreg(uint32_t rtcBaseAddr)
1813 {
1814     return (bool)BR_RTC_RAR_SRR(rtcBaseAddr);
1815 }
1816
1817 /*!
1818  * @brief  Writes 0 to the field Status Register Read (SRR) of the RTC_RAR register.
1819  *
1820  * Once cleared, this bit is only set by system reset. It is not affected by
1821  * VBAT POR or software reset.
1822  *
1823  * @param  rtcBaseAddr The RTC base address
1824  */
1825 static inline void RTC_HAL_ClearStatusRreg(uint32_t rtcBaseAddr)
1826 {
1827     BW_RTC_RAR_SRR(rtcBaseAddr, 0U);
1828 }
1829
1830 /*!
1831  * @brief  Reads the field Control Register Read (CRR) value of the RTC_RAR register.
1832  *
1833  * @param  rtcBaseAddr The RTC base address
1834  *
1835  * @return  true: Reads to the control register completes as normal.\n
1836  *          false: Reads to the control register are ignored.
1837  */
1838 static inline bool RTC_HAL_GetControlRreg(uint32_t rtcBaseAddr)
1839 {
1840     return (bool)BR_RTC_RAR_CRR(rtcBaseAddr);
1841 }
1842
1843 /*!
1844  * @brief  Writes 0 to the field Control Register Read (CRR) of the RTC_RAR register.
1845  *
1846  * Once cleared, this bit is only set by system reset. It is not affected by
1847  * VBAT POR or software reset.
1848  *
1849  * @param  rtcBaseAddr The RTC base address
1850  */
1851 static inline void RTC_HAL_ClearControlRreg(uint32_t rtcBaseAddr)
1852 {
1853     BW_RTC_RAR_CRR(rtcBaseAddr, 0U);
1854 }
1855
1856 /*!
1857  * @brief  Reads the field Time Compensation Register Read (TCRR) value of the RTC_RAR register.
1858  *
1859  * @param  rtcBaseAddr The RTC base address
1860  *
1861  * @return  true: Reads to the time compensation register completes as normal.\n
1862  *          false: Reads to the time compensation register are ignored.
1863  */
1864 static inline bool RTC_HAL_GetCompensationRreg(uint32_t rtcBaseAddr)
1865 {
1866     return (bool)BR_RTC_RAR_TCRR(rtcBaseAddr);
1867 }
1868
1869 /*!
1870  * @brief  Writes 0 to the field Time Compensation Register Read (TCRR) of the RTC_RAR register.
1871  *
1872  * Once cleared, this bit is only set by system reset. It is not affected by
1873  * VBAT POR or software reset.
1874  *
1875  * @param  rtcBaseAddr The RTC base address
1876  */
1877 static inline void RTC_HAL_ClearCompensationRreg(uint32_t rtcBaseAddr)
1878 {
1879     BW_RTC_RAR_TCRR(rtcBaseAddr, 0U);
1880 }
1881
1882 /*!
1883  * @brief  Reads the field Time Alarm Register Read (TARR) value of the RTC_RAR register.
1884  *
1885  * @param  rtcBaseAddr The RTC base address
1886  *
1887  * @return  true: Reads to the time alarm register completes as normal.\n
1888  *          false: Reads to the time alarm register are ignored.
1889  */
1890 static inline bool RTC_HAL_GetAlarmRreg(uint32_t rtcBaseAddr)
1891 {
1892     return (bool)BR_RTC_RAR_TARR(rtcBaseAddr);
1893 }
1894
1895 /*!
1896  * @brief  Writes 0 to the field Time Alarm Register Read (TARR) of the RTC_RAR register.
1897  *
1898  * Once cleared, this bit is only set by system reset. It is not affected by
1899  * VBAT POR or software reset.
1900  *
1901  * @param  rtcBaseAddr The RTC base address
1902  */
1903 static inline void RTC_HAL_ClearAlarmRreg(uint32_t rtcBaseAddr)
1904 {
1905     BW_RTC_RAR_TARR(rtcBaseAddr, 0U);
1906 }
1907
1908 /*!
1909  * @brief  Reads the field Time Prescaler Register Read (TPRR) value of the RTC_RAR register.
1910  *
1911  * @param  rtcBaseAddr The RTC base address
1912  *
1913  * @return  true: Reads to the time prescaler register completes as normal.\n
1914  *          false: Reads to the time prescaler register are ignored.
1915  */
1916 static inline bool RTC_HAL_GetPrescalerRreg(uint32_t rtcBaseAddr)
1917 {
1918     return (bool)BR_RTC_RAR_TPRR(rtcBaseAddr);
1919 }
1920
1921 /*!
1922  * @brief  Writes 0 to the field Time Prescaler Register Read (TPRR) of the RTC_RAR register.
1923  *
1924  * Once cleared, this bit is only set by system reset. It is not affected by
1925  * VBAT POR or software reset.
1926  *
1927  * @param  rtcBaseAddr The RTC base address
1928  */
1929 static inline void RTC_HAL_ClearPrescalerRreg(uint32_t rtcBaseAddr)
1930 {
1931     BW_RTC_RAR_TPRR(rtcBaseAddr, 0U);
1932 }
1933
1934 /*!
1935  * @brief  Reads the field Time Seconds Register Read (TSRR) value of the RTC_RAR register.
1936  *
1937  * @param  rtcBaseAddr The RTC base address
1938  *
1939  * @return  true: Reads to the time seconds register completes as normal.\n
1940  *          false: Reads to the time seconds register are ignored.
1941  */
1942 static inline bool RTC_HAL_GetSecsRreg(uint32_t rtcBaseAddr)
1943 {
1944     return (bool)BR_RTC_RAR_TSRR(rtcBaseAddr);
1945 }
1946
1947 /*!
1948  * @brief  Writes 0 to the field Time Seconds Register Read (TSRR) of the RTC_RAR register.
1949  *
1950  * Once cleared, this bit is only set by system reset. It is not affected by
1951  * VBAT POR or software reset.
1952  *
1953  * @param  rtcBaseAddr The RTC base address
1954  */
1955 static inline void RTC_HAL_ClearSecsRreg(uint32_t rtcBaseAddr)
1956 {
1957     BW_RTC_RAR_TSRR(rtcBaseAddr, 0U);
1958 }
1959
1960 #endif /* FSL_FEATURE_RTC_HAS_ACCESS_CONTROL */
1961
1962 /*! @}*/
1963
1964 #if defined(__cplusplus)
1965 }
1966 #endif
1967
1968
1969 /*! @}*/
1970
1971 #endif /* __FSL_RTC_HAL_H__*/
1972
1973 /*******************************************************************************
1974  * EOF
1975  ******************************************************************************/
1976