53 lines
1002 B
C
53 lines
1002 B
C
#pragma once
|
|
|
|
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
|
|
|
|
#include <Arduino.h>
|
|
#include <DebugLog.h>
|
|
#include "pins.h"
|
|
|
|
#include "driver/gpio.h"
|
|
|
|
enum State
|
|
{
|
|
S_12P,
|
|
S_12N_DELAY,
|
|
S_12N,
|
|
S_WAIT_10MS,
|
|
S_34P,
|
|
S_34N_DELAY,
|
|
S_34N,
|
|
S_WAIT_1MS,
|
|
S_WAIT_10MS_END
|
|
};
|
|
|
|
struct timerPins {
|
|
const uint8_t pin_trig_12p;
|
|
const uint8_t pin_trig_12n;
|
|
const uint8_t pin_trig_34p;
|
|
const uint8_t pin_trig_34n;
|
|
const uint8_t pin_spark_12;
|
|
const uint8_t pin_spark_34;
|
|
};
|
|
|
|
struct timerStatus
|
|
{
|
|
State state = State::S_12P;
|
|
uint32_t state_time = 0;
|
|
uint32_t clock_period_us;
|
|
uint32_t pause_long_us;
|
|
uint32_t pause_short_us;
|
|
uint32_t coil_pulse_us;
|
|
uint32_t spark_pulse_us;
|
|
uint32_t spark_delay_us;
|
|
bool soft_start = false;
|
|
bool coil12p_high = false;
|
|
bool coil34p_high = false;
|
|
bool coil12n_high = false;
|
|
bool coil34n_high = false;
|
|
timerPins pins;
|
|
TaskHandle_t main_task;
|
|
};
|
|
|
|
void IRAM_ATTR onTimer(void *arg);
|