Mod to ISR and Tasks ok working
This commit is contained in:
@@ -77,6 +77,8 @@ void loop()
|
|||||||
.rst_io_34p = RST_EXT_A34P,
|
.rst_io_34p = RST_EXT_A34P,
|
||||||
.rst_io_34n = RST_EXT_A34N}
|
.rst_io_34n = RST_EXT_A34N}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LOG_INFO("Task Variables OK");
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
||||||
rtTaskParams taskB_params {
|
rtTaskParams taskB_params {
|
||||||
@@ -100,13 +102,12 @@ void loop()
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Init 2 SPI interfaces
|
|
||||||
bool spiA_ok = true;
|
bool spiA_ok = true;
|
||||||
SPIClass SPI_A(FSPI);
|
|
||||||
spiA_ok = SPI_A.begin(SPI_A_SCK, SPI_A_MISO, SPI_A_MOSI);
|
|
||||||
|
|
||||||
bool spiB_ok = true;
|
bool spiB_ok = true;
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
|
// Init 2 SPI interfaces
|
||||||
|
SPIClass SPI_A(FSPI);
|
||||||
|
spiA_ok = SPI_A.begin(SPI_A_SCK, SPI_A_MISO, SPI_A_MOSI);
|
||||||
SPIClass SPI_B(HSPI);
|
SPIClass SPI_B(HSPI);
|
||||||
spiB_ok = SPI_B.begin(SPI_B_SCK, SPI_B_MISO, SPI_B_MOSI);
|
spiB_ok = SPI_B.begin(SPI_B_SCK, SPI_B_MISO, SPI_B_MOSI);
|
||||||
#endif
|
#endif
|
||||||
@@ -117,15 +118,15 @@ void loop()
|
|||||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
vTaskDelay(pdMS_TO_TICKS(5000));
|
||||||
esp_restart();
|
esp_restart();
|
||||||
}
|
}
|
||||||
LOG_INFO("Init SPI [OK]");
|
LOG_INFO("Init SPI OK");
|
||||||
|
|
||||||
|
#ifndef TEST
|
||||||
// Init ADC_A
|
// 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 = 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->InitializeADC();
|
||||||
dev.adc_a->setPGA(PGA_1);
|
dev.adc_a->setPGA(PGA_1);
|
||||||
dev.adc_a->setDRATE(DRATE_1000SPS);
|
dev.adc_a->setDRATE(DRATE_1000SPS);
|
||||||
|
|
||||||
#ifndef TEST
|
|
||||||
// Init ADC_B
|
// 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 = 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->InitializeADC();
|
||||||
@@ -133,7 +134,7 @@ void loop()
|
|||||||
dev.adc_a->setDRATE(DRATE_1000SPS);
|
dev.adc_a->setDRATE(DRATE_1000SPS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOG_INFO("Init ADC [OK]");
|
LOG_INFO("Init ADC OK");
|
||||||
|
|
||||||
// Ignition A on Core 0
|
// Ignition A on Core 0
|
||||||
auto ignA_task_success = pdPASS;
|
auto ignA_task_success = pdPASS;
|
||||||
@@ -151,7 +152,7 @@ void loop()
|
|||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
ignB_task_success = xTaskCreatePinnedToCore(
|
ignB_task_success = xTaskCreatePinnedToCore(
|
||||||
rtIgnitionTask,
|
rtIgnitionTask,
|
||||||
"rtIgnitionTask_boxA",
|
"rtIgnitionTask_boxB",
|
||||||
TASK_STACK,
|
TASK_STACK,
|
||||||
(void *)&taskB_params,
|
(void *)&taskB_params,
|
||||||
TASK_PRIORITY, // priorità leggermente più alta
|
TASK_PRIORITY, // priorità leggermente più alta
|
||||||
@@ -173,8 +174,14 @@ void loop()
|
|||||||
uint32_t count(0);
|
uint32_t count(0);
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
// printTaskList();
|
delay(10);
|
||||||
delay(10000);
|
ignitionBoxStatus ignA;
|
||||||
|
if (xQueueReceive(rt_taskA_queue, &ignA, 0) == pdTRUE){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(count++ % 100))
|
||||||
|
printTaskList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trigA_TaskHandle)
|
if (trigA_TaskHandle)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
LOG_ERROR("Null rt_task_ptr parameters");
|
LOG_ERROR("Null rt_task_ptr parameters");
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
LOG_INFO("rtTask Params OK");
|
||||||
|
|
||||||
// Task Parameters and Devices
|
// Task Parameters and Devices
|
||||||
rtTaskParams *params = (rtTaskParams *)pvParameters;
|
rtTaskParams *params = (rtTaskParams *)pvParameters;
|
||||||
@@ -47,6 +48,8 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
.ign_stat = &ign_box_sts,
|
.ign_stat = &ign_box_sts,
|
||||||
.rt_handle_ptr = rt_handle_ptr};
|
.rt_handle_ptr = rt_handle_ptr};
|
||||||
|
|
||||||
|
LOG_INFO("rtTask ISR Params OK");
|
||||||
|
|
||||||
// Attach Pin Interrupts
|
// Attach Pin Interrupts
|
||||||
attachInterruptArg(rt_int.trig_pin_12p, rt_int.isr_ptr, (void *)&isr_params_t12p, RISING);
|
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_12n, rt_int.isr_ptr, (void *)&isr_params_t12n, RISING);
|
||||||
@@ -55,12 +58,15 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
attachInterruptArg(rt_int.spark_pin_12, rt_int.isr_ptr, (void *)&isr_params_sp12, 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(rt_int.spark_pin_34, rt_int.isr_ptr, (void *)&isr_params_sp34, RISING);
|
||||||
|
|
||||||
|
LOG_INFO("rtTask ISR Attach OK");
|
||||||
|
|
||||||
// Compute Reset Pin Bitmask
|
// Compute Reset Pin Bitmask
|
||||||
const uint16_t rst_bitmask = (1 << rt_rst.rst_io_12p) |
|
const uint16_t rst_bitmask = (1 << rt_rst.rst_io_12p) |
|
||||||
(1 << rt_rst.rst_io_12n) |
|
(1 << rt_rst.rst_io_12n) |
|
||||||
(1 << rt_rst.rst_io_34p) |
|
(1 << rt_rst.rst_io_34p) |
|
||||||
(1 << rt_rst.rst_io_34n);
|
(1 << rt_rst.rst_io_34n);
|
||||||
|
|
||||||
|
LOG_WARN("rt Task Init Correct");
|
||||||
uint32_t it = 0;
|
uint32_t it = 0;
|
||||||
uint32_t q_fail_count = 0;
|
uint32_t q_fail_count = 0;
|
||||||
while (params->rt_running)
|
while (params->rt_running)
|
||||||
@@ -72,7 +78,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
#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
|
||||||
LOG_INFO("Iteration [", it, "]");
|
LOG_INFO("Iteration [", it++, "]");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// WAIT FOR PICKUP SIGNAL
|
// WAIT FOR PICKUP SIGNAL
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -23,12 +23,12 @@ const uint8_t spark_timeout_max = 2; // in milliseconds
|
|||||||
// Debug Variables
|
// Debug Variables
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static const std::map<const uint32_t, const char *> names = {
|
static const std::map<const uint32_t, const char *> names = {
|
||||||
{TRIG_FLAG_A12P, "TRIG_FLAG_A12P"},
|
{TRIG_FLAG_12P, "TRIG_FLAG_12P"},
|
||||||
{TRIG_FLAG_A12N, "TRIG_FLAG_A12N"},
|
{TRIG_FLAG_12N, "TRIG_FLAG_12N"},
|
||||||
{TRIG_FLAG_A34P, "TRIG_FLAG_A34P"},
|
{TRIG_FLAG_34P, "TRIG_FLAG_34P"},
|
||||||
{TRIG_FLAG_A34N, "TRIG_FLAG_A34N"},
|
{TRIG_FLAG_34N, "TRIG_FLAG_34N"},
|
||||||
{SPARK_FLAG_A12, "SPARK_FLAG_A12"},
|
{SPARK_FLAG_12, "SPARK_FLAG_12"},
|
||||||
{SPARK_FLAG_A34, "SPARK_FLAG_A34"},
|
{SPARK_FLAG_34, "SPARK_FLAG_34"},
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
14
RotaxMonitor/src/utils.cpp
Normal file
14
RotaxMonitor/src/utils.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
std::string printBits(uint32_t value) {
|
||||||
|
std::string result;
|
||||||
|
for (int i = 31; i >= 0; i--) {
|
||||||
|
// ottieni il singolo bit
|
||||||
|
result += ((value >> i) & 1) ? '1' : '0';
|
||||||
|
// aggiungi uno spazio ogni 8 bit, tranne dopo l'ultimo
|
||||||
|
if (i % 8 == 0 && i != 0) {
|
||||||
|
result += ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -3,15 +3,4 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string printBits(uint32_t value) {
|
std::string printBits(uint32_t value);
|
||||||
std::string result;
|
|
||||||
for (int i = 31; i >= 0; i--) {
|
|
||||||
// ottieni il singolo bit
|
|
||||||
result += ((value >> i) & 1) ? '1' : '0';
|
|
||||||
// aggiungi uno spazio ogni 8 bit, tranne dopo l'ultimo
|
|
||||||
if (i % 8 == 0 && i != 0) {
|
|
||||||
result += ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user