##// END OF EJS Templates
updates for the compliance with the spectral matrix VHDL design
paul -
r150:035669d03c81 VHDLib206
parent child
Show More
@@ -1,273 +1,273
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 09:16:01 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 15:44:22 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=10 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_misc.c \
49 49 ../src/fsw_init.c \
50 50 ../src/fsw_globals.c \
51 51 ../src/fsw_spacewire.c \
52 52 ../src/tc_load_dump_parameters.c \
53 53 ../src/tm_lfr_tc_exe.c \
54 54 ../src/tc_acceptance.c \
55 55 ../src/processing/fsw_processing.c \
56 56 ../src/processing/avf0_prc0.c \
57 57 ../src/processing/avf1_prc1.c \
58 58 ../src/processing/avf2_prc2.c \
59 59 ../src/lfr_cpu_usage_report.c \
60 60 ../src/LFR_basic-parameters/basic_parameters.c
61 61 OBJECTS = obj/wf_handler.o \
62 62 obj/tc_handler.o \
63 63 obj/fsw_misc.o \
64 64 obj/fsw_init.o \
65 65 obj/fsw_globals.o \
66 66 obj/fsw_spacewire.o \
67 67 obj/tc_load_dump_parameters.o \
68 68 obj/tm_lfr_tc_exe.o \
69 69 obj/tc_acceptance.o \
70 70 obj/fsw_processing.o \
71 71 obj/avf0_prc0.o \
72 72 obj/avf1_prc1.o \
73 73 obj/avf2_prc2.o \
74 74 obj/lfr_cpu_usage_report.o \
75 75 obj/basic_parameters.o
76 76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 77 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 82 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 88 sparc.pri \
89 89 /usr/lib64/qt4/mkspecs/features/release.prf \
90 90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 91 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 94 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 95 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 97 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 99 fsw-qt.pro
100 100 QMAKE_TARGET = fsw
101 101 DESTDIR = bin/
102 102 TARGET = bin/fsw
103 103
104 104 first: all
105 105 ####### Implicit rules
106 106
107 107 .SUFFIXES: .o .c .cpp .cc .cxx .C
108 108
109 109 .cpp.o:
110 110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 111
112 112 .cc.o:
113 113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114 114
115 115 .cxx.o:
116 116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117 117
118 118 .C.o:
119 119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120 120
121 121 .c.o:
122 122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123 123
124 124 ####### Build rules
125 125
126 126 all: Makefile $(TARGET)
127 127
128 128 $(TARGET): $(OBJECTS)
129 129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131 131
132 132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 133 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 138 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 144 sparc.pri \
145 145 /usr/lib64/qt4/mkspecs/features/release.prf \
146 146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 147 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 150 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 151 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 153 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 156 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 157 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 162 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 168 sparc.pri:
169 169 /usr/lib64/qt4/mkspecs/features/release.prf:
170 170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 171 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 174 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 175 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 177 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 179 qmake: FORCE
180 180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181 181
182 182 dist:
183 183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
185 185
186 186
187 187 clean:compiler_clean
188 188 -$(DEL_FILE) $(OBJECTS)
189 189 -$(DEL_FILE) *~ core *.core
190 190
191 191
192 192 ####### Sub-libraries
193 193
194 194 distclean: clean
195 195 -$(DEL_FILE) $(TARGET)
196 196 -$(DEL_FILE) Makefile
197 197
198 198
199 199 grmon:
200 200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201 201
202 202 check: first
203 203
204 204 compiler_rcc_make_all:
205 205 compiler_rcc_clean:
206 206 compiler_uic_make_all:
207 207 compiler_uic_clean:
208 208 compiler_image_collection_make_all: qmake_image_collection.cpp
209 209 compiler_image_collection_clean:
210 210 -$(DEL_FILE) qmake_image_collection.cpp
211 211 compiler_yacc_decl_make_all:
212 212 compiler_yacc_decl_clean:
213 213 compiler_yacc_impl_make_all:
214 214 compiler_yacc_impl_clean:
215 215 compiler_lex_make_all:
216 216 compiler_lex_clean:
217 217 compiler_clean:
218 218
219 219 ####### Compile
220 220
221 221 obj/wf_handler.o: ../src/wf_handler.c
222 222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223 223
224 224 obj/tc_handler.o: ../src/tc_handler.c
225 225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226 226
227 227 obj/fsw_misc.o: ../src/fsw_misc.c
228 228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229 229
230 230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232 232
233 233 obj/fsw_globals.o: ../src/fsw_globals.c
234 234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235 235
236 236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238 238
239 239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241 241
242 242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244 244
245 245 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247 247
248 248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250 250
251 251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253 253
254 254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256 256
257 257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259 259
260 260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262 262
263 263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265 265
266 266 ####### Install
267 267
268 268 install: FORCE
269 269
270 270 uninstall: FORCE
271 271
272 272 FORCE:
273 273
@@ -1,201 +1,201
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-06-16T07:35:26. -->
3 <!-- Written by QtCreator 3.0.1, 2014-06-16T15:53:55. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 118 </valuemap>
119 119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 126 </valuemap>
127 127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 131 </valuemap>
132 132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 153 <value type="int">0</value>
154 154 <value type="int">1</value>
155 155 <value type="int">2</value>
156 156 <value type="int">3</value>
157 157 <value type="int">4</value>
158 158 <value type="int">5</value>
159 159 <value type="int">6</value>
160 160 <value type="int">7</value>
161 161 <value type="int">8</value>
162 162 <value type="int">9</value>
163 163 <value type="int">10</value>
164 164 <value type="int">11</value>
165 165 <value type="int">12</value>
166 166 <value type="int">13</value>
167 167 <value type="int">14</value>
168 168 </valuelist>
169 169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
181 181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
182 182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 187 </valuemap>
188 188 </data>
189 189 <data>
190 190 <variable>ProjectExplorer.Project.TargetCount</variable>
191 191 <value type="int">1</value>
192 192 </data>
193 193 <data>
194 194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
195 195 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
196 196 </data>
197 197 <data>
198 198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
199 199 <value type="int">15</value>
200 200 </data>
201 201 </qtcreator>
@@ -1,109 +1,109
1 1 #ifndef GRLIB_REGS_H_INCLUDED
2 2 #define GRLIB_REGS_H_INCLUDED
3 3
4 4 #define NB_GPTIMER 3
5 5
6 6 struct apbuart_regs_str{
7 7 volatile unsigned int data;
8 8 volatile unsigned int status;
9 9 volatile unsigned int ctrl;
10 10 volatile unsigned int scaler;
11 11 volatile unsigned int fifoDebug;
12 12 };
13 13
14 14 struct grgpio_regs_str{
15 15 volatile int io_port_data_register;
16 16 int io_port_output_register;
17 17 int io_port_direction_register;
18 18 int interrupt_mak_register;
19 19 int interrupt_polarity_register;
20 20 int interrupt_edge_register;
21 21 int bypass_register;
22 22 int reserved;
23 23 // 0x20-0x3c interrupt map register(s)
24 24 };
25 25
26 26 typedef struct {
27 27 volatile unsigned int counter;
28 28 volatile unsigned int reload;
29 29 volatile unsigned int ctrl;
30 30 volatile unsigned int unused;
31 31 } timer_regs_t;
32 32
33 33 typedef struct {
34 34 volatile unsigned int scaler_value;
35 35 volatile unsigned int scaler_reload;
36 36 volatile unsigned int conf;
37 37 volatile unsigned int unused0;
38 38 timer_regs_t timer[NB_GPTIMER];
39 39 } gptimer_regs_t;
40 40
41 41 typedef struct {
42 42 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
43 43 volatile int coarse_time_load;
44 44 volatile int coarse_time;
45 45 volatile int fine_time;
46 46 } time_management_regs_t;
47 47
48 48 typedef struct {
49 49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
50 50 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
51 51 volatile int addr_data_f0; // 0x08 10 ***
52 52 volatile int addr_data_f1; // 0x0c 11 ***
53 53 volatile int addr_data_f2; // 0x10 100 ***
54 54 volatile int addr_data_f3; // 0x14 101 ***
55 55 volatile int status; // 0x18 110 ***
56 56 volatile int delta_snapshot; // 0x1c 111 ***
57 57 volatile int delta_f2_f1; // 0x20 0000 ***
58 58 volatile int delta_f2_f0; // 0x24 0001 ***
59 59 volatile int nb_burst_available;// 0x28 0010 ***
60 60 volatile int nb_snapshot_param; // 0x2c 0011 ***
61 61 } waveform_picker_regs_t;
62 62
63 63 typedef struct{
64 64 int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
65 65 int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
66 66 int addr_data_f0; // 0x08
67 67 int addr_data_f1; // 0x0c
68 68 int addr_data_f2; // 0x10
69 69 int addr_data_f3; // 0x14
70 70 volatile int status; // 0x18
71 71 int delta_snapshot; // 0x1c
72 72 int delta_f0; // 0x20
73 73 int delta_f0_2; // 0x24
74 74 int delta_f1; // 0x28
75 75 int delta_f2; // 0x2c
76 76 int nb_data_by_buffer; // 0x30
77 77 int snapshot_param; // 0x34
78 78 int start_date; // 0x38
79 79 int nb_word_in_buffer; // 0x3c
80 80 } waveform_picker_regs_new_t;
81 81
82 82 typedef struct {
83 83 volatile int config; // 0x00
84 84 volatile int status; // 0x04
85 85 volatile int f0_0_address; // 0x08
86 86 volatile int f0_1_address; // 0x0C
87 87 //
88 88 volatile int f1_0_address; // 0x10
89 89 volatile int f1_1_address; // 0x14
90 90 volatile int f2_0_address; // 0x18
91 91 volatile int f2_1_address; // 0x1C
92 92 //
93 volatile int f0_0_coarse_time; // 0x20
94 volatile int f0_0_fine_time; // 0x24
95 volatile int f0_1_coarse_time; // 0x28
96 volatile int f0_1_fine_time; // 0x2C
93 volatile unsigned int f0_0_coarse_time; // 0x20
94 volatile unsigned int f0_0_fine_time; // 0x24
95 volatile unsigned int f0_1_coarse_time; // 0x28
96 volatile unsigned int f0_1_fine_time; // 0x2C
97 97 //
98 volatile int f1_0_coarse_time; // 0x30
99 volatile int f1_0_fine_time; // 0x34
100 volatile int f1_1_coarse_time; // 0x38
101 volatile int f1_1_time_time; // 0x3C
98 volatile unsigned int f1_0_coarse_time; // 0x30
99 volatile unsigned int f1_0_fine_time; // 0x34
100 volatile unsigned int f1_1_coarse_time; // 0x38
101 volatile unsigned int f1_1_time_time; // 0x3C
102 102 //
103 volatile int f2_0_coarse_time; // 0x40
104 volatile int f2_0_fine_time; // 0x44
105 volatile int f2_1_coarse_time; // 0x48
106 volatile int f2_1_time_time; // 0x4C
103 volatile unsigned int f2_0_coarse_time; // 0x40
104 volatile unsigned int f2_0_fine_time; // 0x44
105 volatile unsigned int f2_1_coarse_time; // 0x48
106 volatile unsigned int f2_1_fine_time; // 0x4C
107 107 } spectral_matrix_regs_t;
108 108
109 109 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,36 +1,36
1 1 #ifndef AVF0_PRC0_H_INCLUDED
2 2 #define AVF0_PRC0_H_INCLUDED
3 3
4 4 #include "fsw_processing.h"
5 5 #include "basic_parameters.h"
6 6
7 7 typedef struct {
8 8 unsigned int norm_bp1;
9 9 unsigned int norm_bp2;
10 10 unsigned int norm_asm;
11 11 unsigned int burst_sbm_bp1;
12 12 unsigned int burst_sbm_bp2;
13 13 unsigned int burst_bp1;
14 14 unsigned int burst_bp2;
15 15 unsigned int sbm1_bp1;
16 16 unsigned int sbm1_bp2;
17 17 unsigned int sbm2_bp1;
18 18 unsigned int sbm2_bp2;
19 19 } nb_sm_before_bp_asm_f0;
20 20
21 21 //************
22 22 // RTEMS TASKS
23 23 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
24 24 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
25 25
26 26 //**********
27 27 // FUNCTIONS
28 28
29 29 void reset_nb_sm_f0( unsigned char lfrMode );
30 30
31 31 //*******
32 32 // EXTERN
33 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
33 extern ring_node_sm *ring_node_for_averaging_sm_f0;
34 34 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
35 35
36 36 #endif // AVF0_PRC0_H_INCLUDED
@@ -1,243 +1,243
1 1 #ifndef FSW_PROCESSING_H_INCLUDED
2 2 #define FSW_PROCESSING_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <math.h>
7 7 #include <stdlib.h> // abs() is in the stdlib
8 8 #include <stdio.h> // printf()
9 9 #include <math.h>
10 10
11 11 #include "fsw_params.h"
12 12 #include "fsw_spacewire.h"
13 13
14 14 typedef struct ring_node_sm
15 15 {
16 16 struct ring_node_sm *previous;
17 17 struct ring_node_sm *next;
18 18 int buffer_address;
19 19 unsigned int status;
20 20 unsigned int coarseTime;
21 21 unsigned int fineTime;
22 22 } ring_node_sm;
23 23
24 24 typedef struct ring_node_asm
25 25 {
26 26 struct ring_node_asm *next;
27 27 float matrix[ TOTAL_SIZE_SM ];
28 28 unsigned int status;
29 29 } ring_node_asm;
30 30
31 31 typedef struct
32 32 {
33 33 Header_TM_LFR_SCIENCE_BP_t header;
34 34 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
35 35 } bp_packet;
36 36
37 37 typedef struct
38 38 {
39 39 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
40 40 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
41 41 } bp_packet_with_spare;
42 42
43 43 typedef struct
44 44 {
45 45 ring_node_asm *norm;
46 46 ring_node_asm *burst_sbm;
47 47 rtems_event_set event;
48 48 unsigned int coarseTime;
49 49 unsigned int fineTime;
50 50 } asm_msg;
51 51
52 52 extern volatile int sm_f0[ ];
53 53 extern volatile int sm_f1[ ];
54 54 extern volatile int sm_f2[ ];
55 55
56 56 // parameters
57 57 extern struct param_local_str param_local;
58 58
59 59 // registers
60 60 extern time_management_regs_t *time_management_regs;
61 61 extern spectral_matrix_regs_t *spectral_matrix_regs;
62 62
63 63 extern rtems_name misc_name[5];
64 64 extern rtems_id Task_id[20]; /* array of task ids */
65 65
66 66 // ISR
67 67 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
68 68 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
69 69
70 70 //******************
71 71 // Spectral Matrices
72 72 void reset_nb_sm( void );
73 73 // SM
74 74 void SM_init_rings( void );
75 75 void SM_reset_current_ring_nodes( void );
76 76 void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] );
77 77 // ASM
78 78 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
79 79 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
80 80 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
81 81 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
82 82
83 83 //*****************
84 84 // Basic Parameters
85 85
86 86 void BP_reset_current_ring_nodes( void );
87 87 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
88 88 unsigned int apid, unsigned char sid,
89 89 unsigned int packetLength , unsigned char blkNr);
90 90 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
91 91 unsigned int apid, unsigned char sid,
92 92 unsigned int packetLength, unsigned char blkNr );
93 93 void BP_send( char *data,
94 94 rtems_id queue_id ,
95 95 unsigned int nbBytesToSend , unsigned int sid );
96 96
97 97 //******************
98 98 // general functions
99 99 void reset_spectral_matrix_regs( void );
100 100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
102 102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode);
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
104 104 unsigned char getSID( rtems_event_set event );
105 105
106 106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
107 107 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
108 108
109 109 //***************************************
110 110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
111 static inline void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
111 static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
112 112 ring_node_sm *ring_node_tab[],
113 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
113 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
114 114 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
115 115 float divider );
116 116 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
117 117 float divider,
118 118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
119 119 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
120 120
121 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
121 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
122 122 ring_node_sm *ring_node_tab[],
123 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
123 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
124 124 {
125 125 float sum;
126 126 unsigned int i;
127 127
128 128 for(i=0; i<TOTAL_SIZE_SM; i++)
129 129 {
130 130 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
131 131 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
132 132 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
133 133 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
134 134 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
135 135 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
136 136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
137 137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
138 138
139 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
139 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
140 140 {
141 averaged_spec_mat_f0[ i ] = sum;
142 averaged_spec_mat_f1[ i ] = sum;
141 averaged_spec_mat_NORM[ i ] = sum;
142 averaged_spec_mat_SBM[ i ] = sum;
143 143 }
144 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
144 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
145 145 {
146 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
147 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
146 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
147 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
148 148 }
149 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
149 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
150 150 {
151 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
152 averaged_spec_mat_f1[ i ] = sum;
151 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
152 averaged_spec_mat_SBM[ i ] = sum;
153 153 }
154 154 else
155 155 {
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
157 157 }
158 158 }
159 159 }
160 160
161 161 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
162 162 {
163 163 int frequencyBin;
164 164 int asmComponent;
165 165 unsigned int offsetAveragedSpecMatReorganized;
166 166 unsigned int offsetAveragedSpecMat;
167 167
168 168 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
169 169 {
170 170 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
171 171 {
172 172 offsetAveragedSpecMatReorganized =
173 173 frequencyBin * NB_VALUES_PER_SM
174 174 + asmComponent;
175 175 offsetAveragedSpecMat =
176 176 asmComponent * NB_BINS_PER_SM
177 177 + frequencyBin;
178 178 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
179 179 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
180 180 }
181 181 }
182 182 }
183 183
184 184 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
185 185 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
186 186 {
187 187 int frequencyBin;
188 188 int asmComponent;
189 189 int offsetASM;
190 190 int offsetCompressed;
191 191 int k;
192 192
193 193 // build data
194 194 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
195 195 {
196 196 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
197 197 {
198 198 offsetCompressed = // NO TIME OFFSET
199 199 frequencyBin * NB_VALUES_PER_SM
200 200 + asmComponent;
201 201 offsetASM = // NO TIME OFFSET
202 202 asmComponent * NB_BINS_PER_SM
203 203 + ASMIndexStart
204 204 + frequencyBin * nbBinsToAverage;
205 205 compressed_spec_mat[ offsetCompressed ] = 0;
206 206 for ( k = 0; k < nbBinsToAverage; k++ )
207 207 {
208 208 compressed_spec_mat[offsetCompressed ] =
209 209 ( compressed_spec_mat[ offsetCompressed ]
210 210 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
211 211 }
212 212 }
213 213 }
214 214 }
215 215
216 216 void ASM_convert( volatile float *input_matrix, char *output_matrix)
217 217 {
218 218 unsigned int frequencyBin;
219 219 unsigned int asmComponent;
220 220 char * pt_char_input;
221 221 char * pt_char_output;
222 222 unsigned int offsetInput;
223 223 unsigned int offsetOutput;
224 224
225 225 pt_char_input = (char*) &input_matrix;
226 226 pt_char_output = (char*) &output_matrix;
227 227
228 228 // convert all other data
229 229 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
230 230 {
231 231 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
232 232 {
233 233 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
234 234 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
235 235 pt_char_input = (char*) &input_matrix [ offsetInput ];
236 236 pt_char_output = (char*) &output_matrix[ offsetOutput ];
237 237 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
238 238 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
239 239 }
240 240 }
241 241 }
242 242
243 243 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,615 +1,621
1 1 /** General usage functions and RTEMS tasks.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 */
7 7
8 8 #include "fsw_misc.h"
9 9
10 10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 12 {
13 13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 14 *
15 15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 18 * @param interrupt_level is the interrupt level that the timer drives.
19 19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 20 *
21 21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 22 *
23 23 */
24 24
25 25 rtems_status_code status;
26 26 rtems_isr_entry old_isr_handler;
27 27
28 28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29 29
30 30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 31 if (status!=RTEMS_SUCCESSFUL)
32 32 {
33 33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 34 }
35 35
36 36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
37 37 }
38 38
39 39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
40 40 {
41 41 /** This function starts a GPTIMER timer.
42 42 *
43 43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 45 *
46 46 */
47 47
48 48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 53 }
54 54
55 55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
56 56 {
57 57 /** This function stops a GPTIMER timer.
58 58 *
59 59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 61 *
62 62 */
63 63
64 64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 67 }
68 68
69 69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
70 70 {
71 71 /** This function sets the clock divider of a GPTIMER timer.
72 72 *
73 73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 76 *
77 77 */
78 78
79 79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 80 }
81 81
82 82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
83 83 {
84 84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
85 85
86 86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
87 87
88 88 return 0;
89 89 }
90 90
91 91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
92 92 {
93 93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
94 94
95 95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
96 96
97 97 return 0;
98 98 }
99 99
100 100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
101 101 {
102 102 /** This function sets the scaler reload register of the apbuart module
103 103 *
104 104 * @param regs is the address of the apbuart registers in memory
105 105 * @param value is the value that will be stored in the scaler register
106 106 *
107 107 * The value shall be set by the software to get data on the serial interface.
108 108 *
109 109 */
110 110
111 111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
112 112
113 113 apbuart_regs->scaler = value;
114 114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
115 115 }
116 116
117 117 //************
118 118 // RTEMS TASKS
119 119
120 120 rtems_task stat_task(rtems_task_argument argument)
121 121 {
122 122 int i;
123 123 int j;
124 124 i = 0;
125 125 j = 0;
126 126 BOOT_PRINTF("in STAT *** \n")
127 127 while(1){
128 128 rtems_task_wake_after(1000);
129 129 PRINTF1("%d\n", j)
130 130 if (i == CPU_USAGE_REPORT_PERIOD) {
131 131 // #ifdef PRINT_TASK_STATISTICS
132 132 // rtems_cpu_usage_report();
133 133 // rtems_cpu_usage_reset();
134 134 // #endif
135 135 i = 0;
136 136 }
137 137 else i++;
138 138 j++;
139 139 }
140 140 }
141 141
142 142 rtems_task hous_task(rtems_task_argument argument)
143 143 {
144 144 rtems_status_code status;
145 145 rtems_id queue_id;
146 146 rtems_rate_monotonic_period_status period_status;
147 147
148 148 status = get_message_queue_id_send( &queue_id );
149 149 if (status != RTEMS_SUCCESSFUL)
150 150 {
151 151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 152 }
153 153
154 154 BOOT_PRINTF("in HOUS ***\n")
155 155
156 156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 158 if( status != RTEMS_SUCCESSFUL ) {
159 159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
160 160 }
161 161 }
162 162
163 163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 174 housekeeping_packet.serviceType = TM_TYPE_HK;
175 175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 177 housekeeping_packet.sid = SID_HK;
178 178
179 179 status = rtems_rate_monotonic_cancel(HK_id);
180 180 if( status != RTEMS_SUCCESSFUL ) {
181 181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 182 }
183 183 else {
184 184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 185 }
186 186
187 187 // startup phase
188 188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 192 {
193 193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 194 {
195 195 break; // break if LFR is synchronized
196 196 }
197 197 else
198 198 {
199 199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 200 // sched_yield();
201 201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
202 202 }
203 203 }
204 204 status = rtems_rate_monotonic_cancel(HK_id);
205 205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
206 206
207 207 while(1){ // launch the rate monotonic task
208 208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 209 if ( status != RTEMS_SUCCESSFUL ) {
210 210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 212 }
213 213 else {
214 214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterHK >> 8;
215 215 housekeeping_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterHK;
216 216 increment_seq_counter( &sequenceCounterHK );
217 217
218 218 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
219 219 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
220 220 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
221 221 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
222 222 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
223 223 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
224 224
225 225 spacewire_update_statistics();
226 226
227 227 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
228 228 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
229 229
230 230 // SEND PACKET
231 231 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
232 232 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
233 233 if (status != RTEMS_SUCCESSFUL) {
234 234 PRINTF1("in HOUS *** ERR send: %d\n", status)
235 235 }
236 236 }
237 237 }
238 238
239 239 PRINTF("in HOUS *** deleting task\n")
240 240
241 241 status = rtems_task_delete( RTEMS_SELF ); // should not return
242 242 printf( "rtems_task_delete returned with status of %d.\n", status );
243 243 return;
244 244 }
245 245
246 246 rtems_task dumb_task( rtems_task_argument unused )
247 247 {
248 248 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
249 249 *
250 250 * @param unused is the starting argument of the RTEMS task
251 251 *
252 252 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
253 253 *
254 254 */
255 255
256 256 unsigned int i;
257 257 unsigned int intEventOut;
258 258 unsigned int coarse_time = 0;
259 259 unsigned int fine_time = 0;
260 260 rtems_event_set event_out;
261 261
262 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
262 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
263 263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
265 265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
266 266 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
267 267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
268 268 "ERR HK", // RTEMS_EVENT_6
269 269 "ready for dump", // RTEMS_EVENT_7
270 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
271 "tick" // RTEMS_EVENT_9
270 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
271 "tick", // RTEMS_EVENT_9
272 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
273 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
272 274 };
273 275
274 276 BOOT_PRINTF("in DUMB *** \n")
275 277
276 278 while(1){
277 279 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
278 280 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
279 281 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
280 282 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
281 283 intEventOut = (unsigned int) event_out;
282 284 for ( i=0; i<32; i++)
283 285 {
284 286 if ( ((intEventOut >> i) & 0x0001) != 0)
285 287 {
286 288 coarse_time = time_management_regs->coarse_time;
287 289 fine_time = time_management_regs->fine_time;
288 290 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
289 291 if (i==8)
290 292 {
291 PRINTF1("status = %x\n", spectral_matrix_regs->status)
293 PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status)
294 }
295 if (i==10)
296 {
297 PRINTF1("waveform_picker_regs->status = %x\n", waveform_picker_regs->status)
292 298 }
293 299 }
294 300 }
295 301 }
296 302 }
297 303
298 304 //*****************************
299 305 // init housekeeping parameters
300 306
301 307 void init_housekeeping_parameters( void )
302 308 {
303 309 /** This function initialize the housekeeping_packet global variable with default values.
304 310 *
305 311 */
306 312
307 313 unsigned int i = 0;
308 314 unsigned char *parameters;
309 315
310 316 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
311 317 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
312 318 {
313 319 parameters[i] = 0x00;
314 320 }
315 321 // init status word
316 322 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
317 323 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
318 324 // init software version
319 325 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
320 326 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
321 327 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
322 328 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
323 329 // init fpga version
324 330 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
325 331 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
326 332 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
327 333 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
328 334 }
329 335
330 336 void increment_seq_counter_old( unsigned char *packet_sequence_control)
331 337 {
332 338 /** This function increment the sequence counter psased in argument.
333 339 *
334 340 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
335 341 *
336 342 */
337 343
338 344 unsigned short sequence_cnt;
339 345 unsigned short segmentation_grouping_flag;
340 346 unsigned short new_packet_sequence_control;
341 347
342 348 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
343 349 sequence_cnt = (unsigned short) (
344 350 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
345 351 + packet_sequence_control[1]
346 352 );
347 353
348 354 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
349 355
350 356 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
351 357 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
352 358
353 359 if ( sequence_cnt < SEQ_CNT_MAX)
354 360 {
355 361 sequence_cnt = sequence_cnt + 1;
356 362 }
357 363 else
358 364 {
359 365 sequence_cnt = 0;
360 366 }
361 367 }
362 368
363 369 void increment_seq_counter( unsigned short *packetSequenceControl )
364 370 {
365 371 /** This function increment the sequence counter psased in argument.
366 372 *
367 373 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
368 374 *
369 375 */
370 376
371 377 unsigned short sequence_cnt;
372 378 unsigned short segmentation_grouping_flag;
373 379
374 380 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
375 381 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
376 382
377 383 if ( sequence_cnt < SEQ_CNT_MAX)
378 384 {
379 385 sequence_cnt = sequence_cnt + 1;
380 386 }
381 387 else
382 388 {
383 389 sequence_cnt = 0;
384 390 }
385 391
386 392 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
387 393 }
388 394
389 395 void getTime( unsigned char *time)
390 396 {
391 397 /** This function write the current local time in the time buffer passed in argument.
392 398 *
393 399 */
394 400
395 401 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
396 402 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
397 403 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
398 404 time[3] = (unsigned char) (time_management_regs->coarse_time);
399 405 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
400 406 time[5] = (unsigned char) (time_management_regs->fine_time);
401 407 }
402 408
403 409 unsigned long long int getTimeAsUnsignedLongLongInt( )
404 410 {
405 411 /** This function write the current local time in the time buffer passed in argument.
406 412 *
407 413 */
408 414 unsigned long long int time;
409 415
410 416 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
411 417 + time_management_regs->fine_time;
412 418
413 419 return time;
414 420 }
415 421
416 422 void send_dumb_hk( void )
417 423 {
418 424 Packet_TM_LFR_HK_t dummy_hk_packet;
419 425 unsigned char *parameters;
420 426 unsigned int i;
421 427 rtems_id queue_id;
422 428
423 429 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
424 430 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
425 431 dummy_hk_packet.reserved = DEFAULT_RESERVED;
426 432 dummy_hk_packet.userApplication = CCSDS_USER_APP;
427 433 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
428 434 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
429 435 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
430 436 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
431 437 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
432 438 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
433 439 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
434 440 dummy_hk_packet.serviceType = TM_TYPE_HK;
435 441 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
436 442 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
437 443 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
438 444 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
439 445 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
440 446 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
441 447 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
442 448 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
443 449 dummy_hk_packet.sid = SID_HK;
444 450
445 451 // init status word
446 452 dummy_hk_packet.lfr_status_word[0] = 0xff;
447 453 dummy_hk_packet.lfr_status_word[1] = 0xff;
448 454 // init software version
449 455 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
450 456 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
451 457 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
452 458 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
453 459 // init fpga version
454 460 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
455 461 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
456 462 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
457 463 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
458 464
459 465 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
460 466
461 467 for (i=0; i<100; i++)
462 468 {
463 469 parameters[i] = 0xff;
464 470 }
465 471
466 472 get_message_queue_id_send( &queue_id );
467 473
468 474 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
469 475 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
470 476 }
471 477
472 478 void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential )
473 479 {
474 480 unsigned int coarseTime;
475 481 unsigned int acquisitionTime;
476 482 unsigned int deltaT = 0;
477 483 unsigned char *bufferPtr;
478 484
479 485 unsigned int offset_in_samples;
480 486 unsigned int offset_in_bytes;
481 487 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
482 488
483 489 if (lfrCurrentMode == LFR_MODE_STANDBY)
484 490 {
485 491 spacecraft_potential[0] = 0x00;
486 492 spacecraft_potential[1] = 0x00;
487 493 spacecraft_potential[2] = 0x00;
488 494 spacecraft_potential[3] = 0x00;
489 495 spacecraft_potential[4] = 0x00;
490 496 spacecraft_potential[5] = 0x00;
491 497 }
492 498 else
493 499 {
494 500 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
495 501 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
496 502 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
497 503 + (unsigned int) ( bufferPtr[3] << 16 )
498 504 + (unsigned int) ( bufferPtr[0] << 8 )
499 505 + (unsigned int) ( bufferPtr[1] );
500 506 if ( coarseTime > acquisitionTime )
501 507 {
502 508 deltaT = coarseTime - acquisitionTime;
503 509 offset_in_samples = (deltaT-1) * f3 ;
504 510 }
505 511 else if( coarseTime == acquisitionTime )
506 512 {
507 513 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
508 514 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
509 515 }
510 516 else
511 517 {
512 518 offset_in_samples = 0;
513 519 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
514 520 }
515 521
516 522 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
517 523 {
518 524 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
519 525 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
520 526 }
521 527 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
522 528 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
523 529 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
524 530 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
525 531 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
526 532 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
527 533 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
528 534 }
529 535 }
530 536
531 537 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
532 538 {
533 539 unsigned int coarseTime;
534 540 unsigned int acquisitionTime;
535 541 unsigned int deltaT = 0;
536 542 unsigned char *bufferPtr;
537 543
538 544 unsigned int offset_in_samples;
539 545 unsigned int offset_in_bytes;
540 546 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
541 547
542 548 if (lfrCurrentMode == LFR_MODE_STANDBY)
543 549 {
544 550 spacecraft_potential[0] = 0x00;
545 551 spacecraft_potential[1] = 0x00;
546 552 spacecraft_potential[2] = 0x00;
547 553 spacecraft_potential[3] = 0x00;
548 554 spacecraft_potential[4] = 0x00;
549 555 spacecraft_potential[5] = 0x00;
550 556 }
551 557 else
552 558 {
553 559 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
554 560 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
555 561 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
556 562 + (unsigned int) ( bufferPtr[1] << 16 )
557 563 + (unsigned int) ( bufferPtr[2] << 8 )
558 564 + (unsigned int) ( bufferPtr[3] );
559 565 if ( coarseTime > acquisitionTime )
560 566 {
561 567 deltaT = coarseTime - acquisitionTime;
562 568 offset_in_samples = (deltaT-1) * f3 ;
563 569 }
564 570 else if( coarseTime == acquisitionTime )
565 571 {
566 572 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
567 573 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
568 574 }
569 575 else
570 576 {
571 577 offset_in_samples = 0;
572 578 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
573 579 }
574 580
575 581 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
576 582 {
577 583 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
578 584 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
579 585 }
580 586 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
581 587 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
582 588 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
583 589 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
584 590 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
585 591 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
586 592 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
587 593 }
588 594 }
589 595
590 596 void get_cpu_load( unsigned char *resource_statistics )
591 597 {
592 598 unsigned char cpu_load;
593 599
594 600 cpu_load = lfr_rtems_cpu_usage_report();
595 601
596 602 // HK_LFR_CPU_LOAD
597 603 resource_statistics[0] = cpu_load;
598 604
599 605 // HK_LFR_CPU_LOAD_MAX
600 606 if (cpu_load > resource_statistics[1])
601 607 {
602 608 resource_statistics[1] = cpu_load;
603 609 }
604 610
605 611 // CPU_LOAD_AVE
606 612 resource_statistics[2] = 0;
607 613
608 614 #ifndef PRINT_TASK_STATISTICS
609 615 rtems_cpu_usage_reset();
610 616 #endif
611 617
612 618 }
613 619
614 620
615 621
@@ -1,379 +1,380
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include "avf0_prc0.h"
11 11 #include "fsw_processing.h"
12 12
13 13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
14 14
15 15 //***
16 16 // F0
17 17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
18 18 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
19 19
20 20 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
21 21 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
22 22 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
23 23 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
24 24 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
25 25 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
26 26
27 27 //************
28 28 // RTEMS TASKS
29 29
30 30 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
31 31 {
32 32 int i;
33 33
34 34 rtems_event_set event_out;
35 35 rtems_status_code status;
36 36 rtems_id queue_id_prc0;
37 37 asm_msg msgForMATR;
38 38 ring_node_sm *ring_node_tab[8];
39 39 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
40 40 ring_node_asm *current_ring_node_asm_norm_f0;
41 41
42 42 unsigned int nb_norm_bp1;
43 43 unsigned int nb_norm_bp2;
44 44 unsigned int nb_norm_asm;
45 45 unsigned int nb_sbm_bp1;
46 46 unsigned int nb_sbm_bp2;
47 47
48 48 nb_norm_bp1 = 0;
49 49 nb_norm_bp2 = 0;
50 50 nb_norm_asm = 0;
51 51 nb_sbm_bp1 = 0;
52 52 nb_sbm_bp2 = 0;
53 53
54 54 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
55 55 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
56 56 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
57 57 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
58 58 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
59 59
60 60 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
61 61
62 62 status = get_message_queue_id_prc0( &queue_id_prc0 );
63 63 if (status != RTEMS_SUCCESSFUL)
64 64 {
65 65 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
66 66 }
67 67
68 68 while(1){
69 69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
70
71 //****************************************
72 // initialize the mesage for the MATR task
73 msgForMATR.norm = current_ring_node_asm_norm_f0;
74 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
75 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
76 msgForMATR.coarseTime = ring_node_for_averaging_sm_f0->coarseTime;
77 msgForMATR.fineTime = ring_node_for_averaging_sm_f0->fineTime;
78 //
79 //****************************************
80
70 81 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
71 82 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
72 83 {
73 84 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
74 85 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
75 86 }
76 87
77 88 // compute the average and store it in the averaged_sm_f1 buffer
78 89 SM_average( current_ring_node_asm_norm_f0->matrix,
79 90 current_ring_node_asm_burst_sbm_f0->matrix,
80 91 ring_node_tab,
81 92 nb_norm_bp1, nb_sbm_bp1 );
82 93
83 94 // update nb_average
84 95 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
85 96 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
86 97 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
87 98 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
88 99 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
89 100
90 //****************************************
91 // initialize the mesage for the MATR task
92 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
94 msgForMATR.norm = current_ring_node_asm_norm_f0;
95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
97 msgForMATR.coarseTime = time_management_regs->coarse_time;
98 msgForMATR.fineTime = time_management_regs->fine_time;
99
100 101 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 102 {
102 103 nb_sbm_bp1 = 0;
103 104 // set another ring for the ASM storage
104 105 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
105 106 if ( lfrCurrentMode == LFR_MODE_BURST )
106 107 {
107 108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
108 109 }
109 110 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
110 111 {
111 112 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
112 113 }
113 114 }
114 115
115 116 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
116 117 {
117 118 nb_sbm_bp2 = 0;
118 119 if ( lfrCurrentMode == LFR_MODE_BURST )
119 120 {
120 121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
121 122 }
122 123 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
123 124 {
124 125 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
125 126 }
126 127 }
127 128
128 129 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
129 130 {
130 131 nb_norm_bp1 = 0;
131 132 // set another ring for the ASM storage
132 133 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
133 134 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
134 135 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
135 136 {
136 137 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
137 138 }
138 139 }
139 140
140 141 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
141 142 {
142 143 nb_norm_bp2 = 0;
143 144 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
144 145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
145 146 {
146 147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
147 148 }
148 149 }
149 150
150 151 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
151 152 {
152 153 nb_norm_asm = 0;
153 154 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
154 155 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
155 156 {
156 157 // PRINTF1("%lld\n", localTime)
157 158 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
158 159 }
159 160 }
160 161
161 162 //*************************
162 163 // send the message to MATR
163 164 if (msgForMATR.event != 0x00)
164 165 {
165 166 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
166 167 }
167 168
168 169 if (status != RTEMS_SUCCESSFUL) {
169 170 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
170 171 }
171 172 }
172 173 }
173 174
174 175 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
175 176 {
176 177 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
177 178 size_t size; // size of the incoming TC packet
178 179 asm_msg *incomingMsg;
179 180 //
180 181 unsigned char sid;
181 182 spw_ioctl_pkt_send spw_ioctl_send_ASM;
182 183 rtems_status_code status;
183 184 rtems_id queue_id;
184 185 rtems_id queue_id_q_p0;
185 186 Header_TM_LFR_SCIENCE_ASM_t headerASM;
186 187 bp_packet_with_spare packet_norm_bp1_f0;
187 188 bp_packet packet_norm_bp2_f0;
188 189 bp_packet packet_sbm_bp1_f0;
189 190 bp_packet packet_sbm_bp2_f0;
190 191
191 192 unsigned long long int localTime;
192 193
193 194 ASM_init_header( &headerASM );
194 195
195 196 //*************
196 197 // NORM headers
197 198 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
198 199 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
199 200 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
200 201 BP_init_header( &packet_norm_bp2_f0.header,
201 202 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
202 203 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
203 204
204 205 //****************************
205 206 // BURST SBM1 and SBM2 headers
206 207 if ( lfrRequestedMode == LFR_MODE_BURST )
207 208 {
208 209 BP_init_header( &packet_sbm_bp1_f0.header,
209 210 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
210 211 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
211 212 BP_init_header( &packet_sbm_bp2_f0.header,
212 213 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
213 214 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
214 215 }
215 216 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
216 217 {
217 218 BP_init_header( &packet_sbm_bp1_f0.header,
218 219 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
219 220 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
220 221 BP_init_header( &packet_sbm_bp2_f0.header,
221 222 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
222 223 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
223 224 }
224 225 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
225 226 {
226 227 BP_init_header( &packet_sbm_bp1_f0.header,
227 228 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
228 229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
229 230 BP_init_header( &packet_sbm_bp2_f0.header,
230 231 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
231 232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
232 233 }
233 234 else
234 235 {
235 236 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
236 237 }
237 238
238 239 status = get_message_queue_id_send( &queue_id );
239 240 if (status != RTEMS_SUCCESSFUL)
240 241 {
241 242 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
242 243 }
243 244 status = get_message_queue_id_prc0( &queue_id_q_p0);
244 245 if (status != RTEMS_SUCCESSFUL)
245 246 {
246 247 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
247 248 }
248 249
249 250 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
250 251
251 252 while(1){
252 253 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
253 254 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
254 255
255 256 incomingMsg = (asm_msg*) incomingData;
256 257
257 258 localTime = getTimeAsUnsignedLongLongInt( );
258 259
259 260 //****************
260 261 //****************
261 262 // BURST SBM1 SBM2
262 263 //****************
263 264 //****************
264 265 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
265 266 {
266 267 sid = getSID( incomingMsg->event );
267 268 // 1) compress the matrix for Basic Parameters calculation
268 269 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
269 270 nb_sm_before_f0.burst_sbm_bp1,
270 271 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
271 272 ASM_F0_INDICE_START);
272 273 // 2) compute the BP1 set
273 274 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
274 275 // 3) send the BP1 set
275 276 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
276 277 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
277 278 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
278 279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
279 280 sid);
280 281 // 4) compute the BP2 set if needed
281 282 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
282 283 {
283 284 // 1) compute the BP2 set
284 285
285 286 // 2) send the BP2 set
286 287 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
287 288 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
288 289 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
289 290 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
290 291 sid);
291 292 }
292 293 }
293 294
294 295 //*****
295 296 //*****
296 297 // NORM
297 298 //*****
298 299 //*****
299 300 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
300 301 {
301 302 // 1) compress the matrix for Basic Parameters calculation
302 303 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
303 304 nb_sm_before_f0.norm_bp1,
304 305 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
305 306 ASM_F0_INDICE_START );
306 307 // 2) compute the BP1 set
307 308 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
308 309 // 3) send the BP1 set
309 310 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
310 311 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
311 312 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
312 313 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
313 314 SID_NORM_BP1_F0 );
314 315 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
315 316 {
316 317 // 1) compute the BP2 set using the same ASM as the one used for BP1
317 318
318 319 // 2) send the BP2 set
319 320 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
320 321 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
321 322 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
322 323 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
323 324 SID_NORM_BP2_F0);
324 325 }
325 326 }
326 327
327 328 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
328 329 {
329 330 // 1) reorganize the ASM and divide
330 331 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
331 332 asm_f0_reorganized,
332 333 nb_sm_before_f0.norm_bp1 );
333 334 // 2) convert the float array in a char array
334 335 ASM_convert( asm_f0_reorganized, asm_f0_char);
335 336 // 3) send the spectral matrix packets
336 337 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
337 338 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
338 339 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
339 340 }
340 341
341 342 }
342 343 }
343 344
344 345 //**********
345 346 // FUNCTIONS
346 347
347 348 void reset_nb_sm_f0( unsigned char lfrMode )
348 349 {
349 350 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
350 351 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
351 352 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
352 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
353 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
353 354 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
354 355 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
355 356 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
356 357 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
357 358 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
358 359
359 360 if (lfrMode == LFR_MODE_SBM1)
360 361 {
361 362 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
362 363 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
363 364 }
364 365 else if (lfrMode == LFR_MODE_SBM2)
365 366 {
366 367 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
367 368 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
368 369 }
369 370 else if (lfrMode == LFR_MODE_BURST)
370 371 {
371 372 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
372 373 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
373 374 }
374 375 else
375 376 {
376 377 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
377 378 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
378 379 }
379 380 }
@@ -1,359 +1,360
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include "avf1_prc1.h"
11 11
12 12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
13 13
14 14 //***
15 15 // F1
16 16 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
17 17 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
18 18
19 19 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
20 20 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
21 21 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
22 22 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
23 23
24 24 //************
25 25 // RTEMS TASKS
26 26
27 27 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
28 28 {
29 29 int i;
30 30
31 31 rtems_event_set event_out;
32 32 rtems_status_code status;
33 33 rtems_id queue_id_prc1;
34 34 asm_msg msgForMATR;
35 35 ring_node_sm *ring_node_tab[8];
36 36 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
37 37 ring_node_asm *current_ring_node_asm_norm_f1;
38 38
39 39 unsigned int nb_norm_bp1;
40 40 unsigned int nb_norm_bp2;
41 41 unsigned int nb_norm_asm;
42 42 unsigned int nb_sbm_bp1;
43 43 unsigned int nb_sbm_bp2;
44 44
45 45 nb_norm_bp1 = 0;
46 46 nb_norm_bp2 = 0;
47 47 nb_norm_asm = 0;
48 48 nb_sbm_bp1 = 0;
49 49 nb_sbm_bp2 = 0;
50 50
51 51 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
52 52 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
53 53 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
54 54 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
55 55 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
56 56
57 57 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
58 58
59 59 status = get_message_queue_id_prc1( &queue_id_prc1 );
60 60 if (status != RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
63 63 }
64 64
65 65 while(1){
66 66 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
67
68 //****************************************
69 // initialize the mesage for the MATR task
70 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
71 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
72 msgForMATR.norm = current_ring_node_asm_norm_f1;
73 msgForMATR.coarseTime = ring_node_for_averaging_sm_f1->coarseTime;
74 msgForMATR.fineTime = ring_node_for_averaging_sm_f1->fineTime;
75 //
76 //****************************************
77
67 78 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
68 79 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
69 80 {
70 81 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
71 82 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
72 83 }
73 84
74 85 // compute the average and store it in the averaged_sm_f1 buffer
75 86 SM_average( current_ring_node_asm_norm_f1->matrix,
76 87 current_ring_node_asm_burst_sbm_f1->matrix,
77 88 ring_node_tab,
78 89 nb_norm_bp1, nb_sbm_bp1 );
79 90
80 91 // update nb_average
81 92 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
82 93 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
83 94 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
84 95 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
85 96 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
86 97
87 //****************************************
88 // initialize the mesage for the MATR task
89 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
90 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
91 msgForMATR.norm = current_ring_node_asm_norm_f1;
92 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
93 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
94 msgForMATR.coarseTime = time_management_regs->coarse_time;
95 msgForMATR.fineTime = time_management_regs->fine_time;
96
97 98 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 99 {
99 100 nb_sbm_bp1 = 0;
100 101 // set another ring for the ASM storage
101 102 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
102 103 if ( lfrCurrentMode == LFR_MODE_BURST )
103 104 {
104 105 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
105 106 }
106 107 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
107 108 {
108 109 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
109 110 }
110 111 }
111 112
112 113 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
113 114 {
114 115 nb_sbm_bp2 = 0;
115 116 if ( lfrCurrentMode == LFR_MODE_BURST )
116 117 {
117 118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
118 119 }
119 120 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
120 121 {
121 122 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
122 123 }
123 124 }
124 125
125 126 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
126 127 {
127 128 nb_norm_bp1 = 0;
128 129 // set another ring for the ASM storage
129 130 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
130 131 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
131 132 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
132 133 {
133 134 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
134 135 }
135 136 }
136 137
137 138 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
138 139 {
139 140 nb_norm_bp2 = 0;
140 141 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
141 142 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
142 143 {
143 144 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
144 145 }
145 146 }
146 147
147 148 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
148 149 {
149 150 nb_norm_asm = 0;
150 151 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
151 152 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
152 153 {
153 154 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
154 155 }
155 156 }
156 157
157 158 //*************************
158 159 // send the message to MATR
159 160 if (msgForMATR.event != 0x00)
160 161 {
161 162 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
162 163 }
163 164
164 165 if (status != RTEMS_SUCCESSFUL) {
165 166 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
166 167 }
167 168 }
168 169 }
169 170
170 171 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
171 172 {
172 173 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
173 174 size_t size; // size of the incoming TC packet
174 175 asm_msg *incomingMsg;
175 176 //
176 177 unsigned char sid;
177 178 spw_ioctl_pkt_send spw_ioctl_send_ASM;
178 179 rtems_status_code status;
179 180 rtems_id queue_id_send;
180 181 rtems_id queue_id_q_p1;
181 182 Header_TM_LFR_SCIENCE_ASM_t headerASM;
182 183 bp_packet_with_spare packet_norm_bp1;
183 184 bp_packet packet_norm_bp2;
184 185 bp_packet packet_sbm_bp1;
185 186 bp_packet packet_sbm_bp2;
186 187
187 188 unsigned long long int localTime;
188 189
189 190 ASM_init_header( &headerASM );
190 191
191 192 //*************
192 193 // NORM headers
193 194 BP_init_header_with_spare( &packet_norm_bp1.header,
194 195 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
195 196 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
196 197 BP_init_header( &packet_norm_bp2.header,
197 198 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
198 199 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
199 200
200 201 //***********************
201 202 // BURST and SBM2 headers
202 203 if ( lfrRequestedMode == LFR_MODE_BURST )
203 204 {
204 205 BP_init_header( &packet_sbm_bp1.header,
205 206 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
206 207 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
207 208 BP_init_header( &packet_sbm_bp2.header,
208 209 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
209 210 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
210 211 }
211 212 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
212 213 {
213 214 BP_init_header( &packet_sbm_bp1.header,
214 215 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
215 216 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
216 217 BP_init_header( &packet_sbm_bp2.header,
217 218 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
218 219 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
219 220 }
220 221 else
221 222 {
222 223 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
223 224 }
224 225
225 226 status = get_message_queue_id_send( &queue_id_send );
226 227 if (status != RTEMS_SUCCESSFUL)
227 228 {
228 229 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
229 230 }
230 231 status = get_message_queue_id_prc1( &queue_id_q_p1);
231 232 if (status != RTEMS_SUCCESSFUL)
232 233 {
233 234 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
234 235 }
235 236
236 237 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
237 238
238 239 while(1){
239 240 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
240 241 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
241 242
242 243 incomingMsg = (asm_msg*) incomingData;
243 244
244 245 localTime = getTimeAsUnsignedLongLongInt( );
245 246 //***********
246 247 //***********
247 248 // BURST SBM2
248 249 //***********
249 250 //***********
250 251 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
251 252 {
252 253 sid = getSID( incomingMsg->event );
253 254 // 1) compress the matrix for Basic Parameters calculation
254 255 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
255 256 nb_sm_before_f1.burst_sbm_bp1,
256 257 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
257 258 ASM_F1_INDICE_START);
258 259 // 2) compute the BP1 set
259 260
260 261 // 3) send the BP1 set
261 262 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
262 263 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
263 264 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
264 265 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
265 266 sid );
266 267 // 4) compute the BP2 set if needed
267 268 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
268 269 {
269 270 // 1) compute the BP2 set
270 271
271 272 // 2) send the BP2 set
272 273 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
273 274 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
274 275 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
275 276 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
276 277 sid );
277 278 }
278 279 }
279 280
280 281 //*****
281 282 //*****
282 283 // NORM
283 284 //*****
284 285 //*****
285 286 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
286 287 {
287 288 // 1) compress the matrix for Basic Parameters calculation
288 289 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
289 290 nb_sm_before_f1.norm_bp1,
290 291 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
291 292 ASM_F0_INDICE_START );
292 293 // 2) compute the BP1 set
293 294
294 295 // 3) send the BP1 set
295 296 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 297 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
297 298 BP_send( (char *) &packet_norm_bp1, queue_id_send,
298 299 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
299 300 SID_NORM_BP1_F1 );
300 301 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
301 302 {
302 303 // 1) compute the BP2 set
303 304
304 305 // 2) send the BP2 set
305 306 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 307 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
307 308 BP_send( (char *) &packet_norm_bp2, queue_id_send,
308 309 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
309 310 SID_NORM_BP2_F1 );
310 311 }
311 312 }
312 313
313 314 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
314 315 {
315 316 // 1) reorganize the ASM and divide
316 317 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
317 318 asm_f1_reorganized,
318 319 nb_sm_before_f1.norm_bp1 );
319 320 // 2) convert the float array in a char array
320 321 ASM_convert( asm_f1_reorganized, asm_f1_char);
321 322 // 3) send the spectral matrix packets
322 323 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
323 324 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
324 325 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
325 326 }
326 327
327 328 }
328 329 }
329 330
330 331 //**********
331 332 // FUNCTIONS
332 333
333 334 void reset_nb_sm_f1( unsigned char lfrMode )
334 335 {
335 336 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
336 337 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
337 338 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
338 339 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
339 340 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
340 341 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
341 342 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
342 343
343 344 if (lfrMode == LFR_MODE_SBM2)
344 345 {
345 346 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
346 347 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
347 348 }
348 349 else if (lfrMode == LFR_MODE_BURST)
349 350 {
350 351 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
351 352 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
352 353 }
353 354 else
354 355 {
355 356 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
356 357 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
357 358 }
358 359 }
359 360
@@ -1,253 +1,253
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include "avf2_prc2.h"
11 11
12 12 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
13 13
14 14 //***
15 15 // F2
16 16 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
17 17 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
18 18
19 19 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
20 20 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
21 21 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
22 22 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
23 23
24 24 //************
25 25 // RTEMS TASKS
26 26
27 27 //***
28 28 // F2
29 29 rtems_task avf2_task( rtems_task_argument argument )
30 30 {
31 31 rtems_event_set event_out;
32 32 rtems_status_code status;
33 33 rtems_id queue_id_prc2;
34 34 asm_msg msgForMATR;
35 35 ring_node_asm *current_ring_node_asm_norm_f2;
36 36
37 37 unsigned int nb_norm_bp1;
38 38 unsigned int nb_norm_bp2;
39 39 unsigned int nb_norm_asm;
40 40
41 41 nb_norm_bp1 = 0;
42 42 nb_norm_bp2 = 0;
43 43 nb_norm_asm = 0;
44 44
45 45 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
46 46 ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 );
47 47 current_ring_node_asm_norm_f2 = asm_ring_norm_f2;
48 48
49 49 BOOT_PRINTF("in AVF2 ***\n")
50 50
51 51 status = get_message_queue_id_prc2( &queue_id_prc2 );
52 52 if (status != RTEMS_SUCCESSFUL)
53 53 {
54 54 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
55 55 }
56 56
57 57 while(1){
58 58 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
59 59
60 //****************************************
61 // initialize the mesage for the MATR task
62 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
63 msgForMATR.burst_sbm = NULL;
64 msgForMATR.norm = current_ring_node_asm_norm_f2;
65 msgForMATR.coarseTime = ring_node_for_averaging_sm_f2->coarseTime;
66 msgForMATR.fineTime = ring_node_for_averaging_sm_f2->fineTime;
67 //
68 //****************************************
69
60 70 // compute the average and store it in the averaged_sm_f2 buffer
61 71 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
62 72 ring_node_for_averaging_sm_f2,
63 73 nb_norm_bp1 );
64 74
65 75 // update nb_average
66 76 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
67 77 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
68 78 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
69 79
70 //****************************************
71 // initialize the mesage for the MATR task
72 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
73 msgForMATR.burst_sbm = NULL;
74 msgForMATR.norm = current_ring_node_asm_norm_f2;
75 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
76 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
77 msgForMATR.coarseTime = time_management_regs->coarse_time;
78 msgForMATR.fineTime = time_management_regs->fine_time;
79
80 80 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
81 81 {
82 82 nb_norm_bp1 = 0;
83 83 // set another ring for the ASM storage
84 84 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
85 85 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
86 86 || (lfrCurrentMode == LFR_MODE_SBM2) )
87 87 {
88 88 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2;
89 89 }
90 90 }
91 91
92 92 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
93 93 {
94 94 nb_norm_bp2 = 0;
95 95 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
96 96 || (lfrCurrentMode == LFR_MODE_SBM2) )
97 97 {
98 98 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
99 99 }
100 100 }
101 101
102 102 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
103 103 {
104 104 nb_norm_asm = 0;
105 105 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
106 106 || (lfrCurrentMode == LFR_MODE_SBM2) )
107 107 {
108 108 // PRINTF1("%lld\n", localTime)
109 109 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
110 110 }
111 111 }
112 112
113 113 //*************************
114 114 // send the message to MATR
115 115 if (msgForMATR.event != 0x00)
116 116 {
117 117 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
118 118 }
119 119
120 120 if (status != RTEMS_SUCCESSFUL) {
121 121 printf("in AVF2 *** Error sending message to MATR, code %d\n", status);
122 122 }
123 123 }
124 124 }
125 125
126 126 rtems_task prc2_task( rtems_task_argument argument )
127 127 {
128 128 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
129 129 size_t size; // size of the incoming TC packet
130 130 asm_msg *incomingMsg;
131 131 //
132 132 spw_ioctl_pkt_send spw_ioctl_send_ASM;
133 133 rtems_status_code status;
134 134 rtems_id queue_id;
135 135 rtems_id queue_id_q_p2;
136 136 Header_TM_LFR_SCIENCE_ASM_t headerASM;
137 137 bp_packet packet_norm_bp1_f2;
138 138 bp_packet packet_norm_bp2_f2;
139 139
140 140 unsigned long long int localTime;
141 141
142 142 ASM_init_header( &headerASM );
143 143
144 144 //*************
145 145 // NORM headers
146 146 BP_init_header( &packet_norm_bp1_f2.header,
147 147 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
148 148 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
149 149 BP_init_header( &packet_norm_bp2_f2.header,
150 150 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
151 151 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
152 152
153 153 status = get_message_queue_id_send( &queue_id );
154 154 if (status != RTEMS_SUCCESSFUL)
155 155 {
156 156 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
157 157 }
158 158 status = get_message_queue_id_prc2( &queue_id_q_p2);
159 159 if (status != RTEMS_SUCCESSFUL)
160 160 {
161 161 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
162 162 }
163 163
164 164 BOOT_PRINTF("in PRC2 ***\n")
165 165
166 166 while(1){
167 167 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
168 168 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
169 169
170 170 incomingMsg = (asm_msg*) incomingData;
171 171
172 172 localTime = getTimeAsUnsignedLongLongInt( );
173 173
174 174 //*****
175 175 //*****
176 176 // NORM
177 177 //*****
178 178 //*****
179 179 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
180 180 {
181 181 // 1) compress the matrix for Basic Parameters calculation
182 182 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
183 183 nb_sm_before_f2.norm_bp1,
184 184 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
185 185 ASM_F2_INDICE_START );
186 186 // 2) compute the BP1 set
187 187
188 188 // 3) send the BP1 set
189 189 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
190 190 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
191 191 BP_send( (char *) &packet_norm_bp1_f2, queue_id,
192 192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
193 193 SID_NORM_BP1_F2 );
194 194 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
195 195 {
196 196 // 1) compute the BP2 set using the same ASM as the one used for BP1
197 197
198 198 // 2) send the BP2 set
199 199 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
200 200 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
201 201 BP_send( (char *) &packet_norm_bp2_f2, queue_id,
202 202 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
203 203 SID_NORM_BP2_F2 );
204 204 }
205 205 }
206 206
207 207 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
208 208 {
209 209 // 1) reorganize the ASM and divide
210 210 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
211 211 asm_f2_reorganized,
212 212 nb_sm_before_f2.norm_bp1 );
213 213 // 2) convert the float array in a char array
214 214 ASM_convert( asm_f2_reorganized, asm_f2_char);
215 215 // 3) send the spectral matrix packets
216 216 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
217 217 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
218 218 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
219 219 }
220 220
221 221 }
222 222 }
223 223
224 224 //**********
225 225 // FUNCTIONS
226 226
227 227 void reset_nb_sm_f2( void )
228 228 {
229 229 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
230 230 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
231 231 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
232 232 }
233 233
234 234 void SM_average_f2( float *averaged_spec_mat_f2,
235 235 ring_node_sm *ring_node,
236 236 unsigned int nbAverageNormF2 )
237 237 {
238 238 float sum;
239 239 unsigned int i;
240 240
241 241 for(i=0; i<TOTAL_SIZE_SM; i++)
242 242 {
243 243 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
244 244 if ( (nbAverageNormF2 == 0) )
245 245 {
246 246 averaged_spec_mat_f2[ i ] = sum;
247 247 }
248 248 else
249 249 {
250 250 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
251 251 }
252 252 }
253 253 }
@@ -1,678 +1,689
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include "fsw_processing.h"
11 11 #include "fsw_processing_globals.c"
12 12
13 13 unsigned int nb_sm_f0;
14 14 unsigned int nb_sm_f0_aux_f1;
15 15 unsigned int nb_sm_f1;
16 16 unsigned int nb_sm_f0_aux_f2;
17 17
18 18 //************************
19 19 // spectral matrices rings
20 20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 23 ring_node_sm *current_ring_node_sm_f0;
24 24 ring_node_sm *current_ring_node_sm_f1;
25 25 ring_node_sm *current_ring_node_sm_f2;
26 26 ring_node_sm *ring_node_for_averaging_sm_f0;
27 27 ring_node_sm *ring_node_for_averaging_sm_f1;
28 28 ring_node_sm *ring_node_for_averaging_sm_f2;
29 29
30 30 //***********************************************************
31 31 // Interrupt Service Routine for spectral matrices processing
32 32
33 33 void spectral_matrices_isr_f0( void )
34 34 {
35 35 unsigned char status;
36 36 unsigned long long int time_0;
37 37 unsigned long long int time_1;
38 unsigned long long int syncBit0;
39 unsigned long long int syncBit1;
38 40
39 41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
40 42
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47
41 48 switch(status)
42 49 {
43 50 case 0:
44 51 break;
45 52 case 3:
46 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_0_coarse_time );
47 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_1_coarse_time );
48 53 if ( time_0 < time_1 )
49 54 {
50 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
51 57 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
52 58 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
53 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
54 61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
55 62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
56 63 }
57 64 else
58 65 {
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
60 68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
63 72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
64 73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
65 74 }
66 75 spectral_matrix_regs->status = 0x03; // [0011]
67 76 break;
68 77 case 1:
69 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
70 80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
71 81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
72 82 spectral_matrix_regs->status = 0x01; // [0001]
73 83 break;
74 84 case 2:
75 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
76 87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
77 88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
78 89 spectral_matrix_regs->status = 0x02; // [0010]
79 90 break;
80 91 }
81 92 }
82 93
83 94 void spectral_matrices_isr_f1( void )
84 95 {
85 96 unsigned char status;
86 unsigned long long int time_0;
87 unsigned long long int time_1;
97 unsigned long long int time;
98 unsigned long long int syncBit;
88 99
89 100 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
90 101
91 102 switch(status)
92 103 {
93 104 case 0:
94 105 break;
95 106 case 3:
96 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_0_coarse_time );
97 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_1_coarse_time );
98 if ( time_0 < time_1 )
99 {
100 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
101 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
102 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
103 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
104 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
105 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
106 }
107 else
108 {
109 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
110 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
111 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
112 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
113 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
114 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
115 }
116 spectral_matrix_regs->status = 0x0c; // [1100]
107 // UNEXPECTED VALUE
108 spectral_matrix_regs->status = 0xc0; // [1100]
109 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
117 110 break;
118 111 case 1:
119 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
112 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
113 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
114 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
115 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
120 116 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
121 117 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
122 118 spectral_matrix_regs->status = 0x04; // [0100]
123 119 break;
124 120 case 2:
125 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
121 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
122 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
123 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
124 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
126 125 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
127 126 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
128 127 spectral_matrix_regs->status = 0x08; // [1000]
129 128 break;
130 129 }
131 130 }
132 131
133 132 void spectral_matrices_isr_f2( void )
134 133 {
135 134 unsigned char status;
136 135
137 136 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
138 137
139 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
138 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
140 139
141 140 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
142 141
143 142 switch(status)
144 143 {
145 144 case 0:
146 145 break;
147 146 case 3:
148 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
147 // UNEXPECTED VALUE
149 148 spectral_matrix_regs->status = 0x30; // [0011 0000]
150 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
151 {
152 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 }
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
154 150 break;
155 151 case 1:
152 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
153 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
156 154 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
157 155 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 156 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 157 {
160 158 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 159 }
162 160 break;
163 161 case 2:
162 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
163 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
164 164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
165 165 spectral_matrix_regs->status = 0x20; // [0010 0000]
166 166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
167 167 {
168 168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
169 169 }
170 170 break;
171 171 }
172 172 }
173 173
174 174 void spectral_matrix_isr_error_handler( void )
175 175 {
176 spectral_matrix_regs->status = 0x7c0; // [0111 1100 0000]
176 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
177 {
178 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
179 }
177 180 }
178 181
179 182 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
180 183 {
181 184 // STATUS REGISTER
182 185 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
183 186 // 10 9 8
184 187 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
185 188 // 7 6 5 4 3 2 1 0
186 189
187 190 spectral_matrices_isr_f0();
188 191
189 192 spectral_matrices_isr_f1();
190 193
191 194 spectral_matrices_isr_f2();
192 195
193 196 // spectral_matrix_isr_error_handler();
194 197 }
195 198
196 199 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
197 200 {
198 201 //***
199 202 // F0
200 203 nb_sm_f0 = nb_sm_f0 + 1;
201 204 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
202 205 {
203 206 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
204 207 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
205 208 {
206 209 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
207 210 }
208 211 nb_sm_f0 = 0;
209 212 }
210 213
211 214 //***
212 215 // F1
213 216 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
214 217 if (nb_sm_f0_aux_f1 == 6)
215 218 {
216 219 nb_sm_f0_aux_f1 = 0;
217 220 nb_sm_f1 = nb_sm_f1 + 1;
218 221 }
219 222 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
220 223 {
221 224 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
222 225 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
223 226 {
224 227 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
225 228 }
226 229 nb_sm_f1 = 0;
227 230 }
228 231
229 232 //***
230 233 // F2
231 234 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
232 235 if (nb_sm_f0_aux_f2 == 96)
233 236 {
234 237 nb_sm_f0_aux_f2 = 0;
235 238 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
236 239 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
237 240 {
238 241 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
239 242 }
240 243 }
241 244 }
242 245
243 246 //******************
244 247 // Spectral Matrices
245 248
246 249 void reset_nb_sm( void )
247 250 {
248 251 nb_sm_f0 = 0;
249 252 nb_sm_f0_aux_f1 = 0;
250 253 nb_sm_f0_aux_f2 = 0;
251 254
252 255 nb_sm_f1 = 0;
253 256 }
254 257
255 258 void SM_init_rings( void )
256 259 {
257 260 unsigned char i;
258 261
259 262 // F0 RING
260 263 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
261 264 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
262 265 sm_ring_f0[0].buffer_address =
263 266 (int) &sm_f0[ 0 ];
264 267
265 268 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
266 269 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
267 270 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
268 271 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
269 272
270 273 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
271 274 {
272 275 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
273 276 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
274 277 sm_ring_f0[i].buffer_address =
275 278 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
276 279 }
277 280
278 281 // F1 RING
279 282 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
280 283 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
281 284 sm_ring_f1[0].buffer_address =
282 285 (int) &sm_f1[ 0 ];
283 286
284 287 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
285 288 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
286 289 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
287 290 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
288 291
289 292 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
290 293 {
291 294 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
292 295 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
293 296 sm_ring_f1[i].buffer_address =
294 297 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
295 298 }
296 299
297 300 // F2 RING
298 301 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
299 302 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
300 303 sm_ring_f2[0].buffer_address =
301 304 (int) &sm_f2[ 0 ];
302 305
303 306 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
304 307 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
305 308 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
306 309 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
307 310
308 311 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
309 312 {
310 313 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
311 314 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
312 315 sm_ring_f2[i].buffer_address =
313 316 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
314 317 }
315 318
316 319 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
317 320 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
318 321 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
319 322
320 323 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
321 324 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
322 325 }
323 326
324 327 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
325 328 {
326 329 unsigned char i;
327 330
328 331 //***************
329 332 // BUFFER ADDRESS
330 333 for(i=0; i<nbNodes; i++)
331 334 {
332 335 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
333 336 }
334 337
335 338 //*****
336 339 // NEXT
337 340 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
338 341 for(i=0; i<nbNodes-1; i++)
339 342 {
340 343 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
341 344 }
342 345
343 346 //*********
344 347 // PREVIOUS
345 348 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
346 349 for(i=1; i<nbNodes; i++)
347 350 {
348 351 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
349 352 }
350 353 }
351 354
352 355 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
353 356 {
354 357 unsigned char i;
355 358
356 359 ring[ nbNodes - 1 ].next
357 360 = (ring_node_asm*) &ring[ 0 ];
358 361
359 362 for(i=0; i<nbNodes-1; i++)
360 363 {
361 364 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
362 365 }
363 366 }
364 367
365 368 void SM_reset_current_ring_nodes( void )
366 369 {
367 370 current_ring_node_sm_f0 = sm_ring_f0[0].next;
368 371 current_ring_node_sm_f1 = sm_ring_f1[0].next;
369 372 current_ring_node_sm_f2 = sm_ring_f2[0].next;
370 373
371 374 ring_node_for_averaging_sm_f0 = sm_ring_f0;
372 375 ring_node_for_averaging_sm_f1 = sm_ring_f1;
373 376 ring_node_for_averaging_sm_f2 = sm_ring_f2;
374 377 }
375 378
376 379 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
377 380 {
378 381 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
379 382 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
380 383 header->reserved = 0x00;
381 384 header->userApplication = CCSDS_USER_APP;
382 385 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
383 386 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
384 387 header->packetSequenceControl[0] = 0xc0;
385 388 header->packetSequenceControl[1] = 0x00;
386 389 header->packetLength[0] = 0x00;
387 390 header->packetLength[1] = 0x00;
388 391 // DATA FIELD HEADER
389 392 header->spare1_pusVersion_spare2 = 0x10;
390 393 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
391 394 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
392 395 header->destinationID = TM_DESTINATION_ID_GROUND;
393 396 // AUXILIARY DATA HEADER
394 397 header->sid = 0x00;
395 398 header->biaStatusInfo = 0x00;
396 399 header->pa_lfr_pkt_cnt_asm = 0x00;
397 400 header->pa_lfr_pkt_nr_asm = 0x00;
398 401 header->time[0] = 0x00;
399 402 header->time[0] = 0x00;
400 403 header->time[0] = 0x00;
401 404 header->time[0] = 0x00;
402 405 header->time[0] = 0x00;
403 406 header->time[0] = 0x00;
404 407 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
405 408 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
406 409 }
407 410
408 411 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
409 412 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
410 413 {
411 414 unsigned int i;
412 415 unsigned int length = 0;
413 416 rtems_status_code status;
414 417
415 418 for (i=0; i<2; i++)
416 419 {
417 420 // (1) BUILD THE DATA
418 421 switch(sid)
419 422 {
420 423 case SID_NORM_ASM_F0:
421 424 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
422 425 spw_ioctl_send->data = &spectral_matrix[
423 426 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
424 427 ];
425 428 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
426 429 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
427 430 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
428 431 break;
429 432 case SID_NORM_ASM_F1:
430 433 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
431 434 spw_ioctl_send->data = &spectral_matrix[
432 435 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
433 436 ];
434 437 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
435 438 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
436 439 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
437 440 break;
438 441 case SID_NORM_ASM_F2:
439 442 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
440 443 spw_ioctl_send->data = &spectral_matrix[
441 444 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
442 445 ];
443 446 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
444 447 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
445 448 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
446 449 break;
447 450 default:
448 451 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
449 452 break;
450 453 }
451 454 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
452 455 spw_ioctl_send->hdr = (char *) header;
453 456 spw_ioctl_send->options = 0;
454 457
455 458 // (2) BUILD THE HEADER
456 459 increment_seq_counter_source_id( header->packetSequenceControl, sid );
457 460 header->packetLength[0] = (unsigned char) (length>>8);
458 461 header->packetLength[1] = (unsigned char) (length);
459 462 header->sid = (unsigned char) sid; // SID
460 463 header->pa_lfr_pkt_cnt_asm = 2;
461 464 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
462 465
463 466 // (3) SET PACKET TIME
464 467 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
465 468 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
466 469 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
467 470 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
468 471 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
469 472 header->time[5] = (unsigned char) (time_management_regs->fine_time);
470 473 //
471 474 header->acquisitionTime[0] = header->time[0];
472 475 header->acquisitionTime[1] = header->time[1];
473 476 header->acquisitionTime[2] = header->time[2];
474 477 header->acquisitionTime[3] = header->time[3];
475 478 header->acquisitionTime[4] = header->time[4];
476 479 header->acquisitionTime[5] = header->time[5];
477 480
478 481 // (4) SEND PACKET
479 482 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
480 483 if (status != RTEMS_SUCCESSFUL) {
481 484 printf("in ASM_send *** ERR %d\n", (int) status);
482 485 }
483 486 }
484 487 }
485 488
486 489 //*****************
487 490 // Basic Parameters
488 491
489 492 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
490 493 unsigned int apid, unsigned char sid,
491 494 unsigned int packetLength, unsigned char blkNr )
492 495 {
493 496 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
494 497 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
495 498 header->reserved = 0x00;
496 499 header->userApplication = CCSDS_USER_APP;
497 500 header->packetID[0] = (unsigned char) (apid >> 8);
498 501 header->packetID[1] = (unsigned char) (apid);
499 502 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
500 503 header->packetSequenceControl[1] = 0x00;
501 504 header->packetLength[0] = (unsigned char) (packetLength >> 8);
502 505 header->packetLength[1] = (unsigned char) (packetLength);
503 506 // DATA FIELD HEADER
504 507 header->spare1_pusVersion_spare2 = 0x10;
505 508 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
506 509 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
507 510 header->destinationID = TM_DESTINATION_ID_GROUND;
508 511 // AUXILIARY DATA HEADER
509 512 header->sid = sid;
510 513 header->biaStatusInfo = 0x00;
511 514 header->time[0] = 0x00;
512 515 header->time[0] = 0x00;
513 516 header->time[0] = 0x00;
514 517 header->time[0] = 0x00;
515 518 header->time[0] = 0x00;
516 519 header->time[0] = 0x00;
517 520 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
518 521 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
519 522 }
520 523
521 524 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
522 525 unsigned int apid, unsigned char sid,
523 526 unsigned int packetLength , unsigned char blkNr)
524 527 {
525 528 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
526 529 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
527 530 header->reserved = 0x00;
528 531 header->userApplication = CCSDS_USER_APP;
529 532 header->packetID[0] = (unsigned char) (apid >> 8);
530 533 header->packetID[1] = (unsigned char) (apid);
531 534 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
532 535 header->packetSequenceControl[1] = 0x00;
533 536 header->packetLength[0] = (unsigned char) (packetLength >> 8);
534 537 header->packetLength[1] = (unsigned char) (packetLength);
535 538 // DATA FIELD HEADER
536 539 header->spare1_pusVersion_spare2 = 0x10;
537 540 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
538 541 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
539 542 header->destinationID = TM_DESTINATION_ID_GROUND;
540 543 // AUXILIARY DATA HEADER
541 544 header->sid = sid;
542 545 header->biaStatusInfo = 0x00;
543 546 header->time[0] = 0x00;
544 547 header->time[0] = 0x00;
545 548 header->time[0] = 0x00;
546 549 header->time[0] = 0x00;
547 550 header->time[0] = 0x00;
548 551 header->time[0] = 0x00;
549 552 header->source_data_spare = 0x00;
550 553 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
551 554 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
552 555 }
553 556
554 557 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
555 558 {
556 559 rtems_status_code status;
557 560
558 561 // SET THE SEQUENCE_CNT PARAMETER
559 562 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
560 563 // SEND PACKET
561 564 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
562 565 if (status != RTEMS_SUCCESSFUL)
563 566 {
564 567 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
565 568 }
566 569 }
567 570
568 571 //******************
569 572 // general functions
570 573
571 574 void reset_spectral_matrix_regs( void )
572 575 {
573 576 /** This function resets the spectral matrices module registers.
574 577 *
575 578 * The registers affected by this function are located at the following offset addresses:
576 579 *
577 580 * - 0x00 config
578 581 * - 0x04 status
579 582 * - 0x08 matrixF0_Address0
580 583 * - 0x10 matrixFO_Address1
581 584 * - 0x14 matrixF1_Address
582 585 * - 0x18 matrixF2_Address
583 586 *
584 587 */
585 588
586 589 spectral_matrix_regs->config = 0x00;
587 590 spectral_matrix_regs->status = 0x00;
588 591
589 592 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
590 593 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
591 594 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
592 595 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
593 596 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
594 597 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
595 598 }
596 599
597 600 void set_time( unsigned char *time, unsigned char * timeInBuffer )
598 601 {
599 // time[0] = timeInBuffer[2];
600 // time[1] = timeInBuffer[3];
601 // time[2] = timeInBuffer[0];
602 // time[3] = timeInBuffer[1];
603 // time[4] = timeInBuffer[6];
604 // time[5] = timeInBuffer[7];
605
606 602 time[0] = timeInBuffer[0];
607 603 time[1] = timeInBuffer[1];
608 604 time[2] = timeInBuffer[2];
609 605 time[3] = timeInBuffer[3];
610 606 time[4] = timeInBuffer[6];
611 607 time[5] = timeInBuffer[7];
612 608 }
613 609
614 610 unsigned long long int get_acquisition_time( unsigned char *timePtr )
615 611 {
616 612 unsigned long long int acquisitionTimeAslong;
617 613 acquisitionTimeAslong = 0x00;
618 614 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
619 615 + ( (unsigned long long int) timePtr[1] << 32 )
620 616 + ( timePtr[2] << 24 )
621 617 + ( timePtr[3] << 16 )
622 + ( timePtr[4] << 8 )
623 + ( timePtr[5] );
618 + ( timePtr[6] << 8 )
619 + ( timePtr[7] );
624 620 return acquisitionTimeAslong;
625 621 }
626 622
627 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
628 ring_node_sm *node_for_averaging, ring_node_sm *ringNode )
623 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
624 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
625 unsigned long long int time )
629 626 {
627 unsigned char *timePtr;
628 unsigned char *coarseTimePtr;
629 unsigned char *fineTimePtr;
630
631 timePtr = (unsigned char *) &time;
632 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
633 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
634
630 635 *nb_sm = *nb_sm + 1;
631 636 if (*nb_sm == nb_sm_before_avf)
632 637 {
633 638 node_for_averaging = ringNode;
639 coarseTimePtr[0] = timePtr[2];
640 coarseTimePtr[1] = timePtr[3];
641 coarseTimePtr[2] = timePtr[4];
642 coarseTimePtr[3] = timePtr[5];
643 fineTimePtr[2] = timePtr[6];
644 fineTimePtr[3] = timePtr[7];
634 645 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
635 646 {
636 647 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
637 648 }
638 649 *nb_sm = 0;
639 650 }
640 651 }
641 652
642 653 unsigned char getSID( rtems_event_set event )
643 654 {
644 655 unsigned char sid;
645 656
646 657 rtems_event_set eventSetBURST;
647 658 rtems_event_set eventSetSBM;
648 659
649 660 //******
650 661 // BURST
651 662 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
652 663 | RTEMS_EVENT_BURST_BP1_F1
653 664 | RTEMS_EVENT_BURST_BP2_F0
654 665 | RTEMS_EVENT_BURST_BP2_F1;
655 666
656 667 //****
657 668 // SBM
658 669 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
659 670 | RTEMS_EVENT_SBM_BP1_F1
660 671 | RTEMS_EVENT_SBM_BP2_F0
661 672 | RTEMS_EVENT_SBM_BP2_F1;
662 673
663 674 if (event & eventSetBURST)
664 675 {
665 676 sid = SID_BURST_BP1_F0;
666 677 }
667 678 else if (event & eventSetSBM)
668 679 {
669 680 sid = SID_SBM1_BP1_F0;
670 681 }
671 682 else
672 683 {
673 684 sid = 0;
674 685 }
675 686
676 687 return sid;
677 688 }
678 689
@@ -1,949 +1,949
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 unsigned char time[6];
35 35 rtems_id queue_rcv_id;
36 36 rtems_id queue_snd_id;
37 37
38 38 status = get_message_queue_id_recv( &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 42 }
43 43
44 44 status = get_message_queue_id_send( &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 48 }
49 49
50 50 result = LFR_SUCCESSFUL;
51 51 subtype = 0; // subtype of the current TC packet
52 52
53 53 BOOT_PRINTF("in ACTN *** \n")
54 54
55 55 while(1)
56 56 {
57 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 59 getTime( time ); // set time to the current time
60 60 if (status!=RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 63 }
64 64 else
65 65 {
66 66 subtype = TC.serviceSubType;
67 67 switch(subtype)
68 68 {
69 69 case TC_SUBTYPE_RESET:
70 70 result = action_reset( &TC, queue_snd_id, time );
71 71 close_action( &TC, result, queue_snd_id );
72 72 break;
73 73 //
74 74 case TC_SUBTYPE_LOAD_COMM:
75 75 result = action_load_common_par( &TC );
76 76 close_action( &TC, result, queue_snd_id );
77 77 break;
78 78 //
79 79 case TC_SUBTYPE_LOAD_NORM:
80 80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 81 close_action( &TC, result, queue_snd_id );
82 82 break;
83 83 //
84 84 case TC_SUBTYPE_LOAD_BURST:
85 85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 86 close_action( &TC, result, queue_snd_id );
87 87 break;
88 88 //
89 89 case TC_SUBTYPE_LOAD_SBM1:
90 90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 91 close_action( &TC, result, queue_snd_id );
92 92 break;
93 93 //
94 94 case TC_SUBTYPE_LOAD_SBM2:
95 95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 96 close_action( &TC, result, queue_snd_id );
97 97 break;
98 98 //
99 99 case TC_SUBTYPE_DUMP:
100 100 result = action_dump_par( queue_snd_id );
101 101 close_action( &TC, result, queue_snd_id );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_ENTER:
105 105 result = action_enter_mode( &TC, queue_snd_id );
106 106 close_action( &TC, result, queue_snd_id );
107 107 break;
108 108 //
109 109 case TC_SUBTYPE_UPDT_INFO:
110 110 result = action_update_info( &TC, queue_snd_id );
111 111 close_action( &TC, result, queue_snd_id );
112 112 break;
113 113 //
114 114 case TC_SUBTYPE_EN_CAL:
115 115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 //
119 119 case TC_SUBTYPE_DIS_CAL:
120 120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 121 close_action( &TC, result, queue_snd_id );
122 122 break;
123 123 //
124 124 case TC_SUBTYPE_UPDT_TIME:
125 125 result = action_update_time( &TC );
126 126 close_action( &TC, result, queue_snd_id );
127 127 break;
128 128 //
129 129 default:
130 130 break;
131 131 }
132 132 }
133 133 }
134 134 }
135 135
136 136 //***********
137 137 // TC ACTIONS
138 138
139 139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 140 {
141 141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 142 *
143 143 * @param TC points to the TeleCommand packet that is being processed
144 144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 145 *
146 146 */
147 147
148 148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 149 return LFR_DEFAULT;
150 150 }
151 151
152 152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
153 153 {
154 154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 155 *
156 156 * @param TC points to the TeleCommand packet that is being processed
157 157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 158 *
159 159 */
160 160
161 161 rtems_status_code status;
162 162 unsigned char requestedMode;
163 163 unsigned int *transitionCoarseTime_ptr;
164 164 unsigned int transitionCoarseTime;
165 165 unsigned char * bytePosPtr;
166 166
167 167 bytePosPtr = (unsigned char *) &TC->packetID;
168 168
169 169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
170 170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
171 171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
172 172
173 173 status = check_mode_value( requestedMode );
174 174
175 175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
176 176 {
177 177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
178 178 }
179 179 else // the mode value is consistent, check the transition
180 180 {
181 181 status = check_mode_transition(requestedMode);
182 182 if (status != LFR_SUCCESSFUL)
183 183 {
184 184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
185 185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
186 186 }
187 187 }
188 188
189 189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
190 190 {
191 191 status = check_transition_date( transitionCoarseTime );
192 192 if (status != LFR_SUCCESSFUL)
193 193 {
194 194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
195 195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
196 196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
197 197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
198 198 }
199 199 }
200 200
201 201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
202 202 {
203 203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
204 204 status = enter_mode( requestedMode, transitionCoarseTime );
205 205 }
206 206
207 207 return status;
208 208 }
209 209
210 210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
211 211 {
212 212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
213 213 *
214 214 * @param TC points to the TeleCommand packet that is being processed
215 215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
216 216 *
217 217 * @return LFR directive status code:
218 218 * - LFR_DEFAULT
219 219 * - LFR_SUCCESSFUL
220 220 *
221 221 */
222 222
223 223 unsigned int val;
224 224 int result;
225 225 unsigned int status;
226 226 unsigned char mode;
227 227 unsigned char * bytePosPtr;
228 228
229 229 bytePosPtr = (unsigned char *) &TC->packetID;
230 230
231 231 // check LFR mode
232 232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
233 233 status = check_update_info_hk_lfr_mode( mode );
234 234 if (status == LFR_SUCCESSFUL) // check TDS mode
235 235 {
236 236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
237 237 status = check_update_info_hk_tds_mode( mode );
238 238 }
239 239 if (status == LFR_SUCCESSFUL) // check THR mode
240 240 {
241 241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
242 242 status = check_update_info_hk_thr_mode( mode );
243 243 }
244 244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
245 245 {
246 246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
247 247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
248 248 val++;
249 249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
250 250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
251 251 }
252 252
253 253 result = status;
254 254
255 255 return result;
256 256 }
257 257
258 258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
259 259 {
260 260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
261 261 *
262 262 * @param TC points to the TeleCommand packet that is being processed
263 263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
264 264 *
265 265 */
266 266
267 267 int result;
268 268 unsigned char lfrMode;
269 269
270 270 result = LFR_DEFAULT;
271 271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
272 272
273 273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
274 274 result = LFR_DEFAULT;
275 275
276 276 return result;
277 277 }
278 278
279 279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
280 280 {
281 281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
282 282 *
283 283 * @param TC points to the TeleCommand packet that is being processed
284 284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
285 285 *
286 286 */
287 287
288 288 int result;
289 289 unsigned char lfrMode;
290 290
291 291 result = LFR_DEFAULT;
292 292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
293 293
294 294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
295 295 result = LFR_DEFAULT;
296 296
297 297 return result;
298 298 }
299 299
300 300 int action_update_time(ccsdsTelecommandPacket_t *TC)
301 301 {
302 302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
303 303 *
304 304 * @param TC points to the TeleCommand packet that is being processed
305 305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
306 306 *
307 307 * @return LFR_SUCCESSFUL
308 308 *
309 309 */
310 310
311 311 unsigned int val;
312 312
313 313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
314 314 + (TC->dataAndCRC[1] << 16)
315 315 + (TC->dataAndCRC[2] << 8)
316 316 + TC->dataAndCRC[3];
317 317
318 318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
319 319
320 320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
322 322 val++;
323 323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325 325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
326 326
327 327 return LFR_SUCCESSFUL;
328 328 }
329 329
330 330 //*******************
331 331 // ENTERING THE MODES
332 332 int check_mode_value( unsigned char requestedMode )
333 333 {
334 334 int status;
335 335
336 336 if ( (requestedMode != LFR_MODE_STANDBY)
337 337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
338 338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
339 339 {
340 340 status = LFR_DEFAULT;
341 341 }
342 342 else
343 343 {
344 344 status = LFR_SUCCESSFUL;
345 345 }
346 346
347 347 return status;
348 348 }
349 349
350 350 int check_mode_transition( unsigned char requestedMode )
351 351 {
352 352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
353 353 *
354 354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
355 355 *
356 356 * @return LFR directive status codes:
357 357 * - LFR_SUCCESSFUL - the transition is authorized
358 358 * - LFR_DEFAULT - the transition is not authorized
359 359 *
360 360 */
361 361
362 362 int status;
363 363
364 364 switch (requestedMode)
365 365 {
366 366 case LFR_MODE_STANDBY:
367 367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
368 368 status = LFR_DEFAULT;
369 369 }
370 370 else
371 371 {
372 372 status = LFR_SUCCESSFUL;
373 373 }
374 374 break;
375 375 case LFR_MODE_NORMAL:
376 376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
377 377 status = LFR_DEFAULT;
378 378 }
379 379 else {
380 380 status = LFR_SUCCESSFUL;
381 381 }
382 382 break;
383 383 case LFR_MODE_BURST:
384 384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
385 385 status = LFR_DEFAULT;
386 386 }
387 387 else {
388 388 status = LFR_SUCCESSFUL;
389 389 }
390 390 break;
391 391 case LFR_MODE_SBM1:
392 392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
393 393 status = LFR_DEFAULT;
394 394 }
395 395 else {
396 396 status = LFR_SUCCESSFUL;
397 397 }
398 398 break;
399 399 case LFR_MODE_SBM2:
400 400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
401 401 status = LFR_DEFAULT;
402 402 }
403 403 else {
404 404 status = LFR_SUCCESSFUL;
405 405 }
406 406 break;
407 407 default:
408 408 status = LFR_DEFAULT;
409 409 break;
410 410 }
411 411
412 412 return status;
413 413 }
414 414
415 415 int check_transition_date( unsigned int transitionCoarseTime )
416 416 {
417 417 int status;
418 418 unsigned int localCoarseTime;
419 419 unsigned int deltaCoarseTime;
420 420
421 421 status = LFR_SUCCESSFUL;
422 422
423 423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
424 424 {
425 425 status = LFR_SUCCESSFUL;
426 426 }
427 427 else
428 428 {
429 429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
430 430
431 431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
432 432 {
433 433 status = LFR_DEFAULT;
434 434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
435 435 }
436 436
437 437 if (status == LFR_SUCCESSFUL)
438 438 {
439 439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
440 440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
441 441 {
442 442 status = LFR_DEFAULT;
443 443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
444 444 }
445 445 }
446 446 }
447 447
448 448 return status;
449 449 }
450 450
451 451 int stop_current_mode( void )
452 452 {
453 453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
454 454 *
455 455 * @return RTEMS directive status codes:
456 456 * - RTEMS_SUCCESSFUL - task restarted successfully
457 457 * - RTEMS_INVALID_ID - task id invalid
458 458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
459 459 *
460 460 */
461 461
462 462 rtems_status_code status;
463 463
464 464 status = RTEMS_SUCCESSFUL;
465 465
466 466 // (1) mask interruptions
467 467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
468 468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
469 469
470 470 // (2) clear interruptions
471 471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
472 472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
473 473
474 474 // (3) reset waveform picker registers
475 475 reset_wfp_burst_enable(); // reset burst and enable bits
476 476 reset_wfp_status(); // reset all the status bits
477 477
478 478 // (4) reset spectral matrices registers
479 479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
480 480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
481 481 reset_extractSWF(); // reset the extractSWF flag to false
482 482
483 483 // <Spectral Matrices simulator>
484 484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
485 485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
486 486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
487 487 // </Spectral Matrices simulator>
488 488
489 489 // suspend several tasks
490 490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
491 491 status = suspend_science_tasks();
492 492 }
493 493
494 494 if (status != RTEMS_SUCCESSFUL)
495 495 {
496 496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
497 497 }
498 498
499 499 return status;
500 500 }
501 501
502 502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
503 503 {
504 504 /** This function is launched after a mode transition validation.
505 505 *
506 506 * @param mode is the mode in which LFR will be put.
507 507 *
508 508 * @return RTEMS directive status codes:
509 509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
510 510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
511 511 *
512 512 */
513 513
514 514 rtems_status_code status;
515 515
516 516 //**********************
517 517 // STOP THE CURRENT MODE
518 518 status = stop_current_mode();
519 519 if (status != RTEMS_SUCCESSFUL)
520 520 {
521 521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
522 522 }
523 523
524 524 //*************************
525 525 // ENTER THE REQUESTED MODE
526 526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
527 527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
528 528 {
529 529 #ifdef PRINT_TASK_STATISTICS
530 530 rtems_cpu_usage_reset();
531 531 maxCount = 0;
532 532 #endif
533 533 status = restart_science_tasks( mode );
534 534 launch_waveform_picker( mode, transitionCoarseTime );
535 // launch_spectral_matrix( );
536 launch_spectral_matrix_simu( );
535 launch_spectral_matrix( );
536 // launch_spectral_matrix_simu( );
537 537 }
538 538 else if ( mode == LFR_MODE_STANDBY )
539 539 {
540 540 #ifdef PRINT_TASK_STATISTICS
541 541 rtems_cpu_usage_report();
542 542 #endif
543 543
544 544 #ifdef PRINT_STACK_REPORT
545 545 PRINTF("stack report selected\n")
546 546 rtems_stack_checker_report_usage();
547 547 #endif
548 548 PRINTF1("maxCount = %d\n", maxCount)
549 549 }
550 550 else
551 551 {
552 552 status = RTEMS_UNSATISFIED;
553 553 }
554 554
555 555 if (status != RTEMS_SUCCESSFUL)
556 556 {
557 557 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
558 558 status = RTEMS_UNSATISFIED;
559 559 }
560 560
561 561 return status;
562 562 }
563 563
564 564 int restart_science_tasks(unsigned char lfrRequestedMode )
565 565 {
566 566 /** This function is used to restart all science tasks.
567 567 *
568 568 * @return RTEMS directive status codes:
569 569 * - RTEMS_SUCCESSFUL - task restarted successfully
570 570 * - RTEMS_INVALID_ID - task id invalid
571 571 * - RTEMS_INCORRECT_STATE - task never started
572 572 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
573 573 *
574 574 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
575 575 *
576 576 */
577 577
578 578 rtems_status_code status[10];
579 579 rtems_status_code ret;
580 580
581 581 ret = RTEMS_SUCCESSFUL;
582 582
583 583 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
584 584 if (status[0] != RTEMS_SUCCESSFUL)
585 585 {
586 586 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
587 587 }
588 588
589 589 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
590 590 if (status[1] != RTEMS_SUCCESSFUL)
591 591 {
592 592 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
593 593 }
594 594
595 595 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
596 596 if (status[2] != RTEMS_SUCCESSFUL)
597 597 {
598 598 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
599 599 }
600 600
601 601 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
602 602 if (status[3] != RTEMS_SUCCESSFUL)
603 603 {
604 604 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
605 605 }
606 606
607 607 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
608 608 if (status[4] != RTEMS_SUCCESSFUL)
609 609 {
610 610 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
611 611 }
612 612
613 613 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
614 614 if (status[5] != RTEMS_SUCCESSFUL)
615 615 {
616 616 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
617 617 }
618 618
619 619 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
620 620 if (status[6] != RTEMS_SUCCESSFUL)
621 621 {
622 622 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
623 623 }
624 624
625 625 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
626 626 if (status[7] != RTEMS_SUCCESSFUL)
627 627 {
628 628 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
629 629 }
630 630
631 631 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
632 632 if (status[8] != RTEMS_SUCCESSFUL)
633 633 {
634 634 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
635 635 }
636 636
637 637 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
638 638 if (status[9] != RTEMS_SUCCESSFUL)
639 639 {
640 640 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
641 641 }
642 642
643 643 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
644 644 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
645 645 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
646 646 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
647 647 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
648 648 {
649 649 ret = RTEMS_UNSATISFIED;
650 650 }
651 651
652 652 return ret;
653 653 }
654 654
655 655 int suspend_science_tasks()
656 656 {
657 657 /** This function suspends the science tasks.
658 658 *
659 659 * @return RTEMS directive status codes:
660 660 * - RTEMS_SUCCESSFUL - task restarted successfully
661 661 * - RTEMS_INVALID_ID - task id invalid
662 662 * - RTEMS_ALREADY_SUSPENDED - task already suspended
663 663 *
664 664 */
665 665
666 666 rtems_status_code status;
667 667
668 668 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
669 669 if (status != RTEMS_SUCCESSFUL)
670 670 {
671 671 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
672 672 }
673 673 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
674 674 {
675 675 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
676 676 if (status != RTEMS_SUCCESSFUL)
677 677 {
678 678 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
679 679 }
680 680 }
681 681 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
682 682 {
683 683 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
684 684 if (status != RTEMS_SUCCESSFUL)
685 685 {
686 686 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
687 687 }
688 688 }
689 689 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
690 690 {
691 691 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
692 692 if (status != RTEMS_SUCCESSFUL)
693 693 {
694 694 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
695 695 }
696 696 }
697 697 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
698 698 {
699 699 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
700 700 if (status != RTEMS_SUCCESSFUL)
701 701 {
702 702 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
703 703 }
704 704 }
705 705 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
706 706 {
707 707 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
708 708 if (status != RTEMS_SUCCESSFUL)
709 709 {
710 710 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
711 711 }
712 712 }
713 713 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
714 714 {
715 715 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
716 716 if (status != RTEMS_SUCCESSFUL)
717 717 {
718 718 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
719 719 }
720 720 }
721 721 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
722 722 {
723 723 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
724 724 if (status != RTEMS_SUCCESSFUL)
725 725 {
726 726 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
727 727 }
728 728 }
729 729 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
730 730 {
731 731 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
732 732 if (status != RTEMS_SUCCESSFUL)
733 733 {
734 734 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
735 735 }
736 736 }
737 737 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
738 738 {
739 739 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
740 740 if (status != RTEMS_SUCCESSFUL)
741 741 {
742 742 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
743 743 }
744 744 }
745 745
746 746 return status;
747 747 }
748 748
749 749 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
750 750 {
751 751 WFP_reset_current_ring_nodes();
752 752 reset_waveform_picker_regs();
753 753 set_wfp_burst_enable_register( mode );
754 754
755 755 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
756 756 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
757 757
758 758 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
759 759 if (transitionCoarseTime == 0)
760 760 {
761 761 waveform_picker_regs->start_date = time_management_regs->coarse_time;
762 762 }
763 763 else
764 764 {
765 765 waveform_picker_regs->start_date = transitionCoarseTime;
766 766 }
767 767 }
768 768
769 769 void launch_spectral_matrix( void )
770 770 {
771 771 SM_reset_current_ring_nodes();
772 772 reset_spectral_matrix_regs();
773 773 reset_nb_sm();
774 774
775 775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
776 776 grgpio_regs->io_port_direction_register =
777 777 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
778 778 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
779 779 set_irq_on_new_ready_matrix( 1 );
780 780 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
781 781 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
782 782 set_run_matrix_spectral( 1 );
783 783
784 784 }
785 785
786 786 void launch_spectral_matrix_simu( void )
787 787 {
788 788 SM_reset_current_ring_nodes();
789 789 reset_spectral_matrix_regs();
790 790 reset_nb_sm();
791 791
792 792 // Spectral Matrices simulator
793 793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
794 794 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
795 795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
796 796 }
797 797
798 798 void set_irq_on_new_ready_matrix( unsigned char value )
799 799 {
800 800 if (value == 1)
801 801 {
802 802 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
803 803 }
804 804 else
805 805 {
806 806 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
807 807 }
808 808 }
809 809
810 810 void set_run_matrix_spectral( unsigned char value )
811 811 {
812 812 if (value == 1)
813 813 {
814 814 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
815 815 }
816 816 else
817 817 {
818 818 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
819 819 }
820 820 }
821 821
822 822 //****************
823 823 // CLOSING ACTIONS
824 824 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
825 825 {
826 826 /** This function is used to update the HK packets statistics after a successful TC execution.
827 827 *
828 828 * @param TC points to the TC being processed
829 829 * @param time is the time used to date the TC execution
830 830 *
831 831 */
832 832
833 833 unsigned int val;
834 834
835 835 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
836 836 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
837 837 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
838 838 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
839 839 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
840 840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
841 841 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
842 842 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
843 843 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
844 844 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
845 845 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
846 846 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
847 847
848 848 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
849 849 val++;
850 850 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
851 851 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
852 852 }
853 853
854 854 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
855 855 {
856 856 /** This function is used to update the HK packets statistics after a TC rejection.
857 857 *
858 858 * @param TC points to the TC being processed
859 859 * @param time is the time used to date the TC rejection
860 860 *
861 861 */
862 862
863 863 unsigned int val;
864 864
865 865 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
866 866 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
867 867 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
868 868 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
869 869 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
870 870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
871 871 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
872 872 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
873 873 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
874 874 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
875 875 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
876 876 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
877 877
878 878 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
879 879 val++;
880 880 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
881 881 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
882 882 }
883 883
884 884 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
885 885 {
886 886 /** This function is the last step of the TC execution workflow.
887 887 *
888 888 * @param TC points to the TC being processed
889 889 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
890 890 * @param queue_id is the id of the RTEMS message queue used to send TM packets
891 891 * @param time is the time used to date the TC execution
892 892 *
893 893 */
894 894
895 895 unsigned char requestedMode;
896 896
897 897 if (result == LFR_SUCCESSFUL)
898 898 {
899 899 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
900 900 &
901 901 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
902 902 )
903 903 {
904 904 send_tm_lfr_tc_exe_success( TC, queue_id );
905 905 }
906 906 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
907 907 {
908 908 //**********************************
909 909 // UPDATE THE LFRMODE LOCAL VARIABLE
910 910 requestedMode = TC->dataAndCRC[1];
911 911 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
912 912 updateLFRCurrentMode();
913 913 }
914 914 }
915 915 else if (result == LFR_EXE_ERROR)
916 916 {
917 917 send_tm_lfr_tc_exe_error( TC, queue_id );
918 918 }
919 919 }
920 920
921 921 //***************************
922 922 // Interrupt Service Routines
923 923 rtems_isr commutation_isr1( rtems_vector_number vector )
924 924 {
925 925 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
926 926 printf("In commutation_isr1 *** Error sending event to DUMB\n");
927 927 }
928 928 }
929 929
930 930 rtems_isr commutation_isr2( rtems_vector_number vector )
931 931 {
932 932 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
933 933 printf("In commutation_isr2 *** Error sending event to DUMB\n");
934 934 }
935 935 }
936 936
937 937 //****************
938 938 // OTHER FUNCTIONS
939 939 void updateLFRCurrentMode()
940 940 {
941 941 /** This function updates the value of the global variable lfrCurrentMode.
942 942 *
943 943 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
944 944 *
945 945 */
946 946 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
947 947 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
948 948 }
949 949
General Comments 0
You need to be logged in to leave comments. Login now