EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2
em_rtc.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_RTC_H
34 #define 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;
65 } RTC_Init_TypeDef;
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 #if !defined(_EFM32_GECKO_FAMILY)
96 /***************************************************************************/
103 __STATIC_INLINE void RTC_CounterSet(uint32_t value)
104 {
105  RTC->CNT = value;
106 }
107 #endif
108 
109 void RTC_CounterReset(void);
110 void RTC_Enable(bool enable);
111 void RTC_FreezeEnable(bool enable);
112 void RTC_Init(const RTC_Init_TypeDef *init);
113 
114 /***************************************************************************/
123 __STATIC_INLINE void RTC_IntClear(uint32_t flags)
124 {
125  RTC->IFC = flags;
126 }
127 
128 
129 /***************************************************************************/
138 __STATIC_INLINE void RTC_IntDisable(uint32_t flags)
139 {
140  RTC->IEN &= ~flags;
141 }
142 
143 
144 /***************************************************************************/
158 __STATIC_INLINE void RTC_IntEnable(uint32_t flags)
159 {
160  RTC->IEN |= flags;
161 }
162 
163 
164 /***************************************************************************/
175 __STATIC_INLINE uint32_t RTC_IntGet(void)
176 {
177  return RTC->IF;
178 }
179 
180 
181 /***************************************************************************/
195 __STATIC_INLINE uint32_t RTC_IntGetEnabled(void)
196 {
197  uint32_t ien;
198 
199  ien = RTC->IEN;
200  return RTC->IF & ien;
201 }
202 
203 
204 /***************************************************************************/
213 __STATIC_INLINE void RTC_IntSet(uint32_t flags)
214 {
215  RTC->IFS = flags;
216 }
217 
218 void RTC_Reset(void);
219 
223 #ifdef __cplusplus
224 }
225 #endif
226 
227 #endif /* defined(RTC_COUNT) && (RTC_COUNT > 0) */
228 #endif /* EM_RTC_H */
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.