59 #define ADC_CALIBRATION_TIMEOUT_MS ((uint32_t) 1)
60 #define ADC_ENABLE_TIMEOUT_MS ((uint32_t) 1)
61 #define ADC_DISABLE_TIMEOUT_MS ((uint32_t) 1)
62 #define ADC_STOP_CONVERSION_TIMEOUT_MS ((uint32_t) 1)
63 #define ADC_CONVERSION_TIMEOUT_MS ((uint32_t) 2)
70 #define ADC_DELAY_ENABLE_CALIB_CPU_CYCLES (LL_ADC_DELAY_ENABLE_CALIB_ADC_CYCLES * 32)
76 #define VDDA_APPLI ((uint32_t)3300)
80 #define VAR_CONVERTED_DATA_INIT_VALUE (__LL_ADC_DIGITAL_SCALE(LL_ADC_RESOLUTION_12B) + 1)
107 LL_ADC_InitTypeDef ADC_InitStruct = {0};
108 LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0};
109 LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0};
112 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
120 ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
121 ADC_InitStruct.SequencersScanMode = LL_ADC_SEQ_SCAN_DISABLE;
122 LL_ADC_Init(
ADC1, &ADC_InitStruct);
123 ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT;
124 LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(
ADC1), &ADC_CommonInitStruct);
125 ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
126 ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
127 ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
128 ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
129 ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
130 LL_ADC_REG_Init(
ADC1, &ADC_REG_InitStruct);
133 LL_ADC_REG_SetSequencerRanks(
ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_TEMPSENSOR);
134 LL_ADC_SetChannelSamplingTime(
ADC1, LL_ADC_CHANNEL_TEMPSENSOR, LL_ADC_SAMPLINGTIME_1CYCLE_5);
135 LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(
ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR);
142 LL_ADC_InitTypeDef ADC_InitStruct = {0};
143 LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0};
145 LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
148 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC2);
150 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
154 GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
155 GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
156 LL_GPIO_Init(
GPIOB, &GPIO_InitStruct);
164 ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
165 ADC_InitStruct.SequencersScanMode = LL_ADC_SEQ_SCAN_DISABLE;
166 LL_ADC_Init(
ADC2, &ADC_InitStruct);
167 ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
168 ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
169 ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
170 ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
171 ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
172 LL_ADC_REG_Init(
ADC2, &ADC_REG_InitStruct);
175 LL_ADC_REG_SetSequencerRanks(
ADC2, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_8);
176 LL_ADC_SetChannelSamplingTime(
ADC2, LL_ADC_CHANNEL_8, LL_ADC_SAMPLINGTIME_1CYCLE_5);
200 LL_ADC_SetChannelSamplingTime(
ADC2, LL_ADC_CHANNEL_8, LL_ADC_SAMPLINGTIME_28CYCLES_5);
203 LL_ADC_EnableIT_EOS(
ADC2);
207 __IO uint32_t wait_loop_index = 0;
222 if (LL_ADC_IsEnabled(
ADC2) == 0)
231 while (wait_loop_index != 0) wait_loop_index--;
234 LL_ADC_StartCalibration(
ADC2);
239 while (LL_ADC_IsCalibrationOnGoing(
ADC2) != 0)
295 if (LL_ADC_IsEnabled(
ADC2) == 1) LL_ADC_REG_StartConversionSWStart(
ADC2);