147 #define CR_CLEAR_MASK ((uint32_t)0x00000FFE)
150 #define DUAL_SWTRIG_SET ((uint32_t)0x00000003)
151 #define DUAL_SWTRIG_RESET ((uint32_t)0xFFFFFFFC)
154 #define DHR12R1_OFFSET ((uint32_t)0x00000008)
155 #define DHR12R2_OFFSET ((uint32_t)0x00000014)
156 #define DHR12RD_OFFSET ((uint32_t)0x00000020)
159 #define DOR_OFFSET ((uint32_t)0x0000002C)
208 uint32_t tmpreg1 = 0, tmpreg2 = 0;
211 assert_param(IS_DAC_TRIGGER(DAC_InitStruct->
DAC_Trigger));
220 tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel);
229 DAC_InitStruct->DAC_OutputBuffer);
231 tmpreg1 |= tmpreg2 << DAC_Channel;
266 void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState)
269 assert_param(IS_DAC_CHANNEL(DAC_Channel));
270 assert_param(IS_FUNCTIONAL_STATE(NewState));
272 if (NewState != DISABLE)
275 DAC->CR |= (DAC_CR_EN1 << DAC_Channel);
280 DAC->CR &= (~(DAC_CR_EN1 << DAC_Channel));
297 assert_param(IS_DAC_CHANNEL(DAC_Channel));
298 assert_param(IS_FUNCTIONAL_STATE(NewState));
300 if (NewState != DISABLE)
303 DAC->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4);
308 DAC->SWTRIGR &= ~((uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4));
321 assert_param(IS_FUNCTIONAL_STATE(NewState));
323 if (NewState != DISABLE)
326 DAC->SWTRIGR |= DUAL_SWTRIG_SET;
331 DAC->SWTRIGR &= DUAL_SWTRIG_RESET;
352 assert_param(IS_DAC_CHANNEL(DAC_Channel));
353 assert_param(IS_DAC_WAVE(DAC_Wave));
354 assert_param(IS_FUNCTIONAL_STATE(NewState));
356 if (NewState != DISABLE)
359 DAC->CR |= DAC_Wave << DAC_Channel;
364 DAC->CR &= ~(DAC_Wave << DAC_Channel);
380 __IO uint32_t tmp = 0;
383 assert_param(IS_DAC_ALIGN(DAC_Align));
384 assert_param(IS_DAC_DATA(Data));
386 tmp = (uint32_t)DAC_BASE;
387 tmp += DHR12R1_OFFSET + DAC_Align;
390 *(__IO uint32_t *) tmp = Data;
405 __IO uint32_t tmp = 0;
408 assert_param(IS_DAC_ALIGN(DAC_Align));
409 assert_param(IS_DAC_DATA(Data));
411 tmp = (uint32_t)DAC_BASE;
412 tmp += DHR12R2_OFFSET + DAC_Align;
415 *(__IO uint32_t *)tmp = Data;
433 uint32_t data = 0, tmp = 0;
436 assert_param(IS_DAC_ALIGN(DAC_Align));
437 assert_param(IS_DAC_DATA(Data1));
438 assert_param(IS_DAC_DATA(Data2));
441 if (DAC_Align == DAC_Align_8b_R)
443 data = ((uint32_t)Data2 << 8) | Data1;
447 data = ((uint32_t)Data2 << 16) | Data1;
450 tmp = (uint32_t)DAC_BASE;
451 tmp += DHR12RD_OFFSET + DAC_Align;
454 *(__IO uint32_t *)tmp = data;
467 __IO uint32_t tmp = 0;
470 assert_param(IS_DAC_CHANNEL(DAC_Channel));
472 tmp = (uint32_t) DAC_BASE ;
473 tmp += DOR_OFFSET + ((uint32_t)DAC_Channel >> 2);
476 return (uint16_t) (*(__IO uint32_t*) tmp);
510 void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState)
513 assert_param(IS_DAC_CHANNEL(DAC_Channel));
514 assert_param(IS_FUNCTIONAL_STATE(NewState));
516 if (NewState != DISABLE)
519 DAC->CR |= (DAC_CR_DMAEN1 << DAC_Channel);
524 DAC->CR &= (~(DAC_CR_DMAEN1 << DAC_Channel));
558 void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState)
561 assert_param(IS_DAC_CHANNEL(DAC_Channel));
562 assert_param(IS_FUNCTIONAL_STATE(NewState));
563 assert_param(IS_DAC_IT(DAC_IT));
565 if (NewState != DISABLE)
568 DAC->CR |= (DAC_IT << DAC_Channel);
573 DAC->CR &= (~(uint32_t)(DAC_IT << DAC_Channel));
592 FlagStatus bitstatus = RESET;
594 assert_param(IS_DAC_CHANNEL(DAC_Channel));
595 assert_param(IS_DAC_FLAG(DAC_FLAG));
598 if ((DAC->SR & (DAC_FLAG << DAC_Channel)) != (uint8_t)RESET)
628 assert_param(IS_DAC_CHANNEL(DAC_Channel));
629 assert_param(IS_DAC_FLAG(DAC_FLAG));
632 DAC->SR = (DAC_FLAG << DAC_Channel);
650 ITStatus bitstatus = RESET;
651 uint32_t enablestatus = 0;
654 assert_param(IS_DAC_CHANNEL(DAC_Channel));
655 assert_param(IS_DAC_IT(DAC_IT));
658 enablestatus = (DAC->CR & (DAC_IT << DAC_Channel)) ;
661 if (((DAC->SR & (DAC_IT << DAC_Channel)) != (uint32_t)RESET) && enablestatus)
691 assert_param(IS_DAC_CHANNEL(DAC_Channel));
692 assert_param(IS_DAC_IT(DAC_IT));
695 DAC->SR = (DAC_IT << DAC_Channel);
This file contains all the functions prototypes for the RCC firmware library.
FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG)
Checks whether the specified DAC flag is set or not.
void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState)
Enables or disables the selected DAC channel software trigger.
void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState)
Enables or disables the specified DAC channel.
void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG)
Clears the DAC channel's pending flags.
void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState)
Enables or disables the specified DAC channel DMA request.
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_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState)
Enables or disables the specified DAC interrupts.
#define DAC_LFSRUnmask_Bit0
uint32_t DAC_OutputBuffer
void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
Set the specified data holding register value for dual channel DAC.
This file contains all the functions prototypes for the DAC firmware library.
ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT)
Checks whether the specified DAC interrupt has occurred or not.
DAC Init structure definition.
uint32_t DAC_WaveGeneration
void DAC_StructInit(DAC_InitTypeDef *DAC_InitStruct)
Fills each DAC_InitStruct member with its default value.
void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT)
Clears the DAC channel's interrupt pending bits.
void DAC_DeInit(void)
Deinitializes the DAC peripheral registers to their default reset values.
uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel)
Returns the last data output value of the selected DAC channel.
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data)
Set the specified data holding register value for DAC channel2.
void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data)
Set the specified data holding register value for DAC channel1.
void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
Enables or disables the selected DAC channel wave generation.
void DAC_DualSoftwareTriggerCmd(FunctionalState NewState)
Enables or disables simultaneously the two DAC channels software triggers.
uint32_t DAC_LFSRUnmask_TriangleAmplitude