Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion drivers/adc/adc_sam0.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ static int start_read(const struct device *dev,

wait_synchronization(adc);

if (sequence->channels != 1U) {
if ((sequence->channels == 0) ||
((sequence->channels & (sequence->channels - 1)) != 0)) {
LOG_ERR("Channel scanning is not supported");
return -ENOTSUP;
}
Expand Down
16 changes: 16 additions & 0 deletions samples/drivers/adc/boards/arduino_zero.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2022 Kim Bøndergaard <[email protected]>
*/

/ {
zephyr,user {
/* J106.6 (A5) aka D21G18, pin PB02_AIN10 */
io-channels = <&adc 10>;
};
};

&adc {
status = "okay";
};
9 changes: 8 additions & 1 deletion samples/drivers/adc/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ struct adc_channel_cfg channel_cfg = {
.acquisition_time = ADC_ACQUISITION_TIME,
/* channel ID will be overwritten below */
.channel_id = 0,
.differential = 0
.differential = 0,
#ifdef CONFIG_ADC_CONFIGURABLE_INPUTS
.input_negative = 0,
.input_positive = 0,
#endif
};

struct adc_sequence sequence = {
Expand Down Expand Up @@ -80,6 +84,9 @@ void main(void)
channel_cfg.input_positive = SAADC_CH_PSELP_PSELP_AnalogInput0
+ channel_ids[i];
#endif
#ifdef CONFIG_ADC_CONFIGURABLE_INPUTS
channel_cfg.input_positive = channel_ids[i];
#endif

adc_channel_setup(dev_adc, &channel_cfg);

Expand Down