mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-08 01:32:05 +00:00
FreeRTOS
This commit is contained in:
@@ -73,8 +73,6 @@ void app_main(void)
|
||||
|
||||
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
|
||||
|
||||
|
||||
|
||||
xMutex = xSemaphoreCreateMutex();
|
||||
if (xMutex == NULL) {
|
||||
printf("Failed to create mutex\n");
|
||||
@@ -92,29 +90,19 @@ void app_main(void)
|
||||
xTaskCreate(task2, "Task2", 2048, NULL, 15, NULL);
|
||||
xTaskCreate(display_task, "DisplayTask", 2048, NULL, 5, NULL);
|
||||
xTaskCreate(restart_task, "TaskRestart", 2048, NULL, 20, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void task1(void *pvParameters) {
|
||||
uint32_t x = 0;
|
||||
|
||||
while (1) {
|
||||
if (xSemaphoreTake(xMutex, 1500)) {
|
||||
printf("Task 1 is running\n");
|
||||
|
||||
/*SensorsData data = {
|
||||
.num1 = x,
|
||||
.num2 = 0,
|
||||
.num3 = 0,
|
||||
};*/
|
||||
s_data.num1 = x;
|
||||
//xQueueSend(xQueue1, &data, 0);
|
||||
xQueueSend(xQueue1, &s_data, 0);
|
||||
printf("Task 1 sent x=%" PRIu32 "\n", x);
|
||||
x+=2;
|
||||
|
||||
vTaskDelay((500)); // Delay for 1 second
|
||||
vTaskDelay((500));
|
||||
xSemaphoreGive(xMutex);
|
||||
}
|
||||
else {
|
||||
@@ -130,19 +118,11 @@ void task2(void *pvParameters) {
|
||||
while (1) {
|
||||
if (xSemaphoreTake(xMutex, 1500)) {
|
||||
printf("Task 2 is running\n");
|
||||
|
||||
/*SensorsData data = {
|
||||
.num1 = 0,
|
||||
.num2 = y,
|
||||
.num3 = 0,
|
||||
};*/
|
||||
s_data.num2 = y;
|
||||
//xQueueSend(xQueue2, &data, 0);
|
||||
xQueueSend(xQueue2, &s_data, 0);
|
||||
printf("Task 2 sent y=%" PRIu32 "\n", y);
|
||||
y++;
|
||||
|
||||
vTaskDelay((250)); // Delay for 2 seconds
|
||||
vTaskDelay((250));
|
||||
xSemaphoreGive(xMutex);
|
||||
}
|
||||
else {
|
||||
@@ -172,5 +152,3 @@ void display_task(void *pvParameters) {
|
||||
vTaskDelay(50);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user