Skip to content

Commit c129ecd

Browse files
committed
dirvers: 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 32dc431 commit c129ecd

File tree

3 files changed

+8
-63
lines changed

3 files changed

+8
-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: 4 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,11 @@ 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+
if (!nrfx_comp_psel_is_valid(shim)) {
253252
return -EINVAL;
254253
}
255254

256-
*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
255+
*nrf = nrfx_comp_psel_to_nrf((uint32_t)shim);
257256
return 0;
258257
}
259258
#else
@@ -385,11 +384,11 @@ static int shim_nrf_comp_isource_to_nrf(enum comp_nrf_comp_isource shim,
385384
static int shim_nrf_comp_extrefsel_to_nrf(enum comp_nrf_comp_extrefsel shim,
386385
nrf_comp_ext_ref_t *nrf)
387386
{
388-
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
387+
if (!nrfx_comp_psel_is_valid(shim)) {
389388
return -EINVAL;
390389
}
391390

392-
*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
391+
*nrf = nrfx_comp_psel_to_nrf((uint32_t)shim);
393392
return 0;
394393
}
395394
#else

drivers/comparator/comparator_nrf_lpcomp.c

Lines changed: 4 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,11 @@ 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+
if (!nrfx_lpcomp_psel_is_valid(shim)) {
133132
return -EINVAL;
134133
}
135134

136-
*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
135+
*nrf = nrfx_lpcomp_psel_to_nrf((uint32_t)shim);
137136
return 0;
138137
}
139138
#else
@@ -185,11 +184,11 @@ static int shim_nrf_lpcomp_psel_to_nrf(enum comp_nrf_lpcomp_psel shim,
185184
static int shim_nrf_lpcomp_extrefsel_to_nrf(enum comp_nrf_lpcomp_extrefsel shim,
186185
nrf_lpcomp_ext_ref_t *nrf)
187186
{
188-
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
187+
if (!nrfx_lpcomp_psel_is_valid(shim)) {
189188
return -EINVAL;
190189
}
191190

192-
*nrf = shim_nrf_comp_ain_map[shim];
191+
*nrf = nrfx_lpcomp_psel_to_nrf((uint32_t)shim);
193192
return 0;
194193
}
195194
#else

0 commit comments

Comments
 (0)