File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5555
5656uint32_t * heap ;
5757uint32_t heap_size ;
58- extern TaskHandle_t xTaskToNotify ;
59-
58+ extern TaskHandle_t sleeping_circuitpython_task ;
6059STATIC esp_timer_handle_t _tick_timer ;
6160
6261extern void esp_restart (void ) NORETURN ;
@@ -191,23 +190,23 @@ void port_disable_tick(void) {
191190}
192191
193192TickType_t sleep_time_duration ;
194- uint32_t NotifyValue = 0 ;
195- BaseType_t notify_wait = 0 ;
196193
197194void port_interrupt_after_ticks (uint32_t ticks ) {
198195 sleep_time_duration = (ticks * 100 )/1024 ;
199- xTaskToNotify = xTaskGetCurrentTaskHandle ();
196+ sleeping_circuitpython_task = xTaskGetCurrentTaskHandle ();
200197}
201198
202199void 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}
Original file line number Diff line number Diff line change 5252StackType_t usb_device_stack [USBD_STACK_SIZE ];
5353StaticTask_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}
You can’t perform that action at this time.
0 commit comments