Prepare for SDCC 4.5.0 release.
[sdcc.git] / sdcc / device / lib / pic16 / libio / adc / adcbusy.c
blob2a505dbbb7ab1e13263edec32340ab5625ef0fd7
1 /*-------------------------------------------------------------------------
2 adcbusy - check whether the AD module is busy
4 Copyright (C) 2004, Vangelis Rokas <vrokas AT otenet.gr>
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this library; see the file COPYING. If not, write to the
18 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19 MA 02110-1301, USA.
21 As a special exception, if you link this library with other files,
22 some of which are compiled with SDCC, to produce an executable,
23 this library does not by itself cause the resulting executable to
24 be covered by the GNU General Public License. This exception does
25 not however invalidate any other reasons why the executable file
26 might be covered by the GNU General Public License.
27 -------------------------------------------------------------------------*/
29 #include <pic18fregs.h>
30 #include <adc.h>
33 char adc_busy(void) __naked
35 #if (__SDCC_ADC_STYLE == 1865501)
36 WDTCONbits.ADSHR = 0; /* access ADCON0/1 */
37 #endif
38 #if 0
39 return (ADCON0bits.GO);
40 #else
41 #if (__SDCC_ADC_STYLE == 1802420)
42 __asm
43 movlw 0x00
44 btfsc _ADCON0bits, 2
45 addlw 0x01
46 return
47 __endasm;
48 #elif (__SDCC_ADC_STYLE == 1812200) \
49 || (__SDCC_ADC_STYLE == 1812300) \
50 || (__SDCC_ADC_STYLE == 1813502) \
51 || (__SDCC_ADC_STYLE == 1822200) \
52 || (__SDCC_ADC_STYLE == 1823222) \
53 || (__SDCC_ADC_STYLE == 1824501) \
54 || (__SDCC_ADC_STYLE == 1865501)
55 __asm
56 movlw 0x00
57 btfsc _ADCON0bits, 1
58 addlw 0x01
59 return
60 __endasm;
61 #else /* unsupported ADC style */
62 #error Unsupported ADC style.
63 #endif
64 #endif