auto-sync

This commit is contained in:
rusEfi 2014-11-23 22:03:16 -06:00
parent 138133c894
commit 0e2920efc7
8 changed files with 51 additions and 34 deletions

View File

@ -13,7 +13,7 @@
#define EFI_USE_CCM TRUE
#ifndef EFI_ENABLE_ASSERTS
#define EFI_ENABLE_ASSERTS TRUE
#define EFI_ENABLE_ASSERTS FALSE
#endif /* EFI_ENABLE_ASSERTS */
//#define EFI_UART_ECHO_TEST_MODE TRUE

View File

@ -25,12 +25,15 @@
#include "main.h"
#include "signal_executor.h"
#include "efiGpio.h"
#include "engine.h"
/**
* Signal executors feed digital events right into WaveChart used by Sniffer tab of Dev Console
*/
#include "rpm_calculator.h"
EXTERN_ENGINE;
#include "wave_chart.h"
extern WaveChart waveChart;
@ -38,6 +41,9 @@ extern WaveChart waveChart;
static Logging logger;
#endif
extern OutputPin outputs[IO_PIN_COUNT];
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
void initSignalExecutor(void) {
#if EFI_PROD_CODE || EFI_SIMULATOR
initLogging(&logger, "s exec");
@ -60,32 +66,25 @@ void turnPinHigh(io_pin_e pin) {
#endif /* EFI_DEFAILED_LOGGING */
// turn the output level ACTIVE
// todo: this XOR should go inside the setOutputPinValue method
setOutputPinValue(pin, TRUE);
doSetOutputPinValue(pin, true);
// sleep for the needed duration
#if EFI_PROD_CODE || EFI_SIMULATOR
// if (pin == SPARKOUT_1_OUTPUT || pin == SPARKOUT_3_OUTPUT) {
// time_t now = hTimeNow();
// float an = getCrankshaftAngle(now);
// scheduleMsg(&logger, "spark up%d %d", pin, now);
// scheduleMsg(&logger, "spark angle %d %f", (int)an, an);
// }
#endif
#if EFI_WAVE_CHART
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
const char *pinName = namedPinsArray[pin];
// explicit check here is a performance optimization to speed up no-chart mode
if (!engineConfiguration->isDigitalChartEnabled) {
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
const char *pinName = namedPinsArray[pin];
// dbgDurr = hal_lld_get_counter_value() - dbgStart;
addWaveChartEvent(pinName, WC_UP);
addWaveChartEvent(pinName, WC_UP);
}
#endif /* EFI_WAVE_ANALYZER */
// dbgDurr = hal_lld_get_counter_value() - dbgStart;
}
void turnPinLow(io_pin_e pin) {
// turn off the output
// todo: this XOR should go inside the setOutputPinValue method
setOutputPinValue(pin, false);
doSetOutputPinValue(pin, false);
#if EFI_DEFAILED_LOGGING
systime_t after = hTimeNow();
@ -94,10 +93,12 @@ void turnPinLow(io_pin_e pin) {
#endif /* EFI_DEFAILED_LOGGING */
#if EFI_WAVE_CHART
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
const char *pinName = namedPinsArray[pin];
if (!engineConfiguration->isDigitalChartEnabled) {
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
const char *pinName = namedPinsArray[pin];
addWaveChartEvent(pinName, WC_DOWN);
addWaveChartEvent(pinName, WC_DOWN);
}
#endif /* EFI_WAVE_ANALYZER */
}

View File

@ -64,6 +64,10 @@ static LEElementPool lePool(mainPool, LE_ELEMENT_POOL_SIZE);
static LEElement * fuelPumpLogic;
static LEElement * radiatorFanLogic;
extern OutputPin outputs[IO_PIN_COUNT];
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
persistent_config_container_s persistentState CCM_OPTIONAL;
/**

View File

@ -99,7 +99,7 @@ void onUnlockHook(void) {
if (t > maxLockTime) {
maxLockTime = t;
}
// if (t > 10000) {
// if (t > 2800) {
// // uncomment this if you want a nice stop for a breakpoint
// maxLockTime = t + 1;
// }

View File

@ -96,18 +96,7 @@ extern uint32_t dbgStart;
extern uint32_t dbgDurr;
void setOutputPinValue(io_pin_e pin, int logicValue) {
#if EFI_PROD_CODE
if (outputs[pin].port != GPIO_NULL) {
efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized");
pin_output_mode_e mode = *pinDefaultState[pin];
efiAssertVoid(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e");
#else
pin_output_mode_e mode = OM_DEFAULT;
#endif
OutputPin *output = &outputs[pin];
int eValue = getElectricalValue(logicValue, mode);
setPinValue(output, eValue, logicValue);
}
doSetOutputPinValue(pin, logicValue);
}
bool isPinAssigned(io_pin_e pin) {

View File

@ -79,6 +79,28 @@ void setOutputPinValue(io_pin_e pin, int logicValue);
bool isPinAssigned(io_pin_e pin);
const char *getPinName(io_pin_e io_pin);
#if EFI_PROD_CODE
#define doSetOutputPinValue(pin, logicValue) { \
if (outputs[(pin)].port != GPIO_NULL) { \
efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized"); \
pin_output_mode_e mode = *pinDefaultState[pin]; \
efiAssertVoid(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \
OutputPin *output = &outputs[pin]; \
int eValue = getElectricalValue(logicValue, mode); \
setPinValue(output, eValue, logicValue); \
} \
}
#else
#define doSetOutputPinValue(pin, logicValue) { \
pin_output_mode_e mode = OM_DEFAULT; \
OutputPin *output = &outputs[pin]; \
int eValue = getElectricalValue(logicValue, mode); \
setPinValue(output, eValue, logicValue); \
}
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -76,6 +76,7 @@ uint64_t EventQueue::getNextEventTime(uint64_t nowX) {
}
// static scheduling_s * longScheduling;
// static uint32_t cost;
/**
* Invoke all pending actions prior to specified timestamp
@ -111,7 +112,7 @@ bool EventQueue::executeAll(uint64_t now) {
// uint32_t before = hal_lld_get_counter_value();
current->callback(current->param);
// even with overflow it's safe to substract here
// uint32_t cost = hal_lld_get_counter_value() - before;
// cost = hal_lld_get_counter_value() - before;
// if (cost > 2000) {
// longScheduling = current;
// cost++;

View File

@ -2215,7 +2215,7 @@
<name>$PROJ_DIR$\..\controllers\algo\rusefi_enums.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\controllers\algo\signal_executor.c</name>
<name>$PROJ_DIR$\..\controllers\algo\signal_executor.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\controllers\algo\signal_executor.h</name>