If we think of a class "X" which has member "m" ... we might declare it as:
Code: Select all
class X {
public:
void m() {
// code here
}
}
we might declare an instance of X and call m using:
In C++ m is **not** just a reference to a function ... it also exists in the **context** of the instance of X. Where we have a C language function that expects a pointer to a function ... for example:
we can't call:
because the function "m" doesn't exist outside the context of an instance of X.
In C++, it is trivial to call C, but remember, C++ is a superset of C ... meaning you can do anything in C++ that you can do in C but in C you can't do anything you can do in C++. The ESP-IDF is a C environment and doesn't "know" C++.
In a C++ program, you can declare a function that is exposed as C ... for example:
Code: Select all
extern "C" {
void myFunc();
}
void myFunc() {
X *x = new X();
x->m();
}
and then pass "myFunc" as a C function pointer.
Now, back to your watchdog issue ...
ANY code that is passed as the start routine of a Task should relinquish control back to FreeRTOS periodically ... if not, then it is effectively in a tight loop and it is only by CPU preemption that other tasks get to run. A task delay will release control back from the task.
At a high level, what is it you are doing in your task that requires a tight CPU loop? Are you polling something?