#include <Arduino_FreeRTOS.h>
#include "semphr.h"
//Mutex handler
SemaphoreHandle_t xMutex;
void setup()
{
// Enable serial module of Arduino with 9600 baud rate
Serial.begin(9600);
//API for create mutex and assign it a already create handler
xMutex = xSemaphoreCreateMutex();
//created two task
xTaskCreate(PLAY_STATION,"RAM Turn",100,"RAM Playing Mario \r\n",1,NULL);
xTaskCreate(PLAY_STATION,"LAXMAN Turn",100,"LAXMAN Playing modern Combat \r\n",1,NULL);
}
//Definition of Play Station tasks
void PLAY_STATION(void *pvParameters)
{
char *Display;
Display = (char *)pvParameters;
while(1)
{
LED(Display);
vTaskDelay(pdMS_TO_TICKS(100));
}
}
// Definition of Display for both task
void LED(const char* monitor)
{
xSemaphoreTake(xMutex, portMAX_DELAY); // take mutex
Serial.println(monitor); // send string to serial monitor
xSemaphoreGive(xMutex); // release mutex
}
void loop(){}