rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
adc_math.h File Reference

Detailed Description

todo: all this looks to be about internal ADC, merge this file with adc_inputs.h? these macro are also used in simulator so maybe not really merging with adc_inputs.h until simulator get's it's own implementation?

Date
Mar 18, 2014
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file adc_math.h.

Functions

expected< floatadcGetRawVoltage (const char *msg, adc_channel_e channel)
 
expected< floatadcGetScaledVoltage (const char *msg, adc_channel_e channel)
 

Function Documentation

◆ adcGetRawVoltage()

expected< float > adcGetRawVoltage ( const char msg,
adc_channel_e  channel 
)

Definition at line 78 of file adc_inputs.cpp.

78 {
79 float rawVoltage = adcRawValueToRawVoltage(adcGetRawValue(msg, hwChannel));
80 int inputStatus = boardGetAnalogInputDiagnostic(hwChannel, rawVoltage);
81
82 if (inputStatus == 0) {
83 return expected(rawVoltage);
84 }
85
86 /* TODO: convert inputStatus to unexpected? */
87 return unexpected;
88}
int PUBLIC_API_WEAK boardGetAnalogInputDiagnostic(adc_channel_e channel, float)

Referenced by adcGetScaledVoltage(), adcPrintChannelReport(), AdcSubscription::PrintInfo(), printMAPInfo(), and AdcSubscription::UpdateSubscribers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adcGetScaledVoltage()

expected< float > adcGetScaledVoltage ( const char msg,
adc_channel_e  channel 
)

Definition at line 91 of file adc_inputs.cpp.

91 {
92 auto rawVoltage = adcGetRawVoltage(msg, hwChannel);
93
94 if (rawVoltage) {
95 // TODO: merge getAnalogInputDividerCoefficient() and boardAdjustVoltage() into single board hook?
96 float voltage = rawVoltage.value_or(0) * getAnalogInputDividerCoefficient(hwChannel);
97 return expected(boardAdjustVoltage(voltage, hwChannel));
98 }
99
100 return expected(rawVoltage);
101}
float PUBLIC_API_WEAK boardAdjustVoltage(float voltage, adc_channel_e)
float PUBLIC_API_WEAK getAnalogInputDividerCoefficient(adc_channel_e)
expected< float > adcGetRawVoltage(const char *msg, adc_channel_e hwChannel)

Referenced by adcPrintChannelReport(), getAfr(), and updateRawSensors().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.