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_DRIVE0 CS_CTL2_HFXTDRIVE_0
78 //#define CS_HFXT_DRIVE1 CS_CTL2_HFXTDRIVE_1
79 #define CS_HFXT_DRIVE CS_CTL2_HFXTDRIVE
80 #define CS_HFXT_BYPASS CS_CTL2_HFXTBYPASS
81 
82 #define CS_LFXT_DRIVE0 CS_CTL2_LFXTDRIVE_0
83 #define CS_LFXT_DRIVE1 CS_CTL2_LFXTDRIVE_1
84 #define CS_LFXT_DRIVE2 CS_CTL2_LFXTDRIVE_2
85 #define CS_LFXT_DRIVE3 CS_CTL2_LFXTDRIVE_3
86 #define CS_LFXT_BYPASS CS_CTL2_LFXTBYPASS
87 
88 #define CS_ACLK CS_CLKEN_ACLK_EN
89 #define CS_MCLK CS_CLKEN_MCLK_EN
90 #define CS_SMCLK CS_CLKEN_SMCLK_EN
91 #define CS_HSMCLK CS_CLKEN_HSMCLK_EN
92 #define CS_BCLK CS_STAT_BCLK_READY
93 
94 #define CS_LFXTCLK 0x01
95 
96 #define CS_1MHZ 1000000
97 #define CS_15MHZ 1500000
98 #define CS_3MHZ 3000000
99 #define CS_4MHZ 4000000
100 #define CS_6MHZ 6000000
101 #define CS_8MHZ 8000000
102 #define CS_12MHZ 12000000
103 #define CS_16MHZ 16000000
104 #define CS_24MHZ 24000000
105 #define CS_32MHZ 32000000
106 #define CS_40MHZ 40000000
107 #define CS_48MHZ 48000000
108 
109 #define CS_DCO_FREQUENCY_1_5 CS_CTL0_DCORSEL_0
110 #define CS_DCO_FREQUENCY_3 CS_CTL0_DCORSEL_1
111 #define CS_DCO_FREQUENCY_6 CS_CTL0_DCORSEL_2
112 #define CS_DCO_FREQUENCY_12 CS_CTL0_DCORSEL_3
113 #define CS_DCO_FREQUENCY_24 CS_CTL0_DCORSEL_4
114 #define CS_DCO_FREQUENCY_48 CS_CTL0_DCORSEL_5
115 
116 #define CS_HFXT_FAULT_COUNTER 0x01
117 #define CS_LFXT_FAULT_COUNTER 0x02
118 
119 #define CS_FAULT_COUNTER_4096_CYCLES CS_CTL3_FCNTLF_0
120 #define CS_FAULT_COUNTER_8192_CYCLES CS_CTL3_FCNTLF_1
121 #define CS_FAULT_COUNTER_16384_CYCLES CS_CTL3_FCNTLF_2
122 #define CS_FAULT_COUNTER_32768_CYCLES CS_CTL3_FCNTLF_3
123 
124 #define CS_OVER32MHZ 0x01
125 #define CS_UNDER32MHZ 0x02
126 
127 #define DEVICE_PG1_1 0x42
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 //
190 //
191 //******************************************************************************
192 extern void CS_initClockSignal(uint32_t selectedClockSignal,
193  uint32_t clockSource, uint32_t clockSourceDivider);
194 
195 //******************************************************************************
196 //
208 //
209 //******************************************************************************
210 extern bool CS_startHFXT(bool bypassMode);
211 
212 //******************************************************************************
213 //
229 //
230 //******************************************************************************
231 extern bool CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout);
232 
233 //******************************************************************************
234 //
255 //
256 //******************************************************************************
257 extern bool CS_startLFXT(uint32_t xtDrive);
258 
259 //******************************************************************************
260 //
286 //
287 //******************************************************************************
288 extern bool CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout);
289 
290 //******************************************************************************
291 //
299 //
300 //******************************************************************************
301 extern void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency);
302 
303 //******************************************************************************
304 //
315 //
316 //******************************************************************************
317 extern void CS_enableClockRequest(uint32_t selectClock);
318 
319 //******************************************************************************
320 //
331 //
332 //******************************************************************************
333 extern void CS_disableClockRequest(uint32_t selectClock);
334 
335 //******************************************************************************
336 //
345 //
346 //******************************************************************************
347 extern uint32_t CS_getACLK(void);
348 
349 //******************************************************************************
350 //
359 //
360 //******************************************************************************
361 extern uint32_t CS_getSMCLK(void);
362 
363 //******************************************************************************
364 //
373 //
374 //******************************************************************************
375 extern uint32_t CS_getMCLK(void);
376 
377 //******************************************************************************
378 //
387 //
388 //******************************************************************************
389 extern uint32_t CS_getBCLK(void);
390 
391 //******************************************************************************
392 //
401 //
402 //******************************************************************************
403 extern uint32_t CS_getHSMCLK(void);
404 
405 //******************************************************************************
406 //
421 //
422 //******************************************************************************
423 extern void CS_setDCOCenteredFrequency(uint32_t dcoFreq);
424 
425 //******************************************************************************
426 //
443 //
444 //******************************************************************************
445 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
446 
447 //******************************************************************************
448 //
465 //
466 //******************************************************************************
467 extern void CS_tuneDCOFrequency(int16_t tuneParameter);
468 
469 //******************************************************************************
470 //
474 //
475 //******************************************************************************
476 extern void CS_enableDCOExternalResistor(void);
477 
478 //******************************************************************************
479 //
483 //
484 //******************************************************************************
485 extern void CS_disableDCOExternalResistor(void);
486 
487 //******************************************************************************
488 //
501 //
502 //******************************************************************************
503 extern void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData,
504  uint_fast8_t freqRange);
505 
506 //******************************************************************************
507 //
519 //
520 //******************************************************************************
521 extern uint32_t CS_getDCOFrequency(void);
522 
523 //******************************************************************************
524 //
546 //
547 //******************************************************************************
548 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
549 
550 //******************************************************************************
551 //
560 //
561 //******************************************************************************
562 extern void CS_enableFaultCounter(uint_fast8_t counterSelect);
563 
564 //******************************************************************************
565 //
574 //
575 //******************************************************************************
576 extern void CS_disableFaultCounter(uint_fast8_t counterSelect);
577 
578 //******************************************************************************
579 //
588 //
589 //******************************************************************************
590 extern void CS_resetFaultCounter(uint_fast8_t counterSelect);
591 
592 //******************************************************************************
593 //
607 //
608 //******************************************************************************
609 extern void CS_startFaultCounter(uint_fast8_t counterSelect,
610  uint_fast8_t countValue);
611 
612 //*****************************************************************************
613 //
635 //
636 //*****************************************************************************
637 extern void CS_enableInterrupt(uint32_t flags);
638 
639 //*****************************************************************************
640 //
658 //
659 //*****************************************************************************
660 extern void CS_disableInterrupt(uint32_t flags);
661 
662 //*****************************************************************************
663 //
679 //
680 //*****************************************************************************
681 extern uint32_t CS_getEnabledInterruptStatus(void);
682 
683 //*****************************************************************************
684 //
698 //
699 //*****************************************************************************
700 extern uint32_t CS_getInterruptStatus(void);
701 
702 //*****************************************************************************
703 //
732 //
733 //*****************************************************************************
734 extern void CS_clearInterruptFlag(uint32_t flags);
735 
736 //*****************************************************************************
737 //
755 //
756 //*****************************************************************************
757 extern void CS_registerInterrupt(void (*intHandler)(void));
758 
759 //*****************************************************************************
760 //
771 //
772 //*****************************************************************************
773 extern void CS_unregisterInterrupt(void);
774 
775 //*****************************************************************************
776 //
777 // Mark the end of the C bindings section for C++ compilers.
778 //
779 //*****************************************************************************
780 #ifdef __cplusplus
781 }
782 #endif
783 
784 //*****************************************************************************
785 //
786 // Close the Doxygen group.
788 //
789 //*****************************************************************************
790 
791 #endif
uint32_t CS_getHSMCLK(void)
Definition: cs.c:763
void CS_initClockSignal(uint32_t selectedClockSignal, uint32_t clockSource, uint32_t clockSourceDivider)
Definition: cs.c:176
uint32_t CS_getACLK(void)
Definition: cs.c:773
void CS_enableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:804
void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency, uint32_t hfxt_XT_CLK_frequency)
Definition: cs.c:169
void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency)
Definition: cs.c:459
void CS_enableInterrupt(uint32_t flags)
Definition: cs.c:889
void CS_disableDCOExternalResistor(void)
Definition: cs.c:515
void CS_enableDCOExternalResistor(void)
Definition: cs.c:474
void CS_clearInterruptFlag(uint32_t flags)
Definition: cs.c:921
bool CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout)
Definition: cs.c:304
void CS_unregisterInterrupt(void)
Definition: cs.c:945
uint32_t CS_getInterruptStatus(void)
Definition: cs.c:911
uint32_t CS_getBCLK(void)
Definition: cs.c:755
bool CS_startHFXT(bool bypassMode)
Definition: cs.c:299
void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData, uint_fast8_t freqRange)
Definition: cs.c:485
void CS_registerInterrupt(void(*intHandler)(void))
Definition: cs.c:932
void CS_enableClockRequest(uint32_t selectClock)
Definition: cs.c:429
void CS_startFaultCounter(uint_fast8_t counterSelect, uint_fast8_t countValue)
Definition: cs.c:864
void CS_disableInterrupt(uint32_t flags)
Definition: cs.c:900
uint32_t CS_getMCLK(void)
Definition: cs.c:794
void CS_setDCOFrequency(uint32_t dcoFrequency)
Definition: cs.c:660
bool CS_startLFXT(uint32_t xtDrive)
Definition: cs.c:364
void CS_setDCOCenteredFrequency(uint32_t dcoFreq)
Definition: cs.c:526
uint32_t CS_getEnabledInterruptStatus(void)
Definition: cs.c:916
void CS_disableClockRequest(uint32_t selectClock)
Definition: cs.c:444
void CS_resetFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:844
uint32_t CS_getDCOFrequency(void)
Definition: cs.c:571
bool CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout)
Definition: cs.c:369
void CS_tuneDCOFrequency(int16_t tuneParameter)
Definition: cs.c:545
uint32_t CS_getSMCLK(void)
Definition: cs.c:783
void CS_disableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:824

Copyright 2016, Texas Instruments Incorporated