| 62 | } |
| 63 | |
| 64 | void startSerialCommandsHandlerTask(bool initQueues) { |
| 65 | if (initQueues) { |
| 66 | cmdQueue = xQueueCreate(2, sizeof(CmdPacket)); |
| 67 | rspQueue = xQueueCreate(2, sizeof(bool)); |
| 68 | } |
| 69 | |
| 70 | xTaskCreatePinnedToCore( |
| 71 | _serialCmdsTaskLoop, // Function to implement the task |
| 72 | "serialcmds", // Name of the task (any string) |
| 73 | SERIAL_CMDS_TASK_STACK_SIZE, // Stack size in bytes |
| 74 | NULL, // This is a pointer to the parameter that will be passed to the new task. We are not using it |
| 75 | // here and therefore it is set to NULL. |
| 76 | 2, // Priority of the task |
| 77 | &serialcmdsTaskHandle, // Task handle (optional, can be NULL). |
| 78 | #if SOC_CPU_CORES_NUM > 1 |
| 79 | 1 // Core where the task should run. By default, all your Arduino code runs on Core 1 and the Wi-Fi |
| 80 | // and RF functions |
| 81 | #else |
| 82 | 0 // Core where the task should run. ESP32-C5 has only one core |
| 83 | #endif |
| 84 | ); // (these are usually hidden from the Arduino environment) use the Core 0. |
| 85 | if (!serialcmdsTaskHandle) { Serial.println("Failed to create Serial Commands Handler task"); } |
| 86 | } |