Pins and devices refactoring in progress
This commit is contained in:
@@ -28,38 +28,13 @@ void setup()
|
||||
LOG_INFO("ESP32 Heap:", ESP.getHeapSize());
|
||||
LOG_INFO("ESP32 Sketch:", ESP.getFreeSketchSpace());
|
||||
|
||||
// Initialize Interrupt pins on coil detectors
|
||||
pinMode(TRIG_A12P, INPUT_PULLDOWN);
|
||||
pinMode(TRIG_A12N, INPUT_PULLDOWN);
|
||||
pinMode(TRIG_A34P, INPUT_PULLDOWN);
|
||||
pinMode(TRIG_A34N, INPUT_PULLDOWN);
|
||||
pinMode(TRIG_B12P, INPUT_PULLDOWN);
|
||||
pinMode(TRIG_B12N, INPUT_PULLDOWN);
|
||||
pinMode(TRIG_B34P, INPUT_PULLDOWN);
|
||||
pinMode(TRIG_B34N, INPUT_PULLDOWN);
|
||||
// Initialize Interrupt pins on PICKUP detectors
|
||||
initTriggerPinsInputs();
|
||||
initTriggerPinMapping();
|
||||
// Initialize Interrupt pins on spark detectors
|
||||
pinMode(SPARK_A12, INPUT_PULLDOWN);
|
||||
pinMode(SPARK_A34, INPUT_PULLDOWN);
|
||||
pinMode(SPARK_B12, INPUT_PULLDOWN);
|
||||
pinMode(SPARK_B34, INPUT_PULLDOWN);
|
||||
// Initialize Interrupt pins on SPARK detectors
|
||||
initSparkPinInputs();
|
||||
initSparkPinMapping();
|
||||
|
||||
// Ignition A Interrupts
|
||||
attachInterrupt(TRIG_A12P, trig_isr_a, RISING);
|
||||
attachInterrupt(TRIG_A34P, trig_isr_a, RISING);
|
||||
attachInterrupt(TRIG_A12N, trig_isr_a, RISING);
|
||||
attachInterrupt(TRIG_A34N, trig_isr_a, RISING);
|
||||
attachInterrupt(SPARK_A12, spark_a, RISING);
|
||||
attachInterrupt(SPARK_A34, spark_a, RISING);
|
||||
// Ignition B Interrupts
|
||||
attachInterrupt(TRIG_B12P, trig_isr_b, RISING);
|
||||
attachInterrupt(TRIG_B34P, trig_isr_b, RISING);
|
||||
attachInterrupt(TRIG_B12N, trig_isr_b, RISING);
|
||||
attachInterrupt(TRIG_B34N, trig_isr_b, RISING);
|
||||
attachInterrupt(SPARK_B12, spark_b, RISING);
|
||||
attachInterrupt(SPARK_B34, spark_b, RISING);
|
||||
|
||||
// Init SPI interface
|
||||
SPI.begin();
|
||||
}
|
||||
@@ -71,7 +46,7 @@ void loop()
|
||||
Devices dev;
|
||||
|
||||
// Init devices
|
||||
dev.adc = new ADS1256(ADC_DRDY, ADC_RST, ADC_SYNC, ADC_CS, 2.5, &SPI);
|
||||
dev.adca = new ADS1256(ADC_DRDY, ADC_RST, ADC_SYNC, ADC_CS, 2.5, &SPI);
|
||||
dev.adc->InitializeADC();
|
||||
dev.adc->setPGA(PGA_1);
|
||||
dev.adc->setDRATE(DRATE_1000SPS);
|
||||
@@ -87,19 +62,23 @@ void loop()
|
||||
CORE_0);
|
||||
|
||||
// Ignition B on Core 1
|
||||
auto ignB_task_success = xTaskCreatePinnedToCore(
|
||||
ignitionB_task,
|
||||
"ignitionB_task",
|
||||
TASK_STACK,
|
||||
(void *)&dev,
|
||||
TASK_PRIORITY, // priorità leggermente più alta
|
||||
&trigA_TaskHandle,
|
||||
CORE_1);
|
||||
auto ignB_task_success = pdPASS;
|
||||
// auto ignB_task_success = xTaskCreatePinnedToCore(
|
||||
// ignitionB_task,
|
||||
// "ignitionB_task",
|
||||
// TASK_STACK,
|
||||
// (void *)&dev,
|
||||
// TASK_PRIORITY, // priorità leggermente più alta
|
||||
// &trigA_TaskHandle,
|
||||
// CORE_1);
|
||||
|
||||
if ((ignA_task_success && ignB_task_success) != pdPASS)
|
||||
{
|
||||
LOG_ERROR("Unble to initialize ISR task");
|
||||
}
|
||||
LOG_ERROR("5 seconds to restart...");
|
||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
||||
esp_restart();
|
||||
}
|
||||
LOG_INFO("Real Time Tasks A&B initialized");
|
||||
|
||||
////////////////////// MAIN LOOP //////////////////////
|
||||
|
||||
Reference in New Issue
Block a user