| /** | |
| * @file : gsw_uart_interface.h | |
| * @brief : soc uart api | |
| * @date : | |
| * @author : | |
| * @version : v1.0 | |
| * @copyright Copyright(C) 2022,Gosuncnwelink | |
| */ | |
| #ifndef __GSW_UART_INTERFACE__H__ | |
| #define __GSW_UART_INTERFACE__H__ | |
| #include "gsw_hal_errcode.h" | |
| #if defined(__cplusplus) | |
| extern "C" { | |
| #endif | |
| /** | |
| * @brief uart open | |
| * @param [in] baudrate: baud rate of the UART frame | |
| * @param [in] bits: bit of UART the frame | |
| * @param [in] parity: parity of the UART frame | |
| * @param [in] stop: stop bit of the UART frame | |
| * @retval the UART handle | |
| * @retval -1: fail | |
| */ | |
| int gsw_uart_open(unsigned int baudrate, unsigned int bits, char parity, unsigned int stop); | |
| /** | |
| * @brief uart flush | |
| * @param [in] fd: the gsw_uart_open return handle of UART | |
| * @retval void | |
| */ | |
| void gsw_uart_flush(int fd); | |
| /** | |
| * @brief uart close | |
| * @param [in] fd: the gsw_uart_open return handle of UART | |
| * @retval void | |
| */ | |
| void gsw_uart_close(int fd); | |
| /** | |
| * @brief uart write | |
| * @param [in] fd: the gsw_uart_open return handle of UART | |
| * @param [in] buffer: the user send the data of UART | |
| * @param [in] len: the user send the data length of UART | |
| * @retval 0: success | |
| * @retval other: fail | |
| */ | |
| int gsw_uart_write(int fd, const unsigned char *buffer, int len); | |
| /** | |
| * @brief uart read | |
| * @param [in] fd: the gsw_uart_open return handle of UART | |
| * @param [out] buffer: the user read the data of UART | |
| * @param [in] len: the user need read the data length of UART | |
| * @param [in] timeout_ms: read data MAX timeout;ms | |
| * @retval 0: success | |
| * @retval other: fail | |
| */ | |
| int gsw_uart_read(int fd, unsigned char *buffer, int len,int timeout_ms); | |
| #if defined(__cplusplus) | |
| } | |
| #endif | |
| #endif | |