Browse Source

drivers: adc: mcux_lpadc: support IP instances without side B channel

Updating the LPADC driver to support IP without a side B channel.
The MCXA156 is an example with this instantiation of the IP.

Signed-off-by: Neil Chen <cheng.chen_1@nxp.com>
pull/78839/head
Neil Chen 8 months ago committed by Benjamin Cabé
parent
commit
0436801cf9
  1. 6
      drivers/adc/adc_mcux_lpadc.c

6
drivers/adc/adc_mcux_lpadc.c

@ -157,6 +157,8 @@ static int mcux_lpadc_channel_setup(const struct device *dev, @@ -157,6 +157,8 @@ static int mcux_lpadc_channel_setup(const struct device *dev,
return -EINVAL;
}
#if !(defined(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS) && \
(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS == 0U))
if (channel_cfg->differential) {
/* Channel pairs must match in differential mode */
if ((ADC_CMDL_ADCH(channel_cfg->input_positive)) !=
@ -183,6 +185,7 @@ static int mcux_lpadc_channel_setup(const struct device *dev, @@ -183,6 +185,7 @@ static int mcux_lpadc_channel_setup(const struct device *dev,
} else {
/* Default value for sampleChannelMode is SideA */
}
#endif
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_CSCALE) && FSL_FEATURE_LPADC_HAS_CMDL_CSCALE
/*
* The true scaling factor used by the LPADC is 30/64, instead of
@ -435,6 +438,8 @@ static void mcux_lpadc_isr(const struct device *dev) @@ -435,6 +438,8 @@ static void mcux_lpadc_isr(const struct device *dev)
conv_mode = data->cmd_config[channel].sampleChannelMode;
if (data->ctx.sequence.resolution < 15) {
result = ((conv_result.convValue >> 3) & 0xFFF);
#if !(defined(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS) && \
(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS == 0U))
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_DIFF) && FSL_FEATURE_LPADC_HAS_CMDL_DIFF
if (conv_mode == kLPADC_SampleChannelDiffBothSideAB ||
conv_mode == kLPADC_SampleChannelDiffBothSideBA) {
@ -447,6 +452,7 @@ static void mcux_lpadc_isr(const struct device *dev) @@ -447,6 +452,7 @@ static void mcux_lpadc_isr(const struct device *dev)
}
}
*data->buffer++ = result;
#endif
} else {
*data->buffer++ = conv_result.convValue;
}

Loading…
Cancel
Save