auto-sync
This commit is contained in:
parent
284e0be839
commit
76d14c02d4
|
@ -272,6 +272,8 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat
|
||||||
* CLT D13/W9
|
* CLT D13/W9
|
||||||
*/
|
*/
|
||||||
engineConfiguration->cltAdcChannel = EFI_ADC_12;
|
engineConfiguration->cltAdcChannel = EFI_ADC_12;
|
||||||
|
|
||||||
|
//setFsio(engineConfiguration, 0, GPIO)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* EFI_SUPPORT_DODGE_NEON */
|
#endif /* EFI_SUPPORT_DODGE_NEON */
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "trigger_decoder.h"
|
#include "trigger_decoder.h"
|
||||||
#include "engine_math.h"
|
#include "engine_math.h"
|
||||||
#include "speed_density.h"
|
#include "speed_density.h"
|
||||||
|
#include "logic_expression.h"
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
#include "tunerstudio.h"
|
#include "tunerstudio.h"
|
||||||
|
@ -571,6 +572,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType, Engine *e
|
||||||
firmwareError("Unexpected engine type: %d", engineType);
|
firmwareError("Unexpected engine type: %d", engineType);
|
||||||
}
|
}
|
||||||
applyNonPersistentConfiguration(logger, engine);
|
applyNonPersistentConfiguration(logger, engine);
|
||||||
|
parseUserFsio(PASS_ENGINE_PARAMETER_F);
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
syncTunerStudioCopy();
|
syncTunerStudioCopy();
|
||||||
|
|
|
@ -51,7 +51,7 @@ float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) {
|
||||||
case LE_METHOD_VBATT:
|
case LE_METHOD_VBATT:
|
||||||
return getVBatt(engine->engineConfiguration);
|
return getVBatt(engine->engineConfiguration);
|
||||||
default:
|
default:
|
||||||
firmwareError("No value for %d", action);
|
firmwareError("FSIO unexpected %d", action);
|
||||||
return NAN;
|
return NAN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,16 @@ static LECalculator evalCalc;
|
||||||
static LEElement evalPoolElements[LE_EVAL_POOL_SIZE];
|
static LEElement evalPoolElements[LE_EVAL_POOL_SIZE];
|
||||||
static LEElementPool evalPool(evalPoolElements, LE_EVAL_POOL_SIZE);
|
static LEElementPool evalPool(evalPoolElements, LE_EVAL_POOL_SIZE);
|
||||||
|
|
||||||
|
#define SYS_ELEMENT_POOL_SIZE 128
|
||||||
|
#define UD_ELEMENT_POOL_SIZE 128
|
||||||
|
|
||||||
|
static LEElement sysElements[SYS_ELEMENT_POOL_SIZE];
|
||||||
|
LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE);
|
||||||
|
|
||||||
|
static LEElement userElements[UD_ELEMENT_POOL_SIZE];
|
||||||
|
LEElementPool userPool(userElements, UD_ELEMENT_POOL_SIZE);
|
||||||
|
LEElement * fsioLogics[LE_COMMAND_COUNT] CCM_OPTIONAL;
|
||||||
|
|
||||||
LENameOrdinalPair::LENameOrdinalPair(le_action_e action, const char *name) {
|
LENameOrdinalPair::LENameOrdinalPair(le_action_e action, const char *name) {
|
||||||
this->action = action;
|
this->action = action;
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
@ -237,7 +247,7 @@ void LECalculator::doJob(Engine *engine, LEElement *element) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LE_UNDEFINED:
|
case LE_UNDEFINED:
|
||||||
firmwareError("Undefined not expected here");
|
firmwareError("FSIO undefined action");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stack.push(getLEValue(engine, &stack, element->action));
|
stack.push(getLEValue(engine, &stack, element->action));
|
||||||
|
@ -250,6 +260,10 @@ float LECalculator::getValue2(LEElement *element, Engine *engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float LECalculator::getValue(Engine *engine) {
|
float LECalculator::getValue(Engine *engine) {
|
||||||
|
if (first == NULL) {
|
||||||
|
warning(OBD_PCM_Processor_Fault, "no FSIO code");
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
LEElement *element = first;
|
LEElement *element = first;
|
||||||
|
|
||||||
stack.reset();
|
stack.reset();
|
||||||
|
@ -258,14 +272,16 @@ float LECalculator::getValue(Engine *engine) {
|
||||||
doJob(engine, element);
|
doJob(engine, element);
|
||||||
element = element->next;
|
element = element->next;
|
||||||
}
|
}
|
||||||
efiAssert(stack.size() == 1, "One value expected on stack", NAN);
|
if (stack.size() != 1) {
|
||||||
|
warning(OBD_PCM_Processor_Fault, "unexpected FSIO stack size: %d", stack.size());
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
return stack.pop();
|
return stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
LEElementPool::LEElementPool(LEElement *pool, int size) {
|
LEElementPool::LEElementPool(LEElement *pool, int size) {
|
||||||
this->pool = pool;
|
this->pool = pool;
|
||||||
this->size = size;
|
this->capacity = capacity;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,8 +289,12 @@ void LEElementPool::reset() {
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LEElementPool::getSize() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
LEElement *LEElementPool::next() {
|
LEElement *LEElementPool::next() {
|
||||||
if (index == size - 1) {
|
if (index == capacity - 1) {
|
||||||
// todo: this should not be a fatal error, just an error
|
// todo: this should not be a fatal error, just an error
|
||||||
firmwareError("LE_ELEMENT_POOL_SIZE overflow");
|
firmwareError("LE_ELEMENT_POOL_SIZE overflow");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -375,9 +395,27 @@ static void eval(char *line, Engine *engine) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
void initEval(Engine *engine) {
|
void initEval(Engine *engine) {
|
||||||
initLogging(&logger, "le");
|
initLogging(&logger, "le");
|
||||||
addConsoleActionSP("eval", (VoidCharPtrVoidPtr) eval, engine);
|
addConsoleActionSP("eval", (VoidCharPtrVoidPtr) eval, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void parseUserFsio(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
|
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
|
||||||
|
brain_pin_e brainPin = boardConfiguration->fsioPins[i];
|
||||||
|
|
||||||
|
if (brainPin != GPIO_UNASSIGNED) {
|
||||||
|
const char *formula = boardConfiguration->le_formulas[i];
|
||||||
|
LEElement *logic = userPool.parseExpression(formula);
|
||||||
|
if (logic == NULL) {
|
||||||
|
warning(OBD_PCM_Processor_Fault, "parsing [%s]", formula);
|
||||||
|
}
|
||||||
|
|
||||||
|
fsioLogics[i] = logic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -69,9 +69,10 @@ public:
|
||||||
LEElement *next();
|
LEElement *next();
|
||||||
void reset();
|
void reset();
|
||||||
LEElement * parseExpression(const char * line);
|
LEElement * parseExpression(const char * line);
|
||||||
|
int getSize();
|
||||||
private:
|
private:
|
||||||
int index;
|
int index;
|
||||||
int size;
|
int capacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,5 +113,6 @@ const char *getNextToken(const char *line, char *buffer);
|
||||||
bool isNumeric(const char* line);
|
bool isNumeric(const char* line);
|
||||||
le_action_e parseAction(const char * line);
|
le_action_e parseAction(const char * line);
|
||||||
void initEval(Engine *engine);
|
void initEval(Engine *engine);
|
||||||
|
void parseUserFsio(DECLARE_ENGINE_PARAMETER_F);
|
||||||
|
|
||||||
#endif /* LOGIC_EXPRESSION_H_ */
|
#endif /* LOGIC_EXPRESSION_H_ */
|
||||||
|
|
|
@ -57,12 +57,6 @@
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
#include "pwm_generator.h"
|
#include "pwm_generator.h"
|
||||||
|
|
||||||
#define LE_ELEMENT_POOL_SIZE 256
|
|
||||||
|
|
||||||
static LECalculator calc;
|
|
||||||
static LEElement mainPool[LE_ELEMENT_POOL_SIZE];
|
|
||||||
static LEElementPool lePool(mainPool, LE_ELEMENT_POOL_SIZE);
|
|
||||||
|
|
||||||
static LEElement * acRelayLogic;
|
static LEElement * acRelayLogic;
|
||||||
static LEElement * fuelPumpLogic;
|
static LEElement * fuelPumpLogic;
|
||||||
static LEElement * radiatorFanLogic;
|
static LEElement * radiatorFanLogic;
|
||||||
|
@ -72,7 +66,10 @@ extern OutputPin outputs[IO_PIN_COUNT];
|
||||||
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
|
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
|
||||||
extern bool hasFirmwareErrorFlag;
|
extern bool hasFirmwareErrorFlag;
|
||||||
|
|
||||||
static LEElement * fsioLogics[LE_COMMAND_COUNT] CCM_OPTIONAL;
|
extern LEElementPool sysPool;
|
||||||
|
extern LEElementPool userPool;
|
||||||
|
|
||||||
|
|
||||||
static SimplePwm fsioPwm[LE_COMMAND_COUNT] CCM_OPTIONAL;
|
static SimplePwm fsioPwm[LE_COMMAND_COUNT] CCM_OPTIONAL;
|
||||||
|
|
||||||
persistent_config_container_s persistentState CCM_OPTIONAL;
|
persistent_config_container_s persistentState CCM_OPTIONAL;
|
||||||
|
@ -198,7 +195,10 @@ static void cylinderCleanupControl(Engine *engine) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleGpio(Engine *engine, int index) {
|
static LECalculator calc;
|
||||||
|
extern LEElement * fsioLogics[LE_COMMAND_COUNT];
|
||||||
|
|
||||||
|
static void handleFsio(Engine *engine, int index) {
|
||||||
if (boardConfiguration->fsioPins[index] == GPIO_UNASSIGNED)
|
if (boardConfiguration->fsioPins[index] == GPIO_UNASSIGNED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ static void onEvenyGeneralMilliseconds(Engine *engine) {
|
||||||
engine->updateSlowSensors();
|
engine->updateSlowSensors();
|
||||||
|
|
||||||
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
|
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
|
||||||
handleGpio(engine, i);
|
handleFsio(engine, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_FUEL_PUMP
|
#if EFI_FUEL_PUMP
|
||||||
|
@ -326,6 +326,22 @@ static void printAnalogInfo(void) {
|
||||||
|
|
||||||
static THD_WORKING_AREA(csThreadStack, UTILITY_THREAD_STACK_SIZE); // declare thread stack
|
static THD_WORKING_AREA(csThreadStack, UTILITY_THREAD_STACK_SIZE); // declare thread stack
|
||||||
|
|
||||||
|
static void showFsio(const char *msg, LEElement *element) {
|
||||||
|
scheduleMsg(&logger, "%s:", msg);
|
||||||
|
while (element != NULL) {
|
||||||
|
scheduleMsg(&logger, "action %d: fValue=%f iValue=%d", element->action, element->fValue, element->iValue);
|
||||||
|
element = element->next;
|
||||||
|
}
|
||||||
|
scheduleMsg(&logger, "<end>");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void showFsioInfo(void) {
|
||||||
|
scheduleMsg(&logger, "sys used %d/user used %d", sysPool.getSize(), userPool.getSize());
|
||||||
|
showFsio("ac", acRelayLogic);
|
||||||
|
showFsio("fuel", fuelPumpLogic);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void setFsioFrequency(int index, int frequency) {
|
static void setFsioFrequency(int index, int frequency) {
|
||||||
index--;
|
index--;
|
||||||
if (index < 0 || index > LE_COMMAND_COUNT) {
|
if (index < 0 || index > LE_COMMAND_COUNT) {
|
||||||
|
@ -489,12 +505,12 @@ void initEngineContoller(Engine *engine) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EFI_FUEL_PUMP
|
#if EFI_FUEL_PUMP
|
||||||
fuelPumpLogic = lePool.parseExpression(FUEL_PUMP_LOGIC);
|
fuelPumpLogic = sysPool.parseExpression(FUEL_PUMP_LOGIC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
acRelayLogic = lePool.parseExpression(AC_RELAY_LOGIC);
|
acRelayLogic = sysPool.parseExpression(AC_RELAY_LOGIC);
|
||||||
|
|
||||||
alternatorLogic = lePool.parseExpression(ALTERNATOR_LOGIC);
|
alternatorLogic = sysPool.parseExpression(ALTERNATOR_LOGIC);
|
||||||
|
|
||||||
addConsoleAction("analoginfo", printAnalogInfo);
|
addConsoleAction("analoginfo", printAnalogInfo);
|
||||||
|
|
||||||
|
@ -502,15 +518,6 @@ void initEngineContoller(Engine *engine) {
|
||||||
brain_pin_e brainPin = boardConfiguration->fsioPins[i];
|
brain_pin_e brainPin = boardConfiguration->fsioPins[i];
|
||||||
|
|
||||||
if (brainPin != GPIO_UNASSIGNED) {
|
if (brainPin != GPIO_UNASSIGNED) {
|
||||||
|
|
||||||
const char *formula = boardConfiguration->le_formulas[i];
|
|
||||||
LEElement *logic = lePool.parseExpression(formula);
|
|
||||||
if (logic == NULL) {
|
|
||||||
warning(OBD_PCM_Processor_Fault, "parsing [%s]", formula);
|
|
||||||
}
|
|
||||||
|
|
||||||
fsioLogics[i] = logic;
|
|
||||||
|
|
||||||
//mySetPadMode2("user-defined", boardConfiguration->gpioPins[i], PAL_STM32_MODE_OUTPUT);
|
//mySetPadMode2("user-defined", boardConfiguration->gpioPins[i], PAL_STM32_MODE_OUTPUT);
|
||||||
|
|
||||||
io_pin_e pin = (io_pin_e) ((int) GPIO_0 + i);
|
io_pin_e pin = (io_pin_e) ((int) GPIO_0 + i);
|
||||||
|
@ -532,5 +539,7 @@ void initEngineContoller(Engine *engine) {
|
||||||
addConsoleActionSS("set_int", (VoidCharPtrCharPtr) setInt);
|
addConsoleActionSS("set_int", (VoidCharPtrCharPtr) setInt);
|
||||||
addConsoleActionI("get_float", getFloat);
|
addConsoleActionI("get_float", getFloat);
|
||||||
addConsoleActionI("get_int", getInt);
|
addConsoleActionI("get_int", getInt);
|
||||||
|
|
||||||
|
addConsoleAction("fsioinfo", showFsioInfo);
|
||||||
initEval(engine);
|
initEval(engine);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue