Large cummulative patch for pic16 port.
[fw/sdcc] / device / include / pic16 / adc.h
1
2 /*
3  * A/D conversion module library header
4  *
5  * Devices implemented:
6  *      PIC18F[24][45][28]
7  *
8  */
9
10 /*
11 ** $Id$
12 */
13
14 #ifndef __ADC_H__
15 #define __ADC_H__
16
17
18 /* interrupt on/off flag */
19 #define ADC_INT_OFF     0x00
20 #define ADC_INT_ON      0x01
21
22
23 /* output format */
24 #define ADC_FRM_RJUST   0x80
25 #define ADC_FRM_LJUST   0x00
26
27 /* oscillator frequency */
28 #define ADC_FOSC_2      0x00
29 #define ADC_FOSC_4      0x10
30 #define ADC_FOSC_16     0x11
31 #define ADC_FOSC_32     0x02
32 #define ADC_FOSC_64     0x12
33 #define ADC_FOSC_RC     0x03
34
35
36 /* channel selection */
37 #define ADC_CHN_1               0x00
38 #define ADC_CHN_2               0x01
39 #define ADC_CHN_3               0x03
40 #define ADC_CHN_4               0x04
41 #define ADC_CHN_5               0x05
42 #define ADC_CHN_6               0x06
43 #define ADC_CHN_7               0x07
44
45
46 /* reference and pin configuration */
47 #define ADC_CFG_8A_0R   0x00
48 #define ADC_CFG_7A_1R   0x01
49 #define ADC_CFG_5A_0R   0x02
50 #define ADC_CFG_4A_1R   0x03
51 #define ADC_CFG_3A_0R   0x04
52 #define ADC_CFG_2A_1R   0x05
53 #define ADC_CFG_0A_0R   0x06
54 #define ADC_CFG_6A_2R   0x08
55 #define ADC_CFG_6A_0R   0x09
56 #define ADC_CFG_5A_1R   0x0a
57 #define ADC_CFG_4A_2R   0x0b
58 #define ADC_CFG_3A_2R   0x0c
59 #define ADC_CFG_2A_2R   0x0d
60 #define ADC_CFG_1A_0R   0x0e
61 #define ADC_CFG_1A_2R   0x0f
62
63
64 void adc_open(unsigned char channel, unsigned char fosc, unsigned char pcfg, unsigned char config);
65
66 void adc_close(void);
67
68 void adc_conv(void);
69
70 char adc_busy(void);
71
72 int adc_read(void);
73
74 void adc_setchannel(unsigned char channel);
75
76 #endif