Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding core selection support #10

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/ESP_FlexyStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,23 @@ ESP_FlexyStepper::~ESP_FlexyStepper()
}

//TODO: use https://github.com/nrwiersma/ESP8266Scheduler/blob/master/examples/simple/simple.ino for ESP8266
void ESP_FlexyStepper::startAsService(void)
void ESP_FlexyStepper::startAsService(int core)
Voha888 marked this conversation as resolved.
Show resolved Hide resolved
{
disableCore0WDT(); // we have to disable the Watchdog timer to prevent it from rebooting the ESP all the time another option would be to add a vTaskDelay but it would slow down the stepper
xTaskCreate(

if ( (!core_0_wdt_was_disabled_from_flexyStepper) && (core!=1) ) //If WDT has not been disabled previously and core 1 is not selected
{
disableCore0WDT(); // we have to disable the Watchdog timer to prevent it from rebooting the ESP all the time another option would be to add a vTaskDelay but it would slow down the stepper
core_0_wdt_was_disabled_from_flexyStepper=1; //Let's indicate that we have disabled WDT for kernel 0
}

xTaskCreateUniversal( //This type of task is specially adapted to work with single and dual core versions of ESP32
ESP_FlexyStepper::taskRunner, /* Task function. */
"FlexyStepper", /* String with name of task (by default max 16 characters long) */
2000, /* Stack size in bytes. */
this, /* Parameter passed as input of the task */
1, /* Priority of the task, 1 seems to work just fine for us */
&this->xHandle); /* Task handle. */
&this->xHandle, /* Task handle. */
core); /* The core on which our task will be executed*/
}

void ESP_FlexyStepper::taskRunner(void *parameter)
Expand Down
4 changes: 3 additions & 1 deletion src/ESP_FlexyStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@
typedef void (*callbackFunction)(void);
typedef void (*positionCallbackFunction)(long);

static bool core_0_wdt_was_disabled_from_flexyStepper = 0;

class ESP_FlexyStepper
{
public:
ESP_FlexyStepper();
~ESP_FlexyStepper();
//service functions
void startAsService(void);
void startAsService(int core= (-1) ); //If the user does not specify the desired kernel as a parameter, then the free one will be selected
void stopService(void);
bool isStartedAsService(void);

Expand Down