#pragma once
#include <Arduino.h>

// =====================
// UART DEBUG
// =====================
#define UART_TX 1     // TX0 (USB seriale)
#define UART_RX 3     // RX0


// =====================
// SPI BUS
// =====================
#define SPI_A_MOSI 23
#define SPI_A_MISO 19
#define SPI_A_SCK  18


// =====================
// I2C BUS
// =====================
#define SDA 21
#define SCL 22


// =====================
// ADC CONTROL (SPI + interrupt safe)
// =====================
#define ADC_A_CS   5    // chip select
#define ADC_A_DRDY 34   // input only + interrupt perfetto
#define ADC_A_RST  27   // output
#define ADC_A_SYNC 26   // output


// =====================
// DIGITAL OUT
// =====================
#define POT_A_CS 25
#define POT_B_CS 33


// =====================
// TRIGGER INPUT INTERRUPTS
// =====================
#define TRIG_PIN_A12P 35
#define TRIG_PIN_A12N 32
#define TRIG_PIN_A34P 39
#define TRIG_PIN_A34N 36


// =====================
// SPARK DETECT INTERRUPTS
// =====================
#define SPARK_PIN_A12 4
#define SPARK_PIN_A34 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

// --- RELAY ---
#define A_EXT_RELAY     8


// Init Pin Functions
inline void initTriggerPinsInputs()
{
    pinMode(TRIG_PIN_A12P, INPUT_PULLDOWN);
    pinMode(TRIG_PIN_A12N, INPUT_PULLDOWN);
    pinMode(TRIG_PIN_A34P, INPUT_PULLDOWN);
    pinMode(TRIG_PIN_A34N, INPUT_PULLDOWN);
}

inline void initSparkPinInputs()
{
    pinMode(SPARK_PIN_A12, INPUT_PULLDOWN);
    pinMode(SPARK_PIN_A34, INPUT_PULLDOWN);
}