mirror of https://github.com/rusefi/rusefi-1.git
refactoring
This commit is contained in:
parent
5c0be05378
commit
9d372a29d1
|
@ -272,23 +272,25 @@ static const char *getGpioPinName(int index) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
if (fsioLogics[index] == NULL) {
|
||||||
|
warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(boardConfiguration->fsioOutputPins[index]));
|
||||||
|
return NAN;
|
||||||
|
} else {
|
||||||
|
return calc.getValue2(engine->fsioLastValue[index], fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param index from zero for (FSIO_COMMAND_COUNT - 1)
|
* @param index from zero for (FSIO_COMMAND_COUNT - 1)
|
||||||
*/
|
*/
|
||||||
static void handleFsio(Engine *engine, int index) {
|
static void handleFsio(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
if (boardConfiguration->fsioOutputPins[index] == GPIO_UNASSIGNED)
|
if (boardConfiguration->fsioOutputPins[index] == GPIO_UNASSIGNED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool isPwmMode = boardConfiguration->fsioFrequency[index] != NO_PWM;
|
bool isPwmMode = boardConfiguration->fsioFrequency[index] != NO_PWM;
|
||||||
|
|
||||||
float fvalue;
|
engine->fsioLastValue[index] = getFsioOutputValue(index PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
if (fsioLogics[index] == NULL) {
|
|
||||||
warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(boardConfiguration->fsioOutputPins[index]));
|
|
||||||
fvalue = NAN;
|
|
||||||
} else {
|
|
||||||
fvalue = calc.getValue2(engine->fsioLastValue[index], fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX);
|
|
||||||
}
|
|
||||||
engine->fsioLastValue[index] = fvalue;
|
|
||||||
|
|
||||||
if (isPwmMode) {
|
if (isPwmMode) {
|
||||||
fsioPwm[index].setSimplePwmDutyCycle(fvalue);
|
fsioPwm[index].setSimplePwmDutyCycle(fvalue);
|
||||||
|
@ -365,9 +367,12 @@ static void setFsioFrequency(int index, int frequency) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runFsio(void) {
|
/**
|
||||||
for (int i = 0; i < FSIO_COMMAND_COUNT; i++) {
|
* this method should be invoked periodically to calculate FSIO and toggle corresponding FSIO outputs
|
||||||
handleFsio(engine, i);
|
*/
|
||||||
|
void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
for (int index = 0; index < FSIO_COMMAND_COUNT; index++) {
|
||||||
|
handleFsio(index PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_FUEL_PUMP || defined(__DOXYGEN__)
|
#if EFI_FUEL_PUMP || defined(__DOXYGEN__)
|
||||||
|
|
|
@ -23,7 +23,8 @@ void setFsio(int index, brain_pin_e pin, const char * exp DECLARE_ENGINE_PARAMET
|
||||||
void setFsioExt(int index, brain_pin_e pin, const char * exp, int pwmFrequency DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void setFsioExt(int index, brain_pin_e pin, const char * exp, int pwmFrequency DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
void runFsio(void);
|
void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void prepareFsio(void);
|
void prepareFsio(void);
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
engine->checkShutdown();
|
engine->checkShutdown();
|
||||||
|
|
||||||
#if (EFI_PROD_CODE && EFI_FSIO) || defined(__DOXYGEN__)
|
#if (EFI_PROD_CODE && EFI_FSIO) || defined(__DOXYGEN__)
|
||||||
runFsio();
|
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
#endif /* EFI_PROD_CODE && EFI_FSIO */
|
#endif /* EFI_PROD_CODE && EFI_FSIO */
|
||||||
|
|
||||||
cylinderCleanupControl(engine);
|
cylinderCleanupControl(engine);
|
||||||
|
|
Loading…
Reference in New Issue