EFM32 Wonder Gecko Software Documentation  efm32wg-doc-4.2.1
em_rtc.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __SILICON_LABS_EM_RTC_H__
34 #define __SILICON_LABS_EM_RTC_H__
35 
36 #include "em_device.h"
37 #if defined(RTC_COUNT) && (RTC_COUNT > 0)
38 
39 #include <stdbool.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /***************************************************************************/
50 /***************************************************************************/
55 /*******************************************************************************
56  ******************************* STRUCTS ***********************************
57  ******************************************************************************/
58 
60 typedef struct
61 {
62  bool enable;
63  bool debugRun;
64  bool comp0Top;
66 
68 #define RTC_INIT_DEFAULT \
69 { \
70  true, /* Start counting when init done */ \
71  false, /* Disable updating during debug halt */ \
72  true /* Restart counting from 0 when reaching COMP0 */ \
73 }
74 
75 
76 /*******************************************************************************
77  ***************************** PROTOTYPES **********************************
78  ******************************************************************************/
79 
80 uint32_t RTC_CompareGet(unsigned int comp);
81 void RTC_CompareSet(unsigned int comp, uint32_t value);
82 
83 /***************************************************************************/
90 __STATIC_INLINE uint32_t RTC_CounterGet(void)
91 {
92  return RTC->CNT;
93 }
94 
95 void RTC_CounterReset(void);
96 void RTC_Enable(bool enable);
97 void RTC_FreezeEnable(bool enable);
98 void RTC_Init(const RTC_Init_TypeDef *init);
99 
100 /***************************************************************************/
109 __STATIC_INLINE void RTC_IntClear(uint32_t flags)
110 {
111  RTC->IFC = flags;
112 }
113 
114 
115 /***************************************************************************/
124 __STATIC_INLINE void RTC_IntDisable(uint32_t flags)
125 {
126  RTC->IEN &= ~flags;
127 }
128 
129 
130 /***************************************************************************/
144 __STATIC_INLINE void RTC_IntEnable(uint32_t flags)
145 {
146  RTC->IEN |= flags;
147 }
148 
149 
150 /***************************************************************************/
161 __STATIC_INLINE uint32_t RTC_IntGet(void)
162 {
163  return RTC->IF;
164 }
165 
166 
167 /***************************************************************************/
181 __STATIC_INLINE uint32_t RTC_IntGetEnabled(void)
182 {
183  uint32_t ien;
184 
185  ien = RTC->IEN;
186  return RTC->IF & ien;
187 }
188 
189 
190 /***************************************************************************/
199 __STATIC_INLINE void RTC_IntSet(uint32_t flags)
200 {
201  RTC->IFS = flags;
202 }
203 
204 void RTC_Reset(void);
205 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* defined(RTC_COUNT) && (RTC_COUNT > 0) */
214 #endif /* __SILICON_LABS_EM_RTC_H__ */
void RTC_Reset(void)
Restore RTC to reset state.
Definition: em_rtc.c:343
__STATIC_INLINE void RTC_IntDisable(uint32_t flags)
Disable one or more RTC interrupts.
Definition: em_rtc.h:124
__STATIC_INLINE uint32_t RTC_IntGetEnabled(void)
Get enabled and pending RTC interrupt flags. Useful for handling more interrupt sources in the same i...
Definition: em_rtc.h:181
void RTC_CounterReset(void)
Restart RTC counter from zero.
Definition: em_rtc.c:367
__STATIC_INLINE void RTC_IntClear(uint32_t flags)
Clear one or more pending RTC interrupts.
Definition: em_rtc.h:109
__STATIC_INLINE uint32_t RTC_CounterGet(void)
Get RTC counter value.
Definition: em_rtc.h:90
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
void RTC_CompareSet(unsigned int comp, uint32_t value)
Set RTC compare register value.
Definition: em_rtc.c:158
__STATIC_INLINE uint32_t RTC_IntGet(void)
Get pending RTC interrupt flags.
Definition: em_rtc.h:161
bool debugRun
Definition: em_rtc.h:63
__STATIC_INLINE void RTC_IntEnable(uint32_t flags)
Enable one or more RTC interrupts.
Definition: em_rtc.h:144
#define RTC
bool comp0Top
Definition: em_rtc.h:64
__STATIC_INLINE void RTC_IntSet(uint32_t flags)
Set one or more pending RTC interrupts from SW.
Definition: em_rtc.h:199
void RTC_Init(const RTC_Init_TypeDef *init)
Initialize RTC.
Definition: em_rtc.c:302
void RTC_Enable(bool enable)
Enable/disable RTC.
Definition: em_rtc.c:214
void RTC_FreezeEnable(bool enable)
RTC register synchronization freeze control.
Definition: em_rtc.c:258
uint32_t RTC_CompareGet(unsigned int comp)
Get RTC compare register value.
Definition: em_rtc.c:114