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

Function rt_usart_init

bsp/efm32/drv_usart.c:125–158  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

123 * Error code
124 ******************************************************************************/
125static rt_err_t rt_usart_init (rt_device_t dev)
126{
127 struct efm32_usart_device_t *usart;
128
129 usart = (struct efm32_usart_device_t *)(dev->user_data);
130
131 if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
132 {
133 if (dev->flag & RT_DEVICE_FLAG_DMA_TX)
134 {
135 struct efm32_usart_dma_mode_t *dma_tx;
136
137 dma_tx = (struct efm32_usart_dma_mode_t *)(usart->tx_mode);
138
139 usart->state |= USART_STATE_RX_BUSY;
140 }
141
142 if (dev->flag & RT_DEVICE_FLAG_INT_RX)
143 {
144 struct efm32_usart_int_mode_t *int_rx;
145
146 int_rx = (struct efm32_usart_int_mode_t *)(usart->rx_mode);
147
148 int_rx->data_ptr = RT_NULL;
149 }
150
151 /* Enable USART */
152 USART_Enable(usart->usart_device, usartEnable);
153
154 dev->flag |= RT_DEVICE_FLAG_ACTIVATED;
155 }
156
157 return RT_EOK;
158}
159
160/***************************************************************************//**
161 * @brief

Callers

nothing calls this directly

Calls 1

USART_EnableFunction · 0.50

Tested by

no test coverage detected