/** * @file init_sensorss.cpp */ #include "pch.h" #include "init.h" #include "cli_registry.h" #include "io_pins.h" #include "lua_hooks.h" static void initSensorCli(); void initIfValid(const char* msg, adc_channel_e channel) { if (!isAdcChannelValid(channel)) { return; } #if EFI_PROD_CODE && HAL_USE_ADC /** TODO: this code is similar to AdcSubscription::SubscribeSensor, what is the plan? shall we extract helper method or else? */ brain_pin_e pin = getAdcChannelBrainPin(msg, channel); if (pin == Gpio::Invalid) { // todo: external muxes for internal ADC #3350 return; } efiSetPadMode(msg, pin, PAL_MODE_INPUT_ANALOG); #endif // EFI_PROD_CODE && HAL_USE_ADC } void deInitIfValid(const char* msg, adc_channel_e channel) { if (!isAdcChannelValid(channel)) { return; } #if EFI_PROD_CODE && HAL_USE_ADC brain_pin_e pin = getAdcChannelBrainPin(msg, channel); efiSetPadUnused(pin); #endif // EFI_PROD_CODE && HAL_USE_ADC } static void initOldAnalogInputs() { if (isAdcChannelValid(engineConfiguration->afr.hwChannel) && engineConfiguration->enableAemXSeries) { criticalError("Please pick either analog AFR or CAN AFR input not both."); } initIfValid("AFR", engineConfiguration->afr.hwChannel); initIfValid("AUXF#1", engineConfiguration->auxFastSensor1_adcChannel); } static void deInitOldAnalogInputs() { deInitIfValid("AFR", activeConfiguration.afr.hwChannel); deInitIfValid("AUXF#1", activeConfiguration.auxFastSensor1_adcChannel); } static void initAuxDigital() { #if EFI_PROD_CODE for (size_t i = 0;iluaDigitalInputPins);i++) { efiSetPadMode("Lua Digital", engineConfiguration->luaDigitalInputPins[i], engineConfiguration->luaDigitalInputPinModes[i]); } #endif // EFI_PROD_CODE } void pokeAuxDigital() { #if EFI_PROD_CODE for (size_t i = 0;iluaDigitalInputPins);i++) { engine->luaDigitalInputState[i].state.update(getAuxDigital(i)); } #endif // EFI_PROD_CODE } static void deInitAuxDigital() { for (size_t i = 0;i(idx)); }); }