STM32L4xx_HAL_Driver  1.14.0
IO operation functions

IO operation functions. More...

Functions

HAL_StatusTypeDef HAL_DAC_Start (DAC_HandleTypeDef *hdac, uint32_t Channel)
 Enables DAC and starts conversion of channel. More...
 
HAL_StatusTypeDef HAL_DAC_Stop (DAC_HandleTypeDef *hdac, uint32_t Channel)
 Disables DAC and stop conversion of channel. More...
 
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. More...
 
HAL_StatusTypeDef HAL_DAC_Stop_DMA (DAC_HandleTypeDef *hdac, uint32_t Channel)
 Disables DAC and stop conversion of channel. More...
 
void HAL_DAC_IRQHandler (DAC_HandleTypeDef *hdac)
 Handles DAC interrupt request This function uses the interruption of DMA underrun. More...
 
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. More...
 
void HAL_DAC_ConvCpltCallbackCh1 (DAC_HandleTypeDef *hdac)
 Conversion complete callback in non-blocking mode for Channel1. More...
 
void HAL_DAC_ConvHalfCpltCallbackCh1 (DAC_HandleTypeDef *hdac)
 Conversion half DMA transfer callback in non-blocking mode for Channel1. More...
 
void HAL_DAC_ErrorCallbackCh1 (DAC_HandleTypeDef *hdac)
 Error DAC callback for Channel1. More...
 
void HAL_DAC_DMAUnderrunCallbackCh1 (DAC_HandleTypeDef *hdac)
 DMA underrun DAC callback for channel1. More...
 
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. More...
 
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 callback. More...
 

Detailed Description

IO operation functions.

  ==============================================================================
             ##### IO operation functions #####
  ==============================================================================
    [..]  This section provides functions allowing to:
      (+) Start conversion.
      (+) Stop conversion.
      (+) Start conversion and enable DMA transfer.
      (+) Stop conversion and disable DMA transfer.
      (+) Get result of conversion.

Function Documentation

◆ HAL_DAC_ConvCpltCallbackCh1()

__weak void HAL_DAC_ConvCpltCallbackCh1 ( DAC_HandleTypeDef hdac)

Conversion complete callback in non-blocking mode for Channel1.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
Return values
None

Definition at line 1067 of file stm32l4xx_hal_dac.c.

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 }

◆ HAL_DAC_ConvHalfCpltCallbackCh1()

__weak void HAL_DAC_ConvHalfCpltCallbackCh1 ( DAC_HandleTypeDef hdac)

Conversion half DMA transfer callback in non-blocking mode for Channel1.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
Return values
None

Definition at line 1083 of file stm32l4xx_hal_dac.c.

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 }

◆ HAL_DAC_DMAUnderrunCallbackCh1()

__weak void HAL_DAC_DMAUnderrunCallbackCh1 ( DAC_HandleTypeDef hdac)

DMA underrun DAC callback for channel1.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
Return values
None

Definition at line 1115 of file stm32l4xx_hal_dac.c.

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 }

◆ HAL_DAC_ErrorCallbackCh1()

__weak void HAL_DAC_ErrorCallbackCh1 ( DAC_HandleTypeDef hdac)

Error DAC callback for Channel1.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
Return values
None

Definition at line 1099 of file stm32l4xx_hal_dac.c.

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 }

◆ HAL_DAC_IRQHandler()

void HAL_DAC_IRQHandler ( DAC_HandleTypeDef hdac)

Handles DAC interrupt request This function uses the interruption of DMA underrun.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
Return values
None

Definition at line 959 of file stm32l4xx_hal_dac.c.

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 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
DMA underrun DAC callback for channel1.
void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
DMA underrun DAC callback for Channel2.

◆ HAL_DAC_RegisterCallback()

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.

Parameters
hdacDAC handle
CallbackIDID of the callback to be registered This parameter can be one of the following values:
pCallbackpointer to the Callback function
Return values
status

Definition at line 1457 of file stm32l4xx_hal_dac.c.

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 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_DAC_SetValue()

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.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
ChannelThe selected DAC channel. This parameter can be one of the following values:
  • DAC_CHANNEL_1: DAC Channel1 selected
  • DAC_CHANNEL_2: DAC Channel2 selected
AlignmentSpecifies the data alignment. This parameter can be one of the following values:
  • DAC_ALIGN_8B_R: 8bit right data alignment selected
  • DAC_ALIGN_12B_L: 12bit left data alignment selected
  • DAC_ALIGN_12B_R: 12bit right data alignment selected
DataData to be loaded in the selected data holding register.
Return values
HALstatus

Definition at line 1035 of file stm32l4xx_hal_dac.c.

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 }
if(lpuartdiv >=LPUART_BRR_MIN_VALUE)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_DAC_Start()

HAL_StatusTypeDef HAL_DAC_Start ( DAC_HandleTypeDef hdac,
uint32_t  Channel 
)

Enables DAC and starts conversion of channel.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
ChannelThe selected DAC channel. This parameter can be one of the following values:
  • DAC_CHANNEL_1: DAC Channel1 selected
  • DAC_CHANNEL_2: DAC Channel2 selected (when supported)
Return values
HALstatus

Definition at line 541 of file stm32l4xx_hal_dac.c.

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 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_DAC_Start_DMA()

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.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
ChannelThe selected DAC channel. This parameter can be one of the following values:
  • DAC_CHANNEL_1: DAC Channel1 selected
pDataThe destination peripheral Buffer address.
LengthThe length of data to be transferred from memory to DAC peripheral
AlignmentSpecifies the data alignment for DAC channel. This parameter can be one of the following values:
  • DAC_ALIGN_8B_R: 8bit right data alignment selected
  • DAC_ALIGN_12B_L: 12bit left data alignment selected
  • DAC_ALIGN_12B_R: 12bit right data alignment selected
Return values
HALstatus
Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
ChannelThe selected DAC channel. This parameter can be one of the following values:
  • DAC_CHANNEL_1: DAC Channel1 selected
  • DAC_CHANNEL_2: DAC Channel2 selected
pDataThe destination peripheral Buffer address.
LengthThe length of data to be transferred from memory to DAC peripheral
AlignmentSpecifies the data alignment for DAC channel. This parameter can be one of the following values:
  • DAC_ALIGN_8B_R: 8bit right data alignment selected
  • DAC_ALIGN_12B_L: 12bit left data alignment selected
  • DAC_ALIGN_12B_R: 12bit right data alignment selected
Return values
HALstatus

Definition at line 661 of file stm32l4xx_hal_dac.c.

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 }
void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma)
DMA error callback.
__HAL_UNLOCK(hrtc)
void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma)
DMA half transfer complete callback.
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)
return HAL_OK
void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma)
DMA conversion complete callback.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_DAC_Stop()

HAL_StatusTypeDef HAL_DAC_Stop ( DAC_HandleTypeDef hdac,
uint32_t  Channel 
)

Disables DAC and stop conversion of channel.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
ChannelThe selected DAC channel. This parameter can be one of the following values:
  • DAC_CHANNEL_1: DAC Channel1 selected
  • DAC_CHANNEL_2: DAC Channel2 selected
Return values
HALstatus

Definition at line 629 of file stm32l4xx_hal_dac.c.

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 }
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_DAC_Stop_DMA()

HAL_StatusTypeDef HAL_DAC_Stop_DMA ( DAC_HandleTypeDef hdac,
uint32_t  Channel 
)

Disables DAC and stop conversion of channel.

Parameters
hdacpointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC.
ChannelThe selected DAC channel. This parameter can be one of the following values:
  • DAC_CHANNEL_1: DAC Channel1 selected
  • DAC_CHANNEL_2: DAC Channel2 selected
Return values
HALstatus

Definition at line 885 of file stm32l4xx_hal_dac.c.

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 }
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_DAC_UnRegisterCallback()

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 callback.

Parameters
hdacDAC handle
CallbackIDID of the callback to be unregistered This parameter can be one of the following values:
Return values
status

Definition at line 1564 of file stm32l4xx_hal_dac.c.

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 }
void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef *hdac)
Conversion complete callback in non-blocking mode for Channel2.
void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef *hdac)
Conversion half DMA transfer callback in non-blocking mode for Channel2.
__HAL_UNLOCK(hrtc)
void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef *hdac)
Conversion half DMA transfer callback in non-blocking mode for Channel1.
__HAL_LOCK(hrtc)
void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
DMA underrun DAC callback for channel1.
return HAL_OK
void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac)
Error DAC callback for Channel1.
void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef *hdac)
Conversion complete callback in non-blocking mode for Channel1.
void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac)
DeInitialize the DAC MSP.
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 HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
Error DAC callback for Channel2.