Pin Tasks to cores

This commit is contained in:
Thomas Kolb 2019-12-09 22:21:01 +01:00
parent f91b3c8cfb
commit 154ed66174
4 changed files with 18 additions and 6 deletions

5
include/coreids.h Normal file
View file

@ -0,0 +1,5 @@
#pragma once
#define CORE_ID_LED 1
#define CORE_ID_WEBSERVER 0
#define CORE_ID_UPDATESERVER 0

View file

@ -6,19 +6,22 @@
#include "UpdateServer.h"
#include "coreids.h"
UpdateServer::UpdateServer(const std::string &pw)
: m_cr(pw)
{}
void UpdateServer::start(void)
{
xTaskCreate(
xTaskCreatePinnedToCore(
updateTask, /* Task function. */
"Update Task", /* name of task. */
10000, /* Stack size of task */
this, /* parameter of the task */
2, /* priority of the task */
NULL); /* Task handle to keep track of created task */
NULL, /* Task handle to keep track of created task */
CORE_ID_UPDATESERVER);
}
static void sendMessage(WiFiClient *client, bool success, const char *message)

View file

@ -10,6 +10,8 @@
#include "Fader.h"
#include "Animation/AnimationController.h"
#include "coreids.h"
WebServer::WebServer(void)
: m_cr(Config::instance().getCRPassword()), m_fader(NULL)
{
@ -274,13 +276,14 @@ void WebServer::serverTask(void *arg)
bool WebServer::start(void)
{
xTaskCreate(
xTaskCreatePinnedToCore(
WebServer::serverTask, /* Task function. */
"HTTP Server Task", /* name of task. */
6144, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
NULL); /* Task handle to keep track of created task */
NULL, /* Task handle to keep track of created task */
CORE_ID_WEBSERVER);
return true;
}

View file

@ -221,13 +221,14 @@ void setup()
animController.changeAnimation(std::unique_ptr<Animation>(new ConnectingAnimation(&ledFader)), false);
xTaskCreate(
xTaskCreatePinnedToCore(
ledTask, /* Task function. */
"LED Task", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
3, /* priority of the task */
NULL); /* Task handle to keep track of created task */
NULL, /* Task handle to keep track of created task */
CORE_ID_LED);
// Connect the WiFi network (or start an AP if that doesn't work)
for (auto &net : Config::instance().getWLANList())