First Attempt to print data async, fields not working
This commit is contained in:
@@ -16,7 +16,7 @@ void rtIgnitionTask(void *pvParameters)
|
||||
const rtTaskInterrupts rt_int = params->rt_int; // copy to avoid external override
|
||||
const rtTaskResets rt_rst = params->rt_resets; // copy to avoid external override
|
||||
QueueHandle_t rt_queue = params->rt_queue;
|
||||
TaskHandle_t* rt_handle_ptr = params->rt_handle_ptr;
|
||||
TaskHandle_t *rt_handle_ptr = params->rt_handle_ptr;
|
||||
Devices *dev = params->dev;
|
||||
ADS1256 *adc = dev->adc_a;
|
||||
PCA9555 *io = dev->io;
|
||||
@@ -50,13 +50,15 @@ void rtIgnitionTask(void *pvParameters)
|
||||
|
||||
LOG_INFO("rtTask ISR Params OK");
|
||||
|
||||
pinMode(POT_A_CS, OUTPUT);
|
||||
|
||||
// Attach Pin Interrupts
|
||||
attachInterruptArg(rt_int.trig_pin_12p, rt_int.isr_ptr, (void *)&isr_params_t12p, RISING);
|
||||
attachInterruptArg(rt_int.trig_pin_12n, rt_int.isr_ptr, (void *)&isr_params_t12n, RISING);
|
||||
attachInterruptArg(rt_int.trig_pin_34p, rt_int.isr_ptr, (void *)&isr_params_t34p, RISING);
|
||||
attachInterruptArg(rt_int.trig_pin_34n, rt_int.isr_ptr, (void *)&isr_params_t34n, RISING);
|
||||
attachInterruptArg(rt_int.spark_pin_12, rt_int.isr_ptr, (void *)&isr_params_sp12, RISING);
|
||||
attachInterruptArg(rt_int.spark_pin_34, rt_int.isr_ptr, (void *)&isr_params_sp34, 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_34p), rt_int.isr_ptr, (void *)&isr_params_t34p, RISING);
|
||||
attachInterruptArg(digitalPinToInterrupt(rt_int.trig_pin_34n), rt_int.isr_ptr, (void *)&isr_params_t34n, RISING);
|
||||
attachInterruptArg(digitalPinToInterrupt(rt_int.spark_pin_12), rt_int.isr_ptr, (void *)&isr_params_sp12, RISING);
|
||||
attachInterruptArg(digitalPinToInterrupt(rt_int.spark_pin_34), rt_int.isr_ptr, (void *)&isr_params_sp34, RISING);
|
||||
|
||||
LOG_INFO("rtTask ISR Attach OK");
|
||||
|
||||
@@ -66,29 +68,27 @@ void rtIgnitionTask(void *pvParameters)
|
||||
(1 << rt_rst.rst_io_34p) |
|
||||
(1 << rt_rst.rst_io_34n);
|
||||
|
||||
LOG_WARN("rt Task Init Correct");
|
||||
LOG_WARN("rtTask Init Correct");
|
||||
// Global rt_task_ptr variables
|
||||
uint32_t it = 0;
|
||||
uint32_t q_fail_count = 0;
|
||||
|
||||
while (params->rt_running)
|
||||
{
|
||||
// Global rt_task_ptr variables
|
||||
uint32_t pickup_flag = 0;
|
||||
uint32_t spark_flag = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.print("\033[2J"); // clear screen
|
||||
Serial.print("\033[H"); // cursor home
|
||||
LOG_INFO("Iteration [", it++, "]");
|
||||
#endif
|
||||
|
||||
// WAIT FOR PICKUP SIGNAL
|
||||
xTaskNotifyWait(
|
||||
0x00, // non pulire all'ingresso
|
||||
ULONG_MAX, // non pulire all'ingresso
|
||||
ULONG_MAX, // pulisci i primi 8 bit
|
||||
&pickup_flag, // valore ricevuto
|
||||
portMAX_DELAY);
|
||||
|
||||
#ifdef DEBUG
|
||||
LOG_INFO("Iteration [", it++, "]");
|
||||
Serial.print("\033[2J"); // clear screen
|
||||
Serial.print("\033[H"); // cursor home
|
||||
LOG_INFO("Pickup Flags: ", printBits(pickup_flag).c_str());
|
||||
if (!names.contains(pickup_flag))
|
||||
{
|
||||
@@ -105,9 +105,12 @@ void rtIgnitionTask(void *pvParameters)
|
||||
auto spark_timeout = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(spark_timeout_max));
|
||||
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;
|
||||
else
|
||||
spark_flag == SPARK_FLAG_NIL;
|
||||
|
||||
xTaskNotifyStateClear(NULL);
|
||||
ulTaskNotifyValueClear(NULL, 0xFFFFFFFF);
|
||||
|
||||
#ifdef DEBUG
|
||||
LOG_INFO("Spark Flags: ", printBits(spark_flag).c_str());
|
||||
if (!names.contains(spark_flag))
|
||||
@@ -141,12 +144,11 @@ void rtIgnitionTask(void *pvParameters)
|
||||
bool new_data = false;
|
||||
switch (pickup_flag)
|
||||
{
|
||||
// CASES for NEGATIVE cycle triggering of pickup and sparks 12 & 34
|
||||
case TRIG_FLAG_12P:
|
||||
case TRIG_FLAG_34P:
|
||||
{
|
||||
// Timeout not occourred, expected POSITIVE edge spark OCCOURRED
|
||||
if (spark_timeout == pdPASS)
|
||||
if (spark_flag != SPARK_FLAG_NIL)
|
||||
{
|
||||
coils->spark_delay = coils->spark_time - coils->trig_time;
|
||||
coils->sstart_status = softStartStatus::NORMAL; // because spark on positive edge
|
||||
@@ -157,12 +159,12 @@ void rtIgnitionTask(void *pvParameters)
|
||||
#endif
|
||||
}
|
||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||
else if (spark_timeout == pdFAIL)
|
||||
else if (spark_flag == SPARK_FLAG_NIL)
|
||||
{
|
||||
coils->spark_status = sparkStatus::SPARK_NEG_WAIT;
|
||||
coils->sstart_status = softStartStatus::NORMAL;
|
||||
}
|
||||
new_data = false;
|
||||
new_data = true;
|
||||
break; // Do nothing more on positive pulse
|
||||
}
|
||||
// CASES for NEGATIVE cycle triggering of pickup and sparks 12 & 34
|
||||
@@ -171,7 +173,7 @@ void rtIgnitionTask(void *pvParameters)
|
||||
{
|
||||
const bool expected_negative12 = coils->spark_status == sparkStatus::SPARK_NEG_WAIT;
|
||||
// Timeout not occourred, expected NEGATIVE edge spark OCCOURRED
|
||||
if (spark_timeout == pdPASS && expected_negative12)
|
||||
if (spark_flag != SPARK_FLAG_NIL && expected_negative12)
|
||||
{
|
||||
coils->spark_delay = coils->spark_time - coils->trig_time;
|
||||
coils->sstart_status = softStartStatus::SOFT_START;
|
||||
@@ -182,13 +184,13 @@ void rtIgnitionTask(void *pvParameters)
|
||||
#endif
|
||||
}
|
||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||
else if (spark_timeout == pdFAIL && expected_negative12)
|
||||
else if (spark_flag == SPARK_FLAG_NIL && expected_negative12)
|
||||
{
|
||||
coils->sstart_status = softStartStatus::NORMAL;
|
||||
coils->spark_status = sparkStatus::SPARK_NEG_FAIL;
|
||||
}
|
||||
// Timeout not occouured, unexpected negative edge spark
|
||||
else if (spark_timeout == pdPASS && !expected_negative12)
|
||||
else if (spark_flag != SPARK_FLAG_NIL && !expected_negative12)
|
||||
{
|
||||
coils->sstart_status = softStartStatus::SOFT_START;
|
||||
coils->spark_status = sparkStatus::SPARK_NEG_UNEXPECTED;
|
||||
@@ -198,7 +200,11 @@ void rtIgnitionTask(void *pvParameters)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
#ifdef DEUG
|
||||
LOG_ERROR("Invalid Interrupt");
|
||||
LOG_ERROR("Pickup Flags: ", printBits(pickup_flag).c_str());
|
||||
LOG_ERROR("Spark Flags: ", printBits(spark_flag).c_str());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user