1 /* 2 * Copyright (c) 2020-2021, Bluetrum Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2020-11-20 greedyhao first version 9 */ 10 11 #ifndef DRV_USART_H__ 12 #define DRV_USART_H__ 13 14 #include "drv_common.h" 15 16 #ifdef RT_USING_SERIAL 17 18 /* an32 config class */ 19 struct ab32_uart_config 20 { 21 const char *name; 22 hal_sfr_t instance; 23 uint8_t mode; 24 uint16_t fifo_size; 25 uint8_t reserve[1]; 26 // struct dma_config *dma_rx; 27 // struct dma_config *dma_tx; 28 }; 29 30 /* ab32 uart driver class */ 31 struct ab32_uart 32 { 33 struct uart_handle handle; 34 struct ab32_uart_config *config; 35 36 #ifdef RT_SERIAL_USING_DMA 37 struct 38 { 39 DMA_HandleTypeDef handle; 40 rt_size_t last_index; 41 } dma_rx; 42 struct 43 { 44 DMA_HandleTypeDef handle; 45 } dma_tx; 46 #endif 47 rt_uint16_t uart_dma_flag; 48 struct rt_serial_device serial; 49 rt_uint8_t *rx_buf; 50 rt_uint8_t rx_idx; 51 rt_uint8_t rx_idx_prev; 52 }; 53 54 #endif 55 56 int rt_hw_usart_init(void); 57 58 #endif 59