Skip to content

Commit

Permalink
Correct prototype for sdk_uart_rx_one_char, kudos to @foogod
Browse files Browse the repository at this point in the history
  • Loading branch information
kanflo committed Aug 7, 2015
1 parent 0e521a7 commit 64a1e55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions core/newlib_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion include/espressif/sdk_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 64a1e55

Please sign in to comment.