auto-sync
This commit is contained in:
parent
5ff80d01d6
commit
8283186729
|
@ -78,7 +78,6 @@ static volatile bool fullLog = true;
|
|||
int warningEnabled = true;
|
||||
//int warningEnabled = FALSE;
|
||||
|
||||
extern board_configuration_s *boardConfiguration;
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
#define FULL_LOGGING_KEY "fl"
|
||||
|
||||
|
|
|
@ -153,15 +153,52 @@ static void initTemperatureCurve(int size, float *bins, float *values) {
|
|||
}
|
||||
|
||||
void prepareVoidConfiguration(engine_configuration_s *activeConfiguration) {
|
||||
memset(activeConfiguration, 0xFF, sizeof(engine_configuration_s));
|
||||
memset(activeConfiguration, 0, sizeof(engine_configuration_s));
|
||||
board_configuration_s *boardConfiguration = &activeConfiguration->bc;
|
||||
|
||||
/**
|
||||
* -1 everywhere is probably good, but explicit values are probably better. Too bad GPIO_UNASSIGNED is not zero :(
|
||||
*/
|
||||
boardConfiguration->triggerInputPins[0] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED;
|
||||
|
||||
for (int i = 0; i < JOYSTICK_PIN_COUNT; i++) {
|
||||
boardConfiguration->joystickPins[i] = GPIO_UNASSIGNED;
|
||||
}
|
||||
|
||||
boardConfiguration->acRelayPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->acRelayPinMode = OM_DEFAULT;
|
||||
|
||||
boardConfiguration->alternatorControlPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->alternatorControlPinMode = OM_DEFAULT;
|
||||
boardConfiguration->mainRelayPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->mainRelayPinMode = OM_DEFAULT;
|
||||
boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->idle.solenoidPinMode = OM_DEFAULT;
|
||||
boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->fuelPumpPinMode = OM_DEFAULT;
|
||||
boardConfiguration->electronicThrottlePin1 = GPIO_UNASSIGNED;
|
||||
boardConfiguration->o2heaterPin = GPIO_UNASSIGNED;
|
||||
|
||||
boardConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT;
|
||||
|
||||
boardConfiguration->fanPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->fanPinMode = OM_DEFAULT;
|
||||
|
||||
boardConfiguration->clutchDownPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->clutchDownPinMode = PI_PULLUP;
|
||||
boardConfiguration->clutchUpPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->clutchUpPinMode = PI_PULLUP;
|
||||
|
||||
for (int i = 0;i < INJECTION_PIN_COUNT;i++) {
|
||||
boardConfiguration->injectionPins[i] = GPIO_UNASSIGNED;
|
||||
}
|
||||
boardConfiguration->injectionPinMode = OM_DEFAULT;
|
||||
|
||||
for (int i = 0;i < IGNITION_PIN_COUNT;i++) {
|
||||
boardConfiguration->ignitionPins[i] = GPIO_UNASSIGNED;
|
||||
}
|
||||
boardConfiguration->ignitionPinMode = OM_DEFAULT;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,9 +207,8 @@ void prepareVoidConfiguration(engine_configuration_s *activeConfiguration) {
|
|||
* and the settings saves in flash memory.
|
||||
*/
|
||||
void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||
// technically these regions currently overlap, but I will reset all individually for readability
|
||||
memset(engineConfiguration, 0, sizeof(engine_configuration_s));
|
||||
memset(boardConfiguration, 0, sizeof(board_configuration_s));
|
||||
prepareVoidConfiguration(engineConfiguration);
|
||||
|
||||
#if ! EFI_UNIT_TEST
|
||||
memset(&persistentState.persistentConfiguration, 0, sizeof(persistentState.persistentConfiguration));
|
||||
#endif
|
||||
|
@ -395,12 +431,6 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
|||
// engineConfiguration->idleMode = IM_AUTO;
|
||||
engineConfiguration->idleMode = IM_MANUAL;
|
||||
|
||||
boardConfiguration->acRelayPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->acRelayPinMode = OM_DEFAULT;
|
||||
|
||||
boardConfiguration->alternatorControlPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->alternatorControlPinMode = OM_DEFAULT;
|
||||
|
||||
engineConfiguration->acSwitchAdc = EFI_ADC_NONE;
|
||||
|
||||
engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE;
|
||||
|
@ -460,58 +490,6 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
|||
boardConfiguration->fsioDigitalInputs[i] = GPIO_UNASSIGNED;
|
||||
engineConfiguration->fsioInputModes[i] = PI_DEFAULT;
|
||||
}
|
||||
for (int i = 0; i < JOYSTICK_PIN_COUNT; i++) {
|
||||
boardConfiguration->joystickPins[i] = GPIO_UNASSIGNED;
|
||||
}
|
||||
|
||||
boardConfiguration->mainRelayPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->mainRelayPinMode = OM_DEFAULT;
|
||||
boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->idle.solenoidPinMode = OM_DEFAULT;
|
||||
boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->fuelPumpPinMode = OM_DEFAULT;
|
||||
boardConfiguration->electronicThrottlePin1 = GPIO_UNASSIGNED;
|
||||
boardConfiguration->o2heaterPin = GPIO_UNASSIGNED;
|
||||
|
||||
boardConfiguration->injectionPins[0] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[1] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[3] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[4] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[5] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[6] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[7] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[8] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[9] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[10] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPins[11] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->injectionPinMode = OM_DEFAULT;
|
||||
|
||||
|
||||
boardConfiguration->ignitionPins[0] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[1] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[2] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[3] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[4] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[5] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[6] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[7] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[8] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[9] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[10] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPins[11] = GPIO_UNASSIGNED;
|
||||
boardConfiguration->ignitionPinMode = OM_DEFAULT;
|
||||
|
||||
boardConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT;
|
||||
|
||||
boardConfiguration->fanPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->fanPinMode = OM_DEFAULT;
|
||||
|
||||
boardConfiguration->clutchDownPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->clutchDownPinMode = PI_PULLUP;
|
||||
boardConfiguration->clutchUpPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->clutchUpPinMode = PI_PULLUP;
|
||||
|
||||
boardConfiguration->triggerSimulatorPins[0] = GPIOD_1;
|
||||
boardConfiguration->triggerSimulatorPins[1] = GPIOD_2;
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
#define GPIO_NULL NULL
|
||||
|
||||
#define ENGINE_CHANNEL_COUNT 12
|
||||
|
||||
typedef enum {
|
||||
INJECTOR_1,
|
||||
INJECTOR_2,
|
||||
|
|
|
@ -43,17 +43,18 @@ extern WaveChart waveChart;
|
|||
|
||||
extern engine_pins_s enginePins;
|
||||
|
||||
static const char *sparkNames[ENGINE_CHANNEL_COUNT] = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8",
|
||||
static const char *sparkNames[IGNITION_PIN_COUNT] = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8",
|
||||
"c9", "cA", "cB", "cD"};
|
||||
|
||||
static const char *injectorNames[ENGINE_CHANNEL_COUNT] = { "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8",
|
||||
static const char *injectorNames[INJECTION_PIN_COUNT] = { "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8",
|
||||
"j9", "iA", "iB", "iC"};
|
||||
|
||||
void initSignalExecutor(void) {
|
||||
initSignalExecutorImpl();
|
||||
|
||||
for (int i = 0; i < ENGINE_CHANNEL_COUNT;i++) {
|
||||
for (int i = 0; i < IGNITION_PIN_COUNT;i++) {
|
||||
enginePins.coils[i].name = sparkNames[i];
|
||||
}
|
||||
for (int i = 0; i < INJECTION_PIN_COUNT;i++) {
|
||||
enginePins.injectors[i].name = injectorNames[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -532,7 +532,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) {
|
|||
chThdCreateStatic(csThreadStack, sizeof(csThreadStack), LOWPRIO, (tfunc_t) csThread, NULL);
|
||||
|
||||
#if (EFI_PROD_CODE && EFI_ENGINE_CONTROL) || defined(__DOXYGEN__)
|
||||
initInjectorCentral(engine);
|
||||
initInjectorCentral();
|
||||
initIgnitionCentral();
|
||||
/**
|
||||
* This has to go after 'initInjectorCentral' and 'initInjectorCentral' in order to
|
||||
|
|
|
@ -214,20 +214,38 @@ static msg_t benchThread(int param) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void initInjectorCentral(Engine *engine) {
|
||||
extern engine_configuration_s *activeConfiguration;
|
||||
|
||||
void stopInjectionPins(void) {
|
||||
for (int i = 0; i < INJECTION_PIN_COUNT; i++) {
|
||||
NamedOutputPin *output = &enginePins.injectors[i];
|
||||
if (engineConfiguration->bc.injectionPins[i] != activeConfiguration->bc.injectionPins[i]) {
|
||||
// unmarkPin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void startInjectionPins(void) {
|
||||
// todo: should we move this code closer to the injection logic?
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
NamedOutputPin *output = &enginePins.injectors[i];
|
||||
if (engineConfiguration->bc.injectionPins[i] != activeConfiguration->bc.injectionPins[i]) {
|
||||
|
||||
outputPinRegisterExt2(output->name, output, boardConfiguration->injectionPins[i],
|
||||
&boardConfiguration->injectionPinMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void initInjectorCentral(void) {
|
||||
chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL);
|
||||
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
is_injector_enabled[i] = true;
|
||||
}
|
||||
|
||||
// todo: should we move this code closer to the injection logic?
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
NamedOutputPin *output = &enginePins.injectors[i];
|
||||
startInjectionPins();
|
||||
|
||||
outputPinRegisterExt2(output->name, output, boardConfiguration->injectionPins[i],
|
||||
&boardConfiguration->injectionPinMode);
|
||||
}
|
||||
|
||||
printStatus();
|
||||
addConsoleActionII("injector", setInjectorEnabled);
|
||||
|
|
|
@ -16,10 +16,16 @@
|
|||
|
||||
void fanBench(void);
|
||||
void fuelPumpBench(void);
|
||||
void initInjectorCentral(Engine *engine);
|
||||
void initInjectorCentral(void);
|
||||
void initIgnitionCentral(void);
|
||||
bool_t isRunningBenchTest(void);
|
||||
int isInjectorEnabled(int cylinderId);
|
||||
void assertCylinderId(int cylinderId, const char *msg);
|
||||
|
||||
void stopInjectionPins(void);
|
||||
void startInjectionPins(void);
|
||||
|
||||
void stopIgnitionPins(void);
|
||||
void startIgnitionPins(void);
|
||||
|
||||
#endif /* INJECTOR_CENTRAL_H_ */
|
||||
|
|
|
@ -53,8 +53,8 @@ typedef struct {
|
|||
// OutputPin alternatorField;
|
||||
OutputPin errorLedPin;
|
||||
|
||||
NamedOutputPin injectors[ENGINE_CHANNEL_COUNT];
|
||||
NamedOutputPin coils[ENGINE_CHANNEL_COUNT];
|
||||
NamedOutputPin injectors[INJECTION_PIN_COUNT];
|
||||
NamedOutputPin coils[IGNITION_PIN_COUNT];
|
||||
} engine_pins_s;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "adc_inputs.h"
|
||||
#include "can_hw.h"
|
||||
#include "console_io.h"
|
||||
#include "hardware.h"
|
||||
#include "pin_repository.h"
|
||||
#include "io_pins.h"
|
||||
#include "pin_repository.h"
|
||||
#include "rtc_helper.h"
|
||||
#include "rfiutil.h"
|
||||
#include "console_io.h"
|
||||
|
||||
#include "adc_inputs.h"
|
||||
#include "injector_central.h"
|
||||
#include "vehicle_speed.h"
|
||||
|
||||
#include "trigger_input.h"
|
||||
#include "eficonsole.h"
|
||||
#include "max31855.h"
|
||||
#include "can_hw.h"
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#include "AdcConfiguration.h"
|
||||
|
@ -196,13 +196,20 @@ void turnOnHardware(Logging *sharedLogger) {
|
|||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
}
|
||||
|
||||
void applyNewHardwareSettings(engine_configuration_s *oldConfiguration) {
|
||||
extern engine_configuration_s activeConfiguration;
|
||||
|
||||
void applyNewHardwareSettings(void) {
|
||||
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
||||
applyNewTriggerInputPins(oldConfiguration);
|
||||
applyNewTriggerInputPins();
|
||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
stopInjectionPins();
|
||||
stopIgnitionPins();
|
||||
|
||||
startInjectionPins();
|
||||
startIgnitionPins();
|
||||
}
|
||||
|
||||
void initHardware(Logging *l, Engine *engine) {
|
||||
void initHardware(Logging *l) {
|
||||
sharedLogger = l;
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
efiAssertVoid(engineConfiguration!=NULL, "engineConfiguration");
|
||||
|
|
|
@ -44,8 +44,8 @@ void unlockSpi(void);
|
|||
|
||||
#if EFI_PROD_CODE
|
||||
#include "engine.h"
|
||||
void applyNewHardwareSettings(engine_configuration_s *oldConfiguration);
|
||||
void initHardware(Logging *logging, Engine *engine);
|
||||
void applyNewHardwareSettings(void);
|
||||
void initHardware(Logging *logging);
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -111,21 +111,27 @@ void turnOnTriggerInputPins(Logging *sharedLogger) {
|
|||
rememberPrimaryChannel();
|
||||
}
|
||||
|
||||
void applyNewTriggerInputPins(engine_configuration_s *oldConfiguration) {
|
||||
// first we will turn off all the changed pins
|
||||
extern engine_configuration_s activeConfiguration;
|
||||
|
||||
void stopTriggerInputPins(void) {
|
||||
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
|
||||
if (boardConfiguration->triggerInputPins[i] != oldConfiguration->bc.triggerInputPins[i]) {
|
||||
turnOffTriggerInputPin(oldConfiguration->bc.triggerInputPins[i]);
|
||||
if (boardConfiguration->triggerInputPins[i] != activeConfiguration.bc.triggerInputPins[i]) {
|
||||
turnOffTriggerInputPin(activeConfiguration.bc.triggerInputPins[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void applyNewTriggerInputPins(void) {
|
||||
// first we will turn off all the changed pins
|
||||
stopTriggerInputPins();
|
||||
|
||||
// then we will enable all the changed pins
|
||||
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
|
||||
if (boardConfiguration->triggerInputPins[i] != oldConfiguration->bc.triggerInputPins[i]) {
|
||||
if (boardConfiguration->triggerInputPins[i] != activeConfiguration.bc.triggerInputPins[i]) {
|
||||
turnOnTriggerInputPin(boardConfiguration->triggerInputPins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
turnOffTriggerInputPin(oldConfiguration->bc.triggerInputPins[1]);
|
||||
rememberPrimaryChannel();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
#include "engine.h"
|
||||
|
||||
void turnOnTriggerInputPins(Logging *sharedLogger);
|
||||
void applyNewTriggerInputPins(engine_configuration_s *oldConfiguration);
|
||||
void applyNewTriggerInputPins(void);
|
||||
|
||||
#endif /* CRANK_INPUT_H_ */
|
||||
|
|
|
@ -168,14 +168,14 @@ void swo_init() {
|
|||
// *((volatile unsigned *)(ITM_BASE + 0x40304)) = 0x00000100; // Formatter and Flush Control Register
|
||||
}
|
||||
|
||||
static engine_configuration_s activeConfiguration;
|
||||
engine_configuration_s activeConfiguration;
|
||||
|
||||
static void rememberCurrentConfiguration(void) {
|
||||
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
||||
}
|
||||
|
||||
void applyNewConfiguration() {
|
||||
applyNewHardwareSettings(&activeConfiguration);
|
||||
applyNewHardwareSettings();
|
||||
}
|
||||
|
||||
void runRusEfi(void) {
|
||||
|
@ -208,7 +208,7 @@ void runRusEfi(void) {
|
|||
/**
|
||||
* Initialize hardware drivers
|
||||
*/
|
||||
initHardware(&sharedLogger, engine);
|
||||
initHardware(&sharedLogger);
|
||||
|
||||
initStatusLoop(engine);
|
||||
/**
|
||||
|
@ -290,5 +290,5 @@ int getRusEfiVersion(void) {
|
|||
return 123; // this is here to make the compiler happy about the unused array
|
||||
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||
return 3211; // this is here to make the compiler happy about the unused array
|
||||
return 20150514;
|
||||
return 20150517;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue