auto-sync
This commit is contained in:
parent
055fe76dd2
commit
d576b87617
|
@ -57,10 +57,9 @@ void Engine::init() {
|
||||||
initLogging(&logger, "engine");
|
initLogging(&logger, "engine");
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool stopPin(io_pin_e pin) {
|
static bool stopPin(NamedOutputPin *output) {
|
||||||
NamedOutputPin *output = &outputs[(int)pin];
|
|
||||||
if (output->getLogicValue()) {
|
if (output->getLogicValue()) {
|
||||||
doSetOutputPinValue2(output, false);
|
output->setValue(false);
|
||||||
scheduleMsg(&logger, "turning off %s", output->name);
|
scheduleMsg(&logger, "turning off %s", output->name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -71,9 +70,9 @@ bool Engine::stopPins() {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||||
io_pin_e pin = (io_pin_e) ((int) INJECTOR_1_OUTPUT + i);
|
io_pin_e pin = (io_pin_e) ((int) INJECTOR_1_OUTPUT + i);
|
||||||
result |= stopPin(pin);
|
result |= stopPin(&outputs[(int)pin]);
|
||||||
pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + i);
|
pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + i);
|
||||||
result |= stopPin(pin);
|
result |= stopPin(&outputs[(int)pin]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
TriggerShape triggerShape;
|
TriggerShape triggerShape;
|
||||||
|
|
||||||
float angleExtra[IGNITION_PIN_COUNT];
|
float angleExtra[IGNITION_PIN_COUNT];
|
||||||
io_pin_e ignitionPin[IGNITION_PIN_COUNT];
|
NamedOutputPin *ignitionPin[IGNITION_PIN_COUNT];
|
||||||
|
|
||||||
void onTriggerEvent(uint64_t nowNt);
|
void onTriggerEvent(uint64_t nowNt);
|
||||||
EngineState engineState;
|
EngineState engineState;
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef struct {
|
||||||
typedef struct IgnitionEvent_struct IgnitionEvent;
|
typedef struct IgnitionEvent_struct IgnitionEvent;
|
||||||
|
|
||||||
struct IgnitionEvent_struct {
|
struct IgnitionEvent_struct {
|
||||||
io_pin_e io_pin;
|
NamedOutputPin *output;
|
||||||
scheduling_s signalTimerUp;
|
scheduling_s signalTimerUp;
|
||||||
scheduling_s signalTimerDown;
|
scheduling_s signalTimerDown;
|
||||||
event_trigger_position_s dwellPosition;
|
event_trigger_position_s dwellPosition;
|
||||||
|
|
|
@ -43,9 +43,50 @@ static Logging logger;
|
||||||
|
|
||||||
extern NamedOutputPin outputs[IO_PIN_COUNT];
|
extern NamedOutputPin outputs[IO_PIN_COUNT];
|
||||||
|
|
||||||
|
static const char *namedPinsArray[NAMED_PIN_COUNT] = { "spa1", "spa2", "spa3", "spa4", "spa5", "spa6", "spa7", "spa8",
|
||||||
|
"spa9", "spa10", "spa11", "spa12", "inj1", "inj2", "inj3", "inj4", "inj5", "inj6", "inj7", "inj8", "inj9",
|
||||||
|
"inj10", "inj11", "inj12", };
|
||||||
|
|
||||||
|
static const char *getPinName(io_pin_e io_pin) {
|
||||||
|
switch (io_pin) {
|
||||||
|
// todo: refactor this hell - introduce arrays & checks?
|
||||||
|
case SPARKOUT_1_OUTPUT:
|
||||||
|
case SPARKOUT_2_OUTPUT:
|
||||||
|
case SPARKOUT_3_OUTPUT:
|
||||||
|
case SPARKOUT_4_OUTPUT:
|
||||||
|
case SPARKOUT_5_OUTPUT:
|
||||||
|
case SPARKOUT_6_OUTPUT:
|
||||||
|
case SPARKOUT_7_OUTPUT:
|
||||||
|
case SPARKOUT_8_OUTPUT:
|
||||||
|
case SPARKOUT_9_OUTPUT:
|
||||||
|
case SPARKOUT_10_OUTPUT:
|
||||||
|
case SPARKOUT_11_OUTPUT:
|
||||||
|
case SPARKOUT_12_OUTPUT:
|
||||||
|
case INJECTOR_1_OUTPUT:
|
||||||
|
case INJECTOR_2_OUTPUT:
|
||||||
|
case INJECTOR_3_OUTPUT:
|
||||||
|
case INJECTOR_4_OUTPUT:
|
||||||
|
case INJECTOR_5_OUTPUT:
|
||||||
|
case INJECTOR_6_OUTPUT:
|
||||||
|
case INJECTOR_7_OUTPUT:
|
||||||
|
case INJECTOR_8_OUTPUT:
|
||||||
|
case INJECTOR_9_OUTPUT:
|
||||||
|
case INJECTOR_10_OUTPUT:
|
||||||
|
case INJECTOR_11_OUTPUT:
|
||||||
|
case INJECTOR_12_OUTPUT:
|
||||||
|
return namedPinsArray[io_pin];
|
||||||
|
default:
|
||||||
|
return "Pin needs name";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void initSignalExecutor(void) {
|
void initSignalExecutor(void) {
|
||||||
initLogging(&logger, "s exec");
|
initLogging(&logger, "s exec");
|
||||||
initSignalExecutorImpl();
|
initSignalExecutorImpl();
|
||||||
|
|
||||||
|
for (int i = 0; i < IO_PIN_COUNT;i++)
|
||||||
|
outputs[i].name = getPinName((io_pin_e)i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//uint32_t dbgStart;
|
//uint32_t dbgStart;
|
||||||
|
@ -77,6 +118,7 @@ void turnPinHigh(NamedOutputPin *output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnPinLow(NamedOutputPin *output) {
|
void turnPinLow(NamedOutputPin *output) {
|
||||||
|
efiAssertVoid(output!=NULL, "NULL turnPinLow");
|
||||||
#if EFI_GPIO
|
#if EFI_GPIO
|
||||||
// turn off the output
|
// turn off the output
|
||||||
doSetOutputPinValue2(output, false);
|
doSetOutputPinValue2(output, false);
|
||||||
|
|
|
@ -103,15 +103,15 @@ void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, IgnitionEven
|
||||||
|
|
||||||
for (int i = 0; i < CONFIG(cylindersCount); i++) {
|
for (int i = 0; i < CONFIG(cylindersCount); i++) {
|
||||||
float localAdvance = advance + ENGINE(angleExtra[i]);
|
float localAdvance = advance + ENGINE(angleExtra[i]);
|
||||||
io_pin_e pin = ENGINE(ignitionPin[i]);
|
NamedOutputPin *output = ENGINE(ignitionPin[i]);
|
||||||
|
|
||||||
IgnitionEvent *event = list->add();
|
IgnitionEvent *event = list->add();
|
||||||
|
|
||||||
if (!isPinAssigned(&outputs[(pin)])) {
|
if (!isPinAssigned(output)) {
|
||||||
// todo: extact method for this index math
|
// todo: extact method for this index math
|
||||||
warning(OBD_PCM_Processor_Fault, "no_pin_cl #%d", (int) pin - (int) SPARKOUT_1_OUTPUT + 1);
|
warning(OBD_PCM_Processor_Fault, "no_pin_cl #%s", output->name);
|
||||||
}
|
}
|
||||||
event->io_pin = pin;
|
event->output = output;
|
||||||
event->advance = localAdvance;
|
event->advance = localAdvance;
|
||||||
|
|
||||||
findTriggerPosition(&event->dwellPosition, localAdvance - dwellAngle PASS_ENGINE_PARAMETER);
|
findTriggerPosition(&event->dwellPosition, localAdvance - dwellAngle PASS_ENGINE_PARAMETER);
|
||||||
|
@ -296,26 +296,25 @@ int getCylinderId(firing_order_e firingOrder, int index) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
io_pin_e getIgnitionPinForIndex(int i DECLARE_ENGINE_PARAMETER_S) {
|
static NamedOutputPin * getIgnitionPinForIndex(int i DECLARE_ENGINE_PARAMETER_S) {
|
||||||
switch (CONFIG(ignitionMode)) {
|
switch (CONFIG(ignitionMode)) {
|
||||||
case IM_ONE_COIL:
|
case IM_ONE_COIL:
|
||||||
return SPARKOUT_1_OUTPUT;
|
return &outputs[(int)SPARKOUT_1_OUTPUT];
|
||||||
break;
|
break;
|
||||||
case IM_WASTED_SPARK: {
|
case IM_WASTED_SPARK: {
|
||||||
int wastedIndex = i % (CONFIG(cylindersCount) / 2);
|
int wastedIndex = i % (CONFIG(cylindersCount) / 2);
|
||||||
int id = getCylinderId(CONFIG(firingOrder), wastedIndex) - 1;
|
int id = getCylinderId(CONFIG(firingOrder), wastedIndex) - 1;
|
||||||
return (io_pin_e) (SPARKOUT_1_OUTPUT + id);
|
return &outputs[(int)(SPARKOUT_1_OUTPUT + id)];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IM_INDIVIDUAL_COILS:
|
case IM_INDIVIDUAL_COILS:
|
||||||
return (io_pin_e) ((int) SPARKOUT_1_OUTPUT + getCylinderId(CONFIG(firingOrder), i) - 1);
|
return &outputs[ ((int) SPARKOUT_1_OUTPUT + getCylinderId(CONFIG(firingOrder), i) - 1)];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
firmwareError("unsupported ignitionMode %d in initializeIgnitionActions()", engineConfiguration->ignitionMode);
|
firmwareError("unsupported ignitionMode %d in initializeIgnitionActions()", engineConfiguration->ignitionMode);
|
||||||
return SPARKOUT_1_OUTPUT;
|
return &outputs[(int)SPARKOUT_1_OUTPUT];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||||
|
|
|
@ -208,7 +208,7 @@ static ALWAYS_INLINE void handleSparkEvent(uint32_t eventIndex, IgnitionEvent *i
|
||||||
/**
|
/**
|
||||||
* The start of charge is always within the current trigger event range, so just plain time-based scheduling
|
* The start of charge is always within the current trigger event range, so just plain time-based scheduling
|
||||||
*/
|
*/
|
||||||
scheduleTask("spark up", sUp, sparkDelayUs, (schfunc_t) &turnPinHigh, &outputs[(int)iEvent->io_pin]);
|
scheduleTask("spark up", sUp, sparkDelayUs, (schfunc_t) &turnPinHigh, iEvent->output);
|
||||||
/**
|
/**
|
||||||
* Spark event is often happening during a later trigger event timeframe
|
* Spark event is often happening during a later trigger event timeframe
|
||||||
* TODO: improve precision
|
* TODO: improve precision
|
||||||
|
@ -222,7 +222,7 @@ static ALWAYS_INLINE void handleSparkEvent(uint32_t eventIndex, IgnitionEvent *i
|
||||||
*/
|
*/
|
||||||
float timeTillIgnitionUs = engine->rpmCalculator.oneDegreeUs * iEvent->sparkPosition.angleOffset;
|
float timeTillIgnitionUs = engine->rpmCalculator.oneDegreeUs * iEvent->sparkPosition.angleOffset;
|
||||||
|
|
||||||
scheduleTask("spark 1down", sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnPinLow, &outputs[(int)iEvent->io_pin]);
|
scheduleTask("spark 1down", sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnPinLow, iEvent->output);
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
* Spark should be scheduled in relation to some future trigger event, this way we get better firing precision
|
* Spark should be scheduled in relation to some future trigger event, this way we get better firing precision
|
||||||
|
@ -257,7 +257,7 @@ static ALWAYS_INLINE void handleSpark(uint32_t eventIndex, int rpm,
|
||||||
|
|
||||||
float timeTillIgnitionUs = engine->rpmCalculator.oneDegreeUs * current->sparkPosition.angleOffset;
|
float timeTillIgnitionUs = engine->rpmCalculator.oneDegreeUs * current->sparkPosition.angleOffset;
|
||||||
scheduleTask("spark 2down", sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnPinLow,
|
scheduleTask("spark 2down", sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnPinLow,
|
||||||
(void*) current->io_pin);
|
current->output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ static char timeBuffer[10];
|
||||||
* @brief Register an event for digital sniffer
|
* @brief Register an event for digital sniffer
|
||||||
*/
|
*/
|
||||||
void WaveChart::addWaveChartEvent3(const char *name, const char * msg) {
|
void WaveChart::addWaveChartEvent3(const char *name, const char * msg) {
|
||||||
|
efiAssertVoid(name!=NULL, "WC: NULL name");
|
||||||
if(!engineConfiguration->isDigitalChartEnabled) {
|
if(!engineConfiguration->isDigitalChartEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,61 +97,9 @@ void initPrimaryPins(void) {
|
||||||
outputPinRegister("LED_ERROR", &enginePins.errorLedPin, LED_ERROR_PORT, LED_ERROR_PIN);
|
outputPinRegister("LED_ERROR", &enginePins.errorLedPin, LED_ERROR_PORT, LED_ERROR_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getPinValue(const char *name) {
|
|
||||||
io_pin_e pin = getPinByName(name);
|
|
||||||
if (pin == IO_INVALID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OutputPin * outputPin = &outputs[pin];
|
|
||||||
int value = outputPin->getLogicValue();
|
|
||||||
scheduleMsg(&logger, "pin_value %s %d", name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *namedPinsArray[NAMED_PIN_COUNT] = { "spa1", "spa2", "spa3", "spa4", "spa5", "spa6", "spa7", "spa8",
|
|
||||||
"spa9", "spa10", "spa11", "spa12", "inj1", "inj2", "inj3", "inj4", "inj5", "inj6", "inj7", "inj8", "inj9",
|
|
||||||
"inj10", "inj11", "inj12", };
|
|
||||||
|
|
||||||
static const char *getPinName(io_pin_e io_pin) {
|
|
||||||
switch (io_pin) {
|
|
||||||
// todo: refactor this hell - introduce arrays & checks?
|
|
||||||
case SPARKOUT_1_OUTPUT:
|
|
||||||
case SPARKOUT_2_OUTPUT:
|
|
||||||
case SPARKOUT_3_OUTPUT:
|
|
||||||
case SPARKOUT_4_OUTPUT:
|
|
||||||
case SPARKOUT_5_OUTPUT:
|
|
||||||
case SPARKOUT_6_OUTPUT:
|
|
||||||
case SPARKOUT_7_OUTPUT:
|
|
||||||
case SPARKOUT_8_OUTPUT:
|
|
||||||
case SPARKOUT_9_OUTPUT:
|
|
||||||
case SPARKOUT_10_OUTPUT:
|
|
||||||
case SPARKOUT_11_OUTPUT:
|
|
||||||
case SPARKOUT_12_OUTPUT:
|
|
||||||
case INJECTOR_1_OUTPUT:
|
|
||||||
case INJECTOR_2_OUTPUT:
|
|
||||||
case INJECTOR_3_OUTPUT:
|
|
||||||
case INJECTOR_4_OUTPUT:
|
|
||||||
case INJECTOR_5_OUTPUT:
|
|
||||||
case INJECTOR_6_OUTPUT:
|
|
||||||
case INJECTOR_7_OUTPUT:
|
|
||||||
case INJECTOR_8_OUTPUT:
|
|
||||||
case INJECTOR_9_OUTPUT:
|
|
||||||
case INJECTOR_10_OUTPUT:
|
|
||||||
case INJECTOR_11_OUTPUT:
|
|
||||||
case INJECTOR_12_OUTPUT:
|
|
||||||
return namedPinsArray[io_pin];
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "Pin needs name";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void initOutputPins(void) {
|
void initOutputPins(void) {
|
||||||
initLogging(&logger, "io_pins");
|
initLogging(&logger, "io_pins");
|
||||||
|
|
||||||
for (int i = 0; i < IO_PIN_COUNT;i++)
|
|
||||||
outputs[i].name = getPinName((io_pin_e)i);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* want to make sure it's all zeros so that we can compare in initOutputPinExt() method
|
* want to make sure it's all zeros so that we can compare in initOutputPinExt() method
|
||||||
*/
|
*/
|
||||||
|
@ -210,8 +158,6 @@ void initOutputPins(void) {
|
||||||
ledRegister(LED_HUGE_19, GPIOE, 3);
|
ledRegister(LED_HUGE_19, GPIOE, 3);
|
||||||
ledRegister(LED_HUGE_20, GPIOE, 1);
|
ledRegister(LED_HUGE_20, GPIOE, 1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addConsoleActionS("get_pin_value", getPinValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_GPIO
|
#if EFI_GPIO
|
||||||
|
|
Loading…
Reference in New Issue