00001
00029
00030 #ifndef __STM32F4xx_DAC_H
00031 #define __STM32F4xx_DAC_H
00032
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036
00037
00038 #include "stm32f4xx.h"
00039
00048
00049
00054 typedef struct
00055 {
00056 uint32_t DAC_Trigger;
00059 uint32_t DAC_WaveGeneration;
00063 uint32_t DAC_LFSRUnmask_TriangleAmplitude;
00067 uint32_t DAC_OutputBuffer;
00069 }DAC_InitTypeDef;
00070
00071
00072
00081 #define DAC_Trigger_None ((uint32_t)0x00000000)
00083 #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024)
00084 #define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C)
00085 #define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C)
00086 #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004)
00087 #define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014)
00088 #define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C)
00090 #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034)
00091 #define DAC_Trigger_Software ((uint32_t)0x0000003C)
00093 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \
00094 ((TRIGGER) == DAC_Trigger_T6_TRGO) || \
00095 ((TRIGGER) == DAC_Trigger_T8_TRGO) || \
00096 ((TRIGGER) == DAC_Trigger_T7_TRGO) || \
00097 ((TRIGGER) == DAC_Trigger_T5_TRGO) || \
00098 ((TRIGGER) == DAC_Trigger_T2_TRGO) || \
00099 ((TRIGGER) == DAC_Trigger_T4_TRGO) || \
00100 ((TRIGGER) == DAC_Trigger_Ext_IT9) || \
00101 ((TRIGGER) == DAC_Trigger_Software))
00102
00111 #define DAC_WaveGeneration_None ((uint32_t)0x00000000)
00112 #define DAC_WaveGeneration_Noise ((uint32_t)0x00000040)
00113 #define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080)
00114 #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \
00115 ((WAVE) == DAC_WaveGeneration_Noise) || \
00116 ((WAVE) == DAC_WaveGeneration_Triangle))
00117
00125 #define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000)
00126 #define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100)
00127 #define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200)
00128 #define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300)
00129 #define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400)
00130 #define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500)
00131 #define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600)
00132 #define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700)
00133 #define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800)
00134 #define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900)
00135 #define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00)
00136 #define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00)
00137 #define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000)
00138 #define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100)
00139 #define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200)
00140 #define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300)
00141 #define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400)
00142 #define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500)
00143 #define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600)
00144 #define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700)
00145 #define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800)
00146 #define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900)
00147 #define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00)
00148 #define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00)
00150 #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \
00151 ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \
00152 ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \
00153 ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \
00154 ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \
00155 ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \
00156 ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \
00157 ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \
00158 ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \
00159 ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \
00160 ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \
00161 ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \
00162 ((VALUE) == DAC_TriangleAmplitude_1) || \
00163 ((VALUE) == DAC_TriangleAmplitude_3) || \
00164 ((VALUE) == DAC_TriangleAmplitude_7) || \
00165 ((VALUE) == DAC_TriangleAmplitude_15) || \
00166 ((VALUE) == DAC_TriangleAmplitude_31) || \
00167 ((VALUE) == DAC_TriangleAmplitude_63) || \
00168 ((VALUE) == DAC_TriangleAmplitude_127) || \
00169 ((VALUE) == DAC_TriangleAmplitude_255) || \
00170 ((VALUE) == DAC_TriangleAmplitude_511) || \
00171 ((VALUE) == DAC_TriangleAmplitude_1023) || \
00172 ((VALUE) == DAC_TriangleAmplitude_2047) || \
00173 ((VALUE) == DAC_TriangleAmplitude_4095))
00174
00182 #define DAC_OutputBuffer_Enable ((uint32_t)0x00000000)
00183 #define DAC_OutputBuffer_Disable ((uint32_t)0x00000002)
00184 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \
00185 ((STATE) == DAC_OutputBuffer_Disable))
00186
00194 #define DAC_Channel_1 ((uint32_t)0x00000000)
00195 #define DAC_Channel_2 ((uint32_t)0x00000010)
00196 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \
00197 ((CHANNEL) == DAC_Channel_2))
00198
00206 #define DAC_Align_12b_R ((uint32_t)0x00000000)
00207 #define DAC_Align_12b_L ((uint32_t)0x00000004)
00208 #define DAC_Align_8b_R ((uint32_t)0x00000008)
00209 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \
00210 ((ALIGN) == DAC_Align_12b_L) || \
00211 ((ALIGN) == DAC_Align_8b_R))
00212
00220 #define DAC_Wave_Noise ((uint32_t)0x00000040)
00221 #define DAC_Wave_Triangle ((uint32_t)0x00000080)
00222 #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \
00223 ((WAVE) == DAC_Wave_Triangle))
00224
00232 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0)
00233
00240 #define DAC_IT_DMAUDR ((uint32_t)0x00002000)
00241 #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR))
00242
00251 #define DAC_FLAG_DMAUDR ((uint32_t)0x00002000)
00252 #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR))
00253
00262
00263
00264
00265
00266 void DAC_DeInit(void);
00267
00268
00269 void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
00270 void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);
00271 void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);
00272 void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState);
00273 void DAC_DualSoftwareTriggerCmd(FunctionalState NewState);
00274 void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState);
00275 void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);
00276 void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data);
00277 void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1);
00278 uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);
00279
00280
00281 void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);
00282
00283
00284 void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState);
00285 FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG);
00286 void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG);
00287 ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT);
00288 void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT);
00289
00290 #ifdef __cplusplus
00291 }
00292 #endif
00293
00294 #endif
00295
00304