Added SchedulerTask
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user