MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pico_uart_configure

Function pico_uart_configure

bsp/raspberry-pico/Drivers/drv_uart.c:104–136  ·  view source on GitHub ↗

* UART interface */

Source from the content-addressed store, hash-verified

102 * UART interface
103 */
104static rt_err_t pico_uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
105{
106 struct pico_uart_dev *uart = RT_NULL;
107 RT_ASSERT(serial != RT_NULL);
108 RT_ASSERT(cfg != RT_NULL);
109 uart = rt_container_of(serial, struct pico_uart_dev, parent);
110
111 uart_init(uart->instance, cfg->baud_rate);
112
113 // Set the TX and RX pins by using the function select on the GPIO
114 // Set datasheet for more information on function select
115 gpio_set_function(uart->rx_pin, GPIO_FUNC_UART);
116 gpio_set_function(uart->tx_pin, GPIO_FUNC_UART);
117
118 // Set UART flow control CTS/RTS
119 if (cfg->flowcontrol == RT_SERIAL_FLOWCONTROL_CTSRTS)
120 uart_set_hw_flow(uart->instance, true, true);
121 else
122 uart_set_hw_flow(uart->instance, false, false);
123
124 // Set our data format
125 uart_parity_t uart_parity = UART_PARITY_NONE;
126 if (cfg->parity == PARITY_ODD)
127 uart_parity = UART_PARITY_ODD;
128 else if (cfg->parity == PARITY_EVEN)
129 uart_parity = UART_PARITY_EVEN;
130 uart_set_format(uart->instance, cfg->data_bits, cfg->stop_bits, uart_parity);
131
132 // Turn off FIFO's - we want to do this character by character
133 uart_set_fifo_enabled(uart->instance, false);
134
135 return RT_EOK;
136}
137
138static rt_err_t pico_uart_control(struct rt_serial_device *serial, int cmd, void *arg)
139{

Callers

nothing calls this directly

Calls 2

uart_initFunction · 0.50
uart_set_formatFunction · 0.50

Tested by

no test coverage detected