Skip to content

Commit 5f51b0a

Browse files
decsnydleach02
authored andcommitted
boards: frdm_mcxw71: Enable ADC and tests/sample
Enable LPADC on the FRDM_MCXW71 and add overlays for tests and sample Signed-off-by: Declan Snyder <[email protected]>
1 parent c1affb9 commit 5f51b0a

File tree

7 files changed

+125
-0
lines changed

7 files changed

+125
-0
lines changed

boards/nxp/frdm_mcxw71/doc/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ The ``frdm_mcxw71`` board target in Zephyr currently supports the following feat
6666
+-----------+------------+-------------------------------------+
6767
| VREF | on-chip | regulator |
6868
+-----------+------------+-------------------------------------+
69+
| LPADC | on-chip | adc |
70+
+-----------+------------+-------------------------------------+
6971

7072
Fetch Binary Blobs
7173
******************

boards/nxp/frdm_mcxw71/frdm_mcxw71-pinctrl.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,14 @@
5858
drive-strength = "low";
5959
};
6060
};
61+
62+
pinmux_lpadc0: pinmux_lpadc0 {
63+
group0 {
64+
pinmux = <ADC0_A6_PTD2>,
65+
<ADC0_B6_PTD3>,
66+
<ADC0_B5_PTD1>;
67+
drive-strength = "low";
68+
slew-rate = "fast";
69+
};
70+
};
6171
};

boards/nxp/frdm_mcxw71/frdm_mcxw71.dts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,9 @@
131131
max-bitrate = <5000000>;
132132
};
133133
};
134+
135+
&adc0 {
136+
pinctrl-0 = <&pinmux_lpadc0>;
137+
pinctrl-names = "default";
138+
status = "okay";
139+
};

boards/nxp/frdm_mcxw71/frdm_mcxw71.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ supported:
2020
- i2c
2121
- can
2222
- regulator
23+
- adc
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2024 NXP
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/adc/adc.h>
7+
#include <zephyr/dt-bindings/adc/mcux-lpadc.h>
8+
9+
/ {
10+
zephyr,user {
11+
io-channels = <&adc0 0>;
12+
};
13+
};
14+
15+
&adc0 {
16+
#address-cells = <1>;
17+
#size-cells = <0>;
18+
19+
channel@0 {
20+
reg = <0>;
21+
zephyr,gain = "ADC_GAIN_1";
22+
zephyr,reference = "ADC_REF_EXTERNAL1";
23+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
24+
zephyr,resolution = <12>;
25+
zephyr,vref-mv = <1800>;
26+
/* channel 2 signal 6A */
27+
zephyr,input-positive = <MCUX_LPADC_CH2A>;
28+
};
29+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2024 NXP
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/adc/adc.h>
7+
#include <zephyr/dt-bindings/adc/mcux-lpadc.h>
8+
9+
/ {
10+
zephyr,user {
11+
io-channels = <&adc0 0>;
12+
};
13+
};
14+
15+
&adc0 {
16+
#address-cells = <1>;
17+
#size-cells = <0>;
18+
19+
channel@0 {
20+
reg = <0>;
21+
zephyr,gain = "ADC_GAIN_1";
22+
zephyr,reference = "ADC_REF_EXTERNAL1";
23+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
24+
zephyr,resolution = <12>;
25+
zephyr,vref-mv = <1800>;
26+
/* channel 2 signal 6A */
27+
zephyr,input-positive = <MCUX_LPADC_CH2A>;
28+
};
29+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2024 NXP
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/adc/adc.h>
7+
#include <zephyr/dt-bindings/adc/mcux-lpadc.h>
8+
#include <zephyr/dt-bindings/regulator/nxp_vref.h>
9+
10+
/* To do this test, connect LPADC0 channel 6A(J4 pin 5) to VREF_OUT (J2 pin 3) */
11+
12+
/ {
13+
resources: resources {
14+
compatible = "test-regulator-voltage";
15+
regulators = <&vref>;
16+
tolerance-microvolt = <40000>;
17+
set-read-delay-ms = <1>;
18+
adc-avg-count = <10>;
19+
io-channels = <&adc0 0>;
20+
min-microvolt = <1000000>;
21+
max-microvolt = <2100000>;
22+
};
23+
};
24+
25+
&vref {
26+
regulator-initial-mode = <NXP_VREF_MODE_INTERNAL_REGULATOR>;
27+
};
28+
29+
&adc0 {
30+
#address-cells = <1>;
31+
#size-cells = <0>;
32+
33+
/* In this case, the LPADC reference source cannot be set to VREFO,
34+
* switch the reference source to VDD_ANA.
35+
*/
36+
voltage-ref= <0>;
37+
38+
channel@0 {
39+
reg = <0>;
40+
zephyr,gain = "ADC_GAIN_1";
41+
zephyr,reference = "ADC_REF_EXTERNAL0";
42+
zephyr,vref-mv = <3300>;
43+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
44+
zephyr,resolution = <12>;
45+
/* the signal name is ADC0_A6 but it is still channel 2 */
46+
zephyr,input-positive = <MCUX_LPADC_CH2A>;
47+
};
48+
};

0 commit comments

Comments
 (0)