1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef COMP_E_H_
33 #define COMP_E_H_
34 
35 //*****************************************************************************
36 //
37 //! \addtogroup comp_api
38 //! @{
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #include <stdint.h>
54 #include <stdbool.h>
55 #include <ti/devices/msp432p4xx/inc/msp.h>
56 
57 /* Module defines for Comp */
58 #define COMP_E_CMSIS(x) ((COMP_E_Type *) x)
59 
60 #define COMP_E_FILTEROUTPUT_OFF                                            0x00
61 #define COMP_E_FILTEROUTPUT_DLYLVL1         (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_0)
62 #define COMP_E_FILTEROUTPUT_DLYLVL2         (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_1)
63 #define COMP_E_FILTEROUTPUT_DLYLVL3         (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_2)
64 #define COMP_E_FILTEROUTPUT_DLYLVL4         (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_3)
65 
66 #define COMP_E_INPUT0                                                    (0x01)
67 #define COMP_E_INPUT1                                                    (0x02)
68 #define COMP_E_INPUT2                                                    (0x04)
69 #define COMP_E_INPUT3                                                    (0x08)
70 #define COMP_E_INPUT4                                                    (0x10)
71 #define COMP_E_INPUT5                                                    (0x20)
72 #define COMP_E_INPUT6                                                    (0x40)
73 #define COMP_E_INPUT7                                                    (0x80)
74 #define COMP_E_INPUT8                                                   (0x100)
75 #define COMP_E_INPUT9                                                   (0x200)
76 #define COMP_E_INPUT10                                                  (0x400)
77 #define COMP_E_INPUT11                                                  (0x800)
78 #define COMP_E_INPUT12                                                 (0x1000)
79 #define COMP_E_INPUT13                                                 (0x2000)
80 #define COMP_E_INPUT14                                                 (0x4000)
81 #define COMP_E_INPUT15                                                 (0x8000)
82 #define COMP_E_VREF                                                      (0x9F)
83 
84 #define COMP_E_NORMALOUTPUTPOLARITY                      (!(COMP_E_CTL1_OUTPOL))
85 #define COMP_E_INVERTEDOUTPUTPOLARITY                       (COMP_E_CTL1_OUTPOL)
86 
87 #define COMP_E_REFERENCE_AMPLIFIER_DISABLED               (COMP_E_CTL2_CEREFL_0)
88 #define COMP_E_VREFBASE1_2V                               (COMP_E_CTL2_CEREFL_1)
89 #define COMP_E_VREFBASE2_0V                               (COMP_E_CTL2_CEREFL_2)
90 #define COMP_E_VREFBASE2_5V                               (COMP_E_CTL2_CEREFL_3)
91 
92 #define COMP_E_ACCURACY_STATIC                             (!COMP_E_CTL2_REFACC)
93 #define COMP_E_ACCURACY_CLOCKED                             (COMP_E_CTL2_REFACC)
94 
95 #define COMP_E_HIGH_SPEED_MODE                             (COMP_E_CTL1_PWRMD_0)
96 #define COMP_E_NORMAL_MODE                                 (COMP_E_CTL1_PWRMD_1)
97 #define COMP_E_ULTRA_LOW_POWER_MODE                        (COMP_E_CTL1_PWRMD_2)
98 
99 #define COMP_E_OUTPUT_INTERRUPT                                  (COMP_E_INT_IE)
100 #define COMP_E_INVERTED_POLARITY_INTERRUPT                      (COMP_E_INT_IIE)
101 #define COMP_E_READY_INTERRUPT                                (COMP_E_INT_RDYIE)
102 
103 #define COMP_E_OUTPUT_INTERRUPT_FLAG                            (COMP_E_INT_IFG)
104 #define COMP_E_INTERRUPT_FLAG_INVERTED_POLARITY                (COMP_E_INT_IIFG)
105 #define COMP_E_INTERRUPT_FLAG_READY                          (COMP_E_INT_RDYIFG)
106 
107 #define COMP_E_FALLINGEDGE                                  (!(COMP_E_CTL1_IES))
108 #define COMP_E_RISINGEDGE                                      (COMP_E_CTL1_IES)
109 
110 #define COMP_E_LOW                                                         (0x0)
111 #define COMP_E_HIGH                                            (COMP_E_CTL1_OUT)
112 
113 //*****************************************************************************
114 //
115 //!     ypedef COMP_E_Config
116 //! \brief Type definition for \link _COMP_E_Config \endlink structure
117 //!
118 //! \struct _COMP_E_Config
119 //! \brief Configuration structure for Comparator module. See
120 //!        \link COMP_E_initModule \endlink for parameter documentation.
121 //
122 //*****************************************************************************
123 typedef struct _COMP_E_Config
124 {
125     uint_fast16_t positiveTerminalInput;
126     uint_fast16_t negativeTerminalInput;
127     uint_fast8_t outputFilterEnableAndDelayLevel;
128     uint_fast8_t invertedOutputPolarity;
129     uint_fast16_t powerMode;
130 } COMP_E_Config;
131 
132 //*****************************************************************************
133 //
134 //! Initializes the Comparator Module.
135 //!
136 //! \param comparator is the instance of the Comparator module. Valid
137 //! parameters vary from part to part, but can include:
138 //!         - \b COMP_E0_BASE
139 //!         - \b COMP_E1_BASE
140 //! \param config Configuration structure for the Comparator module
141 //!
142 //! <hr>
143 //! <b>Configuration options for \link COMP_E_Config \endlink structure.</b>
144 //! <hr>
145 //!
146 //! \param positiveTerminalInput selects the input to the positive terminal.
147 //!        Valid values are
148 //!        - \b COMP_E_INPUT0 [Default]
149 //!        - \b COMP_E_INPUT1
150 //!        - \b COMP_E_INPUT2
151 //!        - \b COMP_E_INPUT3
152 //!        - \b COMP_E_INPUT4
153 //!        - \b COMP_E_INPUT5
154 //!        - \b COMP_E_INPUT6
155 //!        - \b COMP_E_INPUT7
156 //!        - \b COMP_E_INPUT8
157 //!        - \b COMP_E_INPUT9
158 //!        - \b COMP_E_INPUT10
159 //!        - \b COMP_E_INPUT11
160 //!        - \b COMP_E_INPUT12
161 //!        - \b COMP_E_INPUT13
162 //!        - \b COMP_E_INPUT14
163 //!        - \b COMP_E_INPUT15
164 //!        - \b COMP_E_VREF
165 //!        \n Modified bits are \b CEIPSEL and \b CEIPEN of \b CECTL0 register,
166 //!        \b CERSEL of \b CECTL2 register, and CEPDx of \b CECTL3 register.
167 //! \param negativeTerminalInput selects the input to the negative terminal.
168 //!        \n Valid values are:
169 //!        - \b COMP_E_INPUT0 [Default]
170 //!        - \b COMP_E_INPUT1
171 //!        - \b COMP_E_INPUT2
172 //!        - \b COMP_E_INPUT3
173 //!        - \b COMP_E_INPUT4
174 //!        - \b COMP_E_INPUT5
175 //!        - \b COMP_E_INPUT6
176 //!        - \b COMP_E_INPUT7
177 //!        - \b COMP_E_INPUT8
178 //!        - \b COMP_E_INPUT9
179 //!        - \b COMP_E_INPUT10
180 //!        - \b COMP_E_INPUT11
181 //!        - \b COMP_E_INPUT12
182 //!        - \b COMP_E_INPUT13
183 //!        - \b COMP_E_INPUT14
184 //!        - \b COMP_E_INPUT15
185 //!        - \b COMP_E_VREF
186 //!        \n Modified bits are \b CEIMSEL and \b CEIMEN of \b CECTL0 register,
187 //!        \b CERSEL of \b CECTL2 register, and CEPDx of \b CECTL3 register.
188 //! \param outputFilterEnableAndDelayLevel controls the output filter delay
189 //!       state, which is either off or enabled with a specified delay level.
190 //!        \n Valid values are
191 //!        - \b COMP_E_FILTEROUTPUT_OFF [Default]
192 //!        - \b COMP_E_FILTEROUTPUT_DLYLVL1
193 //!        - \b COMP_E_FILTEROUTPUT_DLYLVL2
194 //!        - \b COMP_E_FILTEROUTPUT_DLYLVL3
195 //!        - \b COMP_E_FILTEROUTPUT_DLYLVL4
196 //!        \n This parameter is device specific and delay levels should be found
197 //!        in the device's datasheet.
198 //!        \n Modified bits are \b CEF and \b CEFDLY of \b CECTL1 register.
199 //! \param invertedOutputPolarity controls if the output will be inverted or
200 //!        not. Valid values are
201 //!        - \b COMP_E_NORMALOUTPUTPOLARITY - indicates the output should be
202 //!             normal. [Default]
203 //!        - \b COMP_E_INVERTEDOUTPUTPOLARITY -  the output should be inverted.
204 //!        \n Modified bits are \b CEOUTPOL of \b CECTL1 register.
205 //! \param powerMode controls the power mode of the module
206 //!        - \b COMP_E_HIGH_SPEED_MODE [default]
207 //!        - \b COMP_E_NORMAL_MODE
208 //!        - \b COMP_E_ULTRA_LOW_POWER_MODE
209 //! Upon successful initialization of the Comparator module, this function will
210 //! have reset all necessary register bits and set the given options in the
211 //! registers. To actually use the comparator module, the COMP_E_enableModule()
212 //! function must be explicitly called before use.
213 //! If a Reference Voltage is set to a terminal, the Voltage should be set
214 //! using the COMP_E_setReferenceVoltage() function.
215 //!
216 //! \return true or false of the initialization process.
217 //
218 //*****************************************************************************
219 extern bool COMP_E_initModule(uint32_t comparator, const COMP_E_Config *config);
220 
221 //*****************************************************************************
222 //
223 //! Generates a Reference Voltage to the terminal selected during
224 //! initialization.
225 //!
226 //! \param comparator is the instance of the Comparator module. Valid
227 //! parameters vary from part to part, but can include:
228 //!         - \b COMP_E0_BASE
229 //!         - \b COMP_E1_BASE
230 //! \param supplyVoltageReferenceBase decides the source and max amount of
231 //!       Voltage that can be used as a reference.
232 //!        Valid values are
233 //!        - \b COMP_E_REFERENCE_AMPLIFIER_DISABLED
234 //!        - \b COMP_E_VREFBASE1_2V
235 //!        - \b COMP_E_VREFBASE2_0V
236 //!        - \b COMP_E_VREFBASE2_5V
237 //! \param upperLimitSupplyVoltageFractionOf32 is the numerator of the
238 //!       equation to generate the reference voltage for the upper limit
239 //!       reference voltage. Valid values are between 1 and 32.
240 //! \param lowerLimitSupplyVoltageFractionOf32 is the numerator of the
241 //!       equation to generate the reference voltage for the lower limit
242 //!       reference voltage. Valid values are between 1 and 32.
243 //!  <br>Modified bits are \b CEREF0 of \b CECTL2 register.
244 //!
245 //! Use this function to generate a voltage to serve as a reference to the
246 //! terminal selected at initialization. The voltage is determined by the
247 //! equation: Vbase * (Numerator / 32). If the upper and lower limit voltage
248 //! numerators are equal, then a static reference is defined, whereas they are
249 //! different then a hysteresis effect is generated.
250 //!
251 //! \return NONE
252 //
253 //*****************************************************************************
254 extern void COMP_E_setReferenceVoltage(uint32_t comparator,
255         uint_fast16_t supplyVoltageReferenceBase,
256         uint_fast16_t lowerLimitSupplyVoltageFractionOf32,
257         uint_fast16_t upperLimitSupplyVoltageFractionOf32);
258 
259 //*****************************************************************************
260 //
261 //! Sets the reference accuracy
262 //!
263 //! \param comparator is the instance of the Comparator module. Valid
264 //! parameters vary from part to part, but can include:
265 //!         - \b COMP_E0_BASE
266 //!         - \b COMP_E1_BASE
267 //! \param referenceAccuracy is the reference accuracy setting of the
268 //!      comparator. Clocked is for low power/low accuracy.
269 //!      Valid values are
270 //!      - \b COMP_E_ACCURACY_STATIC
271 //!      - \b COMP_E_ACCURACY_CLOCKED
272 //!      <br>Modified bits are \b CEREFACC of \b CECTL2 register.
273 //!
274 //! The reference accuracy is set to the desired setting. Clocked is better for
275 //!  low power operations but has a lower accuracy.
276 //!
277 //! \return NONE
278 //
279 //*****************************************************************************
280 extern void COMP_E_setReferenceAccuracy(uint32_t comparator,
281         uint_fast16_t referenceAccuracy);
282 
283 //*****************************************************************************
284 //
285 //! Sets the power mode
286 //!
287 //! \param comparator is the instance of the Comparator module. Valid
288 //! parameters vary from part to part, but can include:
289 //!         - \b COMP_E0_BASE
290 //!         - \b COMP_E1_BASE
291 //! \param powerMode decides the power mode
292 //!        Valid values are
293 //!        - \b COMP_E_HIGH_SPEED_MODE
294 //!        - \b COMP_E_NORMAL_MODE
295 //!        - \b COMP_E_ULTRA_LOW_POWER_MODE
296 //!        <br>Modified bits are \b CEPWRMD of \b CECTL1 register.
297 //!
298 //! \return NONE
299 //
300 //*****************************************************************************
301 extern void COMP_E_setPowerMode(uint32_t comparator, uint_fast16_t powerMode);
302 
303 //*****************************************************************************
304 //
305 //! Turns on the Comparator module.
306 //!
307 //! \param comparator is the instance of the Comparator module. Valid
308 //! parameters vary from part to part, but can include:
309 //!         - \b COMP_E0_BASE
310 //!         - \b COMP_E1_BASE
311 //!
312 //! This function sets the bit that enables the operation of the
313 //! Comparator module.
314 //!
315 //! \return NONE
316 //
317 //*****************************************************************************
318 extern void COMP_E_enableModule(uint32_t comparator);
319 
320 //*****************************************************************************
321 //
322 //! Turns off the Comparator module.
323 //!
324 //! \param comparator is the instance of the Comparator module. Valid
325 //! parameters vary from part to part, but can include:
326 //!         - \b COMP_E0_BASE
327 //!         - \b COMP_E1_BASE
328 //!
329 //! This function clears the CEON bit disabling the operation of the Comparator
330 //! module, saving from excess power consumption.
331 //!
332 //! Modified bits are \b CEON of \b CECTL1 register.
333 //! \return NONE
334 //
335 //*****************************************************************************
336 extern void COMP_E_disableModule(uint32_t comparator);
337 
338 //*****************************************************************************
339 //
340 //! Shorts the two input pins chosen during initialization.
341 //!
342 //! \param comparator is the instance of the Comparator module. Valid
343 //! parameters vary from part to part, but can include:
344 //!         - \b COMP_E0_BASE
345 //!         - \b COMP_E1_BASE
346 //!
347 //! This function sets the bit that shorts the devices attached to the input
348 //! pins chosen from the initialization of the comparator.
349 //!
350 //! Modified bits are \b CESHORT of \b CECTL1 register.
351 //! \return NONE
352 //
353 //*****************************************************************************
354 extern void COMP_E_shortInputs(uint32_t comparator);
355 
356 //*****************************************************************************
357 //
358 //! Disables the short of the two input pins chosen during initialization.
359 //!
360 //! \param comparator is the instance of the Comparator module. Valid
361 //! parameters vary from part to part, but can include:
362 //!         - \b COMP_E0_BASE
363 //!         - \b COMP_E1_BASE
364 //!
365 //! This function clears the bit that shorts the devices attached to the input
366 //! pins chosen from the initialization of the comparator.
367 //!
368 //! Modified bits are \b CESHORT of \b CECTL1 register.
369 //! \return NONE
370 //
371 //*****************************************************************************
372 extern void COMP_E_unshortInputs(uint32_t comparator);
373 
374 //*****************************************************************************
375 //
376 //! Disables the input buffer of the selected input port to effectively allow
377 //! for analog signals.
378 //!
379 //! \param comparator is the instance of the Comparator module. Valid
380 //! parameters vary from part to part, but can include:
381 //!         - \b COMP_E0_BASE
382 //!         - \b COMP_E1_BASE
383 //! \param inputPort is the port in which the input buffer will be disabled.
384 //!        Valid values are a logical OR of the following:
385 //!        - \b COMP_E_INPUT0 [Default]
386 //!        - \b COMP_E_INPUT1
387 //!        - \b COMP_E_INPUT2
388 //!        - \b COMP_E_INPUT3
389 //!        - \b COMP_E_INPUT4
390 //!        - \b COMP_E_INPUT5
391 //!        - \b COMP_E_INPUT6
392 //!        - \b COMP_E_INPUT7
393 //!        - \b COMP_E_INPUT8
394 //!        - \b COMP_E_INPUT9
395 //!        - \b COMP_E_INPUT10
396 //!        - \b COMP_E_INPUT11
397 //!        - \b COMP_E_INPUT12
398 //!        - \b COMP_E_INPUT13
399 //!        - \b COMP_E_INPUT14
400 //!        - \b COMP_E_INPUT15
401 //!       <br> Modified bits are \b CEPDx of \b CECTL3 register.
402 //!
403 //! This function sets the bit to disable the buffer for the specified input
404 //! port to allow for analog signals from any of the comparator input pins. This
405 //! bit is automatically set when the input is initialized to be used with the
406 //! comparator module. This function should be used whenever an analog input is
407 //! connected to one of these pins to prevent parasitic voltage from causing
408 //! unexpected results.
409 //!
410 //! \return NONE
411 //
412 //*****************************************************************************
413 extern void COMP_E_disableInputBuffer(uint32_t comparator,
414         uint_fast16_t inputPort);
415 
416 //*****************************************************************************
417 //
418 //! Enables the input buffer of the selected input port to allow for digital
419 //! signals.
420 //!
421 //! \param comparator is the instance of the Comparator module. Valid
422 //! parameters vary from part to part, but can include:
423 //!         - \b COMP_E0_BASE
424 //!         - \b COMP_E1_BASE
425 //! \param inputPort is the port in which the input buffer will be enabled.
426 //!        Valid values are a logical OR of the following:
427 //!        - \b COMP_E_INPUT0 [Default]
428 //!        - \b COMP_E_INPUT1
429 //!        - \b COMP_E_INPUT2
430 //!        - \b COMP_E_INPUT3
431 //!        - \b COMP_E_INPUT4
432 //!        - \b COMP_E_INPUT5
433 //!        - \b COMP_E_INPUT6
434 //!        - \b COMP_E_INPUT7
435 //!        - \b COMP_E_INPUT8
436 //!        - \b COMP_E_INPUT9
437 //!        - \b COMP_E_INPUT10
438 //!        - \b COMP_E_INPUT11
439 //!        - \b COMP_E_INPUT12
440 //!        - \b COMP_E_INPUT13
441 //!        - \b COMP_E_INPUT14
442 //!        - \b COMP_E_INPUT15
443 //!      <br> Modified bits are \b CEPDx of \b CECTL3 register.
444 //!
445 //! This function clears the bit to enable the buffer for the specified input
446 //! port to allow for digital signals from any of the comparator input pins.
447 //! This should not be reset if there is an analog signal connected to the
448 //! specified input pin to prevent from unexpected results.
449 //!
450 //! \return NONE
451 //
452 //*****************************************************************************
453 extern void COMP_E_enableInputBuffer(uint32_t comparator,
454         uint_fast16_t inputPort);
455 
456 //*****************************************************************************
457 //
458 //! Toggles the bit that swaps which terminals the inputs go to, while also
459 //! inverting the output of the comparator.
460 //!
461 //! \param comparator is the instance of the Comparator module. Valid
462 //! parameters vary from part to part, but can include:
463 //!         - \ bCOMP_E0
464 //!         - \ bCOMP_E1
465 //!
466 //! This function toggles the bit that controls which input goes to which
467 //! terminal. After initialization, this bit is set to 0, after toggling it once
468 //! the inputs are routed to the opposite terminal and the output is inverted.
469 //!
470 //! Modified bits are \b CEEX of \b CECTL1 register.
471 //! \return NONE
472 //
473 //*****************************************************************************
474 extern void COMP_E_swapIO(uint32_t comparator);
475 
476 //*****************************************************************************
477 //
478 //! Returns the output value of the Comparator module.
479 //!
480 //! \param comparator is the instance of the Comparator module. Valid parameters
481 //! vary from part to part, but can include:
482 //!         - \b COMP_E0_BASE
483 //!         - \b COMP_E1_BASE
484 //!
485 //! Returns the output value of the Comparator module.
486 //!
487 //! \return COMP_E_HIGH or COMP_E_LOW as the output value of the Comparator
488 //!          module.
489 //
490 //*****************************************************************************
491 extern uint8_t COMP_E_outputValue(uint32_t comparator);
492 
493 //*****************************************************************************
494 //
495 //! Enables selected Comparator interrupt sources.
496 //!
497 //! \param comparator is the instance of the Comparator module. Valid
498 //! parameters vary from part to part, but can include:
499 //!         - \b COMP_E0_BASE
500 //!         - \b COMP_E1_BASE
501 //! \param mask is the bit mask of the interrupt sources to be enabled.
502 //!        Mask value is the logical OR of any of the following
503 //!        - \b COMP_E_OUTPUT_INTERRUPT - Output interrupt
504 //!        - \b COMP_E_INVERTED_POLARITY_INTERRUPT - Output interrupt inverted
505 //!                                                 polarity
506 //!        - \b COMP_E_READY_INTERRUPT - Ready interrupt
507 //!
508 //! Enables the indicated Comparator interrupt sources.  Only the sources that
509 //! are enabled can be reflected to the processor interrupt; disabled sources
510 //! have no effect on the processor. The default trigger for the non-inverted
511 //! interrupt is a rising edge of the output, this can be changed with the
512 //! interruptSetEdgeDirection() function.
513 //!
514 //! \return NONE
515 //
516 //*****************************************************************************
517 extern void COMP_E_enableInterrupt(uint32_t comparator, uint_fast16_t mask);
518 
519 //*****************************************************************************
520 //
521 //! Disables selected Comparator interrupt sources.
522 //!
523 //! \param comparator is the instance of the Comparator module. Valid
524 //! parameters vary from part to part, but can include:
525 //!         - \b COMP_E0_BASE
526 //!         - \b COMP_E1_BASE
527 //! \param mask is the bit mask of the interrupt sources to be disabled.
528 //!        Mask value is the logical OR of any of the following
529 //!        - \b COMP_E_OUTPUT_INTERRUPT - Output interrupt
530 //!        - \b COMP_E_INVERTED_POLARITY_INTERRUPT - Output interrupt inverted
531 //!                                                 polarity
532 //!        - \b COMP_E_READY_INTERRUPT - Ready interrupt
533 //!
534 //! Disables the indicated Comparator interrupt sources.  Only the sources that
535 //! are enabled can be reflected to the processor interrupt; disabled sources
536 //! have no effect on the processor.
537 //!
538 //! \return NONE
539 //
540 //*****************************************************************************
541 extern void COMP_E_disableInterrupt(uint32_t comparator, uint_fast16_t mask);
542 
543 //*****************************************************************************
544 //
545 //! Clears Comparator interrupt flags.
546 //!
547 //! \param comparator is the instance of the Comparator module. Valid
548 //! parameters vary from part to part, but can include:
549 //!         - \b COMP_E0_BASE
550 //!         - \b COMP_E1_BASE
551 //! \param mask is a bit mask of the interrupt sources to be cleared.
552 //!        Mask value is the logical OR of any of the following
553 //!        - \b COMP_E_INTERRUPT_FLAG - Output interrupt flag
554 //!        - \b COMP_E_INTERRUPT_FLAG_INVERTED_POLARITY - Output interrupt flag
555 //!                                                     inverted polarity
556 //!        - \b COMP_E_INTERRUPT_FLAG_READY - Ready interrupt flag
557 //!
558 //! The Comparator interrupt source is cleared, so that it no longer asserts.
559 //! The highest interrupt flag is automatically cleared when an interrupt vector
560 //! generator is used.
561 //!
562 //! \return NONE
563 //
564 //*****************************************************************************
565 extern void COMP_E_clearInterruptFlag(uint32_t comparator, uint_fast16_t mask);
566 
567 //*****************************************************************************
568 //
569 //! Gets the current Comparator interrupt status.
570 //!
571 //! \param comparator is the instance of the Comparator module. Valid
572 //! parameters vary from part to part, but can include:
573 //!         - \b COMP_E0_BASE
574 //!         - \b COMP_E1_BASE
575 //!
576 //! This returns the interrupt status for the Comparator module based on which
577 //! flag is passed.
578 //!
579 //! \return The current interrupt flag status for the corresponding mask.
580 //
581 //*****************************************************************************
582 extern uint_fast16_t COMP_E_getInterruptStatus(uint32_t comparator);
583 
584 //*****************************************************************************
585 //
586 //! Enables selected Comparator interrupt sources masked with the enabled
587 //! interrupts. This function is useful to call in ISRs to get a list
588 //! of pending interrupts that are actually enabled and could have caused the
589 //! ISR.
590 //!
591 //! \param comparator is the instance of the Comparator module. Valid
592 //! parameters vary from part to part, but can include:
593 //!         - \b COMP_E0_BASE
594 //!         - \b COMP_E1_BASE
595 //!
596 //! Enables the indicated Comparator interrupt sources.  Only the sources that
597 //! are enabled can be reflected to the processor interrupt; disabled sources
598 //! have no effect on the processor. The default trigger for the non-inverted
599 //! interrupt is a rising edge of the output, this can be changed with the
600 //! COMP_E_setInterruptEdgeDirection() function.
601 //!
602 //! \return NONE
603 //
604 //*****************************************************************************
605 extern uint_fast16_t COMP_E_getEnabledInterruptStatus(uint32_t comparator);
606 
607 //*****************************************************************************
608 //
609 //! Explicitly sets the edge direction that would trigger an interrupt.
610 //!
611 //! \param comparator is the instance of the Comparator module. Valid
612 //! parameters vary from part to part, but can include:
613 //!         - \b COMP_E0_BASE
614 //!         - \b COMP_E1_BASE
615 //! \param edgeDirection determines which direction the edge would have to go
616 //!       to generate an interrupt based on the non-inverted interrupt flag.
617 //!        Valid values are
618 //!        - \b COMP_E_FALLINGEDGE - sets the bit to generate an interrupt when
619 //!             the output of the comparator falls from HIGH to LOW if the
620 //!             normal interrupt bit is set(and LOW to HIGH if the inverted
621 //!             interrupt enable bit is set). [Default]
622 //!        - \b COMP_E_RISINGEDGE - sets the bit to generate an interrupt when the
623 //!             output of the comparator rises from LOW to HIGH if the normal
624 //!             interrupt bit is set(and HIGH to LOW if the inverted interrupt
625 //!             enable bit is set).
626 //!        <br>Modified bits are \b CEIES of \b CECTL1 register.
627 //!
628 //! This function will set which direction the output will have to go, whether
629 //! rising or falling, to generate an interrupt based on a non-inverted
630 //! interrupt.
631 //!
632 //! \return NONE
633 //
634 //*****************************************************************************
635 extern void COMP_E_setInterruptEdgeDirection(uint32_t comparator,
636         uint_fast8_t edgeDirection);
637 
638 //*****************************************************************************
639 //
640 //! Toggles the edge direction that would trigger an interrupt.
641 //!
642 //! \param comparator is the instance of the Comparator module. Valid
643 //! parameters vary from part to part, but can include:
644 //!         - \b COMP_E0_BASE
645 //!         - \b COMP_E1_BASE
646 //!
647 //! This function will toggle which direction the output will have to go,
648 //! whether rising or falling, to generate an interrupt based on a non-inverted
649 //! interrupt. If the direction was rising, it is now falling, if it was
650 //! falling, it is now rising.
651 //!
652 //! Modified bits are \b CEIES of \b CECTL1 register.
653 //!
654 //! \return NONE
655 //
656 //*****************************************************************************
657 extern void COMP_E_toggleInterruptEdgeDirection(uint32_t comparator);
658 
659 //*****************************************************************************
660 //
661 //! Registers an interrupt handler for the Comparator E interrupt.
662 //!
663 //! \param intHandler is a pointer to the function to be called when the
664 //! Comparator interrupt occurs.
665 //!
666 //! \param comparator is the instance of the Comparator module. Valid
667 //! parameters vary from part to part, but can include:
668 //!         - \b COMP_E0_BASE
669 //!         - \b COMP_E1_BASE
670 //!
671 //! This function registers the handler to be called when a Comparator
672 //! interrupt occurs. This function enables the global interrupt in the
673 //! interrupt controller; specific Comparator interrupts must be enabled
674 //! via COMP_E_enableInterrupt().  It is the interrupt handler's responsibility to
675 //! clear the interrupt source via COMP_E_clearInterruptFlag().
676 //!
677 //! \return None.
678 //
679 //*****************************************************************************
680 extern void COMP_E_registerInterrupt(uint32_t comparator,
681         void (*intHandler)(void));
682 
683 //*****************************************************************************
684 //
685 //! Unregisters the interrupt handler for the Comparator E interrupt
686 //!
687 //! \param comparator is the instance of the Comparator module. Valid
688 //! parameters vary from part to part, but can include:
689 //!         - \b COMP_E0_BASE
690 //!         - \b COMP_E1_BASE
691 //!
692 //! This function unregisters the handler to be called when Comparator E
693 //! interrupt occurs.  This function also masks off the interrupt in the
694 //! interrupt controller so that the interrupt handler no longer is called.
695 //!
696 //! \sa Interrupt_registerInterrupt() for important information about
697 //! registering interrupt handlers.
698 //!
699 //! \return None.
700 //
701 //*****************************************************************************
702 extern void COMP_E_unregisterInterrupt(uint32_t comparator);
703 
704 /* Backwards Compatibility Layer */
705 #define COMP_E_enable(a) COMP_E_enableModule(a)
706 #define COMP_E_disable(a) COMP_E_disableModule(a)
707 #define COMP_E_IOSwap(a) COMP_E_swapIO(a)
708 #define COMP_E_interruptToggleEdgeDirection(a) COMP_E_toggleInterruptEdgeDirection(a)
709 #define COMP_E_clearInterrupt(a,b) COMP_E_clearInterruptFlag(a,b)
710 
711 //*****************************************************************************
712 //
713 // Mark the end of the C bindings section for C++ compilers.
714 //
715 //*****************************************************************************
716 #ifdef __cplusplus
717 }
718 #endif
719 
720 //*****************************************************************************
721 //
722 // Close the Doxygen group.
723 //! @}
724 //
725 //*****************************************************************************
726 
727 
728 #endif /* COMP_E_H_ */
729