Lines Matching full:uart
11 #include <zephyr/drivers/uart.h>
20 /* Get UART instance */
24 /* UART TX buffer count max value */
27 /* UART TX/RX data registers size */
44 /* B91 UART registers structure */
59 /* B91 UART data structure */
70 /* B91 UART config structure */
109 static inline uint8_t uart_b91_get_tx_bufcnt(volatile struct uart_b91_t *uart) in uart_b91_get_tx_bufcnt() argument
111 return (uart->bufcnt & FLD_UART_TX_BUF_CNT) >> FLD_UART_TX_BUF_CNT_OFFSET; in uart_b91_get_tx_bufcnt()
115 static inline uint8_t uart_b91_get_rx_bufcnt(volatile struct uart_b91_t *uart) in uart_b91_get_rx_bufcnt() argument
117 return (uart->bufcnt & FLD_UART_RX_BUF_CNT) >> FLD_UART_RX_BUF_CNT_OFFSET; in uart_b91_get_rx_bufcnt()
200 /* Initializes the UART instance */
201 static void uart_b91_init(volatile struct uart_b91_t *uart, uint16_t divider, in uart_b91_init() argument
206 uart->ctrl0 = bwpc; in uart_b91_init()
207 uart->clk_div = divider; in uart_b91_init()
212 uart->ctrl1 |= FLD_UART_PARITY_ENABLE; in uart_b91_init()
216 uart->ctrl1 &= (~FLD_UART_PARITY_POLARITY); in uart_b91_init()
219 uart->ctrl1 |= FLD_UART_PARITY_POLARITY; in uart_b91_init()
222 uart->ctrl1 &= (~FLD_UART_PARITY_ENABLE); /* disable parity function */ in uart_b91_init()
226 uart->ctrl1 &= (~FLD_UART_STOP_SEL); in uart_b91_init()
227 uart->ctrl1 |= stop_bit; in uart_b91_init()
255 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_configure() local
284 /* UART configure */ in uart_b91_configure()
286 uart_b91_init(uart, divider, bwpc, parity, stop_bits); in uart_b91_configure()
312 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_driver_init() local
317 uart->status |= UART_RX_RESET_BIT | UART_TX_RESET_BIT; in uart_b91_driver_init()
328 uart_b91_init(uart, divider, bwpc, UART_PARITY_NONE, UART_STOP_BIT_1); in uart_b91_driver_init()
340 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_poll_out() local
343 while (uart_b91_get_tx_bufcnt(uart) >= UART_TX_BUF_CNT) { in uart_b91_poll_out()
346 uart->data_buf[data->tx_byte_index] = c; in uart_b91_poll_out()
347 data->tx_byte_index = (data->tx_byte_index + 1) % ARRAY_SIZE(uart->data_buf); in uart_b91_poll_out()
353 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_poll_in() local
356 if (uart_b91_get_rx_bufcnt(uart) == 0) { in uart_b91_poll_in()
360 *c = uart->data_buf[data->rx_byte_index]; in uart_b91_poll_in()
361 data->rx_byte_index = (data->rx_byte_index + 1) % ARRAY_SIZE(uart->data_buf); in uart_b91_poll_in()
369 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_err_check() local
371 return ((uart->status & UART_RX_ERR_STATUS) != 0) ? 1 : 0; in uart_b91_err_check()
382 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_fifo_fill() local
389 if (uart_b91_get_rx_bufcnt(uart) != 0) { in uart_b91_fifo_fill()
405 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_fifo_read() local
408 if (uart_b91_get_rx_bufcnt(uart) == 0) { in uart_b91_fifo_read()
421 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_tx_enable() local
423 uart->ctrl3 = (uart->ctrl3 & (~FLD_UART_TX_IRQ_TRIQ_LEV)) | in uart_b91_irq_tx_enable()
425 uart->ctrl0 |= UART_TX_IRQ_MASK; in uart_b91_irq_tx_enable()
431 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_tx_disable() local
433 uart->ctrl0 &= ~UART_TX_IRQ_MASK; in uart_b91_irq_tx_disable()
439 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_tx_ready() local
441 return ((uart_b91_get_tx_bufcnt(uart) < UART_TX_BUF_CNT) && in uart_b91_irq_tx_ready()
442 ((uart->ctrl0 & UART_TX_IRQ_MASK) != 0)) ? 1 : 0; in uart_b91_irq_tx_ready()
448 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_tx_complete() local
450 return (uart_b91_get_tx_bufcnt(uart) == 0) ? 1 : 0; in uart_b91_irq_tx_complete()
456 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_rx_enable() local
458 uart->ctrl3 = (uart->ctrl3 & (~FLD_UART_RX_IRQ_TRIQ_LEV)) | in uart_b91_irq_rx_enable()
460 uart->ctrl0 |= UART_RX_IRQ_MASK; in uart_b91_irq_rx_enable()
466 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_rx_disable() local
468 uart->ctrl0 &= ~UART_RX_IRQ_MASK; in uart_b91_irq_rx_disable()
474 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_rx_ready() local
476 return (uart_b91_get_rx_bufcnt(uart) > 0) ? 1 : 0; in uart_b91_irq_rx_ready()
482 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_err_enable() local
484 uart->rxtimeout |= UART_ERR_IRQ_MASK; in uart_b91_irq_err_enable()
490 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_err_disable() local
492 uart->rxtimeout &= ~UART_ERR_IRQ_MASK; in uart_b91_irq_err_disable()
498 volatile struct uart_b91_t *uart = GET_UART(dev); in uart_b91_irq_is_pending() local
500 return ((uart->status & UART_IRQ_STATUS) != 0) ? 1 : 0; in uart_b91_irq_is_pending()