better conditional compilation

This commit is contained in:
rusefi 2019-01-31 11:57:15 -05:00
parent 43c7df64fa
commit ed4fed57fb
14 changed files with 49 additions and 14 deletions

View File

@ -228,7 +228,7 @@ static void printSensors(Logging *log, bool fileFormat) {
// below are the more advanced data points which only go into log file
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if HAL_USE_ADC || defined(__DOXYGEN__)
reportSensorF(log, fileFormat, GAUGE_NAME_CPU_TEMP, "C", getMCUInternalTemperature(), 2); // log column #3
#endif
@ -869,16 +869,22 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->engineMode = packEngineMode(PASS_ENGINE_PARAMETER_SIGNATURE);
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if HAL_USE_ADC
tsOutputChannels->internalMcuTemperature = getMCUInternalTemperature();
tsOutputChannels->idlePosition = getIdlePosition();
tsOutputChannels->isTriggerError = isTriggerErrorNow();
#endif /* HAL_USE_ADC */
#if EFI_MAX_31855 || defined(__DOXYGEN__)
for (int i = 0; i < EGT_CHANNEL_COUNT; i++)
tsOutputChannels->egtValues.values[i] = getEgtValue(i);
#endif /* EFI_MAX_31855 */
#if EFI_IDLE_CONTROL
tsOutputChannels->idlePosition = getIdlePosition();
#endif
#if EFI_PROD_CODE || defined(__DOXYGEN__)
tsOutputChannels->isTriggerError = isTriggerErrorNow();
#if EFI_INTERNAL_FLASH || defined(__DOXYGEN__)
tsOutputChannels->needBurn = getNeedToWriteConfiguration();
#endif /* EFI_INTERNAL_FLASH */

View File

@ -125,6 +125,7 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
* See also periodicFastCallback
*/
void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
int rpm = GET_RPM();
isEngineChartEnabled = CONFIG(isEngineChartEnabled) && rpm < CONFIG(engineSnifferRpmThreshold);
sensorChartMode = rpm < CONFIG(sensorSnifferRpmThreshold) ? CONFIGB(sensorChartMode) : SC_OFF;
@ -141,6 +142,7 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
sensors.vBatt = hasVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) ? getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) : 12;
engineState.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER_SUFFIX);
#endif
}
void Engine::onTriggerSignalEvent(efitick_t nowNt) {
@ -189,7 +191,7 @@ void Engine::preCalculate(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
sparkTable.preCalc(engineConfiguration->sparkDwellRpmBins,
engineConfiguration->sparkDwellValues);
#if ! EFI_UNIT_TEST
#if HAL_USE_ADC
adcToVoltageInputDividerCoefficient = adcToVolts(1) * engineConfiguration->analogInputDividerCoefficient;
#else
adcToVoltageInputDividerCoefficient = engineConfigurationPtr->analogInputDividerCoefficient;

View File

@ -125,6 +125,7 @@ void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
}
void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
if (!engine->slowCallBackWasInvoked) {
warning(CUSTOM_ERR_6696, "Slow not invoked yet");
}
@ -213,9 +214,11 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} else {
baseTableFuel = getBaseTableFuel(rpm, engineLoad);
}
#endif
}
void EngineState::updateTChargeK(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
float coolantC = ENGINE(sensors.clt);
float intakeC = ENGINE(sensors.iat);
float newTCharge = getTCharge(rpm, tps, coolantC, intakeC PASS_ENGINE_PARAMETER_SUFFIX);
@ -228,6 +231,7 @@ void EngineState::updateTChargeK(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUF
tChargeK = convertCelsiusToKelvin(tCharge);
timeSinceLastTChargeK = curTime;
}
#endif
}
SensorsState::SensorsState() {

View File

@ -47,6 +47,8 @@ extern fuel_Map3D_t ve2Map;
extern afr_Map3D_t afrMap;
extern baroCorr_Map3D_t baroCorrMap;
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
/**
* @return total duration of fuel injection per engine cycle, in milliseconds
*/
@ -349,3 +351,5 @@ float getFuelRate(floatms_t totalInjDuration, efitick_t timePeriod DECLARE_ENGIN
const float cc_min_to_L_h = 60.0f / 1000.0f;
return fuelRate * CONFIG(injector.flow) * cc_min_to_L_h;
}
#endif

View File

@ -277,6 +277,7 @@ static void invokePerSecond(void) {
}
static void periodicSlowCallback(Engine *engine) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
efiAssertVoid(CUSTOM_ERR_6661, getRemainingStack(chThdGetSelfX()) > 64, "lowStckOnEv");
#if EFI_PROD_CODE
/**
@ -319,6 +320,7 @@ static void periodicSlowCallback(Engine *engine) {
engine->periodicSlowCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
scheduleNextSlowInvocation();
#endif
}
void initPeriodicEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
@ -596,7 +598,9 @@ void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S
printf("commonInitEngineController\n");
#endif
initConfigActions();
#if EFI_ENABLE_MOCK_ADC
initMockVoltage();
#endif /* EFI_ENABLE_MOCK_ADC */
#if EFI_PROD_CODE || EFI_SIMULATOR || defined(__DOXYGEN__)
initSignalExecutor();

View File

@ -122,7 +122,7 @@ static void startAveraging(void *arg) {
mapAveragingPin.setHigh();
}
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if HAL_USE_ADC || defined(__DOXYGEN__)
/**
* This method is invoked from ADC callback.
* @note This method is invoked OFTEN, this method is a potential bottle-next - the implementation should be
@ -179,7 +179,7 @@ static void endAveraging(void *arg) {
bool wasLocked = lockAnyContext();
isAveraging = false;
// with locking we would have a consistent state
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if HAL_USE_ADC || defined(__DOXYGEN__)
if (mapMeasurementsCounter > 0) {
v_averagedMapValue = adcToVoltsDivided(mapAdcAccumulator / mapMeasurementsCounter);
// todo: move out of locked context?
@ -255,6 +255,7 @@ void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
*/
static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
// this callback is invoked on interrupt thread
UNUSED(ckpEventType);
if (index != CONFIG(mapAveragingSchedulingAtIndex))
@ -304,6 +305,7 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
engine->m.mapAveragingCbTime = GET_TIMESTAMP()
- engine->m.beforeMapAveragingCb;
}
#endif
}
static void showMapStats(void) {
@ -339,7 +341,9 @@ void initMapAveraging(Logging *sharedLogger, Engine *engine) {
// endTimer[0].name = "map end0";
// endTimer[1].name = "map end1";
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
addTriggerEventListener(&mapAveragingTriggerCallback, "MAP averaging", engine);
#endif /* EFI_SHAFT_POSITION_INPUT */
addConsoleAction("faststat", showMapStats);
applyMapMinBufferLength();
}

View File

@ -12,7 +12,7 @@
#if EFI_MAP_AVERAGING || defined(__DOXYGEN__)
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if HAL_USE_ADC || defined(__DOXYGEN__)
void mapAveragingAdcCallback(adcsample_t newValue);
#endif

View File

@ -263,7 +263,7 @@ void initMapDecoder(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
applyConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
//engine->configurationListeners.registerCallback(applyConfiguration);
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if HAL_USE_ICU || defined(__DOXYGEN__)
if (engineConfiguration->hasFrequencyReportingMapSensor) {
digital_input_s* digitalMapInput = addWaveAnalyzerDriver("map freq", CONFIGB(frequencyReportingMapInputPin));
startInputDriver(digitalMapInput, true);

View File

@ -44,5 +44,7 @@ void initTachometer(void) {
enginePins.tachOut.initPin("analog tach output", CONFIGB(tachOutputPin), &CONFIGB(tachOutputPinMode));
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
addTriggerEventListener(tachSignalCallback, "tach", engine);
#endif /* EFI_SHAFT_POSITION_INPUT */
}

View File

@ -10,9 +10,9 @@
#define ADC_INPUTS_H_
#include "global.h"
#include "adc_math.h"
#if HAL_USE_ADC || defined(__DOXYGEN__)
#include "adc_math.h"
const char * getAdcMode(adc_channel_e hwChannel);
void initAdcInputs(bool boardTestMode);

View File

@ -165,8 +165,6 @@ static Logging *sharedLogger;
#if EFI_PROD_CODE
extern AdcDevice fastAdc;
#define TPS_IS_SLOW -1
static int fastMapSampleIndex;
@ -175,6 +173,9 @@ static int tpsSampleIndex;
extern int tpsFastAdc;
#if HAL_USE_ADC
extern AdcDevice fastAdc;
/**
* This method is not in the adc* lower-level file because it is more business logic then hardware.
*/
@ -205,8 +206,10 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
// }
}
}
#endif /* HAL_USE_ADC */
static void calcFastAdcIndexes(void) {
#if HAL_USE_ADC
fastMapSampleIndex = fastAdc.internalAdcIndexByHardwareIndex[engineConfiguration->map.sensor.hwChannel];
hipSampleIndex =
engineConfiguration->hipOutputChannel == EFI_ADC_NONE ?
@ -216,6 +219,7 @@ static void calcFastAdcIndexes(void) {
} else {
tpsSampleIndex = TPS_IS_SLOW;
}
#endif/* HAL_USE_ADC */
}
static void adcConfigListener(Engine *engine) {

View File

@ -106,6 +106,7 @@ static void lcd_HD44780_write(uint8_t data) {
// LCD Pin RW -> P1
// LCD Pin E -> P2
#if HAL_USE_I2C
// todo: finish all this stuff
i2cAcquireBus(&I2CD1);
//
@ -117,7 +118,7 @@ static void lcd_HD44780_write(uint8_t data) {
// i2cMasterTransmit(&I2CD1, LCD_PORT_EXP_ADDR, txbuf, 1, NULL, 0);
//
i2cReleaseBus(&I2CD1);
#endif /* HAL_USE_I2C */
}
}

View File

@ -42,7 +42,7 @@ static msg_t stThread(StepperMotor *motor) {
// try to get saved stepper position (-1 for no data)
motor->currentPosition = loadStepperPos();
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if HAL_USE_ADC || defined(__DOXYGEN__)
// first wait until at least 1 slowADC sampling is complete
waitForSlowAdc();
#endif

View File

@ -86,6 +86,7 @@ void HardFaultVector(void);
#endif /* MPU_UTIL_H_ */
#if HAL_USE_SPI
void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
brain_pin_e mosi,
int sckMode,
@ -95,7 +96,10 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
* @see getSpiDevice
*/
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin);
#endif /* HAL_USE_SPI */
bool isValidCanTxPin(brain_pin_e pin);
bool isValidCanRxPin(brain_pin_e pin);
#if HAL_USE_CAN
CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx);
#endif /* HAL_USE_CAN */