From 575730a34054c54ec69a8590d9f099462af8f1a6 Mon Sep 17 00:00:00 2001 From: Emanuele Trabattoni Date: Thu, 9 Apr 2026 15:54:59 +0200 Subject: [PATCH] Finalized PINMAP --- RotaxMonitor/data/index.html | 4 +- RotaxMonitor/data/style.css | 4 +- RotaxMonitor/src/main.cpp | 9 ++-- RotaxMonitor/src/pins.h | 97 ++++++++++++++++++------------------ RotaxMonitor/src/tasks.cpp | 24 +-------- RotaxMonitor/src/tasks.h | 6 +-- 6 files changed, 61 insertions(+), 83 deletions(-) diff --git a/RotaxMonitor/data/index.html b/RotaxMonitor/data/index.html index e1bc07c..31c61bf 100644 --- a/RotaxMonitor/data/index.html +++ b/RotaxMonitor/data/index.html @@ -11,7 +11,9 @@ diff --git a/RotaxMonitor/data/style.css b/RotaxMonitor/data/style.css index 11dd233..47ab887 100644 --- a/RotaxMonitor/data/style.css +++ b/RotaxMonitor/data/style.css @@ -1,6 +1,6 @@ :root { --primary-dark: #0a1929; - --primary-blue: #0144a8; + --primary-blue: #003585; --accent-blue: #1e88e5; --light-bg: #f5f7fa; --border-color: #d0d6dd; @@ -38,7 +38,7 @@ body { } .page-header h1 { - margin: 0; + margin: 5px; font-size: 28px; font-weight: 600; } diff --git a/RotaxMonitor/src/main.cpp b/RotaxMonitor/src/main.cpp index 48af1a9..3157173 100644 --- a/RotaxMonitor/src/main.cpp +++ b/RotaxMonitor/src/main.cpp @@ -22,6 +22,7 @@ // #define CH_B_ENABLE #define TEST +// Debug Defines #define WIFI_SSID "AstroRotaxMonitor" #define WIFI_PASSWORD "maledettirotax" @@ -106,7 +107,7 @@ void loop() .trig_pin_34n = TRIG_PIN_A34N, .spark_pin_12 = SPARK_PIN_A12, .spark_pin_34 = SPARK_PIN_A34}, - .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_peak= RST_EXT_PEAK_DETECT, .rst_io_sh = RST_EXT_SAMPLE_HOLD}}; if (!rt_taskA_queue || !rt_taskB_queue) { @@ -143,7 +144,7 @@ void loop() SPIClass SPI_A(FSPI); spiA_ok = SPI_A.begin(SPI_A_SCK, SPI_A_MISO, SPI_A_MOSI); SPI_A.setDataMode(SPI_MODE1); // ADS1256 requires SPI mode 1 -#ifndef TEST +#ifdef CH_B_ENABLE SPIClass SPI_B(HSPI); spiB_ok = SPI_B.begin(SPI_B_SCK, SPI_B_MISO, SPI_B_MOSI); SPI_B.setDataMode(SPI_MODE1); // ADS1256 requires SPI mode 1 @@ -158,12 +159,12 @@ void loop() LOG_DEBUG("Init SPI OK"); // Init ADC_A - dev.adc_a = new ADS1256(ADC_A_DRDY, ADS1256::PIN_UNUSED, ADC_A_SYNC, ADC_A_CS, 2.5, &SPI_A); + dev.adc_a = new ADS1256(ADC_A_DRDY, ADS1256::PIN_UNUSED, ADS1256::PIN_UNUSED, ADC_A_CS, 2.5, &SPI_A); dev.adc_a->InitializeADC(); dev.adc_a->setPGA(PGA_1); dev.adc_a->setDRATE(DRATE_7500SPS); -#ifndef TEST +#ifdef CH_B_ENABLE // 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(); diff --git a/RotaxMonitor/src/pins.h b/RotaxMonitor/src/pins.h index 62a3ded..f5477eb 100644 --- a/RotaxMonitor/src/pins.h +++ b/RotaxMonitor/src/pins.h @@ -4,19 +4,19 @@ // ===================== // USB (RISERVATA) // ===================== -#define USB_DM 19 -#define USB_DP 20 +#define USB_DM 19 +#define USB_DP 20 // ===================== // UART DEBUG (RISERVATA) // ===================== -#define UART_TX 43 -#define UART_RX 44 +#define UART_TX 43 +#define UART_RX 44 // ===================== // RGB Led // ===================== -#define LED 48 +#define LED 48 // ===================== // STRAPPING CRITICI (NON USARE) @@ -26,85 +26,84 @@ // ===================== // SPI BUS ADC1 (VSPI) // ===================== -#define SPI_A_MOSI 11 -#define SPI_A_MISO 13 -#define SPI_A_SCK 12 +#define SPI_A_MOSI 10 +#define SPI_A_SCK 11 +#define SPI_A_MISO 12 // ===================== // SPI BUS ADC2 (HSPI) // ===================== -#define SPI_B_MOSI 35 -#define SPI_B_MISO 37 -#define SPI_B_SCK 36 +#define SPI_B_MOSI 36 +#define SPI_B_SCK 37 +#define SPI_B_MISO 38 // ===================== // I2C BUS (PCA9555) // ===================== -#define SDA 8 -#define SCL 9 +#define SDA 8 +#define SCL 9 +#define I2C_INT 17 // ===================== // ADC CONTROL // ===================== -#define ADC_A_CS 4 -#define ADC_A_DRDY 5 -#define ADC_A_SYNC 6 +#define ADC_A_CS 14 +#define ADC_A_DRDY 13 -#define ADC_B_CS 14 -#define ADC_B_DRDY 15 -#define ADC_B_SYNC 16 +#define ADC_B_CS 21 +#define ADC_B_DRDY 47 // ===================== // DIGITAL POT // ===================== -#define POT_A_CS 7 -#define POT_B_CS 17 +#define POT_A_CS 18 +#define POT_B_CS 35 // ===================== // TRIGGER INPUT INTERRUPTS // ===================== -#define TRIG_PIN_A12P 18 -#define TRIG_PIN_A12N 21 -#define TRIG_PIN_A34P 1 -#define TRIG_PIN_A34N 2 -#define TRIG_PIN_B12P 38 -#define TRIG_PIN_B12N 39 -#define TRIG_PIN_B34P 40 -#define TRIG_PIN_B34N 41 +#define TRIG_PIN_A12P 6 +#define TRIG_PIN_A12N 7 +#define TRIG_PIN_A34P 15 +#define TRIG_PIN_A34N 16 +#define TRIG_PIN_B12P 42 +#define TRIG_PIN_B12N 41 +#define TRIG_PIN_B34P 40 +#define TRIG_PIN_B34N 39 // ===================== // SPARK DETECT INPUTS // ===================== -#define SPARK_PIN_A12 42 -#define SPARK_PIN_A34 45 // OK (strapping ma consentito) 45 -#define SPARK_PIN_B12 46 // OK (strapping ma consentito) 46 -#define SPARK_PIN_B34 47 +#define SPARK_PIN_A12 4 +#define SPARK_PIN_A34 5 +#define SPARK_PIN_B12 1 +#define SPARK_PIN_B34 2 // ===================== // PCA9555 (I2C EXPANDER) // ===================== // --- RESET LINES --- -#define RST_EXT_A12P 0 -#define RST_EXT_A12N 1 -#define RST_EXT_A34P 2 -#define RST_EXT_A34N 3 -#define RST_EXT_B12P 4 -#define RST_EXT_B12N 5 -#define RST_EXT_B34P 6 -#define RST_EXT_B34N 7 +#define RST_EXT_PEAK_DETECT 0 +#define RST_EXT_SAMPLE_HOLD 1 +#define BTN_1 2 +#define BTN_2 3 +#define BTN_3 4 +#define BTN_4 5 +#define BTN_5 6 +#define BTN_6 7 // --- RELAY --- -#define A_EXT_RELAY 8 -#define B_EXT_RELAY 9 +#define A_EXT_RELAY 8 +#define B_EXT_RELAY 9 // --- STATUS / BUTTON --- -#define BTN_3 10 -#define BTN_4 11 -#define STA_1 12 -#define STA_2 13 -#define STA_3 14 -#define STA_4 15 +#define BTN_7 10 +#define BTN_8 11 +#define STA_1 12 +#define STA_2 13 +#define STA_3 14 +#define STA_4 15 // Init Pin Functions inline void initTriggerPinsInputs() diff --git a/RotaxMonitor/src/tasks.cpp b/RotaxMonitor/src/tasks.cpp index 45a9aa0..8bbc8f2 100644 --- a/RotaxMonitor/src/tasks.cpp +++ b/RotaxMonitor/src/tasks.cpp @@ -78,13 +78,6 @@ void rtIgnitionTask(void *pvParameters) LOG_INFO("rtTask ISR Attach OK"); - // Compute Reset Pin Bitmask - const uint16_t rst_bitmask = (1 << rt_rst.rst_io_12p) | - (1 << rt_rst.rst_io_12n) | - (1 << rt_rst.rst_io_34p) | - (1 << rt_rst.rst_io_34n); - - LOG_WARN("rtTask Init Correct"); // Global rt_task_ptr variables bool first_cycle = true; bool cycle12 = false; @@ -107,22 +100,6 @@ void rtIgnitionTask(void *pvParameters) if (first_cycle && pickup_flag != TRIG_FLAG_12P) // skip first cycle because of possible initial noise on pickup signals at startu continue; -#ifdef DEBUG - Serial.print("\033[2J"); // clear screen - Serial.print("\033[H"); // cursor home - - if (!names.contains(pickup_flag)) - { - LOG_ERROR("Wrong Pickup Flag"); - LOG_ERROR("Pickup Flags: ", printBits(pickup_flag).c_str()); - continue; - } - else - { - LOG_INFO("Pickup Trigger: ", names.at(pickup_flag)); - } -#endif - // Start microsecond precision timeout timer esp_timer_stop(timeout_timer); // stop timer in case it was running from previous cycle esp_timer_start_once(timeout_timer, spark_timeout_max); @@ -257,6 +234,7 @@ void rtIgnitionTask(void *pvParameters) if (io) { const uint16_t iostat = io->read(); + const uint16_t rst_bitmask = (0x0001 << rt_rst.rst_io_peak); io->write(iostat | rst_bitmask); vTaskDelay(pdMS_TO_TICKS(1)); io->write(iostat & ~rst_bitmask); diff --git a/RotaxMonitor/src/tasks.h b/RotaxMonitor/src/tasks.h index c1196eb..e5152ec 100644 --- a/RotaxMonitor/src/tasks.h +++ b/RotaxMonitor/src/tasks.h @@ -46,10 +46,8 @@ struct rtTaskInterrupts // RT Task Peak Detector Reset pins struct rtTaskResets { - const uint8_t rst_io_12p; - const uint8_t rst_io_12n; - const uint8_t rst_io_34p; - const uint8_t rst_io_34n; + const uint8_t rst_io_peak; + const uint8_t rst_io_sh; }; // RT task parameters