drivers/adc: stm32: Use bitfield for multiple channels detection
For multiple channels detection, channels variable was compared with the output of find_lsb_set which actually is a decimal number. Since channel is a bitfield the comparison was not behaving as expected (detecting several channels while only one channel was used). Rework the code to use the already existing bitfield "index" for the test. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
c07bb77247
commit
6a012301e6
1 changed files with 3 additions and 3 deletions
|
@ -319,15 +319,15 @@ static int start_read(const struct device *dev,
|
|||
}
|
||||
|
||||
uint32_t channels = sequence->channels;
|
||||
if (channels > find_lsb_set(channels)) {
|
||||
uint8_t index = find_lsb_set(channels) - 1;
|
||||
|
||||
if (channels > BIT(index)) {
|
||||
LOG_ERR("Only single channel supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
data->buffer = sequence->buffer;
|
||||
uint8_t index;
|
||||
|
||||
index = find_lsb_set(channels) - 1;
|
||||
uint32_t channel = __LL_ADC_DECIMAL_NB_TO_CHANNEL(index);
|
||||
#if defined(CONFIG_SOC_SERIES_STM32H7X)
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue