1 /*
2  * Copyright (c) 2020-2022, CQ 100ask Development Team
3  *
4  * Change Logs:
5  *   Date           Author          Notes
6  * 2022-05-29        Alen       first version
7  */
8 
9 #ifndef __DRV_USART_H__
10 #define __DRV_USART_H__
11 
12 #include <rtthread.h>
13 #include "rtdevice.h"
14 #include <rthw.h>
15 #include <drv_common.h>
16 
17 int rt_hw_uart_init(void);
18 
19 #define DMA_INSTANCE_TYPE               MA_Channel_TypeDef
20 
21 #define UART_INSTANCE_CLEAR_FUNCTION    __HAL_UART_CLEAR_FLAG
22 
23 
24 /* mm32 config class */
25 struct mm32_uart_config
26 {
27     const char *name;
28     UART_Type *Instance;
29     IRQn_Type irq_type;
30     struct dma_config *dma_rx;
31     struct dma_config *dma_tx;
32 };
33 
34 /* mm32 uart dirver class */
35 struct mm32_uart
36 {
37     UART_Init_Type handle;
38     struct mm32_uart_config *config;
39 
40 #ifdef RT_SERIAL_USING_DMA
41     struct
42     {
43         DMA_Type handle;
44         rt_size_t last_index;
45     } dma_rx;
46 #endif
47     rt_uint16_t uart_dma_flag;
48     struct rt_serial_device serial;
49 };
50 
51 #endif  /* __DRV_USART_H__ */
52