1 /* 2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include "pico/stdlib.h" 8 #include "hardware/uart.h" 9 getchar_timeout_us(uint32_t timeout_us)10int getchar_timeout_us(uint32_t timeout_us) { 11 absolute_time_t t = make_timeout_time_us(timeout_us); 12 while (!uart_is_readable(uart_default)) { 13 if (absolute_time_diff_us(t, get_absolute_time()) > 0) { 14 return STDIO_NO_INPUT; 15 } 16 sleep_ms(1); 17 } 18 return uart_getc(uart_default); 19 } 20 stdio_uart_init()21void stdio_uart_init() { 22 uart_init(uart_default, 0); 23 }