STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_dac.c
Go to the documentation of this file.
1 
318 /* Includes ------------------------------------------------------------------*/
319 #include "stm32l4xx_hal.h"
320 
325 #ifdef HAL_DAC_MODULE_ENABLED
326 #if defined(DAC1)
327 
333 /* Private typedef -----------------------------------------------------------*/
334 /* Private define ------------------------------------------------------------*/
335 /* Private constants ---------------------------------------------------------*/
339 #define TIMEOUT_DAC_CALIBCONFIG 1U /* 1 ms */
340 #define HFSEL_ENABLE_THRESHOLD_80MHZ 80000000U /* 80 MHz */
341 
346 /* Private macro -------------------------------------------------------------*/
347 /* Private variables ---------------------------------------------------------*/
348 /* Private function prototypes -----------------------------------------------*/
349 /* Exported functions -------------------------------------------------------*/
350 
377 HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef *hdac)
378 {
379  /* Check DAC handle */
380  if (hdac == NULL)
381  {
382  return HAL_ERROR;
383  }
384  /* Check the parameters */
385  assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
386 
387  if (hdac->State == HAL_DAC_STATE_RESET)
388  {
389 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
390  /* Init the DAC Callback settings */
391  hdac->ConvCpltCallbackCh1 = HAL_DAC_ConvCpltCallbackCh1;
392  hdac->ConvHalfCpltCallbackCh1 = HAL_DAC_ConvHalfCpltCallbackCh1;
393  hdac->ErrorCallbackCh1 = HAL_DAC_ErrorCallbackCh1;
394  hdac->DMAUnderrunCallbackCh1 = HAL_DAC_DMAUnderrunCallbackCh1;
395 
396  hdac->ConvCpltCallbackCh2 = HAL_DACEx_ConvCpltCallbackCh2;
397  hdac->ConvHalfCpltCallbackCh2 = HAL_DACEx_ConvHalfCpltCallbackCh2;
398  hdac->ErrorCallbackCh2 = HAL_DACEx_ErrorCallbackCh2;
399  hdac->DMAUnderrunCallbackCh2 = HAL_DACEx_DMAUnderrunCallbackCh2;
400 
401  if (hdac->MspInitCallback == NULL)
402  {
403  hdac->MspInitCallback = HAL_DAC_MspInit;
404  }
405 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
406 
407  /* Allocate lock resource and initialize it */
408  hdac->Lock = HAL_UNLOCKED;
409 
410 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
411  /* Init the low level hardware */
412  hdac->MspInitCallback(hdac);
413 #else
414  /* Init the low level hardware */
415  HAL_DAC_MspInit(hdac);
416 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
417  }
418 
419  /* Initialize the DAC state*/
420  hdac->State = HAL_DAC_STATE_BUSY;
421 
422  /* Set DAC error code to none */
423  hdac->ErrorCode = HAL_DAC_ERROR_NONE;
424 
425  /* Initialize the DAC state*/
426  hdac->State = HAL_DAC_STATE_READY;
427 
428  /* Return function status */
429  return HAL_OK;
430 }
431 
438 HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef *hdac)
439 {
440  /* Check DAC handle */
441  if (hdac == NULL)
442  {
443  return HAL_ERROR;
444  }
445 
446  /* Check the parameters */
447  assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
448 
449  /* Change DAC state */
450  hdac->State = HAL_DAC_STATE_BUSY;
451 
452 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
453  if (hdac->MspDeInitCallback == NULL)
454  {
455  hdac->MspDeInitCallback = HAL_DAC_MspDeInit;
456  }
457  /* DeInit the low level hardware */
458  hdac->MspDeInitCallback(hdac);
459 #else
460  /* DeInit the low level hardware */
461  HAL_DAC_MspDeInit(hdac);
462 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
463 
464  /* Set DAC error code to none */
465  hdac->ErrorCode = HAL_DAC_ERROR_NONE;
466 
467  /* Change DAC state */
468  hdac->State = HAL_DAC_STATE_RESET;
469 
470  /* Release Lock */
471  __HAL_UNLOCK(hdac);
472 
473  /* Return function status */
474  return HAL_OK;
475 }
476 
484 {
485  /* Prevent unused argument(s) compilation warning */
486  UNUSED(hdac);
487 
488  /* NOTE : This function should not be modified, when the callback is needed,
489  the HAL_DAC_MspInit could be implemented in the user file
490  */
491 }
492 
500 {
501  /* Prevent unused argument(s) compilation warning */
502  UNUSED(hdac);
503 
504  /* NOTE : This function should not be modified, when the callback is needed,
505  the HAL_DAC_MspDeInit could be implemented in the user file
506  */
507 }
508 
541 HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef *hdac, uint32_t Channel)
542 {
543  /* Check the parameters */
544  assert_param(IS_DAC_CHANNEL(Channel));
545 
546  /* Process locked */
547  __HAL_LOCK(hdac);
548 
549  /* Change DAC state */
550  hdac->State = HAL_DAC_STATE_BUSY;
551 
552  /* Enable the Peripheral */
553  __HAL_DAC_ENABLE(hdac, Channel);
554 
555 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
556  if (Channel == DAC_CHANNEL_1)
557  {
558  /* Check if software trigger enabled */
559  if ((hdac->Instance->CR & (DAC_CR_TEN1 | DAC_CR_TSEL1)) == DAC_TRIGGER_SOFTWARE)
560  {
561  /* Enable the selected DAC software conversion */
562  SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG1);
563  }
564  }
565  else
566  {
567  /* Check if software trigger enabled */
568  if ((hdac->Instance->CR & (DAC_CR_TEN2 | DAC_CR_TSEL2)) == (DAC_TRIGGER_SOFTWARE << (Channel & 0x10UL)))
569  {
570  /* Enable the selected DAC software conversion*/
571  SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG2);
572  }
573  }
574 
575 #endif /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
576 
577 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
578  defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx)
579  if(Channel == DAC_CHANNEL_1)
580  {
581  /* Check if software trigger enabled */
582  if ((hdac->Instance->CR & (DAC_CR_TEN1 | DAC_CR_TSEL1)) == DAC_CR_TEN1)
583  {
584  /* Enable the selected DAC software conversion */
585  SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG1);
586  }
587  }
588  else
589  {
590  /* Check if software trigger enabled */
591  if ((hdac->Instance->CR & (DAC_CR_TEN2 | DAC_CR_TSEL2)) == DAC_CR_TEN2)
592  {
593  /* Enable the selected DAC software conversion*/
594  SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG2);
595  }
596  }
597 #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
598  /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
599 
600 
601 #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
602  /* Check if software trigger enabled */
603  if((hdac->Instance->CR & (DAC_CR_TEN1 | DAC_CR_TSEL1)) == (DAC_CR_TEN1 | DAC_CR_TSEL1))
604  {
605  /* Enable the selected DAC software conversion */
606  SET_BIT(hdac->Instance->SWTRIGR, DAC_SWTRIGR_SWTRIG1);
607  }
608 #endif /* STM32L451xx STM32L452xx STM32L462xx */
609  /* Change DAC state */
610  hdac->State = HAL_DAC_STATE_READY;
611 
612  /* Process unlocked */
613  __HAL_UNLOCK(hdac);
614 
615  /* Return function status */
616  return HAL_OK;
617 }
618 
629 HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef *hdac, uint32_t Channel)
630 {
631  /* Check the parameters */
632  assert_param(IS_DAC_CHANNEL(Channel));
633 
634  /* Disable the Peripheral */
635  __HAL_DAC_DISABLE(hdac, Channel);
636 
637  /* Change DAC state */
638  hdac->State = HAL_DAC_STATE_READY;
639 
640  /* Return function status */
641  return HAL_OK;
642 }
643 
644 #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
645 
661 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t *pData, uint32_t Length,
662  uint32_t Alignment)
663 {
664  HAL_StatusTypeDef status;
665  uint32_t tmpreg = 0U;
666 
667  /* Check the parameters */
668  assert_param(IS_DAC_CHANNEL(Channel));
669  assert_param(IS_DAC_ALIGN(Alignment));
670 
671  /* Process locked */
672  __HAL_LOCK(hdac);
673 
674  /* Change DAC state */
675  hdac->State = HAL_DAC_STATE_BUSY;
676 
677  /* Set the DMA transfer complete callback for channel1 */
678  hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
679 
680  /* Set the DMA half transfer complete callback for channel1 */
681  hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
682 
683  /* Set the DMA error callback for channel1 */
684  hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
685 
686  /* Enable the selected DAC channel1 DMA request */
687  SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN1);
688 
689  /* Case of use of channel 1 */
690  switch (Alignment)
691  {
692  case DAC_ALIGN_12B_R:
693  /* Get DHR12R1 address */
694  tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
695  break;
696  case DAC_ALIGN_12B_L:
697  /* Get DHR12L1 address */
698  tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
699  break;
700  case DAC_ALIGN_8B_R:
701  /* Get DHR8R1 address */
702  tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
703  break;
704  default:
705  break;
706  }
707 
708  /* Enable the DMA channel */
709  /* Enable the DAC DMA underrun interrupt */
710  __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
711 
712  /* Enable the DMA channel */
713  status = HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
714 
715  /* Process Unlocked */
716  __HAL_UNLOCK(hdac);
717 
718  if (status == HAL_OK)
719  {
720  /* Enable the Peripheral */
721  __HAL_DAC_ENABLE(hdac, Channel);
722  }
723  else
724  {
725  hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
726  }
727 
728  /* Return function status */
729  return status;
730 }
731 #endif /* STM32L451xx STM32L452xx STM32L462xx */
732 
733 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
734  defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
735  defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
736 
754 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t *pData, uint32_t Length,
755  uint32_t Alignment)
756 {
757  HAL_StatusTypeDef status;
758  uint32_t tmpreg = 0U;
759 
760  /* Check the parameters */
761  assert_param(IS_DAC_CHANNEL(Channel));
762  assert_param(IS_DAC_ALIGN(Alignment));
763 
764  /* Process locked */
765  __HAL_LOCK(hdac);
766 
767  /* Change DAC state */
768  hdac->State = HAL_DAC_STATE_BUSY;
769 
770  if (Channel == DAC_CHANNEL_1)
771  {
772  /* Set the DMA transfer complete callback for channel1 */
773  hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1;
774 
775  /* Set the DMA half transfer complete callback for channel1 */
776  hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1;
777 
778  /* Set the DMA error callback for channel1 */
779  hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1;
780 
781  /* Enable the selected DAC channel1 DMA request */
782  SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN1);
783 
784  /* Case of use of channel 1 */
785  switch (Alignment)
786  {
787  case DAC_ALIGN_12B_R:
788  /* Get DHR12R1 address */
789  tmpreg = (uint32_t)&hdac->Instance->DHR12R1;
790  break;
791  case DAC_ALIGN_12B_L:
792  /* Get DHR12L1 address */
793  tmpreg = (uint32_t)&hdac->Instance->DHR12L1;
794  break;
795  case DAC_ALIGN_8B_R:
796  /* Get DHR8R1 address */
797  tmpreg = (uint32_t)&hdac->Instance->DHR8R1;
798  break;
799  default:
800  break;
801  }
802  }
803  else
804  {
805  /* Set the DMA transfer complete callback for channel2 */
806  hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2;
807 
808  /* Set the DMA half transfer complete callback for channel2 */
809  hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2;
810 
811  /* Set the DMA error callback for channel2 */
812  hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2;
813 
814  /* Enable the selected DAC channel2 DMA request */
815  SET_BIT(hdac->Instance->CR, DAC_CR_DMAEN2);
816 
817  /* Case of use of channel 2 */
818  switch (Alignment)
819  {
820  case DAC_ALIGN_12B_R:
821  /* Get DHR12R2 address */
822  tmpreg = (uint32_t)&hdac->Instance->DHR12R2;
823  break;
824  case DAC_ALIGN_12B_L:
825  /* Get DHR12L2 address */
826  tmpreg = (uint32_t)&hdac->Instance->DHR12L2;
827  break;
828  case DAC_ALIGN_8B_R:
829  /* Get DHR8R2 address */
830  tmpreg = (uint32_t)&hdac->Instance->DHR8R2;
831  break;
832  default:
833  break;
834  }
835  }
836 
837  /* Enable the DMA channel */
838  if (Channel == DAC_CHANNEL_1)
839  {
840  /* Enable the DAC DMA underrun interrupt */
841  __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1);
842 
843  /* Enable the DMA channel */
844  status = HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length);
845  }
846  else
847  {
848  /* Enable the DAC DMA underrun interrupt */
849  __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR2);
850 
851  /* Enable the DMA channel */
852  status = HAL_DMA_Start_IT(hdac->DMA_Handle2, (uint32_t)pData, tmpreg, Length);
853  }
854 
855  /* Process Unlocked */
856  __HAL_UNLOCK(hdac);
857 
858  if (status == HAL_OK)
859  {
860  /* Enable the Peripheral */
861  __HAL_DAC_ENABLE(hdac, Channel);
862  }
863  else
864  {
865  hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
866  }
867 
868  /* Return function status */
869  return status;
870 }
871 #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
872  /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
873  /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
874 
885 HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel)
886 {
887  HAL_StatusTypeDef status;
888 
889  /* Check the parameters */
890  assert_param(IS_DAC_CHANNEL(Channel));
891 
892  /* Disable the selected DAC channel DMA request */
893  hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << (Channel & 0x10UL));
894 
895  /* Disable the Peripheral */
896  __HAL_DAC_DISABLE(hdac, Channel);
897 
898  /* Disable the DMA channel */
899 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
900  defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
901  defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
902  /* Channel1 is used */
903  if (Channel == DAC_CHANNEL_1)
904  {
905  /* Disable the DMA channel */
906  status = HAL_DMA_Abort(hdac->DMA_Handle1);
907 
908  /* Disable the DAC DMA underrun interrupt */
909  __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR1);
910  }
911  else /* Channel2 is used for */
912  {
913  /* Disable the DMA channel */
914  status = HAL_DMA_Abort(hdac->DMA_Handle2);
915 
916  /* Disable the DAC DMA underrun interrupt */
917  __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR2);
918  }
919 #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
920  /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
921  /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
922 
923 #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
924  /* Disable the DMA channel */
925  status = HAL_DMA_Abort(hdac->DMA_Handle1);
926 
927  /* Disable the DAC DMA underrun interrupt */
928  __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR1);
929 #endif /* STM32L451xx STM32L452xx STM32L462xx */
930 
931  /* Check if DMA Channel effectively disabled */
932  if (status != HAL_OK)
933  {
934  /* Update DAC state machine to error */
935  hdac->State = HAL_DAC_STATE_ERROR;
936  }
937  else
938  {
939  /* Change DAC state */
940  hdac->State = HAL_DAC_STATE_READY;
941  }
942 
943  /* Return function status */
944  return status;
945 }
946 
947 /* DAC channel 2 is available on top of DAC channel 1 in */
948 /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
949 /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
950 
960 {
961  if (__HAL_DAC_GET_IT_SOURCE(hdac, DAC_IT_DMAUDR1))
962  {
963  /* Check underrun flag of DAC channel 1 */
964  if (__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1))
965  {
966  /* Change DAC state to error state */
967  hdac->State = HAL_DAC_STATE_ERROR;
968 
969  /* Set DAC error code to chanel1 DMA underrun error */
970  SET_BIT(hdac->ErrorCode, HAL_DAC_ERROR_DMAUNDERRUNCH1);
971 
972  /* Clear the underrun flag */
973  __HAL_DAC_CLEAR_FLAG(hdac, DAC_FLAG_DMAUDR1);
974 
975  /* Disable the selected DAC channel1 DMA request */
976  CLEAR_BIT(hdac->Instance->CR, DAC_CR_DMAEN1);
977 
978  /* Error callback */
979 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
980  hdac->DMAUnderrunCallbackCh1(hdac);
981 #else
983 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
984  }
985  }
986 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
987  defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
988  defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
989  if(__HAL_DAC_GET_IT_SOURCE(hdac, DAC_IT_DMAUDR2))
990  {
991  /* Check underrun flag of DAC channel 2 */
992  if (__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR2))
993  {
994  /* Change DAC state to error state */
995  hdac->State = HAL_DAC_STATE_ERROR;
996 
997  /* Set DAC error code to channel2 DMA underrun error */
998  SET_BIT(hdac->ErrorCode, HAL_DAC_ERROR_DMAUNDERRUNCH2);
999 
1000  /* Clear the underrun flag */
1001  __HAL_DAC_CLEAR_FLAG(hdac, DAC_FLAG_DMAUDR2);
1002 
1003  /* Disable the selected DAC channel2 DMA request */
1004  CLEAR_BIT(hdac->Instance->CR, DAC_CR_DMAEN2);
1005 
1006  /* Error callback */
1007 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
1008  hdac->DMAUnderrunCallbackCh2(hdac);
1009 #else
1011 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
1012  }
1013  }
1014 #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
1015  /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
1016  /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
1017 }
1018 
1035 HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data)
1036 {
1037  __IO uint32_t tmp = 0;
1038 
1039  /* Check the parameters */
1040  assert_param(IS_DAC_CHANNEL(Channel));
1041  assert_param(IS_DAC_ALIGN(Alignment));
1042  assert_param(IS_DAC_DATA(Data));
1043 
1044  tmp = (uint32_t)hdac->Instance;
1045  if (Channel == DAC_CHANNEL_1)
1046  {
1047  tmp += DAC_DHR12R1_ALIGNMENT(Alignment);
1048  }
1049  else
1050  {
1051  tmp += DAC_DHR12R2_ALIGNMENT(Alignment);
1052  }
1053 
1054  /* Set the DAC channel selected data holding register */
1055  *(__IO uint32_t *) tmp = Data;
1056 
1057  /* Return function status */
1058  return HAL_OK;
1059 }
1060 
1068 {
1069  /* Prevent unused argument(s) compilation warning */
1070  UNUSED(hdac);
1071 
1072  /* NOTE : This function should not be modified, when the callback is needed,
1073  the HAL_DAC_ConvCpltCallbackCh1 could be implemented in the user file
1074  */
1075 }
1076 
1084 {
1085  /* Prevent unused argument(s) compilation warning */
1086  UNUSED(hdac);
1087 
1088  /* NOTE : This function should not be modified, when the callback is needed,
1089  the HAL_DAC_ConvHalfCpltCallbackCh1 could be implemented in the user file
1090  */
1091 }
1092 
1100 {
1101  /* Prevent unused argument(s) compilation warning */
1102  UNUSED(hdac);
1103 
1104  /* NOTE : This function should not be modified, when the callback is needed,
1105  the HAL_DAC_ErrorCallbackCh1 could be implemented in the user file
1106  */
1107 }
1108 
1116 {
1117  /* Prevent unused argument(s) compilation warning */
1118  UNUSED(hdac);
1119 
1120  /* NOTE : This function should not be modified, when the callback is needed,
1121  the HAL_DAC_DMAUnderrunCallbackCh1 could be implemented in the user file
1122  */
1123 }
1124 
1154 uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef *hdac, uint32_t Channel)
1155 {
1156  /* Check the parameters */
1157  assert_param(IS_DAC_CHANNEL(Channel));
1158 
1159  /* Returns the DAC channel data output register value */
1160 #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
1161  /* Prevent unused argument(s) compilation warning if no assert_param check */
1162  UNUSED(Channel);
1163 
1164  return hdac->Instance->DOR1;
1165 #endif /* STM32L451xx STM32L452xx STM32L462xx */
1166 
1167 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
1168  defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
1169  defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
1170  if(Channel == DAC_CHANNEL_1)
1171  {
1172  return hdac->Instance->DOR1;
1173  }
1174  else
1175  {
1176  return hdac->Instance->DOR2;
1177  }
1178 #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
1179  /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
1180  /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
1181 }
1182 
1199 HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef *hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel)
1200 {
1201  uint32_t tmpreg1;
1202  uint32_t tmpreg2;
1203  uint32_t tickstart = 0U;
1204 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
1205  uint32_t hclkfreq;
1206 #endif /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
1207 
1208  /* Check the DAC parameters */
1209 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
1210  assert_param(IS_DAC_HIGH_FREQUENCY_MODE(sConfig->DAC_HighFrequency));
1211 #endif /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
1212  assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger));
1213  assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer));
1214  assert_param(IS_DAC_CHIP_CONNECTION(sConfig->DAC_ConnectOnChipPeripheral));
1215  assert_param(IS_DAC_TRIMMING(sConfig->DAC_UserTrimming));
1216  if ((sConfig->DAC_UserTrimming) == DAC_TRIMMING_USER)
1217  {
1218  assert_param(IS_DAC_TRIMMINGVALUE(sConfig->DAC_TrimmingValue));
1219  }
1220  assert_param(IS_DAC_SAMPLEANDHOLD(sConfig->DAC_SampleAndHold));
1221  if ((sConfig->DAC_SampleAndHold) == DAC_SAMPLEANDHOLD_ENABLE)
1222  {
1223  assert_param(IS_DAC_SAMPLETIME(sConfig->DAC_SampleAndHoldConfig.DAC_SampleTime));
1224  assert_param(IS_DAC_HOLDTIME(sConfig->DAC_SampleAndHoldConfig.DAC_HoldTime));
1225  assert_param(IS_DAC_REFRESHTIME(sConfig->DAC_SampleAndHoldConfig.DAC_RefreshTime));
1226  }
1227  assert_param(IS_DAC_CHANNEL(Channel));
1228 
1229  /* Process locked */
1230  __HAL_LOCK(hdac);
1231 
1232  /* Change DAC state */
1233  hdac->State = HAL_DAC_STATE_BUSY;
1234 
1235  if (sConfig->DAC_SampleAndHold == DAC_SAMPLEANDHOLD_ENABLE)
1236  /* Sample on old configuration */
1237  {
1238  /* SampleTime */
1239  if (Channel == DAC_CHANNEL_1)
1240  {
1241  /* Get timeout */
1242  tickstart = HAL_GetTick();
1243 
1244  /* SHSR1 can be written when BWST1 is cleared */
1245  while (((hdac->Instance->SR) & DAC_SR_BWST1) != 0UL)
1246  {
1247  /* Check for the Timeout */
1248  if ((HAL_GetTick() - tickstart) > TIMEOUT_DAC_CALIBCONFIG)
1249  {
1250  /* Update error code */
1251  SET_BIT(hdac->ErrorCode, HAL_DAC_ERROR_TIMEOUT);
1252 
1253  /* Change the DMA state */
1254  hdac->State = HAL_DAC_STATE_TIMEOUT;
1255 
1256  return HAL_TIMEOUT;
1257  }
1258  }
1259  HAL_Delay(1);
1260  hdac->Instance->SHSR1 = sConfig->DAC_SampleAndHoldConfig.DAC_SampleTime;
1261  }
1262 #if !defined (STM32L451xx) & !defined (STM32L452xx) & !defined (STM32L462xx)
1263  else /* Channel 2 */
1264  {
1265  /* SHSR2 can be written when BWST2 is cleared */
1266 
1267  while (((hdac->Instance->SR) & DAC_SR_BWST2) != 0UL)
1268  {
1269  /* Check for the Timeout */
1270  if ((HAL_GetTick() - tickstart) > TIMEOUT_DAC_CALIBCONFIG)
1271  {
1272  /* Update error code */
1273  SET_BIT(hdac->ErrorCode, HAL_DAC_ERROR_TIMEOUT);
1274 
1275  /* Change the DMA state */
1276  hdac->State = HAL_DAC_STATE_TIMEOUT;
1277 
1278  return HAL_TIMEOUT;
1279  }
1280  }
1281  HAL_Delay(1U);
1282  hdac->Instance->SHSR2 = sConfig->DAC_SampleAndHoldConfig.DAC_SampleTime;
1283  }
1284 #endif /* STM32L451xx STM32L452xx STM32L462xx */
1285 
1286  /* HoldTime */
1287  MODIFY_REG(hdac->Instance->SHHR, DAC_SHHR_THOLD1 << (Channel & 0x10UL), (sConfig->DAC_SampleAndHoldConfig.DAC_HoldTime) << (Channel & 0x10UL));
1288  /* RefreshTime */
1289  MODIFY_REG(hdac->Instance->SHRR, DAC_SHRR_TREFRESH1 << (Channel & 0x10UL), (sConfig->DAC_SampleAndHoldConfig.DAC_RefreshTime) << (Channel & 0x10UL));
1290  }
1291 
1292  if (sConfig->DAC_UserTrimming == DAC_TRIMMING_USER)
1293  /* USER TRIMMING */
1294  {
1295  /* Get the DAC CCR value */
1296  tmpreg1 = hdac->Instance->CCR;
1297  /* Clear trimming value */
1298  tmpreg1 &= ~(((uint32_t)(DAC_CCR_OTRIM1)) << (Channel & 0x10UL));
1299  /* Configure for the selected trimming offset */
1300  tmpreg2 = sConfig->DAC_TrimmingValue;
1301  /* Calculate CCR register value depending on DAC_Channel */
1302  tmpreg1 |= tmpreg2 << (Channel & 0x10UL);
1303  /* Write to DAC CCR */
1304  hdac->Instance->CCR = tmpreg1;
1305  }
1306  /* else factory trimming is used (factory setting are available at reset)*/
1307  /* SW Nothing has nothing to do */
1308 
1309  /* Get the DAC MCR value */
1310  tmpreg1 = hdac->Instance->MCR;
1311  /* Clear DAC_MCR_MODEx bits */
1312  tmpreg1 &= ~(((uint32_t)(DAC_MCR_MODE1)) << (Channel & 0x10UL));
1313  /* Configure for the selected DAC channel: mode, buffer output & on chip peripheral connect */
1314  tmpreg2 = (sConfig->DAC_SampleAndHold | sConfig->DAC_OutputBuffer | sConfig->DAC_ConnectOnChipPeripheral);
1315  /* Calculate MCR register value depending on DAC_Channel */
1316  tmpreg1 |= tmpreg2 << (Channel & 0x10UL);
1317  /* Write to DAC MCR */
1318  hdac->Instance->MCR = tmpreg1;
1319 
1320  /* DAC in normal operating mode hence clear DAC_CR_CENx bit */
1321  CLEAR_BIT(hdac->Instance->CR, DAC_CR_CEN1 << (Channel & 0x10UL));
1322 
1323  /* Get the DAC CR value */
1324  tmpreg1 = hdac->Instance->CR;
1325  /* Clear TENx, TSELx, WAVEx and MAMPx bits */
1326  tmpreg1 &= ~(((uint32_t)(DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1)) << (Channel & 0x10UL));
1327  /* Configure for the selected DAC channel: trigger */
1328  /* Set TSELx and TENx bits according to DAC_Trigger value */
1329  tmpreg2 = sConfig->DAC_Trigger;
1330  /* Calculate CR register value depending on DAC_Channel */
1331  tmpreg1 |= tmpreg2 << (Channel & 0x10UL);
1332 #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
1333  if (DAC_HIGH_FREQUENCY_INTERFACE_MODE_ABOVE_80MHZ == sConfig->DAC_HighFrequency)
1334  {
1335  tmpreg1 |= DAC_CR_HFSEL;
1336  }
1337  else
1338  {
1339  if (DAC_HIGH_FREQUENCY_INTERFACE_MODE_DISABLE == sConfig->DAC_HighFrequency)
1340  {
1341  tmpreg1 &= ~(DAC_CR_HFSEL);
1342  }
1343  else /* Automatic selection */
1344  {
1345  hclkfreq = HAL_RCC_GetHCLKFreq();
1346  if (hclkfreq > HFSEL_ENABLE_THRESHOLD_80MHZ)
1347  {
1348  /* High frequency enable when HCLK frequency higher than 80 */
1349  tmpreg1 |= DAC_CR_HFSEL;
1350  }
1351  else
1352  {
1353  /* High frequency disable when HCLK frequency higher than 80 */
1354  tmpreg1 &= ~(DAC_CR_HFSEL);
1355  }
1356  }
1357  }
1358 
1359 #endif /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
1360 
1361  /* Write to DAC CR */
1362  hdac->Instance->CR = tmpreg1;
1363  /* Disable wave generation */
1364  hdac->Instance->CR &= ~(DAC_CR_WAVE1 << (Channel & 0x10UL));
1365 
1366  /* Change DAC state */
1367  hdac->State = HAL_DAC_STATE_READY;
1368 
1369  /* Process unlocked */
1370  __HAL_UNLOCK(hdac);
1371 
1372  /* Return function status */
1373  return HAL_OK;
1374 }
1375 
1402 HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef *hdac)
1403 {
1404  /* Return DAC handle state */
1405  return hdac->State;
1406 }
1407 
1408 
1416 {
1417  return hdac->ErrorCode;
1418 }
1419 
1435 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
1436 
1458  pDAC_CallbackTypeDef pCallback)
1459 {
1460  HAL_StatusTypeDef status = HAL_OK;
1461 
1462  if (pCallback == NULL)
1463  {
1464  /* Update the error code */
1465  hdac->ErrorCode |= HAL_DAC_ERROR_INVALID_CALLBACK;
1466  return HAL_ERROR;
1467  }
1468 
1469  /* Process locked */
1470  __HAL_LOCK(hdac);
1471 
1472  if (hdac->State == HAL_DAC_STATE_READY)
1473  {
1474  switch (CallbackID)
1475  {
1477  hdac->ConvCpltCallbackCh1 = pCallback;
1478  break;
1480  hdac->ConvHalfCpltCallbackCh1 = pCallback;
1481  break;
1482  case HAL_DAC_CH1_ERROR_ID :
1483  hdac->ErrorCallbackCh1 = pCallback;
1484  break;
1486  hdac->DMAUnderrunCallbackCh1 = pCallback;
1487  break;
1489  hdac->ConvCpltCallbackCh2 = pCallback;
1490  break;
1492  hdac->ConvHalfCpltCallbackCh2 = pCallback;
1493  break;
1494  case HAL_DAC_CH2_ERROR_ID :
1495  hdac->ErrorCallbackCh2 = pCallback;
1496  break;
1498  hdac->DMAUnderrunCallbackCh2 = pCallback;
1499  break;
1500  case HAL_DAC_MSPINIT_CB_ID :
1501  hdac->MspInitCallback = pCallback;
1502  break;
1504  hdac->MspDeInitCallback = pCallback;
1505  break;
1506  default :
1507  /* Update the error code */
1508  hdac->ErrorCode |= HAL_DAC_ERROR_INVALID_CALLBACK;
1509  /* update return status */
1510  status = HAL_ERROR;
1511  break;
1512  }
1513  }
1514  else if (hdac->State == HAL_DAC_STATE_RESET)
1515  {
1516  switch (CallbackID)
1517  {
1518  case HAL_DAC_MSPINIT_CB_ID :
1519  hdac->MspInitCallback = pCallback;
1520  break;
1522  hdac->MspDeInitCallback = pCallback;
1523  break;
1524  default :
1525  /* Update the error code */
1526  hdac->ErrorCode |= HAL_DAC_ERROR_INVALID_CALLBACK;
1527  /* update return status */
1528  status = HAL_ERROR;
1529  break;
1530  }
1531  }
1532  else
1533  {
1534  /* Update the error code */
1535  hdac->ErrorCode |= HAL_DAC_ERROR_INVALID_CALLBACK;
1536  /* update return status */
1537  status = HAL_ERROR;
1538  }
1539 
1540  /* Release Lock */
1541  __HAL_UNLOCK(hdac);
1542  return status;
1543 }
1544 
1565 {
1566  HAL_StatusTypeDef status = HAL_OK;
1567 
1568  /* Process locked */
1569  __HAL_LOCK(hdac);
1570 
1571  if (hdac->State == HAL_DAC_STATE_READY)
1572  {
1573  switch (CallbackID)
1574  {
1576  hdac->ConvCpltCallbackCh1 = HAL_DAC_ConvCpltCallbackCh1;
1577  break;
1579  hdac->ConvHalfCpltCallbackCh1 = HAL_DAC_ConvHalfCpltCallbackCh1;
1580  break;
1581  case HAL_DAC_CH1_ERROR_ID :
1582  hdac->ErrorCallbackCh1 = HAL_DAC_ErrorCallbackCh1;
1583  break;
1585  hdac->DMAUnderrunCallbackCh1 = HAL_DAC_DMAUnderrunCallbackCh1;
1586  break;
1588  hdac->ConvCpltCallbackCh2 = HAL_DACEx_ConvCpltCallbackCh2;
1589  break;
1591  hdac->ConvHalfCpltCallbackCh2 = HAL_DACEx_ConvHalfCpltCallbackCh2;
1592  break;
1593  case HAL_DAC_CH2_ERROR_ID :
1594  hdac->ErrorCallbackCh2 = HAL_DACEx_ErrorCallbackCh2;
1595  break;
1597  hdac->DMAUnderrunCallbackCh2 = HAL_DACEx_DMAUnderrunCallbackCh2;
1598  break;
1599  case HAL_DAC_MSPINIT_CB_ID :
1600  hdac->MspInitCallback = HAL_DAC_MspInit;
1601  break;
1603  hdac->MspDeInitCallback = HAL_DAC_MspDeInit;
1604  break;
1605  case HAL_DAC_ALL_CB_ID :
1606  hdac->ConvCpltCallbackCh1 = HAL_DAC_ConvCpltCallbackCh1;
1607  hdac->ConvHalfCpltCallbackCh1 = HAL_DAC_ConvHalfCpltCallbackCh1;
1608  hdac->ErrorCallbackCh1 = HAL_DAC_ErrorCallbackCh1;
1609  hdac->DMAUnderrunCallbackCh1 = HAL_DAC_DMAUnderrunCallbackCh1;
1610  hdac->ConvCpltCallbackCh2 = HAL_DACEx_ConvCpltCallbackCh2;
1611  hdac->ConvHalfCpltCallbackCh2 = HAL_DACEx_ConvHalfCpltCallbackCh2;
1612  hdac->ErrorCallbackCh2 = HAL_DACEx_ErrorCallbackCh2;
1613  hdac->DMAUnderrunCallbackCh2 = HAL_DACEx_DMAUnderrunCallbackCh2;
1614  hdac->MspInitCallback = HAL_DAC_MspInit;
1615  hdac->MspDeInitCallback = HAL_DAC_MspDeInit;
1616  break;
1617  default :
1618  /* Update the error code */
1619  hdac->ErrorCode |= HAL_DAC_ERROR_INVALID_CALLBACK;
1620  /* update return status */
1621  status = HAL_ERROR;
1622  break;
1623  }
1624  }
1625  else if (hdac->State == HAL_DAC_STATE_RESET)
1626  {
1627  switch (CallbackID)
1628  {
1629  case HAL_DAC_MSPINIT_CB_ID :
1630  hdac->MspInitCallback = HAL_DAC_MspInit;
1631  break;
1633  hdac->MspDeInitCallback = HAL_DAC_MspDeInit;
1634  break;
1635  default :
1636  /* Update the error code */
1637  hdac->ErrorCode |= HAL_DAC_ERROR_INVALID_CALLBACK;
1638  /* update return status */
1639  status = HAL_ERROR;
1640  break;
1641  }
1642  }
1643  else
1644  {
1645  /* Update the error code */
1646  hdac->ErrorCode |= HAL_DAC_ERROR_INVALID_CALLBACK;
1647  /* update return status */
1648  status = HAL_ERROR;
1649  }
1650 
1651  /* Release Lock */
1652  __HAL_UNLOCK(hdac);
1653  return status;
1654 }
1655 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
1656 
1676 {
1677  DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
1678 
1679 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
1680  hdac->ConvCpltCallbackCh1(hdac);
1681 #else
1683 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
1684 
1685  hdac->State = HAL_DAC_STATE_READY;
1686 }
1687 
1695 {
1696  DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
1697  /* Conversion complete callback */
1698 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
1699  hdac->ConvHalfCpltCallbackCh1(hdac);
1700 #else
1702 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
1703 }
1704 
1712 {
1713  DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
1714 
1715  /* Set DAC error code to DMA error */
1716  hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
1717 
1718 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
1719  hdac->ErrorCallbackCh1(hdac);
1720 #else
1722 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
1723 
1724  hdac->State = HAL_DAC_STATE_READY;
1725 }
1726 
1735 #endif /* DAC1 */
1736 
1737 #endif /* HAL_DAC_MODULE_ENABLED */
1738 
1743 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void(* pDAC_CallbackTypeDef)(DAC_HandleTypeDef *hdac)
HAL DAC Callback pointer definition.
struct __DAC_HandleTypeDef else typedef struct endif DAC_HandleTypeDef
DAC handle Structure definition.
HAL_DAC_CallbackIDTypeDef
HAL DAC Callback ID enumeration definition.
HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef *hdac)
Deinitialize the DAC peripheral registers to their default reset values.
void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma)
DMA error callback.
HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef *hdac)
Initialize the DAC peripheral according to the specified parameters in the DAC_InitStruct and initial...
HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t *pData, uint32_t Length, uint32_t Alignment)
Enables DAC and starts conversion of channel.
void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef *hdac)
Conversion complete callback in non-blocking mode for Channel2.
HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef *hdac)
return the DAC handle state
DMA handle Structure definition.
if(lpuartdiv >=LPUART_BRR_MIN_VALUE)
This file contains all the functions prototypes for the HAL module driver.
void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef *hdac)
Conversion half DMA transfer callback in non-blocking mode for Channel2.
DAC Configuration regular Channel structure definition.
void HAL_Delay(uint32_t Delay)
This function provides minimum delay (in milliseconds) based on variable incremented.
uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac)
Return the DAC error code.
void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
DMA error callback.
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
__HAL_UNLOCK(hrtc)
void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma)
DMA half transfer complete callback.
void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef *hdac)
Conversion half DMA transfer callback in non-blocking mode for Channel1.
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.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
DMA underrun DAC callback for channel1.
return HAL_OK
HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef *hdac, uint32_t Channel)
Disables DAC and stop conversion of channel.
void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma)
DMA conversion complete callback.
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
HAL_StatusTypeDef HAL_DAC_UnRegisterCallback(DAC_HandleTypeDef *hdac, HAL_DAC_CallbackIDTypeDef CallbackID)
Unregister a User DAC Callback DAC Callback is redirected to the weak (surcharged) predefined callbac...
HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data)
Set the specified data holding register value for DAC channel.
HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel)
Disables DAC and stop conversion of channel.
void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac)
Error DAC callback for Channel1.
HAL_StatusTypeDef HAL_DAC_RegisterCallback(DAC_HandleTypeDef *hdac, HAL_DAC_CallbackIDTypeDef CallbackID, pDAC_CallbackTypeDef pCallback)
Register a User DAC Callback To be used instead of the weak (surcharged) predefined callback...
HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef *hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel)
Configures the selected DAC channel.
void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef *hdac)
Conversion complete callback in non-blocking mode for Channel1.
uint32_t HAL_RCC_GetHCLKFreq(void)
Return the HCLK frequency.
DAC_SampleAndHoldConfTypeDef DAC_SampleAndHoldConfig
void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac)
DeInitialize the DAC MSP.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
void HAL_DAC_IRQHandler(DAC_HandleTypeDef *hdac)
Handles DAC interrupt request This function uses the interruption of DMA underrun.
void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
DMA underrun DAC callback for Channel2.
void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac)
Initialize the DAC MSP.
void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
DMA conversion complete callback.
void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
DMA half transfer complete callback.
HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef *hdac, uint32_t Channel)
Enables DAC and starts conversion of channel.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
Error DAC callback for Channel2.
uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef *hdac, uint32_t Channel)
Returns the last data output value of the selected DAC channel.