cs.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef __CS_H__
33 #define __CS_H__
34 
35 //*****************************************************************************
36 //
39 //
40 //*****************************************************************************
41 
42 //*****************************************************************************
43 //
44 // If building with a C++ compiler, make all of the definitions in this header
45 // have a C binding.
46 //
47 //*****************************************************************************
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52 
53 #include <stdint.h>
54 #include <stdbool.h>
55 #include <ti/devices/msp432p4xx/inc/msp.h>
56 
57 //*****************************************************************************
58 //
59 // Control specific variables
60 //
61 //*****************************************************************************
62 #define CS_CLOCK_DIVIDER_1 CS_CTL1_DIVS_0
63 #define CS_CLOCK_DIVIDER_2 CS_CTL1_DIVS_1
64 #define CS_CLOCK_DIVIDER_4 CS_CTL1_DIVS_2
65 #define CS_CLOCK_DIVIDER_8 CS_CTL1_DIVS_3
66 #define CS_CLOCK_DIVIDER_16 CS_CTL1_DIVS_4
67 #define CS_CLOCK_DIVIDER_32 CS_CTL1_DIVS_5
68 #define CS_CLOCK_DIVIDER_64 CS_CTL1_DIVS_6
69 #define CS_CLOCK_DIVIDER_128 CS_CTL1_DIVS_7
70 
71 #define CS_LFXTCLK_SELECT CS_CTL1_SELM_0
72 #define CS_HFXTCLK_SELECT CS_CTL1_SELM_5
73 #define CS_VLOCLK_SELECT CS_CTL1_SELM_1
74 #define CS_REFOCLK_SELECT CS_CTL1_SELM_2
75 #define CS_DCOCLK_SELECT CS_CTL1_SELM_3
76 #define CS_MODOSC_SELECT CS_CTL1_SELM_4
77 
78 #define CS_KEY 0x695A
79 
80 /* Number of positions to shift for divider calculation */
81 #define CS_ACLK_DIV_BITPOS 0x04
82 #define CS_MCLK_DIV_BITPOS 0x0C
83 #define CS_SMCLK_DIV_BITPOS 0x00
84 #define CS_HSMCLK_DIV_BITPOS 0x08
85 
86 /* Number of positions to shift for source calculation */
87 #define CS_ACLK_SRC_BITPOS 0x08
88 #define CS_MCLK_SRC_BITPOS 0x00
89 #define CS_SMCLK_SRC_BITPOS 0x04
90 #define CS_HSMCLK_SRC_BITPOS 0x04
91 
92 /* REFO Clock Values */
93 #define CS_REFO_32KHZ 0x00
94 #define CS_REFO_128KHZ 0x01
95 
96 /* Frequency Values */
97 #define CS_VLOCLK_FREQUENCY 10000
98 #define CS_MODCLK_FREQUENCY 24000000
99 
100 /* Interrupts */
101 #define CS_LFXT_FAULT CS_IE_LFXTIE
102 #define CS_HFXT_FAULT CS_IE_HFXTIE
103 #define CS_DCO_OPEN_FAULT CS_IE_DCOR_OPNIE
104 #define CS_STARTCOUNT_LFXT_FAULT CS_IE_FCNTLFIE
105 #define CS_STARTCOUNT_HFXT_FAULT CS_IE_FCNTHFIE
106 #define CS_DCO_SHORT_FAULT CS_IFG_DCOR_SHTIFG
107 
108 #define CS_HFXT_DRIVE CS_CTL2_HFXTDRIVE
109 #define CS_HFXT_BYPASS CS_CTL2_HFXTBYPASS
110 
111 #define CS_LFXT_DRIVE0 CS_CTL2_LFXTDRIVE_0
112 #define CS_LFXT_DRIVE1 CS_CTL2_LFXTDRIVE_1
113 #define CS_LFXT_DRIVE2 CS_CTL2_LFXTDRIVE_2
114 #define CS_LFXT_DRIVE3 CS_CTL2_LFXTDRIVE_3
115 #define CS_LFXT_BYPASS CS_CTL2_LFXTBYPASS
116 
117 #define CS_ACLK CS_CLKEN_ACLK_EN
118 #define CS_MCLK CS_CLKEN_MCLK_EN
119 #define CS_SMCLK CS_CLKEN_SMCLK_EN
120 #define CS_HSMCLK CS_CLKEN_HSMCLK_EN
121 #define CS_BCLK CS_STAT_BCLK_READY
122 
123 #define CS_LFXTCLK 0x01
124 
125 #define CS_1MHZ 1000000
126 #define CS_15MHZ 1500000
127 #define CS_3MHZ 3000000
128 #define CS_4MHZ 4000000
129 #define CS_6MHZ 6000000
130 #define CS_8MHZ 8000000
131 #define CS_12MHZ 12000000
132 #define CS_16MHZ 16000000
133 #define CS_24MHZ 24000000
134 #define CS_32MHZ 32000000
135 #define CS_40MHZ 40000000
136 #define CS_48MHZ 48000000
137 
138 #define CS_DCO_FREQUENCY_1_5 CS_CTL0_DCORSEL_0
139 #define CS_DCO_FREQUENCY_3 CS_CTL0_DCORSEL_1
140 #define CS_DCO_FREQUENCY_6 CS_CTL0_DCORSEL_2
141 #define CS_DCO_FREQUENCY_12 CS_CTL0_DCORSEL_3
142 #define CS_DCO_FREQUENCY_24 CS_CTL0_DCORSEL_4
143 #define CS_DCO_FREQUENCY_48 CS_CTL0_DCORSEL_5
144 
145 #define CS_HFXT_FAULT_COUNTER 0x01
146 #define CS_LFXT_FAULT_COUNTER 0x02
147 
148 #define CS_FAULT_COUNTER_4096_CYCLES CS_CTL3_FCNTLF_0
149 #define CS_FAULT_COUNTER_8192_CYCLES CS_CTL3_FCNTLF_1
150 #define CS_FAULT_COUNTER_16384_CYCLES CS_CTL3_FCNTLF_2
151 #define CS_FAULT_COUNTER_32768_CYCLES CS_CTL3_FCNTLF_3
152 
153 #define CS_OVER32MHZ 0x01
154 #define CS_UNDER32MHZ 0x02
155 
156 //******************************************************************************
157 //
168 //
169 //******************************************************************************
170 extern void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency,
171  uint32_t hfxt_XT_CLK_frequency);
172 
173 //******************************************************************************
174 //
217 //
218 //******************************************************************************
219 extern void CS_initClockSignal(uint32_t selectedClockSignal,
220  uint32_t clockSource, uint32_t clockSourceDivider);
221 
222 //******************************************************************************
223 //
235 //
236 //******************************************************************************
237 extern bool CS_startHFXT(bool bypassMode);
238 
239 //******************************************************************************
240 //
256 //
257 //******************************************************************************
258 extern bool CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout);
259 
260 //******************************************************************************
261 //
282 //
283 //******************************************************************************
284 extern bool CS_startLFXT(uint32_t xtDrive);
285 
286 //******************************************************************************
287 //
313 //
314 //******************************************************************************
315 extern bool CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout);
316 
317 //******************************************************************************
318 //
326 //
327 //******************************************************************************
328 extern void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency);
329 
330 //******************************************************************************
331 //
342 //
343 //******************************************************************************
344 extern void CS_enableClockRequest(uint32_t selectClock);
345 
346 //******************************************************************************
347 //
358 //
359 //******************************************************************************
360 extern void CS_disableClockRequest(uint32_t selectClock);
361 
362 //******************************************************************************
363 //
372 //
373 //******************************************************************************
374 extern uint32_t CS_getACLK(void);
375 
376 //******************************************************************************
377 //
386 //
387 //******************************************************************************
388 extern uint32_t CS_getSMCLK(void);
389 
390 //******************************************************************************
391 //
400 //
401 //******************************************************************************
402 extern uint32_t CS_getMCLK(void);
403 
404 //******************************************************************************
405 //
414 //
415 //******************************************************************************
416 extern uint32_t CS_getBCLK(void);
417 
418 //******************************************************************************
419 //
428 //
429 //******************************************************************************
430 extern uint32_t CS_getHSMCLK(void);
431 
432 //******************************************************************************
433 //
448 //
449 //******************************************************************************
450 extern void CS_setDCOCenteredFrequency(uint32_t dcoFreq);
451 
452 //******************************************************************************
453 //
470 //
471 //******************************************************************************
472 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
473 
474 //******************************************************************************
475 //
492 //
493 //******************************************************************************
494 extern void CS_tuneDCOFrequency(int16_t tuneParameter);
495 
496 //******************************************************************************
497 //
501 //
502 //******************************************************************************
503 extern void CS_enableDCOExternalResistor(void);
504 
505 //******************************************************************************
506 //
510 //
511 //******************************************************************************
512 extern void CS_disableDCOExternalResistor(void);
513 
514 //******************************************************************************
515 //
528 //
529 //******************************************************************************
530 extern void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData,
531  uint_fast8_t freqRange);
532 
533 //******************************************************************************
534 //
546 //
547 //******************************************************************************
548 extern uint32_t CS_getDCOFrequency(void);
549 
550 //******************************************************************************
551 //
573 //
574 //******************************************************************************
575 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
576 
577 //******************************************************************************
578 //
587 //
588 //******************************************************************************
589 extern void CS_enableFaultCounter(uint_fast8_t counterSelect);
590 
591 //******************************************************************************
592 //
601 //
602 //******************************************************************************
603 extern void CS_disableFaultCounter(uint_fast8_t counterSelect);
604 
605 //******************************************************************************
606 //
615 //
616 //******************************************************************************
617 extern void CS_resetFaultCounter(uint_fast8_t counterSelect);
618 
619 //******************************************************************************
620 //
634 //
635 //******************************************************************************
636 extern void CS_startFaultCounter(uint_fast8_t counterSelect,
637  uint_fast8_t countValue);
638 
639 //*****************************************************************************
640 //
662 //
663 //*****************************************************************************
664 extern void CS_enableInterrupt(uint32_t flags);
665 
666 //*****************************************************************************
667 //
685 //
686 //*****************************************************************************
687 extern void CS_disableInterrupt(uint32_t flags);
688 
689 //*****************************************************************************
690 //
706 //
707 //*****************************************************************************
708 extern uint32_t CS_getEnabledInterruptStatus(void);
709 
710 //*****************************************************************************
711 //
725 //
726 //*****************************************************************************
727 extern uint32_t CS_getInterruptStatus(void);
728 
729 //*****************************************************************************
730 //
759 //
760 //*****************************************************************************
761 extern void CS_clearInterruptFlag(uint32_t flags);
762 
763 //*****************************************************************************
764 //
782 //
783 //*****************************************************************************
784 extern void CS_registerInterrupt(void (*intHandler)(void));
785 
786 //*****************************************************************************
787 //
798 //
799 //*****************************************************************************
800 extern void CS_unregisterInterrupt(void);
801 
802 //*****************************************************************************
803 //
804 // Mark the end of the C bindings section for C++ compilers.
805 //
806 //*****************************************************************************
807 #ifdef __cplusplus
808 }
809 #endif
810 
811 //*****************************************************************************
812 //
813 // Close the Doxygen group.
815 //
816 //*****************************************************************************
817 
818 #endif
uint32_t CS_getHSMCLK(void)
Definition: cs.c:801
void CS_initClockSignal(uint32_t selectedClockSignal, uint32_t clockSource, uint32_t clockSourceDivider)
Definition: cs.c:212
uint32_t CS_getACLK(void)
Definition: cs.c:811
void CS_enableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:842
void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency, uint32_t hfxt_XT_CLK_frequency)
Definition: cs.c:205
void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency)
Definition: cs.c:513
void CS_enableInterrupt(uint32_t flags)
Definition: cs.c:927
void CS_disableDCOExternalResistor(void)
Definition: cs.c:568
void CS_enableDCOExternalResistor(void)
Definition: cs.c:528
void CS_clearInterruptFlag(uint32_t flags)
Definition: cs.c:959
bool CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout)
Definition: cs.c:340
void CS_unregisterInterrupt(void)
Definition: cs.c:983
uint32_t CS_getInterruptStatus(void)
Definition: cs.c:949
uint32_t CS_getBCLK(void)
Definition: cs.c:793
bool CS_startHFXT(bool bypassMode)
Definition: cs.c:335
void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData, uint_fast8_t freqRange)
Definition: cs.c:539
void CS_registerInterrupt(void(*intHandler)(void))
Definition: cs.c:970
void CS_enableClockRequest(uint32_t selectClock)
Definition: cs.c:483
void CS_startFaultCounter(uint_fast8_t counterSelect, uint_fast8_t countValue)
Definition: cs.c:902
void CS_disableInterrupt(uint32_t flags)
Definition: cs.c:938
uint32_t CS_getMCLK(void)
Definition: cs.c:832
void CS_setDCOFrequency(uint32_t dcoFrequency)
Definition: cs.c:695
bool CS_startLFXT(uint32_t xtDrive)
Definition: cs.c:409
void CS_setDCOCenteredFrequency(uint32_t dcoFreq)
Definition: cs.c:579
uint32_t CS_getEnabledInterruptStatus(void)
Definition: cs.c:954
void CS_disableClockRequest(uint32_t selectClock)
Definition: cs.c:498
void CS_resetFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:882
uint32_t CS_getDCOFrequency(void)
Definition: cs.c:620
bool CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout)
Definition: cs.c:414
void CS_tuneDCOFrequency(int16_t tuneParameter)
Definition: cs.c:598
uint32_t CS_getSMCLK(void)
Definition: cs.c:821
void CS_disableFaultCounter(uint_fast8_t counterSelect)
Definition: cs.c:862

Copyright 2019, Texas Instruments Incorporated