blob: cc6bf6ff967ebb0439b4735253082946d561643c (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*
* Copyright (c) 2006-2026, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-10-30 SummerGift first version
*/
#ifndef __DRV_USART_H__
#define __DRV_USART_H__
#include <rtthread.h>
#include "rtdevice.h"
#include <rthw.h>
#include <drv_common.h>
#define UART_CTRL_SET_BLOCK_TIMEOUT 0x20
/* ns800 config class */
struct ns800_uart_config
{
const char *name;
UART_TypeDef *Instance;
IRQn_Type rx_irq_type;
IRQn_Type tx_irq_type;
void (*irq_handler)(void);
GPIO_TypeDef *rx_port;
GPIO_PinNum rx_pin;
GPIO_AltFunc rx_mux;
rt_uint32_t rx_pad;
GPIO_Direction rx_direction;
rt_bool_t rx_drive_max;
GPIO_TypeDef *tx_port;
GPIO_PinNum tx_pin;
GPIO_AltFunc tx_mux;
rt_uint32_t tx_pad;
GPIO_Direction tx_direction;
rt_bool_t tx_drive_max;
rt_uint32_t tx_block_timeout;
rt_uint16_t rx_bufsz;
rt_uint16_t tx_bufsz;
};
typedef struct {
UART_TypeDef *Instance;
rt_uint32_t baud_rate;
rt_uint8_t data_bits;
rt_uint8_t stop_bits;
rt_uint8_t parity;
rt_uint8_t bit_order;
rt_uint8_t invert;
rt_uint8_t bufsz;
rt_uint8_t flowcontrol;
rt_uint8_t reserved;
}UART_HandleTypeDef;
/* ns800 uart dirver class */
struct ns800_uart
{
UART_HandleTypeDef handle;
struct ns800_uart_config *config;
rt_uint32_t DR_mask;
rt_uint32_t tx_block_timeout;
struct rt_serial_device serial;
};
int rt_hw_uart_init(void);
#endif /* __DRV_USART_H__ */
|