diff options
Diffstat (limited to 'ports/esp32/mpthreadport.c')
-rw-r--r-- | ports/esp32/mpthreadport.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ports/esp32/mpthreadport.c b/ports/esp32/mpthreadport.c index 1c13e928d..12a6ede86 100644 --- a/ports/esp32/mpthreadport.c +++ b/ports/esp32/mpthreadport.c @@ -41,6 +41,12 @@ #define MP_THREAD_DEFAULT_STACK_SIZE (MP_THREAD_MIN_STACK_SIZE + 1024) #define MP_THREAD_PRIORITY (ESP_TASK_PRIO_MIN + 1) +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0) && !CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP +#define FREERTOS_TASK_DELETE_HOOK vTaskPreDeletionHook +#else +#define FREERTOS_TASK_DELETE_HOOK vPortCleanUpTCB +#endif + // this structure forms a linked list, one node per active thread typedef struct _mp_thread_t { TaskHandle_t id; // system id of thread @@ -70,7 +76,7 @@ void mp_thread_init(void *stack, uint32_t stack_len) { // memory barrier to ensure above data is committed __sync_synchronize(); - // vPortCleanUpTCB needs the thread ready after thread_mutex is ready + // FREERTOS_TASK_DELETE_HOOK needs the thread ready after thread_mutex is ready thread = &thread_entry0; } @@ -179,7 +185,7 @@ void mp_thread_finish(void) { // This is called from the FreeRTOS idle task and is not within Python context, // so MP_STATE_THREAD is not valid and it does not have the GIL. -void vPortCleanUpTCB(void *tcb) { +void FREERTOS_TASK_DELETE_HOOK(void *tcb) { if (thread == NULL) { // threading not yet initialised return; @@ -235,7 +241,7 @@ void mp_thread_deinit(void) { // No tasks left to delete break; } else { - // Call FreeRTOS to delete the task (it will call vPortCleanUpTCB) + // Call FreeRTOS to delete the task (it will call FREERTOS_TASK_DELETE_HOOK) vTaskDelete(id); } } @@ -243,7 +249,7 @@ void mp_thread_deinit(void) { #else -void vPortCleanUpTCB(void *tcb) { +void FREERTOS_TASK_DELETE_HOOK(void *tcb) { } #endif // MICROPY_PY_THREAD |