debug testing commit
This commit is contained in:
4
RotaxMonitor/.vscode/extensions.json
vendored
4
RotaxMonitor/.vscode/extensions.json
vendored
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
|
"Jason2866.esp-decoder",
|
||||||
|
"pioarduino.pioarduino-ide",
|
||||||
"platformio.platformio-ide"
|
"platformio.platformio-ide"
|
||||||
],
|
],
|
||||||
"unwantedRecommendations": [
|
"unwantedRecommendations": [
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"-DARDUINO_RUNNING_CORE=1",
|
"-DARDUINO_RUNNING_CORE=1",
|
||||||
"-DARDUINO_EVENT_RUNNING_CORE=1",
|
"-DARDUINO_EVENT_RUNNING_CORE=1",
|
||||||
"-DBOARD_HAS_PSRAM",
|
"-DBOARD_HAS_PSRAM",
|
||||||
"-DARDUINO_USB_MODE=1",
|
"-DARDUINO_USB_MODE=0",
|
||||||
"-DARDUINO_USB_CDC_ON_BOOT=0"
|
"-DARDUINO_USB_CDC_ON_BOOT=1"
|
||||||
],
|
],
|
||||||
"f_cpu": "240000000L",
|
"f_cpu": "240000000L",
|
||||||
"f_flash": "80000000L",
|
"f_flash": "80000000L",
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:esp32-s3-n16r8]
|
[env:esp32-s3-devkitc1-n16r8]
|
||||||
board = esp32-s3-n16r8
|
board = esp32-s3-devkitc1-n16r8
|
||||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.37/platform-espressif32.zip
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps =
|
lib_deps =
|
||||||
hideakitai/DebugLog@^0.8.4
|
hideakitai/DebugLog@^0.8.4
|
||||||
@@ -18,51 +18,29 @@ lib_deps =
|
|||||||
hideakitai/PCA95x5@^0.1.3
|
hideakitai/PCA95x5@^0.1.3
|
||||||
adafruit/Adafruit SSD1306@^2.5.16
|
adafruit/Adafruit SSD1306@^2.5.16
|
||||||
garfius/Menu-UI@^1.2.0
|
garfius/Menu-UI@^1.2.0
|
||||||
board_build.partitions = partitions/default_16MB.csv
|
|
||||||
board_build.psram = enabled
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
build_type = release
|
build_type = release
|
||||||
|
|
||||||
[env:esp32-s3-n16r8-debug]
|
[env:esp32-s3-devkitc1-n16r8-debug]
|
||||||
board = ${env:esp32-s3-n16r8.board}
|
board = ${env:esp32-s3-devkitc1-n16r8.board}
|
||||||
platform = ${env:esp32-s3-n16r8.platform}
|
platform = ${env:esp32-s3-devkitc1-n16r8.platform}
|
||||||
framework = ${env:esp32-s3-n16r8.framework}
|
framework = ${env:esp32-s3-devkitc1-n16r8.framework}
|
||||||
lib_deps = ${env:esp32-s3-n16r8.lib_deps}
|
lib_deps = ${env:esp32-s3-devkitc1-n16r8.lib_deps}
|
||||||
board_build.partitions = partitions/default_16MB.csv
|
|
||||||
board_build.psram = enabled
|
build_type = debug
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
build_type = debug
|
|
||||||
build_flags =
|
|
||||||
-O0
|
|
||||||
-g3
|
|
||||||
-ggdb
|
|
||||||
-fno-inline
|
|
||||||
-fno-ipa-sra
|
|
||||||
-fno-tree-sra
|
|
||||||
-fno-builtin
|
|
||||||
|
|
||||||
|
debug_tool = esp-builtin
|
||||||
|
debug_speed = 15000
|
||||||
|
|
||||||
[env:esp32-devtest-debug]
|
build_flags =
|
||||||
board = esp32dev
|
-O0
|
||||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.37/platform-espressif32.zip
|
-g3
|
||||||
framework = arduino
|
-ggdb3
|
||||||
lib_deps =
|
-fno-inline
|
||||||
hideakitai/DebugLog@^0.8.4
|
-DCORE_DEBUG_LEVEL=5
|
||||||
bblanchon/ArduinoJson@^7.4.2
|
-DARDUINO_USB_CDC_ON_BOOT=0
|
||||||
hideakitai/PCA95x5@^0.1.3
|
-fstack-protector-all
|
||||||
adafruit/Adafruit SSD1306@^2.5.16
|
|
||||||
garfius/Menu-UI@^1.2.0
|
|
||||||
board_build.flash_size = 4MB
|
|
||||||
board_build.partitions = default.csv
|
|
||||||
monitor_speed = 115200
|
|
||||||
build_type = debug
|
|
||||||
build_flags =
|
|
||||||
-O0
|
|
||||||
-g3
|
|
||||||
-ggdb
|
|
||||||
-fno-inline
|
|
||||||
-fno-ipa-sra
|
|
||||||
-fno-tree-sra
|
|
||||||
-fno-builtin
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ void trig_isr(void *arg)
|
|||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
isrParams *params = (isrParams *)arg;
|
isrParams *params = (isrParams *)arg;
|
||||||
ignitionBoxStatus *box = params->ign_stat;
|
ignitionBoxStatus *box = params->ign_stat;
|
||||||
TaskHandle_t task_handle = *params->rt_handle_ptr;
|
TaskHandle_t task_handle = params->rt_handle_ptr;
|
||||||
|
|
||||||
// exit if task not running
|
// exit if task not running
|
||||||
if (!task_handle)
|
if (!task_handle)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Test device Flag
|
// Test device Flag
|
||||||
#define TEST
|
// #define TEST
|
||||||
|
|
||||||
// Arduino Libraries
|
// Arduino Libraries
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
@@ -20,14 +20,14 @@
|
|||||||
// =====================
|
// =====================
|
||||||
// Event Flags (bitmask)
|
// Event Flags (bitmask)
|
||||||
// =====================
|
// =====================
|
||||||
#define TRIG_FLAG_12P (1 << 0)
|
static const uint32_t TRIG_FLAG_12P = (1 << 0);
|
||||||
#define TRIG_FLAG_12N (1 << 2)
|
static const uint32_t TRIG_FLAG_12N = (1 << 1);
|
||||||
#define TRIG_FLAG_34P (1 << 1)
|
static const uint32_t TRIG_FLAG_34P = (1 << 2);
|
||||||
#define TRIG_FLAG_34N (1 << 3)
|
static const uint32_t TRIG_FLAG_34N = (1 << 3);
|
||||||
|
|
||||||
#define SPARK_FLAG_NIL (1 << 8)
|
static const uint32_t SPARK_FLAG_NIL = (1 << 8);
|
||||||
#define SPARK_FLAG_12 (1 << 9)
|
static const uint32_t SPARK_FLAG_12 = (1 << 9);
|
||||||
#define SPARK_FLAG_34 (1 << 10)
|
static const uint32_t SPARK_FLAG_34 = (1 << 10);
|
||||||
|
|
||||||
// Spark Status
|
// Spark Status
|
||||||
enum sparkStatus
|
enum sparkStatus
|
||||||
@@ -75,11 +75,11 @@ struct ignitionBoxStatus
|
|||||||
float volts_gen = 0.0;
|
float volts_gen = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct isrParams {
|
struct isrParams
|
||||||
|
{
|
||||||
const uint32_t flag;
|
const uint32_t flag;
|
||||||
ignitionBoxStatus* ign_stat;
|
ignitionBoxStatus *ign_stat;
|
||||||
TaskHandle_t* rt_handle_ptr;
|
TaskHandle_t rt_handle_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void IRAM_ATTR trig_isr(void *arg);
|
void IRAM_ATTR trig_isr(void *arg);
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
#include <devices.h>
|
#include <devices.h>
|
||||||
#include <ui.h>
|
#include <ui.h>
|
||||||
|
|
||||||
|
// #define CH_B_ENABLE
|
||||||
|
#define TEST
|
||||||
|
|
||||||
void printTaskList()
|
void printTaskList()
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
@@ -51,15 +54,15 @@ void loop()
|
|||||||
{
|
{
|
||||||
// global variables
|
// global variables
|
||||||
bool running = true;
|
bool running = true;
|
||||||
Devices dev;
|
static Devices dev;
|
||||||
|
|
||||||
// Task handle
|
// Task handle
|
||||||
TaskHandle_t trigA_TaskHandle = NULL;
|
static TaskHandle_t trigA_TaskHandle = NULL;
|
||||||
TaskHandle_t trigB_TaskHandle = NULL;
|
static TaskHandle_t trigB_TaskHandle = NULL;
|
||||||
|
|
||||||
QueueHandle_t rt_taskA_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
static QueueHandle_t rt_taskA_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
||||||
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
static QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
||||||
rtTaskParams taskA_params{
|
static rtTaskParams taskA_params{
|
||||||
.rt_running = true,
|
.rt_running = true,
|
||||||
.dev = &dev,
|
.dev = &dev,
|
||||||
.rt_handle_ptr = &trigA_TaskHandle,
|
.rt_handle_ptr = &trigA_TaskHandle,
|
||||||
@@ -75,13 +78,14 @@ void loop()
|
|||||||
.rt_resets = rtTaskResets{.rst_io_12p = RST_EXT_A12P, .rst_io_12n = RST_EXT_A12N, .rst_io_34p = RST_EXT_A34P, .rst_io_34n = RST_EXT_A34N}};
|
.rt_resets = rtTaskResets{.rst_io_12p = RST_EXT_A12P, .rst_io_12n = RST_EXT_A12N, .rst_io_34p = RST_EXT_A34P, .rst_io_34n = RST_EXT_A34N}};
|
||||||
|
|
||||||
LOG_INFO("Task Variables OK");
|
LOG_INFO("Task Variables OK");
|
||||||
#ifndef TEST
|
|
||||||
|
#ifdef CH_B_ENABLE
|
||||||
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
QueueHandle_t rt_taskB_queue = xQueueCreate(10, sizeof(ignitionBoxStatus));
|
||||||
rtTaskParams taskB_params{
|
rtTaskParams taskB_params{
|
||||||
.rt_running = true,
|
.rt_running = true,
|
||||||
.dev = &dev,
|
.dev = &dev,
|
||||||
.rt_queue = rt_taskB_queue,
|
|
||||||
.rt_handle_ptr = &trigB_TaskHandle,
|
.rt_handle_ptr = &trigB_TaskHandle,
|
||||||
|
.rt_queue = rt_taskB_queue,
|
||||||
.rt_int = rtTaskInterrupts{
|
.rt_int = rtTaskInterrupts{
|
||||||
.isr_ptr = trig_isr,
|
.isr_ptr = trig_isr,
|
||||||
.trig_pin_12p = TRIG_PIN_B12P,
|
.trig_pin_12p = TRIG_PIN_B12P,
|
||||||
@@ -95,6 +99,7 @@ void loop()
|
|||||||
|
|
||||||
bool spiA_ok = true;
|
bool spiA_ok = true;
|
||||||
bool spiB_ok = true;
|
bool spiB_ok = true;
|
||||||
|
|
||||||
#ifndef TEST
|
#ifndef TEST
|
||||||
// Init 2 SPI interfaces
|
// Init 2 SPI interfaces
|
||||||
SPIClass SPI_A(FSPI);
|
SPIClass SPI_A(FSPI);
|
||||||
@@ -102,6 +107,7 @@ void loop()
|
|||||||
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
|
||||||
|
|
||||||
if (!spiA_ok || !spiB_ok)
|
if (!spiA_ok || !spiB_ok)
|
||||||
{
|
{
|
||||||
LOG_ERROR("Unable to Initialize SPI Busses");
|
LOG_ERROR("Unable to Initialize SPI Busses");
|
||||||
@@ -140,7 +146,7 @@ void loop()
|
|||||||
|
|
||||||
// Ignition B on Core 1
|
// Ignition B on Core 1
|
||||||
auto ignB_task_success = pdPASS;
|
auto ignB_task_success = pdPASS;
|
||||||
#ifndef TEST
|
#ifdef CH_B_ENABLE
|
||||||
ignB_task_success = xTaskCreatePinnedToCore(
|
ignB_task_success = xTaskCreatePinnedToCore(
|
||||||
rtIgnitionTask,
|
rtIgnitionTask,
|
||||||
"rtIgnitionTask_boxB",
|
"rtIgnitionTask_boxB",
|
||||||
@@ -171,40 +177,37 @@ void loop()
|
|||||||
ignitionBoxStatus ignA;
|
ignitionBoxStatus ignA;
|
||||||
if (xQueueReceive(rt_taskA_queue, &ignA, pdMS_TO_TICKS(100)) == pdTRUE)
|
if (xQueueReceive(rt_taskA_queue, &ignA, pdMS_TO_TICKS(100)) == pdTRUE)
|
||||||
{
|
{
|
||||||
printField("++ Timestamp", (uint32_t)ignA.timestamp, 0, 0);
|
if (count++ % 10000 == 0)
|
||||||
if (firstRun)
|
|
||||||
Serial.println("========== Coils 12 =============");
|
|
||||||
printField("Pickup Tim", (uint32_t)ignA.coils12.trig_time, 0, 1);
|
|
||||||
printField("Spark Tim", (uint32_t)ignA.coils12.spark_time, 0, 2);
|
|
||||||
printField("Spark Dly", (uint32_t)ignA.coils12.spark_delay, 0, 3);
|
|
||||||
printField("Spark Sts", (uint32_t)ignA.coils12.spark_status, 0, 4);
|
|
||||||
printField("Peak P_IN", ignA.coils12.peak_p_in, 0, 5);
|
|
||||||
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_OUT", ignA.coils12.peak_n_out, 0, 8);
|
|
||||||
printField("SoftStart ", (uint32_t)ignA.coils12.sstart_status, 0, 9);
|
|
||||||
if (firstRun)
|
|
||||||
Serial.println("========== Coils 34 =============");
|
|
||||||
printField("Pickup Tim", (uint32_t)ignA.coils34.trig_time, 0, 11);
|
|
||||||
printField("Spark Tim", (uint32_t)ignA.coils34.spark_time, 0, 12);
|
|
||||||
printField("Spark Dly", (uint32_t)ignA.coils34.spark_delay, 0, 13);
|
|
||||||
printField("Spark Sts", (uint32_t)ignA.coils34.spark_delay, 0, 14);
|
|
||||||
printField("Peak P_IN", ignA.coils34.peak_p_in, 0, 15);
|
|
||||||
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_OUT", ignA.coils34.peak_n_out, 0, 18);
|
|
||||||
printField("SoftStart ", (uint32_t)ignA.coils34.sstart_status, 0, 19);
|
|
||||||
if (firstRun)
|
|
||||||
Serial.println("========== END =============");
|
|
||||||
if (count++ % 10 == 0)
|
|
||||||
{
|
{
|
||||||
firstRun = true;
|
firstRun = true;
|
||||||
clearScreen();
|
clearScreen();
|
||||||
setCursor(0, 0);
|
setCursor(0, 0);
|
||||||
}
|
printField("++ Timestamp", (uint32_t)ignA.timestamp, 0, 0);
|
||||||
else
|
Serial.println("========== Coils 12 =============");
|
||||||
|
printField("Pickup Tim", (uint32_t)ignA.coils12.trig_time, 0, 1);
|
||||||
|
printField("Spark Tim", (uint32_t)ignA.coils12.spark_time, 0, 2);
|
||||||
|
printField("Spark Dly", (uint32_t)ignA.coils12.spark_delay, 0, 3);
|
||||||
|
printField("Spark Sts", (uint32_t)ignA.coils12.spark_status, 0, 4);
|
||||||
|
printField("Peak P_IN", ignA.coils12.peak_p_in, 0, 5);
|
||||||
|
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_OUT", ignA.coils12.peak_n_out, 0, 8);
|
||||||
|
printField("SoftStart ", (uint32_t)ignA.coils12.sstart_status, 0, 9);
|
||||||
|
|
||||||
firstRun = false;
|
Serial.println("========== Coils 34 =============");
|
||||||
|
printField("Pickup Tim", (uint32_t)ignA.coils34.trig_time, 0, 11);
|
||||||
|
printField("Spark Tim", (uint32_t)ignA.coils34.spark_time, 0, 12);
|
||||||
|
printField("Spark Dly", (uint32_t)ignA.coils34.spark_delay, 0, 13);
|
||||||
|
printField("Spark Sts", (uint32_t)ignA.coils34.spark_delay, 0, 14);
|
||||||
|
printField("Peak P_IN", ignA.coils34.peak_p_in, 0, 15);
|
||||||
|
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_OUT", ignA.coils34.peak_n_out, 0, 18);
|
||||||
|
printField("SoftStart ", (uint32_t)ignA.coils34.sstart_status, 0, 19);
|
||||||
|
|
||||||
|
Serial.println("========== END =============");
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,8 @@
|
|||||||
// =====================
|
// =====================
|
||||||
#define TRIG_PIN_A12P 18
|
#define TRIG_PIN_A12P 18
|
||||||
#define TRIG_PIN_A12N 21
|
#define TRIG_PIN_A12N 21
|
||||||
#define TRIG_PIN_A34P 33
|
#define TRIG_PIN_A34P 38 // ATTENZIONEEEEEEEEEEE
|
||||||
#define TRIG_PIN_A34N 34
|
#define TRIG_PIN_A34N 39 // ATTENZIONEEEEEEEEEEE
|
||||||
#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 45 // OK (strapping ma consentito)
|
#define SPARK_PIN_A34 42 // OK (strapping ma consentito) 45
|
||||||
#define SPARK_PIN_B12 46 // OK (strapping ma consentito)
|
#define SPARK_PIN_B12 42 // OK (strapping ma consentito) 46
|
||||||
#define SPARK_PIN_B34 47
|
#define SPARK_PIN_B34 42
|
||||||
|
|
||||||
// =====================
|
// =====================
|
||||||
// PCA9555 (I2C EXPANDER)
|
// PCA9555 (I2C EXPANDER)
|
||||||
|
|||||||
@@ -16,13 +16,14 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
const rtTaskInterrupts rt_int = params->rt_int; // copy to avoid external override
|
const rtTaskInterrupts rt_int = params->rt_int; // copy to avoid external override
|
||||||
const rtTaskResets rt_rst = params->rt_resets; // copy to avoid external override
|
const rtTaskResets rt_rst = params->rt_resets; // copy to avoid external override
|
||||||
QueueHandle_t rt_queue = params->rt_queue;
|
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;
|
Devices *dev = params->dev;
|
||||||
ADS1256 *adc = dev->adc_a;
|
ADS1256 *adc = dev->adc_a;
|
||||||
PCA9555 *io = dev->io;
|
PCA9555 *io = dev->io;
|
||||||
|
|
||||||
|
static ignitionBoxStatus ign_box_sts;
|
||||||
|
|
||||||
// Variables for ISR, static to be fixed in memory locations
|
// Variables for ISR, static to be fixed in memory locations
|
||||||
static ignitionBoxStatus ign_box_sts; // common for all ISR calls
|
|
||||||
static isrParams isr_params_t12p{
|
static isrParams isr_params_t12p{
|
||||||
.flag = TRIG_FLAG_12P,
|
.flag = TRIG_FLAG_12P,
|
||||||
.ign_stat = &ign_box_sts,
|
.ign_stat = &ign_box_sts,
|
||||||
@@ -47,7 +48,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
.flag = SPARK_FLAG_34,
|
.flag = SPARK_FLAG_34,
|
||||||
.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");
|
LOG_INFO("rtTask ISR Params OK");
|
||||||
|
|
||||||
pinMode(POT_A_CS, OUTPUT);
|
pinMode(POT_A_CS, OUTPUT);
|
||||||
@@ -80,19 +81,20 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
|
|
||||||
// WAIT FOR PICKUP SIGNAL
|
// WAIT FOR PICKUP SIGNAL
|
||||||
xTaskNotifyWait(
|
xTaskNotifyWait(
|
||||||
ULONG_MAX, // non pulire all'ingresso
|
0x00, // non pulire all'ingresso
|
||||||
ULONG_MAX, // pulisci i primi 8 bit
|
ULONG_MAX, // pulisci i primi 8 bit
|
||||||
&pickup_flag, // valore ricevuto
|
&pickup_flag, // valore ricevuto
|
||||||
portMAX_DELAY);
|
portMAX_DELAY);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LOG_INFO("Iteration [", it++, "]");
|
|
||||||
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("Pickup Flags: ", printBits(pickup_flag).c_str());
|
LOG_INFO("Iteration [", it++, "]");
|
||||||
|
|
||||||
if (!names.contains(pickup_flag))
|
if (!names.contains(pickup_flag))
|
||||||
{
|
{
|
||||||
LOG_ERROR("Wrong Pickup Flag");
|
LOG_ERROR("Wrong Pickup Flag");
|
||||||
|
LOG_ERROR("Pickup Flags: ", printBits(pickup_flag).c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -106,18 +108,17 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
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
|
||||||
spark_flag == SPARK_FLAG_NIL;
|
spark_flag = SPARK_FLAG_NIL;
|
||||||
|
|
||||||
xTaskNotifyStateClear(NULL);
|
|
||||||
ulTaskNotifyValueClear(NULL, 0xFFFFFFFF);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
LOG_INFO("Spark Flags: ", printBits(spark_flag).c_str());
|
// LOG_INFO("Spark Flags: ", printBits(spark_flag).c_str());
|
||||||
if (!names.contains(spark_flag))
|
LOG_INFO("Spark12:", ign_box_sts.coils12.spark_ok ? "TRUE" : "FALSE");
|
||||||
LOG_ERROR("No Spark");
|
LOG_INFO("Spark34:", ign_box_sts.coils34.spark_ok ? "TRUE" : "FALSE");
|
||||||
else
|
if (names.contains(spark_flag))
|
||||||
LOG_INFO("Spark Trigger:", names.at(spark_flag));
|
LOG_INFO("Spark Trigger:", names.at(spark_flag));
|
||||||
#endif
|
#endif
|
||||||
|
xTaskNotifyStateClear(NULL);
|
||||||
|
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)
|
||||||
@@ -147,15 +148,16 @@ 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->spark_time - coils->trig_time;
|
coils->spark_delay = coils->trig_time - coils->spark_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("Trigger Spark POSITIVE");
|
LOG_INFO("Spark on POSITIVE pulse");
|
||||||
LOG_INFO("Spark12 Delay Timer: ", (int)coils->spark_delay);
|
LOG_INFO("Spark Delay Timer: ", (int32_t)coils->spark_delay);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||||
@@ -164,33 +166,34 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
coils->spark_status = sparkStatus::SPARK_NEG_WAIT;
|
coils->spark_status = sparkStatus::SPARK_NEG_WAIT;
|
||||||
coils->sstart_status = softStartStatus::NORMAL;
|
coils->sstart_status = softStartStatus::NORMAL;
|
||||||
}
|
}
|
||||||
new_data = true;
|
new_data = false;
|
||||||
break; // Do nothing more on positive pulse
|
break; // Do nothing more on positive pulse
|
||||||
}
|
}
|
||||||
// CASES for NEGATIVE cycle triggering of pickup and sparks 12 & 34
|
// CASES for NEGATIVE cycle triggering of pickup and sparks 12 & 34
|
||||||
case TRIG_FLAG_12N:
|
case TRIG_FLAG_12N:
|
||||||
case TRIG_FLAG_34N:
|
case TRIG_FLAG_34N:
|
||||||
{
|
{
|
||||||
const bool expected_negative12 = coils->spark_status == sparkStatus::SPARK_NEG_WAIT;
|
LOG_INFO("NEGATIVE Edge");
|
||||||
|
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_negative12)
|
if (spark_flag != SPARK_FLAG_NIL && expected_negative)
|
||||||
{
|
{
|
||||||
coils->spark_delay = coils->spark_time - coils->trig_time;
|
coils->spark_delay = coils->trig_time - coils->spark_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("Trigger Spark NEGATIVE");
|
LOG_INFO("Spark on NEGATIVE pulse");
|
||||||
LOG_INFO("Spark12 Delay Timer: ", (int)ign_box_sts.coils12.spark_delay);
|
LOG_INFO("Spark Delay Timer: ", (int32_t)coils->spark_delay);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
// Timeout occourred, expected POSITIVE edge spark NOT OCCOURRED
|
||||||
else if (spark_flag == SPARK_FLAG_NIL && expected_negative12)
|
else if (spark_flag == SPARK_FLAG_NIL && expected_negative)
|
||||||
{
|
{
|
||||||
coils->sstart_status = softStartStatus::NORMAL;
|
coils->sstart_status = softStartStatus::NORMAL;
|
||||||
coils->spark_status = sparkStatus::SPARK_NEG_FAIL;
|
coils->spark_status = sparkStatus::SPARK_NEG_FAIL;
|
||||||
}
|
}
|
||||||
// Timeout not occouured, unexpected negative edge spark
|
// Timeout not occouured, unexpected negative edge spark
|
||||||
else if (spark_flag != SPARK_FLAG_NIL && !expected_negative12)
|
else if (spark_flag != SPARK_FLAG_NIL && !expected_negative)
|
||||||
{
|
{
|
||||||
coils->sstart_status = softStartStatus::SOFT_START;
|
coils->sstart_status = softStartStatus::SOFT_START;
|
||||||
coils->spark_status = sparkStatus::SPARK_NEG_UNEXPECTED;
|
coils->spark_status = sparkStatus::SPARK_NEG_UNEXPECTED;
|
||||||
@@ -210,8 +213,8 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
|
|
||||||
if (new_data)
|
if (new_data)
|
||||||
{
|
{
|
||||||
vTaskDelay(pdMS_TO_TICKS(1)); // delay 1ms to allow peak detectors to charge for negative cycle
|
// vTaskDelay(pdMS_TO_TICKS(1)); // delay 1ms to allow peak detectors to charge for negative cycle
|
||||||
// read adc channels: pickup12, out12 [ pos + neg ]
|
// read adc channels: pickup12, out12 [ pos + neg ]
|
||||||
if (adc) // read only if adc initialized
|
if (adc) // read only if adc initialized
|
||||||
{
|
{
|
||||||
// from peak detector circuits
|
// from peak detector circuits
|
||||||
@@ -225,7 +228,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
ign_box_sts.coils34.peak_n_out = adcReadChannel(adc, ADC_CH_PEAK_34N_OUT);
|
ign_box_sts.coils34.peak_n_out = adcReadChannel(adc, ADC_CH_PEAK_34N_OUT);
|
||||||
}
|
}
|
||||||
else // simulate adc read timig
|
else // simulate adc read timig
|
||||||
vTaskDelay(pdMS_TO_TICKS(6));
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
|
||||||
// reset peak detectors + sample and hold
|
// reset peak detectors + sample and hold
|
||||||
// outputs on io expander
|
// outputs on io expander
|
||||||
@@ -237,7 +240,7 @@ void rtIgnitionTask(void *pvParameters)
|
|||||||
io->write(iostat & ~rst_bitmask);
|
io->write(iostat & ~rst_bitmask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vTaskDelay(pdMS_TO_TICKS(2));
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
|
||||||
// send essage to main loop with ignition info, by copy so local static variable is ok
|
// send essage to main loop with ignition info, by copy so local static variable is ok
|
||||||
if (rt_queue)
|
if (rt_queue)
|
||||||
@@ -245,7 +248,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>
|
||||||
|
|||||||
@@ -15,6 +15,17 @@ static uint32_t count = 0;
|
|||||||
#define SPARK_DLY_MIN 10
|
#define SPARK_DLY_MIN 10
|
||||||
#define SPARK_DLY_MAX 490
|
#define SPARK_DLY_MAX 490
|
||||||
|
|
||||||
|
#define PAUSE_LONG_MIN 10000
|
||||||
|
#define PAUSE_LONG_MAX PAUSE_LONG_MIN*100
|
||||||
|
|
||||||
|
void clearScreen(){
|
||||||
|
Serial.print("\033[2J"); // clear screen
|
||||||
|
Serial.print("\033[H"); // cursor home
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
static double filtered = 0;
|
||||||
|
|
||||||
static const std::map<const uint32_t, const char *> pin2Name = {
|
static const std::map<const uint32_t, const char *> pin2Name = {
|
||||||
{PIN_TRIG_A12P, "HIGH_PIN_TRIG_A12P"},
|
{PIN_TRIG_A12P, "HIGH_PIN_TRIG_A12P"},
|
||||||
{~PIN_TRIG_A12P, "LOW_PIN_TRIG_A12P"},
|
{~PIN_TRIG_A12P, "LOW_PIN_TRIG_A12P"},
|
||||||
@@ -81,6 +92,13 @@ void loop()
|
|||||||
} else {
|
} else {
|
||||||
stsA.soft_start = false;
|
stsA.soft_start = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double new_val = (float)(map(analogRead(FREQ_POT), 0, 4096, PAUSE_LONG_MIN, PAUSE_LONG_MAX));
|
||||||
|
filtered = filtered + 0.1 * (new_val - filtered);
|
||||||
|
stsA.pause_long_us = (uint32_t)filtered;
|
||||||
LOG_INFO("Spark Delay uS: ", stsA.spark_delay_us, "\tSoft Start: ", stsA.soft_start ? "TRUE" : "FALSE");
|
LOG_INFO("Spark Delay uS: ", stsA.spark_delay_us, "\tSoft Start: ", stsA.soft_start ? "TRUE" : "FALSE");
|
||||||
delay(500);
|
LOG_INFO("Pause: ", (uint32_t)(stsA.pause_long_us / 1000), "ms");
|
||||||
|
|
||||||
|
delay(100);
|
||||||
|
clearScreen();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,3 +20,4 @@
|
|||||||
|
|
||||||
// Pot
|
// Pot
|
||||||
#define SPARK_DELAY_POT 12
|
#define SPARK_DELAY_POT 12
|
||||||
|
#define FREQ_POT 14
|
||||||
|
|||||||
Reference in New Issue
Block a user