Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rp2_common/pico_stdio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (NOT TARGET pico_stdio)
pico_wrap_function(pico_stdio vprintf)
pico_wrap_function(pico_stdio puts)
pico_wrap_function(pico_stdio putchar)
pico_wrap_function(pico_stdio getchar)

if (TARGET pico_printf)
target_link_libraries(pico_stdio INTERFACE pico_printf)
Expand Down
10 changes: 6 additions & 4 deletions src/rp2_common/pico_stdio/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ static int stdio_get_until(char *buf, int len, absolute_time_t until) {
}
}
}
// todo maybe a little sleep here?
// we sleep here in case the in_chars methods acquire mutexes or disable IRQs and
// potentially starve out what they are waiting on (have seen this with USB)
busy_wait_us(1);
} while (!time_reached(until));
return PICO_ERROR_TIMEOUT;
}
Expand Down Expand Up @@ -257,9 +259,9 @@ void stdio_init_all() {

int WRAPPER_FUNC(getchar)(void) {
char buf[1];
if (0 == stdio_get_until(buf, sizeof(buf), at_the_end_of_time)) {
return PICO_ERROR_TIMEOUT;
}
int len = stdio_get_until(buf, 1, at_the_end_of_time);
if (len < 0) return len;
assert(len == 1);
return (uint8_t)buf[0];
}

Expand Down