1 //*****************************************************************************
2 //
3 // comp.h - Prototypes for the analog comparator driver.
4 //
5 // Copyright (c) 2005-2012 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 //   Redistribution and use in source and binary forms, with or without
9 //   modification, are permitted provided that the following conditions
10 //   are met:
11 //
12 //   Redistributions of source code must retain the above copyright
13 //   notice, this list of conditions and the following disclaimer.
14 //
15 //   Redistributions in binary form must reproduce the above copyright
16 //   notice, this list of conditions and the following disclaimer in the
17 //   documentation and/or other materials provided with the
18 //   distribution.
19 //
20 //   Neither the name of Texas Instruments Incorporated nor the names of
21 //   its contributors may be used to endorse or promote products derived
22 //   from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __COMP_H__
41 #define __COMP_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Values that can be passed to ComparatorConfigure() as the ulConfig
57 // parameter.  For each group (i.e. COMP_TRIG_xxx, COMP_INT_xxx, etc.), one of
58 // the values may be selected and combined together with values from the other
59 // groups via a logical OR.
60 //
61 //*****************************************************************************
62 #define COMP_TRIG_NONE          0x00000000  // No ADC trigger
63 #define COMP_TRIG_HIGH          0x00000880  // Trigger when high
64 #define COMP_TRIG_LOW           0x00000800  // Trigger when low
65 #define COMP_TRIG_FALL          0x00000820  // Trigger on falling edge
66 #define COMP_TRIG_RISE          0x00000840  // Trigger on rising edge
67 #define COMP_TRIG_BOTH          0x00000860  // Trigger on both edges
68 #define COMP_INT_HIGH           0x00000010  // Interrupt when high
69 #define COMP_INT_LOW            0x00000000  // Interrupt when low
70 #define COMP_INT_FALL           0x00000004  // Interrupt on falling edge
71 #define COMP_INT_RISE           0x00000008  // Interrupt on rising edge
72 #define COMP_INT_BOTH           0x0000000C  // Interrupt on both edges
73 #define COMP_ASRCP_PIN          0x00000000  // Dedicated Comp+ pin
74 #define COMP_ASRCP_PIN0         0x00000200  // Comp0+ pin
75 #define COMP_ASRCP_REF          0x00000400  // Internal voltage reference
76 #ifndef DEPRECATED
77 #define COMP_OUTPUT_NONE        0x00000000  // No comparator output
78 #endif
79 #define COMP_OUTPUT_NORMAL      0x00000000  // Comparator output normal
80 #define COMP_OUTPUT_INVERT      0x00000002  // Comparator output inverted
81 
82 //*****************************************************************************
83 //
84 // Values that can be passed to ComparatorSetRef() as the ulRef parameter.
85 //
86 //*****************************************************************************
87 #define COMP_REF_OFF            0x00000000  // Turn off the internal reference
88 #define COMP_REF_0V             0x00000300  // Internal reference of 0V
89 #define COMP_REF_0_1375V        0x00000301  // Internal reference of 0.1375V
90 #define COMP_REF_0_275V         0x00000302  // Internal reference of 0.275V
91 #define COMP_REF_0_4125V        0x00000303  // Internal reference of 0.4125V
92 #define COMP_REF_0_55V          0x00000304  // Internal reference of 0.55V
93 #define COMP_REF_0_6875V        0x00000305  // Internal reference of 0.6875V
94 #define COMP_REF_0_825V         0x00000306  // Internal reference of 0.825V
95 #define COMP_REF_0_928125V      0x00000201  // Internal reference of 0.928125V
96 #define COMP_REF_0_9625V        0x00000307  // Internal reference of 0.9625V
97 #define COMP_REF_1_03125V       0x00000202  // Internal reference of 1.03125V
98 #define COMP_REF_1_134375V      0x00000203  // Internal reference of 1.134375V
99 #define COMP_REF_1_1V           0x00000308  // Internal reference of 1.1V
100 #define COMP_REF_1_2375V        0x00000309  // Internal reference of 1.2375V
101 #define COMP_REF_1_340625V      0x00000205  // Internal reference of 1.340625V
102 #define COMP_REF_1_375V         0x0000030A  // Internal reference of 1.375V
103 #define COMP_REF_1_44375V       0x00000206  // Internal reference of 1.44375V
104 #define COMP_REF_1_5125V        0x0000030B  // Internal reference of 1.5125V
105 #define COMP_REF_1_546875V      0x00000207  // Internal reference of 1.546875V
106 #define COMP_REF_1_65V          0x0000030C  // Internal reference of 1.65V
107 #define COMP_REF_1_753125V      0x00000209  // Internal reference of 1.753125V
108 #define COMP_REF_1_7875V        0x0000030D  // Internal reference of 1.7875V
109 #define COMP_REF_1_85625V       0x0000020A  // Internal reference of 1.85625V
110 #define COMP_REF_1_925V         0x0000030E  // Internal reference of 1.925V
111 #define COMP_REF_1_959375V      0x0000020B  // Internal reference of 1.959375V
112 #define COMP_REF_2_0625V        0x0000030F  // Internal reference of 2.0625V
113 #define COMP_REF_2_165625V      0x0000020D  // Internal reference of 2.165625V
114 #define COMP_REF_2_26875V       0x0000020E  // Internal reference of 2.26875V
115 #define COMP_REF_2_371875V      0x0000020F  // Internal reference of 2.371875V
116 
117 //*****************************************************************************
118 //
119 // Prototypes for the APIs.
120 //
121 //*****************************************************************************
122 extern void ComparatorConfigure(unsigned long ulBase, unsigned long ulComp,
123                                 unsigned long ulConfig);
124 extern void ComparatorRefSet(unsigned long ulBase, unsigned long ulRef);
125 extern tBoolean ComparatorValueGet(unsigned long ulBase, unsigned long ulComp);
126 extern void ComparatorIntRegister(unsigned long ulBase, unsigned long ulComp,
127                                   void (*pfnHandler)(void));
128 extern void ComparatorIntUnregister(unsigned long ulBase,
129                                     unsigned long ulComp);
130 extern void ComparatorIntEnable(unsigned long ulBase, unsigned long ulComp);
131 extern void ComparatorIntDisable(unsigned long ulBase, unsigned long ulComp);
132 extern tBoolean ComparatorIntStatus(unsigned long ulBase, unsigned long ulComp,
133                                     tBoolean bMasked);
134 extern void ComparatorIntClear(unsigned long ulBase, unsigned long ulComp);
135 
136 //*****************************************************************************
137 //
138 // Mark the end of the C bindings section for C++ compilers.
139 //
140 //*****************************************************************************
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif // __COMP_H__
146