@@ -2312,7 +2312,6 @@ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConf
2312
2312
/* Parameters update conditioned to ADC state: */
2313
2313
/* Parameters that can be updated only when ADC is disabled: */
2314
2314
/* - Single or differential mode */
2315
- /* - Internal measurement channels: Vbat/VrefInt/TempSensor */
2316
2315
if (ADC_IS_ENABLE (hadc ) == RESET )
2317
2316
{
2318
2317
/* Set mode single-ended or differential input of the selected ADC channel */
@@ -2325,71 +2324,56 @@ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConf
2325
2324
LL_ADC_SetChannelSamplingTime (hadc -> Instance , __LL_ADC_DECIMAL_NB_TO_CHANNEL (__LL_ADC_CHANNEL_TO_DECIMAL_NB (sConfig -> Channel ) + 1 ), sConfig -> SamplingTime );
2326
2325
}
2327
2326
2328
- /* Management of internal measurement channels: Vbat/VrefInt/TempSensor. */
2329
- /* If internal channel selected, enable dedicated internal buffers and */
2330
- /* paths. */
2331
- /* Note: these internal measurement paths can be disabled using */
2332
- /* HAL_ADC_DeInit(). */
2333
-
2334
- /* Configuration of common ADC parameters */
2335
- /* If the requested internal measurement path has already been enabled, */
2336
- /* bypass the configuration processing. */
2337
- if (( (sConfig -> Channel == ADC_CHANNEL_TEMPSENSOR ) &&
2338
- ((LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )) & LL_ADC_PATH_INTERNAL_TEMPSENSOR ) == 0U )) ||
2339
- ( (sConfig -> Channel == ADC_CHANNEL_VBAT ) &&
2340
- ((LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )) & LL_ADC_PATH_INTERNAL_VBAT ) == 0U )) ||
2341
- ( (sConfig -> Channel == ADC_CHANNEL_VREFINT ) &&
2342
- ((LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )) & LL_ADC_PATH_INTERNAL_VREFINT ) == 0U ))
2343
- )
2327
+ }
2328
+
2329
+ /* Management of internal measurement channels: Vbat/VrefInt/TempSensor. */
2330
+ /* If internal channel selected, enable dedicated internal buffers and */
2331
+ /* paths. */
2332
+ /* Note: these internal measurement paths can be disabled using */
2333
+ /* HAL_ADC_DeInit(). */
2334
+
2335
+ /* Configuration of common ADC parameters */
2336
+ /* If the requested internal measurement path has already been enabled, */
2337
+ /* bypass the configuration processing. */
2338
+ if (( (sConfig -> Channel == ADC_CHANNEL_TEMPSENSOR ) &&
2339
+ ((LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )) & LL_ADC_PATH_INTERNAL_TEMPSENSOR ) == 0U )) ||
2340
+ ( (sConfig -> Channel == ADC_CHANNEL_VBAT ) &&
2341
+ ((LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )) & LL_ADC_PATH_INTERNAL_VBAT ) == 0U )) ||
2342
+ ( (sConfig -> Channel == ADC_CHANNEL_VREFINT ) &&
2343
+ ((LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )) & LL_ADC_PATH_INTERNAL_VREFINT ) == 0U ))
2344
+ )
2345
+ {
2346
+ /* Configuration of common ADC parameters (continuation) */
2347
+
2348
+ if (sConfig -> Channel == ADC_CHANNEL_TEMPSENSOR )
2344
2349
{
2345
- /* Configuration of common ADC parameters (continuation) */
2346
-
2347
- /* Software is allowed to change common parameters only when all ADCs */
2348
- /* of the common group are disabled. */
2349
- if ((ADC_IS_ENABLE (hadc ) == RESET ) &&
2350
- (ADC_ANY_OTHER_ENABLED (hadc ) == RESET ) )
2350
+ if (ADC_TEMPERATURE_SENSOR_INSTANCE (hadc ))
2351
2351
{
2352
- if (sConfig -> Channel == ADC_CHANNEL_TEMPSENSOR )
2353
- {
2354
- if (ADC_TEMPERATURE_SENSOR_INSTANCE (hadc ))
2355
- {
2356
- LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance ), LL_ADC_PATH_INTERNAL_TEMPSENSOR | LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )));
2357
-
2358
- /* Delay for temperature sensor stabilization time */
2359
- /* Wait loop initialization and execution */
2360
- /* Note: Variable divided by 2 to compensate partially */
2361
- /* CPU processing cycles. */
2362
- wait_loop_index = (LL_ADC_DELAY_TEMPSENSOR_STAB_US * (SystemCoreClock / (1000000 * 2 )));
2363
- while (wait_loop_index != 0 )
2364
- {
2365
- wait_loop_index -- ;
2366
- }
2367
- }
2368
- }
2369
- else if (sConfig -> Channel == ADC_CHANNEL_VBAT )
2352
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance ), LL_ADC_PATH_INTERNAL_TEMPSENSOR | LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )));
2353
+
2354
+ /* Delay for temperature sensor stabilization time */
2355
+ /* Wait loop initialization and execution */
2356
+ /* Note: Variable divided by 2 to compensate partially */
2357
+ /* CPU processing cycles. */
2358
+ wait_loop_index = (LL_ADC_DELAY_TEMPSENSOR_STAB_US * (SystemCoreClock / (1000000 * 2 )));
2359
+ while (wait_loop_index != 0 )
2370
2360
{
2371
- if (ADC_BATTERY_VOLTAGE_INSTANCE (hadc ))
2372
- {
2373
- LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance ), LL_ADC_PATH_INTERNAL_VBAT | LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )));
2374
- }
2375
- }
2376
- else if (sConfig -> Channel == ADC_CHANNEL_VREFINT )
2377
- {
2378
- if (ADC_VREFINT_INSTANCE (hadc ))
2379
- {
2380
- LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance ), LL_ADC_PATH_INTERNAL_VREFINT | LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )));
2381
- }
2361
+ wait_loop_index -- ;
2382
2362
}
2383
2363
}
2384
- /* If the requested internal measurement path has already been */
2385
- /* enabled and other ADC of the common group are enabled, internal */
2386
- /* measurement paths cannot be enabled. */
2387
- else
2364
+ }
2365
+ else if ( sConfig -> Channel == ADC_CHANNEL_VBAT )
2366
+ {
2367
+ if ( ADC_BATTERY_VOLTAGE_INSTANCE ( hadc ))
2388
2368
{
2389
- /* Update ADC state machine to error */
2390
- SET_BIT (hadc -> State , HAL_ADC_STATE_ERROR_CONFIG );
2391
-
2392
- tmp_hal_status = HAL_ERROR ;
2369
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance ), LL_ADC_PATH_INTERNAL_VBAT | LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )));
2370
+ }
2371
+ }
2372
+ else if (sConfig -> Channel == ADC_CHANNEL_VREFINT )
2373
+ {
2374
+ if (ADC_VREFINT_INSTANCE (hadc ))
2375
+ {
2376
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance ), LL_ADC_PATH_INTERNAL_VREFINT | LL_ADC_GetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE (hadc -> Instance )));
2393
2377
}
2394
2378
}
2395
2379
}
0 commit comments