drivers: adc: nrf: add support for nrf54l internal SAADC inputs
SAADC peripheral for nRF54L Series allows to choose internal voltages as positive inputs. Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
This commit is contained in:
parent
d494769948
commit
ece7da5947
|
@ -32,7 +32,7 @@ static const uint8_t saadc_psels[NRF_SAADC_AIN7 + 1] = {
|
|||
[NRF_SAADC_AIN7] = NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1),
|
||||
};
|
||||
#elif defined(CONFIG_SOC_NRF54L15)
|
||||
static const uint8_t saadc_psels[NRF_SAADC_AIN7 + 1] = {
|
||||
static const uint32_t saadc_psels[NRF_SAADC_DVDD + 1] = {
|
||||
[NRF_SAADC_AIN0] = NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
|
||||
[NRF_SAADC_AIN1] = NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1),
|
||||
[NRF_SAADC_AIN2] = NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1),
|
||||
|
@ -41,6 +41,9 @@ static const uint8_t saadc_psels[NRF_SAADC_AIN7 + 1] = {
|
|||
[NRF_SAADC_AIN5] = NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1),
|
||||
[NRF_SAADC_AIN6] = NRF_PIN_PORT_TO_PIN_NUMBER(13U, 1),
|
||||
[NRF_SAADC_AIN7] = NRF_PIN_PORT_TO_PIN_NUMBER(14U, 1),
|
||||
[NRF_SAADC_VDD] = NRF_SAADC_INPUT_VDD,
|
||||
[NRF_SAADC_AVDD] = NRF_SAADC_INPUT_AVDD,
|
||||
[NRF_SAADC_DVDD] = NRF_SAADC_INPUT_DVDD,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -274,13 +277,8 @@ static int adc_nrfx_channel_setup(const struct device *dev,
|
|||
m_data.single_ended_channels |= BIT(channel_cfg->channel_id);
|
||||
}
|
||||
|
||||
/* Keep the channel disabled in hardware (set positive input to
|
||||
* NRF_SAADC_INPUT_DISABLED) until it is selected to be included
|
||||
* in a sampling sequence.
|
||||
*/
|
||||
|
||||
#if (NRF_SAADC_HAS_AIN_AS_PIN)
|
||||
if ((channel_cfg->input_positive > NRF_SAADC_AIN7) ||
|
||||
if ((channel_cfg->input_positive >= ARRAY_SIZE(saadc_psels)) ||
|
||||
(channel_cfg->input_positive < NRF_SAADC_AIN0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -295,17 +293,18 @@ static int adc_nrfx_channel_setup(const struct device *dev,
|
|||
} else {
|
||||
input_negative = NRF_SAADC_INPUT_DISABLED;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Store the positive input selection in a dedicated array,
|
||||
* to get it later when the channel is selected for a sampling
|
||||
* and to mark the channel as configured (ready to be selected).
|
||||
*/
|
||||
m_data.positive_inputs[channel_id] = saadc_psels[channel_cfg->input_positive];
|
||||
#else
|
||||
m_data.positive_inputs[channel_id] = channel_cfg->input_positive;
|
||||
#endif
|
||||
|
||||
nrf_saadc_channel_init(NRF_SAADC, channel_id, &config);
|
||||
/* Keep the channel disabled in hardware (set positive input to
|
||||
* NRF_SAADC_INPUT_DISABLED) until it is selected to be included
|
||||
* in a sampling sequence.
|
||||
*/
|
||||
nrf_saadc_channel_input_set(NRF_SAADC,
|
||||
channel_id,
|
||||
NRF_SAADC_INPUT_DISABLED,
|
||||
|
@ -532,7 +531,12 @@ static int start_read(const struct device *dev,
|
|||
nrf_saadc_channel_pos_input_set(
|
||||
NRF_SAADC,
|
||||
channel_id,
|
||||
m_data.positive_inputs[channel_id]);
|
||||
#if NRF_SAADC_HAS_AIN_AS_PIN
|
||||
saadc_psels[m_data.positive_inputs[channel_id]]
|
||||
#else
|
||||
m_data.positive_inputs[channel_id]
|
||||
#endif
|
||||
);
|
||||
++active_channels;
|
||||
} else {
|
||||
nrf_saadc_burst_set(
|
||||
|
|
Loading…
Reference in New Issue