mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-10-01 06:35:49 +00:00
FreeRTOS
This commit is contained in:
@@ -94,7 +94,16 @@ void task1(void *pvParameters) {
|
|||||||
while (1) {
|
while (1) {
|
||||||
if (xSemaphoreTake(xMutex, 1500)) {
|
if (xSemaphoreTake(xMutex, 1500)) {
|
||||||
printf("Task 1 is running\n");
|
printf("Task 1 is running\n");
|
||||||
printf("This is Task #1\n\n");
|
|
||||||
|
SensorsData data = {
|
||||||
|
.num1 = x,
|
||||||
|
.num2 = 0,
|
||||||
|
.num3 = 0,
|
||||||
|
};
|
||||||
|
xQueueSend(xQueue1 &data, 0);
|
||||||
|
printf("Task 1 sent data");
|
||||||
|
x++;
|
||||||
|
|
||||||
vTaskDelay((500)); // Delay for 1 second
|
vTaskDelay((500)); // Delay for 1 second
|
||||||
xSemaphoreGive(xMutex);
|
xSemaphoreGive(xMutex);
|
||||||
}
|
}
|
||||||
@@ -117,11 +126,10 @@ void task2(void *pvParameters) {
|
|||||||
.num2 = y,
|
.num2 = y,
|
||||||
.num3 = 0,
|
.num3 = 0,
|
||||||
};
|
};
|
||||||
xQueueSend(xQueue1, &data, 0);
|
xQueueSend(xQueue2, &data, 0);
|
||||||
printf("Task 1 sent data");
|
printf("Task 1 sent data");
|
||||||
y++;
|
y++;
|
||||||
|
|
||||||
printf("This is Task #2\n\n");
|
|
||||||
vTaskDelay((2000)); // Delay for 2 seconds
|
vTaskDelay((2000)); // Delay for 2 seconds
|
||||||
xSemaphoreGive(xMutex);
|
xSemaphoreGive(xMutex);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user