ADC: internalIndex should be used as getAvgAdcValue argument (#2618)
* ADC: internalIndex should be used as getAvgAdcValue argument -plus output messages re-formated * ADC: logger -> efiPrintf
This commit is contained in:
parent
941c40d488
commit
2176d1656b
|
@ -265,7 +265,7 @@ void updateDevConsoleState(void) {
|
|||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
#if HAL_USE_ADC
|
||||
printFullAdcReportIfNeeded(&logger);
|
||||
printFullAdcReportIfNeeded();
|
||||
#endif /* HAL_USE_ADC */
|
||||
|
||||
systime_t nowSeconds = getTimeNowSeconds();
|
||||
|
|
|
@ -323,48 +323,38 @@ static void printAdcValue(int channel) {
|
|||
static uint32_t slowAdcConversionCount = 0;
|
||||
static uint32_t slowAdcErrorsCount = 0;
|
||||
|
||||
static void printFullAdcReport(Logging *logger) {
|
||||
static void printFullAdcReport(void) {
|
||||
#if EFI_USE_FAST_ADC
|
||||
efiPrintf("fast %d slow %d", fastAdc.conversionCount, slowAdcConversionCount);
|
||||
efiPrintf("fast %d samples", fastAdc.conversionCount);
|
||||
|
||||
for (int index = 0; index < fastAdc.size(); index++) {
|
||||
appendMsgPrefix(logger);
|
||||
|
||||
adc_channel_e hwIndex = fastAdc.getAdcHardwareIndexByInternalIndex(index);
|
||||
for (int internalIndex = 0; internalIndex < fastAdc.size(); internalIndex++) {
|
||||
adc_channel_e hwIndex = fastAdc.getAdcHardwareIndexByInternalIndex(internalIndex);
|
||||
|
||||
if (isAdcChannelValid(hwIndex)) {
|
||||
ioportid_t port = getAdcChannelPort("print", hwIndex);
|
||||
int pin = getAdcChannelPin(hwIndex);
|
||||
|
||||
int adcValue = getAvgAdcValue(hwIndex, fastAdc.samples, ADC_BUF_DEPTH_FAST, fastAdc.size());
|
||||
logger->appendPrintf(" F ch%d %s%d", index, portname(port), pin);
|
||||
logger->appendPrintf(" ADC%d 12bit=%d", hwIndex, adcValue);
|
||||
int adcValue = getAvgAdcValue(internalIndex, fastAdc.samples, ADC_BUF_DEPTH_FAST, fastAdc.size());
|
||||
float volts = adcToVolts(adcValue);
|
||||
logger->appendPrintf(" v=%.2f", volts);
|
||||
|
||||
appendMsgPostfix(logger);
|
||||
scheduleLogging(logger);
|
||||
/* Human index starts from 1 */
|
||||
efiPrintf(" F ch[%2d] @ %s%d ADC%d 12bit=%4d %.2fV",
|
||||
internalIndex, portname(port), pin, hwIndex - EFI_ADC_0 + 1, adcValue, volts);
|
||||
}
|
||||
}
|
||||
#endif // EFI_USE_FAST_ADC
|
||||
efiPrintf("slow %d samples", slowAdcConversionCount);
|
||||
|
||||
for (int index = 0; index < ADC_MAX_CHANNELS_COUNT; index++) {
|
||||
appendMsgPrefix(logger);
|
||||
|
||||
adc_channel_e hwIndex = static_cast<adc_channel_e>(index + EFI_ADC_0);
|
||||
/* we assume that all slow ADC channels are enabled */
|
||||
for (int internalIndex = 0; internalIndex < ADC_MAX_CHANNELS_COUNT; internalIndex++) {
|
||||
adc_channel_e hwIndex = static_cast<adc_channel_e>(internalIndex + EFI_ADC_0);
|
||||
|
||||
if (isAdcChannelValid(hwIndex)) {
|
||||
ioportid_t port = getAdcChannelPort("print", hwIndex);
|
||||
int pin = getAdcChannelPin(hwIndex);
|
||||
|
||||
int adcValue = slowAdcSamples[index];
|
||||
logger->appendPrintf(" S ch%d %s%d", index, portname(port), pin);
|
||||
logger->appendPrintf(" ADC%d 12bit=%d", hwIndex, adcValue);
|
||||
int adcValue = slowAdcSamples[internalIndex];
|
||||
float volts = adcToVolts(adcValue);
|
||||
logger->appendPrintf(" v=%.2f", volts);
|
||||
|
||||
appendMsgPostfix(logger);
|
||||
scheduleLogging(logger);
|
||||
/* Human index starts from 1 */
|
||||
efiPrintf(" S ch[%2d] @ %s%d ADC%d 12bit=%4d %.2fV",
|
||||
internalIndex, portname(port), pin, hwIndex - EFI_ADC_0 + 1, adcValue, volts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -541,10 +531,10 @@ void initAdcInputs() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void printFullAdcReportIfNeeded(Logging *logger) {
|
||||
void printFullAdcReportIfNeeded(void) {
|
||||
if (!adcDebugReporting)
|
||||
return;
|
||||
printFullAdcReport(logger);
|
||||
printFullAdcReport();
|
||||
}
|
||||
|
||||
#else /* not HAL_USE_ADC */
|
||||
|
|
|
@ -49,7 +49,7 @@ int getSlowAdcCounter();
|
|||
|
||||
int getAdcHardwareIndexByInternalIndex(int index);
|
||||
|
||||
void printFullAdcReportIfNeeded(Logging *log);
|
||||
void printFullAdcReportIfNeeded(void);
|
||||
int getInternalAdcValue(const char *msg, adc_channel_e index);
|
||||
float getMCUInternalTemperature(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue