v0.5.0
- добавлена поддержка платы ELBEAR ACE-NANO; - добавлена поддержка плат ELSOMIK OEM и SE; - добавлена возможность работы в режиме отладки для всех плат, входящих в состав пакета. Доступно для версии ArduinoIDE 2 и выше; - добавлена поддержка библиотеки FreeRTOS; - добавлена поддержка библиотеки IRremote; - добавлена поддержка библиотеки OneWire; - добавлена поддержка аппаратного I2C0 для плат START-MIK32 и ELSOMIK. Для работы с ним доступен экземпляр класса Wire1; - добавлена поддержка аппаратного SPI0 для всех плат, входящих в пакет. Для работы с ним доступен экземпляр класса SPI1; - увеличено быстродействие функций digitalWrite, digitalRead; - исправлены известные ошибки. Co-authored-by: KlassenTS <klassen@elron.tech> Co-committed-by: KlassenTS <klassen@elron.tech>
This commit was merged in pull request #19.
This commit is contained in:
1 parent
de1f0d7fda
commit
1c8e06634c
211 files changed
+97525
-591
No files matched your search
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Example of a FreeRTOS mutex
|
||||
https://www.freertos.org/Real-time-embedded-RTOS-mutexes.html
|
||||
*/
|
||||
|
||||
// Include Arduino FreeRTOS library
|
||||
#include <Arduino_FreeRTOS.h>
|
||||
|
||||
|
||||
// Include mutex support
|
||||
#include <semphr.h>
|
||||
|
||||
/*
|
||||
Declaring a global variable of type SemaphoreHandle_t
|
||||
|
||||
*/
|
||||
SemaphoreHandle_t mutex;
|
||||
|
||||
int globalCount = 0;
|
||||
int task1Delay = 1250;
|
||||
int task2Delay = 1000;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
/**
|
||||
Create a mutex.
|
||||
https://www.freertos.org/CreateMutex.html
|
||||
*/
|
||||
mutex = xSemaphoreCreateMutex();
|
||||
if (mutex != NULL) {
|
||||
Serial.println("Mutex created");
|
||||
}
|
||||
|
||||
/**
|
||||
Create tasks
|
||||
*/
|
||||
xTaskCreate(TaskMutex, // Task function
|
||||
"Task1", // Task name for humans
|
||||
128,
|
||||
&task1Delay, // Task parameter
|
||||
1, // Task priority
|
||||
NULL);
|
||||
|
||||
xTaskCreate(TaskMutex, "Task2", 128, &task2Delay, 1, NULL);
|
||||
}
|
||||
|
||||
void loop() {}
|
||||
|
||||
void TaskMutex(void *pvParameters)
|
||||
{
|
||||
TickType_t delayTime = *((TickType_t*)pvParameters); // Use task parameters to define delay
|
||||
for (;;)
|
||||
{
|
||||
/**
|
||||
Take mutex
|
||||
https://www.freertos.org/a00122.html
|
||||
*/
|
||||
if (xSemaphoreTake(mutex, 10) == pdTRUE)
|
||||
{
|
||||
Serial.print(pcTaskGetName(NULL)); // Get task name
|
||||
Serial.print(", Count read value: ");
|
||||
Serial.print(globalCount);
|
||||
|
||||
globalCount++;
|
||||
|
||||
Serial.print(", Updated value: ");
|
||||
Serial.print(globalCount);
|
||||
|
||||
Serial.println();
|
||||
/**
|
||||
Give mutex
|
||||
https://www.freertos.org/a00123.html
|
||||
*/
|
||||
xSemaphoreGive(mutex);
|
||||
}
|
||||
|
||||
vTaskDelay(delayTime / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user