From 2c3fe5bebf6cf6a9a5fb9c685aa744529c8548cb Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 7 Mar 2025 19:35:13 +0100 Subject: [PATCH] Only pin to core in ESP32-S3 since it is multicore. Signed-off-by: Pol Henarejos --- src/esp_compat.h | 9 ++++++++- src/main.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/esp_compat.h b/src/esp_compat.h index 53e78e3..e91aace 100644 --- a/src/esp_compat.h +++ b/src/esp_compat.h @@ -30,7 +30,14 @@ typedef QueueHandle_t queue_t; #define queue_is_empty(a) (uxQueueMessagesWaiting(*(a)) == 0) #define queue_try_remove(a,b) xQueueReceive(*(a), b, 0) extern TaskHandle_t hcore0, hcore1; -#define multicore_launch_core1(a) xTaskCreatePinnedToCore((void(*)(void *))a, "core1", 4096*ITF_TOTAL*2, NULL, CONFIG_TINYUSB_TASK_PRIORITY - 2, &hcore1, 1) +#ifdef CONFIG_IDF_TARGET_ESP32S3 +#define ESP32_CORE0 0 +#define ESP32_CORE1 1 +#else +#define ESP32_CORE0 tskNO_AFFINITY +#define ESP32_CORE1 tskNO_AFFINITY +#endif +#define multicore_launch_core1(a) xTaskCreatePinnedToCore((void(*)(void *))a, "core1", 4096*ITF_TOTAL*2, NULL, CONFIG_TINYUSB_TASK_PRIORITY - 2, &hcore1, ESP32_CORE1) #define multicore_reset_core1() do { if (hcore1) { eTaskState e = eTaskGetState(hcore1); if (e <= eSuspended) { vTaskDelete(hcore1); }} }while(0) #define sleep_ms(a) vTaskDelay(a / portTICK_PERIOD_MS) static inline uint32_t board_millis(void) { diff --git a/src/main.c b/src/main.c index fe5b0e5..4d7c068 100644 --- a/src/main.c +++ b/src/main.c @@ -343,7 +343,7 @@ int main(void) { #endif #ifdef ESP_PLATFORM - xTaskCreatePinnedToCore(core0_loop, "core0", 4096*ITF_TOTAL*2, NULL, CONFIG_TINYUSB_TASK_PRIORITY - 1, &hcore0, 0); + xTaskCreatePinnedToCore(core0_loop, "core0", 4096*ITF_TOTAL*2, NULL, CONFIG_TINYUSB_TASK_PRIORITY - 1, &hcore0, ESP32_CORE0); #else core0_loop(); #endif