From 3bacab7c67158a999619966d9a85917da49d8053 Mon Sep 17 00:00:00 2001 From: Johan Kanflo Date: Thu, 6 Aug 2015 21:00:24 +0200 Subject: [PATCH] Correct prototype for sdk_uart_rx_one_char, kudos to @foogod --- core/newlib_syscalls.c | 10 +++++++--- include/espressif/sdk_private.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/newlib_syscalls.c b/core/newlib_syscalls.c index 371a183..fb97f7b 100644 --- a/core/newlib_syscalls.c +++ b/core/newlib_syscalls.c @@ -48,9 +48,13 @@ long _write_r(struct _reent *r, int fd, const char *ptr, int len ) */ long _read_r( struct _reent *r, int fd, char *ptr, int len ) { - for(int i = 0; i < len; i++) - ptr[i] = sdk_uart_rx_one_char(); - return len; + for(int i = 0; i < len; i++) { + char ch; + while (sdk_uart_rx_one_char(&ch)) ; + ptr[i] = ch; + + } + return len; } /* These are stub implementations for the reentrant syscalls that diff --git a/include/espressif/sdk_private.h b/include/espressif/sdk_private.h index ac98e43..4340999 100644 --- a/include/espressif/sdk_private.h +++ b/include/espressif/sdk_private.h @@ -30,8 +30,9 @@ struct ip_addr; void sdk_uart_div_modify(uint32_t uart_no, uint32_t new_divisor); /* Read a single character from the UART. + Returns 0 on success, 1 if no character in fifo */ -char sdk_uart_rx_one_char(void); +int sdk_uart_rx_one_char(char *buf); /* Write a single character to the UART. */