66 lines
1.4 KiB
C++
66 lines
1.4 KiB
C++
#pragma once
|
|
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
|
|
|
|
// Serial debug flag
|
|
//#define DEBUG
|
|
|
|
// Arduino Libraries
|
|
#include <Arduino.h>
|
|
#include <DebugLog.h>
|
|
#include "utils.h"
|
|
|
|
// ISR
|
|
#include "isr.h"
|
|
|
|
// DEVICES
|
|
#include "devices.h"
|
|
|
|
// Global Variables and Flags
|
|
const uint8_t spark_timeout_max = 1; // in milliseconds
|
|
|
|
// Debug Variables
|
|
#ifdef DEBUG
|
|
static const std::map<const uint32_t, const char *> names = {
|
|
{TRIG_FLAG_12P, "TRIG_FLAG_12P"},
|
|
{TRIG_FLAG_12N, "TRIG_FLAG_12N"},
|
|
{TRIG_FLAG_34P, "TRIG_FLAG_34P"},
|
|
{TRIG_FLAG_34N, "TRIG_FLAG_34N"},
|
|
{SPARK_FLAG_12, "SPARK_FLAG_12"},
|
|
{SPARK_FLAG_34, "SPARK_FLAG_34"},
|
|
};
|
|
#endif
|
|
|
|
// RT task Interrupt parameters
|
|
struct rtTaskInterrupts
|
|
{
|
|
void (*isr_ptr)(void *);
|
|
const uint8_t trig_pin_12p;
|
|
const uint8_t trig_pin_12n;
|
|
const uint8_t trig_pin_34p;
|
|
const uint8_t trig_pin_34n;
|
|
const uint8_t spark_pin_12;
|
|
const uint8_t spark_pin_34;
|
|
};
|
|
|
|
// 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;
|
|
};
|
|
|
|
// RT task parameters
|
|
struct rtTaskParams
|
|
{
|
|
bool rt_running; // run flag, false to terminate
|
|
Devices *dev;
|
|
TaskHandle_t* rt_handle_ptr;
|
|
const QueueHandle_t rt_queue;
|
|
const rtTaskInterrupts rt_int; // interrupt pins to attach
|
|
const rtTaskResets rt_resets; // reset ping for peak detectors
|
|
};
|
|
|
|
void rtIgnitionTask(void *pvParameters);
|