stm32f10x_dac.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f10x_dac.h
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   This file contains all the functions prototypes for the DAC firmware 
00008   *          library.
00009   ******************************************************************************
00010   * @copy
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00020   */ 
00021 
00022 /* Define to prevent recursive inclusion -------------------------------------*/
00023 #ifndef __STM32F10x_DAC_H
00024 #define __STM32F10x_DAC_H
00025 
00026 #ifdef __cplusplus
00027  extern "C" {
00028 #endif
00029 
00030 /* Includes ------------------------------------------------------------------*/
00031 #include "stm32f10x.h"
00032 
00033 /** @addtogroup STM32F10x_StdPeriph_Driver
00034   * @{
00035   */
00036 
00037 /** @addtogroup DAC
00038   * @{
00039   */
00040 
00041 /** @defgroup DAC_Exported_Types
00042   * @{
00043   */
00044 
00045 /** 
00046   * @brief  DAC Init structure definition
00047   */
00048 
00049 typedef struct
00050 {
00051   uint32_t DAC_Trigger;                      /*!< Specifies the external trigger for the selected DAC channel.
00052                                                   This parameter can be a value of @ref DAC_trigger_selection */
00053 
00054   uint32_t DAC_WaveGeneration;               /*!< Specifies whether DAC channel noise waves or triangle waves
00055                                                   are generated, or whether no wave is generated.
00056                                                   This parameter can be a value of @ref DAC_wave_generation */
00057 
00058   uint32_t DAC_LFSRUnmask_TriangleAmplitude; /*!< Specifies the LFSR mask for noise wave generation or
00059                                                   the maximum amplitude triangle generation for the DAC channel. 
00060                                                   This parameter can be a value of @ref DAC_lfsrunmask_triangleamplitude */
00061 
00062   uint32_t DAC_OutputBuffer;                 /*!< Specifies whether the DAC channel output buffer is enabled or disabled.
00063                                                   This parameter can be a value of @ref DAC_output_buffer */
00064 }DAC_InitTypeDef;
00065 
00066 /**
00067   * @}
00068   */
00069 
00070 /** @defgroup DAC_Exported_Constants
00071   * @{
00072   */
00073 
00074 /** @defgroup DAC_trigger_selection 
00075   * @{
00076   */
00077 
00078 #define DAC_Trigger_None                   ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register 
00079                                                                        has been loaded, and not by external trigger */
00080 #define DAC_Trigger_T6_TRGO                ((uint32_t)0x00000004) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */
00081 #define DAC_Trigger_T8_TRGO                ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel
00082                                                                        only in High-density devices*/
00083 #define DAC_Trigger_T3_TRGO                ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel
00084                                                                        only in Connectivity line, Medium-density and Low-density Value Line devices */
00085 #define DAC_Trigger_T7_TRGO                ((uint32_t)0x00000014) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */
00086 #define DAC_Trigger_T5_TRGO                ((uint32_t)0x0000001C) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */
00087 #define DAC_Trigger_T15_TRGO               ((uint32_t)0x0000001C) /*!< TIM15 TRGO selected as external conversion trigger for DAC channel 
00088                                                                        only in Medium-density and Low-density Value Line devices*/
00089 #define DAC_Trigger_T2_TRGO                ((uint32_t)0x00000024) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */
00090 #define DAC_Trigger_T4_TRGO                ((uint32_t)0x0000002C) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */
00091 #define DAC_Trigger_Ext_IT9                ((uint32_t)0x00000034) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */
00092 #define DAC_Trigger_Software               ((uint32_t)0x0000003C) /*!< Conversion started by software trigger for DAC channel */
00093 
00094 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \
00095                                  ((TRIGGER) == DAC_Trigger_T6_TRGO) || \
00096                                  ((TRIGGER) == DAC_Trigger_T8_TRGO) || \
00097                                  ((TRIGGER) == DAC_Trigger_T7_TRGO) || \
00098                                  ((TRIGGER) == DAC_Trigger_T5_TRGO) || \
00099                                  ((TRIGGER) == DAC_Trigger_T2_TRGO) || \
00100                                  ((TRIGGER) == DAC_Trigger_T4_TRGO) || \
00101                                  ((TRIGGER) == DAC_Trigger_Ext_IT9) || \
00102                                  ((TRIGGER) == DAC_Trigger_Software))
00103 
00104 /**
00105   * @}
00106   */
00107 
00108 /** @defgroup DAC_wave_generation 
00109   * @{
00110   */
00111 
00112 #define DAC_WaveGeneration_None            ((uint32_t)0x00000000)
00113 #define DAC_WaveGeneration_Noise           ((uint32_t)0x00000040)
00114 #define DAC_WaveGeneration_Triangle        ((uint32_t)0x00000080)
00115 #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \
00116                                     ((WAVE) == DAC_WaveGeneration_Noise) || \
00117                                     ((WAVE) == DAC_WaveGeneration_Triangle))
00118 /**
00119   * @}
00120   */
00121 
00122 /** @defgroup DAC_lfsrunmask_triangleamplitude
00123   * @{
00124   */
00125 
00126 #define DAC_LFSRUnmask_Bit0                ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */
00127 #define DAC_LFSRUnmask_Bits1_0             ((uint32_t)0x00000100) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */
00128 #define DAC_LFSRUnmask_Bits2_0             ((uint32_t)0x00000200) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */
00129 #define DAC_LFSRUnmask_Bits3_0             ((uint32_t)0x00000300) /*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */
00130 #define DAC_LFSRUnmask_Bits4_0             ((uint32_t)0x00000400) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */
00131 #define DAC_LFSRUnmask_Bits5_0             ((uint32_t)0x00000500) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */
00132 #define DAC_LFSRUnmask_Bits6_0             ((uint32_t)0x00000600) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */
00133 #define DAC_LFSRUnmask_Bits7_0             ((uint32_t)0x00000700) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */
00134 #define DAC_LFSRUnmask_Bits8_0             ((uint32_t)0x00000800) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */
00135 #define DAC_LFSRUnmask_Bits9_0             ((uint32_t)0x00000900) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */
00136 #define DAC_LFSRUnmask_Bits10_0            ((uint32_t)0x00000A00) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */
00137 #define DAC_LFSRUnmask_Bits11_0            ((uint32_t)0x00000B00) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */
00138 #define DAC_TriangleAmplitude_1            ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */
00139 #define DAC_TriangleAmplitude_3            ((uint32_t)0x00000100) /*!< Select max triangle amplitude of 3 */
00140 #define DAC_TriangleAmplitude_7            ((uint32_t)0x00000200) /*!< Select max triangle amplitude of 7 */
00141 #define DAC_TriangleAmplitude_15           ((uint32_t)0x00000300) /*!< Select max triangle amplitude of 15 */
00142 #define DAC_TriangleAmplitude_31           ((uint32_t)0x00000400) /*!< Select max triangle amplitude of 31 */
00143 #define DAC_TriangleAmplitude_63           ((uint32_t)0x00000500) /*!< Select max triangle amplitude of 63 */
00144 #define DAC_TriangleAmplitude_127          ((uint32_t)0x00000600) /*!< Select max triangle amplitude of 127 */
00145 #define DAC_TriangleAmplitude_255          ((uint32_t)0x00000700) /*!< Select max triangle amplitude of 255 */
00146 #define DAC_TriangleAmplitude_511          ((uint32_t)0x00000800) /*!< Select max triangle amplitude of 511 */
00147 #define DAC_TriangleAmplitude_1023         ((uint32_t)0x00000900) /*!< Select max triangle amplitude of 1023 */
00148 #define DAC_TriangleAmplitude_2047         ((uint32_t)0x00000A00) /*!< Select max triangle amplitude of 2047 */
00149 #define DAC_TriangleAmplitude_4095         ((uint32_t)0x00000B00) /*!< Select max triangle amplitude of 4095 */
00150 
00151 #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \
00152                                                       ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \
00153                                                       ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \
00154                                                       ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \
00155                                                       ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \
00156                                                       ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \
00157                                                       ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \
00158                                                       ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \
00159                                                       ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \
00160                                                       ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \
00161                                                       ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \
00162                                                       ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \
00163                                                       ((VALUE) == DAC_TriangleAmplitude_1) || \
00164                                                       ((VALUE) == DAC_TriangleAmplitude_3) || \
00165                                                       ((VALUE) == DAC_TriangleAmplitude_7) || \
00166                                                       ((VALUE) == DAC_TriangleAmplitude_15) || \
00167                                                       ((VALUE) == DAC_TriangleAmplitude_31) || \
00168                                                       ((VALUE) == DAC_TriangleAmplitude_63) || \
00169                                                       ((VALUE) == DAC_TriangleAmplitude_127) || \
00170                                                       ((VALUE) == DAC_TriangleAmplitude_255) || \
00171                                                       ((VALUE) == DAC_TriangleAmplitude_511) || \
00172                                                       ((VALUE) == DAC_TriangleAmplitude_1023) || \
00173                                                       ((VALUE) == DAC_TriangleAmplitude_2047) || \
00174                                                       ((VALUE) == DAC_TriangleAmplitude_4095))
00175 /**
00176   * @}
00177   */
00178 
00179 /** @defgroup DAC_output_buffer 
00180   * @{
00181   */
00182 
00183 #define DAC_OutputBuffer_Enable            ((uint32_t)0x00000000)
00184 #define DAC_OutputBuffer_Disable           ((uint32_t)0x00000002)
00185 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \
00186                                            ((STATE) == DAC_OutputBuffer_Disable))
00187 /**
00188   * @}
00189   */
00190 
00191 /** @defgroup DAC_Channel_selection 
00192   * @{
00193   */
00194 
00195 #define DAC_Channel_1                      ((uint32_t)0x00000000)
00196 #define DAC_Channel_2                      ((uint32_t)0x00000010)
00197 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \
00198                                  ((CHANNEL) == DAC_Channel_2))
00199 /**
00200   * @}
00201   */
00202 
00203 /** @defgroup DAC_data_alignement 
00204   * @{
00205   */
00206 
00207 #define DAC_Align_12b_R                    ((uint32_t)0x00000000)
00208 #define DAC_Align_12b_L                    ((uint32_t)0x00000004)
00209 #define DAC_Align_8b_R                     ((uint32_t)0x00000008)
00210 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \
00211                              ((ALIGN) == DAC_Align_12b_L) || \
00212                              ((ALIGN) == DAC_Align_8b_R))
00213 /**
00214   * @}
00215   */
00216 
00217 /** @defgroup DAC_wave_generation 
00218   * @{
00219   */
00220 
00221 #define DAC_Wave_Noise                     ((uint32_t)0x00000040)
00222 #define DAC_Wave_Triangle                  ((uint32_t)0x00000080)
00223 #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \
00224                            ((WAVE) == DAC_Wave_Triangle))
00225 /**
00226   * @}
00227   */
00228 
00229 /** @defgroup DAC_data 
00230   * @{
00231   */
00232 
00233 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) 
00234 /**
00235   * @}
00236   */
00237 #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL)  || defined (STM32F10X_HD_VL)
00238 /** @defgroup DAC_interrupts_definition 
00239   * @{
00240   */ 
00241   
00242 #define DAC_IT_DMAUDR                      ((uint32_t)0x00002000)  
00243 #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR)) 
00244 
00245 /**
00246   * @}
00247   */ 
00248 
00249 /** @defgroup DAC_flags_definition 
00250   * @{
00251   */ 
00252   
00253 #define DAC_FLAG_DMAUDR                    ((uint32_t)0x00002000)  
00254 #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR))  
00255 
00256 /**
00257   * @}
00258   */
00259 #endif
00260 
00261 /**
00262   * @}
00263   */
00264 
00265 /** @defgroup DAC_Exported_Macros
00266   * @{
00267   */
00268 
00269 /**
00270   * @}
00271   */
00272 
00273 /** @defgroup DAC_Exported_Functions
00274   * @{
00275   */
00276 
00277 void DAC_DeInit(void);
00278 void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
00279 void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);
00280 void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);
00281 #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
00282 void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState);
00283 #endif
00284 void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);
00285 void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState);
00286 void DAC_DualSoftwareTriggerCmd(FunctionalState NewState);
00287 void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState);
00288 void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);
00289 void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data);
00290 void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1);
00291 uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);
00292 #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) 
00293 FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG);
00294 void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG);
00295 ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT);
00296 void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT);
00297 #endif
00298 
00299 #ifdef __cplusplus
00300 }
00301 #endif
00302 
00303 #endif /*__STM32F10x_DAC_H */
00304 /**
00305   * @}
00306   */
00307 
00308 /**
00309   * @}
00310   */
00311 
00312 /**
00313   * @}
00314   */
00315 
00316 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32