From d8131bc407f11d5b7d7eeed9351d74a8f317722c Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Sat, 20 Jul 2019 05:16:46 +1000 Subject: [PATCH] Minor esp32 fixes (#2837) * Move task_post() into IRAM so it can be used by IRAM'd ISRs. * Don't leave crud on stack on pcall error. --- components/base_nodemcu/uart.c | 4 ++++ components/task/task.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/base_nodemcu/uart.c b/components/base_nodemcu/uart.c index ee9641e5..218b3c9c 100644 --- a/components/base_nodemcu/uart.c +++ b/components/base_nodemcu/uart.c @@ -20,9 +20,11 @@ bool uart_on_data_cb(unsigned id, const char *buf, size_t len){ if(!gL) return false; + int top = lua_gettop(gL); lua_rawgeti(gL, LUA_REGISTRYINDEX, uart_status[id].receive_rf); lua_pushlstring(gL, buf, len); lua_pcall(gL, 1, 0, 0); + lua_settop(gL, top); return !run_input; } @@ -34,9 +36,11 @@ bool uart_on_error_cb(unsigned id, const char *buf, size_t len){ if(!gL) return false; + int top = lua_gettop(gL); lua_rawgeti(gL, LUA_REGISTRYINDEX, uart_status[id].error_rf); lua_pushlstring(gL, buf, len); lua_pcall(gL, 1, 0, 0); + lua_settop(gL, top); return true; } diff --git a/components/task/task.c b/components/task/task.c index 3a3e0e20..9fa69e6f 100644 --- a/components/task/task.c +++ b/components/task/task.c @@ -55,7 +55,7 @@ task_handle_t task_get_id(task_callback_t t) { } -bool task_post (task_prio_t priority, task_handle_t handle, task_param_t param) +bool IRAM_ATTR task_post (task_prio_t priority, task_handle_t handle, task_param_t param) { if (priority >= TASK_PRIORITY_COUNT || (handle & TASK_HANDLE_MASK) != TASK_HANDLE_MONIKER)