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 <stdbool.h>
24 #include <msp.h>
25 
26 //*****************************************************************************
27 //
28 // Control specific variables
29 //
30 //*****************************************************************************
31 #define CS_CLOCK_DIVIDER_1 CS_CTL1_DIVS_0
32 #define CS_CLOCK_DIVIDER_2 CS_CTL1_DIVS_1
33 #define CS_CLOCK_DIVIDER_4 CS_CTL1_DIVS_2
34 #define CS_CLOCK_DIVIDER_8 CS_CTL1_DIVS_3
35 #define CS_CLOCK_DIVIDER_16 CS_CTL1_DIVS_4
36 #define CS_CLOCK_DIVIDER_32 CS_CTL1_DIVS_5
37 #define CS_CLOCK_DIVIDER_64 CS_CTL1_DIVS_6
38 #define CS_CLOCK_DIVIDER_128 CS_CTL1_DIVS_7
39 
40 #define CS_LFXTCLK_SELECT CS_CTL1_SELM_0
41 #define CS_HFXTCLK_SELECT CS_CTL1_SELM_5
42 #define CS_VLOCLK_SELECT CS_CTL1_SELM_1
43 #define CS_REFOCLK_SELECT CS_CTL1_SELM_2
44 #define CS_DCOCLK_SELECT CS_CTL1_SELM_3
45 #define CS_MODOSC_SELECT CS_CTL1_SELM_4
46 
47 #define CS_KEY 0x695A
48 
49 /* Number of positions to shift for divider calculation */
50 #define CS_ACLK_DIV_BITPOS 0x04
51 #define CS_MCLK_DIV_BITPOS 0x0C
52 #define CS_SMCLK_DIV_BITPOS 0x00
53 #define CS_HSMCLK_DIV_BITPOS 0x08
54 
55 /* Number of positions to shift for source calculation */
56 #define CS_ACLK_SRC_BITPOS 0x08
57 #define CS_MCLK_SRC_BITPOS 0x00
58 #define CS_SMCLK_SRC_BITPOS 0x04
59 #define CS_HSMCLK_SRC_BITPOS 0x04
60 
61 /* REFO Clock Values */
62 #define CS_REFO_32KHZ 0x00
63 #define CS_REFO_128KHZ 0x01
64 
65 /* Frequency Values */
66 #define CS_VLOCLK_FREQUENCY 10000
67 #define CS_MODCLK_FREQUENCY 24000000
68 
69 /* Interrupts */
70 #define CS_LFXT_FAULT CS_IE_LFXTIE
71 #define CS_HFXT_FAULT CS_IE_HFXTIE
72 #define CS_DCO_OPEN_FAULT CS_IE_DCOR_OPNIE
73 #define CS_STARTCOUNT_LFXT_FAULT CS_IE_FCNTLFIE
74 #define CS_STARTCOUNT_HFXT_FAULT CS_IE_FCNTHFIE
75 #define CS_DCO_SHORT_FAULT CS_IFG_DCOR_SHTIFG
76 
77 #define CS_HFXT_DRIVE CS_CTL2_HFXTDRIVE
78 #define CS_HFXT_BYPASS CS_CTL2_HFXTBYPASS
79 
80 #define CS_LFXT_DRIVE0 CS_CTL2_LFXTDRIVE_0
81 #define CS_LFXT_DRIVE1 CS_CTL2_LFXTDRIVE_1
82 #define CS_LFXT_DRIVE2 CS_CTL2_LFXTDRIVE_2
83 #define CS_LFXT_DRIVE3 CS_CTL2_LFXTDRIVE_3
84 #define CS_LFXT_BYPASS CS_CTL2_LFXTBYPASS
85 
86 #define CS_ACLK CS_CLKEN_ACLK_EN
87 #define CS_MCLK CS_CLKEN_MCLK_EN
88 #define CS_SMCLK CS_CLKEN_SMCLK_EN
89 #define CS_HSMCLK CS_CLKEN_HSMCLK_EN
90 #define CS_BCLK CS_STAT_BCLK_READY
91 
92 #define CS_LFXTCLK 0x01
93 
94 #define CS_1MHZ 1000000
95 #define CS_15MHZ 1500000
96 #define CS_3MHZ 3000000
97 #define CS_4MHZ 4000000
98 #define CS_6MHZ 6000000
99 #define CS_8MHZ 8000000
100 #define CS_12MHZ 12000000
101 #define CS_16MHZ 16000000
102 #define CS_24MHZ 24000000
103 #define CS_32MHZ 32000000
104 #define CS_40MHZ 40000000
105 #define CS_48MHZ 48000000
106 
107 #define CS_DCO_FREQUENCY_1_5 CS_CTL0_DCORSEL_0
108 #define CS_DCO_FREQUENCY_3 CS_CTL0_DCORSEL_1
109 #define CS_DCO_FREQUENCY_6 CS_CTL0_DCORSEL_2
110 #define CS_DCO_FREQUENCY_12 CS_CTL0_DCORSEL_3
111 #define CS_DCO_FREQUENCY_24 CS_CTL0_DCORSEL_4
112 #define CS_DCO_FREQUENCY_48 CS_CTL0_DCORSEL_5
113 
114 #define CS_HFXT_FAULT_COUNTER 0x01
115 #define CS_LFXT_FAULT_COUNTER 0x02
116 
117 #define CS_FAULT_COUNTER_4096_CYCLES CS_CTL3_FCNTLF_0
118 #define CS_FAULT_COUNTER_8192_CYCLES CS_CTL3_FCNTLF_1
119 #define CS_FAULT_COUNTER_16384_CYCLES CS_CTL3_FCNTLF_2
120 #define CS_FAULT_COUNTER_32768_CYCLES CS_CTL3_FCNTLF_3
121 
122 #define CS_OVER32MHZ 0x01
123 #define CS_UNDER32MHZ 0x02
124 
125 /* Accounting for cross peripheral calls with predefines */
126 #ifndef __MCU_HAS_SYSCTL_A__
127 
128 #define SysCtl_A_getNMISourceStatus SysCtl_getNMISourceStatus
129 #define SysCtl_A_disableNMISource SysCtl_disableNMISource
130 #define SysCtl_A_getNMISourceStatus SysCtl_getNMISourceStatus
131 #define SysCtl_A_enableNMISource SysCtl_enableNMISource
132 #define SysCtl_A_getTLVInfo SysCtl_getTLVInfo
133 #define SYSCTL_A_CS_SRC SYSCTL_CS_SRC
134 #define SysCtl_A_CSCalTLV_Info SysCtl_CSCalTLV_Info
135 
136 #endif
137 
138 
139 //******************************************************************************
140 //
151 //
152 //******************************************************************************
153 extern void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency,
154  uint32_t hfxt_XT_CLK_frequency);
155 
156 //******************************************************************************
157 //
200 //
201 //******************************************************************************
202 extern void CS_initClockSignal(uint32_t selectedClockSignal,
203  uint32_t clockSource, uint32_t clockSourceDivider);
204 
205 //******************************************************************************
206 //
218 //
219 //******************************************************************************
220 extern bool CS_startHFXT(bool bypassMode);
221 
222 //******************************************************************************
223 //
239 //
240 //******************************************************************************
241 extern bool CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout);
242 
243 //******************************************************************************
244 //
265 //
266 //******************************************************************************
267 extern bool CS_startLFXT(uint32_t xtDrive);
268 
269 //******************************************************************************
270 //
296 //
297 //******************************************************************************
298 extern bool CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout);
299 
300 //******************************************************************************
301 //
309 //
310 //******************************************************************************
311 extern void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency);
312 
313 //******************************************************************************
314 //
325 //
326 //******************************************************************************
327 extern void CS_enableClockRequest(uint32_t selectClock);
328 
329 //******************************************************************************
330 //
341 //
342 //******************************************************************************
343 extern void CS_disableClockRequest(uint32_t selectClock);
344 
345 //******************************************************************************
346 //
355 //
356 //******************************************************************************
357 extern uint32_t CS_getACLK(void);
358 
359 //******************************************************************************
360 //
369 //
370 //******************************************************************************
371 extern uint32_t CS_getSMCLK(void);
372 
373 //******************************************************************************
374 //
383 //
384 //******************************************************************************
385 extern uint32_t CS_getMCLK(void);
386 
387 //******************************************************************************
388 //
397 //
398 //******************************************************************************
399 extern uint32_t CS_getBCLK(void);
400 
401 //******************************************************************************
402 //
411 //
412 //******************************************************************************
413 extern uint32_t CS_getHSMCLK(void);
414 
415 //******************************************************************************
416 //
431 //
432 //******************************************************************************
433 extern void CS_setDCOCenteredFrequency(uint32_t dcoFreq);
434 
435 //******************************************************************************
436 //
453 //
454 //******************************************************************************
455 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
456 
457 //******************************************************************************
458 //
475 //
476 //******************************************************************************
477 extern void CS_tuneDCOFrequency(int16_t tuneParameter);
478 
479 //******************************************************************************
480 //
484 //
485 //******************************************************************************
486 extern void CS_enableDCOExternalResistor(void);
487 
488 //******************************************************************************
489 //
493 //
494 //******************************************************************************
495 extern void CS_disableDCOExternalResistor(void);
496 
497 //******************************************************************************
498 //
511 //
512 //******************************************************************************
513 extern void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData,
514  uint_fast8_t freqRange);
515 
516 //******************************************************************************
517 //
529 //
530 //******************************************************************************
531 extern uint32_t CS_getDCOFrequency(void);
532 
533 //******************************************************************************
534 //
556 //
557 //******************************************************************************
558 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
559 
560 //******************************************************************************
561 //
570 //
571 //******************************************************************************
572 extern void CS_enableFaultCounter(uint_fast8_t counterSelect);
573 
574 //******************************************************************************
575 //
584 //
585 //******************************************************************************
586 extern void CS_disableFaultCounter(uint_fast8_t counterSelect);
587 
588 //******************************************************************************
589 //
598 //
599 //******************************************************************************
600 extern void CS_resetFaultCounter(uint_fast8_t counterSelect);
601 
602 //******************************************************************************
603 //
617 //
618 //******************************************************************************
619 extern void CS_startFaultCounter(uint_fast8_t counterSelect,
620  uint_fast8_t countValue);
621 
622 //*****************************************************************************
623 //
645 //
646 //*****************************************************************************
647 extern void CS_enableInterrupt(uint32_t flags);
648 
649 //*****************************************************************************
650 //
668 //
669 //*****************************************************************************
670 extern void CS_disableInterrupt(uint32_t flags);
671 
672 //*****************************************************************************
673 //
689 //
690 //*****************************************************************************
691 extern uint32_t CS_getEnabledInterruptStatus(void);
692 
693 //*****************************************************************************
694 //
708 //
709 //*****************************************************************************
710 extern uint32_t CS_getInterruptStatus(void);
711 
712 //*****************************************************************************
713 //
742 //
743 //*****************************************************************************
744 extern void CS_clearInterruptFlag(uint32_t flags);
745 
746 //*****************************************************************************
747 //
765 //
766 //*****************************************************************************
767 extern void CS_registerInterrupt(void (*intHandler)(void));
768 
769 //*****************************************************************************
770 //
781 //
782 //*****************************************************************************
783 extern void CS_unregisterInterrupt(void);
784 
785 //*****************************************************************************
786 //
787 // Mark the end of the C bindings section for C++ compilers.
788 //
789 //*****************************************************************************
790 #ifdef __cplusplus
791 }
792 #endif
793 
794 //*****************************************************************************
795 //
796 // Close the Doxygen group.
798 //
799 //*****************************************************************************
800 
801 #endif
uint32_t CS_getHSMCLK(void)
Definition: cs.c:728
void CS_initClockSignal(uint32_t selectedClockSignal, uint32_t clockSource, uint32_t clockSourceDivider)
Definition: cs.c:174
uint32_t CS_getACLK(void)
Definition: cs.c:738
void CS_enableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:769
void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency, uint32_t hfxt_XT_CLK_frequency)
Definition: cs.c:167
void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency)
Definition: cs.c:457
void CS_enableInterrupt(uint32_t flags)
Definition: cs.c:854
void CS_disableDCOExternalResistor(void)
Definition: cs.c:512
void CS_enableDCOExternalResistor(void)
Definition: cs.c:472
void CS_clearInterruptFlag(uint32_t flags)
Definition: cs.c:886
bool CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout)
Definition: cs.c:302
void CS_unregisterInterrupt(void)
Definition: cs.c:910
uint32_t CS_getInterruptStatus(void)
Definition: cs.c:876
uint32_t CS_getBCLK(void)
Definition: cs.c:720
bool CS_startHFXT(bool bypassMode)
Definition: cs.c:297
void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData, uint_fast8_t freqRange)
Definition: cs.c:483
void CS_registerInterrupt(void(*intHandler)(void))
Definition: cs.c:897
void CS_enableClockRequest(uint32_t selectClock)
Definition: cs.c:427
void CS_startFaultCounter(uint_fast8_t counterSelect, uint_fast8_t countValue)
Definition: cs.c:829
void CS_disableInterrupt(uint32_t flags)
Definition: cs.c:865
uint32_t CS_getMCLK(void)
Definition: cs.c:759
void CS_setDCOFrequency(uint32_t dcoFrequency)
Definition: cs.c:631
bool CS_startLFXT(uint32_t xtDrive)
Definition: cs.c:362
void CS_setDCOCenteredFrequency(uint32_t dcoFreq)
Definition: cs.c:523
uint32_t CS_getEnabledInterruptStatus(void)
Definition: cs.c:881
void CS_disableClockRequest(uint32_t selectClock)
Definition: cs.c:442
void CS_resetFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:809
uint32_t CS_getDCOFrequency(void)
Definition: cs.c:564
bool CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout)
Definition: cs.c:367
void CS_tuneDCOFrequency(int16_t tuneParameter)
Definition: cs.c:542
uint32_t CS_getSMCLK(void)
Definition: cs.c:748
void CS_disableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:789

Copyright 2016, Texas Instruments Incorporated