⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adc.h

📁 Mplab C30编译器
💻 H
📖 第 1 页 / 共 3 页
字号:
#define SKIP_SCAN_AN4                   0xFFEF /*Skip AN4 for Input Scan */
#define SKIP_SCAN_AN5                   0xFFDF /*Skip AN5 for Input Scan */    
#define SKIP_SCAN_AN6                   0xFFBF /*Skip AN6 for Input Scan */
#define SKIP_SCAN_AN7                   0xFF7F /*Skip AN7 for Input Scan */
#define SKIP_SCAN_AN8                   0xFEFF /*Skip AN8 for Input Scan */
#define SKIP_SCAN_AN9                   0xFDFF /*Skip AN9 for Input Scan */    
#define SKIP_SCAN_AN10                  0xFBFF /*Skip AN10 for Input Scan */
#define SKIP_SCAN_AN11                  0xF7FF /*Skip AN11 for Input Scan */
#define SKIP_SCAN_AN12                  0xEFFF /*Skip AN12 for Input Scan */
#define SKIP_SCAN_AN13                  0xDFFF /*Skip AN13 for Input Scan */   
#define SKIP_SCAN_AN14                  0xBFFF /*Skip AN14 for Input Scan */
#define SKIP_SCAN_AN15                  0x7FFF /*Skip AN15 for Input Scan */
 
/*defines for ADxCSSH register */

#define SKIP_SCAN_AN16                   0xFFFE /*Skip AN16 for Input Scan */
#define SKIP_SCAN_AN17                   0xFFFD /*Skip AN17 for Input Scan */    
#define SKIP_SCAN_AN18                   0xFFFB /*Skip AN18 for Input Scan */
#define SKIP_SCAN_AN19                   0xFFF7 /*Skip AN19 for Input Scan */
#define SKIP_SCAN_AN20                   0xFFEF /*Skip AN20 for Input Scan */
#define SKIP_SCAN_AN21                   0xFFDF /*Skip AN21 for Input Scan */    
#define SKIP_SCAN_AN22                   0xFFBF /*Skip AN22 for Input Scan */
#define SKIP_SCAN_AN23                   0xFF7F /*Skip AN23 for Input Scan */
#define SKIP_SCAN_AN24                   0xFEFF /*Skip AN24 for Input Scan */
#define SKIP_SCAN_AN25                   0xFDFF /*Skip AN25 for Input Scan */    
#define SKIP_SCAN_AN26                   0xFBFF /*Skip AN26 for Input Scan */
#define SKIP_SCAN_AN27                   0xF7FF /*Skip AN27 for Input Scan */
#define SKIP_SCAN_AN28                   0xEFFF /*Skip AN28 for Input Scan */
#define SKIP_SCAN_AN29                   0xDFFF /*Skip AN29 for Input Scan */   
#define SKIP_SCAN_AN30                   0xBFFF /*Skip AN30 for Input Scan */
#define SKIP_SCAN_AN31                   0x7FFF /*Skip AN31 for Input Scan */

#define SCAN_NONE_0_15                       0x0000 /*Skip AN0-AN15 for Input Scan */
#define SCAN_ALL_0_15                        0xFFFF /*Enable AN0-AN15 for Input Scan */

#define SCAN_NONE_16_31                      0x0000 /*Skip AN16-AN31 for Input Scan */
#define SCAN_ALL_16_31                       0xFFFF /*Enable AN16-AN31 for Input Scan */

/*defines for ADxPCFGH register */

#define ENABLE_AN16_ANA                 0xFFFE /*Enable AN16 in analog mode */
#define ENABLE_AN17_ANA                 0xFFFD /*Enable AN17 in analog mode */
#define ENABLE_AN18_ANA                 0xFFFB /*Enable AN18 in analog mode */
#define ENABLE_AN19_ANA                 0xFFF7 /*Enable AN19 in analog mode */
#define ENABLE_AN20_ANA                 0xFFEF /*Enable AN20 in analog mode */
#define ENABLE_AN21_ANA                 0xFFDF /*Enable AN21 in analog mode */
#define ENABLE_AN22_ANA                 0xFFBF /*Enable AN22 in analog mode */
#define ENABLE_AN23_ANA                 0xFF7F /*Enable AN23 in analog mode */
#define ENABLE_AN24_ANA                 0xFEFF /*Enable AN24 in analog mode */
#define ENABLE_AN25_ANA                 0xFDFF /*Enable AN25 in analog mode */
#define ENABLE_AN26_ANA                 0xFBFF /*Enable AN26 in analog mode */
#define ENABLE_AN27_ANA                 0xF7FF /*Enable AN27 in analog mode */
#define ENABLE_AN28_ANA                 0xEFFF /*Enable AN28 in analog mode */
#define ENABLE_AN29_ANA                 0xDFFF /*Enable AN29 in analog mode */
#define ENABLE_AN30_ANA                 0xBFFF /*Enable AN30 in analog mode */
#define ENABLE_AN31_ANA                 0x7FFF /*Enable AN31 in analog mode */

/*defines for ADxPCFGL register */

#define ENABLE_AN0_ANA                  0xFFFE /*Enable AN0 in analog mode */
#define ENABLE_AN1_ANA                  0xFFFD /*Enable AN1 in analog mode */
#define ENABLE_AN2_ANA                  0xFFFB /*Enable AN2 in analog mode */
#define ENABLE_AN3_ANA                  0xFFF7 /*Enable AN3 in analog mode */
#define ENABLE_AN4_ANA                  0xFFEF /*Enable AN4 in analog mode */
#define ENABLE_AN5_ANA                  0xFFDF /*Enable AN5 in analog mode */
#define ENABLE_AN6_ANA                  0xFFBF /*Enable AN6 in analog mode */
#define ENABLE_AN7_ANA                  0xFF7F /*Enable AN7 in analog mode */
#define ENABLE_AN8_ANA                  0xFEFF /*Enable AN8 in analog mode */
#define ENABLE_AN9_ANA                  0xFDFF /*Enable AN9 in analog mode */
#define ENABLE_AN10_ANA                 0xFBFF /*Enable AN10 in analog mode */
#define ENABLE_AN11_ANA                 0xF7FF /*Enable AN11 in analog mode */
#define ENABLE_AN12_ANA                 0xEFFF /*Enable AN12 in analog mode */
#define ENABLE_AN13_ANA                 0xDFFF /*Enable AN13 in analog mode */
#define ENABLE_AN14_ANA                 0xBFFF /*Enable AN14 in analog mode */
#define ENABLE_AN15_ANA                 0x7FFF /*Enable AN15 in analog mode */

#define ENABLE_ALL_ANA_0_15             0x0000 /*Enable AN0-AN15 in analog mode */
#define ENABLE_ALL_DIG_0_15             0xFFFF /*Enable AN0-AN15 in Digital mode */

#define ENABLE_ALL_ANA_16_31            0x0000 /*Enable AN16-AN31 in analog mode */
#define ENABLE_ALL_DIG_16_31            0xFFFF /*Enable AN16-AN31 in Digital mode */

/* Setting the priority of adc interrupt */
#define ADC_INT_PRI_0                   0xFFF8
#define ADC_INT_PRI_1                   0xFFF9
#define ADC_INT_PRI_2                   0xFFFA
#define ADC_INT_PRI_3                   0xFFFB
#define ADC_INT_PRI_4                   0xFFFC
#define ADC_INT_PRI_5                   0xFFFD
#define ADC_INT_PRI_6                   0xFFFE
#define ADC_INT_PRI_7                   0xFFFF

/* enable / disable interrupts */

#define ADC_INT_ENABLE                  0xFFFF
#define ADC_INT_DISABLE                 0xFFF7

/* constants representing the SMPI<3:0> bits */
#define ADC_SAMPLES_PER_INT_1           0xEFC3  /* A/D Interrupt at the completion of conversion for each sample */
#define ADC_SAMPLES_PER_INT_2           0xEFC7  /* A/D Interrupt at the completion of conversion for each 2nd sample */
#define ADC_SAMPLES_PER_INT_3           0xEFCB  /* A/D interrupt at the completion of conversion for each 3rd sample */
#define ADC_SAMPLES_PER_INT_4           0xEFCF  /* A/D interrupt at the completion of conversion for each 4th sample */
#define ADC_SAMPLES_PER_INT_5           0xEFD3  /* A/D interrupt at the completion of conversion for each 5th sample */
#define ADC_SAMPLES_PER_INT_6           0xEFD7  /* A/D interrupt at the completion of conversion for each 6th sample */
#define ADC_SAMPLES_PER_INT_7           0xEFDB  /* A/D interrupt at the completion of conversion for each 7th sample */
#define ADC_SAMPLES_PER_INT_8           0xEFDF  /* A/D interrupt at the completion of conversion for each 8th sample */
#define ADC_SAMPLES_PER_INT_9           0xEFE3  /* A/D interrupt at the completion of conversion for each 9th sample */
#define ADC_SAMPLES_PER_INT_10          0xEFE7  /* A/D interrupt at the completion of conversion for each 10th sample */
#define ADC_SAMPLES_PER_INT_11          0xEFEB  /* A/D interrupt at the completion of conversion for each 11th sample */
#define ADC_SAMPLES_PER_INT_12          0xEFEF  /* A/D interrupt at the completion of conversion for each 12th sample */
#define ADC_SAMPLES_PER_INT_13          0xEFF3  /* A/D interrupt at the completion of conversion for each 13th sample */
#define ADC_SAMPLES_PER_INT_14          0xEFF7  /* A/D interrupt at the completion of conversion for each 14th sample */
#define ADC_SAMPLES_PER_INT_15          0xEFFB  /* A/D interrupt at the completion of conversion for each 15th sample */
#define ADC_SAMPLES_PER_INT_16          0xEFFF  /* A/D interrupt at the completion of conversion for each 16th sample */

/* Macros to  Enable/Disable interrupts and set Interrupt priority */

#define EnableIntADC1                    _AD1IE = 1
#define DisableIntADC1                   _AD1IE = 0
#define SetPriorityIntADC1(priority)     _AD1IP = priority

#define StopSampADC1                ConvertADC1

void OpenADC1(unsigned int config1, unsigned int config2, unsigned int config3,
              unsigned int config4, unsigned int configport_l,
              unsigned int configport_h, unsigned int configscan_h,
              unsigned int configscan_l) __attribute__ ((section (".libperi"))); /* config ADC */

void ConvertADC1(void) __attribute__ ((section (".libperi")));                      /* Start an A/D conversion */

void SetChanADC1(unsigned int channel123, unsigned int channel0)__attribute__ ((section (".libperi")));              /* Set A/D to specified channel */

unsigned int ReadADC1(unsigned char bufIndex)__attribute__ ((section (".libperi")));        /* Read A/D result */

void CloseADC1(void) __attribute__ ((section (".libperi")));                        /* Turn off A/D */

char BusyADC1(void) __attribute__ ((section (".libperi")));                         /* Check status of A/D conversion */

void ConfigIntADC1(unsigned int config)__attribute__ ((section (".libperi")));

#ifdef _AD2IF 

#define EnableIntADC2                    _AD2IE = 1
#define DisableIntADC2                   _AD2IE = 0
#define SetPriorityIntADC2(priority)     _AD2IP = priority

#define StopSampADC2    ConvertADC2

void OpenADC2(unsigned int config1, unsigned int config2, unsigned int
               config3,unsigned int config4, unsigned int configport_l,
         unsigned int configport_h, unsigned int configscan_h,
        unsigned int configscan_l)__attribute__ ((section (".libperi"))); /* config ADC */

void ConvertADC2(void) __attribute__ ((section (".libperi")));                      /* Start an A/D conversion */

void SetChanADC2(unsigned int channel123,unsigned int channel0)__attribute__ ((section (".libperi")));              /* Set A/D to specified channel */

unsigned int ReadADC2(unsigned char bufIndex)__attribute__ ((section (".libperi")));        /* Read A/D result */

void CloseADC2(void) __attribute__ ((section (".libperi")));                        /* Turn off A/D */

char BusyADC2(void) __attribute__ ((section (".libperi")));                         /* Check status of A/D conversion */

void ConfigIntADC2(unsigned int config)__attribute__ ((section (".libperi")));

#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -