Skip to content

Commit

Permalink
feat: add calibration for adc when not single differential (#444)
Browse files Browse the repository at this point in the history
* also calibrate when not single differential

* dont calibrate for 32f4 and 32f7

* Update hal_st/stm32fxxx/AnalogToDigitalPinStm.cpp

Co-authored-by: Gabriel Santos <[email protected]>

* or...

* fix merge problem

* only WBA

* check calibrate for all non single ended

* check not building for F7xx

* check also not building for F4xx

* check addition explicit not for F407 and F429

* check exclude f4 and f7 with other defines

* Found a define that is symmetrical and should work

* calibrate in AdcDmaMultiChannelStm.cpp

* calibrate in AdcDmaStm.cpp

* copy paste mistake resolved

* copy paste mistake resolved

---------

Co-authored-by: Gabriel Santos <[email protected]>
  • Loading branch information
paulpjanssens and gabrielsantosphilips authored Oct 31, 2024
1 parent 5042b8d commit 66d25bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions hal_st/stm32fxxx/AdcDmaMultiChannelStm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace hal
#ifdef ADC_SINGLE_ENDED
auto result = HAL_ADCEx_Calibration_Start(&adc.Handle(), ADC_SINGLE_ENDED);
assert(result == HAL_OK);
#elif defined(IS_ADC_CALFACT)
auto result = HAL_ADCEx_Calibration_Start(&adc.Handle());
assert(result == HAL_OK);
#endif

LL_ADC_REG_SetDMATransfer(adc.Handle().Instance, LL_ADC_REG_DMA_TRANSFER_LIMITED);
Expand Down
2 changes: 2 additions & 0 deletions hal_st/stm32fxxx/AdcDmaStm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace hal

#ifdef ADC_SINGLE_ENDED
result = HAL_ADCEx_Calibration_Start(&adc.Handle(), ADC_SINGLE_ENDED);
#elif defined(IS_ADC_CALFACT)
result = HAL_ADCEx_Calibration_Start(&adc.Handle());
#endif
assert(result == HAL_OK);
}
Expand Down
4 changes: 3 additions & 1 deletion hal_st/stm32fxxx/AnalogToDigitalPinStm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ namespace hal

#ifdef IS_ADC_SINGLE_DIFFERENTIAL
result = HAL_ADCEx_Calibration_Start(&handle, ADC_SINGLE_ENDED);
assert(result == HAL_OK);
#elif defined(IS_ADC_CALFACT)
result = HAL_ADCEx_Calibration_Start(&handle);
#endif
assert(result == HAL_OK);
}

AdcStm::~AdcStm()
Expand Down

0 comments on commit 66d25bc

Please sign in to comment.