Skip to content

Commit 44425b8

Browse files
committed
Requested review changes made
1 parent f5f2036 commit 44425b8

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

ports/esp32s2/supervisor/port.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555

5656
uint32_t* heap;
5757
uint32_t heap_size;
58-
extern TaskHandle_t xTaskToNotify;
59-
58+
extern TaskHandle_t sleeping_circuitpython_task;
6059
STATIC esp_timer_handle_t _tick_timer;
6160

6261
extern void esp_restart(void) NORETURN;
@@ -191,23 +190,23 @@ void port_disable_tick(void) {
191190
}
192191

193192
TickType_t sleep_time_duration;
194-
uint32_t NotifyValue = 0;
195-
BaseType_t notify_wait = 0;
196193

197194
void port_interrupt_after_ticks(uint32_t ticks) {
198195
sleep_time_duration = (ticks * 100)/1024;
199-
xTaskToNotify = xTaskGetCurrentTaskHandle();
196+
sleeping_circuitpython_task = xTaskGetCurrentTaskHandle();
200197
}
201198

202199
void port_sleep_until_interrupt(void) {
203200

201+
uint32_t NotifyValue = 0;
202+
204203
if (sleep_time_duration == 0) {
205204
return;
206205
}
207-
notify_wait = xTaskNotifyWait(0x01,0x01,&NotifyValue,
206+
xTaskNotifyWait(0x01,0x01,&NotifyValue,
208207
sleep_time_duration );
209208
if (NotifyValue == 1) {
210-
xTaskToNotify = NULL;
209+
sleeping_circuitpython_task = NULL;
211210
mp_handle_pending();
212211
}
213212
}

ports/esp32s2/supervisor/usb.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
StackType_t usb_device_stack[USBD_STACK_SIZE];
5353
StaticTask_t usb_device_taskdef;
5454

55-
TaskHandle_t xTaskToNotify = NULL;
55+
TaskHandle_t sleeping_circuitpython_task = NULL;
5656

5757
// USB Device Driver task
5858
// 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)
129129
if (mp_interrupt_char == wanted_char) {
130130
tud_cdc_read_flush(); // flush read fifo
131131
mp_keyboard_interrupt();
132-
if (xTaskToNotify != NULL) {
133-
xTaskNotifyGive(xTaskToNotify);
132+
// CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB.
133+
// So, we must notify the other task when a CTRL-C is received.
134+
if (sleeping_circuitpython_task != NULL) {
135+
xTaskNotifyGive(sleeping_circuitpython_task);
134136
}
135137
}
136138
}

0 commit comments

Comments
 (0)