diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index d79cb86d17..8f39eaea01 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -550,14 +550,18 @@ static void setAdcDebugReporting(int value) { scheduleMsg(&logger, "adcDebug=%d", adcDebugReporting); } -void waitForSlowAdc() { +void waitForSlowAdc(int lastAdcCounter) { // we use slowAdcCounter instead of slowAdc.conversionCount because we need ADC_COMPLETE state // todo: use sync.objects? - while (slowAdcCounter < 1) { + while (slowAdcCounter <= lastAdcCounter) { chThdSleepMilliseconds(1); } } +int getSlowAdcCounter() { + return slowAdcCounter; +} + static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) { (void) buffer; (void) n; @@ -618,6 +622,11 @@ static void configureInputs(void) { addChannel("OilP", engineConfiguration->oilPressure.hwChannel, ADC_SLOW); addChannel("AC", engineConfiguration->acSwitchAdc, ADC_SLOW); + if (boardConfiguration->isCJ125Enabled) { + addChannel("cj125ur", engineConfiguration->cj125ur, ADC_SLOW); + addChannel("cj125ua", engineConfiguration->cj125ua, ADC_SLOW); + } + for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) { addChannel("FSIOadc", engineConfiguration->fsioAdc[i], ADC_SLOW); } diff --git a/firmware/hw_layer/adc_inputs.h b/firmware/hw_layer/adc_inputs.h index df7597adb9..08f7510892 100644 --- a/firmware/hw_layer/adc_inputs.h +++ b/firmware/hw_layer/adc_inputs.h @@ -28,7 +28,9 @@ adc_channel_e getAdcChannel(brain_pin_e pin); brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel); // wait until at least 1 slowADC sampling is complete -void waitForSlowAdc(); +void waitForSlowAdc(int lastAdcCounter = 0); +// get a number of completed slowADC samples +int getSlowAdcCounter(); int getAdcHardwareIndexByInternalIndex(int index);