void LETIMER_setup(void) { /* Enabling the required clocks */ CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_ULFRCO); //Selecting the ULFRCO as the source clock CMU_ClockEnable(cmuClock_LETIMER0, true); //Enable the clock input to LETIMER /* Set the compare values for COMP0 */ LETIMER_CompareSet(LETIMER0, 0,PERIOD/ULFRCO_COUNT); /* Configure the LETIMER0 */ LETIMER_Init_TypeDef letimerInit = LETIMER_INIT_DEFAULT; // { // .enable = true, /* Default: Start counting when init completed. */ // .debugRun = false, /* Default: Counter shall not keep running during debug halt. */ // .rtcComp0Enable = false, /* Default: Don't start counting on RTC COMP0 match. */ // .rtcComp1Enable = false, /* Default: Don't start counting on RTC COMP1 match. */ // .comp0Top = true, /* Load COMP0 register into CNT when counter underflows. COMP0 is used as TOP */ // .bufTop = false, /* Default: Don't load COMP1 into COMP0 when REP0 reaches 0. */ // .out0Pol = 0, /* Default: Idle value for output 0. */ // .out1Pol = 0, /* Default: Idle value for output 1. */ // .ufoa0 = letimerUFOANone, /* Default : No action on underfow on Output 0*/ // .ufoa1 = letimerUFOANone, /* Default : No action on underfow on Output 1*/ // .repMode = letimerRepeatFree /* Default: Count until stopped */ // }; letimerInit.comp0Top= true, /* Default: Start counting when init completed. */ /* Initialize LETIMER with the values above */ LETIMER_Init(LETIMER0, &letimerInit); }
/***************************************************************************//** * @brief * Set the LETIMER top value. * * @note * The LETIMER is a down-counter, so when the counter reaches 0 then the top * value will be loaded into the counter. This function can be used to set * the top value. * * If the LETIMER is not already configured to use a top value then this * function will enable that functionality for the user. * * @param[in] letimer * A pointer to the LETIMER peripheral register block. * * @param[in] value * The top value. This can be a 16 bit value on series-0 and series-1 devices * and a 24 bit value on series-2 devices. ******************************************************************************/ void LETIMER_TopSet(LETIMER_TypeDef *letimer, uint32_t value) { LETIMER_SyncWait(letimer); #if defined(_LETIMER_TOP_MASK) /* Make sure TOP value is enabled. */ if ((letimer->CTRL & LETIMER_CTRL_CNTTOPEN) == 0U) { letimer->CTRL_SET = LETIMER_CTRL_CNTTOPEN; } letimer->TOP = value; #else /* Make sure TOP value is enabled. */ if ((letimer->CTRL & LETIMER_CTRL_COMP0TOP) == 0U) { letimer->CTRL |= LETIMER_CTRL_COMP0TOP; } LETIMER_CompareSet(letimer, 0, value); #endif }