//FreeRTOS Interrupt Management Examples with Arduino
//https://microcontrollerslab.com/freertos-interrupt-management-examples-with-arduino/
// Installation of FreeRTOS on Library Manager on the left radio colume.
#include <Arduino_FreeRTOS.h>
#include "queue.h"
QueueHandle_t xStringQueue;
int timer1_counter;
void setup(){
Serial.begin(9600);
xStringQueue = xQueueCreate(28, sizeof(char *));
xTaskCreate(vTaskStringPrinter," String Printer Task", 256, NULL, 1, NULL);
//xTaskCreate(vTaskStringPrinter," String Printer", 100, NULL, 1,NULL);
InterruptInit();
}
void vTaskStringPrinter(void *pvParameters){
char *pcString;
while(1) {
xQueueReceive(xStringQueue,&pcString,portMAX_DELAY);
Serial.println(pcString);
}
}
ISR(TIMER1_OVF_vect){
//TCNT1 = timer1_counter;
//uint32_t receivedNumber;
static const char *pcStrings[]={"Hello! Hi, I’am Dong."};
/* static const char *pcStrings[]=
{
"Hello\r\n",
"Hi\r\n",
"I\r\n",
"am\r\n",
"Dong.\r\n",
}; */
xQueueSendToBackFromISR(xStringQueue,&pcStrings,pdFALSE);
//xQueueSendToBackFromISR(xStringQueue,&pcStrings[0],pdFALSE);
// Only print "Hello" with &pcStrings[0].
}
void loop(){}
void InterruptInit(){
noInterrupts();
TCCR1A =0;
TCCR1B =0;
timer1_counter = 34286;
TCNT1 = timer1_counter;
TCCR1B |=(1<<CS12);
TIMSK1 |= (1 << TOIE1);
interrupts();
}