EFM32 Pearl Gecko Software Documentation  efm32pg1-doc-4.2.1
em_cryotimer.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_CRYOTIMER_H__
34 #define EM_CRYOTIMER_H__
35 
36 #include <stdbool.h>
37 #include "em_device.h"
38 #include "em_bus.h"
39 
40 #if defined(CRYOTIMER_PRESENT) && (CRYOTIMER_COUNT == 1)
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /***************************************************************************/
51 /***************************************************************************/
79 /*******************************************************************************
80  ********************************* ENUM ************************************
81  ******************************************************************************/
82 
84 typedef enum
85 {
95 
97 typedef enum
98 {
103 
105 typedef enum
106 {
141 
142 /*******************************************************************************
143  ******************************* STRUCTS ***********************************
144  ******************************************************************************/
145 
147 typedef struct
148 {
150  bool enable;
151 
153  bool debugRun;
154 
156  bool em4Wakeup;
157 
160 
163 
167 
168 /*******************************************************************************
169  ******************************* DEFINES ***********************************
170  ******************************************************************************/
171 
173 #define CRYOTIMER_INIT_DEFAULT \
174 { \
175  true, /* Start counting when init done. */ \
176  false, /* Disable CRYOTIMER during debug halt. */ \
177  false, /* Disable EM4 wakeup. */ \
178  cryotimerOscLFRCO, /* Select Low Frequency RC Oscillator. */ \
179  cryotimerPresc_1, /* LF Oscillator frequency undivided. */ \
180  cryotimerPeriod_4096m, /* Wakeup event after 4096M pre-scaled clock cycles. */ \
181 }
182 
183 /*******************************************************************************
184  ***************************** PROTOTYPES **********************************
185  ******************************************************************************/
186 
187 /***************************************************************************/
194 __STATIC_INLINE void CRYOTIMER_IntClear(uint32_t flags)
195 {
196  CRYOTIMER->IFC = flags & _CRYOTIMER_IFC_MASK;
197 }
198 
199 /***************************************************************************/
209 __STATIC_INLINE uint32_t CRYOTIMER_IntGet(void)
210 {
211  return CRYOTIMER->IF;
212 }
213 
214 /***************************************************************************/
228 __STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled(void)
229 {
230  uint32_t ien;
231 
232  ien = CRYOTIMER->IEN & _CRYOTIMER_IEN_MASK;
233  return CRYOTIMER->IF & ien;
234 }
235 
236 /***************************************************************************/
243 __STATIC_INLINE void CRYOTIMER_IntEnable(uint32_t flags)
244 {
245  CRYOTIMER->IEN |= (flags & _CRYOTIMER_IEN_MASK);
246 }
247 
248 /***************************************************************************/
255 __STATIC_INLINE void CRYOTIMER_IntDisable(uint32_t flags)
256 {
257  CRYOTIMER->IEN &= ~(flags & _CRYOTIMER_IEN_MASK);
258 }
259 
260 /***************************************************************************/
270 __STATIC_INLINE void CRYOTIMER_IntSet(uint32_t flags)
271 {
272  CRYOTIMER->IFS = flags & _CRYOTIMER_IFS_MASK;
273 }
274 
275 /***************************************************************************/
288 __STATIC_INLINE void CRYOTIMER_PeriodSet(uint32_t period)
289 {
290  CRYOTIMER->PERIODSEL = period & _CRYOTIMER_PERIODSEL_MASK;
291 }
292 
293 /***************************************************************************/
306 __STATIC_INLINE uint32_t CRYOTIMER_PeriodGet(void)
307 {
308  return CRYOTIMER->PERIODSEL;
309 }
310 
311 /***************************************************************************/
318 __STATIC_INLINE uint32_t CRYOTIMER_CounterGet(void)
319 {
320  return CRYOTIMER->CNT;
321 }
322 
323 /***************************************************************************/
330 __STATIC_INLINE void CRYOTIMER_EM4WakeupEnable(bool enable)
331 {
333 }
334 
335 /***************************************************************************/
342 __STATIC_INLINE void CRYOTIMER_Enable(bool enable)
343 {
345 }
346 
347 void CRYOTIMER_Init(const CRYOTIMER_Init_TypeDef *init);
348 
349 #ifdef __cplusplus
350 }
351 #endif
352 
356 #endif /* defined(CRYOTIMER_PRESENT) && (CRYOTIMER_COUNT == 1) */
357 #endif /* EM_CRYOTIMER_H__ */
#define _CRYOTIMER_CTRL_OSCSEL_ULFRCO
#define _CRYOTIMER_CTRL_PRESC_DIV2
#define _CRYOTIMER_CTRL_PRESC_DIV8
#define _CRYOTIMER_IFC_MASK
#define _CRYOTIMER_CTRL_PRESC_DIV1
__STATIC_INLINE uint32_t CRYOTIMER_IntGet(void)
Get the CRYOTIMER interrupt flag.
Definition: em_cryotimer.h:209
RAM and peripheral bit-field set and clear API.
__STATIC_INLINE uint32_t CRYOTIMER_CounterGet(void)
Get the CRYOTIMER counter value.
Definition: em_cryotimer.h:318
__STATIC_INLINE void CRYOTIMER_EM4WakeupEnable(bool enable)
Enable/disable EM4 wakeup capability.
Definition: em_cryotimer.h:330
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
__STATIC_INLINE void CRYOTIMER_IntDisable(uint32_t flags)
Disable one or more CRYOTIMER interrupts.
Definition: em_cryotimer.h:255
CRYOTIMER_Presc_TypeDef
Definition: em_cryotimer.h:84
CRYOTIMER_Period_TypeDef period
Definition: em_cryotimer.h:165
CRYOTIMER_Osc_TypeDef
Definition: em_cryotimer.h:97
__STATIC_INLINE uint32_t CRYOTIMER_PeriodGet(void)
Get the CRYOTIMER period select value.
Definition: em_cryotimer.h:306
__STATIC_INLINE void CRYOTIMER_IntSet(uint32_t flags)
Set the CRYOTIMER period interrupt flag.
Definition: em_cryotimer.h:270
__STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled(void)
Get enabled and pending CRYOTIMER interrupt flags. Useful for handling more interrupt sources in the ...
Definition: em_cryotimer.h:228
__STATIC_INLINE void CRYOTIMER_Enable(bool enable)
Enable/disable the CRYOTIMER.
Definition: em_cryotimer.h:342
#define _CRYOTIMER_CTRL_PRESC_DIV4
CRYOTIMER_Period_TypeDef
Definition: em_cryotimer.h:105
void CRYOTIMER_Init(const CRYOTIMER_Init_TypeDef *init)
Initialize the CRYOTIMER.
Definition: em_cryotimer.c:51
#define _CRYOTIMER_CTRL_PRESC_DIV16
#define _CRYOTIMER_CTRL_EN_SHIFT
#define _CRYOTIMER_CTRL_PRESC_DIV64
#define _CRYOTIMER_CTRL_OSCSEL_LFXO
CRYOTIMER_Osc_TypeDef osc
Definition: em_cryotimer.h:159
#define _CRYOTIMER_CTRL_PRESC_DIV128
CRYOTIMER_Presc_TypeDef presc
Definition: em_cryotimer.h:162
#define _CRYOTIMER_CTRL_PRESC_DIV32
#define _CRYOTIMER_CTRL_OSCSEL_LFRCO
__STATIC_INLINE void CRYOTIMER_IntEnable(uint32_t flags)
Enable one or more CRYOTIMER interrupts.
Definition: em_cryotimer.h:243
__STATIC_INLINE void BUS_RegBitWrite(volatile uint32_t *addr, unsigned int bit, unsigned int val)
Perform a single-bit write operation on a peripheral register.
Definition: em_bus.h:146
#define CRYOTIMER
__STATIC_INLINE void CRYOTIMER_PeriodSet(uint32_t period)
Set the CRYOTIMER period select.
Definition: em_cryotimer.h:288
#define _CRYOTIMER_IFS_MASK
#define _CRYOTIMER_PERIODSEL_MASK
#define _CRYOTIMER_IEN_MASK
__STATIC_INLINE void CRYOTIMER_IntClear(uint32_t flags)
Clear the CRYOTIMER period interrupt.
Definition: em_cryotimer.h:194
#define _CRYOTIMER_EM4WUEN_EM4WU_SHIFT