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