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

Function LEUART_Init

bsp/efm32/Libraries/emlib/src/em_leuart.c:449–478  ·  view source on GitHub ↗

/ * @brief * Init LEUART. * * @details * This function will configure basic settings in order to operate in normal * asynchronous mode. Consider using LEUART_Reset() prior to this function if * state of configuration is not known, since only configuration settings * specified by @p init are set. * * Special control setup not covered by this function may be done either * bef

Source from the content-addressed store, hash-verified

447 * Pointer to initialization structure used to configure basic async setup.
448 ******************************************************************************/
449void LEUART_Init(LEUART_TypeDef *leuart, LEUART_Init_TypeDef *init)
450{
451 /* Make sure the module exists on the selected chip */
452 EFM_ASSERT(LEUART_REF_VALID(leuart));
453
454 /* LF register about to be modified require sync. busy check */
455 LEUART_Sync(leuart, LEUART_SYNCBUSY_CMD);
456
457 /* Ensure disabled while doing config */
458 leuart->CMD = LEUART_CMD_RXDIS | LEUART_CMD_TXDIS;
459
460 /* Freeze registers to avoid stalling for LF synchronization */
461 LEUART_FreezeEnable(leuart, true);
462
463 /* Configure databits and stopbits */
464 leuart->CTRL = (leuart->CTRL & ~(_LEUART_CTRL_PARITY_MASK |
465 _LEUART_CTRL_STOPBITS_MASK)) |
466 (uint32_t)(init->databits) |
467 (uint32_t)(init->parity) |
468 (uint32_t)(init->stopbits);
469
470 /* Configure baudrate */
471 LEUART_BaudrateSet(leuart, init->refFreq, init->baudrate);
472
473 /* Finally enable (as specified) */
474 leuart->CMD = (uint32_t)(init->enable);
475
476 /* Unfreeze registers, pass new settings on to LEUART */
477 LEUART_FreezeEnable(leuart, false);
478}
479
480
481/***************************************************************************//**

Callers 1

rt_hw_leuart_unit_initFunction · 0.85

Calls 3

LEUART_SyncFunction · 0.85
LEUART_FreezeEnableFunction · 0.85
LEUART_BaudrateSetFunction · 0.85

Tested by

no test coverage detected