Private function prototypes -----------------------------------------------*/ Private functions ---------------------------------------------------------*/ / * @brief * Initialize USART device * * @details * * @note * * @param[in] dev * Pointer to device descriptor * * @return * Error code ******************************************************************************/
| 123 | * Error code |
| 124 | ******************************************************************************/ |
| 125 | static 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 |
nothing calls this directly
no test coverage detected