gd32f3x0_adc.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /*!
  2. \file gd32f3x0_adc.h
  3. \brief definitions for the ADC
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #ifndef GD32F3X0_ADC_H
  10. #define GD32F3X0_ADC_H
  11. #include "gd32f3x0.h"
  12. /* ADC definitions */
  13. #define ADC ADC_BASE
  14. /* registers definitions */
  15. #define ADC_STAT REG32(ADC + 0x00U) /*!< ADC status register */
  16. #define ADC_CTL0 REG32(ADC + 0x04U) /*!< ADC control register 0 */
  17. #define ADC_CTL1 REG32(ADC + 0x08U) /*!< ADC control register 1 */
  18. #define ADC_SAMPT0 REG32(ADC + 0x0CU) /*!< ADC sampling time register 0 */
  19. #define ADC_SAMPT1 REG32(ADC + 0x10U) /*!< ADC sampling time register 1 */
  20. #define ADC_IOFF0 REG32(ADC + 0x14U) /*!< ADC inserted channel data offset register 0 */
  21. #define ADC_IOFF1 REG32(ADC + 0x18U) /*!< ADC inserted channel data offset register 1 */
  22. #define ADC_IOFF2 REG32(ADC + 0x1CU) /*!< ADC inserted channel data offset register 2 */
  23. #define ADC_IOFF3 REG32(ADC + 0x20U) /*!< ADC inserted channel data offset register 3 */
  24. #define ADC_WDHT REG32(ADC + 0x24U) /*!< ADC watchdog high threshold register */
  25. #define ADC_WDLT REG32(ADC + 0x28U) /*!< ADC watchdog low threshold register */
  26. #define ADC_RSQ0 REG32(ADC + 0x2CU) /*!< ADC regular sequence register 0 */
  27. #define ADC_RSQ1 REG32(ADC + 0x30U) /*!< ADC regular sequence register 1 */
  28. #define ADC_RSQ2 REG32(ADC + 0x34U) /*!< ADC regular sequence register 2 */
  29. #define ADC_ISQ REG32(ADC + 0x38U) /*!< ADC inserted sequence register */
  30. #define ADC_IDATA0 REG32(ADC + 0x3CU) /*!< ADC inserted data register 0 */
  31. #define ADC_IDATA1 REG32(ADC + 0x40U) /*!< ADC inserted data register 1 */
  32. #define ADC_IDATA2 REG32(ADC + 0x44U) /*!< ADC inserted data register 2 */
  33. #define ADC_IDATA3 REG32(ADC + 0x48U) /*!< ADC inserted data register 3 */
  34. #define ADC_RDATA REG32(ADC + 0x4CU) /*!< ADC regular data register */
  35. #define ADC_OVSAMPCTL REG32(ADC + 0x80U) /*!< ADC oversampling control register */
  36. /* bits definitions */
  37. /* ADC_STAT */
  38. #define ADC_STAT_WDE BIT(0) /*!< analog watchdog event flag */
  39. #define ADC_STAT_EOC BIT(1) /*!< end of conversion */
  40. #define ADC_STAT_EOIC BIT(2) /*!< inserted channel end of conversion */
  41. #define ADC_STAT_STIC BIT(3) /*!< inserted channel start flag */
  42. #define ADC_STAT_STRC BIT(4) /*!< regular channel start flag */
  43. /* ADC_CTL0 */
  44. #define ADC_CTL0_WDCHSEL BITS(0,4) /*!< analog watchdog channel select bits */
  45. #define ADC_CTL0_EOCIE BIT(5) /*!< interrupt enable for EOC */
  46. #define ADC_CTL0_WDEIE BIT(6) /*!< analog watchdog interrupt enable */
  47. #define ADC_CTL0_EOICIE BIT(7) /*!< interrupt enable for inserted channels */
  48. #define ADC_CTL0_SM BIT(8) /*!< scan mode */
  49. #define ADC_CTL0_WDSC BIT(9) /*!< when in scan mode, analog watchdog is effective on a single channel */
  50. #define ADC_CTL0_ICA BIT(10) /*!< automatic inserted group conversion */
  51. #define ADC_CTL0_DISRC BIT(11) /*!< discontinuous mode on regular channels */
  52. #define ADC_CTL0_DISIC BIT(12) /*!< discontinuous mode on inserted channels */
  53. #define ADC_CTL0_DISNUM BITS(13,15) /*!< discontinuous mode channel count */
  54. #define ADC_CTL0_IWDEN BIT(22) /*!< analog watchdog enable on inserted channels */
  55. #define ADC_CTL0_RWDEN BIT(23) /*!< analog watchdog enable on regular channels */
  56. #define ADC_CTL0_DRES BITS(24,25) /*!< ADC data resolution */
  57. /* ADC_CTL1 */
  58. #define ADC_CTL1_ADCON BIT(0) /*!< ADC converter on */
  59. #define ADC_CTL1_CTN BIT(1) /*!< continuous conversion */
  60. #define ADC_CTL1_CLB BIT(2) /*!< ADC calibration */
  61. #define ADC_CTL1_RSTCLB BIT(3) /*!< reset calibration */
  62. #define ADC_CTL1_DMA BIT(8) /*!< direct memory access mode */
  63. #define ADC_CTL1_DAL BIT(11) /*!< data alignment */
  64. #define ADC_CTL1_ETSIC BITS(12,14) /*!< external trigger select for inserted channel */
  65. #define ADC_CTL1_ETEIC BIT(15) /*!< external trigger enable for inserted channel */
  66. #define ADC_CTL1_ETSRC BITS(17,19) /*!< external trigger select for regular channel */
  67. #define ADC_CTL1_ETERC BIT(20) /*!< external trigger enable for regular channel */
  68. #define ADC_CTL1_SWICST BIT(21) /*!< start on inserted channel */
  69. #define ADC_CTL1_SWRCST BIT(22) /*!< start on regular channel */
  70. #define ADC_CTL1_TSVREN BIT(23) /*!< enable channel 16 and 17 */
  71. #define ADC_CTL1_VBETEN BIT(24) /*!< VBAT enable */
  72. /* ADC_SAMPTx x=0,1 */
  73. #define ADC_SAMPTX_SPTN BITS(0,2) /*!< channel n sample time selection */
  74. /* ADC_IOFFx x=0..3 */
  75. #define ADC_IOFFX_IOFF BITS(0,11) /*!< data offset for inserted channel x */
  76. /* ADC_WDHT */
  77. #define ADC_WDHT_WDHT BITS(0,11) /*!< analog watchdog high threshold */
  78. /* ADC_WDLT */
  79. #define ADC_WDLT_WDLT BITS(0,11) /*!< analog watchdog low threshold */
  80. /* ADC_RSQx x=0..2 */
  81. #define ADC_RSQX_RSQN BITS(0,4) /*!< x conversion in regular sequence */
  82. #define ADC_RSQ0_RL BITS(20,23) /*!< regular channel sequence length */
  83. /* ADC_ISQ */
  84. #define ADC_ISQ_ISQN BITS(0,4) /*!< n conversion in regular sequence */
  85. #define ADC_ISQ_IL BITS(20,21) /*!< inserted sequence length */
  86. /* ADC_IDATAx x=0..3*/
  87. #define ADC_IDATAX_IDATAN BITS(0,15) /*!< inserted channel x conversion data */
  88. /* ADC_RDATA */
  89. #define ADC_RDATA_RDATA BITS(0,15) /*!< regular channel data */
  90. /* ADC_OVSAMPCTL */
  91. #define ADC_OVSAMPCTL_OVSEN BIT(0) /*!< oversampling enable */
  92. #define ADC_OVSAMPCTL_OVSR BITS(2,4) /*!< oversampling ratio */
  93. #define ADC_OVSAMPCTL_OVSS BITS(5,8) /*!< oversampling shift */
  94. #define ADC_OVSAMPCTL_TOVS BIT(9) /*!< triggered oversampling */
  95. /* constants definitions */
  96. /* ADC flag definitions */
  97. #define ADC_FLAG_WDE ADC_STAT_WDE /*!< analog watchdog event flag */
  98. #define ADC_FLAG_EOC ADC_STAT_EOC /*!< end of group conversion flag */
  99. #define ADC_FLAG_EOIC ADC_STAT_EOIC /*!< end of inserted channel group conversion flag */
  100. #define ADC_FLAG_STIC ADC_STAT_STIC /*!< start flag of inserted channel group */
  101. #define ADC_FLAG_STRC ADC_STAT_STRC /*!< start flag of regular channel group */
  102. /* adc_ctl0 register value */
  103. #define CTL0_DISNUM(regval) (BITS(13,15) & ((uint32_t)(regval) << 13)) /*!< number of conversions in discontinuous mode */
  104. /* ADC special function */
  105. #define ADC_SCAN_MODE ADC_CTL0_SM /*!< scan mode */
  106. #define ADC_INSERTED_CHANNEL_AUTO ADC_CTL0_ICA /*!< inserted channel group convert automatically */
  107. #define ADC_CONTINUOUS_MODE ADC_CTL1_CTN /*!< continuous mode */
  108. /* ADC data alignment */
  109. #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000U) /*!< LSB alignment */
  110. #define ADC_DATAALIGN_LEFT ADC_CTL1_DAL /*!< MSB alignment */
  111. /* external trigger select for regular channel */
  112. #define CTL1_ETSRC(regval) (BITS(17,19) & ((uint32_t)(regval) << 17))
  113. #define ADC_EXTTRIG_REGULAR_T0_CH0 CTL1_ETSRC(0) /*!< TIMER0 CH0 event select */
  114. #define ADC_EXTTRIG_REGULAR_T0_CH1 CTL1_ETSRC(1) /*!< TIMER0 CH1 event select */
  115. #define ADC_EXTTRIG_REGULAR_T0_CH2 CTL1_ETSRC(2) /*!< TIMER0 CH2 event select */
  116. #define ADC_EXTTRIG_REGULAR_T1_CH1 CTL1_ETSRC(3) /*!< TIMER1 CH1 event select */
  117. #define ADC_EXTTRIG_REGULAR_T2_TRGO CTL1_ETSRC(4) /*!< TIMER2 TRGO event select */
  118. #define ADC_EXTTRIG_REGULAR_T14_CH1 CTL1_ETSRC(5) /*!< TIMER14 CH1 event select */
  119. #define ADC_EXTTRIG_REGULAR_EXTI_11 CTL1_ETSRC(6) /*!< external interrupt line 11 */
  120. #define ADC_EXTTRIG_REGULAR_NONE CTL1_ETSRC(7) /*!< software trigger */
  121. /* external trigger select for inserted channel */
  122. #define CTL1_ETSIC(regval) (BITS(12,14) & ((uint32_t)(regval) << 12))
  123. #define ADC_EXTTRIG_INSERTED_T0_TRGO CTL1_ETSIC(0) /*!< TIMER0 TRGO event select */
  124. #define ADC_EXTTRIG_INSERTED_T0_CH3 CTL1_ETSIC(1) /*!< TIMER0 CH3 event select */
  125. #define ADC_EXTTRIG_INSERTED_T1_TRGO CTL1_ETSIC(2) /*!< TIMER1 TRGO event select */
  126. #define ADC_EXTTRIG_INSERTED_T1_CH0 CTL1_ETSIC(3) /*!< TIMER1 CH0 event select */
  127. #define ADC_EXTTRIG_INSERTED_T2_CH3 CTL1_ETSIC(4) /*!< TIMER2 CH3 event select */
  128. #define ADC_EXTTRIG_INSERTED_T14_TRGO CTL1_ETSIC(5) /*!< TIMER14 TRGO event select */
  129. #define ADC_EXTTRIG_INSERTED_EXTI_15 CTL1_ETSIC(6) /*!< external interrupt line 15 */
  130. #define ADC_EXTTRIG_INSERTED_NONE CTL1_ETSIC(7) /*!< software trigger */
  131. /* adc_samptx register value */
  132. #define SAMPTX_SPT(regval) (BITS(0,2) & ((uint32_t)(regval) << 0))
  133. #define ADC_SAMPLETIME_1POINT5 SAMPTX_SPT(0) /*!< 1.5 sampling cycles */
  134. #define ADC_SAMPLETIME_7POINT5 SAMPTX_SPT(1) /*!< 7.5 sampling cycles */
  135. #define ADC_SAMPLETIME_13POINT5 SAMPTX_SPT(2) /*!< 13.5 sampling cycles */
  136. #define ADC_SAMPLETIME_28POINT5 SAMPTX_SPT(3) /*!< 28.5 sampling cycles */
  137. #define ADC_SAMPLETIME_41POINT5 SAMPTX_SPT(4) /*!< 41.5 sampling cycles */
  138. #define ADC_SAMPLETIME_55POINT5 SAMPTX_SPT(5) /*!< 55.5 sampling cycles */
  139. #define ADC_SAMPLETIME_71POINT5 SAMPTX_SPT(6) /*!< 71.5 sampling cycles */
  140. #define ADC_SAMPLETIME_239POINT5 SAMPTX_SPT(7) /*!< 239.5 sampling cycles */
  141. /* ADC data offset for inserted channel x*/
  142. #define IOFFX_IOFF(regval) (BITS(0,11) & ((uint32_t)(regval) << 0))
  143. /* ADC analog watchdog high threshold */
  144. #define WDHT_WDHT(regval) (BITS(0,11) & ((uint32_t)(regval) << 0))
  145. /* ADC analog watchdog low threshold */
  146. #define WDLT_WDLT(regval) (BITS(0,11) & ((uint32_t)(regval) << 0))
  147. /* ADC regular channel group length */
  148. #define RSQ0_RL(regval) (BITS(20,23) & ((uint32_t)(regval) << 20))
  149. /* ADC inserted channel group length */
  150. #define ISQ_IL(regval) (BITS(20,21) & ((uint32_t)(regval) << 20))
  151. /* ADC resolution definitions */
  152. #define CTL0_DRES(regval) (BITS(24,25) & ((regval) << 24)) /*!< ADC resolution */
  153. #define ADC_RESOLUTION_12B CTL0_DRES(0) /*!< 12-bit ADC resolution */
  154. #define ADC_RESOLUTION_10B CTL0_DRES(1) /*!< 10-bit ADC resolution */
  155. #define ADC_RESOLUTION_8B CTL0_DRES(2) /*!< 8-bit ADC resolution */
  156. #define ADC_RESOLUTION_6B CTL0_DRES(3) /*!< 6-bit ADC resolution */
  157. /* ADC oversampling shift */
  158. #define OVSAMPCTL_OVSS(regval) (BITS(5,8) & ((uint32_t)(regval) << 5))
  159. #define ADC_OVERSAMPLING_SHIFT_NONE OVSAMPCTL_OVSS(0) /*!< no oversampling shift */
  160. #define ADC_OVERSAMPLING_SHIFT_1B OVSAMPCTL_OVSS(1) /*!< 1-bit oversampling shift */
  161. #define ADC_OVERSAMPLING_SHIFT_2B OVSAMPCTL_OVSS(2) /*!< 2-bit oversampling shift */
  162. #define ADC_OVERSAMPLING_SHIFT_3B OVSAMPCTL_OVSS(3) /*!< 3-bit oversampling shift */
  163. #define ADC_OVERSAMPLING_SHIFT_4B OVSAMPCTL_OVSS(4) /*!< 4-bit oversampling shift */
  164. #define ADC_OVERSAMPLING_SHIFT_5B OVSAMPCTL_OVSS(5) /*!< 5-bit oversampling shift */
  165. #define ADC_OVERSAMPLING_SHIFT_6B OVSAMPCTL_OVSS(6) /*!< 6-bit oversampling shift */
  166. #define ADC_OVERSAMPLING_SHIFT_7B OVSAMPCTL_OVSS(7) /*!< 7-bit oversampling shift */
  167. #define ADC_OVERSAMPLING_SHIFT_8B OVSAMPCTL_OVSS(8) /*!< 8-bit oversampling shift */
  168. /* ADC oversampling ratio */
  169. #define OVSAMPCTL_OVSR(regval) (BITS(2,4) & ((uint32_t)(regval) << 2))
  170. #define ADC_OVERSAMPLING_RATIO_MUL2 OVSAMPCTL_OVSR(0) /*!< oversampling ratio multiple 2 */
  171. #define ADC_OVERSAMPLING_RATIO_MUL4 OVSAMPCTL_OVSR(1) /*!< oversampling ratio multiple 4 */
  172. #define ADC_OVERSAMPLING_RATIO_MUL8 OVSAMPCTL_OVSR(2) /*!< oversampling ratio multiple 8 */
  173. #define ADC_OVERSAMPLING_RATIO_MUL16 OVSAMPCTL_OVSR(3) /*!< oversampling ratio multiple 16 */
  174. #define ADC_OVERSAMPLING_RATIO_MUL32 OVSAMPCTL_OVSR(4) /*!< oversampling ratio multiple 32 */
  175. #define ADC_OVERSAMPLING_RATIO_MUL64 OVSAMPCTL_OVSR(5) /*!< oversampling ratio multiple 64 */
  176. #define ADC_OVERSAMPLING_RATIO_MUL128 OVSAMPCTL_OVSR(6) /*!< oversampling ratio multiple 128 */
  177. #define ADC_OVERSAMPLING_RATIO_MUL256 OVSAMPCTL_OVSR(7) /*!< oversampling ratio multiple 256 */
  178. /* ADC triggered oversampling */
  179. #define ADC_OVERSAMPLING_ALL_CONVERT 0U /*!< all oversampled conversions for a channel are done consecutively after a trigger */
  180. #define ADC_OVERSAMPLING_ONE_CONVERT 1U /*!< each oversampled conversion for a channel needs a trigger */
  181. /* ADC channel group definitions */
  182. #define ADC_REGULAR_CHANNEL ((uint8_t)0x01U) /*!< ADC regular channel group */
  183. #define ADC_INSERTED_CHANNEL ((uint8_t)0x02U) /*!< ADC inserted channel group */
  184. #define ADC_REGULAR_INSERTED_CHANNEL ((uint8_t)0x03U) /*!< both regular and inserted channel group */
  185. #define ADC_CHANNEL_DISCON_DISABLE ((uint8_t)0x04U) /*!< disable discontinuous mode of regular & inserted channel */
  186. /* ADC inserted channel definitions */
  187. #define ADC_INSERTED_CHANNEL_0 ((uint8_t)0x00U) /*!< ADC inserted channel 0 */
  188. #define ADC_INSERTED_CHANNEL_1 ((uint8_t)0x01U) /*!< ADC inserted channel 1 */
  189. #define ADC_INSERTED_CHANNEL_2 ((uint8_t)0x02U) /*!< ADC inserted channel 2 */
  190. #define ADC_INSERTED_CHANNEL_3 ((uint8_t)0x03U) /*!< ADC inserted channel 3 */
  191. /* ADC channel definitions */
  192. #define ADC_CHANNEL_0 ((uint8_t)0x00U) /*!< ADC channel 0 */
  193. #define ADC_CHANNEL_1 ((uint8_t)0x01U) /*!< ADC channel 1 */
  194. #define ADC_CHANNEL_2 ((uint8_t)0x02U) /*!< ADC channel 2 */
  195. #define ADC_CHANNEL_3 ((uint8_t)0x03U) /*!< ADC channel 3 */
  196. #define ADC_CHANNEL_4 ((uint8_t)0x04U) /*!< ADC channel 4 */
  197. #define ADC_CHANNEL_5 ((uint8_t)0x05U) /*!< ADC channel 5 */
  198. #define ADC_CHANNEL_6 ((uint8_t)0x06U) /*!< ADC channel 6 */
  199. #define ADC_CHANNEL_7 ((uint8_t)0x07U) /*!< ADC channel 7 */
  200. #define ADC_CHANNEL_8 ((uint8_t)0x08U) /*!< ADC channel 8 */
  201. #define ADC_CHANNEL_9 ((uint8_t)0x09U) /*!< ADC channel 9 */
  202. #define ADC_CHANNEL_10 ((uint8_t)0x0AU) /*!< ADC channel 10 */
  203. #define ADC_CHANNEL_11 ((uint8_t)0x0BU) /*!< ADC channel 11 */
  204. #define ADC_CHANNEL_12 ((uint8_t)0x0CU) /*!< ADC channel 12 */
  205. #define ADC_CHANNEL_13 ((uint8_t)0x0DU) /*!< ADC channel 13 */
  206. #define ADC_CHANNEL_14 ((uint8_t)0x0EU) /*!< ADC channel 14 */
  207. #define ADC_CHANNEL_15 ((uint8_t)0x0FU) /*!< ADC channel 15 */
  208. #define ADC_CHANNEL_16 ((uint8_t)0x10U) /*!< ADC channel 16 */
  209. #define ADC_CHANNEL_17 ((uint8_t)0x11U) /*!< ADC channel 17 */
  210. #define ADC_CHANNEL_18 ((uint8_t)0x12U) /*!< ADC channel 18 */
  211. /* ADC interrupt definitions */
  212. #define ADC_INT_WDE ADC_STAT_WDE /*!< analog watchdog event interrupt */
  213. #define ADC_INT_EOC ADC_STAT_EOC /*!< end of group conversion interrupt */
  214. #define ADC_INT_EOIC ADC_STAT_EOIC /*!< end of inserted group conversion interrupt */
  215. /* ADC interrupt flag */
  216. #define ADC_INT_FLAG_WDE ADC_STAT_WDE /*!< analog watchdog event interrupt flag */
  217. #define ADC_INT_FLAG_EOC ADC_STAT_EOC /*!< end of group conversion interrupt flag */
  218. #define ADC_INT_FLAG_EOIC ADC_STAT_EOIC /*!< end of inserted group conversion interrupt flag */
  219. /* function declarations */
  220. /* reset ADC */
  221. void adc_deinit(void);
  222. /* enable ADC interface */
  223. void adc_enable(void);
  224. /* disable ADC interface */
  225. void adc_disable(void);
  226. /* ADC calibration and reset calibration */
  227. void adc_calibration_enable(void);
  228. /* enable DMA request */
  229. void adc_dma_mode_enable(void);
  230. /* disable DMA request */
  231. void adc_dma_mode_disable(void);
  232. /* enable the temperature sensor and Vrefint channel */
  233. void adc_tempsensor_vrefint_enable(void);
  234. /* disable the temperature sensor and Vrefint channel */
  235. void adc_tempsensor_vrefint_disable(void);
  236. /* enable the vbat channel */
  237. void adc_vbat_enable(void);
  238. /* disable the vbat channel */
  239. void adc_vbat_disable(void);
  240. /* configure ADC discontinuous mode */
  241. void adc_discontinuous_mode_config(uint8_t channel_group, uint8_t length);
  242. /* configure ADC special function */
  243. void adc_special_function_config(uint32_t function, ControlStatus newvalue);
  244. /* configure ADC data alignment */
  245. void adc_data_alignment_config(uint32_t data_alignment);
  246. /* configure the length of regular channel group or inserted channel group */
  247. void adc_channel_length_config(uint8_t channel_group, uint32_t length);
  248. /* configure ADC regular channel */
  249. void adc_regular_channel_config(uint8_t rank, uint8_t channel, uint32_t sample_time);
  250. /* configure ADC inserted channel */
  251. void adc_inserted_channel_config(uint8_t rank, uint8_t channel, uint32_t sample_time);
  252. /* configure ADC inserted channel offset */
  253. void adc_inserted_channel_offset_config(uint8_t inserted_channel, uint16_t offset);
  254. /* enable ADC external trigger */
  255. void adc_external_trigger_config(uint8_t channel_group, ControlStatus newvalue);
  256. /* configure ADC external trigger source */
  257. void adc_external_trigger_source_config(uint8_t channel_group, uint32_t external_trigger_source);
  258. /* enable ADC software trigger */
  259. void adc_software_trigger_enable(uint8_t channel_group);
  260. /* read ADC regular group data register */
  261. uint16_t adc_regular_data_read(void);
  262. /* read ADC inserted group data register */
  263. uint16_t adc_inserted_data_read(uint8_t inserted_channel);
  264. /* get the ADC flag bits */
  265. FlagStatus adc_flag_get(uint32_t flag);
  266. /* clear the ADC flag bits */
  267. void adc_flag_clear(uint32_t flag);
  268. /* get the ADC interrupt bits */
  269. FlagStatus adc_interrupt_flag_get(uint32_t flag);
  270. /* clear the ADC flag */
  271. void adc_interrupt_flag_clear(uint32_t flag);
  272. /* enable ADC interrupt */
  273. void adc_interrupt_enable(uint32_t interrupt);
  274. /* disable ADC interrupt */
  275. void adc_interrupt_disable(uint32_t interrupt);
  276. /* configure ADC analog watchdog single channel */
  277. void adc_watchdog_single_channel_enable(uint8_t channel);
  278. /* configure ADC analog watchdog group channel */
  279. void adc_watchdog_group_channel_enable(uint8_t channel_group);
  280. /* disable ADC analog watchdog */
  281. void adc_watchdog_disable(void);
  282. /* configure ADC analog watchdog threshold */
  283. void adc_watchdog_threshold_config(uint16_t low_threshold, uint16_t high_threshold);
  284. /* configure ADC resolution */
  285. void adc_resolution_config(uint32_t resolution);
  286. /* configure ADC oversample mode */
  287. void adc_oversample_mode_config(uint8_t mode, uint16_t shift, uint8_t ratio);
  288. /* enable ADC oversample mode */
  289. void adc_oversample_mode_enable(void);
  290. /* disable ADC oversample mode */
  291. void adc_oversample_mode_disable(void);
  292. #endif /* GD32F3X0_ADC_H */