hardware_uart Library FunctionsTo use this library, add following to the C/C++ file,
#include <hardware/uart.h>
and following to the CMakeLists.txt file.
target_link_libraries(projectName pico_stdlib hardware_gpio hardware_uart)
Following are some of the most commonly used functions for configuring and using the UART peripheral.
uint uart_init(uart_inst_t* uart, uint baudRate)Initialize a specific instance of UART on the μC.
uart is a pointer to the UART instance that should be initialized. The library already defines variables for both the instances. So, you only have to specify uart0 or uart1.baudRate is the baud rate, in bits/s, that the UART instance should use for communication. It must be an unsigned integer number.uart_putc(uart_inst_t* uart, char c)Transmit a character through the UART instance specified.
uart is a pointer to the UART instance that should be used to transmit the character.c is a character being transmitted.char uart_getc(uart_inst_t* uart)Receive a character through the UART instance specified.
uart is a pointer to the UART instance that should be used to receive the character.