/[dtapublic]/to_be_filed/uculib01/include/stm8/cosmic/c/uculib.h
ViewVC logotype

Contents of /to_be_filed/uculib01/include/stm8/cosmic/c/uculib.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations) (download)
Sat Oct 8 07:22:17 2016 UTC (7 years, 5 months ago) by dashley
File MIME type: text/plain
File size: 13231 byte(s)
Initial commit.
1 //-------------------------------------------------------------------------------
2 //$Header: /home/dashley/cvsrep/uculib01/uculib01/include/stm8/cosmic/c/uculib.h,v 1.60 2010/06/11 18:23:19 dashley Exp $
3 //-------------------------------------------------------------------------------
4 //Copyright (c)2010 David T. Ashley
5 //
6 //Permission is hereby granted, free of charge, to any person obtaining a copy
7 //of this software source code and associated documentation files (the
8 //"Software"), to deal in the Software without restriction, including without
9 //limitation the rights to use, copy, modify, merge, publish, distribute,
10 //sublicense, and/or sell copies of the Software, and to permit persons to whom
11 //the Software is furnished to do so, subject to the following conditions:
12 //
13 //The above copyright notice and this permission notice shall be included in
14 //all copies or substantial portions of the Software.
15 //
16 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 //THE SOFTWARE.
23 //-------------------------------------------------------------------------------
24 #ifndef UCULIB_H_INCLUDED
25 #define UCULIB_H_INCLUDED
26
27 //CPU core identifiers
28 #define UCU_CPUCORE_STM8 (1)
29 #define UCU_CPUCORE_CPU08 (2)
30
31 //CPU core variant identifiers. At the present time, there are no variants.
32 #define UCU_CPUCOREVAR_STM8_BASE (1)
33 #define UCU_CPUCOREVAR_CPU08_BASE (1)
34
35 //Boolean constants.
36 #define UCU_FALSE (0)
37 #define UCU_TRUE (1)
38
39 //Library version constants. The version below is "0.1e".
40 #define UCU_LIBVER_MAJOR (0)
41 #define UCU_LIBVER_MINOR (1)
42 #define UCU_LIBVER_MICRO (4)
43 #define UCU_LIBVER_CPUCORE (UCU_CPUCORE_STM8)
44 #define UCU_LIBVER_CPUCOREVAR (UCU_CPUCOREVAR_STM8_BASE)
45
46 //Data types. Fortunately, the compiler does not seem to allow any switches on
47 //the command line to modify the types (such switches would add complexity).
48 typedef unsigned char UCU_UINT8;
49 typedef signed char UCU_SINT8;
50 typedef unsigned int UCU_UINT16;
51 typedef signed int UCU_SINT16;
52 typedef unsigned long UCU_UINT32;
53 typedef signed long UCU_SINT32;
54 typedef unsigned char UCU_BOOLEAN;
55 typedef _Bool UCU_BOOLEAN_C99;
56
57 typedef UCU_UINT8 UCU_CPU_CCR; //It takes a byte to hold the CCR.
58 typedef UCU_UINT16 UCU_CPU_SPTR_PC; //It takes 16 bits to hold the program counter stack pointer.
59
60 //Data types.
61 typedef union
62 {
63 UCU_UINT16 ui; //Largest all-encompassing value must come first so that union initialization
64 //works correctly (={0}, for example).
65 UCU_UINT8 uc[2];
66 } UCU_UNION16;
67
68 typedef union
69 {
70 UCU_UINT32 ul; //Largest all-encompassing value must come first so that union initialization
71 //works correctly (={0}, for example).
72 UCU_UINT16 ui[2];
73 UCU_UINT8 uc[4];
74 } UCU_UNION32;
75
76 typedef union
77 {
78 struct {UCU_UINT8 uc[6];} uca;
79 //Mnemonic: unsigned character array.
80 struct {UCU_UINT16 uw[3];} uwa;
81 //Mnemonic: unsigned word array.
82 struct {UCU_UINT32 ul; UCU_UINT16 uw;} uluwni;
83 //Mnemonic: unsigned long followed by unsigned word named individually.
84 struct {UCU_UINT16 uw; UCU_UINT32 ul;} uwulni;
85 //Mnemonic: unsigned word followed by unsigned long named individually.
86 } UCU_UNION48;
87
88 typedef union
89 {
90 struct {UCU_UINT8 uc[8];} uca;
91 //Mnemonic: unsigned character array.
92 struct {UCU_UINT16 uw[4];} uwa;
93 //Mnemonic: unsigned word array.
94 struct {UCU_UINT32 ul[2];} ula;
95 //Mnemonic: unsigned long array.
96 } UCU_UNION64;
97
98
99 //*******************************************************************************
100 //**** Arithmetic Functions *****************************************************
101 //*******************************************************************************
102 //UCU_UINT16 Comparison Functions
103 extern UCU_BOOLEAN UcuAtU16CmpDiffAbsGtRxx(UCU_UINT16 x1, UCU_UINT16 x2, UCU_UINT16 d);
104 //UCU_UINT16 Linear Scaling Functions, Zero Y-Offset
105 extern UCU_UINT16 UcuAtU16LscZyiFAxdAxrRxx(UCU_UINT16 arg, UCU_UINT16 arg_outof, UCU_UINT16 tgt_outof);
106 extern UCU_UINT16 UcuAtU16LscZyiRAxdAxrRxx(UCU_UINT16 arg, UCU_UINT16 arg_outof, UCU_UINT16 tgt_outof);
107 //UCU_UINT16 Ratiometric Adjustment Functions.
108 extern UCU_UINT16 UcuAtU16RatAdjRRxx(UCU_UINT16 arg, UCU_UINT16 arg_max, UCU_UINT16 adj_in, UCU_UINT16 adj_nom);
109 //UCU_UINT16 Vector Functions
110 extern UCU_UINT16 UcuAtU16v2CpDiva2FRxx(UCU_UINT16 in_a_vec_1, UCU_UINT16 in_a_vec_2, UCU_UINT16 in_g_vec_1, UCU_UINT16 in_g_vec_2);
111 //Square Root Extraction Functions
112 extern UCU_UINT8 UcuAtU8SqrtFRxx(UCU_UINT8 arg);
113 extern UCU_UINT8 UcuAtU16SqrtFRxx(UCU_UINT16 arg);
114 extern UCU_UINT16 UcuAtU16SqrtX10FRxx(UCU_UINT16 val);
115 //Trigonometric Functions
116 //UCU_UINT16 Trigonometric Functions
117 extern UCU_UINT8 UcuAtAtanIx100Odegx1RRxx(UCU_UINT16 arg);
118 //
119 //*******************************************************************************
120 //**** Bounded Arithmetic Functions *********************************************
121 //*******************************************************************************
122 //UCU_SINT8 Functions
123 extern UCU_SINT8 UcuBaS8AbsDiffBoundedRxx(UCU_SINT8 x1, UCU_SINT8 x2);
124 extern UCU_SINT8 UcuBaS8DiffBoundedRxx(UCU_SINT8 x1, UCU_SINT8 x2);
125 //UCU_SINT16 Functions
126 extern UCU_SINT16 UcuBaS16AbsDiffBoundedRxx(UCU_SINT16 x1, UCU_SINT16 x2);
127 extern UCU_SINT16 UcuBaS16DiffBoundedRxx(UCU_SINT16 x1, UCU_SINT16 x2);
128 //UCU_SINT32 Functions
129 extern UCU_SINT32 UcuBaS32AbsBoundedRxx(UCU_SINT32 x);
130 //
131 //*******************************************************************************
132 //**** Fixed-Point Arithmetic Functions *****************************************
133 //*******************************************************************************
134 //UCU_UINT16 [0,1024] [0,1] Bounded Functions
135 extern UCU_UINT16 UcuFpUm1024uProjIntoRU16aRxx(UCU_UINT16 arg, UCU_UINT16 arg_outof);
136 extern UCU_UINT16 UcuFpUm1024uMulRRxx(UCU_UINT16 arg1, UCU_UINT16 arg2);
137 //
138 //*******************************************************************************
139 //**** Large-Operand and Extended-Precision Arithmetic Functions ****************
140 //*******************************************************************************
141 //
142 //*******************************************************************************
143 //**** Block Memory Functions ***************************************************
144 //*******************************************************************************
145 //
146 //*******************************************************************************
147 //**** Bit-Mapped Set Functions *************************************************
148 //*******************************************************************************
149 //Bit set cardinality tables.
150 extern const UCU_UINT8 UcuBtU8ByteCardNibpLut[128];
151 extern const UCU_UINT32 UcuBtU32RmaskLut[33];
152 extern const UCU_UINT32 UcuBtU32BitByIndexLut[32];
153 //Bit set cardinality functions.
154 extern UCU_UINT8 UcuBtU8BitCardRxx(UCU_UINT8 arg);
155 extern UCU_UINT8 UcuBtU16BitCardRxx(UCU_UINT16 arg);
156 extern UCU_UINT8 UcuBtU32BitCardRxx(UCU_UINT32 arg);
157 extern UCU_UINT8 UcuBtU32BitCardRnRxx(UCU_UINT32 arg, UCU_UINT8 n);
158 //Rotation functions.
159 extern void UcuBtU32RotLeftNInPlaceRxn(UCU_UINT32 *tgt, UCU_UINT8 n);
160 //
161 //*******************************************************************************
162 //**** Search Functions *********************************************************
163 //*******************************************************************************
164 //
165 //*******************************************************************************
166 //**** Sort Functions ***********************************************************
167 //*******************************************************************************
168 //
169 //*******************************************************************************
170 //**** Array Manipulation Functions *********************************************
171 //*******************************************************************************
172 //Decrement But Not Below Zero Array Element Functions
173 extern void UcuAmU8aDnbzU16nRxn(UCU_UINT8 *in_arg, UCU_UINT16 in_nelem);
174 extern void UcuAmU16aDnbzU16nRxn(UCU_UINT16 *in_arg, UCU_UINT16 in_nelem);
175 extern void UcuAmU32aDnbzU16nRxn(UCU_UINT32 *in_arg, UCU_UINT16 in_nelem);
176 //Right shift functions.
177 extern void UcuAmU8aRs1U16nRxn(UCU_UINT8 *in_arr, UCU_UINT16 in_nelem, UCU_UINT8 in_pushval);
178 extern void UcuAmU16aRs1U16nRxn(UCU_UINT16 *in_arr, UCU_UINT16 in_nelem, UCU_UINT16 in_pushval);
179 //Average Functions
180 extern UCU_UINT16 UcuAmU16aAvgFU16nRxn(const UCU_UINT16 *in_array, UCU_UINT16 in_nelem);
181 extern UCU_UINT16 UcuAmU16aAvgFDmmU16nRxn(const UCU_UINT16 *in_array, UCU_UINT16 in_nelem);
182 extern void UcuAmU16aAvgFDmmRmmU16nRxn(const UCU_UINT16 *in_array,
183 UCU_UINT16 in_nelem,
184 UCU_UINT16 *out_avg,
185 UCU_UINT16 *out_el_min,
186 UCU_UINT16 *out_el_max);
187 //
188 //*******************************************************************************
189 //**** Linear Filter Functions **************************************************
190 //*******************************************************************************
191 //Linear Filter A
192 extern void UcuLfU16FiltAInitRxn(UCU_UNION48 *in_fs, UCU_UINT16 in_x_k_initial);
193 extern UCU_UINT16 UcuLfU16FiltAFiltRxn(UCU_UNION48 *in_fs, UCU_UINT16 in_x_k, UCU_UINT16 in_h);
194 //
195 //*******************************************************************************
196 //**** Non-Linear Filter Functions **********************************************
197 //*******************************************************************************
198 //
199 //*******************************************************************************
200 //**** Vertical Counter Functions ***********************************************
201 //*******************************************************************************
202 //
203 //*******************************************************************************
204 //**** Control System Component Functions ***************************************
205 //*******************************************************************************
206 //
207 //*******************************************************************************
208 //**** CRC, Checksum, and Non-Cryptographic Hash Functions **********************
209 //*******************************************************************************
210 //
211 //*******************************************************************************
212 //**** Cryptographic Hash Functions *********************************************
213 //*******************************************************************************
214 //
215 //*******************************************************************************
216 //**** Cipher Functions *********************************************************
217 //*******************************************************************************
218 //
219 //*******************************************************************************
220 //**** Miscellaneous Functions **************************************************
221 //*******************************************************************************
222 //Library version functions.
223 extern UCU_UINT16 UcuMfLibVerMajRxx(void);
224 extern UCU_UINT16 UcuMfLibVerMinMicRxx(void);
225 extern UCU_UINT16 UcuMfLibVerCpuRxx(void);
226 extern UCU_BOOLEAN UcuMfLibVerCmpRxx(UCU_UINT16 in_majorversion,
227 UCU_UINT8 in_minorversion,
228 UCU_UINT8 in_microversion,
229 UCU_UINT8 in_cpucore,
230 UCU_UINT8 in_cpucorevariant);
231 //CPU register manipulation functions.
232 extern UCU_CPU_CCR UcuMfCpuCcrGetRxx(void);
233 extern void UcuMfCpuCcrSetRxx(UCU_CPU_CCR in_ccr);
234 extern UCU_CPU_SPTR_PC UcuMfCpuSptrPcGetRxx(void);
235 //
236 //*******************************************************************************
237 //**** Utility Functions ********************************************************
238 //*******************************************************************************
239 //
240 //*******************************************************************************
241 //*******************************************************************************
242 //*******************************************************************************
243
244 #endif
245
246 //-------------------------------------------------------------------------------
247 //End of $Id: uculib.h,v 1.60 2010/06/11 18:23:19 dashley Exp $
248 //-------------------------------------------------------------------------------
249

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25