2020-2021 Sunseeker Telemetry and Lighting System
ucs.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // ucs.h - Driver for the UCS Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_UCS_H__
8 #define __MSP430WARE_UCS_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #if defined(__MSP430_HAS_UCS__) || defined(__MSP430_HAS_UCS_RF__)
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 //*****************************************************************************
26 //
27 // Internal very low power VLOCLK, low frequency oscillator with 10 kHz typical
28 // frequency
29 //
30 //*****************************************************************************
31 #define UCS_VLOCLK_FREQUENCY 10000
32 
33 //*****************************************************************************
34 //
35 // Internal, trimmed, low-frequency oscillator with 32768 Hz typical frequency
36 //
37 //*****************************************************************************
38 #define UCS_REFOCLK_FREQUENCY 32768
39 
40 //*****************************************************************************
41 //
42 // The following are values that can be passed to the clockSourceDivider
43 // parameter for functions: UCS_initClockSignal().
44 //
45 //*****************************************************************************
46 #define UCS_CLOCK_DIVIDER_1 DIVM__1
47 #define UCS_CLOCK_DIVIDER_2 DIVM__2
48 #define UCS_CLOCK_DIVIDER_4 DIVM__4
49 #define UCS_CLOCK_DIVIDER_8 DIVM__8
50 #define UCS_CLOCK_DIVIDER_12 DIVM__32
51 #define UCS_CLOCK_DIVIDER_16 DIVM__16
52 #define UCS_CLOCK_DIVIDER_32 DIVM__32
53 
54 //*****************************************************************************
55 //
56 // The following are values that can be passed to the selectedClockSignal
57 // parameter for functions: UCS_initClockSignal().
58 //
59 //*****************************************************************************
60 #define UCS_ACLK 0x01
61 #define UCS_MCLK 0x02
62 #define UCS_SMCLK 0x04
63 #define UCS_FLLREF 0x08
64 
65 //*****************************************************************************
66 //
67 // The following are values that can be passed to the clockSource parameter for
68 // functions: UCS_initClockSignal().
69 //
70 //*****************************************************************************
71 #define UCS_XT1CLK_SELECT SELM__XT1CLK
72 #define UCS_VLOCLK_SELECT SELM__VLOCLK
73 #define UCS_REFOCLK_SELECT SELM__REFOCLK
74 #define UCS_DCOCLK_SELECT SELM__DCOCLK
75 #define UCS_DCOCLKDIV_SELECT SELM__DCOCLKDIV
76 #define UCS_XT2CLK_SELECT SELM__XT2CLK
77 
78 //*****************************************************************************
79 //
80 // The following are values that can be passed to the xcap parameter for
81 // functions: UCS_turnOnLFXT1(), and UCS_turnOnLFXT1WithTimeout().
82 //
83 //*****************************************************************************
84 #define UCS_XCAP_0 XCAP_0
85 #define UCS_XCAP_1 XCAP_1
86 #define UCS_XCAP_2 XCAP_2
87 #define UCS_XCAP_3 XCAP_3
88 
89 //*****************************************************************************
90 //
91 // The following are values that can be passed to the xt1drive parameter for
92 // functions: UCS_turnOnLFXT1(), UCS_turnOnHFXT1(),
93 // UCS_turnOnLFXT1WithTimeout(), and UCS_turnOnHFXT1WithTimeout().
94 //
95 //*****************************************************************************
96 #define UCS_XT1_DRIVE_0 XT1DRIVE_0
97 #define UCS_XT1_DRIVE_1 XT1DRIVE_1
98 #define UCS_XT1_DRIVE_2 XT1DRIVE_2
99 #define UCS_XT1_DRIVE_3 XT1DRIVE_3
100 
101 //*****************************************************************************
102 //
103 // The following are values that can be passed to the highOrLowFrequency
104 // parameter for functions: UCS_bypassXT1(), and UCS_bypassXT1WithTimeout().
105 //
106 //*****************************************************************************
107 #define UCS_XT1_HIGH_FREQUENCY XTS
108 #define UCS_XT1_LOW_FREQUENCY 0x00
109 
110 //*****************************************************************************
111 //
112 // The following are values that can be passed to the xt2drive parameter for
113 // functions: UCS_turnOnXT2(), and UCS_turnOnXT2WithTimeout().
114 //
115 //*****************************************************************************
116 #define UCS_XT2_DRIVE_4MHZ_8MHZ XT2DRIVE_0
117 #define UCS_XT2_DRIVE_8MHZ_16MHZ XT2DRIVE_1
118 #define UCS_XT2_DRIVE_16MHZ_24MHZ XT2DRIVE_2
119 #define UCS_XT2_DRIVE_24MHZ_32MHZ XT2DRIVE_3
120 
121 //*****************************************************************************
122 //
123 // The following are values that can be passed to the selectClock parameter for
124 // functions: UCS_enableClockRequest(), and UCS_disableClockRequest().
125 //
126 //*****************************************************************************
127 #define UCS_ACLK 0x01
128 #define UCS_SMCLK 0x04
129 #define UCS_MCLK 0x02
130 #define UCS_MODOSC MODOSCREQEN
131 
132 //*****************************************************************************
133 //
134 // The following are values that can be passed to the mask parameter for
135 // functions: UCS_getFaultFlagStatus(), and UCS_clearFaultFlag() as well as
136 // returned by the UCS_clearAllOscFlagsWithTimeout() function.
137 //
138 //*****************************************************************************
139 #define UCS_XT2OFFG XT2OFFG
140 #define UCS_XT1HFOFFG XT1HFOFFG
141 #define UCS_XT1LFOFFG XT1LFOFFG
142 #define UCS_DCOFFG DCOFFG
143 
144 //*****************************************************************************
145 //
146 // Prototypes for the APIs.
147 //
148 //*****************************************************************************
149 
150 //*****************************************************************************
151 //
164 //
165 //*****************************************************************************
166 extern void UCS_setExternalClockSource(uint32_t XT1CLK_frequency,
167  uint32_t XT2CLK_frequency);
168 
169 //*****************************************************************************
170 //
208 //
209 //*****************************************************************************
210 extern void UCS_initClockSignal(uint8_t selectedClockSignal,
211  uint16_t clockSource,
212  uint16_t clockSourceDivider);
213 
214 //*****************************************************************************
215 //
246 //
247 //*****************************************************************************
248 extern void UCS_turnOnLFXT1(uint16_t xt1drive,
249  uint8_t xcap);
250 
251 //*****************************************************************************
252 //
271 //
272 //*****************************************************************************
273 extern void UCS_turnOnHFXT1(uint16_t xt1drive);
274 
275 //*****************************************************************************
276 //
292 //
293 //*****************************************************************************
294 extern void UCS_bypassXT1(uint8_t highOrLowFrequency);
295 
296 //*****************************************************************************
297 //
332 //
333 //*****************************************************************************
334 extern bool UCS_turnOnLFXT1WithTimeout(uint16_t xt1drive,
335  uint8_t xcap,
336  uint16_t timeout);
337 
338 //*****************************************************************************
339 //
362 //
363 //*****************************************************************************
364 extern bool UCS_turnOnHFXT1WithTimeout(uint16_t xt1drive,
365  uint16_t timeout);
366 
367 //*****************************************************************************
368 //
387 //
388 //*****************************************************************************
389 extern bool UCS_bypassXT1WithTimeout(uint8_t highOrLowFrequency,
390  uint16_t timeout);
391 
392 //*****************************************************************************
393 //
398 //
399 //*****************************************************************************
400 extern void UCS_turnOffXT1(void);
401 
402 //*****************************************************************************
403 //
423 //
424 //*****************************************************************************
425 extern void UCS_turnOnXT2(uint16_t xt2drive);
426 
427 //*****************************************************************************
428 //
440 //
441 //*****************************************************************************
442 extern void UCS_bypassXT2(void);
443 
444 //*****************************************************************************
445 //
468 //
469 //*****************************************************************************
470 extern bool UCS_turnOnXT2WithTimeout(uint16_t xt2drive,
471  uint16_t timeout);
472 
473 //*****************************************************************************
474 //
488 //
489 //*****************************************************************************
490 extern bool UCS_bypassXT2WithTimeout(uint16_t timeout);
491 
492 //*****************************************************************************
493 //
500 //
501 //*****************************************************************************
502 extern void UCS_turnOffXT2(void);
503 
504 //*****************************************************************************
505 //
528 //
529 //*****************************************************************************
530 extern void UCS_initFLLSettle(uint16_t fsystem,
531  uint16_t ratio);
532 
533 //*****************************************************************************
534 //
555 //
556 //*****************************************************************************
557 extern void UCS_initFLL(uint16_t fsystem,
558  uint16_t ratio);
559 
560 //*****************************************************************************
561 //
574 //
575 //*****************************************************************************
576 extern void UCS_enableClockRequest(uint8_t selectClock);
577 
578 //*****************************************************************************
579 //
592 //
593 //*****************************************************************************
594 extern void UCS_disableClockRequest(uint8_t selectClock);
595 
596 //*****************************************************************************
597 //
608 //
609 //*****************************************************************************
610 extern uint8_t UCS_getFaultFlagStatus(uint8_t mask);
611 
612 //*****************************************************************************
613 //
627 //
628 //*****************************************************************************
629 extern void UCS_clearFaultFlag(uint8_t mask);
630 
631 //*****************************************************************************
632 //
639 //
640 //*****************************************************************************
641 extern void UCS_turnOffSMCLK(void);
642 
643 //*****************************************************************************
644 //
651 //
652 //*****************************************************************************
653 extern void UCS_turnOnSMCLK(void);
654 
655 //*****************************************************************************
656 //
665 //
666 //*****************************************************************************
667 extern uint32_t UCS_getACLK(void);
668 
669 //*****************************************************************************
670 //
679 //
680 //*****************************************************************************
681 extern uint32_t UCS_getSMCLK(void);
682 
683 //*****************************************************************************
684 //
693 //
694 //*****************************************************************************
695 extern uint32_t UCS_getMCLK(void);
696 
697 //*****************************************************************************
698 //
710 //
711 //*****************************************************************************
712 extern uint16_t UCS_clearAllOscFlagsWithTimeout(uint16_t timeout);
713 
714 //*****************************************************************************
715 //
716 // Mark the end of the C bindings section for C++ compilers.
717 //
718 //*****************************************************************************
719 #ifdef __cplusplus
720 }
721 #endif
722 
723 #endif
724 #endif // __MSP430WARE_UCS_H__