MSP430 DriverLib for MSP430FR2xx_4xx Devices  2.91.13.01
cs.h
1 //*****************************************************************************
2 //
3 // cs.h - Driver for the CS Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_CS_H__
8 #define __MSP430WARE_CS_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_CS__
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 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
28 //! \brief Used in the CS_initFLLCalculateTrim(), CS_initFLLLoadTrim()
29 //! functions as the param parameter.
30 //
31 //*****************************************************************************
32 typedef struct CS_initFLLParam {
33  //! Contains software trim value for DCOTAP
34  uint16_t csCtl0;
35  //! Contains software trim value for DCOFTRIM
36  uint16_t csCtl1;
37  //! Is the target frequency for MCLK in kHz
38  uint16_t fsystem;
40 
41 
42 //*****************************************************************************
43 //
44 // The following are values that can be passed to the clockSourceDivider
45 // parameter for functions: CS_initClockSignal().
46 //
47 //*****************************************************************************
48 #define CS_CLOCK_DIVIDER_1 DIVM__1
49 #define CS_CLOCK_DIVIDER_2 DIVM__2
50 #define CS_CLOCK_DIVIDER_4 DIVM__4
51 #define CS_CLOCK_DIVIDER_8 DIVM__8
52 #define CS_CLOCK_DIVIDER_16 DIVM__16
53 #define CS_CLOCK_DIVIDER_32 DIVM__32
54 #define CS_CLOCK_DIVIDER_64 DIVM__64
55 #define CS_CLOCK_DIVIDER_128 DIVM__128
56 #define CS_CLOCK_DIVIDER_256 0x8
57 #define CS_CLOCK_DIVIDER_384 0x9
58 #define CS_CLOCK_DIVIDER_512 0xA
59 #define CS_CLOCK_DIVIDER_768 0xB
60 #define CS_CLOCK_DIVIDER_1024 0xC
61 #define CS_CLOCK_DIVIDER_108 0xD
62 #define CS_CLOCK_DIVIDER_338 0xE
63 #define CS_CLOCK_DIVIDER_414 0xF
64 #define CS_CLOCK_DIVIDER_640 0x10
65 
66 //*****************************************************************************
67 //
68 // The following are values that can be passed to the selectClock parameter for
69 // functions: CS_enableClockRequest(), and CS_disableClockRequest(); the
70 // selectedClockSignal parameter for functions: CS_initClockSignal().
71 //
72 //*****************************************************************************
73 #define CS_ACLK 0x01
74 #define CS_MCLK 0x02
75 #define CS_SMCLK 0x04
76 
77 //*****************************************************************************
78 //
79 // The following are values that can be passed to the selectedClockSignal
80 // parameter for functions: CS_initClockSignal().
81 //
82 //*****************************************************************************
83 #define CS_FLLREF 0x08
84 
85 //*****************************************************************************
86 //
87 // The following are values that can be passed to the selectClock parameter for
88 // functions: CS_enableClockRequest(), and CS_disableClockRequest().
89 //
90 //*****************************************************************************
91 #define CS_MODOSC MODCLKREQEN
92 
93 //*****************************************************************************
94 //
95 // The following are values that can be passed to the clockSource parameter for
96 // functions: CS_initClockSignal().
97 //
98 //*****************************************************************************
99 #define CS_XT1CLK_SELECT SELMS__XT1CLK
100 #define CS_VLOCLK_SELECT SELMS__VLOCLK
101 #define CS_REFOCLK_SELECT SELMS__REFOCLK
102 #define CS_DCOCLKDIV_SELECT SELMS__DCOCLKDIV
103 
104 //*****************************************************************************
105 //
106 // The following are values that can be passed to the xt1Drive parameter for
107 // functions: CS_turnOnXT1LF(), CS_turnOnXT1LFWithTimeout(), CS_turnOnXT1HF(),
108 // and CS_turnOnXT1HFWithTimeout().
109 //
110 //*****************************************************************************
111 #define CS_XT1_DRIVE_0 XT1DRIVE_0
112 #define CS_XT1_DRIVE_1 XT1DRIVE_1
113 #define CS_XT1_DRIVE_2 XT1DRIVE_2
114 #define CS_XT1_DRIVE_3 XT1DRIVE_3
115 
116 //*****************************************************************************
117 //
118 // The following are values that can be passed to the xt1HFFreq parameter for
119 // functions: CS_turnOnXT1HF(), and CS_turnOnXT1HFWithTimeout().
120 //
121 //*****************************************************************************
122 #define CS_XT1_HFFREQ_1MHZ_4MHZ XT1HFFREQ_0
123 #define CS_XT1_HFFREQ_4MHZ_6MHZ XT1HFFREQ_1
124 #define CS_XT1_HFFREQ_6MHZ_16MHZ XT1HFFREQ_2
125 #define CS_XT1_HFFREQ_16MHZ_24MHZ XT1HFFREQ_3
126 
127 //*****************************************************************************
128 //
129 // The following are values that can be passed to the mask parameter for
130 // functions: CS_getFaultFlagStatus(), and CS_clearFaultFlag() as well as
131 // returned by the CS_clearAllOscFlagsWithTimeout() function.
132 //
133 //*****************************************************************************
134 #define CS_XT1OFFG XT1OFFG
135 #define CS_DCOFFG DCOFFG
136 #define CS_FLLULIFG FLLULIFG
137 
138 //*****************************************************************************
139 //
140 // Prototypes for the APIs.
141 //
142 //*****************************************************************************
143 
144 //*****************************************************************************
145 //
146 //! \brief Sets the external clock source
147 //!
148 //! This function sets the external clock sources XT1 crystal oscillator
149 //! frequency values. This function must be called if an external crystal XT1
150 //! is used and the user intends to call CS_getMCLK, CS_getSMCLK or CS_getACLK
151 //! APIs. If not, it is not necessary to invoke this API.
152 //!
153 //! \param XT1CLK_frequency is the XT1 crystal frequencies in Hz
154 //!
155 //! \return None
156 //
157 //*****************************************************************************
158 extern void CS_setExternalClockSource(uint32_t XT1CLK_frequency);
159 
160 //*****************************************************************************
161 //
162 //! \brief Initializes a clock signal
163 //!
164 //! This function initializes each of the clock signals. The user must ensure
165 //! that this function is called for each clock signal. If not, the default
166 //! state is assumed for the particular clock signal. Please check the device
167 //! specific data sheet for details on the following: Some
168 //! devices do not support divider settings for \b CS_FLLREF.
169 //! VLO is only a valid clock source for ACLK on some devices.
170 //!
171 //! \param selectedClockSignal selected clock signal
172 //! Valid values are:
173 //! - \b CS_ACLK
174 //! - \b CS_MCLK
175 //! - \b CS_SMCLK
176 //! - \b CS_FLLREF
177 //! \param clockSource is clock source for the selectedClockSignal
178 //! Valid values are:
179 //! - \b CS_XT1CLK_SELECT
180 //! - \b CS_VLOCLK_SELECT
181 //! - \b CS_REFOCLK_SELECT
182 //! - \b CS_DCOCLKDIV_SELECT
183 //! \param clockSourceDivider selected the clock divider to calculate
184 //! clocksignal from clock source.
185 //! Valid values are:
186 //! - \b CS_CLOCK_DIVIDER_1 [Default] - [Valid for CS_FLLREF, CS_MCLK,
187 //! CS_ACLK, CS_SMCLK]
188 //! - \b CS_CLOCK_DIVIDER_2 - [Valid for CS_MCLK, CS_SMCLK]
189 //! - \b CS_CLOCK_DIVIDER_4 - [Valid for CS_MCLK, CS_SMCLK]
190 //! - \b CS_CLOCK_DIVIDER_8 - [Valid for CS_MCLK, CS_SMCLK]
191 //! - \b CS_CLOCK_DIVIDER_16 - [Valid for CS_MCLK, CS_ACLK]
192 //! - \b CS_CLOCK_DIVIDER_32 - [Valid for CS_FLLREF, CS_MCLK, CS_ACLK]
193 //! - \b CS_CLOCK_DIVIDER_64 - [Valid for CS_FLLREF, CS_MCLK, CS_ACLK]
194 //! - \b CS_CLOCK_DIVIDER_128 - [Valid for CS_FLLREF, CS_MCLK, CS_ACLK]
195 //! - \b CS_CLOCK_DIVIDER_256 - [Valid for CS_FLLREF, CS_ACLK]
196 //! - \b CS_CLOCK_DIVIDER_384 - [Valid for CS_FLLREF, CS_ACLK]
197 //! - \b CS_CLOCK_DIVIDER_512 - [Valid for CS_FLLREF, CS_ACLK]
198 //! - \b CS_CLOCK_DIVIDER_768 - [Valid for CS_FLLREF, CS_ACLK] [Only
199 //! available in 24MHz clock system] [If CS_ACLK, 24 MHz preference]
200 //! - \b CS_CLOCK_DIVIDER_1024 - [Valid for CS_FLLREF, CS_ACLK] [Only
201 //! available in 24MHz clock system] [If CS_ACLK, 32 MHz preference]
202 //! - \b CS_CLOCK_DIVIDER_108 - [Valid for CS_ACLK] [Only available in
203 //! 24MHz clock system] [If CS_ACLK, 3.5712 MHz preference]
204 //! - \b CS_CLOCK_DIVIDER_338 - [Valid for CS_ACLK] [Only available in
205 //! 24MHz clock system] [If CS_ACLK, 11.0592 MHz preference]
206 //! - \b CS_CLOCK_DIVIDER_414 - [Valid for CS_ACLK] [Only available in
207 //! 24MHz clock system] [If CS_ACLK, 13.56 MHz preference]
208 //! - \b CS_CLOCK_DIVIDER_640 - [Valid for CS_FLLREF, CS_ACLK] [Only
209 //! available in 24MHz clock system] [If CS_ACLK, 20.00 MHz
210 //! preference]
211 //!
212 //! Modified bits of \b CSCTL3 register, bits of \b CSCTL5 register and bits of
213 //! \b CSCTL4 register.
214 //!
215 //! \return None
216 //
217 //*****************************************************************************
218 extern void CS_initClockSignal(uint8_t selectedClockSignal,
219  uint16_t clockSource,
220  uint16_t clockSourceDivider);
221 
222 //*****************************************************************************
223 //
224 //! \brief Intializes the XT1 crystal oscillator in low frequency mode
225 //!
226 //! Initializes the XT1 crystal oscillator in low frequency mode. Loops until
227 //! all oscillator fault flags are cleared, with no timeout. See the device-
228 //! specific data sheet for appropriate drive settings.
229 //!
230 //! \param xt1Drive is the target drive strength for the XT1 crystal
231 //! oscillator.
232 //! Valid values are:
233 //! - \b CS_XT1_DRIVE_0
234 //! - \b CS_XT1_DRIVE_1
235 //! - \b CS_XT1_DRIVE_2
236 //! - \b CS_XT1_DRIVE_3 [Default]
237 //! \n Modified bits are \b XT1DRIVE of \b UCSCTL6 register.
238 //!
239 //! \return None
240 //
241 //*****************************************************************************
242 extern void CS_turnOnXT1LF(uint16_t xt1Drive);
243 
244 //*****************************************************************************
245 //
246 //! \brief Bypass the XT1 crystal oscillator
247 //!
248 //! Bypasses the XT1 crystal oscillator. Loops until all oscillator fault flags
249 //! are cleared, with no timeout.
250 //!
251 //!
252 //! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
253 //! of \b CSCTL6 register.
254 //!
255 //! \return None
256 //
257 //*****************************************************************************
258 extern void CS_bypassXT1(void);
259 
260 //*****************************************************************************
261 //
262 //! \brief Initializes the XT1 crystal oscillator in low frequency mode with
263 //! timeout
264 //!
265 //! Initializes the XT1 crystal oscillator in low frequency mode with timeout.
266 //! Loops until all oscillator fault flags are cleared or until a timeout
267 //! counter is decremented and equals to zero. See the device-specific
268 //! datasheet for appropriate drive settings.
269 //!
270 //! \param xt1Drive is the target drive strength for the XT1 crystal
271 //! oscillator.
272 //! Valid values are:
273 //! - \b CS_XT1_DRIVE_0
274 //! - \b CS_XT1_DRIVE_1
275 //! - \b CS_XT1_DRIVE_2
276 //! - \b CS_XT1_DRIVE_3 [Default]
277 //! \param timeout is the count value that gets decremented every time the loop
278 //! that clears oscillator fault flags gets executed.
279 //!
280 //! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
281 //! of \b CSCTL6 register.
282 //!
283 //! \return STATUS_SUCCESS or STATUS_FAIL
284 //
285 //*****************************************************************************
286 extern bool CS_turnOnXT1LFWithTimeout(uint16_t xt1Drive,
287  uint16_t timeout);
288 
289 //*****************************************************************************
290 //
291 //! \brief Bypasses the XT1 crystal oscillator with time out
292 //!
293 //! Bypasses the XT1 crystal oscillator with time out. Loops until all
294 //! oscillator fault flags are cleared or until a timeout counter is
295 //! decremented and equals to zero.
296 //!
297 //! \param timeout is the count value that gets decremented every time the loop
298 //! that clears oscillator fault flags gets executed.
299 //!
300 //! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
301 //! of \b CSCTL6 register.
302 //!
303 //! \return STATUS_SUCCESS or STATUS_FAIL
304 //
305 //*****************************************************************************
306 extern bool CS_bypassXT1WithTimeout(uint16_t timeout);
307 
308 //*****************************************************************************
309 //
310 //! \brief Stops the XT1 oscillator using the XT1AUTOOFF bit.
311 //!
312 //!
313 //! Modified bits are \b XT1AUTOOFF of \b CSCTL6 register.
314 //!
315 //! \return None
316 //
317 //*****************************************************************************
318 extern void CS_turnOffXT1(void);
319 
320 //*****************************************************************************
321 //
322 //! \brief Intializes the XT1 crystal oscillator in high frequency mode
323 //!
324 //! Initializes the XT1 crystal oscillator in high frequency mode. Loops until
325 //! all oscillator fault flags are cleared, with no timeout. See the device-
326 //! specific data sheet for appropriate drive settings.
327 //!
328 //! \param xt1Drive is the target drive strength for the XT1 crystal
329 //! oscillator.
330 //! Valid values are:
331 //! - \b CS_XT1_DRIVE_0
332 //! - \b CS_XT1_DRIVE_1
333 //! - \b CS_XT1_DRIVE_2
334 //! - \b CS_XT1_DRIVE_3 [Default]
335 //! \n Modified bits are \b XT1DRIVE of \b UCSCTL6 register.
336 //! \param xt1HFFreq is the high frequency range selection.
337 //! Valid values are:
338 //! - \b CS_XT1_HFFREQ_1MHZ_4MHZ [Default] - 1 MHz to 4 MHz
339 //! - \b CS_XT1_HFFREQ_4MHZ_6MHZ - Above 4 MHz to 6 MHz
340 //! - \b CS_XT1_HFFREQ_6MHZ_16MHZ - Above 6 MHz to 16 MHz
341 //! - \b CS_XT1_HFFREQ_16MHZ_24MHZ - Above 16 MHz to 24 MHz (Only
342 //! available in 24MHz clock system)
343 //!
344 //! \return None
345 //
346 //*****************************************************************************
347 extern void CS_turnOnXT1HF(uint16_t xt1Drive,
348  uint16_t xt1HFFreq);
349 
350 //*****************************************************************************
351 //
352 //! \brief Initializes the XT1 crystal oscillator in high frequency mode with
353 //! timeout
354 //!
355 //! Initializes the XT1 crystal oscillator in high frequency mode with timeout.
356 //! Loops until all oscillator fault flags are cleared or until a timeout
357 //! counter is decremented and equals to zero. See the device-specific
358 //! datasheet for appropriate drive settings.
359 //!
360 //! \param xt1Drive is the target drive strength for the XT1 crystal
361 //! oscillator.
362 //! Valid values are:
363 //! - \b CS_XT1_DRIVE_0
364 //! - \b CS_XT1_DRIVE_1
365 //! - \b CS_XT1_DRIVE_2
366 //! - \b CS_XT1_DRIVE_3 [Default]
367 //! \param xt1HFFreq is the high frequency range selection.
368 //! Valid values are:
369 //! - \b CS_XT1_HFFREQ_1MHZ_4MHZ [Default] - 1 MHz to 4 MHz
370 //! - \b CS_XT1_HFFREQ_4MHZ_6MHZ - Above 4 MHz to 6 MHz
371 //! - \b CS_XT1_HFFREQ_6MHZ_16MHZ - Above 6 MHz to 16 MHz
372 //! - \b CS_XT1_HFFREQ_16MHZ_24MHZ - Above 16 MHz to 24 MHz (Only
373 //! available in 24MHz clock system)
374 //! \param timeout is the count value that gets decremented every time the loop
375 //! that clears oscillator fault flags gets executed.
376 //!
377 //! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
378 //! of \b CSCTL6 register.
379 //!
380 //! \return STATUS_SUCCESS or STATUS_FAIL
381 //
382 //*****************************************************************************
383 extern bool CS_turnOnXT1HFWithTimeout(uint16_t xt1Drive,
384  uint16_t xt1HFFreq,
385  uint16_t timeout);
386 
387 //*****************************************************************************
388 //
389 //! \brief Turn On SMCLK
390 //!
391 //!
392 //! \return None
393 //
394 //*****************************************************************************
395 extern void CS_turnOnSMCLK(void);
396 
397 //*****************************************************************************
398 //
399 //! \brief Turn Off SMCLK
400 //!
401 //!
402 //! \return None
403 //
404 //*****************************************************************************
405 extern void CS_turnOffSMCLK(void);
406 
407 //*****************************************************************************
408 //
409 //! \brief VLO is turned off when not used
410 //!
411 //!
412 //! \return None
413 //
414 //*****************************************************************************
415 extern void CS_enableVLOAutoOff(void);
416 
417 //*****************************************************************************
418 //
419 //! \brief VLO is always on
420 //!
421 //!
422 //! \return None
423 //
424 //*****************************************************************************
425 extern void CS_disableVLOAutoOff(void);
426 
427 //*****************************************************************************
428 //
429 //! \brief Initializes the DCO to operate a frequency that is a multiple of the
430 //! reference frequency into the FLL
431 //!
432 //! Initializes the DCO to operate a frequency that is a multiple of the
433 //! reference frequency into the FLL. Loops until all oscillator fault flags
434 //! are cleared, with a timeout. If the frequency is greater than clock system
435 //! allows, the function sets the MCLK and SMCLK source to the undivided DCO
436 //! frequency and returns false. Otherwise, the function sets the MCLK and
437 //! SMCLK source to the DCOCLKDIV frequency. This function executes a software
438 //! delay that is proportional in length to the ratio of the target FLL
439 //! frequency and the FLL reference.
440 //!
441 //! \param fsystem is the target frequency for MCLK in kHz
442 //! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
443 //! frequency.
444 //!
445 //! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
446 //! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
447 //! bits of \b SFRIFG1 register.
448 //!
449 //! \return True if successful, false if unsuccessful and resorted to undivided
450 //! DCO frequency for MCLK and SMCLK source
451 //
452 //*****************************************************************************
453 extern bool CS_initFLLSettle(uint16_t fsystem,
454  uint16_t ratio);
455 
456 //*****************************************************************************
457 //
458 //! \brief Initializes the DCO to operate a frequency that is a multiple of the
459 //! reference frequency into the FLL. This function performs DCO Factory Trim.
460 //!
461 //! Initializes the DCO to operate a frequency that is a multiple of the
462 //! reference frequency into the FLL. Loops until all oscillator fault flags
463 //! are cleared, with a timeout. If the frequency is greater than clock system
464 //! allows, the function sets the MCLK and SMCLK source to the undivided DCO
465 //! frequency and returns false. Otherwise, the function sets the MCLK and
466 //! SMCLK source to the DCOCLKDIV frequency.
467 //!
468 //! \param fsystem is the target frequency for MCLK in kHz
469 //! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
470 //! frequency.
471 //!
472 //! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
473 //! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
474 //! bits of \b SFRIFG1 register.
475 //!
476 //! \return True if successful, false if unsuccessful and resorted to undivided
477 //! DCO frequency for MCLK and SMCLK source
478 //
479 //*****************************************************************************
480 extern bool CS_initFLL(uint16_t fsystem,
481  uint16_t ratio);
482 
483 //*****************************************************************************
484 //
485 //! \brief Performs same function as initFLLSettle in addition to setting the
486 //! proper DCOFTRIM according to clock frequency. This function performs DCO
487 //! Software Trim and saves the trim value into initFLLParam.
488 //!
489 //! Initializes the DCO to operate a frequency that is a multiple of the
490 //! reference frequency into the FLL. Loops until all oscillator fault flags
491 //! are cleared, with a timeout. If the frequency is greater than clock system
492 //! allows, the function sets the MCLK and SMCLK source to the undivided DCO
493 //! frequency and returns false. Otherwise, the function sets the MCLK and
494 //! SMCLK source to the DCOCLKDIV frequency. This function executes a software
495 //! delay that is proportional in length to the ratio of the target FLL
496 //! frequency and the FLL reference. It also calibrates the DCOFTRIM value
497 //! according to clock frequency. Lastly, it saves the DCOTAP and DCOFTRIM
498 //! values for future use.
499 //!
500 //! \param fsystem is the target frequency for MCLK in kHz
501 //! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
502 //! frequency.
503 //!
504 //! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
505 //! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
506 //! bits of \b SFRIFG1 register.
507 //!
508 //! \return True if successful, false if unsuccessful and resorted to undivided
509 //! DCO frequency for MCLK and SMCLK source
510 //
511 //*****************************************************************************
512 extern bool CS_initFLLCalculateTrim(uint16_t fsystem,
513  uint16_t ratio,
514  CS_initFLLParam *param);
515 
516 //*****************************************************************************
517 //
518 //! \brief Performs same function as initFLLCalculateTrim without the overhead
519 //! of calculating the trim, but rather using the one specified in param. This
520 //! function corresponds with the DCO Software Trim.
521 //!
522 //! Initializes the DCO to operate a frequency that is a multiple of the
523 //! reference frequency into the FLL. Loops until all oscillator fault flags
524 //! are cleared, with a timeout. If the frequency is greater than clock system
525 //! allows, the function sets the MCLK and SMCLK source to the undivided DCO
526 //! frequency and returns false. Otherwise, the function sets the MCLK and
527 //! SMCLK source to the DCOCLKDIV frequency. This function executes a software
528 //! delay that is proportional in length to the ratio of the target FLL
529 //! frequency and the FLL reference. Lastly, it uses the saved DCOTAP and
530 //! DCOFTRIM values from the param to avoid overhead in recalculation.
531 //!
532 //! \param fsystem is the target frequency for MCLK in kHz
533 //! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
534 //! frequency.
535 //!
536 //! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
537 //! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
538 //! bits of \b SFRIFG1 register.
539 //!
540 //! \return True if initialization successful, false if saved DCOFTRIM value is
541 //! not for the correct clock frequency combination or resorted to
542 //! undivided DCO frequency for MCLK and SMCLK source
543 //
544 //*****************************************************************************
545 extern bool CS_initFLLLoadTrim(uint16_t fsystem,
546  uint16_t ratio,
547  CS_initFLLParam *param);
548 
549 //*****************************************************************************
550 //
551 //! \brief Enables conditional module requests
552 //!
553 //! \param selectClock selects specific request enables
554 //! Valid values are:
555 //! - \b CS_ACLK
556 //! - \b CS_MCLK
557 //! - \b CS_SMCLK
558 //! - \b CS_MODOSC
559 //!
560 //! Modified bits of \b CSCTL8 register.
561 //!
562 //! \return None
563 //
564 //*****************************************************************************
565 extern void CS_enableClockRequest(uint8_t selectClock);
566 
567 //*****************************************************************************
568 //
569 //! \brief Disables conditional module requests
570 //!
571 //! \param selectClock selects specific request disable
572 //! Valid values are:
573 //! - \b CS_ACLK
574 //! - \b CS_MCLK
575 //! - \b CS_SMCLK
576 //! - \b CS_MODOSC
577 //!
578 //! Modified bits of \b CSCTL8 register.
579 //!
580 //! \return None
581 //
582 //*****************************************************************************
583 extern void CS_disableClockRequest(uint8_t selectClock);
584 
585 //*****************************************************************************
586 //
587 //! \brief Gets the current CS fault flag status.
588 //!
589 //! \param mask is the masked interrupt flag status to be returned. Mask
590 //! parameter can be either any of the following selection.
591 //! Valid values are:
592 //! - \b CS_XT1OFFG - XT1 oscillator fault flag
593 //! - \b CS_DCOFFG - DCO fault flag
594 //! - \b CS_FLLULIFG - FLL unlock interrupt flag
595 //!
596 //! Modified bits of \b CSCTL7 register.
597 //!
598 //! \return The current flag status for the corresponding masked bit
599 //
600 //*****************************************************************************
601 extern uint8_t CS_getFaultFlagStatus(uint8_t mask);
602 
603 //*****************************************************************************
604 //
605 //! \brief Clears the current CS fault flag status for the masked bit.
606 //!
607 //! \param mask is the masked interrupt flag status to be returned. mask
608 //! parameter can be any one of the following
609 //! Valid values are:
610 //! - \b CS_XT1OFFG - XT1 oscillator fault flag
611 //! - \b CS_DCOFFG - DCO fault flag
612 //! - \b CS_FLLULIFG - FLL unlock interrupt flag
613 //!
614 //! Modified bits of \b CSCTL7 register.
615 //!
616 //! \return None
617 //
618 //*****************************************************************************
619 extern void CS_clearFaultFlag(uint8_t mask);
620 
621 //*****************************************************************************
622 //
623 //! \brief Get the current ACLK frequency
624 //!
625 //! Get the current ACLK frequency. The user of this API must ensure that
626 //! CS_setExternalClockSource API was invoked before in case XT1 is being used.
627 //!
628 //!
629 //! \return Current ACLK frequency in Hz
630 //
631 //*****************************************************************************
632 extern uint32_t CS_getACLK(void);
633 
634 //*****************************************************************************
635 //
636 //! \brief Get the current SMCLK frequency
637 //!
638 //! Get the current SMCLK frequency. The user of this API must ensure that
639 //! CS_setExternalClockSource API was invoked before in case XT1 is being used.
640 //!
641 //!
642 //! \return Current SMCLK frequency in Hz
643 //
644 //*****************************************************************************
645 extern uint32_t CS_getSMCLK(void);
646 
647 //*****************************************************************************
648 //
649 //! \brief Get the current MCLK frequency
650 //!
651 //! Get the current MCLK frequency. The user of this API must ensure that
652 //! CS_setExternalClockSource API was invoked before in case XT1 is being used.
653 //!
654 //!
655 //! \return Current MCLK frequency in Hz
656 //
657 //*****************************************************************************
658 extern uint32_t CS_getMCLK(void);
659 
660 //*****************************************************************************
661 //
662 //! \brief Clears all the Oscillator Flags
663 //!
664 //! \param timeout is the count value that gets decremented every time the loop
665 //! that clears oscillator fault flags gets executed.
666 //!
667 //! \return The mask of the oscillator flag status
668 //! Return Logical OR of any of the following:
669 //! - \b CS_XT1OFFG XT1 oscillator fault flag
670 //! - \b CS_DCOFFG DCO fault flag
671 //! - \b CS_FLLULIFG FLL unlock interrupt flag
672 //! \n indicating the status of the osciallator fault flags
673 //
674 //*****************************************************************************
675 extern uint16_t CS_clearAllOscFlagsWithTimeout(uint16_t timeout);
676 
677 //*****************************************************************************
678 //
679 //! \brief Enables XT1 automatic gain control
680 //!
681 //!
682 //! Modified bits of \b CSCTL6 register.
683 //!
684 //! \return None
685 //
686 //*****************************************************************************
687 extern void CS_enableXT1AutomaticGainControl(void);
688 
689 //*****************************************************************************
690 //
691 //! \brief Disables XT1 automatic gain control
692 //!
693 //!
694 //! Modified bits of \b CSCTL6 register.
695 //!
696 //! \return None
697 //
698 //*****************************************************************************
699 extern void CS_disableXT1AutomaticGainControl(void);
700 
701 //*****************************************************************************
702 //
703 //! \brief Enables FLL unlock interrupt.
704 //!
705 //!
706 //! Modified bits are \b FLLULIE of \b CSCTL7 register.
707 //!
708 //! \return None
709 //
710 //*****************************************************************************
711 extern void CS_enableFLLUnlock(void);
712 
713 //*****************************************************************************
714 //
715 //! \brief Disables FLL unlock interrupt.
716 //!
717 //!
718 //! Modified bits are \b FLLULIE of \b CSCTL7 register.
719 //!
720 //! \return None
721 //
722 //*****************************************************************************
723 extern void CS_disableFLLUnlock(void);
724 
725 //*****************************************************************************
726 //
727 //! \brief Enable low-power REFO.
728 //!
729 //!
730 //! Modified bits are \b REFOLP of \b CSCTL3 register.
731 //!
732 //! \return None
733 //
734 //*****************************************************************************
735 extern void CS_enableREFOLP(void);
736 
737 //*****************************************************************************
738 //
739 //! \brief Disable low-power REFO.
740 //!
741 //!
742 //! Modified bits are \b REFOLP of \b CSCTL3 register.
743 //!
744 //! \return None
745 //
746 //*****************************************************************************
747 extern void CS_disableREFOLP(void);
748 
749 //*****************************************************************************
750 //
751 //! \brief Get status of low-power REFO.
752 //!
753 //!
754 //! \return Get status of low-power REFO.
755 //
756 //*****************************************************************************
757 extern bool CS_getREFOLP(void);
758 
759 //*****************************************************************************
760 //
761 //! \brief Turns off switching from XT1 to REFO when XT1 fails.
762 //!
763 //!
764 //! Modified bits are \b XT1FAULTOFF of \b CSCTL6 register.
765 //!
766 //! \return None
767 //
768 //*****************************************************************************
769 extern void CS_enableXT1FaultOff(void);
770 
771 //*****************************************************************************
772 //
773 //! \brief Turns on switching from XT1 to REFO when XT1 fails.
774 //!
775 //!
776 //! Modified bits are \b XT1FAULTOFF of \b CSCTL6 register.
777 //!
778 //! \return None
779 //
780 //*****************************************************************************
781 extern void CS_disableXT1FaultOff(void);
782 
783 //*****************************************************************************
784 //
785 //! \brief Get status of XT1 fault switching.
786 //!
787 //!
788 //! \return Get status of XT1 fault switching.
789 //
790 //*****************************************************************************
791 extern bool CS_getXT1FaultOff(void);
792 
793 //*****************************************************************************
794 //
795 //! \brief Get status indication of low-power REFO switching.
796 //!
797 //!
798 //! \return Get status indication of low-power REFO switching.
799 //
800 //*****************************************************************************
801 extern bool CS_getREFOReady(void);
802 
803 //*****************************************************************************
804 //
805 // The following are deprecated APIs.
806 //
807 //*****************************************************************************
808 #define CS_turnOnXT1 CS_turnOnXT1LF
809 #define CS_turnOnXT1WithTimeout CS_turnOnXT1LFWithTimeout
810 
811 //*****************************************************************************
812 //
813 // Mark the end of the C bindings section for C++ compilers.
814 //
815 //*****************************************************************************
816 #ifdef __cplusplus
817 }
818 #endif
819 
820 #endif
821 #endif // __MSP430WARE_CS_H__
void CS_turnOnXT1LF(uint16_t xt1Drive)
Intializes the XT1 crystal oscillator in low frequency mode.
Definition: cs.c:381
void CS_disableFLLUnlock(void)
Disables FLL unlock interrupt.
Definition: cs.c:1092
void CS_disableClockRequest(uint8_t selectClock)
Disables conditional module requests.
Definition: cs.c:949
uint32_t CS_getACLK(void)
Get the current ACLK frequency.
Definition: cs.c:967
uint16_t csCtl1
Contains software trim value for DCOFTRIM.
Definition: cs.h:36
bool CS_bypassXT1WithTimeout(uint16_t timeout)
Bypasses the XT1 crystal oscillator with time out.
Definition: cs.c:460
uint8_t CS_getFaultFlagStatus(uint8_t mask)
Gets the current CS fault flag status.
Definition: cs.c:955
bool CS_initFLLCalculateTrim(uint16_t fsystem, uint16_t ratio, CS_initFLLParam *param)
Performs same function as initFLLSettle in addition to setting the proper DCOFTRIM according to clock...
Definition: cs.c:698
void CS_setExternalClockSource(uint32_t XT1CLK_frequency)
Sets the external clock source.
Definition: cs.c:295
bool CS_turnOnXT1LFWithTimeout(uint16_t xt1Drive, uint16_t timeout)
Initializes the XT1 crystal oscillator in low frequency mode with timeout.
Definition: cs.c:426
void CS_disableVLOAutoOff(void)
VLO is always on.
Definition: cs.c:575
uint16_t CS_clearAllOscFlagsWithTimeout(uint16_t timeout)
Clears all the Oscillator Flags.
Definition: cs.c:1063
void CS_enableFLLUnlock(void)
Enables FLL unlock interrupt.
Definition: cs.c:1087
bool CS_getREFOReady(void)
Get status indication of low-power REFO switching.
Definition: cs.c:1143
void CS_initClockSignal(uint8_t selectedClockSignal, uint16_t clockSource, uint16_t clockSourceDivider)
Initializes a clock signal.
Definition: cs.c:301
bool CS_initFLLSettle(uint16_t fsystem, uint16_t ratio)
Initializes the DCO to operate a frequency that is a multiple of the reference frequency into the FLL...
Definition: cs.c:581
uint16_t fsystem
Is the target frequency for MCLK in kHz.
Definition: cs.h:38
bool CS_initFLL(uint16_t fsystem, uint16_t ratio)
Initializes the DCO to operate a frequency that is a multiple of the reference frequency into the FLL...
Definition: cs.c:597
void CS_enableVLOAutoOff(void)
VLO is turned off when not used.
Definition: cs.c:569
void CS_disableXT1AutomaticGainControl(void)
Disables XT1 automatic gain control.
Definition: cs.c:1082
void CS_disableREFOLP(void)
Disable low-power REFO.
Definition: cs.c:1104
void CS_enableClockRequest(uint8_t selectClock)
Enables conditional module requests.
Definition: cs.c:943
bool CS_turnOnXT1HFWithTimeout(uint16_t xt1Drive, uint16_t xt1HFFreq, uint16_t timeout)
Initializes the XT1 crystal oscillator in high frequency mode with timeout.
Definition: cs.c:520
Used in the CS_initFLLCalculateTrim(), CS_initFLLLoadTrim() functions as the param parameter...
Definition: cs.h:32
bool CS_getREFOLP(void)
Get status of low-power REFO.
Definition: cs.c:1111
bool CS_getXT1FaultOff(void)
Get status of XT1 fault switching.
Definition: cs.c:1134
void CS_turnOffXT1(void)
Stops the XT1 oscillator using the XT1AUTOOFF bit.
Definition: cs.c:487
void CS_turnOnXT1HF(uint16_t xt1Drive, uint16_t xt1HFFreq)
Intializes the XT1 crystal oscillator in high frequency mode.
Definition: cs.c:493
void CS_disableXT1FaultOff(void)
Turns on switching from XT1 to REFO when XT1 fails.
Definition: cs.c:1127
void CS_enableREFOLP(void)
Enable low-power REFO.
Definition: cs.c:1097
uint32_t CS_getMCLK(void)
Get the current MCLK frequency.
Definition: cs.c:1049
bool CS_initFLLLoadTrim(uint16_t fsystem, uint16_t ratio, CS_initFLLParam *param)
Performs same function as initFLLCalculateTrim without the overhead of calculating the trim...
Definition: cs.c:811
void CS_enableXT1FaultOff(void)
Turns off switching from XT1 to REFO when XT1 fails.
Definition: cs.c:1120
void CS_bypassXT1(void)
Bypass the XT1 crystal oscillator.
Definition: cs.c:407
void CS_enableXT1AutomaticGainControl(void)
Enables XT1 automatic gain control.
Definition: cs.c:1077
void CS_turnOffSMCLK(void)
Turn Off SMCLK.
Definition: cs.c:563
void CS_turnOnSMCLK(void)
Turn On SMCLK.
Definition: cs.c:557
void CS_clearFaultFlag(uint8_t mask)
Clears the current CS fault flag status for the masked bit.
Definition: cs.c:961
uint32_t CS_getSMCLK(void)
Get the current SMCLK frequency.
Definition: cs.c:1034
uint16_t csCtl0
Contains software trim value for DCOTAP.
Definition: cs.h:34

Copyright 2020, Texas Instruments Incorporated