elbear_arduino_bsp/libraries/FreeRTOS/examples/Notifications/Notifications.ino
KlassenTS 1c8e06634c 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>
2025-04-28 07:06:08 +03:00

62 lines
1.4 KiB
C++

/**
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);
}