From c5dd2c2a849f7ed66f3f5107acb65ea4adb32400 Mon Sep 17 00:00:00 2001 From: Lucien Zhao Date: Sat, 31 Aug 2024 14:37:17 +0800 Subject: [PATCH] samples: sensor: mcux_acmp: add case support for RT1180-EVK Use gpio_ad_01_acmp1_in2 as ACMP1_IN2, test case can be captured in J45-13. Signed-off-by: Lucien Zhao --- boards/nxp/mimxrt1180_evk/doc/index.rst | 2 ++ samples/sensor/mcux_acmp/README.rst | 22 +++++++++++++++++-- .../mimxrt1180_evk_mimxrt1189_cm33.overlay | 22 +++++++++++++++++++ .../mimxrt1180_evk_mimxrt1189_cm7.overlay | 22 +++++++++++++++++++ samples/sensor/mcux_acmp/sample.yaml | 2 ++ samples/sensor/mcux_acmp/src/main.c | 4 +++- 6 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm33.overlay create mode 100644 samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm7.overlay diff --git a/boards/nxp/mimxrt1180_evk/doc/index.rst b/boards/nxp/mimxrt1180_evk/doc/index.rst index cb283aab36e..80926edc464 100644 --- a/boards/nxp/mimxrt1180_evk/doc/index.rst +++ b/boards/nxp/mimxrt1180_evk/doc/index.rst @@ -107,6 +107,8 @@ configuration supports the following hardware features: +-----------+------------+-------------------------------------+ | I2C | on-chip | i2c | +-----------+------------+-------------------------------------+ +| ACMP | on-chip | analog comparator | ++-----------+------------+-------------------------------------+ The default configuration can be found in the defconfig file: :zephyr_file:`boards/nxp/mimxrt1180_evk/mimxrt1180_evk_mimxrt1189_cm33_defconfig` diff --git a/samples/sensor/mcux_acmp/README.rst b/samples/sensor/mcux_acmp/README.rst index 499d39ddcb1..5a7d1844ad3 100644 --- a/samples/sensor/mcux_acmp/README.rst +++ b/samples/sensor/mcux_acmp/README.rst @@ -9,14 +9,15 @@ Overview This sample show how to use the NXP MCUX Analog Comparator (ACMP) driver. The sample supports the :ref:`twr_ke18f`, :ref:`mimxrt1170_evk`, :ref:`frdm_ke17z` -and :ref:`frdm_ke17z512`. +, :ref:`frdm_ke17z512` and :ref:`mimxrt1180_evk`. The input voltage for the negative input of the analog comparator is provided by the ACMP Digital-to-Analog Converter (DAC). The input voltage for the positive input can be adjusted by turning the on-board potentiometer for :ref:`twr_ke18f` board, for :ref:`mimxrt1170_evk` the voltage signal is captured on J25-13, the :ref:`frdm_ke17z` and :ref:`frdm_ke17z512` boards are -captured in J2-3, need change the external voltage signal to check the output. +captured in J2-3, the :ref:`mimxrt1180_evk` board are captured in J45-13, need +change the external voltage signal to check the output. The output value of the analog comparator is reported on the console. @@ -66,3 +67,20 @@ ACMP input voltage by changing the voltage input to J2-3. :board: frdm_ke17z512 :goals: flash :compact: + +Building and Running for MIMXRT1180-EVK +======================================= +Build the application for the MIMXRT1180-EVK board, and adjust the +ACMP input voltage by changing the voltage input to J45-13. + +.. zephyr-app-commands:: + :zephyr-app: samples/sensor/mcux_acmp + :board: mimxrt1180_evk/mimxrt1189/cm33 + :goals: flash + :compact: + +.. zephyr-app-commands:: + :zephyr-app: samples/sensor/mcux_acmp + :board: mimxrt1180_evk/mimxrt1189/cm7 + :goals: flash + :compact: diff --git a/samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm33.overlay b/samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm33.overlay new file mode 100644 index 00000000000..9a9e00b91b7 --- /dev/null +++ b/samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm33.overlay @@ -0,0 +1,22 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + acmp1_default: acmp1_default { + group0 { + pinmux = <&iomuxc_gpio_ad_01_acmp1_in2>; + drive-strength = "high"; + bias-pull-up; + slew-rate = "fast"; + }; + }; +}; + +&acmp1 { + status = "okay"; + pinctrl-0 = <&acmp1_default>; + pinctrl-names = "default"; +}; diff --git a/samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm7.overlay b/samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm7.overlay new file mode 100644 index 00000000000..9a9e00b91b7 --- /dev/null +++ b/samples/sensor/mcux_acmp/boards/mimxrt1180_evk_mimxrt1189_cm7.overlay @@ -0,0 +1,22 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + acmp1_default: acmp1_default { + group0 { + pinmux = <&iomuxc_gpio_ad_01_acmp1_in2>; + drive-strength = "high"; + bias-pull-up; + slew-rate = "fast"; + }; + }; +}; + +&acmp1 { + status = "okay"; + pinctrl-0 = <&acmp1_default>; + pinctrl-names = "default"; +}; diff --git a/samples/sensor/mcux_acmp/sample.yaml b/samples/sensor/mcux_acmp/sample.yaml index 408008460b4..fa7782d896d 100644 --- a/samples/sensor/mcux_acmp/sample.yaml +++ b/samples/sensor/mcux_acmp/sample.yaml @@ -8,6 +8,8 @@ common: - mimxrt1170_evk/mimxrt1176/cm4 - frdm_ke17z - frdm_ke17z512 + - mimxrt1180_evk/mimxrt1189/cm33 + - mimxrt1180_evk/mimxrt1189/cm7 integration_platforms: - twr_ke18f tags: diff --git a/samples/sensor/mcux_acmp/src/main.c b/samples/sensor/mcux_acmp/src/main.c index 8e96a8d406c..a915b1eecb8 100644 --- a/samples/sensor/mcux_acmp/src/main.c +++ b/samples/sensor/mcux_acmp/src/main.c @@ -16,7 +16,7 @@ #define ACMP_POSITIVE 5 #define ACMP_NEGATIVE 5 #define ACMP_DAC_VREF 0 -#elif defined(CONFIG_BOARD_MIMXRT1170_EVK) +#elif (defined(CONFIG_BOARD_MIMXRT1170_EVK) || defined(CONFIG_BOARD_MIMXRT1180_EVK)) #define ACMP_NODE DT_NODELABEL(acmp1) #define ACMP_POSITIVE 2 #define ACMP_NEGATIVE 7 @@ -58,8 +58,10 @@ static const struct acmp_attr attrs[] = { .val = ACMP_DAC_VREF }, /* DAC value */ { .attr = SENSOR_ATTR_MCUX_ACMP_DAC_VALUE, .val = ACMP_DAC_VALUE }, +#if MCUX_ACMP_HAS_HYSTCTR /* Hysteresis level */ { .attr = SENSOR_ATTR_MCUX_ACMP_HYSTERESIS_LEVEL, .val = 3 }, +#endif #if MCUX_ACMP_HAS_DISCRETE_MODE /* Discrete mode */ { .attr = SENSOR_ATTR_MCUX_ACMP_POSITIVE_DISCRETE_MODE, .val = 1 },