UCOS_TI_LM3S_Keil
 全部 结构体 文件 函数 变量 类型定义 宏定义 
cpu_bsp.c
浏览该文件的文档.
1 /*
2 *********************************************************************************************************
3 * uC/CPU
4 * CPU CONFIGURATION & PORT LAYER
5 *
6 * (c) Copyright 2004-2009; Micrium, Inc.; Weston, FL
7 *
8 * All rights reserved. Protected by international copyright laws.
9 *
10 * uC/CPU is provided in source form for FREE evaluation, for educational
11 * use or peaceful research. If you plan on using uC/CPU in a commercial
12 * product you need to contact Micrium to properly license its use in your
13 * product. We provide ALL the source code for your convenience and to
14 * help you experience uC/CPU. The fact that the source code is provided
15 * does NOT mean that you can use it without paying a licensing fee.
16 *
17 * Knowledge of the source code may NOT be used to develop a similar product.
18 *
19 * Please help us continue to provide the Embedded community with the finest
20 * software available. Your honesty is greatly appreciated.
21 *********************************************************************************************************
22 */
23 
24 /*
25 *********************************************************************************************************
26 *
27 * CPU BOARD SUPPORT PACKAGE (BSP) FUNCTIONS
28 *
29 * LUMINARY MICRO LM3S1968 on the EK-LM3S1968
30 *
31 * Filename : cpu_bsp.c
32 * Version : V1.23
33 * Programmer(s) : ITJ
34 *********************************************************************************************************
35 */
36 
37 
38 /*
39 *********************************************************************************************************
40 * INCLUDE FILES
41 *********************************************************************************************************
42 */
43 
44 #define CPU_BSP_MODULE
45 #include <cpu_core.h>
46 #include <bsp.h>
47 
48 
49 /*$PAGE*/
50 /*
51 *********************************************************************************************************
52 * LOCAL DEFINES
53 *********************************************************************************************************
54 */
55 
56 #define BSP_REG_DWT_CR (*(CPU_REG32 *)0xE0001000)
57 #define BSP_REG_DWT_CYCCNT (*(CPU_REG32 *)0xE0001004)
58 
59 
60 /*
61 *********************************************************************************************************
62 * LOCAL CONSTANTS
63 *********************************************************************************************************
64 */
65 
66 
67 /*
68 *********************************************************************************************************
69 * LOCAL DATA TYPES
70 *********************************************************************************************************
71 */
72 
73 
74 /*
75 *********************************************************************************************************
76 * LOCAL TABLES
77 *********************************************************************************************************
78 */
79 
80 
81 /*
82 *********************************************************************************************************
83 * LOCAL GLOBAL VARIABLES
84 *********************************************************************************************************
85 */
86 
87 
88 /*
89 *********************************************************************************************************
90 * LOCAL FUNCTION PROTOTYPES
91 *********************************************************************************************************
92 */
93 
94 
95 /*
96 *********************************************************************************************************
97 * LOCAL CONFIGURATION ERRORS
98 *********************************************************************************************************
99 */
100 
101 
102 /*$PAGE*/
103 /*
104 *********************************************************************************************************
105 * CPU_TS_TmrInit()
106 *
107 * Description : Initialize & start CPU timestamp timer.
108 *
109 * Argument(s) : none.
110 *
111 * Return(s) : Number of left-shifts to scale & return timer as (32-bit) 'CPU_TS' data type
112 * (see Note #2a1), if necessary.
113 *
114 * 0 (see Note #2a2), otherwise.
115 *
116 * Caller(s) : CPU_TS_Init().
117 *
118 * This function is an INTERNAL CPU module function & MUST be implemented by application/
119 * BSP function(s) [see Note #1] but MUST NOT be called by application function(s).
120 *
121 * Note(s) : (1) CPU_TS_TmrInit() is an application/BSP function that MUST be defined by the developer
122 * if either of the following CPU features is enabled :
123 *
124 * (a) CPU timestamps
125 * (b) CPU interrupts disabled time measurements
126 *
127 * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1'
128 * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'.
129 *
130 * (2) (a) Timer count values MUST be scaled & returned via (32-bit) 'CPU_TS' data type.
131 *
132 * (1) If timer has less bits, left-shift timer values until the most
133 * significant bit of the timer value is shifted into the most
134 * significant bit of the return timestamp data type.
135 * (2) If timer has more bits, truncate timer values' higher-order
136 * bits greater than the return timestamp data type.
137 *
138 * (b) Timer SHOULD be an 'up' counter whose values increase with each time count.
139 *
140 * (c) When applicable, timer period SHOULD be less than the typical measured time
141 * but MUST be less than the maximum measured time; otherwise, timer resolution
142 * inadequate to measure desired times.
143 *
144 * See also 'CPU_TS_TmrRd() Note #2'.
145 *********************************************************************************************************
146 */
147 
148 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
150 {
151  CPU_INT16U nbr_shifts;
152 
153 
155 
156  nbr_shifts = 0u;
157  return (nbr_shifts);
158 }
159 #endif
160 
161 
162 /*$PAGE*/
163 /*
164 *********************************************************************************************************
165 * CPU_TS_TmrRd()
166 *
167 * Description : Get current CPU timestamp timer count value.
168 *
169 * Argument(s) : none.
170 *
171 * Return(s) : (32-bit) Timestamp timer count (see Notes #2a & #2b).
172 *
173 * Caller(s) : CPU_TS_Init(),
174 * CPU_TS_UpdateHandler(),
175 * CPU_IntDisMeasStart(),
176 * CPU_IntDisMeasStop().
177 *
178 * This function is an INTERNAL CPU module function & MUST be implemented by application/
179 * BSP function(s) [see Note #1] but SHOULD NOT be called by application function(s).
180 *
181 * Note(s) : (1) CPU_TS_TmrRd() is an application/BSP function that MUST be defined by the developer
182 * if either of the following CPU features is enabled :
183 *
184 * (a) CPU timestamps
185 * (b) CPU interrupts disabled time measurements
186 *
187 * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1'
188 * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'.
189 *
190 * (2) (a) Timer count values MUST be returned via (32-bit) 'CPU_TS' data type.
191 *
192 * (1) If timer has less bits, left-shift timer values until the most
193 * significant bit of the timer value is shifted into the most
194 * significant bit of the return timestamp data type.
195 * (2) If timer has more bits, truncate timer values' higher-order
196 * bits greater than the return timestamp data type.
197 *
198 * (b) Timer SHOULD be an 'up' counter whose values increase with each time count.
199 *
200 * (1) If timer is a 'down' counter whose values decrease with each time count,
201 * then the returned timer value MUST be ones-complemented.
202 *
203 * (c) (1) When applicable, the amount of time measured by CPU timestamps is
204 * calculated by either of the following equations :
205 *
206 * (A) Time measured = Number timer counts * Timer period
207 *
208 * where
209 *
210 * Number timer counts Number of timer counts measured
211 * Timer period Timer's period in some units of
212 * (fractional) seconds
213 * Time measured Amount of time measured, in same
214 * units of (fractional) seconds
215 * as the Timer period
216 *
217 * Number timer counts
218 * (B) Time measured = ---------------------
219 * Timer frequency
220 *
221 * where
222 *
223 * Number timer counts Number of timer counts measured
224 * Timer frequency Timer's frequency in some units
225 * of counts per second
226 * Time measured Amount of time measured, in seconds
227 *
228 * (2) Timer period SHOULD be less than the typical measured time but MUST be less
229 * than the maximum measured time; otherwise, timer resolution inadequate to
230 * measure desired times.
231 *********************************************************************************************************
232 */
233 
234 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
236 {
237  CPU_TS time_meas_cnts;
238 
239 
240  time_meas_cnts = (CPU_TS)BSP_REG_DWT_CYCCNT;
241 
242  return (time_meas_cnts);
243 }
244 #endif
245 
246 
247 /*$PAGE*/
248 /*
249 *********************************************************************************************************
250 * CPU_TS_to_uSec()
251 *
252 * Description : Convert a CPU timestamp from timer counts to microseconds.
253 *
254 * Argument(s) : ts_lo_cnts CPU timestamp lower half (in timestamp timer counts [see Note #2aA]).
255 *
256 * ts_hi_cnts CPU timestamp upper half (in timestamp timer counts [see Note #2aA]).
257 *
258 * p_ts_lo_usec Pointer to variable that will receive the converted CPU timestamp's
259 * lower half [in microseconds (see Note #2aD)], if available.
260 *
261 * p_ts_hi_usec Pointer to variable that will receive the converted CPU timestamp's
262 * upper half [in microseconds (see Note #2aD)], if available.
263 *
264 * Return(s) : none.
265 *
266 * Caller(s) : Application.
267 *
268 * This function is an (optional) CPU module application interface (API) function which
269 * MAY be implemented by application/BSP function(s) [see Note #1] & MAY be called by
270 * application function(s).
271 *
272 * Note(s) : (1) CPU_TS_to_uSec() is an application/BSP function that MAY be optionally defined by
273 * the developer when either of the following CPU features is enabled :
274 *
275 * (a) CPU timestamps
276 * (b) CPU interrupts disabled time measurements
277 *
278 * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1'
279 * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'.
280 *
281 * (2) (a) The amount of time measured by CPU timestamps is calculated by either of
282 * the following equations :
283 *
284 * 10^6 microseconds
285 * (1) Time measured = Number timer counts * ------------------- * Timer period
286 * 1 second
287 *
288 * Number timer counts 10^6 microseconds
289 * (2) Time measured = --------------------- * -------------------
290 * Timer frequency 1 second
291 *
292 * where
293 *
294 * (A) Number timer counts Number of timer counts measured
295 * (B) Timer frequency Timer's frequency in some units
296 * of counts per second
297 * (C) Timer period Timer's period in some units of
298 * (fractional) seconds
299 * (D) Time measured Amount of time measured,
300 * in microseconds
301 *
302 * (b) Timer period SHOULD be less than the typical measured time but MUST be less
303 * than the maximum measured time; otherwise, timer resolution inadequate to
304 * measure desired times.
305 *
306 * (c) Specific implementations may convert any number of CPU timestamps bits, up
307 * to 64, into microseconds.
308 *********************************************************************************************************
309 */
310 
311 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
312 void CPU_TS_to_uSec(CPU_TS ts_lo_cnts,
313  CPU_TS ts_hi_cnts,
314  CPU_INT32U *p_ts_lo_usec,
315  CPU_INT32U *p_ts_hi_usec)
316 {
317 
318 }
319 #endif
320