modified to also read channel B
This commit is contained in:
@@ -7,20 +7,18 @@ void onTimer(void *arg)
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
timerStatus *params = (timerStatus *)(arg);
|
||||
TaskHandle_t task = params->main_task;
|
||||
const timerPins pins = params->pins;
|
||||
|
||||
// increment state time
|
||||
params->state_time += params->clock_period_us;
|
||||
|
||||
digitalWrite(PIN_TRIG_B12P, HIGH);
|
||||
|
||||
switch (params->state)
|
||||
{
|
||||
|
||||
case S_12P:
|
||||
if (params->state_time == params->clock_period_us && !params->coil12p_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, PIN_TRIG_A12P, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A12P, HIGH);
|
||||
digitalWrite(pins.pin_trig_12p, HIGH);
|
||||
params->coil12p_high = true;
|
||||
wait_sent = false;
|
||||
}
|
||||
@@ -29,21 +27,18 @@ void onTimer(void *arg)
|
||||
{
|
||||
if (params->state_time == params->spark_delay_us)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, SPARK_A12, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A12, HIGH);
|
||||
digitalWrite(pins.pin_spark_12, HIGH);
|
||||
}
|
||||
|
||||
if (params->state_time == (params->spark_delay_us + params->spark_pulse_us))
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~SPARK_A12, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A12, LOW);
|
||||
digitalWrite(pins.pin_spark_12, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
if (params->state_time >= params->coil_pulse_us && params->coil12p_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~PIN_TRIG_A12P, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A12P, LOW);
|
||||
digitalWrite(pins.pin_trig_12p, LOW);
|
||||
params->coil12p_high = false;
|
||||
}
|
||||
|
||||
@@ -57,8 +52,7 @@ void onTimer(void *arg)
|
||||
case S_12N:
|
||||
if (params->state_time == params->clock_period_us && !params->coil12n_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, PIN_TRIG_A12N, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A12N, HIGH);
|
||||
digitalWrite(pins.pin_trig_12n, HIGH);
|
||||
params->coil12n_high = true;
|
||||
}
|
||||
|
||||
@@ -66,21 +60,18 @@ void onTimer(void *arg)
|
||||
{
|
||||
if (params->state_time == params->spark_delay_us)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, SPARK_A12, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A12, HIGH);
|
||||
digitalWrite(pins.pin_spark_12, HIGH);
|
||||
}
|
||||
|
||||
if (params->state_time == (params->spark_delay_us + params->spark_pulse_us))
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~SPARK_A12, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A12, LOW);
|
||||
digitalWrite(pins.pin_spark_12, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
if (params->state_time >= params->coil_pulse_us && params->coil12n_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~PIN_TRIG_A12N, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A12N, LOW);
|
||||
digitalWrite(pins.pin_trig_12n, LOW);
|
||||
params->coil12n_high = false;
|
||||
params->state = S_WAIT_10MS;
|
||||
params->state_time = 0;
|
||||
@@ -90,7 +81,6 @@ void onTimer(void *arg)
|
||||
case S_WAIT_10MS:
|
||||
if (!wait_sent)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, S_WAIT_10MS, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
wait_sent = true;
|
||||
}
|
||||
if (params->state_time >= params->pause_long_us)
|
||||
@@ -103,8 +93,7 @@ void onTimer(void *arg)
|
||||
case S_34P:
|
||||
if (params->state_time == params->clock_period_us && !params->coil34p_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, PIN_TRIG_A34P, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A34P, HIGH);
|
||||
digitalWrite(pins.pin_trig_34p, HIGH);
|
||||
params->coil34p_high = true;;
|
||||
wait_sent = false;
|
||||
}
|
||||
@@ -113,21 +102,18 @@ void onTimer(void *arg)
|
||||
{
|
||||
if (params->state_time == params->spark_delay_us)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, SPARK_A34, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A34, HIGH);
|
||||
digitalWrite(pins.pin_spark_34, HIGH);
|
||||
}
|
||||
|
||||
if (params->state_time == params->spark_delay_us + params->spark_pulse_us)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~SPARK_A34, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A34, LOW);
|
||||
digitalWrite(pins.pin_spark_34, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
if (params->state_time >= params->coil_pulse_us && params->coil34p_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~PIN_TRIG_A34P, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A34P, LOW);
|
||||
digitalWrite(pins.pin_trig_34p, LOW);
|
||||
params->coil34p_high = false;
|
||||
}
|
||||
|
||||
@@ -141,8 +127,7 @@ void onTimer(void *arg)
|
||||
case S_34N:
|
||||
if (params->state_time == params->clock_period_us && !params->coil34n_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, PIN_TRIG_A34N, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A34N, HIGH);
|
||||
digitalWrite(pins.pin_trig_34n, HIGH);
|
||||
params->coil34n_high = true;
|
||||
}
|
||||
|
||||
@@ -150,21 +135,18 @@ void onTimer(void *arg)
|
||||
{
|
||||
if (params->state_time == params->spark_delay_us)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, SPARK_A34, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A34, HIGH);
|
||||
digitalWrite(pins.pin_spark_34, HIGH);
|
||||
}
|
||||
|
||||
if (params->state_time == params->spark_delay_us + params->spark_pulse_us)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~SPARK_A34, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(SPARK_A34, LOW);
|
||||
digitalWrite(pins.pin_spark_34, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
if (params->state_time >= params->coil_pulse_us && params->coil34n_high)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, ~PIN_TRIG_A34N, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
digitalWrite(PIN_TRIG_A34N, LOW);
|
||||
digitalWrite(pins.pin_trig_34n, LOW);
|
||||
params->coil34n_high = false;
|
||||
params->state = S_WAIT_10MS_END;
|
||||
params->state_time = 0;
|
||||
@@ -174,7 +156,6 @@ void onTimer(void *arg)
|
||||
case S_WAIT_10MS_END:
|
||||
if (!wait_sent)
|
||||
{
|
||||
// xTaskNotifyFromISR(task, S_WAIT_10MS_END, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||
wait_sent = true;
|
||||
}
|
||||
if (params->state_time >= params->pause_long_us)
|
||||
@@ -184,9 +165,7 @@ void onTimer(void *arg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
digitalWrite(PIN_TRIG_B12P, LOW);
|
||||
|
||||
|
||||
if (xHigherPriorityTaskWoken)
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user