adc.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /******************************************************************************
  2. *
  3. * @brief header file for ADC module utilities (ADC).
  4. *
  5. *******************************************************************************
  6. *
  7. * provide APIs for accessing ADC module (ADC)
  8. ******************************************************************************/
  9. #ifndef ADC_H_
  10. #define ADC_H_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /******************************************************************************
  15. * Macros
  16. ******************************************************************************/
  17. /******************************************************************************
  18. *define ADC refernce voltage
  19. *
  20. *//*! @addtogroup adc_ref_list
  21. * @{
  22. *******************************************************************************/
  23. #define ADC_VREF_VREFH 0x00 /*!< ADC reference voltage is VREFH*/
  24. #define ADC_VREF_VDDA 0x01 /*!< ADC reference voltage is VDDA*/
  25. /*! @} End of adc_ref_list */
  26. /******************************************************************************
  27. * define ADC clock source
  28. *
  29. *//*! @addtogroup adc_clock_source_list
  30. * @{
  31. *******************************************************************************/
  32. #define CLOCK_SOURCE_BUS_CLOCK 0x00 /*!< ADC clock source is bus clock*/
  33. #define CLOCK_SOURCE_BUS_CLOCK_DIVIDE_2 0x01 /*!< ADC clock source is bus clock devided by 2*/
  34. #define CLOCK_SOURCE_ALTCLK 0x02 /*!< ADC clock source is alternative clcok*/
  35. #define CLOCK_SOURCE_ADACK 0x03 /*!< ADC clock source is asynchronous clock*/
  36. /*! @} End of adc_clock_source_list */
  37. /******************************************************************************
  38. * define ADC divider
  39. *
  40. *//*! @addtogroup adc_clock_divider_list
  41. * @{
  42. *******************************************************************************/
  43. #define ADC_ADIV_DIVIDE_1 0x00 /*!< ADC clock divide by 1*/
  44. #define ADC_ADIV_DIVIDE_2 0x01 /*!< ADC clock divide by 2*/
  45. #define ADC_ADIV_DIVIDE_4 0x02 /*!< ADC clock divide by 4*/
  46. #define ADC_ADIV_DIVIDE_8 0x03 /*!< ADC clock divide by 8*/
  47. /*! @} End of adc_clock_divider_list */
  48. /******************************************************************************
  49. * define ADC mode
  50. *
  51. *//*! @addtogroup adc_mode_list
  52. * @{
  53. *******************************************************************************/
  54. #define ADC_MODE_8BIT 0x00 /*!< ADC 8bit mode*/
  55. #define ADC_MODE_10BIT 0x01 /*!< ADC 10bit mode*/
  56. #define ADC_MODE_12BIT 0x02 /*!< ADC 12bit mode */
  57. /*! @} End of adc_mode_list */
  58. /******************************************************************************
  59. * define ADC channel
  60. *
  61. *//*! @addtogroup adc_channel_list
  62. * @{
  63. *******************************************************************************/
  64. #define ADC_CHANNEL_AD0 0x0 /*!< ADC input channel 0 */
  65. #define ADC_CHANNEL_AD1 0x1 /*!< ADC input channel 1 */
  66. #define ADC_CHANNEL_AD2 0x2 /*!< ADC input channel 2 */
  67. #define ADC_CHANNEL_AD3 0x3 /*!< ADC input channel 3 */
  68. #define ADC_CHANNEL_AD4 0x4 /*!< ADC input channel 4 */
  69. #define ADC_CHANNEL_AD5 0x5 /*!< ADC input channel 5 */
  70. #define ADC_CHANNEL_AD6 0x6 /*!< ADC input channel 6 */
  71. #define ADC_CHANNEL_AD7 0x7 /*!< ADC input channel 7 */
  72. #define ADC_CHANNEL_AD8 0x8 /*!< ADC input channel 8 */
  73. #define ADC_CHANNEL_AD9 0x9 /*!< ADC input channel 9 */
  74. #define ADC_CHANNEL_AD10 0xa /*!< ADC input channel 10 */
  75. #define ADC_CHANNEL_AD11 0xb /*!< ADC input channel 11 */
  76. #define ADC_CHANNEL_AD12 0xc /*!< ADC input channel 12 */
  77. #define ADC_CHANNEL_AD13 0xd /*!< ADC input channel 13 */
  78. #define ADC_CHANNEL_AD14 0xe /*!< ADC input channel 14 */
  79. #define ADC_CHANNEL_AD15 0xf /*!< ADC input channel 15 */
  80. #define ADC_CHANNEL_AD18_VSS 0x12 /*!< ADC input channel VSS */
  81. #define ADC_CHANNEL_AD22_TEMPSENSOR 0x16 /*!< ADC input channel internal temperature sensor */
  82. #define ADC_CHANNEL_AD23_BANDGAP 0x17 /*!< ADC input channel bandgap */
  83. #define ADC_CHANNEL_AD29_VREFH 0x1D /*!< ADC input channel Vrefh */
  84. #define ADC_CHANNEL_AD30_VREFL 0x1E /*!< ADC input channel Vrefl */
  85. #define ADC_CHANNEL_DISABLE 0x1F /*!< ADC disable */
  86. /*! @} End of adc_channel_list */
  87. /******************************************************************************
  88. * define ADC FIFO_LEVEL
  89. *
  90. *//*! @addtogroup adc_fifo_level_list
  91. * @{
  92. *******************************************************************************/
  93. #define ADC_FIFO_DISABLE 0 /*!< FIFO Level 0 */
  94. #define ADC_FIFO_LEVEL2 1 /*!< FIFO Level 1 */
  95. #define ADC_FIFO_LEVEL3 2 /*!< FIFO Level 2 */
  96. #define ADC_FIFO_LEVEL4 3 /*!< FIFO Level 3 */
  97. #define ADC_FIFO_LEVEL5 4 /*!< FIFO Level 4 */
  98. #define ADC_FIFO_LEVEL6 5 /*!< FIFO Level 5 */
  99. #define ADC_FIFO_LEVEL7 6 /*!< FIFO Level 6 */
  100. #define ADC_FIFO_LEVEL8 7 /*!< FIFO Level 7 */
  101. /*! @} End of adc_fifo_level_list */
  102. /******************************************************************************
  103. * define ADC trigger source
  104. *
  105. *//*! @addtogroup adc_trigger_list
  106. * @{
  107. *******************************************************************************/
  108. #define ADC_HARDWARE_TRIGGER 0x01 /*!< hardware trigger */
  109. #define ADC_SOFTWARE_TRIGGER 0x00 /*!< software trigger */
  110. #define ADC_TRIGGER_RTC 0x00 /*!< RTC act as trigger source */
  111. #define ADC_TRIGGER_PIT 0x01 /*!< PIT act as trigger source */
  112. #define ADC_TRIGGER_ETM2INIT 0x10 /*!< ETM2 initialization act as trigger source */
  113. #define ADC_TRIGGER_ETM2MATCH 0x11 /*!< ETM2 match interrupt act as trigger source */
  114. /*! @} End of adc_trigger_list */
  115. #define ADC_COMPARE_LESS 0x00
  116. #define ADC_COMPARE_GREATER 0x01
  117. /******************************************************************************
  118. * define ADC call back
  119. *
  120. *//*! @addtogroup adc_callback
  121. * @{
  122. *******************************************************************************/
  123. typedef void (*ADC_CallbackType)(void); /*!< ADC call back function */
  124. /*! @} End of adc_callback */
  125. /******************************************************************************
  126. *
  127. *
  128. *//*! @addtogroup adc_setting_type
  129. * @{
  130. *******************************************************************************/
  131. /*!
  132. * @brief ADC setting type.
  133. *
  134. */
  135. typedef struct
  136. {
  137. uint16_t bIntEn :1; /*!< 1: Interrupt Enable, 0: Interrupt disable */
  138. uint16_t bContinuousEn :1; /*!< 1: Continuous Conversion Enable, 0: Continuous Conversion disable */
  139. uint16_t bHardwareTriggerEn :1; /*!< 1: hardware trigger, 0: software trigger */
  140. uint16_t bCompareEn :1; /*!< 1: compare mode Enable, 0: compare mode disable */
  141. uint16_t bCompareGreaterEn :1; /*!< 1: Compare greater mode, 0: compare less than mode */
  142. uint16_t bLowPowerEn :1; /*!< 1: Low power mode, 0: high speed mode */
  143. uint16_t bLongSampleEn :1; /*!< 1: long sample mode, 0: short sample mode */
  144. uint16_t bFiFoScanModeEn :1; /*!< 1: FIFO scan mode enable, 0: FIFO scan mode disable */
  145. uint16_t bCompareAndEn :1; /*!< 1: Compare and logic, 0: Compare and logic */
  146. #ifdef CPU_NV32
  147. uint16_t bReverse :7;
  148. #else
  149. uint16_t bHTRGMEn :1; /*!< one hardware trigger pulse trigger multiple conversions in fifo mode */
  150. uint16_t bHTRGMASKEn :1; /*!< Hardware trigger mask enable. */
  151. uint16_t bHTRGMASKSEL :1; /*!< This field selects hardware trigger mask mode. */
  152. uint16_t Reserve :4;
  153. #endif
  154. }ADC_SettingType;
  155. /*! @} End of adc_setting_type */
  156. /******************************************************************************
  157. *
  158. *
  159. *//*! @addtogroup adc_config_type
  160. * @{
  161. *******************************************************************************/
  162. /*!
  163. * @brief ADC configure type.
  164. *
  165. */
  166. typedef struct
  167. {
  168. ADC_SettingType sSetting; /*!< ADC setting structure*/
  169. uint16_t u16PinControl; /*!< pin control */
  170. uint8_t u8ClockSource; /*!< clock source selection */
  171. uint8_t u8ClockDiv; /*!< set clock divider */
  172. uint8_t u8Mode; /*!< set clcok mode(8/10/12 bit mode) */
  173. uint8_t u8FiFoLevel; /*!< set FIFO level */
  174. }ADC_ConfigType,*ADC_ConfigTypePtr;
  175. /*! @} End of adc_config_type */
  176. /******************************************************************************
  177. * define ADC APIs
  178. *
  179. *//*! @addtogroup adc_api_list
  180. * @{
  181. *******************************************************************************/
  182. /*****************************************************************************//*!
  183. *
  184. * @brief enable ADC interrupt.
  185. *
  186. * @param[in] pADC point to ADC module type.
  187. *
  188. * @return none
  189. *
  190. * @ Pass/ Fail criteria: none
  191. *****************************************************************************/
  192. __STATIC_INLINE void ADC_IntEnable( ADC_Type *pADC )
  193. {
  194. pADC->SC1 |= ADC_SC1_AIEN_MASK;
  195. }
  196. /*****************************************************************************//*!
  197. *
  198. * @brief disable ADC interrupt.
  199. *
  200. * @param[in] pADC point to ADC module type.
  201. *
  202. * @return none
  203. *
  204. * @ Pass/ Fail criteria: none
  205. *****************************************************************************/
  206. __STATIC_INLINE void ADC_IntDisable( ADC_Type *pADC )
  207. {
  208. pADC->SC1 &= ~ADC_SC1_AIEN_MASK;
  209. }
  210. /*****************************************************************************//*!
  211. *
  212. * @brief enable ADC continuous conversion.
  213. *
  214. * @param[in] pADC point to ADC module type.
  215. *
  216. * @return none
  217. *
  218. * @ Pass/ Fail criteria: none
  219. *****************************************************************************/
  220. __STATIC_INLINE void ADC_ContinuousConversion( ADC_Type *pADC )
  221. {
  222. pADC->SC1 |= ADC_SC1_ADCO_MASK;
  223. }
  224. /*****************************************************************************//*!
  225. *
  226. * @brief enable ADC single conversion
  227. *
  228. * @param[in] pADC point to ADC module type.
  229. *
  230. * @return none
  231. *
  232. * @ Pass/ Fail criteria: none
  233. *****************************************************************************/
  234. __STATIC_INLINE void ADC_SingleConversion( ADC_Type *pADC )
  235. {
  236. pADC->SC1 &= ~ADC_SC1_ADCO_MASK;
  237. }
  238. /*****************************************************************************//*!
  239. *
  240. * @brief set the ADC to hardware trigger.
  241. *
  242. * @param[in] pADC point to ADC module type.
  243. *
  244. * @return none.
  245. *
  246. * @ Pass/ Fail criteria: none.
  247. *****************************************************************************/
  248. __STATIC_INLINE void ADC_SetHardwareTrigger( ADC_Type *pADC )
  249. {
  250. pADC->SC2 |= ADC_SC2_ADTRG_MASK;
  251. }
  252. /*****************************************************************************//*!
  253. *
  254. * @brief set the ADC to software trigger.
  255. *
  256. * @param[in] pADC point to ADC module type.
  257. *
  258. * @return none
  259. *
  260. * @ Pass/ Fail criteria: none
  261. *****************************************************************************/
  262. __STATIC_INLINE void ADC_SetSoftwareTrigger( ADC_Type *pADC )
  263. {
  264. pADC->SC2 &= ~ADC_SC2_ADTRG_MASK;
  265. }
  266. /*****************************************************************************//*!
  267. *
  268. * @brief enable ADC compare function.
  269. *
  270. * @param[in] pADC point to ADC module type.
  271. *
  272. * @return none
  273. *
  274. * @ Pass/ Fail criteria: none
  275. *****************************************************************************/
  276. __STATIC_INLINE void ADC_CompareEnable( ADC_Type *pADC )
  277. {
  278. pADC->SC2 |= ADC_SC2_ACFE_MASK;
  279. }
  280. /*****************************************************************************//*!
  281. *
  282. * @brief disable ADC compare function.
  283. *
  284. * @param[in] pADC point to ADC module type.
  285. *
  286. * @return none
  287. *
  288. * @ Pass/ Fail criteria: none
  289. *****************************************************************************/
  290. __STATIC_INLINE void ADC_CompareDisable( ADC_Type *pADC )
  291. {
  292. pADC->SC2 &= ~ADC_SC2_ACFE_MASK;
  293. }
  294. /*****************************************************************************//*!
  295. *
  296. * @brief enable ADC compare greater function.
  297. *
  298. * @param[in] pADC point to ADC module type.
  299. *
  300. * @return none
  301. *
  302. * @ Pass/ Fail criteria: none
  303. *****************************************************************************/
  304. __STATIC_INLINE void ADC_CompareGreaterFunction( ADC_Type *pADC )
  305. {
  306. pADC->SC2 |= ADC_SC2_ACFGT_MASK;
  307. }
  308. /*****************************************************************************//*!
  309. *
  310. * @brief enable ADC compare less function.
  311. *
  312. * @param[in] pADC point to ADC module type.
  313. *
  314. * @return none
  315. *
  316. * @ Pass/ Fail criteria: none
  317. *****************************************************************************/
  318. __STATIC_INLINE void ADC_CompareLessFunction( ADC_Type *pADC )
  319. {
  320. pADC->SC2 &= ~ADC_SC2_ACFGT_MASK;
  321. }
  322. /*****************************************************************************//*!
  323. *
  324. * @brief set ADC to low power configuration.
  325. *
  326. * @param[in] pADC point to ADC module type.
  327. *
  328. * @return none
  329. *
  330. * @ Pass/ Fail criteria: none
  331. *****************************************************************************/
  332. __STATIC_INLINE void ADC_SetLowPower( ADC_Type *pADC )
  333. {
  334. pADC->SC3 |= ADC_SC3_ADLPC_MASK;
  335. }
  336. /*****************************************************************************//*!
  337. *
  338. * @brief set ADC to high speed configuration.
  339. *
  340. * @param[in] pADC point to ADC module type.
  341. *
  342. * @return none
  343. *
  344. * @ Pass/ Fail criteria: none
  345. *****************************************************************************/
  346. __STATIC_INLINE void ADC_SetHighSpeed( ADC_Type *pADC )
  347. {
  348. pADC->SC3 &= ~ADC_SC3_ADLPC_MASK;
  349. }
  350. /*****************************************************************************//*!
  351. *
  352. * @brief Long Sample ETMe Configuration.
  353. *
  354. * @param[in] pADC point to ADC module type.
  355. *
  356. * @return none
  357. *
  358. * @ Pass/ Fail criteria: none
  359. *****************************************************************************/
  360. __STATIC_INLINE void ADC_SetLongSample( ADC_Type *pADC )
  361. {
  362. pADC->SC3 |= ADC_SC3_ADLSMP_MASK;
  363. }
  364. /*****************************************************************************//*!
  365. *
  366. * @brief Short Sample ETMe Configuration.
  367. *
  368. * @param[in] pADC point to ADC module type.
  369. *
  370. * @return none
  371. *
  372. * @ Pass/ Fail criteria: none
  373. *****************************************************************************/
  374. __STATIC_INLINE void ADC_SetShortSample( ADC_Type *pADC )
  375. {
  376. pADC->SC3 &= ~ADC_SC3_ADLSMP_MASK;
  377. }
  378. /*****************************************************************************//*!
  379. *
  380. * @brief FIFO scan mode enable.
  381. *
  382. * @param[in] pADC point to ADC module type.
  383. *
  384. * @return none.
  385. *
  386. * @ Pass/ Fail criteria: none.
  387. *****************************************************************************/
  388. __STATIC_INLINE void ADC_FifoScanModeEnable( ADC_Type *pADC )
  389. {
  390. pADC->SC4 |= ADC_SC4_ASCANE_MASK;
  391. }
  392. /*****************************************************************************//*!
  393. *
  394. * @brief FIFO scan mode disable.
  395. *
  396. * @param[in] pADC point to ADC module type.
  397. *
  398. * @return none
  399. *
  400. * @ Pass/ Fail criteria: none
  401. *****************************************************************************/
  402. __STATIC_INLINE void ADC_FifoScanModeDisable( ADC_Type *pADC )
  403. {
  404. pADC->SC4 &= ~ADC_SC4_ASCANE_MASK;
  405. }
  406. /*****************************************************************************//*!
  407. *
  408. * @brief OR all of compare trigger.
  409. *
  410. * @param[in] pADC point to ADC module type.
  411. *
  412. * @return none
  413. *
  414. * @ Pass/ Fail criteria: none
  415. *****************************************************************************/
  416. __STATIC_INLINE void ADC_CompareFifoOr( ADC_Type *pADC )
  417. {
  418. pADC->SC4 &= ~ADC_SC4_ACFSEL_MASK;
  419. }
  420. /*****************************************************************************//*!
  421. *
  422. * @brief And all of compare trigger.
  423. *
  424. * @param[in] pADC point to ADC module type.
  425. *
  426. * @return none
  427. *
  428. * @ Pass/ Fail criteria: none
  429. *****************************************************************************/
  430. __STATIC_INLINE void ADC_CompareFifoAnd( ADC_Type *pADC )
  431. {
  432. pADC->SC4 |= ADC_SC4_ACFSEL_MASK;
  433. }
  434. /*****************************************************************************//*!
  435. *
  436. * @brief read ADC result register.
  437. *
  438. * @param[in] pADC point to ADC module type.
  439. *
  440. * @return ADC result value.
  441. *
  442. * @ Pass/ Fail criteria: none
  443. *****************************************************************************/
  444. __STATIC_INLINE uint16_t ADC_ReadResultReg( ADC_Type *pADC )
  445. {
  446. return (uint16_t)pADC->R;
  447. }
  448. /*****************************************************************************//*!
  449. *
  450. * @brief set ADC compare value.
  451. *
  452. * @param[in] pADC point to ADC module type.
  453. * @param[in] u16Compare compare value.
  454. *
  455. * @return none
  456. *
  457. * @ Pass/ Fail criteria: none
  458. *****************************************************************************/
  459. __STATIC_INLINE void ADC_SetCompareValue( ADC_Type *pADC, uint16_t u16Compare )
  460. {
  461. pADC->CV = u16Compare;
  462. }
  463. /*****************************************************************************//*!
  464. *
  465. * @brief ADC pin control enable.
  466. *
  467. * @param[in] pADC point to ADC module type.
  468. * @param[in] u16PinNumber enable ADC function to specified pin number.
  469. *
  470. * @return none
  471. *
  472. * @ Pass/ Fail criteria: none
  473. *****************************************************************************/
  474. __STATIC_INLINE void ADC_PinControlEnable( ADC_Type *pADC, uint16_t u16PinNumber)
  475. {
  476. ASSERT((u16PinNumber<16));
  477. pADC->APCTL1 &= ~(0x01<<u16PinNumber);
  478. }
  479. /*****************************************************************************//*!
  480. *
  481. * @brief ADC pin control disable.
  482. *
  483. * @param[in] pADC point to ADC module type.
  484. * @param[in] u16PinNumber disable ADC function to specified pin number.
  485. *
  486. * @return none
  487. *
  488. * @ Pass/ Fail criteria: none
  489. *****************************************************************************/
  490. __STATIC_INLINE void ADC_PinControlDisable( ADC_Type *pADC, uint16_t u16PinNumber)
  491. {
  492. ASSERT((u16PinNumber<16));
  493. pADC->APCTL1 |= (0x01<<u16PinNumber);
  494. }
  495. /*****************************************************************************//*!
  496. *
  497. * @brief check conversion active status
  498. *
  499. * @param[in] pADC point to ADC module type.
  500. *
  501. * @return TRUE or FALSE
  502. *
  503. * @ Pass/ Fail criteria: none
  504. *****************************************************************************/
  505. __STATIC_INLINE uint8_t ADC_IsConversionActiveFlag( ADC_Type *pADC )
  506. {
  507. return(pADC->SC2 & ADC_SC2_ADACT_MASK);
  508. }
  509. /*****************************************************************************//*!
  510. *
  511. * @brief check COCO flag
  512. *
  513. * @param[in] pADC point to ADC module type.
  514. *
  515. * @return TRUE or FALSE
  516. *
  517. * @ Pass/ Fail criteria: none
  518. *****************************************************************************/
  519. __STATIC_INLINE uint8_t ADC_IsCOCOFlag( ADC_Type *pADC )
  520. {
  521. return(pADC->SC1 & ADC_SC1_COCO_MASK);
  522. }
  523. /*****************************************************************************//*!
  524. *
  525. * @brief check Result FIFO empty
  526. *
  527. * @param[in] pADC point to ADC module type.
  528. *
  529. * @return TRUE or FALSE
  530. *
  531. * @ Pass/ Fail criteria: none
  532. *****************************************************************************/
  533. __STATIC_INLINE uint8_t ADC_IsFIFOEmptyFlag( ADC_Type *pADC )
  534. {
  535. return(pADC->SC2 & ADC_SC2_FEMPTY_MASK);
  536. }
  537. /*****************************************************************************//*!
  538. *
  539. * @brief check Result FIFO full
  540. *
  541. * @param[in] pADC point to ADC module type.
  542. *
  543. * @return TRUE or FALSE
  544. *
  545. * @ Pass/ Fail criteria: none
  546. *****************************************************************************/
  547. __STATIC_INLINE uint8_t ADC_IsFIFOFullFlag( ADC_Type *pADC )
  548. {
  549. return(pADC->SC2 & ADC_SC2_FFULL_MASK);
  550. }
  551. #ifndef CPU_NV32
  552. /*****************************************************************************//*!
  553. *
  554. * @brief Hardware Trigger Multiple Conversion Enable
  555. *
  556. * @param[in] pADC point to ADC module type.
  557. *
  558. * @return none
  559. *
  560. * @ Pass/ Fail criteria: none
  561. *****************************************************************************/
  562. __STATIC_INLINE void ADC_HardwareTriggerMultiple( ADC_Type *pADC )
  563. {
  564. pADC->SC4 |= ADC_SC4_HTRGME_MASK;
  565. }
  566. /*****************************************************************************//*!
  567. *
  568. * @brief Hardware Trigger Single Conversion
  569. *
  570. * @param[in] pADC point to ADC module type.
  571. *
  572. * @return none
  573. *
  574. * @ Pass/ Fail criteria: none
  575. *****************************************************************************/
  576. __STATIC_INLINE void ADC_HardwareTriggerSingle( ADC_Type *pADC )
  577. {
  578. pADC->SC4 &= ~ADC_SC4_HTRGME_MASK;
  579. }
  580. /*****************************************************************************//*!
  581. *
  582. * @brief Hardware Trigger Mask Enable
  583. *
  584. * @param[in] pADC point to ADC module type.
  585. *
  586. * @return none
  587. *
  588. * @ Pass/ Fail criteria: none
  589. *****************************************************************************/
  590. __STATIC_INLINE void ADC_HardwareTriggerMaskEnable( ADC_Type *pADC )
  591. {
  592. pADC->SC5 |= ADC_SC5_HTRGMASKE_MASK;
  593. }
  594. /*****************************************************************************//*!
  595. *
  596. * @brief Hardware Trigger Mask Disable
  597. *
  598. * @param[in] pADC point to ADC module type.
  599. *
  600. * @return none
  601. *
  602. * @ Pass/ Fail criteria: none
  603. *****************************************************************************/
  604. __STATIC_INLINE void ADC_HardwareTriggerMaskDisable( ADC_Type *pADC )
  605. {
  606. pADC->SC5 &= ~ADC_SC5_HTRGMASKE_MASK;
  607. }
  608. /*****************************************************************************//*!
  609. *
  610. * @brief Hardware Trigger Mask Mode Select Automatic Mode
  611. *
  612. * @param[in] pADC point to ADC module type.
  613. *
  614. * @return none
  615. *
  616. * @ Pass/ Fail criteria: none
  617. *****************************************************************************/
  618. __STATIC_INLINE void ADC_HardwareTriggerMaskAuto( ADC_Type *pADC )
  619. {
  620. pADC->SC5 |= ADC_SC5_HTRGMASKSEL_MASK;
  621. }
  622. /*****************************************************************************//*!
  623. *
  624. * @brief Hardware Trigger Mask Mode Select to be with HTRGMASKE
  625. *
  626. * @param[in] pADC point to ADC module type.
  627. *
  628. * @return none
  629. *
  630. * @ Pass/ Fail criteria: none
  631. *****************************************************************************/
  632. __STATIC_INLINE void ADC_HardwareTriggerMaskNonAuto( ADC_Type *pADC )
  633. {
  634. pADC->SC5 &= ~ADC_SC5_HTRGMASKSEL_MASK;
  635. }
  636. #endif
  637. /******************************************************************************
  638. * Global function
  639. ******************************************************************************/
  640. void ADC_SetChannel( ADC_Type *pADC, uint8_t u8Channel );
  641. void ADC_IntEnable( ADC_Type *pADC );
  642. void ADC_IntDisable( ADC_Type *pADC );
  643. void ADC_ContinuousConversion( ADC_Type *pADC );
  644. void ADC_SingleConversion( ADC_Type *pADC );
  645. void ADC_SetSoftwareTrigger( ADC_Type *pADC );
  646. void ADC_SetHardwareTrigger( ADC_Type *pADC );
  647. void ADC_VrefSelect( ADC_Type *pADC, uint8_t u8Vref );
  648. void ADC_CompareEnable( ADC_Type *pADC );
  649. void ADC_CompareDisable( ADC_Type *pADC );
  650. void ADC_CompareGreaterFunction( ADC_Type *pADC );
  651. void ADC_CompareLessFunction( ADC_Type *pADC );
  652. void ADC_SetLowPower( ADC_Type *pADC );
  653. void ADC_SetHighSpeed( ADC_Type *pADC );
  654. void ADC_SelectClockDivide( ADC_Type *pADC, uint8_t u8Div);
  655. void ADC_SetLongSample(ADC_Type *pADC);
  656. void ADC_SetShortSample(ADC_Type *pADC);
  657. void ADC_SetMode(ADC_Type *pADC, uint8_t u8Mode);
  658. void ADC_SelectClock(ADC_Type *pADC, uint8_t u8Clock);
  659. void ADC_FifoScanModeEnable(ADC_Type *pADC);
  660. void ADC_FifoScanModeDisable(ADC_Type *pADC);
  661. void ADC_CompareFifoOr(ADC_Type *pADC);
  662. void ADC_CompareFifoAnd(ADC_Type *pADC);
  663. void ADC_SetFifoLevel(ADC_Type *pADC, uint8_t u8FifoLevel);
  664. uint16_t ADC_ReadResultReg(ADC_Type *pADC );
  665. void ADC_SetCompareValue(ADC_Type *pADC, uint16_t u16Compare );
  666. void ADC_PinControlEnable(ADC_Type *pADC, uint16_t u16PinNumber);
  667. void ADC_PinControlDisable(ADC_Type *pADC, uint16_t u16PinNumber);
  668. uint8_t ADC_IsConversionActiveFlag(ADC_Type *pADC);
  669. uint8_t ADC_IsCOCOFlag(ADC_Type *pADC);
  670. uint8_t ADC_IsFIFOEmptyFlag(ADC_Type *pADC);
  671. uint8_t ADC_IsFIFOFullFlag(ADC_Type *pADC);
  672. void ADC_HardwareTriggerMaskNonAuto(ADC_Type *pADC);
  673. void ADC_HardwareTriggerMaskAuto(ADC_Type *pADC);
  674. void ADC_HardwareTriggerMaskDisable( ADC_Type *pADC );
  675. void ADC_HardwareTriggerMaskEnable( ADC_Type *pADC );
  676. void ADC_HardwareTriggerSingle( ADC_Type *pADC );
  677. void ADC_HardwareTriggerMultiple( ADC_Type *pADC );
  678. unsigned int ADC_PollRead( ADC_Type *pADC, uint8_t u8Channel);
  679. void ADC_SetCallBack(ADC_CallbackType pADC_CallBack);
  680. void ADC_DeInit(ADC_Type *pADC);
  681. void ADC_Init(ADC_Type *pADC, ADC_ConfigTypePtr pADC_Config);
  682. /*! @} End of adc_api_list */
  683. #ifdef __cplusplus
  684. }
  685. #endif
  686. #endif /* ADC_H_ */