/*
* Example of a basic FreeRTOS queue
* https://www.freertos.org/Embedded-RTOS-Queues.html
*/
// Include Arduino FreeRTOS library
#include <Arduino_FreeRTOS.h>
// Include queue support
#include <queue.h>
// Define a Array
int pinReadArray[4]={0,0,0,0};
//Function Declaration
void TaskBlink(void *pvParameters);
void TaskAnalogReadPin0(void *pvParameters);
void TaskAnalogReadPin1(void *pvParameters);
void TaskSerial(void *pvParameters);
/*
* Declaring a global variable of type QueueHandle_t
*
*/
QueueHandle_t arrayQueue;
int count0=0;
int count1=0;
void setup() {
/**
* Create a queue.
* https://www.freertos.org/a00116.html
*/
arrayQueue=xQueueCreate(4, //Queue length
sizeof(int)); //Queue item size
if(arrayQueue!=NULL){
// Create task that consumes the queue if it was created.
xTaskCreate(TaskSerial,// Task function
"PrintSerial",// Task name
128,// Stack size
NULL,
2,// Priority
NULL);
// Create task that publish data in the queue if it was created.
xTaskCreate(TaskAnalogReadPin0, // Task function
"AnalogRead1",// Task name
128,// Stack size
NULL,
1,// Priority
NULL);
// Create other task that publish data in the queue if it was created.
xTaskCreate(TaskAnalogReadPin1,// Task function
"AnalogRead2",// Task name
128,// Stack size
NULL,
1,// Priority
NULL);
xTaskCreate(TaskBlink,// Task function
"Blink", // Task name
128,// Stack size
NULL,
0,// Priority
NULL);
}
}
void loop() {
}