rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
adc_onchip_slow.cpp File Reference

Functions

void adcOnchipSlowUpdate (efitick_t nowNt)
 
adcsample_t adcOnchipSlowGetAvgRaw (adc_channel_e hwChannel)
 
void adcPrintChannelReport (const char *prefix, int internalIndex, adc_channel_e hwChannel)
 
void adcOnchipSlowShowReport ()
 
float getMCUInternalTemperature ()
 
float getMCUVref ()
 
void waitForSlowAdc (uint32_t lastAdcCounter)
 

Variables

static volatile NO_CACHE adcsample_t slowAdcSamples [SLOW_ADC_CHANNEL_COUNT]
 
static uint32_t slowAdcConversionCount = 0
 
static float mcuTemperature
 
static float mcuVrefVoltage
 

Function Documentation

◆ adcOnchipSlowGetAvgRaw()

adcsample_t adcOnchipSlowGetAvgRaw ( adc_channel_e  hwChannel)

Definition at line 59 of file adc_onchip_slow.cpp.

60{
61 return slowAdcSamples[hwChannel - EFI_ADC_0];
62}
static volatile NO_CACHE adcsample_t slowAdcSamples[SLOW_ADC_CHANNEL_COUNT]

Referenced by getInternalAdcValue().

Here is the caller graph for this function:

◆ adcOnchipSlowShowReport()

void adcOnchipSlowShowReport ( )

Definition at line 66 of file adc_onchip_slow.cpp.

67{
68 efiPrintf("slow %lu samples", slowAdcConversionCount);
69
70 /* we assume that all slow ADC channels are enabled */
71 for (int internalIndex = 0; internalIndex < SLOW_ADC_CHANNEL_COUNT; internalIndex++) {
72 adc_channel_e hwChannel = static_cast<adc_channel_e>(internalIndex + EFI_ADC_0);
73
74 adcPrintChannelReport("S", internalIndex, hwChannel);
75 }
76}
void adcPrintChannelReport(const char *prefix, int internalIndex, adc_channel_e hwChannel)
static uint32_t slowAdcConversionCount

Referenced by printFullAdcReport().

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

◆ adcOnchipSlowUpdate()

void adcOnchipSlowUpdate ( efitick_t  nowNt)

Definition at line 32 of file adc_onchip_slow.cpp.

32 {
33 UNUSED(nowNt);
34
36
37 /* drop volatile type qualifier - this is safe */
40 return;
41 }
42
43 // TODO:
44 //engine->outputChannels.slowAdcConversionCount++;
46
47 // Ask the port to sample the MCU temperature
49 if (mcuTemperature > 150.0f || mcuTemperature < -50.0f) {
50 /*
51 * we have a sporadic issue with this check todo https://github.com/rusefi/rusefi/issues/2552
52 */
53 //criticalError("Invalid CPU temperature measured %f", degrees);
54 }
55
57}
static float mcuTemperature
static float mcuVrefVoltage
TunerStudioOutputChannels outputChannels
Definition engine.h:109
bool readSlowAnalogInputs(adcsample_t *convertedSamples)
Definition mpu_util.cpp:274
float getMcuVrefVoltage()
Definition mpu_util.cpp:269
float getMcuTemperature()
Definition mpu_util.cpp:264
static EngineAccessor engine
Definition engine.h:413
uint16_t adcsample_t
ADC sample data type.
UNUSED(samplingTimeSeconds)
@ AdcConversionSlow

Referenced by adcInputsUpdateSubscribers().

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

◆ adcPrintChannelReport()

void adcPrintChannelReport ( const char prefix,
int  internalIndex,
adc_channel_e  hwChannel 
)
extern

Definition at line 142 of file adc_inputs.cpp.

143{
144 if (isAdcChannelValid(hwChannel)) {
145 ioportid_t port = getAdcChannelPort("print", hwChannel);
146 int pin = getAdcChannelPin(hwChannel);
147 int adcValue = adcGetRawValue("print", hwChannel);
148 auto volts = adcGetRawVoltage("print", hwChannel);
149 auto voltsInput = adcGetScaledVoltage("print", hwChannel);
150 /* Human index starts from 1 */
151 efiPrintf(" %s ch[%2d] @ %s%d ADC%d 12bit=%4d %.3fV input %.3fV %s",
152 prefix, internalIndex, portname(port), pin,
153 /* TODO: */ hwChannel - EFI_ADC_0 + 1,
154 adcValue, volts.value_or(0), voltsInput.value_or(0), volts ? "valid" : "INVALID");
155 }
156}
expected< float > adcGetScaledVoltage(const char *msg, adc_channel_e hwChannel)
expected< float > adcGetRawVoltage(const char *msg, adc_channel_e hwChannel)
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition adc_inputs.h:23
int getAdcChannelPin(adc_channel_e hwChannel)
ioportid_t getAdcChannelPort(const char *msg, adc_channel_e hwChannel)
const char * portname(ioportid_t GPIOx)
GPIO_TypeDef * ioportid_t
Port Identifier.
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by adcOnchipSlowShowReport(), and printFullAdcReport().

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

◆ getMCUInternalTemperature()

float getMCUInternalTemperature ( void  )

Definition at line 78 of file adc_onchip_slow.cpp.

78 {
79 return mcuTemperature;
80}

Referenced by populateFrame(), and updateMiscSensors().

Here is the caller graph for this function:

◆ getMCUVref()

float getMCUVref ( void  )

Definition at line 82 of file adc_onchip_slow.cpp.

82 {
83 return mcuVrefVoltage;
84}

Referenced by analogGetVrefDiagnostic(), and updateMiscSensors().

Here is the caller graph for this function:

◆ waitForSlowAdc()

void waitForSlowAdc ( uint32_t  lastAdcCounter)

Definition at line 87 of file adc_onchip_slow.cpp.

87 {
88 // note that having ADC reading is one thing while having new sensor API is a totally different thing!
89 // todo: use sync.objects?
90 while (slowAdcConversionCount <= lastAdcCounter) {
91 chThdSleepMilliseconds(1);
92 }
93}

Referenced by StepperMotorBase::setInitialPosition().

Here is the caller graph for this function:

Variable Documentation

◆ mcuTemperature

float mcuTemperature
static

Definition at line 29 of file adc_onchip_slow.cpp.

Referenced by adcOnchipSlowUpdate(), and getMCUInternalTemperature().

◆ mcuVrefVoltage

float mcuVrefVoltage
static

Definition at line 30 of file adc_onchip_slow.cpp.

Referenced by adcOnchipSlowUpdate(), and getMCUVref().

◆ slowAdcConversionCount

uint32_t slowAdcConversionCount = 0
static

◆ slowAdcSamples

volatile NO_CACHE adcsample_t slowAdcSamples[SLOW_ADC_CHANNEL_COUNT]
static

Definition at line 25 of file adc_onchip_slow.cpp.

Referenced by adcOnchipSlowGetAvgRaw(), and adcOnchipSlowUpdate().

Go to the source code of this file.