rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
adc_math.h
Go to the documentation of this file.
1/**
2 * @file adc_math.h
3 *
4 * todo: all this looks to be about internal ADC, merge this file with adc_inputs.h?
5 * these macro are also used in simulator so maybe not really merging with adc_inputs.h until simulator get's it's own implementation?
6 *
7 * @date Mar 18, 2014
8 * @author Andrey Belomutskiy, (c) 2012-2020
9 */
10
11#pragma once
12
13#if EFI_PROD_CODE
14#include "port_mpu_util.h"
15#include "rusefi_hw_enums.h"
16#else // not EFI_PROD_CODE
17#define ADC_MAX_VALUE 4095
18#endif
19
20#define adcRawValueToRawVoltage(adc) ((engineConfiguration->adcVcc) / ADC_MAX_VALUE * (adc))
21
22#define voltsToAdc(volts) ((volts) * (ADC_MAX_VALUE / (engineConfiguration->adcVcc)))
23
24// voltage in MCU universe, from zero to Vref
25expected<float> adcGetRawVoltage(const char *msg, adc_channel_e channel);
26
27// voltage in ECU universe, with all input dividers and OpAmps gains taken into account, voltage at ECU connector pin
28expected<float> adcGetScaledVoltage(const char *msg, adc_channel_e channel);
29
uint16_t channel
Definition adc_inputs.h:104
expected< float > adcGetScaledVoltage(const char *msg, adc_channel_e channel)
expected< float > adcGetRawVoltage(const char *msg, adc_channel_e channel)