rusefi-1/firmware/hw_layer/algo/adc_math.h

26 lines
807 B
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file adc_math.h
*
2017-11-24 16:16:00 -08:00
* 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?
2017-11-24 14:40:20 -08:00
*
2015-07-10 06:01:56 -07:00
* @date Mar 18, 2014
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
#ifndef ADC_MATH_H_
#define ADC_MATH_H_
#include "engine_configuration.h"
2015-07-10 06:01:56 -07:00
#define ADC_MAX_VALUE 4095
2017-08-31 04:57:39 -07:00
#define adcToVolts(adc) ((engineConfiguration->adcVcc) / ADC_MAX_VALUE * (adc))
2015-07-10 06:01:56 -07:00
2017-08-31 04:57:39 -07:00
#define voltsToAdc(volts) ((volts) * (ADC_MAX_VALUE / (engineConfiguration->adcVcc)))
2015-07-10 06:01:56 -07:00
float getVoltage(const char *msg, adc_channel_e channel DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
float getVoltageDivided(const char *msg, adc_channel_e channel DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
#endif /* ADC_MATH_H_ */