2024年6月6日发(作者:)
50 {
51 *write_ptr = data;
52 write_ptr++;
53 if (write_ptr >= buf + BUF_SIZE)
54 write_ptr = buf;
55 }
56
57 static void serial_in(char *data)
58 {
59 if (read_ptr == NULL) {
60 DBG("pointer is null !n");
61 }
62
63 if (read_ptr && (read_ptr != write_ptr)) {
64 *data = *read_ptr;
65 read_ptr++;
66 if(read_ptr >= buf + BUF_SIZE)
67 read_ptr = buf;
68 }
69 }
70
71
72 static void tiny_stop_tx(struct uart_port *port)
73 {
74 DBG("tiny_stop_tx()n");
75 }
76
77 static void tiny_stop_rx(struct uart_port *port)
78 {
79 DBG("tiny_stop_rx()n");
80 }
81
82 static void tiny_enable_ms(struct uart_port *port)
83 {
84 DBG("tiny_enable_ms()n");
85 }
86
87 static void tiny_rx_chars(struct uart_port *port, int size)
88 {
89 int i = 0;
90 char byte;
91 char flag;
92 struct tty_port *tty = &port->state->port;
93
94 if (size <= 0) {
95 return;
96 }
97
98 while (size--) {
99 serial_in(&byte);
100 DBG("read: 0x%2xn", byte);
101 flag = TTY_NORMAL;
102 port->++;
103
104 if (uart_handle_sysrq_char(port, byte)) {
105 DBG("found ignore char !n");
106 goto ignore_char;
107 }
108
109 uart_insert_char(port, 0, 0, byte, flag);
110 ignore_char:
111 i ++;
112 }
113 tty_flip_buffer_push(tty);
114 DBG("push to user space !n");
115 }
116
117 static int tiny_tx_chars(struct uart_port *port)
118 {
119 struct circ_buf *xmit = &port->state->xmit;
120 int count;
121
122 DBG("tiny_tx_chars()n");
123
124 if (port->x_char) {
125 DBG("wrote 0x%2xrn", port->x_char);
126 port->++;
127 port->x_char = 0;
128 return;
129 }
130 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
131 tiny_stop_tx(port);
132 return;
133 }


发布评论