]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - msp430-bsl/msp430-bsl.git/blob - source/driverlib/MSP430F5xx_6xx/comp_b.h
MSP-BSL v3.0
[msp430-bsl/msp430-bsl.git] / source / driverlib / MSP430F5xx_6xx / comp_b.h
1 /* --COPYRIGHT--,BSD\r
2  * Copyright (c) 2014, Texas Instruments Incorporated\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  *\r
9  * *  Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  * *  Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the distribution.\r
15  *\r
16  * *  Neither the name of Texas Instruments Incorporated nor the names of\r
17  *    its contributors may be used to endorse or promote products derived\r
18  *    from this software without specific prior written permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  * --/COPYRIGHT--*/\r
32 //*****************************************************************************\r
33 //\r
34 // comp_b.h - Driver for the COMP_B Module.\r
35 //\r
36 //*****************************************************************************\r
37 \r
38 #ifndef __MSP430WARE_COMP_B_H__\r
39 #define __MSP430WARE_COMP_B_H__\r
40 \r
41 #include "inc/hw_memmap.h"\r
42 \r
43 #ifdef __MSP430_HAS_COMPB__\r
44 \r
45 //*****************************************************************************\r
46 //\r
47 // If building with a C++ compiler, make all of the definitions in this header\r
48 // have a C binding.\r
49 //\r
50 //*****************************************************************************\r
51 #ifdef __cplusplus\r
52 extern "C"\r
53 {\r
54 #endif\r
55 \r
56 //******************************************************************************\r
57 //\r
58 // The following is a struct that is passed to COMP_B_initialize()\r
59 //\r
60 //******************************************************************************\r
61 typedef struct COMP_B_initializeParam {\r
62         uint8_t positiveTerminalInput;\r
63         uint8_t negativeTerminalInput;\r
64         uint16_t powerModeSelect;\r
65         uint8_t outputFilterEnableAndDelayLevel;\r
66         uint16_t invertedOutputPolarity;\r
67 } COMP_B_initializeParam;\r
68 \r
69 //******************************************************************************\r
70 //\r
71 // The following is a struct that is passed to COMP_B_configureReferenceVoltage()\r
72 //\r
73 //******************************************************************************\r
74 typedef struct COMP_B_configureReferenceVoltageParam {\r
75         uint16_t supplyVoltageReferenceBase;\r
76         uint16_t lowerLimitSupplyVoltageFractionOf32;\r
77         uint16_t upperLimitSupplyVoltageFractionOf32;\r
78         uint16_t referenceAccuracy;\r
79 } COMP_B_configureReferenceVoltageParam;\r
80 \r
81 //*****************************************************************************\r
82 //\r
83 // The following are values that can be passed to the powerModeSelect parameter\r
84 // for functions: COMP_B_init().\r
85 //\r
86 //*****************************************************************************\r
87 #define COMP_B_POWERMODE_HIGHSPEED                                  (CBPWRMD_0)\r
88 #define COMP_B_POWERMODE_NORMALMODE                                 (CBPWRMD_1)\r
89 #define COMP_B_POWERMODE_ULTRALOWPOWER                              (CBPWRMD_2)\r
90 \r
91 //*****************************************************************************\r
92 //\r
93 // The following are values that can be passed to the positiveTerminalInput\r
94 // parameter for functions: COMP_B_init(); the inputPort parameter for\r
95 // functions: COMP_B_disableInputBuffer(), and COMP_B_enableInputBuffer(); the\r
96 // negativeTerminalInput parameter for functions: COMP_B_init().\r
97 //\r
98 //*****************************************************************************\r
99 #define COMP_B_INPUT0                                               (CBIPSEL_0)\r
100 #define COMP_B_INPUT1                                               (CBIPSEL_1)\r
101 #define COMP_B_INPUT2                                               (CBIPSEL_2)\r
102 #define COMP_B_INPUT3                                               (CBIPSEL_3)\r
103 #define COMP_B_INPUT4                                               (CBIPSEL_4)\r
104 #define COMP_B_INPUT5                                               (CBIPSEL_5)\r
105 #define COMP_B_INPUT6                                               (CBIPSEL_6)\r
106 #define COMP_B_INPUT7                                               (CBIPSEL_7)\r
107 #define COMP_B_INPUT8                                               (CBIPSEL_8)\r
108 #define COMP_B_INPUT9                                               (CBIPSEL_9)\r
109 #define COMP_B_INPUT10                                             (CBIPSEL_10)\r
110 #define COMP_B_INPUT11                                             (CBIPSEL_11)\r
111 #define COMP_B_INPUT12                                             (CBIPSEL_12)\r
112 #define COMP_B_INPUT13                                             (CBIPSEL_13)\r
113 #define COMP_B_INPUT14                                             (CBIPSEL_14)\r
114 #define COMP_B_INPUT15                                             (CBIPSEL_15)\r
115 #define COMP_B_VREF                                                      (0x10)\r
116 \r
117 //*****************************************************************************\r
118 //\r
119 // The following are values that can be passed to the\r
120 // outputFilterEnableAndDelayLevel parameter for functions: COMP_B_init().\r
121 //\r
122 //*****************************************************************************\r
123 #define COMP_B_FILTEROUTPUT_OFF                                            0x00\r
124 #define COMP_B_FILTEROUTPUT_DLYLVL1                            (CBF + CBFDLY_0)\r
125 #define COMP_B_FILTEROUTPUT_DLYLVL2                            (CBF + CBFDLY_1)\r
126 #define COMP_B_FILTEROUTPUT_DLYLVL3                            (CBF + CBFDLY_2)\r
127 #define COMP_B_FILTEROUTPUT_DLYLVL4                            (CBF + CBFDLY_3)\r
128 \r
129 //*****************************************************************************\r
130 //\r
131 // The following are values that can be passed to the invertedOutputPolarity\r
132 // parameter for functions: COMP_B_init().\r
133 //\r
134 //*****************************************************************************\r
135 #define COMP_B_NORMALOUTPUTPOLARITY                               (!(CBOUTPOL))\r
136 #define COMP_B_INVERTEDOUTPUTPOLARITY                                (CBOUTPOL)\r
137 \r
138 //*****************************************************************************\r
139 //\r
140 // The following are values that can be passed to the referenceAccuracy\r
141 // parameter for functions: COMP_B_setReferenceVoltage().\r
142 //\r
143 //*****************************************************************************\r
144 #define COMP_B_ACCURACY_STATIC                                      (!CBREFACC)\r
145 #define COMP_B_ACCURACY_CLOCKED                                      (CBREFACC)\r
146 \r
147 //*****************************************************************************\r
148 //\r
149 // The following are values that can be passed to the\r
150 // supplyVoltageReferenceBase parameter for functions:\r
151 // COMP_B_setReferenceVoltage().\r
152 //\r
153 //*****************************************************************************\r
154 #define COMP_B_VREFBASE_VCC                                          (CBREFL_0)\r
155 #define COMP_B_VREFBASE1_5V                                          (CBREFL_1)\r
156 #define COMP_B_VREFBASE2_0V                                          (CBREFL_2)\r
157 #define COMP_B_VREFBASE2_5V                                          (CBREFL_3)\r
158 \r
159 //*****************************************************************************\r
160 //\r
161 // The following are values that can be passed to the interruptMask parameter\r
162 // for functions: COMP_B_enableInterrupt(), and COMP_B_disableInterrupt().\r
163 //\r
164 //*****************************************************************************\r
165 #define COMP_B_OUTPUT_INT                                                  CBIE\r
166 #define COMP_B_OUTPUTINVERTED_INT                                         CBIIE\r
167 \r
168 //*****************************************************************************\r
169 //\r
170 // The following are values that can be passed to the interruptFlagMask\r
171 // parameter for functions: COMP_B_clearInterrupt(), and\r
172 // COMP_B_getInterruptStatus() as well as returned by the\r
173 // COMP_B_getInterruptStatus() function.\r
174 //\r
175 //*****************************************************************************\r
176 #define COMP_B_OUTPUT_FLAG                                                CBIFG\r
177 #define COMP_B_OUTPUTINVERTED_FLAG                                       CBIIFG\r
178 \r
179 //*****************************************************************************\r
180 //\r
181 // The following are values that can be passed to the edgeDirection parameter\r
182 // for functions: COMP_B_interruptSetEdgeDirection().\r
183 //\r
184 //*****************************************************************************\r
185 #define COMP_B_FALLINGEDGE                                           (!(CBIES))\r
186 #define COMP_B_RISINGEDGE                                               (CBIES)\r
187 \r
188 //*****************************************************************************\r
189 //\r
190 // The following are values that can be passed toThe following are values that\r
191 // can be returned by the COMP_B_outputValue() function.\r
192 //\r
193 //*****************************************************************************\r
194 #define COMP_B_LOW                                                        (0x0)\r
195 #define COMP_B_HIGH                                                     (CBOUT)\r
196 \r
197 //*****************************************************************************\r
198 //\r
199 // Prototypes for the APIs.\r
200 //\r
201 //*****************************************************************************\r
202 extern bool COMP_B_initialize(uint16_t baseAddress,\r
203                               COMP_B_initializeParam *param);\r
204 \r
205 extern void COMP_B_configureReferenceVoltage(uint16_t baseAddress,\r
206                                              COMP_B_configureReferenceVoltageParam *param);\r
207 \r
208 extern void COMP_B_enableInterrupt(uint16_t baseAddress,\r
209                                    uint16_t interruptMask);\r
210 \r
211 extern void COMP_B_disableInterrupt(uint16_t baseAddress,\r
212                                     uint16_t interruptMask);\r
213 \r
214 extern void COMP_B_clearInterrupt(uint16_t baseAddress,\r
215                                   uint16_t interruptFlagMask);\r
216 \r
217 extern uint8_t COMP_B_getInterruptStatus(uint16_t baseAddress,\r
218                                          uint16_t interruptFlagMask);\r
219 \r
220 extern void COMP_B_interruptSetEdgeDirection(uint16_t baseAddress,\r
221                                              uint16_t edgeDirection);\r
222 \r
223 extern void COMP_B_interruptToggleEdgeDirection(uint16_t baseAddress);\r
224 \r
225 extern void COMP_B_enable(uint16_t baseAddress);\r
226 \r
227 extern void COMP_B_disable(uint16_t baseAddress);\r
228 \r
229 extern void COMP_B_shortInputs(uint16_t baseAddress);\r
230 \r
231 extern void COMP_B_unshortInputs(uint16_t baseAddress);\r
232 \r
233 extern void COMP_B_disableInputBuffer(uint16_t baseAddress,\r
234                                       uint8_t inputPort);\r
235 \r
236 extern void COMP_B_enableInputBuffer(uint16_t baseAddress,\r
237                                      uint8_t inputPort);\r
238 \r
239 extern void COMP_B_IOSwap(uint16_t baseAddress);\r
240 \r
241 extern uint16_t COMP_B_outputValue(uint16_t baseAddress);\r
242 \r
243 //*****************************************************************************\r
244 //\r
245 // The following are deprecated APIs.\r
246 //\r
247 //*****************************************************************************\r
248 extern bool COMP_B_init(uint16_t baseAddress,\r
249                         uint8_t positiveTerminalInput,\r
250                         uint8_t negativeTerminalInput,\r
251                         uint16_t powerModeSelect,\r
252                         uint8_t outputFilterEnableAndDelayLevel,\r
253                         uint16_t invertedOutputPolarity);\r
254 \r
255 extern void COMP_B_setReferenceVoltage(uint16_t baseAddress,\r
256                                        uint16_t supplyVoltageReferenceBase,\r
257                                        uint16_t lowerLimitSupplyVoltageFractionOf32,\r
258                                        uint16_t upperLimitSupplyVoltageFractionOf32,\r
259                                        uint16_t referenceAccuracy);\r
260 \r
261 //*****************************************************************************\r
262 //\r
263 // Mark the end of the C bindings section for C++ compilers.\r
264 //\r
265 //*****************************************************************************\r
266 #ifdef __cplusplus\r
267 }\r
268 #endif\r
269 \r
270 #endif\r
271 #endif // __MSP430WARE_COMP_B_H__\r