adc: mchp_xec: right justify ADC output data under 10-bit res
This enables the ADC output data to be shifted right when using 10-bit resolution. Or else, data would be left justified as if it's doing 12-bit ADC with the right 2 bits filled with zeroes. Fixes #23202 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
7f2996b061
commit
c3701f51d7
1 changed files with 3 additions and 1 deletions
|
@ -168,12 +168,14 @@ static int adc_xec_start_read(struct device *dev,
|
|||
|
||||
/* Setup ADC resolution */
|
||||
reg = adc_regs->sar_control_reg;
|
||||
reg &= ~MCHP_ADC_SAR_CTRL_RES_MASK;
|
||||
reg &= ~(MCHP_ADC_SAR_CTRL_RES_MASK |
|
||||
(1 << MCHP_ADC_SAR_CTRL_SHIFTD_POS));
|
||||
|
||||
if (sequence->resolution == 12) {
|
||||
reg |= MCHP_ADC_SAR_CTRL_RES_12_BITS;
|
||||
} else if (sequence->resolution == 10) {
|
||||
reg |= MCHP_ADC_SAR_CTRL_RES_10_BITS;
|
||||
reg |= MCHP_ADC_SAR_CTRL_SHIFTD_EN;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue