cs.h
Go to the documentation of this file.
1 #ifndef __CS_H__
2 #define __CS_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 "register_remap.h"
24 #include <stdbool.h>
25 #include <msp432.h>
26 
27 //*****************************************************************************
28 //
29 // Control specific variables
30 //
31 //*****************************************************************************
32 #define CS_CLOCK_DIVIDER_1 CS_CTL1_DIVS__0
33 #define CS_CLOCK_DIVIDER_2 CS_CTL1_DIVS__1
34 #define CS_CLOCK_DIVIDER_4 CS_CTL1_DIVS__2
35 #define CS_CLOCK_DIVIDER_8 CS_CTL1_DIVS__3
36 #define CS_CLOCK_DIVIDER_16 CS_CTL1_DIVS__4
37 #define CS_CLOCK_DIVIDER_32 CS_CTL1_DIVS__5
38 #define CS_CLOCK_DIVIDER_64 CS_CTL1_DIVS__6
39 #define CS_CLOCK_DIVIDER_128 CS_CTL1_DIVS__7
40 
41 #define CS_LFXTCLK_SELECT CS_CTL1_SELM__0
42 #define CS_HFXTCLK_SELECT CS_CTL1_SELM__5
43 #define CS_VLOCLK_SELECT CS_CTL1_SELM__1
44 #define CS_REFOCLK_SELECT CS_CTL1_SELM__2
45 #define CS_DCOCLK_SELECT CS_CTL1_SELM__3
46 #define CS_MODOSC_SELECT CS_CTL1_SELM__4
47 
48 #define CS_KEY 0x695A
49 
50 /* Number of positions to shift for divider calculation */
51 #define CS_ACLK_DIV_BITPOS 0x04
52 #define CS_MCLK_DIV_BITPOS 0x0C
53 #define CS_SMCLK_DIV_BITPOS 0x00
54 #define CS_HSMCLK_DIV_BITPOS 0x08
55 
56 /* Number of positions to shift for source calculation */
57 #define CS_ACLK_SRC_BITPOS 0x08
58 #define CS_MCLK_SRC_BITPOS 0x00
59 #define CS_SMCLK_SRC_BITPOS 0x04
60 #define CS_HSMCLK_SRC_BITPOS 0x04
61 
62 /* REFO Clock Values */
63 #define CS_REFO_32KHZ 0x00
64 #define CS_REFO_128KHZ 0x01
65 
66 /* Frequency Values */
67 #define CS_VLOCLK_FREQUENCY 10000
68 #define CS_MODCLK_FREQUENCY 24000000
69 
70 /* Interrupts */
71 #define CS_LFXT_FAULT CS_IE_LFXTIE
72 #define CS_HFXT_FAULT CS_IE_HFXTIE
73 #define CS_DCOMIN_FAULT CS_IE_DCOMINIE
74 #define CS_DCOMAX_FAULT CS_IE_DCOMAXIE
75 #define CS_DCORESISTOR_FAULT CS_IE_DCORIE
76 #define CS_STARTCOUNT_LFXT_FAULT CS_IE_FCNTLFIE
77 #define CS_STARTCOUNT_HFXT_FAULT CS_IE_FCNTHFIE
78 #define CS_PLL_OUTOFLOCK CS_IE_PLLOOLIE
79 #define CS_PLL_OUTOFSIGNAL CS_IE_PLLLOSIE
80 #define CS_PLL_OUTOFRANGE CS_IE_PLLOORIE
81 #define CS_REFCNT_PERIOD_COUNTER CS_IE_CALIE
82 
83 #define CS_HFXT_DRIVE0 CS_CTL2_HFXTDRIVE__0
84 #define CS_HFXT_DRIVE1 CS_CTL2_HFXTDRIVE__1
85 #define CS_HFXT_BYPASS CS_CTL2_HFXTBYPASS
86 
87 #define CS_LFXT_DRIVE0 CS_CTL2_LFXTDRIVE__0
88 #define CS_LFXT_DRIVE1 CS_CTL2_LFXTDRIVE__1
89 #define CS_LFXT_DRIVE2 CS_CTL2_LFXTDRIVE__2
90 #define CS_LFXT_DRIVE3 CS_CTL2_LFXTDRIVE__3
91 #define CS_LFXT_BYPASS CS_CTL2_LFXTBYPASS
92 
93 #define CS_ACLK CS_CLKEN_ACLK_EN
94 #define CS_MCLK CS_CLKEN_MCLK_EN
95 #define CS_SMCLK CS_CLKEN_SMCLK_EN
96 #define CS_HSMCLK CS_CLKEN_HSMCLK_EN
97 #define CS_BCLK CS_STAT_BCLK_READY
98 
99 #define CS_LFXTCLK 0x01
100 
101 #define CS_1MHZ 1000000
102 #define CS_15MHZ 1500000
103 #define CS_3MHZ 3000000
104 #define CS_4MHZ 4000000
105 #define CS_6MHZ 6000000
106 #define CS_8MHZ 8000000
107 #define CS_12MHZ 12000000
108 #define CS_16MHZ 16000000
109 #define CS_24MHZ 24000000
110 #define CS_32MHZ 32000000
111 #define CS_40MHZ 40000000
112 #define CS_48MHZ 48000000
113 
114 #define CS_DCO_FREQUENCY_1_5 CS_CTL0_DCORSEL__0
115 #define CS_DCO_FREQUENCY_3 CS_CTL0_DCORSEL__1
116 #define CS_DCO_FREQUENCY_6 CS_CTL0_DCORSEL__2
117 #define CS_DCO_FREQUENCY_12 CS_CTL0_DCORSEL__3
118 #define CS_DCO_FREQUENCY_24 CS_CTL0_DCORSEL__4
119 #define CS_DCO_FREQUENCY_48 CS_CTL0_DCORSEL__5
120 
121 #define CS_HFXT_FAULT_COUNTER 0x01
122 #define CS_LFXT_FAULT_COUNTER 0x02
123 
124 #define CS_FAULT_COUNTER_4096_CYCLES CS_CTL3_FCNTLF__0
125 #define CS_FAULT_COUNTER_8192_CYCLES CS_CTL3_FCNTLF__1
126 #define CS_FAULT_COUNTER_16384_CYCLES CS_CTL3_FCNTLF__2
127 #define CS_FAULT_COUNTER_32768_CYCLES CS_CTL3_FCNTLF__3
128 
129 //******************************************************************************
130 //
141 //
142 //******************************************************************************
143 extern void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency,
144  uint32_t hfxt_XT_CLK_frequency);
145 
146 //******************************************************************************
147 //
186 //
187 //******************************************************************************
188 extern void CS_initClockSignal(uint32_t selectedClockSignal,
189  uint32_t clockSource, uint32_t clockSourceDivider);
190 
191 //******************************************************************************
192 //
205 //
206 //******************************************************************************
207 extern void CS_startHFXT(bool bypassMode);
208 
209 //******************************************************************************
210 //
226 //
227 //******************************************************************************
228 extern void CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout);
229 
230 //******************************************************************************
231 //
253 //
254 //******************************************************************************
255 extern void CS_startLFXT(uint32_t xtDrive);
256 
257 //******************************************************************************
258 //
288 //
289 //******************************************************************************
290 extern void CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout);
291 
292 //******************************************************************************
293 //
301 //
302 //******************************************************************************
303 extern void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency);
304 
305 //******************************************************************************
306 //
317 //
318 //******************************************************************************
319 extern void CS_enableClockRequest(uint32_t selectClock);
320 
321 //******************************************************************************
322 //
333 //
334 //******************************************************************************
335 extern void CS_disableClockRequest(uint32_t selectClock);
336 
337 //******************************************************************************
338 //
347 //
348 //******************************************************************************
349 extern uint32_t CS_getACLK(void);
350 
351 //******************************************************************************
352 //
361 //
362 //******************************************************************************
363 extern uint32_t CS_getSMCLK(void);
364 
365 //******************************************************************************
366 //
375 //
376 //******************************************************************************
377 extern uint32_t CS_getMCLK(void);
378 
379 //******************************************************************************
380 //
389 //
390 //******************************************************************************
391 extern uint32_t CS_getBCLK(void);
392 
393 //******************************************************************************
394 //
403 //
404 //******************************************************************************
405 extern uint32_t CS_getHSMCLK(void);
406 
407 //******************************************************************************
408 //
423 //
424 //******************************************************************************
425 extern void CS_setDCOCenteredFrequency(uint32_t dcoFreq);
426 
427 //******************************************************************************
428 //
445 //
446 //******************************************************************************
447 extern void CS_tuneDCOFrequency(int16_t tuneParameter);
448 
449 //******************************************************************************
450 //
454 //
455 //******************************************************************************
456 extern void CS_enableDCOExternalResistor(void);
457 
458 //******************************************************************************
459 //
463 //
464 //******************************************************************************
465 extern void CS_disableDCOExternalResistor(void);
466 
467 //******************************************************************************
468 //
477 //
478 //******************************************************************************
479 extern void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData);
480 
481 //******************************************************************************
482 //
494 //
495 //******************************************************************************
496 extern uint32_t CS_getDCOFrequency(void);
497 
498 //******************************************************************************
499 //
521 //
522 //******************************************************************************
523 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
524 
525 //******************************************************************************
526 //
535 //
536 //******************************************************************************
537 extern void CS_enableFaultCounter(uint_fast8_t counterSelect);
538 
539 //******************************************************************************
540 //
549 //
550 //******************************************************************************
551 extern void CS_disableFaultCounter(uint_fast8_t counterSelect);
552 
553 //******************************************************************************
554 //
563 //
564 //******************************************************************************
565 extern void CS_resetFaultCounter(uint_fast8_t counterSelect);
566 
567 //******************************************************************************
568 //
582 //
583 //******************************************************************************
584 extern void CS_startFaultCounter(uint_fast8_t counterSelect,
585  uint_fast8_t countValue);
586 
587 //*****************************************************************************
588 //
614 //
615 //*****************************************************************************
616 extern void CS_enableInterrupt(uint32_t flags);
617 
618 //*****************************************************************************
619 //
641 //
642 //*****************************************************************************
643 extern void CS_disableInterrupt(uint32_t flags);
644 
645 //*****************************************************************************
646 //
667 //
668 //*****************************************************************************
669 extern uint32_t CS_getEnabledInterruptStatus(void);
670 
671 //*****************************************************************************
672 //
691 //
692 //*****************************************************************************
693 extern uint32_t CS_getInterruptStatus(void);
694 
695 //*****************************************************************************
696 //
731 //
732 //*****************************************************************************
733 extern void CS_clearInterruptFlag(uint32_t flags);
734 
735 //*****************************************************************************
736 //
754 //
755 //*****************************************************************************
756 extern void CS_registerInterrupt(void (*intHandler)(void));
757 
758 //*****************************************************************************
759 //
770 //
771 //*****************************************************************************
772 extern void CS_unregisterInterrupt(void);
773 
774 //*****************************************************************************
775 //
776 // Mark the end of the C bindings section for C++ compilers.
777 //
778 //*****************************************************************************
779 #ifdef __cplusplus
780 }
781 #endif
782 
783 //*****************************************************************************
784 //
785 // Close the Doxygen group.
787 //
788 //*****************************************************************************
789 
790 #endif
uint32_t CS_getHSMCLK(void)
Definition: cs.c:615
void CS_initClockSignal(uint32_t selectedClockSignal, uint32_t clockSource, uint32_t clockSourceDivider)
Definition: cs.c:178
uint32_t CS_getACLK(void)
Definition: cs.c:625
void CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout)
Definition: cs.c:306
void CS_enableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:656
void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency, uint32_t hfxt_XT_CLK_frequency)
Definition: cs.c:171
void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency)
Definition: cs.c:452
void CS_enableInterrupt(uint32_t flags)
Definition: cs.c:741
void CS_disableDCOExternalResistor(void)
Definition: cs.c:483
void CS_enableDCOExternalResistor(void)
Definition: cs.c:467
void CS_clearInterruptFlag(uint32_t flags)
Definition: cs.c:773
void CS_unregisterInterrupt(void)
Definition: cs.c:797
uint32_t CS_getInterruptStatus(void)
Definition: cs.c:763
void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData)
Definition: cs.c:478
uint32_t CS_getBCLK(void)
Definition: cs.c:607
void CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout)
Definition: cs.c:367
void CS_registerInterrupt(void(*intHandler)(void))
Definition: cs.c:784
void CS_enableClockRequest(uint32_t selectClock)
Definition: cs.c:422
void CS_startFaultCounter(uint_fast8_t counterSelect, uint_fast8_t countValue)
Definition: cs.c:716
void CS_disableInterrupt(uint32_t flags)
Definition: cs.c:752
uint32_t CS_getMCLK(void)
Definition: cs.c:646
void CS_setDCOFrequency(uint32_t dcoFrequency)
void CS_setDCOCenteredFrequency(uint32_t dcoFreq)
Definition: cs.c:494
uint32_t CS_getEnabledInterruptStatus(void)
Definition: cs.c:768
void CS_startHFXT(bool bypassMode)
Definition: cs.c:301
void CS_disableClockRequest(uint32_t selectClock)
Definition: cs.c:437
void CS_resetFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:696
uint32_t CS_getDCOFrequency(void)
Definition: cs.c:523
void CS_startLFXT(uint32_t xtDrive)
Definition: cs.c:362
void CS_tuneDCOFrequency(int16_t tuneParameter)
uint32_t CS_getSMCLK(void)
Definition: cs.c:635
void CS_disableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:676

Copyright 2014, Texas Instruments Incorporated