boards: Add analog comparator support on MIMXRT1170 EVK
Updated mcux_acmp sample to support discrete mode config. Add ACMP support on MIMXRT1170 EVK. Signed-off-by: Chay Guo <changyi.guo@nxp.com>
This commit is contained in:
parent
08641f0616
commit
191f93c325
|
@ -127,6 +127,8 @@ features:
|
|||
+-----------+------------+-------------------------------------+
|
||||
| DISPLAY | on-chip | display |
|
||||
+-----------+------------+-------------------------------------+
|
||||
| ACMP | on-chip | analog comparator |
|
||||
+-----------+------------+-------------------------------------+
|
||||
|
||||
The default configuration can be found in the defconfig file:
|
||||
``boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm7_defconfig``
|
||||
|
|
|
@ -916,6 +916,42 @@
|
|||
#io-channel-cells = <1>;
|
||||
};
|
||||
|
||||
acmp1: cmp@401a4000 {
|
||||
compatible = "nxp,kinetis-acmp";
|
||||
reg = <0x401a4000 0x4000>;
|
||||
interrupts = <157 0>;
|
||||
label = "CMP_1";
|
||||
status = "disabled";
|
||||
#io-channel-cells = <2>;
|
||||
};
|
||||
|
||||
acmp2: cmp@401a8000 {
|
||||
compatible = "nxp,kinetis-acmp";
|
||||
reg = <0x401a8000 0x4000>;
|
||||
interrupts = <158 0>;
|
||||
label = "CMP_2";
|
||||
status = "disabled";
|
||||
#io-channel-cells = <2>;
|
||||
};
|
||||
|
||||
acmp3: cmp@401ac000 {
|
||||
compatible = "nxp,kinetis-acmp";
|
||||
reg = <0x401ac000 0x4000>;
|
||||
interrupts = <159 0>;
|
||||
label = "CMP_3";
|
||||
status = "disabled";
|
||||
#io-channel-cells = <2>;
|
||||
};
|
||||
|
||||
acmp4: cmp@401b0000 {
|
||||
compatible = "nxp,kinetis-acmp";
|
||||
reg = <0x401b0000 0x4000>;
|
||||
interrupts = <160 0>;
|
||||
label = "CMP_4";
|
||||
status = "disabled";
|
||||
#io-channel-cells = <2>;
|
||||
};
|
||||
|
||||
anatop: anatop@40c84000 {
|
||||
compatible = "nxp,imx-anatop";
|
||||
reg = <0x40c84000 0x4000>;
|
||||
|
|
|
@ -7,17 +7,22 @@ Overview
|
|||
********
|
||||
|
||||
This sample show how to use the NXP MCUX Analog Comparator (ACMP) driver. The
|
||||
sample supports the :ref:`twr_ke18f`.
|
||||
sample supports the :ref:`twr_ke18f`, :ref:`mimxrt1170_evk`.
|
||||
|
||||
The input voltage for the 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.
|
||||
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, need change the external voltage signal to check the
|
||||
output.
|
||||
|
||||
The output value of the analog comparator is reported on the console.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
Building and Running for TWR-KE18F
|
||||
==================================
|
||||
Build the application for the :ref:`twr_ke18f` board, and adjust the
|
||||
ACMP input voltage by turning the on-board potentiometer.
|
||||
|
||||
|
@ -26,3 +31,14 @@ ACMP input voltage by turning the on-board potentiometer.
|
|||
:board: twr_ke18f
|
||||
:goals: flash
|
||||
:compact:
|
||||
|
||||
Building and Running for MIMXRT1170-EVK
|
||||
=======================================
|
||||
Build the application for the MIMXRT1170-EVK board, and adjust the
|
||||
ACMP input voltage by changing the voltage input to J25-13.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/drivers/mcux_acmp
|
||||
:board: mimxrt1170_evk_cm7
|
||||
:goals: flash
|
||||
:compact:
|
||||
|
|
22
samples/sensor/mcux_acmp/boards/mimxrt1170_evk_cm4.overlay
Normal file
22
samples/sensor/mcux_acmp/boards/mimxrt1170_evk_cm4.overlay
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2022 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";
|
||||
};
|
22
samples/sensor/mcux_acmp/boards/mimxrt1170_evk_cm7.overlay
Normal file
22
samples/sensor/mcux_acmp/boards/mimxrt1170_evk_cm7.overlay
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2022 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";
|
||||
};
|
|
@ -2,7 +2,7 @@ sample:
|
|||
description: Demonstration of the NXP MCUX ACMP sensor driver
|
||||
name: NXP MCUX ACMP sample
|
||||
common:
|
||||
platform_allow: twr_ke18f
|
||||
platform_allow: twr_ke18f mimxrt1170_evk_cm7 mimxrt1170_evk_cm4
|
||||
integration_platforms:
|
||||
- twr_ke18f
|
||||
tags: drivers
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
#define ACMP_POSITIVE 5
|
||||
#define ACMP_NEGATIVE 5
|
||||
#define ACMP_DAC_VREF 0
|
||||
#elif (defined(CONFIG_BOARD_MIMXRT1170_EVK_CM7) || defined(CONFIG_BOARD_MIMXRT1170_EVK_CM4))
|
||||
#define ACMP_NODE DT_NODELABEL(acmp1)
|
||||
#define ACMP_POSITIVE 2
|
||||
#define ACMP_NEGATIVE 7
|
||||
/* Select Vin2. Vin1 is not used and tied to ground on this chip. Vin2 is from VDDA_1P8_IN. */
|
||||
#define ACMP_DAC_VREF 1
|
||||
#else
|
||||
#error Unsupported board
|
||||
#endif
|
||||
|
@ -28,13 +34,17 @@ struct acmp_attr {
|
|||
};
|
||||
|
||||
static const struct acmp_attr attrs[] = {
|
||||
#if MCUX_ACMP_HAS_INPSEL
|
||||
/* Positive input port set to MUX */
|
||||
{ .attr = SENSOR_ATTR_MCUX_ACMP_POSITIVE_PORT_INPUT, .val = 1 },
|
||||
#endif
|
||||
/* Positive input channel */
|
||||
{ .attr = SENSOR_ATTR_MCUX_ACMP_POSITIVE_MUX_INPUT,
|
||||
.val = ACMP_POSITIVE },
|
||||
#if MCUX_ACMP_HAS_INNSEL
|
||||
/* Negative input port set to DAC */
|
||||
{ .attr = SENSOR_ATTR_MCUX_ACMP_NEGATIVE_PORT_INPUT, .val = 0 },
|
||||
#endif
|
||||
/* Negative input channel */
|
||||
{ .attr = SENSOR_ATTR_MCUX_ACMP_NEGATIVE_MUX_INPUT,
|
||||
.val = ACMP_NEGATIVE },
|
||||
|
@ -45,8 +55,14 @@ static const struct acmp_attr attrs[] = {
|
|||
{ .attr = SENSOR_ATTR_MCUX_ACMP_DAC_VALUE, .val = ACMP_DAC_VALUE },
|
||||
/* Hysteresis level */
|
||||
{ .attr = SENSOR_ATTR_MCUX_ACMP_HYSTERESIS_LEVEL, .val = 3 },
|
||||
#if MCUX_ACMP_HAS_DISCRETE_MODE
|
||||
/* Discrete mode */
|
||||
{ .attr = SENSOR_ATTR_MCUX_ACMP_POSITIVE_DISCRETE_MODE, .val = 1 },
|
||||
#endif
|
||||
#if MCUX_ACMP_HAS_OFFSET
|
||||
/* Offset level */
|
||||
{ .attr = SENSOR_ATTR_MCUX_ACMP_OFFSET_LEVEL, .val = 0 },
|
||||
#endif
|
||||
};
|
||||
|
||||
static const int16_t triggers[] = {
|
||||
|
|
|
@ -318,6 +318,7 @@ config SOC_MIMXRT1176_CM7
|
|||
select HAS_MCUX_GPC
|
||||
select HAS_MCUX_I2S
|
||||
select HAS_MCUX_USB_EHCI
|
||||
select HAS_MCUX_ACMP
|
||||
select HAS_MCUX_SRC_V2
|
||||
select HAS_MCUX_IOMUXC
|
||||
|
||||
|
@ -346,6 +347,7 @@ config SOC_MIMXRT1176_CM4
|
|||
select HAS_MCUX_ENET
|
||||
select HAS_MCUX_GPC
|
||||
select HAS_MCUX_I2S
|
||||
select HAS_MCUX_ACMP
|
||||
select HAS_MCUX_SRC_V2
|
||||
select HAS_MCUX_IOMUXC
|
||||
|
||||
|
|
|
@ -406,6 +406,15 @@ static ALWAYS_INLINE void clock_init(void)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MCUX_ACMP
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(acmp1), okay)
|
||||
/* Configure ACMP1 using Osc48MDiv2*/
|
||||
rootCfg.mux = kCLOCK_ACMP_ClockRoot_MuxOscRc48MDiv2;
|
||||
rootCfg.div = 1;
|
||||
CLOCK_SetRootClock(kCLOCK_Root_Acmp, &rootCfg);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DISPLAY_MCUX_ELCDIF
|
||||
rootCfg.mux = kCLOCK_LCDIF_ClockRoot_MuxSysPll2Out;
|
||||
rootCfg.div = 9;
|
||||
|
|
Loading…
Reference in a new issue