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

4  * SPDX-License-Identifier: Apache-2.0
11 #include <zephyr/drivers/uart.h>
14 /* UART REGISTERS DEFINITIONS */
71 /* Receive full - raised even when 1 char arrived */
129 typedef void (*irq_cfg_func_t)(const struct device *dev);
144 const struct device *dev; member
150 #define DEV_UART(dev) \ argument
152 ((const struct uart_miv_device_config * const)(dev)->config)->uart_addr)
154 static void uart_miv_poll_out(const struct device *dev, in uart_miv_poll_out() argument
157 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_poll_out() local
159 while (!(uart->status & STATUS_TXRDY_MASK)) { in uart_miv_poll_out()
162 uart->tx = c; in uart_miv_poll_out()
165 static int uart_miv_poll_in(const struct device *dev, unsigned char *c) in uart_miv_poll_in() argument
167 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_poll_in() local
169 if (uart->status & STATUS_RXFULL_MASK) { in uart_miv_poll_in()
170 *c = (unsigned char)(uart->rx & RXDATA_MASK); in uart_miv_poll_in()
174 return -1; in uart_miv_poll_in()
177 static int uart_miv_err_check(const struct device *dev) in uart_miv_err_check() argument
179 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_err_check() local
180 uint32_t flags = uart->status; in uart_miv_err_check()
201 static int uart_miv_fifo_fill(const struct device *dev, in uart_miv_fifo_fill() argument
205 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_fifo_fill() local
208 for (i = 0; i < size && (uart->status & STATUS_TXRDY_MASK); i++) { in uart_miv_fifo_fill()
209 uart->tx = tx_data[i]; in uart_miv_fifo_fill()
215 static int uart_miv_fifo_read(const struct device *dev, in uart_miv_fifo_read() argument
219 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_fifo_read() local
223 if (uart->status & STATUS_RXFULL_MASK) { in uart_miv_fifo_read()
224 rx_data[i] = (unsigned char)(uart->rx & RXDATA_MASK); in uart_miv_fifo_read()
233 static void uart_miv_irq_tx_enable(const struct device *dev) in uart_miv_irq_tx_enable() argument
235 ARG_UNUSED(dev); in uart_miv_irq_tx_enable()
238 static void uart_miv_irq_tx_disable(const struct device *dev) in uart_miv_irq_tx_disable() argument
240 ARG_UNUSED(dev); in uart_miv_irq_tx_disable()
243 static int uart_miv_irq_tx_ready(const struct device *dev) in uart_miv_irq_tx_ready() argument
245 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_irq_tx_ready() local
247 return !(uart->status & STATUS_TXRDY_MASK); in uart_miv_irq_tx_ready()
250 static int uart_miv_irq_tx_complete(const struct device *dev) in uart_miv_irq_tx_complete() argument
252 ARG_UNUSED(dev); in uart_miv_irq_tx_complete()
257 static void uart_miv_irq_rx_enable(const struct device *dev) in uart_miv_irq_rx_enable() argument
259 ARG_UNUSED(dev); in uart_miv_irq_rx_enable()
262 static void uart_miv_irq_rx_disable(const struct device *dev) in uart_miv_irq_rx_disable() argument
264 ARG_UNUSED(dev); in uart_miv_irq_rx_disable()
267 static int uart_miv_irq_rx_ready(const struct device *dev) in uart_miv_irq_rx_ready() argument
269 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_irq_rx_ready() local
271 return !!(uart->status & STATUS_RXFULL_MASK); in uart_miv_irq_rx_ready()
274 static void uart_miv_irq_err_enable(const struct device *dev) in uart_miv_irq_err_enable() argument
276 ARG_UNUSED(dev); in uart_miv_irq_err_enable()
279 static void uart_miv_irq_err_disable(const struct device *dev) in uart_miv_irq_err_disable() argument
281 ARG_UNUSED(dev); in uart_miv_irq_err_disable()
284 static int uart_miv_irq_is_pending(const struct device *dev) in uart_miv_irq_is_pending() argument
286 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_irq_is_pending() local
288 return !!(uart->status & STATUS_RXFULL_MASK); in uart_miv_irq_is_pending()
291 static int uart_miv_irq_update(const struct device *dev) in uart_miv_irq_update() argument
296 static void uart_miv_irq_handler(const struct device *dev) in uart_miv_irq_handler() argument
298 struct uart_miv_data *data = dev->data; in uart_miv_irq_handler()
300 if (data->callback) { in uart_miv_irq_handler()
301 data->callback(dev, data->cb_data); in uart_miv_irq_handler()
306 * This thread is a workaround for IRQs that are not connected in Mi-V.
314 const struct device *dev = data->dev; in uart_miv_rx_thread() local
315 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_rx_thread() local
316 const struct uart_miv_device_config *const cfg = dev->config; in uart_miv_rx_thread()
320 uint32_t delay = 1000000 / cfg->baud_rate; in uart_miv_rx_thread()
326 if (uart->status & STATUS_RXFULL_MASK) { in uart_miv_rx_thread()
327 uart_miv_irq_handler(dev); in uart_miv_rx_thread()
333 static void uart_miv_irq_callback_set(const struct device *dev, in uart_miv_irq_callback_set() argument
337 struct uart_miv_data *data = dev->data; in uart_miv_irq_callback_set()
339 data->callback = cb; in uart_miv_irq_callback_set()
340 data->cb_data = cb_data; in uart_miv_irq_callback_set()
345 static int uart_miv_init(const struct device *dev) in uart_miv_init() argument
347 const struct uart_miv_device_config *const cfg = dev->config; in uart_miv_init()
348 volatile struct uart_miv_regs_t *uart = DEV_UART(dev); in uart_miv_init() local
350 uint16_t baud_value = (cfg->sys_clk_freq / (cfg->baud_rate * 16U)) - 1; in uart_miv_init()
353 uart->ctrlreg1 = (uint8_t)(baud_value & BAUDVALUE_LSB); in uart_miv_init()
354 uart->ctrlreg2 = (uint8_t)(cfg->line_config) | in uart_miv_init()
359 cfg->cfg_func(dev); in uart_miv_init()
364 static DEVICE_API(uart, uart_miv_driver_api) = {
386 /* This driver is single-instance. */
395 static void uart_miv_irq_cfg_func_0(const struct device *dev);
414 static void uart_miv_irq_cfg_func_0(const struct device *dev) in uart_miv_irq_cfg_func_0() argument
416 struct uart_miv_data *data = dev->data; in uart_miv_irq_cfg_func_0()
418 data->dev = dev; in uart_miv_irq_cfg_func_0()
420 /* Create a thread which will poll for data - replacement for IRQ */ in uart_miv_irq_cfg_func_0()