samples: drivers: uart: Detect missing FIFO mode in echo_bot
Print an error message if the UART doesn't support FIFO mode or FIFO mode is not enabled. Previously the sample would run with no errors, but wouldn't receive or echo any data. Signed-off-by: Trent Piepho <tpiepho@gmail.com>
This commit is contained in:
parent
9ee1e64613
commit
8c8d41c32f
1 changed files with 12 additions and 1 deletions
|
@ -78,7 +78,18 @@ void main(void)
|
|||
}
|
||||
|
||||
/* configure interrupt and callback to receive data */
|
||||
uart_irq_callback_user_data_set(uart_dev, serial_cb, NULL);
|
||||
int ret = uart_irq_callback_user_data_set(uart_dev, serial_cb, NULL);
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret == -ENOTSUP) {
|
||||
printk("Interrupt-driven UART API support not enabled\n");
|
||||
} else if (ret == -ENOSYS) {
|
||||
printk("UART device does not support interrupt-driven API\n");
|
||||
} else {
|
||||
printk("Error setting UART callback: %d\n", ret);
|
||||
}
|
||||
return;
|
||||
}
|
||||
uart_irq_rx_enable(uart_dev);
|
||||
|
||||
print_uart("Hello! I'm your echo bot.\r\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue