blob: 037e8cc5a1d0f2e1a97ed3a914a0864ba7d9e580 [file] [log] [blame]
hong.liucd370792025-05-28 06:29:19 -07001/**
2* @file : gsw_uart_interface.h
3* @brief : soc uart api
4* @date :
5* @author :
6* @version : v1.0
7* @copyright Copyright(C) 2022,Gosuncnwelink
8*/
9#ifndef __GSW_UART_INTERFACE__H__
10#define __GSW_UART_INTERFACE__H__
11#include "gsw_hal_errcode.h"
12
13#if defined(__cplusplus)
14extern "C" {
15#endif
16/**
17 * @brief uart open
18 * @param [in] baudrate: baud rate of the UART frame
19 * @param [in] bits: bit of UART the frame
20 * @param [in] parity: parity of the UART frame
21 * @param [in] stop: stop bit of the UART frame
22 * @retval the UART handle
23 * @retval -1: fail
24 */
25int gsw_uart_open(unsigned int baudrate, unsigned int bits, char parity, unsigned int stop);
26
27/**
28 * @brief uart flush
29 * @param [in] fd: the gsw_uart_open return handle of UART
30 * @retval void
31 */
32void gsw_uart_flush(int fd);
33
34/**
35 * @brief uart close
36 * @param [in] fd: the gsw_uart_open return handle of UART
37 * @retval void
38 */
39void gsw_uart_close(int fd);
40
41/**
42 * @brief uart write
43 * @param [in] fd: the gsw_uart_open return handle of UART
44 * @param [in] buffer: the user send the data of UART
45 * @param [in] len: the user send the data length of UART
46 * @retval 0: success
47 * @retval other: fail
48 */
49int gsw_uart_write(int fd, const unsigned char *buffer, int len);
50
51/**
52 * @brief uart read
53 * @param [in] fd: the gsw_uart_open return handle of UART
54 * @param [out] buffer: the user read the data of UART
55 * @param [in] len: the user need read the data length of UART
56 * @param [in] timeout_ms: read data MAX timeout;ms
57 * @retval 0: success
58 * @retval other: fail
59 */
60int gsw_uart_read(int fd, unsigned char *buffer, int len,int timeout_ms);
61
62#if defined(__cplusplus)
63}
64#endif
65#endif
66