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.
This commit is contained in:
Nicko van Someren
2018-07-01 20:27:10 -06:00
committed by Damien George
parent bccf9d3dcf
commit 14ab81e87a
5 changed files with 28 additions and 4 deletions

View File

@@ -34,6 +34,7 @@
#include "py/obj.h"
#include "py/runtime.h"
#include "modmachine.h"
#include "mphalport.h"
#define TIMER_INTR_SEL TIMER_INTR_LEVEL
#define TIMER_DIVIDER 40000
@@ -109,6 +110,7 @@ STATIC void machine_timer_isr(void *self_in) {
device->hw_timer[self->index].config.alarm_en = self->repeat;
mp_sched_schedule(self->callback, self);
mp_hal_wake_main_task_from_isr();
}
STATIC void machine_timer_enable(machine_timer_obj_t *self) {