EFM32 Gecko Software Documentation  efm32g-doc-5.1.2
em_letimer.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_LETIMER_H
34 #define EM_LETIMER_H
35 
36 #include <stdbool.h>
37 #include "em_device.h"
38 #if defined(LETIMER_COUNT) && (LETIMER_COUNT > 0)
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /***************************************************************************/
49 /***************************************************************************/
54 /*******************************************************************************
55  ******************************** ENUMS ************************************
56  ******************************************************************************/
57 
59 typedef enum
60 {
76 
77 
79 typedef enum
80 {
90 
91 /*******************************************************************************
92  ******************************* STRUCTS ***********************************
93  ******************************************************************************/
94 
96 typedef struct
97 {
98  bool enable;
99  bool debugRun;
100 #if defined(LETIMER_CTRL_RTCC0TEN)
103 #endif
104  bool comp0Top;
105  bool bufTop;
106  uint8_t out0Pol;
107  uint8_t out1Pol;
112 
114 #if defined(LETIMER_CTRL_RTCC0TEN)
115 #define LETIMER_INIT_DEFAULT \
116 { \
117  true, /* Enable timer when init complete. */ \
118  false, /* Stop counter during debug halt. */ \
119  false, /* Do not start counting on RTC COMP0 match. */ \
120  false, /* Do not start counting on RTC COMP1 match. */ \
121  false, /* Do not load COMP0 into CNT on underflow. */ \
122  false, /* Do not load COMP1 into COMP0 when REP0 reaches 0. */ \
123  0, /* Idle value 0 for output 0. */ \
124  0, /* Idle value 0 for output 1. */ \
125  letimerUFOANone, /* No action on underflow on output 0. */ \
126  letimerUFOANone, /* No action on underflow on output 1. */ \
127  letimerRepeatFree /* Count until stopped by SW. */ \
128 }
129 #else
130 #define LETIMER_INIT_DEFAULT \
131 { \
132  true, /* Enable timer when init complete. */ \
133  false, /* Stop counter during debug halt. */ \
134  false, /* Do not load COMP0 into CNT on underflow. */ \
135  false, /* Do not load COMP1 into COMP0 when REP0 reaches 0. */ \
136  0, /* Idle value 0 for output 0. */ \
137  0, /* Idle value 0 for output 1. */ \
138  letimerUFOANone, /* No action on underflow on output 0. */ \
139  letimerUFOANone, /* No action on underflow on output 1. */ \
140  letimerRepeatFree /* Count until stopped by SW. */ \
141 }
142 #endif
143 
144 /*******************************************************************************
145  ***************************** PROTOTYPES **********************************
146  ******************************************************************************/
147 
148 uint32_t LETIMER_CompareGet(LETIMER_TypeDef *letimer, unsigned int comp);
149 void LETIMER_CompareSet(LETIMER_TypeDef *letimer,
150  unsigned int comp,
151  uint32_t value);
152 
153 
154 /***************************************************************************/
164 __STATIC_INLINE uint32_t LETIMER_CounterGet(LETIMER_TypeDef *letimer)
165 {
166  return(letimer->CNT);
167 }
168 
169 
170 void LETIMER_Enable(LETIMER_TypeDef *letimer, bool enable);
171 #if defined(_LETIMER_FREEZE_MASK)
172 void LETIMER_FreezeEnable(LETIMER_TypeDef *letimer, bool enable);
173 #endif
174 void LETIMER_Init(LETIMER_TypeDef *letimer, const LETIMER_Init_TypeDef *init);
175 
176 
177 /***************************************************************************/
189 __STATIC_INLINE void LETIMER_IntClear(LETIMER_TypeDef *letimer, uint32_t flags)
190 {
191  letimer->IFC = flags;
192 }
193 
194 
195 /***************************************************************************/
206 __STATIC_INLINE void LETIMER_IntDisable(LETIMER_TypeDef *letimer, uint32_t flags)
207 {
208  letimer->IEN &= ~flags;
209 }
210 
211 
212 /***************************************************************************/
228 __STATIC_INLINE void LETIMER_IntEnable(LETIMER_TypeDef *letimer, uint32_t flags)
229 {
230  letimer->IEN |= flags;
231 }
232 
233 
234 /***************************************************************************/
248 __STATIC_INLINE uint32_t LETIMER_IntGet(LETIMER_TypeDef *letimer)
249 {
250  return letimer->IF;
251 }
252 
253 
254 /***************************************************************************/
275 __STATIC_INLINE uint32_t LETIMER_IntGetEnabled(LETIMER_TypeDef *letimer)
276 {
277  uint32_t ien;
278 
279 
280  /* Store flags in temporary variable in order to define explicit order
281  * of volatile accesses. */
282  ien = letimer->IEN;
283 
284  /* Bitwise AND of pending and enabled interrupts */
285  return letimer->IF & ien;
286 }
287 
288 
289 /***************************************************************************/
300 __STATIC_INLINE void LETIMER_IntSet(LETIMER_TypeDef *letimer, uint32_t flags)
301 {
302  letimer->IFS = flags;
303 }
304 
305 
306 uint32_t LETIMER_RepeatGet(LETIMER_TypeDef *letimer, unsigned int rep);
307 void LETIMER_RepeatSet(LETIMER_TypeDef *letimer,
308  unsigned int rep,
309  uint32_t value);
310 void LETIMER_Reset(LETIMER_TypeDef *letimer);
311 
312 
316 #ifdef __cplusplus
317 }
318 #endif
319 
320 #endif /* defined(LETIMER_COUNT) && (LETIMER_COUNT > 0) */
321 #endif /* EM_LETIMER_H */
#define _LETIMER_CTRL_UFOA0_PWM
void LETIMER_Enable(LETIMER_TypeDef *letimer, bool enable)
Start/stop LETIMER.
Definition: em_letimer.c:231
void LETIMER_Init(LETIMER_TypeDef *letimer, const LETIMER_Init_TypeDef *init)
Initialize LETIMER.
Definition: em_letimer.c:327
uint32_t LETIMER_CompareGet(LETIMER_TypeDef *letimer, unsigned int comp)
Get LETIMER compare register value.
Definition: em_letimer.c:129
#define _LETIMER_CTRL_REPMODE_DOUBLE
LETIMER_UFOA_TypeDef ufoa1
Definition: em_letimer.h:109
uint32_t LETIMER_RepeatGet(LETIMER_TypeDef *letimer, unsigned int rep)
Get LETIMER repeat register value.
Definition: em_letimer.c:417
LETIMER_RepeatMode_TypeDef
Definition: em_letimer.h:59
__STATIC_INLINE void LETIMER_IntClear(LETIMER_TypeDef *letimer, uint32_t flags)
Clear one or more pending LETIMER interrupts.
Definition: em_letimer.h:189
__IOM uint32_t IEN
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
void LETIMER_Reset(LETIMER_TypeDef *letimer)
Reset LETIMER to same state as after a HW reset.
Definition: em_letimer.c:520
void LETIMER_RepeatSet(LETIMER_TypeDef *letimer, unsigned int rep, uint32_t value)
Set LETIMER repeat counter register value.
Definition: em_letimer.c:464
LETIMER_UFOA_TypeDef ufoa0
Definition: em_letimer.h:108
#define _LETIMER_CTRL_REPMODE_FREE
#define _LETIMER_CTRL_UFOA0_PULSE
__IOM uint32_t IFC
__STATIC_INLINE void LETIMER_IntEnable(LETIMER_TypeDef *letimer, uint32_t flags)
Enable one or more LETIMER interrupts.
Definition: em_letimer.h:228
#define _LETIMER_CTRL_UFOA0_TOGGLE
__STATIC_INLINE void LETIMER_IntSet(LETIMER_TypeDef *letimer, uint32_t flags)
Set one or more pending LETIMER interrupts from SW.
Definition: em_letimer.h:300
__IM uint32_t IF
void LETIMER_CompareSet(LETIMER_TypeDef *letimer, unsigned int comp, uint32_t value)
Set LETIMER compare register value.
Definition: em_letimer.c:176
__IM uint32_t CNT
#define _LETIMER_CTRL_REPMODE_ONESHOT
LETIMER_RepeatMode_TypeDef repMode
Definition: em_letimer.h:110
__STATIC_INLINE uint32_t LETIMER_IntGet(LETIMER_TypeDef *letimer)
Get pending LETIMER interrupt flags.
Definition: em_letimer.h:248
void LETIMER_FreezeEnable(LETIMER_TypeDef *letimer, bool enable)
LETIMER register synchronization freeze control.
Definition: em_letimer.c:278
#define _LETIMER_CTRL_REPMODE_BUFFERED
__IOM uint32_t IFS
__STATIC_INLINE uint32_t LETIMER_CounterGet(LETIMER_TypeDef *letimer)
Get LETIMER counter value.
Definition: em_letimer.h:164
__STATIC_INLINE uint32_t LETIMER_IntGetEnabled(LETIMER_TypeDef *letimer)
Get enabled and pending LETIMER interrupt flags.
Definition: em_letimer.h:275
LETIMER_UFOA_TypeDef
Definition: em_letimer.h:79
__STATIC_INLINE void LETIMER_IntDisable(LETIMER_TypeDef *letimer, uint32_t flags)
Disable one or more LETIMER interrupts.
Definition: em_letimer.h:206
#define _LETIMER_CTRL_UFOA0_NONE