at32f425_adc.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /**
  2. **************************************************************************
  3. * @file at32f425_adc.h
  4. * @brief at32f425 adc header file
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. /* Define to prevent recursive inclusion -------------------------------------*/
  25. #ifndef __AT32F425_ADC_H
  26. #define __AT32F425_ADC_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f425.h"
  32. /** @addtogroup AT32F425_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup ADC
  36. * @{
  37. */
  38. /** @defgroup ADC_interrupts_definition
  39. * @brief adc interrupt
  40. * @{
  41. */
  42. #define ADC_CCE_INT ((uint32_t)0x00000020) /*!< channels conversion end interrupt */
  43. #define ADC_VMOR_INT ((uint32_t)0x00000040) /*!< voltage monitoring out of range interrupt */
  44. #define ADC_PCCE_INT ((uint32_t)0x00000080) /*!< preempt channels conversion end interrupt */
  45. /**
  46. * @}
  47. */
  48. /** @defgroup ADC_flags_definition
  49. * @brief adc flag
  50. * @{
  51. */
  52. #define ADC_VMOR_FLAG ((uint8_t)0x01) /*!< voltage monitoring out of range flag */
  53. #define ADC_CCE_FLAG ((uint8_t)0x02) /*!< channels conversion end flag */
  54. #define ADC_PCCE_FLAG ((uint8_t)0x04) /*!< preempt channels conversion end flag */
  55. #define ADC_PCCS_FLAG ((uint8_t)0x08) /*!< preempt channel conversion start flag */
  56. #define ADC_OCCS_FLAG ((uint8_t)0x10) /*!< ordinary channel conversion start flag */
  57. /**
  58. * @}
  59. */
  60. /** @defgroup ADC_exported_types
  61. * @{
  62. */
  63. /**
  64. * @brief adc data align type
  65. */
  66. typedef enum
  67. {
  68. ADC_RIGHT_ALIGNMENT = 0x00, /*!< data right alignment */
  69. ADC_LEFT_ALIGNMENT = 0x01 /*!< data left alignment */
  70. } adc_data_align_type;
  71. /**
  72. * @brief adc channel select type
  73. */
  74. typedef enum
  75. {
  76. ADC_CHANNEL_0 = 0x00, /*!< adc channel 0 */
  77. ADC_CHANNEL_1 = 0x01, /*!< adc channel 1 */
  78. ADC_CHANNEL_2 = 0x02, /*!< adc channel 2 */
  79. ADC_CHANNEL_3 = 0x03, /*!< adc channel 3 */
  80. ADC_CHANNEL_4 = 0x04, /*!< adc channel 4 */
  81. ADC_CHANNEL_5 = 0x05, /*!< adc channel 5 */
  82. ADC_CHANNEL_6 = 0x06, /*!< adc channel 6 */
  83. ADC_CHANNEL_7 = 0x07, /*!< adc channel 7 */
  84. ADC_CHANNEL_8 = 0x08, /*!< adc channel 8 */
  85. ADC_CHANNEL_9 = 0x09, /*!< adc channel 9 */
  86. ADC_CHANNEL_10 = 0x0A, /*!< adc channel 10 */
  87. ADC_CHANNEL_11 = 0x0B, /*!< adc channel 11 */
  88. ADC_CHANNEL_12 = 0x0C, /*!< adc channel 12 */
  89. ADC_CHANNEL_13 = 0x0D, /*!< adc channel 13 */
  90. ADC_CHANNEL_14 = 0x0E, /*!< adc channel 14 */
  91. ADC_CHANNEL_15 = 0x0F, /*!< adc channel 15 */
  92. ADC_CHANNEL_16 = 0x10, /*!< adc channel 16 */
  93. ADC_CHANNEL_17 = 0x11 /*!< adc channel 17 */
  94. } adc_channel_select_type;
  95. /**
  96. * @brief adc sampletime select type
  97. */
  98. typedef enum
  99. {
  100. ADC_SAMPLETIME_1_5 = 0x00, /*!< adc sample time 1.5 cycle */
  101. ADC_SAMPLETIME_7_5 = 0x01, /*!< adc sample time 7.5 cycle */
  102. ADC_SAMPLETIME_13_5 = 0x02, /*!< adc sample time 13.5 cycle */
  103. ADC_SAMPLETIME_28_5 = 0x03, /*!< adc sample time 28.5 cycle */
  104. ADC_SAMPLETIME_41_5 = 0x04, /*!< adc sample time 41.5 cycle */
  105. ADC_SAMPLETIME_55_5 = 0x05, /*!< adc sample time 55.5 cycle */
  106. ADC_SAMPLETIME_71_5 = 0x06, /*!< adc sample time 71.5 cycle */
  107. ADC_SAMPLETIME_239_5 = 0x07 /*!< adc sample time 239.5 cycle */
  108. } adc_sampletime_select_type;
  109. /**
  110. * @brief adc ordinary group trigger event select type
  111. */
  112. typedef enum
  113. {
  114. /*adc1 ordinary trigger event*/
  115. ADC12_ORDINARY_TRIG_TMR1TRGOUT = 0x00, /*!< timer1 trgout as trigger source of adc1 ordinary sequence */
  116. ADC12_ORDINARY_TRIG_TMR1CH4 = 0x01, /*!< timer1 ch4 event as trigger source of adc1 ordinary sequence */
  117. ADC12_ORDINARY_TRIG_TMR2TRGOUT = 0x02, /*!< timer2 trgout as trigger source of adc1 ordinary sequence */
  118. ADC12_ORDINARY_TRIG_TMR3TRGOUT = 0x03, /*!< timer3 trgout event as trigger source of adc1 ordinary sequence */
  119. ADC12_ORDINARY_TRIG_TMR15TRGOUT = 0x04, /*!< timer15 trgout event as trigger source of adc1 ordinary sequence */
  120. ADC12_ORDINARY_TRIG_TMR1CH1 = 0x05, /*!< timer1 ch1 event as trigger source of adc1 ordinary sequence */
  121. ADC12_ORDINARY_TRIG_EXINT11 = 0x06, /*!< exint line11 event as trigger source of adc1 ordinary sequence */
  122. ADC12_ORDINARY_TRIG_SOFTWARE = 0x07, /*!< software(OCSWTRG) control bit as trigger source of adc1 ordinary sequence */
  123. } adc_ordinary_trig_select_type;
  124. /**
  125. * @brief adc preempt group trigger event select type
  126. */
  127. typedef enum
  128. {
  129. /*adc1 preempt trigger event*/
  130. ADC12_PREEMPT_TRIG_TMR1CH2 = 0x00, /*!< timer1 ch2 event as trigger source of adc1 preempt sequence */
  131. ADC12_PREEMPT_TRIG_TMR1CH3 = 0x01, /*!< timer1 ch3 event as trigger source of adc1 preempt sequence */
  132. ADC12_PREEMPT_TRIG_TMR2CH4 = 0x02, /*!< timer2 ch4 event as trigger source of adc1 preempt sequence */
  133. ADC12_PREEMPT_TRIG_TMR3CH4 = 0x03, /*!< timer3 ch4 event as trigger source of adc1 preempt sequence */
  134. ADC12_PREEMPT_TRIG_TMR15CH1 = 0x04, /*!< timer15 ch1 event as trigger source of adc1 preempt sequence */
  135. ADC12_PREEMPT_TRIG_TMR6TRGOUT = 0x05, /*!< timer6 trgout event as trigger source of adc1 preempt sequence */
  136. ADC12_PREEMPT_TRIG_EXINT15 = 0x06, /*!< exint line15 event as trigger source of adc1 preempt sequence */
  137. ADC12_PREEMPT_TRIG_SOFTWARE = 0x07, /*!< software(PCSWTRG) control bit as trigger source of adc1 preempt sequence */
  138. } adc_preempt_trig_select_type;
  139. /**
  140. * @brief adc preempt channel type
  141. */
  142. typedef enum
  143. {
  144. ADC_PREEMPT_CHANNEL_1 = 0x00, /*!< adc preempt channel 1 */
  145. ADC_PREEMPT_CHANNEL_2 = 0x01, /*!< adc preempt channel 2 */
  146. ADC_PREEMPT_CHANNEL_3 = 0x02, /*!< adc preempt channel 3 */
  147. ADC_PREEMPT_CHANNEL_4 = 0x03 /*!< adc preempt channel 4 */
  148. } adc_preempt_channel_type;
  149. /**
  150. * @brief adc voltage_monitoring type
  151. */
  152. typedef enum
  153. {
  154. ADC_VMONITOR_SINGLE_ORDINARY = 0x00800200, /*!< voltage_monitoring on a single ordinary channel */
  155. ADC_VMONITOR_SINGLE_PREEMPT = 0x00400200, /*!< voltage_monitoring on a single preempt channel */
  156. ADC_VMONITOR_SINGLE_ORDINARY_PREEMPT = 0x00C00200, /*!< voltage_monitoring on a single ordinary or preempt channel */
  157. ADC_VMONITOR_ALL_ORDINARY = 0x00800000, /*!< voltage_monitoring on all ordinary channel */
  158. ADC_VMONITOR_ALL_PREEMPT = 0x00400000, /*!< voltage_monitoring on all preempt channel */
  159. ADC_VMONITOR_ALL_ORDINARY_PREEMPT = 0x00C00000, /*!< voltage_monitoring on all ordinary and preempt channel */
  160. ADC_VMONITOR_NONE = 0x00000000 /*!< no channel guarded by the voltage_monitoring */
  161. } adc_voltage_monitoring_type;
  162. /**
  163. * @brief adc oversample ratio type
  164. */
  165. typedef enum
  166. {
  167. ADC_OVERSAMPLE_RATIO_2 = 0x00, /*!< adc oversample ratio 2 */
  168. ADC_OVERSAMPLE_RATIO_4 = 0x01, /*!< adc oversample ratio 4 */
  169. ADC_OVERSAMPLE_RATIO_8 = 0x02, /*!< adc oversample ratio 8 */
  170. ADC_OVERSAMPLE_RATIO_16 = 0x03, /*!< adc oversample ratio 16 */
  171. ADC_OVERSAMPLE_RATIO_32 = 0x04, /*!< adc oversample ratio 32 */
  172. ADC_OVERSAMPLE_RATIO_64 = 0x05, /*!< adc oversample ratio 64 */
  173. ADC_OVERSAMPLE_RATIO_128 = 0x06, /*!< adc oversample ratio 128 */
  174. ADC_OVERSAMPLE_RATIO_256 = 0x07 /*!< adc oversample ratio 256 */
  175. } adc_oversample_ratio_type;
  176. /**
  177. * @brief adc oversample shift type
  178. */
  179. typedef enum
  180. {
  181. ADC_OVERSAMPLE_SHIFT_0 = 0x00, /*!< adc oversample shift 0 */
  182. ADC_OVERSAMPLE_SHIFT_1 = 0x01, /*!< adc oversample shift 1 */
  183. ADC_OVERSAMPLE_SHIFT_2 = 0x02, /*!< adc oversample shift 2 */
  184. ADC_OVERSAMPLE_SHIFT_3 = 0x03, /*!< adc oversample shift 3 */
  185. ADC_OVERSAMPLE_SHIFT_4 = 0x04, /*!< adc oversample shift 4 */
  186. ADC_OVERSAMPLE_SHIFT_5 = 0x05, /*!< adc oversample shift 5 */
  187. ADC_OVERSAMPLE_SHIFT_6 = 0x06, /*!< adc oversample shift 6 */
  188. ADC_OVERSAMPLE_SHIFT_7 = 0x07, /*!< adc oversample shift 7 */
  189. ADC_OVERSAMPLE_SHIFT_8 = 0x08 /*!< adc oversample shift 8 */
  190. } adc_oversample_shift_type;
  191. /**
  192. * @brief adc ordinary oversample recover type
  193. */
  194. typedef enum
  195. {
  196. ADC_OVERSAMPLE_CONTINUE = 0x00, /*!< continue mode:when preempt triggered,oversampling is temporary stopped and continued after preempt sequence */
  197. ADC_OVERSAMPLE_RESTART = 0x01 /*!< restart mode:when preempt triggered,oversampling is aborted and resumed from start after preempt sequence */
  198. } adc_ordinary_oversample_restart_type;
  199. /**
  200. * @brief adc base config type
  201. */
  202. typedef struct
  203. {
  204. confirm_state sequence_mode; /*!< adc sequence mode */
  205. confirm_state repeat_mode; /*!< adc repeat mode */
  206. adc_data_align_type data_align; /*!< adc data alignment */
  207. uint8_t ordinary_channel_length; /*!< adc ordinary channel sequence length*/
  208. } adc_base_config_type;
  209. /**
  210. * @brief type define adc register all
  211. */
  212. typedef struct
  213. {
  214. /**
  215. * @brief adc sts register, offset:0x00
  216. */
  217. union
  218. {
  219. __IO uint32_t sts;
  220. struct
  221. {
  222. __IO uint32_t vmor : 1; /* [0] */
  223. __IO uint32_t cce : 1; /* [1] */
  224. __IO uint32_t pcce : 1; /* [2] */
  225. __IO uint32_t pccs : 1; /* [3] */
  226. __IO uint32_t occs : 1; /* [4] */
  227. __IO uint32_t reserved1 : 27;/* [31:5] */
  228. } sts_bit;
  229. };
  230. /**
  231. * @brief adc ctrl1 register, offset:0x04
  232. */
  233. union
  234. {
  235. __IO uint32_t ctrl1;
  236. struct
  237. {
  238. __IO uint32_t vmcsel : 5; /* [4:0] */
  239. __IO uint32_t cceien : 1; /* [5] */
  240. __IO uint32_t vmorien : 1; /* [6] */
  241. __IO uint32_t pcceien : 1; /* [7] */
  242. __IO uint32_t sqen : 1; /* [8] */
  243. __IO uint32_t vmsgen : 1; /* [9] */
  244. __IO uint32_t pcautoen : 1; /* [10] */
  245. __IO uint32_t ocpen : 1; /* [11] */
  246. __IO uint32_t pcpen : 1; /* [12] */
  247. __IO uint32_t ocpcnt : 3; /* [15:13] */
  248. __IO uint32_t reserved1 : 6; /* [21:16] */
  249. __IO uint32_t pcvmen : 1; /* [22] */
  250. __IO uint32_t ocvmen : 1; /* [23] */
  251. __IO uint32_t reserved2 : 8; /* [31:24] */
  252. } ctrl1_bit;
  253. };
  254. /**
  255. * @brief adc ctrl2 register, offset:0x08
  256. */
  257. union
  258. {
  259. __IO uint32_t ctrl2;
  260. struct
  261. {
  262. __IO uint32_t adcen : 1; /* [0] */
  263. __IO uint32_t rpen : 1; /* [1] */
  264. __IO uint32_t adcal : 1; /* [2] */
  265. __IO uint32_t adcalinit : 1; /* [3] */
  266. __IO uint32_t reserved1 : 4; /* [7:4] */
  267. __IO uint32_t ocdmaen : 1; /* [8] */
  268. __IO uint32_t reserved2 : 2; /* [10:9] */
  269. __IO uint32_t dtalign : 1; /* [11] */
  270. __IO uint32_t pctesel_l : 3; /* [14:12] */
  271. __IO uint32_t pcten : 1; /* [15] */
  272. __IO uint32_t reserved3 : 1; /* [16] */
  273. __IO uint32_t octesel_l : 3; /* [19:17] */
  274. __IO uint32_t octen : 1; /* [20] */
  275. __IO uint32_t pcswtrg : 1; /* [21] */
  276. __IO uint32_t ocswtrg : 1; /* [22] */
  277. __IO uint32_t itsrven : 1; /* [23] */
  278. __IO uint32_t pctesel_h : 1; /* [24] */
  279. __IO uint32_t octesel_h : 1; /* [25] */
  280. __IO uint32_t reserved4 : 6; /* [31:26] */
  281. } ctrl2_bit;
  282. };
  283. /**
  284. * @brief adc spt1 register, offset:0x0C
  285. */
  286. union
  287. {
  288. __IO uint32_t spt1;
  289. struct
  290. {
  291. __IO uint32_t cspt10 : 3; /* [2:0] */
  292. __IO uint32_t cspt11 : 3; /* [5:3] */
  293. __IO uint32_t cspt12 : 3; /* [8:6] */
  294. __IO uint32_t cspt13 : 3; /* [11:9] */
  295. __IO uint32_t cspt14 : 3; /* [14:12] */
  296. __IO uint32_t cspt15 : 3; /* [17:15] */
  297. __IO uint32_t cspt16 : 3; /* [20:18] */
  298. __IO uint32_t cspt17 : 3; /* [23:21] */
  299. __IO uint32_t reserved1 : 8;/* [31:24] */
  300. } spt1_bit;
  301. };
  302. /**
  303. * @brief adc spt2 register, offset:0x10
  304. */
  305. union
  306. {
  307. __IO uint32_t spt2;
  308. struct
  309. {
  310. __IO uint32_t cspt0 : 3;/* [2:0] */
  311. __IO uint32_t cspt1 : 3;/* [5:3] */
  312. __IO uint32_t cspt2 : 3;/* [8:6] */
  313. __IO uint32_t cspt3 : 3;/* [11:9] */
  314. __IO uint32_t cspt4 : 3;/* [14:12] */
  315. __IO uint32_t cspt5 : 3;/* [17:15] */
  316. __IO uint32_t cspt6 : 3;/* [20:18] */
  317. __IO uint32_t cspt7 : 3;/* [23:21] */
  318. __IO uint32_t cspt8 : 3;/* [26:24] */
  319. __IO uint32_t cspt9 : 3;/* [29:27] */
  320. __IO uint32_t reserved1 : 2;/* [31:30] */
  321. } spt2_bit;
  322. };
  323. /**
  324. * @brief adc pcdto1 register, offset:0x14
  325. */
  326. union
  327. {
  328. __IO uint32_t pcdto1;
  329. struct
  330. {
  331. __IO uint32_t pcdto1 : 12; /* [11:0] */
  332. __IO uint32_t reserved1 : 20; /* [31:12] */
  333. } pcdto1_bit;
  334. };
  335. /**
  336. * @brief adc pcdto2 register, offset:0x18
  337. */
  338. union
  339. {
  340. __IO uint32_t pcdto2;
  341. struct
  342. {
  343. __IO uint32_t pcdto2 : 12; /* [11:0] */
  344. __IO uint32_t reserved1 : 20; /* [31:12] */
  345. } pcdto2_bit;
  346. };
  347. /**
  348. * @brief adc pcdto3 register, offset:0x1C
  349. */
  350. union
  351. {
  352. __IO uint32_t pcdto3;
  353. struct
  354. {
  355. __IO uint32_t pcdto3 : 12; /* [11:0] */
  356. __IO uint32_t reserved1 : 20; /* [31:12] */
  357. } pcdto3_bit;
  358. };
  359. /**
  360. * @brief adc pcdto4 register, offset:0x20
  361. */
  362. union
  363. {
  364. __IO uint32_t pcdto4;
  365. struct
  366. {
  367. __IO uint32_t pcdto4 : 12; /* [11:0] */
  368. __IO uint32_t reserved1 : 20; /* [31:12] */
  369. } pcdto4_bit;
  370. };
  371. /**
  372. * @brief adc vmhb register, offset:0x24
  373. */
  374. union
  375. {
  376. __IO uint32_t vmhb;
  377. struct
  378. {
  379. __IO uint32_t vmhb : 12; /* [11:0] */
  380. __IO uint32_t reserved1 : 20; /* [31:12] */
  381. } vmhb_bit;
  382. };
  383. /**
  384. * @brief adc vmlb register, offset:0x28
  385. */
  386. union
  387. {
  388. __IO uint32_t vmlb;
  389. struct
  390. {
  391. __IO uint32_t vmlb : 12; /* [11:0] */
  392. __IO uint32_t reserved1 : 20; /* [31:12] */
  393. } vmlb_bit;
  394. };
  395. /**
  396. * @brief adc osq1 register, offset:0x2C
  397. */
  398. union
  399. {
  400. __IO uint32_t osq1;
  401. struct
  402. {
  403. __IO uint32_t osn13 : 5; /* [4:0] */
  404. __IO uint32_t osn14 : 5; /* [9:5] */
  405. __IO uint32_t osn15 : 5; /* [14:10] */
  406. __IO uint32_t osn16 : 5; /* [19:15] */
  407. __IO uint32_t oclen : 4; /* [23:20] */
  408. __IO uint32_t reserved1 : 8; /* [31:24] */
  409. } osq1_bit;
  410. };
  411. /**
  412. * @brief adc osq2 register, offset:0x30
  413. */
  414. union
  415. {
  416. __IO uint32_t osq2;
  417. struct
  418. {
  419. __IO uint32_t osn7 : 5; /* [4:0] */
  420. __IO uint32_t osn8 : 5; /* [9:5] */
  421. __IO uint32_t osn9 : 5; /* [14:10] */
  422. __IO uint32_t osn10 : 5; /* [19:15] */
  423. __IO uint32_t osn11 : 5; /* [24:20] */
  424. __IO uint32_t osn12 : 5; /* [29:25] */
  425. __IO uint32_t reserved1 : 2; /* [31:30] */
  426. } osq2_bit;
  427. };
  428. /**
  429. * @brief adc osq3 register, offset:0x34
  430. */
  431. union
  432. {
  433. __IO uint32_t osq3;
  434. struct
  435. {
  436. __IO uint32_t osn1 : 5; /* [4:0] */
  437. __IO uint32_t osn2 : 5; /* [9:5] */
  438. __IO uint32_t osn3 : 5; /* [14:10] */
  439. __IO uint32_t osn4 : 5; /* [19:15] */
  440. __IO uint32_t osn5 : 5; /* [24:20] */
  441. __IO uint32_t osn6 : 5; /* [29:25] */
  442. __IO uint32_t reserved1 : 2; /* [31:30] */
  443. } osq3_bit;
  444. };
  445. /**
  446. * @brief adc psq register, offset:0x38
  447. */
  448. union
  449. {
  450. __IO uint32_t psq;
  451. struct
  452. {
  453. __IO uint32_t psn1 : 5; /* [4:0] */
  454. __IO uint32_t psn2 : 5; /* [9:5] */
  455. __IO uint32_t psn3 : 5; /* [14:10] */
  456. __IO uint32_t psn4 : 5; /* [19:15] */
  457. __IO uint32_t pclen : 2; /* [21:20] */
  458. __IO uint32_t reserved1 : 10;/* [31:22] */
  459. } psq_bit;
  460. };
  461. /**
  462. * @brief adc pdt1 register, offset:0x3C
  463. */
  464. union
  465. {
  466. __IO uint32_t pdt1;
  467. struct
  468. {
  469. __IO uint32_t pdt1 : 16; /* [15:0] */
  470. __IO uint32_t reserved1 : 16; /* [31:16] */
  471. } pdt1_bit;
  472. };
  473. /**
  474. * @brief adc pdt2 register, offset:0x40
  475. */
  476. union
  477. {
  478. __IO uint32_t pdt2;
  479. struct
  480. {
  481. __IO uint32_t pdt2 : 16; /* [15:0] */
  482. __IO uint32_t reserved1 : 16; /* [31:16] */
  483. } pdt2_bit;
  484. };
  485. /**
  486. * @brief adc pdt3 register, offset:0x44
  487. */
  488. union
  489. {
  490. __IO uint32_t pdt3;
  491. struct
  492. {
  493. __IO uint32_t pdt3 : 16; /* [15:0] */
  494. __IO uint32_t reserved1 : 16; /* [31:16] */
  495. } pdt3_bit;
  496. };
  497. /**
  498. * @brief adc pdt4 register, offset:0x48
  499. */
  500. union
  501. {
  502. __IO uint32_t pdt4;
  503. struct
  504. {
  505. __IO uint32_t pdt4 : 16; /* [15:0] */
  506. __IO uint32_t reserved1 : 16; /* [31:16] */
  507. } pdt4_bit;
  508. };
  509. /**
  510. * @brief adc odt register, offset:0x4C
  511. */
  512. union
  513. {
  514. __IO uint32_t odt;
  515. struct
  516. {
  517. __IO uint32_t odt : 16; /* [15:0] */
  518. __IO uint32_t reserved1 : 16; /* [31:16] */
  519. } odt_bit;
  520. };
  521. /**
  522. * @brief adc reserved register, offset:0x50~0x7C
  523. */
  524. __IO uint32_t reserved1[12];
  525. /**
  526. * @brief adc oversample register, offset:0x80
  527. */
  528. union
  529. {
  530. __IO uint32_t ovsp;
  531. struct
  532. {
  533. __IO uint32_t oosen : 1; /* [0] */
  534. __IO uint32_t posen : 1; /* [1] */
  535. __IO uint32_t osrsel : 3; /* [4:2] */
  536. __IO uint32_t osssel : 4; /* [8:5] */
  537. __IO uint32_t oostren : 1; /* [9] */
  538. __IO uint32_t oosrsel : 1; /* [10] */
  539. __IO uint32_t reserved1 : 21; /* [31:11] */
  540. } ovsp_bit;
  541. };
  542. } adc_type;
  543. /**
  544. * @}
  545. */
  546. #define ADC1 ((adc_type *) ADC1_BASE)
  547. /** @defgroup ADC_exported_functions
  548. * @{
  549. */
  550. void adc_reset(adc_type *adc_x);
  551. void adc_enable(adc_type *adc_x, confirm_state new_state);
  552. void adc_base_default_para_init(adc_base_config_type *adc_base_struct);
  553. void adc_base_config(adc_type *adc_x, adc_base_config_type *adc_base_struct);
  554. void adc_dma_mode_enable(adc_type *adc_x, confirm_state new_state);
  555. void adc_interrupt_enable(adc_type *adc_x, uint32_t adc_int, confirm_state new_state);
  556. void adc_calibration_init(adc_type *adc_x);
  557. flag_status adc_calibration_init_status_get(adc_type *adc_x);
  558. void adc_calibration_start(adc_type *adc_x);
  559. flag_status adc_calibration_status_get(adc_type *adc_x);
  560. void adc_voltage_monitor_enable(adc_type *adc_x, adc_voltage_monitoring_type adc_voltage_monitoring);
  561. void adc_voltage_monitor_threshold_value_set(adc_type *adc_x, uint16_t adc_high_threshold, uint16_t adc_low_threshold);
  562. void adc_voltage_monitor_single_channel_select(adc_type *adc_x, adc_channel_select_type adc_channel);
  563. void adc_ordinary_channel_set(adc_type *adc_x, adc_channel_select_type adc_channel, uint8_t adc_sequence, adc_sampletime_select_type adc_sampletime);
  564. void adc_preempt_channel_length_set(adc_type *adc_x, uint8_t adc_channel_lenght);
  565. void adc_preempt_channel_set(adc_type *adc_x, adc_channel_select_type adc_channel, uint8_t adc_sequence, adc_sampletime_select_type adc_sampletime);
  566. void adc_ordinary_conversion_trigger_set(adc_type *adc_x, adc_ordinary_trig_select_type adc_ordinary_trig, confirm_state new_state);
  567. void adc_preempt_conversion_trigger_set(adc_type *adc_x, adc_preempt_trig_select_type adc_preempt_trig, confirm_state new_state);
  568. void adc_preempt_offset_value_set(adc_type *adc_x, adc_preempt_channel_type adc_preempt_channel, uint16_t adc_offset_value);
  569. void adc_ordinary_part_count_set(adc_type *adc_x, uint8_t adc_channel_count);
  570. void adc_ordinary_part_mode_enable(adc_type *adc_x, confirm_state new_state);
  571. void adc_preempt_part_mode_enable(adc_type *adc_x, confirm_state new_state);
  572. void adc_preempt_auto_mode_enable(adc_type *adc_x, confirm_state new_state);
  573. void adc_tempersensor_vintrv_enable(confirm_state new_state);
  574. void adc_ordinary_software_trigger_enable(adc_type *adc_x, confirm_state new_state);
  575. flag_status adc_ordinary_software_trigger_status_get(adc_type *adc_x);
  576. void adc_preempt_software_trigger_enable(adc_type *adc_x, confirm_state new_state);
  577. flag_status adc_preempt_software_trigger_status_get(adc_type *adc_x);
  578. uint16_t adc_ordinary_conversion_data_get(adc_type *adc_x);
  579. uint16_t adc_preempt_conversion_data_get(adc_type *adc_x, adc_preempt_channel_type adc_preempt_channel);
  580. flag_status adc_flag_get(adc_type *adc_x, uint8_t adc_flag);
  581. void adc_flag_clear(adc_type *adc_x, uint32_t adc_flag);
  582. void adc_ordinary_oversample_enable(adc_type *adc_x, confirm_state new_state);
  583. void adc_preempt_oversample_enable(adc_type *adc_x, confirm_state new_state);
  584. void adc_oversample_ratio_shift_set(adc_type *adc_x, adc_oversample_ratio_type adc_oversample_ratio, adc_oversample_shift_type adc_oversample_shift);
  585. void adc_ordinary_oversample_trig_enable(adc_type *adc_x, confirm_state new_state);
  586. void adc_ordinary_oversample_restart_set(adc_type *adc_x, adc_ordinary_oversample_restart_type adc_ordinary_oversample_restart);
  587. /**
  588. * @}
  589. */
  590. /**
  591. * @}
  592. */
  593. /**
  594. * @}
  595. */
  596. #ifdef __cplusplus
  597. }
  598. #endif
  599. #endif