Separate code from headers

This commit is contained in:
Emanuele Trabattoni
2026-03-30 16:29:40 +02:00
parent 1adbf7fdb9
commit ec138553ad
5 changed files with 321 additions and 295 deletions

54
RotaxMonitor/src/isr.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include "isr.h"
// =====================
// ISR (Pass return bitmask to ISR management function)
// one function for each wake up pin conncted to a trigger
// =====================
void trig_isr(void *arg)
{
const int64_t time_us = esp_timer_get_time();
// exit if invalid args
if (!arg)
return;
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
isrParams *params = (isrParams*)arg;
ignitionBoxStatus *box = params->ign_stat;
TaskHandle_t task_handle = *params->rt_handle_ptr;
// exit if task not running
if (!task_handle)
return;
// reset spark flags, cannot be same time as trigger flags
box->coils12.spark_ok = false;
box->coils34.spark_ok = false;
switch (params->flag)
{
case TRIG_FLAG_12P:
box->coils12.trig_time = time_us;
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
break;
case TRIG_FLAG_34P:
box->coils34.trig_time = time_us;
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
break;
case SPARK_FLAG_12:
box->coils12.spark_ok = true;
box->coils12.spark_time = time_us;
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
break;
case SPARK_FLAG_34:
box->coils34.spark_ok = true;
box->coils34.spark_time = time_us;
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
break;
default:
break;
}
if (xHigherPriorityTaskWoken)
portYIELD_FROM_ISR();
}