Browse code

Power saving changes, add new fonts, bitmaps and screens

Nils Faerber authored on 19/05/2013 00:07:04
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,163 @@
1
+/*******************************************************************************
2
+ *
3
+ * HAL_UCS.h
4
+ * Provides Functions to Initialize the UCS/FLL and clock sources
5
+ * 
6
+ *
7
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ 
8
+ * 
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   
20
+ *    distribution.
21
+ *
22
+ *    Neither the name of Texas Instruments Incorporated nor the names of
23
+ *    its contributors may be used to endorse or promote products derived
24
+ *    from this software without specific prior written permission.
25
+ *
26
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
27
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
28
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
30
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
32
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
35
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
36
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+ * 
38
+ * Created: Version 1.0 11/24/2009
39
+ * Updated: Version 2.0 12/15/2010
40
+ *          Added Functions: XT2_Stop() and XT1_Stop()
41
+ *  
42
+ ******************************************************************************/
43
+
44
+#ifndef HAL_UCS_H
45
+#define HAL_UCS_H
46
+
47
+#include "HAL_MACROS.h"
48
+
49
+/*******************************************************************************
50
+ * Macros
51
+ ******************************************************************************/
52
+
53
+/* Select source for FLLREF  e.g. SELECT_FLLREF(SELREF__XT1CLK) */
54
+#define SELECT_FLLREF(source) st(UCSCTL3 = (UCSCTL3 & ~(SELREF_7)) | (source);) 
55
+/* Select source for ACLK    e.g. SELECT_ACLK(SELA__XT1CLK) */
56
+#define SELECT_ACLK(source)   st(UCSCTL4 = (UCSCTL4 & ~(SELA_7))   | (source);) 
57
+/* Select source for MCLK    e.g. SELECT_MCLK(SELM__XT2CLK) */
58
+#define SELECT_MCLK(source)   st(UCSCTL4 = (UCSCTL4 & ~(SELM_7))   | (source);) 
59
+/* Select source for SMCLK   e.g. SELECT_SMCLK(SELS__XT2CLK) */
60
+#define SELECT_SMCLK(source)  st(UCSCTL4 = (UCSCTL4 & ~(SELS_7))   | (source);) 
61
+/* Select source for MCLK and SMCLK e.g. SELECT_MCLK_SMCLK(SELM__DCOCLK + SELS__DCOCLK) */
62
+#define SELECT_MCLK_SMCLK(sources) st(UCSCTL4 = (UCSCTL4 & ~(SELM_7 + SELS_7)) | (sources);)
63
+
64
+/* set ACLK/x */
65
+#define ACLK_DIV(x)         st(UCSCTL5 = (UCSCTL5 & ~(DIVA_7)) | (DIVA__##x);)     
66
+/* set MCLK/x */
67
+#define MCLK_DIV(x)         st(UCSCTL5 = (UCSCTL5 & ~(DIVM_7)) | (DIVM__##x);)     
68
+/* set SMCLK/x */
69
+#define SMCLK_DIV(x)        st(UCSCTL5 = (UCSCTL5 & ~(DIVS_7)) | (DIVS__##x);)     
70
+/* Select divider for FLLREF  e.g. SELECT_FLLREFDIV(2) */
71
+#define SELECT_FLLREFDIV(x) st(UCSCTL3 = (UCSCTL3 & ~(FLLREFDIV_7))|(FLLREFDIV__##x);) 
72
+
73
+/*******************************************************************************
74
+ * Defines
75
+ ******************************************************************************/
76
+#define UCS_STATUS_OK     0
77
+#define UCS_STATUS_ERROR  1
78
+
79
+#if 0
80
+/*******************************************************************************
81
+ * \brief   Startup routine for 32kHz Crystal on LFXT1
82
+ *
83
+ * \param xtdrive   Bits defining the LFXT drive mode after startup
84
+ ******************************************************************************/
85
+extern void LFXT_Start(unsigned int xtdrive);
86
+#endif
87
+
88
+/*******************************************************************************
89
+ * \brief   Startup routine for 32kHz Crystal on LFXT1 with timeout counter
90
+ *
91
+ * \param xtdrive   Bits defining the LFXT drive mode after startup
92
+ * \param timeout   Value for the timeout counter
93
+ ******************************************************************************/
94
+extern unsigned int LFXT_Start_Timeout(unsigned int xtdrive, unsigned int timeout);
95
+
96
+#if 0
97
+/*******************************************************************************
98
+ * \brief   Startup routine for XT1
99
+ *
100
+ * \param xtdrive   Bits defining the XT drive mode
101
+ ******************************************************************************/
102
+extern void XT1_Start(unsigned int xtdrive);
103
+
104
+/*******************************************************************************
105
+ * \brief   Startup routine for XT1 with timeout counter
106
+ *
107
+ * \param xtdrive   Bits defining the XT drive mode
108
+ * \param timeout   Value for the timeout counter
109
+ ******************************************************************************/
110
+extern unsigned int XT1_Start_Timeout(unsigned int xtdrive, unsigned int timeout);
111
+
112
+/*******************************************************************************
113
+ * \brief   Use XT1 in Bypasss mode
114
+ ******************************************************************************/
115
+extern void XT1_Bypass(void);
116
+
117
+#endif
118
+
119
+/*******************************************************************************
120
+ * \brief   Stop XT1 oscillator
121
+ ******************************************************************************/
122
+extern void XT1_Stop(void);
123
+
124
+#if 0
125
+/*******************************************************************************
126
+ * \brief   Startup routine for XT2
127
+ *
128
+ * \param xtdrive   Bits defining the XT drive mode
129
+ ******************************************************************************/
130
+extern void XT2_Start(unsigned int xtdrive);
131
+
132
+/*******************************************************************************
133
+ * \brief   Startup routine for XT2 with timeout counter
134
+ *
135
+ * \param xtdrive   Bits defining the XT drive mode
136
+ * \param timeout   Value for the timeout counter
137
+ ******************************************************************************/
138
+extern unsigned int XT2_Start_Timeout(unsigned int xtdrive, unsigned int timeout);
139
+
140
+/*******************************************************************************
141
+ * \brief   Use XT2 in Bypasss mode for MCLK
142
+ ******************************************************************************/
143
+extern void XT2_Bypass(void);
144
+
145
+/*******************************************************************************
146
+ * \brief   Stop XT2 oscillator
147
+ ******************************************************************************/
148
+extern void XT2_Stop(void);
149
+
150
+#endif
151
+
152
+/*******************************************************************************
153
+ * \brief   Initializes FLL of the UCS and wait till settled before allowing
154
+ *          code execution to resume. The use of this function is preferred
155
+ *          over the use of Init_FLL().
156
+ *
157
+ * \param fsystem  Required system frequency (MCLK) in kHz
158
+ * \param ratio    Ratio between fsystem and FLLREFCLK
159
+ ******************************************************************************/
160
+extern void Init_FLL_Settle(unsigned int fsystem, unsigned int ratio);
161
+
162
+
163
+#endif /* HAL_UCS_H */