#include "gpio.h" #include "uart.h" #include "resets.h" #include "stdio.h" #define UART_ID uart0_hw int main(void) { reset_unreset_blocks_wait(RESETS_BLOCK_IO_BANK0 | RESETS_BLOCK_UART0); gpio_init(0, GPIO_FUNC_UART | GPIO_PULL_UP | GPIO_DRIVE_4MA); /* UART_TX pin */ gpio_init(1, GPIO_FUNC_UART | GPIO_PULL_UP | GPIO_SCHMITT | GPIO_PAD_IE | GPIO_PAD_OD); /* UART_RX pin */ uart_init(UART_ID, 2 * 1000 * 1000, UART_DATABITS_8 | UART_PARITY_NONE | UART_STOPBITS_1); printf("uart_loopback example\r\n"); while (1) { int c = uart_get_char(UART_ID); if (c < 0) { continue; } uart_put_char(UART_ID, (uint8_t)c); } return 0; }