drivers: sensor: stm32 Vref sensor calibration on 12bit
The Calibration value of the VRef on stm32U5 is acquired on 14Bit by ADC1 and should be adjusted on 12bit becasue the resolution is 12bit in this stm32_vref driver. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
parent
be5cf2ddb9
commit
4e070a0867
1 changed files with 9 additions and 0 deletions
|
@ -86,7 +86,16 @@ static int stm32_vref_channel_get(const struct device *dev, enum sensor_channel
|
|||
#endif /* CONFIG_SOC_SERIES_STM32H5X */
|
||||
|
||||
/* Calculate VREF+ using VREFINT bandgap voltage and calibration data */
|
||||
#if defined(CONFIG_SOC_SERIES_STM32U5X)
|
||||
/*
|
||||
* The VREF CALIBRATION value is acquired on 14 bits
|
||||
* and the data acquired is on 12 bits
|
||||
* since the adc_sequence.resolution is 12
|
||||
*/
|
||||
vref = (cfg->cal_mv * (*cfg->cal_addr) >> 2) / data->raw;
|
||||
#else
|
||||
vref = cfg->cal_mv * (*cfg->cal_addr) / data->raw;
|
||||
#endif /* CONFIG_SOC_SERIES_STM32H5X */
|
||||
/* millivolt to volt */
|
||||
vref /= 1000;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue