Добавлена поддержка FreeRTOS #16
@ -18,9 +18,6 @@ SemaphoreHandle_t interruptSemaphore;
|
||||
|
||||
void setup() {
|
||||
|
||||
// Configure pin 2 as an input and enable the internal pull-up resistor
|
||||
pinMode(2, INPUT_PULLUP);
|
||||
|
||||
// Create task for Arduino led
|
||||
xTaskCreate(TaskLed, // Task function
|
||||
"Led", // Task name
|
||||
@ -36,7 +33,7 @@ void setup() {
|
||||
interruptSemaphore = xSemaphoreCreateBinary();
|
||||
if (interruptSemaphore != NULL) {
|
||||
// Attach interrupt for Arduino digital pin
|
||||
attachInterrupt(digitalPinToInterrupt(2), interruptHandler, LOW);
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_BUILTIN), interruptHandler, RISING);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -13,9 +13,6 @@ TaskHandle_t taskNotificationHandler;
|
||||
|
||||
void setup() {
|
||||
|
||||
// Configure pin 2 as an input and enable the internal pull-up resistor.
|
||||
pinMode(2, INPUT_PULLUP);
|
||||
|
||||
// Create task for FreeRTOS notification
|
||||
xTaskCreate(TaskNotification, // Task function
|
||||
"Notification", // Task name
|
||||
@ -36,11 +33,11 @@ void TaskNotification(void *pvParameters)
|
||||
{
|
||||
(void) pvParameters;
|
||||
|
||||
int digitalPin = 2;
|
||||
int digitalPin = BTN_BUILTIN;
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
attachInterrupt(digitalPinToInterrupt(digitalPin), digitalPinInterruptHandler, LOW);
|
||||
attachInterrupt(digitalPinToInterrupt(digitalPin), digitalPinInterruptHandler, RISING);
|
||||
|
||||
for (;;) {
|
||||
|
||||
@ -55,7 +52,6 @@ void TaskNotification(void *pvParameters)
|
||||
void digitalPinInterruptHandler() {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
vTaskNotifyGiveFromISR(taskNotificationHandler, &xHigherPriorityTaskWoken);
|
||||
if (xHigherPriorityTaskWoken) {
|
||||
taskYIELD();
|
||||
}
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user