Lines Matching refs:uart
27 static inline void uart_reset(uart_inst_t *uart) { in uart_reset() argument
28 invalid_params_if(UART, uart != uart0 && uart != uart1); in uart_reset()
29 reset_block(uart_get_index(uart) ? RESETS_RESET_UART1_BITS : RESETS_RESET_UART0_BITS); in uart_reset()
32 static inline void uart_unreset(uart_inst_t *uart) { in uart_unreset() argument
33 invalid_params_if(UART, uart != uart0 && uart != uart1); in uart_unreset()
34 unreset_block_wait(uart_get_index(uart) ? RESETS_RESET_UART1_BITS : RESETS_RESET_UART0_BITS); in uart_unreset()
39 uint uart_init(uart_inst_t *uart, uint baudrate) { in uart_init() argument
40 invalid_params_if(UART, uart != uart0 && uart != uart1); in uart_init()
46 uart_reset(uart); in uart_init()
47 uart_unreset(uart); in uart_init()
50 uart_set_translate_crlf(uart, PICO_UART_DEFAULT_CRLF); in uart_init()
54 uint baud = uart_set_baudrate(uart, baudrate); in uart_init()
55 uart_set_format(uart, 8, 1, UART_PARITY_NONE); in uart_init()
58 hw_set_bits(&uart_get_hw(uart)->lcr_h, UART_UARTLCR_H_FEN_BITS); in uart_init()
60 uart_get_hw(uart)->cr = UART_UARTCR_UARTEN_BITS | UART_UARTCR_TXE_BITS | UART_UARTCR_RXE_BITS; in uart_init()
62 uart_get_hw(uart)->dmacr = UART_UARTDMACR_TXDMAE_BITS | UART_UARTDMACR_RXDMAE_BITS; in uart_init()
68 void uart_deinit(uart_inst_t *uart) { in uart_deinit() argument
69 invalid_params_if(UART, uart != uart0 && uart != uart1); in uart_deinit()
70 uart_reset(uart); in uart_deinit()
73 static uint32_t uart_disable_before_lcr_write(uart_inst_t *uart) { in uart_disable_before_lcr_write() argument
94 uint32_t cr_save = uart_get_hw(uart)->cr; in uart_disable_before_lcr_write()
97 hw_clear_bits(&uart_get_hw(uart)->cr, in uart_disable_before_lcr_write()
100 uint32_t current_ibrd = uart_get_hw(uart)->ibrd; in uart_disable_before_lcr_write()
101 uint32_t current_fbrd = uart_get_hw(uart)->fbrd; in uart_disable_before_lcr_write()
116 static void uart_write_lcr_bits_masked(uart_inst_t *uart, uint32_t values, uint32_t write_mask) { in uart_write_lcr_bits_masked() argument
117 invalid_params_if(UART, uart != uart0 && uart != uart1); in uart_write_lcr_bits_masked()
120 uint32_t cr_save = uart_disable_before_lcr_write(uart); in uart_write_lcr_bits_masked()
122 hw_write_masked(&uart_get_hw(uart)->lcr_h, values, write_mask); in uart_write_lcr_bits_masked()
124 uart_get_hw(uart)->cr = cr_save; in uart_write_lcr_bits_masked()
128 uint uart_set_baudrate(uart_inst_t *uart, uint baudrate) { in uart_set_baudrate() argument
144 uart_get_hw(uart)->ibrd = baud_ibrd; in uart_set_baudrate()
145 uart_get_hw(uart)->fbrd = baud_fbrd; in uart_set_baudrate()
149 uart_write_lcr_bits_masked(uart, 0, 0); in uart_set_baudrate()
156 void uart_set_format(uart_inst_t *uart, uint data_bits, uint stop_bits, uart_parity_t parity) { in uart_set_format() argument
161 uart_write_lcr_bits_masked(uart, in uart_set_format()
172 void uart_set_fifo_enabled(uart_inst_t *uart, bool enabled) { in uart_set_fifo_enabled() argument
180 uart_write_lcr_bits_masked(uart, lcr_h_fen_bits, UART_UARTLCR_H_FEN_BITS); in uart_set_fifo_enabled()
183 void uart_set_break(uart_inst_t *uart, bool en) { in uart_set_break() argument
191 uart_write_lcr_bits_masked(uart, lcr_h_brk_bits, UART_UARTLCR_H_BRK_BITS); in uart_set_break()
194 void uart_set_translate_crlf(uart_inst_t *uart, bool crlf) { in uart_set_translate_crlf() argument
196 uart_char_to_line_feed[uart_get_index(uart)] = crlf ? '\n' : 0x100; in uart_set_translate_crlf()
202 bool uart_is_readable_within_us(uart_inst_t *uart, uint32_t us) { in uart_is_readable_within_us() argument
205 if (uart_is_readable(uart)) { in uart_is_readable_within_us()