move ADC pin initialization (#2660)

* set the pin in adc subscription land

* remove from adc_inputs

* more subscriptions

* use our lib instead
This commit is contained in:
Matthew Kennedy 2021-05-09 11:36:11 -07:00 committed by GitHub
parent 969609f3e3
commit 3f36d488bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 26 deletions

View File

@ -463,32 +463,11 @@ static void configureInputs(void) {
addChannel("Baro Press", engineConfiguration->baroSensor.hwChannel, ADC_SLOW);
addChannel("TPS 1 Primary", engineConfiguration->tps1_1AdcChannel, ADC_SLOW);
addChannel("TPS 1 Secondary", engineConfiguration->tps1_2AdcChannel, ADC_SLOW);
addChannel("TPS 2 Primary", engineConfiguration->tps2_1AdcChannel, ADC_SLOW);
addChannel("TPS 2 Secondary", engineConfiguration->tps2_2AdcChannel, ADC_SLOW);
addChannel("Wastegate Position", engineConfiguration->wastegatePositionSensor, ADC_SLOW);
addChannel("Idle Position Sensor", engineConfiguration->idlePositionSensor, ADC_SLOW);
addChannel("Fuel Level", engineConfiguration->fuelLevelSensor, ADC_SLOW);
addChannel("Acc Pedal1", engineConfiguration->throttlePedalPositionAdcChannel, ADC_SLOW);
addChannel("Acc Pedal2", engineConfiguration->throttlePedalPositionSecondAdcChannel, ADC_SLOW);
addChannel("VBatt", engineConfiguration->vbattAdcChannel, ADC_SLOW);
// not currently used addChannel("Vref", engineConfiguration->vRefAdcChannel, ADC_SLOW);
addChannel("CLT", engineConfiguration->clt.adcChannel, ADC_SLOW);
addChannel("IAT", engineConfiguration->iat.adcChannel, ADC_SLOW);
addChannel("AUX Temp 1", engineConfiguration->auxTempSensor1.adcChannel, ADC_SLOW);
addChannel("AUX Temp 2", engineConfiguration->auxTempSensor2.adcChannel, ADC_SLOW);
addChannel("AUXF#1", engineConfiguration->auxFastSensor1_adcChannel, ADC_FAST);
addChannel("AFR", engineConfiguration->afr.hwChannel, ADC_SLOW);
addChannel("Oil Pressure", engineConfiguration->oilPressure.hwChannel, ADC_SLOW);
addChannel("LFP", engineConfiguration->lowPressureFuel.hwChannel, ADC_SLOW);
addChannel("HFP", engineConfiguration->highPressureFuel.hwChannel, ADC_SLOW);
if (CONFIG(isCJ125Enabled)) {
addChannel("CJ125 UR", engineConfiguration->cj125ur, ADC_SLOW);

View File

@ -5,8 +5,6 @@
#include "perf_trace.h"
#include "biquad.h"
#include <iterator>
EXTERN_ENGINE;
#if EFI_UNIT_TEST
@ -29,7 +27,7 @@ struct AdcSubscriptionEntry {
};
static size_t s_nextEntry = 0;
static AdcSubscriptionEntry s_entries[8];
static AdcSubscriptionEntry s_entries[16];
void AdcSubscription::SubscribeSensor(FunctionalSensor &sensor,
adc_channel_e channel,
@ -40,11 +38,21 @@ void AdcSubscription::SubscribeSensor(FunctionalSensor &sensor,
return;
}
// bounds check
if (s_nextEntry >= std::size(s_entries)) {
const char* name = sensor.getSensorName();
if (/*type-limited (int)setting < 0 || */(int)channel >= HW_MAX_ADC_INDEX) {
firmwareError(CUSTOM_INVALID_ADC, "Invalid ADC setting %s", name);
return;
}
// Ensure that enough entries are available
if (s_nextEntry >= efi::size(s_entries)) {
firmwareError(CUSTOM_INVALID_ADC, "too many ADC subscriptions");
return;
}
// Enable the input pin
efiSetPadMode(name, getAdcChannelBrainPin(name, channel), PAL_MODE_INPUT_ANALOG);
// if 0, default to the board's divider coefficient
if (voltsPerAdcVolt == 0) {
voltsPerAdcVolt = engineConfiguration->analogInputDividerCoefficient;