| 12345678910111213141516171819202122232425262728293031323334 |
- // uart_lib.h
- #ifndef UART_LIB_H
- #define UART_LIB_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stddef.h>
- #include <unistd.h> /*Unix 标准函数定义*/
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h> /*文件控制定义*/
- #include <termios.h> /*POSIX 终端控制定义*/
- #include <errno.h> /*错误号定义*/
- #include <string.h> /*字符串功能函数*/
- #include <stdio.h> /* perror */
- typedef int UART_HANDLE;
- extern const UART_HANDLE UART_INVALID_HANDLE;
- // 初始化/反初始化
- UART_HANDLE UartInit(const char *dev, int baudrate, int byteSize, int stopBits, int parity);
- int UartUninit(UART_HANDLE handle);
- // 数据收发
- int UartSend(UART_HANDLE handle, const void *buf, size_t size);
- int UartRecv(UART_HANDLE handle, void *buf, size_t size);
- #ifdef __cplusplus
- }
- #endif
- #endif // UART_LIB_H
|