@@ -82,6 +82,8 @@ static PinName g_current_pin = NC;
8282#define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_239CYCLES_5
8383#elif defined(ADC_SAMPLETIME_160CYCLES_5)
8484#define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_160CYCLES_5
85+ #elif defined(ADC_SAMPLETIME_814CYCLES_5)
86+ #define ADC_SAMPLINGTIME_INTERNAL ADC_SAMPLETIME_814CYCLES_5
8587#else
8688#error "ADC sampling time could not be defined for internal channels!"
8789#endif
@@ -157,6 +159,7 @@ uint32_t get_adc_channel(PinName pin, uint32_t *bank)
157159 case 13 :
158160 channel = ADC_CHANNEL_13;
159161 break ;
162+ #ifdef ADC_CHANNEL_14
160163 case 14 :
161164 channel = ADC_CHANNEL_14;
162165 break ;
@@ -224,6 +227,7 @@ uint32_t get_adc_channel(PinName pin, uint32_t *bank)
224227#endif
225228#endif
226229#endif
230+ #endif
227231#endif
228232 default :
229233 _Error_Handler (" ADC: Unknown adc channel" , (int )(STM_PIN_CHANNEL (function)));
@@ -563,6 +567,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
563567{
564568 /* ##-1- Enable peripherals and GPIO Clocks #################################*/
565569 /* ADC Periph clock enable */
570+ #ifdef ADC1
566571 if (hadc->Instance == ADC1) {
567572#ifdef __HAL_RCC_ADC1_CLK_ENABLE
568573 __HAL_RCC_ADC1_CLK_ENABLE ();
@@ -571,8 +576,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
571576 __HAL_RCC_ADC12_CLK_ENABLE ();
572577#endif
573578 }
579+ #endif
574580#ifdef ADC2
575- else if (hadc->Instance == ADC2) {
581+ if (hadc->Instance == ADC2) {
576582#ifdef __HAL_RCC_ADC2_CLK_ENABLE
577583 __HAL_RCC_ADC2_CLK_ENABLE ();
578584#endif
@@ -582,7 +588,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
582588 }
583589#endif
584590#ifdef ADC3
585- else if (hadc->Instance == ADC3) {
591+ if (hadc->Instance == ADC3) {
586592#ifdef __HAL_RCC_ADC3_CLK_ENABLE
587593 __HAL_RCC_ADC3_CLK_ENABLE ();
588594#endif
@@ -595,7 +601,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
595601 }
596602#endif
597603#ifdef ADC4
598- else if (hadc->Instance == ADC4) {
604+ if (hadc->Instance == ADC4) {
599605#ifdef __HAL_RCC_ADC4_CLK_ENABLE
600606 __HAL_RCC_ADC4_CLK_ENABLE ();
601607#endif
@@ -608,7 +614,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
608614 }
609615#endif
610616#ifdef ADC5
611- else if (hadc->Instance == ADC5) {
617+ if (hadc->Instance == ADC5) {
612618#if defined(ADC345_COMMON)
613619 __HAL_RCC_ADC345_CLK_ENABLE ();
614620#endif
@@ -647,6 +653,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
647653 __HAL_RCC_ADC_RELEASE_RESET ();
648654#endif
649655
656+ #ifdef ADC1
650657 if (hadc->Instance == ADC1) {
651658#ifdef __HAL_RCC_ADC1_FORCE_RESET
652659 __HAL_RCC_ADC1_FORCE_RESET ();
@@ -667,8 +674,9 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
667674 __HAL_RCC_ADC12_CLK_DISABLE ();
668675#endif
669676 }
677+ #endif
670678#ifdef ADC2
671- else if (hadc->Instance == ADC2) {
679+ if (hadc->Instance == ADC2) {
672680#ifdef __HAL_RCC_ADC2_FORCE_RESET
673681 __HAL_RCC_ADC2_FORCE_RESET ();
674682#endif
@@ -690,7 +698,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
690698 }
691699#endif
692700#ifdef ADC3
693- else if (hadc->Instance == ADC3) {
701+ if (hadc->Instance == ADC3) {
694702#ifdef __HAL_RCC_ADC3_FORCE_RESET
695703 __HAL_RCC_ADC3_FORCE_RESET ();
696704#endif
@@ -717,7 +725,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
717725 }
718726#endif
719727#ifdef ADC4
720- else if (hadc->Instance == ADC4) {
728+ if (hadc->Instance == ADC4) {
721729#ifdef __HAL_RCC_ADC4_FORCE_RESET
722730 __HAL_RCC_ADC4_FORCE_RESET ();
723731#endif
@@ -744,7 +752,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
744752 }
745753#endif
746754#ifdef ADC5
747- else if (hadc->Instance == ADC5) {
755+ if (hadc->Instance == ADC5) {
748756#if defined(ADC345_COMMON)
749757 __HAL_RCC_ADC345_FORCE_RESET ();
750758 __HAL_RCC_ADC345_RELEASE_RESET ();
@@ -781,6 +789,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
781789#else
782790 AdcHandle.Instance = ADC2;
783791#endif
792+ #elif defined(STM32WBAxx)
793+ AdcHandle.Instance = ADC4;
784794#else
785795 AdcHandle.Instance = ADC1;
786796#if defined(ADC5) && defined(ADC_CHANNEL_TEMPSENSOR_ADC5)
@@ -877,7 +887,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
877887#endif
878888 AdcHandle.Init .DiscontinuousConvMode = DISABLE; /* Parameter discarded because sequencer is disabled */
879889#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)
881892 AdcHandle.Init .NbrOfDiscConversion = 0 ; /* Parameter discarded because sequencer is disabled */
882893#endif
883894 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)
902913 AdcHandle.Init .SamplingTimeCommon = samplingTime;
903914#endif
904915#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)
906917 AdcHandle.Init .SamplingTimeCommon1 = samplingTime; /* Set sampling time common to a group of channels. */
907918 AdcHandle.Init .SamplingTimeCommon2 = samplingTime; /* Set sampling time common to a group of channels, second common setting possible.*/
908919#endif
@@ -966,8 +977,8 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
966977#endif
967978#if !defined(STM32C0xx) && !defined(STM32F0xx) && !defined(STM32F1xx) && \
968979 !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)
971982 AdcChannelConf.Offset = 0 ; /* Parameter discarded because offset correction is disabled */
972983#endif
973984#if defined (STM32H7xx) || defined(STM32MP1xx)
0 commit comments