- Main Page
- Data Structures
- Files

- File List
- Globals

# hal_UCS.h

Go to the documentation of this file.

    00001 /* ***********************************************************
    00002 * THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
    00003 * REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
    00004 * INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
    00005 * FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
    00006 * COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
    00007 * TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
    00008 * POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
    00009 * INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
    00010 * YOUR USE OF THE PROGRAM.
    00011 *
    00012 * IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
    00013 * CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
    00014 * THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
    00015 * OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
    00016 * OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
    00017 * EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
    00018 * REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
    00019 * OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
    00020 * USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
    00021 * AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
    00022 * YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
    00023 * (U.S.$500).
    00024 *
    00025 * Unless otherwise stated, the Program written and copyrighted
    00026 * by Texas Instruments is distributed as "freeware".  You may,
    00027 * only under TI's copyright in the Program, use and modify the
    00028 * Program without any charge or restriction.  You may
    00029 * distribute to third parties, provided that you transfer a
    00030 * copy of this license to the third party and the third party
    00031 * agrees to these terms by its first use of the Program. You
    00032 * must reproduce the copyright notice and any other legend of
    00033 * ownership on each copy or partial copy, of the Program.
    00034 *
    00035 * You acknowledge and agree that the Program contains
    00036 * copyrighted material, trade secrets and other TI proprietary
    00037 * information and is protected by copyright laws,
    00038 * international copyright treaties, and trade secret laws, as
    00039 * well as other intellectual property laws.  To protect TI's
    00040 * rights in the Program, you agree not to decompile, reverse
    00041 * engineer, disassemble or otherwise translate any object code
    00042 * versions of the Program to a human-readable form.  You agree
    00043 * that in no event will you alter, remove or destroy any
    00044 * copyright notice included in the Program.  TI reserves all
    00045 * rights not specifically granted under this license. Except
    00046 * as specifically provided herein, nothing in this agreement
    00047 * shall be construed as conferring by implication, estoppel,
    00048 * or otherwise, upon you, any license or other right under any
    00049 * TI patents, copyrights or trade secrets.
    00050 *
    00051 * You may not use the Program in non-TI devices.
    00052 //
    00053 //This software has been submitted to export control regulations
    00054 //The ECCN is EAR99
    00055 * ********************************************************* */
    00056 //*****************************************************************************
    00068 //*******************************************************************************
    00069 //  Provides Functions to Initialize the UCS/FLL and clock sources
    00070 //    File: hal_ucs.c
    00071 //
    00072 //    Texas Instruments
    00073 //
    00074 //    Version 1.2
    00075 //    11/24/09
    00076 //
    00077 //    V1.0  Initial Version
    00078 //    V1.1  Added timeout function
    00079 //    V1.1  Added parameter for XTDrive
    00080 //*******************************************************************************
    00081
    00082
    00083 #ifndef __hal_UCS
    00084 #define __hal_UCS
    00085
    00086 #include <stdint.h>
    00087 #include "hal_macros.h"
    00088
    00089 //************************************************************************
    00090 // Check and define required Defines
    00091 //************************************************************************
    00092
    00093 #ifndef XT1LFOFFG               // Defines if not available in header file
    00094 #define XT1LFOFFG 0
    00095 #endif
    00096 #ifndef XT1HFOFFG               // Defines if not available in header file
    00097 #define XT1HFOFFG 0
    00098 #endif
    00099 #ifndef XT2OFFG                 // Defines if not available in header file
    00100 #define XT2OFFG 0
    00101 #endif
    00102 #ifndef XTS                    // Defines if not available in header file
    00103 #define XTS 0
    00104 #endif
    00105 #ifndef XT2DRIVE_3             // Defines if not available in header file
    00106 #define XT2DRIVE_3  0
    00107 #endif
    00108 /*************************************************************************
    00109 * MACROS
    00110 **************************************************************************/
    00111
    00112 /* Select source for FLLREF  e.g. SELECT_FLLREF(SELREF__XT1CLK) */
    00113 #define SELECT_FLLREF(source) st(UCSCTL3 = (UCSCTL3 & ~(SELREF_7)) | (source);)
    00114 /* Select source for ACLK    e.g. SELECT_ACLK(SELA__XT1CLK) */
    00115 #define SELECT_ACLK(source)   st(UCSCTL4 = (UCSCTL4 & ~(SELA_7))   | (source);)
    00116 /* Select source for MCLK    e.g. SELECT_MCLK(SELM__XT2CLK) */
    00117 #define SELECT_MCLK(source)   st(UCSCTL4 = (UCSCTL4 & ~(SELM_7))   | (source);)
    00118 /* Select source for SMCLK   e.g. SELECT_SMCLK(SELS__XT2CLK) */
    00119 #define SELECT_SMCLK(source)  st(UCSCTL4 = (UCSCTL4 & ~(SELS_7))   | (source);)
    00120 /* Select source for MCLK and SMCLK e.g. SELECT_MCLK_SMCLK(SELM__DCOCLK + SELS__DCOCLK) */
    00121 #define SELECT_MCLK_SMCLK(sources) st(UCSCTL4 = (UCSCTL4 & ~(SELM_7 + SELS_7)) | (sources);)
    00122
    00123 /* set ACLK/x */
    00124 #define ACLK_DIV(x)         st(UCSCTL5 = (UCSCTL5 & ~(DIVA_7)) | (DIVA__##x);)
    00125 /* set MCLK/x */
    00126 #define MCLK_DIV(x)         st(UCSCTL5 = (UCSCTL5 & ~(DIVM_7)) | (DIVM__##x);)
    00127 /* set SMCLK/x */
    00128 #define SMCLK_DIV(x)        st(UCSCTL5 = (UCSCTL5 & ~(DIVS_7)) | (DIVS__##x);)
    00129 /* Select divider for FLLREF  e.g. SELECT_FLLREFDIV(2) */
    00130 #define SELECT_FLLREFDIV(x) st(UCSCTL3 = (UCSCTL3 & ~(FLLREFDIV_7))|(FLLREFDIV__##x);)
    00131
    00132 //************************************************************************
    00133 // Defines
    00134 //************************************************************************
    00135
    00136 #define UCS_STATUS_OK     0
    00137 #define UCS_STATUS_ERROR  1
    00138
    00139 //====================================================================
    00146 extern void LFXT_Start(uint16_t xtdrive);
    00147
    00148 //====================================================================
    00156 extern uint16_t LFXT_Start_Timeout(uint16_t xtdrive, uint16_t timeout);
    00157
    00158 //====================================================================
    00165 extern void XT1_Start(uint16_t xtdrive);
    00166
    00167 //====================================================================
    00175 extern uint16_t XT1_Start_Timeout(uint16_t xtdrive, uint16_t timeout);
    00176
    00177 //====================================================================
    00182 extern void XT1_Bypass(void);
    00183
    00184 //====================================================================
    00191 extern void XT2_Start(uint16_t xtdrive);
    00192
    00193 //====================================================================
    00201 extern uint16_t XT2_Start_Timeout(uint16_t xtdrive, uint16_t timeout);
    00202
    00203 //====================================================================
    00208 extern void XT2_Bypass(void);
    00209
    00210 //====================================================================
    00217 extern void Init_FLL_Settle(uint16_t fsystem, uint16_t ratio);
    00218
    00219
    00220 //====================================================================
    00227 static void Init_FLL(uint16_t fsystem, uint16_t ratio);
    00228
    00229 #endif /* __hal_UCS */