//https://github.com/SIMS-IOT-Devices/FreeRTOS-ESP-IDF-SPI/blob/main/Slave_transmitter.c
//https://github.com/martinberlin/esp32-spi-slave/blob/master/src/main.cpp
//https://github.com/scottbez1/esp32DualSpiTest/blob/master/src/main.cpp
//https://github.com/dahmadjid/spi_master_fpga
//https://github.com/zile01/ESP32_SPI_Communication

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#define LED_1 GPIO_NUM_5
#define LED_2 GPIO_NUM_4

TaskHandle_t Task1;
TaskHandle_t Task2;

void setup() {
    Serial.begin(115200);
    pinMode(LED_1, OUTPUT);
    pinMode(LED_2, OUTPUT);
    xTaskCreatePinnedToCore(Task1code,"Task 1", 10000, NULL,1,&Task1,0);
    xTaskCreatePinnedToCore(Task2code,"Task 2", 10000, NULL,1,&Task2,1);
}

void Task1code(void * parameter){
    Serial.print("Task 1 blue running on core ");
    Serial.println(xPortGetCoreID());

    for(;;) {
        digitalWrite(LED_1, HIGH);
        delay(251);
        digitalWrite(LED_1, LOW);
        delay(250);
    }
}

void Task2code(void * parameter){
    Serial.print("Task 2 green running on core ");
    Serial.println(xPortGetCoreID());

    for(;;) {
        digitalWrite(LED_2, HIGH);
        delay(250);
        digitalWrite(LED_2, LOW);
        delay(251);
    }
}

void loop(){

}

// void Task1code(void * parameter){
//     Serial.print("Task 1 running on core ");
//     Serial.println(xPortGetCoreID());
// }

// void loop() {
//   Serial.print("loop() is running on core ");
//   Serial.println(xPortGetCoreID());
// }