@@ -82,6 +82,8 @@ static PinName g_current_pin = NC;
82
82
#define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_239CYCLES_5
83
83
#elif defined(ADC_SAMPLETIME_160CYCLES_5)
84
84
#define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_160CYCLES_5
85
+ #elif defined(ADC_SAMPLETIME_814CYCLES_5)
86
+ #define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_814CYCLES_5
85
87
#else
86
88
#error "ADC sampling time could not be defined for internal channels!"
87
89
#endif
@@ -157,6 +159,7 @@ uint32_t get_adc_channel(PinName pin, uint32_t *bank)
157
159
case 13 :
158
160
channel = ADC_CHANNEL_13;
159
161
break ;
162
+ #ifdef ADC_CHANNEL_14
160
163
case 14 :
161
164
channel = ADC_CHANNEL_14;
162
165
break ;
@@ -224,6 +227,7 @@ uint32_t get_adc_channel(PinName pin, uint32_t *bank)
224
227
#endif
225
228
#endif
226
229
#endif
230
+ #endif
227
231
#endif
228
232
default :
229
233
_Error_Handler (" ADC: Unknown adc channel" , (int )(STM_PIN_CHANNEL (function)));
@@ -563,6 +567,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
563
567
{
564
568
/* ##-1- Enable peripherals and GPIO Clocks #################################*/
565
569
/* ADC Periph clock enable */
570
+ #ifdef ADC1
566
571
if (hadc->Instance == ADC1) {
567
572
#ifdef __HAL_RCC_ADC1_CLK_ENABLE
568
573
__HAL_RCC_ADC1_CLK_ENABLE ();
@@ -571,8 +576,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
571
576
__HAL_RCC_ADC12_CLK_ENABLE ();
572
577
#endif
573
578
}
579
+ #endif
574
580
#ifdef ADC2
575
- else if (hadc->Instance == ADC2) {
581
+ if (hadc->Instance == ADC2) {
576
582
#ifdef __HAL_RCC_ADC2_CLK_ENABLE
577
583
__HAL_RCC_ADC2_CLK_ENABLE ();
578
584
#endif
@@ -582,7 +588,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
582
588
}
583
589
#endif
584
590
#ifdef ADC3
585
- else if (hadc->Instance == ADC3) {
591
+ if (hadc->Instance == ADC3) {
586
592
#ifdef __HAL_RCC_ADC3_CLK_ENABLE
587
593
__HAL_RCC_ADC3_CLK_ENABLE ();
588
594
#endif
@@ -595,7 +601,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
595
601
}
596
602
#endif
597
603
#ifdef ADC4
598
- else if (hadc->Instance == ADC4) {
604
+ if (hadc->Instance == ADC4) {
599
605
#ifdef __HAL_RCC_ADC4_CLK_ENABLE
600
606
__HAL_RCC_ADC4_CLK_ENABLE ();
601
607
#endif
@@ -608,7 +614,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
608
614
}
609
615
#endif
610
616
#ifdef ADC5
611
- else if (hadc->Instance == ADC5) {
617
+ if (hadc->Instance == ADC5) {
612
618
#if defined(ADC345_COMMON)
613
619
__HAL_RCC_ADC345_CLK_ENABLE ();
614
620
#endif
@@ -647,6 +653,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
647
653
__HAL_RCC_ADC_RELEASE_RESET ();
648
654
#endif
649
655
656
+ #ifdef ADC1
650
657
if (hadc->Instance == ADC1) {
651
658
#ifdef __HAL_RCC_ADC1_FORCE_RESET
652
659
__HAL_RCC_ADC1_FORCE_RESET ();
@@ -667,8 +674,9 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
667
674
__HAL_RCC_ADC12_CLK_DISABLE ();
668
675
#endif
669
676
}
677
+ #endif
670
678
#ifdef ADC2
671
- else if (hadc->Instance == ADC2) {
679
+ if (hadc->Instance == ADC2) {
672
680
#ifdef __HAL_RCC_ADC2_FORCE_RESET
673
681
__HAL_RCC_ADC2_FORCE_RESET ();
674
682
#endif
@@ -690,7 +698,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
690
698
}
691
699
#endif
692
700
#ifdef ADC3
693
- else if (hadc->Instance == ADC3) {
701
+ if (hadc->Instance == ADC3) {
694
702
#ifdef __HAL_RCC_ADC3_FORCE_RESET
695
703
__HAL_RCC_ADC3_FORCE_RESET ();
696
704
#endif
@@ -717,7 +725,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
717
725
}
718
726
#endif
719
727
#ifdef ADC4
720
- else if (hadc->Instance == ADC4) {
728
+ if (hadc->Instance == ADC4) {
721
729
#ifdef __HAL_RCC_ADC4_FORCE_RESET
722
730
__HAL_RCC_ADC4_FORCE_RESET ();
723
731
#endif
@@ -744,7 +752,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
744
752
}
745
753
#endif
746
754
#ifdef ADC5
747
- else if (hadc->Instance == ADC5) {
755
+ if (hadc->Instance == ADC5) {
748
756
#if defined(ADC345_COMMON)
749
757
__HAL_RCC_ADC345_FORCE_RESET ();
750
758
__HAL_RCC_ADC345_RELEASE_RESET ();
@@ -781,6 +789,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
781
789
#else
782
790
AdcHandle.Instance = ADC2;
783
791
#endif
792
+ #elif defined(STM32WBAxx)
793
+ AdcHandle.Instance = ADC4;
784
794
#else
785
795
AdcHandle.Instance = ADC1;
786
796
#if defined(ADC5) && defined(ADC_CHANNEL_TEMPSENSOR_ADC5)
@@ -877,7 +887,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
877
887
#endif
878
888
AdcHandle.Init .DiscontinuousConvMode = DISABLE; /* Parameter discarded because sequencer is disabled */
879
889
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32G0xx) && \
880
- !defined (STM32L0xx) && !defined (STM32WLxx) && !defined (ADC_SUPPORT_2_5_MSPS)
890
+ !defined (STM32L0xx) && !defined (STM32WBAxx) && !defined (STM32WLxx) && \
891
+ !defined (ADC_SUPPORT_2_5_MSPS)
881
892
AdcHandle.Init .NbrOfDiscConversion = 0 ; /* Parameter discarded because sequencer is disabled */
882
893
#endif
883
894
AdcHandle.Init .ExternalTrigConv = ADC_SOFTWARE_START; /* Software start to trig the 1st conversion manually, without external event */
@@ -902,7 +913,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
902
913
AdcHandle.Init .SamplingTimeCommon = samplingTime;
903
914
#endif
904
915
#if defined(STM32C0xx) || defined(STM32G0xx) || defined(STM32U5xx) || \
905
- defined (STM32WLxx) || defined (ADC_SUPPORT_2_5_MSPS)
916
+ defined (STM32WBAxx) || defined ( STM32WLxx) || defined (ADC_SUPPORT_2_5_MSPS)
906
917
AdcHandle.Init .SamplingTimeCommon1 = samplingTime; /* Set sampling time common to a group of channels. */
907
918
AdcHandle.Init .SamplingTimeCommon2 = samplingTime; /* Set sampling time common to a group of channels, second common setting possible.*/
908
919
#endif
@@ -966,8 +977,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
966
977
#endif
967
978
#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32F1xx) && \
968
979
!defined (STM32F2xx) && !defined (STM32G0xx) && !defined (STM32L0xx) && \
969
- !defined (STM32L1xx) && !defined (STM32WBxx ) && !defined (STM32WLxx ) && \
970
- !defined (ADC1_V2_5)
980
+ !defined (STM32L1xx) && !defined (STM32WBAxx ) && !defined (STM32WBxx ) && \
981
+ !defined (STM32WLxx) && ! defined ( ADC1_V2_5)
971
982
AdcChannelConf.Offset = 0 ; /* Parameter discarded because offset correction is disabled */
972
983
#endif
973
984
#if defined (STM32H7xx) || defined(STM32MP1xx)
0 commit comments