Added SchedulerTask

This commit is contained in:
2021-08-09 16:38:13 +02:00
parent a6deb67f6d
commit 3195a3e590
6 changed files with 206 additions and 3 deletions

View File

@@ -1,6 +1,19 @@
#include "taskutils.h"
#include "sdkconfig.h"
#define LOG_LOCAL_LEVEL CONFIG_ESPCPPUTILS_LOG_LOCAL_LEVEL
// esp-idf includes
#include <esp_log.h>
// local includes
#include "futurecpp.h"
namespace espcpputils {
namespace {
constexpr const char * const TAG = "ESPCPPUTILS";
} // namespace
BaseType_t createTask(TaskFunction_t pvTaskCode,
const char * const pcName,
const uint32_t usStackDepth,
@@ -13,11 +26,22 @@ BaseType_t createTask(TaskFunction_t pvTaskCode,
{
case CoreAffinity::Core0:
case CoreAffinity::Core1:
return xTaskCreatePinnedToCore(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask, int(coreAffinity));
{
const auto result = xTaskCreatePinnedToCore(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask, int(coreAffinity));
if (result != pdPASS)
ESP_LOGW(TAG, "xTaskCreatePinnedToCore() %s failed with %i", pcName, result);
return result;
}
case CoreAffinity::Both:
return xTaskCreate(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask);
{
const auto result = xTaskCreate(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask);
if (result != pdPASS)
ESP_LOGW(TAG, "xTaskCreate() %s failed with %i", pcName, result);
return result;
}
default:
__builtin_unreachable();
ESP_LOGE(TAG, "unknown coreAffinity %i", std::to_underlying(coreAffinity));
return pdFAIL;
}
}