Добавлена поддержка FreeRTOS
This commit was merged in pull request #16.
This commit is contained in:
1 parent
1aaf8c59ae
commit
43c97f7b56
49 files changed
+35167
-1
No files matched your search
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
Example of a Arduino interruption and RTOS Task Notification.
|
||||
https://www.freertos.org/RTOS_Task_Notification_As_Binary_Semaphore.html
|
||||
*/
|
||||
|
||||
// Include Arduino FreeRTOS library
|
||||
#include <Arduino_FreeRTOS.h>
|
||||
|
||||
/**
|
||||
Declaring a global TaskHandle for the led task.
|
||||
*/
|
||||
TaskHandle_t taskNotificationHandler;
|
||||
|
||||
// set interrupt pin
|
||||
#ifdef BTN_BUILTIN
|
||||
uint8_t int_pin = BTN_BUILTIN;
|
||||
#elif defined(ARDUINO_ELSOMIK)
|
||||
uint8_t int_pin = P0_8;
|
||||
#else
|
||||
uint8_t int_pin = 2;
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
// Create task for FreeRTOS notification
|
||||
xTaskCreate(TaskNotification, // Task function
|
||||
"Notification", // Task name
|
||||
128, // Stack size
|
||||
NULL,
|
||||
3, // Priority
|
||||
&taskNotificationHandler); // TaskHandle
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Notification task.
|
||||
*/
|
||||
void TaskNotification(void *pvParameters)
|
||||
{
|
||||
(void) pvParameters;
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
attachInterrupt(digitalPinToInterrupt(int_pin), digitalPinInterruptHandler, RISING);
|
||||
|
||||
for (;;) {
|
||||
|
||||
if (ulTaskNotifyTake(pdTRUE, portMAX_DELAY)) {
|
||||
Serial.println("Notification received");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void digitalPinInterruptHandler() {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
vTaskNotifyGiveFromISR(taskNotificationHandler, &xHigherPriorityTaskWoken);
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
Reference in new issue
Block a user