Skip to content

Commit b42b595

Browse files
committed
samples: adc_dt: add support for the CH32V003EVT evaluation board
This demonstrates the ADC driver added in the previous commit. The sample reads A0 as well as two built-in channels - one that reports the internal 1.2 reference volatage and one that reports half the analog supply voltage. Signed-off-by: Michael Hope <[email protected]>
1 parent 325883a commit b42b595

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2025 Michael Hope <[email protected]>
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/adc/adc.h>
7+
8+
/ {
9+
zephyr,user {
10+
io-channels = <&adc1 0>, <&adc1 8>, <&adc1 9>;
11+
};
12+
};
13+
14+
&pinctrl {
15+
adc1_default: adc1_default {
16+
group1 {
17+
pinmux = <ADC1_A0_PA2_0>;
18+
};
19+
};
20+
};
21+
22+
&adc1 {
23+
#address-cells = <1>;
24+
#size-cells = <0>;
25+
status = "okay";
26+
27+
pinctrl-0 = <&adc1_default>;
28+
pinctrl-names = "default";
29+
30+
/* Channel 0 is floating */
31+
channel@0 {
32+
reg = <0>;
33+
zephyr,gain = "ADC_GAIN_1";
34+
zephyr,reference = "ADC_REF_INTERNAL";
35+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
36+
zephyr,resolution = <10>;
37+
};
38+
39+
/* Channel 8 is connected to Vref, which is between 1.17 and 1.23 V */
40+
channel@8 {
41+
reg = <8>;
42+
zephyr,gain = "ADC_GAIN_1";
43+
zephyr,reference = "ADC_REF_INTERNAL";
44+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
45+
zephyr,resolution = <10>;
46+
};
47+
48+
/* Channel 8 is connected to Vcal, which is half of Avdd, i.e ~1.65 V */
49+
channel@9 {
50+
reg = <9>;
51+
zephyr,gain = "ADC_GAIN_1";
52+
zephyr,reference = "ADC_REF_INTERNAL";
53+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
54+
zephyr,resolution = <10>;
55+
};
56+
};

0 commit comments

Comments
 (0)