Lines Matching +full:uart +full:- +full:dev

5  * SPDX-License-Identifier: Apache-2.0
19 #include <zephyr/drivers/uart.h>
34 const struct device *dev; member
47 static void eswifi_iface_uart_flush(struct eswifi_uart_data *uart) in eswifi_iface_uart_flush() argument
51 while (uart_fifo_read(uart->dev, &c, 1) > 0) { in eswifi_iface_uart_flush()
59 struct eswifi_uart_data *uart = &eswifi_uart0; /* Static instance */ in eswifi_iface_uart_isr() local
67 while (uart_irq_update(uart->dev) && in eswifi_iface_uart_isr()
68 uart_irq_rx_ready(uart->dev)) { in eswifi_iface_uart_isr()
70 partial_size = ring_buf_put_claim(&uart->rx_rb, &dst, in eswifi_iface_uart_isr()
75 eswifi_iface_uart_flush(uart); in eswifi_iface_uart_isr()
79 rx = uart_fifo_read(uart->dev, dst, partial_size); in eswifi_iface_uart_isr()
86 partial_size -= rx; in eswifi_iface_uart_isr()
89 ring_buf_put_finish(&uart->rx_rb, total_size); in eswifi_iface_uart_isr()
110 static int eswifi_uart_get_resp(struct eswifi_uart_data *uart) in eswifi_uart_get_resp() argument
114 while (ring_buf_get(&uart->rx_rb, &c, 1) > 0) { in eswifi_uart_get_resp()
116 get_fsm_char(uart->fsm), c, c); in eswifi_uart_get_resp()
118 if (uart->rx_buf_size > 0) { in eswifi_uart_get_resp()
119 uart->rx_buf[uart->rx_count++] = c; in eswifi_uart_get_resp()
121 if (uart->rx_count == uart->rx_buf_size) { in eswifi_uart_get_resp()
122 return -ENOMEM; in eswifi_uart_get_resp()
126 switch (uart->fsm) { in eswifi_uart_get_resp()
129 uart->fsm = ESWIFI_UART_FSM_WAIT_LF; in eswifi_uart_get_resp()
134 uart->fsm = ESWIFI_UART_FSM_WAIT_MARK; in eswifi_uart_get_resp()
136 uart->fsm = ESWIFI_UART_FSM_WAIT_CR; in eswifi_uart_get_resp()
141 uart->fsm = ESWIFI_UART_FSM_WAIT_SPACE; in eswifi_uart_get_resp()
143 uart->fsm = ESWIFI_UART_FSM_WAIT_LF; in eswifi_uart_get_resp()
145 uart->fsm = ESWIFI_UART_FSM_WAIT_CR; in eswifi_uart_get_resp()
150 uart->fsm = ESWIFI_UART_FSM_END; in eswifi_uart_get_resp()
152 uart->fsm = ESWIFI_UART_FSM_WAIT_LF; in eswifi_uart_get_resp()
154 uart->fsm = ESWIFI_UART_FSM_WAIT_CR; in eswifi_uart_get_resp()
165 static int eswifi_uart_wait_prompt(struct eswifi_uart_data *uart) in eswifi_uart_wait_prompt() argument
170 while (--max_retries) { in eswifi_uart_wait_prompt()
171 err = eswifi_uart_get_resp(uart); in eswifi_uart_wait_prompt()
173 LOG_DBG("Err: 0x%08x - %d", err, err); in eswifi_uart_wait_prompt()
177 if (uart->fsm == ESWIFI_UART_FSM_END) { in eswifi_uart_wait_prompt()
179 return uart->rx_count; in eswifi_uart_wait_prompt()
187 return -ETIMEDOUT; in eswifi_uart_wait_prompt()
193 struct eswifi_uart_data *uart = eswifi->bus_data; in eswifi_uart_request() local
201 uart_poll_out(uart->dev, cmd[count]); in eswifi_uart_request()
204 uart->fsm = ESWIFI_UART_FSM_WAIT_CR; in eswifi_uart_request()
205 uart->rx_count = 0; in eswifi_uart_request()
206 uart->rx_buf = rsp; in eswifi_uart_request()
207 uart->rx_buf_size = rlen; in eswifi_uart_request()
209 err = eswifi_uart_wait_prompt(uart); in eswifi_uart_request()
212 LOG_HEXDUMP_DBG(uart->rx_buf, uart->rx_count, "Stream"); in eswifi_uart_request()
220 struct eswifi_uart_data *uart = &eswifi_uart0; /* Static instance */ in eswifi_uart_init() local
222 uart->dev = DEVICE_DT_GET(DT_INST_BUS(0)); in eswifi_uart_init()
223 if (!device_is_ready(uart->dev)) { in eswifi_uart_init()
225 return -ENODEV; in eswifi_uart_init()
228 eswifi->bus_data = uart; in eswifi_uart_init()
230 uart_irq_rx_disable(uart->dev); in eswifi_uart_init()
231 uart_irq_tx_disable(uart->dev); in eswifi_uart_init()
232 eswifi_iface_uart_flush(uart); in eswifi_uart_init()
233 uart_irq_callback_set(uart->dev, eswifi_iface_uart_isr); in eswifi_uart_init()
234 uart_irq_rx_enable(uart->dev); in eswifi_uart_init()
236 ring_buf_init(&uart->rx_rb, sizeof(uart->iface_rb_buf), in eswifi_uart_init()
237 uart->iface_rb_buf); in eswifi_uart_init()