diff --git a/core/app_main.c b/core/app_main.c index 215f606..316cb6d 100644 --- a/core/app_main.c +++ b/core/app_main.c @@ -363,15 +363,6 @@ static void dump_excinfo(void) { sdk_system_rtc_mem_write(0, excinfo, 32); } -// .irom0.text+0x368 -int sdk_uart_rx_one_char(char *buf) { - /* This functions returns 1 instead of -1 on error, - but is otherwise the same. Unsure if anyone checks the - result for a specific value though. - */ - return uart_getc_nowait(0) ? 1 : 0; -} - // .irom0.text+0x398 void sdk_wdt_init(void) { WDT.CTRL &= ~WDT_CTRL_ENABLE; diff --git a/core/sdk_compat.c b/core/sdk_compat.c index b6bb6b3..b0d6789 100644 --- a/core/sdk_compat.c +++ b/core/sdk_compat.c @@ -1,5 +1,5 @@ /* - * Wrappers for functions called by binary espressif libraries + * Compatibility routines for the Espressif SDK and its API * * Part of esp-open-rtos * Copyright (C) 2015 Superhouse Automation Pty Ltd @@ -10,6 +10,8 @@ #include #include +#include + void IRAM *zalloc(size_t nbytes) { return calloc(1, nbytes); @@ -18,9 +20,8 @@ void IRAM *zalloc(size_t nbytes) extern void (*__init_array_start)(void); extern void (*__init_array_end)(void); -/* Do things which should be done as part of the startup code, but aren't. - - Can be replaced with _start() once we have open source startup code. +/* Do things which should be done as part of the SDK startup code, but aren't. + TODO: Move into app_main.c */ void sdk_compat_initialise() { @@ -29,3 +30,15 @@ void sdk_compat_initialise() for ( p = &__init_array_start; p != &__init_array_end; ++p) (*p)(); } + +/* UART RX function from Espressif SDK internals. + * + * Not part of published API. + */ +int sdk_uart_rx_one_char(char *buf) { + int c = uart_getc_nowait(0); + if(c < 0) + return 1; + *buf = (char)c; + return 0; +}