Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d221bc6

Browse files
committed
chore(wl3): ADC support
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 9d36c79 commit d221bc6

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

‎libraries/SrcWrapper/src/stm32/analog.cpp‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static PinName g_current_pin = NC;
3030
/* Private_Defines */
3131
#if defined(HAL_ADC_MODULE_ENABLED) && !defined(HAL_ADC_MODULE_ONLY)
3232

33-
#if defined(STM32WB0x)
33+
#if defined(STM32WB0x) || defined(STM32WL3x)
3434
#ifndef ADC_SAMPLING_RATE
3535
#define ADC_SAMPLING_RATE ADC_SAMPLE_RATE_16
3636
#endif /* !ADC_SAMPLING_RATE */
@@ -117,7 +117,7 @@ static PinName g_current_pin = NC;
117117
#ifndef ADC_REGULAR_RANK_1
118118
#define ADC_REGULAR_RANK_1 1
119119
#endif
120-
#endif /* STM32WB0x */
120+
#endif /* STM32WB0x || STM32WL3x */
121121

122122
/* Exported Functions */
123123
/**
@@ -478,7 +478,7 @@ void dac_write_value(PinName pin, uint32_t value, uint8_t do_init)
478478
if (HAL_DAC_SetValue(&DacHandle, dacChannel, DAC_ALIGN_12B_R, value) != HAL_OK) {
479479
#else
480480
if (HAL_DAC_SetValue(&DacHandle, dacChannel, DAC_ALIGN_6B_R, value) != HAL_OK) {
481-
#endif
481+
#endif
482482
/* Setting value Error */
483483
return;
484484
}
@@ -847,12 +847,12 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
847847
ADC_HandleTypeDef AdcHandle = {};
848848
ADC_ChannelConfTypeDef AdcChannelConf = {};
849849
__IO uint16_t uhADCxConvertedValue = 0;
850-
#if defined(STM32WB0x)
850+
#if defined(STM32WB0x) || defined(STM32WL3x)
851851
uint32_t samplingRate = ADC_SAMPLING_RATE;
852852
uint32_t voltageRange = ADC_VOLT_RANGE;
853853
#else
854854
uint32_t samplingTime = ADC_SAMPLINGTIME;
855-
#endif /* STM32WB0x */
855+
#endif /* STM32WB0x || STM32WL3x */
856856
uint32_t channel = 0;
857857
uint32_t bank = 0;
858858

@@ -874,7 +874,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
874874
#endif
875875
#endif
876876
channel = get_adc_internal_channel(pin);
877-
#if defined(STM32WB0x)
877+
#if defined(STM32WB0x) || defined(STM32WL3x)
878878
samplingRate = ADC_SAMPLING_RATE_INTERNAL;
879879
if (channel == ADC_CHANNEL_TEMPSENSOR) {
880880
voltageRange = ADC_VIN_RANGE_1V2;
@@ -883,13 +883,11 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
883883
}
884884
#else
885885
samplingTime = ADC_SAMPLINGTIME_INTERNAL;
886-
#endif /* STM32WB0x */
886+
#endif /* STM32WB0x || STM32WL3x */
887887
} else {
888888
AdcHandle.Instance = (ADC_TypeDef *)pinmap_peripheral(pin, PinMap_ADC);
889889
channel = get_adc_channel(pin, &bank);
890-
#if defined(STM32WB0x)
891-
892-
#else
890+
#if !defined(STM32WB0x) && !defined(STM32WL3x)
893891
#if defined(ADC_VER_V5_V90)
894892
if (AdcHandle.Instance == ADC3) {
895893
samplingTime = ADC3_SAMPLINGTIME;
@@ -900,14 +898,16 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
900898
samplingTime = ADC4_SAMPLINGTIME;
901899
}
902900
#endif
903-
#endif /* STM32WB0x */
901+
#endif /* !STM32WB0x && !STM32WL3x */
904902
}
905903

906904
if (AdcHandle.Instance == NP) {
907905
return 0;
908906
}
909-
#if defined(STM32WB0x)
907+
#if defined(STM32WB0x) || defined(STM32WL3x)
908+
#if defined(ADC_CONVERSION_WITH_DS)
910909
AdcHandle.Init.ConversionType = ADC_CONVERSION_WITH_DS;
910+
#endif /* ADC_CONVERSION_WITH_DS */
911911
AdcHandle.Init.ContinuousConvMode = DISABLE;
912912
AdcHandle.Init.SequenceLength = 1;
913913
AdcHandle.Init.SamplingMode = ADC_SAMPLING_AT_START;
@@ -1051,7 +1051,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
10511051
#ifdef ADC_VREF_PPROT_NONE
10521052
AdcHandle.Init.VrefProtection = ADC_VREF_PPROT_NONE;
10531053
#endif
1054-
#endif /* STM32WB0x*/
1054+
#endif /* STM32WB0x || STM32WL3x */
10551055
AdcHandle.State = HAL_ADC_STATE_RESET;
10561056
AdcHandle.DMA_Handle = NULL;
10571057
AdcHandle.Lock = HAL_UNLOCKED;
@@ -1074,7 +1074,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
10741074
return 0;
10751075
}
10761076

1077-
#if defined(STM32WB0x)
1077+
#if defined(STM32WB0x) || defined(STM32WL3x)
10781078
AdcChannelConf.Rank = ADC_RANK_1;
10791079
AdcChannelConf.VoltRange = voltageRange;
10801080
AdcChannelConf.CalibrationPoint.Number = ADC_CALIB_POINT_1;
@@ -1142,7 +1142,7 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
11421142
AdcChannelConf.OffsetRightShift = DISABLE; /* No Right Offset Shift */
11431143
AdcChannelConf.OffsetSignedSaturation = DISABLE; /* Signed saturation feature is not used */
11441144
#endif
1145-
#endif /* STM32WB0x */
1145+
#endif /* STM32WB0x || STM32WL3x */
11461146
/*##-2- Configure ADC regular channel ######################################*/
11471147
if (HAL_ADC_ConfigChannel(&AdcHandle, &AdcChannelConf) != HAL_OK) {
11481148
/* Channel Configuration Error */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /