Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ADC support for NXP frdm_ke17z and frdm_ke17z512 #75068

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards/nxp/frdm_ke17z/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ features:
+-----------+------------+-------------------------------------+
| PINCTRL | on-chip | pinctrl |
+-----------+------------+-------------------------------------+
| ADC | on-chip | adc |
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| UART | on-chip | uart |
Expand Down
7 changes: 7 additions & 0 deletions boards/nxp/frdm_ke17z/frdm_ke17z-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#include <nxp/kinetis/MKE17Z256VLL7-pinctrl.h>

&pinctrl {
adc0_default: adc0_default {
group0 {
pinmux = <ADC0_SE0_PTE9>;
drive-strength = "low";
slew-rate = "slow";
};
};

lpuart0_default: lpuart0_default {
group0 {
Expand Down
7 changes: 7 additions & 0 deletions boards/nxp/frdm_ke17z/frdm_ke17z.dts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
pinctrl-names = "default";
};

&adc0 {
status = "okay";
sample-time = <12>;
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};

&lpi2c0 {
status = "okay";
pinctrl-0 = <&lpi2c0_default>;
Expand Down
1 change: 1 addition & 0 deletions boards/nxp/frdm_ke17z/frdm_ke17z.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ toolchain:
- xtools
supported:
- gpio
- adc
- uart
- i2c
- spi
Expand Down
2 changes: 2 additions & 0 deletions boards/nxp/frdm_ke17z512/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ features:
+-----------+------------+-------------------------------------+
| SYSTICK | on-chip | systick |
+-----------+------------+-------------------------------------+
| ADC | on-chip | adc |
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| UART | on-chip | uart polling; |
Expand Down
7 changes: 7 additions & 0 deletions boards/nxp/frdm_ke17z512/frdm_ke17z512-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#include <nxp/kinetis/MKE17Z512VLL9-pinctrl.h>

&pinctrl {
adc0_default: adc0_default {
group0 {
pinmux = <ADC0_SE0_PTE9>;
drive-strength = "low";
slew-rate = "slow";
};
};

/* Configures pin routing and optionally pin electrical features. */
lpuart2_default: lpuart2_default {
Expand Down
7 changes: 7 additions & 0 deletions boards/nxp/frdm_ke17z512/frdm_ke17z512.dts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
current-speed = <115200>;
};

&adc0 {
status = "okay";
sample-time = <12>;
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};

&gpiod {
status = "okay";
};
Expand Down
1 change: 1 addition & 0 deletions boards/nxp/frdm_ke17z512/frdm_ke17z512.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ toolchain:
- xtools
supported:
- gpio
- adc
- uart
- i2c
- spi
Expand Down
12 changes: 12 additions & 0 deletions dts/arm/nxp/nxp_ke1xz.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <mem.h>
#include "armv6-m.dtsi"
#include <zephyr/dt-bindings/adc/adc.h>
#include <zephyr/dt-bindings/clock/kinetis_pcc.h>
#include <zephyr/dt-bindings/clock/kinetis_scg.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
Expand Down Expand Up @@ -114,6 +115,17 @@
};
};

adc0: adc@4003b000 {
compatible = "nxp,kinetis-adc12";
reg = <0x4003b000 0x1000>;
interrupts = <15 0>;
clocks = <&pcc 0xec KINETIS_PCC_SRC_SIRC_ASYNC>;
clk-source = <0>;
clk-divider = <1>;
status = "disabled";
#io-channel-cells = <1>;
};

lpuart0: uart@4006a000 {
compatible = "nxp,kinetis-lpuart";
reg = <0x4006a000 0x1000>;
Expand Down
4 changes: 4 additions & 0 deletions soc/nxp/kinetis/ke1xz/soc.c
ankeXiao marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ static ALWAYS_INLINE void clk_init(void)
CLOCK_SetIpSrc(kCLOCK_Lpspi1,
DT_CLOCKS_CELL(DT_NODELABEL(lpspi1), ip_source));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc0), okay)
CLOCK_SetIpSrc(kCLOCK_Adc0,
DT_CLOCKS_CELL(DT_NODELABEL(adc0), ip_source));
#endif
}

static int ke1xz_init(void)
Expand Down
32 changes: 32 additions & 0 deletions tests/drivers/adc/adc_api/boards/frdm_ke17z.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
io-channels = <&adc0 0>, <&adc0 1>;
};
};

&adc0 {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};

channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
};
32 changes: 32 additions & 0 deletions tests/drivers/adc/adc_api/boards/frdm_ke17z512.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
io-channels = <&adc0 0>, <&adc0 1>;
};
};

&adc0 {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};

channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
};
Loading