2 #include <pic18fregs.h>
8 * channel: one of ADC_CHN_*
9 * fosc: one of ADC_FOSC_*
10 * pcfg: one of ADC_CFG_*
11 * config: ADC_FRM_* | ADC_INT_*
14 void adc_open(unsigned char channel, unsigned char fosc, unsigned char pcfg, unsigned char config)
20 ADCON0 |= (channel & 0x07) << 3;
23 ADCON0 |= (fosc & 0x03) << 6;
24 ADCON1 |= (fosc & 0x04) << 4;
26 /* setup reference and pins */
27 ADCON1 |= pcfg & 0x0f;
29 ADCON0 |= (config & ADC_FRM_RJUST);
31 if(config & ADC_INT_ON) {
37 /* enable the A/D module */