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

Function USART_InitSync

bsp/efm32/Libraries/emlib/src/em_usart.c:586–619  ·  view source on GitHub ↗

/ * @brief * Init USART for synchronous mode. * * @details * This function will configure basic settings in order to operate in * synchronous mode. * * Special control setup not covered by this function must be done after * using this function by direct modification of the CTRL register. * * Notice that pins used by the USART module must be properly configured * by the use

Source from the content-addressed store, hash-verified

584 * Pointer to initialization structure used to configure basic async setup.
585 ******************************************************************************/
586void USART_InitSync(USART_TypeDef *usart, const USART_InitSync_TypeDef *init)
587{
588 /* Make sure the module exists on the selected chip */
589 EFM_ASSERT(USART_REF_VALID(usart));
590
591 /* Init USART registers to HW reset state. */
592 USART_Reset(usart);
593
594 /* Set bits for synchronous mode */
595 usart->CTRL |= (USART_CTRL_SYNC) |
596 ((uint32_t)init->clockMode) |
597 (init->msbf ? USART_CTRL_MSBF : 0);
598
599#if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_TINY_FAMILY)
600 usart->CTRL |= (init->prsRxEnable ? USART_INPUT_RXPRS : 0) |
601 (init->autoTx ? USART_CTRL_AUTOTX : 0);
602#endif
603
604 /* Configure databits, leave stopbits and parity at reset default (not used) */
605 usart->FRAME = ((uint32_t)(init->databits)) |
606 (USART_FRAME_STOPBITS_DEFAULT) |
607 (USART_FRAME_PARITY_DEFAULT);
608
609 /* Configure baudrate */
610 USART_BaudrateSyncSet(usart, init->refFreq, init->baudrate);
611
612 /* Finally enable (as specified) */
613 if (init->master)
614 {
615 usart->CMD = USART_CMD_MASTEREN;
616 }
617
618 usart->CMD = (uint32_t)(init->enable);
619}
620
621
622/***************************************************************************//**

Callers 4

drv_usart.cFile · 0.85
SPI_BC_InitFunction · 0.85
USART_InitI2sFunction · 0.85
spiInitFunction · 0.85

Calls 2

USART_BaudrateSyncSetFunction · 0.85
USART_ResetFunction · 0.70

Tested by

no test coverage detected