hc32f460_adc.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /*******************************************************************************
  2. * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by HDSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. */
  9. /******************************************************************************/
  10. /** \file hc32f460_adc.h
  11. **
  12. ** A detailed description is available at
  13. ** @link AdcGroup Adc description @endlink
  14. **
  15. ** - 2018-11-30 CDT First version for Device Driver Library of Adc.
  16. **
  17. ******************************************************************************/
  18. #ifndef __HC32F460_ADC_H__
  19. #define __HC32F460_ADC_H__
  20. /*******************************************************************************
  21. * Include files
  22. ******************************************************************************/
  23. #include "hc32_common.h"
  24. #include "ddl_config.h"
  25. #if (DDL_ADC_ENABLE == DDL_ON)
  26. /* C binding of definitions if building with C++ compiler */
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif
  31. /**
  32. *******************************************************************************
  33. ** \defgroup AdcGroup Analog-to-Digital Converter(ADC)
  34. **
  35. ******************************************************************************/
  36. //@{
  37. /*******************************************************************************
  38. * Global type definitions ('typedef')
  39. ******************************************************************************/
  40. /**
  41. *******************************************************************************
  42. ** \brief ADC average count.
  43. **
  44. ******************************************************************************/
  45. typedef enum en_adc_avcnt
  46. {
  47. AdcAvcnt_2 = 0x0, ///< Average after 2 conversions.
  48. AdcAvcnt_4 = 0x1, ///< Average after 4 conversions.
  49. AdcAvcnt_8 = 0x2, ///< Average after 8 conversions.
  50. AdcAvcnt_16 = 0x3, ///< Average after 16 conversions.
  51. AdcAvcnt_32 = 0x4, ///< Average after 32 conversions.
  52. AdcAvcnt_64 = 0x5, ///< Average after 64 conversions.
  53. AdcAvcnt_128 = 0x6, ///< Average after 128 conversions.
  54. AdcAvcnt_256 = 0x7, ///< Average after 256 conversions.
  55. } en_adc_avcnt_t;
  56. /**
  57. *******************************************************************************
  58. ** \brief ADC data alignment
  59. **
  60. ******************************************************************************/
  61. typedef enum en_adc_data_align
  62. {
  63. AdcDataAlign_Right = 0x0, ///< Data right alignment.
  64. AdcDataAlign_Left = 0x1, ///< Data left alignment.
  65. } en_adc_data_align_t;
  66. /**
  67. *******************************************************************************
  68. ** \brief Automatically clear data registers after reading data.
  69. ** The auto clear function is mainly used to detect whether the data register
  70. ** is updated.
  71. **
  72. ******************************************************************************/
  73. typedef enum en_adc_clren
  74. {
  75. AdcClren_Disable = 0x0, ///< Automatic clear function disable.
  76. AdcClren_Enable = 0x1, ///< Automatic clear function enable.
  77. } en_adc_clren_t;
  78. /**
  79. *******************************************************************************
  80. ** \brief ADC resolution.
  81. **
  82. ******************************************************************************/
  83. typedef enum en_adc_resolution
  84. {
  85. AdcResolution_12Bit = 0x0, ///< Resolution is 12 bit.
  86. AdcResolution_10Bit = 0x1, ///< Resolution is 10 bit.
  87. AdcResolution_8Bit = 0x2, ///< Resolution is 8 bit.
  88. } en_adc_resolution_t;
  89. /**
  90. *******************************************************************************
  91. ** \brief ADC scan mode.
  92. **
  93. ******************************************************************************/
  94. typedef enum en_adc_scan_mode
  95. {
  96. AdcMode_SAOnce = 0x0, ///< Sequence A works once.
  97. AdcMode_SAContinuous = 0x1, ///< Sequence A works always.
  98. AdcMode_SAOnceSBOnce = 0x2, ///< Sequence A and sequence B work once.
  99. AdcMode_SAContinuousSBOnce = 0x3, ///< Sequence A works always, sequence works once.
  100. } en_adc_scan_mode_t;
  101. /**
  102. *******************************************************************************
  103. ** \brief ADC sequence A restart position.
  104. **
  105. ******************************************************************************/
  106. typedef enum en_adc_rschsel
  107. {
  108. AdcRschsel_Continue = 0x0, ///< After sequence A is interrupted by sequence B,
  109. ///< sequence A continues to scan from the interrupt
  110. ///< when it restarts.
  111. AdcRschsel_Restart = 0x1, ///< After sequence A is interrupted by sequence B,
  112. ///< sequence A restarts scanning from the first channel
  113. ///< when it restarts.
  114. } en_adc_rschsel_t;
  115. /**
  116. *******************************************************************************
  117. ** \brief ADC external or internal trigger source enable/disable .
  118. **
  119. ******************************************************************************/
  120. typedef enum en_adc_trgen
  121. {
  122. AdcTrgen_Disable = 0x0, ///< External or internal trigger source disable.
  123. AdcTrgen_Enable = 0x1, ///< External or internal trigger source enable.
  124. } en_adc_trgen_t;
  125. /**
  126. *******************************************************************************
  127. ** \brief ADC sequence trigger source selection.
  128. **
  129. ******************************************************************************/
  130. typedef enum en_adc_trgsel
  131. {
  132. AdcTrgsel_ADTRGX = 0x0, ///< X = 1(use ADC1) / 2(use ADC2), same as below.
  133. AdcTrgsel_TRGX0 = 0x1, ///< Pin IN_TRG10 / IN_TRG20.
  134. AdcTrgsel_TRGX1 = 0x2, ///< Pin IN_TRG11 / IN_TRG21.
  135. AdcTrgsel_TRGX0_TRGX1 = 0x3, ///< Pin IN_TRG10 + IN_TRG11 / IN_TRG20 + IN_TRG21.
  136. } en_adc_trgsel_t;
  137. /**
  138. *******************************************************************************
  139. ** \brief Sequence A/B conversion completion interrupt enable/disable.
  140. **
  141. ******************************************************************************/
  142. typedef enum en_adc_eocien
  143. {
  144. AdcEocien_Disable = 0x0, ///< Conversion completion interrupt disable.
  145. AdcEocien_Enable = 0x1, ///< Conversion completion interrupt enable.
  146. } en_adc_eocien_t;
  147. /**
  148. *******************************************************************************
  149. ** \brief ADC sync mode.
  150. **
  151. ******************************************************************************/
  152. typedef enum en_adc_sync_mode
  153. {
  154. AdcSync_SingleSerial = 0x0u, ///< Single: ADC1 and ADC2 only sample and convert once after triggering.
  155. ///< Serial: ADC2 start after ADC1 N PCLK4 cycles.
  156. AdcSync_SingleParallel = 0x2u, ///< Parallel: ADC1 and ADC2 start at the same time.
  157. AdcSync_ContinuousSerial = 0x4u, ///< Continuous: ADC1 and ADC2 continuously sample and convert after triggering.
  158. AdcSync_ContinuousParallel = 0x6u,
  159. } en_adc_sync_mode_t;
  160. /**
  161. *******************************************************************************
  162. ** \brief ADC sync enable/disable.
  163. **
  164. ******************************************************************************/
  165. typedef enum en_adc_syncen
  166. {
  167. AdcSync_Disable = 0x0, ///< Disable sync mode.
  168. AdcSync_Enable = 0x1, ///< Enable sync mode.
  169. } en_adc_syncen_t;
  170. /**
  171. *******************************************************************************
  172. ** \brief Analog watchdog interrupt enable/disable.
  173. **
  174. ******************************************************************************/
  175. typedef enum en_adc_awdien
  176. {
  177. AdcAwdInt_Disable = 0x0, ///< Disable AWD interrupt.
  178. AdcAwdInt_Enable = 0x1, ///< Enable AWD interrupt.
  179. } en_adc_awdien_t;
  180. /**
  181. *******************************************************************************
  182. ** \brief Analog watchdog interrupt event sequence selection.
  183. **
  184. ******************************************************************************/
  185. typedef enum en_adc_awdss
  186. {
  187. AdcAwdSel_SA_SB = 0x0, ///< Sequence A and B output interrupt event -- ADC_SEQCMP.
  188. AdcAwdSel_SA = 0x1, ///< Sequence A output interrupt event -- ADC_SEQCMP.
  189. AdcAwdSel_SB = 0x2, ///< Sequence B output interrupt event -- ADC_SEQCMP.
  190. AdcAwdSel_SB_SA = 0x3, ///< Same as AdcAwdSel_SA_SB.
  191. } en_adc_awdss_t;
  192. /**
  193. *******************************************************************************
  194. ** \brief Analog watchdog comparison mode selection.
  195. **
  196. ******************************************************************************/
  197. typedef enum en_adc_awdmd
  198. {
  199. AdcAwdCmpMode_0 = 0x0, ///< Upper limit is AWDDR0, lower limit is AWDDR1.
  200. ///< If AWDDR0 > result or result > AWDDR1,
  201. ///< the interrupt will be occur.
  202. AdcAwdCmpMode_1 = 0x1, ///< The range is [AWDDR0, AWDDR1].
  203. ///< If AWDDR0 <= result <= AWDDR1, the interrupt will be occur.
  204. } en_adc_awdmd_t;
  205. /**
  206. *******************************************************************************
  207. ** \brief Analog watchdog enable/disable.
  208. **
  209. ******************************************************************************/
  210. typedef enum en_adc_awden
  211. {
  212. AdcAwd_Disable = 0x0, ///< Disable AWD.
  213. AdcAwd_Enable = 0x1, ///< Enable AWD.
  214. } en_adc_awden_t;
  215. /**
  216. *******************************************************************************
  217. ** \brief PGA control.
  218. **
  219. ******************************************************************************/
  220. typedef enum en_adc_pga_ctl
  221. {
  222. AdcPgaCtl_Invalid = 0x0, ///< Amplifier is invalid.
  223. AdcPgaCtl_Amplify = 0xE, ///< Amplifier effective.
  224. } en_adc_pga_ctl_t;
  225. /**
  226. *******************************************************************************
  227. ** \brief The amplification factor of the amplifier is as follows.
  228. **
  229. ******************************************************************************/
  230. typedef enum en_adc_pga_factor
  231. {
  232. AdcPgaFactor_2 = 0x0, ///< PGA magnification 2.
  233. AdcPgaFactor_2P133 = 0x1, ///< PGA magnification 2.133.
  234. AdcPgaFactor_2P286 = 0x2, ///< PGA magnification 2.286.
  235. AdcPgaFactor_2P667 = 0x3, ///< PGA magnification 2.667.
  236. AdcPgaFactor_2P909 = 0x4, ///< PGA magnification 2.909.
  237. AdcPgaFactor_3P2 = 0x5, ///< PGA magnification 3.2.
  238. AdcPgaFactor_3P556 = 0x6, ///< PGA magnification 3.556.
  239. AdcPgaFactor_4 = 0x7, ///< PGA magnification 4.
  240. AdcPgaFactor_4P571 = 0x8, ///< PGA magnification 4.571.
  241. AdcPgaFactor_5P333 = 0x9, ///< PGA magnification 5.333.
  242. AdcPgaFactor_6P4 = 0xA, ///< PGA magnification 6.4.
  243. AdcPgaFactor_8 = 0xB, ///< PGA magnification 8.
  244. AdcPgaFactor_10P667 = 0xC, ///< PGA magnification 10.667.
  245. AdcPgaFactor_16 = 0xD, ///< PGA magnification 16.
  246. AdcPgaFactor_32 = 0xE, ///< PGA magnification 32.
  247. } en_adc_pga_factor_t;
  248. /**
  249. *******************************************************************************
  250. ** \brief Negative phase input selection
  251. **
  252. ******************************************************************************/
  253. typedef enum en_adc_pga_negative
  254. {
  255. AdcPgaNegative_PGAVSS = 0x0, ///< Use external port PGAVSS as PGA negative input.
  256. AdcPgaNegative_VSSA = 0x1, ///< Use internal analog ground VSSA as PGA negative input.
  257. } en_adc_pga_negative_t;
  258. /**
  259. *******************************************************************************
  260. ** \brief ADC common trigger source select
  261. **
  262. ******************************************************************************/
  263. typedef enum en_adc_com_trigger
  264. {
  265. AdcComTrigger_1 = 0x1, ///< Select common trigger 1.
  266. AdcComTrigger_2 = 0x2, ///< Select common trigger 2.
  267. AdcComTrigger_1_2 = 0x3, ///< Select common trigger 1 and 2.
  268. } en_adc_com_trigger_t;
  269. /**
  270. *******************************************************************************
  271. ** \brief Structure definition of ADC
  272. **
  273. ******************************************************************************/
  274. typedef struct stc_adc_ch_cfg
  275. {
  276. uint32_t u32Channel; ///< ADC channels mask.
  277. uint8_t u8Sequence; ///< The sequence which the channel(s) belong to.
  278. uint8_t *pu8SampTime; ///< Pointer to sampling time.
  279. } stc_adc_ch_cfg_t;
  280. typedef struct stc_adc_awd_cfg
  281. {
  282. en_adc_awdmd_t enAwdmd; ///< Comparison mode of the values.
  283. en_adc_awdss_t enAwdss; ///< Interrupt output select.
  284. uint16_t u16AwdDr0; ///< Your range DR0.
  285. uint16_t u16AwdDr1; ///< Your range DR1.
  286. } stc_adc_awd_cfg_t;
  287. typedef struct stc_adc_trg_cfg
  288. {
  289. uint8_t u8Sequence; ///< The sequence will be configured trigger source.
  290. en_adc_trgsel_t enTrgSel; ///< Trigger source type.
  291. en_event_src_t enInTrg0; ///< Internal trigger 0 source number
  292. ///< (event number @ref en_event_src_t).
  293. en_event_src_t enInTrg1; ///< Internal trigger 1 source number
  294. ///< (event number @ref en_event_src_t).
  295. } stc_adc_trg_cfg_t;
  296. typedef struct stc_adc_init
  297. {
  298. en_adc_resolution_t enResolution; ///< ADC resolution 12bit/10bit/8bit.
  299. en_adc_data_align_t enDataAlign; ///< ADC data alignment.
  300. en_adc_clren_t enAutoClear; ///< Automatically clear data register.
  301. ///< after reading data register(enable/disable).
  302. en_adc_scan_mode_t enScanMode; ///< ADC scan mode.
  303. en_adc_rschsel_t enRschsel; ///< Restart or continue.
  304. } stc_adc_init_t;
  305. /*******************************************************************************
  306. * Global pre-processor symbols/macros ('#define')
  307. ******************************************************************************/
  308. /**
  309. *******************************************************************************
  310. ** \brief ADC sequence definition.
  311. **
  312. ******************************************************************************/
  313. /* ADC sequence definition */
  314. #define ADC_SEQ_A ((uint8_t)0)
  315. #define ADC_SEQ_B ((uint8_t)1)
  316. /* ADC pin definition */
  317. #define ADC1_IN0 ((uint8_t)0)
  318. #define ADC1_IN1 ((uint8_t)1)
  319. #define ADC1_IN2 ((uint8_t)2)
  320. #define ADC1_IN3 ((uint8_t)3)
  321. #define ADC12_IN4 ((uint8_t)4)
  322. #define ADC12_IN5 ((uint8_t)5)
  323. #define ADC12_IN6 ((uint8_t)6)
  324. #define ADC12_IN7 ((uint8_t)7)
  325. #define ADC12_IN8 ((uint8_t)8)
  326. #define ADC12_IN9 ((uint8_t)9)
  327. #define ADC12_IN10 ((uint8_t)10)
  328. #define ADC12_IN11 ((uint8_t)11)
  329. #define ADC1_IN12 ((uint8_t)12)
  330. #define ADC1_IN13 ((uint8_t)13)
  331. #define ADC1_IN14 ((uint8_t)14)
  332. #define ADC1_IN15 ((uint8_t)15)
  333. #define ADC_PIN_INVALID ((uint8_t)0xFF)
  334. /* ADC channel index definition */
  335. #define ADC_CH_IDX0 (0u)
  336. #define ADC_CH_IDX1 (1u)
  337. #define ADC_CH_IDX2 (2u)
  338. #define ADC_CH_IDX3 (3u)
  339. #define ADC_CH_IDX4 (4u)
  340. #define ADC_CH_IDX5 (5u)
  341. #define ADC_CH_IDX6 (6u)
  342. #define ADC_CH_IDX7 (7u)
  343. #define ADC_CH_IDX8 (8u)
  344. #define ADC_CH_IDX9 (9u)
  345. #define ADC_CH_IDX10 (10u)
  346. #define ADC_CH_IDX11 (11u)
  347. #define ADC_CH_IDX12 (12u)
  348. #define ADC_CH_IDX13 (13u)
  349. #define ADC_CH_IDX14 (14u)
  350. #define ADC_CH_IDX15 (15u)
  351. #define ADC_CH_IDX16 (16u)
  352. /* ADC1 channel mask definition */
  353. #define ADC1_CH0 (0x1ul << 0u) ///< Default mapping pin ADC1_IN0
  354. #define ADC1_CH1 (0x1ul << 1u) ///< Default mapping pin ADC1_IN1
  355. #define ADC1_CH2 (0x1ul << 2u) ///< Default mapping pin ADC1_IN2
  356. #define ADC1_CH3 (0x1ul << 3u) ///< Default mapping pin ADC1_IN3
  357. #define ADC1_CH4 (0x1ul << 4u) ///< Default mapping pin ADC12_IN4
  358. #define ADC1_CH5 (0x1ul << 5u) ///< Default mapping pin ADC12_IN5
  359. #define ADC1_CH6 (0x1ul << 6u) ///< Default mapping pin ADC12_IN6
  360. #define ADC1_CH7 (0x1ul << 7u) ///< Default mapping pin ADC12_IN7
  361. #define ADC1_CH8 (0x1ul << 8u) ///< Default mapping pin ADC12_IN8
  362. #define ADC1_CH9 (0x1ul << 9u) ///< Default mapping pin ADC12_IN9
  363. #define ADC1_CH10 (0x1ul << 10u) ///< Default mapping pin ADC12_IN10
  364. #define ADC1_CH11 (0x1ul << 11u) ///< Default mapping pin ADC12_IN11
  365. #define ADC1_CH12 (0x1ul << 12u) ///< Default mapping pin ADC12_IN12
  366. #define ADC1_CH13 (0x1ul << 13u) ///< Default mapping pin ADC12_IN13
  367. #define ADC1_CH14 (0x1ul << 14u) ///< Default mapping pin ADC12_IN14
  368. #define ADC1_CH15 (0x1ul << 15u) ///< Default mapping pin ADC12_IN15
  369. #define ADC1_CH16 (0x1ul << 16u)
  370. #define ADC1_CH_INTERNAL (ADC1_CH16) ///< 8bit DAC_1/DAC_2 or internal VERF, dependent on CMP_RVADC
  371. #define ADC1_CH_ALL (0x0001FFFFul)
  372. #define ADC1_PIN_MASK_ALL (ADC1_CH_ALL & ~ADC1_CH_INTERNAL)
  373. /* ADC2 channel definition */
  374. #define ADC2_CH0 (0x1ul << 0u) ///< Default mapping pin ADC12_IN4
  375. #define ADC2_CH1 (0x1ul << 1u) ///< Default mapping pin ADC12_IN5
  376. #define ADC2_CH2 (0x1ul << 2u) ///< Default mapping pin ADC12_IN6
  377. #define ADC2_CH3 (0x1ul << 3u) ///< Default mapping pin ADC12_IN7
  378. #define ADC2_CH4 (0x1ul << 4u) ///< Default mapping pin ADC12_IN8
  379. #define ADC2_CH5 (0x1ul << 5u) ///< Default mapping pin ADC12_IN9
  380. #define ADC2_CH6 (0x1ul << 6u) ///< Default mapping pin ADC12_IN10
  381. #define ADC2_CH7 (0x1ul << 7u) ///< Default mapping pin ADC12_IN11
  382. #define ADC2_CH8 (0x1ul << 8u)
  383. #define ADC2_CH_INTERNAL (ADC2_CH8) ///< 8bit DAC_1/DAC_2 or internal VERF, dependent on CMP_RVADC
  384. #define ADC2_CH_ALL (0x000001FFul)
  385. #define ADC2_PIN_MASK_ALL (ADC2_CH_ALL & ~ADC2_CH_INTERNAL)
  386. /*
  387. * PGA channel definition.
  388. * NOTE: The PGA channel directly maps external pins and does not correspond to the ADC channel.
  389. */
  390. #define PGA_CH0 (0x1ul << ADC1_IN0) ///< Mapping pin ADC1_IN0
  391. #define PGA_CH1 (0x1ul << ADC1_IN1) ///< Mapping pin ADC1_IN1
  392. #define PGA_CH2 (0x1ul << ADC1_IN2) ///< Mapping pin ADC1_IN2
  393. #define PGA_CH3 (0x1ul << ADC1_IN3) ///< Mapping pin ADC1_IN3
  394. #define PGA_CH4 (0x1ul << ADC12_IN4) ///< Mapping pin ADC12_IN4
  395. #define PGA_CH5 (0x1ul << ADC12_IN5) ///< Mapping pin ADC12_IN5
  396. #define PGA_CH6 (0x1ul << ADC12_IN6) ///< Mapping pin ADC12_IN6
  397. #define PGA_CH7 (0x1ul << ADC12_IN7) ///< Mapping pin ADC12_IN7
  398. #define PGA_CH8 (0x1ul << ADC12_IN8) ///< Mapping internal 8bit DAC1 output
  399. #define PGA_CH_ALL (0x000001FFul)
  400. /* ADC1 has up to 17 channels */
  401. #define ADC1_CH_COUNT (17u)
  402. /* ADC2 has up to 9 channels */
  403. #define ADC2_CH_COUNT (9u)
  404. /*******************************************************************************
  405. * Global variable definitions ('extern')
  406. ******************************************************************************/
  407. /*******************************************************************************
  408. * Global function prototypes (definition in C source)
  409. ******************************************************************************/
  410. en_result_t ADC_Init(M4_ADC_TypeDef *ADCx, const stc_adc_init_t *pstcInit);
  411. en_result_t ADC_DeInit(M4_ADC_TypeDef *ADCx);
  412. en_result_t ADC_SetScanMode(M4_ADC_TypeDef *ADCx, en_adc_scan_mode_t enMode);
  413. en_result_t ADC_ConfigTriggerSrc(M4_ADC_TypeDef *ADCx, const stc_adc_trg_cfg_t *pstcTrgCfg);
  414. en_result_t ADC_TriggerSrcCmd(M4_ADC_TypeDef *ADCx, uint8_t u8Seq, en_functional_state_t enState);
  415. void ADC_ComTriggerCmd(M4_ADC_TypeDef *ADCx, en_adc_trgsel_t enTrgSel, \
  416. en_adc_com_trigger_t enComTrigger, en_functional_state_t enState);
  417. en_result_t ADC_AddAdcChannel(M4_ADC_TypeDef *ADCx, const stc_adc_ch_cfg_t *pstcChCfg);
  418. en_result_t ADC_DelAdcChannel(M4_ADC_TypeDef *ADCx, uint32_t u32Channel);
  419. en_result_t ADC_SeqITCmd(M4_ADC_TypeDef *ADCx, uint8_t u8Seq, en_functional_state_t enState);
  420. en_result_t ADC_ConfigAvg(M4_ADC_TypeDef *ADCx, en_adc_avcnt_t enAvgCnt);
  421. en_result_t ADC_AddAvgChannel(M4_ADC_TypeDef *ADCx, uint32_t u32Channel);
  422. en_result_t ADC_DelAvgChannel(M4_ADC_TypeDef *ADCx, uint32_t u32Channel);
  423. en_result_t ADC_ConfigAwd(M4_ADC_TypeDef *ADCx, const stc_adc_awd_cfg_t *pstcAwdCfg);
  424. en_result_t ADC_AwdCmd(M4_ADC_TypeDef *ADCx, en_functional_state_t enState);
  425. en_result_t ADC_AwdITCmd(M4_ADC_TypeDef *ADCx, en_functional_state_t enState);
  426. en_result_t ADC_AddAwdChannel(M4_ADC_TypeDef *ADCx, uint32_t u32Channel);
  427. en_result_t ADC_DelAwdChannel(M4_ADC_TypeDef *ADCx, uint32_t u32Channel);
  428. void ADC_ConfigPga(en_adc_pga_factor_t enFactor, en_adc_pga_negative_t enNegativeIn);
  429. void ADC_PgaCmd(en_functional_state_t enState);
  430. void ADC_AddPgaChannel(uint32_t u32Channel);
  431. void ADC_DelPgaChannel(uint32_t u32Channel);
  432. void ADC_ConfigSync(en_adc_sync_mode_t enMode, uint8_t u8TrgDelay);
  433. void ADC_SyncCmd(en_functional_state_t enState);
  434. en_result_t ADC_StartConvert(M4_ADC_TypeDef *ADCx);
  435. en_result_t ADC_StopConvert(M4_ADC_TypeDef *ADCx);
  436. en_flag_status_t ADC_GetEocFlag(const M4_ADC_TypeDef *ADCx, uint8_t u8Seq);
  437. void ADC_ClrEocFlag(M4_ADC_TypeDef *ADCx, uint8_t u8Seq);
  438. en_result_t ADC_PollingSa(M4_ADC_TypeDef *ADCx, uint16_t *pu16AdcData, uint8_t u8Length, uint32_t u32Timeout);
  439. en_result_t ADC_GetAllData(const M4_ADC_TypeDef *ADCx, uint16_t *pu16AdcData, uint8_t u8Length);
  440. en_result_t ADC_GetChData(const M4_ADC_TypeDef *ADCx, uint32_t u32TargetCh, uint16_t *pu16AdcData, uint8_t u8Length);
  441. uint16_t ADC_GetValue(const M4_ADC_TypeDef *ADCx, uint8_t u8ChIndex);
  442. uint32_t ADC_GetAwdFlag(const M4_ADC_TypeDef *ADCx);
  443. void ADC_ClrAwdFlag(M4_ADC_TypeDef *ADCx);
  444. void ADC_ClrAwdChFlag(M4_ADC_TypeDef *ADCx, uint32_t u32AwdCh);
  445. en_result_t ADC_ChannelRemap(M4_ADC_TypeDef *ADCx, uint32_t u32DestChannel, uint8_t u8AdcPin);
  446. uint8_t ADC_GetChannelPinNum(const M4_ADC_TypeDef *ADCx, uint8_t u8ChIndex);
  447. //@} // AdcGroup
  448. #ifdef __cplusplus
  449. }
  450. #endif
  451. #endif /* DDL_ADC_ENABLE */
  452. #endif /* __HC32F460_ADC_H__ */
  453. /*******************************************************************************
  454. * EOF (not truncated)
  455. ******************************************************************************/