Skip to content

Commit 5abf43c

Browse files
nika-nordickartben
authored andcommitted
drivers: adc: nrf: align to channel-wide burst configuration
Some nRF devices allow to configure burst setting per channel while others globally. Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
1 parent f46798f commit 5abf43c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

drivers/adc/adc_nrfx_saadc.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ static int adc_nrfx_channel_setup(const struct device *dev,
220220
.resistor_p = NRF_SAADC_RESISTOR_DISABLED,
221221
.resistor_n = NRF_SAADC_RESISTOR_DISABLED,
222222
#endif
223+
#if NRF_SAADC_HAS_CH_BURST
223224
.burst = NRF_SAADC_BURST_DISABLED,
225+
#endif
224226
};
225227
uint8_t channel_id = channel_cfg->channel_id;
226228
uint32_t input_negative = channel_cfg->input_negative;
@@ -530,6 +532,7 @@ static int start_read(const struct device *dev,
530532
uint8_t resolution = sequence->resolution;
531533
uint8_t active_channels;
532534
uint8_t channel_id;
535+
nrf_saadc_burst_t burst;
533536

534537
/* Signal an error if channel selection is invalid (no channels or
535538
* a non-existing one is selected).
@@ -581,10 +584,13 @@ static int start_read(const struct device *dev,
581584
* is not used (hence, the multiple channel sampling is
582585
* possible), the burst mode have to be deactivated.
583586
*/
584-
nrf_saadc_burst_set(NRF_SAADC, channel_id,
585-
(sequence->oversampling != 0U ?
586-
NRF_SAADC_BURST_ENABLED :
587-
NRF_SAADC_BURST_DISABLED));
587+
burst = (sequence->oversampling != 0U ?
588+
NRF_SAADC_BURST_ENABLED : NRF_SAADC_BURST_DISABLED);
589+
#if NRF_SAADC_HAS_CH_BURST
590+
nrf_saadc_channel_burst_set(NRF_SAADC, channel_id, burst);
591+
#else
592+
nrf_saadc_burst_set(NRF_SAADC, burst);
593+
#endif
588594
nrf_saadc_channel_pos_input_set(
589595
NRF_SAADC,
590596
channel_id,
@@ -596,10 +602,12 @@ static int start_read(const struct device *dev,
596602
);
597603
++active_channels;
598604
} else {
599-
nrf_saadc_burst_set(
600-
NRF_SAADC,
601-
channel_id,
602-
NRF_SAADC_BURST_DISABLED);
605+
burst = NRF_SAADC_BURST_DISABLED;
606+
#if NRF_SAADC_HAS_CH_BURST
607+
nrf_saadc_channel_burst_set(NRF_SAADC, channel_id, burst);
608+
#else
609+
nrf_saadc_burst_set(NRF_SAADC, burst);
610+
#endif
603611
nrf_saadc_channel_pos_input_set(
604612
NRF_SAADC,
605613
channel_id,

0 commit comments

Comments
 (0)