##// END OF EJS Templates
spacecraft potential extraction upgraded
paul -
r130:811e6b78e458 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 6 08:24:43 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue May 6 15:49:26 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-06T09:36:02. -->
3 <!-- Written by QtCreator 3.0.1, 2014-05-12T06:56:36. -->
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,501 +1,503
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 false );
227 227
228 228 // SEND PACKET
229 229 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
230 230 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
231 231 if (status != RTEMS_SUCCESSFUL) {
232 232 PRINTF1("in HOUS *** ERR send: %d\n", status)
233 233 }
234 234 }
235 235 }
236 236
237 237 PRINTF("in HOUS *** deleting task\n")
238 238
239 239 status = rtems_task_delete( RTEMS_SELF ); // should not return
240 240 printf( "rtems_task_delete returned with status of %d.\n", status );
241 241 return;
242 242 }
243 243
244 244 rtems_task dumb_task( rtems_task_argument unused )
245 245 {
246 246 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
247 247 *
248 248 * @param unused is the starting argument of the RTEMS task
249 249 *
250 250 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
251 251 *
252 252 */
253 253
254 254 unsigned int i;
255 255 unsigned int intEventOut;
256 256 unsigned int coarse_time = 0;
257 257 unsigned int fine_time = 0;
258 258 rtems_event_set event_out;
259 259
260 260 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
261 261 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
262 262 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
263 263 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
264 264 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
265 265 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
266 266 "ERR HK", // RTEMS_EVENT_6
267 267 "ready for dump", // RTEMS_EVENT_7
268 268 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
269 269 "tick" // RTEMS_EVENT_9
270 270 };
271 271
272 272 BOOT_PRINTF("in DUMB *** \n")
273 273
274 274 while(1){
275 275 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
276 276 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
277 277 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
278 278 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
279 279 intEventOut = (unsigned int) event_out;
280 280 for ( i=0; i<32; i++)
281 281 {
282 282 if ( ((intEventOut >> i) & 0x0001) != 0)
283 283 {
284 284 coarse_time = time_management_regs->coarse_time;
285 285 fine_time = time_management_regs->fine_time;
286 286 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
287 287 }
288 288 }
289 289 }
290 290 }
291 291
292 292 //*****************************
293 293 // init housekeeping parameters
294 294
295 295 void init_housekeeping_parameters( void )
296 296 {
297 297 /** This function initialize the housekeeping_packet global variable with default values.
298 298 *
299 299 */
300 300
301 301 unsigned int i = 0;
302 302 unsigned char *parameters;
303 303
304 304 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
305 305 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
306 306 {
307 307 parameters[i] = 0x00;
308 308 }
309 309 // init status word
310 310 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
311 311 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
312 312 // init software version
313 313 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
314 314 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
315 315 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
316 316 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
317 317 // init fpga version
318 318 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
319 319 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
320 320 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
321 321 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
322 322 }
323 323
324 324 void increment_seq_counter( unsigned char *packet_sequence_control)
325 325 {
326 326 /** This function increment the sequence counter psased in argument.
327 327 *
328 328 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
329 329 *
330 330 */
331 331
332 332 unsigned short sequence_cnt;
333 333 unsigned short segmentation_grouping_flag;
334 334 unsigned short new_packet_sequence_control;
335 335
336 336 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
337 337 sequence_cnt = (unsigned short) (
338 338 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
339 339 + packet_sequence_control[1]
340 340 );
341 341
342 342 if ( sequence_cnt < SEQ_CNT_MAX)
343 343 {
344 344 sequence_cnt = sequence_cnt + 1;
345 345 }
346 346 else
347 347 {
348 348 sequence_cnt = 0;
349 349 }
350 350
351 351 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
352 352
353 353 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
354 354 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
355 355 }
356 356
357 357 void getTime( unsigned char *time)
358 358 {
359 359 /** This function write the current local time in the time buffer passed in argument.
360 360 *
361 361 */
362 362
363 363 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
364 364 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
365 365 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
366 366 time[3] = (unsigned char) (time_management_regs->coarse_time);
367 367 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
368 368 time[5] = (unsigned char) (time_management_regs->fine_time);
369 369 }
370 370
371 371 unsigned long long int getTimeAsUnsignedLongLongInt( )
372 372 {
373 373 /** This function write the current local time in the time buffer passed in argument.
374 374 *
375 375 */
376 376 unsigned long long int time;
377 377
378 378 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
379 379 + time_management_regs->fine_time;
380 380
381 381 return time;
382 382 }
383 383
384 384 void send_dumb_hk( void )
385 385 {
386 386 Packet_TM_LFR_HK_t dummy_hk_packet;
387 387 unsigned char *parameters;
388 388 unsigned int i;
389 389 rtems_id queue_id;
390 390
391 391 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
392 392 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
393 393 dummy_hk_packet.reserved = DEFAULT_RESERVED;
394 394 dummy_hk_packet.userApplication = CCSDS_USER_APP;
395 395 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
396 396 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
397 397 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
398 398 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
399 399 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
400 400 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
401 401 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
402 402 dummy_hk_packet.serviceType = TM_TYPE_HK;
403 403 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
404 404 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
405 405 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
406 406 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
407 407 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
408 408 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
409 409 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
410 410 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
411 411 dummy_hk_packet.sid = SID_HK;
412 412
413 413 // init status word
414 414 dummy_hk_packet.lfr_status_word[0] = 0xff;
415 415 dummy_hk_packet.lfr_status_word[1] = 0xff;
416 416 // init software version
417 417 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
418 418 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
419 419 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
420 420 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
421 421 // init fpga version
422 422 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
423 423 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
424 424 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
425 425 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
426 426
427 427 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
428 428
429 429 for (i=0; i<100; i++)
430 430 {
431 431 parameters[i] = 0xff;
432 432 }
433 433
434 434 get_message_queue_id_send( &queue_id );
435 435
436 436 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
437 437 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
438 438 }
439 439
440 440 void get_v_e1_e2_f3( unsigned char *v, unsigned char *e1, unsigned char *e2, bool init_buffer_addr )
441 441 {
442 static int *current_addr_data_f3 = NULL;
443 int *new_addr_data_f3;
444 unsigned char *ptr;
442 unsigned int coarseTime;
443 unsigned int acquisitionTime;
444 unsigned int deltaT = 0;
445 unsigned char *bufferPtr;
445 446
446 static unsigned int counter = 0;
447 447 unsigned int offset_in_samples;
448 unsigned int offset_in_words;
449 unsigned char delta = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
448 unsigned int offset_in_bytes;
449 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
450 450
451 new_addr_data_f3 = (int *) waveform_picker_regs->addr_data_f3;
452
453 if (init_buffer_addr == true) // when the waveform_picker is launched
451 if (lfrCurrentMode == LFR_MODE_STANDBY)
454 452 {
455 current_addr_data_f3 = NULL;
453 v[0] = 0x00;
454 v[1] = 0x00;
455 e1[0] = 0x00;
456 e1[1] = 0x00;
457 e2[0] = 0x00;
458 e2[1] = 0x00;
456 459 }
457 460 else
458 461 {
459 if (lfrCurrentMode == LFR_MODE_STANDBY)
462 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
463 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3;
464 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
465 + (unsigned int) ( bufferPtr[3] << 16 )
466 + (unsigned int) ( bufferPtr[0] << 8 )
467 + (unsigned int) ( bufferPtr[1] );
468 if ( coarseTime > acquisitionTime )
460 469 {
461 v[0] = 0x00;
462 v[1] = 0x00;
463 e1[0] = 0x00;
464 e1[1] = 0x00;
465 e2[0] = 0x00;
466 e2[1] = 0x00;
470 deltaT = coarseTime - acquisitionTime;
471 offset_in_samples = (deltaT-1) * f3 ;
472 }
473 else if( coarseTime == acquisitionTime )
474 {
475 offset_in_samples = 0;
467 476 }
468 477 else
469 478 {
470 if ( new_addr_data_f3 != current_addr_data_f3 )
471 {
472 counter = 0;
473 offset_in_samples = 0;
474 current_addr_data_f3 = new_addr_data_f3;
475 }
476 else
477 {
478 counter = counter + 1;
479 offset_in_samples = counter * delta;
480 if ( offset_in_samples > NB_SAMPLES_PER_SNAPSHOT )
481 {
482 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
483 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out the buffer, counter = %d\n", counter)
484 }
485 }
486 offset_in_words = TIME_OFFSET + offset_in_samples * NB_WORDS_SWF_BLK;
487 ptr = (unsigned char*) &current_addr_data_f3[ offset_in_words ];
488 v[0] = ptr[0];
489 v[1] = ptr[1];
490 e1[0] = ptr[2];
491 e1[1] = ptr[3];
492 e2[0] = ptr[4];
493 e2[1] = ptr[5];
479 offset_in_samples = 0;
480 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
481 }
482
483 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
484 {
485 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out the buffer, counter = %d\n", offset_in_samples)
486 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
494 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 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
491 v[0] = bufferPtr[ offset_in_bytes + 0];
492 v[1] = bufferPtr[ offset_in_bytes + 1];
493 e1[0] = bufferPtr[ offset_in_bytes + 2];
494 e1[1] = bufferPtr[ offset_in_bytes + 3];
495 e2[0] = bufferPtr[ offset_in_bytes + 4];
496 e2[1] = bufferPtr[ offset_in_bytes + 5];
495 497 }
496 498 }
497 499
498 500
499 501
500 502
501 503
@@ -1,951 +1,950
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 get_v_e1_e2_f3( NULL, NULL, NULL, true );
755 754
756 755 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
757 756 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
758 757
759 758 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
760 759 if (transitionCoarseTime == 0)
761 760 {
762 761 waveform_picker_regs->start_date = time_management_regs->coarse_time;
763 762 }
764 763 else
765 764 {
766 765 waveform_picker_regs->start_date = transitionCoarseTime;
767 766 }
768 767 }
769 768
770 769 void launch_spectral_matrix( void )
771 770 {
772 771 SM_reset_current_ring_nodes();
773 772 reset_spectral_matrix_regs();
774 773 reset_nb_sm();
775 774
776 775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
777 776 grgpio_regs->io_port_direction_register =
778 777 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
779 778 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
780 779 set_irq_on_new_ready_matrix( 1 );
781 780 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
782 781 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
783 782 set_run_matrix_spectral( 1 );
784 783
785 784 }
786 785
787 786 void launch_spectral_matrix_simu( void )
788 787 {
789 788 SM_reset_current_ring_nodes();
790 789 reset_spectral_matrix_regs();
791 790 reset_nb_sm();
792 791
793 792 // Spectral Matrices simulator
794 793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
795 794 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
796 795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
797 796 set_local_nb_interrupt_f0_MAX();
798 797 }
799 798
800 799 void set_irq_on_new_ready_matrix( unsigned char value )
801 800 {
802 801 if (value == 1)
803 802 {
804 803 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
805 804 }
806 805 else
807 806 {
808 807 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
809 808 }
810 809 }
811 810
812 811 void set_run_matrix_spectral( unsigned char value )
813 812 {
814 813 if (value == 1)
815 814 {
816 815 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
817 816 }
818 817 else
819 818 {
820 819 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
821 820 }
822 821 }
823 822
824 823 //****************
825 824 // CLOSING ACTIONS
826 825 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
827 826 {
828 827 /** This function is used to update the HK packets statistics after a successful TC execution.
829 828 *
830 829 * @param TC points to the TC being processed
831 830 * @param time is the time used to date the TC execution
832 831 *
833 832 */
834 833
835 834 unsigned int val;
836 835
837 836 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
838 837 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
839 838 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
840 839 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
841 840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
842 841 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
843 842 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
844 843 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
845 844 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
846 845 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
847 846 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
848 847 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
849 848
850 849 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
851 850 val++;
852 851 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
853 852 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
854 853 }
855 854
856 855 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
857 856 {
858 857 /** This function is used to update the HK packets statistics after a TC rejection.
859 858 *
860 859 * @param TC points to the TC being processed
861 860 * @param time is the time used to date the TC rejection
862 861 *
863 862 */
864 863
865 864 unsigned int val;
866 865
867 866 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
868 867 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
869 868 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
870 869 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
871 870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
872 871 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
873 872 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
874 873 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
875 874 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
876 875 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
877 876 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
878 877 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
879 878
880 879 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
881 880 val++;
882 881 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
883 882 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
884 883 }
885 884
886 885 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
887 886 {
888 887 /** This function is the last step of the TC execution workflow.
889 888 *
890 889 * @param TC points to the TC being processed
891 890 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
892 891 * @param queue_id is the id of the RTEMS message queue used to send TM packets
893 892 * @param time is the time used to date the TC execution
894 893 *
895 894 */
896 895
897 896 unsigned char requestedMode;
898 897
899 898 if (result == LFR_SUCCESSFUL)
900 899 {
901 900 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
902 901 &
903 902 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
904 903 )
905 904 {
906 905 send_tm_lfr_tc_exe_success( TC, queue_id );
907 906 }
908 907 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
909 908 {
910 909 //**********************************
911 910 // UPDATE THE LFRMODE LOCAL VARIABLE
912 911 requestedMode = TC->dataAndCRC[1];
913 912 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
914 913 updateLFRCurrentMode();
915 914 }
916 915 }
917 916 else if (result == LFR_EXE_ERROR)
918 917 {
919 918 send_tm_lfr_tc_exe_error( TC, queue_id );
920 919 }
921 920 }
922 921
923 922 //***************************
924 923 // Interrupt Service Routines
925 924 rtems_isr commutation_isr1( rtems_vector_number vector )
926 925 {
927 926 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
928 927 printf("In commutation_isr1 *** Error sending event to DUMB\n");
929 928 }
930 929 }
931 930
932 931 rtems_isr commutation_isr2( rtems_vector_number vector )
933 932 {
934 933 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
935 934 printf("In commutation_isr2 *** Error sending event to DUMB\n");
936 935 }
937 936 }
938 937
939 938 //****************
940 939 // OTHER FUNCTIONS
941 940 void updateLFRCurrentMode()
942 941 {
943 942 /** This function updates the value of the global variable lfrCurrentMode.
944 943 *
945 944 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
946 945 *
947 946 */
948 947 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
949 948 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
950 949 }
951 950
@@ -1,1347 +1,1348
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 *current_ring_node_f0;
31 31 ring_node *ring_node_to_send_swf_f0;
32 32 ring_node *current_ring_node_f1;
33 33 ring_node *ring_node_to_send_swf_f1;
34 34 ring_node *ring_node_to_send_cwf_f1;
35 35 ring_node *current_ring_node_f2;
36 36 ring_node *ring_node_to_send_swf_f2;
37 37 ring_node *ring_node_to_send_cwf_f2;
38 38
39 39 bool extractSWF = false;
40 40 bool swf_f0_ready = false;
41 41 bool swf_f1_ready = false;
42 42 bool swf_f2_ready = false;
43 43
44 44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
45 45
46 46 //*********************
47 47 // Interrupt SubRoutine
48 48
49 49 void reset_extractSWF( void )
50 50 {
51 51 extractSWF = false;
52 52 swf_f0_ready = false;
53 53 swf_f1_ready = false;
54 54 swf_f2_ready = false;
55 55 }
56 56
57 57 rtems_isr waveforms_isr( rtems_vector_number vector )
58 58 {
59 59 /** This is the interrupt sub routine called by the waveform picker core.
60 60 *
61 61 * This ISR launch different actions depending mainly on two pieces of information:
62 62 * 1. the values read in the registers of the waveform picker.
63 63 * 2. the current LFR mode.
64 64 *
65 65 */
66 66
67 67 rtems_status_code status;
68 68
69 69 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
70 70 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
71 71 { // in modes other than STANDBY and BURST, send the CWF_F3 data
72 72 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
73 73 // (1) change the receiving buffer for the waveform picker
74 74 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
75 75 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
76 76 }
77 77 else {
78 78 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
79 79 }
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 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
84 85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
85 86 }
86 87 }
87 88
88 89 switch(lfrCurrentMode)
89 90 {
90 91 //********
91 92 // STANDBY
92 93 case(LFR_MODE_STANDBY):
93 94 break;
94 95
95 96 //******
96 97 // NORMAL
97 98 case(LFR_MODE_NORMAL):
98 99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
99 100 {
100 101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
101 102 }
102 103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
103 104 {
104 105 // change F0 ring node
105 106 ring_node_to_send_swf_f0 = current_ring_node_f0;
106 107 current_ring_node_f0 = current_ring_node_f0->next;
107 108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
108 109 // change F1 ring node
109 110 ring_node_to_send_swf_f1 = current_ring_node_f1;
110 111 current_ring_node_f1 = current_ring_node_f1->next;
111 112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
112 113 // change F2 ring node
113 114 ring_node_to_send_swf_f2 = current_ring_node_f2;
114 115 current_ring_node_f2 = current_ring_node_f2->next;
115 116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
116 117 //
117 118 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
118 119 {
119 120 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
120 121 }
121 122 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
122 123 }
123 124 break;
124 125
125 126 //******
126 127 // BURST
127 128 case(LFR_MODE_BURST):
128 129 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
129 130 // (1) change the receiving buffer for the waveform picker
130 131 ring_node_to_send_cwf_f2 = current_ring_node_f2;
131 132 current_ring_node_f2 = current_ring_node_f2->next;
132 133 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
133 134 // (2) send an event for the waveforms transmission
134 135 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
135 136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
136 137 }
137 138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
138 139 }
139 140 break;
140 141
141 142 //*****
142 143 // SBM1
143 144 case(LFR_MODE_SBM1):
144 145 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
145 146 // (1) change the receiving buffer for the waveform picker
146 147 ring_node_to_send_cwf_f1 = current_ring_node_f1;
147 148 current_ring_node_f1 = current_ring_node_f1->next;
148 149 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
149 150 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
150 151 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
151 152 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
152 153 }
153 154 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
154 155 swf_f0_ready = true;
155 156 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
156 157 }
157 158 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
158 159 swf_f2_ready = true;
159 160 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
160 161 }
161 162 break;
162 163
163 164 //*****
164 165 // SBM2
165 166 case(LFR_MODE_SBM2):
166 167 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
167 168 // (1) change the receiving buffer for the waveform picker
168 169 ring_node_to_send_cwf_f2 = current_ring_node_f2;
169 170 current_ring_node_f2 = current_ring_node_f2->next;
170 171 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
171 172 // (2) send an event for the waveforms transmission
172 173 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
173 174 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
174 175 }
175 176 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
176 177 swf_f0_ready = true;
177 178 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
178 179 }
179 180 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
180 181 swf_f1_ready = true;
181 182 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
182 183 }
183 184 break;
184 185
185 186 //********
186 187 // DEFAULT
187 188 default:
188 189 break;
189 190 }
190 191 }
191 192
192 193 //************
193 194 // RTEMS TASKS
194 195
195 196 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
196 197 {
197 198 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
198 199 *
199 200 * @param unused is the starting argument of the RTEMS task
200 201 *
201 202 * The following data packets are sent by this task:
202 203 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
203 204 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
204 205 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
205 206 *
206 207 */
207 208
208 209 rtems_event_set event_out;
209 210 rtems_id queue_id;
210 211 rtems_status_code status;
211 212
212 213 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
213 214 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
214 215 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
215 216
216 217 init_waveforms();
217 218
218 219 status = get_message_queue_id_send( &queue_id );
219 220 if (status != RTEMS_SUCCESSFUL)
220 221 {
221 222 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
222 223 }
223 224
224 225 BOOT_PRINTF("in WFRM ***\n")
225 226
226 227 while(1){
227 228 // wait for an RTEMS_EVENT
228 229 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
229 230 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
230 231 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
231 232 if (event_out == RTEMS_EVENT_MODE_NORMAL)
232 233 {
233 234 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
234 235 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
235 236 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
236 237 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
237 238 }
238 239 if (event_out == RTEMS_EVENT_MODE_SBM1)
239 240 {
240 241 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
241 242 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
242 243 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
243 244 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
244 245 }
245 246 if (event_out == RTEMS_EVENT_MODE_SBM2)
246 247 {
247 248 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
248 249 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
249 250 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
250 251 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
251 252 }
252 253 }
253 254 }
254 255
255 256 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
256 257 {
257 258 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
258 259 *
259 260 * @param unused is the starting argument of the RTEMS task
260 261 *
261 262 * The following data packet is sent by this task:
262 263 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
263 264 *
264 265 */
265 266
266 267 rtems_event_set event_out;
267 268 rtems_id queue_id;
268 269 rtems_status_code status;
269 270
270 271 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
271 272 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
272 273
273 274 status = get_message_queue_id_send( &queue_id );
274 275 if (status != RTEMS_SUCCESSFUL)
275 276 {
276 277 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
277 278 }
278 279
279 280 BOOT_PRINTF("in CWF3 ***\n")
280 281
281 282 while(1){
282 283 // wait for an RTEMS_EVENT
283 284 rtems_event_receive( RTEMS_EVENT_0,
284 285 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
285 286 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
286 287 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
287 288 {
288 289 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
289 290 {
290 291 PRINTF("send CWF_LONG_F3\n")
291 292 }
292 293 else
293 294 {
294 295 PRINTF("send CWF_F3 (light)\n")
295 296 }
296 297 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
297 298 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
298 299 {
299 300 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
300 301 }
301 302 else
302 303 {
303 304 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
304 305 }
305 306 }
306 307 else
307 308 {
308 309 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
309 310 {
310 311 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
311 312 }
312 313 else
313 314 {
314 315 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
315 316 }
316 317
317 318 }
318 319 }
319 320 else
320 321 {
321 322 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
322 323 }
323 324 }
324 325 }
325 326
326 327 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
327 328 {
328 329 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
329 330 *
330 331 * @param unused is the starting argument of the RTEMS task
331 332 *
332 333 * The following data packet is sent by this function:
333 334 * - TM_LFR_SCIENCE_BURST_CWF_F2
334 335 * - TM_LFR_SCIENCE_SBM2_CWF_F2
335 336 *
336 337 */
337 338
338 339 rtems_event_set event_out;
339 340 rtems_id queue_id;
340 341 rtems_status_code status;
341 342
342 343 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
343 344 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
344 345
345 346 status = get_message_queue_id_send( &queue_id );
346 347 if (status != RTEMS_SUCCESSFUL)
347 348 {
348 349 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
349 350 }
350 351
351 352 BOOT_PRINTF("in CWF2 ***\n")
352 353
353 354 while(1){
354 355 // wait for an RTEMS_EVENT
355 356 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
356 357 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
357 358 if (event_out == RTEMS_EVENT_MODE_BURST)
358 359 {
359 360 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
360 361 }
361 362 if (event_out == RTEMS_EVENT_MODE_SBM2)
362 363 {
363 364 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
364 365 // launch snapshot extraction if needed
365 366 if (extractSWF == true)
366 367 {
367 368 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
368 369 // extract the snapshot
369 370 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
370 371 // send the snapshot when built
371 372 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
372 373 extractSWF = false;
373 374 }
374 375 if (swf_f0_ready && swf_f1_ready)
375 376 {
376 377 extractSWF = true;
377 378 swf_f0_ready = false;
378 379 swf_f1_ready = false;
379 380 }
380 381 }
381 382 }
382 383 }
383 384
384 385 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
385 386 {
386 387 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
387 388 *
388 389 * @param unused is the starting argument of the RTEMS task
389 390 *
390 391 * The following data packet is sent by this function:
391 392 * - TM_LFR_SCIENCE_SBM1_CWF_F1
392 393 *
393 394 */
394 395
395 396 rtems_event_set event_out;
396 397 rtems_id queue_id;
397 398 rtems_status_code status;
398 399
399 400 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
400 401
401 402 status = get_message_queue_id_send( &queue_id );
402 403 if (status != RTEMS_SUCCESSFUL)
403 404 {
404 405 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
405 406 }
406 407
407 408 BOOT_PRINTF("in CWF1 ***\n")
408 409
409 410 while(1){
410 411 // wait for an RTEMS_EVENT
411 412 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
412 413 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
413 414 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
414 415 // launch snapshot extraction if needed
415 416 if (extractSWF == true)
416 417 {
417 418 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
418 419 // launch the snapshot extraction
419 420 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
420 421 extractSWF = false;
421 422 }
422 423 if (swf_f0_ready == true)
423 424 {
424 425 extractSWF = true;
425 426 swf_f0_ready = false; // this step shall be executed only one time
426 427 }
427 428 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
428 429 {
429 430 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
430 431 swf_f1_ready = false;
431 432 swf_f2_ready = false;
432 433 }
433 434 }
434 435 }
435 436
436 437 rtems_task swbd_task(rtems_task_argument argument)
437 438 {
438 439 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
439 440 *
440 441 * @param unused is the starting argument of the RTEMS task
441 442 *
442 443 */
443 444
444 445 rtems_event_set event_out;
445 446
446 447 BOOT_PRINTF("in SWBD ***\n")
447 448
448 449 while(1){
449 450 // wait for an RTEMS_EVENT
450 451 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
451 452 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
452 453 if (event_out == RTEMS_EVENT_MODE_SBM1)
453 454 {
454 455 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
455 456 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
456 457 }
457 458 else
458 459 {
459 460 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
460 461 }
461 462 }
462 463 }
463 464
464 465 //******************
465 466 // general functions
466 467 void init_waveforms( void )
467 468 {
468 469 int i = 0;
469 470
470 471 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
471 472 {
472 473 //***
473 474 // F0
474 475 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
475 476 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
476 477 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
477 478
478 479 //***
479 480 // F1
480 481 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
481 482 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
482 483 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
483 484
484 485 //***
485 486 // F2
486 487 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
487 488 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
488 489 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
489 490
490 491 //***
491 492 // F3
492 493 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
493 494 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
494 495 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
495 496 }
496 497 }
497 498
498 499 void init_waveform_rings( void )
499 500 {
500 501 unsigned char i;
501 502
502 503 // F0 RING
503 504 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
504 505 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
505 506 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
506 507
507 508 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
508 509 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
509 510 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
510 511
511 512 for(i=1; i<NB_RING_NODES_F0-1; i++)
512 513 {
513 514 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
514 515 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
515 516 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
516 517 }
517 518
518 519 // F1 RING
519 520 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
520 521 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
521 522 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
522 523
523 524 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
524 525 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
525 526 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
526 527
527 528 for(i=1; i<NB_RING_NODES_F1-1; i++)
528 529 {
529 530 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
530 531 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
531 532 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
532 533 }
533 534
534 535 // F2 RING
535 536 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
536 537 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
537 538 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
538 539
539 540 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
540 541 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
541 542 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
542 543
543 544 for(i=1; i<NB_RING_NODES_F2-1; i++)
544 545 {
545 546 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
546 547 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
547 548 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
548 549 }
549 550
550 551 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
551 552 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
552 553 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
553 554
554 555 }
555 556
556 557 void reset_current_ring_nodes( void )
557 558 {
558 559 current_ring_node_f0 = waveform_ring_f0;
559 560 ring_node_to_send_swf_f0 = waveform_ring_f0;
560 561
561 562 current_ring_node_f1 = waveform_ring_f1;
562 563 ring_node_to_send_cwf_f1 = waveform_ring_f1;
563 564 ring_node_to_send_swf_f1 = waveform_ring_f1;
564 565
565 566 current_ring_node_f2 = waveform_ring_f2;
566 567 ring_node_to_send_cwf_f2 = waveform_ring_f2;
567 568 ring_node_to_send_swf_f2 = waveform_ring_f2;
568 569 }
569 570
570 571 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
571 572 {
572 573 unsigned char i;
573 574
574 575 for (i=0; i<7; i++)
575 576 {
576 577 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
577 578 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
578 579 headerSWF[ i ].reserved = DEFAULT_RESERVED;
579 580 headerSWF[ i ].userApplication = CCSDS_USER_APP;
580 581 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
581 582 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
582 583 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
583 584 if (i == 6)
584 585 {
585 586 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
586 587 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
587 588 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
588 589 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
589 590 }
590 591 else
591 592 {
592 593 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
593 594 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
594 595 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
595 596 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
596 597 }
597 598 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
598 599 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
599 600 headerSWF[ i ].pktNr = i+1; // PKT_NR
600 601 // DATA FIELD HEADER
601 602 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
602 603 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
603 604 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
604 605 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
605 606 // AUXILIARY DATA HEADER
606 607 headerSWF[ i ].time[0] = 0x00;
607 608 headerSWF[ i ].time[0] = 0x00;
608 609 headerSWF[ i ].time[0] = 0x00;
609 610 headerSWF[ i ].time[0] = 0x00;
610 611 headerSWF[ i ].time[0] = 0x00;
611 612 headerSWF[ i ].time[0] = 0x00;
612 613 headerSWF[ i ].sid = sid;
613 614 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
614 615 }
615 616 return LFR_SUCCESSFUL;
616 617 }
617 618
618 619 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
619 620 {
620 621 unsigned int i;
621 622
622 623 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
623 624 {
624 625 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
625 626 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
626 627 headerCWF[ i ].reserved = DEFAULT_RESERVED;
627 628 headerCWF[ i ].userApplication = CCSDS_USER_APP;
628 629 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
629 630 {
630 631 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
631 632 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
632 633 }
633 634 else
634 635 {
635 636 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
636 637 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
637 638 }
638 639 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
639 640 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
640 641 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
641 642 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
642 643 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
643 644 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
644 645 // DATA FIELD HEADER
645 646 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
646 647 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
647 648 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
648 649 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
649 650 // AUXILIARY DATA HEADER
650 651 headerCWF[ i ].sid = sid;
651 652 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
652 653 headerCWF[ i ].time[0] = 0x00;
653 654 headerCWF[ i ].time[0] = 0x00;
654 655 headerCWF[ i ].time[0] = 0x00;
655 656 headerCWF[ i ].time[0] = 0x00;
656 657 headerCWF[ i ].time[0] = 0x00;
657 658 headerCWF[ i ].time[0] = 0x00;
658 659 }
659 660 return LFR_SUCCESSFUL;
660 661 }
661 662
662 663 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
663 664 {
664 665 unsigned int i;
665 666
666 667 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
667 668 {
668 669 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
669 670 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
670 671 headerCWF[ i ].reserved = DEFAULT_RESERVED;
671 672 headerCWF[ i ].userApplication = CCSDS_USER_APP;
672 673
673 674 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
674 675 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
675 676
676 677 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
677 678 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
678 679 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
679 680 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
680 681 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
681 682
682 683 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
683 684 // DATA FIELD HEADER
684 685 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
685 686 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
686 687 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
687 688 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
688 689 // AUXILIARY DATA HEADER
689 690 headerCWF[ i ].sid = SID_NORM_CWF_F3;
690 691 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
691 692 headerCWF[ i ].time[0] = 0x00;
692 693 headerCWF[ i ].time[0] = 0x00;
693 694 headerCWF[ i ].time[0] = 0x00;
694 695 headerCWF[ i ].time[0] = 0x00;
695 696 headerCWF[ i ].time[0] = 0x00;
696 697 headerCWF[ i ].time[0] = 0x00;
697 698 }
698 699 return LFR_SUCCESSFUL;
699 700 }
700 701
701 702 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
702 703 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
703 704 {
704 705 /** This function sends SWF CCSDS packets (F2, F1 or F0).
705 706 *
706 707 * @param waveform points to the buffer containing the data that will be send.
707 708 * @param sid is the source identifier of the data that will be sent.
708 709 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
709 710 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
710 711 * contain information to setup the transmission of the data packets.
711 712 *
712 713 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
713 714 *
714 715 */
715 716
716 717 unsigned int i;
717 718 int ret;
718 719 unsigned int coarseTime;
719 720 unsigned int fineTime;
720 721 rtems_status_code status;
721 722 spw_ioctl_pkt_send spw_ioctl_send_SWF;
722 723
723 724 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
724 725 spw_ioctl_send_SWF.options = 0;
725 726
726 727 ret = LFR_DEFAULT;
727 728
728 729 coarseTime = waveform[0];
729 730 fineTime = waveform[1];
730 731
731 732 for (i=0; i<7; i++) // send waveform
732 733 {
733 734 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
734 735 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
735 736 // BUILD THE DATA
736 737 if (i==6) {
737 738 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
738 739 }
739 740 else {
740 741 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
741 742 }
742 743 // SET PACKET SEQUENCE COUNTER
743 744 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
744 745 // SET PACKET TIME
745 746 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
746 747 //
747 748 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
748 749 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
749 750 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
750 751 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
751 752 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
752 753 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
753 754 // SEND PACKET
754 755 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
755 756 if (status != RTEMS_SUCCESSFUL) {
756 757 printf("%d-%d, ERR %d\n", sid, i, (int) status);
757 758 ret = LFR_DEFAULT;
758 759 }
759 760 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
760 761 }
761 762
762 763 return ret;
763 764 }
764 765
765 766 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
766 767 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
767 768 {
768 769 /** This function sends CWF CCSDS packets (F2, F1 or F0).
769 770 *
770 771 * @param waveform points to the buffer containing the data that will be send.
771 772 * @param sid is the source identifier of the data that will be sent.
772 773 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
773 774 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
774 775 * contain information to setup the transmission of the data packets.
775 776 *
776 777 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
777 778 *
778 779 */
779 780
780 781 unsigned int i;
781 782 int ret;
782 783 unsigned int coarseTime;
783 784 unsigned int fineTime;
784 785 rtems_status_code status;
785 786 spw_ioctl_pkt_send spw_ioctl_send_CWF;
786 787
787 788 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
788 789 spw_ioctl_send_CWF.options = 0;
789 790
790 791 ret = LFR_DEFAULT;
791 792
792 793 coarseTime = waveform[0];
793 794 fineTime = waveform[1];
794 795
795 796 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
796 797 {
797 798 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
798 799 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
799 800 // BUILD THE DATA
800 801 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
801 802 // SET PACKET SEQUENCE COUNTER
802 803 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
803 804 // SET PACKET TIME
804 805 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
805 806 //
806 807 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
807 808 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
808 809 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
809 810 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
810 811 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
811 812 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
812 813 // SEND PACKET
813 814 if (sid == SID_NORM_CWF_LONG_F3)
814 815 {
815 816 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
816 817 if (status != RTEMS_SUCCESSFUL) {
817 818 printf("%d-%d, ERR %d\n", sid, i, (int) status);
818 819 ret = LFR_DEFAULT;
819 820 }
820 821 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
821 822 }
822 823 else
823 824 {
824 825 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
825 826 if (status != RTEMS_SUCCESSFUL) {
826 827 printf("%d-%d, ERR %d\n", sid, i, (int) status);
827 828 ret = LFR_DEFAULT;
828 829 }
829 830 }
830 831 }
831 832
832 833 return ret;
833 834 }
834 835
835 836 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
836 837 {
837 838 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
838 839 *
839 840 * @param waveform points to the buffer containing the data that will be send.
840 841 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
841 842 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
842 843 * contain information to setup the transmission of the data packets.
843 844 *
844 845 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
845 846 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
846 847 *
847 848 */
848 849
849 850 unsigned int i;
850 851 int ret;
851 852 unsigned int coarseTime;
852 853 unsigned int fineTime;
853 854 rtems_status_code status;
854 855 spw_ioctl_pkt_send spw_ioctl_send_CWF;
855 856 char *sample;
856 857
857 858 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
858 859 spw_ioctl_send_CWF.options = 0;
859 860
860 861 ret = LFR_DEFAULT;
861 862
862 863 //**********************
863 864 // BUILD CWF3_light DATA
864 865 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
865 866 {
866 867 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
867 868 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
868 869 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
869 870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
870 871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
871 872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
872 873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
873 874 }
874 875
875 876 coarseTime = waveform[0];
876 877 fineTime = waveform[1];
877 878
878 879 //*********************
879 880 // SEND CWF3_light DATA
880 881 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
881 882 {
882 883 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];
883 884 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
884 885 // BUILD THE DATA
885 886 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
886 887 // SET PACKET SEQUENCE COUNTER
887 888 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
888 889 // SET PACKET TIME
889 890 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
890 891 //
891 892 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
892 893 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
893 894 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
894 895 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
895 896 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
896 897 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
897 898 // SEND PACKET
898 899 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
899 900 if (status != RTEMS_SUCCESSFUL) {
900 901 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
901 902 ret = LFR_DEFAULT;
902 903 }
903 904 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
904 905 }
905 906
906 907 return ret;
907 908 }
908 909
909 910 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
910 911 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
911 912 {
912 913 unsigned long long int acquisitionTimeAsLong;
913 914 unsigned char localAcquisitionTime[6];
914 915 double deltaT;
915 916
916 917 deltaT = 0.;
917 918
918 919 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
919 920 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
920 921 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
921 922 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
922 923 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
923 924 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
924 925
925 926 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
926 927 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
927 928 + ( localAcquisitionTime[2] << 24 )
928 929 + ( localAcquisitionTime[3] << 16 )
929 930 + ( localAcquisitionTime[4] << 8 )
930 931 + ( localAcquisitionTime[5] );
931 932
932 933 switch( sid )
933 934 {
934 935 case SID_NORM_SWF_F0:
935 936 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
936 937 break;
937 938
938 939 case SID_NORM_SWF_F1:
939 940 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
940 941 break;
941 942
942 943 case SID_NORM_SWF_F2:
943 944 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
944 945 break;
945 946
946 947 case SID_SBM1_CWF_F1:
947 948 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
948 949 break;
949 950
950 951 case SID_SBM2_CWF_F2:
951 952 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
952 953 break;
953 954
954 955 case SID_BURST_CWF_F2:
955 956 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
956 957 break;
957 958
958 959 case SID_NORM_CWF_F3:
959 960 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
960 961 break;
961 962
962 963 case SID_NORM_CWF_LONG_F3:
963 964 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
964 965 break;
965 966
966 967 default:
967 968 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
968 969 deltaT = 0.;
969 970 break;
970 971 }
971 972
972 973 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
973 974 //
974 975 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
975 976 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
976 977 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
977 978 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
978 979 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
979 980 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
980 981
981 982 }
982 983
983 984 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
984 985 {
985 986 unsigned int i;
986 987 unsigned long long int centerTime_asLong;
987 988 unsigned long long int acquisitionTimeF0_asLong;
988 989 unsigned long long int acquisitionTime_asLong;
989 990 unsigned long long int bufferAcquisitionTime_asLong;
990 991 unsigned char *ptr1;
991 992 unsigned char *ptr2;
992 993 unsigned char nb_ring_nodes;
993 994 unsigned long long int frequency_asLong;
994 995 unsigned long long int nbTicksPerSample_asLong;
995 996 unsigned long long int nbSamplesPart1_asLong;
996 997 unsigned long long int sampleOffset_asLong;
997 998
998 999 unsigned int deltaT_F0;
999 1000 unsigned int deltaT_F1;
1000 1001 unsigned long long int deltaT_F2;
1001 1002
1002 1003 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1003 1004 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1004 1005 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1005 1006 sampleOffset_asLong = 0x00;
1006 1007
1007 1008 // (1) get the f0 acquisition time
1008 1009 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1009 1010
1010 1011 // (2) compute the central reference time
1011 1012 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1012 1013
1013 1014 // (3) compute the acquisition time of the current snapshot
1014 1015 switch(frequencyChannel)
1015 1016 {
1016 1017 case 1: // 1 is for F1 = 4096 Hz
1017 1018 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1018 1019 nb_ring_nodes = NB_RING_NODES_F1;
1019 1020 frequency_asLong = 4096;
1020 1021 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1021 1022 break;
1022 1023 case 2: // 2 is for F2 = 256 Hz
1023 1024 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1024 1025 nb_ring_nodes = NB_RING_NODES_F2;
1025 1026 frequency_asLong = 256;
1026 1027 nbTicksPerSample_asLong = 256; // 65536 / 256;
1027 1028 break;
1028 1029 default:
1029 1030 acquisitionTime_asLong = centerTime_asLong;
1030 1031 frequency_asLong = 256;
1031 1032 nbTicksPerSample_asLong = 256;
1032 1033 break;
1033 1034 }
1034 1035
1035 1036 //****************************************************************************
1036 1037 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1037 1038 for (i=0; i<nb_ring_nodes; i++)
1038 1039 {
1039 1040 PRINTF1("%d ... ", i)
1040 1041 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1041 1042 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1042 1043 {
1043 1044 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1044 1045 break;
1045 1046 }
1046 1047 ring_node_to_send = ring_node_to_send->previous;
1047 1048 }
1048 1049
1049 1050 // (5) compute the number of samples to take in the current buffer
1050 1051 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1051 1052 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1052 1053 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1053 1054
1054 1055 // (6) compute the final acquisition time
1055 1056 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1056 1057 sampleOffset_asLong * nbTicksPerSample_asLong;
1057 1058
1058 1059 // (7) copy the acquisition time at the beginning of the extrated snapshot
1059 1060 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1060 1061 ptr2 = (unsigned char*) wf_snap_extracted;
1061 1062 ptr2[0] = ptr1[ 2 + 2 ];
1062 1063 ptr2[1] = ptr1[ 3 + 2 ];
1063 1064 ptr2[2] = ptr1[ 0 + 2 ];
1064 1065 ptr2[3] = ptr1[ 1 + 2 ];
1065 1066 ptr2[4] = ptr1[ 4 + 2 ];
1066 1067 ptr2[5] = ptr1[ 5 + 2 ];
1067 1068
1068 1069 // re set the synchronization bit
1069 1070
1070 1071
1071 1072 // copy the part 1 of the snapshot in the extracted buffer
1072 1073 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1073 1074 {
1074 1075 wf_snap_extracted[i + TIME_OFFSET] =
1075 1076 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1076 1077 }
1077 1078 // copy the part 2 of the snapshot in the extracted buffer
1078 1079 ring_node_to_send = ring_node_to_send->next;
1079 1080 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1080 1081 {
1081 1082 wf_snap_extracted[i + TIME_OFFSET] =
1082 1083 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1083 1084 }
1084 1085 }
1085 1086
1086 1087 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1087 1088 {
1088 1089 unsigned char *acquisitionTimeCharPtr;
1089 1090
1090 1091 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1091 1092
1092 1093 *acquisitionTimeAslong = 0x00;
1093 1094 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1094 1095 + ( acquisitionTimeCharPtr[1] << 16 )
1095 1096 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1096 1097 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1097 1098 + ( acquisitionTimeCharPtr[4] << 8 )
1098 1099 + ( acquisitionTimeCharPtr[5] );
1099 1100 }
1100 1101
1101 1102 //**************
1102 1103 // wfp registers
1103 1104 void reset_wfp_burst_enable(void)
1104 1105 {
1105 1106 /** This function resets the waveform picker burst_enable register.
1106 1107 *
1107 1108 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1108 1109 *
1109 1110 */
1110 1111
1111 1112 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1112 1113 }
1113 1114
1114 1115 void reset_wfp_status( void )
1115 1116 {
1116 1117 /** This function resets the waveform picker status register.
1117 1118 *
1118 1119 * All status bits are set to 0 [new_err full_err full].
1119 1120 *
1120 1121 */
1121 1122
1122 1123 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1123 1124 }
1124 1125
1125 1126 void reset_waveform_picker_regs(void)
1126 1127 {
1127 1128 /** This function resets the waveform picker module registers.
1128 1129 *
1129 1130 * The registers affected by this function are located at the following offset addresses:
1130 1131 * - 0x00 data_shaping
1131 1132 * - 0x04 run_burst_enable
1132 1133 * - 0x08 addr_data_f0
1133 1134 * - 0x0C addr_data_f1
1134 1135 * - 0x10 addr_data_f2
1135 1136 * - 0x14 addr_data_f3
1136 1137 * - 0x18 status
1137 1138 * - 0x1C delta_snapshot
1138 1139 * - 0x20 delta_f0
1139 1140 * - 0x24 delta_f0_2
1140 1141 * - 0x28 delta_f1
1141 1142 * - 0x2c delta_f2
1142 1143 * - 0x30 nb_data_by_buffer
1143 1144 * - 0x34 nb_snapshot_param
1144 1145 * - 0x38 start_date
1145 1146 * - 0x3c nb_word_in_buffer
1146 1147 *
1147 1148 */
1148 1149
1149 1150 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1150 1151 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1151 1152 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1152 1153 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1153 1154 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1154 1155 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1155 1156 reset_wfp_status(); // 0x18
1156 1157 //
1157 1158 set_wfp_delta_snapshot(); // 0x1c
1158 1159 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1159 1160 set_wfp_delta_f1(); // 0x28
1160 1161 set_wfp_delta_f2(); // 0x2c
1161 1162 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1162 1163 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1163 1164 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1164 1165 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1165 1166 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1166 1167 // 2688 = 8 * 336
1167 1168 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1168 1169 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1169 1170 waveform_picker_regs->start_date = 0x00; // 0x38
1170 1171 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1171 1172 }
1172 1173
1173 1174 void set_wfp_data_shaping( void )
1174 1175 {
1175 1176 /** This function sets the data_shaping register of the waveform picker module.
1176 1177 *
1177 1178 * The value is read from one field of the parameter_dump_packet structure:\n
1178 1179 * bw_sp0_sp1_r0_r1
1179 1180 *
1180 1181 */
1181 1182
1182 1183 unsigned char data_shaping;
1183 1184
1184 1185 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1185 1186 // waveform picker : [R1 R0 SP1 SP0 BW]
1186 1187
1187 1188 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1188 1189
1189 1190 waveform_picker_regs->data_shaping =
1190 1191 ( (data_shaping & 0x10) >> 4 ) // BW
1191 1192 + ( (data_shaping & 0x08) >> 2 ) // SP0
1192 1193 + ( (data_shaping & 0x04) ) // SP1
1193 1194 + ( (data_shaping & 0x02) << 2 ) // R0
1194 1195 + ( (data_shaping & 0x01) << 4 ); // R1
1195 1196 }
1196 1197
1197 1198 void set_wfp_burst_enable_register( unsigned char mode )
1198 1199 {
1199 1200 /** This function sets the waveform picker burst_enable register depending on the mode.
1200 1201 *
1201 1202 * @param mode is the LFR mode to launch.
1202 1203 *
1203 1204 * The burst bits shall be before the enable bits.
1204 1205 *
1205 1206 */
1206 1207
1207 1208 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1208 1209 // the burst bits shall be set first, before the enable bits
1209 1210 switch(mode) {
1210 1211 case(LFR_MODE_NORMAL):
1211 1212 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1212 1213 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1213 1214 break;
1214 1215 case(LFR_MODE_BURST):
1215 1216 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1216 1217 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1217 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x06; // [0110] enable f3 AND f2
1218 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1218 1219 break;
1219 1220 case(LFR_MODE_SBM1):
1220 1221 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1221 1222 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1222 1223 break;
1223 1224 case(LFR_MODE_SBM2):
1224 1225 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1225 1226 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1226 1227 break;
1227 1228 default:
1228 1229 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1229 1230 break;
1230 1231 }
1231 1232 }
1232 1233
1233 1234 void set_wfp_delta_snapshot( void )
1234 1235 {
1235 1236 /** This function sets the delta_snapshot register of the waveform picker module.
1236 1237 *
1237 1238 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1238 1239 * - sy_lfr_n_swf_p[0]
1239 1240 * - sy_lfr_n_swf_p[1]
1240 1241 *
1241 1242 */
1242 1243
1243 1244 unsigned int delta_snapshot;
1244 1245 unsigned int delta_snapshot_in_T2;
1245 1246
1246 1247 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1247 1248 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1248 1249
1249 1250 delta_snapshot_in_T2 = delta_snapshot * 256;
1250 1251 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1251 1252 }
1252 1253
1253 1254 void set_wfp_delta_f0_f0_2( void )
1254 1255 {
1255 1256 unsigned int delta_snapshot;
1256 1257 unsigned int nb_samples_per_snapshot;
1257 1258 float delta_f0_in_float;
1258 1259
1259 1260 delta_snapshot = waveform_picker_regs->delta_snapshot;
1260 1261 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1261 1262 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1262 1263
1263 1264 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1264 1265 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1265 1266 }
1266 1267
1267 1268 void set_wfp_delta_f1( void )
1268 1269 {
1269 1270 unsigned int delta_snapshot;
1270 1271 unsigned int nb_samples_per_snapshot;
1271 1272 float delta_f1_in_float;
1272 1273
1273 1274 delta_snapshot = waveform_picker_regs->delta_snapshot;
1274 1275 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1275 1276 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1276 1277
1277 1278 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1278 1279 }
1279 1280
1280 1281 void set_wfp_delta_f2()
1281 1282 {
1282 1283 unsigned int delta_snapshot;
1283 1284 unsigned int nb_samples_per_snapshot;
1284 1285
1285 1286 delta_snapshot = waveform_picker_regs->delta_snapshot;
1286 1287 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1287 1288
1288 1289 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1289 1290 }
1290 1291
1291 1292 //*****************
1292 1293 // local parameters
1293 1294 void set_local_nb_interrupt_f0_MAX( void )
1294 1295 {
1295 1296 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1296 1297 *
1297 1298 * This parameter is used for the SM validation only.\n
1298 1299 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1299 1300 * module before launching a basic processing.
1300 1301 *
1301 1302 */
1302 1303
1303 1304 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1304 1305 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1305 1306 }
1306 1307
1307 1308 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1308 1309 {
1309 1310 unsigned short *sequence_cnt;
1310 1311 unsigned short segmentation_grouping_flag;
1311 1312 unsigned short new_packet_sequence_control;
1312 1313
1313 1314 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1314 1315 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1315 1316 {
1316 1317 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1317 1318 }
1318 1319 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1319 1320 {
1320 1321 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1321 1322 }
1322 1323 else
1323 1324 {
1324 1325 sequence_cnt = (unsigned short *) NULL;
1325 1326 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1326 1327 }
1327 1328
1328 1329 if (sequence_cnt != NULL)
1329 1330 {
1330 1331 // increment the sequence counter
1331 1332 if ( *sequence_cnt < SEQ_CNT_MAX)
1332 1333 {
1333 1334 *sequence_cnt = *sequence_cnt + 1;
1334 1335 }
1335 1336 else
1336 1337 {
1337 1338 *sequence_cnt = 0;
1338 1339 }
1339 1340 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1340 1341 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1341 1342
1342 1343 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1343 1344
1344 1345 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1345 1346 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1346 1347 }
1347 1348 }
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now