1 /*
2  *  Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions
6  *  are met:
7  *
8  *    Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *
11  *    Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the
14  *    distribution.
15  *
16  *    Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 //*****************************************************************************
34 //
35 //  adc.h
36 //
37 //  Defines and Macros for the ADC.
38 //
39 //*****************************************************************************
40 
41 #ifndef __ADC_H__
42 #define __ADC_H__
43 
44 //*****************************************************************************
45 //
46 // If building with a C++ compiler, make all of the definitions in this header
47 // have a C binding.
48 //
49 //*****************************************************************************
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 //*****************************************************************************
56 // Values that can be passed to APIs as ulChannel parameter
57 //*****************************************************************************
58 #define ADC_CH_0   0x00000000
59 #define ADC_CH_1   0x00000008
60 #define ADC_CH_2   0x00000010
61 #define ADC_CH_3   0x00000018
62 
63 
64 //*****************************************************************************
65 //
66 // Values that can be passed to ADCIntEnable(), ADCIntDisable()
67 // and ADCIntClear() as ulIntFlags, and returned from ADCIntStatus()
68 //
69 //*****************************************************************************
70 #define ADC_DMA_DONE        0x00000010
71 #define ADC_FIFO_OVERFLOW   0x00000008
72 #define ADC_FIFO_UNDERFLOW  0x00000004
73 #define ADC_FIFO_EMPTY      0x00000002
74 #define ADC_FIFO_FULL       0x00000001
75 
76 
77 //*****************************************************************************
78 //
79 // API Function prototypes
80 //
81 //*****************************************************************************
82 extern void ADCEnable(unsigned long ulBase);
83 extern void ADCDisable(unsigned long ulBase);
84 extern void ADCChannelEnable(unsigned long ulBase,unsigned long ulChannel);
85 extern void ADCChannelDisable(unsigned long ulBase,unsigned long ulChannel);
86 extern void ADCIntRegister(unsigned long ulBase, unsigned long ulChannel,
87                     void (*pfnHandler)(void));
88 extern void ADCIntUnregister(unsigned long ulBase, unsigned long ulChannel);
89 extern void ADCIntEnable(unsigned long ulBase, unsigned long ulChannel,
90                   unsigned long ulIntFlags);
91 extern void ADCIntDisable(unsigned long ulBase, unsigned long ulChannel,
92                   unsigned long ulIntFlags);
93 extern unsigned long ADCIntStatus(unsigned long ulBase,unsigned long ulChannel);
94 extern void ADCIntClear(unsigned long ulBase, unsigned long ulChannel,
95                   unsigned long ulIntFlags);
96 extern void ADCDMAEnable(unsigned long ulBase, unsigned long ulChannel);
97 extern void ADCDMADisable(unsigned long ulBase, unsigned long ulChannel);
98 extern void ADCTimerConfig(unsigned long ulBase, unsigned long ulValue);
99 extern void ADCTimerEnable(unsigned long ulBase);
100 extern void ADCTimerDisable(unsigned long ulBase);
101 extern void ADCTimerReset(unsigned long ulBase);
102 extern unsigned long ADCTimerValueGet(unsigned long ulBase);
103 extern unsigned char ADCFIFOLvlGet(unsigned long ulBase,
104                                    unsigned long ulChannel);
105 extern unsigned long ADCFIFORead(unsigned long ulBase,
106                                    unsigned long ulChannel);
107 
108 //*****************************************************************************
109 //
110 // Mark the end of the C bindings section for C++ compilers.
111 //
112 //*****************************************************************************
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif // __ADC_H__
118 
119