// Configure a highly optimized idle hook function with minimal instructions,
// which prints a string every 10seconds
#include <Arduino.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
// Define the string to be printed
const char *message = "Idle hook function executed.";
// Function to print the message every 10 seconds
void idleTask(void *pvParameters) {
while (1) {
Serial.println(message);
// Delay for 10 seconds
vTaskDelay(pdMS_TO_TICKS(10000));
}
}
void setup() {
// Initialize serial communication
Serial.begin(115200);
// Give the serial port some time to initialize
delay(1000);
// Print an initial message
Serial.println("System is starting...");
// Create the idle task
xTaskCreate(
idleTask, // Task function
"IdleTask", // Task name
1024, // Stack size
NULL, // Task parameters
tskIDLE_PRIORITY, // Task priority
NULL // Task handle
);
}
void loop() {
// Do nothing, everything is handled by the FreeRTOS tasks
}