исправлены ошибки

This commit is contained in:
KLASSENTS 2025-03-26 16:31:28 +07:00
parent 42e9becdb9
commit 6f84c00718
2 changed files with 5 additions and 12 deletions

View File

@ -18,9 +18,6 @@ SemaphoreHandle_t interruptSemaphore;
void setup() { void setup() {
// Configure pin 2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
// Create task for Arduino led // Create task for Arduino led
xTaskCreate(TaskLed, // Task function xTaskCreate(TaskLed, // Task function
"Led", // Task name "Led", // Task name
@ -36,7 +33,7 @@ void setup() {
interruptSemaphore = xSemaphoreCreateBinary(); interruptSemaphore = xSemaphoreCreateBinary();
if (interruptSemaphore != NULL) { if (interruptSemaphore != NULL) {
// Attach interrupt for Arduino digital pin // Attach interrupt for Arduino digital pin
attachInterrupt(digitalPinToInterrupt(2), interruptHandler, LOW); attachInterrupt(digitalPinToInterrupt(BTN_BUILTIN), interruptHandler, RISING);
} }

View File

@ -13,9 +13,6 @@ TaskHandle_t taskNotificationHandler;
void setup() { void setup() {
// Configure pin 2 as an input and enable the internal pull-up resistor.
pinMode(2, INPUT_PULLUP);
// Create task for FreeRTOS notification // Create task for FreeRTOS notification
xTaskCreate(TaskNotification, // Task function xTaskCreate(TaskNotification, // Task function
"Notification", // Task name "Notification", // Task name
@ -36,11 +33,11 @@ void TaskNotification(void *pvParameters)
{ {
(void) pvParameters; (void) pvParameters;
int digitalPin = 2; int digitalPin = BTN_BUILTIN;
Serial.begin(9600); Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(digitalPin), digitalPinInterruptHandler, LOW); attachInterrupt(digitalPinToInterrupt(digitalPin), digitalPinInterruptHandler, RISING);
for (;;) { for (;;) {
@ -55,7 +52,6 @@ void TaskNotification(void *pvParameters)
void digitalPinInterruptHandler() { void digitalPinInterruptHandler() {
BaseType_t xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(taskNotificationHandler, &xHigherPriorityTaskWoken); vTaskNotifyGiveFromISR(taskNotificationHandler, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken) { portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
taskYIELD();
}
} }