Commit 1425ae1a authored by Zhaoxiang Jin's avatar Zhaoxiang Jin Committed by David Leach
Browse files

samples: sensor/mcux_lpcmp: Add LPCMP use case



Add LPCMP use case.
Enable LPCMP use case on NXP frdm_mcxn947 board.

Signed-off-by: default avatarZhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
parent ea8eea4d
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(mcux_lpcmp)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
+36 −0
Original line number Diff line number Diff line
.. _mcux_lpcmp:

NXP MCUX Low-power Analog Comparator (LPCMP)
############################################

Overview
********

This sample show how to use the NXP MCUX Analog Comparator (LPCMP) driver.

In this application, the negative input port of the LPCMP is set to 7 which
means the input voltage comes from the LPCMP internal DAC, the reference
voltage of the DAC is set to 0 (for the specific chip, the user needs to
check the reference manual to confirm where this reference voltage comes
from), the output voltage of the DAC is equal to (VREF/256)*(data+1), where
data is set through the attribute ``SENSOR_ATTR_MCUX_LPCMP_DAC_OUTPUT_VOLTAGE``.
The positive input port is set to 0, the user needs to check the reference
manual and board schematic to confirm which specific port is used and can
connect an external voltage to that port and change the input voltage to
see the output change of the LPCMP.

The output value of the LPCMP is reported on the console.

Building and Running
********************

Building and Running for NXP FRDM-MCXN947
=========================================
Build the application for the :ref:`frdm_mcxn947` board, and adjust the
LPCMP positive input port voltage by changing the voltage input to J2-17.

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/mcux_lpcmp
   :board: frdm_mcxn947//cpu0
   :goals: build flash
   :compact:
+9 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 NXP
 *
 * SPDX-License-Identifier: Apache-2.0
 */

&lpcmp0 {
    function-clock = "CMP_CLOCK";
};
+2 −0
Original line number Diff line number Diff line
CONFIG_SENSOR=y
CONFIG_MCUX_LPCMP_TRIGGER=y
+23 −0
Original line number Diff line number Diff line
sample:
  description: Demonstration of the NXP MCUX LPCMP driver
  name: NXP MCUX LPCMP sample
common:
  platform_allow:
    - frdm_mcxn947/mcxn947/cpu0
  integration_platforms:
    - frdm_mcxn947/mcxn947/cpu0
  tags:
    - drivers
    - sensor
tests:
  sample.sensor.mcux_lpcmp:
    harness: console
    harness_config:
      type: one_line
      ordered: true
      regex:
        - "LPCMP input [a-z]* threshold"
  sample.sensor.mcux_lpcmp.no_trigger:
    build_only: true
    extra_configs:
      - CONFIG_MCUX_LPCMP_TRIGGER=n
Loading