summaryrefslogtreecommitdiff
path: root/bsp/mm32/libraries/HAL_Drivers/drivers/drv_uart.h
blob: 39c8326441bc8f8081ffd95484e39e4e5e79d5a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef __DRV_UART_H__
#define __DRV_UART_H__

#include <rtthread.h>
#include <rtdevice.h>
#include <rthw.h>

#ifdef __cplusplus
extern "C" {
#endif

int rt_hw_uart_init(void);

#if defined(SOC_SERIES_MM32F3277)

#include <drv_common.h>

#define DMA_INSTANCE_TYPE               MA_Channel_TypeDef
#define UART_INSTANCE_CLEAR_FUNCTION    __HAL_UART_CLEAR_FLAG

struct dma_config;

struct mm32_uart_config
{
    const char *name;
    UART_Type *Instance;
    IRQn_Type irq_type;
    struct dma_config *dma_rx;
    struct dma_config *dma_tx;
};

struct mm32_uart
{
    UART_Init_Type handle;
    struct mm32_uart_config *config;

#ifdef RT_SERIAL_USING_DMA
    struct
    {
        DMA_Type handle;
        rt_size_t last_index;
    } dma_rx;
#endif

    rt_uint16_t uart_dma_flag;
    struct rt_serial_device serial;
};

#endif /* SOC_SERIES_MM32F3277 */

#ifdef __cplusplus
}
#endif

#endif /* __DRV_UART_H__ */