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

Function rt_leuart_init

bsp/efm32/drv_leuart.c:71–104  ·  view source on GitHub ↗

Private function prototypes -----------------------------------------------*/ Private functions ---------------------------------------------------------*/ / * @brief * Initialize LEUART device * * @details * * @note * * @param[in] dev * Pointer to device descriptor * * @return * Error code ******************************************************************************/

Source from the content-addressed store, hash-verified

69 * Error code
70 ******************************************************************************/
71static rt_err_t rt_leuart_init (rt_device_t dev)
72{
73 struct efm32_leuart_device_t *leuart;
74
75 leuart = (struct efm32_leuart_device_t *)(dev->user_data);
76
77 if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
78 {
79 if (dev->flag & RT_DEVICE_FLAG_DMA_TX)
80 {
81 struct efm32_leuart_dma_mode_t *dma_tx;
82
83 dma_tx = (struct efm32_leuart_dma_mode_t *)(leuart->tx_mode);
84
85 leuart->state |= LEUART_STATE_RX_BUSY;
86 }
87
88 if (dev->flag & RT_DEVICE_FLAG_INT_RX)
89 {
90 struct efm32_leuart_int_mode_t *int_rx;
91
92 int_rx = (struct efm32_leuart_int_mode_t *)(leuart->rx_mode);
93
94 int_rx->data_ptr = RT_NULL;
95 }
96
97 /* Enable LEUART */
98 LEUART_Enable(leuart->leuart_device, leuartEnable);
99
100 dev->flag |= RT_DEVICE_FLAG_ACTIVATED;
101 }
102
103 return RT_EOK;
104}
105
106/***************************************************************************//**
107 * @brief

Callers

nothing calls this directly

Calls 1

LEUART_EnableFunction · 0.85

Tested by

no test coverage detected