Skip to content

Commit 0436801

Browse files
NeilChen93kartben
authored andcommitted
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>
1 parent 3f60489 commit 0436801

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/adc/adc_mcux_lpadc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ static int mcux_lpadc_channel_setup(const struct device *dev,
157157
return -EINVAL;
158158
}
159159

160+
#if !(defined(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS) && \
161+
(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS == 0U))
160162
if (channel_cfg->differential) {
161163
/* Channel pairs must match in differential mode */
162164
if ((ADC_CMDL_ADCH(channel_cfg->input_positive)) !=
@@ -183,6 +185,7 @@ static int mcux_lpadc_channel_setup(const struct device *dev,
183185
} else {
184186
/* Default value for sampleChannelMode is SideA */
185187
}
188+
#endif
186189
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_CSCALE) && FSL_FEATURE_LPADC_HAS_CMDL_CSCALE
187190
/*
188191
* 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)
435438
conv_mode = data->cmd_config[channel].sampleChannelMode;
436439
if (data->ctx.sequence.resolution < 15) {
437440
result = ((conv_result.convValue >> 3) & 0xFFF);
441+
#if !(defined(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS) && \
442+
(FSL_FEATURE_LPADC_HAS_B_SIDE_CHANNELS == 0U))
438443
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_DIFF) && FSL_FEATURE_LPADC_HAS_CMDL_DIFF
439444
if (conv_mode == kLPADC_SampleChannelDiffBothSideAB ||
440445
conv_mode == kLPADC_SampleChannelDiffBothSideBA) {
@@ -447,6 +452,7 @@ static void mcux_lpadc_isr(const struct device *dev)
447452
}
448453
}
449454
*data->buffer++ = result;
455+
#endif
450456
} else {
451457
*data->buffer++ = conv_result.convValue;
452458
}

0 commit comments

Comments
 (0)