EFM32 Happy Gecko Software Documentation  efm32hg-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;
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 */
void RTC_Reset(void)
Restore RTC to reset state.
Definition: em_rtc.c:346
__STATIC_INLINE void RTC_IntDisable(uint32_t flags)
Disable one or more RTC interrupts.
Definition: em_rtc.h:138
__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:195
void RTC_CounterReset(void)
Restart RTC counter from zero.
Definition: em_rtc.c:370
__STATIC_INLINE void RTC_IntClear(uint32_t flags)
Clear one or more pending RTC interrupts.
Definition: em_rtc.h:123
__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:161
__STATIC_INLINE uint32_t RTC_IntGet(void)
Get pending RTC interrupt flags.
Definition: em_rtc.h:175
__STATIC_INLINE void RTC_CounterSet(uint32_t value)
Set the RTC counter value.
Definition: em_rtc.h:103
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:158
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:213
void RTC_Init(const RTC_Init_TypeDef *init)
Initialize RTC.
Definition: em_rtc.c:305
void RTC_Enable(bool enable)
Enable/disable RTC.
Definition: em_rtc.c:217
void RTC_FreezeEnable(bool enable)
RTC register synchronization freeze control.
Definition: em_rtc.c:261
uint32_t RTC_CompareGet(unsigned int comp)
Get RTC compare register value.
Definition: em_rtc.c:117
#define RTC