summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32s2/supervisor/port.c13
-rw-r--r--ports/esp32s2/supervisor/usb.c8
2 files changed, 11 insertions, 10 deletions
diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c
index 46de63627..4b9a4f7ef 100644
--- a/ports/esp32s2/supervisor/port.c
+++ b/ports/esp32s2/supervisor/port.c
@@ -55,8 +55,7 @@
uint32_t* heap;
uint32_t heap_size;
-extern TaskHandle_t xTaskToNotify;
-
+extern TaskHandle_t sleeping_circuitpython_task;
STATIC esp_timer_handle_t _tick_timer;
extern void esp_restart(void) NORETURN;
@@ -191,23 +190,23 @@ void port_disable_tick(void) {
}
TickType_t sleep_time_duration;
-uint32_t NotifyValue = 0;
-BaseType_t notify_wait = 0;
void port_interrupt_after_ticks(uint32_t ticks) {
sleep_time_duration = (ticks * 100)/1024;
- xTaskToNotify = xTaskGetCurrentTaskHandle();
+ sleeping_circuitpython_task = xTaskGetCurrentTaskHandle();
}
void port_sleep_until_interrupt(void) {
+ uint32_t NotifyValue = 0;
+
if (sleep_time_duration == 0) {
return;
}
- notify_wait = xTaskNotifyWait(0x01,0x01,&NotifyValue,
+ xTaskNotifyWait(0x01,0x01,&NotifyValue,
sleep_time_duration );
if (NotifyValue == 1) {
- xTaskToNotify = NULL;
+ sleeping_circuitpython_task = NULL;
mp_handle_pending();
}
}
diff --git a/ports/esp32s2/supervisor/usb.c b/ports/esp32s2/supervisor/usb.c
index 86186d36b..2bfcdfb12 100644
--- a/ports/esp32s2/supervisor/usb.c
+++ b/ports/esp32s2/supervisor/usb.c
@@ -52,7 +52,7 @@
StackType_t usb_device_stack[USBD_STACK_SIZE];
StaticTask_t usb_device_taskdef;
-TaskHandle_t xTaskToNotify = NULL;
+TaskHandle_t sleeping_circuitpython_task = NULL;
// USB Device Driver task
// This top level thread process all usb events and invoke callbacks
@@ -129,8 +129,10 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char)
if (mp_interrupt_char == wanted_char) {
tud_cdc_read_flush(); // flush read fifo
mp_keyboard_interrupt();
- if (xTaskToNotify != NULL) {
- xTaskNotifyGive(xTaskToNotify);
+ // CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB.
+ // So, we must notify the other task when a CTRL-C is received.
+ if (sleeping_circuitpython_task != NULL) {
+ xTaskNotifyGive(sleeping_circuitpython_task);
}
}
}