drivers: adc: adc_sam0: Fix interpretation of channels
Previously this was expected to be equal to 1 at all times. This doesn't play well with the sample or other users (e.g: adc_shell). Instead, we should count the number of active channels in the bitfield, and ensure that only one is identified. Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
This commit is contained in:
parent
f86f6e0025
commit
d45a9a11b7
1 changed files with 9 additions and 1 deletions
|
@ -387,7 +387,15 @@ 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)) {
|
||||
/* The caller is expected to identify a single input channel, which will
|
||||
* typically be the positive input, though no check is made for this...
|
||||
*
|
||||
* While ensuring that the channels bitfield matches the positive input
|
||||
* might be sensible, this will likely break users before this revision
|
||||
* was put in place.
|
||||
*/
|
||||
LOG_ERR("Channel scanning is not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue