34 #if defined(LETIMER_COUNT) && (LETIMER_COUNT > 0)
60 #define LETIMER_COMP_REG_VALID(reg) (((reg) <= 1))
63 #define LETIMER_REF_VALID(ref) ((ref) == LETIMER0)
66 #define LETIMER_REP_REG_VALID(reg) (((reg) <= 1))
77 #if defined(_EFM32_GECKO_FAMILY)
94 __STATIC_INLINE
void regSync(LETIMER_TypeDef *letimer, uint32_t mask)
96 #if defined(_LETIMER_FREEZE_MASK)
99 if (letimer->FREEZE & LETIMER_FREEZE_REGFREEZE)
105 while (letimer->SYNCBUSY & mask)
129 uint32_t LETIMER_CompareGet(LETIMER_TypeDef *letimer,
unsigned int comp)
133 EFM_ASSERT(LETIMER_REF_VALID(letimer) && LETIMER_COMP_REG_VALID(comp));
139 ret = letimer->COMP0;
143 ret = letimer->COMP1;
176 void LETIMER_CompareSet(LETIMER_TypeDef *letimer,
180 volatile uint32_t *compReg;
182 EFM_ASSERT(LETIMER_REF_VALID(letimer)
183 && LETIMER_COMP_REG_VALID(comp)
184 && ((value & ~(_LETIMER_COMP0_COMP0_MASK
185 >> _LETIMER_COMP0_COMP0_SHIFT))
192 compReg = &(letimer->COMP0);
196 compReg = &(letimer->COMP1);
204 #if defined(_EFM32_GECKO_FAMILY)
206 regSync(letimer, comp ? LETIMER_SYNCBUSY_COMP1 : LETIMER_SYNCBUSY_COMP0);
231 void LETIMER_Enable(LETIMER_TypeDef *letimer,
bool enable)
233 EFM_ASSERT(LETIMER_REF_VALID(letimer));
235 #if defined(_EFM32_GECKO_FAMILY)
237 regSync(letimer, LETIMER_SYNCBUSY_CMD);
242 letimer->CMD = LETIMER_CMD_START;
246 letimer->CMD = LETIMER_CMD_STOP;
250 #if defined(_LETIMER_FREEZE_MASK)
278 void LETIMER_FreezeEnable(LETIMER_TypeDef *letimer,
bool enable)
291 while (letimer->SYNCBUSY)
294 letimer->FREEZE = LETIMER_FREEZE_REGFREEZE;
327 void LETIMER_Init(LETIMER_TypeDef *letimer,
const LETIMER_Init_TypeDef *init)
331 EFM_ASSERT(LETIMER_REF_VALID(letimer));
334 if (!(init->enable) && (letimer->STATUS & LETIMER_STATUS_RUNNING))
336 #if defined(_EFM32_GECKO_FAMILY)
338 regSync(letimer, LETIMER_SYNCBUSY_CMD);
340 letimer->CMD = LETIMER_CMD_STOP;
347 tmp |= LETIMER_CTRL_DEBUGRUN;
350 #if defined(LETIMER_CTRL_RTCC0TEN)
351 if (init->rtcComp0Enable)
353 tmp |= LETIMER_CTRL_RTCC0TEN;
356 if (init->rtcComp1Enable)
358 tmp |= LETIMER_CTRL_RTCC1TEN;
364 tmp |= LETIMER_CTRL_COMP0TOP;
369 tmp |= LETIMER_CTRL_BUFTOP;
374 tmp |= LETIMER_CTRL_OPOL0;
379 tmp |= LETIMER_CTRL_OPOL1;
382 tmp |= init->ufoa0 << _LETIMER_CTRL_UFOA0_SHIFT;
383 tmp |= init->ufoa1 << _LETIMER_CTRL_UFOA1_SHIFT;
384 tmp |= init->repMode << _LETIMER_CTRL_REPMODE_SHIFT;
386 #if defined(_EFM32_GECKO_FAMILY)
388 regSync(letimer, LETIMER_SYNCBUSY_CTRL);
393 if (init->enable && !(letimer->STATUS & LETIMER_STATUS_RUNNING))
395 #if defined(_EFM32_GECKO_FAMILY)
397 regSync(letimer, LETIMER_SYNCBUSY_CMD);
399 letimer->CMD = LETIMER_CMD_START;
417 uint32_t LETIMER_RepeatGet(LETIMER_TypeDef *letimer,
unsigned int rep)
421 EFM_ASSERT(LETIMER_REF_VALID(letimer) && LETIMER_REP_REG_VALID(rep));
464 void LETIMER_RepeatSet(LETIMER_TypeDef *letimer,
468 volatile uint32_t *repReg;
469 #if defined(_EFM32_GECKO_FAMILY)
472 EFM_ASSERT(LETIMER_REF_VALID(letimer)
473 && LETIMER_REP_REG_VALID(rep)
474 && ((value & ~(_LETIMER_REP0_REP0_MASK
475 >> _LETIMER_REP0_REP0_SHIFT))
482 repReg = &(letimer->REP0);
483 #if defined(_EFM32_GECKO_FAMILY)
484 syncbusy = LETIMER_SYNCBUSY_REP0;
489 repReg = &(letimer->REP1);
490 #if defined(_EFM32_GECKO_FAMILY)
491 syncbusy = LETIMER_SYNCBUSY_REP1;
500 #if defined(_EFM32_GECKO_FAMILY)
502 regSync(letimer, syncbusy);
520 void LETIMER_Reset(LETIMER_TypeDef *letimer)
522 #if defined(_LETIMER_FREEZE_MASK)
524 LETIMER_FreezeEnable(letimer,
true);
528 letimer->CMD = LETIMER_CMD_STOP | LETIMER_CMD_CLEAR
529 | LETIMER_CMD_CTO0 | LETIMER_CMD_CTO1;
530 letimer->CTRL = _LETIMER_CTRL_RESETVALUE;
531 letimer->COMP0 = _LETIMER_COMP0_RESETVALUE;
532 letimer->COMP1 = _LETIMER_COMP1_RESETVALUE;
533 letimer->REP0 = _LETIMER_REP0_RESETVALUE;
534 letimer->REP1 = _LETIMER_REP1_RESETVALUE;
535 letimer->IEN = _LETIMER_IEN_RESETVALUE;
536 letimer->IFC = _LETIMER_IFC_MASK;
539 #if defined(_LETIMER_FREEZE_MASK)
541 LETIMER_FreezeEnable(letimer,
false);
Clock management unit (CMU) API.
Emlib peripheral API "assert" implementation.
Low Energy Timer (LETIMER) peripheral API.