Sync 12 and 34 working
This commit is contained in:
@@ -21,12 +21,12 @@ lib_deps =
|
|||||||
|
|
||||||
;Upload protocol configuration
|
;Upload protocol configuration
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
upload_port = /dev/ttyACM1
|
upload_port = /dev/ttyACM2
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
|
|
||||||
;Monitor configuration
|
;Monitor configuration
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
monitor_port = /dev/ttyACM1
|
monitor_port = /dev/ttyACM2
|
||||||
|
|
||||||
; Build configuration
|
; Build configuration
|
||||||
build_type = debug
|
build_type = debug
|
||||||
@@ -39,12 +39,12 @@ lib_deps = ${env:esp32-s3-devkitc1-n16r8.lib_deps}
|
|||||||
|
|
||||||
;Upload protocol configuration
|
;Upload protocol configuration
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
upload_port = /dev/ttyACM1
|
upload_port = /dev/ttyACM2
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
|
|
||||||
;Monitor configuration
|
;Monitor configuration
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
monitor_port = /dev/ttyACM1
|
monitor_port = /dev/ttyACM2
|
||||||
|
|
||||||
; Debug configuration
|
; Debug configuration
|
||||||
debug_tool = esp-builtin
|
debug_tool = esp-builtin
|
||||||
@@ -58,4 +58,5 @@ build_flags =
|
|||||||
-ggdb3
|
-ggdb3
|
||||||
-DCORE_DEBUG_LEVEL=5
|
-DCORE_DEBUG_LEVEL=5
|
||||||
-DARDUINO_USB_CDC_ON_BOOT=0
|
-DARDUINO_USB_CDC_ON_BOOT=0
|
||||||
|
-DARDUINO_USB_MODE=0
|
||||||
-fstack-protector-all
|
-fstack-protector-all
|
||||||
|
|||||||
@@ -7,12 +7,11 @@
|
|||||||
void trig_isr(void *arg)
|
void trig_isr(void *arg)
|
||||||
{
|
{
|
||||||
const int64_t time_us = esp_timer_get_time();
|
const int64_t time_us = esp_timer_get_time();
|
||||||
|
static uint8_t isr_firing_count = 0;
|
||||||
|
|
||||||
// exit if invalid args
|
// exit if invalid args
|
||||||
if (!arg)
|
if (!arg)
|
||||||
return;
|
return;
|
||||||
// FOR TESTING ONLY
|
|
||||||
digitalWrite(POT_A_CS, HIGH);
|
|
||||||
|
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
isrParams *params = (isrParams *)arg;
|
isrParams *params = (isrParams *)arg;
|
||||||
@@ -23,37 +22,54 @@ void trig_isr(void *arg)
|
|||||||
if (!task_handle)
|
if (!task_handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// reset spark flags, cannot be same time as trigger flags
|
|
||||||
box->coils12.spark_ok = false;
|
|
||||||
box->coils34.spark_ok = false;
|
|
||||||
|
|
||||||
switch (params->flag)
|
switch (params->flag)
|
||||||
{
|
{
|
||||||
case TRIG_FLAG_12P:
|
case TRIG_FLAG_12P:
|
||||||
case TRIG_FLAG_12N:
|
case TRIG_FLAG_12N:
|
||||||
|
//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;
|
box->coils12.trig_time = time_us;
|
||||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRIG_FLAG_34P:
|
case TRIG_FLAG_34P:
|
||||||
case TRIG_FLAG_34N:
|
case TRIG_FLAG_34N:
|
||||||
|
//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;
|
box->coils34.trig_time = time_us;
|
||||||
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
xTaskNotifyFromISR(task_handle, params->flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SPARK_FLAG_12:
|
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_ok = true;
|
||||||
box->coils12.spark_time = time_us;
|
box->coils12.spark_time = time_us;
|
||||||
|
isr_firing_count = 0; // reset trigger timeout counter on spark event
|
||||||
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
|
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SPARK_FLAG_34:
|
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_ok = true;
|
||||||
box->coils34.spark_time = time_us;
|
box->coils34.spark_time = time_us;
|
||||||
|
isr_firing_count = 0; // reset trigger timeout counter on spark event
|
||||||
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
|
vTaskNotifyGiveFromISR(task_handle, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// FOR TESTING ONLY
|
|
||||||
digitalWrite(POT_A_CS, LOW);
|
|
||||||
|
|
||||||
if (xHigherPriorityTaskWoken)
|
if (xHigherPriorityTaskWoken)
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
// Arduino Libraries
|
// Arduino Libraries
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "soc/gpio_struct.h"
|
#include "soc/gpio_struct.h"
|
||||||
|
#include <map>
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
#else
|
#else
|
||||||
@@ -45,12 +46,31 @@ enum sparkStatus
|
|||||||
SPARK_SYNC_FAIL,
|
SPARK_SYNC_FAIL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const std::map<const sparkStatus, const char *> sparkStatusNames = {
|
||||||
|
{SPARK_POS_OK, "SPARK_POS_OK"},
|
||||||
|
{SPARK_NEG_OK, "SPARK_NEG_OK"},
|
||||||
|
{SPARK_POS_SKIP, "SPARK_POS_SKIP"},
|
||||||
|
{SPARK_NEG_SKIP, "SPARK_NEG_SKIP"},
|
||||||
|
{SPARK_POS_WAIT, "SPARK_POS_WAIT"},
|
||||||
|
{SPARK_NEG_WAIT, "SPARK_NEG_WAIT"},
|
||||||
|
{SPARK_POS_FAIL, "SPARK_POS_FAIL"},
|
||||||
|
{SPARK_NEG_FAIL, "SPARK_NEG_FAIL"},
|
||||||
|
{SPARK_POS_UNEXPECTED, "SPARK_POS_UNEXPECTED"},
|
||||||
|
{SPARK_NEG_UNEXPECTED, "SPARK_NEG_UNEXPECTED"},
|
||||||
|
{SPARK_SYNC_FAIL, "SPARK_SYNC_FAIL"},
|
||||||
|
};
|
||||||
|
|
||||||
enum softStartStatus
|
enum softStartStatus
|
||||||
{
|
{
|
||||||
NORMAL,
|
NORMAL,
|
||||||
SOFT_START
|
SOFT_START
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const std::map<const softStartStatus, const char *> softStartStatusNames = {
|
||||||
|
{NORMAL, "NORMAL"},
|
||||||
|
{SOFT_START, "SOFT_START"},
|
||||||
|
};
|
||||||
|
|
||||||
struct coilsStatus
|
struct coilsStatus
|
||||||
{
|
{
|
||||||
int64_t trig_time;
|
int64_t trig_time;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void printTaskList()
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(921600);
|
||||||
delay(250);
|
delay(250);
|
||||||
|
|
||||||
// Setup Logger
|
// Setup Logger
|
||||||
@@ -187,23 +187,23 @@ void loop()
|
|||||||
printField("Pickup Tim", (uint32_t)ignA.coils12.trig_time, 0, 1);
|
printField("Pickup Tim", (uint32_t)ignA.coils12.trig_time, 0, 1);
|
||||||
printField("Spark Tim", (uint32_t)ignA.coils12.spark_time, 0, 2);
|
printField("Spark Tim", (uint32_t)ignA.coils12.spark_time, 0, 2);
|
||||||
printField("Spark Dly", (uint32_t)ignA.coils12.spark_delay, 0, 3);
|
printField("Spark Dly", (uint32_t)ignA.coils12.spark_delay, 0, 3);
|
||||||
printField("Spark Sts", (uint32_t)ignA.coils12.spark_status, 0, 4);
|
printField("Spark Sts", sparkStatusNames.at(ignA.coils12.spark_status), 0, 4);
|
||||||
printField("Peak P_IN", ignA.coils12.peak_p_in, 0, 5);
|
printField("Peak P_IN", ignA.coils12.peak_p_in, 0, 5);
|
||||||
printField("Peak P_OUT", ignA.coils12.peak_p_out, 0, 6);
|
printField("Peak P_OUT", ignA.coils12.peak_p_out, 0, 6);
|
||||||
printField("Peak N_IN", ignA.coils12.peak_n_in, 0, 7);
|
printField("Peak N_IN", ignA.coils12.peak_n_in, 0, 7);
|
||||||
printField("Peak N_OUT", ignA.coils12.peak_n_out, 0, 8);
|
printField("Peak N_OUT", ignA.coils12.peak_n_out, 0, 8);
|
||||||
printField("SoftStart ", (uint32_t)ignA.coils12.sstart_status, 0, 9);
|
printField("SoftStart ", softStartStatusNames.at(ignA.coils12.sstart_status), 0, 9);
|
||||||
|
|
||||||
Serial.println("========== Coils 34 =============");
|
Serial.println("========== Coils 34 =============");
|
||||||
printField("Pickup Tim", (uint32_t)ignA.coils34.trig_time, 0, 11);
|
printField("Pickup Tim", (uint32_t)ignA.coils34.trig_time, 0, 11);
|
||||||
printField("Spark Tim", (uint32_t)ignA.coils34.spark_time, 0, 12);
|
printField("Spark Tim", (uint32_t)ignA.coils34.spark_time, 0, 12);
|
||||||
printField("Spark Dly", (uint32_t)ignA.coils34.spark_delay, 0, 13);
|
printField("Spark Dly", (uint32_t)ignA.coils34.spark_delay, 0, 13);
|
||||||
printField("Spark Sts", (uint32_t)ignA.coils34.spark_delay, 0, 14);
|
printField("Spark Sts", sparkStatusNames.at(ignA.coils34.spark_status), 0, 14);
|
||||||
printField("Peak P_IN", ignA.coils34.peak_p_in, 0, 15);
|
printField("Peak P_IN", ignA.coils34.peak_p_in, 0, 15);
|
||||||
printField("Peak P_OUT", ignA.coils34.peak_p_out, 0, 16);
|
printField("Peak P_OUT", ignA.coils34.peak_p_out, 0, 16);
|
||||||
printField("Peak N_IN", ignA.coils34.peak_n_in, 0, 17);
|
printField("Peak N_IN", ignA.coils34.peak_n_in, 0, 17);
|
||||||
printField("Peak N_OUT", ignA.coils34.peak_n_out, 0, 18);
|
printField("Peak N_OUT", ignA.coils34.peak_n_out, 0, 18);
|
||||||
printField("SoftStart ", (uint32_t)ignA.coils34.sstart_status, 0, 19);
|
printField("SoftStart ", softStartStatusNames.at(ignA.coils34.sstart_status), 0, 19);
|
||||||
|
|
||||||
Serial.println("========== END =============");
|
Serial.println("========== END =============");
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|||||||
@@ -59,16 +59,16 @@
|
|||||||
// =====================
|
// =====================
|
||||||
// DIGITAL POT
|
// DIGITAL POT
|
||||||
// =====================
|
// =====================
|
||||||
#define POT_A_CS 1
|
//#define POT_A_CS 1
|
||||||
#define POT_B_CS 2
|
//#define POT_B_CS 2
|
||||||
|
|
||||||
// =====================
|
// =====================
|
||||||
// TRIGGER INPUT INTERRUPTS
|
// TRIGGER INPUT INTERRUPTS
|
||||||
// =====================
|
// =====================
|
||||||
#define TRIG_PIN_A12P 18
|
#define TRIG_PIN_A12P 18
|
||||||
#define TRIG_PIN_A12N 21
|
#define TRIG_PIN_A12N 21
|
||||||
#define TRIG_PIN_A34P 38 // ATTENZIONEEEEEEEEEEE
|
#define TRIG_PIN_A34P 1
|
||||||
#define TRIG_PIN_A34N 39 // ATTENZIONEEEEEEEEEEE
|
#define TRIG_PIN_A34N 2
|
||||||
#define TRIG_PIN_B12P 38
|
#define TRIG_PIN_B12P 38
|
||||||
#define TRIG_PIN_B12N 39
|
#define TRIG_PIN_B12N 39
|
||||||
#define TRIG_PIN_B34P 40
|
#define TRIG_PIN_B34P 40
|
||||||
@@ -78,9 +78,9 @@
|
|||||||
// SPARK DETECT INPUTS
|
// SPARK DETECT INPUTS
|
||||||
// =====================
|
// =====================
|
||||||
#define SPARK_PIN_A12 42
|
#define SPARK_PIN_A12 42
|
||||||
#define SPARK_PIN_A34 42 // OK (strapping ma consentito) 45
|
#define SPARK_PIN_A34 45 // OK (strapping ma consentito) 45
|
||||||
#define SPARK_PIN_B12 42 // OK (strapping ma consentito) 46
|
#define SPARK_PIN_B12 46 // OK (strapping ma consentito) 46
|
||||||
#define SPARK_PIN_B34 42
|
#define SPARK_PIN_B34 47
|
||||||
|
|
||||||
// =====================
|
// =====================
|
||||||
// PCA9555 (I2C EXPANDER)
|
// PCA9555 (I2C EXPANDER)
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
|
|
||||||
LOG_INFO("rtTask ISR Params OK");
|
LOG_INFO("rtTask ISR Params OK");
|
||||||
|
|
||||||
pinMode(POT_A_CS, OUTPUT);
|
|
||||||
|
|
||||||
// Attach Pin Interrupts
|
// Attach Pin Interrupts
|
||||||
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_12p), rt_int.isr_ptr, (void *)&isr_params_t12p, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_12p), rt_int.isr_ptr, (void *)&isr_params_t12p, RISING);
|
||||||
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_12n), rt_int.isr_ptr, (void *)&isr_params_t12n, RISING);
|
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_12n), rt_int.isr_ptr, (void *)&isr_params_t12n, RISING);
|
||||||
@@ -73,6 +71,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
// Global rt_task_ptr variables
|
// Global rt_task_ptr variables
|
||||||
uint32_t it = 0;
|
uint32_t it = 0;
|
||||||
uint32_t q_fail_count = 0;
|
uint32_t q_fail_count = 0;
|
||||||
|
bool first_cycle = true;
|
||||||
|
|
||||||
while (params->rt_running)
|
while (params->rt_running)
|
||||||
{
|
{
|
||||||
@@ -86,6 +85,11 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
&pickup_flag, // valore ricevuto
|
&pickup_flag, // valore ricevuto
|
||||||
portMAX_DELAY);
|
portMAX_DELAY);
|
||||||
|
|
||||||
|
if (first_cycle && pickup_flag != TRIG_FLAG_12P) // skip first cycle because of possible initial noise on pickup signals at startu
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print("\033[2J"); // clear screen
|
Serial.print("\033[2J"); // clear screen
|
||||||
Serial.print("\033[H"); // cursor home
|
Serial.print("\033[H"); // cursor home
|
||||||
@@ -105,6 +109,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
|
|
||||||
// WAIT FOR SPARK TO HAPPEN
|
// WAIT FOR SPARK TO HAPPEN
|
||||||
auto spark_timeout = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(spark_timeout_max));
|
auto spark_timeout = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(spark_timeout_max));
|
||||||
|
//auto spark_timeout = ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||||
if (ign_box_sts.coils12.spark_ok || ign_box_sts.coils34.spark_ok) // otherwise timeout if none is set in the ISR
|
if (ign_box_sts.coils12.spark_ok || ign_box_sts.coils34.spark_ok) // otherwise timeout if none is set in the ISR
|
||||||
spark_flag = ign_box_sts.coils12.spark_ok ? SPARK_FLAG_12 : SPARK_FLAG_34;
|
spark_flag = ign_box_sts.coils12.spark_ok ? SPARK_FLAG_12 : SPARK_FLAG_34;
|
||||||
else
|
else
|
||||||
@@ -121,7 +126,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
ulTaskNotifyValueClear(NULL, 0xFFFFFFFF);
|
ulTaskNotifyValueClear(NULL, 0xFFFFFFFF);
|
||||||
|
|
||||||
// A trigger from pickup 12 is followed by a spark event on 34 or vice versa pickup 34 triggers spark on 12
|
// A trigger from pickup 12 is followed by a spark event on 34 or vice versa pickup 34 triggers spark on 12
|
||||||
if ((pickup_flag == TRIG_FLAG_12P || pickup_flag == TRIG_FLAG_12N) && spark_flag != SPARK_FLAG_12)
|
if ((pickup_flag == TRIG_FLAG_12P || pickup_flag == TRIG_FLAG_12N) && (spark_flag != SPARK_FLAG_12 && spark_flag != SPARK_FLAG_NIL))
|
||||||
{
|
{
|
||||||
ign_box_sts.coils12.spark_status = ign_box_sts.coils34.spark_status = sparkStatus::SPARK_SYNC_FAIL;
|
ign_box_sts.coils12.spark_status = ign_box_sts.coils34.spark_status = sparkStatus::SPARK_SYNC_FAIL;
|
||||||
// Save error on circular buffer and skip to next cycle //
|
// Save error on circular buffer and skip to next cycle //
|
||||||
@@ -133,6 +138,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
switch (pickup_flag)
|
switch (pickup_flag)
|
||||||
{
|
{
|
||||||
case TRIG_FLAG_12P:
|
case TRIG_FLAG_12P:
|
||||||
|
first_cycle = false;
|
||||||
case TRIG_FLAG_12N:
|
case TRIG_FLAG_12N:
|
||||||
coils = &ign_box_sts.coils12;
|
coils = &ign_box_sts.coils12;
|
||||||
break;
|
break;
|
||||||
@@ -148,16 +154,15 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
case TRIG_FLAG_12P:
|
case TRIG_FLAG_12P:
|
||||||
case TRIG_FLAG_34P:
|
case TRIG_FLAG_34P:
|
||||||
{
|
{
|
||||||
LOG_INFO("POSITIVE Edge");
|
|
||||||
// Timeout not occourred, expected POSITIVE edge spark OCCOURRED
|
// Timeout not occourred, expected POSITIVE edge spark OCCOURRED
|
||||||
if (spark_flag != SPARK_FLAG_NIL)
|
if (spark_flag != SPARK_FLAG_NIL)
|
||||||
{
|
{
|
||||||
coils->spark_delay = coils->trig_time - coils->spark_time;
|
coils->spark_delay = coils->spark_time - coils->trig_time;
|
||||||
coils->sstart_status = softStartStatus::NORMAL; // because spark on positive edge
|
coils->sstart_status = softStartStatus::NORMAL; // because spark on positive edge
|
||||||
coils->spark_status = sparkStatus::SPARK_POS_OK; // do not wait for spark on negative edge
|
coils->spark_status = sparkStatus::SPARK_POS_OK; // do not wait for spark on negative edge
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LOG_INFO("Spark on POSITIVE pulse");
|
LOG_INFO("Spark on POSITIVE pulse");
|
||||||
LOG_INFO("Spark Delay Timer: ", (int32_t)coils->spark_delay);
|
LOG_INFO("Spark Delay Time: ", (int32_t)coils->spark_delay);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||||
@@ -173,17 +178,16 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
case TRIG_FLAG_12N:
|
case TRIG_FLAG_12N:
|
||||||
case TRIG_FLAG_34N:
|
case TRIG_FLAG_34N:
|
||||||
{
|
{
|
||||||
LOG_INFO("NEGATIVE Edge");
|
|
||||||
const bool expected_negative = coils->spark_status == sparkStatus::SPARK_NEG_WAIT;
|
const bool expected_negative = coils->spark_status == sparkStatus::SPARK_NEG_WAIT;
|
||||||
// Timeout not occourred, expected NEGATIVE edge spark OCCOURRED
|
// Timeout not occourred, expected NEGATIVE edge spark OCCOURRED
|
||||||
if (spark_flag != SPARK_FLAG_NIL && expected_negative)
|
if (spark_flag != SPARK_FLAG_NIL && expected_negative)
|
||||||
{
|
{
|
||||||
coils->spark_delay = coils->trig_time - coils->spark_time;
|
coils->spark_delay = coils->spark_time - coils->trig_time;
|
||||||
coils->sstart_status = softStartStatus::SOFT_START;
|
coils->sstart_status = softStartStatus::SOFT_START;
|
||||||
coils->spark_status == sparkStatus::SPARK_NEG_OK;
|
coils->spark_status = sparkStatus::SPARK_NEG_OK;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LOG_INFO("Spark on NEGATIVE pulse");
|
LOG_INFO("Spark on NEGATIVE pulse");
|
||||||
LOG_INFO("Spark Delay Timer: ", (int32_t)coils->spark_delay);
|
LOG_INFO("Spark Delay Time: ", (int32_t)coils->spark_delay);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||||
@@ -248,7 +252,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
if (xQueueSendToBack(rt_queue, (void *)&ign_box_sts, pdMS_TO_TICKS(1)) != pdPASS)
|
if (xQueueSendToBack(rt_queue, (void *)&ign_box_sts, pdMS_TO_TICKS(1)) != pdPASS)
|
||||||
{
|
{
|
||||||
q_fail_count++;
|
q_fail_count++;
|
||||||
// LOG_ERROR("Failed to send to rt_queue");
|
LOG_ERROR("Failed to send to rt_queue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
|
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
|
||||||
|
|
||||||
// Serial debug flag
|
// Serial debug flag
|
||||||
#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
// Arduino Libraries
|
// Arduino Libraries
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "devices.h"
|
#include "devices.h"
|
||||||
|
|
||||||
// Global Variables and Flags
|
// Global Variables and Flags
|
||||||
const uint8_t spark_timeout_max = 2; // in milliseconds
|
const uint8_t spark_timeout_max = 1; // in milliseconds
|
||||||
|
|
||||||
// Debug Variables
|
// Debug Variables
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@@ -46,3 +46,14 @@ void printField(const char name[], const float val, const uint8_t x, const uint8
|
|||||||
Serial.print(val);
|
Serial.print(val);
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printField(const char name[], const char *val, const uint8_t x, const uint8_t y) {
|
||||||
|
if (firstRun) {
|
||||||
|
setCursor(x,y);
|
||||||
|
Serial.printf("%15s: %s\n", name, val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setCursor(x+16, y);
|
||||||
|
Serial.print(val);
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user