comp_e.h
Go to the documentation of this file.
1 #ifndef COMP_E_H_
2 #define COMP_E_H_
3 
4 //*****************************************************************************
5 //
8 //
9 //*****************************************************************************
10 
11 //*****************************************************************************
12 //
13 // If building with a C++ compiler, make all of the definitions in this header
14 // have a C binding.
15 //
16 //*****************************************************************************
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 #include <stdint.h>
23 #include <stdbool.h>
24 #include <msp.h>
25 
26 /* Module defines for Comp */
27 #define COMP_E_CMSIS(x) ((COMP_E_Type *) x)
28 
29 #define COMP_E_FILTEROUTPUT_OFF 0x00
30 #define COMP_E_FILTEROUTPUT_DLYLVL1 (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_0)
31 #define COMP_E_FILTEROUTPUT_DLYLVL2 (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_1)
32 #define COMP_E_FILTEROUTPUT_DLYLVL3 (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_2)
33 #define COMP_E_FILTEROUTPUT_DLYLVL4 (COMP_E_CTL1_F + COMP_E_CTL1_FDLY_3)
34 
35 #define COMP_E_INPUT0 (0x01)
36 #define COMP_E_INPUT1 (0x02)
37 #define COMP_E_INPUT2 (0x04)
38 #define COMP_E_INPUT3 (0x08)
39 #define COMP_E_INPUT4 (0x10)
40 #define COMP_E_INPUT5 (0x20)
41 #define COMP_E_INPUT6 (0x40)
42 #define COMP_E_INPUT7 (0x80)
43 #define COMP_E_INPUT8 (0x100)
44 #define COMP_E_INPUT9 (0x200)
45 #define COMP_E_INPUT10 (0x400)
46 #define COMP_E_INPUT11 (0x800)
47 #define COMP_E_INPUT12 (0x1000)
48 #define COMP_E_INPUT13 (0x2000)
49 #define COMP_E_INPUT14 (0x4000)
50 #define COMP_E_INPUT15 (0x8000)
51 #define COMP_E_VREF (0x9F)
52 
53 #define COMP_E_NORMALOUTPUTPOLARITY (!(COMP_E_CTL1_OUTPOL))
54 #define COMP_E_INVERTEDOUTPUTPOLARITY (COMP_E_CTL1_OUTPOL)
55 
56 #define COMP_E_REFERENCE_AMPLIFIER_DISABLED (COMP_E_CTL2_CEREFL_0)
57 #define COMP_E_VREFBASE1_2V (COMP_E_CTL2_CEREFL_1)
58 #define COMP_E_VREFBASE2_0V (COMP_E_CTL2_CEREFL_2)
59 #define COMP_E_VREFBASE2_5V (COMP_E_CTL2_CEREFL_3)
60 
61 #define COMP_E_ACCURACY_STATIC (!COMP_E_CTL2_REFACC)
62 #define COMP_E_ACCURACY_CLOCKED (COMP_E_CTL2_REFACC)
63 
64 #define COMP_E_HIGH_SPEED_MODE (COMP_E_CTL1_PWRMD_0)
65 #define COMP_E_NORMAL_MODE (COMP_E_CTL1_PWRMD_1)
66 #define COMP_E_ULTRA_LOW_POWER_MODE (COMP_E_CTL1_PWRMD_2)
67 
68 #define COMP_E_OUTPUT_INTERRUPT (COMP_E_INT_IE)
69 #define COMP_E_INVERTED_POLARITY_INTERRUPT (COMP_E_INT_IIE)
70 #define COMP_E_READY_INTERRUPT (COMP_E_INT_RDYIE)
71 
72 #define COMP_E_OUTPUT_INTERRUPT_FLAG (COMP_E_INT_IFG)
73 #define COMP_E_INTERRUPT_FLAG_INVERTED_POLARITY (COMP_E_INT_IIFG)
74 #define COMP_E_INTERRUPT_FLAG_READY (COMP_E_INT_RDYIFG)
75 
76 #define COMP_E_FALLINGEDGE (!(COMP_E_CTL1_IES))
77 #define COMP_E_RISINGEDGE (COMP_E_CTL1_IES)
78 
79 #define COMP_E_LOW (0x0)
80 #define COMP_E_HIGH (COMP_E_CTL1_OUT)
81 
82 //*****************************************************************************
83 //
90 //
91 //*****************************************************************************
92 typedef struct _COMP_E_Config
93 {
94  uint_fast16_t positiveTerminalInput;
95  uint_fast16_t negativeTerminalInput;
97  uint_fast8_t invertedOutputPolarity;
98  uint_fast16_t powerMode;
100 
101 //*****************************************************************************
102 //
186 //
187 //*****************************************************************************
188 extern bool COMP_E_initModule(uint32_t comparator, const COMP_E_Config *config);
189 
190 //*****************************************************************************
191 //
221 //
222 //*****************************************************************************
223 extern void COMP_E_setReferenceVoltage(uint32_t comparator,
224  uint_fast16_t supplyVoltageReferenceBase,
225  uint_fast16_t lowerLimitSupplyVoltageFractionOf32,
226  uint_fast16_t upperLimitSupplyVoltageFractionOf32);
227 
228 //*****************************************************************************
229 //
247 //
248 //*****************************************************************************
249 extern void COMP_E_setReferenceAccuracy(uint32_t comparator,
250  uint_fast16_t referenceAccuracy);
251 
252 //*****************************************************************************
253 //
268 //
269 //*****************************************************************************
270 extern void COMP_E_setPowerMode(uint32_t comparator, uint_fast16_t powerMode);
271 
272 //*****************************************************************************
273 //
285 //
286 //*****************************************************************************
287 extern void COMP_E_enableModule(uint32_t comparator);
288 
289 //*****************************************************************************
290 //
303 //
304 //*****************************************************************************
305 extern void COMP_E_disableModule(uint32_t comparator);
306 
307 //*****************************************************************************
308 //
321 //
322 //*****************************************************************************
323 extern void COMP_E_shortInputs(uint32_t comparator);
324 
325 //*****************************************************************************
326 //
339 //
340 //*****************************************************************************
341 extern void COMP_E_unshortInputs(uint32_t comparator);
342 
343 //*****************************************************************************
344 //
380 //
381 //*****************************************************************************
382 extern void COMP_E_disableInputBuffer(uint32_t comparator,
383  uint_fast16_t inputPort);
384 
385 //*****************************************************************************
386 //
420 //
421 //*****************************************************************************
422 extern void COMP_E_enableInputBuffer(uint32_t comparator,
423  uint_fast16_t inputPort);
424 
425 //*****************************************************************************
426 //
441 //
442 //*****************************************************************************
443 extern void COMP_E_swapIO(uint32_t comparator);
444 
445 //*****************************************************************************
446 //
458 //
459 //*****************************************************************************
460 extern uint8_t COMP_E_outputValue(uint32_t comparator);
461 
462 //*****************************************************************************
463 //
484 //
485 //*****************************************************************************
486 extern void COMP_E_enableInterrupt(uint32_t comparator, uint_fast16_t mask);
487 
488 //*****************************************************************************
489 //
508 //
509 //*****************************************************************************
510 extern void COMP_E_disableInterrupt(uint32_t comparator, uint_fast16_t mask);
511 
512 //*****************************************************************************
513 //
532 //
533 //*****************************************************************************
534 extern void COMP_E_clearInterruptFlag(uint32_t comparator, uint_fast16_t mask);
535 
536 //*****************************************************************************
537 //
549 //
550 //*****************************************************************************
551 extern uint_fast16_t COMP_E_getInterruptStatus(uint32_t comparator);
552 
553 //*****************************************************************************
554 //
572 //
573 //*****************************************************************************
574 extern uint_fast16_t COMP_E_getEnabledInterruptStatus(uint32_t comparator);
575 
576 //*****************************************************************************
577 //
602 //
603 //*****************************************************************************
604 extern void COMP_E_setInterruptEdgeDirection(uint32_t comparator,
605  uint_fast8_t edgeDirection);
606 
607 //*****************************************************************************
608 //
624 //
625 //*****************************************************************************
626 extern void COMP_E_toggleInterruptEdgeDirection(uint32_t comparator);
627 
628 //*****************************************************************************
629 //
647 //
648 //*****************************************************************************
649 extern void COMP_E_registerInterrupt(uint32_t comparator,
650  void (*intHandler)(void));
651 
652 //*****************************************************************************
653 //
669 //
670 //*****************************************************************************
671 extern void COMP_E_unregisterInterrupt(uint32_t comparator);
672 
673 /* Backwards Compatibility Layer */
674 #define COMP_E_enable(a) COMP_E_enableModule(a)
675 #define COMP_E_disable(a) COMP_E_disableModule(a)
676 #define COMP_E_IOSwap(a) COMP_E_swapIO(a)
677 #define COMP_E_interruptToggleEdgeDirection(a) COMP_E_toggleInterruptEdgeDirection(a)
678 #define COMP_E_clearInterrupt(a,b) COMP_E_clearInterruptFlag(a,b)
679 
680 //*****************************************************************************
681 //
682 // Mark the end of the C bindings section for C++ compilers.
683 //
684 //*****************************************************************************
685 #ifdef __cplusplus
686 }
687 #endif
688 
689 //*****************************************************************************
690 //
691 // Close the Doxygen group.
693 //
694 //*****************************************************************************
695 
696 
697 #endif /* COMP_E_H_ */
void COMP_E_clearInterruptFlag(uint32_t comparator, uint_fast16_t mask)
Definition: comp_e.c:219
uint_fast8_t outputFilterEnableAndDelayLevel
Definition: comp_e.h:96
void COMP_E_setReferenceAccuracy(uint32_t comparator, uint_fast16_t referenceAccuracy)
Definition: comp_e.c:138
void COMP_E_swapIO(uint32_t comparator)
Definition: comp_e.c:192
void COMP_E_enableInterrupt(uint32_t comparator, uint_fast16_t mask)
Definition: comp_e.c:202
void COMP_E_setInterruptEdgeDirection(uint32_t comparator, uint_fast8_t edgeDirection)
Definition: comp_e.c:231
void COMP_E_enableInputBuffer(uint32_t comparator, uint_fast16_t inputPort)
Definition: comp_e.c:185
void COMP_E_unshortInputs(uint32_t comparator)
Definition: comp_e.c:173
void COMP_E_disableModule(uint32_t comparator)
Definition: comp_e.c:163
void COMP_E_unregisterInterrupt(uint32_t comparator)
Definition: comp_e.c:265
struct _COMP_E_Config COMP_E_Config
Type definition for _COMP_E_Config structure.
Definition: comp_e.h:92
uint8_t COMP_E_outputValue(uint32_t comparator)
Definition: comp_e.c:197
uint_fast16_t COMP_E_getInterruptStatus(uint32_t comparator)
Definition: comp_e.c:224
uint_fast16_t positiveTerminalInput
Definition: comp_e.h:94
uint_fast16_t powerMode
Definition: comp_e.h:98
void COMP_E_toggleInterruptEdgeDirection(uint32_t comparator)
Definition: comp_e.c:243
void COMP_E_setReferenceVoltage(uint32_t comparator, uint_fast16_t supplyVoltageReferenceBase, uint_fast16_t lowerLimitSupplyVoltageFractionOf32, uint_fast16_t upperLimitSupplyVoltageFractionOf32)
Definition: comp_e.c:106
uint_fast16_t COMP_E_getEnabledInterruptStatus(uint32_t comparator)
Definition: comp_e.c:208
bool COMP_E_initModule(uint32_t comparator, const COMP_E_Config *config)
Definition: comp_e.c:50
void COMP_E_enableModule(uint32_t comparator)
Definition: comp_e.c:158
void COMP_E_disableInputBuffer(uint32_t comparator, uint_fast16_t inputPort)
Definition: comp_e.c:178
void COMP_E_registerInterrupt(uint32_t comparator, void(*intHandler)(void))
Definition: comp_e.c:248
uint_fast8_t invertedOutputPolarity
Definition: comp_e.h:97
void COMP_E_disableInterrupt(uint32_t comparator, uint_fast16_t mask)
Definition: comp_e.c:214
void COMP_E_shortInputs(uint32_t comparator)
Definition: comp_e.c:168
void COMP_E_setPowerMode(uint32_t comparator, uint_fast16_t powerMode)
Definition: comp_e.c:152
uint_fast16_t negativeTerminalInput
Definition: comp_e.h:95

Copyright 2016, Texas Instruments Incorporated