diff --git a/src/shared/drivers/adc/InternalADC.cpp b/src/shared/drivers/adc/InternalADC.cpp index 525c56e10a1a35c15c2606c6a2eec11eaefee154..f5dbbe0afe40e71c5eebb8f1e92b1d290ae686a7 100644 --- a/src/shared/drivers/adc/InternalADC.cpp +++ b/src/shared/drivers/adc/InternalADC.cpp @@ -61,7 +61,8 @@ static const float VBAT_DIV = 4.0f; // If it is missing you need to define it, preferably in the board_settings.h // file in miosix. Check your board schematic to find the voltage value. #ifndef V_DDA_VOLTAGE -#error Missing V_DDA_VOLTAGE definition for current target +#warning Missing V_DDA_VOLTAGE definition for current target, using default value of 3.0V +#define V_DDA_VOLTAGE 3.0f #endif InternalADC::InternalADC(ADC_TypeDef *adc) : adc(adc) @@ -115,9 +116,7 @@ InternalADCData InternalADC::sampleImpl() { newData.voltage[i] = readChannel(static_cast<Channel>(i)); newData.voltage[i] = - newData.voltage[i] * - V_DDA_VOLTAGE // cppcheck-suppress ConfigurationNotChecked - / ADC_RESOLUTION; + newData.voltage[i] * V_DDA_VOLTAGE / ADC_RESOLUTION; } } @@ -141,9 +140,7 @@ InternalADCData InternalADC::sampleImpl() if (temperatureRawValue != 0) { newData.temperature = - temperatureRawValue * - V_DDA_VOLTAGE // cppcheck-suppress ConfigurationNotChecked - / ADC_RESOLUTION; + temperatureRawValue * V_DDA_VOLTAGE / ADC_RESOLUTION; #ifdef INTERNAL_ADC_WITHOUT_CALIBRATION // Default conversion @@ -168,9 +165,7 @@ InternalADCData InternalADC::sampleImpl() ADC->CCR &= ~ADC_CCR_VBATE; newData.vBat = - vbatVoltageRawValue * - V_DDA_VOLTAGE // cppcheck-suppress ConfigurationNotChecked - / ADC_RESOLUTION * VBAT_DIV; + vbatVoltageRawValue * V_DDA_VOLTAGE / ADC_RESOLUTION * VBAT_DIV; } return newData; diff --git a/src/shared/drivers/adc/InternalADCData.h b/src/shared/drivers/adc/InternalADCData.h index 8161edeb633dc1af545c164d56741b84f599f688..81656954509fbeda9f2acd37308ba3bf5a4e0d1c 100644 --- a/src/shared/drivers/adc/InternalADCData.h +++ b/src/shared/drivers/adc/InternalADCData.h @@ -34,7 +34,7 @@ struct InternalADCData float temperature; float vBat; - InternalADCData() {} + InternalADCData() : voltage(), temperature(), vBat() {} static std::string header() {