Skip to content

Commit ba30de0

Browse files
committed
drivers: comparator: nordic: Replace analog pin mapping method
Replace the analog pin mapping method with the generic one from the (LP)COMP driver. Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
1 parent 42c2b49 commit ba30de0

File tree

3 files changed

+12
-63
lines changed

3 files changed

+12
-63
lines changed

drivers/comparator/comparator_nrf_common.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

drivers/comparator/comparator_nrf_comp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <zephyr/drivers/comparator/nrf_comp.h>
1010
#include <zephyr/kernel.h>
1111
#include <zephyr/pm/device.h>
12-
#include "comparator_nrf_common.h"
1312

1413
#define DT_DRV_COMPAT nordic_nrf_comp
1514

@@ -249,11 +248,12 @@ static int shim_nrf_comp_pm_callback(const struct device *dev, enum pm_device_ac
249248
static int shim_nrf_comp_psel_to_nrf(enum comp_nrf_comp_psel shim,
250249
nrf_comp_input_t *nrf)
251250
{
252-
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
251+
nrfx_err_t err = nrfx_comp_input_convert(shim, nrf);
252+
253+
if (err != NRFX_SUCCESS) {
253254
return -EINVAL;
254255
}
255256

256-
*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
257257
return 0;
258258
}
259259
#else
@@ -385,11 +385,12 @@ static int shim_nrf_comp_isource_to_nrf(enum comp_nrf_comp_isource shim,
385385
static int shim_nrf_comp_extrefsel_to_nrf(enum comp_nrf_comp_extrefsel shim,
386386
nrf_comp_ext_ref_t *nrf)
387387
{
388-
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
388+
nrfx_err_t err = nrfx_comp_input_convert(shim, nrf);
389+
390+
if (err != NRFX_SUCCESS) {
389391
return -EINVAL;
390392
}
391393

392-
*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
393394
return 0;
394395
}
395396
#else

drivers/comparator/comparator_nrf_lpcomp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <zephyr/drivers/comparator/nrf_lpcomp.h>
1010
#include <zephyr/kernel.h>
1111
#include <zephyr/pm/device.h>
12-
#include "comparator_nrf_common.h"
1312

1413
#include <string.h>
1514

@@ -129,11 +128,12 @@ static int shim_nrf_lpcomp_pm_callback(const struct device *dev, enum pm_device_
129128
static int shim_nrf_lpcomp_psel_to_nrf(enum comp_nrf_lpcomp_psel shim,
130129
nrf_lpcomp_input_t *nrf)
131130
{
132-
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
131+
nrfx_err_t err = nrfx_lpcomp_input_convert(shim, nrf);
132+
133+
if (err != NRFX_SUCCESS) {
133134
return -EINVAL;
134135
}
135136

136-
*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
137137
return 0;
138138
}
139139
#else
@@ -185,11 +185,12 @@ static int shim_nrf_lpcomp_psel_to_nrf(enum comp_nrf_lpcomp_psel shim,
185185
static int shim_nrf_lpcomp_extrefsel_to_nrf(enum comp_nrf_lpcomp_extrefsel shim,
186186
nrf_lpcomp_ext_ref_t *nrf)
187187
{
188-
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
188+
nrfx_err_t err = nrfx_lpcomp_input_convert(shim, nrf);
189+
190+
if (err != NRFX_SUCCESS) {
189191
return -EINVAL;
190192
}
191193

192-
*nrf = shim_nrf_comp_ain_map[shim];
193194
return 0;
194195
}
195196
#else

0 commit comments

Comments
 (0)