refactoring
This commit is contained in:
parent
d66bd27f96
commit
384b459ca0
|
@ -45,7 +45,7 @@ bool isRunningBenchTest(void) {
|
||||||
return isRunningBench;
|
return isRunningBench;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertCylinderId(int cylinderId, const char *msg) {
|
static void assertCylinderId(int cylinderId, const char *msg) {
|
||||||
int isValid = cylinderId >= 1 && cylinderId <= engineConfiguration->specs.cylindersCount;
|
int isValid = cylinderId >= 1 && cylinderId <= engineConfiguration->specs.cylindersCount;
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
// we are here only in case of a fatal issue - at this point it is fine to make some blocking i-o
|
// we are here only in case of a fatal issue - at this point it is fine to make some blocking i-o
|
||||||
|
@ -58,12 +58,12 @@ void assertCylinderId(int cylinderId, const char *msg) {
|
||||||
/**
|
/**
|
||||||
* @param cylinderId - from 1 to NUMBER_OF_CYLINDERS
|
* @param cylinderId - from 1 to NUMBER_OF_CYLINDERS
|
||||||
*/
|
*/
|
||||||
int isInjectorEnabled(int cylinderId) {
|
static int isInjectorEnabled(int cylinderId) {
|
||||||
assertCylinderId(cylinderId, "isInjectorEnabled");
|
assertCylinderId(cylinderId, "isInjectorEnabled");
|
||||||
return is_injector_enabled[cylinderId - 1];
|
return is_injector_enabled[cylinderId - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printStatus(void) {
|
static void printInjectorsStatus(void) {
|
||||||
for (int id = 1; id <= engineConfiguration->specs.cylindersCount; id++) {
|
for (int id = 1; id <= engineConfiguration->specs.cylindersCount; id++) {
|
||||||
scheduleMsg(logger, "injector_%d_%d", isInjectorEnabled(id));
|
scheduleMsg(logger, "injector_%d_%d", isInjectorEnabled(id));
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ static void printStatus(void) {
|
||||||
static void setInjectorEnabled(int id, int value) {
|
static void setInjectorEnabled(int id, int value) {
|
||||||
efiAssertVoid(id >= 0 && id < engineConfiguration->specs.cylindersCount, "injector id");
|
efiAssertVoid(id >= 0 && id < engineConfiguration->specs.cylindersCount, "injector id");
|
||||||
is_injector_enabled[id] = value;
|
is_injector_enabled[id] = value;
|
||||||
printStatus();
|
printInjectorsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, float onTimeMs, float offTimeMs,
|
static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, float onTimeMs, float offTimeMs,
|
||||||
|
@ -304,14 +304,14 @@ void initInjectorCentral(Logging *sharedLogger) {
|
||||||
logger = sharedLogger;
|
logger = sharedLogger;
|
||||||
chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL);
|
chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL);
|
||||||
|
|
||||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
for (int i = 0; i < INJECTION_PIN_COUNT; i++) {
|
||||||
is_injector_enabled[i] = true;
|
is_injector_enabled[i] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
startInjectionPins();
|
startInjectionPins();
|
||||||
startIgnitionPins();
|
startIgnitionPins();
|
||||||
|
|
||||||
printStatus();
|
printInjectorsStatus();
|
||||||
addConsoleActionII("injector", setInjectorEnabled);
|
addConsoleActionII("injector", setInjectorEnabled);
|
||||||
|
|
||||||
addConsoleAction("fuelpumpbench", fuelPumpBench);
|
addConsoleAction("fuelpumpbench", fuelPumpBench);
|
||||||
|
|
|
@ -19,8 +19,6 @@ void fuelPumpBench(void);
|
||||||
void milBench(void);
|
void milBench(void);
|
||||||
void initInjectorCentral(Logging *sharedLogger);
|
void initInjectorCentral(Logging *sharedLogger);
|
||||||
bool isRunningBenchTest(void);
|
bool isRunningBenchTest(void);
|
||||||
int isInjectorEnabled(int cylinderId);
|
|
||||||
void assertCylinderId(int cylinderId, const char *msg);
|
|
||||||
|
|
||||||
void stopInjectionPins(void);
|
void stopInjectionPins(void);
|
||||||
void startInjectionPins(void);
|
void startInjectionPins(void);
|
||||||
|
|
Loading…
Reference in New Issue