UCOS_TI_LM3S_Keil
 全部 结构体 文件 函数 变量 类型定义 宏定义 
cpu_core.h
浏览该文件的文档.
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 * CORE CPU MODULE
28 *
29 * Filename : cpu_core.h
30 * Version : V1.23
31 * Programmer(s) : SR
32 * ITJ
33 *********************************************************************************************************
34 */
35 
36 
37 /*
38 *********************************************************************************************************
39 * MODULE
40 *********************************************************************************************************
41 */
42 
43 #ifndef CPU_CORE_MODULE_PRESENT
44 #define CPU_CORE_MODULE_PRESENT
45 
46 
47 /*$PAGE*/
48 /*
49 *********************************************************************************************************
50 * CORE CPU MODULE VERSION NUMBER
51 *
52 * Note(s) : (1) (a) The core CPU module software version is denoted as follows :
53 *
54 * Vx.yy
55 *
56 * where
57 * V denotes 'Version' label
58 * x denotes major software version revision number
59 * yy denotes minor software version revision number
60 *
61 * (b) The software version label #define is formatted as follows :
62 *
63 * ver = x.yy * 100
64 *
65 * where
66 * ver denotes software version number scaled as an integer value
67 * x.yy denotes software version number
68 *********************************************************************************************************
69 */
70 
71 #define CPU_CORE_VERSION 123u /* See Note #1. */
72 
73 
74 /*
75 *********************************************************************************************************
76 * EXTERNS
77 *********************************************************************************************************
78 */
79 
80 #ifdef CPU_CORE_MODULE
81 #define CPU_CORE_EXT
82 #else
83 #define CPU_CORE_EXT extern
84 #endif
85 
86 
87 /*
88 *********************************************************************************************************
89 * INCLUDE FILES
90 *********************************************************************************************************
91 */
92 
93 #include <cpu.h>
94 #include <lib_def.h>
95 #include <cpu_cfg.h>
96 
97 #include <lib_mem.h>
98 #include <lib_str.h>
99 
100 
101 /*$PAGE*/
102 /*
103 *********************************************************************************************************
104 * CPU CONFIGURATION
105 *
106 * Note(s) : (1) The following pre-processor directives correctly configure CPU parameters. DO NOT MODIFY.
107 *
108 * (2) CPU timestamp timer feature is required for :
109 *
110 * (a) CPU timestamps
111 * (b) CPU interrupts disabled time measurement
112 *
113 * See also 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1'
114 * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1'.
115 *********************************************************************************************************
116 */
117 
118 #if ((CPU_CFG_TS_EN == DEF_ENABLED) || \
119 (defined(CPU_CFG_INT_DIS_MEAS_EN)))
120 #define CPU_CFG_TS_TMR_EN DEF_ENABLED
121 #else
122 #define CPU_CFG_TS_TMR_EN DEF_DISABLED
123 #endif
124 
125 
126 /*
127 *********************************************************************************************************
128 * DEFINES
129 *********************************************************************************************************
130 */
131 
132 #define CPU_TIME_MEAS_NBR_MIN 1
133 #define CPU_TIME_MEAS_NBR_MAX 128
134 
135 
136 /*
137 *********************************************************************************************************
138 * CPU ERROR CODES
139 *********************************************************************************************************
140 */
141 
142 #define CPU_ERR_NONE 0
143 #define CPU_ERR_NULL_PTR 10
144 
145 #define CPU_ERR_NAME_SIZE 100
146 
147 
148 /*$PAGE*/
149 /*
150 *********************************************************************************************************
151 * DATA TYPES
152 *********************************************************************************************************
153 */
154 
155 /*
156 *********************************************************************************************************
157 * CPU ERROR CODES DATA TYPE
158 *********************************************************************************************************
159 */
160 
162 
163 
164 /*
165 *********************************************************************************************************
166 * CPU TIMESTAMP DATA TYPE
167 *********************************************************************************************************
168 */
169 
171 
172 
173 /*
174 *********************************************************************************************************
175 * GLOBAL VARIABLES
176 *********************************************************************************************************
177 */
178 
179 #if (CPU_CFG_NAME_EN == DEF_ENABLED)
180 CPU_CORE_EXT CPU_CHAR CPU_Name[CPU_CFG_NAME_SIZE]; /* CPU host name. */
181 #endif
182 
183 
184 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
185 CPU_CORE_EXT CPU_INT16U CPU_TS_TmrNbrShifts; /* Nbr left-shifts to adj ts tmr. */
186 #endif
187 
188 #if (CPU_CFG_TS_EN == DEF_ENABLED)
189 CPU_CORE_EXT CPU_TS CPU_TS_Lo; /* Cur ts (lo half) [in ts tmr cnts]. */
190 CPU_CORE_EXT CPU_TS CPU_TS_Hi; /* Cur ts (hi half) [in ts tmr cnts]. */
191 CPU_CORE_EXT CPU_TS CPU_TS_Prev; /* Prev ts [in ts tmr cnts]. */
192 #endif
193 
194 #ifdef CPU_CFG_INT_DIS_MEAS_EN
195 CPU_CORE_EXT CPU_INT16U CPU_IntDisNestCtr; /* Nbr nested ints dis'd ctr. */
196  /* Ints dis'd time (in ts tmr cnts) : ... */
197 CPU_CORE_EXT CPU_TS CPU_IntDisMeasStartRaw_cnts; /* ... start time. */
198 CPU_CORE_EXT CPU_TS CPU_IntDisMeasStopRaw_cnts; /* ... stop time. */
199 CPU_CORE_EXT CPU_TS CPU_IntDisMeasOvrhdRaw_cnts; /* ... time meas ovrhd. */
200 CPU_CORE_EXT CPU_TS CPU_IntDisMeasMaxCurRaw_cnts; /* ... (raw/un-adj'd) resetable max time dis'd. */
201 CPU_CORE_EXT CPU_TS CPU_IntDisMeasMaxRaw_cnts; /* ... (raw/un-adj'd) non-resetable max time dis'd. */
202 #endif
203 
204 
205 /*$PAGE*/
206 /*
207 *********************************************************************************************************
208 * FUNCTION PROTOTYPES
209 *
210 * Note(s) : (1) CPU interrupts disabled time measurement functions prototyped/defined only if
211 * CPU_CFG_INT_DIS_MEAS_EN #define'd in 'cpu_cfg.h'.
212 *
213 * (2) CPU_CntLeadZeros() prototyped/defined respectively in :
214 *
215 * (a) 'cpu.h'/'cpu_a.asm', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT #define'd in 'cpu.h'/
216 * 'cpu_cfg.h' to enable assembly-version function
217 *
218 * (b) 'cpu_core.h'/'cpu_core.c', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT NOT #define'd in 'cpu.h'/
219 * 'cpu_cfg.h' to enable C-source-version function otherwise
220 *********************************************************************************************************
221 */
222 
223 void CPU_Init (void);
224 
225 
226 #if (CPU_CFG_NAME_EN == DEF_ENABLED) /* ------------------ CPU NAME FNCTS ------------------ */
227 void CPU_NameClr (void);
228 
229 void CPU_NameGet (CPU_CHAR *p_name,
230  CPU_ERR *p_err);
231 
232 void CPU_NameSet (CPU_CHAR *p_name,
233  CPU_ERR *p_err);
234 #endif
235 
236 
237 #if (CPU_CFG_TS_EN == DEF_ENABLED) /* ------------------- CPU TS FNCTS ------------------- */
238 void CPU_TS_Get (CPU_TS *p_ts_lo,
239  CPU_TS *p_ts_hi);
240 
241 CPU_TS CPU_TS_GetLo (void);
242 
243 void CPU_TS_Update (void);
244 #endif
245 
246 
247 #ifdef CPU_CFG_INT_DIS_MEAS_EN /* ------------ CPU INT DIS TIME MEAS FNCTS ----------- */
248  /* See Note #1. */
249 CPU_TS CPU_IntDisMeasMaxCurReset(void);
250 
251 CPU_TS CPU_IntDisMeasMaxCurGet (void);
252 
253 CPU_TS CPU_IntDisMeasMaxGet (void);
254 
255 
256 void CPU_IntDisMeasStart (void);
257 
258 void CPU_IntDisMeasStop (void);
259 #endif
260 
261 
262 #ifndef CPU_CFG_LEAD_ZEROS_ASM_PRESENT /* ------------- CPU CNT LEAD ZEROS FNCTS ------------- */
263 CPU_DATA CPU_CntLeadZeros (CPU_DATA val); /* See Note #2. */
264 #endif
265 
266 
267 /*$PAGE*/
268 /*
269 *********************************************************************************************************
270 * FUNCTION PROTOTYPES
271 * DEFINED IN PRODUCT'S BSP
272 *********************************************************************************************************
273 */
274 
275 /*
276 *********************************************************************************************************
277 * CPU_TS_TmrInit()
278 *
279 * Description : Initialize & start CPU timestamp timer.
280 *
281 * Argument(s) : none.
282 *
283 * Return(s) : Number of left-shifts to scale & return timer as (32-bit) 'CPU_TS' data type
284 * (see Note #2a1), if necessary.
285 *
286 * 0 (see Note #2a2), otherwise.
287 *
288 * Caller(s) : CPU_TS_Init().
289 *
290 * This function is an INTERNAL CPU module function & MUST be implemented by application/
291 * BSP function(s) [see Note #1] but MUST NOT be called by application function(s).
292 *
293 * Note(s) : (1) CPU_TS_TmrInit() is an application/BSP function that MUST be defined by the developer
294 * if either of the following CPU features is enabled :
295 *
296 * (a) CPU timestamps
297 * (b) CPU interrupts disabled time measurements
298 *
299 * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1'
300 * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'.
301 *
302 * (2) (a) Timer count values MUST be scaled & returned via (32-bit) 'CPU_TS' data type.
303 *
304 * (1) If timer has less bits, left-shift timer values until the most
305 * significant bit of the timer value is shifted into the most
306 * significant bit of the return timestamp data type.
307 * (2) If timer has more bits, truncate timer values' higher-order
308 * bits greater than the return timestamp data type.
309 *
310 * (b) Timer SHOULD be an 'up' counter whose values increase with each time count.
311 *
312 * (c) When applicable, timer period SHOULD be less than the typical measured time
313 * but MUST be less than the maximum measured time; otherwise, timer resolution
314 * inadequate to measure desired times.
315 *
316 * See also 'CPU_TS_TmrRd() Note #2'.
317 *********************************************************************************************************
318 */
319 
320 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
322 #endif
323 
324 
325 /*$PAGE*/
326 /*
327 *********************************************************************************************************
328 * CPU_TS_TmrRd()
329 *
330 * Description : Get current CPU timestamp timer count value.
331 *
332 * Argument(s) : none.
333 *
334 * Return(s) : (32-bit) Timestamp timer count (see Notes #2a & #2b).
335 *
336 * Caller(s) : CPU_TS_Init(),
337 * CPU_TS_UpdateHandler(),
338 * CPU_IntDisMeasStart(),
339 * CPU_IntDisMeasStop().
340 *
341 * This function is an INTERNAL CPU module function & MUST be implemented by application/
342 * BSP function(s) [see Note #1] but SHOULD NOT be called by application function(s).
343 *
344 * Note(s) : (1) CPU_TS_TmrRd() is an application/BSP function that MUST be defined by the developer
345 * if either of the following CPU features is enabled :
346 *
347 * (a) CPU timestamps
348 * (b) CPU interrupts disabled time measurements
349 *
350 * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1'
351 * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'.
352 *
353 * (2) (a) Timer count values MUST be returned via (32-bit) 'CPU_TS' data type.
354 *
355 * (1) If timer has less bits, left-shift timer values until the most
356 * significant bit of the timer value is shifted into the most
357 * significant bit of the return timestamp data type.
358 * (2) If timer has more bits, truncate timer values' higher-order
359 * bits greater than the return timestamp data type.
360 *
361 * (b) Timer SHOULD be an 'up' counter whose values increase with each time count.
362 *
363 * (1) If timer is a 'down' counter whose values decrease with each time count,
364 * then the returned timer value MUST be ones-complemented.
365 *
366 * (c) (1) When applicable, the amount of time measured by CPU timestamps is
367 * calculated by either of the following equations :
368 *
369 * (A) Time measured = Number timer counts * Timer period
370 *
371 * where
372 *
373 * Number timer counts Number of timer counts measured
374 * Timer period Timer's period in some units of
375 * (fractional) seconds
376 * Time measured Amount of time measured, in same
377 * units of (fractional) seconds
378 * as the Timer period
379 *
380 * Number timer counts
381 * (B) Time measured = ---------------------
382 * Timer frequency
383 *
384 * where
385 *
386 * Number timer counts Number of timer counts measured
387 * Timer frequency Timer's frequency in some units
388 * of counts per second
389 * Time measured Amount of time measured, in seconds
390 *
391 * (2) Timer period SHOULD be less than the typical measured time but MUST be less
392 * than the maximum measured time; otherwise, timer resolution inadequate to
393 * measure desired times.
394 *********************************************************************************************************
395 */
396 
397 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
398 CPU_TS CPU_TS_TmrRd(void);
399 #endif
400 
401 
402 /*$PAGE*/
403 /*
404 *********************************************************************************************************
405 * CPU_TS_to_uSec()
406 *
407 * Description : Convert a CPU timestamp from timer counts to microseconds.
408 *
409 * Argument(s) : ts_lo_cnts CPU timestamp lower half (in timestamp timer counts [see Note #2aA]).
410 *
411 * ts_hi_cnts CPU timestamp upper half (in timestamp timer counts [see Note #2aA]).
412 *
413 * p_ts_lo_usec Pointer to variable that will receive the converted CPU timestamp's
414 * lower half [in microseconds (see Note #2aD)], if available.
415 *
416 * p_ts_hi_usec Pointer to variable that will receive the converted CPU timestamp's
417 * upper half [in microseconds (see Note #2aD)], if available.
418 *
419 * Return(s) : none.
420 *
421 * Caller(s) : Application.
422 *
423 * This function is an (optional) CPU module application interface (API) function which
424 * MAY be implemented by application/BSP function(s) [see Note #1] & MAY be called by
425 * application function(s).
426 *
427 * Note(s) : (1) CPU_TS_to_uSec() is an application/BSP function that MAY be optionally defined by
428 * the developer when either of the following CPU features is enabled :
429 *
430 * (a) CPU timestamps
431 * (b) CPU interrupts disabled time measurements
432 *
433 * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1'
434 * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'.
435 *
436 * (2) (a) The amount of time measured by CPU timestamps is calculated by either of
437 * the following equations :
438 *
439 * 10^6 microseconds
440 * (1) Time measured = Number timer counts * ------------------- * Timer period
441 * 1 second
442 *
443 * Number timer counts 10^6 microseconds
444 * (2) Time measured = --------------------- * -------------------
445 * Timer frequency 1 second
446 *
447 * where
448 *
449 * (A) Number timer counts Number of timer counts measured
450 * (B) Timer frequency Timer's frequency in some units
451 * of counts per second
452 * (C) Timer period Timer's period in some units of
453 * (fractional) seconds
454 * (D) Time measured Amount of time measured,
455 * in microseconds
456 *
457 * (b) Timer period SHOULD be less than the typical measured time but MUST be less
458 * than the maximum measured time; otherwise, timer resolution inadequate to
459 * measure desired times.
460 *
461 * (c) Specific implementations may convert any number of CPU timestamps bits, up
462 * to 64, into microseconds.
463 *********************************************************************************************************
464 */
465 
466 #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
467 void CPU_TS_to_uSec(CPU_TS ts_lo_cnts,
468  CPU_TS ts_hi_cnts,
469  CPU_INT32U *p_ts_lo_usec,
470  CPU_INT32U *p_ts_hi_usec);
471 #endif
472 
473 
474 /*$PAGE*/
475 /*
476 *********************************************************************************************************
477 * CONFIGURATION ERRORS
478 *********************************************************************************************************
479 */
480 
481 #ifndef CPU_CFG_NAME_EN
482 #error "CPU_CFG_NAME_EN not #define'd in 'cpu_cfg.h'"
483 #error " [MUST be DEF_ENABLED ] "
484 #error " [ || DEF_DISABLED] "
485 
486 #elif ((CPU_CFG_NAME_EN != DEF_ENABLED ) && \
487  (CPU_CFG_NAME_EN != DEF_DISABLED))
488 #error "CPU_CFG_NAME_EN illegally #define'd in 'cpu_cfg.h'"
489 #error " [MUST be DEF_ENABLED ] "
490 #error " [ || DEF_DISABLED] "
491 
492 #else
493 
494 #ifndef CPU_CFG_NAME_SIZE
495 #error "CPU_CFG_NAME_SIZE not #define'd in 'cpu_cfg.h'"
496 #error " [MUST be >= 1] "
497 #error " [ && <= 255] "
498 
499 #elif ((CPU_CFG_NAME_SIZE < 1) || \
500  (CPU_CFG_NAME_SIZE > DEF_INT_08U_MAX_VAL))
501 #error "CPU_CFG_NAME_SIZE illegally #define'd in 'cpu_cfg.h'"
502 #error " [MUST be >= 1] "
503 #error " [ && <= 255] "
504 #endif
505 
506 #endif
507 
508 
509 
510 
511 #ifndef CPU_CFG_TS_EN
512 #error "CPU_CFG_TS_EN not #define'd in 'cpu_cfg.h'"
513 #error " [MUST be DEF_DISABLED] "
514 #error " [ || DEF_ENABLED ] "
515 
516 #elif ((CPU_CFG_TS_EN != DEF_DISABLED) && \
517  (CPU_CFG_TS_EN != DEF_ENABLED ))
518 #error "CPU_CFG_TS_EN illegally #define'd in 'cpu_cfg.h'"
519 #error " [MUST be DEF_DISABLED] "
520 #error " [ || DEF_ENABLED ] "
521 
522 #endif
523 
524 
525  /* Correctly configured in 'cpu_core.h'; DO NOT MODIFY. */
526 #ifndef CPU_CFG_TS_TMR_EN
527 #error "CPU_CFG_TS_TMR_EN not #define'd in 'cpu_core.h'"
528 #error " [MUST be DEF_DISABLED] "
529 #error " [ || DEF_ENABLED ] "
530 
531 #elif ((CPU_CFG_TS_TMR_EN != DEF_DISABLED) && \
532  (CPU_CFG_TS_TMR_EN != DEF_ENABLED ))
533 #error "CPU_CFG_TS_TMR_EN illegally #define'd in 'cpu_core.h'"
534 #error " [MUST be DEF_DISABLED] "
535 #error " [ || DEF_ENABLED ] "
536 
537 #endif
538 
539 
540 
541 #ifndef CPU_CFG_INT_DIS_MEAS_EN
542 #if 0 /* Optionally configured in 'cpu_cfg.h'; DO NOT MODIFY. */
543 #error "CPU_CFG_INT_DIS_MEAS_EN not #define'd in 'cpu_cfg.h'"
544 #endif
545 
546 #else
547 
548 #ifndef CPU_CFG_INT_DIS_MEAS_OVRHD_NBR
549 #error "CPU_CFG_INT_DIS_MEAS_OVRHD_NBR not #define'd in 'cpu_cfg.h' "
550 #error " [MUST be >= CPU_TIME_MEAS_NBR_MIN]"
551 #error " [ || <= CPU_TIME_MEAS_NBR_MAX]"
552 
553 #elif ((CPU_CFG_INT_DIS_MEAS_OVRHD_NBR < CPU_TIME_MEAS_NBR_MIN) || \
554  (CPU_CFG_INT_DIS_MEAS_OVRHD_NBR > CPU_TIME_MEAS_NBR_MAX))
555 #error "CPU_CFG_INT_DIS_MEAS_OVRHD_NBR illegally #define'd in 'cpu_cfg.h' "
556 #error " [MUST be >= CPU_TIME_MEAS_NBR_MIN]"
557 #error " [ || <= CPU_TIME_MEAS_NBR_MAX]"
558 
559 #endif
560 
561 #endif
562 
563 
564 
565 
566 #ifndef CPU_CFG_LEAD_ZEROS_ASM_PRESENT
567 #if 0 /* Optionally configured in 'cpu_cfg.h'; DO NOT MODIFY. */
568 #error "CPU_CFG_LEAD_ZEROS_ASM_PRESENT not #define'd in 'cpu.h'/'cpu_cfg.h'"
569 #endif
570 #endif
571 
572 
573 /*$PAGE*/
574 /*
575 *********************************************************************************************************
576 * MODULE END
577 *********************************************************************************************************
578 */
579 
580 #endif /* End of CPU core module include. */
581