drivers: lpadc: fix ADC command chaining

When reading multiple ADC channel in parallel, an ADC command chain will be
build. This is similar to a linked list, as every command references the
next command.

Before this patch every ADC command after the first, would always reference
this initial command. So that during execution only two commands (the last
and first) would be executed which resulted in readout of only two analog
values. As Zephyr expected more to come in, the `read_adc` function would
block endlessly.

The patch fixes the behaviour and allows a correct chain to build up.

Signed-off-by: Elisabeth Friedrich <auxsys@flowerpot.me>
This commit is contained in:
Elisabeth Friedrich 2023-07-06 20:20:14 +02:00 committed by Carles Cufí
commit f4356f3b2e

View file

@ -238,8 +238,8 @@ static int mcux_lpadc_start_read(const struct device *dev,
} else {
/* End of chain */
data->cmd_config[channel].chainedNextCommandNumber = 0;
last_enabled = channel;
}
last_enabled = channel;
LPADC_SetConvCommandConfig(config->base,
channel + 1, &data->cmd_config[channel]);
}