1 /* 2 * Copyright (c) 2006-2022, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2022.03.02 FMD-AE first version 9 */ 10 11 #ifndef __DRV_USART_H__ 12 #define __DRV_USART_H__ 13 14 #include <rtthread.h> 15 #include "rtdevice.h" 16 #include <rthw.h> 17 #include "drv_dma.h" 18 19 int rt_hw_usart_init(void); 20 21 #if defined(SOC_SERIES_FT32F0) 22 #define DMA_INSTANCE_TYPE DMA_Channel_TypeDef 23 #endif 24 25 #if defined(SOC_SERIES_FT32F0) 26 #define UART_INSTANCE_CLEAR_FUNCTION USART_ClearITPendingBit 27 #endif 28 29 #define USART_TX_Pin GPIO_PIN_2 30 #define USART_TX_GPIO_Port GPIOA 31 #define USART_RX_Pin GPIO_PIN_3 32 #define USART_RX_GPIO_Port GPIOA 33 34 /* ft32 config class */ 35 struct ft32_uart_config 36 { 37 const char *name; 38 USART_TypeDef *Instance; 39 IRQn_Type irq_type; 40 struct dma_config *dma_rx; 41 struct dma_config *dma_tx; 42 }; 43 44 /* ft32 uart dirver class */ 45 struct ft32_uart 46 { 47 USART_InitTypeDef Init; 48 struct ft32_uart_config *config; 49 50 #ifdef RT_SERIAL_USING_DMA 51 struct 52 { 53 DMA_InitTypeDef Init; 54 DMA_Channel_TypeDef *Instance; 55 rt_size_t last_index; 56 } dma_rx; 57 struct 58 { 59 DMA_InitTypeDef Init; 60 DMA_Channel_TypeDef *Instance; 61 } dma_tx; 62 #endif 63 rt_uint16_t uart_dma_flag; 64 struct rt_serial_device serial; 65 }; 66 67 #endif /* __DRV_USART_H__ */ 68