1 /* --COPYRIGHT--,BSD
2 * Copyright (c) $(CPYYEAR), Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * --/COPYRIGHT--*/
32 /*
33 * ======== Transformer.xdc ========
34 */
35
36 import xdc.rov.ViewInfo;
37
38 import xdc.runtime.Error;
39 import ti.sdo.io.IConverter;
40
41 /*!
42 * Transformer module
43 *
44 * This module allows the user to create instances which modify a data stream
45 * by applying a function to each point produced or consumed by an underlying
46 * driver. The number of transformer instances in the system is limited only
47 * by the availability of memory;
48 *
49 * This module implements {@link ti.sdo.io.IConverter} interface and as such is
50 * only usable with {@link ti.sdo.io.Stream}. IConverter instances are added to
51 * a table within Stream and they can be linked together to form an IO
52 * stack/chain.
53 *
54 * For example, is "/scale" is a Transformer instance in the stream table
55 * and "/adc" is a driver in {@link ti.sdo.io.DriverTable} then the name
56 * "/scale/adc" can be used to create a Stream instance.
57 *
58 * For every Transformer instance the user can supply a tranfer function.
59 * Transformer provides three of these functions - {@link #multiply},
60 * {@link #fix2flt} and {@link #flt2fix}.
61 */
62
63 module Transformer inherits IConverter
64 {
65 /*! typedefs for transformer function
66 *
67 * Functions of this type get passed the buffer, buffer size and a
68 * function specific argument. The function should NOT act on the buffer
69 * if buffer is NULL or buffer size is zero.
70 */
71 typedef Void (*TransFunc)(Ptr, SizeT, UArg);
72
73 metaonlystruct BasicView {
74 String label;
75 Ptr lowerConverter;
76 String mode;
77 String callbackFxn[];
78 UArg callbackArg;
79 String transformFxn[];
80 UArg transformArg;
81 }
82
83 @Facet
84 metaonlyconfig ViewInfo.Instance rovViewInfo =
85 ViewInfo.create({
86 viewMap: [
87 ['Basic', {type: ViewInfo.INSTANCE, viewInitFxn: 'viewInitBasic', structName: 'BasicView'}],
88 ]
89 });
90
91 /*!
92 * ======== multiply ========
93 * multiply function mutiples each data point with a scale value
94 *
95 * This function casts the scaleFactor to a UInt before using it.
96 * If arg is NULL a scaleFactor of 1 is used.
97 */
98 Void multiply(Ptr addr, SizeT size, UArg scaleFactor);
99
100 /*!
101 * ======== fix2flt ========
102 * fix2flt converts each data point from fixed point to floating point
103 *
104 * This function ignores the scaleFactor.
105 */
106 Void fix2flt(Ptr addr, SizeT size, UArg scaleFactor);
107
108 /*!
109 * ======== flt2fix ========
110 * flt2fix converts each data point from floating point to fixed point
111 *
112 * This function ignores the scaleFactor.
113 */
114 Void flt2fix(Ptr addr, SizeT size, UArg scalePtr);
115
116 instance:
117 /*!
118 * Function can be {@link #multiply}, {@link #fix2flt}
119 * or {@link #flt2fix} or a user specific function.
120 */
121 config TransFunc fxn = null;
122
123 /*!
124 * Arg to be used with transform functions.
125 */
126 config UArg arg = null;
127
128 internal:
129
130 /*!
131 * ======== callback ========
132 * @_nodoc 133 * callback function for lower IConverter instance.
134 *
135 * @param(cbArg) callback argument
136 */
137 Void callback(UArg cbArg);
138
139 // -------- Internal Structures --------
140 struct Instance_State {
141 IConverter.Handle convHandle; /* handle for IConverter */
142 Bool drvAdapHdl; /* created DriverAdapter */
143 UInt mode;
144 IConverter.DoneFxn cbFxn;
145 UArg cbArg;
146 TransFunc fxn; /* transform function */
147 UArg arg; /* transform func arg */
148 };
149 }