UCOS_TI_LM3S_Keil
 全部 结构体 文件 函数 变量 类型定义 宏定义 
lib_math.h
浏览该文件的文档.
1 /*
2 *********************************************************************************************************
3 * uC/LIB
4 * CUSTOM LIBRARY MODULES
5 *
6 * (c) Copyright 2004-2009; Micrium, Inc.; Weston, FL
7 *
8 * All rights reserved. Protected by international copyright laws.
9 *
10 * uC/LIB is provided in source form for FREE evaluation, for educational
11 * use or peaceful research. If you plan on using uC/LIB 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/LIB. 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 * MATHEMATIC OPERATIONS
28 *
29 * Filename : lib_math.h
30 * Version : V1.30
31 * Programmer(s) : SR
32 * ITJ
33 *********************************************************************************************************
34 * Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
35 *
36 * (a) ALL standard library functions are implemented in the custom library modules :
37 *
38 * (1) <Custom Library Directory>\lib*.*
39 *
40 * (2) <Custom Library Directory>\Ports<cpu><compiler>\lib*_a.*
41 *
42 * where
43 * <Custom Library Directory> directory path for custom library software
44 * <cpu> directory name for specific processor (CPU)
45 * <compiler> directory name for specific compiler
46 *
47 * (b) Product-specific library functions are implemented in individual products.
48 *
49 *********************************************************************************************************
50 * Notice(s) : (1) The Institute of Electrical and Electronics Engineers and The Open Group, have given
51 * us permission to reprint portions of their documentation. Portions of this text are
52 * reprinted and reproduced in electronic form from the IEEE Std 1003.1, 2004 Edition,
53 * Standard for Information Technology -- Portable Operating System Interface (POSIX),
54 * The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute
55 * of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any
56 * discrepancy between these versions and the original IEEE and The Open Group Standard,
57 * the original IEEE and The Open Group Standard is the referee document. The original
58 * Standard can be obtained online at http://www.opengroup.org/unix/online.html.
59 *********************************************************************************************************
60 */
61 
62 
63 /*
64 *********************************************************************************************************
65 * MODULE
66 *********************************************************************************************************
67 */
68 
69 #ifndef LIB_MATH_MODULE_PRESENT
70 #define LIB_MATH_MODULE_PRESENT
71 
72 
73 /*$PAGE*/
74 /*
75 *********************************************************************************************************
76 * INCLUDE FILES
77 *
78 * Note(s) : (1) The following common software files are located in the following directories :
79 *
80 * (a) <Custom Library Directory>\lib*.*
81 *
82 * (b) (1) <CPU-Compiler Directory>\cpu_def.h
83 *
84 * (2) <CPU-Compiler Directory><cpu><compiler>\cpu*.*
85 *
86 * where
87 * <Custom Library Directory> directory path for custom library software
88 * <CPU-Compiler Directory> directory path for common CPU-compiler software
89 * <cpu> directory name for specific processor (CPU)
90 * <compiler> directory name for specific compiler
91 *
92 * (2) Compiler MUST be configured to include the '<Custom Library Directory>\uC-LIB\',
93 * '<CPU-Compiler Directory>\' directory, & the specific CPU-compiler directory as
94 * additional include path directories.
95 *
96 * (3) NO compiler-supplied standard library functions SHOULD be used.
97 *********************************************************************************************************
98 */
99 
100 #include <cpu.h>
101 #include <cpu_core.h>
102 
103 #include <lib_def.h>
104 
105 
106 /*
107 *********************************************************************************************************
108 * EXTERNS
109 *********************************************************************************************************
110 */
111 
112 #ifdef LIB_MATH_MODULE
113 #define LIB_MATH_EXT
114 #else
115 #define LIB_MATH_EXT extern
116 #endif
117 
118 
119 /*$PAGE*/
120 /*
121 *********************************************************************************************************
122 * DEFINES
123 *********************************************************************************************************
124 */
125 
126 /*
127 *********************************************************************************************************
128 * RANDOM NUMBER DEFINES
129 *
130 * Note(s) : (1) (a) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that "if rand()
131 * is called before any calls to srand() are made, the same sequence shall be generated
132 * as when srand() is first called with a seed value of 1".
133 *
134 * (b) (1) BSD/ANSI-C implements rand() as a Linear Congruential Generator (LCG) :
135 *
136 * (A) random_number = [(a * random_number ) + b] modulo m
137 * n + 1 n
138 *
139 * where
140 * (1) (a) random_number Next random number to generate
141 * n+1
142 * (b) random_number Previous random number generated
143 * n
144 * (c) random_number Initial random number seed
145 * 0 See also Note #1a
146 *
147 * (2) a = 1103515245 LCG multiplier
148 * (3) b = 12345 LCG incrementor
149 * (4) m = RAND_MAX + 1 LCG modulus See also Note #1b2
150 *
151 * (2) (A) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that
152 * "rand() ... shall compute a sequence of pseudo-random integers in the range
153 * [0, {RAND_MAX}] with a period of at least 2^32".
154 *
155 * (B) However, BSD/ANSI-C 'stdlib.h' defines "RAND_MAX" as "0x7fffffff", or 2^31;
156 * which therefore limits the range AND period to no more than 2^31.
157 *********************************************************************************************************
158 */
159 
160 #define RAND_SEED_INIT_VAL 1u /* See Note #1a. */
161 
162 #define RAND_LCG_PARAM_M 0x7FFFFFFFu /* See Note #1b2B. */
163 #define RAND_LCG_PARAM_A 1103515245u /* See Note #1b1A2. */
164 #define RAND_LCG_PARAM_B 12345u /* See Note #1b1A3. */
165 
166 
167 /*$PAGE*/
168 /*
169 *********************************************************************************************************
170 * DATA TYPES
171 *********************************************************************************************************
172 */
173 
174 /*
175 *********************************************************************************************************
176 * RANDOM NUMBER DATA TYPE
177 *********************************************************************************************************
178 */
179 
181 
182 
183 /*
184 *********************************************************************************************************
185 * GLOBAL VARIABLES
186 *********************************************************************************************************
187 */
188 
189 
190 /*
191 *********************************************************************************************************
192 * FUNCTION PROTOTYPES
193 *********************************************************************************************************
194 */
195 
196 void Math_Init (void);
197 
198  /* ------------------ RAND NBR FNCTS ------------------ */
199 void Math_RandSetSeed(RAND_NBR seed);
200 
201 RAND_NBR Math_Rand (void);
202 
204 
205 
206 /*$PAGE*/
207 /*
208 *********************************************************************************************************
209 * CONFIGURATION ERRORS
210 *********************************************************************************************************
211 */
212 
213 
214 /*
215 *********************************************************************************************************
216 * MODULE END
217 *********************************************************************************************************
218 */
219 
220 #endif /* End of lib math module include. */
221