zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.93k stars 6.65k forks source link

drivers: adc for stm32h7 depends on the version for oversampling #37379

Closed FRASTM closed 3 years ago

FRASTM commented 3 years ago

Describe the bug The stm32h7 HAL and LL has ADC_LL_EC_OVS_RATIO Oversampling - Ratio defined for only ADC of version ADC_VER_V5_V90. For some stm32H7xx soc, like the stm32h743 and stm32h753, the function LL_ADC_ConfigOverSamplingRatioShift has a different prototype which is not compatible with other soc series. The start-read() fails because the ADC_LL_EC_OVS_RATIO does not exist So the build fails for nucleo_h743zi and nucleo_h753zi target boards.

To Reproduce Steps to reproduce the behavior:

  1. west build -p auto -b nucleo_h743zi tests/drivers/adc/adc_api/

Expected behavior compilation passed

Impact What impact does this issue have on your progress (e.g., annoyance, showstopper)

Logs and console output

./drivers/adc/adc_stm32.c: In function 'start_read':
./drivers/adc/adc_stm32.c:444:44: error: 'LL_ADC_OVS_RATIO_2' undeclared (first use in this function)

Environment (please complete the following information):

Additional context ./modules/hal/stm32/stm32cube/stm32h7xx/stm32h7xx_ll_adc.h:

LL_ADC_ConfigOverSamplingRatioShift
  * @param  Ratio This parameter can be in the range from 1 to 1024.
FRASTM commented 3 years ago

In the LL_ADC_ConfigOverSamplingRatioShift() function of the stm32h7xx Cube, the LL_ADC_OVS_RATIO must be converted in a value from 1 to 1024 LL_ADC_OVS_RATIO_2 replaced by ratio = 1 LL_ADC_OVS_RATIO_4 replaced by ratio = 2 LL_ADC_OVS_RATIO_8 replaced by ratio = 3 LL_ADC_OVS_RATIO_16 replaced by ratio = 4 LL_ADC_OVS_RATIO_32 replaced by ratio = 5 LL_ADC_OVS_RATIO_64 replaced by ratio = 6 LL_ADC_OVS_RATIO_128 replaced by ratio = 7 LL_ADC_OVS_RATIO_256 replaced by ratio = 8