ft32f0xx_adc.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /**
  2. ******************************************************************************
  3. * @file ft32f0xx_adc.h
  4. * @author FMD AE
  5. * @brief This file contains all the functions prototypes for the ADC firmware
  6. * library
  7. * @version V1.0.0
  8. * @data 2021-07-01
  9. ******************************************************************************
  10. */
  11. /* Define to prevent recursive inclusion -------------------------------------*/
  12. #ifndef __FT32F0XX_ADC_H
  13. #define __FT32F0XX_ADC_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Includes ------------------------------------------------------------------*/
  18. #include "ft32f0xx.h"
  19. /** @addtogroup ADC
  20. * @{
  21. */
  22. /* Exported types ------------------------------------------------------------*/
  23. /**
  24. * @brief ADC Init structure definition
  25. */
  26. typedef struct
  27. {
  28. uint32_t ADC_Resolution; /*!< Selects the resolution of the conversion.
  29. This parameter can be a value of @ref ADC_Resolution */
  30. FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion is performed in
  31. Continuous or Single mode.
  32. This parameter can be set to ENABLE or DISABLE. */
  33. uint32_t ADC_ExternalTrigConvEdge; /*!< Selects the external trigger Edge and enables the
  34. trigger of a regular group. This parameter can be a value
  35. of @ref ADC_external_trigger_edge_conversion */
  36. uint32_t ADC_ExternalTrigConv; /*!< Defines the external trigger used to start the analog
  37. to digital conversion of regular channels. This parameter
  38. can be a value of @ref ADC_external_trigger_sources_for_channels_conversion */
  39. uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
  40. This parameter can be a value of @ref ADC_data_align */
  41. uint32_t ADC_ScanDirection; /*!< Specifies in which direction the channels will be scanned
  42. in the sequence.
  43. This parameter can be a value of @ref ADC_Scan_Direction */
  44. }ADC_InitTypeDef;
  45. /* Exported constants --------------------------------------------------------*/
  46. /** @defgroup ADC_Exported_Constants
  47. * @{
  48. */
  49. #define IS_ADC_ALL_PERIPH(PERIPH) ((PERIPH) == ADC1)
  50. /** @defgroup ADC_JitterOff
  51. * @{
  52. */
  53. /* These defines are obsolete and maintained for legacy purpose only. They are replaced by the ADC_ClockMode */
  54. #define ADC_JitterOff_PCLKDiv2 ADC_CFGR2_JITOFFDIV2
  55. #define ADC_JitterOff_PCLKDiv4 ADC_CFGR2_JITOFFDIV4
  56. #define IS_ADC_JITTEROFF(JITTEROFF) (((JITTEROFF) & 0x3FFFFFFF) == (uint32_t)RESET)
  57. /**
  58. * @}
  59. */
  60. /** @defgroup ADC_ClockMode
  61. * @{
  62. */
  63. #define ADC_ClockMode_AsynClk ((uint32_t)0x00000000) /*!< ADC Asynchronous clock mode */
  64. #define ADC_ClockMode_SynClkDiv2 ADC_CFGR2_CKMODE_0 /*!< Synchronous clock mode divided by 2 */
  65. #define ADC_ClockMode_SynClkDiv4 ADC_CFGR2_CKMODE_1 /*!< Synchronous clock mode divided by 4 */
  66. #define IS_ADC_CLOCKMODE(CLOCK) (((CLOCK) == ADC_ClockMode_AsynClk) ||\
  67. ((CLOCK) == ADC_ClockMode_SynClkDiv2) ||\
  68. ((CLOCK) == ADC_ClockMode_SynClkDiv4))
  69. /**
  70. * @}
  71. */
  72. /** @defgroup ADC_Resolution
  73. * @{
  74. */
  75. #define ADC_Resolution_12b ((uint32_t)0x00000000)
  76. #define ADC_Resolution_10b ADC_CFGR1_RES_0
  77. #define ADC_Resolution_8b ADC_CFGR1_RES_1
  78. #define ADC_Resolution_6b ADC_CFGR1_RES
  79. #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_Resolution_12b) || \
  80. ((RESOLUTION) == ADC_Resolution_10b) || \
  81. ((RESOLUTION) == ADC_Resolution_8b) || \
  82. ((RESOLUTION) == ADC_Resolution_6b))
  83. /**
  84. * @}
  85. */
  86. /** @defgroup ADC_external_trigger_edge_conversion
  87. * @{
  88. */
  89. #define ADC_ExternalTrigConvEdge_None ((uint32_t)0x00000000)
  90. #define ADC_ExternalTrigConvEdge_Rising ADC_CFGR1_EXTEN_0
  91. #define ADC_ExternalTrigConvEdge_Falling ADC_CFGR1_EXTEN_1
  92. #define ADC_ExternalTrigConvEdge_RisingFalling ADC_CFGR1_EXTEN
  93. #define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_ExternalTrigConvEdge_None) || \
  94. ((EDGE) == ADC_ExternalTrigConvEdge_Rising) || \
  95. ((EDGE) == ADC_ExternalTrigConvEdge_Falling) || \
  96. ((EDGE) == ADC_ExternalTrigConvEdge_RisingFalling))
  97. /**
  98. * @}
  99. */
  100. /** @defgroup ADC_external_trigger_sources_for_channels_conversion
  101. * @{
  102. */
  103. /* TIM1 */
  104. #define ADC_ExternalTrigConv_T1_TRGO ((uint32_t)0x00000000)
  105. #define ADC_ExternalTrigConv_T1_CC4 ADC_CFGR1_EXTSEL_0
  106. /* TIM2 */
  107. #define ADC_ExternalTrigConv_T2_TRGO ADC_CFGR1_EXTSEL_1
  108. /* TIM3 */
  109. #define ADC_ExternalTrigConv_T3_TRGO ((uint32_t)(ADC_CFGR1_EXTSEL_0 | ADC_CFGR1_EXTSEL_1))
  110. /* TIM15 */
  111. #define ADC_ExternalTrigConv_T15_TRGO ADC_CFGR1_EXTSEL_2
  112. #define IS_ADC_EXTERNAL_TRIG_CONV(CONV) (((CONV) == ADC_ExternalTrigConv_T1_TRGO) || \
  113. ((CONV) == ADC_ExternalTrigConv_T1_CC4) || \
  114. ((CONV) == ADC_ExternalTrigConv_T2_TRGO) || \
  115. ((CONV) == ADC_ExternalTrigConv_T3_TRGO) || \
  116. ((CONV) == ADC_ExternalTrigConv_T15_TRGO))
  117. /**
  118. * @}
  119. */
  120. /** @defgroup ADC_data_align
  121. * @{
  122. */
  123. #define ADC_DataAlign_Right ((uint32_t)0x00000000)
  124. #define ADC_DataAlign_Left ADC_CFGR1_ALIGN
  125. #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DataAlign_Right) || \
  126. ((ALIGN) == ADC_DataAlign_Left))
  127. /**
  128. * @}
  129. */
  130. /** @defgroup ADC_Scan_Direction
  131. * @{
  132. */
  133. #define ADC_ScanDirection_Upward ((uint32_t)0x00000000)
  134. #define ADC_ScanDirection_Backward ADC_CFGR1_SCANDIR
  135. #define IS_ADC_SCAN_DIRECTION(DIRECTION) (((DIRECTION) == ADC_ScanDirection_Upward) || \
  136. ((DIRECTION) == ADC_ScanDirection_Backward))
  137. /**
  138. * @}
  139. */
  140. /** @defgroup ADC_DMA_Mode
  141. * @{
  142. */
  143. #define ADC_DMAMode_OneShot ((uint32_t)0x00000000)
  144. #define ADC_DMAMode_Circular ADC_CFGR1_DMACFG
  145. #define IS_ADC_DMA_MODE(MODE) (((MODE) == ADC_DMAMode_OneShot) || \
  146. ((MODE) == ADC_DMAMode_Circular))
  147. /**
  148. * @}
  149. */
  150. /** @defgroup ADC_analog_watchdog_selection
  151. * @{
  152. */
  153. #define ADC_AnalogWatchdog_Channel_0 ((uint32_t)0x00000000)
  154. #define ADC_AnalogWatchdog_Channel_1 ((uint32_t)0x04000000)
  155. #define ADC_AnalogWatchdog_Channel_2 ((uint32_t)0x08000000)
  156. #define ADC_AnalogWatchdog_Channel_3 ((uint32_t)0x0C000000)
  157. #define ADC_AnalogWatchdog_Channel_4 ((uint32_t)0x10000000)
  158. #define ADC_AnalogWatchdog_Channel_5 ((uint32_t)0x14000000)
  159. #define ADC_AnalogWatchdog_Channel_6 ((uint32_t)0x18000000)
  160. #define ADC_AnalogWatchdog_Channel_7 ((uint32_t)0x1C000000)
  161. #define ADC_AnalogWatchdog_Channel_8 ((uint32_t)0x20000000)
  162. #define ADC_AnalogWatchdog_Channel_9 ((uint32_t)0x24000000)
  163. #define ADC_AnalogWatchdog_Channel_10 ((uint32_t)0x28000000)
  164. #define ADC_AnalogWatchdog_Channel_11 ((uint32_t)0x2C000000)
  165. #define ADC_AnalogWatchdog_Channel_12 ((uint32_t)0x30000000)
  166. #define ADC_AnalogWatchdog_Channel_13 ((uint32_t)0x34000000)
  167. #define ADC_AnalogWatchdog_Channel_14 ((uint32_t)0x38000000)
  168. #define ADC_AnalogWatchdog_Channel_15 ((uint32_t)0x3C000000)
  169. #define ADC_AnalogWatchdog_Channel_16 ((uint32_t)0x40000000)
  170. #define ADC_AnalogWatchdog_Channel_17 ((uint32_t)0x44000000)
  171. #define ADC_AnalogWatchdog_Channel_18 ((uint32_t)0x48000000)
  172. #define IS_ADC_ANALOG_WATCHDOG_CHANNEL(CHANNEL) (((CHANNEL) == ADC_AnalogWatchdog_Channel_0) || \
  173. ((CHANNEL) == ADC_AnalogWatchdog_Channel_1) || \
  174. ((CHANNEL) == ADC_AnalogWatchdog_Channel_2) || \
  175. ((CHANNEL) == ADC_AnalogWatchdog_Channel_3) || \
  176. ((CHANNEL) == ADC_AnalogWatchdog_Channel_4) || \
  177. ((CHANNEL) == ADC_AnalogWatchdog_Channel_5) || \
  178. ((CHANNEL) == ADC_AnalogWatchdog_Channel_6) || \
  179. ((CHANNEL) == ADC_AnalogWatchdog_Channel_7) || \
  180. ((CHANNEL) == ADC_AnalogWatchdog_Channel_8) || \
  181. ((CHANNEL) == ADC_AnalogWatchdog_Channel_9) || \
  182. ((CHANNEL) == ADC_AnalogWatchdog_Channel_10) || \
  183. ((CHANNEL) == ADC_AnalogWatchdog_Channel_11) || \
  184. ((CHANNEL) == ADC_AnalogWatchdog_Channel_12) || \
  185. ((CHANNEL) == ADC_AnalogWatchdog_Channel_13) || \
  186. ((CHANNEL) == ADC_AnalogWatchdog_Channel_14) || \
  187. ((CHANNEL) == ADC_AnalogWatchdog_Channel_15) || \
  188. ((CHANNEL) == ADC_AnalogWatchdog_Channel_16) || \
  189. ((CHANNEL) == ADC_AnalogWatchdog_Channel_17) || \
  190. ((CHANNEL) == ADC_AnalogWatchdog_Channel_18))
  191. /**
  192. * @}
  193. */
  194. /** @defgroup ADC_sampling_times
  195. * @{
  196. */
  197. #define ADC_SampleTime_1_5Cycles ((uint32_t)0x00000000)
  198. #define ADC_SampleTime_7_5Cycles ((uint32_t)0x00000001)
  199. #define ADC_SampleTime_13_5Cycles ((uint32_t)0x00000002)
  200. #define ADC_SampleTime_28_5Cycles ((uint32_t)0x00000003)
  201. #define ADC_SampleTime_41_5Cycles ((uint32_t)0x00000004)
  202. #define ADC_SampleTime_55_5Cycles ((uint32_t)0x00000005)
  203. #define ADC_SampleTime_71_5Cycles ((uint32_t)0x00000006)
  204. #define ADC_SampleTime_239_5Cycles ((uint32_t)0x00000007)
  205. #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SampleTime_1_5Cycles) || \
  206. ((TIME) == ADC_SampleTime_7_5Cycles) || \
  207. ((TIME) == ADC_SampleTime_13_5Cycles) || \
  208. ((TIME) == ADC_SampleTime_28_5Cycles) || \
  209. ((TIME) == ADC_SampleTime_41_5Cycles) || \
  210. ((TIME) == ADC_SampleTime_55_5Cycles) || \
  211. ((TIME) == ADC_SampleTime_71_5Cycles) || \
  212. ((TIME) == ADC_SampleTime_239_5Cycles))
  213. /**
  214. * @}
  215. */
  216. /** @defgroup ADC_thresholds
  217. * @{
  218. */
  219. #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFF)
  220. /**
  221. * @}
  222. */
  223. /** @defgroup ADC_channels
  224. * @{
  225. */
  226. #define ADC_Channel_0 ADC_CHSELR_CHSEL0
  227. #define ADC_Channel_1 ADC_CHSELR_CHSEL1
  228. #define ADC_Channel_2 ADC_CHSELR_CHSEL2
  229. #define ADC_Channel_3 ADC_CHSELR_CHSEL3
  230. #define ADC_Channel_4 ADC_CHSELR_CHSEL4
  231. #define ADC_Channel_5 ADC_CHSELR_CHSEL5
  232. #define ADC_Channel_6 ADC_CHSELR_CHSEL6
  233. #define ADC_Channel_7 ADC_CHSELR_CHSEL7
  234. #define ADC_Channel_8 ADC_CHSELR_CHSEL8
  235. #define ADC_Channel_9 ADC_CHSELR_CHSEL9
  236. #define ADC_Channel_10 ADC_CHSELR_CHSEL10
  237. #define ADC_Channel_11 ADC_CHSELR_CHSEL11
  238. #define ADC_Channel_12 ADC_CHSELR_CHSEL12
  239. #define ADC_Channel_13 ADC_CHSELR_CHSEL13
  240. #define ADC_Channel_14 ADC_CHSELR_CHSEL14
  241. #define ADC_Channel_15 ADC_CHSELR_CHSEL15
  242. #define ADC_Channel_16 ADC_CHSELR_CHSEL16
  243. #define ADC_Channel_17 ADC_CHSELR_CHSEL17
  244. #define ADC_Channel_18 ADC_CHSELR_CHSEL18
  245. #define ADC_Channel_19 ADC_CHSELR_CHSEL19
  246. #define ADC_Channel_20 ADC_CHSELR_CHSEL20
  247. #define ADC_Channel_21 ADC_CHSELR_CHSEL21
  248. #define ADC_Channel_TempSensor ((uint32_t)ADC_Channel_16)
  249. #define ADC_Channel_Vrefint ((uint32_t)ADC_Channel_17)
  250. #if defined (FT32F072xB)
  251. #define ADC_Channel_OP1 ((uint32_t)ADC_Channel_18)
  252. #define ADC_Channel_OP2 ((uint32_t)ADC_Channel_19)
  253. #define ADC_Channel_IOSH1 ((uint32_t)ADC_Channel_20)
  254. #define ADC_Channel_IOSH2 ((uint32_t)ADC_Channel_21)
  255. #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) != (uint32_t)RESET) && (((CHANNEL) & 0xFFC00000) == (uint32_t)RESET))
  256. #else
  257. #define ADC_Channel_IOSH ((uint32_t)ADC_Channel_18)
  258. #define ADC_Channel_OP ((uint32_t)ADC_Channel_19)
  259. #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) != (uint32_t)RESET) && (((CHANNEL) & 0xFFF00000) == (uint32_t)RESET))
  260. #endif
  261. #if defined (FT32F072xB)
  262. /**
  263. * @}ADC_IOSH1_SMPSEL
  264. */
  265. #define ADC_IOSH1_SMPSEL_PB1 ((uint32_t)0x00000000)
  266. #define ADC_IOSH1_SMPSEL_OP1OUT ((uint32_t)0x00000400)
  267. #define ADC_IOSH2_SMPSEL_PB0 ((uint32_t)0x00000000)
  268. #define ADC_IOSH2_SMPSEL_OP2OUT ((uint32_t)0x00004000)
  269. #define IS_ADC_SMPSEL(SEL) ( ((SEL) == ADC_IOSH2_SMPSEL_PB1) || \
  270. ((SEL) == ADC_IOSH2_SMPSEL_OP1OUT) || \
  271. ((SEL) == ADC_IOSH1_SMPSEL_OP2OUT) )
  272. /**
  273. * @}IS_ADC_SMPEN
  274. */
  275. #define ADC_IOSH1_SMPEN ((uint32_t)0x00000200)
  276. #define ADC_IOSH2_SMPEN ((uint32_t)0x00002000)
  277. #define IS_ADC_SMPEN(SMPEN) ( ((SMPEN) == ADC_IOSH1_SMPEN) || \
  278. ((SMPEN) == ADC_IOSH2_SMPEN) )
  279. /**
  280. * @}IS_ADC_SMPMOD
  281. */
  282. #define IS_ADC_SMPMOD(SMPMOD) ( ((SMPMOD) == ADC_CR2_IOSH1_SMPMOD) || \
  283. ((SMPMOD) == ADC_CR2_IOSH2_SMPMOD) )
  284. #define ADC_SMP_SOFTWARE_MODE ((uint32_t)0x00000000)
  285. #define ADC_SMP_HARDWARE_MODE ((uint32_t)0x00000001)
  286. #define IS_ADC_MODE(MODE) ( ((MODE) == ADC_SMP_SOFTWARE_MODE) || \
  287. ((MODE) == ADC_SMP_HARDWARE_MODE) )
  288. /**
  289. * @}IS_ADC_AMPEN
  290. */
  291. #define ADC_IOSH1_AMPEN ((uint32_t)0x00000100)
  292. #define ADC_IOSH2_AMPEN ((uint32_t)0x00001000)
  293. #define IS_ADC_AMPEN(AMPEN) ( ((AMPEN) == ADC_IOSH1_AMPEN) || \
  294. ((AMPEN) == ADC_IOSH2_AMPEN) )
  295. /**
  296. * @}IS_ADC_EXTDLY
  297. */
  298. #define IS_ADC_EXTDLY(EXTDLY) ( ((EXTDLY) >=0 ) && ((EXTDLY) <= 0x000003FF))
  299. /**
  300. * @}IS_ADC_RTEN
  301. */
  302. #define IS_ADC_RTEN(RTEN) ( ((RTEN) == ADC_RTENR_RTEN) || \
  303. ((RTEN) == ADC_RTENR_RTEN_0) || \
  304. ((RTEN) == ADC_RTENR_RTEN_1) || \
  305. ((RTEN) == ADC_RTENR_RTEN_2) || \
  306. ((RTEN) == ADC_RTENR_RTEN_3) || \
  307. ((RTEN) == ADC_RTENR_RTEN_4) || \
  308. ((RTEN) == ADC_RTENR_RTEN_5) || \
  309. ((RTEN) == ADC_RTENR_RTEN_6) || \
  310. ((RTEN) == ADC_RTENR_RTEN_7) || \
  311. ((RTEN) == ADC_RTENR_RTEN_8) || \
  312. ((RTEN) == ADC_RTENR_RTEN_9) || \
  313. ((RTEN) == ADC_RTENR_RTEN_10) || \
  314. ((RTEN) == ADC_RTENR_RTEN_11) || \
  315. ((RTEN) == ADC_RTENR_RTEN_12) || \
  316. ((RTEN) == ADC_RTENR_RTEN_13) || \
  317. ((RTEN) == ADC_RTENR_RTEN_14) || \
  318. ((RTEN) == ADC_RTENR_RTEN_15) || \
  319. ((RTEN) == ADC_RTENR_RTEN_16) || \
  320. ((RTEN) == ADC_RTENR_RTEN_17) || \
  321. ((RTEN) == ADC_RTENR_RTEN_18) )
  322. /**
  323. * @}IS_ADC_FTEN
  324. */
  325. #define IS_ADC_FTEN(FTEN) ( ((FTEN) == ADC_FTENR_FTEN) || \
  326. ((FTEN) == ADC_FTENR_FTEN_0) || \
  327. ((FTEN) == ADC_FTENR_FTEN_1) || \
  328. ((FTEN) == ADC_FTENR_FTEN_2) || \
  329. ((FTEN) == ADC_FTENR_FTEN_3) || \
  330. ((FTEN) == ADC_FTENR_FTEN_4) || \
  331. ((FTEN) == ADC_FTENR_FTEN_5) || \
  332. ((FTEN) == ADC_FTENR_FTEN_6) || \
  333. ((FTEN) == ADC_FTENR_FTEN_7) || \
  334. ((FTEN) == ADC_FTENR_FTEN_8) || \
  335. ((FTEN) == ADC_FTENR_FTEN_9) || \
  336. ((FTEN) == ADC_FTENR_FTEN_10) || \
  337. ((FTEN) == ADC_FTENR_FTEN_11) || \
  338. ((FTEN) == ADC_FTENR_FTEN_12) || \
  339. ((FTEN) == ADC_FTENR_FTEN_13) || \
  340. ((FTEN) == ADC_FTENR_FTEN_14) || \
  341. ((FTEN) == ADC_FTENR_FTEN_15) || \
  342. ((FTEN) == ADC_FTENR_FTEN_16) || \
  343. ((FTEN) == ADC_FTENR_FTEN_17) || \
  344. ((FTEN) == ADC_FTENR_FTEN_18))
  345. #else
  346. /**
  347. * @}IS_ADC_AMPEN
  348. */
  349. #define ADC_IOSH1_AMPEN ((uint32_t)0x00000100)
  350. #define ADC_IOSH_AMPEN ADC_IOSH1_AMPEN
  351. #define IS_ADC_AMPEN(AMPEN) ( ((AMPEN) == ADC_IOSH1_AMPEN))
  352. /**
  353. * @}IS_ADC_SMPEN
  354. */
  355. #define ADC_IOSH1_SMPEN ((uint32_t)0x00000200)
  356. #define ADC_IOSH_SMPEN ADC_IOSH1_SMPEN
  357. #define IS_ADC_SMPEN(SMPEN) ( ((SMPEN) == ADC_IOSH1_SMPEN) )
  358. #endif
  359. /**
  360. * @}
  361. */
  362. /** @defgroup ADC_interrupts_definition
  363. * @{
  364. */
  365. #define ADC_IT_ADRDY ADC_IER_ADRDYIE
  366. #define ADC_IT_EOSMP ADC_IER_EOSMPIE
  367. #define ADC_IT_EOC ADC_IER_EOCIE
  368. #define ADC_IT_EOSEQ ADC_IER_EOSEQIE
  369. #define ADC_IT_OVR ADC_IER_OVRIE
  370. #define ADC_IT_AWD ADC_IER_AWDIE
  371. #define IS_ADC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFF60) == (uint32_t)RESET))
  372. #define IS_ADC_GET_IT(IT) (((IT) == ADC_IT_ADRDY) || ((IT) == ADC_IT_EOSMP) || \
  373. ((IT) == ADC_IT_EOC) || ((IT) == ADC_IT_EOSEQ) || \
  374. ((IT) == ADC_IT_OVR) || ((IT) == ADC_IT_AWD))
  375. #define IS_ADC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFF60) == (uint32_t)RESET))
  376. /**
  377. * @}
  378. */
  379. /** @defgroup ADC_flags_definition
  380. * @{
  381. */
  382. #define ADC_FLAG_ADRDY ADC_ISR_ADRDY
  383. #define ADC_FLAG_EOSMP ADC_ISR_EOSMP
  384. #define ADC_FLAG_EOC ADC_ISR_EOC
  385. #define ADC_FLAG_EOSEQ ADC_ISR_EOSEQ
  386. #define ADC_FLAG_OVR ADC_ISR_OVR
  387. #define ADC_FLAG_AWD ADC_ISR_AWD
  388. #define ADC_FLAG_ADEN ((uint32_t)0x01000001)
  389. #define ADC_FLAG_ADDIS ((uint32_t)0x01000002)
  390. #define ADC_FLAG_ADSTART ((uint32_t)0x01000004)
  391. #define ADC_FLAG_ADSTP ((uint32_t)0x01000010)
  392. #define ADC_FLAG_ADCAL ((uint32_t)0x81000000)
  393. #define IS_ADC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFFFF60) == (uint32_t)RESET))
  394. #define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_ADRDY) || ((FLAG) == ADC_FLAG_EOSMP) || \
  395. ((FLAG) == ADC_FLAG_EOC) || ((FLAG) == ADC_FLAG_EOSEQ) || \
  396. ((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_OVR) || \
  397. ((FLAG) == ADC_FLAG_ADEN) || ((FLAG) == ADC_FLAG_ADDIS) || \
  398. ((FLAG) == ADC_FLAG_ADSTART) || ((FLAG) == ADC_FLAG_ADSTP) || \
  399. ((FLAG) == ADC_FLAG_ADCAL))
  400. #define ADC_Vrefsel_0_625V ((uint32_t)0x00000002)
  401. #define ADC_Vrefsel_1_5V ((uint32_t)0x00000006)
  402. #define ADC_Vrefsel_2_5V ((uint32_t)0x0000000A)
  403. #define ADC_Vrefsel_VDDA ((uint32_t)(~(uint32_t)0x0000000E))
  404. #define IS_ADC_Vrefsel(Vref) ( ( (Vref) == ADC_Vrefsel_0_625V) || \
  405. ( (Vref) == ADC_Vrefsel_1_5V ) || \
  406. ( (Vref) == ADC_Vrefsel_2_5V ) || \
  407. ( (Vref) == ADC_Vrefsel_VDDA ) )
  408. #define ADC_VrefEN ((uint32_t)0x00000002)
  409. /**
  410. * @}
  411. */
  412. /**
  413. * @}
  414. */
  415. /* Exported macro ------------------------------------------------------------*/
  416. /* Exported functions ------------------------------------------------------- */
  417. /* Function used to set the ADC configuration to the default reset state *****/
  418. void ADC_DeInit(ADC_TypeDef* ADCx);
  419. /* Initialization and Configuration functions *********************************/
  420. void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct);
  421. void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct);
  422. void ADC_ClockModeConfig(ADC_TypeDef* ADCx, uint32_t ADC_ClockMode);
  423. void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  424. /* This Function is obsolete and maintained for legacy purpose only.
  425. ADC_ClockModeConfig() function should be used instead */
  426. void ADC_JitterCmd(ADC_TypeDef* ADCx, uint32_t ADC_JitterOff, FunctionalState NewState);
  427. /* Power saving functions *****************************************************/
  428. void ADC_AutoPowerOffCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  429. void ADC_WaitModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  430. /* Analog Watchdog configuration functions ************************************/
  431. void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  432. void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold,uint16_t LowThreshold);
  433. void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog_Channel);
  434. void ADC_AnalogWatchdogSingleChannelCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  435. /* Temperature Sensor , Vrefint and Vbat management function ... ******************/
  436. void ADC_TempSensorCmd(FunctionalState NewState);
  437. void ADC_VrefintCmd(FunctionalState NewState);
  438. void ADC_VbatCmd(FunctionalState NewState);
  439. void ADC_VrefDecibCmd(FunctionalState NewState);
  440. void ADC_IoshSmpCmd(uint32_t SmpEn, FunctionalState NewState);
  441. void ADC_IoshAmpCmd(uint32_t AmpEn, FunctionalState NewState);
  442. /* Channels Configuration functions *******************************************/
  443. void ADC_ChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime);
  444. void ADC_ContinuousModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  445. void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  446. void ADC_OverrunModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  447. uint32_t ADC_GetCalibrationFactor(ADC_TypeDef* ADCx);
  448. void ADC_StopOfConversion(ADC_TypeDef* ADCx);
  449. void ADC_StartOfConversion(ADC_TypeDef* ADCx);
  450. uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx);
  451. #if defined (FT32F072xB)
  452. void ADC_IoshSmpSel(uint32_t Ioshx, uint32_t SmpSel);
  453. void ADC_IoshSmpMod(uint32_t SmpModBit, uint32_t Mode);
  454. void ADC_ExtModeCmd(FunctionalState NewState);
  455. void ADC_TrgdDisSmpCmd(FunctionalState NewState);
  456. void ADC_ExtDlyConfig(uint32_t ExtDly);
  457. void ADC_RtenCmd(uint32_t Rtenx, FunctionalState NewState);
  458. void ADC_FtenCmd(uint32_t Ftenx, FunctionalState NewState);
  459. #endif
  460. /* Regular Channels DMA Configuration functions *******************************/
  461. void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState);
  462. void ADC_DMARequestModeConfig(ADC_TypeDef* ADCx, uint32_t ADC_DMARequestMode);
  463. /* Interrupts and flags management functions **********************************/
  464. void ADC_ITConfig(ADC_TypeDef* ADCx, uint32_t ADC_IT, FunctionalState NewState);
  465. FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint32_t ADC_FLAG);
  466. void ADC_ClearFlag(ADC_TypeDef* ADCx, uint32_t ADC_FLAG);
  467. ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint32_t ADC_IT);
  468. void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint32_t ADC_IT);
  469. void ADC_VrefselConfig(uint32_t ADC_Vrefsel);
  470. #ifdef __cplusplus
  471. }
  472. #endif
  473. #endif /*__ft32F0XX_ADC_H */
  474. /**
  475. * @}
  476. */
  477. /**
  478. * @}
  479. */
  480. /************************ (C) COPYRIGHT FMD *****END OF FILE****/