STM32F10x Standard Peripherals Library
3.5.0
|
00001 00023 /* Define to prevent recursive inclusion -------------------------------------*/ 00024 #ifndef __STM32F10x_DAC_H 00025 #define __STM32F10x_DAC_H 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 /* Includes ------------------------------------------------------------------*/ 00032 #include "stm32f10x.h" 00033 00050 typedef struct 00051 { 00052 uint32_t DAC_Trigger; 00055 uint32_t DAC_WaveGeneration; 00059 uint32_t DAC_LFSRUnmask_TriangleAmplitude; 00063 uint32_t DAC_OutputBuffer; 00065 }DAC_InitTypeDef; 00066 00079 #define DAC_Trigger_None ((uint32_t)0x00000000) 00081 #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) 00082 #define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C) 00084 #define DAC_Trigger_T3_TRGO ((uint32_t)0x0000000C) 00086 #define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014) 00087 #define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C) 00088 #define DAC_Trigger_T15_TRGO ((uint32_t)0x0000001C) 00090 #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) 00091 #define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C) 00092 #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) 00093 #define DAC_Trigger_Software ((uint32_t)0x0000003C) 00095 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \ 00096 ((TRIGGER) == DAC_Trigger_T6_TRGO) || \ 00097 ((TRIGGER) == DAC_Trigger_T8_TRGO) || \ 00098 ((TRIGGER) == DAC_Trigger_T7_TRGO) || \ 00099 ((TRIGGER) == DAC_Trigger_T5_TRGO) || \ 00100 ((TRIGGER) == DAC_Trigger_T2_TRGO) || \ 00101 ((TRIGGER) == DAC_Trigger_T4_TRGO) || \ 00102 ((TRIGGER) == DAC_Trigger_Ext_IT9) || \ 00103 ((TRIGGER) == DAC_Trigger_Software)) 00104 00113 #define DAC_WaveGeneration_None ((uint32_t)0x00000000) 00114 #define DAC_WaveGeneration_Noise ((uint32_t)0x00000040) 00115 #define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080) 00116 #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \ 00117 ((WAVE) == DAC_WaveGeneration_Noise) || \ 00118 ((WAVE) == DAC_WaveGeneration_Triangle)) 00119 00127 #define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) 00128 #define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) 00129 #define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200) 00130 #define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300) 00131 #define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400) 00132 #define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500) 00133 #define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600) 00134 #define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700) 00135 #define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800) 00136 #define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) 00137 #define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) 00138 #define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) 00139 #define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000) 00140 #define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100) 00141 #define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200) 00142 #define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300) 00143 #define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400) 00144 #define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500) 00145 #define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600) 00146 #define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700) 00147 #define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800) 00148 #define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) 00149 #define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) 00150 #define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) 00152 #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \ 00153 ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \ 00154 ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \ 00155 ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \ 00156 ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \ 00157 ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \ 00158 ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \ 00159 ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \ 00160 ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \ 00161 ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \ 00162 ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \ 00163 ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \ 00164 ((VALUE) == DAC_TriangleAmplitude_1) || \ 00165 ((VALUE) == DAC_TriangleAmplitude_3) || \ 00166 ((VALUE) == DAC_TriangleAmplitude_7) || \ 00167 ((VALUE) == DAC_TriangleAmplitude_15) || \ 00168 ((VALUE) == DAC_TriangleAmplitude_31) || \ 00169 ((VALUE) == DAC_TriangleAmplitude_63) || \ 00170 ((VALUE) == DAC_TriangleAmplitude_127) || \ 00171 ((VALUE) == DAC_TriangleAmplitude_255) || \ 00172 ((VALUE) == DAC_TriangleAmplitude_511) || \ 00173 ((VALUE) == DAC_TriangleAmplitude_1023) || \ 00174 ((VALUE) == DAC_TriangleAmplitude_2047) || \ 00175 ((VALUE) == DAC_TriangleAmplitude_4095)) 00176 00184 #define DAC_OutputBuffer_Enable ((uint32_t)0x00000000) 00185 #define DAC_OutputBuffer_Disable ((uint32_t)0x00000002) 00186 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \ 00187 ((STATE) == DAC_OutputBuffer_Disable)) 00188 00196 #define DAC_Channel_1 ((uint32_t)0x00000000) 00197 #define DAC_Channel_2 ((uint32_t)0x00000010) 00198 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \ 00199 ((CHANNEL) == DAC_Channel_2)) 00200 00208 #define DAC_Align_12b_R ((uint32_t)0x00000000) 00209 #define DAC_Align_12b_L ((uint32_t)0x00000004) 00210 #define DAC_Align_8b_R ((uint32_t)0x00000008) 00211 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \ 00212 ((ALIGN) == DAC_Align_12b_L) || \ 00213 ((ALIGN) == DAC_Align_8b_R)) 00214 00222 #define DAC_Wave_Noise ((uint32_t)0x00000040) 00223 #define DAC_Wave_Triangle ((uint32_t)0x00000080) 00224 #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \ 00225 ((WAVE) == DAC_Wave_Triangle)) 00226 00234 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) 00235 00238 #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) 00239 00243 #define DAC_IT_DMAUDR ((uint32_t)0x00002000) 00244 #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR)) 00245 00254 #define DAC_FLAG_DMAUDR ((uint32_t)0x00002000) 00255 #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR)) 00256 00260 #endif 00261 00278 void DAC_DeInit(void); 00279 void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct); 00280 void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct); 00281 void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState); 00282 #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) 00283 void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState); 00284 #endif 00285 void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState); 00286 void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState); 00287 void DAC_DualSoftwareTriggerCmd(FunctionalState NewState); 00288 void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState); 00289 void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data); 00290 void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data); 00291 void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1); 00292 uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel); 00293 #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) 00294 FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG); 00295 void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG); 00296 ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT); 00297 void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT); 00298 #endif 00299 00300 #ifdef __cplusplus 00301 } 00302 #endif 00303 00304 #endif /*__STM32F10x_DAC_H */ 00305 00317 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/