50 строки
Без EOL
1,7 КиБ
C++
50 строки
Без EOL
1,7 КиБ
C++
#include <Arduino.h>
|
|
#include "config.h"
|
|
#include "main.go.h"
|
|
|
|
static TaskHandle_t taskInterruptsReceiverHandle = NULL;
|
|
|
|
void IRAM_ATTR dvizhHandler() {
|
|
BaseType_t xHigherPriorityTaskWoken;
|
|
|
|
/* xHigherPriorityTaskWoken must be initialised to pdFALSE.
|
|
If calling vTaskNotifyGiveFromISR() unblocks the handling
|
|
task, and the priority of the handling task is higher than
|
|
the priority of the currently running task, then
|
|
xHigherPriorityTaskWoken will be automatically set to pdTRUE. */
|
|
xHigherPriorityTaskWoken = pdFALSE;
|
|
|
|
/* Unblock the handling task so the task can perform
|
|
any processing necessitated by the interrupt. xHandlingTask
|
|
is the task's handle, which was obtained when the task was
|
|
created. vTaskNotifyGiveFromISR() also increments
|
|
the receiving task's notification value. */
|
|
vTaskNotifyGiveFromISR(taskInterruptsReceiverHandle, &xHigherPriorityTaskWoken);
|
|
|
|
/* Force a context switch if xHigherPriorityTaskWoken is now
|
|
set to pdTRUE. The macro used to do this is dependent on
|
|
the port and may be called portEND_SWITCHING_ISR. */
|
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
|
}
|
|
|
|
void TaskInterruptsReceiver(void*) {
|
|
TaskSveta();
|
|
}
|
|
|
|
void setup_dvizh() {
|
|
pinMode(DVIZH_VERH_PIN, INPUT);
|
|
pinMode(DVIZH_NIZ_PIN, INPUT);
|
|
pinMode(SVET_ONOFF_PIN, OUTPUT);
|
|
pinMode(SVET_YARK_PIN, OUTPUT);
|
|
|
|
initSvet();
|
|
|
|
xTaskCreate(TaskInterruptsReceiver, "taskInterruptsReceiver", 4096, NULL, ESP_TASKD_EVENT_PRIO - 1, &taskInterruptsReceiverHandle);
|
|
attachInterrupt(DVIZH_VERH_PIN, dvizhHandler, DVIZH_TRIGGER);
|
|
attachInterrupt(DVIZH_NIZ_PIN, dvizhHandler, DVIZH_TRIGGER);
|
|
}
|
|
|
|
void action() {
|
|
if (DEBUG)
|
|
Serial.println("Action!");
|
|
} |