Skip to content

Commit 4510124

Browse files
committed
adc: Adjust the adc resolution with the oversampling factor
Oversampling factor does not impact the resolution Corrected this by adjusting the resolution with the oversampling factor More info in the pull request Fixes: #74607 Signed-off-by: Robin Carrupt <[email protected]>
1 parent 1159c2a commit 4510124

File tree

1 file changed

+5
-0
lines changed
  • include/zephyr/drivers

1 file changed

+5
-0
lines changed

include/zephyr/drivers/adc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,11 @@ static inline int adc_raw_to_millivolts_dt(const struct adc_dt_spec *spec,
929929
resolution -= 1U;
930930
}
931931

932+
/* Adjust resolution with the oversampling factor */
933+
if (spec->oversampling) {
934+
resolution += spec->oversampling >> 1U;
935+
}
936+
932937
return adc_raw_to_millivolts(vref_mv, spec->channel_cfg.gain,
933938
resolution, valp);
934939
}

0 commit comments

Comments
 (0)