STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_adc_ex.c
Go to the documentation of this file.
1 
116 /* Includes ------------------------------------------------------------------*/
117 #include "stm32f7xx_hal.h"
118 
128 #ifdef HAL_ADC_MODULE_ENABLED
129 
130 /* Private typedef -----------------------------------------------------------*/
131 /* Private define ------------------------------------------------------------*/
132 /* Private macro -------------------------------------------------------------*/
133 /* Private variables ---------------------------------------------------------*/
137 /* Private function prototypes -----------------------------------------------*/
138 static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma);
139 static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma);
140 static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma);
145 /* Exported functions --------------------------------------------------------*/
178 {
179  __IO uint32_t counter = 0;
180  uint32_t tmp1 = 0, tmp2 = 0;
181 
182  /* Process locked */
183  __HAL_LOCK(hadc);
184 
185  /* Enable the ADC peripheral */
186 
187  /* Check if ADC peripheral is disabled in order to enable it and wait during
188  Tstab time the ADC's stabilization */
189  if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON)
190  {
191  /* Enable the Peripheral */
192  __HAL_ADC_ENABLE(hadc);
193 
194  /* Delay for ADC stabilization time */
195  /* Compute number of CPU cycles to wait for */
196  counter = (ADC_STAB_DELAY_US * (SystemCoreClock / 1000000));
197  while(counter != 0)
198  {
199  counter--;
200  }
201  }
202 
203  /* Start conversion if ADC is effectively enabled */
205  {
206  /* Set ADC state */
207  /* - Clear state bitfield related to injected group conversion results */
208  /* - Set state bitfield related to injected operation */
209  ADC_STATE_CLR_SET(hadc->State,
212 
213  /* Check if a regular conversion is ongoing */
214  /* Note: On this device, there is no ADC error code fields related to */
215  /* conversions on group injected only. In case of conversion on */
216  /* going on group regular, no error code is reset. */
218  {
219  /* Reset ADC all error code fields */
220  ADC_CLEAR_ERRORCODE(hadc);
221  }
222 
223  /* Process unlocked */
224  /* Unlock before starting ADC conversions: in case of potential */
225  /* interruption, to let the process to ADC IRQ Handler. */
226  __HAL_UNLOCK(hadc);
227 
228  /* Clear injected group conversion flag */
229  /* (To ensure of no unknown state from potential previous ADC operations) */
231 
232  /* Check if Multimode enabled */
233  if(HAL_IS_BIT_CLR(ADC->CCR, ADC_CCR_MULTI))
234  {
235  tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
236  tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
237  if(tmp1 && tmp2)
238  {
239  /* Enable the selected ADC software conversion for injected group */
240  hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
241  }
242  }
243  else
244  {
245  tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
246  tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
247  if((hadc->Instance == ADC1) && tmp1 && tmp2)
248  {
249  /* Enable the selected ADC software conversion for injected group */
250  hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
251  }
252  }
253  }
254 
255  /* Return function status */
256  return HAL_OK;
257 }
258 
267 {
268  __IO uint32_t counter = 0;
269  uint32_t tmp1 = 0, tmp2 = 0;
270 
271  /* Process locked */
272  __HAL_LOCK(hadc);
273 
274  /* Enable the ADC peripheral */
275 
276  /* Check if ADC peripheral is disabled in order to enable it and wait during
277  Tstab time the ADC's stabilization */
278  if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON)
279  {
280  /* Enable the Peripheral */
281  __HAL_ADC_ENABLE(hadc);
282 
283  /* Delay for ADC stabilization time */
284  /* Compute number of CPU cycles to wait for */
285  counter = (ADC_STAB_DELAY_US * (SystemCoreClock / 1000000));
286  while(counter != 0)
287  {
288  counter--;
289  }
290  }
291 
292  /* Start conversion if ADC is effectively enabled */
294  {
295  /* Set ADC state */
296  /* - Clear state bitfield related to injected group conversion results */
297  /* - Set state bitfield related to injected operation */
298  ADC_STATE_CLR_SET(hadc->State,
301 
302  /* Check if a regular conversion is ongoing */
303  /* Note: On this device, there is no ADC error code fields related to */
304  /* conversions on group injected only. In case of conversion on */
305  /* going on group regular, no error code is reset. */
307  {
308  /* Reset ADC all error code fields */
309  ADC_CLEAR_ERRORCODE(hadc);
310  }
311 
312  /* Process unlocked */
313  /* Unlock before starting ADC conversions: in case of potential */
314  /* interruption, to let the process to ADC IRQ Handler. */
315  __HAL_UNLOCK(hadc);
316 
317  /* Clear injected group conversion flag */
318  /* (To ensure of no unknown state from potential previous ADC operations) */
320 
321  /* Enable end of conversion interrupt for injected channels */
323 
324  /* Check if Multimode enabled */
325  if(HAL_IS_BIT_CLR(ADC->CCR, ADC_CCR_MULTI))
326  {
327  tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
328  tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
329  if(tmp1 && tmp2)
330  {
331  /* Enable the selected ADC software conversion for injected group */
332  hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
333  }
334  }
335  else
336  {
337  tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN);
338  tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO);
339  if((hadc->Instance == ADC1) && tmp1 && tmp2)
340  {
341  /* Enable the selected ADC software conversion for injected group */
342  hadc->Instance->CR2 |= ADC_CR2_JSWSTART;
343  }
344  }
345  }
346 
347  /* Return function status */
348  return HAL_OK;
349 }
350 
364 {
365  HAL_StatusTypeDef tmp_hal_status = HAL_OK;
366 
367  /* Check the parameters */
369 
370  /* Process locked */
371  __HAL_LOCK(hadc);
372 
373  /* Stop potential conversion and disable ADC peripheral */
374  /* Conditioned to: */
375  /* - No conversion on the other group (regular group) is intended to */
376  /* continue (injected and regular groups stop conversion and ADC disable */
377  /* are common) */
378  /* - In case of auto-injection mode, HAL_ADC_Stop must be used. */
379  if(((hadc->State & HAL_ADC_STATE_REG_BUSY) == RESET) &&
381  {
382  /* Stop potential conversion on going, on regular and injected groups */
383  /* Disable ADC peripheral */
384  __HAL_ADC_DISABLE(hadc);
385 
386  /* Check if ADC is effectively disabled */
388  {
389  /* Set ADC state */
390  ADC_STATE_CLR_SET(hadc->State,
393  }
394  }
395  else
396  {
397  /* Update ADC state machine to error */
399 
400  tmp_hal_status = HAL_ERROR;
401  }
402 
403  /* Process unlocked */
404  __HAL_UNLOCK(hadc);
405 
406  /* Return function status */
407  return tmp_hal_status;
408 }
409 
418 {
419  uint32_t tickstart = 0;
420 
421  /* Get tick */
422  tickstart = HAL_GetTick();
423 
424  /* Check End of conversion flag */
425  while(!(__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_JEOC)))
426  {
427  /* Check for the Timeout */
428  if(Timeout != HAL_MAX_DELAY)
429  {
430  if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
431  {
433  /* Process unlocked */
434  __HAL_UNLOCK(hadc);
435  return HAL_TIMEOUT;
436  }
437  }
438  }
439 
440  /* Clear injected group conversion flag */
442 
443  /* Update ADC state machine */
445 
446  /* Determine whether any further conversion upcoming on group injected */
447  /* by external trigger, continuous mode or scan sequence on going. */
448  /* Note: On STM32F7, there is no independent flag of end of sequence. */
449  /* The test of scan sequence on going is done either with scan */
450  /* sequence disabled or with end of conversion flag set to */
451  /* of end of sequence. */
457  (hadc->Init.ContinuousConvMode == DISABLE) ) ) )
458  {
459  /* Set ADC state */
461 
463  {
465  }
466  }
467 
468  /* Return ADC state */
469  return HAL_OK;
470 }
471 
485 {
486  HAL_StatusTypeDef tmp_hal_status = HAL_OK;
487 
488  /* Check the parameters */
490 
491  /* Process locked */
492  __HAL_LOCK(hadc);
493 
494  /* Stop potential conversion and disable ADC peripheral */
495  /* Conditioned to: */
496  /* - No conversion on the other group (regular group) is intended to */
497  /* continue (injected and regular groups stop conversion and ADC disable */
498  /* are common) */
499  /* - In case of auto-injection mode, HAL_ADC_Stop must be used. */
500  if(((hadc->State & HAL_ADC_STATE_REG_BUSY) == RESET) &&
502  {
503  /* Stop potential conversion on going, on regular and injected groups */
504  /* Disable ADC peripheral */
505  __HAL_ADC_DISABLE(hadc);
506 
507  /* Check if ADC is effectively disabled */
509  {
510  /* Disable ADC end of conversion interrupt for injected channels */
512 
513  /* Set ADC state */
514  ADC_STATE_CLR_SET(hadc->State,
517  }
518  }
519  else
520  {
521  /* Update ADC state machine to error */
523 
524  tmp_hal_status = HAL_ERROR;
525  }
526 
527  /* Process unlocked */
528  __HAL_UNLOCK(hadc);
529 
530  /* Return function status */
531  return tmp_hal_status;
532 }
533 
546 uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank)
547 {
548  __IO uint32_t tmp = 0;
549 
550  /* Check the parameters */
551  assert_param(IS_ADC_INJECTED_RANK(InjectedRank));
552 
553  /* Clear injected group conversion flag to have similar behaviour as */
554  /* regular group: reading data register also clears end of conversion flag. */
556 
557  /* Return the selected ADC converted value */
558  switch(InjectedRank)
559  {
560  case ADC_INJECTED_RANK_4:
561  {
562  tmp = hadc->Instance->JDR4;
563  }
564  break;
565  case ADC_INJECTED_RANK_3:
566  {
567  tmp = hadc->Instance->JDR3;
568  }
569  break;
570  case ADC_INJECTED_RANK_2:
571  {
572  tmp = hadc->Instance->JDR2;
573  }
574  break;
575  case ADC_INJECTED_RANK_1:
576  {
577  tmp = hadc->Instance->JDR1;
578  }
579  break;
580  default:
581  break;
582  }
583  return tmp;
584 }
585 
597 HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length)
598 {
599  __IO uint32_t counter = 0;
600 
601  /* Check the parameters */
605 
606  /* Process locked */
607  __HAL_LOCK(hadc);
608 
609  /* Check if ADC peripheral is disabled in order to enable it and wait during
610  Tstab time the ADC's stabilization */
611  if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON)
612  {
613  /* Enable the Peripheral */
614  __HAL_ADC_ENABLE(hadc);
615 
616  /* Delay for temperature sensor stabilization time */
617  /* Compute number of CPU cycles to wait for */
618  counter = (ADC_STAB_DELAY_US * (SystemCoreClock / 1000000));
619  while(counter != 0)
620  {
621  counter--;
622  }
623  }
624 
625  /* Start conversion if ADC is effectively enabled */
627  {
628  /* Set ADC state */
629  /* - Clear state bitfield related to regular group conversion results */
630  /* - Set state bitfield related to regular group operation */
631  ADC_STATE_CLR_SET(hadc->State,
634 
635  /* If conversions on group regular are also triggering group injected, */
636  /* update ADC state. */
637  if (READ_BIT(hadc->Instance->CR1, ADC_CR1_JAUTO) != RESET)
638  {
640  }
641 
642  /* State machine update: Check if an injected conversion is ongoing */
644  {
645  /* Reset ADC error code fields related to conversions on group regular */
647  }
648  else
649  {
650  /* Reset ADC all error code fields */
651  ADC_CLEAR_ERRORCODE(hadc);
652  }
653 
654  /* Process unlocked */
655  /* Unlock before starting ADC conversions: in case of potential */
656  /* interruption, to let the process to ADC IRQ Handler. */
657  __HAL_UNLOCK(hadc);
658 
659  /* Set the DMA transfer complete callback */
660  hadc->DMA_Handle->XferCpltCallback = ADC_MultiModeDMAConvCplt;
661 
662  /* Set the DMA half transfer complete callback */
663  hadc->DMA_Handle->XferHalfCpltCallback = ADC_MultiModeDMAHalfConvCplt;
664 
665  /* Set the DMA error callback */
666  hadc->DMA_Handle->XferErrorCallback = ADC_MultiModeDMAError ;
667 
668  /* Manage ADC and DMA start: ADC overrun interruption, DMA start, ADC */
669  /* start (in case of SW start): */
670 
671  /* Clear regular group conversion flag and overrun flag */
672  /* (To ensure of no unknown state from potential previous ADC operations) */
674 
675  /* Enable ADC overrun interrupt */
677 
678  if (hadc->Init.DMAContinuousRequests != DISABLE)
679  {
680  /* Enable the selected ADC DMA request after last transfer */
681  ADC->CCR |= ADC_CCR_DDS;
682  }
683  else
684  {
685  /* Disable the selected ADC EOC rising on each regular channel conversion */
686  ADC->CCR &= ~ADC_CCR_DDS;
687  }
688 
689  /* Enable the DMA Stream */
690  HAL_DMA_Start_IT(hadc->DMA_Handle, (uint32_t)&ADC->CDR, (uint32_t)pData, Length);
691 
692  /* if no external trigger present enable software conversion of regular channels */
693  if((hadc->Instance->CR2 & ADC_CR2_EXTEN) == RESET)
694  {
695  /* Enable the selected ADC software conversion for regular group */
696  hadc->Instance->CR2 |= (uint32_t)ADC_CR2_SWSTART;
697  }
698  }
699 
700  /* Return function status */
701  return HAL_OK;
702 }
703 
711 {
712  HAL_StatusTypeDef tmp_hal_status = HAL_OK;
713 
714  /* Check the parameters */
716 
717  /* Process locked */
718  __HAL_LOCK(hadc);
719 
720  /* Stop potential conversion on going, on regular and injected groups */
721  /* Disable ADC peripheral */
722  __HAL_ADC_DISABLE(hadc);
723 
724  /* Check if ADC is effectively disabled */
726  {
727  /* Disable the selected ADC DMA mode for multimode */
728  ADC->CCR &= ~ADC_CCR_DDS;
729 
730  /* Disable the DMA channel (in case of DMA in circular mode or stop while */
731  /* DMA transfer is on going) */
732  tmp_hal_status = HAL_DMA_Abort(hadc->DMA_Handle);
733 
734  /* Disable ADC overrun interrupt */
736 
737  /* Set ADC state */
738  ADC_STATE_CLR_SET(hadc->State,
741  }
742 
743  /* Process unlocked */
744  __HAL_UNLOCK(hadc);
745 
746  /* Return function status */
747  return tmp_hal_status;
748 }
749 
758 {
759  /* Return the multi mode conversion value */
760  return ADC->CDR;
761 }
762 
770 {
771  /* Prevent unused argument(s) compilation warning */
772  UNUSED(hadc);
773  /* NOTE : This function Should not be modified, when the callback is needed,
774  the HAL_ADC_InjectedConvCpltCallback could be implemented in the user file
775  */
776 }
777 
787 {
788 
789 #ifdef USE_FULL_ASSERT
790  uint32_t tmp = 0;
791 #endif /* USE_FULL_ASSERT */
792 
793  /* Check the parameters */
794  assert_param(IS_ADC_CHANNEL(sConfigInjected->InjectedChannel));
801 
802 #ifdef USE_FULL_ASSERT
803  tmp = ADC_GET_RESOLUTION(hadc);
804  assert_param(IS_ADC_RANGE(tmp, sConfigInjected->InjectedOffset));
805 #endif /* USE_FULL_ASSERT */
806 
808  {
810  }
811 
812  /* Process locked */
813  __HAL_LOCK(hadc);
814 
815  /* if ADC_Channel_10 ... ADC_Channel_18 is selected */
816  if (sConfigInjected->InjectedChannel > ADC_CHANNEL_9)
817  {
818  /* Clear the old sample time */
819  hadc->Instance->SMPR1 &= ~ADC_SMPR1(ADC_SMPR1_SMP10, sConfigInjected->InjectedChannel);
820 
821  /* Set the new sample time */
822  hadc->Instance->SMPR1 |= ADC_SMPR1(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel);
823  }
824  else /* ADC_Channel include in ADC_Channel_[0..9] */
825  {
826  /* Clear the old sample time */
827  hadc->Instance->SMPR2 &= ~ADC_SMPR2(ADC_SMPR2_SMP0, sConfigInjected->InjectedChannel);
828 
829  /* Set the new sample time */
830  hadc->Instance->SMPR2 |= ADC_SMPR2(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel);
831  }
832 
833  /*---------------------------- ADCx JSQR Configuration -----------------*/
834  hadc->Instance->JSQR &= ~(ADC_JSQR_JL);
835  hadc->Instance->JSQR |= ADC_SQR1(sConfigInjected->InjectedNbrOfConversion);
836 
837  /* Rank configuration */
838 
839  /* Clear the old SQx bits for the selected rank */
840  hadc->Instance->JSQR &= ~ADC_JSQR(ADC_JSQR_JSQ1, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion);
841 
842  /* Set the SQx bits for the selected rank */
843  hadc->Instance->JSQR |= ADC_JSQR(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion);
844 
845  /* Enable external trigger if trigger selection is different of software */
846  /* start. */
847  /* Note: This configuration keeps the hardware feature of parameter */
848  /* ExternalTrigConvEdge "trigger edge none" equivalent to */
849  /* software start. */
850  if(sConfigInjected->ExternalTrigInjecConv != ADC_INJECTED_SOFTWARE_START)
851  {
852  /* Select external trigger to start conversion */
853  hadc->Instance->CR2 &= ~(ADC_CR2_JEXTSEL);
854  hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConv;
855 
856  /* Select external trigger polarity */
857  hadc->Instance->CR2 &= ~(ADC_CR2_JEXTEN);
858  hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConvEdge;
859  }
860  else
861  {
862  /* Reset the external trigger */
863  hadc->Instance->CR2 &= ~(ADC_CR2_JEXTSEL);
864  hadc->Instance->CR2 &= ~(ADC_CR2_JEXTEN);
865  }
866 
867  if (sConfigInjected->AutoInjectedConv != DISABLE)
868  {
869  /* Enable the selected ADC automatic injected group conversion */
870  hadc->Instance->CR1 |= ADC_CR1_JAUTO;
871  }
872  else
873  {
874  /* Disable the selected ADC automatic injected group conversion */
875  hadc->Instance->CR1 &= ~(ADC_CR1_JAUTO);
876  }
877 
878  if (sConfigInjected->InjectedDiscontinuousConvMode != DISABLE)
879  {
880  /* Enable the selected ADC injected discontinuous mode */
881  hadc->Instance->CR1 |= ADC_CR1_JDISCEN;
882  }
883  else
884  {
885  /* Disable the selected ADC injected discontinuous mode */
886  hadc->Instance->CR1 &= ~(ADC_CR1_JDISCEN);
887  }
888 
889  switch(sConfigInjected->InjectedRank)
890  {
891  case 1:
892  /* Set injected channel 1 offset */
893  hadc->Instance->JOFR1 &= ~(ADC_JOFR1_JOFFSET1);
894  hadc->Instance->JOFR1 |= sConfigInjected->InjectedOffset;
895  break;
896  case 2:
897  /* Set injected channel 2 offset */
898  hadc->Instance->JOFR2 &= ~(ADC_JOFR2_JOFFSET2);
899  hadc->Instance->JOFR2 |= sConfigInjected->InjectedOffset;
900  break;
901  case 3:
902  /* Set injected channel 3 offset */
903  hadc->Instance->JOFR3 &= ~(ADC_JOFR3_JOFFSET3);
904  hadc->Instance->JOFR3 |= sConfigInjected->InjectedOffset;
905  break;
906  default:
907  /* Set injected channel 4 offset */
908  hadc->Instance->JOFR4 &= ~(ADC_JOFR4_JOFFSET4);
909  hadc->Instance->JOFR4 |= sConfigInjected->InjectedOffset;
910  break;
911  }
912 
913  /* if ADC1 Channel_18 is selected enable VBAT Channel */
914  if ((hadc->Instance == ADC1) && (sConfigInjected->InjectedChannel == ADC_CHANNEL_VBAT))
915  {
916  /* Enable the VBAT channel*/
917  ADC->CCR |= ADC_CCR_VBATE;
918  }
919 
920  /* if ADC1 Channel_16 or Channel_17 is selected enable TSVREFE Channel(Temperature sensor and VREFINT) */
921  if ((hadc->Instance == ADC1) && ((sConfigInjected->InjectedChannel == ADC_CHANNEL_TEMPSENSOR) || (sConfigInjected->InjectedChannel == ADC_CHANNEL_VREFINT)))
922  {
923  /* Enable the TSVREFE channel*/
924  ADC->CCR |= ADC_CCR_TSVREFE;
925  }
926 
927  /* Process unlocked */
928  __HAL_UNLOCK(hadc);
929 
930  /* Return function status */
931  return HAL_OK;
932 }
933 
943 {
944  /* Check the parameters */
945  assert_param(IS_ADC_MODE(multimode->Mode));
948 
949  /* Process locked */
950  __HAL_LOCK(hadc);
951 
952  /* Set ADC mode */
953  ADC->CCR &= ~(ADC_CCR_MULTI);
954  ADC->CCR |= multimode->Mode;
955 
956  /* Set the ADC DMA access mode */
957  ADC->CCR &= ~(ADC_CCR_DMA);
958  ADC->CCR |= multimode->DMAAccessMode;
959 
960  /* Set delay between two sampling phases */
961  ADC->CCR &= ~(ADC_CCR_DELAY);
962  ADC->CCR |= multimode->TwoSamplingDelay;
963 
964  /* Process unlocked */
965  __HAL_UNLOCK(hadc);
966 
967  /* Return function status */
968  return HAL_OK;
969 }
970 
981 static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma)
982 {
983  /* Retrieve ADC handle corresponding to current DMA handle */
984  ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
985 
986  /* Update state machine on conversion status if not in error state */
988  {
989  /* Update ADC state machine */
991 
992  /* Determine whether any further conversion upcoming on group regular */
993  /* by external trigger, continuous mode or scan sequence on going. */
994  /* Note: On STM32F7, there is no independent flag of end of sequence. */
995  /* The test of scan sequence on going is done either with scan */
996  /* sequence disabled or with end of conversion flag set to */
997  /* of end of sequence. */
999  (hadc->Init.ContinuousConvMode == DISABLE) &&
1000  (HAL_IS_BIT_CLR(hadc->Instance->SQR1, ADC_SQR1_L) ||
1002  {
1003  /* Disable ADC end of single conversion interrupt on group regular */
1004  /* Note: Overrun interrupt was enabled with EOC interrupt in */
1005  /* HAL_ADC_Start_IT(), but is not disabled here because can be used */
1006  /* by overrun IRQ process below. */
1008 
1009  /* Set ADC state */
1011 
1013  {
1015  }
1016  }
1017 
1018  /* Conversion complete callback */
1020  }
1021  else
1022  {
1023  /* Call DMA error callback */
1024  hadc->DMA_Handle->XferErrorCallback(hdma);
1025  }
1026 }
1027 
1034 static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma)
1035 {
1036  ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
1037  /* Conversion complete callback */
1039 }
1040 
1047 static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma)
1048 {
1049  ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
1051  /* Set ADC error code to DMA error */
1052  hadc->ErrorCode |= HAL_ADC_ERROR_DMA;
1053  HAL_ADC_ErrorCallback(hadc);
1054 }
1055 
1060 #endif /* HAL_ADC_MODULE_ENABLED */
1061 
1069 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define CLEAR_BIT(REG, BIT)
Definition: stm32f7xx.h:180
#define IS_ADC_SAMPLE_TIME(__TIME__)
#define ADC_CCR_DMA
Definition: stm32f745xx.h:1728
__IO uint32_t JOFR3
Definition: stm32f745xx.h:213
#define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__)
Get the selected ADC's flag status.
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc)
#define ADC_INJECTED_RANK_4
#define ADC_CR2_JEXTEN
Definition: stm32f745xx.h:1425
__IO uint32_t JSQR
Definition: stm32f745xx.h:220
uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc)
DMA_HandleTypeDef * DMA_Handle
#define HAL_ADC_STATE_REG_OVR
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
#define IS_ADC_INJECTED_RANK(__RANK__)
#define ADC_SQR1_L
Definition: stm32f745xx.h:1562
#define ADC_CHANNEL_TEMPSENSOR
__IO uint32_t JOFR4
Definition: stm32f745xx.h:214
#define HAL_ADC_STATE_REG_EOC
ADC_TypeDef * Instance
#define ADC
Definition: stm32f745xx.h:1293
#define assert_param(expr)
Include module's header file.
void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc)
#define ADC_FLAG_JSTRT
#define ADC_CHANNEL_VREFINT
uint32_t SystemCoreClock
#define __HAL_ADC_DISABLE(__HANDLE__)
Disable the ADC peripheral.
#define ADC_CHANNEL_VBAT
#define ADC_FLAG_JEOC
#define __HAL_UNLOCK(__HANDLE__)
#define ADC_CLEAR_ERRORCODE(__HANDLE__)
Clear ADC error code (set it to error code: "no error")
#define ADC_INJECTED_RANK_2
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
#define HAL_ADC_ERROR_DMA
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
#define IS_ADC_ALL_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8782
__IO uint32_t JDR2
Definition: stm32f745xx.h:222
#define ADC_JSQR(_CHANNELNB_, _RANKNB_, _JSQR_JL_)
Set the selected injected Channel rank.
#define HAL_ADC_STATE_INJ_EOC
#define HAL_ADC_ERROR_OVR
#define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__)
Enable the ADC end of conversion interrupt.
#define ADC_JOFR4_JOFFSET4
Definition: stm32f745xx.h:1529
__IO uint32_t JDR1
Definition: stm32f745xx.h:221
HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef *hadc)
#define ADC_CCR_DELAY
Definition: stm32f745xx.h:1722
#define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_)
Set the ADC's sample time for channel numbers between 0 and 9.
#define ADC_SMPR2_SMP0
Definition: stm32f745xx.h:1478
#define ADC_JOFR2_JOFFSET2
Definition: stm32f745xx.h:1523
uint32_t ExternalTrigConvEdge
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
__IO uint32_t CR2
Definition: stm32f745xx.h:208
#define __HAL_LOCK(__HANDLE__)
#define ADC_CCR_DDS
Definition: stm32f745xx.h:1727
#define ADC_INJECTED_SOFTWARE_START
#define IS_ADC_CHANNEL(CHANNEL)
#define HAL_MAX_DELAY
#define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__)
Test if conversion trigger of regular group is software start or external trigger.
#define __IO
Definition: core_cm0.h:213
#define HAL_ADC_STATE_ERROR_CONFIG
#define ADC_INJECTED_RANK_3
#define ADC_CCR_TSVREFE
Definition: stm32f745xx.h:1735
#define READ_BIT(REG, BIT)
Definition: stm32f7xx.h:182
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode)
__IO uint32_t JDR4
Definition: stm32f745xx.h:224
#define ADC_CR2_SWSTART
Definition: stm32f745xx.h:1437
#define HAL_IS_BIT_CLR(REG, BIT)
#define ADC_STATE_CLR_SET
Simultaneously clears and sets specific bits of the handle State.
#define ADC_IT_EOC
HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef *hadc, ADC_InjectionConfTypeDef *sConfigInjected)
#define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__)
Disable the ADC end of conversion interrupt.
HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length)
ADC Configuration multi-mode structure definition.
#define ADC_CR2_JEXTSEL
Definition: stm32f745xx.h:1420
#define ADC_JSQR_JL
Definition: stm32f745xx.h:1669
#define HAL_ADC_STATE_ERROR_INTERNAL
__IO uint32_t JOFR1
Definition: stm32f745xx.h:211
void(* XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)
#define IS_ADC_INJECTED_LENGTH(__LENGTH__)
#define HAL_ADC_STATE_READY
#define ADC_STAB_DELAY_US
__IO uint32_t ErrorCode
#define ADC_CR2_EOCS
Definition: stm32f745xx.h:1418
#define ADC1
Definition: stm32f745xx.h:1294
#define UNUSED(x)
__IO uint32_t JOFR2
Definition: stm32f745xx.h:212
ADC handle Structure definition.
uint32_t DMAContinuousRequests
#define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__)
Test if conversion trigger of injected group is software start or external trigger.
#define SET_BIT(REG, BIT)
Definition: stm32f7xx.h:178
#define ADC_IT_OVR
#define HAL_IS_BIT_SET(REG, BIT)
#define IS_ADC_EXT_TRIG_EDGE(__EDGE__)
#define ADC_SMPR1_SMP10
Definition: stm32f745xx.h:1440
#define HAL_ADC_STATE_REG_BUSY
#define ADC_CR2_JSWSTART
Definition: stm32f745xx.h:1428
#define ADC_CR1_JAUTO
Definition: stm32f745xx.h:1399
uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef *hadc, uint32_t InjectedRank)
HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef *hadc, uint32_t Timeout)
DMA handle Structure definition.
#define ADC_JOFR3_JOFFSET3
Definition: stm32f745xx.h:1526
#define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_)
Set the ADC's sample time for channel numbers between 10 and 18.
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f7xx.h:163
#define ADC_CR2_ADON
Definition: stm32f745xx.h:1414
#define HAL_ADC_STATE_ERROR_DMA
__IO uint32_t CR1
Definition: stm32f745xx.h:207
__IO uint32_t SMPR1
Definition: stm32f745xx.h:209
#define ADC_CCR_VBATE
Definition: stm32f745xx.h:1734
#define ADC_FLAG_EOC
#define HAL_ADC_STATE_INJ_BUSY
#define ADC_INJECTED_RANK_1
__IO uint32_t SMPR2
Definition: stm32f745xx.h:210
#define ADC_JOFR1_JOFFSET1
Definition: stm32f745xx.h:1520
#define ADC_CHANNEL_9
#define ADC_CR2_EXTEN
Definition: stm32f745xx.h:1434
HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef *hadc)
ADC Configuration injected Channel structure definition.
#define IS_ADC_DMA_ACCESS_MODE(__MODE__)
uint32_t ContinuousConvMode
HAL_StatusTypeDef
HAL Status structures definition.
__IO uint32_t SQR1
Definition: stm32f745xx.h:217
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc)
#define ADC_CR1_JDISCEN
Definition: stm32f745xx.h:1401
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
#define ADC_JSQR_JSQ1
Definition: stm32f745xx.h:1645
HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef *hadc)
#define IS_ADC_SAMPLING_DELAY(__DELAY__)
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc)
ADC_InitTypeDef Init
__IO uint32_t JDR3
Definition: stm32f745xx.h:223
#define ADC_IT_JEOC
HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef *hadc)
#define IS_ADC_EXT_INJEC_TRIG(__INJTRIG__)
#define ADC_CCR_MULTI
Definition: stm32f745xx.h:1716
#define ADC_SQR1(_NbrOfConversion_)
Set ADC Regular channel sequence length.
#define __HAL_ADC_ENABLE(__HANDLE__)
Enable the ADC peripheral.
#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the ADC's pending flags.
#define IS_ADC_MODE(__MODE__)
#define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__)
#define IS_ADC_EXT_INJEC_TRIG_EDGE(__EDGE__)
#define ADC_GET_RESOLUTION(__HANDLE__)
Return resolution bits in CR1 register.
#define HAL_ADC_STATE_TIMEOUT