uart.h 839 B

12345678910111213141516171819202122232425262728293031323334
  1. // uart_lib.h
  2. #ifndef UART_LIB_H
  3. #define UART_LIB_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <stddef.h>
  8. #include <unistd.h> /*Unix 标准函数定义*/
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <fcntl.h> /*文件控制定义*/
  12. #include <termios.h> /*POSIX 终端控制定义*/
  13. #include <errno.h> /*错误号定义*/
  14. #include <string.h> /*字符串功能函数*/
  15. #include <stdio.h> /* perror */
  16. typedef int UART_HANDLE;
  17. extern const UART_HANDLE UART_INVALID_HANDLE;
  18. // 初始化/反初始化
  19. UART_HANDLE UartInit(const char *dev, int baudrate, int byteSize, int stopBits, int parity);
  20. int UartUninit(UART_HANDLE handle);
  21. // 数据收发
  22. int UartSend(UART_HANDLE handle, const void *buf, size_t size);
  23. int UartRecv(UART_HANDLE handle, void *buf, size_t size);
  24. #ifdef __cplusplus
  25. }
  26. #endif
  27. #endif // UART_LIB_H