STM32L4xx_HAL_Driver  1.14.0
Extended Input and Output operation functions

Extended IO operation functions. More...

Functions

HAL_StatusTypeDef HAL_ADCEx_Calibration_Start (ADC_HandleTypeDef *hadc, uint32_t SingleDiff)
 Perform an ADC automatic self-calibration Calibration prerequisite: ADC must be disabled (execute this function before HAL_ADC_Start() or after HAL_ADC_Stop() ). More...
 
uint32_t HAL_ADCEx_Calibration_GetValue (ADC_HandleTypeDef *hadc, uint32_t SingleDiff)
 Get the calibration factor. More...
 
HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue (ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor)
 Set the calibration factor to overwrite automatic conversion result. ADC must be enabled and no conversion is ongoing. More...
 
HAL_StatusTypeDef HAL_ADCEx_InjectedStart (ADC_HandleTypeDef *hadc)
 Enable ADC, start conversion of injected group. More...
 
HAL_StatusTypeDef HAL_ADCEx_InjectedStop (ADC_HandleTypeDef *hadc)
 Stop conversion of injected channels. Disable ADC peripheral if no regular conversion is on going. More...
 
HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion (ADC_HandleTypeDef *hadc, uint32_t Timeout)
 Wait for injected group conversion to be completed. More...
 
HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT (ADC_HandleTypeDef *hadc)
 Enable ADC, start conversion of injected group with interruption. More...
 
HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT (ADC_HandleTypeDef *hadc)
 Stop conversion of injected channels, disable interruption of end-of-conversion. Disable ADC peripheral if no regular conversion is on going. More...
 
HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA (ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length)
 Enable ADC, start MultiMode conversion and transfer regular results through DMA. More...
 
HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA (ADC_HandleTypeDef *hadc)
 Stop multimode ADC conversion, disable ADC DMA transfer, disable ADC peripheral. More...
 
uint32_t HAL_ADCEx_MultiModeGetValue (ADC_HandleTypeDef *hadc)
 Return the last ADC Master and Slave regular conversions results when in multimode configuration. More...
 
uint32_t HAL_ADCEx_InjectedGetValue (ADC_HandleTypeDef *hadc, uint32_t InjectedRank)
 Get ADC injected group conversion result. More...
 
void HAL_ADCEx_InjectedConvCpltCallback (ADC_HandleTypeDef *hadc)
 Injected conversion complete callback in non-blocking mode. More...
 
void HAL_ADCEx_InjectedQueueOverflowCallback (ADC_HandleTypeDef *hadc)
 Injected context queue overflow callback. More...
 
void HAL_ADCEx_LevelOutOfWindow2Callback (ADC_HandleTypeDef *hadc)
 Analog watchdog 2 callback in non-blocking mode. More...
 
void HAL_ADCEx_LevelOutOfWindow3Callback (ADC_HandleTypeDef *hadc)
 Analog watchdog 3 callback in non-blocking mode. More...
 
void HAL_ADCEx_EndOfSamplingCallback (ADC_HandleTypeDef *hadc)
 End Of Sampling callback in non-blocking mode. More...
 
HAL_StatusTypeDef HAL_ADCEx_RegularStop (ADC_HandleTypeDef *hadc)
 Stop ADC conversion of regular group (and injected channels in case of auto_injection mode), disable ADC peripheral if no conversion is on going on injected group. More...
 
HAL_StatusTypeDef HAL_ADCEx_RegularStop_IT (ADC_HandleTypeDef *hadc)
 Stop ADC conversion of ADC groups regular and injected, disable interrution of end-of-conversion, disable ADC peripheral if no conversion is on going on injected group. More...
 
HAL_StatusTypeDef HAL_ADCEx_RegularStop_DMA (ADC_HandleTypeDef *hadc)
 Stop ADC conversion of regular group (and injected group in case of auto_injection mode), disable ADC DMA transfer, disable ADC peripheral if no conversion is on going on injected group. More...
 
HAL_StatusTypeDef HAL_ADCEx_RegularMultiModeStop_DMA (ADC_HandleTypeDef *hadc)
 Stop DMA-based multimode ADC conversion, disable ADC DMA transfer, disable ADC peripheral if no injected conversion is on-going. More...
 

Detailed Description

Extended IO operation functions.

 ===============================================================================
                      ##### IO operation functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:

      (+) Perform the ADC self-calibration for single or differential ending.
      (+) Get calibration factors for single or differential ending.
      (+) Set calibration factors for single or differential ending.

      (+) Start conversion of ADC group injected.
      (+) Stop conversion of ADC group injected.
      (+) Poll for conversion complete on ADC group injected.
      (+) Get result of ADC group injected channel conversion.
      (+) Start conversion of ADC group injected and enable interruptions.
      (+) Stop conversion of ADC group injected and disable interruptions.

      (+) When multimode feature is available, start multimode and enable DMA transfer.
      (+) Stop multimode and disable ADC DMA transfer.
      (+) Get result of multimode conversion.

Function Documentation

◆ HAL_ADCEx_Calibration_GetValue()

uint32_t HAL_ADCEx_Calibration_GetValue ( ADC_HandleTypeDef hadc,
uint32_t  SingleDiff 
)

Get the calibration factor.

Parameters
hadcADC handle.
SingleDiffThis parameter can be only:
  • ADC_SINGLE_ENDED Channel in mode input single ended
  • ADC_DIFFERENTIAL_ENDED Channel in mode input differential ended
Return values
Calibrationvalue.

Definition at line 203 of file stm32l4xx_hal_adc_ex.c.

204 {
205  /* Check the parameters */
206  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
207  assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff));
208 
209  /* Return the selected ADC calibration value */
210  return LL_ADC_GetCalibrationFactor(hadc->Instance, SingleDiff);
211 }
__STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff)
Get ADC calibration factor in the mode single-ended or differential (for devices with differential mo...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_Calibration_SetValue()

HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue ( ADC_HandleTypeDef hadc,
uint32_t  SingleDiff,
uint32_t  CalibrationFactor 
)

Set the calibration factor to overwrite automatic conversion result. ADC must be enabled and no conversion is ongoing.

Parameters
hadcADC handle
SingleDiffThis parameter can be only:
  • ADC_SINGLE_ENDED Channel in mode input single ended
  • ADC_DIFFERENTIAL_ENDED Channel in mode input differential ended
CalibrationFactorCalibration factor (coded on 7 bits maximum)
Return values
HALstate

Definition at line 223 of file stm32l4xx_hal_adc_ex.c.

224 {
225  HAL_StatusTypeDef tmp_hal_status = HAL_OK;
226  uint32_t tmp_adc_is_conversion_on_going_regular;
227  uint32_t tmp_adc_is_conversion_on_going_injected;
228 
229  /* Check the parameters */
230  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
231  assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff));
232  assert_param(IS_ADC_CALFACT(CalibrationFactor));
233 
234  /* Process locked */
235  __HAL_LOCK(hadc);
236 
237  /* Verification of hardware constraints before modifying the calibration */
238  /* factors register: ADC must be enabled, no conversion on going. */
239  tmp_adc_is_conversion_on_going_regular = LL_ADC_REG_IsConversionOngoing(hadc->Instance);
240  tmp_adc_is_conversion_on_going_injected = LL_ADC_INJ_IsConversionOngoing(hadc->Instance);
241 
242  if ((LL_ADC_IsEnabled(hadc->Instance) != 0UL)
243  && (tmp_adc_is_conversion_on_going_regular == 0UL)
244  && (tmp_adc_is_conversion_on_going_injected == 0UL)
245  )
246  {
247  /* Set the selected ADC calibration value */
248  LL_ADC_SetCalibrationFactor(hadc->Instance, SingleDiff, CalibrationFactor);
249  }
250  else
251  {
252  /* Update ADC state machine */
253  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
254  /* Update ADC error code */
255  SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
256 
257  /* Update ADC state machine to error */
258  tmp_hal_status = HAL_ERROR;
259  }
260 
261  /* Process unlocked */
262  __HAL_UNLOCK(hadc);
263 
264  /* Return function status */
265  return tmp_hal_status;
266 }
__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
Get the selected ADC instance enable state.
__STATIC_INLINE void LL_ADC_SetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff, uint32_t CalibrationFactor)
Set ADC calibration factor in the mode single-ended or differential (for devices with differential mo...
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__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_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular conversion state. CR ADSTART LL_ADC_REG_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_Calibration_Start()

HAL_StatusTypeDef HAL_ADCEx_Calibration_Start ( ADC_HandleTypeDef hadc,
uint32_t  SingleDiff 
)

Perform an ADC automatic self-calibration Calibration prerequisite: ADC must be disabled (execute this function before HAL_ADC_Start() or after HAL_ADC_Stop() ).

Parameters
hadcADC handle
SingleDiffSelection of single-ended or differential input This parameter can be one of the following values:
  • ADC_SINGLE_ENDED Channel in mode input single ended
  • ADC_DIFFERENTIAL_ENDED Channel in mode input differential ended
Return values
HALstatus

Definition at line 129 of file stm32l4xx_hal_adc_ex.c.

130 {
131  HAL_StatusTypeDef tmp_hal_status;
132  __IO uint32_t wait_loop_index = 0UL;
133 
134  /* Check the parameters */
135  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
136  assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff));
137 
138  /* Process locked */
139  __HAL_LOCK(hadc);
140 
141  /* Calibration prerequisite: ADC must be disabled. */
142 
143  /* Disable the ADC (if not already disabled) */
144  tmp_hal_status = ADC_Disable(hadc);
145 
146  /* Check if ADC is effectively disabled */
147  if (tmp_hal_status == HAL_OK)
148  {
149  /* Set ADC state */
150  ADC_STATE_CLR_SET(hadc->State,
151  HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
152  HAL_ADC_STATE_BUSY_INTERNAL);
153 
154  /* Start ADC calibration in mode single-ended or differential */
155  LL_ADC_StartCalibration(hadc->Instance, SingleDiff);
156 
157  /* Wait for calibration completion */
158  while (LL_ADC_IsCalibrationOnGoing(hadc->Instance) != 0UL)
159  {
160  wait_loop_index++;
161  if (wait_loop_index >= ADC_CALIBRATION_TIMEOUT)
162  {
163  /* Update ADC state machine to error */
164  ADC_STATE_CLR_SET(hadc->State,
165  HAL_ADC_STATE_BUSY_INTERNAL,
166  HAL_ADC_STATE_ERROR_INTERNAL);
167 
168  /* Process unlocked */
169  __HAL_UNLOCK(hadc);
170 
171  return HAL_ERROR;
172  }
173  }
174 
175  /* Set ADC state */
176  ADC_STATE_CLR_SET(hadc->State,
177  HAL_ADC_STATE_BUSY_INTERNAL,
178  HAL_ADC_STATE_READY);
179  }
180  else
181  {
182  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
183 
184  /* Note: No need to update variable "tmp_hal_status" here: already set */
185  /* to state "HAL_ERROR" by function disabling the ADC. */
186  }
187 
188  /* Process unlocked */
189  __HAL_UNLOCK(hadc);
190 
191  /* Return function status */
192  return tmp_hal_status;
193 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
Get ADC calibration state. CR ADCAL LL_ADC_IsCalibrationOnGoing.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
__STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx, uint32_t SingleDiff)
Start ADC calibration in the mode single-ended or differential (for devices with differential mode av...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_EndOfSamplingCallback()

__weak void HAL_ADCEx_EndOfSamplingCallback ( ADC_HandleTypeDef hadc)

End Of Sampling callback in non-blocking mode.

Parameters
hadcADC handle
Return values
None

Definition at line 1235 of file stm32l4xx_hal_adc_ex.c.

1236 {
1237  /* Prevent unused argument(s) compilation warning */
1238  UNUSED(hadc);
1239 
1240  /* NOTE : This function should not be modified. When the callback is needed,
1241  function HAL_ADCEx_EndOfSamplingCallback must be implemented in the user file.
1242  */
1243 }

◆ HAL_ADCEx_InjectedConvCpltCallback()

__weak void HAL_ADCEx_InjectedConvCpltCallback ( ADC_HandleTypeDef hadc)

Injected conversion complete callback in non-blocking mode.

Parameters
hadcADC handle
Return values
None

Definition at line 1170 of file stm32l4xx_hal_adc_ex.c.

1171 {
1172  /* Prevent unused argument(s) compilation warning */
1173  UNUSED(hadc);
1174 
1175  /* NOTE : This function should not be modified. When the callback is needed,
1176  function HAL_ADCEx_InjectedConvCpltCallback must be implemented in the user file.
1177  */
1178 }

◆ HAL_ADCEx_InjectedGetValue()

uint32_t HAL_ADCEx_InjectedGetValue ( ADC_HandleTypeDef hadc,
uint32_t  InjectedRank 
)

Get ADC injected group conversion result.

Note
Reading register JDRx automatically clears ADC flag JEOC (ADC group injected end of unitary conversion).
This function does not clear ADC flag JEOS (ADC group injected end of sequence conversion) Occurrence of flag JEOS rising:
  • If sequencer is composed of 1 rank, flag JEOS is equivalent to flag JEOC.
  • If sequencer is composed of several ranks, during the scan sequence flag JEOC only is raised, at the end of the scan sequence both flags JEOC and EOS are raised. Flag JEOS must not be cleared by this function because it would not be compliant with low power features (feature low power auto-wait, not available on all STM32 families). To clear this flag, either use function: in programming model IT: HAL_ADC_IRQHandler(), in programming model polling: HAL_ADCEx_InjectedPollForConversion() or __HAL_ADC_CLEAR_FLAG(&hadc, ADC_FLAG_JEOS).
Parameters
hadcADC handle
InjectedRankthe converted ADC injected rank. This parameter can be one of the following values:
  • ADC_INJECTED_RANK_1 ADC group injected rank 1
  • ADC_INJECTED_RANK_2 ADC group injected rank 2
  • ADC_INJECTED_RANK_3 ADC group injected rank 3
  • ADC_INJECTED_RANK_4 ADC group injected rank 4
Return values
ADCgroup injected conversion data

Definition at line 1135 of file stm32l4xx_hal_adc_ex.c.

1136 {
1137  uint32_t tmp_jdr;
1138 
1139  /* Check the parameters */
1140  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
1141  assert_param(IS_ADC_INJECTED_RANK(InjectedRank));
1142 
1143  /* Get ADC converted value */
1144  switch (InjectedRank)
1145  {
1146  case ADC_INJECTED_RANK_4:
1147  tmp_jdr = hadc->Instance->JDR4;
1148  break;
1149  case ADC_INJECTED_RANK_3:
1150  tmp_jdr = hadc->Instance->JDR3;
1151  break;
1152  case ADC_INJECTED_RANK_2:
1153  tmp_jdr = hadc->Instance->JDR2;
1154  break;
1155  case ADC_INJECTED_RANK_1:
1156  default:
1157  tmp_jdr = hadc->Instance->JDR1;
1158  break;
1159  }
1160 
1161  /* Return ADC converted value */
1162  return tmp_jdr;
1163 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_InjectedPollForConversion()

HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion ( ADC_HandleTypeDef hadc,
uint32_t  Timeout 
)

Wait for injected group conversion to be completed.

Parameters
hadcADC handle
TimeoutTimeout value in millisecond.
Note
Depending on hadc->Init.EOCSelection, JEOS or JEOC is checked and cleared depending on AUTDLY bit status.
Return values
HALstatus

Definition at line 483 of file stm32l4xx_hal_adc_ex.c.

484 {
485  uint32_t tickstart;
486  uint32_t tmp_Flag_End;
487  uint32_t tmp_adc_inj_is_trigger_source_sw_start;
488  uint32_t tmp_adc_reg_is_trigger_source_sw_start;
489  uint32_t tmp_cfgr;
490 #if defined(ADC_MULTIMODE_SUPPORT)
491  const ADC_TypeDef *tmpADC_Master;
492  uint32_t tmp_multimode_config = LL_ADC_GetMultimode(__LL_ADC_COMMON_INSTANCE(hadc->Instance));
493 #endif
494 
495  /* Check the parameters */
496  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
497 
498  /* If end of sequence selected */
499  if (hadc->Init.EOCSelection == ADC_EOC_SEQ_CONV)
500  {
501  tmp_Flag_End = ADC_FLAG_JEOS;
502  }
503  else /* end of conversion selected */
504  {
505  tmp_Flag_End = ADC_FLAG_JEOC;
506  }
507 
508  /* Get timeout */
509  tickstart = HAL_GetTick();
510 
511  /* Wait until End of Conversion or Sequence flag is raised */
512  while ((hadc->Instance->ISR & tmp_Flag_End) == 0UL)
513  {
514  /* Check if timeout is disabled (set to infinite wait) */
515  if (Timeout != HAL_MAX_DELAY)
516  {
517  if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0UL))
518  {
519  /* Update ADC state machine to timeout */
520  SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
521 
522  /* Process unlocked */
523  __HAL_UNLOCK(hadc);
524 
525  return HAL_TIMEOUT;
526  }
527  }
528  }
529 
530  /* Retrieve ADC configuration */
531  tmp_adc_inj_is_trigger_source_sw_start = LL_ADC_INJ_IsTriggerSourceSWStart(hadc->Instance);
532  tmp_adc_reg_is_trigger_source_sw_start = LL_ADC_REG_IsTriggerSourceSWStart(hadc->Instance);
533  /* Get relevant register CFGR in ADC instance of ADC master or slave */
534  /* in function of multimode state (for devices with multimode */
535  /* available). */
536 #if defined(ADC_MULTIMODE_SUPPORT)
537  if ((__LL_ADC_MULTI_INSTANCE_MASTER(hadc->Instance) == hadc->Instance)
538  || (tmp_multimode_config == LL_ADC_MULTI_INDEPENDENT)
539  || (tmp_multimode_config == LL_ADC_MULTI_DUAL_REG_SIMULT)
540  || (tmp_multimode_config == LL_ADC_MULTI_DUAL_REG_INTERL)
541  )
542  {
543  tmp_cfgr = READ_REG(hadc->Instance->CFGR);
544  }
545  else
546  {
547  tmpADC_Master = __LL_ADC_MULTI_INSTANCE_MASTER(hadc->Instance);
548  tmp_cfgr = READ_REG(tmpADC_Master->CFGR);
549  }
550 #else
551  tmp_cfgr = READ_REG(hadc->Instance->CFGR);
552 #endif
553 
554  /* Update ADC state machine */
555  SET_BIT(hadc->State, HAL_ADC_STATE_INJ_EOC);
556 
557  /* Determine whether any further conversion upcoming on group injected */
558  /* by external trigger or by automatic injected conversion */
559  /* from group regular. */
560  if ((tmp_adc_inj_is_trigger_source_sw_start != 0UL) ||
561  ((READ_BIT(tmp_cfgr, ADC_CFGR_JAUTO) == 0UL) &&
562  ((tmp_adc_reg_is_trigger_source_sw_start != 0UL) &&
563  (READ_BIT(tmp_cfgr, ADC_CFGR_CONT) == 0UL))))
564  {
565  /* Check whether end of sequence is reached */
566  if (__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_JEOS))
567  {
568  /* Particular case if injected contexts queue is enabled: */
569  /* when the last context has been fully processed, JSQR is reset */
570  /* by the hardware. Even if no injected conversion is planned to come */
571  /* (queue empty, triggers are ignored), it can start again */
572  /* immediately after setting a new context (JADSTART is still set). */
573  /* Therefore, state of HAL ADC injected group is kept to busy. */
574  if (READ_BIT(tmp_cfgr, ADC_CFGR_JQM) == 0UL)
575  {
576  /* Set ADC state */
577  CLEAR_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
578 
579  if ((hadc->State & HAL_ADC_STATE_REG_BUSY) == 0UL)
580  {
581  SET_BIT(hadc->State, HAL_ADC_STATE_READY);
582  }
583  }
584  }
585  }
586 
587  /* Clear polled flag */
588  if (tmp_Flag_End == ADC_FLAG_JEOS)
589  {
590  /* Clear end of sequence JEOS flag of injected group if low power feature */
591  /* "LowPowerAutoWait " is disabled, to not interfere with this feature. */
592  /* For injected groups, no new conversion will start before JEOS is */
593  /* cleared. */
594  if (READ_BIT(tmp_cfgr, ADC_CFGR_AUTDLY) == 0UL)
595  {
596  __HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_JEOC | ADC_FLAG_JEOS));
597  }
598  }
599  else
600  {
601  __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JEOC);
602  }
603 
604  /* Return API HAL status */
605  return HAL_OK;
606 }
__STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
Get ADC group regular conversion trigger source internal (SW start) or external.
__STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON)
Get ADC multimode configuration to operate in independent mode or multimode (for devices with several...
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
Get ADC group injected conversion trigger source internal (SW start) or external. ...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_InjectedQueueOverflowCallback()

__weak void HAL_ADCEx_InjectedQueueOverflowCallback ( ADC_HandleTypeDef hadc)

Injected context queue overflow callback.

Note
This callback is called if injected context queue is enabled (parameter "QueueInjectedContext" in injected channel configuration) and if a new injected context is set when queue is full (maximum 2 contexts).
Parameters
hadcADC handle
Return values
None

Definition at line 1189 of file stm32l4xx_hal_adc_ex.c.

1190 {
1191  /* Prevent unused argument(s) compilation warning */
1192  UNUSED(hadc);
1193 
1194  /* NOTE : This function should not be modified. When the callback is needed,
1195  function HAL_ADCEx_InjectedQueueOverflowCallback must be implemented in the user file.
1196  */
1197 }

◆ HAL_ADCEx_InjectedStart()

HAL_StatusTypeDef HAL_ADCEx_InjectedStart ( ADC_HandleTypeDef hadc)

Enable ADC, start conversion of injected group.

Note
Interruptions enabled in this function: None.
Case of multimode enabled when multimode feature is available: HAL_ADCEx_InjectedStart() API must be called for ADC slave first, then for ADC master. For ADC slave, ADC is enabled only (conversion is not started). For ADC master, ADC is enabled and multimode conversion is started.
Parameters
hadcADC handle.
Return values
HALstatus

Definition at line 279 of file stm32l4xx_hal_adc_ex.c.

280 {
281  HAL_StatusTypeDef tmp_hal_status;
282  uint32_t tmp_config_injected_queue;
283 #if defined(ADC_MULTIMODE_SUPPORT)
284  uint32_t tmp_multimode_config = LL_ADC_GetMultimode(__LL_ADC_COMMON_INSTANCE(hadc->Instance));
285 #endif
286 
287  /* Check the parameters */
288  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
289 
290  if (LL_ADC_INJ_IsConversionOngoing(hadc->Instance) != 0UL)
291  {
292  return HAL_BUSY;
293  }
294  else
295  {
296  /* In case of software trigger detection enabled, JQDIS must be set
297  (which can be done only if ADSTART and JADSTART are both cleared).
298  If JQDIS is not set at that point, returns an error
299  - since software trigger detection is disabled. User needs to
300  resort to HAL_ADCEx_DisableInjectedQueue() API to set JQDIS.
301  - or (if JQDIS is intentionally reset) since JEXTEN = 0 which means
302  the queue is empty */
303  tmp_config_injected_queue = READ_BIT(hadc->Instance->CFGR, ADC_CFGR_JQDIS);
304 
305  if ((READ_BIT(hadc->Instance->JSQR, ADC_JSQR_JEXTEN) == 0UL)
306  && (tmp_config_injected_queue == 0UL)
307  )
308  {
309  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
310  return HAL_ERROR;
311  }
312 
313  /* Process locked */
314  __HAL_LOCK(hadc);
315 
316  /* Enable the ADC peripheral */
317  tmp_hal_status = ADC_Enable(hadc);
318 
319  /* Start conversion if ADC is effectively enabled */
320  if (tmp_hal_status == HAL_OK)
321  {
322  /* Check if a regular conversion is ongoing */
323  if ((hadc->State & HAL_ADC_STATE_REG_BUSY) != 0UL)
324  {
325  /* Reset ADC error code field related to injected conversions only */
326  CLEAR_BIT(hadc->ErrorCode, HAL_ADC_ERROR_JQOVF);
327  }
328  else
329  {
330  /* Set ADC error code to none */
331  ADC_CLEAR_ERRORCODE(hadc);
332  }
333 
334  /* Set ADC state */
335  /* - Clear state bitfield related to injected group conversion results */
336  /* - Set state bitfield related to injected operation */
337  ADC_STATE_CLR_SET(hadc->State,
338  HAL_ADC_STATE_READY | HAL_ADC_STATE_INJ_EOC,
339  HAL_ADC_STATE_INJ_BUSY);
340 
341 #if defined(ADC_MULTIMODE_SUPPORT)
342  /* Reset HAL_ADC_STATE_MULTIMODE_SLAVE bit
343  - if ADC instance is master or if multimode feature is not available
344  - if multimode setting is disabled (ADC instance slave in independent mode) */
345  if ((__LL_ADC_MULTI_INSTANCE_MASTER(hadc->Instance) == hadc->Instance)
346  || (tmp_multimode_config == LL_ADC_MULTI_INDEPENDENT)
347  )
348  {
349  CLEAR_BIT(hadc->State, HAL_ADC_STATE_MULTIMODE_SLAVE);
350  }
351 #endif
352 
353  /* Clear ADC group injected group conversion flag */
354  /* (To ensure of no unknown state from potential previous ADC operations) */
355  __HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_JEOC | ADC_FLAG_JEOS));
356 
357  /* Process unlocked */
358  /* Unlock before starting ADC conversions: in case of potential */
359  /* interruption, to let the process to ADC IRQ Handler. */
360  __HAL_UNLOCK(hadc);
361 
362  /* Enable conversion of injected group, if automatic injected conversion */
363  /* is disabled. */
364  /* If software start has been selected, conversion starts immediately. */
365  /* If external trigger has been selected, conversion will start at next */
366  /* trigger event. */
367  /* Case of multimode enabled (when multimode feature is available): */
368  /* if ADC is slave, */
369  /* - ADC is enabled only (conversion is not started), */
370  /* - if multimode only concerns regular conversion, ADC is enabled */
371  /* and conversion is started. */
372  /* If ADC is master or independent, */
373  /* - ADC is enabled and conversion is started. */
374 #if defined(ADC_MULTIMODE_SUPPORT)
375  if ((__LL_ADC_MULTI_INSTANCE_MASTER(hadc->Instance) == hadc->Instance)
376  || (tmp_multimode_config == LL_ADC_MULTI_INDEPENDENT)
377  || (tmp_multimode_config == LL_ADC_MULTI_DUAL_REG_SIMULT)
378  || (tmp_multimode_config == LL_ADC_MULTI_DUAL_REG_INTERL)
379  )
380  {
381  /* ADC instance is not a multimode slave instance with multimode injected conversions enabled */
382  if (LL_ADC_INJ_GetTrigAuto(hadc->Instance) == LL_ADC_INJ_TRIG_INDEPENDENT)
383  {
384  LL_ADC_INJ_StartConversion(hadc->Instance);
385  }
386  }
387  else
388  {
389  /* ADC instance is not a multimode slave instance with multimode injected conversions enabled */
390  SET_BIT(hadc->State, HAL_ADC_STATE_MULTIMODE_SLAVE);
391  }
392 #else
393  if (LL_ADC_INJ_GetTrigAuto(hadc->Instance) == LL_ADC_INJ_TRIG_INDEPENDENT)
394  {
395  /* Start ADC group injected conversion */
396  LL_ADC_INJ_StartConversion(hadc->Instance);
397  }
398 #endif
399 
400  }
401  else
402  {
403  /* Process unlocked */
404  __HAL_UNLOCK(hadc);
405  }
406 
407  /* Return function status */
408  return tmp_hal_status;
409  }
410 }
__STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON)
Get ADC multimode configuration to operate in independent mode or multimode (for devices with several...
__HAL_UNLOCK(hrtc)
HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef *hadc)
Enable the selected ADC.
__STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
Get ADC group injected conversion trigger: independent or from ADC group regular. CFGR JAUTO LL_ADC_...
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected conversion state. CR JADSTART LL_ADC_INJ_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
Start ADC group injected conversion.

◆ HAL_ADCEx_InjectedStart_IT()

HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT ( ADC_HandleTypeDef hadc)

Enable ADC, start conversion of injected group with interruption.

Note
Interruptions enabled in this function according to initialization setting : JEOC (end of conversion) or JEOS (end of sequence)
Case of multimode enabled (when multimode feature is enabled): HAL_ADCEx_InjectedStart_IT() API must be called for ADC slave first, then for ADC master. For ADC slave, ADC is enabled only (conversion is not started). For ADC master, ADC is enabled and multimode conversion is started.
Parameters
hadcADC handle.
Return values
HALstatus.

Definition at line 620 of file stm32l4xx_hal_adc_ex.c.

621 {
622  HAL_StatusTypeDef tmp_hal_status;
623  uint32_t tmp_config_injected_queue;
624 #if defined(ADC_MULTIMODE_SUPPORT)
625  uint32_t tmp_multimode_config = LL_ADC_GetMultimode(__LL_ADC_COMMON_INSTANCE(hadc->Instance));
626 #endif
627 
628  /* Check the parameters */
629  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
630 
631  if (LL_ADC_INJ_IsConversionOngoing(hadc->Instance) != 0UL)
632  {
633  return HAL_BUSY;
634  }
635  else
636  {
637  /* In case of software trigger detection enabled, JQDIS must be set
638  (which can be done only if ADSTART and JADSTART are both cleared).
639  If JQDIS is not set at that point, returns an error
640  - since software trigger detection is disabled. User needs to
641  resort to HAL_ADCEx_DisableInjectedQueue() API to set JQDIS.
642  - or (if JQDIS is intentionally reset) since JEXTEN = 0 which means
643  the queue is empty */
644  tmp_config_injected_queue = READ_BIT(hadc->Instance->CFGR, ADC_CFGR_JQDIS);
645 
646  if ((READ_BIT(hadc->Instance->JSQR, ADC_JSQR_JEXTEN) == 0UL)
647  && (tmp_config_injected_queue == 0UL)
648  )
649  {
650  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
651  return HAL_ERROR;
652  }
653 
654  /* Process locked */
655  __HAL_LOCK(hadc);
656 
657  /* Enable the ADC peripheral */
658  tmp_hal_status = ADC_Enable(hadc);
659 
660  /* Start conversion if ADC is effectively enabled */
661  if (tmp_hal_status == HAL_OK)
662  {
663  /* Check if a regular conversion is ongoing */
664  if ((hadc->State & HAL_ADC_STATE_REG_BUSY) != 0UL)
665  {
666  /* Reset ADC error code field related to injected conversions only */
667  CLEAR_BIT(hadc->ErrorCode, HAL_ADC_ERROR_JQOVF);
668  }
669  else
670  {
671  /* Set ADC error code to none */
672  ADC_CLEAR_ERRORCODE(hadc);
673  }
674 
675  /* Set ADC state */
676  /* - Clear state bitfield related to injected group conversion results */
677  /* - Set state bitfield related to injected operation */
678  ADC_STATE_CLR_SET(hadc->State,
679  HAL_ADC_STATE_READY | HAL_ADC_STATE_INJ_EOC,
680  HAL_ADC_STATE_INJ_BUSY);
681 
682 #if defined(ADC_MULTIMODE_SUPPORT)
683  /* Reset HAL_ADC_STATE_MULTIMODE_SLAVE bit
684  - if ADC instance is master or if multimode feature is not available
685  - if multimode setting is disabled (ADC instance slave in independent mode) */
686  if ((__LL_ADC_MULTI_INSTANCE_MASTER(hadc->Instance) == hadc->Instance)
687  || (tmp_multimode_config == LL_ADC_MULTI_INDEPENDENT)
688  )
689  {
690  CLEAR_BIT(hadc->State, HAL_ADC_STATE_MULTIMODE_SLAVE);
691  }
692 #endif
693 
694  /* Clear ADC group injected group conversion flag */
695  /* (To ensure of no unknown state from potential previous ADC operations) */
696  __HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_JEOC | ADC_FLAG_JEOS));
697 
698  /* Process unlocked */
699  /* Unlock before starting ADC conversions: in case of potential */
700  /* interruption, to let the process to ADC IRQ Handler. */
701  __HAL_UNLOCK(hadc);
702 
703  /* Enable ADC Injected context queue overflow interrupt if this feature */
704  /* is enabled. */
705  if ((hadc->Instance->CFGR & ADC_CFGR_JQM) != 0UL)
706  {
707  __HAL_ADC_ENABLE_IT(hadc, ADC_FLAG_JQOVF);
708  }
709 
710  /* Enable ADC end of conversion interrupt */
711  switch (hadc->Init.EOCSelection)
712  {
713  case ADC_EOC_SEQ_CONV:
714  __HAL_ADC_DISABLE_IT(hadc, ADC_IT_JEOC);
715  __HAL_ADC_ENABLE_IT(hadc, ADC_IT_JEOS);
716  break;
717  /* case ADC_EOC_SINGLE_CONV */
718  default:
719  __HAL_ADC_DISABLE_IT(hadc, ADC_IT_JEOS);
720  __HAL_ADC_ENABLE_IT(hadc, ADC_IT_JEOC);
721  break;
722  }
723 
724  /* Enable conversion of injected group, if automatic injected conversion */
725  /* is disabled. */
726  /* If software start has been selected, conversion starts immediately. */
727  /* If external trigger has been selected, conversion will start at next */
728  /* trigger event. */
729  /* Case of multimode enabled (when multimode feature is available): */
730  /* if ADC is slave, */
731  /* - ADC is enabled only (conversion is not started), */
732  /* - if multimode only concerns regular conversion, ADC is enabled */
733  /* and conversion is started. */
734  /* If ADC is master or independent, */
735  /* - ADC is enabled and conversion is started. */
736 #if defined(ADC_MULTIMODE_SUPPORT)
737  if ((__LL_ADC_MULTI_INSTANCE_MASTER(hadc->Instance) == hadc->Instance)
738  || (tmp_multimode_config == LL_ADC_MULTI_INDEPENDENT)
739  || (tmp_multimode_config == LL_ADC_MULTI_DUAL_REG_SIMULT)
740  || (tmp_multimode_config == LL_ADC_MULTI_DUAL_REG_INTERL)
741  )
742  {
743  /* ADC instance is not a multimode slave instance with multimode injected conversions enabled */
744  if (LL_ADC_INJ_GetTrigAuto(hadc->Instance) == LL_ADC_INJ_TRIG_INDEPENDENT)
745  {
746  LL_ADC_INJ_StartConversion(hadc->Instance);
747  }
748  }
749  else
750  {
751  /* ADC instance is not a multimode slave instance with multimode injected conversions enabled */
752  SET_BIT(hadc->State, HAL_ADC_STATE_MULTIMODE_SLAVE);
753  }
754 #else
755  if (LL_ADC_INJ_GetTrigAuto(hadc->Instance) == LL_ADC_INJ_TRIG_INDEPENDENT)
756  {
757  /* Start ADC group injected conversion */
758  LL_ADC_INJ_StartConversion(hadc->Instance);
759  }
760 #endif
761 
762  }
763  else
764  {
765  /* Process unlocked */
766  __HAL_UNLOCK(hadc);
767  }
768 
769  /* Return function status */
770  return tmp_hal_status;
771  }
772 }
__STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON)
Get ADC multimode configuration to operate in independent mode or multimode (for devices with several...
__HAL_UNLOCK(hrtc)
HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef *hadc)
Enable the selected ADC.
__STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
Get ADC group injected conversion trigger: independent or from ADC group regular. CFGR JAUTO LL_ADC_...
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected conversion state. CR JADSTART LL_ADC_INJ_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
Start ADC group injected conversion.

◆ HAL_ADCEx_InjectedStop()

HAL_StatusTypeDef HAL_ADCEx_InjectedStop ( ADC_HandleTypeDef hadc)

Stop conversion of injected channels. Disable ADC peripheral if no regular conversion is on going.

Note
If ADC must be disabled and if conversion is on going on regular group, function HAL_ADC_Stop must be used to stop both injected and regular groups, and disable the ADC.
If injected group mode auto-injection is enabled, function HAL_ADC_Stop must be used.
In case of multimode enabled (when multimode feature is available), HAL_ADCEx_InjectedStop() must be called for ADC master first, then for ADC slave. For ADC master, conversion is stopped and ADC is disabled. For ADC slave, ADC is disabled only (conversion stop of ADC master has already stopped conversion of ADC slave).
Parameters
hadcADC handle.
Return values
HALstatus

Definition at line 428 of file stm32l4xx_hal_adc_ex.c.

429 {
430  HAL_StatusTypeDef tmp_hal_status;
431 
432  /* Check the parameters */
433  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
434 
435  /* Process locked */
436  __HAL_LOCK(hadc);
437 
438  /* 1. Stop potential conversion on going on injected group only. */
439  tmp_hal_status = ADC_ConversionStop(hadc, ADC_INJECTED_GROUP);
440 
441  /* Disable ADC peripheral if injected conversions are effectively stopped */
442  /* and if no conversion on regular group is on-going */
443  if (tmp_hal_status == HAL_OK)
444  {
445  if (LL_ADC_REG_IsConversionOngoing(hadc->Instance) == 0UL)
446  {
447  /* 2. Disable the ADC peripheral */
448  tmp_hal_status = ADC_Disable(hadc);
449 
450  /* Check if ADC is effectively disabled */
451  if (tmp_hal_status == HAL_OK)
452  {
453  /* Set ADC state */
454  ADC_STATE_CLR_SET(hadc->State,
455  HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
456  HAL_ADC_STATE_READY);
457  }
458  }
459  /* Conversion on injected group is stopped, but ADC not disabled since */
460  /* conversion on regular group is still running. */
461  else
462  {
463  /* Set ADC state */
464  CLEAR_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
465  }
466  }
467 
468  /* Process unlocked */
469  __HAL_UNLOCK(hadc);
470 
471  /* Return function status */
472  return tmp_hal_status;
473 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup)
Stop ADC conversion.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
__STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular conversion state. CR ADSTART LL_ADC_REG_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_InjectedStop_IT()

HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT ( ADC_HandleTypeDef hadc)

Stop conversion of injected channels, disable interruption of end-of-conversion. Disable ADC peripheral if no regular conversion is on going.

Note
If ADC must be disabled and if conversion is on going on regular group, function HAL_ADC_Stop must be used to stop both injected and regular groups, and disable the ADC.
If injected group mode auto-injection is enabled, function HAL_ADC_Stop must be used.
Case of multimode enabled (when multimode feature is available): HAL_ADCEx_InjectedStop_IT() API must be called for ADC master first, then for ADC slave. For ADC master, conversion is stopped and ADC is disabled. For ADC slave, ADC is disabled only (conversion stop of ADC master has already stopped conversion of ADC slave).
In case of auto-injection mode, HAL_ADC_Stop() must be used.
Parameters
hadcADC handle
Return values
HALstatus

Definition at line 793 of file stm32l4xx_hal_adc_ex.c.

794 {
795  HAL_StatusTypeDef tmp_hal_status;
796 
797  /* Check the parameters */
798  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
799 
800  /* Process locked */
801  __HAL_LOCK(hadc);
802 
803  /* 1. Stop potential conversion on going on injected group only. */
804  tmp_hal_status = ADC_ConversionStop(hadc, ADC_INJECTED_GROUP);
805 
806  /* Disable ADC peripheral if injected conversions are effectively stopped */
807  /* and if no conversion on the other group (regular group) is intended to */
808  /* continue. */
809  if (tmp_hal_status == HAL_OK)
810  {
811  /* Disable ADC end of conversion interrupt for injected channels */
812  __HAL_ADC_DISABLE_IT(hadc, (ADC_IT_JEOC | ADC_IT_JEOS | ADC_FLAG_JQOVF));
813 
814  if (LL_ADC_REG_IsConversionOngoing(hadc->Instance) == 0UL)
815  {
816  /* 2. Disable the ADC peripheral */
817  tmp_hal_status = ADC_Disable(hadc);
818 
819  /* Check if ADC is effectively disabled */
820  if (tmp_hal_status == HAL_OK)
821  {
822  /* Set ADC state */
823  ADC_STATE_CLR_SET(hadc->State,
824  HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
825  HAL_ADC_STATE_READY);
826  }
827  }
828  /* Conversion on injected group is stopped, but ADC not disabled since */
829  /* conversion on regular group is still running. */
830  else
831  {
832  /* Set ADC state */
833  CLEAR_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
834  }
835  }
836 
837  /* Process unlocked */
838  __HAL_UNLOCK(hadc);
839 
840  /* Return function status */
841  return tmp_hal_status;
842 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup)
Stop ADC conversion.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
__STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular conversion state. CR ADSTART LL_ADC_REG_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_LevelOutOfWindow2Callback()

__weak void HAL_ADCEx_LevelOutOfWindow2Callback ( ADC_HandleTypeDef hadc)

Analog watchdog 2 callback in non-blocking mode.

Parameters
hadcADC handle
Return values
None

Definition at line 1204 of file stm32l4xx_hal_adc_ex.c.

1205 {
1206  /* Prevent unused argument(s) compilation warning */
1207  UNUSED(hadc);
1208 
1209  /* NOTE : This function should not be modified. When the callback is needed,
1210  function HAL_ADCEx_LevelOutOfWindow2Callback must be implemented in the user file.
1211  */
1212 }

◆ HAL_ADCEx_LevelOutOfWindow3Callback()

__weak void HAL_ADCEx_LevelOutOfWindow3Callback ( ADC_HandleTypeDef hadc)

Analog watchdog 3 callback in non-blocking mode.

Parameters
hadcADC handle
Return values
None

Definition at line 1219 of file stm32l4xx_hal_adc_ex.c.

1220 {
1221  /* Prevent unused argument(s) compilation warning */
1222  UNUSED(hadc);
1223 
1224  /* NOTE : This function should not be modified. When the callback is needed,
1225  function HAL_ADCEx_LevelOutOfWindow3Callback must be implemented in the user file.
1226  */
1227 }

◆ HAL_ADCEx_MultiModeGetValue()

uint32_t HAL_ADCEx_MultiModeGetValue ( ADC_HandleTypeDef hadc)

Return the last ADC Master and Slave regular conversions results when in multimode configuration.

Parameters
hadcADC handle of ADC Master (handle of ADC Slave must not be used)
Return values
Theconverted data values.

Definition at line 1088 of file stm32l4xx_hal_adc_ex.c.

1089 {
1090  const ADC_Common_TypeDef *tmpADC_Common;
1091 
1092  /* Check the parameters */
1093  assert_param(IS_ADC_MULTIMODE_MASTER_INSTANCE(hadc->Instance));
1094 
1095  /* Prevent unused argument(s) compilation warning if no assert_param check */
1096  /* and possible no usage in __LL_ADC_COMMON_INSTANCE() below */
1097  UNUSED(hadc);
1098 
1099  /* Pointer to the common control register */
1100  tmpADC_Common = __LL_ADC_COMMON_INSTANCE(hadc->Instance);
1101 
1102  /* Return the multi mode conversion value */
1103  return tmpADC_Common->CDR;
1104 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_MultiModeStart_DMA()

HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA ( ADC_HandleTypeDef hadc,
uint32_t *  pData,
uint32_t  Length 
)

Enable ADC, start MultiMode conversion and transfer regular results through DMA.

Note
Multimode must have been previously configured using HAL_ADCEx_MultiModeConfigChannel() function. Interruptions enabled in this function: overrun, DMA half transfer, DMA transfer complete. Each of these interruptions has its dedicated callback function.
State field of Slave ADC handle is not updated in this configuration: user should not rely on it for information related to Slave regular conversions.
Parameters
hadcADC handle of ADC master (handle of ADC slave must not be used)
pDataDestination Buffer address.
LengthLength of data to be transferred from ADC peripheral to memory (in bytes).
Return values
HALstatus

Definition at line 860 of file stm32l4xx_hal_adc_ex.c.

861 {
862  HAL_StatusTypeDef tmp_hal_status;
863  ADC_HandleTypeDef tmphadcSlave;
864  ADC_Common_TypeDef *tmpADC_Common;
865 
866  /* Check the parameters */
867  assert_param(IS_ADC_MULTIMODE_MASTER_INSTANCE(hadc->Instance));
868  assert_param(IS_FUNCTIONAL_STATE(hadc->Init.ContinuousConvMode));
869  assert_param(IS_ADC_EXTTRIG_EDGE(hadc->Init.ExternalTrigConvEdge));
870  assert_param(IS_FUNCTIONAL_STATE(hadc->Init.DMAContinuousRequests));
871 
872  if (LL_ADC_REG_IsConversionOngoing(hadc->Instance) != 0UL)
873  {
874  return HAL_BUSY;
875  }
876  else
877  {
878  /* Process locked */
879  __HAL_LOCK(hadc);
880 
881  /* Set a temporary handle of the ADC slave associated to the ADC master */
882  ADC_MULTI_SLAVE(hadc, &tmphadcSlave);
883 
884  if (tmphadcSlave.Instance == NULL)
885  {
886  /* Set ADC state */
887  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
888 
889  /* Process unlocked */
890  __HAL_UNLOCK(hadc);
891 
892  return HAL_ERROR;
893  }
894 
895  /* Enable the ADC peripherals: master and slave (in case if not already */
896  /* enabled previously) */
897  tmp_hal_status = ADC_Enable(hadc);
898  if (tmp_hal_status == HAL_OK)
899  {
900  tmp_hal_status = ADC_Enable(&tmphadcSlave);
901  }
902 
903  /* Start multimode conversion of ADCs pair */
904  if (tmp_hal_status == HAL_OK)
905  {
906  /* Set ADC state */
907  ADC_STATE_CLR_SET(hadc->State,
908  (HAL_ADC_STATE_READY | HAL_ADC_STATE_REG_EOC | HAL_ADC_STATE_REG_OVR | HAL_ADC_STATE_REG_EOSMP),
909  HAL_ADC_STATE_REG_BUSY);
910 
911  /* Set ADC error code to none */
912  ADC_CLEAR_ERRORCODE(hadc);
913 
914  /* Set the DMA transfer complete callback */
915  hadc->DMA_Handle->XferCpltCallback = ADC_DMAConvCplt;
916 
917  /* Set the DMA half transfer complete callback */
918  hadc->DMA_Handle->XferHalfCpltCallback = ADC_DMAHalfConvCplt;
919 
920  /* Set the DMA error callback */
921  hadc->DMA_Handle->XferErrorCallback = ADC_DMAError ;
922 
923  /* Pointer to the common control register */
924  tmpADC_Common = __LL_ADC_COMMON_INSTANCE(hadc->Instance);
925 
926  /* Manage ADC and DMA start: ADC overrun interruption, DMA start, ADC */
927  /* start (in case of SW start): */
928 
929  /* Clear regular group conversion flag and overrun flag */
930  /* (To ensure of no unknown state from potential previous ADC operations) */
931  __HAL_ADC_CLEAR_FLAG(hadc, (ADC_FLAG_EOC | ADC_FLAG_EOS | ADC_FLAG_OVR));
932 
933  /* Process unlocked */
934  /* Unlock before starting ADC conversions: in case of potential */
935  /* interruption, to let the process to ADC IRQ Handler. */
936  __HAL_UNLOCK(hadc);
937 
938  /* Enable ADC overrun interrupt */
939  __HAL_ADC_ENABLE_IT(hadc, ADC_IT_OVR);
940 
941  /* Start the DMA channel */
942  tmp_hal_status = HAL_DMA_Start_IT(hadc->DMA_Handle, (uint32_t)&tmpADC_Common->CDR, (uint32_t)pData, Length);
943 
944  /* Enable conversion of regular group. */
945  /* If software start has been selected, conversion starts immediately. */
946  /* If external trigger has been selected, conversion will start at next */
947  /* trigger event. */
948  /* Start ADC group regular conversion */
949  LL_ADC_REG_StartConversion(hadc->Instance);
950  }
951  else
952  {
953  /* Process unlocked */
954  __HAL_UNLOCK(hadc);
955  }
956 
957  /* Return function status */
958  return tmp_hal_status;
959  }
960 }
void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma)
DMA transfer complete callback.
void ADC_DMAError(DMA_HandleTypeDef *hdma)
DMA error callback.
__HAL_UNLOCK(hrtc)
__STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
Start ADC group regular conversion.
HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef *hadc)
Enable the selected ADC.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
__HAL_LOCK(hrtc)
struct __ADC_HandleTypeDef else typedef struct endif ADC_HandleTypeDef
ADC handle Structure definition.
return HAL_OK
void ADC_DMAHalfConvCplt(DMA_HandleTypeDef *hdma)
DMA half transfer complete callback.
__STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular conversion state. CR ADSTART LL_ADC_REG_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_MultiModeStop_DMA()

HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA ( ADC_HandleTypeDef hadc)

Stop multimode ADC conversion, disable ADC DMA transfer, disable ADC peripheral.

Note
Multimode is kept enabled after this function. MultiMode DMA bits (MDMA and DMACFG bits of common CCR register) are maintained. To disable Multimode (set with HAL_ADCEx_MultiModeConfigChannel()), ADC must be reinitialized using HAL_ADC_Init() or HAL_ADC_DeInit(), or the user can resort to HAL_ADCEx_DisableMultiMode() API.
In case of DMA configured in circular mode, function HAL_ADC_Stop_DMA() must be called after this function with handle of ADC slave, to properly disable the DMA channel.
Parameters
hadcADC handle of ADC master (handle of ADC slave must not be used)
Return values
HALstatus

Definition at line 975 of file stm32l4xx_hal_adc_ex.c.

976 {
977  HAL_StatusTypeDef tmp_hal_status;
978  uint32_t tickstart;
979  ADC_HandleTypeDef tmphadcSlave;
980  uint32_t tmphadcSlave_conversion_on_going;
981  HAL_StatusTypeDef tmphadcSlave_disable_status;
982 
983  /* Check the parameters */
984  assert_param(IS_ADC_MULTIMODE_MASTER_INSTANCE(hadc->Instance));
985 
986  /* Process locked */
987  __HAL_LOCK(hadc);
988 
989 
990  /* 1. Stop potential multimode conversion on going, on regular and injected groups */
991  tmp_hal_status = ADC_ConversionStop(hadc, ADC_REGULAR_INJECTED_GROUP);
992 
993  /* Disable ADC peripheral if conversions are effectively stopped */
994  if (tmp_hal_status == HAL_OK)
995  {
996  /* Set a temporary handle of the ADC slave associated to the ADC master */
997  ADC_MULTI_SLAVE(hadc, &tmphadcSlave);
998 
999  if (tmphadcSlave.Instance == NULL)
1000  {
1001  /* Update ADC state machine to error */
1002  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
1003 
1004  /* Process unlocked */
1005  __HAL_UNLOCK(hadc);
1006 
1007  return HAL_ERROR;
1008  }
1009 
1010  /* Procedure to disable the ADC peripheral: wait for conversions */
1011  /* effectively stopped (ADC master and ADC slave), then disable ADC */
1012 
1013  /* 1. Wait for ADC conversion completion for ADC master and ADC slave */
1014  tickstart = HAL_GetTick();
1015 
1016  tmphadcSlave_conversion_on_going = LL_ADC_REG_IsConversionOngoing((&tmphadcSlave)->Instance);
1017  while ((LL_ADC_REG_IsConversionOngoing(hadc->Instance) == 1UL)
1018  || (tmphadcSlave_conversion_on_going == 1UL)
1019  )
1020  {
1021  if ((HAL_GetTick() - tickstart) > ADC_STOP_CONVERSION_TIMEOUT)
1022  {
1023  /* Update ADC state machine to error */
1024  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
1025 
1026  /* Process unlocked */
1027  __HAL_UNLOCK(hadc);
1028 
1029  return HAL_ERROR;
1030  }
1031 
1032  tmphadcSlave_conversion_on_going = LL_ADC_REG_IsConversionOngoing((&tmphadcSlave)->Instance);
1033  }
1034 
1035  /* Disable the DMA channel (in case of DMA in circular mode or stop */
1036  /* while DMA transfer is on going) */
1037  /* Note: DMA channel of ADC slave should be stopped after this function */
1038  /* with HAL_ADC_Stop_DMA() API. */
1039  tmp_hal_status = HAL_DMA_Abort(hadc->DMA_Handle);
1040 
1041  /* Check if DMA channel effectively disabled */
1042  if (tmp_hal_status == HAL_ERROR)
1043  {
1044  /* Update ADC state machine to error */
1045  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_DMA);
1046  }
1047 
1048  /* Disable ADC overrun interrupt */
1049  __HAL_ADC_DISABLE_IT(hadc, ADC_IT_OVR);
1050 
1051  /* 2. Disable the ADC peripherals: master and slave */
1052  /* Update "tmp_hal_status" only if DMA channel disabling passed, to keep in */
1053  /* memory a potential failing status. */
1054  if (tmp_hal_status == HAL_OK)
1055  {
1056  tmphadcSlave_disable_status = ADC_Disable(&tmphadcSlave);
1057  if ((ADC_Disable(hadc) == HAL_OK) &&
1058  (tmphadcSlave_disable_status == HAL_OK))
1059  {
1060  tmp_hal_status = HAL_OK;
1061  }
1062  }
1063  else
1064  {
1065  /* In case of error, attempt to disable ADC master and slave without status assert */
1066  (void) ADC_Disable(hadc);
1067  (void) ADC_Disable(&tmphadcSlave);
1068  }
1069 
1070  /* Set ADC state (ADC master) */
1071  ADC_STATE_CLR_SET(hadc->State,
1072  HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
1073  HAL_ADC_STATE_READY);
1074  }
1075 
1076  /* Process unlocked */
1077  __HAL_UNLOCK(hadc);
1078 
1079  /* Return function status */
1080  return tmp_hal_status;
1081 }
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
struct __ADC_HandleTypeDef else typedef struct endif ADC_HandleTypeDef
ADC handle Structure definition.
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup)
Stop ADC conversion.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
__STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular conversion state. CR ADSTART LL_ADC_REG_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_RegularMultiModeStop_DMA()

HAL_StatusTypeDef HAL_ADCEx_RegularMultiModeStop_DMA ( ADC_HandleTypeDef hadc)

Stop DMA-based multimode ADC conversion, disable ADC DMA transfer, disable ADC peripheral if no injected conversion is on-going.

Note
Multimode is kept enabled after this function. Multimode DMA bits (MDMA and DMACFG bits of common CCR register) are maintained. To disable multimode (set with HAL_ADCEx_MultiModeConfigChannel()), ADC must be reinitialized using HAL_ADC_Init() or HAL_ADC_DeInit(), or the user can resort to HAL_ADCEx_DisableMultiMode() API.
In case of DMA configured in circular mode, function HAL_ADCEx_RegularStop_DMA() must be called after this function with handle of ADC slave, to properly disable the DMA channel.
Parameters
hadcADC handle of ADC master (handle of ADC slave must not be used)
Return values
HALstatus

Definition at line 1457 of file stm32l4xx_hal_adc_ex.c.

1458 {
1459  HAL_StatusTypeDef tmp_hal_status;
1460  uint32_t tickstart;
1461  ADC_HandleTypeDef tmphadcSlave;
1462  uint32_t tmphadcSlave_conversion_on_going;
1463 
1464  /* Check the parameters */
1465  assert_param(IS_ADC_MULTIMODE_MASTER_INSTANCE(hadc->Instance));
1466 
1467  /* Process locked */
1468  __HAL_LOCK(hadc);
1469 
1470 
1471  /* 1. Stop potential multimode conversion on going, on regular groups */
1472  tmp_hal_status = ADC_ConversionStop(hadc, ADC_REGULAR_GROUP);
1473 
1474  /* Disable ADC peripheral if conversions are effectively stopped */
1475  if (tmp_hal_status == HAL_OK)
1476  {
1477  /* Clear HAL_ADC_STATE_REG_BUSY bit */
1478  CLEAR_BIT(hadc->State, HAL_ADC_STATE_REG_BUSY);
1479 
1480  /* Set a temporary handle of the ADC slave associated to the ADC master */
1481  ADC_MULTI_SLAVE(hadc, &tmphadcSlave);
1482 
1483  if (tmphadcSlave.Instance == NULL)
1484  {
1485  /* Update ADC state machine to error */
1486  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
1487 
1488  /* Process unlocked */
1489  __HAL_UNLOCK(hadc);
1490 
1491  return HAL_ERROR;
1492  }
1493 
1494  /* Procedure to disable the ADC peripheral: wait for conversions */
1495  /* effectively stopped (ADC master and ADC slave), then disable ADC */
1496 
1497  /* 1. Wait for ADC conversion completion for ADC master and ADC slave */
1498  tickstart = HAL_GetTick();
1499 
1500  tmphadcSlave_conversion_on_going = LL_ADC_REG_IsConversionOngoing((&tmphadcSlave)->Instance);
1501  while ((LL_ADC_REG_IsConversionOngoing(hadc->Instance) == 1UL)
1502  || (tmphadcSlave_conversion_on_going == 1UL)
1503  )
1504  {
1505  if ((HAL_GetTick() - tickstart) > ADC_STOP_CONVERSION_TIMEOUT)
1506  {
1507  /* Update ADC state machine to error */
1508  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
1509 
1510  /* Process unlocked */
1511  __HAL_UNLOCK(hadc);
1512 
1513  return HAL_ERROR;
1514  }
1515 
1516  tmphadcSlave_conversion_on_going = LL_ADC_REG_IsConversionOngoing((&tmphadcSlave)->Instance);
1517  }
1518 
1519  /* Disable the DMA channel (in case of DMA in circular mode or stop */
1520  /* while DMA transfer is on going) */
1521  /* Note: DMA channel of ADC slave should be stopped after this function */
1522  /* with HAL_ADCEx_RegularStop_DMA() API. */
1523  tmp_hal_status = HAL_DMA_Abort(hadc->DMA_Handle);
1524 
1525  /* Check if DMA channel effectively disabled */
1526  if (tmp_hal_status != HAL_OK)
1527  {
1528  /* Update ADC state machine to error */
1529  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_DMA);
1530  }
1531 
1532  /* Disable ADC overrun interrupt */
1533  __HAL_ADC_DISABLE_IT(hadc, ADC_IT_OVR);
1534 
1535  /* 2. Disable the ADC peripherals: master and slave if no injected */
1536  /* conversion is on-going. */
1537  /* Update "tmp_hal_status" only if DMA channel disabling passed, to keep in */
1538  /* memory a potential failing status. */
1539  if (tmp_hal_status == HAL_OK)
1540  {
1541  if (LL_ADC_INJ_IsConversionOngoing(hadc->Instance) == 0UL)
1542  {
1543  tmp_hal_status = ADC_Disable(hadc);
1544  if (tmp_hal_status == HAL_OK)
1545  {
1546  if (LL_ADC_INJ_IsConversionOngoing((&tmphadcSlave)->Instance) == 0UL)
1547  {
1548  tmp_hal_status = ADC_Disable(&tmphadcSlave);
1549  }
1550  }
1551  }
1552 
1553  if (tmp_hal_status == HAL_OK)
1554  {
1555  /* Both Master and Slave ADC's could be disabled. Update Master State */
1556  /* Clear HAL_ADC_STATE_INJ_BUSY bit, set HAL_ADC_STATE_READY bit */
1557  ADC_STATE_CLR_SET(hadc->State, HAL_ADC_STATE_INJ_BUSY, HAL_ADC_STATE_READY);
1558  }
1559  else
1560  {
1561  /* injected (Master or Slave) conversions are still on-going,
1562  no Master State change */
1563  }
1564  }
1565  }
1566 
1567  /* Process unlocked */
1568  __HAL_UNLOCK(hadc);
1569 
1570  /* Return function status */
1571  return tmp_hal_status;
1572 }
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
struct __ADC_HandleTypeDef else typedef struct endif ADC_HandleTypeDef
ADC handle Structure definition.
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected conversion state. CR JADSTART LL_ADC_INJ_IsConversionOngoing.
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup)
Stop ADC conversion.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
__STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group regular conversion state. CR ADSTART LL_ADC_REG_IsConversionOngoing.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_RegularStop()

HAL_StatusTypeDef HAL_ADCEx_RegularStop ( ADC_HandleTypeDef hadc)

Stop ADC conversion of regular group (and injected channels in case of auto_injection mode), disable ADC peripheral if no conversion is on going on injected group.

Parameters
hadcADC handle
Return values
HALstatus.

Definition at line 1252 of file stm32l4xx_hal_adc_ex.c.

1253 {
1254  HAL_StatusTypeDef tmp_hal_status;
1255 
1256  /* Check the parameters */
1257  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
1258 
1259  /* Process locked */
1260  __HAL_LOCK(hadc);
1261 
1262  /* 1. Stop potential regular conversion on going */
1263  tmp_hal_status = ADC_ConversionStop(hadc, ADC_REGULAR_GROUP);
1264 
1265  /* Disable ADC peripheral if regular conversions are effectively stopped
1266  and if no injected conversions are on-going */
1267  if (tmp_hal_status == HAL_OK)
1268  {
1269  /* Clear HAL_ADC_STATE_REG_BUSY bit */
1270  CLEAR_BIT(hadc->State, HAL_ADC_STATE_REG_BUSY);
1271 
1272  if (LL_ADC_INJ_IsConversionOngoing(hadc->Instance) == 0UL)
1273  {
1274  /* 2. Disable the ADC peripheral */
1275  tmp_hal_status = ADC_Disable(hadc);
1276 
1277  /* Check if ADC is effectively disabled */
1278  if (tmp_hal_status == HAL_OK)
1279  {
1280  /* Set ADC state */
1281  ADC_STATE_CLR_SET(hadc->State,
1282  HAL_ADC_STATE_INJ_BUSY,
1283  HAL_ADC_STATE_READY);
1284  }
1285  }
1286  /* Conversion on injected group is stopped, but ADC not disabled since */
1287  /* conversion on regular group is still running. */
1288  else
1289  {
1290  SET_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
1291  }
1292  }
1293 
1294  /* Process unlocked */
1295  __HAL_UNLOCK(hadc);
1296 
1297  /* Return function status */
1298  return tmp_hal_status;
1299 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected conversion state. CR JADSTART LL_ADC_INJ_IsConversionOngoing.
HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup)
Stop ADC conversion.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_RegularStop_DMA()

HAL_StatusTypeDef HAL_ADCEx_RegularStop_DMA ( ADC_HandleTypeDef hadc)

Stop ADC conversion of regular group (and injected group in case of auto_injection mode), disable ADC DMA transfer, disable ADC peripheral if no conversion is on going on injected group.

Note
HAL_ADCEx_RegularStop_DMA() function is dedicated to single-ADC mode only. For multimode (when multimode feature is available), HAL_ADCEx_RegularMultiModeStop_DMA() API must be used.
Parameters
hadcADC handle
Return values
HALstatus.

Definition at line 1370 of file stm32l4xx_hal_adc_ex.c.

1371 {
1372  HAL_StatusTypeDef tmp_hal_status;
1373 
1374  /* Check the parameters */
1375  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
1376 
1377  /* Process locked */
1378  __HAL_LOCK(hadc);
1379 
1380  /* 1. Stop potential regular conversion on going */
1381  tmp_hal_status = ADC_ConversionStop(hadc, ADC_REGULAR_GROUP);
1382 
1383  /* Disable ADC peripheral if conversions are effectively stopped
1384  and if no injected conversion is on-going */
1385  if (tmp_hal_status == HAL_OK)
1386  {
1387  /* Clear HAL_ADC_STATE_REG_BUSY bit */
1388  CLEAR_BIT(hadc->State, HAL_ADC_STATE_REG_BUSY);
1389 
1390  /* Disable ADC DMA (ADC DMA configuration ADC_CFGR_DMACFG is kept) */
1391  CLEAR_BIT(hadc->Instance->CFGR, ADC_CFGR_DMAEN);
1392 
1393  /* Disable the DMA channel (in case of DMA in circular mode or stop while */
1394  /* while DMA transfer is on going) */
1395  tmp_hal_status = HAL_DMA_Abort(hadc->DMA_Handle);
1396 
1397  /* Check if DMA channel effectively disabled */
1398  if (tmp_hal_status != HAL_OK)
1399  {
1400  /* Update ADC state machine to error */
1401  SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_DMA);
1402  }
1403 
1404  /* Disable ADC overrun interrupt */
1405  __HAL_ADC_DISABLE_IT(hadc, ADC_IT_OVR);
1406 
1407  /* 2. Disable the ADC peripheral */
1408  /* Update "tmp_hal_status" only if DMA channel disabling passed, */
1409  /* to keep in memory a potential failing status. */
1410  if (LL_ADC_INJ_IsConversionOngoing(hadc->Instance) == 0UL)
1411  {
1412  if (tmp_hal_status == HAL_OK)
1413  {
1414  tmp_hal_status = ADC_Disable(hadc);
1415  }
1416  else
1417  {
1418  (void)ADC_Disable(hadc);
1419  }
1420 
1421  /* Check if ADC is effectively disabled */
1422  if (tmp_hal_status == HAL_OK)
1423  {
1424  /* Set ADC state */
1425  ADC_STATE_CLR_SET(hadc->State,
1426  HAL_ADC_STATE_INJ_BUSY,
1427  HAL_ADC_STATE_READY);
1428  }
1429  }
1430  else
1431  {
1432  SET_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
1433  }
1434  }
1435 
1436  /* Process unlocked */
1437  __HAL_UNLOCK(hadc);
1438 
1439  /* Return function status */
1440  return tmp_hal_status;
1441 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected conversion state. CR JADSTART LL_ADC_INJ_IsConversionOngoing.
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup)
Stop ADC conversion.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_ADCEx_RegularStop_IT()

HAL_StatusTypeDef HAL_ADCEx_RegularStop_IT ( ADC_HandleTypeDef hadc)

Stop ADC conversion of ADC groups regular and injected, disable interrution of end-of-conversion, disable ADC peripheral if no conversion is on going on injected group.

Parameters
hadcADC handle
Return values
HALstatus.

Definition at line 1310 of file stm32l4xx_hal_adc_ex.c.

1311 {
1312  HAL_StatusTypeDef tmp_hal_status;
1313 
1314  /* Check the parameters */
1315  assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
1316 
1317  /* Process locked */
1318  __HAL_LOCK(hadc);
1319 
1320  /* 1. Stop potential regular conversion on going */
1321  tmp_hal_status = ADC_ConversionStop(hadc, ADC_REGULAR_GROUP);
1322 
1323  /* Disable ADC peripheral if conversions are effectively stopped
1324  and if no injected conversion is on-going */
1325  if (tmp_hal_status == HAL_OK)
1326  {
1327  /* Clear HAL_ADC_STATE_REG_BUSY bit */
1328  CLEAR_BIT(hadc->State, HAL_ADC_STATE_REG_BUSY);
1329 
1330  /* Disable all regular-related interrupts */
1331  __HAL_ADC_DISABLE_IT(hadc, (ADC_IT_EOC | ADC_IT_EOS | ADC_IT_OVR));
1332 
1333  /* 2. Disable ADC peripheral if no injected conversions are on-going */
1334  if (LL_ADC_INJ_IsConversionOngoing(hadc->Instance) == 0UL)
1335  {
1336  tmp_hal_status = ADC_Disable(hadc);
1337  /* if no issue reported */
1338  if (tmp_hal_status == HAL_OK)
1339  {
1340  /* Set ADC state */
1341  ADC_STATE_CLR_SET(hadc->State,
1342  HAL_ADC_STATE_INJ_BUSY,
1343  HAL_ADC_STATE_READY);
1344  }
1345  }
1346  else
1347  {
1348  SET_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
1349  }
1350  }
1351 
1352  /* Process unlocked */
1353  __HAL_UNLOCK(hadc);
1354 
1355  /* Return function status */
1356  return tmp_hal_status;
1357 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
__STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
Get ADC group injected conversion state. CR JADSTART LL_ADC_INJ_IsConversionOngoing.
HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup)
Stop ADC conversion.
HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
Disable the selected ADC.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))