comp_e.h
Go to the documentation of this file.
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 //
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 //
121 //
122 //*****************************************************************************
123 typedef struct _COMP_E_Config
124 {
125  uint_fast16_t positiveTerminalInput;
126  uint_fast16_t negativeTerminalInput;
129  uint_fast16_t powerMode;
130 } COMP_E_Config;
131 
132 //*****************************************************************************
133 //
217 //
218 //*****************************************************************************
219 extern bool COMP_E_initModule(uint32_t comparator, const COMP_E_Config *config);
220 
221 //*****************************************************************************
222 //
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 //
278 //
279 //*****************************************************************************
280 extern void COMP_E_setReferenceAccuracy(uint32_t comparator,
281  uint_fast16_t referenceAccuracy);
282 
283 //*****************************************************************************
284 //
299 //
300 //*****************************************************************************
301 extern void COMP_E_setPowerMode(uint32_t comparator, uint_fast16_t powerMode);
302 
303 //*****************************************************************************
304 //
316 //
317 //*****************************************************************************
318 extern void COMP_E_enableModule(uint32_t comparator);
319 
320 //*****************************************************************************
321 //
334 //
335 //*****************************************************************************
336 extern void COMP_E_disableModule(uint32_t comparator);
337 
338 //*****************************************************************************
339 //
352 //
353 //*****************************************************************************
354 extern void COMP_E_shortInputs(uint32_t comparator);
355 
356 //*****************************************************************************
357 //
370 //
371 //*****************************************************************************
372 extern void COMP_E_unshortInputs(uint32_t comparator);
373 
374 //*****************************************************************************
375 //
411 //
412 //*****************************************************************************
413 extern void COMP_E_disableInputBuffer(uint32_t comparator,
414  uint_fast16_t inputPort);
415 
416 //*****************************************************************************
417 //
451 //
452 //*****************************************************************************
453 extern void COMP_E_enableInputBuffer(uint32_t comparator,
454  uint_fast16_t inputPort);
455 
456 //*****************************************************************************
457 //
472 //
473 //*****************************************************************************
474 extern void COMP_E_swapIO(uint32_t comparator);
475 
476 //*****************************************************************************
477 //
489 //
490 //*****************************************************************************
491 extern uint8_t COMP_E_outputValue(uint32_t comparator);
492 
493 //*****************************************************************************
494 //
515 //
516 //*****************************************************************************
517 extern void COMP_E_enableInterrupt(uint32_t comparator, uint_fast16_t mask);
518 
519 //*****************************************************************************
520 //
539 //
540 //*****************************************************************************
541 extern void COMP_E_disableInterrupt(uint32_t comparator, uint_fast16_t mask);
542 
543 //*****************************************************************************
544 //
563 //
564 //*****************************************************************************
565 extern void COMP_E_clearInterruptFlag(uint32_t comparator, uint_fast16_t mask);
566 
567 //*****************************************************************************
568 //
580 //
581 //*****************************************************************************
582 extern uint_fast16_t COMP_E_getInterruptStatus(uint32_t comparator);
583 
584 //*****************************************************************************
585 //
603 //
604 //*****************************************************************************
605 extern uint_fast16_t COMP_E_getEnabledInterruptStatus(uint32_t comparator);
606 
607 //*****************************************************************************
608 //
633 //
634 //*****************************************************************************
635 extern void COMP_E_setInterruptEdgeDirection(uint32_t comparator,
636  uint_fast8_t edgeDirection);
637 
638 //*****************************************************************************
639 //
655 //
656 //*****************************************************************************
657 extern void COMP_E_toggleInterruptEdgeDirection(uint32_t comparator);
658 
659 //*****************************************************************************
660 //
678 //
679 //*****************************************************************************
680 extern void COMP_E_registerInterrupt(uint32_t comparator,
681  void (*intHandler)(void));
682 
683 //*****************************************************************************
684 //
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.
724 //
725 //*****************************************************************************
726 
727 
728 #endif /* COMP_E_H_ */
void COMP_E_clearInterruptFlag(uint32_t comparator, uint_fast16_t mask)
Definition: comp_e.c:250
uint_fast8_t outputFilterEnableAndDelayLevel
Definition: comp_e.h:127
void COMP_E_setReferenceAccuracy(uint32_t comparator, uint_fast16_t referenceAccuracy)
Definition: comp_e.c:169
void COMP_E_swapIO(uint32_t comparator)
Definition: comp_e.c:223
void COMP_E_enableInterrupt(uint32_t comparator, uint_fast16_t mask)
Definition: comp_e.c:233
void COMP_E_setInterruptEdgeDirection(uint32_t comparator, uint_fast8_t edgeDirection)
Definition: comp_e.c:262
void COMP_E_enableInputBuffer(uint32_t comparator, uint_fast16_t inputPort)
Definition: comp_e.c:216
void COMP_E_unshortInputs(uint32_t comparator)
Definition: comp_e.c:204
void COMP_E_disableModule(uint32_t comparator)
Definition: comp_e.c:194
void COMP_E_unregisterInterrupt(uint32_t comparator)
Definition: comp_e.c:296
struct _COMP_E_Config COMP_E_Config
Type definition for _COMP_E_Config structure.
Definition: comp_e.h:123
uint8_t COMP_E_outputValue(uint32_t comparator)
Definition: comp_e.c:228
uint_fast16_t COMP_E_getInterruptStatus(uint32_t comparator)
Definition: comp_e.c:255
uint_fast16_t positiveTerminalInput
Definition: comp_e.h:125
uint_fast16_t powerMode
Definition: comp_e.h:129
void COMP_E_toggleInterruptEdgeDirection(uint32_t comparator)
Definition: comp_e.c:274
void COMP_E_setReferenceVoltage(uint32_t comparator, uint_fast16_t supplyVoltageReferenceBase, uint_fast16_t lowerLimitSupplyVoltageFractionOf32, uint_fast16_t upperLimitSupplyVoltageFractionOf32)
Definition: comp_e.c:137
uint_fast16_t COMP_E_getEnabledInterruptStatus(uint32_t comparator)
Definition: comp_e.c:239
bool COMP_E_initModule(uint32_t comparator, const COMP_E_Config *config)
Definition: comp_e.c:81
void COMP_E_enableModule(uint32_t comparator)
Definition: comp_e.c:189
void COMP_E_disableInputBuffer(uint32_t comparator, uint_fast16_t inputPort)
Definition: comp_e.c:209
void COMP_E_registerInterrupt(uint32_t comparator, void(*intHandler)(void))
Definition: comp_e.c:279
uint_fast8_t invertedOutputPolarity
Definition: comp_e.h:128
void COMP_E_disableInterrupt(uint32_t comparator, uint_fast16_t mask)
Definition: comp_e.c:245
void COMP_E_shortInputs(uint32_t comparator)
Definition: comp_e.c:199
void COMP_E_setPowerMode(uint32_t comparator, uint_fast16_t powerMode)
Definition: comp_e.c:183
uint_fast16_t negativeTerminalInput
Definition: comp_e.h:126

Copyright 2018, Texas Instruments Incorporated