Skip to content

Commit c008c1e

Browse files
silabs-bozontnashif
authored andcommitted
boards: sparkfun: add ADC support for the ThingPlus MGM240P
ADC pins are now mapped to the A0-A7 pins. Signed-off-by: Tamas Jozsi <tamas.jozsi@silabs.com>
1 parent 9358697 commit c008c1e

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

boards/sparkfun/thing_plus_matter_mgm240p/sparkfun_thing_plus_matter_mgm240p-pinctrl.dtsi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@
2020
};
2121
};
2222

23+
iadc0_default: iadc0_default {
24+
group0 {
25+
silabs,analog-bus = <ABUS_AEVEN0_IADC0>;
26+
};
27+
28+
group1 {
29+
silabs,analog-bus = <ABUS_BEVEN0_IADC0>;
30+
};
31+
32+
group2 {
33+
silabs,analog-bus = <ABUS_BODD0_IADC0>;
34+
};
35+
36+
group3 {
37+
silabs,analog-bus = <ABUS_CDEVEN0_IADC0>;
38+
};
39+
};
40+
2341
i2c0_default: i2c0_default {
2442
group0 {
2543
pins = <I2C0_SDA_PB3>, <I2C0_SCL_PB4>;

boards/sparkfun/thing_plus_matter_mgm240p/sparkfun_thing_plus_matter_mgm240p.dts

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/dts-v1/;
1010
#include <silabs/xg24/mgm240pb32vna.dtsi>
1111
#include <zephyr/dt-bindings/pwm/pwm.h>
12+
#include <dt-bindings/adc/silabs-adc.h>
1213
#include "sparkfun_thing_plus_matter_mgm240p-pinctrl.dtsi"
1314
#include <zephyr/dt-bindings/input/input-event-codes.h>
1415
#include <zephyr/dt-bindings/regulator/silabs_dcdc.h>
@@ -31,6 +32,7 @@
3132
pwm-led0 = &blue_pwm_led;
3233
spi0 = &eusart1;
3334
watchdog0 = &wdog0;
35+
adc0 = &adc0;
3436
};
3537

3638
leds {
@@ -49,6 +51,17 @@
4951
label = "blue";
5052
};
5153
};
54+
55+
zephyr,user {
56+
io-channels = <&adc0 0>,
57+
<&adc0 1>,
58+
<&adc0 2>,
59+
<&adc0 3>,
60+
<&adc0 4>,
61+
<&adc0 5>,
62+
<&adc0 6>,
63+
<&adc0 7>;
64+
};
5265
};
5366

5467
&timer0 {
@@ -180,7 +193,99 @@ zephyr_i2c: &i2c0 {
180193
};
181194

182195
&adc0 {
196+
pinctrl-0 = <&iadc0_default>;
197+
pinctrl-names = "default";
198+
#address-cells = <1>;
199+
#size-cells = <0>;
183200
status = "okay";
201+
202+
/* A0 - PB4 */
203+
channel@0 {
204+
reg = <0>;
205+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
206+
zephyr,gain = "ADC_GAIN_1";
207+
zephyr,input-positive = <IADC_INPUT_PB4>;
208+
zephyr,reference = "ADC_REF_VDD_1";
209+
zephyr,resolution = <12>;
210+
zephyr,vref-mv = <3300>;
211+
};
212+
213+
/* A1 - PB3 */
214+
channel@1 {
215+
reg = <1>;
216+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
217+
zephyr,gain = "ADC_GAIN_1";
218+
zephyr,input-positive = <IADC_INPUT_PB3>;
219+
zephyr,reference = "ADC_REF_VDD_1";
220+
zephyr,resolution = <12>;
221+
zephyr,vref-mv = <3300>;
222+
};
223+
224+
/* A2 - PB2 */
225+
channel@2 {
226+
reg = <2>;
227+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
228+
zephyr,gain = "ADC_GAIN_1";
229+
zephyr,input-positive = <IADC_INPUT_PB2>;
230+
zephyr,reference = "ADC_REF_VDD_1";
231+
zephyr,resolution = <12>;
232+
zephyr,vref-mv = <3300>;
233+
};
234+
235+
/* A3 - PB1 */
236+
channel@3 {
237+
reg = <3>;
238+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
239+
zephyr,gain = "ADC_GAIN_1";
240+
zephyr,input-positive = <IADC_INPUT_PB1>;
241+
zephyr,reference = "ADC_REF_VDD_1";
242+
zephyr,resolution = <12>;
243+
zephyr,vref-mv = <3300>;
244+
};
245+
246+
/* A4 - PB0 */
247+
channel@4 {
248+
reg = <4>;
249+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
250+
zephyr,gain = "ADC_GAIN_1";
251+
zephyr,input-positive = <IADC_INPUT_PB0>;
252+
zephyr,reference = "ADC_REF_VDD_1";
253+
zephyr,resolution = <12>;
254+
zephyr,vref-mv = <3300>;
255+
};
256+
257+
/* A5 - PA0 */
258+
channel@5 {
259+
reg = <5>;
260+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
261+
zephyr,gain = "ADC_GAIN_1";
262+
zephyr,input-positive = <IADC_INPUT_PA0>;
263+
zephyr,reference = "ADC_REF_VDD_1";
264+
zephyr,resolution = <12>;
265+
zephyr,vref-mv = <3300>;
266+
};
267+
268+
/* A6 - PA4 */
269+
channel@6 {
270+
reg = <6>;
271+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
272+
zephyr,gain = "ADC_GAIN_1";
273+
zephyr,input-positive = <IADC_INPUT_PA4>;
274+
zephyr,reference = "ADC_REF_VDD_1";
275+
zephyr,resolution = <12>;
276+
zephyr,vref-mv = <3300>;
277+
};
278+
279+
/* A7 - PC4 */
280+
channel@7 {
281+
reg = <7>;
282+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
283+
zephyr,gain = "ADC_GAIN_1";
284+
zephyr,input-positive = <IADC_INPUT_PC4>;
285+
zephyr,reference = "ADC_REF_VDD_1";
286+
zephyr,resolution = <12>;
287+
zephyr,vref-mv = <3300>;
288+
};
184289
};
185290

186291
&sysrtc0 {

0 commit comments

Comments
 (0)