STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Functions

ErrorStatus LL_ADC_CommonDeInit (ADC_Common_TypeDef *ADCxy_COMMON)
 De-initialize registers of all ADC instances belonging to the same ADC common instance to their default reset values. More...
 
ErrorStatus LL_ADC_CommonInit (ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
 Initialize some features of ADC common parameters (all ADC instances belonging to the same ADC common instance) and multimode (for devices with several ADC instances available). More...
 
void LL_ADC_CommonStructInit (LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
 Set each LL_ADC_CommonInitTypeDef field to default value. More...
 
ErrorStatus LL_ADC_DeInit (ADC_TypeDef *ADCx)
 De-initialize registers of the selected ADC instance to their default reset values. More...
 
ErrorStatus LL_ADC_Init (ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct)
 Initialize some features of ADC instance. More...
 
void LL_ADC_StructInit (LL_ADC_InitTypeDef *ADC_InitStruct)
 Set each LL_ADC_InitTypeDef field to default value. More...
 
ErrorStatus LL_ADC_REG_Init (ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
 Initialize some features of ADC group regular. More...
 
void LL_ADC_REG_StructInit (LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
 Set each LL_ADC_REG_InitTypeDef field to default value. More...
 
ErrorStatus LL_ADC_INJ_Init (ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct)
 Initialize some features of ADC group injected. More...
 
void LL_ADC_INJ_StructInit (LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct)
 Set each LL_ADC_INJ_InitTypeDef field to default value. More...
 

Detailed Description

Function Documentation

◆ LL_ADC_CommonDeInit()

ErrorStatus LL_ADC_CommonDeInit ( ADC_Common_TypeDef *  ADCxy_COMMON)

De-initialize registers of all ADC instances belonging to the same ADC common instance to their default reset values.

Note
This function is performing a hard reset, using high level clock source RCC ADC reset. Caution: On this STM32 serie, if several ADC instances are available on the selected device, RCC ADC reset will reset all ADC instances belonging to the common ADC instance. To de-initialize only 1 ADC instance, use function LL_ADC_DeInit().
Parameters
ADCxy_COMMONADC common instance (can be set directly from CMSIS definition or by using helper macro __LL_ADC_COMMON_INSTANCE() )
Return values
AnErrorStatus enumeration value:
  • SUCCESS: ADC common registers are de-initialized
  • ERROR: not applicable

Definition at line 310 of file stm32l4xx_ll_adc.c.

311 {
312  /* Check the parameters */
313  assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
314 
315  /* Force reset of ADC clock (core clock) */
316  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_ADC);
317 
318  /* Release reset of ADC clock (core clock) */
319  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_ADC);
320 
321  return SUCCESS;
322 }
__STATIC_INLINE void LL_AHB2_GRP1_ForceReset(uint32_t Periphs)
Force AHB2 peripherals reset. AHB2RSTR GPIOARST LL_AHB2_GRP1_ForceReset AHB2RSTR GPIOBRST LL_AHB2_G...
__STATIC_INLINE void LL_AHB2_GRP1_ReleaseReset(uint32_t Periphs)
Release AHB2 peripherals reset. AHB2RSTR GPIOARST LL_AHB2_GRP1_ReleaseReset AHB2RSTR GPIOBRST LL_AH...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_ADC_CommonInit()

ErrorStatus LL_ADC_CommonInit ( ADC_Common_TypeDef *  ADCxy_COMMON,
LL_ADC_CommonInitTypeDef ADC_CommonInitStruct 
)

Initialize some features of ADC common parameters (all ADC instances belonging to the same ADC common instance) and multimode (for devices with several ADC instances available).

Note
The setting of ADC common parameters is conditioned to ADC instances state: All ADC instances belonging to the same ADC common instance must be disabled.
Parameters
ADCxy_COMMONADC common instance (can be set directly from CMSIS definition or by using helper macro __LL_ADC_COMMON_INSTANCE() )
ADC_CommonInitStructPointer to a LL_ADC_CommonInitTypeDef structure
Return values
AnErrorStatus enumeration value:
  • SUCCESS: ADC common registers are initialized
  • ERROR: ADC common registers are not initialized

Definition at line 339 of file stm32l4xx_ll_adc.c.

340 {
341  ErrorStatus status = SUCCESS;
342 
343  /* Check the parameters */
344  assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
345  assert_param(IS_LL_ADC_COMMON_CLOCK(ADC_CommonInitStruct->CommonClock));
346 
347 #if defined(ADC_MULTIMODE_SUPPORT)
348  assert_param(IS_LL_ADC_MULTI_MODE(ADC_CommonInitStruct->Multimode));
349  if (ADC_CommonInitStruct->Multimode != LL_ADC_MULTI_INDEPENDENT)
350  {
351  assert_param(IS_LL_ADC_MULTI_DMA_TRANSFER(ADC_CommonInitStruct->MultiDMATransfer));
352  assert_param(IS_LL_ADC_MULTI_TWOSMP_DELAY(ADC_CommonInitStruct->MultiTwoSamplingDelay));
353  }
354 #endif /* ADC_MULTIMODE_SUPPORT */
355 
356  /* Note: Hardware constraint (refer to description of functions */
357  /* "LL_ADC_SetCommonXXX()" and "LL_ADC_SetMultiXXX()"): */
358  /* On this STM32 serie, setting of these features is conditioned to */
359  /* ADC state: */
360  /* All ADC instances of the ADC common group must be disabled. */
361  if (__LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(ADCxy_COMMON) == 0UL)
362  {
363  /* Configuration of ADC hierarchical scope: */
364  /* - common to several ADC */
365  /* (all ADC instances belonging to the same ADC common instance) */
366  /* - Set ADC clock (conversion clock) */
367  /* - multimode (if several ADC instances available on the */
368  /* selected device) */
369  /* - Set ADC multimode configuration */
370  /* - Set ADC multimode DMA transfer */
371  /* - Set ADC multimode: delay between 2 sampling phases */
372 #if defined(ADC_MULTIMODE_SUPPORT)
373  if (ADC_CommonInitStruct->Multimode != LL_ADC_MULTI_INDEPENDENT)
374  {
375  MODIFY_REG(ADCxy_COMMON->CCR,
376  ADC_CCR_CKMODE
377  | ADC_CCR_PRESC
378  | ADC_CCR_DUAL
379  | ADC_CCR_MDMA
380  | ADC_CCR_DELAY
381  ,
382  ADC_CommonInitStruct->CommonClock
383  | ADC_CommonInitStruct->Multimode
384  | ADC_CommonInitStruct->MultiDMATransfer
385  | ADC_CommonInitStruct->MultiTwoSamplingDelay
386  );
387  }
388  else
389  {
390  MODIFY_REG(ADCxy_COMMON->CCR,
391  ADC_CCR_CKMODE
392  | ADC_CCR_PRESC
393  | ADC_CCR_DUAL
394  | ADC_CCR_MDMA
395  | ADC_CCR_DELAY
396  ,
397  ADC_CommonInitStruct->CommonClock
398  | LL_ADC_MULTI_INDEPENDENT
399  );
400  }
401 #else
402  LL_ADC_SetCommonClock(ADCxy_COMMON, ADC_CommonInitStruct->CommonClock);
403 #endif
404  }
405  else
406  {
407  /* Initialization error: One or several ADC instances belonging to */
408  /* the same ADC common instance are not disabled. */
409  status = ERROR;
410  }
411 
412  return status;
413 }
__STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
Set parameter common to several ADC: Clock source and prescaler.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_ADC_CommonStructInit()

void LL_ADC_CommonStructInit ( LL_ADC_CommonInitTypeDef ADC_CommonInitStruct)

Set each LL_ADC_CommonInitTypeDef field to default value.

Parameters
ADC_CommonInitStructPointer to a LL_ADC_CommonInitTypeDef structure whose fields will be set to default values.
Return values
None

Definition at line 421 of file stm32l4xx_ll_adc.c.

422 {
423  /* Set ADC_CommonInitStruct fields to default values */
424  /* Set fields of ADC common */
425  /* (all ADC instances belonging to the same ADC common instance) */
426  ADC_CommonInitStruct->CommonClock = LL_ADC_CLOCK_SYNC_PCLK_DIV2;
427 
428 #if defined(ADC_MULTIMODE_SUPPORT)
429  /* Set fields of ADC multimode */
430  ADC_CommonInitStruct->Multimode = LL_ADC_MULTI_INDEPENDENT;
431  ADC_CommonInitStruct->MultiDMATransfer = LL_ADC_MULTI_REG_DMA_EACH_ADC;
432  ADC_CommonInitStruct->MultiTwoSamplingDelay = LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE;
433 #endif /* ADC_MULTIMODE_SUPPORT */
434 }

◆ LL_ADC_DeInit()

ErrorStatus LL_ADC_DeInit ( ADC_TypeDef *  ADCx)

De-initialize registers of the selected ADC instance to their default reset values.

Note
To reset all ADC instances quickly (perform a hard reset), use function LL_ADC_CommonDeInit().
If this functions returns error status, it means that ADC instance is in an unknown state. In this case, perform a hard reset using high level clock source RCC ADC reset. Caution: On this STM32 serie, if several ADC instances are available on the selected device, RCC ADC reset will reset all ADC instances belonging to the common ADC instance. Refer to function LL_ADC_CommonDeInit().
Parameters
ADCxADC instance
Return values
AnErrorStatus enumeration value:
  • SUCCESS: ADC registers are de-initialized
  • ERROR: ADC registers are not de-initialized

Definition at line 454 of file stm32l4xx_ll_adc.c.

455 {
456  ErrorStatus status = SUCCESS;
457 
458  __IO uint32_t timeout_cpu_cycles = 0UL;
459 
460  /* Check the parameters */
461  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
462 
463  /* Disable ADC instance if not already disabled. */
464  if (LL_ADC_IsEnabled(ADCx) == 1UL)
465  {
466  /* Set ADC group regular trigger source to SW start to ensure to not */
467  /* have an external trigger event occurring during the conversion stop */
468  /* ADC disable process. */
469  LL_ADC_REG_SetTriggerSource(ADCx, LL_ADC_REG_TRIG_SOFTWARE);
470 
471  /* Stop potential ADC conversion on going on ADC group regular. */
472  if (LL_ADC_REG_IsConversionOngoing(ADCx) != 0UL)
473  {
474  if (LL_ADC_REG_IsStopConversionOngoing(ADCx) == 0UL)
475  {
477  }
478  }
479 
480  /* Set ADC group injected trigger source to SW start to ensure to not */
481  /* have an external trigger event occurring during the conversion stop */
482  /* ADC disable process. */
483  LL_ADC_INJ_SetTriggerSource(ADCx, LL_ADC_INJ_TRIG_SOFTWARE);
484 
485  /* Stop potential ADC conversion on going on ADC group injected. */
486  if (LL_ADC_INJ_IsConversionOngoing(ADCx) != 0UL)
487  {
488  if (LL_ADC_INJ_IsStopConversionOngoing(ADCx) == 0UL)
489  {
491  }
492  }
493 
494  /* Wait for ADC conversions are effectively stopped */
495  timeout_cpu_cycles = ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES;
497  | LL_ADC_INJ_IsStopConversionOngoing(ADCx)) == 1UL)
498  {
499  timeout_cpu_cycles--;
500  if (timeout_cpu_cycles == 0UL)
501  {
502  /* Time-out error */
503  status = ERROR;
504  break;
505  }
506  }
507 
508  /* Flush group injected contexts queue (register JSQR): */
509  /* Note: Bit JQM must be set to empty the contexts queue (otherwise */
510  /* contexts queue is maintained with the last active context). */
511  LL_ADC_INJ_SetQueueMode(ADCx, LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY);
512 
513  /* Disable the ADC instance */
514  LL_ADC_Disable(ADCx);
515 
516  /* Wait for ADC instance is effectively disabled */
517  timeout_cpu_cycles = ADC_TIMEOUT_DISABLE_CPU_CYCLES;
518  while (LL_ADC_IsDisableOngoing(ADCx) == 1UL)
519  {
520  timeout_cpu_cycles--;
521  if (timeout_cpu_cycles == 0UL)
522  {
523  /* Time-out error */
524  status = ERROR;
525  break;
526  }
527  }
528  }
529 
530  /* Check whether ADC state is compliant with expected state */
531  if (READ_BIT(ADCx->CR,
532  (ADC_CR_JADSTP | ADC_CR_ADSTP | ADC_CR_JADSTART | ADC_CR_ADSTART
533  | ADC_CR_ADDIS | ADC_CR_ADEN)
534  )
535  == 0UL)
536  {
537  /* ========== Reset ADC registers ========== */
538  /* Reset register IER */
539  CLEAR_BIT(ADCx->IER,
540  (LL_ADC_IT_ADRDY
541  | LL_ADC_IT_EOC
542  | LL_ADC_IT_EOS
543  | LL_ADC_IT_OVR
544  | LL_ADC_IT_EOSMP
545  | LL_ADC_IT_JEOC
546  | LL_ADC_IT_JEOS
547  | LL_ADC_IT_JQOVF
548  | LL_ADC_IT_AWD1
549  | LL_ADC_IT_AWD2
550  | LL_ADC_IT_AWD3
551  )
552  );
553 
554  /* Reset register ISR */
555  SET_BIT(ADCx->ISR,
556  (LL_ADC_FLAG_ADRDY
557  | LL_ADC_FLAG_EOC
558  | LL_ADC_FLAG_EOS
559  | LL_ADC_FLAG_OVR
560  | LL_ADC_FLAG_EOSMP
561  | LL_ADC_FLAG_JEOC
562  | LL_ADC_FLAG_JEOS
563  | LL_ADC_FLAG_JQOVF
564  | LL_ADC_FLAG_AWD1
565  | LL_ADC_FLAG_AWD2
566  | LL_ADC_FLAG_AWD3
567  )
568  );
569 
570  /* Reset register CR */
571  /* - Bits ADC_CR_JADSTP, ADC_CR_ADSTP, ADC_CR_JADSTART, ADC_CR_ADSTART, */
572  /* ADC_CR_ADCAL, ADC_CR_ADDIS, ADC_CR_ADEN are in */
573  /* access mode "read-set": no direct reset applicable. */
574  /* - Reset Calibration mode to default setting (single ended). */
575  /* - Disable ADC internal voltage regulator. */
576  /* - Enable ADC deep power down. */
577  /* Note: ADC internal voltage regulator disable and ADC deep power */
578  /* down enable are conditioned to ADC state disabled: */
579  /* already done above. */
580  CLEAR_BIT(ADCx->CR, ADC_CR_ADVREGEN | ADC_CR_ADCALDIF);
581  SET_BIT(ADCx->CR, ADC_CR_DEEPPWD);
582 
583  /* Reset register CFGR */
584  MODIFY_REG(ADCx->CFGR,
585  (ADC_CFGR_AWD1CH | ADC_CFGR_JAUTO | ADC_CFGR_JAWD1EN
586  | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL | ADC_CFGR_JQM
587  | ADC_CFGR_JDISCEN | ADC_CFGR_DISCNUM | ADC_CFGR_DISCEN
588  | ADC_CFGR_AUTDLY | ADC_CFGR_CONT | ADC_CFGR_OVRMOD
589  | ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL | ADC_CFGR_ALIGN
590  | ADC_CFGR_RES | ADC_CFGR_DMACFG | ADC_CFGR_DMAEN),
591  ADC_CFGR_JQDIS
592  );
593 
594  /* Reset register CFGR2 */
595  CLEAR_BIT(ADCx->CFGR2,
596  (ADC_CFGR2_ROVSM | ADC_CFGR2_TROVS | ADC_CFGR2_OVSS
597  | ADC_CFGR2_OVSR | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSE)
598  );
599 
600  /* Reset register SMPR1 */
601  CLEAR_BIT(ADCx->SMPR1,
602  (ADC_SMPR1_SMP9 | ADC_SMPR1_SMP8 | ADC_SMPR1_SMP7
603  | ADC_SMPR1_SMP6 | ADC_SMPR1_SMP5 | ADC_SMPR1_SMP4
604  | ADC_SMPR1_SMP3 | ADC_SMPR1_SMP2 | ADC_SMPR1_SMP1)
605  );
606 
607  /* Reset register SMPR2 */
608  CLEAR_BIT(ADCx->SMPR2,
609  (ADC_SMPR2_SMP18 | ADC_SMPR2_SMP17 | ADC_SMPR2_SMP16
610  | ADC_SMPR2_SMP15 | ADC_SMPR2_SMP14 | ADC_SMPR2_SMP13
611  | ADC_SMPR2_SMP12 | ADC_SMPR2_SMP11 | ADC_SMPR2_SMP10)
612  );
613 
614  /* Reset register TR1 */
615  MODIFY_REG(ADCx->TR1, ADC_TR1_HT1 | ADC_TR1_LT1, ADC_TR1_HT1);
616 
617  /* Reset register TR2 */
618  MODIFY_REG(ADCx->TR2, ADC_TR2_HT2 | ADC_TR2_LT2, ADC_TR2_HT2);
619 
620  /* Reset register TR3 */
621  MODIFY_REG(ADCx->TR3, ADC_TR3_HT3 | ADC_TR3_LT3, ADC_TR3_HT3);
622 
623  /* Reset register SQR1 */
624  CLEAR_BIT(ADCx->SQR1,
625  (ADC_SQR1_SQ4 | ADC_SQR1_SQ3 | ADC_SQR1_SQ2
626  | ADC_SQR1_SQ1 | ADC_SQR1_L)
627  );
628 
629  /* Reset register SQR2 */
630  CLEAR_BIT(ADCx->SQR2,
631  (ADC_SQR2_SQ9 | ADC_SQR2_SQ8 | ADC_SQR2_SQ7
632  | ADC_SQR2_SQ6 | ADC_SQR2_SQ5)
633  );
634 
635  /* Reset register SQR3 */
636  CLEAR_BIT(ADCx->SQR3,
637  (ADC_SQR3_SQ14 | ADC_SQR3_SQ13 | ADC_SQR3_SQ12
638  | ADC_SQR3_SQ11 | ADC_SQR3_SQ10)
639  );
640 
641  /* Reset register SQR4 */
642  CLEAR_BIT(ADCx->SQR4, ADC_SQR4_SQ16 | ADC_SQR4_SQ15);
643 
644  /* Reset register JSQR */
645  CLEAR_BIT(ADCx->JSQR,
646  (ADC_JSQR_JL
647  | ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN
648  | ADC_JSQR_JSQ4 | ADC_JSQR_JSQ3
649  | ADC_JSQR_JSQ2 | ADC_JSQR_JSQ1)
650  );
651 
652  /* Reset register DR */
653  /* Note: bits in access mode read only, no direct reset applicable */
654 
655  /* Reset register OFR1 */
656  CLEAR_BIT(ADCx->OFR1, ADC_OFR1_OFFSET1_EN | ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1);
657  /* Reset register OFR2 */
658  CLEAR_BIT(ADCx->OFR2, ADC_OFR2_OFFSET2_EN | ADC_OFR2_OFFSET2_CH | ADC_OFR2_OFFSET2);
659  /* Reset register OFR3 */
660  CLEAR_BIT(ADCx->OFR3, ADC_OFR3_OFFSET3_EN | ADC_OFR3_OFFSET3_CH | ADC_OFR3_OFFSET3);
661  /* Reset register OFR4 */
662  CLEAR_BIT(ADCx->OFR4, ADC_OFR4_OFFSET4_EN | ADC_OFR4_OFFSET4_CH | ADC_OFR4_OFFSET4);
663 
664  /* Reset registers JDR1, JDR2, JDR3, JDR4 */
665  /* Note: bits in access mode read only, no direct reset applicable */
666 
667  /* Reset register AWD2CR */
668  CLEAR_BIT(ADCx->AWD2CR, ADC_AWD2CR_AWD2CH);
669 
670  /* Reset register AWD3CR */
671  CLEAR_BIT(ADCx->AWD3CR, ADC_AWD3CR_AWD3CH);
672 
673  /* Reset register DIFSEL */
674  CLEAR_BIT(ADCx->DIFSEL, ADC_DIFSEL_DIFSEL);
675 
676  /* Reset register CALFACT */
677  CLEAR_BIT(ADCx->CALFACT, ADC_CALFACT_CALFACT_D | ADC_CALFACT_CALFACT_S);
678  }
679  else
680  {
681  /* ADC instance is in an unknown state */
682  /* Need to performing a hard reset of ADC instance, using high level */
683  /* clock source RCC ADC reset. */
684  /* Caution: On this STM32 serie, if several ADC instances are available */
685  /* on the selected device, RCC ADC reset will reset */
686  /* all ADC instances belonging to the common ADC instance. */
687  /* Caution: On this STM32 serie, if several ADC instances are available */
688  /* on the selected device, RCC ADC reset will reset */
689  /* all ADC instances belonging to the common ADC instance. */
690  status = ERROR;
691  }
692 
693  return status;
694 }
__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
Get the selected ADC instance enable state.
__STATIC_INLINE void LL_ADC_INJ_StopConversion(ADC_TypeDef *ADCx)
Stop ADC group injected conversion.
__STATIC_INLINE uint32_t LL_ADC_IsDisableOngoing(ADC_TypeDef *ADCx)
Get the selected ADC instance disable state. CR ADDIS LL_ADC_IsDisableOngoing.
__STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
Set ADC group injected conversion trigger source: internal (SW start) or from external peripheral (ti...
__STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
Set ADC group regular conversion trigger source: internal (SW start) or from external peripheral (tim...
__STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
Disable the selected ADC instance.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
Stop ADC group regular conversion.
__STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected conversion state. CR JADSTART LL_ADC_INJ_IsConversionOngoing.
__STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular command of conversion stop state CR ADSTP LL_ADC_REG_IsStopConversionOngoing.
__STATIC_INLINE void LL_ADC_INJ_SetQueueMode(ADC_TypeDef *ADCx, uint32_t QueueMode)
Set ADC group injected contexts queue mode.
__STATIC_INLINE uint32_t LL_ADC_INJ_IsStopConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected command of conversion stop state CR JADSTP LL_ADC_INJ_IsStopConversionOngoing...
__STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular conversion state. CR ADSTART LL_ADC_REG_IsConversionOngoing.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_ADC_Init()

ErrorStatus LL_ADC_Init ( ADC_TypeDef *  ADCx,
LL_ADC_InitTypeDef ADC_InitStruct 
)

Initialize some features of ADC instance.

Note
These parameters have an impact on ADC scope: ADC instance. Affects both group regular and group injected (availability of ADC group injected depends on STM32 families). Refer to corresponding unitary functions into Configuration of ADC hierarchical scope: ADC instance .
The setting of these parameters by function LL_ADC_Init() is conditioned to ADC state: ADC instance must be disabled. This condition is applied to all ADC features, for efficiency and compatibility over all STM32 families. However, the different features can be set under different ADC state conditions (setting possible with ADC enabled without conversion on going, ADC enabled with conversion on going, ...) Each feature can be updated afterwards with a unitary function and potentially with ADC in a different state than disabled, refer to description of each function for setting conditioned to ADC state.
After using this function, some other features must be configured using LL unitary functions. The minimum configuration remaining to be done is:
Parameters
ADCxADC instance
ADC_InitStructPointer to a LL_ADC_REG_InitTypeDef structure
Return values
AnErrorStatus enumeration value:
  • SUCCESS: ADC registers are initialized
  • ERROR: ADC registers are not initialized

Definition at line 729 of file stm32l4xx_ll_adc.c.

730 {
731  ErrorStatus status = SUCCESS;
732 
733  /* Check the parameters */
734  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
735 
736  assert_param(IS_LL_ADC_RESOLUTION(ADC_InitStruct->Resolution));
737  assert_param(IS_LL_ADC_DATA_ALIGN(ADC_InitStruct->DataAlignment));
738  assert_param(IS_LL_ADC_LOW_POWER(ADC_InitStruct->LowPowerMode));
739 
740  /* Note: Hardware constraint (refer to description of this function): */
741  /* ADC instance must be disabled. */
742  if (LL_ADC_IsEnabled(ADCx) == 0UL)
743  {
744  /* Configuration of ADC hierarchical scope: */
745  /* - ADC instance */
746  /* - Set ADC data resolution */
747  /* - Set ADC conversion data alignment */
748  /* - Set ADC low power mode */
749  MODIFY_REG(ADCx->CFGR,
750  ADC_CFGR_RES
751  | ADC_CFGR_ALIGN
752  | ADC_CFGR_AUTDLY
753  ,
754  ADC_InitStruct->Resolution
755  | ADC_InitStruct->DataAlignment
756  | ADC_InitStruct->LowPowerMode
757  );
758 
759  }
760  else
761  {
762  /* Initialization error: ADC instance is not disabled. */
763  status = ERROR;
764  }
765  return status;
766 }
__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
Get the selected ADC instance enable state.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_ADC_INJ_Init()

ErrorStatus LL_ADC_INJ_Init ( ADC_TypeDef *  ADCx,
LL_ADC_INJ_InitTypeDef ADC_INJ_InitStruct 
)

Initialize some features of ADC group injected.

Note
These parameters have an impact on ADC scope: ADC group injected. Refer to corresponding unitary functions into Configuration of ADC hierarchical scope: group regular (functions with prefix "INJ").
The setting of these parameters by function LL_ADC_Init() is conditioned to ADC state: ADC instance must be disabled. This condition is applied to all ADC features, for efficiency and compatibility over all STM32 families. However, the different features can be set under different ADC state conditions (setting possible with ADC enabled without conversion on going, ADC enabled with conversion on going, ...) Each feature can be updated afterwards with a unitary function and potentially with ADC in a different state than disabled, refer to description of each function for setting conditioned to ADC state.
After using this function, other features must be configured using LL unitary functions. The minimum configuration remaining to be done is:
Parameters
ADCxADC instance
ADC_INJ_InitStructPointer to a LL_ADC_INJ_InitTypeDef structure
Return values
AnErrorStatus enumeration value:
  • SUCCESS: ADC registers are initialized
  • ERROR: ADC registers are not initialized

Definition at line 949 of file stm32l4xx_ll_adc.c.

950 {
951  ErrorStatus status = SUCCESS;
952 
953  /* Check the parameters */
954  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
955  assert_param(IS_LL_ADC_INJ_TRIG_SOURCE(ADC_INJ_InitStruct->TriggerSource));
956  assert_param(IS_LL_ADC_INJ_SEQ_SCAN_LENGTH(ADC_INJ_InitStruct->SequencerLength));
957  if (ADC_INJ_InitStruct->SequencerLength != LL_ADC_INJ_SEQ_SCAN_DISABLE)
958  {
959  assert_param(IS_LL_ADC_INJ_SEQ_SCAN_DISCONT_MODE(ADC_INJ_InitStruct->SequencerDiscont));
960  }
961  assert_param(IS_LL_ADC_INJ_TRIG_AUTO(ADC_INJ_InitStruct->TrigAuto));
962 
963  /* Note: Hardware constraint (refer to description of this function): */
964  /* ADC instance must be disabled. */
965  if (LL_ADC_IsEnabled(ADCx) == 0UL)
966  {
967  /* Configuration of ADC hierarchical scope: */
968  /* - ADC group injected */
969  /* - Set ADC group injected trigger source */
970  /* - Set ADC group injected sequencer length */
971  /* - Set ADC group injected sequencer discontinuous mode */
972  /* - Set ADC group injected conversion trigger: independent or */
973  /* from ADC group regular */
974  /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by */
975  /* setting of trigger source to SW start. */
976  if (ADC_INJ_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
977  {
978  MODIFY_REG(ADCx->CFGR,
979  ADC_CFGR_JDISCEN
980  | ADC_CFGR_JAUTO
981  ,
982  ADC_INJ_InitStruct->SequencerDiscont
983  | ADC_INJ_InitStruct->TrigAuto
984  );
985  }
986  else
987  {
988  MODIFY_REG(ADCx->CFGR,
989  ADC_CFGR_JDISCEN
990  | ADC_CFGR_JAUTO
991  ,
992  LL_ADC_REG_SEQ_DISCONT_DISABLE
993  | ADC_INJ_InitStruct->TrigAuto
994  );
995  }
996 
997  MODIFY_REG(ADCx->JSQR,
998  ADC_JSQR_JEXTSEL
999  | ADC_JSQR_JEXTEN
1000  | ADC_JSQR_JL
1001  ,
1002  ADC_INJ_InitStruct->TriggerSource
1003  | ADC_INJ_InitStruct->SequencerLength
1004  );
1005  }
1006  else
1007  {
1008  /* Initialization error: ADC instance is not disabled. */
1009  status = ERROR;
1010  }
1011  return status;
1012 }
__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
Get the selected ADC instance enable state.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_ADC_INJ_StructInit()

void LL_ADC_INJ_StructInit ( LL_ADC_INJ_InitTypeDef ADC_INJ_InitStruct)

Set each LL_ADC_INJ_InitTypeDef field to default value.

Parameters
ADC_INJ_InitStructPointer to a LL_ADC_INJ_InitTypeDef structure whose fields will be set to default values.
Return values
None

Definition at line 1020 of file stm32l4xx_ll_adc.c.

1021 {
1022  /* Set ADC_INJ_InitStruct fields to default values */
1023  /* Set fields of ADC group injected */
1024  ADC_INJ_InitStruct->TriggerSource = LL_ADC_INJ_TRIG_SOFTWARE;
1025  ADC_INJ_InitStruct->SequencerLength = LL_ADC_INJ_SEQ_SCAN_DISABLE;
1026  ADC_INJ_InitStruct->SequencerDiscont = LL_ADC_INJ_SEQ_DISCONT_DISABLE;
1027  ADC_INJ_InitStruct->TrigAuto = LL_ADC_INJ_TRIG_INDEPENDENT;
1028 }

◆ LL_ADC_REG_Init()

ErrorStatus LL_ADC_REG_Init ( ADC_TypeDef *  ADCx,
LL_ADC_REG_InitTypeDef ADC_REG_InitStruct 
)

Initialize some features of ADC group regular.

Note
These parameters have an impact on ADC scope: ADC group regular. Refer to corresponding unitary functions into Configuration of ADC hierarchical scope: group regular (functions with prefix "REG").
The setting of these parameters by function LL_ADC_Init() is conditioned to ADC state: ADC instance must be disabled. This condition is applied to all ADC features, for efficiency and compatibility over all STM32 families. However, the different features can be set under different ADC state conditions (setting possible with ADC enabled without conversion on going, ADC enabled with conversion on going, ...) Each feature can be updated afterwards with a unitary function and potentially with ADC in a different state than disabled, refer to description of each function for setting conditioned to ADC state.
After using this function, other features must be configured using LL unitary functions. The minimum configuration remaining to be done is:
Parameters
ADCxADC instance
ADC_REG_InitStructPointer to a LL_ADC_REG_InitTypeDef structure
Return values
AnErrorStatus enumeration value:
  • SUCCESS: ADC registers are initialized
  • ERROR: ADC registers are not initialized

Definition at line 816 of file stm32l4xx_ll_adc.c.

817 {
818  ErrorStatus status = SUCCESS;
819 
820  /* Check the parameters */
821  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
822  assert_param(IS_LL_ADC_REG_TRIG_SOURCE(ADC_REG_InitStruct->TriggerSource));
823  assert_param(IS_LL_ADC_REG_SEQ_SCAN_LENGTH(ADC_REG_InitStruct->SequencerLength));
824  if (ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
825  {
826  assert_param(IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(ADC_REG_InitStruct->SequencerDiscont));
827  }
828  assert_param(IS_LL_ADC_REG_CONTINUOUS_MODE(ADC_REG_InitStruct->ContinuousMode));
829  assert_param(IS_LL_ADC_REG_DMA_TRANSFER(ADC_REG_InitStruct->DMATransfer));
830  assert_param(IS_LL_ADC_REG_OVR_DATA_BEHAVIOR(ADC_REG_InitStruct->Overrun));
831 
832  /* Note: Hardware constraint (refer to description of this function): */
833  /* ADC instance must be disabled. */
834  if (LL_ADC_IsEnabled(ADCx) == 0UL)
835  {
836  /* Configuration of ADC hierarchical scope: */
837  /* - ADC group regular */
838  /* - Set ADC group regular trigger source */
839  /* - Set ADC group regular sequencer length */
840  /* - Set ADC group regular sequencer discontinuous mode */
841  /* - Set ADC group regular continuous mode */
842  /* - Set ADC group regular conversion data transfer: no transfer or */
843  /* transfer by DMA, and DMA requests mode */
844  /* - Set ADC group regular overrun behavior */
845  /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by */
846  /* setting of trigger source to SW start. */
847  if (ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
848  {
849  MODIFY_REG(ADCx->CFGR,
850  ADC_CFGR_EXTSEL
851  | ADC_CFGR_EXTEN
852  | ADC_CFGR_DISCEN
853  | ADC_CFGR_DISCNUM
854  | ADC_CFGR_CONT
855  | ADC_CFGR_DMAEN
856  | ADC_CFGR_DMACFG
857  | ADC_CFGR_OVRMOD
858  ,
859  ADC_REG_InitStruct->TriggerSource
860  | ADC_REG_InitStruct->SequencerDiscont
861  | ADC_REG_InitStruct->ContinuousMode
862  | ADC_REG_InitStruct->DMATransfer
863  | ADC_REG_InitStruct->Overrun
864  );
865  }
866  else
867  {
868  MODIFY_REG(ADCx->CFGR,
869  ADC_CFGR_EXTSEL
870  | ADC_CFGR_EXTEN
871  | ADC_CFGR_DISCEN
872  | ADC_CFGR_DISCNUM
873  | ADC_CFGR_CONT
874  | ADC_CFGR_DMAEN
875  | ADC_CFGR_DMACFG
876  | ADC_CFGR_OVRMOD
877  ,
878  ADC_REG_InitStruct->TriggerSource
879  | LL_ADC_REG_SEQ_DISCONT_DISABLE
880  | ADC_REG_InitStruct->ContinuousMode
881  | ADC_REG_InitStruct->DMATransfer
882  | ADC_REG_InitStruct->Overrun
883  );
884  }
885 
886  /* Set ADC group regular sequencer length and scan direction */
887  LL_ADC_REG_SetSequencerLength(ADCx, ADC_REG_InitStruct->SequencerLength);
888  }
889  else
890  {
891  /* Initialization error: ADC instance is not disabled. */
892  status = ERROR;
893  }
894  return status;
895 }
__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
Get the selected ADC instance enable state.
__STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
Set ADC group regular sequencer length and scan direction.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_ADC_REG_StructInit()

void LL_ADC_REG_StructInit ( LL_ADC_REG_InitTypeDef ADC_REG_InitStruct)

Set each LL_ADC_REG_InitTypeDef field to default value.

Parameters
ADC_REG_InitStructPointer to a LL_ADC_REG_InitTypeDef structure whose fields will be set to default values.
Return values
None

Definition at line 903 of file stm32l4xx_ll_adc.c.

904 {
905  /* Set ADC_REG_InitStruct fields to default values */
906  /* Set fields of ADC group regular */
907  /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by */
908  /* setting of trigger source to SW start. */
909  ADC_REG_InitStruct->TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
910  ADC_REG_InitStruct->SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
911  ADC_REG_InitStruct->SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
912  ADC_REG_InitStruct->ContinuousMode = LL_ADC_REG_CONV_SINGLE;
913  ADC_REG_InitStruct->DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
914  ADC_REG_InitStruct->Overrun = LL_ADC_REG_OVR_DATA_OVERWRITTEN;
915 }

◆ LL_ADC_StructInit()

void LL_ADC_StructInit ( LL_ADC_InitTypeDef ADC_InitStruct)

Set each LL_ADC_InitTypeDef field to default value.

Parameters
ADC_InitStructPointer to a LL_ADC_InitTypeDef structure whose fields will be set to default values.
Return values
None

Definition at line 774 of file stm32l4xx_ll_adc.c.

775 {
776  /* Set ADC_InitStruct fields to default values */
777  /* Set fields of ADC instance */
778  ADC_InitStruct->Resolution = LL_ADC_RESOLUTION_12B;
779  ADC_InitStruct->DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
780  ADC_InitStruct->LowPowerMode = LL_ADC_LP_MODE_NONE;
781 
782 }