##// END OF EJS Templates
sequence_cnt field set for BP and ASM packets
paul -
r133:0209817182bd VHDLib206
parent child
Show More
@@ -1,268 +1,268
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue May 13 15:18:10 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Thu May 15 08:30:40 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=7 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
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/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/basic_parameters/basic_parameters.c \
56 56 ../src/processing/fsw_processing.c \
57 57 ../src/processing/avf0_prc0.c \
58 58 ../src/processing/avf1_prc1.c \
59 59 ../src/processing/avf2_prc2.c
60 60 OBJECTS = obj/wf_handler.o \
61 61 obj/tc_handler.o \
62 62 obj/fsw_misc.o \
63 63 obj/fsw_init.o \
64 64 obj/fsw_globals.o \
65 65 obj/fsw_spacewire.o \
66 66 obj/tc_load_dump_parameters.o \
67 67 obj/tm_lfr_tc_exe.o \
68 68 obj/tc_acceptance.o \
69 69 obj/basic_parameters.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 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
75 75 /usr/lib64/qt4/mkspecs/common/linux.conf \
76 76 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
77 77 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
78 78 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/qconfig.pri \
81 81 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
82 82 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
83 83 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
84 84 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
85 85 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
86 86 sparc.pri \
87 87 /usr/lib64/qt4/mkspecs/features/release.prf \
88 88 /usr/lib64/qt4/mkspecs/features/default_post.prf \
89 89 /usr/lib64/qt4/mkspecs/features/shared.prf \
90 90 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
91 91 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
92 92 /usr/lib64/qt4/mkspecs/features/resources.prf \
93 93 /usr/lib64/qt4/mkspecs/features/uic.prf \
94 94 /usr/lib64/qt4/mkspecs/features/yacc.prf \
95 95 /usr/lib64/qt4/mkspecs/features/lex.prf \
96 96 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
97 97 fsw-qt.pro
98 98 QMAKE_TARGET = fsw
99 99 DESTDIR = bin/
100 100 TARGET = bin/fsw
101 101
102 102 first: all
103 103 ####### Implicit rules
104 104
105 105 .SUFFIXES: .o .c .cpp .cc .cxx .C
106 106
107 107 .cpp.o:
108 108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
109 109
110 110 .cc.o:
111 111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112 112
113 113 .cxx.o:
114 114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
115 115
116 116 .C.o:
117 117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
118 118
119 119 .c.o:
120 120 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
121 121
122 122 ####### Build rules
123 123
124 124 all: Makefile $(TARGET)
125 125
126 126 $(TARGET): $(OBJECTS)
127 127 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
128 128 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
129 129
130 130 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
131 131 /usr/lib64/qt4/mkspecs/common/linux.conf \
132 132 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
133 133 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
134 134 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/qconfig.pri \
137 137 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
138 138 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
139 139 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
140 140 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
141 141 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
142 142 sparc.pri \
143 143 /usr/lib64/qt4/mkspecs/features/release.prf \
144 144 /usr/lib64/qt4/mkspecs/features/default_post.prf \
145 145 /usr/lib64/qt4/mkspecs/features/shared.prf \
146 146 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
147 147 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
148 148 /usr/lib64/qt4/mkspecs/features/resources.prf \
149 149 /usr/lib64/qt4/mkspecs/features/uic.prf \
150 150 /usr/lib64/qt4/mkspecs/features/yacc.prf \
151 151 /usr/lib64/qt4/mkspecs/features/lex.prf \
152 152 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
153 153 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
154 154 /usr/lib64/qt4/mkspecs/common/unix.conf:
155 155 /usr/lib64/qt4/mkspecs/common/linux.conf:
156 156 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
157 157 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
158 158 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/qconfig.pri:
161 161 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
162 162 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
163 163 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
164 164 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
165 165 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
166 166 sparc.pri:
167 167 /usr/lib64/qt4/mkspecs/features/release.prf:
168 168 /usr/lib64/qt4/mkspecs/features/default_post.prf:
169 169 /usr/lib64/qt4/mkspecs/features/shared.prf:
170 170 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
171 171 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
172 172 /usr/lib64/qt4/mkspecs/features/resources.prf:
173 173 /usr/lib64/qt4/mkspecs/features/uic.prf:
174 174 /usr/lib64/qt4/mkspecs/features/yacc.prf:
175 175 /usr/lib64/qt4/mkspecs/features/lex.prf:
176 176 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
177 177 qmake: FORCE
178 178 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
179 179
180 180 dist:
181 181 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
182 182 $(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
183 183
184 184
185 185 clean:compiler_clean
186 186 -$(DEL_FILE) $(OBJECTS)
187 187 -$(DEL_FILE) *~ core *.core
188 188
189 189
190 190 ####### Sub-libraries
191 191
192 192 distclean: clean
193 193 -$(DEL_FILE) $(TARGET)
194 194 -$(DEL_FILE) Makefile
195 195
196 196
197 197 grmon:
198 198 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
199 199
200 200 check: first
201 201
202 202 compiler_rcc_make_all:
203 203 compiler_rcc_clean:
204 204 compiler_uic_make_all:
205 205 compiler_uic_clean:
206 206 compiler_image_collection_make_all: qmake_image_collection.cpp
207 207 compiler_image_collection_clean:
208 208 -$(DEL_FILE) qmake_image_collection.cpp
209 209 compiler_yacc_decl_make_all:
210 210 compiler_yacc_decl_clean:
211 211 compiler_yacc_impl_make_all:
212 212 compiler_yacc_impl_clean:
213 213 compiler_lex_make_all:
214 214 compiler_lex_clean:
215 215 compiler_clean:
216 216
217 217 ####### Compile
218 218
219 219 obj/wf_handler.o: ../src/wf_handler.c
220 220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
221 221
222 222 obj/tc_handler.o: ../src/tc_handler.c
223 223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
224 224
225 225 obj/fsw_misc.o: ../src/fsw_misc.c
226 226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
227 227
228 228 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
229 229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
230 230
231 231 obj/fsw_globals.o: ../src/fsw_globals.c
232 232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
233 233
234 234 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
235 235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
236 236
237 237 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
238 238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
239 239
240 240 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
241 241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
242 242
243 243 obj/tc_acceptance.o: ../src/tc_acceptance.c
244 244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
245 245
246 246 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
247 247 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
248 248
249 249 obj/fsw_processing.o: ../src/processing/fsw_processing.c
250 250 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
251 251
252 252 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
253 253 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
254 254
255 255 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
256 256 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
257 257
258 258 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
259 259 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
260 260
261 261 ####### Install
262 262
263 263 install: FORCE
264 264
265 265 uninstall: FORCE
266 266
267 267 FORCE:
268 268
@@ -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-05-13T15:58:32. -->
3 <!-- Written by QtCreator 3.0.1, 2014-05-15T06:56:44. -->
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,251 +1,250
1 1 #ifndef FSW_PARAMS_H_INCLUDED
2 2 #define FSW_PARAMS_H_INCLUDED
3 3
4 4 #include "grlib_regs.h"
5 5 #include "fsw_params_processing.h"
6 6 #include "fsw_params_nb_bytes.h"
7 7 #include "tm_byte_positions.h"
8 8 #include "ccsds_types.h"
9 9
10 10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 11 #define UART_DEVICE_NAME "/dev/console"
12 12
13 13 typedef struct ring_node
14 14 {
15 15 struct ring_node *previous;
16 16 int buffer_address;
17 17 struct ring_node *next;
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 21 //************************
22 22 // flight software version
23 23 // this parameters is handled by the Qt project options
24 24
25 25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 28 #define TIME_OFFSET 2
29 29 #define TIME_OFFSET_IN_BYTES 8
30 30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 31 #define NB_BYTES_SWF_BLK (2 * 6)
32 32 #define NB_WORDS_SWF_BLK 3
33 33 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 38 #define NB_RING_NODES_F3 3 // AT LEAST 3
39 39
40 40 //**********
41 41 // LFR MODES
42 42 #define LFR_MODE_STANDBY 0
43 43 #define LFR_MODE_NORMAL 1
44 44 #define LFR_MODE_BURST 2
45 45 #define LFR_MODE_SBM1 3
46 46 #define LFR_MODE_SBM2 4
47 47
48 48 #define TDS_MODE_LFM 5
49 49 #define TDS_MODE_STANDBY 0
50 50 #define TDS_MODE_NORMAL 1
51 51 #define TDS_MODE_BURST 2
52 52 #define TDS_MODE_SBM1 3
53 53 #define TDS_MODE_SBM2 4
54 54
55 55 #define THR_MODE_STANDBY 0
56 56 #define THR_MODE_NORMAL 1
57 57 #define THR_MODE_BURST 2
58 58
59 59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
60 60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
61 61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
62 62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
63 63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
64 64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
65 65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
66 66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
67 67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
68 68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
69 69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
70 70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
71 71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
72 72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
73 73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
74 74 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
75 75 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
76 76 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
77 77 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
78 78
79 79 //****************************
80 80 // LFR DEFAULT MODE PARAMETERS
81 81 // COMMON
82 82 #define DEFAULT_SY_LFR_COMMON0 0x00
83 83 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
84 84 // NORM
85 85 #define SY_LFR_N_SWF_L 2048 // nb sample
86 86 #define SY_LFR_N_SWF_P 300 // sec
87 87 #define SY_LFR_N_ASM_P 3600 // sec
88 88 #define SY_LFR_N_BP_P0 4 // sec
89 89 #define SY_LFR_N_BP_P1 20 // sec
90 90 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
91 91 #define MIN_DELTA_SNAPSHOT 16 // sec
92 92 // BURST
93 93 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
94 94 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
95 95 // SBM1
96 96 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
97 97 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
98 98 // SBM2
99 99 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
100 100 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
101 101 // ADDITIONAL PARAMETERS
102 102 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
103 103 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
104 104 // STATUS WORD
105 105 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
106 106 #define DEFAULT_STATUS_WORD_BYTE1 0x00
107 107 //
108 108 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
109 109 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
110 110 //****************************
111 111
112 112 //*****************************
113 113 // APB REGISTERS BASE ADDRESSES
114 114 #define REGS_ADDR_APBUART 0x80000100
115 115 #define REGS_ADDR_GPTIMER 0x80000300
116 116 #define REGS_ADDR_GRSPW 0x80000500
117 117 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
118 118 #define REGS_ADDR_GRGPIO 0x80000b00
119 119
120 120 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
121 121 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
122 122
123 123 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
124 124 #define APBUART_CTRL_REG_MASK_TE 0x00000002
125 125 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
126 126
127 127 //**********
128 128 // IRQ LINES
129 129 #define IRQ_SM_SIMULATOR 9
130 130 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
131 131 #define IRQ_WAVEFORM_PICKER 14
132 132 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
133 133 #define IRQ_SPECTRAL_MATRIX 6
134 134 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
135 135
136 136 //*****
137 137 // TIME
138 138 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
139 139 #define TIMER_SM_SIMULATOR 1
140 140 #define HK_PERIOD 100 // 100 * 10ms => 1s
141 141 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
142 142 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
143 143
144 144 //**********
145 145 // LPP CODES
146 146 #define LFR_SUCCESSFUL 0
147 147 #define LFR_DEFAULT 1
148 148 #define LFR_EXE_ERROR 2
149 149
150 150 //******
151 151 // RTEMS
152 152 #define TASKID_RECV 1
153 153 #define TASKID_ACTN 2
154 154 #define TASKID_SPIQ 3
155 155 #define TASKID_STAT 4
156 156 #define TASKID_AVF0 5
157 157 #define TASKID_SWBD 6
158 158 #define TASKID_WFRM 7
159 159 #define TASKID_DUMB 8
160 160 #define TASKID_HOUS 9
161 161 #define TASKID_PRC0 10
162 162 #define TASKID_CWF3 11
163 163 #define TASKID_CWF2 12
164 164 #define TASKID_CWF1 13
165 165 #define TASKID_SEND 14
166 166 #define TASKID_WTDG 15
167 167 #define TASKID_AVF1 16
168 168 #define TASKID_PRC1 17
169 169 #define TASKID_AVF2 18
170 170 #define TASKID_PRC2 19
171 171
172 172 #define TASK_PRIORITY_SPIQ 5
173 173 #define TASK_PRIORITY_WTDG 20
174 174 #define TASK_PRIORITY_HOUS 30
175 175 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
176 176 #define TASK_PRIORITY_CWF2 35 //
177 177 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
178 178 #define TASK_PRIORITY_WFRM 40
179 179 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
180 180 #define TASK_PRIORITY_SEND 45
181 181 #define TASK_PRIORITY_RECV 50
182 182 #define TASK_PRIORITY_ACTN 50
183 183 #define TASK_PRIORITY_AVF0 60
184 184 #define TASK_PRIORITY_AVF1 70
185 185 #define TASK_PRIORITY_PRC0 100
186 186 #define TASK_PRIORITY_PRC1 100
187 187 #define TASK_PRIORITY_AVF2 110
188 188 #define TASK_PRIORITY_PRC2 110
189 189 #define TASK_PRIORITY_STAT 200
190 190 #define TASK_PRIORITY_DUMB 200
191 191
192 192 #define MSG_QUEUE_COUNT_RECV 10
193 193 #define MSG_QUEUE_COUNT_SEND 50
194 194 #define MSG_QUEUE_COUNT_PRC0 10
195 195 #define MSG_QUEUE_COUNT_PRC1 10
196 196 #define MSG_QUEUE_COUNT_PRC2 5
197 197 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
198 198 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
199 199 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
200 200 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
201 201 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
202 202
203 203 #define QUEUE_RECV 0
204 204 #define QUEUE_SEND 1
205 205 #define QUEUE_PRC0 2
206 206 #define QUEUE_PRC1 3
207 207 #define QUEUE_PRC2 4
208 208
209 209 //*******
210 210 // MACROS
211 211 #ifdef PRINT_MESSAGES_ON_CONSOLE
212 212 #define PRINTF(x) printf(x);
213 213 #define PRINTF1(x,y) printf(x,y);
214 214 #define PRINTF2(x,y,z) printf(x,y,z);
215 215 #else
216 216 #define PRINTF(x) ;
217 217 #define PRINTF1(x,y) ;
218 218 #define PRINTF2(x,y,z) ;
219 219 #endif
220 220
221 221 #ifdef BOOT_MESSAGES
222 222 #define BOOT_PRINTF(x) printf(x);
223 223 #define BOOT_PRINTF1(x,y) printf(x,y);
224 224 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
225 225 #else
226 226 #define BOOT_PRINTF(x) ;
227 227 #define BOOT_PRINTF1(x,y) ;
228 228 #define BOOT_PRINTF2(x,y,z) ;
229 229 #endif
230 230
231 231 #ifdef DEBUG_MESSAGES
232 232 #define DEBUG_PRINTF(x) printf(x);
233 233 #define DEBUG_PRINTF1(x,y) printf(x,y);
234 234 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
235 235 #else
236 236 #define DEBUG_PRINTF(x) ;
237 237 #define DEBUG_PRINTF1(x,y) ;
238 238 #define DEBUG_PRINTF2(x,y,z) ;
239 239 #endif
240 240
241 241 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
242 242
243 243 struct param_local_str{
244 244 unsigned int local_sbm1_nb_cwf_sent;
245 245 unsigned int local_sbm1_nb_cwf_max;
246 246 unsigned int local_sbm2_nb_cwf_sent;
247 247 unsigned int local_sbm2_nb_cwf_max;
248 unsigned int local_nb_interrupt_f0_MAX;
249 248 };
250 249
251 250 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,34 +1,37
1 1 #ifndef TM_BYTE_POSITIONS_H
2 2 #define TM_BYTE_POSITIONS_H
3 3
4 // SEQUENCE_CNT
5 #define PACKET_POS_SEQUENCE_CNT 6 // 4 + 2
6
4 7 // TC_LFR_LOAD_COMMON_PAR
5 8
6 9 // TC_LFR_LOAD_NORMAL_PAR
7 10 #define DATAFIELD_POS_SY_LFR_N_SWF_L 0
8 11 #define DATAFIELD_POS_SY_LFR_N_SWF_P 2
9 12 #define DATAFIELD_POS_SY_LFR_N_ASM_P 4
10 13 #define DATAFIELD_POS_SY_LFR_N_BP_P0 6
11 14 #define DATAFIELD_POS_SY_LFR_N_BP_P1 7
12 15 #define DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 8
13 16
14 17 // TC_LFR_LOAD_BURST_PAR
15 18 #define DATAFIELD_POS_SY_LFR_B_BP_P0 0
16 19 #define DATAFIELD_POS_SY_LFR_B_BP_P1 1
17 20
18 21 // TC_LFR_LOAD_SBM1_PAR
19 22 #define DATAFIELD_POS_SY_LFR_S1_BP_P0 0
20 23 #define DATAFIELD_POS_SY_LFR_S1_BP_P1 1
21 24
22 25 // TC_LFR_LOAD_SBM2_PAR
23 26 #define DATAFIELD_POS_SY_LFR_S2_BP_P0 0
24 27 #define DATAFIELD_POS_SY_LFR_S2_BP_P1 1
25 28
26 29 // TC_LFR_UPDATE_INFO
27 30 #define BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 34
28 31 #define BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 35
29 32
30 33 // TC_LFR_ENTER_MODE
31 34 #define BYTE_POS_CP_MODE_LFR_SET 11
32 35 #define BYTE_POS_CP_LFR_ENTER_MODE_TIME 12
33 36
34 37 #endif // TM_BYTE_POSITIONS_H
@@ -1,70 +1,70
1 1 #ifndef FSW_PARAMS_PROCESSING_H
2 2 #define FSW_PARAMS_PROCESSING_H
3 3
4 4 #define NB_BINS_PER_SM 128
5 5 #define NB_VALUES_PER_SM 25
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
6 #define TOTAL_SIZE_SM 3200 // 25 * 128 = 0xC80
7 7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
8 8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
9 9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
11 11 //
12 12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 3
13 13 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
14 14 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
15 15 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
16 16 #define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3
17 17 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
18 18 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
19 19 #define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3
20 20 #define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3
21 21 //
22 #define NB_BINS_PER_ASM_F0 88
23 #define NB_BINS_PER_PKT_ASM_F0 44
24 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
25 #define ASM_F0_INDICE_START 17 // 88 bins
26 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
22 #define NB_BINS_PER_ASM_F0 88
23 #define NB_BINS_PER_PKT_ASM_F0 44
24 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
25 #define ASM_F0_INDICE_START 17 // 88 bins
26 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
27 27 //
28 #define NB_BINS_PER_ASM_F1 104
29 #define NB_BINS_PER_PKT_ASM_F1 52
30 #define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2
31 #define ASM_F1_INDICE_START 6 // 104 bins
32 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
28 #define NB_BINS_PER_ASM_F1 104
29 #define NB_BINS_PER_PKT_ASM_F1 52
30 #define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2
31 #define ASM_F1_INDICE_START 6 // 104 bins
32 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
33 33 //
34 #define NB_BINS_PER_ASM_F2 96
35 #define NB_BINS_PER_PKT_ASM_F2 48
36 #define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2
37 #define ASM_F2_INDICE_START 7 // 96 bins
38 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
34 #define NB_BINS_PER_ASM_F2 96
35 #define NB_BINS_PER_PKT_ASM_F2 48
36 #define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2
37 #define ASM_F2_INDICE_START 7 // 96 bins
38 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
39 39 //
40 40 #define NB_BINS_COMPRESSED_SM_F0 11
41 41 #define NB_BINS_COMPRESSED_SM_F1 13
42 42 #define NB_BINS_COMPRESSED_SM_F2 12
43 43 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
44 44 #define NB_BINS_COMPRESSED_SM_SBM_F1 26
45 45 #define NB_BINS_COMPRESSED_SM_SBM_F2 24
46 46 //
47 47 #define NB_BYTES_PER_BP1 9
48 48 //
49 49 #define NB_BINS_TO_AVERAGE_ASM_F0 8
50 50 #define NB_BINS_TO_AVERAGE_ASM_F1 8
51 51 #define NB_BINS_TO_AVERAGE_ASM_F2 8
52 52 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
53 53 #define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4
54 54 #define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4
55 55 //
56 56 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
57 57 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
58 58 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS
59 59 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
60 60 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
61 61 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS
62 62 #define TOTAL_SIZE_BP1_NORM_F0 99 // 9 * 11 UNSIGNED CHAR
63 63 #define TOTAL_SIZE_BP1_SBM_F0 198 // 9 * 22 UNSIGNED CHAR
64 64 // GENERAL
65 65 #define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function
66 66 #define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function
67 67 #define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function
68 68
69 69 #endif // FSW_PARAMS_PROCESSING_H
70 70
@@ -1,238 +1,238
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 typedef struct bp_packet
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 typedef struct bp_packet_with_spare
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 typedef struct asm_msg
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 // ASM
77 77 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
78 78 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
79 79 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
80 80 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
81 81
82 82 //*****************
83 83 // Basic Parameters
84 84
85 85 void BP_reset_current_ring_nodes( void );
86 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
87 unsigned int apid, unsigned char sid,
88 unsigned int packetLength , unsigned char blkNr);
89 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
90 unsigned int apid, unsigned char sid,
91 unsigned int packetLength, unsigned char blkNr );
92 void BP_send(char *data,
93 rtems_id queue_id ,
94 unsigned int nbBytesToSend );
86 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
87 unsigned int apid, unsigned char sid,
88 unsigned int packetLength , unsigned char blkNr);
89 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
90 unsigned int apid, unsigned char sid,
91 unsigned int packetLength, unsigned char blkNr );
92 void BP_send( char *data,
93 rtems_id queue_id ,
94 unsigned int nbBytesToSend , unsigned int sid );
95 95
96 96 //******************
97 97 // general functions
98 98 void reset_spectral_matrix_regs( void );
99 99 void set_time(unsigned char *time, unsigned char *timeInBuffer );
100 100
101 101 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
102 102 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
103 103
104 104 //***************************************
105 105 // DEFINITIONS OF STATIC INLINE FUNCTIONS
106 106 static inline void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
107 107 ring_node_sm *ring_node_tab[],
108 108 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
109 109 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
110 110 float divider );
111 111 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
112 112 float divider,
113 113 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
114 114 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
115 115
116 116 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
117 117 ring_node_sm *ring_node_tab[],
118 118 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
119 119 {
120 120 float sum;
121 121 unsigned int i;
122 122
123 123 for(i=0; i<TOTAL_SIZE_SM; i++)
124 124 {
125 125 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
126 126 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
127 127 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
128 128 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
129 129 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
130 130 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
131 131 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
132 132 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
133 133
134 134 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
135 135 {
136 136 averaged_spec_mat_f0[ i ] = sum;
137 137 averaged_spec_mat_f1[ i ] = sum;
138 138 }
139 139 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
140 140 {
141 141 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
142 142 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
143 143 }
144 144 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
145 145 {
146 146 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
147 147 averaged_spec_mat_f1[ i ] = sum;
148 148 }
149 149 else
150 150 {
151 151 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
152 152 }
153 153 }
154 154 }
155 155
156 156 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
157 157 {
158 158 int frequencyBin;
159 159 int asmComponent;
160 160 unsigned int offsetAveragedSpecMatReorganized;
161 161 unsigned int offsetAveragedSpecMat;
162 162
163 163 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
164 164 {
165 165 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
166 166 {
167 167 offsetAveragedSpecMatReorganized =
168 168 frequencyBin * NB_VALUES_PER_SM
169 169 + asmComponent;
170 170 offsetAveragedSpecMat =
171 171 asmComponent * NB_BINS_PER_SM
172 172 + frequencyBin;
173 173 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
174 174 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
175 175 }
176 176 }
177 177 }
178 178
179 179 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
180 180 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
181 181 {
182 182 int frequencyBin;
183 183 int asmComponent;
184 184 int offsetASM;
185 185 int offsetCompressed;
186 186 int k;
187 187
188 188 // build data
189 189 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
190 190 {
191 191 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
192 192 {
193 193 offsetCompressed = // NO TIME OFFSET
194 194 frequencyBin * NB_VALUES_PER_SM
195 195 + asmComponent;
196 196 offsetASM = // NO TIME OFFSET
197 197 asmComponent * NB_BINS_PER_SM
198 198 + ASMIndexStart
199 199 + frequencyBin * nbBinsToAverage;
200 200 compressed_spec_mat[ offsetCompressed ] = 0;
201 201 for ( k = 0; k < nbBinsToAverage; k++ )
202 202 {
203 203 compressed_spec_mat[offsetCompressed ] =
204 204 ( compressed_spec_mat[ offsetCompressed ]
205 205 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
206 206 }
207 207 }
208 208 }
209 209 }
210 210
211 211 void ASM_convert( volatile float *input_matrix, char *output_matrix)
212 212 {
213 213 unsigned int frequencyBin;
214 214 unsigned int asmComponent;
215 215 char * pt_char_input;
216 216 char * pt_char_output;
217 217 unsigned int offsetInput;
218 218 unsigned int offsetOutput;
219 219
220 220 pt_char_input = (char*) &input_matrix;
221 221 pt_char_output = (char*) &output_matrix;
222 222
223 223 // convert all other data
224 224 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
225 225 {
226 226 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
227 227 {
228 228 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
229 229 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
230 230 pt_char_input = (char*) &input_matrix [ offsetInput ];
231 231 pt_char_output = (char*) &output_matrix[ offsetOutput ];
232 232 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
233 233 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
234 234 }
235 235 }
236 236 }
237 237
238 238 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,94 +1,92
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8
9 9 #include "fsw_params.h"
10 10 #include "fsw_spacewire.h"
11 11 #include "fsw_misc.h"
12 12 #include "fsw_params_wf_handler.h"
13 13
14 14 #define pi 3.1415
15 15
16 16 extern int fdSPW;
17 17
18 18 //*****************
19 19 // waveform buffers
20 20 extern volatile int wf_snap_f0[ ];
21 21 extern volatile int wf_snap_f1[ ];
22 22 extern volatile int wf_snap_f2[ ];
23 23 extern volatile int wf_cont_f3[ ];
24 24 extern char wf_cont_f3_light[ ];
25 25
26 26 extern waveform_picker_regs_new_t *waveform_picker_regs;
27 27 extern time_management_regs_t *time_management_regs;
28 28 extern Packet_TM_LFR_HK_t housekeeping_packet;
29 29 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
30 30 extern struct param_local_str param_local;
31 31
32 32 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
33 33 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
34 34
35 35 extern rtems_id Task_id[20]; /* array of task ids */
36 36
37 37 extern unsigned char lfrCurrentMode;
38 38
39 39 //**********
40 40 // RTEMS_ISR
41 41 void reset_extractSWF( void );
42 42 rtems_isr waveforms_isr( rtems_vector_number vector );
43 43
44 44 //***********
45 45 // RTEMS_TASK
46 46 rtems_task wfrm_task( rtems_task_argument argument );
47 47 rtems_task cwf3_task( rtems_task_argument argument );
48 48 rtems_task cwf2_task( rtems_task_argument argument );
49 49 rtems_task cwf1_task( rtems_task_argument argument );
50 50 rtems_task swbd_task( rtems_task_argument argument );
51 51
52 52 //******************
53 53 // general functions
54 54 void init_waveform_rings( void );
55 55 void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] );
56 56 void reset_current_ring_nodes( void );
57 57 //
58 58 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
59 59 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
60 60 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
61 61 //
62 62 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 63 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 64 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 65 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
66 66 //
67 67 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
68 68 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
69 69 void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel );
70 70 void build_acquisition_time( unsigned long long int * acquisitionTimeAslong, ring_node *current_ring_node );
71 71 //
72 72 rtems_id get_pkts_queue_id( void );
73 73
74 74 //**************
75 75 // wfp registers
76 76 // RESET
77 77 void reset_wfp_burst_enable( void );
78 78 void reset_wfp_status(void);
79 79 void reset_waveform_picker_regs( void );
80 80 // SET
81 81 void set_wfp_data_shaping(void);
82 82 void set_wfp_burst_enable_register( unsigned char mode );
83 83 void set_wfp_delta_snapshot( void );
84 84 void set_wfp_delta_f0_f0_2( void );
85 85 void set_wfp_delta_f1( void );
86 86 void set_wfp_delta_f2( void );
87 87
88 88 //*****************
89 89 // local parameters
90 void set_local_nb_interrupt_f0_MAX( void );
91
92 90 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
93 91
94 92 #endif // WF_HANDLER_H_INCLUDED
@@ -1,767 +1,766
1 1 /** This is the RTEMS initialization module.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * This module contains two very different information:
7 7 * - specific instructions to configure the compilation of the RTEMS executive
8 8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 9 *
10 10 */
11 11
12 12 //*************************
13 13 // GPL reminder to be added
14 14 //*************************
15 15
16 16 #include <rtems.h>
17 17
18 18 /* configuration information */
19 19
20 20 #define CONFIGURE_INIT
21 21
22 22 #include <bsp.h> /* for device driver prototypes */
23 23
24 24 /* configuration information */
25 25
26 26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28 28
29 29 #define CONFIGURE_MAXIMUM_TASKS 20
30 30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 39 #ifdef PRINT_STACK_REPORT
40 40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 41 #endif
42 42
43 43 #include <rtems/confdefs.h>
44 44
45 45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 46 #ifdef RTEMS_DRVMGR_STARTUP
47 47 #ifdef LEON3
48 48 /* Add Timer and UART Driver */
49 49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 51 #endif
52 52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 54 #endif
55 55 #endif
56 56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 57 #include <drvmgr/drvmgr_confdefs.h>
58 58 #endif
59 59
60 60 #include "fsw_init.h"
61 61 #include "fsw_config.c"
62 62
63 63 rtems_task Init( rtems_task_argument ignored )
64 64 {
65 65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 66 *
67 67 * @param unused is the starting argument of the RTEMS task
68 68 *
69 69 * The INIT task create and run all other RTEMS tasks.
70 70 *
71 71 */
72 72
73 73 reset_local_time();
74 74
75 75 rtems_status_code status;
76 76 rtems_status_code status_spw;
77 77 rtems_isr_entry old_isr_handler;
78 78
79 79 // UART settings
80 80 send_console_outputs_on_apbuart_port();
81 81 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
82 82 enable_apbuart_transmitter();
83 83 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
84 84
85 85 PRINTF("\n\n\n\n\n")
86 86 PRINTF("*************************\n")
87 87 PRINTF("** LFR Flight Software **\n")
88 88 PRINTF1("** %d.", SW_VERSION_N1)
89 89 PRINTF1("%d." , SW_VERSION_N2)
90 90 PRINTF1("%d." , SW_VERSION_N3)
91 91 PRINTF1("%d **\n", SW_VERSION_N4)
92 92 PRINTF("*************************\n")
93 93 PRINTF("\n\n")
94 94
95 95 init_parameter_dump();
96 96 init_local_mode_parameters();
97 97 init_housekeeping_parameters();
98 98
99 99 init_waveform_rings(); // initialize the waveform rings
100 100 SM_init_rings(); // initialize spectral matrices rings
101 101
102 102 reset_wfp_burst_enable();
103 103 reset_wfp_status();
104 104 set_wfp_data_shaping();
105 105
106 106 updateLFRCurrentMode();
107 107
108 108 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
109 109
110 110 create_names(); // create all names
111 111
112 112 status = create_message_queues(); // create message queues
113 113 if (status != RTEMS_SUCCESSFUL)
114 114 {
115 115 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
116 116 }
117 117
118 118 status = create_all_tasks(); // create all tasks
119 119 if (status != RTEMS_SUCCESSFUL)
120 120 {
121 121 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
122 122 }
123 123
124 124 // **************************
125 125 // <SPACEWIRE INITIALIZATION>
126 126 grspw_timecode_callback = &timecode_irq_handler;
127 127
128 128 status_spw = spacewire_open_link(); // (1) open the link
129 129 if ( status_spw != RTEMS_SUCCESSFUL )
130 130 {
131 131 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
132 132 }
133 133
134 134 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
135 135 {
136 136 status_spw = spacewire_configure_link( fdSPW );
137 137 if ( status_spw != RTEMS_SUCCESSFUL )
138 138 {
139 139 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
140 140 }
141 141 }
142 142
143 143 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
144 144 {
145 145 status_spw = spacewire_start_link( fdSPW );
146 146 if ( status_spw != RTEMS_SUCCESSFUL )
147 147 {
148 148 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
149 149 }
150 150 }
151 151 // </SPACEWIRE INITIALIZATION>
152 152 // ***************************
153 153
154 154 status = start_all_tasks(); // start all tasks
155 155 if (status != RTEMS_SUCCESSFUL)
156 156 {
157 157 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
158 158 }
159 159
160 160 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
161 161 status = start_recv_send_tasks();
162 162 if ( status != RTEMS_SUCCESSFUL )
163 163 {
164 164 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
165 165 }
166 166
167 167 // suspend science tasks, they will be restarted later depending on the mode
168 168 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
169 169 if (status != RTEMS_SUCCESSFUL)
170 170 {
171 171 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
172 172 }
173 173
174 174 //******************************
175 175 // <SPECTRAL MATRICES SIMULATOR>
176 176 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
177 177 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
178 178 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
179 179 // </SPECTRAL MATRICES SIMULATOR>
180 180 //*******************************
181 181
182 182 // configure IRQ handling for the waveform picker unit
183 183 status = rtems_interrupt_catch( waveforms_isr,
184 184 IRQ_SPARC_WAVEFORM_PICKER,
185 185 &old_isr_handler) ;
186 186 // configure IRQ handling for the spectral matrices unit
187 187 status = rtems_interrupt_catch( spectral_matrices_isr,
188 188 IRQ_SPARC_SPECTRAL_MATRIX,
189 189 &old_isr_handler) ;
190 190
191 191 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
192 192 if ( status_spw != RTEMS_SUCCESSFUL )
193 193 {
194 194 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
195 195 if ( status != RTEMS_SUCCESSFUL ) {
196 196 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
197 197 }
198 198 }
199 199
200 200 BOOT_PRINTF("delete INIT\n")
201 201
202 202 send_dumb_hk();
203 203
204 204 status = rtems_task_delete(RTEMS_SELF);
205 205
206 206 }
207 207
208 208 void init_local_mode_parameters( void )
209 209 {
210 210 /** This function initialize the param_local global variable with default values.
211 211 *
212 212 */
213 213
214 214 unsigned int i;
215 215
216 216 // LOCAL PARAMETERS
217 set_local_nb_interrupt_f0_MAX();
218 217
219 218 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
220 219 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
221 220 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
222 221
223 222 // init sequence counters
224 223
225 224 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
226 225 {
227 226 sequenceCounters_TC_EXE[i] = 0x00;
228 227 }
229 228 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
230 229 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
231 230 }
232 231
233 232 void reset_local_time( void )
234 233 {
235 234 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
236 235 }
237 236
238 237 void create_names( void ) // create all names for tasks and queues
239 238 {
240 239 /** This function creates all RTEMS names used in the software for tasks and queues.
241 240 *
242 241 * @return RTEMS directive status codes:
243 242 * - RTEMS_SUCCESSFUL - successful completion
244 243 *
245 244 */
246 245
247 246 // task names
248 247 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
249 248 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
250 249 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
251 250 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
252 251 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
253 252 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
254 253 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
255 254 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
256 255 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
257 256 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
258 257 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
259 258 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
260 259 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
261 260 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
262 261 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
263 262 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
264 263 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
265 264 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
266 265 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
267 266
268 267 // rate monotonic period names
269 268 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
270 269
271 270 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
272 271 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
273 272 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
274 273 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
275 274 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
276 275 }
277 276
278 277 int create_all_tasks( void ) // create all tasks which run in the software
279 278 {
280 279 /** This function creates all RTEMS tasks used in the software.
281 280 *
282 281 * @return RTEMS directive status codes:
283 282 * - RTEMS_SUCCESSFUL - task created successfully
284 283 * - RTEMS_INVALID_ADDRESS - id is NULL
285 284 * - RTEMS_INVALID_NAME - invalid task name
286 285 * - RTEMS_INVALID_PRIORITY - invalid task priority
287 286 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
288 287 * - RTEMS_TOO_MANY - too many tasks created
289 288 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
290 289 * - RTEMS_TOO_MANY - too many global objects
291 290 *
292 291 */
293 292
294 293 rtems_status_code status;
295 294
296 295 //**********
297 296 // SPACEWIRE
298 297 // RECV
299 298 status = rtems_task_create(
300 299 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
301 300 RTEMS_DEFAULT_MODES,
302 301 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
303 302 );
304 303 if (status == RTEMS_SUCCESSFUL) // SEND
305 304 {
306 305 status = rtems_task_create(
307 306 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
308 307 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
309 308 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
310 309 );
311 310 }
312 311 if (status == RTEMS_SUCCESSFUL) // WTDG
313 312 {
314 313 status = rtems_task_create(
315 314 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
316 315 RTEMS_DEFAULT_MODES,
317 316 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
318 317 );
319 318 }
320 319 if (status == RTEMS_SUCCESSFUL) // ACTN
321 320 {
322 321 status = rtems_task_create(
323 322 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
324 323 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
325 324 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
326 325 );
327 326 }
328 327 if (status == RTEMS_SUCCESSFUL) // SPIQ
329 328 {
330 329 status = rtems_task_create(
331 330 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
332 331 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
333 332 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
334 333 );
335 334 }
336 335
337 336 //******************
338 337 // SPECTRAL MATRICES
339 338 if (status == RTEMS_SUCCESSFUL) // AVF0
340 339 {
341 340 status = rtems_task_create(
342 341 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
343 342 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
344 343 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
345 344 );
346 345 }
347 346 if (status == RTEMS_SUCCESSFUL) // PRC0
348 347 {
349 348 status = rtems_task_create(
350 349 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
351 350 RTEMS_DEFAULT_MODES,
352 351 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
353 352 );
354 353 }
355 354 if (status == RTEMS_SUCCESSFUL) // AVF1
356 355 {
357 356 status = rtems_task_create(
358 357 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
359 358 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
360 359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
361 360 );
362 361 }
363 362 if (status == RTEMS_SUCCESSFUL) // PRC1
364 363 {
365 364 status = rtems_task_create(
366 365 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
367 366 RTEMS_DEFAULT_MODES,
368 367 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
369 368 );
370 369 }
371 370 if (status == RTEMS_SUCCESSFUL) // AVF2
372 371 {
373 372 status = rtems_task_create(
374 373 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
375 374 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
376 375 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
377 376 );
378 377 }
379 378 if (status == RTEMS_SUCCESSFUL) // PRC2
380 379 {
381 380 status = rtems_task_create(
382 381 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
383 382 RTEMS_DEFAULT_MODES,
384 383 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
385 384 );
386 385 }
387 386
388 387 //****************
389 388 // WAVEFORM PICKER
390 389 if (status == RTEMS_SUCCESSFUL) // WFRM
391 390 {
392 391 status = rtems_task_create(
393 392 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
394 393 RTEMS_DEFAULT_MODES,
395 394 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
396 395 );
397 396 }
398 397 if (status == RTEMS_SUCCESSFUL) // CWF3
399 398 {
400 399 status = rtems_task_create(
401 400 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
402 401 RTEMS_DEFAULT_MODES,
403 402 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
404 403 );
405 404 }
406 405 if (status == RTEMS_SUCCESSFUL) // CWF2
407 406 {
408 407 status = rtems_task_create(
409 408 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
410 409 RTEMS_DEFAULT_MODES,
411 410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
412 411 );
413 412 }
414 413 if (status == RTEMS_SUCCESSFUL) // CWF1
415 414 {
416 415 status = rtems_task_create(
417 416 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
418 417 RTEMS_DEFAULT_MODES,
419 418 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
420 419 );
421 420 }
422 421 if (status == RTEMS_SUCCESSFUL) // SWBD
423 422 {
424 423 status = rtems_task_create(
425 424 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
426 425 RTEMS_DEFAULT_MODES,
427 426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
428 427 );
429 428 }
430 429
431 430 //*****
432 431 // MISC
433 432 if (status == RTEMS_SUCCESSFUL) // STAT
434 433 {
435 434 status = rtems_task_create(
436 435 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
437 436 RTEMS_DEFAULT_MODES,
438 437 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
439 438 );
440 439 }
441 440 if (status == RTEMS_SUCCESSFUL) // DUMB
442 441 {
443 442 status = rtems_task_create(
444 443 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
445 444 RTEMS_DEFAULT_MODES,
446 445 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
447 446 );
448 447 }
449 448 if (status == RTEMS_SUCCESSFUL) // HOUS
450 449 {
451 450 status = rtems_task_create(
452 451 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
453 452 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
454 453 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
455 454 );
456 455 }
457 456
458 457 return status;
459 458 }
460 459
461 460 int start_recv_send_tasks( void )
462 461 {
463 462 rtems_status_code status;
464 463
465 464 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
466 465 if (status!=RTEMS_SUCCESSFUL) {
467 466 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
468 467 }
469 468
470 469 if (status == RTEMS_SUCCESSFUL) // SEND
471 470 {
472 471 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
473 472 if (status!=RTEMS_SUCCESSFUL) {
474 473 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
475 474 }
476 475 }
477 476
478 477 return status;
479 478 }
480 479
481 480 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
482 481 {
483 482 /** This function starts all RTEMS tasks used in the software.
484 483 *
485 484 * @return RTEMS directive status codes:
486 485 * - RTEMS_SUCCESSFUL - ask started successfully
487 486 * - RTEMS_INVALID_ADDRESS - invalid task entry point
488 487 * - RTEMS_INVALID_ID - invalid task id
489 488 * - RTEMS_INCORRECT_STATE - task not in the dormant state
490 489 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
491 490 *
492 491 */
493 492 // starts all the tasks fot eh flight software
494 493
495 494 rtems_status_code status;
496 495
497 496 //**********
498 497 // SPACEWIRE
499 498 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
500 499 if (status!=RTEMS_SUCCESSFUL) {
501 500 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
502 501 }
503 502
504 503 if (status == RTEMS_SUCCESSFUL) // WTDG
505 504 {
506 505 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
507 506 if (status!=RTEMS_SUCCESSFUL) {
508 507 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
509 508 }
510 509 }
511 510
512 511 if (status == RTEMS_SUCCESSFUL) // ACTN
513 512 {
514 513 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
515 514 if (status!=RTEMS_SUCCESSFUL) {
516 515 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
517 516 }
518 517 }
519 518
520 519 //******************
521 520 // SPECTRAL MATRICES
522 521 if (status == RTEMS_SUCCESSFUL) // AVF0
523 522 {
524 523 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
525 524 if (status!=RTEMS_SUCCESSFUL) {
526 525 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
527 526 }
528 527 }
529 528 if (status == RTEMS_SUCCESSFUL) // PRC0
530 529 {
531 530 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
532 531 if (status!=RTEMS_SUCCESSFUL) {
533 532 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
534 533 }
535 534 }
536 535 if (status == RTEMS_SUCCESSFUL) // AVF1
537 536 {
538 537 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
539 538 if (status!=RTEMS_SUCCESSFUL) {
540 539 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
541 540 }
542 541 }
543 542 if (status == RTEMS_SUCCESSFUL) // PRC1
544 543 {
545 544 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
546 545 if (status!=RTEMS_SUCCESSFUL) {
547 546 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
548 547 }
549 548 }
550 549 if (status == RTEMS_SUCCESSFUL) // AVF2
551 550 {
552 551 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
553 552 if (status!=RTEMS_SUCCESSFUL) {
554 553 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
555 554 }
556 555 }
557 556 if (status == RTEMS_SUCCESSFUL) // PRC2
558 557 {
559 558 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
560 559 if (status!=RTEMS_SUCCESSFUL) {
561 560 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
562 561 }
563 562 }
564 563
565 564 //****************
566 565 // WAVEFORM PICKER
567 566 if (status == RTEMS_SUCCESSFUL) // WFRM
568 567 {
569 568 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
570 569 if (status!=RTEMS_SUCCESSFUL) {
571 570 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
572 571 }
573 572 }
574 573 if (status == RTEMS_SUCCESSFUL) // CWF3
575 574 {
576 575 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
577 576 if (status!=RTEMS_SUCCESSFUL) {
578 577 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
579 578 }
580 579 }
581 580 if (status == RTEMS_SUCCESSFUL) // CWF2
582 581 {
583 582 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
584 583 if (status!=RTEMS_SUCCESSFUL) {
585 584 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
586 585 }
587 586 }
588 587 if (status == RTEMS_SUCCESSFUL) // CWF1
589 588 {
590 589 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
591 590 if (status!=RTEMS_SUCCESSFUL) {
592 591 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
593 592 }
594 593 }
595 594 if (status == RTEMS_SUCCESSFUL) // SWBD
596 595 {
597 596 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
598 597 if (status!=RTEMS_SUCCESSFUL) {
599 598 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
600 599 }
601 600 }
602 601
603 602 //*****
604 603 // MISC
605 604 if (status == RTEMS_SUCCESSFUL) // HOUS
606 605 {
607 606 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
608 607 if (status!=RTEMS_SUCCESSFUL) {
609 608 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
610 609 }
611 610 }
612 611 if (status == RTEMS_SUCCESSFUL) // DUMB
613 612 {
614 613 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
615 614 if (status!=RTEMS_SUCCESSFUL) {
616 615 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
617 616 }
618 617 }
619 618 if (status == RTEMS_SUCCESSFUL) // STAT
620 619 {
621 620 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
622 621 if (status!=RTEMS_SUCCESSFUL) {
623 622 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
624 623 }
625 624 }
626 625
627 626 return status;
628 627 }
629 628
630 629 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
631 630 {
632 631 rtems_status_code status_recv;
633 632 rtems_status_code status_send;
634 633 rtems_status_code status_q_p0;
635 634 rtems_status_code status_q_p1;
636 635 rtems_status_code status_q_p2;
637 636 rtems_status_code ret;
638 637 rtems_id queue_id;
639 638
640 639 //****************************************
641 640 // create the queue for handling valid TCs
642 641 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
643 642 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
644 643 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
645 644 if ( status_recv != RTEMS_SUCCESSFUL ) {
646 645 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
647 646 }
648 647
649 648 //************************************************
650 649 // create the queue for handling TM packet sending
651 650 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
652 651 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
653 652 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
654 653 if ( status_send != RTEMS_SUCCESSFUL ) {
655 654 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
656 655 }
657 656
658 657 //*****************************************************************************
659 658 // create the queue for handling averaged spectral matrices for processing @ f0
660 659 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
661 660 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
662 661 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
663 662 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
664 663 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
665 664 }
666 665
667 666 //*****************************************************************************
668 667 // create the queue for handling averaged spectral matrices for processing @ f1
669 668 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
670 669 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
671 670 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
672 671 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
673 672 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
674 673 }
675 674
676 675 //*****************************************************************************
677 676 // create the queue for handling averaged spectral matrices for processing @ f2
678 677 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
679 678 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
680 679 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
681 680 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
682 681 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
683 682 }
684 683
685 684 if ( status_recv != RTEMS_SUCCESSFUL )
686 685 {
687 686 ret = status_recv;
688 687 }
689 688 else if( status_send != RTEMS_SUCCESSFUL )
690 689 {
691 690 ret = status_send;
692 691 }
693 692 else if( status_q_p0 != RTEMS_SUCCESSFUL )
694 693 {
695 694 ret = status_q_p0;
696 695 }
697 696 else if( status_q_p1 != RTEMS_SUCCESSFUL )
698 697 {
699 698 ret = status_q_p1;
700 699 }
701 700 else
702 701 {
703 702 ret = status_q_p2;
704 703 }
705 704
706 705 return ret;
707 706 }
708 707
709 708 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
710 709 {
711 710 rtems_status_code status;
712 711 rtems_name queue_name;
713 712
714 713 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
715 714
716 715 status = rtems_message_queue_ident( queue_name, 0, queue_id );
717 716
718 717 return status;
719 718 }
720 719
721 720 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
722 721 {
723 722 rtems_status_code status;
724 723 rtems_name queue_name;
725 724
726 725 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
727 726
728 727 status = rtems_message_queue_ident( queue_name, 0, queue_id );
729 728
730 729 return status;
731 730 }
732 731
733 732 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
734 733 {
735 734 rtems_status_code status;
736 735 rtems_name queue_name;
737 736
738 737 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
739 738
740 739 status = rtems_message_queue_ident( queue_name, 0, queue_id );
741 740
742 741 return status;
743 742 }
744 743
745 744 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
746 745 {
747 746 rtems_status_code status;
748 747 rtems_name queue_name;
749 748
750 749 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
751 750
752 751 status = rtems_message_queue_ident( queue_name, 0, queue_id );
753 752
754 753 return status;
755 754 }
756 755
757 756 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
758 757 {
759 758 rtems_status_code status;
760 759 rtems_name queue_name;
761 760
762 761 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
763 762
764 763 status = rtems_message_queue_ident( queue_name, 0, queue_id );
765 764
766 765 return status;
767 766 }
@@ -1,503 +1,501
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 increment_seq_counter( housekeeping_packet.packetSequenceControl );
215 215 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
216 216 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
217 217 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
218 218 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
219 219 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
220 220 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
221 221
222 222 spacewire_update_statistics();
223 223
224 224 get_v_e1_e2_f3(
225 225 housekeeping_packet.hk_lfr_sc_v_f3, housekeeping_packet.hk_lfr_sc_e1_f3, housekeeping_packet.hk_lfr_sc_e2_f3 );
226 226
227 227 // SEND PACKET
228 228 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
229 229 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
230 230 if (status != RTEMS_SUCCESSFUL) {
231 231 PRINTF1("in HOUS *** ERR send: %d\n", status)
232 232 }
233 233 }
234 234 }
235 235
236 236 PRINTF("in HOUS *** deleting task\n")
237 237
238 238 status = rtems_task_delete( RTEMS_SELF ); // should not return
239 239 printf( "rtems_task_delete returned with status of %d.\n", status );
240 240 return;
241 241 }
242 242
243 243 rtems_task dumb_task( rtems_task_argument unused )
244 244 {
245 245 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
246 246 *
247 247 * @param unused is the starting argument of the RTEMS task
248 248 *
249 249 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
250 250 *
251 251 */
252 252
253 253 unsigned int i;
254 254 unsigned int intEventOut;
255 255 unsigned int coarse_time = 0;
256 256 unsigned int fine_time = 0;
257 257 rtems_event_set event_out;
258 258
259 259 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
260 260 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
261 261 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
262 262 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
263 263 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
264 264 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
265 265 "ERR HK", // RTEMS_EVENT_6
266 266 "ready for dump", // RTEMS_EVENT_7
267 267 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
268 268 "tick" // RTEMS_EVENT_9
269 269 };
270 270
271 271 BOOT_PRINTF("in DUMB *** \n")
272 272
273 273 while(1){
274 274 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
275 275 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
276 276 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
277 277 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
278 278 intEventOut = (unsigned int) event_out;
279 279 for ( i=0; i<32; i++)
280 280 {
281 281 if ( ((intEventOut >> i) & 0x0001) != 0)
282 282 {
283 283 coarse_time = time_management_regs->coarse_time;
284 284 fine_time = time_management_regs->fine_time;
285 285 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
286 286 }
287 287 }
288 288 }
289 289 }
290 290
291 291 //*****************************
292 292 // init housekeeping parameters
293 293
294 294 void init_housekeeping_parameters( void )
295 295 {
296 296 /** This function initialize the housekeeping_packet global variable with default values.
297 297 *
298 298 */
299 299
300 300 unsigned int i = 0;
301 301 unsigned char *parameters;
302 302
303 303 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
304 304 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
305 305 {
306 306 parameters[i] = 0x00;
307 307 }
308 308 // init status word
309 309 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
310 310 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
311 311 // init software version
312 312 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
313 313 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
314 314 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
315 315 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
316 316 // init fpga version
317 317 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
318 318 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
319 319 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
320 320 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
321 321 }
322 322
323 323 void increment_seq_counter( unsigned char *packet_sequence_control)
324 324 {
325 325 /** This function increment the sequence counter psased in argument.
326 326 *
327 327 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
328 328 *
329 329 */
330 330
331 331 unsigned short sequence_cnt;
332 332 unsigned short segmentation_grouping_flag;
333 333 unsigned short new_packet_sequence_control;
334 334
335 335 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
336 336 sequence_cnt = (unsigned short) (
337 337 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
338 338 + packet_sequence_control[1]
339 339 );
340 340
341 341 if ( sequence_cnt < SEQ_CNT_MAX)
342 342 {
343 343 sequence_cnt = sequence_cnt + 1;
344 344 }
345 345 else
346 346 {
347 347 sequence_cnt = 0;
348 348 }
349 349
350 350 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
351 351
352 352 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
353 353 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
354 354 }
355 355
356 356 void getTime( unsigned char *time)
357 357 {
358 358 /** This function write the current local time in the time buffer passed in argument.
359 359 *
360 360 */
361 361
362 362 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
363 363 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
364 364 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
365 365 time[3] = (unsigned char) (time_management_regs->coarse_time);
366 366 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
367 367 time[5] = (unsigned char) (time_management_regs->fine_time);
368 368 }
369 369
370 370 unsigned long long int getTimeAsUnsignedLongLongInt( )
371 371 {
372 372 /** This function write the current local time in the time buffer passed in argument.
373 373 *
374 374 */
375 375 unsigned long long int time;
376 376
377 377 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
378 378 + time_management_regs->fine_time;
379 379
380 380 return time;
381 381 }
382 382
383 383 void send_dumb_hk( void )
384 384 {
385 385 Packet_TM_LFR_HK_t dummy_hk_packet;
386 386 unsigned char *parameters;
387 387 unsigned int i;
388 388 rtems_id queue_id;
389 389
390 390 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
391 391 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
392 392 dummy_hk_packet.reserved = DEFAULT_RESERVED;
393 393 dummy_hk_packet.userApplication = CCSDS_USER_APP;
394 394 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
395 395 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
396 396 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
397 397 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
398 398 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
399 399 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
400 400 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
401 401 dummy_hk_packet.serviceType = TM_TYPE_HK;
402 402 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
403 403 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
404 404 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
405 405 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
406 406 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
407 407 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
408 408 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
409 409 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
410 410 dummy_hk_packet.sid = SID_HK;
411 411
412 412 // init status word
413 413 dummy_hk_packet.lfr_status_word[0] = 0xff;
414 414 dummy_hk_packet.lfr_status_word[1] = 0xff;
415 415 // init software version
416 416 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
417 417 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
418 418 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
419 419 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
420 420 // init fpga version
421 421 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
422 422 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
423 423 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
424 424 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
425 425
426 426 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
427 427
428 428 for (i=0; i<100; i++)
429 429 {
430 430 parameters[i] = 0xff;
431 431 }
432 432
433 433 get_message_queue_id_send( &queue_id );
434 434
435 435 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
436 436 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
437 437 }
438 438
439 439 void get_v_e1_e2_f3( unsigned char *v, unsigned char *e1, unsigned char *e2 )
440 440 {
441 441 unsigned int coarseTime;
442 442 unsigned int acquisitionTime;
443 443 unsigned int deltaT = 0;
444 444 unsigned char *bufferPtr;
445 445
446 446 unsigned int offset_in_samples;
447 447 unsigned int offset_in_bytes;
448 448 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
449 449
450 450 if (lfrCurrentMode == LFR_MODE_STANDBY)
451 451 {
452 452 v[0] = 0x00;
453 453 v[1] = 0x00;
454 454 e1[0] = 0x00;
455 455 e1[1] = 0x00;
456 456 e2[0] = 0x00;
457 457 e2[1] = 0x00;
458 458 }
459 459 else
460 460 {
461 461 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
462 462 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
463 463 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
464 464 + (unsigned int) ( bufferPtr[3] << 16 )
465 465 + (unsigned int) ( bufferPtr[0] << 8 )
466 466 + (unsigned int) ( bufferPtr[1] );
467 467 if ( coarseTime > acquisitionTime )
468 468 {
469 469 deltaT = coarseTime - acquisitionTime;
470 470 offset_in_samples = (deltaT-1) * f3 ;
471 471 }
472 472 else if( coarseTime == acquisitionTime )
473 473 {
474 474 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
475 475 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
476 476 }
477 477 else
478 478 {
479 479 offset_in_samples = 0;
480 480 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
481 481 }
482 482
483 483 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
484 484 {
485 485 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
486 486 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
487 487 }
488 PRINTF1("f3 data @ %x *** ", waveform_picker_regs->addr_data_f3 )
489 PRINTF2("deltaT = %d, offset_in_samples = %d\n", deltaT, offset_in_samples )
490 488 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
491 489 v[0] = bufferPtr[ offset_in_bytes + 0];
492 490 v[1] = bufferPtr[ offset_in_bytes + 1];
493 491 e1[0] = bufferPtr[ offset_in_bytes + 2];
494 492 e1[1] = bufferPtr[ offset_in_bytes + 3];
495 493 e2[0] = bufferPtr[ offset_in_bytes + 4];
496 494 e2[1] = bufferPtr[ offset_in_bytes + 5];
497 495 }
498 496 }
499 497
500 498
501 499
502 500
503 501
@@ -1,366 +1,370
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 70 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
71 71 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
72 72 {
73 73 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
74 74 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
75 75 }
76 76
77 77 // compute the average and store it in the averaged_sm_f1 buffer
78 78 SM_average( current_ring_node_asm_norm_f0->matrix,
79 79 current_ring_node_asm_burst_sbm_f0->matrix,
80 80 ring_node_tab,
81 81 nb_norm_bp1, nb_sbm_bp1 );
82 82
83 83 // update nb_average
84 84 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
85 85 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
86 86 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
87 87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
88 88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
89 89
90 90 //****************************************
91 91 // initialize the mesage for the MATR task
92 92 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
93 93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
94 94 msgForMATR.norm = current_ring_node_asm_norm_f0;
95 95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
96 96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
97 97 msgForMATR.coarseTime = time_management_regs->coarse_time;
98 98 msgForMATR.fineTime = time_management_regs->fine_time;
99 99
100 100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 101 {
102 102 nb_sbm_bp1 = 0;
103 103 // set another ring for the ASM storage
104 104 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
105 105 if ( (lfrCurrentMode == LFR_MODE_BURST)
106 106 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
107 107 {
108 108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
109 109 }
110 110 }
111 111
112 112 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
113 113 {
114 114 nb_sbm_bp2 = 0;
115 115 if ( (lfrCurrentMode == LFR_MODE_BURST)
116 116 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
117 117 {
118 118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
119 119 }
120 120 }
121 121
122 122 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
123 123 {
124 124 nb_norm_bp1 = 0;
125 125 // set another ring for the ASM storage
126 126 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
127 127 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
128 128 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
129 129 {
130 130 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
131 131 }
132 132 }
133 133
134 134 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
135 135 {
136 136 nb_norm_bp2 = 0;
137 137 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
138 138 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
139 139 {
140 140 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
141 141 }
142 142 }
143 143
144 144 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
145 145 {
146 146 nb_norm_asm = 0;
147 147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 149 {
150 150 // PRINTF1("%lld\n", localTime)
151 151 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
152 152 }
153 153 }
154 154
155 155 //*************************
156 156 // send the message to MATR
157 157 if (msgForMATR.event != 0x00)
158 158 {
159 159 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
160 160 }
161 161
162 162 if (status != RTEMS_SUCCESSFUL) {
163 163 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
164 164 }
165 165 }
166 166 }
167 167
168 168 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
169 169 {
170 170 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
171 171 size_t size; // size of the incoming TC packet
172 172 asm_msg *incomingMsg;
173 173 //
174 174 spw_ioctl_pkt_send spw_ioctl_send_ASM;
175 175 rtems_status_code status;
176 176 rtems_id queue_id;
177 177 rtems_id queue_id_q_p0;
178 178 Header_TM_LFR_SCIENCE_ASM_t headerASM;
179 179 bp_packet_with_spare packet_norm_bp1_f0;
180 180 bp_packet packet_norm_bp2_f0;
181 181 bp_packet packet_sbm_bp1_f0;
182 182 bp_packet packet_sbm_bp2_f0;
183 183
184 184 unsigned long long int localTime;
185 185
186 186 ASM_init_header( &headerASM );
187 187
188 188 //*************
189 189 // NORM headers
190 190 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
191 191 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
192 192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
193 193 BP_init_header( &packet_norm_bp2_f0.header,
194 194 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
195 195 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
196 196
197 197 //****************************
198 198 // BURST SBM1 and SBM2 headers
199 199 if ( lfrRequestedMode == LFR_MODE_BURST )
200 200 {
201 201 BP_init_header( &packet_sbm_bp1_f0.header,
202 202 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
203 203 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
204 204 BP_init_header( &packet_sbm_bp2_f0.header,
205 205 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
206 206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
207 207 }
208 208 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
209 209 {
210 210 BP_init_header( &packet_sbm_bp1_f0.header,
211 211 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
212 212 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
213 213 BP_init_header( &packet_sbm_bp2_f0.header,
214 214 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
215 215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
216 216 }
217 217 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
218 218 {
219 219 BP_init_header( &packet_sbm_bp1_f0.header,
220 220 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
221 221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
222 222 BP_init_header( &packet_sbm_bp2_f0.header,
223 223 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
224 224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
225 225 }
226 226 else
227 227 {
228 228 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
229 229 }
230 230
231 231 status = get_message_queue_id_send( &queue_id );
232 232 if (status != RTEMS_SUCCESSFUL)
233 233 {
234 234 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
235 235 }
236 236 status = get_message_queue_id_prc0( &queue_id_q_p0);
237 237 if (status != RTEMS_SUCCESSFUL)
238 238 {
239 239 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
240 240 }
241 241
242 242 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
243 243
244 244 while(1){
245 245 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
246 246 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
247 247
248 248 incomingMsg = (asm_msg*) incomingData;
249 249
250 250 localTime = getTimeAsUnsignedLongLongInt( );
251 251 //****************
252 252 //****************
253 253 // BURST SBM1 SBM2
254 254 //****************
255 255 //****************
256 256 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
257 257 {
258 258 // 1) compress the matrix for Basic Parameters calculation
259 259 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
260 260 nb_sm_before_f0.burst_sbm_bp1,
261 261 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
262 262 ASM_F0_INDICE_START);
263 263 // 2) compute the BP1 set
264 264 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
265 265 // 3) send the BP1 set
266 266 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
267 267 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
268 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
269 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
268 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
269 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
270 SID_SBM1_BP1_F0);
270 271 // 4) compute the BP2 set if needed
271 272 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
272 273 {
273 274 // 1) compute the BP2 set
274 275
275 276 // 2) send the BP2 set
276 277 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
277 278 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
278 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
279 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
280 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
281 SID_SBM1_BP2_F0);
280 282 }
281 283 }
282 284
283 285 //*****
284 286 //*****
285 287 // NORM
286 288 //*****
287 289 //*****
288 290 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
289 291 {
290 292 // 1) compress the matrix for Basic Parameters calculation
291 293 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
292 294 nb_sm_before_f0.norm_bp1,
293 295 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
294 296 ASM_F0_INDICE_START );
295 297 // 2) compute the BP1 set
296 298 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
297 299 // 3) send the BP1 set
298 300 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
299 301 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
300 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
301 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
302 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
303 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
304 SID_NORM_BP1_F0 );
302 305 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
303 306 {
304 307 // 1) compute the BP2 set using the same ASM as the one used for BP1
305 308
306 309 // 2) send the BP2 set
307 310 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
308 311 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
309 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
310 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
312 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
313 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
314 SID_NORM_BP2_F0);
311 315 }
312 316 }
313 317
314 318 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
315 319 {
316 320 // 1) reorganize the ASM and divide
317 321 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
318 322 asm_f0_reorganized,
319 323 nb_sm_before_f0.norm_bp1 );
320 324 // 2) convert the float array in a char array
321 325 ASM_convert( asm_f0_reorganized, asm_f0_char);
322 326 // 3) send the spectral matrix packets
323 327 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
324 328 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
325 329 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
326 330 }
327 331
328 332 }
329 333 }
330 334
331 335 //**********
332 336 // FUNCTIONS
333 337
334 338 void reset_nb_sm_f0( unsigned char lfrMode )
335 339 {
336 340 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
337 341 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
338 342 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;
339 343 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
340 344 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
341 345 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
342 346 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
343 347 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
344 348 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
345 349
346 350 if (lfrMode == LFR_MODE_SBM1)
347 351 {
348 352 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
349 353 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
350 354 }
351 355 else if (lfrMode == LFR_MODE_SBM2)
352 356 {
353 357 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
354 358 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
355 359 }
356 360 else if (lfrMode == LFR_MODE_BURST)
357 361 {
358 362 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
359 363 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
360 364 }
361 365 else
362 366 {
363 367 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
364 368 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
365 369 }
366 370 }
@@ -1,345 +1,349
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 67 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
68 68 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
69 69 {
70 70 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
71 71 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
72 72 }
73 73
74 74 // compute the average and store it in the averaged_sm_f1 buffer
75 75 SM_average( current_ring_node_asm_norm_f1->matrix,
76 76 current_ring_node_asm_burst_sbm_f1->matrix,
77 77 ring_node_tab,
78 78 nb_norm_bp1, nb_sbm_bp1 );
79 79
80 80 // update nb_average
81 81 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
82 82 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
83 83 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
84 84 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
85 85 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
86 86
87 87 //****************************************
88 88 // initialize the mesage for the MATR task
89 89 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
90 90 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
91 91 msgForMATR.norm = current_ring_node_asm_norm_f1;
92 92 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
93 93 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
94 94 msgForMATR.coarseTime = time_management_regs->coarse_time;
95 95 msgForMATR.fineTime = time_management_regs->fine_time;
96 96
97 97 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 98 {
99 99 nb_sbm_bp1 = 0;
100 100 // set another ring for the ASM storage
101 101 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
102 102 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
103 103 {
104 104 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
105 105 }
106 106 }
107 107
108 108 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
109 109 {
110 110 nb_sbm_bp2 = 0;
111 111 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
112 112 {
113 113 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
114 114 }
115 115 }
116 116
117 117 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
118 118 {
119 119 nb_norm_bp1 = 0;
120 120 // set another ring for the ASM storage
121 121 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
122 122 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
123 123 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
124 124 {
125 125 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
126 126 }
127 127 }
128 128
129 129 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
130 130 {
131 131 nb_norm_bp2 = 0;
132 132 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
133 133 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
134 134 {
135 135 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
136 136 }
137 137 }
138 138
139 139 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
140 140 {
141 141 nb_norm_asm = 0;
142 142 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
143 143 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
144 144 {
145 145 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
146 146 }
147 147 }
148 148
149 149 //*************************
150 150 // send the message to MATR
151 151 if (msgForMATR.event != 0x00)
152 152 {
153 153 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
154 154 }
155 155
156 156 if (status != RTEMS_SUCCESSFUL) {
157 157 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
158 158 }
159 159 }
160 160 }
161 161
162 162 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
163 163 {
164 164 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
165 165 size_t size; // size of the incoming TC packet
166 166 asm_msg *incomingMsg;
167 167 //
168 168 spw_ioctl_pkt_send spw_ioctl_send_ASM;
169 169 rtems_status_code status;
170 170 rtems_id queue_id_send;
171 171 rtems_id queue_id_q_p1;
172 172 Header_TM_LFR_SCIENCE_ASM_t headerASM;
173 173 bp_packet_with_spare packet_norm_bp1;
174 174 bp_packet packet_norm_bp2;
175 175 bp_packet packet_sbm_bp1;
176 176 bp_packet packet_sbm_bp2;
177 177
178 178 unsigned long long int localTime;
179 179
180 180 ASM_init_header( &headerASM );
181 181
182 182 //*************
183 183 // NORM headers
184 184 BP_init_header_with_spare( &packet_norm_bp1.header,
185 185 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
186 186 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
187 187 BP_init_header( &packet_norm_bp2.header,
188 188 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
189 189 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
190 190
191 191 //***********************
192 192 // BURST and SBM2 headers
193 193 if ( lfrRequestedMode == LFR_MODE_BURST )
194 194 {
195 195 BP_init_header( &packet_sbm_bp1.header,
196 196 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
197 197 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
198 198 BP_init_header( &packet_sbm_bp2.header,
199 199 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
200 200 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
201 201 }
202 202 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
203 203 {
204 204 BP_init_header( &packet_sbm_bp1.header,
205 205 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
206 206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
207 207 BP_init_header( &packet_sbm_bp2.header,
208 208 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
209 209 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
210 210 }
211 211 else
212 212 {
213 213 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
214 214 }
215 215
216 216 status = get_message_queue_id_send( &queue_id_send );
217 217 if (status != RTEMS_SUCCESSFUL)
218 218 {
219 219 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
220 220 }
221 221 status = get_message_queue_id_prc1( &queue_id_q_p1);
222 222 if (status != RTEMS_SUCCESSFUL)
223 223 {
224 224 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
225 225 }
226 226
227 227 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
228 228
229 229 while(1){
230 230 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
231 231 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
232 232
233 233 incomingMsg = (asm_msg*) incomingData;
234 234
235 235 localTime = getTimeAsUnsignedLongLongInt( );
236 236 //***********
237 237 //***********
238 238 // BURST SBM2
239 239 //***********
240 240 //***********
241 241 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
242 242 {
243 243 // 1) compress the matrix for Basic Parameters calculation
244 244 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
245 245 nb_sm_before_f1.burst_sbm_bp1,
246 246 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
247 247 ASM_F1_INDICE_START);
248 248 // 2) compute the BP1 set
249 249
250 250 // 3) send the BP1 set
251 251 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
252 252 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
253 BP_send( (char *) &packet_sbm_bp1.header, queue_id_send,
254 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA);
253 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
254 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
255 SID_SBM2_BP1_F1 );
255 256 // 4) compute the BP2 set if needed
256 257 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
257 258 {
258 259 // 1) compute the BP2 set
259 260
260 261 // 2) send the BP2 set
261 262 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
262 263 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
263 BP_send( (char *) &packet_sbm_bp2.header, queue_id_send,
264 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA);
264 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
265 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
266 SID_SBM2_BP2_F1 );
265 267 }
266 268 }
267 269
268 270 //*****
269 271 //*****
270 272 // NORM
271 273 //*****
272 274 //*****
273 275 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
274 276 {
275 277 // 1) compress the matrix for Basic Parameters calculation
276 278 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
277 279 nb_sm_before_f1.norm_bp1,
278 280 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
279 281 ASM_F0_INDICE_START );
280 282 // 2) compute the BP1 set
281 283
282 284 // 3) send the BP1 set
283 285 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
284 286 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
285 BP_send( (char *) &packet_norm_bp1.header, queue_id_send,
286 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA);
287 BP_send( (char *) &packet_norm_bp1, queue_id_send,
288 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
289 SID_NORM_BP1_F1 );
287 290 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
288 291 {
289 292 // 1) compute the BP2 set
290 293
291 294 // 2) send the BP2 set
292 295 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
293 296 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
294 BP_send( (char *) &packet_norm_bp2.header, queue_id_send,
295 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA);
297 BP_send( (char *) &packet_norm_bp2, queue_id_send,
298 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
299 SID_NORM_BP2_F1 );
296 300 }
297 301 }
298 302
299 303 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
300 304 {
301 305 // 1) reorganize the ASM and divide
302 306 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
303 307 asm_f1_reorganized,
304 308 nb_sm_before_f1.norm_bp1 );
305 309 // 2) convert the float array in a char array
306 310 ASM_convert( asm_f1_reorganized, asm_f1_char);
307 311 // 3) send the spectral matrix packets
308 312 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
309 313 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
310 314 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
311 315 }
312 316
313 317 }
314 318 }
315 319
316 320 //**********
317 321 // FUNCTIONS
318 322
319 323 void reset_nb_sm_f1( unsigned char lfrMode )
320 324 {
321 325 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
322 326 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
323 327 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;
324 328 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
325 329 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
326 330 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
327 331 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
328 332
329 333 if (lfrMode == LFR_MODE_SBM2)
330 334 {
331 335 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
332 336 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
333 337 }
334 338 else if (lfrMode == LFR_MODE_BURST)
335 339 {
336 340 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
337 341 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
338 342 }
339 343 else
340 344 {
341 345 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
342 346 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
343 347 }
344 348 }
345 349
@@ -1,251 +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 60 // compute the average and store it in the averaged_sm_f2 buffer
61 61 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
62 62 ring_node_for_averaging_sm_f2,
63 63 nb_norm_bp1 );
64 64
65 65 // update nb_average
66 66 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
67 67 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
68 68 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
69 69
70 70 //****************************************
71 71 // initialize the mesage for the MATR task
72 72 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
73 73 msgForMATR.burst_sbm = NULL;
74 74 msgForMATR.norm = current_ring_node_asm_norm_f2;
75 75 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
76 76 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
77 77 msgForMATR.coarseTime = time_management_regs->coarse_time;
78 78 msgForMATR.fineTime = time_management_regs->fine_time;
79 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->fineTime );
191 BP_send( (char *) &packet_norm_bp1_f2.header, queue_id,
192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA);
191 BP_send( (char *) &packet_norm_bp1_f2, queue_id,
192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
193 SID_NORM_BP1_F2 );
193 194 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
194 195 {
195 196 // 1) compute the BP2 set using the same ASM as the one used for BP1
196 197
197 198 // 2) send the BP2 set
198 199 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
199 200 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
200 BP_send( (char *) &packet_norm_bp2_f2.header, queue_id,
201 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA);
201 BP_send( (char *) &packet_norm_bp2_f2, queue_id,
202 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
203 SID_NORM_BP2_F2 );
202 204 }
203 205 }
204 206
205 207 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
206 208 {
207 209 // 1) reorganize the ASM and divide
208 210 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
209 211 asm_f2_reorganized,
210 212 nb_sm_before_f2.norm_bp1 );
211 213 // 2) convert the float array in a char array
212 214 ASM_convert( asm_f2_reorganized, asm_f2_char);
213 215 // 3) send the spectral matrix packets
214 216 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
215 217 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
216 218 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
217 219 }
218 220
219 221 }
220 222 }
221 223
222 224 //**********
223 225 // FUNCTIONS
224 226
225 227 void reset_nb_sm_f2( void )
226 228 {
227 229 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
228 230 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
229 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];
230 232 }
231 233
232 234 void SM_average_f2( float *averaged_spec_mat_f2,
233 235 ring_node_sm *ring_node,
234 236 unsigned int nbAverageNormF2 )
235 237 {
236 238 float sum;
237 239 unsigned int i;
238 240
239 241 for(i=0; i<TOTAL_SIZE_SM; i++)
240 242 {
241 243 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
242 244 if ( (nbAverageNormF2 == 0) )
243 245 {
244 246 averaged_spec_mat_f2[ i ] = sum;
245 247 }
246 248 else
247 249 {
248 250 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
249 251 }
250 252 }
251 253 }
@@ -1,455 +1,458
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 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
34 34 {
35 35 // ring_node_sm *previous_ring_node_sm_f0;
36 36
37 37 //// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
38 38
39 39 // previous_ring_node_sm_f0 = current_ring_node_sm_f0;
40 40
41 41 // if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1
42 42 // {
43 43 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
44 44 // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
45 45 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
46 46 // nb_sm_f0 = nb_sm_f0 + 1;
47 47 // }
48 48
49 49 // //************************
50 50 // // reset status error bits
51 51 // if ( (spectral_matrix_regs->status & 0x30) != 0x00)
52 52 // {
53 53 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
54 54 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
55 55 // }
56 56
57 57 // //**************************************
58 58 // // reset ready matrix bits for f0_0, f1 and f2
59 59 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010
60 60
61 61 // if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
62 62 // {
63 63 // ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0;
64 64 // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
65 65 // {
66 66 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
67 67 // }
68 68 // nb_sm_f0 = 0;
69 69 // }
70 70
71 71 }
72 72
73 73 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
74 74 {
75 75 //***
76 76 // F0
77 77 nb_sm_f0 = nb_sm_f0 + 1;
78 78 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
79 79 {
80 80 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
81 81 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
82 82 {
83 83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
84 84 }
85 85 nb_sm_f0 = 0;
86 86 }
87 87
88 88 //***
89 89 // F1
90 90 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
91 91 if (nb_sm_f0_aux_f1 == 6)
92 92 {
93 93 nb_sm_f0_aux_f1 = 0;
94 94 nb_sm_f1 = nb_sm_f1 + 1;
95 95 }
96 96 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
97 97 {
98 98 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
99 99 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
100 100 {
101 101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
102 102 }
103 103 nb_sm_f1 = 0;
104 104 }
105 105
106 106 //***
107 107 // F2
108 108 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
109 109 if (nb_sm_f0_aux_f2 == 96)
110 110 {
111 111 nb_sm_f0_aux_f2 = 0;
112 112 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
113 113 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
114 114 {
115 115 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
116 116 }
117 117 }
118 118 }
119 119
120 120 //******************
121 121 // Spectral Matrices
122 122
123 123 void reset_nb_sm( void )
124 124 {
125 125 nb_sm_f0 = 0;
126 126 nb_sm_f0_aux_f1 = 0;
127 127 nb_sm_f0_aux_f2 = 0;
128 128
129 129 nb_sm_f1 = 0;
130 130 }
131 131
132 132 void SM_init_rings( void )
133 133 {
134 134 unsigned char i;
135 135
136 136 // F0 RING
137 137 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
138 138 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
139 139 sm_ring_f0[0].buffer_address =
140 140 (int) &sm_f0[ 0 ];
141 141
142 142 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
143 143 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
144 144 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
145 145 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
146 146
147 147 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
148 148 {
149 149 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
150 150 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
151 151 sm_ring_f0[i].buffer_address =
152 152 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
153 153 }
154 154
155 155 // F1 RING
156 156 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
157 157 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
158 158 sm_ring_f1[0].buffer_address =
159 159 (int) &sm_f1[ 0 ];
160 160
161 161 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
162 162 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
163 163 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
164 164 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
165 165
166 166 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
167 167 {
168 168 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
169 169 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
170 170 sm_ring_f1[i].buffer_address =
171 171 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
172 172 }
173 173
174 174 // F2 RING
175 175 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
176 176 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
177 177 sm_ring_f2[0].buffer_address =
178 178 (int) &sm_f2[ 0 ];
179 179
180 180 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
181 181 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
182 182 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
183 183 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
184 184
185 185 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
186 186 {
187 187 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
188 188 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
189 189 sm_ring_f2[i].buffer_address =
190 190 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
191 191 }
192 192
193 193 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
194 194 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
195 195 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
196 196
197 197 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
198 198 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
199 199 }
200 200
201 201 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
202 202 {
203 203 unsigned char i;
204 204
205 205 ring[ nbNodes - 1 ].next
206 206 = (ring_node_asm*) &ring[ 0 ];
207 207
208 208 for(i=0; i<nbNodes-1; i++)
209 209 {
210 210 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
211 211 }
212 212 }
213 213
214 214 void SM_reset_current_ring_nodes( void )
215 215 {
216 216 current_ring_node_sm_f0 = sm_ring_f0;
217 217 current_ring_node_sm_f1 = sm_ring_f1;
218 218 current_ring_node_sm_f2 = sm_ring_f2;
219 219
220 220 ring_node_for_averaging_sm_f0 = sm_ring_f0;
221 221 ring_node_for_averaging_sm_f1 = sm_ring_f1;
222 222 ring_node_for_averaging_sm_f2 = sm_ring_f2;
223 223 }
224 224
225 225 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
226 226 {
227 227 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
228 228 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
229 229 header->reserved = 0x00;
230 230 header->userApplication = CCSDS_USER_APP;
231 231 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
232 232 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
233 233 header->packetSequenceControl[0] = 0xc0;
234 234 header->packetSequenceControl[1] = 0x00;
235 235 header->packetLength[0] = 0x00;
236 236 header->packetLength[1] = 0x00;
237 237 // DATA FIELD HEADER
238 238 header->spare1_pusVersion_spare2 = 0x10;
239 239 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
240 240 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
241 241 header->destinationID = TM_DESTINATION_ID_GROUND;
242 242 // AUXILIARY DATA HEADER
243 243 header->sid = 0x00;
244 244 header->biaStatusInfo = 0x00;
245 245 header->pa_lfr_pkt_cnt_asm = 0x00;
246 246 header->pa_lfr_pkt_nr_asm = 0x00;
247 247 header->time[0] = 0x00;
248 248 header->time[0] = 0x00;
249 249 header->time[0] = 0x00;
250 250 header->time[0] = 0x00;
251 251 header->time[0] = 0x00;
252 252 header->time[0] = 0x00;
253 253 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
254 254 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
255 255 }
256 256
257 257 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
258 258 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
259 259 {
260 260 unsigned int i;
261 261 unsigned int length = 0;
262 262 rtems_status_code status;
263 263
264 264 for (i=0; i<2; i++)
265 265 {
266 266 // (1) BUILD THE DATA
267 267 switch(sid)
268 268 {
269 269 case SID_NORM_ASM_F0:
270 270 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
271 271 spw_ioctl_send->data = &spectral_matrix[
272 272 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
273 273 ];
274 274 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
275 275 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
276 276 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
277 277 break;
278 278 case SID_NORM_ASM_F1:
279 279 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
280 280 spw_ioctl_send->data = &spectral_matrix[
281 281 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
282 282 ];
283 283 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
284 284 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
285 285 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
286 286 break;
287 287 case SID_NORM_ASM_F2:
288 288 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
289 289 spw_ioctl_send->data = &spectral_matrix[
290 290 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
291 291 ];
292 292 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
293 293 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
294 294 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
295 295 break;
296 296 default:
297 297 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
298 298 break;
299 299 }
300 300 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
301 301 spw_ioctl_send->hdr = (char *) header;
302 302 spw_ioctl_send->options = 0;
303 303
304 304 // (2) BUILD THE HEADER
305 increment_seq_counter_source_id( header->packetSequenceControl, sid );
305 306 header->packetLength[0] = (unsigned char) (length>>8);
306 307 header->packetLength[1] = (unsigned char) (length);
307 308 header->sid = (unsigned char) sid; // SID
308 309 header->pa_lfr_pkt_cnt_asm = 2;
309 310 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
310 311
311 312 // (3) SET PACKET TIME
312 313 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
313 314 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
314 315 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
315 316 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
316 317 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
317 318 header->time[5] = (unsigned char) (time_management_regs->fine_time);
318 319 //
319 320 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
320 321 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
321 322 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
322 323 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
323 324 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
324 325 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
325 326
326 327 // (4) SEND PACKET
327 328 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
328 329 if (status != RTEMS_SUCCESSFUL) {
329 330 printf("in ASM_send *** ERR %d\n", (int) status);
330 331 }
331 332 }
332 333 }
333 334
334 335 //*****************
335 336 // Basic Parameters
336 337
337 338 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
338 339 unsigned int apid, unsigned char sid,
339 340 unsigned int packetLength, unsigned char blkNr )
340 341 {
341 342 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
342 343 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
343 344 header->reserved = 0x00;
344 345 header->userApplication = CCSDS_USER_APP;
345 346 header->packetID[0] = (unsigned char) (apid >> 8);
346 347 header->packetID[1] = (unsigned char) (apid);
347 348 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
348 349 header->packetSequenceControl[1] = 0x00;
349 350 header->packetLength[0] = (unsigned char) (packetLength >> 8);
350 351 header->packetLength[1] = (unsigned char) (packetLength);
351 352 // DATA FIELD HEADER
352 353 header->spare1_pusVersion_spare2 = 0x10;
353 354 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
354 355 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
355 356 header->destinationID = TM_DESTINATION_ID_GROUND;
356 357 // AUXILIARY DATA HEADER
357 358 header->sid = sid;
358 359 header->biaStatusInfo = 0x00;
359 360 header->time[0] = 0x00;
360 361 header->time[0] = 0x00;
361 362 header->time[0] = 0x00;
362 363 header->time[0] = 0x00;
363 364 header->time[0] = 0x00;
364 365 header->time[0] = 0x00;
365 366 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
366 367 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
367 368 }
368 369
369 370 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
370 371 unsigned int apid, unsigned char sid,
371 372 unsigned int packetLength , unsigned char blkNr)
372 373 {
373 374 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
374 375 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
375 376 header->reserved = 0x00;
376 377 header->userApplication = CCSDS_USER_APP;
377 378 header->packetID[0] = (unsigned char) (apid >> 8);
378 379 header->packetID[1] = (unsigned char) (apid);
379 380 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
380 381 header->packetSequenceControl[1] = 0x00;
381 382 header->packetLength[0] = (unsigned char) (packetLength >> 8);
382 383 header->packetLength[1] = (unsigned char) (packetLength);
383 384 // DATA FIELD HEADER
384 385 header->spare1_pusVersion_spare2 = 0x10;
385 386 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
386 387 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
387 388 header->destinationID = TM_DESTINATION_ID_GROUND;
388 389 // AUXILIARY DATA HEADER
389 390 header->sid = sid;
390 391 header->biaStatusInfo = 0x00;
391 392 header->time[0] = 0x00;
392 393 header->time[0] = 0x00;
393 394 header->time[0] = 0x00;
394 395 header->time[0] = 0x00;
395 396 header->time[0] = 0x00;
396 397 header->time[0] = 0x00;
397 398 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
398 399 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
399 400 }
400 401
401 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
402 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
402 403 {
403 404 rtems_status_code status;
404 405
406 // SET THE SEQUENCE_CNT PARAMETER
407 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
405 408 // SEND PACKET
406 409 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
407 410 if (status != RTEMS_SUCCESSFUL)
408 411 {
409 412 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
410 413 }
411 414 }
412 415
413 416 //******************
414 417 // general functions
415 418
416 419 void reset_spectral_matrix_regs( void )
417 420 {
418 421 /** This function resets the spectral matrices module registers.
419 422 *
420 423 * The registers affected by this function are located at the following offset addresses:
421 424 *
422 425 * - 0x00 config
423 426 * - 0x04 status
424 427 * - 0x08 matrixF0_Address0
425 428 * - 0x10 matrixFO_Address1
426 429 * - 0x14 matrixF1_Address
427 430 * - 0x18 matrixF2_Address
428 431 *
429 432 */
430 433
431 434 spectral_matrix_regs->config = 0x00;
432 435 spectral_matrix_regs->status = 0x00;
433 436
434 437 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
435 438 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
436 439 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
437 440 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
438 441 }
439 442
440 443 void set_time( unsigned char *time, unsigned char * timeInBuffer )
441 444 {
442 445 // time[0] = timeInBuffer[2];
443 446 // time[1] = timeInBuffer[3];
444 447 // time[2] = timeInBuffer[0];
445 448 // time[3] = timeInBuffer[1];
446 449 // time[4] = timeInBuffer[6];
447 450 // time[5] = timeInBuffer[7];
448 451
449 452 time[0] = timeInBuffer[0];
450 453 time[1] = timeInBuffer[1];
451 454 time[2] = timeInBuffer[2];
452 455 time[3] = timeInBuffer[3];
453 456 time[4] = timeInBuffer[6];
454 457 time[5] = timeInBuffer[7];
455 458 }
@@ -1,950 +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 535 // launch_spectral_matrix( );
536 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 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 set_local_nb_interrupt_f0_MAX();
797 796 }
798 797
799 798 void set_irq_on_new_ready_matrix( unsigned char value )
800 799 {
801 800 if (value == 1)
802 801 {
803 802 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
804 803 }
805 804 else
806 805 {
807 806 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
808 807 }
809 808 }
810 809
811 810 void set_run_matrix_spectral( unsigned char value )
812 811 {
813 812 if (value == 1)
814 813 {
815 814 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
816 815 }
817 816 else
818 817 {
819 818 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
820 819 }
821 820 }
822 821
823 822 //****************
824 823 // CLOSING ACTIONS
825 824 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
826 825 {
827 826 /** This function is used to update the HK packets statistics after a successful TC execution.
828 827 *
829 828 * @param TC points to the TC being processed
830 829 * @param time is the time used to date the TC execution
831 830 *
832 831 */
833 832
834 833 unsigned int val;
835 834
836 835 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
837 836 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
838 837 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
839 838 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
840 839 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
841 840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
842 841 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
843 842 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
844 843 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
845 844 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
846 845 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
847 846 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
848 847
849 848 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
850 849 val++;
851 850 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
852 851 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
853 852 }
854 853
855 854 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
856 855 {
857 856 /** This function is used to update the HK packets statistics after a TC rejection.
858 857 *
859 858 * @param TC points to the TC being processed
860 859 * @param time is the time used to date the TC rejection
861 860 *
862 861 */
863 862
864 863 unsigned int val;
865 864
866 865 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
867 866 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
868 867 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
869 868 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
870 869 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
871 870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
872 871 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
873 872 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
874 873 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
875 874 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
876 875 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
877 876 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
878 877
879 878 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
880 879 val++;
881 880 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
882 881 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
883 882 }
884 883
885 884 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
886 885 {
887 886 /** This function is the last step of the TC execution workflow.
888 887 *
889 888 * @param TC points to the TC being processed
890 889 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
891 890 * @param queue_id is the id of the RTEMS message queue used to send TM packets
892 891 * @param time is the time used to date the TC execution
893 892 *
894 893 */
895 894
896 895 unsigned char requestedMode;
897 896
898 897 if (result == LFR_SUCCESSFUL)
899 898 {
900 899 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
901 900 &
902 901 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
903 902 )
904 903 {
905 904 send_tm_lfr_tc_exe_success( TC, queue_id );
906 905 }
907 906 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
908 907 {
909 908 //**********************************
910 909 // UPDATE THE LFRMODE LOCAL VARIABLE
911 910 requestedMode = TC->dataAndCRC[1];
912 911 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
913 912 updateLFRCurrentMode();
914 913 }
915 914 }
916 915 else if (result == LFR_EXE_ERROR)
917 916 {
918 917 send_tm_lfr_tc_exe_error( TC, queue_id );
919 918 }
920 919 }
921 920
922 921 //***************************
923 922 // Interrupt Service Routines
924 923 rtems_isr commutation_isr1( rtems_vector_number vector )
925 924 {
926 925 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
927 926 printf("In commutation_isr1 *** Error sending event to DUMB\n");
928 927 }
929 928 }
930 929
931 930 rtems_isr commutation_isr2( rtems_vector_number vector )
932 931 {
933 932 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
934 933 printf("In commutation_isr2 *** Error sending event to DUMB\n");
935 934 }
936 935 }
937 936
938 937 //****************
939 938 // OTHER FUNCTIONS
940 939 void updateLFRCurrentMode()
941 940 {
942 941 /** This function updates the value of the global variable lfrCurrentMode.
943 942 *
944 943 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
945 944 *
946 945 */
947 946 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
948 947 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
949 948 }
950 949
@@ -1,1282 +1,1303
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 //*****************
13 13 // waveform headers
14 14 // SWF
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 18 // CWF
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24 24
25 25 //**************
26 26 // waveform ring
27 27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 30 ring_node waveform_ring_f3[NB_RING_NODES_F3];
31 31 ring_node *current_ring_node_f0;
32 32 ring_node *ring_node_to_send_swf_f0;
33 33 ring_node *current_ring_node_f1;
34 34 ring_node *ring_node_to_send_swf_f1;
35 35 ring_node *ring_node_to_send_cwf_f1;
36 36 ring_node *current_ring_node_f2;
37 37 ring_node *ring_node_to_send_swf_f2;
38 38 ring_node *ring_node_to_send_cwf_f2;
39 39 ring_node *current_ring_node_f3;
40 40 ring_node *ring_node_to_send_cwf_f3;
41 41
42 42 bool extractSWF = false;
43 43 bool swf_f0_ready = false;
44 44 bool swf_f1_ready = false;
45 45 bool swf_f2_ready = false;
46 46
47 47 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
48 48
49 49 //*********************
50 50 // Interrupt SubRoutine
51 51
52 52 void reset_extractSWF( void )
53 53 {
54 54 extractSWF = false;
55 55 swf_f0_ready = false;
56 56 swf_f1_ready = false;
57 57 swf_f2_ready = false;
58 58 }
59 59
60 60 rtems_isr waveforms_isr( rtems_vector_number vector )
61 61 {
62 62 /** This is the interrupt sub routine called by the waveform picker core.
63 63 *
64 64 * This ISR launch different actions depending mainly on two pieces of information:
65 65 * 1. the values read in the registers of the waveform picker.
66 66 * 2. the current LFR mode.
67 67 *
68 68 */
69 69
70 70 rtems_status_code status;
71 71
72 72 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
73 73 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
74 74 { // in modes other than STANDBY and BURST, send the CWF_F3 data
75 75 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
76 76 // (1) change the receiving buffer for the waveform picker
77 77 ring_node_to_send_cwf_f3 = current_ring_node_f3;
78 78 current_ring_node_f3 = current_ring_node_f3->next;
79 79 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address;
80 80 // (2) send an event for the waveforms transmission
81 81 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
82 82 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
83 83 }
84 84 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
85 85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
86 86 }
87 87 }
88 88
89 89 switch(lfrCurrentMode)
90 90 {
91 91 //********
92 92 // STANDBY
93 93 case(LFR_MODE_STANDBY):
94 94 break;
95 95
96 96 //******
97 97 // NORMAL
98 98 case(LFR_MODE_NORMAL):
99 99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 100 {
101 101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 102 }
103 103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 104 {
105 105 // change F0 ring node
106 106 ring_node_to_send_swf_f0 = current_ring_node_f0;
107 107 current_ring_node_f0 = current_ring_node_f0->next;
108 108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
109 109 // change F1 ring node
110 110 ring_node_to_send_swf_f1 = current_ring_node_f1;
111 111 current_ring_node_f1 = current_ring_node_f1->next;
112 112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
113 113 // change F2 ring node
114 114 ring_node_to_send_swf_f2 = current_ring_node_f2;
115 115 current_ring_node_f2 = current_ring_node_f2->next;
116 116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
117 117 //
118 118 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
119 119 {
120 120 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
121 121 }
122 122 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
123 123 }
124 124 break;
125 125
126 126 //******
127 127 // BURST
128 128 case(LFR_MODE_BURST):
129 129 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
130 130 // (1) change the receiving buffer for the waveform picker
131 131 ring_node_to_send_cwf_f2 = current_ring_node_f2;
132 132 current_ring_node_f2 = current_ring_node_f2->next;
133 133 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
134 134 // (2) send an event for the waveforms transmission
135 135 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
136 136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 137 }
138 138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
139 139 }
140 140 break;
141 141
142 142 //*****
143 143 // SBM1
144 144 case(LFR_MODE_SBM1):
145 145 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
146 146 // (1) change the receiving buffer for the waveform picker
147 147 ring_node_to_send_cwf_f1 = current_ring_node_f1;
148 148 current_ring_node_f1 = current_ring_node_f1->next;
149 149 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
150 150 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
151 151 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
152 152 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
153 153 }
154 154 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
155 155 swf_f0_ready = true;
156 156 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
157 157 }
158 158 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
159 159 swf_f2_ready = true;
160 160 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
161 161 }
162 162 break;
163 163
164 164 //*****
165 165 // SBM2
166 166 case(LFR_MODE_SBM2):
167 167 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
168 168 // (1) change the receiving buffer for the waveform picker
169 169 ring_node_to_send_cwf_f2 = current_ring_node_f2;
170 170 current_ring_node_f2 = current_ring_node_f2->next;
171 171 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
172 172 // (2) send an event for the waveforms transmission
173 173 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
174 174 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
175 175 }
176 176 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
177 177 swf_f0_ready = true;
178 178 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
179 179 }
180 180 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
181 181 swf_f1_ready = true;
182 182 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
183 183 }
184 184 break;
185 185
186 186 //********
187 187 // DEFAULT
188 188 default:
189 189 break;
190 190 }
191 191 }
192 192
193 193 //************
194 194 // RTEMS TASKS
195 195
196 196 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
197 197 {
198 198 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
199 199 *
200 200 * @param unused is the starting argument of the RTEMS task
201 201 *
202 202 * The following data packets are sent by this task:
203 203 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
204 204 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
205 205 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
206 206 *
207 207 */
208 208
209 209 rtems_event_set event_out;
210 210 rtems_id queue_id;
211 211 rtems_status_code status;
212 212
213 213 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
214 214 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
215 215 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
216 216
217 217 status = get_message_queue_id_send( &queue_id );
218 218 if (status != RTEMS_SUCCESSFUL)
219 219 {
220 220 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
221 221 }
222 222
223 223 BOOT_PRINTF("in WFRM ***\n")
224 224
225 225 while(1){
226 226 // wait for an RTEMS_EVENT
227 227 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
228 228 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
229 229 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
230 230 if (event_out == RTEMS_EVENT_MODE_NORMAL)
231 231 {
232 232 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
233 233 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
234 234 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
235 235 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
236 236 }
237 237 if (event_out == RTEMS_EVENT_MODE_SBM1)
238 238 {
239 239 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
240 240 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
241 241 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
242 242 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
243 243 }
244 244 if (event_out == RTEMS_EVENT_MODE_SBM2)
245 245 {
246 246 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
247 247 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
248 248 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
249 249 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
250 250 }
251 251 }
252 252 }
253 253
254 254 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
255 255 {
256 256 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
257 257 *
258 258 * @param unused is the starting argument of the RTEMS task
259 259 *
260 260 * The following data packet is sent by this task:
261 261 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
262 262 *
263 263 */
264 264
265 265 rtems_event_set event_out;
266 266 rtems_id queue_id;
267 267 rtems_status_code status;
268 268
269 269 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
270 270 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
271 271
272 272 status = get_message_queue_id_send( &queue_id );
273 273 if (status != RTEMS_SUCCESSFUL)
274 274 {
275 275 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
276 276 }
277 277
278 278 BOOT_PRINTF("in CWF3 ***\n")
279 279
280 280 while(1){
281 281 // wait for an RTEMS_EVENT
282 282 rtems_event_receive( RTEMS_EVENT_0,
283 283 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
284 284 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
285 285 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
286 286 {
287 287 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
288 288 {
289 289 PRINTF("send CWF_LONG_F3\n")
290 290 send_waveform_CWF(
291 291 (volatile int*) current_ring_node_f3->buffer_address,
292 292 SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
293 293 }
294 294 else
295 295 {
296 296 PRINTF("send CWF_F3 (light)\n")
297 297 send_waveform_CWF3_light(
298 298 (volatile int*) current_ring_node_f3->buffer_address,
299 299 headerCWF_F3_light, queue_id );
300 300 }
301 301
302 302 }
303 303 else
304 304 {
305 305 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
306 306 }
307 307 }
308 308 }
309 309
310 310 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
311 311 {
312 312 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
313 313 *
314 314 * @param unused is the starting argument of the RTEMS task
315 315 *
316 316 * The following data packet is sent by this function:
317 317 * - TM_LFR_SCIENCE_BURST_CWF_F2
318 318 * - TM_LFR_SCIENCE_SBM2_CWF_F2
319 319 *
320 320 */
321 321
322 322 rtems_event_set event_out;
323 323 rtems_id queue_id;
324 324 rtems_status_code status;
325 325
326 326 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
327 327 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
328 328
329 329 status = get_message_queue_id_send( &queue_id );
330 330 if (status != RTEMS_SUCCESSFUL)
331 331 {
332 332 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
333 333 }
334 334
335 335 BOOT_PRINTF("in CWF2 ***\n")
336 336
337 337 while(1){
338 338 // wait for an RTEMS_EVENT
339 339 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
340 340 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
341 341 if (event_out == RTEMS_EVENT_MODE_BURST)
342 342 {
343 343 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
344 344 }
345 345 if (event_out == RTEMS_EVENT_MODE_SBM2)
346 346 {
347 347 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
348 348 // launch snapshot extraction if needed
349 349 if (extractSWF == true)
350 350 {
351 351 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
352 352 // extract the snapshot
353 353 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
354 354 // send the snapshot when built
355 355 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
356 356 extractSWF = false;
357 357 }
358 358 if (swf_f0_ready && swf_f1_ready)
359 359 {
360 360 extractSWF = true;
361 361 swf_f0_ready = false;
362 362 swf_f1_ready = false;
363 363 }
364 364 }
365 365 }
366 366 }
367 367
368 368 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
369 369 {
370 370 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
371 371 *
372 372 * @param unused is the starting argument of the RTEMS task
373 373 *
374 374 * The following data packet is sent by this function:
375 375 * - TM_LFR_SCIENCE_SBM1_CWF_F1
376 376 *
377 377 */
378 378
379 379 rtems_event_set event_out;
380 380 rtems_id queue_id;
381 381 rtems_status_code status;
382 382
383 383 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
384 384
385 385 status = get_message_queue_id_send( &queue_id );
386 386 if (status != RTEMS_SUCCESSFUL)
387 387 {
388 388 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
389 389 }
390 390
391 391 BOOT_PRINTF("in CWF1 ***\n")
392 392
393 393 while(1){
394 394 // wait for an RTEMS_EVENT
395 395 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
396 396 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
397 397 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
398 398 // launch snapshot extraction if needed
399 399 if (extractSWF == true)
400 400 {
401 401 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
402 402 // launch the snapshot extraction
403 403 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
404 404 extractSWF = false;
405 405 }
406 406 if (swf_f0_ready == true)
407 407 {
408 408 extractSWF = true;
409 409 swf_f0_ready = false; // this step shall be executed only one time
410 410 }
411 411 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
412 412 {
413 413 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
414 414 swf_f1_ready = false;
415 415 swf_f2_ready = false;
416 416 }
417 417 }
418 418 }
419 419
420 420 rtems_task swbd_task(rtems_task_argument argument)
421 421 {
422 422 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
423 423 *
424 424 * @param unused is the starting argument of the RTEMS task
425 425 *
426 426 */
427 427
428 428 rtems_event_set event_out;
429 429
430 430 BOOT_PRINTF("in SWBD ***\n")
431 431
432 432 while(1){
433 433 // wait for an RTEMS_EVENT
434 434 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
435 435 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
436 436 if (event_out == RTEMS_EVENT_MODE_SBM1)
437 437 {
438 438 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
439 439 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
440 440 }
441 441 else
442 442 {
443 443 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
444 444 }
445 445 }
446 446 }
447 447
448 448 //******************
449 449 // general functions
450 450
451 451 void init_waveform_rings( void )
452 452 {
453 453 // F0 RING
454 454 init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 );
455 455 // F1 RING
456 456 init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 );
457 457 // F2 RING
458 458 init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 );
459 459 // F3 RING
460 460 init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 );
461 461
462 462 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
463 463 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
464 464 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
465 465 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
466 466 }
467 467
468 468 void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] )
469 469 {
470 470 unsigned char i;
471 471
472 472 waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ];
473 473 waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ];
474 474 waveform_ring[0].buffer_address = (int) &wfrm[0];
475 475
476 476 waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ];
477 477 waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ];
478 478 waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ];
479 479
480 480 for(i=1; i<nbNodes-1; i++)
481 481 {
482 482 waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ];
483 483 waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ];
484 484 waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ];
485 485 }
486 486 }
487 487
488 488 void reset_current_ring_nodes( void )
489 489 {
490 490 current_ring_node_f0 = waveform_ring_f0;
491 491 ring_node_to_send_swf_f0 = waveform_ring_f0;
492 492
493 493 current_ring_node_f1 = waveform_ring_f1;
494 494 ring_node_to_send_cwf_f1 = waveform_ring_f1;
495 495 ring_node_to_send_swf_f1 = waveform_ring_f1;
496 496
497 497 current_ring_node_f2 = waveform_ring_f2;
498 498 ring_node_to_send_cwf_f2 = waveform_ring_f2;
499 499 ring_node_to_send_swf_f2 = waveform_ring_f2;
500 500
501 501 current_ring_node_f3 = waveform_ring_f3;
502 502 ring_node_to_send_cwf_f3 = waveform_ring_f3;
503 503 }
504 504
505 505 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
506 506 {
507 507 unsigned char i;
508 508
509 509 for (i=0; i<7; i++)
510 510 {
511 511 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
512 512 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
513 513 headerSWF[ i ].reserved = DEFAULT_RESERVED;
514 514 headerSWF[ i ].userApplication = CCSDS_USER_APP;
515 515 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
516 516 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
517 517 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
518 518 if (i == 6)
519 519 {
520 520 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
521 521 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
522 522 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
523 523 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
524 524 }
525 525 else
526 526 {
527 527 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
528 528 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
529 529 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
530 530 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
531 531 }
532 532 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
533 533 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
534 534 headerSWF[ i ].pktNr = i+1; // PKT_NR
535 535 // DATA FIELD HEADER
536 536 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
537 537 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
538 538 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
539 539 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
540 540 // AUXILIARY DATA HEADER
541 541 headerSWF[ i ].time[0] = 0x00;
542 542 headerSWF[ i ].time[0] = 0x00;
543 543 headerSWF[ i ].time[0] = 0x00;
544 544 headerSWF[ i ].time[0] = 0x00;
545 545 headerSWF[ i ].time[0] = 0x00;
546 546 headerSWF[ i ].time[0] = 0x00;
547 547 headerSWF[ i ].sid = sid;
548 548 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
549 549 }
550 550 return LFR_SUCCESSFUL;
551 551 }
552 552
553 553 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
554 554 {
555 555 unsigned int i;
556 556
557 557 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
558 558 {
559 559 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
560 560 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
561 561 headerCWF[ i ].reserved = DEFAULT_RESERVED;
562 562 headerCWF[ i ].userApplication = CCSDS_USER_APP;
563 563 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
564 564 {
565 565 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
566 566 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
567 567 }
568 568 else
569 569 {
570 570 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
571 571 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
572 572 }
573 573 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
574 574 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
575 575 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
576 576 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
577 577 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
578 578 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
579 579 // DATA FIELD HEADER
580 580 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
581 581 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
582 582 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
583 583 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
584 584 // AUXILIARY DATA HEADER
585 585 headerCWF[ i ].sid = sid;
586 586 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
587 587 headerCWF[ i ].time[0] = 0x00;
588 588 headerCWF[ i ].time[0] = 0x00;
589 589 headerCWF[ i ].time[0] = 0x00;
590 590 headerCWF[ i ].time[0] = 0x00;
591 591 headerCWF[ i ].time[0] = 0x00;
592 592 headerCWF[ i ].time[0] = 0x00;
593 593 }
594 594 return LFR_SUCCESSFUL;
595 595 }
596 596
597 597 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
598 598 {
599 599 unsigned int i;
600 600
601 601 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
602 602 {
603 603 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
604 604 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
605 605 headerCWF[ i ].reserved = DEFAULT_RESERVED;
606 606 headerCWF[ i ].userApplication = CCSDS_USER_APP;
607 607
608 608 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
609 609 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
610 610
611 611 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
612 612 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
613 613 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
614 614 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
615 615 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
616 616
617 617 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
618 618 // DATA FIELD HEADER
619 619 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
620 620 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
621 621 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
622 622 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
623 623 // AUXILIARY DATA HEADER
624 624 headerCWF[ i ].sid = SID_NORM_CWF_F3;
625 625 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
626 626 headerCWF[ i ].time[0] = 0x00;
627 627 headerCWF[ i ].time[0] = 0x00;
628 628 headerCWF[ i ].time[0] = 0x00;
629 629 headerCWF[ i ].time[0] = 0x00;
630 630 headerCWF[ i ].time[0] = 0x00;
631 631 headerCWF[ i ].time[0] = 0x00;
632 632 }
633 633 return LFR_SUCCESSFUL;
634 634 }
635 635
636 636 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
637 637 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
638 638 {
639 639 /** This function sends SWF CCSDS packets (F2, F1 or F0).
640 640 *
641 641 * @param waveform points to the buffer containing the data that will be send.
642 642 * @param sid is the source identifier of the data that will be sent.
643 643 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
644 644 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
645 645 * contain information to setup the transmission of the data packets.
646 646 *
647 647 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
648 648 *
649 649 */
650 650
651 651 unsigned int i;
652 652 int ret;
653 653 unsigned int coarseTime;
654 654 unsigned int fineTime;
655 655 rtems_status_code status;
656 656 spw_ioctl_pkt_send spw_ioctl_send_SWF;
657 657
658 658 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
659 659 spw_ioctl_send_SWF.options = 0;
660 660
661 661 ret = LFR_DEFAULT;
662 662
663 663 coarseTime = waveform[0];
664 664 fineTime = waveform[1];
665 665
666 666 for (i=0; i<7; i++) // send waveform
667 667 {
668 668 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
669 669 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
670 670 // BUILD THE DATA
671 671 if (i==6) {
672 672 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
673 673 }
674 674 else {
675 675 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
676 676 }
677 677 // SET PACKET SEQUENCE COUNTER
678 678 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
679 679 // SET PACKET TIME
680 680 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
681 681 //
682 682 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
683 683 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
684 684 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
685 685 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
686 686 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
687 687 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
688 688 // SEND PACKET
689 689 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
690 690 if (status != RTEMS_SUCCESSFUL) {
691 691 printf("%d-%d, ERR %d\n", sid, i, (int) status);
692 692 ret = LFR_DEFAULT;
693 693 }
694 694 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
695 695 }
696 696
697 697 return ret;
698 698 }
699 699
700 700 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
701 701 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
702 702 {
703 703 /** This function sends CWF CCSDS packets (F2, F1 or F0).
704 704 *
705 705 * @param waveform points to the buffer containing the data that will be send.
706 706 * @param sid is the source identifier of the data that will be sent.
707 707 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
708 708 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
709 709 * contain information to setup the transmission of the data packets.
710 710 *
711 711 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
712 712 *
713 713 */
714 714
715 715 unsigned int i;
716 716 int ret;
717 717 unsigned int coarseTime;
718 718 unsigned int fineTime;
719 719 rtems_status_code status;
720 720 spw_ioctl_pkt_send spw_ioctl_send_CWF;
721 721
722 722 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
723 723 spw_ioctl_send_CWF.options = 0;
724 724
725 725 ret = LFR_DEFAULT;
726 726
727 727 coarseTime = waveform[0];
728 728 fineTime = waveform[1];
729 729
730 730 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
731 731 {
732 732 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
733 733 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
734 734 // BUILD THE DATA
735 735 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
736 736 // SET PACKET SEQUENCE COUNTER
737 737 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
738 738 // SET PACKET TIME
739 739 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
740 740 //
741 741 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
742 742 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
743 743 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
744 744 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
745 745 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
746 746 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
747 747 // SEND PACKET
748 748 if (sid == SID_NORM_CWF_LONG_F3)
749 749 {
750 750 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
751 751 if (status != RTEMS_SUCCESSFUL) {
752 752 printf("%d-%d, ERR %d\n", sid, i, (int) status);
753 753 ret = LFR_DEFAULT;
754 754 }
755 755 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
756 756 }
757 757 else
758 758 {
759 759 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
760 760 if (status != RTEMS_SUCCESSFUL) {
761 761 printf("%d-%d, ERR %d\n", sid, i, (int) status);
762 762 ret = LFR_DEFAULT;
763 763 }
764 764 }
765 765 }
766 766
767 767 return ret;
768 768 }
769 769
770 770 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
771 771 {
772 772 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
773 773 *
774 774 * @param waveform points to the buffer containing the data that will be send.
775 775 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
776 776 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
777 777 * contain information to setup the transmission of the data packets.
778 778 *
779 779 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
780 780 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
781 781 *
782 782 */
783 783
784 784 unsigned int i;
785 785 int ret;
786 786 unsigned int coarseTime;
787 787 unsigned int fineTime;
788 788 rtems_status_code status;
789 789 spw_ioctl_pkt_send spw_ioctl_send_CWF;
790 790 char *sample;
791 791
792 792 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
793 793 spw_ioctl_send_CWF.options = 0;
794 794
795 795 ret = LFR_DEFAULT;
796 796
797 797 //**********************
798 798 // BUILD CWF3_light DATA
799 799 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
800 800 {
801 801 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
802 802 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
803 803 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
804 804 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
805 805 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
806 806 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
807 807 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
808 808 }
809 809
810 810 coarseTime = waveform[0];
811 811 fineTime = waveform[1];
812 812
813 813 //*********************
814 814 // SEND CWF3_light DATA
815 815 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
816 816 {
817 817 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
818 818 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
819 819 // BUILD THE DATA
820 820 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
821 821 // SET PACKET SEQUENCE COUNTER
822 822 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
823 823 // SET PACKET TIME
824 824 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
825 825 //
826 826 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
827 827 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
828 828 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
829 829 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
830 830 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
831 831 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
832 832 // SEND PACKET
833 833 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
834 834 if (status != RTEMS_SUCCESSFUL) {
835 835 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
836 836 ret = LFR_DEFAULT;
837 837 }
838 838 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
839 839 }
840 840
841 841 return ret;
842 842 }
843 843
844 844 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
845 845 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
846 846 {
847 847 unsigned long long int acquisitionTimeAsLong;
848 848 unsigned char localAcquisitionTime[6];
849 849 double deltaT;
850 850
851 851 deltaT = 0.;
852 852
853 853 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
854 854 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
855 855 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
856 856 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
857 857 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
858 858 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
859 859
860 860 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
861 861 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
862 862 + ( localAcquisitionTime[2] << 24 )
863 863 + ( localAcquisitionTime[3] << 16 )
864 864 + ( localAcquisitionTime[4] << 8 )
865 865 + ( localAcquisitionTime[5] );
866 866
867 867 switch( sid )
868 868 {
869 869 case SID_NORM_SWF_F0:
870 870 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
871 871 break;
872 872
873 873 case SID_NORM_SWF_F1:
874 874 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
875 875 break;
876 876
877 877 case SID_NORM_SWF_F2:
878 878 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
879 879 break;
880 880
881 881 case SID_SBM1_CWF_F1:
882 882 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
883 883 break;
884 884
885 885 case SID_SBM2_CWF_F2:
886 886 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
887 887 break;
888 888
889 889 case SID_BURST_CWF_F2:
890 890 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
891 891 break;
892 892
893 893 case SID_NORM_CWF_F3:
894 894 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
895 895 break;
896 896
897 897 case SID_NORM_CWF_LONG_F3:
898 898 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
899 899 break;
900 900
901 901 default:
902 902 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
903 903 deltaT = 0.;
904 904 break;
905 905 }
906 906
907 907 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
908 908 //
909 909 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
910 910 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
911 911 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
912 912 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
913 913 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
914 914 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
915 915
916 916 }
917 917
918 918 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
919 919 {
920 920 unsigned int i;
921 921 unsigned long long int centerTime_asLong;
922 922 unsigned long long int acquisitionTimeF0_asLong;
923 923 unsigned long long int acquisitionTime_asLong;
924 924 unsigned long long int bufferAcquisitionTime_asLong;
925 925 unsigned char *ptr1;
926 926 unsigned char *ptr2;
927 927 unsigned char nb_ring_nodes;
928 928 unsigned long long int frequency_asLong;
929 929 unsigned long long int nbTicksPerSample_asLong;
930 930 unsigned long long int nbSamplesPart1_asLong;
931 931 unsigned long long int sampleOffset_asLong;
932 932
933 933 unsigned int deltaT_F0;
934 934 unsigned int deltaT_F1;
935 935 unsigned long long int deltaT_F2;
936 936
937 937 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
938 938 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
939 939 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
940 940 sampleOffset_asLong = 0x00;
941 941
942 942 // (1) get the f0 acquisition time
943 943 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
944 944
945 945 // (2) compute the central reference time
946 946 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
947 947
948 948 // (3) compute the acquisition time of the current snapshot
949 949 switch(frequencyChannel)
950 950 {
951 951 case 1: // 1 is for F1 = 4096 Hz
952 952 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
953 953 nb_ring_nodes = NB_RING_NODES_F1;
954 954 frequency_asLong = 4096;
955 955 nbTicksPerSample_asLong = 16; // 65536 / 4096;
956 956 break;
957 957 case 2: // 2 is for F2 = 256 Hz
958 958 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
959 959 nb_ring_nodes = NB_RING_NODES_F2;
960 960 frequency_asLong = 256;
961 961 nbTicksPerSample_asLong = 256; // 65536 / 256;
962 962 break;
963 963 default:
964 964 acquisitionTime_asLong = centerTime_asLong;
965 965 frequency_asLong = 256;
966 966 nbTicksPerSample_asLong = 256;
967 967 break;
968 968 }
969 969
970 970 //****************************************************************************
971 971 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
972 972 for (i=0; i<nb_ring_nodes; i++)
973 973 {
974 974 PRINTF1("%d ... ", i)
975 975 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
976 976 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
977 977 {
978 978 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
979 979 break;
980 980 }
981 981 ring_node_to_send = ring_node_to_send->previous;
982 982 }
983 983
984 984 // (5) compute the number of samples to take in the current buffer
985 985 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
986 986 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
987 987 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
988 988
989 989 // (6) compute the final acquisition time
990 990 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
991 991 sampleOffset_asLong * nbTicksPerSample_asLong;
992 992
993 993 // (7) copy the acquisition time at the beginning of the extrated snapshot
994 994 ptr1 = (unsigned char*) &acquisitionTime_asLong;
995 995 ptr2 = (unsigned char*) wf_snap_extracted;
996 996 ptr2[0] = ptr1[ 2 + 2 ];
997 997 ptr2[1] = ptr1[ 3 + 2 ];
998 998 ptr2[2] = ptr1[ 0 + 2 ];
999 999 ptr2[3] = ptr1[ 1 + 2 ];
1000 1000 ptr2[4] = ptr1[ 4 + 2 ];
1001 1001 ptr2[5] = ptr1[ 5 + 2 ];
1002 1002
1003 1003 // re set the synchronization bit
1004 1004
1005 1005
1006 1006 // copy the part 1 of the snapshot in the extracted buffer
1007 1007 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1008 1008 {
1009 1009 wf_snap_extracted[i + TIME_OFFSET] =
1010 1010 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1011 1011 }
1012 1012 // copy the part 2 of the snapshot in the extracted buffer
1013 1013 ring_node_to_send = ring_node_to_send->next;
1014 1014 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1015 1015 {
1016 1016 wf_snap_extracted[i + TIME_OFFSET] =
1017 1017 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1018 1018 }
1019 1019 }
1020 1020
1021 1021 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1022 1022 {
1023 1023 unsigned char *acquisitionTimeCharPtr;
1024 1024
1025 1025 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1026 1026
1027 1027 *acquisitionTimeAslong = 0x00;
1028 1028 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1029 1029 + ( acquisitionTimeCharPtr[1] << 16 )
1030 1030 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1031 1031 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1032 1032 + ( acquisitionTimeCharPtr[4] << 8 )
1033 1033 + ( acquisitionTimeCharPtr[5] );
1034 1034 }
1035 1035
1036 1036 //**************
1037 1037 // wfp registers
1038 1038 void reset_wfp_burst_enable(void)
1039 1039 {
1040 1040 /** This function resets the waveform picker burst_enable register.
1041 1041 *
1042 1042 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1043 1043 *
1044 1044 */
1045 1045
1046 1046 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1047 1047 }
1048 1048
1049 1049 void reset_wfp_status( void )
1050 1050 {
1051 1051 /** This function resets the waveform picker status register.
1052 1052 *
1053 1053 * All status bits are set to 0 [new_err full_err full].
1054 1054 *
1055 1055 */
1056 1056
1057 1057 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1058 1058 }
1059 1059
1060 1060 void reset_waveform_picker_regs(void)
1061 1061 {
1062 1062 /** This function resets the waveform picker module registers.
1063 1063 *
1064 1064 * The registers affected by this function are located at the following offset addresses:
1065 1065 * - 0x00 data_shaping
1066 1066 * - 0x04 run_burst_enable
1067 1067 * - 0x08 addr_data_f0
1068 1068 * - 0x0C addr_data_f1
1069 1069 * - 0x10 addr_data_f2
1070 1070 * - 0x14 addr_data_f3
1071 1071 * - 0x18 status
1072 1072 * - 0x1C delta_snapshot
1073 1073 * - 0x20 delta_f0
1074 1074 * - 0x24 delta_f0_2
1075 1075 * - 0x28 delta_f1
1076 1076 * - 0x2c delta_f2
1077 1077 * - 0x30 nb_data_by_buffer
1078 1078 * - 0x34 nb_snapshot_param
1079 1079 * - 0x38 start_date
1080 1080 * - 0x3c nb_word_in_buffer
1081 1081 *
1082 1082 */
1083 1083
1084 1084 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1085 1085 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1086 1086 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1087 1087 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1088 1088 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1089 1089 waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14
1090 1090 reset_wfp_status(); // 0x18
1091 1091 //
1092 1092 set_wfp_delta_snapshot(); // 0x1c
1093 1093 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1094 1094 set_wfp_delta_f1(); // 0x28
1095 1095 set_wfp_delta_f2(); // 0x2c
1096 1096 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1097 1097 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1098 1098 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1099 1099 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1100 1100 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1101 1101 // 2688 = 8 * 336
1102 1102 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1103 1103 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1104 1104 waveform_picker_regs->start_date = 0x00; // 0x38
1105 1105 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1106 1106 }
1107 1107
1108 1108 void set_wfp_data_shaping( void )
1109 1109 {
1110 1110 /** This function sets the data_shaping register of the waveform picker module.
1111 1111 *
1112 1112 * The value is read from one field of the parameter_dump_packet structure:\n
1113 1113 * bw_sp0_sp1_r0_r1
1114 1114 *
1115 1115 */
1116 1116
1117 1117 unsigned char data_shaping;
1118 1118
1119 1119 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1120 1120 // waveform picker : [R1 R0 SP1 SP0 BW]
1121 1121
1122 1122 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1123 1123
1124 1124 waveform_picker_regs->data_shaping =
1125 1125 ( (data_shaping & 0x10) >> 4 ) // BW
1126 1126 + ( (data_shaping & 0x08) >> 2 ) // SP0
1127 1127 + ( (data_shaping & 0x04) ) // SP1
1128 1128 + ( (data_shaping & 0x02) << 2 ) // R0
1129 1129 + ( (data_shaping & 0x01) << 4 ); // R1
1130 1130 }
1131 1131
1132 1132 void set_wfp_burst_enable_register( unsigned char mode )
1133 1133 {
1134 1134 /** This function sets the waveform picker burst_enable register depending on the mode.
1135 1135 *
1136 1136 * @param mode is the LFR mode to launch.
1137 1137 *
1138 1138 * The burst bits shall be before the enable bits.
1139 1139 *
1140 1140 */
1141 1141
1142 1142 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1143 1143 // the burst bits shall be set first, before the enable bits
1144 1144 switch(mode) {
1145 1145 case(LFR_MODE_NORMAL):
1146 1146 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1147 1147 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1148 1148 break;
1149 1149 case(LFR_MODE_BURST):
1150 1150 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1151 1151 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1152 1152 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1153 1153 break;
1154 1154 case(LFR_MODE_SBM1):
1155 1155 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1156 1156 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1157 1157 break;
1158 1158 case(LFR_MODE_SBM2):
1159 1159 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1160 1160 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1161 1161 break;
1162 1162 default:
1163 1163 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1164 1164 break;
1165 1165 }
1166 1166 }
1167 1167
1168 1168 void set_wfp_delta_snapshot( void )
1169 1169 {
1170 1170 /** This function sets the delta_snapshot register of the waveform picker module.
1171 1171 *
1172 1172 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1173 1173 * - sy_lfr_n_swf_p[0]
1174 1174 * - sy_lfr_n_swf_p[1]
1175 1175 *
1176 1176 */
1177 1177
1178 1178 unsigned int delta_snapshot;
1179 1179 unsigned int delta_snapshot_in_T2;
1180 1180
1181 1181 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1182 1182 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1183 1183
1184 1184 delta_snapshot_in_T2 = delta_snapshot * 256;
1185 1185 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1186 1186 }
1187 1187
1188 1188 void set_wfp_delta_f0_f0_2( void )
1189 1189 {
1190 1190 unsigned int delta_snapshot;
1191 1191 unsigned int nb_samples_per_snapshot;
1192 1192 float delta_f0_in_float;
1193 1193
1194 1194 delta_snapshot = waveform_picker_regs->delta_snapshot;
1195 1195 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1196 1196 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1197 1197
1198 1198 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1199 1199 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1200 1200 }
1201 1201
1202 1202 void set_wfp_delta_f1( void )
1203 1203 {
1204 1204 unsigned int delta_snapshot;
1205 1205 unsigned int nb_samples_per_snapshot;
1206 1206 float delta_f1_in_float;
1207 1207
1208 1208 delta_snapshot = waveform_picker_regs->delta_snapshot;
1209 1209 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1210 1210 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1211 1211
1212 1212 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1213 1213 }
1214 1214
1215 1215 void set_wfp_delta_f2()
1216 1216 {
1217 1217 unsigned int delta_snapshot;
1218 1218 unsigned int nb_samples_per_snapshot;
1219 1219
1220 1220 delta_snapshot = waveform_picker_regs->delta_snapshot;
1221 1221 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1222 1222
1223 1223 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1224 1224 }
1225 1225
1226 1226 //*****************
1227 1227 // local parameters
1228 void set_local_nb_interrupt_f0_MAX( void )
1228
1229 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1229 1230 {
1230 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1231 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1231 1232 *
1232 * This parameter is used for the SM validation only.\n
1233 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1234 * module before launching a basic processing.
1233 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1234 * @param sid is the source identifier of the packet being updated.
1235 *
1236 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1237 * The sequence counters shall wrap around from 2^14 to zero.
1238 * The sequence counter shall start at zero at startup.
1239 *
1240 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1241 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1235 1242 *
1236 1243 */
1237 1244
1238 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1239 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1240 }
1241
1242 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1243 {
1244 1245 unsigned short *sequence_cnt;
1245 1246 unsigned short segmentation_grouping_flag;
1246 1247 unsigned short new_packet_sequence_control;
1248 rtems_mode initial_mode_set;
1249 rtems_mode current_mode_set;
1250 rtems_status_code status;
1247 1251
1248 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1249 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1252 //******************************************
1253 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1254 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1255
1256 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1257 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1258 || (sid == SID_BURST_CWF_F2)
1259 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1260 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1261 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1262 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1263 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1250 1264 {
1251 1265 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1252 1266 }
1253 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1267 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1268 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1269 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1270 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1254 1271 {
1255 1272 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1256 1273 }
1257 1274 else
1258 1275 {
1259 1276 sequence_cnt = (unsigned short *) NULL;
1260 1277 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1261 1278 }
1262 1279
1263 1280 if (sequence_cnt != NULL)
1264 1281 {
1265 1282 // increment the sequence counter
1266 1283 if ( *sequence_cnt < SEQ_CNT_MAX)
1267 1284 {
1268 1285 *sequence_cnt = *sequence_cnt + 1;
1269 1286 }
1270 1287 else
1271 1288 {
1272 1289 *sequence_cnt = 0;
1273 1290 }
1274 1291 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1275 1292 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1276 1293
1277 1294 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1278 1295
1279 1296 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1280 1297 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1281 1298 }
1299
1300 //***********************************
1301 // RESET THE MODE OF THE CALLING TASK
1302 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1282 1303 }
General Comments 0
You need to be logged in to leave comments. Login now