1 /**
2  * @file xmc_rtc.h
3  * @date 2016-05-19
4  *
5  * @cond
6  *********************************************************************************************************************
7  * XMClib v2.1.24 - XMC Peripheral Driver Library
8  *
9  * Copyright (c) 2015-2019, Infineon Technologies AG
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
13  * following conditions are met:
14  *
15  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
16  * disclaimer.
17  *
18  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided with the distribution.
20  *
21  * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
22  * products derived from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with
33  * Infineon Technologies AG dave@infineon.com).
34  *********************************************************************************************************************
35  *
36  * Change History
37  * --------------
38  *
39  * 2015-02-20:
40  *     - Initial
41  *
42  * 2015-05-20:
43  *     - Documentation updates <br>
44  *     - In xmc1_rtc file XMC_RTC_Init function
45  *       is modified by adding the RTC running condition check
46  *
47  * 2015-06-20:
48  *     - Removed version macros and declaration of GetDriverVersion API
49  *
50  * 2016-05-19:
51  *     - Added XMC_RTC_SetTimeStdFormat() and XMC_RTC_SetAlarmStdFormat()
52  *
53  * @endcond
54  *
55  */
56 
57 #ifndef XMC_RTC_H
58 #define XMC_RTC_H
59 
60 /*********************************************************************************************************************
61  * HEADER FILES
62  *********************************************************************************************************************/
63 
64 #include <xmc_common.h>
65 #include <time.h>
66 
67 /**
68  *
69  * @addtogroup XMClib XMC Peripheral Library
70  * @{
71  */
72 
73 /**
74  * @addtogroup RTC
75  * @brief RTC driver for XMC microcontroller family.
76  *
77  * Real-time clock (RTC) is a clock that keeps track of the current time. Precise
78  * real time keeping is with a 32.768 KHz external crystal clock or a 32.768 KHz
79  * high precision internal clock. It provides a periodic time based interrupt and
80  * a programmable alarm interrupt on time match. It also supports wakeup from
81  * hibernate.
82  *
83  * The RTC low level driver provides functions to configure and initialize the RTC
84  * hardware peripheral.
85  *
86  * @{
87  */
88 
89 /*********************************************************************************************************************
90  * MACROS
91  *********************************************************************************************************************/
92 
93 /*********************************************************************************************************************
94  * ENUMS
95  *********************************************************************************************************************/
96 
97 /**
98  *  Status return values for RTC low level driver
99  */
100 typedef enum XMC_RTC_STATUS
101 {
102   XMC_RTC_STATUS_OK    = 0U, /**< Operation successful */
103   XMC_RTC_STATUS_ERROR = 1U, /**< Operation unsuccessful */
104   XMC_RTC_STATUS_BUSY  = 2U  /**< Busy with a previous request */
105 } XMC_RTC_STATUS_t;
106 
107 /**
108  * Events which enables interrupt request generation
109  */
110 typedef enum XMC_RTC_EVENT
111 {
112   XMC_RTC_EVENT_PERIODIC_SECONDS = RTC_MSKSR_MPSE_Msk, /**< Mask value to enable an event on periodic seconds */
113   XMC_RTC_EVENT_PERIODIC_MINUTES = RTC_MSKSR_MPMI_Msk, /**< Mask value to enable an event on periodic seconds */
114   XMC_RTC_EVENT_PERIODIC_HOURS   = RTC_MSKSR_MPHO_Msk, /**< Mask value to enable an event on periodic seconds */
115   XMC_RTC_EVENT_PERIODIC_DAYS    = RTC_MSKSR_MPDA_Msk, /**< Mask value to enable an event on periodic seconds */
116   XMC_RTC_EVENT_PERIODIC_MONTHS  = RTC_MSKSR_MPMO_Msk, /**< Mask value to enable an event on periodic seconds */
117   XMC_RTC_EVENT_PERIODIC_YEARS   = RTC_MSKSR_MPYE_Msk, /**< Mask value to enable an event on periodic seconds */
118   XMC_RTC_EVENT_ALARM            = RTC_MSKSR_MAI_Msk   /**< Mask value to enable an event on periodic seconds */
119 } XMC_RTC_EVENT_t;
120 
121 /**
122  *  Months used to program the date
123  */
124 typedef enum XMC_RTC_MONTH
125 {
126   XMC_RTC_MONTH_JANUARY   = 0U,
127   XMC_RTC_MONTH_FEBRUARY  = 1U,
128   XMC_RTC_MONTH_MARCH     = 2U,
129   XMC_RTC_MONTH_APRIL     = 3U,
130   XMC_RTC_MONTH_MAY       = 4U,
131   XMC_RTC_MONTH_JUNE      = 5U,
132   XMC_RTC_MONTH_JULY      = 6U,
133   XMC_RTC_MONTH_AUGUST    = 7U,
134   XMC_RTC_MONTH_SEPTEMBER = 8U,
135   XMC_RTC_MONTH_OCTOBER   = 9U,
136   XMC_RTC_MONTH_NOVEMBER  = 10U,
137   XMC_RTC_MONTH_DECEMBER  = 11U
138 } XMC_RTC_MONTH_t;
139 
140 /**
141  *  Week days used program the date
142  */
143 typedef enum XMC_RTC_WEEKDAY
144 {
145   XMC_RTC_WEEKDAY_SUNDAY    = 0U,
146   XMC_RTC_WEEKDAY_MONDAY    = 1U,
147   XMC_RTC_WEEKDAY_TUESDAY   = 2U,
148   XMC_RTC_WEEKDAY_WEDNESDAY = 3U,
149   XMC_RTC_WEEKDAY_THURSDAY  = 4U,
150   XMC_RTC_WEEKDAY_FRIDAY    = 5U,
151   XMC_RTC_WEEKDAY_SATURDAY  = 6U
152 } XMC_RTC_WEEKDAY_t;
153 
154 /*********************************************************************************************************************
155  * DATA STRUCTURES
156  *********************************************************************************************************************/
157 /*Anonymous structure/union guard start*/
158 #if defined(__CC_ARM)
159   #pragma push
160   #pragma anon_unions
161 #elif defined(__TASKING__)
162   #pragma warning 586
163 #endif
164 
165 
166 /**
167  * Alarm time values of RTC  <br>
168  *
169  * The structure presents a convenient way to set/obtain the
170  * alarm time values for seconds, minutes, hours, days, month and year of RTC.
171  * The XMC_RTC_SetAlarm() and XMC_RTC_GetAlarm() can be
172  * used to populate the structure with the alarm time value of
173  * RTC
174  */
175 typedef struct XMC_RTC_ALARM
176 {
177   union
178   {
179 	  uint32_t raw0;
180 	  struct
181 	  {
182 	    uint32_t seconds  : 6; /**< Alarm seconds compare value (0-59: Above this causes this bitfield to be set with 0)*/
183 	    uint32_t          : 2;
184 	    uint32_t minutes  : 6; /**< Alarm minutes compare value (0-59: Above this causes this bitfield to be set with 0)*/
185 	    uint32_t          : 2;
186 	    uint32_t hours    : 5; /**< Alarm hours compare value   (0-23: Above this causes this bitfield to be set with 0)*/
187 	    uint32_t          : 3;
188 	    uint32_t days     : 5; /**< Alarm days compare value (0-Actual days of month: Above this causes this bitfield to be set with 0)*/
189 	    uint32_t          : 3;
190 	  };
191   };
192 
193   union
194   {
195     uint32_t raw1;
196 	  struct
197 	  {
198 	    uint32_t          : 8;
199 	    uint32_t month    : 4; /**< Alarm month compare value (0-11: Above this causes this bitfield to be set with 0) */
200 	    uint32_t          : 4;
201 	    uint32_t year     : 16; /**< Alarm year compare value */
202 	  };
203   };
204 } XMC_RTC_ALARM_t;
205 
206 /**
207  * Time values of RTC  <br>
208  *
209  * The structure presents a convenient way to set/obtain the
210  * time values for seconds, minutes, hours, days, month and year of RTC.
211  * The XMC_RTC_SetTime() and XMC_RTC_GetTime() can be
212  * used to populate the structure with the time value of
213  * RTC
214  */
215 typedef struct XMC_RTC_TIME
216 {
217   union
218   {
219     uint32_t raw0;
220 	  struct
221 	  {
222 	    uint32_t seconds  : 6; /**< Seconds time value (0-59: Above this causes this bitfield to be set with 0) */
223 	    uint32_t          : 2;
224 	    uint32_t minutes  : 6; /**< Minutes time value (0-59: Above this causes this bitfield to be set with 0) */
225 	    uint32_t          : 2;
226 	    uint32_t hours    : 5; /**< Hours time value   (0-23: Above this causes this bitfield to be set with 0) */
227 	    uint32_t          : 3;
228 	    uint32_t days     : 5; /**< Days time value (0-Actual days of month: Above this causes this bitfield to be set with 0)*/
229 	    uint32_t          : 3;
230 	  };
231   };
232 
233   union
234   {
235     uint32_t raw1;
236 	  struct
237 	  {
238 	    uint32_t daysofweek  : 3; /**< Days of week time value (0-6: Above this causes this bitfield to be set with 0) */
239 	    uint32_t             : 5;
240 	    uint32_t month       : 4; /**< Month time value       (0-11: Above this causes this bitfield to be set with 0) */
241 	    uint32_t             : 4;
242 	    uint32_t year        : 16; /**< Year time value */
243 	 };
244   };
245 } XMC_RTC_TIME_t;
246 /*Anonymous structure/union guard end*/
247 #if defined(__CC_ARM)
248   #pragma pop
249 #elif defined(__TASKING__)
250   #pragma warning restore
251 #endif
252 
253 /**
254  * RTC initialization with time, alarm and clock divider(prescaler) configurations <br>
255  *
256  * The structure presents a convenient way to set/obtain the time and alarm configurations
257  * for RTC. The XMC_RTC_Init() can be used to populate the structure with the time and alarm
258  * values of RTC.
259  */
260 typedef struct XMC_RTC_CONFIG
261 {
262   XMC_RTC_TIME_t    time;
263   XMC_RTC_ALARM_t   alarm;
264   uint16_t          prescaler;
265 } XMC_RTC_CONFIG_t;
266 
267 /*******************************************************************************
268  * EXTENSIONS
269  *******************************************************************************/
270 
271 #if UC_FAMILY == XMC1
272 #include "xmc1_rtc.h"
273 #endif
274 
275 #if UC_FAMILY == XMC4
276 #include "xmc4_rtc.h"
277 #endif
278 
279 /*******************************************************************************
280  * API PROTOTYPES
281  *********************************************************************************************************************/
282 
283 #ifdef __cplusplus
284 extern "C" {
285 #endif
286 
287 /**
288  * @param config Constant pointer to a constant ::XMC_RTC_CONFIG_t structure containing the
289  *               time, alarm time and clock divider(prescaler) configuration.
290  * @return XMC_RTC_STATUS_t Always returns XMC_RTC_STATUS_OK (It contains only register assignment statements)
291  *
292  * \par<b>Description: </b><br>
293  * Initialize the RTC peripheral <br>
294  *
295  * \par \if XMC4
296  * The function enables the hibernate domain for accessing RTC peripheral registers, configures
297  * internal clock divider, time and alarm values by writing to the CTR.DIV, TIM0, TIM1, ATIM0 and
298  * ATIM1 registers.
299  * \endif
300  *
301  * \if XMC1
302  * The function ungates the peripheral clock for RTC, configures
303  * internal clock divider, time and alarm values by writing to the CTR.DIV, TIM0, TIM1, ATIM0 and
304  * ATIM1 registers.
305  * \endif
306  */
307 XMC_RTC_STATUS_t XMC_RTC_Init(const XMC_RTC_CONFIG_t *const config);
308 
309 /**
310  * @return None
311  *
312  * \par<b>Description</b><br>
313  * Enables RTC peripheral for programming its registers <br>
314  *
315  * \par \if XMC4
316  * Enables the hibernate domain for accessing RTC peripheral registers.
317  * \endif
318  *
319  * \if XMC1
320  * Ungates the peripheral clock.
321  * \endif
322  *
323  * \par<b>Related APIs:</b><br>
324  * XMC_RTC_Disable(), XMC_SCU_RESET_DeassertPeripheralReset()
325  */
326 void XMC_RTC_Enable(void);
327 
328 /**
329  * @return None
330  *
331  * \par<b>Description</b><br>
332  * Disables RTC peripheral for programming its registers <br>
333  *
334  * \par \if XMC4
335  * Empty function (Hibernate domain is not disabled).
336  * \endif
337  *
338  * \if XMC1
339  * Gates the peripheral clock.
340  * \endif
341  *
342  * \par<b>Related APIs:</b><br>
343  * XMC_RTC_Enable(), XMC_SCU_RESET_AssertPeripheralReset()
344  */
345 void XMC_RTC_Disable(void);
346 
347 /**
348  * @return None
349  *
350  * \par<b>Description</b><br>
351  * Checks RTC peripheral is enabled for programming its registers <br>
352  *
353  * \par \if XMC4
354  * Checks the hibernate domain is enabled or not.
355  * \endif
356  *
357  * \if XMC1
358  * Checks peripheral clock is ungated or not.
359  * \endif
360  *
361  * \par<b>Related APIs:</b><br>
362  * XMC_RTC_Enable(), XMC_RTC_Disable(), XMC_SCU_RESET_DeassertPeripheralReset(),
363  * XMC_SCU_RESET_AssertPeripheralReset()
364  */
365 bool XMC_RTC_IsEnabled(void);
366 
367 /**
368  * @return None
369  *
370  * \par<b>Description</b><br>
371  * Enables RTC peripheral to start counting time <br>
372  *
373  * \par
374  * The function starts the RTC for counting time by setting
375  * CTR.ENB bit. Before starting the RTC, it should not be in
376  * running mode and also hibernate domain should be enabled.
377  *
378  * \par<b>Related APIs:</b><br>
379  * XMC_RTC_Enable(), XMC_RTC_Stop(), XMC_SCU_RESET_DeassertPeripheralReset()
380  */
381 void XMC_RTC_Start(void);
382 
383 /**
384  * @return None
385  *
386  * \par<b>Description</b><br>
387  * Disables RTC peripheral to start counting time <br>
388  *
389  * \par
390  * The function stops the RTC for counting time by resetting
391  * CTR.ENB. Before stopping the RTC, hibernate domain should be enabled.
392  *
393  * \par<b>Related APIs:</b><br>
394  * XMC_RTC_Enable(), XMC_RTC_Start(), XMC_SCU_RESET_AssertPeripheralReset()
395  */
396 void XMC_RTC_Stop(void);
397 
398 /**
399  * @param prescaler Prescaler value to be set
400  * @return None
401  *
402  * \par<b>Description: </b><br>
403  * Sets the RTC module prescaler value <br>
404  *
405  * \par
406  * The function sets the CTR.DIV bitfield to configure the prescalar value.
407  * The default value for the prescalar with the 32.768kHz crystal (or the internal clock)
408  * is 7FFFH for a time interval of 1 sec. Before setting the prescaler value RTC should be
409  * in stop mode and hibernate domain should be enabled.
410  *
411  * \par<b>Related APIs:</b><br>
412  * XMC_RTC_Stop(), XMC_RTC_Enable(), XMC_RTC_GetPrescaler()
413  */
414 void XMC_RTC_SetPrescaler(uint16_t prescaler);
415 
416 /**
417  * @return None
418  *
419  * \par<b>Description: </b><br>
420  * Gets the RTC module prescaler value <br>
421  *
422  * \par
423  * The function reads the CTR.DIV bitfield to get the prescalar value. The default value
424  * for the prescalar with the 32.768kHz crystal (or the internal clock) is 7FFFH for a
425  * time interval of 1 sec.
426  *
427  * \par<b>Related APIs:</b><br>
428  * XMC_RTC_SetPrescaler()
429  */
XMC_RTC_GetPrescaler(void)430 __STATIC_INLINE uint32_t XMC_RTC_GetPrescaler(void)
431 {
432   return (uint32_t)(((uint32_t)RTC->CTR & (uint32_t)RTC_CTR_DIV_Msk) >> (uint32_t)RTC_CTR_DIV_Pos);
433 }
434 
435 /**
436  * @param timeval Contstant pointer to a constant ::XMC_RTC_TIME_t structure containing the
437  *                time parameters seconds, minutes, hours, days, daysofweek, month and year.
438  * @return None
439  *
440  * \par<b>Description: </b><br>
441  * Sets the RTC module time values <br>
442  *
443  * \par
444  * The function sets the TIM0, TIM1 registers with time values.
445  * The values can only be written when RTC is disabled.
446  * See the structure ::XMC_RTC_TIME_t for the valid range of time value parameters. <br>
447  *
448  * \par<b>Related APIs:</b><br>
449  * XMC_RTC_GetTime(), XMC_RTC_Stop()
450  */
451 void XMC_RTC_SetTime(const XMC_RTC_TIME_t *const timeval);
452 
453 /**
454  * @param time Pointer to a constant ::XMC_RTC_TIME_t structure containing the time parameters
455  *             seconds, minutes, hours, days, daysofweek, month and year.
456  * @return None
457  *
458  * \par<b>Description: </b><br>
459  * Gets the RTC module time value <br>
460  *
461  * \par
462  * The function gets the time values from TIM0, TIM1 registers.
463  * See the structure ::XMC_RTC_TIME_t for the valid range of time value parameters. <br>
464  *
465  * \par<b>Related APIs:</b><br>
466  * XMC_RTC_SetTime()
467  */
468 void XMC_RTC_GetTime(XMC_RTC_TIME_t *const time);
469 
470 /**
471  * @param stdtime Pointer to a ::tm structure containing the time parameters seconds,
472  *                minutes, hours, days, daysofweek, month, year(since 1900) and days in a
473  *                year in standard format.
474  * @return None
475  *
476  * \par<b>Description: </b><br>
477  * Sets the RTC module time value in standard format <br>
478  *
479  * \par
480  * The function sets the time values from TIM0, TIM1 registers.
481  *
482  * \par<b>Related APIs:</b><br>
483  * XMC_RTC_SetTime(), XMC_RTC_GetTime()
484  */
485 void XMC_RTC_SetTimeStdFormat(const struct tm *const stdtime);
486 
487 /**
488  * @param stdtime Pointer to a constant ::tm structure containing the time parameters seconds,
489  *                minutes, hours, days, daysofweek, month, year(since 1900) and days in a
490  *                year in standard format.
491  * @return None
492  *
493  * \par<b>Description: </b><br>
494  * Gets the RTC module time value in standard format <br>
495  *
496  * \par
497  * The function gets the time values from TIM0, TIM1 registers.
498  * See the structure ::XMC_RTC_TIME_t for the valid range of time value parameters. <br>
499  * For days the valid range is (1 - Actual days of month), year (since 1900) and
500  * daysinyear (0 -365).
501  *
502  * \par<b>Related APIs:</b><br>
503  * XMC_RTC_SetTime(), XMC_RTC_GetTime()
504  */
505 void XMC_RTC_GetTimeStdFormat(struct tm *const stdtime);
506 
507 /**
508  * @param alarm Constant pointer to a constant ::XMC_RTC_ALARM_t structure containing the
509  *                alarm time parameters alarm seconds, alarm minutes, alarm hours, alarm days,
510  *                alarm daysofweek, alarm month and alarm year.
511  * @return None
512  *
513  * \par<b>Description: </b><br>
514  * Sets the RTC module alarm time value <br>
515  *
516  * \par
517  * The function sets the ATIM0, ATIM1 registers with alarm time values.
518  * See the structure ::XMC_RTC_ALARM_t for the valid range of alarm time value parameters. <br>
519  *
520  * \par<b>Related APIs:</b><br>
521  * XMC_RTC_GetAlarm()
522  */
523 void XMC_RTC_SetAlarm(const XMC_RTC_ALARM_t *const alarm);
524 
525 /**
526  * @param alarm Pointer to a constant ::XMC_RTC_ALARM_t structure containing the
527  *             time parameters alarm seconds, alarm minutes, alarm hours, alarm days,
528  *             alarm daysofweek, alarm month and alarm year.
529  * @return None
530  *
531  * \par<b>Description: </b><br>
532  * Gets the RTC module alarm time value <br>
533  *
534  * \par
535  * The function gets the alarm time values from ATIM0, ATIM1 registers.
536  * See the structure ::XMC_RTC_ALARM_t for the valid range of alarm time value parameters. <br>
537  *
538  * \par<b>Related APIs:</b><br>
539  * XMC_RTC_SetAlarm()
540  */
541 void XMC_RTC_GetAlarm(XMC_RTC_ALARM_t *const alarm);
542 
543 /**
544  * @param stdtime Pointer to a ::tm structure containing the time parameters alarm seconds,
545  *                alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month,
546  *                alarm year(since 1900) and alarm days in a year in standard format.
547  * @return None
548  *
549  * \par<b>Description: </b><br>
550  * Sets the RTC module alarm time value in standard format <br>
551  *
552  * \par
553  * The function sets the alarm time values from ATIM0, ATIM1 registers.
554  *
555  * \par<b>Related APIs:</b><br>
556  * XMC_RTC_SetAlarm(), XMC_RTC_GetAlarm()
557  */
558 void XMC_RTC_SetAlarmStdFormat(const struct tm *const stdtime);
559 
560 /**
561  * @param stdtime Pointer to a constant ::tm structure containing the time parameters alarm seconds,
562  *                alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month,
563  *                alarm year(since 1900) and alarm days in a year in standard format.
564  * @return None
565  *
566  * \par<b>Description: </b><br>
567  * Gets the RTC module alarm time value in standard format <br>
568  *
569  * \par
570  * The function gets the alarm time values from ATIM0, ATIM1 registers.
571  * See the structure ::XMC_RTC_ALARM_t for the valid range of alarm time value parameters. <br>
572  * For days the valid range is (1 - Actual days of month), year (since 1900) and
573  * daysinyear (0 -365).
574  *
575  * \par<b>Related APIs:</b><br>
576  * XMC_RTC_SetAlarm(), XMC_RTC_GetAlarm()
577  */
578 void XMC_RTC_GetAlarmStdFormat(struct tm *const stdtime);
579 
580 /**
581  * @param event A valid RTC event (::XMC_RTC_EVENT_t) or a valid combination of
582  *              logically OR'd events
583  * @return None
584  *
585  * \par<b>Description: </b><br>
586  * Enable RTC periodic and alarm event(s) <br>
587  *
588  * \par
589  * The function sets the bitfields of MSKSR register to enable interrupt generation
590  * for requested RTC event(s).
591  * Setting the masking value for the event(s) containing in the ::XMC_RTC_EVENT_t leads
592  * to a generation of the interrupt.
593  *
594  * \par<b>Related APIs:</b><br>
595  * XMC_RTC_DisableEvent()
596  */
597 void XMC_RTC_EnableEvent(const uint32_t event);
598 
599 /**
600  * @param event A valid RTC event (::XMC_RTC_EVENT_t) or a valid combination of
601  *              logically OR'd events
602  * @return None
603  *
604  * \par<b>Description: </b><br>
605  * Disable RTC periodic and alarm event(s) <br>
606  *
607  * \par
608  * The function resets the bitfields of MSKSR register to disable interrupt generation
609  * for requested RTC event(s).
610  * Resetting the masking value for the the event(s) containing in the ::XMC_RTC_EVENT_t blocks
611  * the generation of the interrupt.
612  *
613  * \par<b>Related APIs:</b><br>
614  * XMC_RTC_EnableEvent()
615  */
616 void XMC_RTC_DisableEvent(const uint32_t event);
617 
618 /**
619  * @param event A valid RTC event (::XMC_RTC_EVENT_t) or a valid combination of
620  *              logically OR'd events
621  * @return None
622  *
623  * \par<b>Description: </b><br>
624  * Clears periodic and alarm event(s) status <br>
625  *
626  * \par
627  * The function sets the bitfields of CLRSR register to clear status bits in RAWSTAT and STSSR registers.
628  * Setting the value for the the RTC event(s) containing in the ::XMC_RTC_EVENT_t clears the
629  * corresponding status bits in RAWSTAT and STSSR registers.
630  *
631  * \par<b>Related APIs:</b><br>
632  * XMC_RTC_GetEventStatus()
633  */
634 void XMC_RTC_ClearEvent(const uint32_t event);
635 
636 /**
637  * @return None
638  *
639  * \par<b>Description: </b><br>
640  * Gets the RTC periodic and alarm event(s) status <br>
641  *
642  * \par
643  * The function reads the bitfields of STSSR register
644  * to get the status of RTC events.
645  * Reading the value of the register STSSR gives the status of the event(s) containing in the ::XMC_RTC_EVENT_t.
646  *
647  * \par<b>Related APIs:</b><br>
648  * XMC_RTC_ClearEvent()
649  */
650 uint32_t XMC_RTC_GetEventStatus(void);
651 
652 /**
653  * @return bool true if RTC is running
654  *              false if RTC is not running
655  *
656  * \par<b>Description: </b><br>
657  * Checks the running status of the RTC <br>
658  *
659  * \par
660  * The function reads the bitfield ENB of CTR register
661  * to get the running status of RTC.
662  *
663  * \par<b>Related APIs:</b><br>
664  * XMC_RTC_Start(), XMC_RTC_Stop()
665  */
XMC_RTC_IsRunning(void)666 __STATIC_INLINE bool XMC_RTC_IsRunning(void)
667 {
668   return (bool)(RTC->CTR & RTC_CTR_ENB_Msk);
669 }
670 
671 #ifdef __cplusplus
672 }
673 #endif
674 
675 /**
676  * @}
677  */
678 
679 /**
680  * @}
681  */
682 
683 #endif /* XMC_RTC_H */
684