]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil/driverlib/cs.h
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil / driverlib / cs.h
1 /*
2  * -------------------------------------------
3  *    MSP432 DriverLib - v01_04_00_18 
4  * -------------------------------------------
5  *
6  * --COPYRIGHT--,BSD,BSD
7  * Copyright (c) 2015, Texas Instruments Incorporated
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * *  Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  *
17  * *  Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * *  Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  * --/COPYRIGHT--*/
37 #ifndef __CS_H__
38 #define __CS_H__
39
40 //*****************************************************************************
41 //
42 //! \addtogroup cs_api
43 //! @{
44 //
45 //*****************************************************************************
46
47 //*****************************************************************************
48 //
49 // If building with a C++ compiler, make all of the definitions in this header
50 // have a C binding.
51 //
52 //*****************************************************************************
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57
58 #include <stdint.h>
59 #include <stdbool.h>
60 #include <msp.h>
61
62 //*****************************************************************************
63 //
64 // Control specific variables
65 //
66 //*****************************************************************************
67 #define CS_CLOCK_DIVIDER_1 DIVS_0
68 #define CS_CLOCK_DIVIDER_2 DIVS_1
69 #define CS_CLOCK_DIVIDER_4 DIVS_2
70 #define CS_CLOCK_DIVIDER_8 DIVS_3
71 #define CS_CLOCK_DIVIDER_16 DIVS_4
72 #define CS_CLOCK_DIVIDER_32 DIVS_5
73 #define CS_CLOCK_DIVIDER_64 DIVS_6
74 #define CS_CLOCK_DIVIDER_128 DIVS_7
75
76 #define CS_LFXTCLK_SELECT   SELM_0
77 #define CS_HFXTCLK_SELECT   SELM_5
78 #define CS_VLOCLK_SELECT    SELM_1
79 #define CS_REFOCLK_SELECT   SELM_2
80 #define CS_DCOCLK_SELECT    SELM_3
81 #define CS_MODOSC_SELECT    SELM_4
82
83 #define CS_KEY 0x695A
84
85 /* Number of positions to shift for divider calculation */
86 #define CS_ACLK_DIV_BITPOS 0x04
87 #define CS_MCLK_DIV_BITPOS 0x0C
88 #define CS_SMCLK_DIV_BITPOS 0x00
89 #define CS_HSMCLK_DIV_BITPOS 0x08
90
91 /* Number of positions to shift for source calculation */
92 #define CS_ACLK_SRC_BITPOS 0x08
93 #define CS_MCLK_SRC_BITPOS 0x00
94 #define CS_SMCLK_SRC_BITPOS 0x04
95 #define CS_HSMCLK_SRC_BITPOS 0x04
96
97 /* REFO Clock Values */
98 #define CS_REFO_32KHZ 0x00
99 #define CS_REFO_128KHZ 0x01
100
101 /* Frequency Values */
102 #define CS_VLOCLK_FREQUENCY 10000
103 #define CS_MODCLK_FREQUENCY 24000000
104
105 /* Interrupts */
106 #define CS_LFXT_FAULT   LFXTIE
107 #define CS_HFXT_FAULT   HFXTIE
108 #define CS_DCOMIN_FAULT   DCOMINIE
109 #define CS_DCOMAX_FAULT   DCOMAXIE
110 #define CS_DCORESISTOR_FAULT   DCORIE
111 #define CS_STARTCOUNT_LFXT_FAULT   FCNTLFIE
112 #define CS_STARTCOUNT_HFXT_FAULT   FCNTHFIE
113 #define CS_PLL_OUTOFLOCK   PLLOOLIE
114 #define CS_PLL_OUTOFSIGNAL   PLLLOSIE
115 #define CS_PLL_OUTOFRANGE   PLLOORIE
116 #define CS_REFCNT_PERIOD_COUNTER   CALIE
117
118 #define CS_HFXT_DRIVE0 CS_CTL2_HFXTDRIVE_0
119 #define CS_HFXT_DRIVE1 CS_CTL2_HFXTDRIVE_1
120 #define CS_HFXT_BYPASS CS_CTL2_HFXTBYPASS
121
122 #define CS_LFXT_DRIVE0 LFXTDRIVE_0
123 #define CS_LFXT_DRIVE1 LFXTDRIVE_1
124 #define CS_LFXT_DRIVE2 LFXTDRIVE_2
125 #define CS_LFXT_DRIVE3 LFXTDRIVE_3
126 #define CS_LFXT_BYPASS LFXTBYPASS
127
128 #define CS_ACLK ACLK_EN
129 #define CS_MCLK MCLK_EN
130 #define CS_SMCLK SMCLK_EN
131 #define CS_HSMCLK HSMCLK_EN
132 #define CS_BCLK BCLK_READY
133
134 #define CS_LFXTCLK  0x01
135
136 #define CS_1MHZ 1000000
137 #define CS_15MHZ 1500000
138 #define CS_3MHZ 3000000
139 #define CS_4MHZ 4000000
140 #define CS_6MHZ 6000000
141 #define CS_8MHZ 8000000
142 #define CS_12MHZ 12000000
143 #define CS_16MHZ 16000000
144 #define CS_24MHZ 24000000
145 #define CS_32MHZ 32000000
146 #define CS_40MHZ 40000000
147 #define CS_48MHZ 48000000
148
149 #define CS_DCO_FREQUENCY_1_5 DCORSEL_0
150 #define CS_DCO_FREQUENCY_3 DCORSEL_1
151 #define CS_DCO_FREQUENCY_6 DCORSEL_2
152 #define CS_DCO_FREQUENCY_12 DCORSEL_3
153 #define CS_DCO_FREQUENCY_24 DCORSEL_4
154 #define CS_DCO_FREQUENCY_48 DCORSEL_5
155
156 #define CS_HFXT_FAULT_COUNTER 0x01
157 #define CS_LFXT_FAULT_COUNTER 0x02
158
159 #define CS_FAULT_COUNTER_4096_CYCLES FCNTLF_0
160 #define CS_FAULT_COUNTER_8192_CYCLES FCNTLF_1
161 #define CS_FAULT_COUNTER_16384_CYCLES FCNTLF_2
162 #define CS_FAULT_COUNTER_32768_CYCLES FCNTLF_3
163
164 //******************************************************************************
165 //
166 //! This function sets the external clock sources LFXT and HFXT crystal
167 //! oscillator frequency values. This function must be called if an external
168 //! crystal LFXT or HFXT is used and the user intends to call
169 //! CS_getSMCLK, CS_getMCLK, CS_getBCLK,  CS_getHSMCLK, CS_getACLK and
170 //! any of the HFXT oscillator control functions
171 //!
172 //! \param lfxt_XT_CLK_frequency is the LFXT crystal frequencies in Hz
173 //! \param hfxt_XT_CLK_frequency is the HFXT crystal frequencies in Hz
174 //!
175 //! \return None
176 //
177 //******************************************************************************
178 extern void CS_setExternalClockSourceFrequency(uint32_t lfxt_XT_CLK_frequency,
179         uint32_t hfxt_XT_CLK_frequency);
180
181 //******************************************************************************
182 //
183 //! This function initializes each of the clock signals. The user must ensure
184 //! that this function is called for each clock signal. If not, the default
185 //! state is assumed for the particular clock signal. Refer to DriverLib
186 //! documentation for CS module or Device Family User's Guide for details of
187 //! default clock signal states. 
188 //!
189 //! Note that this function is blocking and will wait on the appropriate bit
190 //! to be set in the CSSTAT READY register to be set before setting the clock
191 //! source
192 //!
193 //! HFXTCLK is not available for BCLK or ACLK.
194 //!
195 //! \param selectedClockSignal Clock signal to initialize.
196 //!           - \b CS_ACLK,
197 //!           - \b CS_MCLK,
198 //!           - \b CS_HSMCLK
199 //!           - \b CS_SMCLK
200 //!           - \b CS_BCLK  [clockSourceDivider is ignored for this parameter]
201 //! \param clockSource  Clock source for the selectedClockSignal signal.
202 //!            - \b CS_LFXTCLK_SELECT,
203 //!            - \b CS_HFXTCLK_SELECT,
204 //!            - \b CS_VLOCLK_SELECT,     [Not available for BCLK]
205 //!            - \b CS_DCOCLK_SELECT,     [Not available for ACLK, BCLK]
206 //!            - \b CS_REFOCLK_SELECT,
207 //!            - \b CS_MODOSC_SELECT      [Not available for ACLK, BCLK]
208 //! \param clockSourceDivider - selected the clock divider to calculate
209 //!         clock signal from clock source. This parameter is ignored when
210 //!         setting BLCK. Valid values are:
211 //!           - \b CS_CLOCK_DIVIDER_1,
212 //!           - \b CS_CLOCK_DIVIDER_2,
213 //!           - \b CS_CLOCK_DIVIDER_4,
214 //!           - \b CS_CLOCK_DIVIDER_8,
215 //!           - \b CS_CLOCK_DIVIDER_16,
216 //!           - \b CS_CLOCK_DIVIDER_32,
217 //!           - \b CS_CLOCK_DIVIDER_64,
218 //!           - \b CS_CLOCK_DIVIDER_128
219 //!
220 //! \return NONE
221 //
222 //******************************************************************************
223 extern void CS_initClockSignal(uint32_t selectedClockSignal,
224         uint32_t clockSource, uint32_t clockSourceDivider);
225
226 //******************************************************************************
227 //
228 //! Initializes the HFXT crystal oscillator, which supports crystal frequencies
229 //! between 0 MHz and 48 MHz, depending on the selected drive strength. Loops
230 //! until all oscillator fault flags are cleared, with no timeout. See the
231 //! device-specific data sheet for appropriate drive settings. NOTE: User must
232 //! call CS_setExternalClockSourceFrequency to set frequency of external clocks
233 //! before calling this function.
234 //!
235 //! \param bypassMode When this variable is set, the oscillator will start
236 //! in bypass mode and the signal can be generated by a digital square wave.
237 //!
238 //!
239 //! \return NONE
240 //
241 //******************************************************************************
242 extern void CS_startHFXT(bool bypassMode);
243
244 //******************************************************************************
245 //
246 //! Initializes the HFXT crystal oscillator, which supports crystal frequencies
247 //! between 0 MHz and 48 MHz, depending on the selected drive strength. Loops
248 //! until all oscillator fault flags are cleared, with no timeout. See the
249 //! device-specific data sheet for appropriate drive settings. NOTE: User must
250 //! call CS_setExternalClockSourceFrequency to set frequency of external clocks
251 //! before calling this function. This function has a timeout associated with
252 //! stabilizing the oscillator.
253 //!
254 //! \param bypassMode When this variable is set, the oscillator will start
255 //! in bypass mode and the signal can be generated by a digital square wave.
256 //!
257 //! \param timeout is the count value that gets decremented every time the loop
258 //!         that clears oscillator fault flags gets executed.
259 //!
260 //! \return NONE
261 //
262 //******************************************************************************
263 extern void CS_startHFXTWithTimeout(bool bypassMode, uint32_t timeout);
264
265 //******************************************************************************
266 //
267 //! Initializes the LFXT crystal oscillator, which supports crystal frequencies
268 //! up to 50kHz, depending on the selected drive strength. Loops
269 //! until all oscillator fault flags are cleared, with no timeout. See the
270 //! device-specific data sheet for appropriate drive settings. NOTE: User must
271 //! call CS_setExternalClockSourceFrequency to set frequency of external clocks
272 //! before calling this function.
273 //!
274 //! \param xtDrive is the target drive strength for the LFXT crystal
275 //!                  oscillator.
276 //!      Valid values are:
277 //!         - \b CS_LFXT_DRIVE0,
278 //!         - \b CS_LFXT_DRIVE1,
279 //!         - \b CS_LFXT_DRIVE2,
280 //!         - \b CS_LFXT_DRIVE3,  [Default Value]
281 //!         - \b CS_LFXT_BYPASS
282 //!
283 //! \note When CS_LFXT_BYPASS is passed as a parameter the oscillator will start
284 //! in bypass mode and the signal can be generated by a digital square wave.
285 //!
286 //!
287 //! \return NONE
288 //
289 //******************************************************************************
290 extern void CS_startLFXT(uint32_t xtDrive);
291
292 //******************************************************************************
293 //
294 //! Initializes the LFXT crystal oscillator, which supports crystal frequencies
295 //! up to 50kHz, depending on the selected drive strength. Loops
296 //! until all oscillator fault flags are cleared. See the
297 //! device-specific data sheet for appropriate drive settings. NOTE: User must
298 //! call CS_setExternalClockSourceFrequency to set frequency of external clocks
299 //! before calling this function. This function has a timeout associated with
300 //! stabilizing the oscillator.
301 //!
302 //! \param xtDrive is the target drive strength for the LFXT crystal
303 //!                  oscillator.
304 //!      Valid values are:
305 //!         - \b CS_LFXT_DRIVE0,
306 //!         - \b CS_LFXT_DRIVE1,
307 //!         - \b CS_LFXT_DRIVE2,
308 //!         - \b CS_LFXT_DRIVE3,  [Default Value]
309 //!         - \b CS_LFXT_BYPASS
310 //!
311 //! \note When CS_LFXT_BYPASS is passed as a parameter the oscillator will
312 //! start in bypass mode and the signal can be generated by a digital square
313 //! wave.
314 //!
315 //! \param timeout is the count value that gets decremented every time the loop
316 //!         that clears oscillator fault flags gets executed.
317 //!
318 //! \return NONE
319 //
320 //******************************************************************************
321 extern void CS_startLFXTWithTimeout(uint32_t xtDrive, uint32_t timeout);
322
323 //******************************************************************************
324 //
325 //! Selects between the frequency of the internal REFO clock source
326 //!
327 //! \param referenceFrequency selects between the valid frequencies:
328 //!        - \b CS_REFO_32KHZ,
329 //!        - \b CS_REFO_128KHZ,
330 //!
331 //! \return NONE
332 //
333 //******************************************************************************
334 extern void CS_setReferenceOscillatorFrequency(uint8_t referenceFrequency);
335
336 //******************************************************************************
337 //
338 //! Enables conditional module requests
339 //!
340 //! \param selectClock selects specific request enables. Valid values are
341 //!        are a logical OR of the following values:
342 //!        - \b CS_ACLK,
343 //!        - \b CS_HSMCLK,
344 //!        - \b CS_SMCLK,
345 //!        - \b CS_MCLK
346 //!
347 //! \return NONE
348 //
349 //******************************************************************************
350 extern void CS_enableClockRequest(uint32_t selectClock);
351
352 //******************************************************************************
353 //
354 //! Disables conditional module requests
355 //!
356 //! \param selectClock selects specific request disables. Valid values are
357 //!        are a logical OR of the following values:
358 //!        - \b CS_ACLK,
359 //!        - \b CS_HSMCLK,
360 //!        - \b CS_SMCLK,
361 //!        - \b CS_MCLK
362 //!
363 //! \return NONE
364 //
365 //******************************************************************************
366 extern void CS_disableClockRequest(uint32_t selectClock);
367
368 //******************************************************************************
369 //
370 //! Get the current ACLK frequency.
371 //!
372 //! If a oscillator fault is set, the frequency returned will be based on the
373 //! fail safe mechanism of CS module. The user of this API must ensure that
374 //! \link CS_setExternalClockSourceFrequency() \endlink API was invoked before
375 //! in case LFXT is being used.
376 //!
377 //! \return Current ACLK frequency in Hz
378 //
379 //******************************************************************************
380 extern uint32_t CS_getACLK(void);
381
382 //******************************************************************************
383 //
384 //! Get the current SMCLK frequency.
385 //!
386 //! If a oscillator fault is set, the frequency returned will be based on the
387 //! fail safe mechanism of CS module. The user of this API must ensure that
388 //! CS_setExternalClockSourceFrequency API was invoked before in case LFXT or
389 //! HFXT is being used.
390 //!
391 //! \return Current SMCLK frequency in Hz
392 //
393 //******************************************************************************
394 extern uint32_t CS_getSMCLK(void);
395
396 //******************************************************************************
397 //
398 //! Get the current MCLK frequency.
399 //!
400 //! If a oscillator fault is set, the frequency returned will be based on the
401 //! fail safe mechanism of CS module. The user of this API must ensure that
402 //! CS_setExternalClockSourceFrequency API was invoked before in case LFXT or
403 //! HFXT is being used.
404 //!
405 //! \return Current MCLK frequency in Hz
406 //
407 //******************************************************************************
408 extern uint32_t CS_getMCLK(void);
409
410 //******************************************************************************
411 //
412 //! Get the current BCLK frequency.
413 //!
414 //! If a oscillator fault is set, the frequency returned will be based on the
415 //! fail safe mechanism of CS module. The user of this API must ensure that
416 //! \link CS_setExternalClockSourceFrequency \endlink API was invoked before in
417 //! case LFXT or HFXT is being used.
418 //!
419 //! \return Current BCLK frequency in Hz
420 //
421 //******************************************************************************
422 extern uint32_t CS_getBCLK(void);
423
424 //******************************************************************************
425 //
426 //! Get the current HSMCLK frequency.
427 //!
428 //! If a oscillator fault is set, the frequency returned will be based on the
429 //! fail safe mechanism of CS module. The user of this API must ensure that
430 //! \link CS_setExternalClockSourceFrequency \endlink API was invoked before in
431 //! case LFXT or HFXT is being used.
432 //!
433 //! \return Current HSMCLK frequency in Hz
434 //
435 //******************************************************************************
436 extern uint32_t CS_getHSMCLK(void);
437
438 //******************************************************************************
439 //
440 //! Sets the centered frequency of DCO operation.  Each frequency represents
441 //! the centred frequency of a particular frequency range. Further tuning can
442 //! be achieved by using the CS_tuneDCOFrequency function. Note that setting
443 //! the nominal frequency will reset the tuning parameters.
444 //!
445 //! \param dcoFreq selects between the valid frequencies:
446 //!        - \b CS_DCO_FREQUENCY_1_5, [1MHz to 2MHz]
447 //!        - \b CS_DCO_FREQUENCY_3,   [2MHz to 4MHz]
448 //!        - \b CS_DCO_FREQUENCY_6,   [4MHz to 8MHz]
449 //!        - \b CS_DCO_FREQUENCY_12,  [8MHz to 16MHz]
450 //!        - \b CS_DCO_FREQUENCY_24,  [16MHz to 32MHz]
451 //!        - \b CS_DCO_FREQUENCY_48   [32MHz to 64MHz]
452 //!
453 //! \return NONE
454 //
455 //******************************************************************************
456 extern void CS_setDCOCenteredFrequency(uint32_t dcoFreq);
457
458 //******************************************************************************
459 //
460 //! Automatically sets/tunes the DCO to the given frequency. Any valid value
461 //! up to max frequency in the spec can be given to this function and the API
462 //! will do its best to determine the correct tuning parameter.
463 //!
464 //! \note The frequency ranges that can be custom tuned on early release MSP432
465 //! devices is limited. For further details on supported tunable frequencies,
466 //! please refer to the device errata sheet or data sheet.
467 //!
468 //! \param dcoFrequency Frequency in Hz that the user wants to set the DCO to.
469 //!
470 //! \note This function uses floating point math to calculate the DCO tuning
471 //!         parameter. If efficiency is a concern, the user should use the
472 //!         \link FPU_enableModule \endlink function (if available) to enable
473 //!         the floating point co-processor.
474 //!
475 //! \return None
476 //
477 //******************************************************************************
478 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
479
480 //******************************************************************************
481 //
482 //! Tunes the DCO to a specific frequency. Tuning of the DCO is based off of the
483 //! following equation in the user's guide:
484 //!
485 //! See the user's guide for more detailed information about DCO tuning.
486 //!
487 //! \note This function is not currently available on pre-release MSP432 devices.
488 //!  On early release versions of MSP432, the DCO calibration information has not been
489 //!  populated making the DCO only able to operate at the pre-calibrated centered 
490 //!  frequencies accessible by the \link CS_setDCOCenteredFrequency \endlink
491 //!  function. While this function will be added on the final devices being released,
492 //!  for early silicon please default to the pre-calibrated DCO center frequencies.
493 //!
494 //! \param tuneParameter Tuning parameter in 2's Compliment representation.
495 //!  Can be negative or positive.
496 //!
497 //! \return NONE
498 //
499 //******************************************************************************
500 extern void CS_tuneDCOFrequency(int16_t tuneParameter);
501
502 //******************************************************************************
503 //
504 //! Enables the external resistor for DCO operation
505 //!
506 //! \return NONE
507 //
508 //******************************************************************************
509 extern void CS_enableDCOExternalResistor(void);
510
511 //******************************************************************************
512 //
513 //! Disables the external resistor for DCO operation
514 //!
515 //! \return NONE
516 //
517 //******************************************************************************
518 extern void CS_disableDCOExternalResistor(void);
519
520 //******************************************************************************
521 //
522 //! Sets the calibration value for the DCO when using the external resistor
523 //! mode. This value is used for tuning the DCO to custom frequencies. By
524 //! default, the value in the CS module is populated by the calibration
525 //! data of the suggested external resistor (see device datasheet).
526 //!
527 //! \param uiCalData is the calibration data constant for the external resistor.
528 //!
529 //! \return None
530 //
531 //******************************************************************************
532 extern void CS_setDCOExternalResistorCalibration(uint_fast8_t uiCalData);
533
534 //******************************************************************************
535 //
536 //! Gets the current tuned DCO frequency. If no tuning has been done, this
537 //! returns the nominal DCO frequency of the current DCO range. Note that this
538 //! function will grab any constant/calibration data from the DDDS table
539 //! without any user interaction needed.
540 //!
541 //! \note This function uses floating point math to calculate the DCO tuning
542 //!         parameter. If efficiency is a concern, the user should use the
543 //!         \link FPU_enableModule \endlink function (if available) to enable
544 //!         the floating point co-processor.
545 //!
546 //! \return Current DCO frequency in Hz
547 //
548 //******************************************************************************
549 extern uint32_t CS_getDCOFrequency(void);
550
551 //******************************************************************************
552 //
553 //! Automatically sets/tunes the DCO to the given frequency. Any valid value
554 //! up to (and including) 64Mhz can be given to this function and the API
555 //! will do its best to determine the correct tuning parameter.
556 //!
557 //!
558 //! \note This function is not currently available on pre-release MSP432 devices.
559 //!  On early release versions of MSP432, the DCO calibration information has not been
560 //!  populated making the DCO only able to operate at the pre-calibrated centered 
561 //!  frequencies accessible by the \link CS_setDCOCenteredFrequency \endlink
562 //!  function. While this function will be added on the final devices being released,
563 //!  for early silicon please default to the pre-calibrated DCO center frequencies.
564 //!
565 //! \param dcoFrequency Frequency in Hz (1500000 - 64000000) that the user wants
566 //!         to set the DCO to.
567 //!
568 //! \note This function uses floating point math to calculate the DCO tuning
569 //!         parameter. If efficiency is a concern, the user should use the
570 //!         \link FPU_enableModule \endlink function (if available) to enable
571 //!         the floating point co-processor.
572 //!
573 //! \return None
574 //
575 //******************************************************************************
576 extern void CS_setDCOFrequency(uint32_t dcoFrequency);
577
578 //******************************************************************************
579 //
580 //! Enables the fault counter for the CS module. This function can enable
581 //! either the HFXT fault counter or the LFXT fault counter.
582 //!
583 //! \param counterSelect selects the fault counter to enable
584 //!        - \b CS_HFXT_FAULT_COUNTER
585 //!        - \b CS_LFXT_FAULT_COUNTER
586 //!
587 //! \return NONE
588 //
589 //******************************************************************************
590 extern void CS_enableFaultCounter(uint_fast8_t counterSelect);
591
592 //******************************************************************************
593 //
594 //! Disables the fault counter for the CS module. This function can disable
595 //! either the HFXT fault counter or the LFXT fault counter.
596 //!
597 //! \param counterSelect selects the fault counter to disable
598 //!        - \b CS_HFXT_FAULT_COUNTER
599 //!        - \b CS_LFXT_FAULT_COUNTER
600 //!
601 //! \return NONE
602 //
603 //******************************************************************************
604 extern void CS_disableFaultCounter(uint_fast8_t counterSelect);
605
606 //******************************************************************************
607 //
608 //! Resets the fault counter for the CS module. This function can reset
609 //! either the HFXT fault counter or the LFXT fault counter.
610 //!
611 //! \param counterSelect selects the fault counter to reset
612 //!        - \b CS_HFXT_FAULT_COUNTER
613 //!        - \b CS_LFXT_FAULT_COUNTER
614 //!
615 //! \return NONE
616 //
617 //******************************************************************************
618 extern void CS_resetFaultCounter(uint_fast8_t counterSelect);
619
620 //******************************************************************************
621 //
622 //! Sets the count for the start value of the fault counter. This function can
623 //! be used to set either the HFXT count or the LFXT count.
624 //!
625 //! \param counterSelect selects the fault counter to reset
626 //!        - \b CS_HFXT_FAULT_COUNTER
627 //!        - \b CS_LFXT_FAULT_COUNTER
628 //! \param countValue selects the cycles to set the fault counter to
629 //!        - \b CS_FAULT_COUNTER_4096_CYCLES
630 //!        - \b CS_FAULT_COUNTER_8192_CYCLES
631 //!        - \b CS_FAULT_COUNTER_16384_CYCLES
632 //!        - \b CS_FAULT_COUNTER_32768_CYCLES
633 //!
634 //! \return NONE
635 //
636 //******************************************************************************
637 extern void CS_startFaultCounter(uint_fast8_t counterSelect,
638         uint_fast8_t countValue);
639
640 //*****************************************************************************
641 //
642 //! Enables individual clock control interrupt sources.
643 //!
644 //! \param flags is a bit mask of the interrupt sources to be enabled.  Must
645 //! be a logical OR of:
646 //!                     - \b CS_LFXT_FAULT,
647 //!                     - \b CS_HFXT_FAULT,
648 //!                     - \b CS_DCOMIN_FAULT,
649 //!                     - \b CS_DCOMAX_FAULT,
650 //!                     - \b CS_DCORESISTOR_FAULT,
651 //!                     - \b CS_STARTCOUNT_LFXT_FAULT,
652 //!                     - \b CS_STARTCOUNT_HFXT_FAULT,
653 //!                     - \b CS_PLL_OUTOFLOCK,
654 //!                     - \b CS_PLL_OUTOFSIGNAL,
655 //!                     - \b CS_PLL_OUTOFRANGE,
656 //!                     - \b CS_REFCNT_PERIOD_COUNTER
657 //!
658 //! This function enables the indicated clock system interrupt sources.  Only
659 //! the sources that are enabled can be reflected to the processor interrupt;
660 //! disabled sources have no effect on the processor.
661 //!
662 //! \note The interrupt sources vary based on the part in use.
663 //! Please consult the data sheet for the part you are using to determine
664 //! which interrupt sources are available.
665 //!
666 //! \return None.
667 //
668 //*****************************************************************************
669 extern void CS_enableInterrupt(uint32_t flags);
670
671 //*****************************************************************************
672 //
673 //! Disables individual clock system interrupt sources.
674 //!
675 //! \param flags is a bit mask of the interrupt sources to be disabled.  Must
676 //! be a logical OR of:
677 //!                     - \b CS_LFXT_FAULT,
678 //!                     - \b CS_HFXT_FAULT,
679 //!                     - \b CS_DCOMIN_FAULT,
680 //!                     - \b CS_DCOMAX_FAULT,
681 //!                     - \b CS_DCORESISTOR_FAULT,
682 //!                     - \b CS_STARTCOUNT_LFXT_FAULT,
683 //!                     - \b CS_STARTCOUNT_HFXT_FAULT,
684 //!                     - \b CS_PLL_OUTOFLOCK,
685 //!                     - \b CS_PLL_OUTOFSIGNAL,
686 //!                     - \b CS_PLL_OUTOFRANGE,
687 //!                     - \b CS_REFCNT_PERIOD_COUNTER
688 //!
689 //! \note The interrupt sources vary based on the part in use.
690 //! Please consult the data sheet for the part you are using to determine
691 //! which interrupt sources are available.
692 //!
693 //! \return None.
694 //
695 //*****************************************************************************
696 extern void CS_disableInterrupt(uint32_t flags);
697
698 //*****************************************************************************
699 //
700 //! Gets the current interrupt status masked with the enabled interrupts.
701 //! This function is useful to call in ISRs to get a list of pending interrupts
702 //! that are actually enabled and could have caused the ISR.
703 //!
704 //! \return The current interrupt status, enumerated as a bit field of
705 //!                     - \b CS_LFXT_FAULT,
706 //!                     - \b CS_HFXT_FAULT,
707 //!                     - \b CS_DCOMIN_FAULT,
708 //!                     - \b CS_DCOMAX_FAULT,
709 //!                     - \b CS_DCORESISTOR_FAULT,
710 //!                     - \b CS_STARTCOUNT_LFXT_FAULT,
711 //!                     - \b CS_STARTCOUNT_HFXT_FAULT,
712 //!                     - \b CS_PLL_OUTOFLOCK,
713 //!                     - \b CS_PLL_OUTOFSIGNAL,
714 //!                     - \b CS_PLL_OUTOFRANGE,
715 //!                     - \b CS_REFCNT_PERIOD_COUNTER
716 //!
717 //! \note The interrupt sources vary based on the part in use.
718 //! Please consult the data sheet for the part you are using to determine
719 //! which interrupt sources are available.
720 //
721 //*****************************************************************************
722 extern uint32_t CS_getEnabledInterruptStatus(void);
723
724 //*****************************************************************************
725 //
726 //! Gets the current interrupt status.
727 //!
728 //! \return The current interrupt status, enumerated as a bit field of:
729 //!                     - \b CS_LFXT_FAULT,
730 //!                     - \b CS_HFXT_FAULT,
731 //!                     - \b CS_DCOMIN_FAULT,
732 //!                     - \b CS_DCOMAX_FAULT,
733 //!                     - \b CS_DCORESISTOR_FAULT,
734 //!                     - \b CS_STARTCOUNT_LFXT_FAULT,
735 //!                     - \b CS_STARTCOUNT_HFXT_FAULT,
736 //!                     - \b CS_PLL_OUTOFLOCK,
737 //!                     - \b CS_PLL_OUTOFSIGNAL,
738 //!                     - \b CS_PLL_OUTOFRANGE,
739 //!                     - \b CS_REFCNT_PERIOD_COUNTER
740 //!
741 //! \note The interrupt sources vary based on the part in use.
742 //! Please consult the data sheet for the part you are using to determine
743 //! which interrupt sources are available.
744 //
745 //*****************************************************************************
746 extern uint32_t CS_getInterruptStatus(void);
747
748 //*****************************************************************************
749 //
750 //! Clears clock system interrupt sources.
751 //!
752 //! \param flags is a bit mask of the interrupt sources to be cleared.  Must
753 //! be a logical OR of:
754 //!                     - \b CS_LFXT_FAULT,
755 //!                     - \b CS_HFXT_FAULT,
756 //!                     - \b CS_DCOMIN_FAULT,
757 //!                     - \b CS_DCOMAX_FAULT,
758 //!                     - \b CS_DCORESISTOR_FAULT,
759 //!                     - \b CS_STARTCOUNT_LFXT_FAULT,
760 //!                     - \b CS_STARTCOUNT_HFXT_FAULT,
761 //!                     - \b CS_PLL_OUTOFLOCK,
762 //!                     - \b CS_PLL_OUTOFSIGNAL,
763 //!                     - \b CS_PLL_OUTOFRANGE,
764 //!                     - \b CS_REFCNT_PERIOD_COUNTER
765 //!
766 //! The specified clock system interrupt sources are cleared, so that they no
767 //! longer assert.  This function must be called in the interrupt handler to
768 //! keep it from being called again immediately upon exit.
769 //!
770 //! \note Because there is a write buffer in the Cortex-M processor, it may
771 //! take several clock cycles before the interrupt source is actually cleared.
772 //! Therefore, it is recommended that the interrupt source be cleared early in
773 //! the interrupt handler (as opposed to the very last action) to avoid
774 //! returning from the interrupt handler before the interrupt source is
775 //! actually cleared.  Failure to do so may result in the interrupt handler
776 //! being immediately reentered (because the interrupt controller still sees
777 //! the interrupt source asserted).
778 //!
779 //! \note The interrupt sources vary based on the part in use.
780 //! Please consult the data sheet for the part you are using to determine
781 //! which interrupt sources are available.
782 //!
783 //! \return None.
784 //
785 //*****************************************************************************
786 extern void CS_clearInterruptFlag(uint32_t flags);
787
788 //*****************************************************************************
789 //
790 //! Registers an interrupt handler for the clock system interrupt.
791 //!
792 //! \param intHandler is a pointer to the function to be called when the clock
793 //! system interrupt occurs.
794 //!
795 //! This function registers the handler to be called when a clock system
796 //! interrupt occurs. This function enables the global interrupt in the
797 //! interrupt controller; specific clock system interrupts must be enabled
798 //! via CS_enableInterrupt().  It is the interrupt handler's responsibility to
799 //! clear the interrupt source via CS_clearInterruptFlag().
800 //!
801 //! Clock System can generate interrupts when
802 //!
803 //! \sa Interrupt_registerInterrupt() for important information about
804 //! registering interrupt handlers.
805 //!
806 //! \return None.
807 //
808 //*****************************************************************************
809 extern void CS_registerInterrupt(void (*intHandler)(void));
810
811 //*****************************************************************************
812 //
813 //! Unregisters the interrupt handler for the clock system.
814 //!
815 //! This function unregisters the handler to be called when a clock system
816 //! interrupt occurs.  This function also masks off the interrupt in the
817 //! interrupt controller so that the interrupt handler no longer is called.
818 //!
819 //! \sa Interrupt_registerInterrupt() for important information about
820 //! registering interrupt handlers.
821 //!
822 //! \return None.
823 //
824 //*****************************************************************************
825 extern void CS_unregisterInterrupt(void);
826
827 //*****************************************************************************
828 //
829 // Mark the end of the C bindings section for C++ compilers.
830 //
831 //*****************************************************************************
832 #ifdef __cplusplus
833 }
834 #endif
835
836 //*****************************************************************************
837 //
838 // Close the Doxygen group.
839 //! @}
840 //
841 //*****************************************************************************
842
843 #endif