2020-2021 Sunseeker Telemetry and Lighting System
comp_b.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // comp_b.h - Driver for the COMP_B Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_COMP_B_H__
8 #define __MSP430WARE_COMP_B_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_COMPB__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
29 //
30 //*****************************************************************************
31 typedef struct Comp_B_initParam {
51  uint8_t positiveTerminalInput;
71  uint8_t negativeTerminalInput;
77  uint16_t powerModeSelect;
87  uint8_t outputFilterEnableAndDelayLevel;
92  uint16_t invertedOutputPolarity;
93 } Comp_B_initParam;
94 
95 //*****************************************************************************
96 //
99 //
100 //*****************************************************************************
101 typedef struct Comp_B_configureReferenceVoltageParam {
109  uint16_t supplyVoltageReferenceBase;
112  uint16_t lowerLimitSupplyVoltageFractionOf32;
115  uint16_t upperLimitSupplyVoltageFractionOf32;
121  uint16_t referenceAccuracy;
122 } Comp_B_configureReferenceVoltageParam;
123 
124 
125 //*****************************************************************************
126 //
127 // The following are values that can be passed to the powerModeSelect parameter
128 // for functions: Comp_B_init(); the param parameter for functions:
129 // Comp_B_init().
130 //
131 //*****************************************************************************
132 #define COMP_B_POWERMODE_HIGHSPEED (CBPWRMD_0)
133 #define COMP_B_POWERMODE_NORMALMODE (CBPWRMD_1)
134 #define COMP_B_POWERMODE_ULTRALOWPOWER (CBPWRMD_2)
135 
136 //*****************************************************************************
137 //
138 // The following are values that can be passed to the positiveTerminalInput
139 // parameter for functions: Comp_B_init(); the inputPort parameter for
140 // functions: Comp_B_disableInputBuffer(), and Comp_B_enableInputBuffer(); the
141 // param parameter for functions: Comp_B_init(), and Comp_B_init(); the
142 // negativeTerminalInput parameter for functions: Comp_B_init().
143 //
144 //*****************************************************************************
145 #define COMP_B_INPUT0 (CBIPSEL_0)
146 #define COMP_B_INPUT1 (CBIPSEL_1)
147 #define COMP_B_INPUT2 (CBIPSEL_2)
148 #define COMP_B_INPUT3 (CBIPSEL_3)
149 #define COMP_B_INPUT4 (CBIPSEL_4)
150 #define COMP_B_INPUT5 (CBIPSEL_5)
151 #define COMP_B_INPUT6 (CBIPSEL_6)
152 #define COMP_B_INPUT7 (CBIPSEL_7)
153 #define COMP_B_INPUT8 (CBIPSEL_8)
154 #define COMP_B_INPUT9 (CBIPSEL_9)
155 #define COMP_B_INPUT10 (CBIPSEL_10)
156 #define COMP_B_INPUT11 (CBIPSEL_11)
157 #define COMP_B_INPUT12 (CBIPSEL_12)
158 #define COMP_B_INPUT13 (CBIPSEL_13)
159 #define COMP_B_INPUT14 (CBIPSEL_14)
160 #define COMP_B_INPUT15 (CBIPSEL_15)
161 #define COMP_B_VREF (0x10)
162 
163 //*****************************************************************************
164 //
165 // The following are values that can be passed to the
166 // outputFilterEnableAndDelayLevel parameter for functions: Comp_B_init(); the
167 // param parameter for functions: Comp_B_init().
168 //
169 //*****************************************************************************
170 #define COMP_B_FILTEROUTPUT_OFF 0x00
171 #define COMP_B_FILTEROUTPUT_DLYLVL1 (CBF + CBFDLY_0)
172 #define COMP_B_FILTEROUTPUT_DLYLVL2 (CBF + CBFDLY_1)
173 #define COMP_B_FILTEROUTPUT_DLYLVL3 (CBF + CBFDLY_2)
174 #define COMP_B_FILTEROUTPUT_DLYLVL4 (CBF + CBFDLY_3)
175 
176 //*****************************************************************************
177 //
178 // The following are values that can be passed to the invertedOutputPolarity
179 // parameter for functions: Comp_B_init(); the param parameter for functions:
180 // Comp_B_init().
181 //
182 //*****************************************************************************
183 #define COMP_B_NORMALOUTPUTPOLARITY (!(CBOUTPOL))
184 #define COMP_B_INVERTEDOUTPUTPOLARITY (CBOUTPOL)
185 
186 //*****************************************************************************
187 //
188 // The following are values that can be passed to the param parameter for
189 // functions: Comp_B_configureReferenceVoltage().
190 //
191 //*****************************************************************************
192 #define COMP_B_ACCURACY_STATIC (!CBREFACC)
193 #define COMP_B_ACCURACY_CLOCKED (CBREFACC)
194 
195 //*****************************************************************************
196 //
197 // The following are values that can be passed to the param parameter for
198 // functions: Comp_B_configureReferenceVoltage().
199 //
200 //*****************************************************************************
201 #define COMP_B_VREFBASE_VCC (CBREFL_0)
202 #define COMP_B_VREFBASE1_5V (CBREFL_1)
203 #define COMP_B_VREFBASE2_0V (CBREFL_2)
204 #define COMP_B_VREFBASE2_5V (CBREFL_3)
205 
206 //*****************************************************************************
207 //
208 // The following are values that can be passed to the interruptMask parameter
209 // for functions: Comp_B_enableInterrupt(), and Comp_B_disableInterrupt().
210 //
211 //*****************************************************************************
212 #define COMP_B_OUTPUT_INT CBIE
213 #define COMP_B_OUTPUTINVERTED_INT CBIIE
214 
215 //*****************************************************************************
216 //
217 // The following are values that can be passed to the interruptFlagMask
218 // parameter for functions: Comp_B_clearInterrupt(), and
219 // Comp_B_getInterruptStatus() as well as returned by the
220 // Comp_B_getInterruptStatus() function.
221 //
222 //*****************************************************************************
223 #define COMP_B_OUTPUT_FLAG CBIFG
224 #define COMP_B_OUTPUTINVERTED_FLAG CBIIFG
225 
226 //*****************************************************************************
227 //
228 // The following are values that can be passed to the edgeDirection parameter
229 // for functions: Comp_B_setInterruptEdgeDirection().
230 //
231 //*****************************************************************************
232 #define COMP_B_RISINGEDGE (!(CBIES))
233 #define COMP_B_FALLINGEDGE (CBIES)
234 
235 //*****************************************************************************
236 //
237 // The following are values that can be passed toThe following are values that
238 // can be returned by the Comp_B_outputValue() function.
239 //
240 //*****************************************************************************
241 #define COMP_B_LOW (0x0)
242 #define COMP_B_HIGH (CBOUT)
243 
244 //*****************************************************************************
245 //
246 // The following are values that can be passed to the selectType parameter for
247 // functions: Comp_B_selectReferenceVoltage().
248 //
249 //*****************************************************************************
250 #define COMP_B_VREF_AUTO_SELECT 0x0000
251 #define COMP_B_VREF_MANUAL_SELECT CBMRVS
252 
253 //*****************************************************************************
254 //
255 // The following are values that can be passed to the selectVRef parameter for
256 // functions: Comp_B_selectReferenceVoltage().
257 //
258 //*****************************************************************************
259 #define COMP_B_SELECT_VREF0 0x0000
260 #define COMP_B_SELECT_VREF1 CBMRVL
261 
262 //*****************************************************************************
263 //
264 // Prototypes for the APIs.
265 //
266 //*****************************************************************************
267 
268 //*****************************************************************************
269 //
283 //
284 //*****************************************************************************
285 extern bool Comp_B_init(uint16_t baseAddress,
286  Comp_B_initParam *param);
287 
288 //*****************************************************************************
289 //
303 //
304 //*****************************************************************************
305 extern void Comp_B_configureReferenceVoltage(uint16_t baseAddress,
306  Comp_B_configureReferenceVoltageParam *param);
307 
308 //*****************************************************************************
309 //
325 //
326 //*****************************************************************************
327 extern void Comp_B_enableInterrupt(uint16_t baseAddress,
328  uint16_t interruptMask);
329 
330 //*****************************************************************************
331 //
347 //
348 //*****************************************************************************
349 extern void Comp_B_disableInterrupt(uint16_t baseAddress,
350  uint16_t interruptMask);
351 
352 //*****************************************************************************
353 //
369 //
370 //*****************************************************************************
371 extern void Comp_B_clearInterrupt(uint16_t baseAddress,
372  uint16_t interruptFlagMask);
373 
374 //*****************************************************************************
375 //
392 //
393 //*****************************************************************************
394 extern uint8_t Comp_B_getInterruptStatus(uint16_t baseAddress,
395  uint16_t interruptFlagMask);
396 
397 //*****************************************************************************
398 //
420 //
421 //*****************************************************************************
422 extern void Comp_B_setInterruptEdgeDirection(uint16_t baseAddress,
423  uint16_t edgeDirection);
424 
425 //*****************************************************************************
426 //
437 //
438 //*****************************************************************************
439 extern void Comp_B_toggleInterruptEdgeDirection(uint16_t baseAddress);
440 
441 //*****************************************************************************
442 //
450 //
451 //*****************************************************************************
452 extern void Comp_B_enable(uint16_t baseAddress);
453 
454 //*****************************************************************************
455 //
464 //
465 //*****************************************************************************
466 extern void Comp_B_disable(uint16_t baseAddress);
467 
468 //*****************************************************************************
469 //
478 //
479 //*****************************************************************************
480 extern void Comp_B_shortInputs(uint16_t baseAddress);
481 
482 //*****************************************************************************
483 //
493 //
494 //*****************************************************************************
495 extern void Comp_B_unshortInputs(uint16_t baseAddress);
496 
497 //*****************************************************************************
498 //
532 //
533 //*****************************************************************************
534 extern void Comp_B_disableInputBuffer(uint16_t baseAddress,
535  uint8_t inputPort);
536 
537 //*****************************************************************************
538 //
570 //
571 //*****************************************************************************
572 extern void Comp_B_enableInputBuffer(uint16_t baseAddress,
573  uint8_t inputPort);
574 
575 //*****************************************************************************
576 //
588 //
589 //*****************************************************************************
590 extern void Comp_B_swapIO(uint16_t baseAddress);
591 
592 //*****************************************************************************
593 //
604 //
605 //*****************************************************************************
606 extern uint16_t Comp_B_outputValue(uint16_t baseAddress);
607 
608 //*****************************************************************************
609 //
633 //
634 //*****************************************************************************
635 extern void Comp_B_selectReferenceVoltage(uint16_t baseAddress,
636  uint16_t selectType,
637  uint16_t selectVRef);
638 
639 //*****************************************************************************
640 //
641 // Mark the end of the C bindings section for C++ compilers.
642 //
643 //*****************************************************************************
644 #ifdef __cplusplus
645 }
646 #endif
647 
648 #endif
649 #endif // __MSP430WARE_COMP_B_H__
MPU_initThreeSegmentsParam param