gd32f10x_dac.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /**
  2. ******************************************************************************
  3. * @brief DAC header file of the firmware library.
  4. ******************************************************************************
  5. */
  6. /* Define to prevent recursive inclusion -------------------------------------*/
  7. #ifndef __GD32F10X_DAC_H
  8. #define __GD32F10X_DAC_H
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /* Includes ------------------------------------------------------------------*/
  13. #include "gd32f10x.h"
  14. /** @addtogroup GD32F10x_Firmware
  15. * @{
  16. */
  17. /** @addtogroup DAC
  18. * @{
  19. */
  20. /** @defgroup DAC_Exported_Types
  21. * @{
  22. */
  23. /**
  24. * @brief DAC Init structure definition
  25. */
  26. typedef struct {
  27. uint32_t DAC_Trigger; /*!< External trigger of the selected DAC channel.
  28. This parameter can be a value of @ref DAC_Trigger */
  29. uint32_t DAC_WaveType; /*!< Wave type of the DAC channel, noise waves or triangle waves.
  30. This parameter can be a value of @ref DAC_wave_type */
  31. uint32_t DAC_LFSRNoise_AmplitudeTriangle; /*!< The LFSR mask for noise wave generation or
  32. the maximum amplitude triangle generation for the DAC channel.
  33. This parameter can be a value of @ref DAC_lfsrnoise_amplitudetriangle */
  34. uint32_t DAC_OutputBuffer; /*!< whether the DAC channel output buffer is enabled or disabled.
  35. This parameter can be a value of @ref DAC_OutputBuffer */
  36. } DAC_InitPara;
  37. /**
  38. * @}
  39. */
  40. /** @defgroup DAC_Exported_Constants
  41. * @{
  42. */
  43. /** @defgroup DAC_Trigger
  44. * @{
  45. */
  46. #define DAC_TRIGGER_NONE ((uint32_t)0x00000000) /*!< no trigger */
  47. #define DAC_TRIGGER_T2_TRIG ((uint32_t)0x00000024) /*!< TIMER2 TRIG */
  48. #define DAC_TRIGGER_T3_TRIG ((uint32_t)0x0000000C) /*!< TIMER3 TRIG */
  49. #define DAC_TRIGGER_T4_TRIG ((uint32_t)0x0000002C) /*!< TIMER4 TRIG */
  50. #define DAC_TRIGGER_T5_TRIG ((uint32_t)0x0000001C) /*!< TIMER5 TRIG */
  51. #define DAC_TRIGGER_T6_TRIG ((uint32_t)0x00000004) /*!< TIMER6 TRIG */
  52. #define DAC_TRIGGER_T7_TRIG ((uint32_t)0x00000014) /*!< TIMER7 TRIG */
  53. #define DAC_TRIGGER_T8_TRIG ((uint32_t)0x0000000C) /*!< TIMER8 TRIG */
  54. #define DAC_TRIGGER_T15_TRIG ((uint32_t)0x0000001C) /*!< TIMER15 TRIG */
  55. #define DAC_TRIGGER_EXTI_LINE9 ((uint32_t)0x00000034) /*!< EXTI Line9 event */
  56. #define DAC_TRIGGER_SOFTWARE ((uint32_t)0x0000003C) /*!< software trigger */
  57. /**
  58. * @}
  59. */
  60. /** @defgroup DAC_wave_type
  61. * @{
  62. */
  63. #define DAC_WAVEGENE_NONE ((uint32_t)0x00000000)
  64. #define DAC_WAVEGENE_NOISE ((uint32_t)0x00000040)
  65. #define DAC_WAVEGENE_TRIANGLE ((uint32_t)0x00000080)
  66. /**
  67. * @}
  68. */
  69. /** @defgroup DAC_lfsrnoise_amplitudetriangle
  70. * @{
  71. */
  72. #define DAC_LFSR_BIT0 ((uint32_t)0x00000000) /*!< LFSR bit0 for noise wave generation */
  73. #define DAC_LFSR_BITS1_0 ((uint32_t)0x00000100) /*!< LFSR bit[1:0] for noise wave generation */
  74. #define DAC_LFSR_BITS2_0 ((uint32_t)0x00000200) /*!< LFSR bit[2:0] for noise wave generation */
  75. #define DAC_LFSR_BITS3_0 ((uint32_t)0x00000300) /*!< LFSR bit[3:0] for noise wave generation */
  76. #define DAC_LFSR_BITS4_0 ((uint32_t)0x00000400) /*!< LFSR bit[4:0] for noise wave generation */
  77. #define DAC_LFSR_BITS5_0 ((uint32_t)0x00000500) /*!< LFSR bit[5:0] for noise wave generation */
  78. #define DAC_LFSR_BITS6_0 ((uint32_t)0x00000600) /*!< LFSR bit[6:0] for noise wave generation */
  79. #define DAC_LFSR_BITS7_0 ((uint32_t)0x00000700) /*!< LFSR bit[7:0] for noise wave generation */
  80. #define DAC_LFSR_BITS8_0 ((uint32_t)0x00000800) /*!< LFSR bit[8:0] for noise wave generation */
  81. #define DAC_LFSR_BITS9_0 ((uint32_t)0x00000900) /*!< LFSR bit[9:0] for noise wave generation */
  82. #define DAC_LFSR_BITS10_0 ((uint32_t)0x00000A00) /*!< LFSR bit[10:0] for noise wave generation */
  83. #define DAC_LFSR_BITS11_0 ((uint32_t)0x00000B00) /*!< LFSR bit[11:0] for noise wave generation */
  84. #define DAC_AMPLITUDETRIANGLE_1 ((uint32_t)0x00000000) /*!< max triangle amplitude: 1 */
  85. #define DAC_AMPLITUDETRIANGLE_3 ((uint32_t)0x00000100) /*!< max triangle amplitude: 3 */
  86. #define DAC_AMPLITUDETRIANGLE_7 ((uint32_t)0x00000200) /*!< max triangle amplitude: 7 */
  87. #define DAC_AMPLITUDETRIANGLE_15 ((uint32_t)0x00000300) /*!< max triangle amplitude: 15 */
  88. #define DAC_AMPLITUDETRIANGLE_31 ((uint32_t)0x00000400) /*!< max triangle amplitude: 31 */
  89. #define DAC_AMPLITUDETRIANGLE_63 ((uint32_t)0x00000500) /*!< max triangle amplitude: 63 */
  90. #define DAC_AMPLITUDETRIANGLE_127 ((uint32_t)0x00000600) /*!< max triangle amplitude: 127 */
  91. #define DAC_AMPLITUDETRIANGLE_255 ((uint32_t)0x00000700) /*!< max triangle amplitude: 255 */
  92. #define DAC_AMPLITUDETRIANGLE_511 ((uint32_t)0x00000800) /*!< max triangle amplitude: 511 */
  93. #define DAC_AMPLITUDETRIANGLE_1023 ((uint32_t)0x00000900) /*!< max triangle amplitude: 1023 */
  94. #define DAC_AMPLITUDETRIANGLE_2047 ((uint32_t)0x00000A00) /*!< max triangle amplitude: 2047 */
  95. #define DAC_AMPLITUDETRIANGLE_4095 ((uint32_t)0x00000B00) /*!< max triangle amplitude: 4095 */
  96. /**
  97. * @}
  98. */
  99. /** @defgroup DAC_OutputBuffer
  100. * @{
  101. */
  102. #define DAC_OUTPUTBUFFER_ENABLE ((uint32_t)0x00000000)
  103. #define DAC_OUTPUTBUFFER_DISABLE ((uint32_t)0x00000002)
  104. /**
  105. * @}
  106. */
  107. /** @defgroup DAC_Channel_selection
  108. * @{
  109. */
  110. #define DAC_CHANNEL_1 ((uint32_t)0x00000000)
  111. #define DAC_CHANNEL_2 ((uint32_t)0x00000010)
  112. /**
  113. * @}
  114. */
  115. /** @defgroup DAC_data_alignment
  116. * @{
  117. */
  118. #define DAC_ALIGN_12B_R ((uint32_t)0x00000000)
  119. #define DAC_ALIGN_12B_L ((uint32_t)0x00000004)
  120. #define DAC_ALIGN_8B_R ((uint32_t)0x00000008)
  121. /**
  122. * @}
  123. */
  124. /** @defgroup DAC_wave_generation
  125. * @{
  126. */
  127. #define DAC_WAVE_NOISE ((uint32_t)0x00000040)
  128. #define DAC_WAVE_TRIANGLE ((uint32_t)0x00000080)
  129. /**
  130. * @}
  131. */
  132. /** @defgroup DAC_interrupts_definition
  133. * @{
  134. */
  135. #define DAC_INT_DMAUDR ((uint32_t)0x00002000)
  136. /**
  137. * @}
  138. */
  139. /** @defgroup DAC_flags_definition
  140. * @{
  141. */
  142. #define DAC_FLAG_DMAUDR ((uint32_t)0x00002000)
  143. /**
  144. * @}
  145. */
  146. /**
  147. * @}
  148. */
  149. /** @defgroup DAC_Exported_Functions
  150. * @{
  151. */
  152. void DAC_DeInit(DAC_InitPara *DAC_InitParaStruct);
  153. void DAC_Init(uint32_t DAC_Channel, DAC_InitPara *DAC_InitParaStruct);
  154. void DAC_Enable(uint32_t DAC_Channel, TypeState NewValue);
  155. void DAC_IntConfig(uint32_t DAC_Channel, TypeState NewValue);
  156. void DAC_SoftwareTrigger_Enable(uint32_t DAC_Channel, TypeState NewValue);
  157. void DAC_DualSoftwareTrigger_Enable(TypeState NewValue);
  158. void DAC_WaveGeneration_Enable(uint32_t DAC_Channel, uint32_t DAC_Wave, TypeState NewValue);
  159. void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);
  160. void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data);
  161. void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1);
  162. uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);
  163. void DAC_DMA_Enable(uint32_t DAC_Channel, TypeState NewValue);
  164. #ifdef __cplusplus
  165. }
  166. #endif
  167. #endif /*__GD32F10X_DAC_H */
  168. /**
  169. * @}
  170. */
  171. /**
  172. * @}
  173. */
  174. /**
  175. * @}
  176. */