First Test env
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
#include <SPI.h>
|
||||
|
||||
// Definitions
|
||||
#include <pins.h>
|
||||
#include <channels.h>
|
||||
#include <tasks.h>
|
||||
#include <channels.h>
|
||||
#include <devices.h>
|
||||
|
||||
void setup()
|
||||
@@ -23,7 +22,11 @@ void setup()
|
||||
|
||||
// Print Processor Info
|
||||
LOG_INFO("ESP32 Chip:", ESP.getChipModel());
|
||||
LOG_INFO("ESP32 PSram:", ESP.getPsramSize());
|
||||
if (psramFound()){
|
||||
LOG_INFO("ESP32 PSram Found");
|
||||
LOG_INFO("ESP32 PSram:", ESP.getPsramSize());
|
||||
psramInit();
|
||||
}
|
||||
LOG_INFO("ESP32 Flash:", ESP.getFlashChipSize());
|
||||
LOG_INFO("ESP32 Heap:", ESP.getHeapSize());
|
||||
LOG_INFO("ESP32 Sketch:", ESP.getFreeSketchSpace());
|
||||
@@ -34,29 +37,49 @@ void setup()
|
||||
// Initialize Interrupt pins on SPARK detectors
|
||||
initSparkPinInputs();
|
||||
initSparkPinMapping();
|
||||
|
||||
// Init SPI interface
|
||||
SPI.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// global variables
|
||||
bool running = true;
|
||||
rtTaskParams taskA_params, taskB_params;
|
||||
Devices dev;
|
||||
|
||||
// Init devices
|
||||
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);
|
||||
#ifndef TEST
|
||||
// Init 2 SPI interfaces
|
||||
SPIClass SPI_A(FSPI);
|
||||
SPIClass SPI_B(HSPI);
|
||||
if (!SPI_A.begin(SPI_A_SCK, SPI_A_MISO, SPI_A_MOSI) || !SPI_B.begin(SPI_A_SCK, SPI_A_MISO, SPI_A_MOSI)) {
|
||||
LOG_ERROR("Unable to Initialize SPI Busses");
|
||||
LOG_ERROR("5 seconds to restart...");
|
||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
||||
esp_restart();
|
||||
}
|
||||
#endif
|
||||
|
||||
pinMode(POT_A_CS, OUTPUT); // Temporary!
|
||||
pinMode(POT_B_CS, OUTPUT); // Temporary!
|
||||
LOG_INFO("Init SPI [OK]");
|
||||
|
||||
// Init ADC_A
|
||||
// dev.adc_a = new ADS1256(ADC_A_DRDY, ADC_A_RST, ADC_A_SYNC, ADC_A_CS, 2.5, &SPI_A);
|
||||
// dev.adc_a->InitializeADC();
|
||||
// dev.adc_a->setPGA(PGA_1);
|
||||
// dev.adc_a->setDRATE(DRATE_1000SPS);
|
||||
|
||||
// Init ADC_B
|
||||
// dev.adc_a = new ADS1256(ADC_B_DRDY, ADC_B_RST, ADC_B_SYNC, ADC_B_CS, 2.5, &SPI_B);
|
||||
// dev.adc_a->InitializeADC();
|
||||
// dev.adc_a->setPGA(PGA_1);
|
||||
// dev.adc_a->setDRATE(DRATE_1000SPS);
|
||||
|
||||
// Ignition A on Core 0
|
||||
auto ignA_task_success = xTaskCreatePinnedToCore(
|
||||
ignitionA_task,
|
||||
"ignitionA_task",
|
||||
TASK_STACK,
|
||||
(void *)&dev,
|
||||
(void *)&taskA_params,
|
||||
TASK_PRIORITY,
|
||||
&trigA_TaskHandle,
|
||||
CORE_0);
|
||||
@@ -67,7 +90,7 @@ void loop()
|
||||
// ignitionB_task,
|
||||
// "ignitionB_task",
|
||||
// TASK_STACK,
|
||||
// (void *)&dev,
|
||||
// (void *)&taskB_params,
|
||||
// TASK_PRIORITY, // priorità leggermente più alta
|
||||
// &trigA_TaskHandle,
|
||||
// CORE_1);
|
||||
@@ -82,8 +105,14 @@ void loop()
|
||||
LOG_INFO("Real Time Tasks A&B initialized");
|
||||
|
||||
////////////////////// MAIN LOOP //////////////////////
|
||||
uint32_t count(0);
|
||||
while (running)
|
||||
{
|
||||
//digitalWrite(POT_B_CS, HIGH);
|
||||
//delay(500);
|
||||
//LOG_INFO("Main Loop [", count++, "]");
|
||||
//digitalWrite(POT_B_CS, LOW);
|
||||
//delay(500);
|
||||
}
|
||||
|
||||
if (trigA_TaskHandle)
|
||||
|
||||
Reference in New Issue
Block a user