Sync 12 and 34 working
This commit is contained in:
@@ -7,12 +7,11 @@
|
||||
void trig_isr(void *arg)
|
||||
{
|
||||
const int64_t time_us = esp_timer_get_time();
|
||||
static uint8_t isr_firing_count = 0;
|
||||
|
||||
// exit if invalid args
|
||||
if (!arg)
|
||||
return;
|
||||
// FOR TESTING ONLY
|
||||
digitalWrite(POT_A_CS, HIGH);
|
||||
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
isrParams *params = (isrParams *)arg;
|
||||
@@ -23,37 +22,54 @@ void trig_isr(void *arg)
|
||||
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:
|
||||
case TRIG_FLAG_12N:
|
||||
box->coils12.trig_time = time_us;
|
||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
//if (isr_firing_count == 0)
|
||||
{
|
||||
// only on first trigger to avoid multiple firing due to noise, to be fixed with hardware debounce
|
||||
isr_firing_count++;
|
||||
box->coils12.spark_ok = false; // reset spark ok flag on new trigger event
|
||||
box->coils12.trig_time = time_us;
|
||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIG_FLAG_34P:
|
||||
case TRIG_FLAG_34N:
|
||||
box->coils34.trig_time = time_us;
|
||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
//if (isr_firing_count == 0)
|
||||
{
|
||||
// only on first trigger to avoid multiple firing due to noise, to be fixed with hardware debounce
|
||||
isr_firing_count++;
|
||||
box->coils34.spark_ok = false; // reset spark ok flag on new trigger event
|
||||
box->coils34.trig_time = time_us;
|
||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
}
|
||||
break;
|
||||
case SPARK_FLAG_12:
|
||||
//if (isr_firing_count > 0) // only consider spark if a trigger has been detected, otherwise noise on spark pin can cause false positives
|
||||
{
|
||||
box->coils34.spark_ok = false;
|
||||
box->coils12.spark_ok = true;
|
||||
box->coils12.spark_time = time_us;
|
||||
isr_firing_count = 0; // reset trigger timeout counter on spark event
|
||||
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
|
||||
}
|
||||
break;
|
||||
case SPARK_FLAG_34:
|
||||
//if (isr_firing_count > 0) // only consider spark if a trigger has been detected, otherwise noise on spark pin can cause false positives
|
||||
{
|
||||
box->coils12.spark_ok = false;
|
||||
box->coils34.spark_ok = true;
|
||||
box->coils34.spark_time = time_us;
|
||||
isr_firing_count = 0; // reset trigger timeout counter on spark event
|
||||
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// FOR TESTING ONLY
|
||||
digitalWrite(POT_A_CS, LOW);
|
||||
|
||||
if (xHigherPriorityTaskWoken)
|
||||
portYIELD_FROM_ISR();
|
||||
|
||||
Reference in New Issue
Block a user