STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Functions

ErrorStatus LL_DAC_DeInit (DAC_TypeDef *DACx)
 De-initialize registers of the selected DAC instance to their default reset values. More...
 
ErrorStatus LL_DAC_Init (DAC_TypeDef *DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef *DAC_InitStruct)
 Initialize some features of DAC channel. More...
 
void LL_DAC_StructInit (LL_DAC_InitTypeDef *DAC_InitStruct)
 Set each LL_DAC_InitTypeDef field to default value. More...
 

Detailed Description

Function Documentation

◆ LL_DAC_DeInit()

ErrorStatus LL_DAC_DeInit ( DAC_TypeDef *  DACx)

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

Parameters
DACxDAC instance
Return values
AnErrorStatus enumeration value:
  • SUCCESS: DAC registers are de-initialized
  • ERROR: not applicable

Definition at line 167 of file stm32l4xx_ll_dac.c.

168 {
169  /* Check the parameters */
170  assert_param(IS_DAC_ALL_INSTANCE(DACx));
171 
172  /* Force reset of DAC clock */
173  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_DAC1);
174 
175  /* Release reset of DAC clock */
176  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_DAC1);
177 
178  return SUCCESS;
179 }
__STATIC_INLINE void LL_APB1_GRP1_ReleaseReset(uint32_t Periphs)
Release APB1 peripherals reset. APB1RSTR1 TIM2RST LL_APB1_GRP1_ReleaseReset APB1RSTR1 TIM3RST LL_AP...
__STATIC_INLINE void LL_APB1_GRP1_ForceReset(uint32_t Periphs)
Force APB1 peripherals reset. APB1RSTR1 TIM2RST LL_APB1_GRP1_ForceReset APB1RSTR1 TIM3RST LL_APB1_G...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_DAC_Init()

ErrorStatus LL_DAC_Init ( DAC_TypeDef *  DACx,
uint32_t  DAC_Channel,
LL_DAC_InitTypeDef DAC_InitStruct 
)

Initialize some features of DAC channel.

Note
LL_DAC_Init() aims to ease basic configuration of a DAC channel. Leaving it ready to be enabled and output: a level by calling one of LL_DAC_ConvertData12RightAligned LL_DAC_ConvertData12LeftAligned LL_DAC_ConvertData8RightAligned or one of the supported autogenerated wave.
This function allows configuration of:
  • Output mode
  • Trigger
  • Wave generation
The setting of these parameters by function LL_DAC_Init() is conditioned to DAC state: DAC channel must be disabled.
Parameters
DACxDAC instance
DAC_ChannelThis parameter can be one of the following values:
  • LL_DAC_CHANNEL_1
  • LL_DAC_CHANNEL_2 (1)
(1) On this STM32 serie, parameter not available on all devices. Refer to device datasheet for channels availability.
DAC_InitStructPointer to a LL_DAC_InitTypeDef structure
Return values
AnErrorStatus enumeration value:
  • SUCCESS: DAC registers are initialized
  • ERROR: DAC registers are not initialized

Definition at line 209 of file stm32l4xx_ll_dac.c.

210 {
211  ErrorStatus status = SUCCESS;
212 
213  /* Check the parameters */
214  assert_param(IS_DAC_ALL_INSTANCE(DACx));
215  assert_param(IS_LL_DAC_CHANNEL(DAC_Channel));
216  assert_param(IS_LL_DAC_TRIGGER_SOURCE(DAC_InitStruct->TriggerSource));
217  assert_param(IS_LL_DAC_OUTPUT_BUFFER(DAC_InitStruct->OutputBuffer));
218  assert_param(IS_LL_DAC_OUTPUT_CONNECTION(DAC_InitStruct->OutputConnection));
219  assert_param(IS_LL_DAC_OUTPUT_MODE(DAC_InitStruct->OutputMode));
220  assert_param(IS_LL_DAC_WAVE_AUTO_GENER_MODE(DAC_InitStruct->WaveAutoGeneration));
221  if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE)
222  {
223  assert_param(IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(DAC_InitStruct->WaveAutoGeneration,
224  DAC_InitStruct->WaveAutoGenerationConfig));
225  }
226 
227  /* Note: Hardware constraint (refer to description of this function) */
228  /* DAC instance must be disabled. */
229  if (LL_DAC_IsEnabled(DACx, DAC_Channel) == 0U)
230  {
231  /* Configuration of DAC channel: */
232  /* - TriggerSource */
233  /* - WaveAutoGeneration */
234  /* - OutputBuffer */
235  /* - OutputConnection */
236  /* - OutputMode */
237  if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE)
238  {
239  MODIFY_REG(DACx->CR,
240  (DAC_CR_TSEL1
241  | DAC_CR_WAVE1
242  | DAC_CR_MAMP1
243  ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
244  ,
245  (DAC_InitStruct->TriggerSource
246  | DAC_InitStruct->WaveAutoGeneration
247  | DAC_InitStruct->WaveAutoGenerationConfig
248  ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
249  );
250  }
251  else
252  {
253  MODIFY_REG(DACx->CR,
254  (DAC_CR_TSEL1
255  | DAC_CR_WAVE1
256  ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
257  ,
258  (DAC_InitStruct->TriggerSource
259  | LL_DAC_WAVE_AUTO_GENERATION_NONE
260  ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
261  );
262  }
263  MODIFY_REG(DACx->MCR,
264  (DAC_MCR_MODE1_1
265  | DAC_MCR_MODE1_0
266  | DAC_MCR_MODE1_2
267  ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
268  ,
269  (DAC_InitStruct->OutputBuffer
270  | DAC_InitStruct->OutputConnection
271  | DAC_InitStruct->OutputMode
272  ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
273  );
274  }
275  else
276  {
277  /* Initialization error: DAC instance is not disabled. */
278  status = ERROR;
279  }
280  return status;
281 }
uint32_t WaveAutoGenerationConfig
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__STATIC_INLINE uint32_t LL_DAC_IsEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
Get DAC enable state of the selected channel. (0: DAC channel is disabled, 1: DAC channel is enabled)...

◆ LL_DAC_StructInit()

void LL_DAC_StructInit ( LL_DAC_InitTypeDef DAC_InitStruct)

Set each LL_DAC_InitTypeDef field to default value.

Parameters
DAC_InitStructpointer to a LL_DAC_InitTypeDef structure whose fields will be set to default values.
Return values
None

Definition at line 289 of file stm32l4xx_ll_dac.c.

290 {
291  /* Set DAC_InitStruct fields to default values */
292  DAC_InitStruct->TriggerSource = LL_DAC_TRIG_SOFTWARE;
293  DAC_InitStruct->WaveAutoGeneration = LL_DAC_WAVE_AUTO_GENERATION_NONE;
294  /* Note: Parameter discarded if wave auto generation is disabled, */
295  /* set anyway to its default value. */
296  DAC_InitStruct->WaveAutoGenerationConfig = LL_DAC_NOISE_LFSR_UNMASK_BIT0;
297  DAC_InitStruct->OutputBuffer = LL_DAC_OUTPUT_BUFFER_ENABLE;
298  DAC_InitStruct->OutputConnection = LL_DAC_OUTPUT_CONNECT_GPIO;
299  DAC_InitStruct->OutputMode = LL_DAC_OUTPUT_MODE_NORMAL;
300 }
uint32_t WaveAutoGenerationConfig