/* Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct.  */
void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef *DAC_InitStruct)
/* Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct.  */
void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef *DAC_InitStruct)
{
  uint32_t tmpreg1 = 0, tmpreg2 = 0;
  assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger));
  assert_param(IS_DAC_GENERATE_WAVE(DAC_InitStruct->DAC_WaveGeneration));
  assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude));
  assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer));
  tmpreg1 = DAC->CR;
  tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel);   
  tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_WaveGeneration |
             DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude | DAC_InitStruct->DAC_OutputBuffer);
  tmpreg1 |= tmpreg2 << DAC_Channel;
  DAC->CR = tmpreg1;
}