#include <esp_task_wdt.h>
#if CONFIG_FREEROTS_UNICORE
int cores = 0;
#else
int cores = 1;
#endif

void
tID ()
{

  Serial.print ("my core and prio ");
  Serial.print (xPortGetCoreID ());
  Serial.print (" ");
  Serial.println (uxTaskPriorityGet (NULL));

}

void
task0 (void *pParm)
{
  vTaskDelay (1000);
  tID ();
  while (1)
    {
      yield ();
    }
}


void
task1 (void *pParm)
{
  vTaskDelay (1000);
  tID ();
  while (1)
    {
    }
}


void
task2 (void *pParm)
{
  vTaskDelay (1000);
  tID ();
  while (1)
    {
    }
}

void
setup ()
{
  Serial.begin (115200);
  delay (1000);
  esp_task_wdt_init (1, true);
  vTaskDelay (1000);
  //disableCore0WDT();
  //disableCore1WDT(); // is not enabled by default
  //disableLoopWDT()
  xTaskCreate (task0, "t0", 2000, NULL, 2, NULL);
  xTaskCreate (task1, "t1", 2000, NULL, 2, NULL);
  xTaskCreatePinnedToCore (task2, "t2", 2000, NULL, 2, NULL, 0);
  /*                                                        ^--  ´core (0or 1 on esp32)
     ^------  handle to task code
     ^---------- priority 0(lowest) to  (configMAX_PRIORITIES-1)
     ^---------------- pointer to parameter to be used as pParm in task
     ^--------------------- amoont of stak to be allocated
     ^--------------------------- name
     ^---------------------------------- function to be used as code for task
   */
  tID ();
}

void
loop ()
{
}
