Skip to content

Commit 4da73af

Browse files
ABOSTMfpistm
authored andcommitted
libraries(C0): ADC support
Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 60eba70 commit 4da73af

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

libraries/SrcWrapper/src/stm32/analog.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ uint32_t get_adc_channel(PinName pin, uint32_t *bank)
191191
case 22:
192192
channel = ADC_CHANNEL_22;
193193
break;
194+
#ifdef ADC_CHANNEL_23
194195
case 23:
195196
channel = ADC_CHANNEL_23;
196197
break;
@@ -222,6 +223,7 @@ uint32_t get_adc_channel(PinName pin, uint32_t *bank)
222223
break;
223224
#endif
224225
#endif
226+
#endif
225227
#endif
226228
default:
227229
_Error_Handler("ADC: Unknown adc channel", (int)(STM_PIN_CHANNEL(function)));
@@ -873,8 +875,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
873875
AdcHandle.Init.NbrOfConversion = 1; /* Specifies the number of ranks that will be converted within the regular group sequencer. */
874876
#endif
875877
AdcHandle.Init.DiscontinuousConvMode = DISABLE; /* Parameter discarded because sequencer is disabled */
876-
#if !defined(STM32F0xx) && !defined(STM32G0xx) && !defined(STM32L0xx) && \
877-
!defined(STM32WLxx) && !defined(ADC_SUPPORT_2_5_MSPS)
878+
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && \
879+
!defined(STM32L0xx) && !defined(STM32WLxx) && !defined(ADC_SUPPORT_2_5_MSPS)
878880
AdcHandle.Init.NbrOfDiscConversion = 0; /* Parameter discarded because sequencer is disabled */
879881
#endif
880882
AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START; /* Software start to trig the 1st conversion manually, without external event */
@@ -898,8 +900,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
898900
#if defined(STM32F0xx)
899901
AdcHandle.Init.SamplingTimeCommon = samplingTime;
900902
#endif
901-
#if defined(STM32G0xx) || defined(STM32U5xx) || defined(STM32WLxx) || \
902-
defined(ADC_SUPPORT_2_5_MSPS)
903+
#if defined(STM32C0xx) || defined(STM32G0xx) || defined(STM32U5xx) || \
904+
defined(STM32WLxx) || defined(ADC_SUPPORT_2_5_MSPS)
903905
AdcHandle.Init.SamplingTimeCommon1 = samplingTime; /* Set sampling time common to a group of channels. */
904906
AdcHandle.Init.SamplingTimeCommon2 = samplingTime; /* Set sampling time common to a group of channels, second common setting possible.*/
905907
#endif
@@ -961,9 +963,9 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
961963
AdcChannelConf.SingleDiff = ADC_SINGLE_ENDED; /* Single-ended input channel */
962964
AdcChannelConf.OffsetNumber = ADC_OFFSET_NONE; /* No offset subtraction */
963965
#endif
964-
#if !defined(STM32F0xx) && !defined(STM32F1xx) && !defined(STM32F2xx) && \
965-
!defined(STM32G0xx) && !defined(STM32L0xx) && !defined(STM32L1xx) && \
966-
!defined(STM32WBxx) && !defined(STM32WLxx) && \
966+
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32F1xx) && \
967+
!defined(STM32F2xx) && !defined(STM32G0xx) && !defined(STM32L0xx) && \
968+
!defined(STM32L1xx) && !defined(STM32WBxx) && !defined(STM32WLxx) && \
967969
!defined(ADC1_V2_5)
968970
AdcChannelConf.Offset = 0; /* Parameter discarded because offset correction is disabled */
969971
#endif

0 commit comments

Comments
 (0)