I'm running into a situation where trying to read from the UART halts my application. I've configured two pins for UART communication, and have attached a USB to TTL adapter to those pins. Under these conditions, everything works fine, but if I power up the board without the USB to TTL adapter connected, the application seems to halt when calling ad_uart_read(). I also found that it does not halt when I simply connect the RX and TX pins.
For my application, communication over UART is an optional feature, and I need the application to run regardless of whether RX/TX are connected.
How I have things configured is as follows:
//Configure two pins for UART:
static const gpio_config gpio_cfg[] = {
HW_GPIO_PINCONFIG(HW_GPIO_PORT_1, HW_GPIO_PIN_2, OUTPUT, UART_TX, false),
HW_GPIO_PINCONFIG(HW_GPIO_PORT_1, HW_GPIO_PIN_4, OUTPUT, UART_RX, false),
HW_GPIO_PINCONFIG_END
}
...
static void periph_init(void) {
hw_gpio_configure(gpio_cfg);
}
//In a separate task setup a loop to read from the UART:
uart_device uart = ad_uart_open(SERIAL1);
for (;;) {
uint8_t buf[BUF_LEN];
int len = ad_uart_read(uart, buf, BUF_LEN, OS_EVENT_FOREVER);
}