drivers: comparator: comparator_nrf: Add analog pins for nRF54L20
Added set of analog pins for nRF54L20 COMP and LPCOMP. Moved the array of analong pins for both comparator variants to avoid code duplication. Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
This commit is contained in:
parent
8b998060f2
commit
03a9df38e9
3 changed files with 50 additions and 52 deletions
44
drivers/comparator/comparator_nrf_common.h
Normal file
44
drivers/comparator/comparator_nrf_common.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Nordic Semiconductor ASA
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_DRIVERS_COMPARATOR_NRF_COMMON_H_
|
||||
#define ZEPHYR_DRIVERS_COMPARATOR_NRF_COMMON_H_
|
||||
|
||||
#include <nrfx.h>
|
||||
|
||||
#if (NRF_COMP_HAS_AIN_AS_PIN || NRF_LPCOMP_HAS_AIN_AS_PIN)
|
||||
static const uint32_t shim_nrf_comp_ain_map[] = {
|
||||
#if defined(CONFIG_SOC_NRF54H20) || defined(CONFIG_SOC_NRF9280)
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(1U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(2U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1),
|
||||
#elif defined(CONFIG_SOC_NRF54L05) || defined(CONFIG_SOC_NRF54L10) || defined(CONFIG_SOC_NRF54L15)
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(11U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(13U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(14U, 1),
|
||||
#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(31U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(30U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(29U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1),
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_COMPARATOR_NRF_COMMON_H_ */
|
|
@ -9,6 +9,7 @@
|
|||
#include <zephyr/drivers/comparator/nrf_comp.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/pm/device.h>
|
||||
#include "comparator_nrf_common.h"
|
||||
|
||||
#define DT_DRV_COMPAT nordic_nrf_comp
|
||||
|
||||
|
@ -67,30 +68,6 @@ struct shim_nrf_comp_data {
|
|||
void *user_data;
|
||||
};
|
||||
|
||||
#if (NRF_COMP_HAS_AIN_AS_PIN)
|
||||
static const uint32_t shim_nrf_comp_ain_map[] = {
|
||||
#if defined(CONFIG_SOC_NRF54H20) || defined(CONFIG_SOC_NRF9280)
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(1U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(2U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1),
|
||||
#elif defined(CONFIG_SOC_NRF54L05) || defined(CONFIG_SOC_NRF54L10) || defined(CONFIG_SOC_NRF54L15)
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(11U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(13U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(14U, 1),
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#if SHIM_NRF_COMP_DT_INST_MAIN_MODE_IS_SE(0)
|
||||
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_TH_DOWN(0) < 64);
|
||||
BUILD_ASSERT(SHIM_NRF_COMP_DT_INST_TH_UP(0) < 64);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <zephyr/drivers/comparator/nrf_lpcomp.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/pm/device.h>
|
||||
#include "comparator_nrf_common.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -38,30 +39,6 @@ struct shim_nrf_lpcomp_data {
|
|||
void *user_data;
|
||||
};
|
||||
|
||||
#if (NRF_LPCOMP_HAS_AIN_AS_PIN)
|
||||
static const uint32_t shim_nrf_lpcomp_ain_map[] = {
|
||||
#if defined(CONFIG_SOC_NRF54H20) || defined(CONFIG_SOC_NRF9280)
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(1U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(2U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1),
|
||||
#elif defined(CONFIG_SOC_NRF54L05) || defined(CONFIG_SOC_NRF54L10) || defined(CONFIG_SOC_NRF54L15)
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(11U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(13U, 1),
|
||||
NRF_PIN_PORT_TO_PIN_NUMBER(14U, 1),
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (NRF_LPCOMP_HAS_AIN_AS_PIN)
|
||||
BUILD_ASSERT(COMP_NRF_LPCOMP_PSEL_AIN0 == 0);
|
||||
BUILD_ASSERT(COMP_NRF_LPCOMP_PSEL_AIN7 == 7);
|
||||
|
@ -152,11 +129,11 @@ static int shim_nrf_lpcomp_pm_callback(const struct device *dev, enum pm_device_
|
|||
static int shim_nrf_lpcomp_psel_to_nrf(enum comp_nrf_lpcomp_psel shim,
|
||||
nrf_lpcomp_input_t *nrf)
|
||||
{
|
||||
if (shim >= ARRAY_SIZE(shim_nrf_lpcomp_ain_map)) {
|
||||
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*nrf = shim_nrf_lpcomp_ain_map[(uint32_t)shim];
|
||||
*nrf = shim_nrf_comp_ain_map[(uint32_t)shim];
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
@ -208,11 +185,11 @@ static int shim_nrf_lpcomp_psel_to_nrf(enum comp_nrf_lpcomp_psel shim,
|
|||
static int shim_nrf_lpcomp_extrefsel_to_nrf(enum comp_nrf_lpcomp_extrefsel shim,
|
||||
nrf_lpcomp_ext_ref_t *nrf)
|
||||
{
|
||||
if (shim >= ARRAY_SIZE(shim_nrf_lpcomp_ain_map)) {
|
||||
if (shim >= ARRAY_SIZE(shim_nrf_comp_ain_map)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*nrf = shim_nrf_lpcomp_ain_map[shim];
|
||||
*nrf = shim_nrf_comp_ain_map[shim];
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue