blob: 3808419a42a20cc5a9531a66ce0d784d4130e2c3 [file] [log] [blame]
b.liu68a94c92025-05-24 12:53:41 +08001/**
2 @file
3 ql_uart.h
4
5 @brief
6 This file provides the definitions for uart, and declares the
7 API functions.
8
9*/
10/*============================================================================
11 Copyright (c) 2017 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
12 Quectel Wireless Solution Proprietary and Confidential.
13 =============================================================================*/
14/*===========================================================================
15
16 EDIT HISTORY FOR MODULE
17
18This section contains comments describing changes made to the module.
19Notice that changes are listed in reverse chronological order.
20
21
22WHEN WHO WHAT, WHERE, WHY
23---------- ------------ ----------------------------------------------------
242019/08/20 Juson create
25=============================================================================*/
26
27#ifndef __QL_UART_H__
28#define __QL_UART_H__
29
30typedef enum {
31 FC_NONE = 0, // None Flow Control
32 FC_RTSCTS, // Hardware Flow Control (rtscts)
33 FC_XONXOFF // Software Flow Control (xon/xoff)
34}Enum_FlowCtrl;
35
36typedef enum {
37 PB_NONE = 0, //none parity check
38 PB_ODD, //odd parity check
39 PB_EVEN //even parity check
40}Enum_ParityBit;
41
42typedef enum {
43 DB_CS5 = 5,
44 DB_CS6 = 6,
45 DB_CS7 = 7,
46 DB_CS8 = 8
47}Enum_DataBit;
48
49typedef enum {
50 SB_1 = 1,
51 SB_2 = 2
52}Enum_StopBit;
53
54typedef enum {
55 B_300 = 300,
56 B_600 = 600,
57 B_1200 = 1200,
58 B_2400 = 2400,
59 B_4800 = 4800,
60 B_9600 = 9600,
61 B_19200 = 19200,
62 B_38400 = 38400,
63 B_57600 = 57600,
64 B_115200 = 115200,
65 B_230400 = 230400,
66 B_460800 = 460800,
67 B_921600 = 921600,
68 B_3000000 = 3000000,
69 B_4000000 = 4000000,
70}Enum_BaudRate;
71
72typedef struct {
73 Enum_BaudRate baudrate;
74 Enum_DataBit databit;
75 Enum_StopBit stopbit;
76 Enum_ParityBit parity;
77 Enum_FlowCtrl flowctrl;
78}ST_UARTDCB;
79
80int Ql_UART_Open(const char* port, Enum_BaudRate baudrate, Enum_FlowCtrl flowctrl);
81int Ql_UART_Read(int fd, char* buf, unsigned int buf_len);
82int Ql_UART_Write(int fd, const char* buf, unsigned int buf_len);
83int Ql_UART_SetDCB(int fd, ST_UARTDCB *dcb);
84int Ql_UART_GetDCB(int fd, ST_UARTDCB *dcb);
85int Ql_UART_IoCtl(int fd, unsigned int cmd, void* pValue);
86int Ql_UART_Close(int fd);
87
88#endif /* __QL_UART_H__ */
89