pico_stdio improvements (#598)
* add stdio_usb_connected() method * add PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS to allow waiting for CDC connection during init(* * add puts_raw and putchar_raw to skip any CR/LF translation
This commit is contained in:
@ -103,9 +103,29 @@ bool stdio_usb_init(void) {
|
||||
bool rc = add_alarm_in_us(PICO_STDIO_USB_TASK_INTERVAL_US, timer_task, NULL, true);
|
||||
if (rc) {
|
||||
stdio_set_driver_enabled(&stdio_usb, true);
|
||||
#if PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS
|
||||
#if PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS > 0
|
||||
absolute_time_t until = make_timeout_time_ms(PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS);
|
||||
#else
|
||||
absolute_time_t until = at_the_end_of_time;
|
||||
#endif
|
||||
do {
|
||||
if (stdio_usb_connected()) {
|
||||
#if PICO_STDIO_USB_POST_CONNECT_WAIT_DELAY_MS != 0
|
||||
sleep_ms(PICO_STDIO_USB_POST_CONNECT_WAIT_DELAY_MS);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
sleep_ms(10);
|
||||
} while (!time_reached(until));
|
||||
#endif
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool stdio_usb_connected(void) {
|
||||
return tud_cdc_connected();
|
||||
}
|
||||
#else
|
||||
#include "pico/stdio_usb.h"
|
||||
#warning stdio USB was configured, but is being disabled as TinyUSB is explicitly linked
|
||||
|
Reference in New Issue
Block a user