stm32f0xx_dac.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_dac.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 23-March-2012
  7. * @brief This file contains all the functions prototypes for the DAC firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM32F0XX_DAC_H
  30. #define __STM32F0XX_DAC_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "stm32f0xx.h"
  36. /** @addtogroup STM32F0xx_StdPeriph_Driver
  37. * @{
  38. */
  39. /** @addtogroup DAC
  40. * @{
  41. */
  42. /* Exported types ------------------------------------------------------------*/
  43. /**
  44. * @brief DAC Init structure definition
  45. */
  46. typedef struct
  47. {
  48. uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel.
  49. This parameter can be a value of @ref DAC_Trigger */
  50. uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled.
  51. This parameter can be a value of @ref DAC_OutputBuffer */
  52. }DAC_InitTypeDef;
  53. /* Exported constants --------------------------------------------------------*/
  54. /** @defgroup DAC_Exported_Constants
  55. * @{
  56. */
  57. /** @defgroup DAC_Trigger
  58. * @{
  59. */
  60. #define DAC_Trigger_None ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register
  61. has been loaded, and not by external trigger */
  62. #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */
  63. #define DAC_Trigger_T3_TRGO ((uint32_t)0x0000000C) /*!< TIM3 TRGO selected as external conversion trigger for DAC channel */
  64. #define DAC_Trigger_T15_TRGO ((uint32_t)0x0000001C) /*!< TIM15 TRGO selected as external conversion trigger for DAC channel */
  65. #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */
  66. #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */
  67. #define DAC_Trigger_Software ((uint32_t)0x0000003C) /*!< Conversion started by software trigger for DAC channel */
  68. #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \
  69. ((TRIGGER) == DAC_Trigger_T6_TRGO) || \
  70. ((TRIGGER) == DAC_Trigger_T3_TRGO) || \
  71. ((TRIGGER) == DAC_Trigger_T15_TRGO) || \
  72. ((TRIGGER) == DAC_Trigger_T2_TRGO) || \
  73. ((TRIGGER) == DAC_Trigger_Ext_IT9) || \
  74. ((TRIGGER) == DAC_Trigger_Software))
  75. /**
  76. * @}
  77. */
  78. /** @defgroup DAC_OutputBuffer
  79. * @{
  80. */
  81. #define DAC_OutputBuffer_Enable ((uint32_t)0x00000000)
  82. #define DAC_OutputBuffer_Disable DAC_CR_BOFF1
  83. #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \
  84. ((STATE) == DAC_OutputBuffer_Disable))
  85. /**
  86. * @}
  87. */
  88. /** @defgroup DAC_Channel_selection
  89. * @{
  90. */
  91. #define DAC_Channel_1 ((uint32_t)0x00000000)
  92. #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1))
  93. /**
  94. * @}
  95. */
  96. /** @defgroup DAC_data_alignment
  97. * @{
  98. */
  99. #define DAC_Align_12b_R ((uint32_t)0x00000000)
  100. #define DAC_Align_12b_L ((uint32_t)0x00000004)
  101. #define DAC_Align_8b_R ((uint32_t)0x00000008)
  102. #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \
  103. ((ALIGN) == DAC_Align_12b_L) || \
  104. ((ALIGN) == DAC_Align_8b_R))
  105. /**
  106. * @}
  107. */
  108. /** @defgroup DAC_data
  109. * @{
  110. */
  111. #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0)
  112. /**
  113. * @}
  114. */
  115. /** @defgroup DAC_interrupts_definition
  116. * @{
  117. */
  118. #define DAC_IT_DMAUDR DAC_SR_DMAUDR1
  119. #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR))
  120. /**
  121. * @}
  122. */
  123. /** @defgroup DAC_flags_definition
  124. * @{
  125. */
  126. #define DAC_FLAG_DMAUDR DAC_SR_DMAUDR1
  127. #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR))
  128. /**
  129. * @}
  130. */
  131. /**
  132. * @}
  133. */
  134. /* Exported macro ------------------------------------------------------------*/
  135. /* Exported functions ------------------------------------------------------- */
  136. /* Function used to set the DAC configuration to the default reset state *****/
  137. void DAC_DeInit(void);
  138. /* DAC channels configuration: trigger, output buffer, data format functions */
  139. void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
  140. void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);
  141. void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);
  142. void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState);
  143. void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);
  144. uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);
  145. /* DMA management functions ***************************************************/
  146. void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);
  147. /* Interrupts and flags management functions **********************************/
  148. void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState);
  149. FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG);
  150. void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG);
  151. ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT);
  152. void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT);
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156. #endif /*__STM32F0XX_DAC_H */
  157. /**
  158. * @}
  159. */
  160. /**
  161. * @}
  162. */
  163. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/