From 884e391954b33342bbe0a8af60b04689f8caf5f5 Mon Sep 17 00:00:00 2001 From: sp-cai <70000077+sp-cai@users.noreply.github.com> Date: Sat, 1 Jun 2024 13:27:12 +0800 Subject: [PATCH] =?UTF-8?q?[fix][misc][adc]=20=E4=BF=AE=E5=A4=8D=20ADC=20?= =?UTF-8?q?=E7=94=B5=E5=8E=8B=E8=BD=AC=E6=8D=A2=E7=9A=84=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/misc/adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c index 4a580b32806..c07ef6e6116 100644 --- a/components/drivers/misc/adc.c +++ b/components/drivers/misc/adc.c @@ -184,7 +184,7 @@ rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_int8_t channel) /*read the value and convert to voltage*/ dev->ops->convert(dev, channel, &value); - voltage = value * vref / (1 << resolution); + voltage = value * vref / ((1 << resolution) - 1); _voltage_exit: return voltage; @@ -285,6 +285,7 @@ static int adc(int argc, char **argv) rt_kprintf("adc read - read adc value on the channel\n"); rt_kprintf("adc disable - disable adc channel\n"); rt_kprintf("adc enable - enable adc channel\n"); + rt_kprintf("adc voltage - read voltage on the channel\n"); result = -RT_ERROR; }