[BSP][stm32] fix the compile error
This commit is contained in:
parent
a2647aa3e2
commit
c9f7f0e771
|
@ -67,23 +67,44 @@ static rt_err_t stm32_adc_enabled(struct rt_adc_device *device, rt_uint32_t chan
|
||||||
|
|
||||||
/* ADC channel number is up to 17 */
|
/* ADC channel number is up to 17 */
|
||||||
#if !defined(ADC_CHANNEL_18)
|
#if !defined(ADC_CHANNEL_18)
|
||||||
if (channel <= 17 || \
|
if (channel <= 17 || (
|
||||||
(channel != (ADC_CHANNEL_VREFINT - ADC_CHANNEL_0) || \
|
#ifdef ADC_CHANNEL_VREFINT
|
||||||
channel != (ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0) || \
|
channel != (ADC_CHANNEL_VREFINT - ADC_CHANNEL_0)
|
||||||
channel != (ADC_CHANNEL_VBAT - ADC_CHANNEL_0)))
|
#endif /* ADC_CHANNEL_VREFINT */
|
||||||
|
#ifdef ADC_CHANNEL_TEMPSENSOR
|
||||||
|
|| channel != (ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0)
|
||||||
|
#endif /* ADC_CHANNEL_TEMPSENSOR */
|
||||||
|
#ifdef ADC_CHANNEL_VBAT
|
||||||
|
|| channel != (ADC_CHANNEL_VBAT - ADC_CHANNEL_0)
|
||||||
|
#endif /* ADC_CHANNEL_VBAT */
|
||||||
|
))
|
||||||
/* ADC channel number is up to 19 */
|
/* ADC channel number is up to 19 */
|
||||||
#elif defined(ADC_CHANNEL_19)
|
#elif defined(ADC_CHANNEL_19)
|
||||||
if (channel <= 19 || \
|
if (channel <= 19 || (
|
||||||
(channel != (ADC_CHANNEL_VREFINT - ADC_CHANNEL_0) || \
|
#ifdef ADC_CHANNEL_VREFINT
|
||||||
channel != (ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0) || \
|
channel != (ADC_CHANNEL_VREFINT - ADC_CHANNEL_0)
|
||||||
channel != (ADC_CHANNEL_VBAT - ADC_CHANNEL_0)))
|
#endif /* ADC_CHANNEL_VREFINT */
|
||||||
|
#ifndef ADC_CHANNEL_TEMPSENSOR
|
||||||
|
|| channel != (ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0)
|
||||||
|
#endif /* ADC_CHANNEL_TEMPSENSOR */
|
||||||
|
#ifdef ADC_CHANNEL_VBAT
|
||||||
|
|| channel != (=ADC_CHANNEL_VBAT - ADC_CHANNEL_0)
|
||||||
|
#endif /* ADC_CHANNEL_VBAT */
|
||||||
|
))
|
||||||
/* ADC channel number is up to 18 */
|
/* ADC channel number is up to 18 */
|
||||||
#else
|
#else
|
||||||
if (channel <= 18 || \
|
if (channel <= 18 || (
|
||||||
(channel != (ADC_CHANNEL_VREFINT - ADC_CHANNEL_0) || \
|
#ifdef ADC_CHANNEL_VREFINT
|
||||||
channel != (ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0) || \
|
channel != (ADC_CHANNEL_VREFINT - ADC_CHANNEL_0)
|
||||||
channel != (ADC_CHANNEL_VBAT - ADC_CHANNEL_0)))
|
#endif /* ADC_CHANNEL_VREFINT */
|
||||||
#endif
|
#ifdef ADC_CHANNEL_TEMPSENSOR
|
||||||
|
|| channel != (ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0)
|
||||||
|
#endif /* ADC_CHANNEL_TEMPSENSOR */
|
||||||
|
#ifdef ADC_CHANNEL_VBAT
|
||||||
|
|| channel != (ADC_CHANNEL_VBAT - ADC_CHANNEL_0)
|
||||||
|
#endif /* ADC_CHANNEL_VBAT */
|
||||||
|
))
|
||||||
|
#endif /* !defined(ADC_CHANNEL_18) */
|
||||||
{
|
{
|
||||||
/* set stm32 ADC channel */
|
/* set stm32 ADC channel */
|
||||||
ADC_ChanConf.Channel = stm32_adc_get_channel(channel);
|
ADC_ChanConf.Channel = stm32_adc_get_channel(channel);
|
||||||
|
@ -96,7 +117,7 @@ static rt_err_t stm32_adc_enabled(struct rt_adc_device *device, rt_uint32_t chan
|
||||||
LOG_E("ADC channel must be between 0 and 19.");
|
LOG_E("ADC channel must be between 0 and 19.");
|
||||||
#else
|
#else
|
||||||
LOG_E("ADC channel must be between 0 and 18.");
|
LOG_E("ADC channel must be between 0 and 18.");
|
||||||
#endif
|
#endif /* !defined(ADC_CHANNEL_18) */
|
||||||
return -RT_ERROR;
|
return -RT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,15 +294,21 @@ static rt_uint32_t stm32_adc_get_channel(rt_uint32_t channel)
|
||||||
default:
|
default:
|
||||||
switch (channel)
|
switch (channel)
|
||||||
{
|
{
|
||||||
|
#ifdef ADC_CHANNEL_VREFINT
|
||||||
case ADC_CHANNEL_VREFINT - ADC_CHANNEL_0:
|
case ADC_CHANNEL_VREFINT - ADC_CHANNEL_0:
|
||||||
stm32_channel = ADC_CHANNEL_VREFINT;
|
stm32_channel = ADC_CHANNEL_VREFINT;
|
||||||
break;
|
break;
|
||||||
|
#endif /* ADC_CHANNEL_VREFINT */
|
||||||
|
#ifdef ADC_CHANNEL_VBAT
|
||||||
case ADC_CHANNEL_VBAT - ADC_CHANNEL_0:
|
case ADC_CHANNEL_VBAT - ADC_CHANNEL_0:
|
||||||
stm32_channel = ADC_CHANNEL_VBAT;
|
stm32_channel = ADC_CHANNEL_VBAT;
|
||||||
break;
|
break;
|
||||||
|
#endif /* ADC_CHANNEL_VBAT */
|
||||||
|
#ifdef ADC_CHANNEL_TEMPSENSOR
|
||||||
case ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0:
|
case ADC_CHANNEL_TEMPSENSOR - ADC_CHANNEL_0:
|
||||||
stm32_channel = ADC_CHANNEL_TEMPSENSOR;
|
stm32_channel = ADC_CHANNEL_TEMPSENSOR;
|
||||||
break;
|
break;
|
||||||
|
#endif /* ADC_CHANNEL_TEMPSENSOR */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue