ubinos
uart.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Sung Ho Park and CSOS
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef UBIDRV_UART_H_
8 #define UBIDRV_UART_H_
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14 
23 #include <ubinos_config.h>
24 #include <ubinos/type.h>
25 
26 #define UBIDRV_UART_FILE_NAME_MAX 64
27 
28 #define UBIDRV_UART_DATA_BITS_8 0
29 #define UBIDRV_UART_DATA_BITS_9 1
30 
31 #define UBIDRV_UART_STOP_BITS_1 0
32 #define UBIDRV_UART_STOP_BITS_2 1
33 
34 #define UBIDRV_UART_PARITY_TYPE_NONE 0
35 #define UBIDRV_UART_PARITY_TYPE_EVEN 1
36 #define UBIDRV_UART_PARITY_TYPE_ODD 2
37 
38 #define UBIDRV_UART_HW_FLOW_CTRL_NONE 0
39 #define UBIDRV_UART_HW_FLOW_CTRL_RTS 1
40 #define UBIDRV_UART_HW_FLOW_CTRL_CTS 2
41 #define UBIDRV_UART_HW_FLOW_CTRL_RTS_CTS 3
42 
44 typedef struct _ubidrv_uart_t
45 {
46  char file_name[UBIDRV_UART_FILE_NAME_MAX];
47  uint32_t baud_rate;
48  unsigned int data_bits :2;
49  unsigned int stop_bits :2;
50  unsigned int parity_type :2;
51  unsigned int hw_flow_ctl :2;
52 
53  int fd;
55 
64 
73 
83 ubi_st_t ubidrv_uart_getc(int fd, char *ch_p);
84 
95 
109 ubi_st_t ubidrv_uart_getc_timedms(int fd, char *ch_p, uint32_t timeoutms, uint32_t *remain_timeoutms);
110 
120 ubi_st_t ubidrv_uart_putc(int fd, int ch);
121 
130 
142 int ubidrv_uart_putn(int fd, const char *str, int len);
143 
152 int ubidrv_uart_kbhit(int fd);
153 
167 int ubidrv_uart_puts(int fd, const char *str, int max);
168 
183 int ubidrv_uart_gets(int fd, char *str, int max);
184 
195 ubi_st_t ubidrv_uart_setecho(int fd, int echo);
196 
206 
219 ubi_st_t ubidrv_uart_setautocr(int fd, int autocr);
220 
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #endif /* UBIDRV_UART_H_ */
Definition: uart.h:45
ubinos basic data type
ubi_st_t
Definition: type.h:140
ubi_st_t ubidrv_uart_getc_unblocked(int fd, char *ch_p)
ubi_st_t ubidrv_uart_putc(int fd, int ch)
int ubidrv_uart_getecho(int fd)
ubi_st_t ubidrv_uart_flush(int fd)
ubi_st_t ubidrv_uart_setautocr(int fd, int autocr)
ubi_st_t ubidrv_uart_setecho(int fd, int echo)
int ubidrv_uart_getautocr(int fd)
int ubidrv_uart_putn(int fd, const char *str, int len)
int ubidrv_uart_kbhit(int fd)
ubi_st_t ubidrv_uart_open(ubidrv_uart_t *uart)
int ubidrv_uart_gets(int fd, char *str, int max)
int ubidrv_uart_puts(int fd, const char *str, int max)
ubi_st_t ubidrv_uart_close(ubidrv_uart_t *uart)
struct _ubidrv_uart_t ubidrv_uart_t
ubi_st_t ubidrv_uart_getc(int fd, char *ch_p)
ubi_st_t ubidrv_uart_getc_timedms(int fd, char *ch_p, uint32_t timeoutms, uint32_t *remain_timeoutms)