ETB target is using integer values #945
refactoring - ADC mocking is a mess
This commit is contained in:
parent
f600bbc6d7
commit
b3b8d8607c
|
@ -53,6 +53,11 @@ float getVoltageDivided(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_
|
||||||
return getVoltage(msg, hwChannel PASS_ENGINE_PARAMETER_SUFFIX) * engineConfiguration->analogInputDividerCoefficient;
|
return getVoltage(msg, hwChannel PASS_ENGINE_PARAMETER_SUFFIX) * engineConfiguration->analogInputDividerCoefficient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// voltage in MCU universe, from zero to VDD
|
||||||
|
float getVoltage(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
return adcToVolts(getAdcValue(msg, hwChannel));
|
||||||
|
}
|
||||||
|
|
||||||
AdcDevice::AdcDevice(ADCConversionGroup* hwConfig) {
|
AdcDevice::AdcDevice(ADCConversionGroup* hwConfig) {
|
||||||
this->hwConfig = hwConfig;
|
this->hwConfig = hwConfig;
|
||||||
channelCount = 0;
|
channelCount = 0;
|
||||||
|
|
|
@ -11,15 +11,14 @@
|
||||||
#ifndef ADC_MATH_H_
|
#ifndef ADC_MATH_H_
|
||||||
#define ADC_MATH_H_
|
#define ADC_MATH_H_
|
||||||
|
|
||||||
#include "global.h"
|
#include "engine_configuration.h"
|
||||||
#define ADC_MAX_VALUE 4095
|
#define ADC_MAX_VALUE 4095
|
||||||
|
|
||||||
#define adcToVolts(adc) ((engineConfiguration->adcVcc) / ADC_MAX_VALUE * (adc))
|
#define adcToVolts(adc) ((engineConfiguration->adcVcc) / ADC_MAX_VALUE * (adc))
|
||||||
|
|
||||||
#define voltsToAdc(volts) ((volts) * (ADC_MAX_VALUE / (engineConfiguration->adcVcc)))
|
#define voltsToAdc(volts) ((volts) * (ADC_MAX_VALUE / (engineConfiguration->adcVcc)))
|
||||||
|
|
||||||
// voltage in MCU universe, from zero to VDD
|
float getVoltage(const char *msg, adc_channel_e channel DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
#define getVoltage(msg, hwChannel) (adcToVolts(getAdcValue(msg, hwChannel)))
|
|
||||||
|
|
||||||
// DECLARE_ENGINE_PARAMETER_SUFFIX
|
// DECLARE_ENGINE_PARAMETER_SUFFIX
|
||||||
float getVoltageDivided(const char *msg, adc_channel_e channel);
|
float getVoltageDivided(const char *msg, adc_channel_e channel);
|
||||||
|
|
|
@ -19,6 +19,11 @@ int getAdcValue(const char *msg, int hwChannel) {
|
||||||
return engine->engineState.mockAdcState.getMockAdcValue(hwChannel);
|
return engine->engineState.mockAdcState.getMockAdcValue(hwChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// voltage in MCU universe, from zero to VDD
|
||||||
|
float getVoltage(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
return adcToVolts(getAdcValue(msg, hwChannel));
|
||||||
|
}
|
||||||
|
|
||||||
// Board voltage, with divider coefficient accounted for
|
// Board voltage, with divider coefficient accounted for
|
||||||
float getVoltageDivided(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
float getVoltageDivided(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
return getVoltage(msg, hwChannel) * engineConfiguration->analogInputDividerCoefficient;
|
return getVoltage(msg, hwChannel) * engineConfiguration->analogInputDividerCoefficient;
|
||||||
|
|
Loading…
Reference in New Issue