изменения для лучшей работы
This commit is contained in:
parent
a682dc80a9
commit
902d7b0932
@ -5,7 +5,7 @@
|
||||
|
||||
#include <Arduino_FreeRTOS.h>
|
||||
|
||||
const boolean valueToAssert = true;
|
||||
const bool valueToAssert = true;
|
||||
|
||||
// The setup function runs once when you press reset or power the board
|
||||
void setup() {
|
||||
|
||||
@ -102,6 +102,6 @@ void TaskAnalogRead(void *pvParameters) // This is a task.
|
||||
int sensorValue = analogRead(A0);
|
||||
// print out the value you read:
|
||||
Serial.println(sensorValue);
|
||||
vTaskDelay(1); // one tick delay (15ms) in between reads for stability
|
||||
vTaskDelay(250 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
SemaphoreHandle_t mutex;
|
||||
|
||||
int globalCount = 0;
|
||||
int task1Delay = 1250;
|
||||
int task2Delay = 1000;
|
||||
|
||||
void setup() {
|
||||
|
||||
@ -37,11 +39,11 @@ void setup() {
|
||||
xTaskCreate(TaskMutex, // Task function
|
||||
"Task1", // Task name for humans
|
||||
128,
|
||||
1000, // Task parameter
|
||||
&task1Delay, // Task parameter
|
||||
1, // Task priority
|
||||
NULL);
|
||||
|
||||
xTaskCreate(TaskMutex, "Task2", 128, 1000, 1, NULL);
|
||||
xTaskCreate(TaskMutex, "Task2", 128, &task2Delay, 1, NULL);
|
||||
|
||||
}
|
||||
|
||||
@ -50,7 +52,6 @@ void loop() {}
|
||||
void TaskMutex(void *pvParameters)
|
||||
{
|
||||
TickType_t delayTime = *((TickType_t*)pvParameters); // Use task parameters to define delay
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/**
|
||||
|
||||
@ -72,15 +72,15 @@ void loop() {}
|
||||
void TaskBlink(void *pvParameters){
|
||||
(void) pvParameters;
|
||||
|
||||
pinMode(13,OUTPUT);
|
||||
pinMode(LED_BUILTIN,OUTPUT);
|
||||
|
||||
digitalWrite(13,LOW);
|
||||
digitalWrite(LED_BUILTIN,LOW);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
digitalWrite(13,HIGH);
|
||||
digitalWrite(LED_BUILTIN,HIGH);
|
||||
vTaskDelay(250/portTICK_PERIOD_MS);
|
||||
digitalWrite(13,LOW);
|
||||
digitalWrite(LED_BUILTIN,LOW);
|
||||
vTaskDelay(250/portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user