drivers: sensor: mcux_acmp: update mcux_acmp drivers

add MCUX_ACMP_HAS_HYSTCTR macro to adapt feature if IP
don't exist HYSTCTR bit

Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
This commit is contained in:
Lucien Zhao 2024-08-31 14:31:06 +08:00 committed by Carles Cufí
commit 62e5805c57
2 changed files with 12 additions and 2 deletions

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020 Vestas Wind Systems A/S
* Copyright 2022 NXP
* Copyright 2022, 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -107,6 +107,7 @@ static int mcux_acmp_attr_set(const struct device *dev,
}
break;
#endif /* MCUX_ACMP_HAS_OFFSET */
#if MCUX_ACMP_HAS_HYSTCTR
case SENSOR_ATTR_MCUX_ACMP_HYSTERESIS_LEVEL:
if (val1 >= kACMP_HysteresisLevel0 &&
val1 <= kACMP_HysteresisLevel3) {
@ -118,6 +119,7 @@ static int mcux_acmp_attr_set(const struct device *dev,
return -EINVAL;
}
break;
#endif /* MCUX_ACMP_HAS_HYSTCTR */
case SENSOR_ATTR_MCUX_ACMP_DAC_VOLTAGE_REFERENCE:
if (val1 >= kACMP_VrefSourceVin1 &&
val1 <= kACMP_VrefSourceVin2) {
@ -271,9 +273,11 @@ static int mcux_acmp_attr_get(const struct device *dev,
val->val1 = data->config.offsetMode;
break;
#endif /* MCUX_ACMP_HAS_OFFSET */
#if MCUX_ACMP_HAS_HYSTCTR
case SENSOR_ATTR_MCUX_ACMP_HYSTERESIS_LEVEL:
val->val1 = data->config.hysteresisMode;
break;
#endif /* MCUX_ACMP_HAS_HYSTCTR */
case SENSOR_ATTR_MCUX_ACMP_DAC_VOLTAGE_REFERENCE:
val->val1 = data->dac.referenceVoltageSource;
break;

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020 Vestas Wind Systems A/S
* Copyright 2022 NXP
* Copyright 2022, 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -43,6 +43,12 @@ extern "C" {
#define MCUX_ACMP_HAS_DISCRETE_MODE 0
#endif
#if defined(FSL_FEATURE_ACMP_HAS_C0_HYSTCTR_BIT) && (FSL_FEATURE_ACMP_HAS_C0_HYSTCTR_BIT == 1U)
#define MCUX_ACMP_HAS_HYSTCTR 1
#else
#define MCUX_ACMP_HAS_HYSTCTR 0
#endif
enum sensor_channel_mcux_acmp {
/** Analog Comparator Output. */
SENSOR_CHAN_MCUX_ACMP_OUTPUT = SENSOR_CHAN_PRIV_START,