The Big Refactoring of 2019: DECLARE_ENGINE_PARAMETER_SUFFIX consistency and simplification #657
This commit is contained in:
parent
57993ff1b4
commit
cbd2d69731
|
@ -49,7 +49,7 @@ static void runCommands() {
|
|||
chThdSleepMilliseconds(1000); // safety
|
||||
|
||||
// Store current serial port speed - we're going to change it
|
||||
int savedSerialSpeed = boardConfiguration->tunerStudioSerialSpeed;
|
||||
int savedSerialSpeed = CONFIGB(tunerStudioSerialSpeed);
|
||||
|
||||
int prevBaudIdx = -1, baudIdx = -1, baudListIdx = 0;
|
||||
int cmdIdx = 0;
|
||||
|
@ -75,7 +75,7 @@ static void runCommands() {
|
|||
}
|
||||
chThdSleepMilliseconds(10); // safety
|
||||
// change the port speed
|
||||
boardConfiguration->tunerStudioSerialSpeed = restoreAndExit ? savedSerialSpeed : baudRates[baudIdx];
|
||||
CONFIGB(tunerStudioSerialSpeed) = restoreAndExit ? savedSerialSpeed : baudRates[baudIdx];
|
||||
// init UART
|
||||
startTsPort(tsChannel);
|
||||
chThdSleepMilliseconds(10); // safety
|
||||
|
@ -160,7 +160,7 @@ void bluetoothStart(ts_channel_s *tsChan, bluetooth_module_e moduleType, const c
|
|||
tsChannel = tsChan;
|
||||
|
||||
// if a binary protocol uses USB, we cannot init the bluetooth module!
|
||||
if (!boardConfiguration->useSerialPort) {
|
||||
if (!CONFIGB(useSerialPort)) {
|
||||
scheduleMsg(&btLogger, "Failed! Serial Port connection is disabled!");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ static SerialConfig serialConfig = { 0, 0, USART_CR2_STOP1_BITS | USART_CR2_LINE
|
|||
bool consoleInBinaryMode = false;
|
||||
|
||||
void runConsoleLoop(ts_channel_s *console) {
|
||||
if (boardConfiguration->startConsoleInBinaryMode) {
|
||||
if (CONFIGB(startConsoleInBinaryMode)) {
|
||||
// switch to binary protocol
|
||||
consoleInBinaryMode = true;
|
||||
#if EFI_TUNER_STUDIO || defined(__DOXYGEN__)
|
||||
|
|
|
@ -400,21 +400,21 @@ void printOverallStatus(systime_t nowSeconds) {
|
|||
getTimeNowSeconds(),
|
||||
DELIMETER);
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
printOutPin(CRANK1, boardConfiguration->triggerInputPins[0]);
|
||||
printOutPin(CRANK2, boardConfiguration->triggerInputPins[1]);
|
||||
printOutPin(CRANK1, CONFIGB(triggerInputPins)[0]);
|
||||
printOutPin(CRANK2, CONFIGB(triggerInputPins)[1]);
|
||||
printOutPin(VVT_NAME, engineConfiguration->camInput);
|
||||
printOutPin(HIP_NAME, boardConfiguration->hip9011IntHoldPin);
|
||||
printOutPin(TACH_NAME, boardConfiguration->tachOutputPin);
|
||||
printOutPin(HIP_NAME, CONFIGB(hip9011IntHoldPin));
|
||||
printOutPin(TACH_NAME, CONFIGB(tachOutputPin));
|
||||
printOutPin(DIZZY_NAME, engineConfiguration->dizzySparkOutputPin);
|
||||
#if EFI_WAVE_ANALYZER || defined(__DOXYGEN__)
|
||||
printOutPin(WA_CHANNEL_1, boardConfiguration->logicAnalyzerPins[0]);
|
||||
printOutPin(WA_CHANNEL_2, boardConfiguration->logicAnalyzerPins[1]);
|
||||
printOutPin(WA_CHANNEL_1, CONFIGB(logicAnalyzerPins)[0]);
|
||||
printOutPin(WA_CHANNEL_2, CONFIGB(logicAnalyzerPins)[1]);
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
printOutPin(enginePins.coils[i].name, boardConfiguration->ignitionPins[i]);
|
||||
printOutPin(enginePins.coils[i].name, CONFIGB(ignitionPins)[i]);
|
||||
|
||||
printOutPin(enginePins.injectors[i].name, boardConfiguration->injectionPins[i]);
|
||||
printOutPin(enginePins.injectors[i].name, CONFIGB(injectionPins)[i]);
|
||||
}
|
||||
for (int i = 0; i < AUX_DIGITAL_VALVE_COUNT;i++) {
|
||||
printOutPin(enginePins.auxValve[i].name, engineConfiguration->auxValves[i]);
|
||||
|
@ -558,7 +558,7 @@ static OutputPin *leds[] = { &enginePins.warningLedPin, &enginePins.runningLedPi
|
|||
static void initStatusLeds(void) {
|
||||
enginePins.communicationLedPin.initPin("led: comm status", engineConfiguration->communicationLedPin);
|
||||
// we initialize this here so that we can blink it on start-up
|
||||
enginePins.checkEnginePin.initPin("MalfunctionIndicator", boardConfiguration->malfunctionIndicatorPin, &boardConfiguration->malfunctionIndicatorPinMode);
|
||||
enginePins.checkEnginePin.initPin("MalfunctionIndicator", CONFIGB(malfunctionIndicatorPin), &CONFIGB(malfunctionIndicatorPinMode));
|
||||
|
||||
|
||||
#if EFI_WARNING_LED || defined(__DOXYGEN__)
|
||||
|
|
|
@ -35,7 +35,7 @@ static void startPwmTest(int freq) {
|
|||
/**
|
||||
* See custom_engine.cpp for pinout
|
||||
*/
|
||||
// currently this is PB9 by default - see boardConfiguration->injectionPins
|
||||
// currently this is PB9 by default - see CONFIGB(injectionPins)
|
||||
startSimplePwm(&pwmTest[1], "tester", &enginePins.injectors[0], freq / 1.3333333333, 0.5f, applyPinState);
|
||||
// currently this is PE2 by default
|
||||
startSimplePwm(&pwmTest[2], "tester", &enginePins.injectors[1], freq / 1000, 0.5f, applyPinState);
|
||||
|
|
|
@ -61,7 +61,7 @@ static const ignition_table_t defaultIatTiming = {
|
|||
};
|
||||
|
||||
bool isStep1Condition(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
return boardConfiguration->enabledStep1Limiter && rpm >= engineConfiguration->step1rpm;
|
||||
return CONFIGB(enabledStep1Limiter) && rpm >= engineConfiguration->step1rpm;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,7 +97,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
|
|||
float idleAdvance = interpolate2d("idleAdvance", rpm, config->idleAdvanceBins, config->idleAdvance, IDLE_ADVANCE_CURVE_SIZE);
|
||||
// interpolate between idle table and normal (running) table using TPS threshold
|
||||
float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
advanceAngle = interpolateClamped(0.0f, idleAdvance, boardConfiguration->idlePidDeactivationTpsThreshold, advanceAngle, tps);
|
||||
advanceAngle = interpolateClamped(0.0f, idleAdvance, CONFIGB(idlePidDeactivationTpsThreshold), advanceAngle, tps);
|
||||
}
|
||||
|
||||
engine->m.advanceLookupTime = GET_TIMESTAMP() - engine->m.beforeAdvance;
|
||||
|
|
|
@ -77,7 +77,7 @@ static msg_t AltCtrlThread(int param) {
|
|||
float vBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
float targetVoltage = engineConfiguration->targetVBatt;
|
||||
|
||||
if (boardConfiguration->onOffAlternatorLogic) {
|
||||
if (CONFIGB(onOffAlternatorLogic)) {
|
||||
float h = 0.1;
|
||||
bool newState = (vBatt < targetVoltage - h) || (currentPlainOnOffState && vBatt < targetVoltage);
|
||||
enginePins.alternatorPin.setValue(newState);
|
||||
|
@ -93,7 +93,7 @@ static msg_t AltCtrlThread(int param) {
|
|||
|
||||
|
||||
currentAltDuty = altPid.getValue(targetVoltage, vBatt);
|
||||
if (boardConfiguration->isVerboseAlternator) {
|
||||
if (CONFIGB(isVerboseAlternator)) {
|
||||
scheduleMsg(logger, "alt duty: %.2f/vbatt=%.2f/p=%.2f/i=%.2f/d=%.2f int=%.2f", currentAltDuty, vBatt,
|
||||
altPid.getP(), altPid.getI(), altPid.getD(), altPid.getIntegration());
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ static msg_t AltCtrlThread(int param) {
|
|||
|
||||
void showAltInfo(void) {
|
||||
scheduleMsg(logger, "alt=%s @%s t=%dms", boolToString(engineConfiguration->isAlternatorControlEnabled),
|
||||
hwPortname(boardConfiguration->alternatorControlPin),
|
||||
hwPortname(CONFIGB(alternatorControlPin)),
|
||||
engineConfiguration->alternatorControl.period);
|
||||
scheduleMsg(logger, "p=%.2f/i=%.2f/d=%.2f offset=%.2f", engineConfiguration->alternatorControl.pFactor,
|
||||
0, 0, engineConfiguration->alternatorControl.offset); // todo: i & d
|
||||
|
@ -139,8 +139,8 @@ static void applyAlternatorPinState(PwmConfig *state, int stateIndex) {
|
|||
void setDefaultAlternatorParameters(void) {
|
||||
engineConfiguration->alternatorOffAboveTps = 120;
|
||||
|
||||
boardConfiguration->alternatorControlPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->alternatorControlPinMode = OM_DEFAULT;
|
||||
CONFIGB(alternatorControlPin) = GPIO_UNASSIGNED;
|
||||
CONFIGB(alternatorControlPinMode) = OM_DEFAULT;
|
||||
engineConfiguration->targetVBatt = 14;
|
||||
|
||||
engineConfiguration->alternatorControl.offset = 0;
|
||||
|
@ -155,17 +155,17 @@ void onConfigurationChangeAlternatorCallback(engine_configuration_s *previousCon
|
|||
void initAlternatorCtrl(Logging *sharedLogger) {
|
||||
logger = sharedLogger;
|
||||
addConsoleAction("altinfo", showAltInfo);
|
||||
if (boardConfiguration->alternatorControlPin == GPIO_UNASSIGNED)
|
||||
if (CONFIGB(alternatorControlPin) == GPIO_UNASSIGNED)
|
||||
return;
|
||||
|
||||
if (boardConfiguration->onOffAlternatorLogic) {
|
||||
enginePins.alternatorPin.initPin("on/off alternator", boardConfiguration->alternatorControlPin);
|
||||
if (CONFIGB(onOffAlternatorLogic)) {
|
||||
enginePins.alternatorPin.initPin("on/off alternator", CONFIGB(alternatorControlPin));
|
||||
|
||||
} else {
|
||||
startSimplePwmExt(&alternatorControl,
|
||||
"Alternator control",
|
||||
&engine->executor,
|
||||
boardConfiguration->alternatorControlPin,
|
||||
CONFIGB(alternatorControlPin),
|
||||
&enginePins.alternatorPin,
|
||||
engineConfiguration->alternatorPwmFrequency, 0.1, applyAlternatorPinState);
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ static void periodicSlowCallback(Engine *engine);
|
|||
|
||||
static void scheduleNextSlowInvocation(void) {
|
||||
// schedule next invocation
|
||||
int periodMs = boardConfiguration->generalPeriodicThreadPeriod;
|
||||
int periodMs = CONFIGB(generalPeriodicThreadPeriod);
|
||||
if (periodMs == 0)
|
||||
periodMs = 50; // this might happen while resetting configuration
|
||||
chVTSetAny(&periodicSlowTimer, MS2ST(periodMs), (vtfunc_t) &periodicSlowCallback, engine);
|
||||
|
@ -370,7 +370,7 @@ static void printAnalogChannelInfoExt(const char *name, adc_channel_e hwChannel,
|
|||
}
|
||||
|
||||
if (fastAdc.isHwUsed(hwChannel)) {
|
||||
scheduleMsg(&logger, "fast enabled=%s", boolToString(boardConfiguration->isFastAdcEnabled));
|
||||
scheduleMsg(&logger, "fast enabled=%s", boolToString(CONFIGB(isFastAdcEnabled)));
|
||||
}
|
||||
|
||||
float voltage = adcVoltage * dividerCoeff;
|
||||
|
@ -735,7 +735,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
|
|||
initEgoAveraging(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||
if (boardConfiguration->isEngineControlEnabled) {
|
||||
if (CONFIGB(isEngineControlEnabled)) {
|
||||
/**
|
||||
* This method initialized the main listener which actually runs injectors & ignition
|
||||
*/
|
||||
|
|
|
@ -99,18 +99,18 @@ void idleDebug(const char *msg, percent_t value) {
|
|||
static void showIdleInfo(void) {
|
||||
const char * idleModeStr = getIdle_mode_e(engineConfiguration->idleMode);
|
||||
scheduleMsg(logger, "idleMode=%s position=%.2f isStepper=%s", idleModeStr,
|
||||
getIdlePosition(), boolToString(boardConfiguration->useStepperIdle));
|
||||
getIdlePosition(), boolToString(CONFIGB(useStepperIdle)));
|
||||
|
||||
if (boardConfiguration->useStepperIdle) {
|
||||
scheduleMsg(logger, "directionPin=%s reactionTime=%.2f", hwPortname(boardConfiguration->idle.stepperDirectionPin),
|
||||
if (CONFIGB(useStepperIdle)) {
|
||||
scheduleMsg(logger, "directionPin=%s reactionTime=%.2f", hwPortname(CONFIGB(idle).stepperDirectionPin),
|
||||
engineConfiguration->idleStepperReactionTime);
|
||||
scheduleMsg(logger, "stepPin=%s steps=%d", hwPortname(boardConfiguration->idle.stepperStepPin),
|
||||
scheduleMsg(logger, "stepPin=%s steps=%d", hwPortname(CONFIGB(idle).stepperStepPin),
|
||||
engineConfiguration->idleStepperTotalSteps);
|
||||
scheduleMsg(logger, "enablePin=%s/%d", hwPortname(engineConfiguration->stepperEnablePin),
|
||||
engineConfiguration->stepperEnablePinMode);
|
||||
} else {
|
||||
scheduleMsg(logger, "idle valve freq=%d on %s", boardConfiguration->idle.solenoidFrequency,
|
||||
hwPortname(boardConfiguration->idle.solenoidPin));
|
||||
scheduleMsg(logger, "idle valve freq=%d on %s", CONFIGB(idle).solenoidFrequency,
|
||||
hwPortname(CONFIGB(idle).solenoidPin));
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ void setIdleMode(idle_mode_e value) {
|
|||
}
|
||||
|
||||
static void applyIACposition(percent_t position) {
|
||||
if (boardConfiguration->useStepperIdle) {
|
||||
if (CONFIGB(useStepperIdle)) {
|
||||
iacMotor.setTargetPosition(position / 100 * engineConfiguration->idleStepperTotalSteps);
|
||||
} else {
|
||||
/**
|
||||
|
@ -138,7 +138,7 @@ static void applyIACposition(percent_t position) {
|
|||
|
||||
static percent_t manualIdleController(float cltCorrection) {
|
||||
|
||||
percent_t correctedPosition = cltCorrection * boardConfiguration->manIdlePosition;
|
||||
percent_t correctedPosition = cltCorrection * CONFIGB(manIdlePosition);
|
||||
|
||||
// let's put the value into the right range
|
||||
correctedPosition = maxF(correctedPosition, 0.01);
|
||||
|
@ -153,7 +153,7 @@ void setIdleValvePosition(int positionPercent) {
|
|||
scheduleMsg(logger, "setting idle valve position %d", positionPercent);
|
||||
showIdleInfo();
|
||||
// todo: this is not great that we have to write into configuration here
|
||||
boardConfiguration->manIdlePosition = positionPercent;
|
||||
CONFIGB(manIdlePosition) = positionPercent;
|
||||
}
|
||||
|
||||
static percent_t blipIdlePosition;
|
||||
|
@ -191,7 +191,7 @@ percent_t getIdlePosition(void) {
|
|||
*/
|
||||
static percent_t automaticIdleController() {
|
||||
percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
if (tpsPos > boardConfiguration->idlePidDeactivationTpsThreshold) {
|
||||
if (tpsPos > CONFIGB(idlePidDeactivationTpsThreshold)) {
|
||||
// Don't store old I and D terms if PID doesn't work anymore.
|
||||
// Otherwise they will affect the idle position much later, when the throttle is closed.
|
||||
if (mightResetPid) {
|
||||
|
@ -240,7 +240,7 @@ static percent_t automaticIdleController() {
|
|||
#if EFI_IDLE_INCREMENTAL_PID_CIC || defined(__DOXYGEN__)
|
||||
// Treat the 'newValue' as if it contains not an actual IAC position, but an incremental delta.
|
||||
// So we add this delta to the base IAC position, with a smooth taper for TPS transients.
|
||||
newValue = baseIdlePosition + interpolateClamped(0.0f, newValue, boardConfiguration->idlePidDeactivationTpsThreshold, 0.0f, tpsPos);
|
||||
newValue = baseIdlePosition + interpolateClamped(0.0f, newValue, CONFIGB(idlePidDeactivationTpsThreshold), 0.0f, tpsPos);
|
||||
|
||||
// apply the PID limits
|
||||
newValue = maxF(newValue, CONFIG(idleRpmPid.minValue));
|
||||
|
@ -254,7 +254,7 @@ static percent_t automaticIdleController() {
|
|||
// Currently it's user-defined. But eventually we'll use a real calculated and stored IAC position instead.
|
||||
int idlePidLowerRpm = targetRpm + CONFIG(idlePidRpmDeadZone);
|
||||
if (CONFIG(idlePidRpmUpperLimit) > 0) {
|
||||
if (boardConfiguration->useIacTableForCoasting) {
|
||||
if (CONFIGB(useIacTableForCoasting)) {
|
||||
percent_t iacPosForCoasting = interpolate2d("iacCoasting", clt, CONFIG(iacCoastingBins), CONFIG(iacCoasting), CLT_CURVE_SIZE);
|
||||
newValue = interpolateClamped(idlePidLowerRpm, newValue, idlePidLowerRpm + CONFIG(idlePidRpmUpperLimit), iacPosForCoasting, rpm);
|
||||
} else {
|
||||
|
@ -293,11 +293,11 @@ static msg_t ivThread(int param) {
|
|||
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
// this value is not used yet
|
||||
if (boardConfiguration->clutchDownPin != GPIO_UNASSIGNED) {
|
||||
engine->clutchDownState = efiReadPin(boardConfiguration->clutchDownPin);
|
||||
if (CONFIGB(clutchDownPin) != GPIO_UNASSIGNED) {
|
||||
engine->clutchDownState = efiReadPin(CONFIGB(clutchDownPin));
|
||||
}
|
||||
if (boardConfiguration->clutchUpPin != GPIO_UNASSIGNED) {
|
||||
engine->clutchUpState = efiReadPin(boardConfiguration->clutchUpPin);
|
||||
if (CONFIGB(clutchUpPin) != GPIO_UNASSIGNED) {
|
||||
engine->clutchUpState = efiReadPin(CONFIGB(clutchUpPin));
|
||||
}
|
||||
|
||||
if (engineConfiguration->brakePedalPin != GPIO_UNASSIGNED) {
|
||||
|
@ -346,7 +346,7 @@ static msg_t ivThread(int param) {
|
|||
|
||||
percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
float additionalAir = (float)engineConfiguration->iacByTpsTaper;
|
||||
iacPosition += interpolateClamped(0.0f, 0.0f, boardConfiguration->idlePidDeactivationTpsThreshold, additionalAir, tpsPos);
|
||||
iacPosition += interpolateClamped(0.0f, 0.0f, CONFIGB(idlePidDeactivationTpsThreshold), additionalAir, tpsPos);
|
||||
|
||||
// taper transition from cranking to running (uint32_t to float conversion is safe here)
|
||||
if (engineConfiguration->afterCrankingIACtaperDuration > 0)
|
||||
|
@ -426,7 +426,7 @@ void setIdleDT(int value) {
|
|||
|
||||
void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration) {
|
||||
shouldResetPid = !idlePid.isSame(&previousConfiguration->idleRpmPid);
|
||||
idleSolenoid.setFrequency(boardConfiguration->idle.solenoidFrequency);
|
||||
idleSolenoid.setFrequency(CONFIGB(idle).solenoidFrequency);
|
||||
}
|
||||
|
||||
void startIdleBench(void) {
|
||||
|
@ -455,8 +455,8 @@ static void applyIdleSolenoidPinState(PwmConfig *state, int stateIndex) {
|
|||
}
|
||||
|
||||
static void initIdleHardware() {
|
||||
if (boardConfiguration->useStepperIdle) {
|
||||
iacMotor.initialize(boardConfiguration->idle.stepperStepPin, boardConfiguration->idle.stepperDirectionPin,
|
||||
if (CONFIGB(useStepperIdle)) {
|
||||
iacMotor.initialize(CONFIGB(idle).stepperStepPin, CONFIGB(idle).stepperDirectionPin,
|
||||
engineConfiguration->stepperDirectionPinMode, engineConfiguration->idleStepperReactionTime,
|
||||
engineConfiguration->idleStepperTotalSteps, engineConfiguration->stepperEnablePin, logger);
|
||||
// This greatly improves PID accuracy for steppers with a small number of steps
|
||||
|
@ -467,8 +467,8 @@ static void initIdleHardware() {
|
|||
*/
|
||||
startSimplePwmExt(&idleSolenoid, "Idle Valve",
|
||||
&engine->executor,
|
||||
boardConfiguration->idle.solenoidPin, &enginePins.idleSolenoidPin,
|
||||
boardConfiguration->idle.solenoidFrequency, boardConfiguration->manIdlePosition / 100,
|
||||
CONFIGB(idle).solenoidPin, &enginePins.idleSolenoidPin,
|
||||
CONFIGB(idle).solenoidFrequency, CONFIGB(manIdlePosition) / 100,
|
||||
applyIdleSolenoidPinState);
|
||||
idlePositionSensitivityThreshold = 0.0f;
|
||||
}
|
||||
|
@ -486,14 +486,14 @@ void startIdleThread(Logging*sharedLogger) {
|
|||
|
||||
// this is idle switch INPUT - sometimes there is a switch on the throttle pedal
|
||||
// this switch is not used yet
|
||||
if (boardConfiguration->clutchDownPin != GPIO_UNASSIGNED) {
|
||||
efiSetPadMode("clutch down switch", boardConfiguration->clutchDownPin,
|
||||
getInputMode(boardConfiguration->clutchDownPinMode));
|
||||
if (CONFIGB(clutchDownPin) != GPIO_UNASSIGNED) {
|
||||
efiSetPadMode("clutch down switch", CONFIGB(clutchDownPin),
|
||||
getInputMode(CONFIGB(clutchDownPinMode)));
|
||||
}
|
||||
|
||||
if (boardConfiguration->clutchUpPin != GPIO_UNASSIGNED) {
|
||||
efiSetPadMode("clutch up switch", boardConfiguration->clutchUpPin,
|
||||
getInputMode(boardConfiguration->clutchUpPinMode));
|
||||
if (CONFIGB(clutchUpPin) != GPIO_UNASSIGNED) {
|
||||
efiSetPadMode("clutch up switch", CONFIGB(clutchUpPin),
|
||||
getInputMode(CONFIGB(clutchUpPinMode)));
|
||||
}
|
||||
|
||||
if (engineConfiguration->brakePedalPin != GPIO_UNASSIGNED) {
|
||||
|
|
|
@ -139,7 +139,7 @@ static void doRunFuel(int humanIndex, const char *delayStr, const char * onTimeS
|
|||
scheduleMsg(logger, "Invalid index: %d", humanIndex);
|
||||
return;
|
||||
}
|
||||
brain_pin_e b = boardConfiguration->injectionPins[humanIndex - 1];
|
||||
brain_pin_e b = CONFIGB(injectionPins)[humanIndex - 1];
|
||||
pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.injectors[humanIndex - 1], b);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ static void fuelbench2(const char *delayStr, const char *indexStr, const char *
|
|||
}
|
||||
|
||||
static void fanBenchExt(const char *durationMs) {
|
||||
pinbench("0", durationMs, "100", "1", &enginePins.fanRelay, boardConfiguration->fanPin);
|
||||
pinbench("0", durationMs, "100", "1", &enginePins.fanRelay, CONFIGB(fanPin));
|
||||
}
|
||||
|
||||
void fanBench(void) {
|
||||
|
@ -162,11 +162,11 @@ void fanBench(void) {
|
|||
}
|
||||
|
||||
void milBench(void) {
|
||||
pinbench("0", "500", "500", "16", &enginePins.checkEnginePin, boardConfiguration->malfunctionIndicatorPin);
|
||||
pinbench("0", "500", "500", "16", &enginePins.checkEnginePin, CONFIGB(malfunctionIndicatorPin));
|
||||
}
|
||||
|
||||
void fuelPumpBenchExt(const char *durationMs) {
|
||||
pinbench("0", durationMs, "100", "1", &enginePins.fuelPumpRelay, boardConfiguration->fuelPumpPin);
|
||||
pinbench("0", durationMs, "100", "1", &enginePins.fuelPumpRelay, CONFIGB(fuelPumpPin));
|
||||
}
|
||||
|
||||
void fuelPumpBench(void) {
|
||||
|
@ -184,7 +184,7 @@ static void doRunSpark(int humanIndex, const char *delayStr, const char * onTime
|
|||
scheduleMsg(logger, "Invalid index: %d", humanIndex);
|
||||
return;
|
||||
}
|
||||
brain_pin_e b = boardConfiguration->ignitionPins[humanIndex - 1];
|
||||
brain_pin_e b = CONFIGB(ignitionPins)[humanIndex - 1];
|
||||
pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.coils[humanIndex - 1], b);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ static void showLine(lcd_line_e line, int screenY) {
|
|||
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
||||
{
|
||||
char sdState;
|
||||
if (boardConfiguration->isSdCardEnabled) {
|
||||
if (CONFIGB(isSdCardEnabled)) {
|
||||
sdState = isSdCardAlive() ? 'L' : 'n';
|
||||
} else {
|
||||
sdState = 'D';
|
||||
|
|
|
@ -205,7 +205,7 @@ static void endAveraging(void *arg) {
|
|||
|
||||
static void applyMapMinBufferLength() {
|
||||
// check range
|
||||
mapMinBufferLength = maxI(minI(boardConfiguration->mapMinBufferLength, MAX_MAP_BUFFER_LENGTH), 1);
|
||||
mapMinBufferLength = maxI(minI(CONFIGB(mapMinBufferLength), MAX_MAP_BUFFER_LENGTH), 1);
|
||||
// reset index
|
||||
averagedMapBufIdx = 0;
|
||||
// fill with maximum values
|
||||
|
@ -266,14 +266,14 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
|
|||
return;
|
||||
}
|
||||
|
||||
if (boardConfiguration->mapMinBufferLength != mapMinBufferLength) {
|
||||
if (CONFIGB(mapMinBufferLength) != mapMinBufferLength) {
|
||||
applyMapMinBufferLength();
|
||||
}
|
||||
|
||||
measurementsPerRevolution = measurementsPerRevolutionCounter;
|
||||
measurementsPerRevolutionCounter = 0;
|
||||
|
||||
int samplingCount = boardConfiguration->measureMapOnlyInOneCylinder ? 1 : engineConfiguration->specs.cylindersCount;
|
||||
int samplingCount = CONFIGB(measureMapOnlyInOneCylinder) ? 1 : engineConfiguration->specs.cylindersCount;
|
||||
|
||||
for (int i = 0; i < samplingCount; i++) {
|
||||
angle_t samplingStart = ENGINE(engineState.mapAveragingStart[i]);
|
||||
|
|
|
@ -46,7 +46,7 @@ static float lastAfr = stoichAfr;
|
|||
|
||||
void initEgoAveraging(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
// Our averaging is intended for use only with Narrow EGOs.
|
||||
if (boardConfiguration->afr_type == ES_NarrowBand) {
|
||||
if (CONFIGB(afr_type) == ES_NarrowBand) {
|
||||
totalEgoCnt = prevEgoCnt = 0;
|
||||
egoAfrBuf.clear();
|
||||
useAveraging = true;
|
||||
|
@ -93,7 +93,7 @@ void initEgoAveraging(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
bool hasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
#if EFI_CJ125 || defined(__DOXYGEN__)
|
||||
if (boardConfiguration->isCJ125Enabled) {
|
||||
if (CONFIGB(isCJ125Enabled)) {
|
||||
return cjHasAfrSensor(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
}
|
||||
#endif /* EFI_CJ125 */
|
||||
|
@ -102,7 +102,7 @@ bool hasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
float getAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
#if EFI_CJ125 || defined(__DOXYGEN__)
|
||||
if (boardConfiguration->isCJ125Enabled) {
|
||||
if (CONFIGB(isCJ125Enabled)) {
|
||||
return cjGetAfr(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
}
|
||||
#endif /* EFI_CJ125 */
|
||||
|
@ -110,7 +110,7 @@ float getAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
float volts = getVoltageDivided("ego", sensor->hwChannel);
|
||||
|
||||
if (boardConfiguration->afr_type == ES_NarrowBand) {
|
||||
if (CONFIGB(afr_type) == ES_NarrowBand) {
|
||||
float afr = interpolate2d("narrow", volts, engineConfiguration->narrowToWideOxygenBins, engineConfiguration->narrowToWideOxygen, NARROW_BAND_WIDE_BAND_CONVERSION_SIZE);
|
||||
#ifdef EFI_NARROW_EGO_AVERAGING
|
||||
if (useAveraging)
|
||||
|
@ -170,6 +170,6 @@ static void initEgoSensor(afr_sensor_s *sensor, ego_sensor_e type) {
|
|||
}
|
||||
|
||||
void setEgoSensor(ego_sensor_e type DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
boardConfiguration->afr_type = type;
|
||||
CONFIGB(afr_type) = type;
|
||||
initEgoSensor(&engineConfiguration->afr, type);
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ float getMapByVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
*/
|
||||
float getRawMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
if (engineConfiguration->hasFrequencyReportingMapSensor) {
|
||||
return interpolateMsg("rmap", boardConfiguration->mapFrequency0Kpa, 0, boardConfiguration->mapFrequency100Kpa, 100, mapFreq);
|
||||
return interpolateMsg("rmap", CONFIGB(mapFrequency0Kpa), 0, CONFIGB(mapFrequency100Kpa), 100, mapFreq);
|
||||
}
|
||||
|
||||
float voltage = getVoltageDivided("map", engineConfiguration->map.sensor.hwChannel);
|
||||
|
@ -222,7 +222,7 @@ static void printMAPInfo(void) {
|
|||
|
||||
|
||||
if (engineConfiguration->hasFrequencyReportingMapSensor) {
|
||||
scheduleMsg(logger, "instant value=%.2fHz @ %s", mapFreq, hwPortname(boardConfiguration->frequencyReportingMapInputPin));
|
||||
scheduleMsg(logger, "instant value=%.2fHz @ %s", mapFreq, hwPortname(CONFIGB(frequencyReportingMapInputPin)));
|
||||
} else {
|
||||
scheduleMsg(logger, "map type=%d/%s MAP=%.2fkPa mapMinBufferLength=%d", engineConfiguration->map.sensor.type,
|
||||
getAir_pressure_sensor_type_e(engineConfiguration->map.sensor.type),
|
||||
|
@ -265,7 +265,7 @@ void initMapDecoder(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
if (engineConfiguration->hasFrequencyReportingMapSensor) {
|
||||
digital_input_s* digitalMapInput = addWaveAnalyzerDriver("map freq", boardConfiguration->frequencyReportingMapInputPin);
|
||||
digital_input_s* digitalMapInput = addWaveAnalyzerDriver("map freq", CONFIGB(frequencyReportingMapInputPin));
|
||||
startInputDriver(digitalMapInput, true);
|
||||
|
||||
digitalMapInput->widthListeners.registerCallback((VoidInt) digitalMapWidthCallback, NULL);
|
||||
|
|
|
@ -166,9 +166,9 @@ void EnginePins::startIgnitionPins(void) {
|
|||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
NamedOutputPin *output = &enginePins.coils[i];
|
||||
// todo: we need to check if mode has changed
|
||||
if (boardConfiguration->ignitionPins[i] != activeConfiguration.bc.ignitionPins[i]) {
|
||||
output->initPin(output->name, boardConfiguration->ignitionPins[i],
|
||||
&boardConfiguration->ignitionPinMode);
|
||||
if (CONFIGB(ignitionPins)[i] != activeConfiguration.bc.ignitionPins[i]) {
|
||||
output->initPin(output->name, CONFIGB(ignitionPins)[i],
|
||||
&CONFIGB(ignitionPinMode));
|
||||
}
|
||||
}
|
||||
// todo: we need to check if mode has changed
|
||||
|
@ -188,8 +188,8 @@ void EnginePins::startInjectionPins(void) {
|
|||
// todo: we need to check if mode has changed
|
||||
if (engineConfiguration->bc.injectionPins[i] != activeConfiguration.bc.injectionPins[i]) {
|
||||
|
||||
output->initPin(output->name, boardConfiguration->injectionPins[i],
|
||||
&boardConfiguration->injectionPinMode);
|
||||
output->initPin(output->name, CONFIGB(injectionPins)[i],
|
||||
&CONFIGB(injectionPinMode));
|
||||
}
|
||||
}
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
@ -322,17 +322,17 @@ void initOutputPins(void) {
|
|||
// memset(&outputs, 0, sizeof(outputs));
|
||||
|
||||
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
||||
enginePins.sdCsPin.initPin("spi CS5", boardConfiguration->sdCardCsPin);
|
||||
enginePins.sdCsPin.initPin("spi CS5", CONFIGB(sdCardCsPin));
|
||||
#endif /* HAL_USE_SPI */
|
||||
|
||||
// todo: should we move this code closer to the fuel pump logic?
|
||||
enginePins.fuelPumpRelay.initPin("fuel pump relay", boardConfiguration->fuelPumpPin, &boardConfiguration->fuelPumpPinMode);
|
||||
enginePins.fuelPumpRelay.initPin("fuel pump relay", CONFIGB(fuelPumpPin), &CONFIGB(fuelPumpPinMode));
|
||||
|
||||
enginePins.mainRelay.initPin("main relay", boardConfiguration->mainRelayPin, &boardConfiguration->mainRelayPinMode);
|
||||
enginePins.mainRelay.initPin("main relay", CONFIGB(mainRelayPin), &CONFIGB(mainRelayPinMode));
|
||||
|
||||
enginePins.fanRelay.initPin("fan relay", boardConfiguration->fanPin, &boardConfiguration->fanPinMode);
|
||||
enginePins.o2heater.initPin("o2 heater", boardConfiguration->o2heaterPin);
|
||||
enginePins.acRelay.initPin("A/C relay", boardConfiguration->acRelayPin, &boardConfiguration->acRelayPinMode);
|
||||
enginePins.fanRelay.initPin("fan relay", CONFIGB(fanPin), &CONFIGB(fanPinMode));
|
||||
enginePins.o2heater.initPin("o2 heater", CONFIGB(o2heaterPin));
|
||||
enginePins.acRelay.initPin("A/C relay", CONFIGB(acRelayPin), &CONFIGB(acRelayPinMode));
|
||||
|
||||
// digit 1
|
||||
/*
|
||||
|
|
|
@ -38,11 +38,11 @@ static void tachSignalCallback(trigger_event_e ckpSignalType,
|
|||
}
|
||||
|
||||
void initTachometer(void) {
|
||||
if (boardConfiguration->tachOutputPin == GPIO_UNASSIGNED) {
|
||||
if (CONFIGB(tachOutputPin) == GPIO_UNASSIGNED) {
|
||||
return;
|
||||
}
|
||||
|
||||
enginePins.tachOut.initPin("analog tach output", boardConfiguration->tachOutputPin, &boardConfiguration->tachOutputPinMode);
|
||||
enginePins.tachOut.initPin("analog tach output", CONFIGB(tachOutputPin), &CONFIGB(tachOutputPinMode));
|
||||
|
||||
addTriggerEventListener(tachSignalCallback, "tach", engine);
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
if (GET_RPM() < CONFIG(fuelClosedLoopRpmThreshold) ||
|
||||
ENGINE(sensors.clt) < CONFIG(fuelClosedLoopCltThreshold) ||
|
||||
getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(fuelClosedLoopTpsThreshold) ||
|
||||
ENGINE(sensors.currentAfr) < boardConfiguration->fuelClosedLoopAfrLowThreshold ||
|
||||
ENGINE(sensors.currentAfr) < CONFIGB(fuelClosedLoopAfrLowThreshold) ||
|
||||
ENGINE(sensors.currentAfr) > engineConfiguration->fuelClosedLoopAfrHighThreshold) {
|
||||
engine->engineState.fuelPidCorrection = 0;
|
||||
fuelPid.reset();
|
||||
|
|
|
@ -202,7 +202,7 @@ void RpmCalculator::setStopSpinning(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
}
|
||||
|
||||
void RpmCalculator::setSpinningUp(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
if (!boardConfiguration->isFasterEngineSpinUpEnabled)
|
||||
if (!CONFIGB(isFasterEngineSpinUpEnabled))
|
||||
return;
|
||||
// Only a completely stopped and non-spinning engine can enter the spinning-up state.
|
||||
if (isStopped(PASS_ENGINE_PARAMETER_SIGNATURE) && !isSpinning) {
|
||||
|
|
|
@ -100,7 +100,7 @@ void initEngineEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
|
||||
#if EFI_POTENTIOMETER
|
||||
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
||||
initPotentiometers(sharedLogger, &engineConfiguration->bc);
|
||||
initPotentiometers(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif /* HAL_USE_SPI */
|
||||
#endif /* EFI_POTENTIOMETER */
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
/**
|
||||
* MCP42010 digital potentiometer driver
|
||||
*
|
||||
|
@ -90,22 +92,22 @@ static void setPotValue1(int value) {
|
|||
|
||||
#endif /* EFI_POTENTIOMETER */
|
||||
|
||||
void initPotentiometers(Logging *sharedLogger, board_configuration_s *boardConfiguration) {
|
||||
void initPotentiometers(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
logger = sharedLogger;
|
||||
#if EFI_POTENTIOMETER
|
||||
if (boardConfiguration->digitalPotentiometerSpiDevice == SPI_NONE) {
|
||||
if (CONFIGB(digitalPotentiometerSpiDevice) == SPI_NONE) {
|
||||
scheduleMsg(logger, "digiPot spi disabled");
|
||||
return;
|
||||
}
|
||||
turnOnSpi(boardConfiguration->digitalPotentiometerSpiDevice);
|
||||
turnOnSpi(CONFIGB(digitalPotentiometerSpiDevice));
|
||||
|
||||
for (int i = 0; i < DIGIPOT_COUNT; i++) {
|
||||
brain_pin_e csPin = boardConfiguration->digitalPotentiometerChipSelect[i];
|
||||
brain_pin_e csPin = CONFIGB(digitalPotentiometerChipSelect)[i];
|
||||
if (csPin == GPIO_UNASSIGNED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
initPotentiometer(&potConfig[i], getSpiDevice(boardConfiguration->digitalPotentiometerSpiDevice),
|
||||
initPotentiometer(&potConfig[i], getSpiDevice(CONFIGB(digitalPotentiometerSpiDevice)),
|
||||
csPin);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef struct {
|
|||
} Mcp42010Driver;
|
||||
|
||||
//void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, ioportid_t port, ioportmask_t pin);
|
||||
void initPotentiometers(Logging *sharedLogger, board_configuration_s *boardConfiguration);
|
||||
void initPotentiometers(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setPotResistance(Mcp42010Driver *driver, int channel, int resistance);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,12 +43,12 @@ static const SPIConfig accelerometerCfg = {
|
|||
|
||||
void configureAccelerometerPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
// engineConfiguration->LIS302DLCsPin = GPIOE_3; // we have a conflict with VVT output on Miata
|
||||
// boardConfiguration->is_enabled_spi_1 = true; // we have a conflict with PA5 input pin
|
||||
// CONFIGB(is_enabled_spi_1) = true; // we have a conflict with PA5 input pin
|
||||
|
||||
// stm32f4discovery defaults
|
||||
boardConfiguration->spi1mosiPin = GPIOA_7;
|
||||
boardConfiguration->spi1misoPin = GPIOA_6;
|
||||
boardConfiguration->spi1sckPin = GPIOA_5;
|
||||
CONFIGB(spi1mosiPin) = GPIOA_7;
|
||||
CONFIGB(spi1misoPin) = GPIOA_6;
|
||||
CONFIGB(spi1sckPin) = GPIOA_5;
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
if (engineConfiguration->LIS302DLCsPin == GPIO_UNASSIGNED)
|
||||
return; // not used
|
||||
|
||||
if (!boardConfiguration->is_enabled_spi_1)
|
||||
if (!CONFIGB(is_enabled_spi_1))
|
||||
return; // temporary
|
||||
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
||||
driver = getSpiDevice(engineConfiguration->accelerometerSpiDevice);
|
||||
|
@ -86,8 +86,8 @@ void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
initSpiCs((SPIConfig *)driver->config, engineConfiguration->LIS302DLCsPin);
|
||||
|
||||
// memsCs.initPin("LIS302 CS", engineConfiguration->LIS302DLCsPin);
|
||||
// memsCfg.ssport = getHwPort("mmc", boardConfiguration->sdCardCsPin);
|
||||
// memsCfg.sspad = getHwPin("mmc", boardConfiguration->sdCardCsPin);
|
||||
// memsCfg.ssport = getHwPort("mmc", CONFIGB(sdCardCsPin));
|
||||
// memsCfg.sspad = getHwPin("mmc", CONFIGB(sdCardCsPin));
|
||||
|
||||
|
||||
/* LIS302DL initialization.*/
|
||||
|
|
|
@ -630,7 +630,7 @@ static void configureInputs(void) {
|
|||
addChannel("OilP", engineConfiguration->oilPressure.hwChannel, ADC_SLOW);
|
||||
addChannel("AC", engineConfiguration->acSwitchAdc, ADC_SLOW);
|
||||
|
||||
if (boardConfiguration->isCJ125Enabled) {
|
||||
if (CONFIGB(isCJ125Enabled)) {
|
||||
addChannel("cj125ur", engineConfiguration->cj125ur, ADC_SLOW);
|
||||
addChannel("cj125ua", engineConfiguration->cj125ua, ADC_SLOW);
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ void initAdcInputs(bool boardTestMode) {
|
|||
pwmEnablePeriodicNotification(EFI_INTERNAL_SLOW_ADC_PWM);
|
||||
#endif /* HAL_USE_PWM */
|
||||
|
||||
if (boardConfiguration->isFastAdcEnabled) {
|
||||
if (CONFIGB(isFastAdcEnabled)) {
|
||||
fastAdc.init();
|
||||
/*
|
||||
* Initializes the PWM driver.
|
||||
|
|
|
@ -105,8 +105,8 @@ void commonTxInit(int eid) {
|
|||
* send CAN message from txmsg buffer
|
||||
*/
|
||||
static void sendCanMessage2(int size) {
|
||||
CANDriver *device = detectCanDevice(boardConfiguration->canRxPin,
|
||||
boardConfiguration->canTxPin);
|
||||
CANDriver *device = detectCanDevice(CONFIGB(canRxPin),
|
||||
CONFIGB(canTxPin));
|
||||
if (device == NULL) {
|
||||
warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN configuration issue");
|
||||
return;
|
||||
|
@ -227,8 +227,8 @@ static void canInfoNBCBroadcast(can_nbc_e typeOfNBC) {
|
|||
}
|
||||
|
||||
static void canRead(void) {
|
||||
CANDriver *device = detectCanDevice(boardConfiguration->canRxPin,
|
||||
boardConfiguration->canTxPin);
|
||||
CANDriver *device = detectCanDevice(CONFIGB(canRxPin),
|
||||
CONFIGB(canTxPin));
|
||||
if (device == NULL) {
|
||||
warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN configuration issue");
|
||||
return;
|
||||
|
@ -276,8 +276,8 @@ static void canInfo(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
scheduleMsg(&logger, "CAN TX %s", hwPortname(boardConfiguration->canTxPin));
|
||||
scheduleMsg(&logger, "CAN RX %s", hwPortname(boardConfiguration->canRxPin));
|
||||
scheduleMsg(&logger, "CAN TX %s", hwPortname(CONFIGB(canTxPin)));
|
||||
scheduleMsg(&logger, "CAN RX %s", hwPortname(CONFIGB(canRxPin)));
|
||||
scheduleMsg(&logger, "type=%d canReadEnabled=%s canWriteEnabled=%s period=%d", engineConfiguration->canNbcType,
|
||||
boolToString(engineConfiguration->canReadEnabled), boolToString(engineConfiguration->canWriteEnabled),
|
||||
engineConfiguration->canSleepPeriod);
|
||||
|
@ -297,8 +297,8 @@ void postCanState(TunerStudioOutputChannels *tsOutputChannels) {
|
|||
}
|
||||
|
||||
void enableFrankensoCan(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
boardConfiguration->canTxPin = GPIOB_6;
|
||||
boardConfiguration->canRxPin = GPIOB_12;
|
||||
CONFIGB(canTxPin) = GPIOB_6;
|
||||
CONFIGB(canRxPin) = GPIOB_12;
|
||||
engineConfiguration->canReadEnabled = false;
|
||||
}
|
||||
|
||||
|
@ -308,17 +308,17 @@ void stopCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
}
|
||||
|
||||
void startCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
efiSetPadMode("CAN TX", boardConfiguration->canTxPin, PAL_MODE_ALTERNATE(EFI_CAN_TX_AF));
|
||||
efiSetPadMode("CAN RX", boardConfiguration->canRxPin, PAL_MODE_ALTERNATE(EFI_CAN_RX_AF));
|
||||
efiSetPadMode("CAN TX", CONFIGB(canTxPin), PAL_MODE_ALTERNATE(EFI_CAN_TX_AF));
|
||||
efiSetPadMode("CAN RX", CONFIGB(canRxPin), PAL_MODE_ALTERNATE(EFI_CAN_RX_AF));
|
||||
}
|
||||
|
||||
void initCan(void) {
|
||||
isCanEnabled = (boardConfiguration->canTxPin != GPIO_UNASSIGNED) && (boardConfiguration->canRxPin != GPIO_UNASSIGNED);
|
||||
isCanEnabled = (CONFIGB(canTxPin) != GPIO_UNASSIGNED) && (CONFIGB(canRxPin) != GPIO_UNASSIGNED);
|
||||
if (isCanEnabled) {
|
||||
if (!isValidCanTxPin(boardConfiguration->canTxPin))
|
||||
firmwareError(CUSTOM_OBD_70, "invalid CAN TX %s", hwPortname(boardConfiguration->canTxPin));
|
||||
if (!isValidCanRxPin(boardConfiguration->canRxPin))
|
||||
firmwareError(CUSTOM_OBD_70, "invalid CAN RX %s", hwPortname(boardConfiguration->canRxPin));
|
||||
if (!isValidCanTxPin(CONFIGB(canTxPin)))
|
||||
firmwareError(CUSTOM_OBD_70, "invalid CAN TX %s", hwPortname(CONFIGB(canTxPin)));
|
||||
if (!isValidCanRxPin(CONFIGB(canRxPin)))
|
||||
firmwareError(CUSTOM_OBD_70, "invalid CAN RX %s", hwPortname(CONFIGB(canRxPin)));
|
||||
}
|
||||
|
||||
addConsoleAction("caninfo", canInfo);
|
||||
|
|
|
@ -56,17 +56,17 @@ static void extIonCallback(EXTDriver *extp, expchannel_t channel) {
|
|||
|
||||
void cdmIonInit(void) {
|
||||
// todo: allow 'GPIOA_0' once we migrate to new mandatory configuration
|
||||
if (boardConfiguration->cdmInputPin == GPIOA_0 || boardConfiguration->cdmInputPin == GPIO_UNASSIGNED) {
|
||||
if (CONFIGB(cdmInputPin) == GPIOA_0 || CONFIGB(cdmInputPin) == GPIO_UNASSIGNED) {
|
||||
return;
|
||||
}
|
||||
int pin = (int)boardConfiguration->cdmInputPin;
|
||||
int pin = (int)CONFIGB(cdmInputPin);
|
||||
if (pin <= 0 || pin > (int)GPIO_UNASSIGNED) {
|
||||
// todo: remove this protection once we migrate to new mandatory configuration
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
enableExti(boardConfiguration->cdmInputPin, EXT_CH_MODE_RISING_EDGE, extIonCallback);
|
||||
enableExti(CONFIGB(cdmInputPin), EXT_CH_MODE_RISING_EDGE, extIonCallback);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -97,13 +97,13 @@ void unlockSpi(void) {
|
|||
}
|
||||
|
||||
static void initSpiModules(board_configuration_s *boardConfiguration) {
|
||||
if (boardConfiguration->is_enabled_spi_1) {
|
||||
if (CONFIGB(is_enabled_spi_1)) {
|
||||
turnOnSpi(SPI_DEVICE_1);
|
||||
}
|
||||
if (boardConfiguration->is_enabled_spi_2) {
|
||||
if (CONFIGB(is_enabled_spi_2)) {
|
||||
turnOnSpi(SPI_DEVICE_2);
|
||||
}
|
||||
if (boardConfiguration->is_enabled_spi_3) {
|
||||
if (CONFIGB(is_enabled_spi_3)) {
|
||||
turnOnSpi(SPI_DEVICE_3);
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
|||
mapAveragingAdcCallback(fastAdc.samples[fastMapSampleIndex]);
|
||||
#endif /* EFI_MAP_AVERAGING */
|
||||
#if EFI_HIP_9011 || defined(__DOXYGEN__)
|
||||
if (boardConfiguration->isHip9011Enabled) {
|
||||
if (CONFIGB(isHip9011Enabled)) {
|
||||
hipAdcCallback(fastAdc.samples[hipSampleIndex]);
|
||||
}
|
||||
#endif
|
||||
|
@ -390,13 +390,13 @@ void initHardware(Logging *l) {
|
|||
#endif
|
||||
|
||||
bool isBoardTestMode_b;
|
||||
if (boardConfiguration->boardTestModeJumperPin != GPIO_UNASSIGNED) {
|
||||
efiSetPadMode("board test", boardConfiguration->boardTestModeJumperPin,
|
||||
if (CONFIGB(boardTestModeJumperPin) != GPIO_UNASSIGNED) {
|
||||
efiSetPadMode("board test", CONFIGB(boardTestModeJumperPin),
|
||||
PAL_MODE_INPUT_PULLUP);
|
||||
isBoardTestMode_b = (!efiReadPin(boardConfiguration->boardTestModeJumperPin));
|
||||
isBoardTestMode_b = (!efiReadPin(CONFIGB(boardTestModeJumperPin)));
|
||||
|
||||
// we can now relese this pin, it is actually used as output sometimes
|
||||
unmarkPin(boardConfiguration->boardTestModeJumperPin);
|
||||
unmarkPin(CONFIGB(boardTestModeJumperPin));
|
||||
} else {
|
||||
isBoardTestMode_b = false;
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ void initHardware(Logging *l) {
|
|||
initOutputPins();
|
||||
|
||||
#if EFI_MAX_31855
|
||||
initMax31855(sharedLogger, getSpiDevice(boardConfiguration->max31855spiDevice), boardConfiguration->max31855_cs);
|
||||
initMax31855(sharedLogger, getSpiDevice(CONFIGB(max31855spiDevice)), CONFIGB(max31855_cs));
|
||||
#endif /* EFI_MAX_31855 */
|
||||
|
||||
#if EFI_CAN_SUPPORT
|
||||
|
|
|
@ -54,21 +54,21 @@ static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
|||
joyTotal++;
|
||||
joystick_button_e button;
|
||||
// todo: I guess it's time to reduce code duplication and start working with an array
|
||||
if (channel == getHwPin("joy", boardConfiguration->joystickCenterPin)) {
|
||||
if (channel == getHwPin("joy", CONFIGB(joystickCenterPin))) {
|
||||
joyCenter++;
|
||||
button = JB_CENTER;
|
||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickAPin)) {
|
||||
} else if (channel == getHwPin("joy", CONFIGB(joystickAPin))) {
|
||||
joyA++;
|
||||
button = JB_BUTTON_A;
|
||||
/* not used so far
|
||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickBPin)) {
|
||||
} else if (channel == getHwPin("joy", CONFIGB(joystickBPin))) {
|
||||
joyB++;
|
||||
button = JB_BUTTON_B;
|
||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickCPin)) {
|
||||
} else if (channel == getHwPin("joy", CONFIGB(joystickCPin))) {
|
||||
joyC++;
|
||||
button = JB_BUTTON_C;
|
||||
*/
|
||||
} else if (channel == getHwPin("joy", boardConfiguration->joystickDPin)) {
|
||||
} else if (channel == getHwPin("joy", CONFIGB(joystickDPin))) {
|
||||
joyD++;
|
||||
button = JB_BUTTON_D;
|
||||
} else {
|
||||
|
@ -84,19 +84,19 @@ static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
|||
|
||||
static void joystickInfo(void) {
|
||||
scheduleMsg(sharedLogger, "total %d center=%d@%s", joyTotal, joyCenter,
|
||||
hwPortname(boardConfiguration->joystickCenterPin));
|
||||
scheduleMsg(sharedLogger, "a=%d@%s", joyA, hwPortname(boardConfiguration->joystickAPin));
|
||||
scheduleMsg(sharedLogger, "b=%d@%s", joyB, hwPortname(boardConfiguration->joystickBPin));
|
||||
scheduleMsg(sharedLogger, "c=%d@%s", joyC, hwPortname(boardConfiguration->joystickCPin));
|
||||
scheduleMsg(sharedLogger, "d=%d@%s", joyD, hwPortname(boardConfiguration->joystickDPin));
|
||||
hwPortname(CONFIGB(joystickCenterPin)));
|
||||
scheduleMsg(sharedLogger, "a=%d@%s", joyA, hwPortname(CONFIGB(joystickAPin)));
|
||||
scheduleMsg(sharedLogger, "b=%d@%s", joyB, hwPortname(CONFIGB(joystickBPin)));
|
||||
scheduleMsg(sharedLogger, "c=%d@%s", joyC, hwPortname(CONFIGB(joystickCPin)));
|
||||
scheduleMsg(sharedLogger, "d=%d@%s", joyD, hwPortname(CONFIGB(joystickDPin)));
|
||||
}
|
||||
|
||||
static bool isJoystickEnabled() {
|
||||
return boardConfiguration->joystickCenterPin != GPIO_UNASSIGNED ||
|
||||
boardConfiguration->joystickAPin != GPIO_UNASSIGNED ||
|
||||
// not used so far boardConfiguration->joystickBPin != GPIO_UNASSIGNED ||
|
||||
// not used so far boardConfiguration->joystickCPin != GPIO_UNASSIGNED ||
|
||||
boardConfiguration->joystickDPin != GPIO_UNASSIGNED;
|
||||
return CONFIGB(joystickCenterPin) != GPIO_UNASSIGNED ||
|
||||
CONFIGB(joystickAPin) != GPIO_UNASSIGNED ||
|
||||
// not used so far CONFIGB(joystickBPin) != GPIO_UNASSIGNED ||
|
||||
// not used so far CONFIGB(joystickCPin) != GPIO_UNASSIGNED ||
|
||||
CONFIGB(joystickDPin) != GPIO_UNASSIGNED;
|
||||
}
|
||||
|
||||
void initJoystick(Logging *shared) {
|
||||
|
@ -104,17 +104,17 @@ void initJoystick(Logging *shared) {
|
|||
return;
|
||||
sharedLogger = shared;
|
||||
|
||||
enableExti(boardConfiguration->joystickCenterPin, EXT_CH_MODE_RISING_EDGE, extCallback);
|
||||
enableExti(boardConfiguration->joystickAPin, EXT_CH_MODE_RISING_EDGE, extCallback);
|
||||
// not used so far applyPin(boardConfiguration->joystickBPin);
|
||||
// not used so far applyPin(boardConfiguration->joystickCPin);
|
||||
enableExti(boardConfiguration->joystickDPin, EXT_CH_MODE_RISING_EDGE, extCallback);
|
||||
enableExti(CONFIGB(joystickCenterPin), EXT_CH_MODE_RISING_EDGE, extCallback);
|
||||
enableExti(CONFIGB(joystickAPin), EXT_CH_MODE_RISING_EDGE, extCallback);
|
||||
// not used so far applyPin(CONFIGB(joystickBPin));
|
||||
// not used so far applyPin(CONFIGB(joystickCPin));
|
||||
enableExti(CONFIGB(joystickDPin), EXT_CH_MODE_RISING_EDGE, extCallback);
|
||||
|
||||
efiSetPadMode("joy center", boardConfiguration->joystickCenterPin, PAL_MODE_INPUT_PULLUP);
|
||||
efiSetPadMode("joy A", boardConfiguration->joystickAPin, PAL_MODE_INPUT_PULLUP);
|
||||
// not used so far efiSetPadMode("joy B", boardConfiguration->joystickBPin, PAL_MODE_INPUT_PULLUP);
|
||||
// not used so far efiSetPadMode("joy C", boardConfiguration->joystickCPin, PAL_MODE_INPUT_PULLUP);
|
||||
efiSetPadMode("joy D", boardConfiguration->joystickDPin, PAL_MODE_INPUT_PULLUP);
|
||||
efiSetPadMode("joy center", CONFIGB(joystickCenterPin), PAL_MODE_INPUT_PULLUP);
|
||||
efiSetPadMode("joy A", CONFIGB(joystickAPin), PAL_MODE_INPUT_PULLUP);
|
||||
// not used so far efiSetPadMode("joy B", CONFIGB(joystickBPin), PAL_MODE_INPUT_PULLUP);
|
||||
// not used so far efiSetPadMode("joy C", CONFIGB(joystickCPin), PAL_MODE_INPUT_PULLUP);
|
||||
efiSetPadMode("joy D", CONFIGB(joystickDPin), PAL_MODE_INPUT_PULLUP);
|
||||
|
||||
addConsoleAction("joystickinfo", joystickInfo);
|
||||
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
#include "pin_repository.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "engine_configuration.h"
|
||||
#include "engine.h"
|
||||
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
extern board_configuration_s *boardConfiguration;
|
||||
EXTERN_ENGINE;
|
||||
|
||||
static Logging *logger;
|
||||
|
||||
|
@ -84,18 +83,18 @@ static void writePad(const char *msg, brain_pin_e pin, int bit) {
|
|||
//-----------------------------------------------------------------------------
|
||||
static void lcd_HD44780_write(uint8_t data) {
|
||||
if (engineConfiguration->displayMode == DM_HD44780) {
|
||||
writePad("lcd", boardConfiguration->HD44780_db7,
|
||||
writePad("lcd", CONFIGB(HD44780_db7),
|
||||
data & 0x80 ? 1 : 0);
|
||||
writePad("lcd", boardConfiguration->HD44780_db6,
|
||||
writePad("lcd", CONFIGB(HD44780_db6),
|
||||
data & 0x40 ? 1 : 0);
|
||||
writePad("lcd", boardConfiguration->HD44780_db5,
|
||||
writePad("lcd", CONFIGB(HD44780_db5),
|
||||
data & 0x20 ? 1 : 0);
|
||||
writePad("lcd", boardConfiguration->HD44780_db4,
|
||||
writePad("lcd", CONFIGB(HD44780_db4),
|
||||
data & 0x10 ? 1 : 0);
|
||||
|
||||
writePad("lcd", boardConfiguration->HD44780_e, 1); // En high
|
||||
writePad("lcd", CONFIGB(HD44780_e), 1); // En high
|
||||
lcdSleep(10); // enable pulse must be >450ns
|
||||
writePad("lcd", boardConfiguration->HD44780_e, 0); // En low
|
||||
writePad("lcd", CONFIGB(HD44780_e), 0); // En low
|
||||
lcdSleep(40); // commands need > 37us to settle
|
||||
} else {
|
||||
|
||||
|
@ -124,7 +123,7 @@ static void lcd_HD44780_write(uint8_t data) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
void lcd_HD44780_write_command(uint8_t data) {
|
||||
palClearPad(getHwPort("lcd", boardConfiguration->HD44780_rs), getHwPin("lcd", boardConfiguration->HD44780_rs));
|
||||
palClearPad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs)));
|
||||
|
||||
lcd_HD44780_write(data);
|
||||
lcd_HD44780_write(data << 4);
|
||||
|
@ -132,13 +131,13 @@ void lcd_HD44780_write_command(uint8_t data) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
void lcd_HD44780_write_data(uint8_t data) {
|
||||
palSetPad(getHwPort("lcd", boardConfiguration->HD44780_rs), getHwPin("lcd", boardConfiguration->HD44780_rs));
|
||||
palSetPad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs)));
|
||||
|
||||
lcd_HD44780_write(data);
|
||||
lcd_HD44780_write(data << 4);
|
||||
currentColumn++;
|
||||
|
||||
palClearPad(getHwPort("lcd", boardConfiguration->HD44780_rs), getHwPin("lcd", boardConfiguration->HD44780_rs));
|
||||
palClearPad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs)));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -169,14 +168,15 @@ void lcd_HD44780_print_string(const char* string) {
|
|||
while (*string != 0x00)
|
||||
lcd_HD44780_print_char(*string++);
|
||||
}
|
||||
//getHwPin(boardConfiguration->HD44780_db7)
|
||||
static void lcdInfo(void) {
|
||||
scheduleMsg(logger, "HD44780 RS=%s", hwPortname(boardConfiguration->HD44780_rs));
|
||||
scheduleMsg(logger, "HD44780 E=%s", hwPortname(boardConfiguration->HD44780_e));
|
||||
scheduleMsg(logger, "HD44780 D4=%s", hwPortname(boardConfiguration->HD44780_db4));
|
||||
scheduleMsg(logger, "HD44780 D5=%s", hwPortname(boardConfiguration->HD44780_db5));
|
||||
scheduleMsg(logger, "HD44780 D6=%s", hwPortname(boardConfiguration->HD44780_db6));
|
||||
scheduleMsg(logger, "HD44780 D7=%s", hwPortname(boardConfiguration->HD44780_db7));
|
||||
|
||||
//getHwPin(CONFIGB(HD44780_db7))
|
||||
static void lcdInfo(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
scheduleMsg(logger, "HD44780 RS=%s", hwPortname(CONFIGB(HD44780_rs)));
|
||||
scheduleMsg(logger, "HD44780 E=%s", hwPortname(CONFIGB(HD44780_e)));
|
||||
scheduleMsg(logger, "HD44780 D4=%s", hwPortname(CONFIGB(HD44780_db4)));
|
||||
scheduleMsg(logger, "HD44780 D5=%s", hwPortname(CONFIGB(HD44780_db5)));
|
||||
scheduleMsg(logger, "HD44780 D6=%s", hwPortname(CONFIGB(HD44780_db6)));
|
||||
scheduleMsg(logger, "HD44780 D7=%s", hwPortname(CONFIGB(HD44780_db7)));
|
||||
}
|
||||
|
||||
void lcd_HD44780_init(Logging *sharedLogger) {
|
||||
|
@ -194,19 +194,19 @@ void lcd_HD44780_init(Logging *sharedLogger) {
|
|||
|
||||
if (engineConfiguration->displayMode == DM_HD44780) {
|
||||
// initialize hardware lines
|
||||
efiSetPadMode("lcd RS", boardConfiguration->HD44780_rs, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd E", boardConfiguration->HD44780_e, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB4", boardConfiguration->HD44780_db4, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB5", boardConfiguration->HD44780_db5, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB6", boardConfiguration->HD44780_db6, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB7", boardConfiguration->HD44780_db7, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd RS", CONFIGB(HD44780_rs), PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd E", CONFIGB(HD44780_e), PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB4", CONFIGB(HD44780_db4), PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB5", CONFIGB(HD44780_db5), PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB6", CONFIGB(HD44780_db6), PAL_MODE_OUTPUT_PUSHPULL);
|
||||
efiSetPadMode("lcd DB7", CONFIGB(HD44780_db7), PAL_MODE_OUTPUT_PUSHPULL);
|
||||
// and zero values
|
||||
palWritePad(getHwPort("lcd", boardConfiguration->HD44780_rs), getHwPin("lcd", boardConfiguration->HD44780_rs), 0);
|
||||
palWritePad(getHwPort("lcd", boardConfiguration->HD44780_e), getHwPin("lcd", boardConfiguration->HD44780_e), 0);
|
||||
palWritePad(getHwPort("lcd", boardConfiguration->HD44780_db4), getHwPin("lcd", boardConfiguration->HD44780_db4), 0);
|
||||
palWritePad(getHwPort("lcd", boardConfiguration->HD44780_db5), getHwPin("lcd", boardConfiguration->HD44780_db5), 0);
|
||||
palWritePad(getHwPort("lcd", boardConfiguration->HD44780_db6), getHwPin("lcd", boardConfiguration->HD44780_db6), 0);
|
||||
palWritePad(getHwPort("lcd", boardConfiguration->HD44780_db7), getHwPin("lcd", boardConfiguration->HD44780_db7), 0);
|
||||
palWritePad(getHwPort("lcd", CONFIGB(HD44780_rs)), getHwPin("lcd", CONFIGB(HD44780_rs)), 0);
|
||||
palWritePad(getHwPort("lcd", CONFIGB(HD44780_e)), getHwPin("lcd", CONFIGB(HD44780_e)), 0);
|
||||
palWritePad(getHwPort("lcd", CONFIGB(HD44780_db4)), getHwPin("lcd", CONFIGB(HD44780_db4)), 0);
|
||||
palWritePad(getHwPort("lcd", CONFIGB(HD44780_db5)), getHwPin("lcd", CONFIGB(HD44780_db5)), 0);
|
||||
palWritePad(getHwPort("lcd", CONFIGB(HD44780_db6)), getHwPin("lcd", CONFIGB(HD44780_db6)), 0);
|
||||
palWritePad(getHwPort("lcd", CONFIGB(HD44780_db7)), getHwPin("lcd", CONFIGB(HD44780_db7)), 0);
|
||||
}
|
||||
|
||||
chThdSleepMilliseconds(20); // LCD needs some time to wake up
|
||||
|
|
|
@ -39,11 +39,11 @@ static void showEgtInfo(void) {
|
|||
#if EFI_PROD_CODE
|
||||
printSpiState(logger, boardConfiguration);
|
||||
|
||||
scheduleMsg(logger, "EGT spi: %d", boardConfiguration->max31855spiDevice);
|
||||
scheduleMsg(logger, "EGT spi: %d", CONFIGB(max31855spiDevice));
|
||||
|
||||
for (int i = 0; i < EGT_CHANNEL_COUNT; i++) {
|
||||
if (boardConfiguration->max31855_cs[i] != GPIO_UNASSIGNED) {
|
||||
scheduleMsg(logger, "%d ETG @ %s", i, hwPortname(boardConfiguration->max31855_cs[i]));
|
||||
if (CONFIGB(max31855_cs)[i] != GPIO_UNASSIGNED) {
|
||||
scheduleMsg(logger, "%d ETG @ %s", i, hwPortname(CONFIGB(max31855_cs)[i]));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -340,7 +340,7 @@ static void cjCalibrate(void) {
|
|||
}
|
||||
|
||||
static void cjStart(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
if (!boardConfiguration->isCJ125Enabled) {
|
||||
if (!CONFIGB(isCJ125Enabled)) {
|
||||
scheduleMsg(logger, "cj125 is disabled.");
|
||||
return;
|
||||
}
|
||||
|
@ -395,12 +395,12 @@ static void cjSetIdleHeater(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
}
|
||||
|
||||
static void cjStartHeaterControl(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
if (boardConfiguration->wboHeaterPin != GPIO_UNASSIGNED) {
|
||||
if (CONFIGB(wboHeaterPin) != GPIO_UNASSIGNED) {
|
||||
scheduleMsg(logger, "cj125: Starting heater control");
|
||||
// todo: use custom pin state method, turn pin off while not running
|
||||
startSimplePwmExt(&wboHeaterControl, "wboHeaterPin",
|
||||
&engine->executor,
|
||||
boardConfiguration->wboHeaterPin,
|
||||
CONFIGB(wboHeaterPin),
|
||||
&wboHeaterPin, CJ125_HEATER_PWM_FREQ, 0.0f, applyPinState);
|
||||
cjSetIdleHeater(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
}
|
||||
|
@ -441,32 +441,32 @@ static void cjInitPid(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
// engineConfiguration->spi2SckMode = PAL_STM32_OTYPE_OPENDRAIN; // 4
|
||||
// engineConfiguration->spi2MosiMode = PAL_STM32_OTYPE_OPENDRAIN; // 4
|
||||
// engineConfiguration->spi2MisoMode = PAL_STM32_PUDR_PULLUP; // 32
|
||||
// boardConfiguration->cj125CsPin = GPIOA_15;
|
||||
// CONFIGB(cj125CsPin) = GPIOA_15;
|
||||
// engineConfiguration->cj125CsPinMode = OM_OPENDRAIN;
|
||||
|
||||
void cj125defaultPinout(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
engineConfiguration->cj125ua = EFI_ADC_13; // PC3
|
||||
engineConfiguration->cj125ur = EFI_ADC_4; // PA4
|
||||
boardConfiguration->wboHeaterPin = GPIOC_13;
|
||||
CONFIGB(wboHeaterPin) = GPIOC_13;
|
||||
|
||||
boardConfiguration->isCJ125Enabled = false;
|
||||
CONFIGB(isCJ125Enabled) = false;
|
||||
|
||||
boardConfiguration->spi2mosiPin = GPIOB_15;
|
||||
boardConfiguration->spi2misoPin = GPIOB_14;
|
||||
boardConfiguration->spi2sckPin = GPIOB_13;
|
||||
CONFIGB(spi2mosiPin) = GPIOB_15;
|
||||
CONFIGB(spi2misoPin) = GPIOB_14;
|
||||
CONFIGB(spi2sckPin) = GPIOB_13;
|
||||
|
||||
boardConfiguration->cj125CsPin = GPIOB_0;
|
||||
boardConfiguration->isCJ125Enabled = true;
|
||||
boardConfiguration->is_enabled_spi_2 = true;
|
||||
CONFIGB(cj125CsPin) = GPIOB_0;
|
||||
CONFIGB(isCJ125Enabled) = true;
|
||||
CONFIGB(is_enabled_spi_2) = true;
|
||||
}
|
||||
|
||||
static void cjStartSpi(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
cj125Cs.initPin("cj125 CS", boardConfiguration->cj125CsPin,
|
||||
cj125Cs.initPin("cj125 CS", CONFIGB(cj125CsPin),
|
||||
&engineConfiguration->cj125CsPinMode);
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
cj125spicfg.ssport = getHwPort("cj125", boardConfiguration->cj125CsPin);
|
||||
cj125spicfg.sspad = getHwPin("cj125", boardConfiguration->cj125CsPin);
|
||||
cj125spicfg.ssport = getHwPort("cj125", CONFIGB(cj125CsPin));
|
||||
cj125spicfg.sspad = getHwPin("cj125", CONFIGB(cj125CsPin));
|
||||
driver = getSpiDevice(engineConfiguration->cj125SpiDevice);
|
||||
scheduleMsg(logger, "cj125: Starting SPI driver");
|
||||
spiStart(driver, &cj125spicfg);
|
||||
|
@ -590,7 +590,7 @@ static msg_t cjThread(void)
|
|||
|
||||
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
|
||||
static bool cjCheckConfig(void) {
|
||||
if (!boardConfiguration->isCJ125Enabled) {
|
||||
if (!CONFIGB(isCJ125Enabled)) {
|
||||
scheduleMsg(logger, "cj125 is disabled. Failed!");
|
||||
return false;
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ float cjGetAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
}
|
||||
|
||||
bool cjHasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
if (!boardConfiguration->isCJ125Enabled)
|
||||
if (!CONFIGB(isCJ125Enabled))
|
||||
return false;
|
||||
#if ! EFI_UNIT_TEST
|
||||
// check if controller is functioning
|
||||
|
@ -680,7 +680,7 @@ void cjPostState(TunerStudioOutputChannels *tsOutputChannels) {
|
|||
void initCJ125(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
logger = sharedLogger;
|
||||
|
||||
if (!boardConfiguration->isCJ125Enabled)
|
||||
if (!CONFIGB(isCJ125Enabled))
|
||||
return;
|
||||
|
||||
if (CONFIG(cj125ur) == EFI_ADC_NONE || CONFIG(cj125ua) == EFI_ADC_NONE) {
|
||||
|
@ -688,7 +688,7 @@ void initCJ125(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (boardConfiguration->wboHeaterPin == GPIO_UNASSIGNED) {
|
||||
if (CONFIGB(wboHeaterPin) == GPIO_UNASSIGNED) {
|
||||
scheduleMsg(logger, "cj125 init error! wboHeaterPin is required.");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -240,11 +240,11 @@ static int getSpiAf(SPIDriver *driver) {
|
|||
brain_pin_e getMisoPin(spi_device_e device) {
|
||||
switch(device) {
|
||||
case SPI_DEVICE_1:
|
||||
return boardConfiguration->spi1misoPin;
|
||||
return CONFIGB(spi1misoPin);
|
||||
case SPI_DEVICE_2:
|
||||
return boardConfiguration->spi2misoPin;
|
||||
return CONFIGB(spi2misoPin);
|
||||
case SPI_DEVICE_3:
|
||||
return boardConfiguration->spi3misoPin;
|
||||
return CONFIGB(spi3misoPin);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -254,11 +254,11 @@ brain_pin_e getMisoPin(spi_device_e device) {
|
|||
brain_pin_e getMosiPin(spi_device_e device) {
|
||||
switch(device) {
|
||||
case SPI_DEVICE_1:
|
||||
return boardConfiguration->spi1mosiPin;
|
||||
return CONFIGB(spi1mosiPin);
|
||||
case SPI_DEVICE_2:
|
||||
return boardConfiguration->spi2mosiPin;
|
||||
return CONFIGB(spi2mosiPin);
|
||||
case SPI_DEVICE_3:
|
||||
return boardConfiguration->spi3mosiPin;
|
||||
return CONFIGB(spi3mosiPin);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -268,11 +268,11 @@ brain_pin_e getMosiPin(spi_device_e device) {
|
|||
brain_pin_e getSckPin(spi_device_e device) {
|
||||
switch(device) {
|
||||
case SPI_DEVICE_1:
|
||||
return boardConfiguration->spi1sckPin;
|
||||
return CONFIGB(spi1sckPin);
|
||||
case SPI_DEVICE_2:
|
||||
return boardConfiguration->spi2sckPin;
|
||||
return CONFIGB(spi2sckPin);
|
||||
case SPI_DEVICE_3:
|
||||
return boardConfiguration->spi3sckPin;
|
||||
return CONFIGB(spi3sckPin);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -237,11 +237,11 @@ static int getSpiAf(SPIDriver *driver) {
|
|||
brain_pin_e getMisoPin(spi_device_e device) {
|
||||
switch(device) {
|
||||
case SPI_DEVICE_1:
|
||||
return boardConfiguration->spi1misoPin;
|
||||
return CONFIGB(spi1misoPin);
|
||||
case SPI_DEVICE_2:
|
||||
return boardConfiguration->spi2misoPin;
|
||||
return CONFIGB(spi2misoPin);
|
||||
case SPI_DEVICE_3:
|
||||
return boardConfiguration->spi3misoPin;
|
||||
return CONFIGB(spi3misoPin);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -251,11 +251,11 @@ brain_pin_e getMisoPin(spi_device_e device) {
|
|||
brain_pin_e getMosiPin(spi_device_e device) {
|
||||
switch(device) {
|
||||
case SPI_DEVICE_1:
|
||||
return boardConfiguration->spi1mosiPin;
|
||||
return CONFIGB(spi1mosiPin);
|
||||
case SPI_DEVICE_2:
|
||||
return boardConfiguration->spi2mosiPin;
|
||||
return CONFIGB(spi2mosiPin);
|
||||
case SPI_DEVICE_3:
|
||||
return boardConfiguration->spi3mosiPin;
|
||||
return CONFIGB(spi3mosiPin);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -265,11 +265,11 @@ brain_pin_e getMosiPin(spi_device_e device) {
|
|||
brain_pin_e getSckPin(spi_device_e device) {
|
||||
switch(device) {
|
||||
case SPI_DEVICE_1:
|
||||
return boardConfiguration->spi1sckPin;
|
||||
return CONFIGB(spi1sckPin);
|
||||
case SPI_DEVICE_2:
|
||||
return boardConfiguration->spi2sckPin;
|
||||
return CONFIGB(spi2sckPin);
|
||||
case SPI_DEVICE_3:
|
||||
return boardConfiguration->spi3sckPin;
|
||||
return CONFIGB(spi3sckPin);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -186,6 +186,7 @@ void runRusEfi(void) {
|
|||
* In order to have complete flexibility configuration has to go before anything else.
|
||||
*/
|
||||
readConfiguration(&sharedLogger);
|
||||
// TODO: need to fix this place!!! should be a version of PASS_ENGINE_PARAMETER_SIGNATURE somehow
|
||||
prepareVoidConfiguration(&activeConfiguration);
|
||||
|
||||
/**
|
||||
|
@ -239,7 +240,7 @@ void runRusEfi(void) {
|
|||
updateDevConsoleState();
|
||||
#endif /* EFI_CLI_SUPPORT */
|
||||
|
||||
chThdSleepMilliseconds(boardConfiguration->consoleLoopPeriod);
|
||||
chThdSleepMilliseconds(CONFIGB(consoleLoopPeriod));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ static void resetTrigger(EngineTestHelper ð) {
|
|||
|
||||
static void testNoiselessDecoderProcedure(EngineTestHelper ð, int errorToleranceCnt DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
printf("*** (bc->useNoiselessTriggerDecoder = %s)\r\n",
|
||||
boardConfiguration->useNoiselessTriggerDecoder ? "true" : "false");
|
||||
CONFIGB(useNoiselessTriggerDecoder) ? "true" : "false");
|
||||
|
||||
resetTrigger(eth);
|
||||
|
||||
|
@ -195,13 +195,13 @@ void testNoiselessDecoder(void) {
|
|||
|
||||
#if 0
|
||||
// try normal trigger mode, no noise filtering
|
||||
boardConfiguration->useNoiselessTriggerDecoder = false;
|
||||
CONFIGB(useNoiselessTriggerDecoder) = false;
|
||||
// for test validation, it should be 1 trigger error
|
||||
testNoiselessDecoderProcedure(eth, 1 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif
|
||||
|
||||
// now enable our noise filtering algo
|
||||
boardConfiguration->useNoiselessTriggerDecoder = true;
|
||||
CONFIGB(useNoiselessTriggerDecoder) = true;
|
||||
// should be 0 errors!
|
||||
testNoiselessDecoderProcedure(eth, 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
|
|
Loading…
Reference in New Issue