MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / LETIMER_Init

Function LETIMER_Init

bsp/efm32/Libraries/emlib/src/em_letimer.c:321–393  ·  view source on GitHub ↗

/ * @brief * Initialize LETIMER. * * @details * Note that the compare/repeat values must be set separately with * LETIMER_CompareSet() and LETIMER_RepeatSet(). That should probably be done * prior to the use of this function if configuring the LETIMER to start when * initialization is completed. * * @note * The initialization of the LETIMER modifies the LETIMER CTRL/CMD regis

Source from the content-addressed store, hash-verified

319 * Pointer to LETIMER initialization structure.
320 ******************************************************************************/
321void LETIMER_Init(LETIMER_TypeDef *letimer, const LETIMER_Init_TypeDef *init)
322{
323 uint32_t tmp = 0;
324
325 EFM_ASSERT(LETIMER_REF_VALID(letimer));
326
327 /* Stop timer if specified to be disabled and running */
328 if (!(init->enable) && (letimer->STATUS & LETIMER_STATUS_RUNNING))
329 {
330#if defined(_EFM32_GECKO_FAMILY)
331 /* LF register about to be modified require sync. busy check */
332 LETIMER_Sync(letimer, LETIMER_SYNCBUSY_CMD);
333#endif
334 letimer->CMD = LETIMER_CMD_STOP;
335 }
336
337 /* Configure DEBUGRUN flag, sets whether or not counter should be
338 * updated when debugger is active */
339 if (init->debugRun)
340 {
341 tmp |= LETIMER_CTRL_DEBUGRUN;
342 }
343
344 if (init->rtcComp0Enable)
345 {
346 tmp |= LETIMER_CTRL_RTCC0TEN;
347 }
348
349 if (init->rtcComp1Enable)
350 {
351 tmp |= LETIMER_CTRL_RTCC1TEN;
352 }
353
354 if (init->comp0Top)
355 {
356 tmp |= LETIMER_CTRL_COMP0TOP;
357 }
358
359 if (init->bufTop)
360 {
361 tmp |= LETIMER_CTRL_BUFTOP;
362 }
363
364 if (init->out0Pol)
365 {
366 tmp |= LETIMER_CTRL_OPOL0;
367 }
368
369 if (init->out1Pol)
370 {
371 tmp |= LETIMER_CTRL_OPOL1;
372 }
373
374 tmp |= init->ufoa0 << _LETIMER_CTRL_UFOA0_SHIFT;
375 tmp |= init->ufoa1 << _LETIMER_CTRL_UFOA1_SHIFT;
376 tmp |= init->repMode << _LETIMER_CTRL_REPMODE_SHIFT;
377
378#if defined(_EFM32_GECKO_FAMILY)

Callers 1

SysTick_ConfigurationFunction · 0.85

Calls 1

LETIMER_SyncFunction · 0.85

Tested by

no test coverage detected