STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f4xx_dac.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F4xx_DAC_H
31 #define __STM32F4xx_DAC_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f4xx.h"
39 
48 /* Exported types ------------------------------------------------------------*/
49 
54 typedef struct
55 {
56  uint32_t DAC_Trigger;
59  uint32_t DAC_WaveGeneration;
63  uint32_t DAC_LFSRUnmask_TriangleAmplitude;
67  uint32_t DAC_OutputBuffer;
70 
71 /* Exported constants --------------------------------------------------------*/
72 
81 #define DAC_Trigger_None ((uint32_t)0x00000000)
83 #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024)
84 #define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C)
85 #define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C)
86 #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004)
87 #define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014)
88 #define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C)
90 #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034)
91 #define DAC_Trigger_Software ((uint32_t)0x0000003C)
93 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \
94  ((TRIGGER) == DAC_Trigger_T6_TRGO) || \
95  ((TRIGGER) == DAC_Trigger_T8_TRGO) || \
96  ((TRIGGER) == DAC_Trigger_T7_TRGO) || \
97  ((TRIGGER) == DAC_Trigger_T5_TRGO) || \
98  ((TRIGGER) == DAC_Trigger_T2_TRGO) || \
99  ((TRIGGER) == DAC_Trigger_T4_TRGO) || \
100  ((TRIGGER) == DAC_Trigger_Ext_IT9) || \
101  ((TRIGGER) == DAC_Trigger_Software))
102 
111 #define DAC_WaveGeneration_None ((uint32_t)0x00000000)
112 #define DAC_WaveGeneration_Noise ((uint32_t)0x00000040)
113 #define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080)
114 #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \
115  ((WAVE) == DAC_WaveGeneration_Noise) || \
116  ((WAVE) == DAC_WaveGeneration_Triangle))
117 
125 #define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000)
126 #define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100)
127 #define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200)
128 #define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300)
129 #define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400)
130 #define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500)
131 #define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600)
132 #define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700)
133 #define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800)
134 #define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900)
135 #define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00)
136 #define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00)
137 #define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000)
138 #define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100)
139 #define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200)
140 #define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300)
141 #define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400)
142 #define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500)
143 #define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600)
144 #define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700)
145 #define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800)
146 #define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900)
147 #define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00)
148 #define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00)
150 #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \
151  ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \
152  ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \
153  ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \
154  ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \
155  ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \
156  ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \
157  ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \
158  ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \
159  ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \
160  ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \
161  ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \
162  ((VALUE) == DAC_TriangleAmplitude_1) || \
163  ((VALUE) == DAC_TriangleAmplitude_3) || \
164  ((VALUE) == DAC_TriangleAmplitude_7) || \
165  ((VALUE) == DAC_TriangleAmplitude_15) || \
166  ((VALUE) == DAC_TriangleAmplitude_31) || \
167  ((VALUE) == DAC_TriangleAmplitude_63) || \
168  ((VALUE) == DAC_TriangleAmplitude_127) || \
169  ((VALUE) == DAC_TriangleAmplitude_255) || \
170  ((VALUE) == DAC_TriangleAmplitude_511) || \
171  ((VALUE) == DAC_TriangleAmplitude_1023) || \
172  ((VALUE) == DAC_TriangleAmplitude_2047) || \
173  ((VALUE) == DAC_TriangleAmplitude_4095))
174 
182 #define DAC_OutputBuffer_Enable ((uint32_t)0x00000000)
183 #define DAC_OutputBuffer_Disable ((uint32_t)0x00000002)
184 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \
185  ((STATE) == DAC_OutputBuffer_Disable))
186 
194 #define DAC_Channel_1 ((uint32_t)0x00000000)
195 #define DAC_Channel_2 ((uint32_t)0x00000010)
196 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \
197  ((CHANNEL) == DAC_Channel_2))
198 
206 #define DAC_Align_12b_R ((uint32_t)0x00000000)
207 #define DAC_Align_12b_L ((uint32_t)0x00000004)
208 #define DAC_Align_8b_R ((uint32_t)0x00000008)
209 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \
210  ((ALIGN) == DAC_Align_12b_L) || \
211  ((ALIGN) == DAC_Align_8b_R))
212 
220 #define DAC_Wave_Noise ((uint32_t)0x00000040)
221 #define DAC_Wave_Triangle ((uint32_t)0x00000080)
222 #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \
223  ((WAVE) == DAC_Wave_Triangle))
224 
232 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0)
233 
240 #define DAC_IT_DMAUDR ((uint32_t)0x00002000)
241 #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR))
242 
251 #define DAC_FLAG_DMAUDR ((uint32_t)0x00002000)
252 #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR))
253 
262 /* Exported macro ------------------------------------------------------------*/
263 /* Exported functions --------------------------------------------------------*/
264 
265 /* Function used to set the DAC configuration to the default reset state *****/
266 void DAC_DeInit(void);
267 
268 /* DAC channels configuration: trigger, output buffer, data format functions */
269 void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
270 void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);
271 void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);
272 void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState);
273 void DAC_DualSoftwareTriggerCmd(FunctionalState NewState);
274 void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState);
275 void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);
276 void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data);
277 void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1);
278 uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);
279 
280 /* DMA management functions ***************************************************/
281 void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);
282 
283 /* Interrupts and flags management functions **********************************/
284 void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState);
285 FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG);
286 void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG);
287 ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT);
288 void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT);
289 
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #endif /*__STM32F4xx_DAC_H */
295 
304 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/