Skip to content
Open
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
11 changes: 11 additions & 0 deletions doc/releases/migration-guide-4.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ Device Drivers and Devicetree

.. zephyr-keep-sorted-start re(^\w)

Comparator
==========

* :dtcompatible:`nordic,nrf-comp` and :dtcompatible:`nordic,nrf-lpcomp` ``psel`` and ``extrefsel``
properties type has been changed to integer. The value of these properties is in the range
of :c:macro:`NRF_COMP_AIN0` to :c:macro:`NRF_COMP_AIN_VDDH_DIV5`, where :c:macro:`NRF_COMP_AIN0`
to :c:macro:`NRF_COMP_AIN7` represent the external inputs AIN0 to AIN7,
:c:macro:`NRF_COMP_AIN_VDD_DIV2` represents internal reference VDD/2,
and :c:macro:`NRF_COMP_AIN_VDDH_DIV5` represents VDDH/5.
The old ``string`` properties type is deprecated.

Phy
===

Expand Down
131 changes: 63 additions & 68 deletions drivers/comparator/comparator_nrf_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#define SHIM_NRF_COMP_DT_INST_REFSEL_IS_AREF(inst) \
DT_INST_ENUM_HAS_VALUE(inst, refsel, aref)

#define SHIM_NRF_COMP_DT_INST_EXTREFSEL(inst) \
_CONCAT(COMP_NRF_COMP_EXTREFSEL_, DT_INST_STRING_TOKEN(inst, extrefsel))
#define SHIM_NRF_COMP_DT_INST_EXTREFSEL(inst) DT_INST_PROP(inst, extrefsel)

#define SHIM_NRF_COMP_DT_INST_MAIN_MODE_IS_SE(inst) \
DT_INST_ENUM_HAS_VALUE(inst, main_mode, se)
Expand All @@ -43,8 +42,7 @@
#define SHIM_NRF_COMP_DT_INST_ISOURCE(inst) \
_CONCAT(COMP_NRF_COMP_ISOURCE_, DT_INST_STRING_TOKEN(inst, isource))

#define SHIM_NRF_COMP_DT_INST_PSEL(inst) \
_CONCAT(COMP_NRF_COMP_PSEL_, DT_INST_STRING_TOKEN(inst, psel))
#define SHIM_NRF_COMP_DT_INST_PSEL(inst) DT_INST_PROP(inst, psel)

#if defined(COMP_HYST_HYST_Hyst40mV)
#define NRF_COMP_HYST_ENABLED NRF_COMP_HYST_40MV
Expand Down Expand Up @@ -73,35 +71,50 @@
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_TH_UP(0) < 64);
#endif

#if NRF_COMP_HAS_AIN_AS_PIN
BUILD_ASSERT((COMP_NRF_COMP_PSEL_AIN0 == 0));
BUILD_ASSERT((COMP_NRF_COMP_PSEL_AIN7 == 7));
BUILD_ASSERT((COMP_NRF_COMP_EXTREFSEL_AIN0 == 0));
BUILD_ASSERT((COMP_NRF_COMP_EXTREFSEL_AIN7 == 7));
#if (NRF_COMP_HAS_AIN_AS_PIN)
BUILD_ASSERT(NRF_COMP_AIN0 == 0);
BUILD_ASSERT(NRF_COMP_AIN7 == 7);
#else
#ifndef COMP_PSEL_PSEL_AnalogInput4
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_PSEL(0) != COMP_NRF_COMP_PSEL_AIN4);
BUILD_ASSERT((NRF_COMP_AIN0 == NRF_COMP_INPUT_0) &&
(NRF_COMP_AIN1 == NRF_COMP_INPUT_1) &&
(NRF_COMP_AIN2 == NRF_COMP_INPUT_2) &&
(NRF_COMP_AIN3 == NRF_COMP_INPUT_3) &&
#if defined(COMP_PSEL_PSEL_AnalogInput4)
(NRF_COMP_AIN4 == NRF_COMP_INPUT_4) &&
#endif

#ifndef COMP_PSEL_PSEL_AnalogInput5
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_PSEL(0) != COMP_NRF_COMP_PSEL_AIN5);
#if defined(COMP_PSEL_PSEL_AnalogInput5)
(NRF_COMP_AIN5 == NRF_COMP_INPUT_5) &&
#endif

#ifndef COMP_PSEL_PSEL_AnalogInput6
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_PSEL(0) != COMP_NRF_COMP_PSEL_AIN6);
#if defined(COMP_PSEL_PSEL_AnalogInput6)
(NRF_COMP_AIN6 == NRF_COMP_INPUT_6) &&
#endif

#ifndef COMP_PSEL_PSEL_AnalogInput7
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_PSEL(0) != COMP_NRF_COMP_PSEL_AIN7);
#if defined(COMP_PSEL_PSEL_AnalogInput7)
(NRF_COMP_AIN7 == NRF_COMP_INPUT_7) &&
#endif
(NRF_COMP_AIN0 == NRF_COMP_EXT_REF_0) &&
(NRF_COMP_AIN1 == NRF_COMP_EXT_REF_1) &&
(NRF_COMP_AIN2 == NRF_COMP_EXT_REF_2) &&
(NRF_COMP_AIN3 == NRF_COMP_EXT_REF_3) &&
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference4)
(NRF_COMP_AIN4 == NRF_COMP_EXT_REF_4) &&
#endif

#ifndef COMP_PSEL_PSEL_VddDiv2
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_PSEL(0) != COMP_NRF_COMP_PSEL_VDD_DIV2);
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference5)
(NRF_COMP_AIN5 == NRF_COMP_EXT_REF_5) &&
#endif

#ifndef COMP_PSEL_PSEL_VddhDiv5
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_PSEL(0) != COMP_NRF_COMP_PSEL_VDDH_DIV5);
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference6)
(NRF_COMP_AIN6 == NRF_COMP_EXT_REF_6) &&
#endif
#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference7)
(NRF_COMP_AIN7 == NRF_COMP_EXT_REF_7) &&
#endif
#if defined(COMP_PSEL_PSEL_VddDiv2)
(NRF_COMP_VDD_DIV2 == NRF_COMP_VDD_DIV2) &&
#endif
#if defined(COMP_PSEL_PSEL_VddhDiv5)
(NRF_COMP_VDDH_DIV5 == NRF_COMP_VDDH_DIV5) &&
#endif
1,
"Definitions from nrf-comp.h do not match those from HAL");

Check notice on line 117 in drivers/comparator/comparator_nrf_comp.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/comparator/comparator_nrf_comp.c:117 -BUILD_ASSERT((NRF_COMP_AIN0 == NRF_COMP_INPUT_0) && - (NRF_COMP_AIN1 == NRF_COMP_INPUT_1) && - (NRF_COMP_AIN2 == NRF_COMP_INPUT_2) && - (NRF_COMP_AIN3 == NRF_COMP_INPUT_3) && +BUILD_ASSERT((NRF_COMP_AIN0 == NRF_COMP_INPUT_0) && (NRF_COMP_AIN1 == NRF_COMP_INPUT_1) && + (NRF_COMP_AIN2 == NRF_COMP_INPUT_2) && (NRF_COMP_AIN3 == NRF_COMP_INPUT_3) && #if defined(COMP_PSEL_PSEL_AnalogInput4) - (NRF_COMP_AIN4 == NRF_COMP_INPUT_4) && + (NRF_COMP_AIN4 == NRF_COMP_INPUT_4) && #endif #if defined(COMP_PSEL_PSEL_AnalogInput5) - (NRF_COMP_AIN5 == NRF_COMP_INPUT_5) && + (NRF_COMP_AIN5 == NRF_COMP_INPUT_5) && #endif #if defined(COMP_PSEL_PSEL_AnalogInput6) - (NRF_COMP_AIN6 == NRF_COMP_INPUT_6) && + (NRF_COMP_AIN6 == NRF_COMP_INPUT_6) && #endif #if defined(COMP_PSEL_PSEL_AnalogInput7) - (NRF_COMP_AIN7 == NRF_COMP_INPUT_7) && -#endif - (NRF_COMP_AIN0 == NRF_COMP_EXT_REF_0) && - (NRF_COMP_AIN1 == NRF_COMP_EXT_REF_1) && - (NRF_COMP_AIN2 == NRF_COMP_EXT_REF_2) && - (NRF_COMP_AIN3 == NRF_COMP_EXT_REF_3) && + (NRF_COMP_AIN7 == NRF_COMP_INPUT_7) && +#endif + (NRF_COMP_AIN0 == NRF_COMP_EXT_REF_0) && + (NRF_COMP_AIN1 == NRF_COMP_EXT_REF_1) && + (NRF_COMP_AIN2 == NRF_COMP_EXT_REF_2) && + (NRF_COMP_AIN3 == NRF_COMP_EXT_REF_3) && #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference4) - (NRF_COMP_AIN4 == NRF_COMP_EXT_REF_4) && + (NRF_COMP_AIN4 == NRF_COMP_EXT_REF_4) && #endif #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference5) - (NRF_COMP_AIN5 == NRF_COMP_EXT_REF_5) && + (NRF_COMP_AIN5 == NRF_COMP_EXT_REF_5) && #endif #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference6) - (NRF_COMP_AIN6 == NRF_COMP_EXT_REF_6) && + (NRF_COMP_AIN6 == NRF_COMP_EXT_REF_6) && #endif #if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference7) - (NRF_COMP_AIN7 == NRF_COMP_EXT_REF_7) && + (NRF_COMP_AIN7 == NRF_COMP_EXT_REF_7) && #endif #if defined(COMP_PSEL_PSEL_VddDiv2) - (NRF_COMP_VDD_DIV2 == NRF_COMP_VDD_DIV2) && + (NRF_COMP_VDD_DIV2 == NRF_COMP_VDD_DIV2) && #endif #if defined(COMP_PSEL_PSEL_VddhDiv5) - (NRF_COMP_VDDH_DIV5 == NRF_COMP_VDDH_DIV5) && -#endif - 1, + (NRF_COMP_VDDH_DIV5 == NRF_COMP_VDDH_DIV5) && +#endif + 1,
#endif

#ifndef COMP_MODE_SP_Normal
Expand All @@ -122,24 +135,6 @@
#endif
#endif

#if SHIM_NRF_COMP_DT_INST_REFSEL_IS_AREF(0)
#ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference4
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_EXTREFSEL(0) != COMP_NRF_COMP_EXTREFSEL_AIN4);
#endif

#ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference5
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_EXTREFSEL(0) != COMP_NRF_COMP_EXTREFSEL_AIN5);
#endif

#ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference6
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_EXTREFSEL(0) != COMP_NRF_COMP_EXTREFSEL_AIN6);
#endif

#ifndef COMP_EXTREFSEL_EXTREFSEL_AnalogReference7
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_EXTREFSEL(0) != COMP_NRF_COMP_EXTREFSEL_AIN7);
#endif
#endif

#if SHIM_NRF_COMP_DT_INST_MAIN_MODE_IS_SE(0)
#ifndef COMP_REFSEL_REFSEL_Int1V8
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_REFSEL(0) != COMP_NRF_COMP_REFSEL_INT_1V8);
Expand Down Expand Up @@ -246,69 +241,69 @@
}

#if (NRF_COMP_HAS_AIN_AS_PIN)
static int shim_nrf_comp_psel_to_nrf(enum comp_nrf_comp_psel shim,
static int shim_nrf_comp_psel_to_nrf(uint8_t shim,
nrf_comp_input_t *nrf)
{

Check notice on line 246 in drivers/comparator/comparator_nrf_comp.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/comparator/comparator_nrf_comp.c:246 -static int shim_nrf_comp_psel_to_nrf(uint8_t shim, - nrf_comp_input_t *nrf) +static int shim_nrf_comp_psel_to_nrf(uint8_t shim, nrf_comp_input_t *nrf)
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
return -EINVAL;
}

*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
*nrf = shim_nrf_comp_ain_map[shim];
return 0;
}
#else
static int shim_nrf_comp_psel_to_nrf(enum comp_nrf_comp_psel shim,
static int shim_nrf_comp_psel_to_nrf(uint8_t shim,
nrf_comp_input_t *nrf)
{

Check notice on line 257 in drivers/comparator/comparator_nrf_comp.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/comparator/comparator_nrf_comp.c:257 -static int shim_nrf_comp_psel_to_nrf(uint8_t shim, - nrf_comp_input_t *nrf) +static int shim_nrf_comp_psel_to_nrf(uint8_t shim, nrf_comp_input_t *nrf)
switch (shim) {
case COMP_NRF_COMP_PSEL_AIN0:
case NRF_COMP_AIN0:
*nrf = NRF_COMP_INPUT_0;
break;

case COMP_NRF_COMP_PSEL_AIN1:
case NRF_COMP_AIN1:
*nrf = NRF_COMP_INPUT_1;
break;

case COMP_NRF_COMP_PSEL_AIN2:
case NRF_COMP_AIN2:
*nrf = NRF_COMP_INPUT_2;
break;

case COMP_NRF_COMP_PSEL_AIN3:
case NRF_COMP_AIN3:
*nrf = NRF_COMP_INPUT_3;
break;

#if defined(COMP_PSEL_PSEL_AnalogInput4)
case COMP_NRF_COMP_PSEL_AIN4:
case NRF_COMP_AIN4:
*nrf = NRF_COMP_INPUT_4;
break;
#endif

#if defined(COMP_PSEL_PSEL_AnalogInput5)
case COMP_NRF_COMP_PSEL_AIN5:
case NRF_COMP_AIN5:
*nrf = NRF_COMP_INPUT_5;
break;
#endif

#if defined(COMP_PSEL_PSEL_AnalogInput6)
case COMP_NRF_COMP_PSEL_AIN6:
case NRF_COMP_AIN6:
*nrf = NRF_COMP_INPUT_6;
break;
#endif

#if defined(COMP_PSEL_PSEL_AnalogInput7)
case COMP_NRF_COMP_PSEL_AIN7:
case NRF_COMP_AIN7:
*nrf = NRF_COMP_INPUT_7;
break;
#endif

#if defined(COMP_PSEL_PSEL_VddDiv2)
case COMP_NRF_COMP_PSEL_VDD_DIV2:
case NRF_COMP_AIN_VDD_DIV2:
*nrf = NRF_COMP_VDD_DIV2;
break;
#endif

#if defined(COMP_PSEL_PSEL_VddhDiv5)
case COMP_NRF_COMP_PSEL_VDDH_DIV5:
case NRF_COMP_AIN_VDDH_DIV5:
*nrf = NRF_COMP_VDDH_DIV5;
break;
#endif
Expand Down Expand Up @@ -382,57 +377,57 @@
#endif

#if (NRF_COMP_HAS_AIN_AS_PIN)
static int shim_nrf_comp_extrefsel_to_nrf(enum comp_nrf_comp_extrefsel shim,
static int shim_nrf_comp_extrefsel_to_nrf(uint8_t shim,
nrf_comp_ext_ref_t *nrf)
{

Check notice on line 382 in drivers/comparator/comparator_nrf_comp.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/comparator/comparator_nrf_comp.c:382 -static int shim_nrf_comp_extrefsel_to_nrf(uint8_t shim, - nrf_comp_ext_ref_t *nrf) +static int shim_nrf_comp_extrefsel_to_nrf(uint8_t shim, nrf_comp_ext_ref_t *nrf)
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
return -EINVAL;
}

*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
*nrf = shim_nrf_comp_ain_map[shim];
return 0;
}
#else
static int shim_nrf_comp_extrefsel_to_nrf(enum comp_nrf_comp_extrefsel shim,
static int shim_nrf_comp_extrefsel_to_nrf(uint8_t shim,
nrf_comp_ext_ref_t *nrf)
{

Check notice on line 393 in drivers/comparator/comparator_nrf_comp.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/comparator/comparator_nrf_comp.c:393 -static int shim_nrf_comp_extrefsel_to_nrf(uint8_t shim, - nrf_comp_ext_ref_t *nrf) +static int shim_nrf_comp_extrefsel_to_nrf(uint8_t shim, nrf_comp_ext_ref_t *nrf)
switch (shim) {
case COMP_NRF_COMP_EXTREFSEL_AIN0:
case NRF_COMP_AIN0:
*nrf = NRF_COMP_EXT_REF_0;
break;

case COMP_NRF_COMP_EXTREFSEL_AIN1:
case NRF_COMP_AIN1:
*nrf = NRF_COMP_EXT_REF_1;
break;

case COMP_NRF_COMP_EXTREFSEL_AIN2:
case NRF_COMP_AIN2:
*nrf = NRF_COMP_EXT_REF_2;
break;

case COMP_NRF_COMP_EXTREFSEL_AIN3:
case NRF_COMP_AIN3:
*nrf = NRF_COMP_EXT_REF_3;
break;

#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference4)
case COMP_NRF_COMP_EXTREFSEL_AIN4:
case NRF_COMP_AIN4:
*nrf = NRF_COMP_EXT_REF_4;
break;
#endif

#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference5)
case COMP_NRF_COMP_EXTREFSEL_AIN5:
case NRF_COMP_AIN5:
*nrf = NRF_COMP_EXT_REF_5;
break;
#endif

#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference6)
case COMP_NRF_COMP_EXTREFSEL_AIN6:
case NRF_COMP_AIN6:
*nrf = NRF_COMP_EXT_REF_6;
break;
#endif

#if defined(COMP_EXTREFSEL_EXTREFSEL_AnalogReference7)
case COMP_NRF_COMP_EXTREFSEL_AIN7:
case NRF_COMP_AIN7:
*nrf = NRF_COMP_EXT_REF_7;
break;
#endif
Expand Down
Loading
Loading