I’m updating my last post because it won’t work. The info here is tested on an ESP32.
The Espressif API modified the FreeRTOS hooks to be compatible with multicore CPUs, allowing you to specify a separate idle task for each core. Under this system, you have to register your idle task function. The original idle hook has been modified to call the hooks you register, and you can not write:
If you do, when you compile you’ll get an error indication that this function has been redefined by your code. This example is written for the idle hook, but the tick hook has similar changes.
All this is (mostly) explained here:
I tested this, and here is what you need to do to make this work:
In your mos.yml file:
In your code, you’ll need these header files:
Then you’ll need to write your idle hook callback:
static long int ctr;
The callback should return true if it should be called by the idle hook once per interrupt (or FreeRTOS tick), and return false if it should be called repeatedly as fast as possible by the idle hook.
Finally, register the idle task callback. There are a bunch of functions available for this, see the link above for complete details. This function registers the callback for the core on which it is called:
if(esp_register_freertos_idle_hook(myTestIdleHook) == ESP_OK)
LOG(LL_INFO, ("Idle hook successfully registered."));
LOG(LL_INFO, ("Idle hook registration failed."));
Check the link above for return information. It took a bit of research to figure this out, so I hope its useful to someone.