Skip to content

Commit 647477c

Browse files
nika-nordickartben
authored andcommitted
drivers: adc: nrf: align to non-gain configuration
Some nRF devices do not allow to configure gain. Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
1 parent 5abf43c commit 647477c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/adc/adc_nrfx_saadc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ static const uint32_t saadc_psels[NRF_SAADC_DVDD + 1] = {
6565
[NRF_SAADC_AIN6] = NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1),
6666
[NRF_SAADC_AIN7] = NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1),
6767
[NRF_SAADC_VDD] = NRF_SAADC_INPUT_VDD,
68+
#if defined(NRF_SAADC_INPUT_AVDD)
6869
[NRF_SAADC_AVDD] = NRF_SAADC_INPUT_AVDD,
70+
#endif
6971
[NRF_SAADC_DVDD] = NRF_SAADC_INPUT_DVDD,
7072
};
7173
#endif
@@ -231,6 +233,7 @@ static int adc_nrfx_channel_setup(const struct device *dev,
231233
return -EINVAL;
232234
}
233235

236+
#if NRF_SAADC_HAS_CH_GAIN
234237
switch (channel_cfg->gain) {
235238
#if defined(SAADC_CH_CONFIG_GAIN_Gain1_6)
236239
case ADC_GAIN_1_6:
@@ -284,6 +287,9 @@ static int adc_nrfx_channel_setup(const struct device *dev,
284287
break;
285288
#endif
286289
default:
290+
#else
291+
if (channel_cfg->gain != ADC_GAIN_1) {
292+
#endif /* defined(NRF_SAADC_HAS_CH_GAIN) */
287293
LOG_ERR("Selected ADC gain is not valid");
288294
return -EINVAL;
289295
}

0 commit comments

Comments
 (0)