summaryrefslogtreecommitdiffstatshomepage
path: root/ports/esp32/machine_pin.c
diff options
context:
space:
mode:
authorNicko van Someren <nicko@nicko.org>2018-07-01 20:27:10 -0600
committerDamien George <damien.p.george@gmail.com>2018-07-04 10:49:37 +1000
commit14ab81e87accedfb9ed231b206dd21f3a0143404 (patch)
tree1d02c23fb94d9fedfa27bac5c39ffe757bef6adc /ports/esp32/machine_pin.c
parentbccf9d3dcfd000b81b89b9ef862f9bc6104df99d (diff)
downloadmicropython-14ab81e87accedfb9ed231b206dd21f3a0143404.tar.gz
micropython-14ab81e87accedfb9ed231b206dd21f3a0143404.zip
esp32: Reduce latency for handling of scheduled Python callbacks.
Prior to this patch there was a large latency for executing scheduled callbacks when when Python code is sleeping: at the heart of the implementation of sleep_ms() is a call to vTaskDelay(1), which always sleeps for one 100Hz tick, before performing another call to MICROPY_EVENT_POLL_HOOK. This patch fixes this issue by using FreeRTOS Task Notifications to signal the main thread that a new callback is pending.
Diffstat (limited to 'ports/esp32/machine_pin.c')
-rw-r--r--ports/esp32/machine_pin.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ports/esp32/machine_pin.c b/ports/esp32/machine_pin.c
index 2a26d6bfb0..0b9150f556 100644
--- a/ports/esp32/machine_pin.c
+++ b/ports/esp32/machine_pin.c
@@ -33,6 +33,7 @@
#include "py/runtime.h"
#include "py/mphal.h"
+#include "mphalport.h"
#include "modmachine.h"
#include "extmod/virtpin.h"
#include "machine_rtc.h"
@@ -115,6 +116,7 @@ STATIC void IRAM_ATTR machine_pin_isr_handler(void *arg) {
machine_pin_obj_t *self = arg;
mp_obj_t handler = MP_STATE_PORT(machine_pin_irq_handler)[self->id];
mp_sched_schedule(handler, MP_OBJ_FROM_PTR(self));
+ mp_hal_wake_main_task_from_isr();
}
gpio_num_t machine_pin_get_id(mp_obj_t pin_in) {