diff --git a/epicardium/drivers/sleep.c b/epicardium/drivers/sleep.c index 8370d47be7643760a43b8912ca00452fbbeacba3..524a4a5ab73c612059c5c2a066de28e53013f92e 100644 --- a/epicardium/drivers/sleep.c +++ b/epicardium/drivers/sleep.c @@ -210,5 +210,7 @@ void sleep_deepsleep(void) void epic_sleep(uint32_t ms) { - vTaskDelay(pdMS_TO_TICKS(ms)); + /* Allow the interrupt module to break us out of a call to + * epic_sleep() */ + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(ms)); } diff --git a/epicardium/user_core/interrupts.c b/epicardium/user_core/interrupts.c index 76675eb284a92c4682d9dba485504928b006ba2f..0ccfd87fb9b8f21a67e7bb6181770b60501975cb 100644 --- a/epicardium/user_core/interrupts.c +++ b/epicardium/user_core/interrupts.c @@ -2,6 +2,7 @@ #include "os/core.h" #include "epicardium.h" #include "api/interrupt-sender.h" +#include "user_core/user_core.h" #include <assert.h> struct interrupt_priv { @@ -45,6 +46,10 @@ void interrupt_trigger_sync(api_int_id_t id) ; api_interrupt_trigger(id); + + /* Break the dispatcher task out of a potential call + * to epic_sleep() */ + xTaskNotifyGive(dispatcher_task_id); out: mutex_unlock(&interrupt_mutex); } @@ -171,6 +176,10 @@ void vInterruptsTask(void *pvParameters) interrupt_data.has_pending = false; } else if (interrupt_data.int_enabled[current_irq]) { api_interrupt_trigger(current_irq); + + /* Break the dispatcher task out of a potential call + * to epic_sleep() */ + xTaskNotifyGive(dispatcher_task_id); } mutex_unlock(&interrupt_mutex);