##// END OF EJS Templates
Sync
paul -
r174:c6546d192260 VHDL_0_1_28
parent child
Show More
@@ -0,0 +1,2
1 header/common_lfr_headers = https://hephaistos.lpp.polytechnique.fr/rhodecode/HG_REPOSITORIES/LPP/INSTRUMENTATION/SOLO_LFR/lfr_common_headers
2
@@ -0,0 +1,1
1 0000000000000000000000000000000000000000 header/common_lfr_headers
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
@@ -1,14 +1,14
1 1 syntax: glob
2 2 *.pdf
3 3 *~
4 4 *.o
5 5 *.gcno
6 6 *.gcda
7 7 *.html
8 8 *.zip
9 9 tests/*.err
10 10 doc
11 11 *.srec
12 12 FSW-qt/bin/fsw
13 13 src/LFR_basic-parameters
14
14 *.pro.user.*
@@ -1,273 +1,273
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Fri Nov 14 07:56:09 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Wed Nov 26 13:14:53 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=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DLPP_DPU_DESTID -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_misc.c \
49 49 ../src/fsw_init.c \
50 50 ../src/fsw_globals.c \
51 51 ../src/fsw_spacewire.c \
52 52 ../src/tc_load_dump_parameters.c \
53 53 ../src/tm_lfr_tc_exe.c \
54 54 ../src/tc_acceptance.c \
55 55 ../src/processing/fsw_processing.c \
56 56 ../src/processing/avf0_prc0.c \
57 57 ../src/processing/avf1_prc1.c \
58 58 ../src/processing/avf2_prc2.c \
59 59 ../src/lfr_cpu_usage_report.c \
60 60 ../src/LFR_basic-parameters/basic_parameters.c
61 61 OBJECTS = obj/wf_handler.o \
62 62 obj/tc_handler.o \
63 63 obj/fsw_misc.o \
64 64 obj/fsw_init.o \
65 65 obj/fsw_globals.o \
66 66 obj/fsw_spacewire.o \
67 67 obj/tc_load_dump_parameters.o \
68 68 obj/tm_lfr_tc_exe.o \
69 69 obj/tc_acceptance.o \
70 70 obj/fsw_processing.o \
71 71 obj/avf0_prc0.o \
72 72 obj/avf1_prc1.o \
73 73 obj/avf2_prc2.o \
74 74 obj/lfr_cpu_usage_report.o \
75 75 obj/basic_parameters.o
76 76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 77 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 82 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 88 sparc.pri \
89 89 /usr/lib64/qt4/mkspecs/features/release.prf \
90 90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 91 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 94 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 95 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 97 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 99 fsw-qt.pro
100 100 QMAKE_TARGET = fsw
101 101 DESTDIR = bin/
102 102 TARGET = bin/fsw
103 103
104 104 first: all
105 105 ####### Implicit rules
106 106
107 107 .SUFFIXES: .o .c .cpp .cc .cxx .C
108 108
109 109 .cpp.o:
110 110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 111
112 112 .cc.o:
113 113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114 114
115 115 .cxx.o:
116 116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117 117
118 118 .C.o:
119 119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120 120
121 121 .c.o:
122 122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123 123
124 124 ####### Build rules
125 125
126 126 all: Makefile $(TARGET)
127 127
128 128 $(TARGET): $(OBJECTS)
129 129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131 131
132 132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 133 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 138 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 144 sparc.pri \
145 145 /usr/lib64/qt4/mkspecs/features/release.prf \
146 146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 147 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 150 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 151 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 153 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 156 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 157 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 162 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 168 sparc.pri:
169 169 /usr/lib64/qt4/mkspecs/features/release.prf:
170 170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 171 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 174 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 175 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 177 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 179 qmake: FORCE
180 180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181 181
182 182 dist:
183 183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
185 185
186 186
187 187 clean:compiler_clean
188 188 -$(DEL_FILE) $(OBJECTS)
189 189 -$(DEL_FILE) *~ core *.core
190 190
191 191
192 192 ####### Sub-libraries
193 193
194 194 distclean: clean
195 195 -$(DEL_FILE) $(TARGET)
196 196 -$(DEL_FILE) Makefile
197 197
198 198
199 199 grmon:
200 200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201 201
202 202 check: first
203 203
204 204 compiler_rcc_make_all:
205 205 compiler_rcc_clean:
206 206 compiler_uic_make_all:
207 207 compiler_uic_clean:
208 208 compiler_image_collection_make_all: qmake_image_collection.cpp
209 209 compiler_image_collection_clean:
210 210 -$(DEL_FILE) qmake_image_collection.cpp
211 211 compiler_yacc_decl_make_all:
212 212 compiler_yacc_decl_clean:
213 213 compiler_yacc_impl_make_all:
214 214 compiler_yacc_impl_clean:
215 215 compiler_lex_make_all:
216 216 compiler_lex_clean:
217 217 compiler_clean:
218 218
219 219 ####### Compile
220 220
221 221 obj/wf_handler.o: ../src/wf_handler.c
222 222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223 223
224 224 obj/tc_handler.o: ../src/tc_handler.c
225 225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226 226
227 227 obj/fsw_misc.o: ../src/fsw_misc.c
228 228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229 229
230 230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232 232
233 233 obj/fsw_globals.o: ../src/fsw_globals.c
234 234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235 235
236 236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238 238
239 239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241 241
242 242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244 244
245 245 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247 247
248 248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250 250
251 251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253 253
254 254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256 256
257 257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259 259
260 260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262 262
263 263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265 265
266 266 ####### Install
267 267
268 268 install: FORCE
269 269
270 270 uninstall: FORCE
271 271
272 272 FORCE:
273 273
@@ -1,208 +1,208
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.2.1, 2014-11-13T16:06:58. -->
3 <!-- Written by QtCreator 3.2.1, 2014-12-10T17:20:49. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>EnvironmentId</variable>
7 7 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.ActiveTarget</variable>
11 11 <value type="int">0</value>
12 12 </data>
13 13 <data>
14 14 <variable>ProjectExplorer.Project.EditorSettings</variable>
15 15 <valuemap type="QVariantMap">
16 16 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
17 17 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
18 18 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
19 19 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
20 20 <value type="QString" key="language">Cpp</value>
21 21 <valuemap type="QVariantMap" key="value">
22 22 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
23 23 </valuemap>
24 24 </valuemap>
25 25 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
26 26 <value type="QString" key="language">QmlJS</value>
27 27 <valuemap type="QVariantMap" key="value">
28 28 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
29 29 </valuemap>
30 30 </valuemap>
31 31 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
32 32 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
33 33 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
34 34 <value type="int" key="EditorConfiguration.IndentSize">4</value>
35 35 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
36 36 <value type="int" key="EditorConfiguration.MarginColumn">80</value>
37 37 <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
38 38 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
39 39 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
40 40 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
41 41 <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
42 42 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
43 43 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
44 44 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
45 45 <value type="int" key="EditorConfiguration.TabSize">8</value>
46 46 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
47 47 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
48 48 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
49 49 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
50 50 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
51 51 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
52 52 </valuemap>
53 53 </data>
54 54 <data>
55 55 <variable>ProjectExplorer.Project.PluginSettings</variable>
56 56 <valuemap type="QVariantMap"/>
57 57 </data>
58 58 <data>
59 59 <variable>ProjectExplorer.Project.Target.0</variable>
60 60 <valuemap type="QVariantMap">
61 61 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
62 62 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
63 63 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
64 64 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
65 65 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
66 66 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
67 67 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
68 68 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
69 69 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
70 70 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
71 71 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
72 72 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
73 73 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
74 74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
75 75 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
76 76 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
77 77 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
78 78 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
79 79 </valuemap>
80 80 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
81 81 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
82 82 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
83 83 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
84 84 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
85 85 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
86 86 <value type="QString">-w</value>
87 87 <value type="QString">-r</value>
88 88 </valuelist>
89 89 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
90 90 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
91 91 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
92 92 </valuemap>
93 93 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
97 97 </valuemap>
98 98 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
99 99 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
100 100 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
101 101 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
102 102 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
103 103 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
104 104 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
105 105 <value type="QString">-w</value>
106 106 <value type="QString">-r</value>
107 107 </valuelist>
108 108 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
109 109 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
110 110 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
111 111 </valuemap>
112 112 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
116 116 </valuemap>
117 117 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
118 118 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
119 119 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
120 120 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
121 121 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
122 122 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
123 123 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
124 124 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
125 125 </valuemap>
126 126 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
127 127 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
128 128 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
129 129 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
131 131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
132 132 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
133 133 </valuemap>
134 134 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
136 136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
137 137 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
138 138 </valuemap>
139 139 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
140 140 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
141 141 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
142 142 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
143 143 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
144 144 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
145 145 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
146 146 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
147 147 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
148 148 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
149 149 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
150 150 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
151 151 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
152 152 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
153 153 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
154 154 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
155 155 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
156 156 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
157 157 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
158 158 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
159 159 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
160 160 <value type="int">0</value>
161 161 <value type="int">1</value>
162 162 <value type="int">2</value>
163 163 <value type="int">3</value>
164 164 <value type="int">4</value>
165 165 <value type="int">5</value>
166 166 <value type="int">6</value>
167 167 <value type="int">7</value>
168 168 <value type="int">8</value>
169 169 <value type="int">9</value>
170 170 <value type="int">10</value>
171 171 <value type="int">11</value>
172 172 <value type="int">12</value>
173 173 <value type="int">13</value>
174 174 <value type="int">14</value>
175 175 </valuelist>
176 176 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
177 177 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
178 178 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
179 179 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
180 180 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
181 181 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
182 182 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
183 183 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
184 184 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
185 185 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
186 186 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
187 187 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
188 188 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
189 189 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
190 190 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
191 191 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
192 192 </valuemap>
193 193 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
194 194 </valuemap>
195 195 </data>
196 196 <data>
197 197 <variable>ProjectExplorer.Project.TargetCount</variable>
198 198 <value type="int">1</value>
199 199 </data>
200 200 <data>
201 201 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
202 202 <value type="int">16</value>
203 203 </data>
204 204 <data>
205 205 <variable>Version</variable>
206 206 <value type="int">16</value>
207 207 </data>
208 208 </qtcreator>
@@ -1,574 +1,574
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_status_code spare_status;
146 146 rtems_id queue_id;
147 147 rtems_rate_monotonic_period_status period_status;
148 148
149 149 status = get_message_queue_id_send( &queue_id );
150 150 if (status != RTEMS_SUCCESSFUL)
151 151 {
152 152 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
153 153 }
154 154
155 155 BOOT_PRINTF("in HOUS ***\n")
156 156
157 157 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
158 158 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
159 159 if( status != RTEMS_SUCCESSFUL ) {
160 160 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
161 161 }
162 162 }
163 163
164 164 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
165 165 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
166 166 housekeeping_packet.reserved = DEFAULT_RESERVED;
167 167 housekeeping_packet.userApplication = CCSDS_USER_APP;
168 168 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
169 169 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
170 170 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
171 171 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
172 172 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
173 173 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
174 174 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
175 175 housekeeping_packet.serviceType = TM_TYPE_HK;
176 176 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
177 177 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
178 178 housekeeping_packet.sid = SID_HK;
179 179
180 180 status = rtems_rate_monotonic_cancel(HK_id);
181 181 if( status != RTEMS_SUCCESSFUL ) {
182 182 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
183 183 }
184 184 else {
185 185 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
186 186 }
187 187
188 188 // startup phase
189 189 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
190 190 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
191 191 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
192 192 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
193 193 {
194 194 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
195 195 {
196 196 break; // break if LFR is synchronized
197 197 }
198 198 else
199 199 {
200 200 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
201 201 // sched_yield();
202 202 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
203 203 }
204 204 }
205 205 status = rtems_rate_monotonic_cancel(HK_id);
206 206 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
207 207
208 208 while(1){ // launch the rate monotonic task
209 209 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
210 210 if ( status != RTEMS_SUCCESSFUL ) {
211 211 PRINTF1( "in HOUS *** ERR period: %d\n", status);
212 212 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
213 213 }
214 214 else {
215 215 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
216 216 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
217 217 increment_seq_counter( &sequenceCounterHK );
218 218
219 219 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
220 220 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
221 221 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
222 222 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
223 223 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
224 224 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
225 225
226 226 spacewire_update_statistics();
227 227
228 228 // get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
229 229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230 230
231 231 // SEND PACKET
232 232 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
233 233 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
234 234 if (status != RTEMS_SUCCESSFUL) {
235 235 PRINTF1("in HOUS *** ERR send: %d\n", status)
236 236 }
237 237 }
238 238 }
239 239
240 240 PRINTF("in HOUS *** deleting task\n")
241 241
242 242 status = rtems_task_delete( RTEMS_SELF ); // should not return
243 243 printf( "rtems_task_delete returned with status of %d.\n", status );
244 244 return;
245 245 }
246 246
247 247 rtems_task dumb_task( rtems_task_argument unused )
248 248 {
249 249 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
250 250 *
251 251 * @param unused is the starting argument of the RTEMS task
252 252 *
253 253 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
254 254 *
255 255 */
256 256
257 257 unsigned int i;
258 258 unsigned int intEventOut;
259 259 unsigned int coarse_time = 0;
260 260 unsigned int fine_time = 0;
261 261 rtems_event_set event_out;
262 262
263 263 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
264 264 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
265 265 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
266 266 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
267 267 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
268 268 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
269 "ERR HK", // RTEMS_EVENT_6
269 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
270 270 "ready for dump", // RTEMS_EVENT_7
271 271 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
272 272 "tick", // RTEMS_EVENT_9
273 273 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
274 274 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
275 275 };
276 276
277 277 BOOT_PRINTF("in DUMB *** \n")
278 278
279 279 while(1){
280 280 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
281 281 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
282 282 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
283 283 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
284 284 intEventOut = (unsigned int) event_out;
285 285 for ( i=0; i<32; i++)
286 286 {
287 287 if ( ((intEventOut >> i) & 0x0001) != 0)
288 288 {
289 289 coarse_time = time_management_regs->coarse_time;
290 290 fine_time = time_management_regs->fine_time;
291 291 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
292 292 if (i==8)
293 293 {
294 294 }
295 295 if (i==10)
296 296 {
297 297 }
298 298 }
299 299 }
300 300 }
301 301 }
302 302
303 303 //*****************************
304 304 // init housekeeping parameters
305 305
306 306 void init_housekeeping_parameters( void )
307 307 {
308 308 /** This function initialize the housekeeping_packet global variable with default values.
309 309 *
310 310 */
311 311
312 312 unsigned int i = 0;
313 313 unsigned char *parameters;
314 314
315 315 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
316 316 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
317 317 {
318 318 parameters[i] = 0x00;
319 319 }
320 320 // init status word
321 321 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
322 322 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
323 323 // init software version
324 324 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
325 325 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
326 326 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
327 327 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
328 328 // init fpga version
329 329 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
330 330 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
331 331 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
332 332 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
333 333 }
334 334
335 335 void increment_seq_counter( unsigned short *packetSequenceControl )
336 336 {
337 337 /** This function increment the sequence counter psased in argument.
338 338 *
339 339 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
340 340 *
341 341 */
342 342
343 343 unsigned short segmentation_grouping_flag;
344 344 unsigned short sequence_cnt;
345 345
346 346 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
347 347 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
348 348
349 349 if ( sequence_cnt < SEQ_CNT_MAX)
350 350 {
351 351 sequence_cnt = sequence_cnt + 1;
352 352 }
353 353 else
354 354 {
355 355 sequence_cnt = 0;
356 356 }
357 357
358 358 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
359 359 }
360 360
361 361 void getTime( unsigned char *time)
362 362 {
363 363 /** This function write the current local time in the time buffer passed in argument.
364 364 *
365 365 */
366 366
367 367 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
368 368 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
369 369 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
370 370 time[3] = (unsigned char) (time_management_regs->coarse_time);
371 371 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
372 372 time[5] = (unsigned char) (time_management_regs->fine_time);
373 373 }
374 374
375 375 unsigned long long int getTimeAsUnsignedLongLongInt( )
376 376 {
377 377 /** This function write the current local time in the time buffer passed in argument.
378 378 *
379 379 */
380 380 unsigned long long int time;
381 381
382 382 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
383 383 + time_management_regs->fine_time;
384 384
385 385 return time;
386 386 }
387 387
388 388 void send_dumb_hk( void )
389 389 {
390 390 Packet_TM_LFR_HK_t dummy_hk_packet;
391 391 unsigned char *parameters;
392 392 unsigned int i;
393 393 rtems_id queue_id;
394 394
395 395 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
396 396 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
397 397 dummy_hk_packet.reserved = DEFAULT_RESERVED;
398 398 dummy_hk_packet.userApplication = CCSDS_USER_APP;
399 399 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
400 400 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
401 401 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
402 402 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
403 403 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
404 404 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
405 405 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
406 406 dummy_hk_packet.serviceType = TM_TYPE_HK;
407 407 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
408 408 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
409 409 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
410 410 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
411 411 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
412 412 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
413 413 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
414 414 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
415 415 dummy_hk_packet.sid = SID_HK;
416 416
417 417 // init status word
418 418 dummy_hk_packet.lfr_status_word[0] = 0xff;
419 419 dummy_hk_packet.lfr_status_word[1] = 0xff;
420 420 // init software version
421 421 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
422 422 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
423 423 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
424 424 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
425 425 // init fpga version
426 426 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
427 427 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
428 428 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
429 429 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
430 430
431 431 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
432 432
433 433 for (i=0; i<100; i++)
434 434 {
435 435 parameters[i] = 0xff;
436 436 }
437 437
438 438 get_message_queue_id_send( &queue_id );
439 439
440 440 rtems_message_queue_send( queue_id, &dummy_hk_packet,
441 441 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
442 442 }
443 443
444 444 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
445 445 {
446 446 unsigned long long int localTime_asLong;
447 447 unsigned long long int f3_0_AcquisitionTime_asLong;
448 448 unsigned long long int f3_1_AcquisitionTime_asLong;
449 449 unsigned long long int deltaT;
450 450 unsigned long long int deltaT_f3_0;
451 451 unsigned long long int deltaT_f3_1;
452 452 unsigned char *bufferPtr;
453 453
454 454 unsigned int offset_in_samples;
455 455 unsigned int offset_in_bytes;
456 456 unsigned char f3;
457 457
458 458 bufferPtr = NULL;
459 459 deltaT = 0;
460 460 deltaT_f3_0 = 0xffffffff;
461 461 deltaT_f3_1 = 0xffffffff;
462 462 f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
463 463
464 464 if (lfrCurrentMode == LFR_MODE_STANDBY)
465 465 {
466 466 spacecraft_potential[0] = 0x00;
467 467 spacecraft_potential[1] = 0x00;
468 468 spacecraft_potential[2] = 0x00;
469 469 spacecraft_potential[3] = 0x00;
470 470 spacecraft_potential[4] = 0x00;
471 471 spacecraft_potential[5] = 0x00;
472 472 }
473 473 else
474 474 {
475 475 localTime_asLong = get_acquisition_time( (unsigned char *) &time_management_regs->coarse_time );
476 476 f3_0_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_0_coarse_time );
477 477 f3_1_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_1_coarse_time );
478 478 printf("localTime 0x%llx, f3_0 0x%llx, f3_1 0x%llx\n",
479 479 localTime_asLong,
480 480 f3_0_AcquisitionTime_asLong,
481 481 f3_1_AcquisitionTime_asLong);
482 482
483 483 if ( localTime_asLong >= f3_0_AcquisitionTime_asLong )
484 484 {
485 485 deltaT_f3_0 = localTime_asLong - f3_0_AcquisitionTime_asLong;
486 486 }
487 487
488 488 if ( localTime_asLong > f3_1_AcquisitionTime_asLong )
489 489 {
490 490 deltaT_f3_1 = localTime_asLong - f3_1_AcquisitionTime_asLong;
491 491 }
492 492
493 493 if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
494 494 {
495 495 if ( deltaT_f3_0 > deltaT_f3_1 )
496 496 {
497 497 deltaT = deltaT_f3_1;
498 498 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
499 499 }
500 500 else
501 501 {
502 502 deltaT = deltaT_f3_0;
503 503 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_0;
504 504 }
505 505 }
506 506 else if ( (deltaT_f3_0 == 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
507 507 {
508 508 deltaT = deltaT_f3_1;
509 509 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
510 510 }
511 511 else if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 == 0xffffffff) )
512 512 {
513 513 deltaT = deltaT_f3_0;
514 514 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
515 515 }
516 516 else
517 517 {
518 518 deltaT = 0xffffffff;
519 519 }
520 520
521 521 if ( deltaT == 0xffffffff )
522 522 {
523 523 spacecraft_potential[0] = 0x00;
524 524 spacecraft_potential[1] = 0x00;
525 525 spacecraft_potential[2] = 0x00;
526 526 spacecraft_potential[3] = 0x00;
527 527 spacecraft_potential[4] = 0x00;
528 528 spacecraft_potential[5] = 0x00;
529 529 }
530 530 else
531 531 {
532 532 offset_in_samples = ( (double) deltaT ) / 65536. * f3;
533 533 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
534 534 {
535 535 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
536 536 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT - 1;
537 537 }
538 538 offset_in_bytes = offset_in_samples * NB_WORDS_SWF_BLK * 4;
539 539 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
540 540 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
541 541 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
542 542 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
543 543 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
544 544 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
545 545 }
546 546 }
547 547 }
548 548
549 549 void get_cpu_load( unsigned char *resource_statistics )
550 550 {
551 551 unsigned char cpu_load;
552 552
553 553 cpu_load = lfr_rtems_cpu_usage_report();
554 554
555 555 // HK_LFR_CPU_LOAD
556 556 resource_statistics[0] = cpu_load;
557 557
558 558 // HK_LFR_CPU_LOAD_MAX
559 559 if (cpu_load > resource_statistics[1])
560 560 {
561 561 resource_statistics[1] = cpu_load;
562 562 }
563 563
564 564 // CPU_LOAD_AVE
565 565 resource_statistics[2] = 0;
566 566
567 567 #ifndef PRINT_TASK_STATISTICS
568 568 rtems_cpu_usage_reset();
569 569 #endif
570 570
571 571 }
572 572
573 573
574 574
@@ -1,519 +1,523
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include "fsw_processing.h"
11 11 #include "fsw_processing_globals.c"
12 12
13 13 unsigned int nb_sm_f0;
14 14 unsigned int nb_sm_f0_aux_f1;
15 15 unsigned int nb_sm_f1;
16 16 unsigned int nb_sm_f0_aux_f2;
17 17
18 18 //************************
19 19 // spectral matrices rings
20 20 ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 21 ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 22 ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 23 ring_node *current_ring_node_sm_f0;
24 24 ring_node *current_ring_node_sm_f1;
25 25 ring_node *current_ring_node_sm_f2;
26 26 ring_node *ring_node_for_averaging_sm_f0;
27 27 ring_node *ring_node_for_averaging_sm_f1;
28 28 ring_node *ring_node_for_averaging_sm_f2;
29 29
30 30 //***********************************************************
31 31 // Interrupt Service Routine for spectral matrices processing
32 32
33 33 void spectral_matrices_isr_f0( void )
34 34 {
35 35 unsigned char status;
36 36 unsigned long long int time_0;
37 37 unsigned long long int time_1;
38 38 unsigned long long int syncBit0;
39 39 unsigned long long int syncBit1;
40 40
41 41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
42 42
43 43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47 47
48 48 switch(status)
49 49 {
50 50 case 0:
51 51 break;
52 52 case 3:
53 // send a message if two buffers are ready
54 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
53 55 if ( time_0 < time_1 )
54 56 {
55 57 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
56 58 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
57 59 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
58 60 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
59 61 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
60 62 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
61 63 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
62 64 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
63 65 }
64 66 else
65 67 {
66 68 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
67 69 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
68 70 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
69 71 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
70 72 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
71 73 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
72 74 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
73 75 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
74 76 }
75 77 spectral_matrix_regs->status = 0x03; // [0011]
76 78 break;
77 79 case 1:
78 80 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
79 81 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
80 82 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
81 83 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
82 84 spectral_matrix_regs->status = 0x01; // [0001]
83 85 break;
84 86 case 2:
85 87 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
86 88 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
87 89 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
88 90 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
89 91 spectral_matrix_regs->status = 0x02; // [0010]
90 92 break;
91 93 }
92 94 }
93 95
94 96 void spectral_matrices_isr_f1( void )
95 97 {
96 98 unsigned char status;
97 99 unsigned long long int time;
98 100 unsigned long long int syncBit;
99 101 rtems_status_code status_code;
100 102
101 103 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
102 104
103 105 switch(status)
104 106 {
105 107 case 0:
106 108 break;
107 109 case 3:
108 110 // UNEXPECTED VALUE
109 111 spectral_matrix_regs->status = 0xc0; // [1100]
110 112 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
111 113 break;
112 114 case 1:
113 115 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
114 116 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
115 117 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
116 118 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
117 119 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
118 120 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
119 121 spectral_matrix_regs->status = 0x04; // [0100]
120 122 break;
121 123 case 2:
122 124 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
123 125 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
124 126 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
125 127 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
126 128 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
127 129 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
128 130 spectral_matrix_regs->status = 0x08; // [1000]
129 131 break;
130 132 }
131 133 }
132 134
133 135 void spectral_matrices_isr_f2( void )
134 136 {
135 137 unsigned char status;
136 138 rtems_status_code status_code;
137 139
138 140 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
139 141
140 142 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
141 143
142 144 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
143 145
144 146 switch(status)
145 147 {
146 148 case 0:
147 149 break;
148 150 case 3:
149 151 // UNEXPECTED VALUE
150 152 spectral_matrix_regs->status = 0x30; // [0011 0000]
151 153 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
152 154 break;
153 155 case 1:
154 156 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
155 157 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
156 158 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
157 159 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 160 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 161 {
160 162 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 163 }
162 164 break;
163 165 case 2:
164 166 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
165 167 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
166 168 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
167 169 spectral_matrix_regs->status = 0x20; // [0010 0000]
168 170 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
169 171 {
170 172 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
171 173 }
172 174 break;
173 175 }
174 176 }
175 177
176 178 void spectral_matrix_isr_error_handler( void )
177 179 {
178 rtems_status_code status_code;
180 // rtems_status_code status_code;
179 181
180 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
181 {
182 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
183 }
182 // if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
183 // {
184 // status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
185 // }
186
187 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
184 188 }
185 189
186 190 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
187 191 {
188 192 // STATUS REGISTER
189 193 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
190 194 // 10 9 8
191 195 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
192 196 // 7 6 5 4 3 2 1 0
193 197
194 198 spectral_matrices_isr_f0();
195 199
196 200 spectral_matrices_isr_f1();
197 201
198 202 spectral_matrices_isr_f2();
199 203
200 // spectral_matrix_isr_error_handler();
204 spectral_matrix_isr_error_handler();
201 205 }
202 206
203 207 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
204 208 {
205 209 rtems_status_code status_code;
206 210
207 211 //***
208 212 // F0
209 213 nb_sm_f0 = nb_sm_f0 + 1;
210 214 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
211 215 {
212 216 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
213 217 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
214 218 {
215 219 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
216 220 }
217 221 nb_sm_f0 = 0;
218 222 }
219 223
220 224 //***
221 225 // F1
222 226 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
223 227 if (nb_sm_f0_aux_f1 == 6)
224 228 {
225 229 nb_sm_f0_aux_f1 = 0;
226 230 nb_sm_f1 = nb_sm_f1 + 1;
227 231 }
228 232 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
229 233 {
230 234 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
231 235 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
232 236 {
233 237 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
234 238 }
235 239 nb_sm_f1 = 0;
236 240 }
237 241
238 242 //***
239 243 // F2
240 244 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
241 245 if (nb_sm_f0_aux_f2 == 96)
242 246 {
243 247 nb_sm_f0_aux_f2 = 0;
244 248 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
245 249 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
246 250 {
247 251 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
248 252 }
249 253 }
250 254 }
251 255
252 256 //******************
253 257 // Spectral Matrices
254 258
255 259 void reset_nb_sm( void )
256 260 {
257 261 nb_sm_f0 = 0;
258 262 nb_sm_f0_aux_f1 = 0;
259 263 nb_sm_f0_aux_f2 = 0;
260 264
261 265 nb_sm_f1 = 0;
262 266 }
263 267
264 268 void SM_init_rings( void )
265 269 {
266 270 init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
267 271 init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM );
268 272 init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM );
269 273
270 274 DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
271 275 DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
272 276 DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
273 277 DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
274 278 DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
275 279 DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
276 280 }
277 281
278 282 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
279 283 {
280 284 unsigned char i;
281 285
282 286 ring[ nbNodes - 1 ].next
283 287 = (ring_node_asm*) &ring[ 0 ];
284 288
285 289 for(i=0; i<nbNodes-1; i++)
286 290 {
287 291 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
288 292 }
289 293 }
290 294
291 295 void SM_reset_current_ring_nodes( void )
292 296 {
293 297 current_ring_node_sm_f0 = sm_ring_f0[0].next;
294 298 current_ring_node_sm_f1 = sm_ring_f1[0].next;
295 299 current_ring_node_sm_f2 = sm_ring_f2[0].next;
296 300
297 301 ring_node_for_averaging_sm_f0 = sm_ring_f0;
298 302 ring_node_for_averaging_sm_f1 = sm_ring_f1;
299 303 ring_node_for_averaging_sm_f2 = sm_ring_f2;
300 304 }
301 305
302 306 //*****************
303 307 // Basic Parameters
304 308
305 309 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
306 310 unsigned int apid, unsigned char sid,
307 311 unsigned int packetLength, unsigned char blkNr )
308 312 {
309 313 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
310 314 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
311 315 header->reserved = 0x00;
312 316 header->userApplication = CCSDS_USER_APP;
313 317 header->packetID[0] = (unsigned char) (apid >> 8);
314 318 header->packetID[1] = (unsigned char) (apid);
315 319 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
316 320 header->packetSequenceControl[1] = 0x00;
317 321 header->packetLength[0] = (unsigned char) (packetLength >> 8);
318 322 header->packetLength[1] = (unsigned char) (packetLength);
319 323 // DATA FIELD HEADER
320 324 header->spare1_pusVersion_spare2 = 0x10;
321 325 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
322 326 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
323 327 header->destinationID = TM_DESTINATION_ID_GROUND;
324 328 // AUXILIARY DATA HEADER
325 329 header->sid = sid;
326 330 header->biaStatusInfo = 0x00;
327 331 header->time[0] = 0x00;
328 332 header->time[0] = 0x00;
329 333 header->time[0] = 0x00;
330 334 header->time[0] = 0x00;
331 335 header->time[0] = 0x00;
332 336 header->time[0] = 0x00;
333 337 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
334 338 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
335 339 }
336 340
337 341 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
338 342 unsigned int apid, unsigned char sid,
339 343 unsigned int packetLength , unsigned char blkNr)
340 344 {
341 345 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
342 346 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
343 347 header->reserved = 0x00;
344 348 header->userApplication = CCSDS_USER_APP;
345 349 header->packetID[0] = (unsigned char) (apid >> 8);
346 350 header->packetID[1] = (unsigned char) (apid);
347 351 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
348 352 header->packetSequenceControl[1] = 0x00;
349 353 header->packetLength[0] = (unsigned char) (packetLength >> 8);
350 354 header->packetLength[1] = (unsigned char) (packetLength);
351 355 // DATA FIELD HEADER
352 356 header->spare1_pusVersion_spare2 = 0x10;
353 357 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
354 358 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
355 359 header->destinationID = TM_DESTINATION_ID_GROUND;
356 360 // AUXILIARY DATA HEADER
357 361 header->sid = sid;
358 362 header->biaStatusInfo = 0x00;
359 363 header->time[0] = 0x00;
360 364 header->time[0] = 0x00;
361 365 header->time[0] = 0x00;
362 366 header->time[0] = 0x00;
363 367 header->time[0] = 0x00;
364 368 header->time[0] = 0x00;
365 369 header->source_data_spare = 0x00;
366 370 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
367 371 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
368 372 }
369 373
370 374 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
371 375 {
372 376 rtems_status_code status;
373 377
374 378 // SET THE SEQUENCE_CNT PARAMETER
375 379 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
376 380 // SEND PACKET
377 381 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
378 382 if (status != RTEMS_SUCCESSFUL)
379 383 {
380 384 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
381 385 }
382 386 }
383 387
384 388 //******************
385 389 // general functions
386 390
387 391 void reset_sm_status( void )
388 392 {
389 393 // error
390 394 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
391 395 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
392 396 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
393 397 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
394 398
395 399 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
396 400 }
397 401
398 402 void reset_spectral_matrix_regs( void )
399 403 {
400 404 /** This function resets the spectral matrices module registers.
401 405 *
402 406 * The registers affected by this function are located at the following offset addresses:
403 407 *
404 408 * - 0x00 config
405 409 * - 0x04 status
406 410 * - 0x08 matrixF0_Address0
407 411 * - 0x10 matrixFO_Address1
408 412 * - 0x14 matrixF1_Address
409 413 * - 0x18 matrixF2_Address
410 414 *
411 415 */
412 416
413 417 set_sm_irq_onError( 0 );
414 418
415 419 set_sm_irq_onNewMatrix( 0 );
416 420
417 421 reset_sm_status();
418 422
419 423 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
420 424 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
421 425 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
422 426 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
423 427 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
424 428 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
425 429
426 430 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
427 431 }
428 432
429 433 void set_time( unsigned char *time, unsigned char * timeInBuffer )
430 434 {
431 435 time[0] = timeInBuffer[0];
432 436 time[1] = timeInBuffer[1];
433 437 time[2] = timeInBuffer[2];
434 438 time[3] = timeInBuffer[3];
435 439 time[4] = timeInBuffer[6];
436 440 time[5] = timeInBuffer[7];
437 441 }
438 442
439 443 unsigned long long int get_acquisition_time( unsigned char *timePtr )
440 444 {
441 445 unsigned long long int acquisitionTimeAslong;
442 446 acquisitionTimeAslong = 0x00;
443 447 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
444 448 + ( (unsigned long long int) timePtr[1] << 32 )
445 449 + ( (unsigned long long int) timePtr[2] << 24 )
446 450 + ( (unsigned long long int) timePtr[3] << 16 )
447 451 + ( (unsigned long long int) timePtr[6] << 8 )
448 452 + ( (unsigned long long int) timePtr[7] );
449 453 return acquisitionTimeAslong;
450 454 }
451 455
452 456 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
453 457 ring_node *node_for_averaging, ring_node *ringNode,
454 458 unsigned long long int time )
455 459 {
456 460 unsigned char *timePtr;
457 461 unsigned char *coarseTimePtr;
458 462 unsigned char *fineTimePtr;
459 463 rtems_status_code status_code;
460 464
461 465 timePtr = (unsigned char *) &time;
462 466 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
463 467 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
464 468
465 469 *nb_sm = *nb_sm + 1;
466 470 if (*nb_sm == nb_sm_before_avf)
467 471 {
468 472 node_for_averaging = ringNode;
469 473 coarseTimePtr[0] = timePtr[2];
470 474 coarseTimePtr[1] = timePtr[3];
471 475 coarseTimePtr[2] = timePtr[4];
472 476 coarseTimePtr[3] = timePtr[5];
473 477 fineTimePtr[2] = timePtr[6];
474 478 fineTimePtr[3] = timePtr[7];
475 479 if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
476 480 {
477 481 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
478 482 }
479 483 *nb_sm = 0;
480 484 }
481 485 }
482 486
483 487 unsigned char getSID( rtems_event_set event )
484 488 {
485 489 unsigned char sid;
486 490
487 491 rtems_event_set eventSetBURST;
488 492 rtems_event_set eventSetSBM;
489 493
490 494 //******
491 495 // BURST
492 496 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
493 497 | RTEMS_EVENT_BURST_BP1_F1
494 498 | RTEMS_EVENT_BURST_BP2_F0
495 499 | RTEMS_EVENT_BURST_BP2_F1;
496 500
497 501 //****
498 502 // SBM
499 503 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
500 504 | RTEMS_EVENT_SBM_BP1_F1
501 505 | RTEMS_EVENT_SBM_BP2_F0
502 506 | RTEMS_EVENT_SBM_BP2_F1;
503 507
504 508 if (event & eventSetBURST)
505 509 {
506 510 sid = SID_BURST_BP1_F0;
507 511 }
508 512 else if (event & eventSetSBM)
509 513 {
510 514 sid = SID_SBM1_BP1_F0;
511 515 }
512 516 else
513 517 {
514 518 sid = 0;
515 519 }
516 520
517 521 return sid;
518 522 }
519 523
@@ -1,1347 +1,1347
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 rings
14 14 // F0
15 15 ring_node waveform_ring_f0[NB_RING_NODES_F0];
16 16 ring_node *current_ring_node_f0;
17 17 ring_node *ring_node_to_send_swf_f0;
18 18 // F1
19 19 ring_node waveform_ring_f1[NB_RING_NODES_F1];
20 20 ring_node *current_ring_node_f1;
21 21 ring_node *ring_node_to_send_swf_f1;
22 22 ring_node *ring_node_to_send_cwf_f1;
23 23 // F2
24 24 ring_node waveform_ring_f2[NB_RING_NODES_F2];
25 25 ring_node *current_ring_node_f2;
26 26 ring_node *ring_node_to_send_swf_f2;
27 27 ring_node *ring_node_to_send_cwf_f2;
28 28 // F3
29 29 ring_node waveform_ring_f3[NB_RING_NODES_F3];
30 30 ring_node *current_ring_node_f3;
31 31 ring_node *ring_node_to_send_cwf_f3;
32 32
33 33 bool extractSWF = false;
34 34 bool swf_f0_ready = false;
35 35 bool swf_f1_ready = false;
36 36 bool swf_f2_ready = false;
37 37
38 38 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
39 39 ring_node ring_node_wf_snap_extracted;
40 40
41 41 //*********************
42 42 // Interrupt SubRoutine
43 43
44 44 void reset_extractSWF( void )
45 45 {
46 46 extractSWF = false;
47 47 swf_f0_ready = false;
48 48 swf_f1_ready = false;
49 49 swf_f2_ready = false;
50 50 }
51 51
52 52 inline void waveforms_isr_f3( void )
53 53 {
54 54 rtems_status_code spare_status;
55 55
56 56 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
57 57 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
58 58 { // in modes other than STANDBY and BURST, send the CWF_F3 data
59 59 //***
60 60 // F3
61 61 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
62 62 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
63 63 current_ring_node_f3 = current_ring_node_f3->next;
64 64 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
65 65 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
66 66 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
67 67 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
68 68 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
69 69 }
70 70 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
71 71 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
72 72 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
73 73 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
74 74 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
75 75 }
76 76 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
77 77 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
78 78 }
79 79 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
80 80 }
81 81 }
82 82 }
83 83
84 84 inline void waveforms_isr_normal( void )
85 85 {
86 86 rtems_status_code status;
87 87
88 88 if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits
89 89 && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits
90 90 && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
91 91 {
92 92 //***
93 93 // F0
94 94 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
95 95 current_ring_node_f0 = current_ring_node_f0->next;
96 96 if ( (waveform_picker_regs->status & 0x01) == 0x01)
97 97 {
98 98
99 99 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
100 100 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
101 101 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
102 102 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
103 103 }
104 104 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
105 105 {
106 106 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
107 107 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
108 108 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
109 109 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
110 110 }
111 111
112 112 //***
113 113 // F1
114 114 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
115 115 current_ring_node_f1 = current_ring_node_f1->next;
116 116 if ( (waveform_picker_regs->status & 0x04) == 0x04)
117 117 {
118 118 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
119 119 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
120 120 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
121 121 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
122 122 }
123 123 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
124 124 {
125 125 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
126 126 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
127 127 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
128 128 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
129 129 }
130 130
131 131 //***
132 132 // F2
133 133 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
134 134 current_ring_node_f2 = current_ring_node_f2->next;
135 135 if ( (waveform_picker_regs->status & 0x10) == 0x10)
136 136 {
137 137 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
138 138 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
139 139 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
140 140 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
141 141 }
142 142 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
143 143 {
144 144 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
145 145 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
146 146 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
147 147 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
148 148 }
149 149 //
150 150 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
151 151 if ( status != RTEMS_SUCCESSFUL)
152 152 {
153 153 status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
154 154 }
155 155 }
156 156 }
157 157
158 158 inline void waveforms_isr_burst( void )
159 159 {
160 160 rtems_status_code spare_status;
161 161
162 162 if ( (waveform_picker_regs->status & 0x30) != 0 ){ // [0100] check the f2 full bit
163 163 // (1) change the receiving buffer for the waveform picker
164 164 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
165 165 current_ring_node_f2 = current_ring_node_f2->next;
166 166 if ( (waveform_picker_regs->status & 0x10) == 0x10)
167 167 {
168 168 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
169 169 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
170 170 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
171 171 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
172 172 }
173 173 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
174 174 {
175 175 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
176 176 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
177 177 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
178 178 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
179 179 }
180 180 // (2) send an event for the waveforms transmission
181 181 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
182 182 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
183 183 }
184 184 }
185 185 }
186 186
187 187 inline void waveforms_isr_sbm1( void )
188 188 {
189 189 rtems_status_code status;
190 190
191 191 //***
192 192 // F1
193 193 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
194 194 // (1) change the receiving buffer for the waveform picker
195 195 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
196 196 current_ring_node_f1 = current_ring_node_f1->next;
197 197 if ( (waveform_picker_regs->status & 0x04) == 0x04)
198 198 {
199 199 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
200 200 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
201 201 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
202 202 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
203 203 }
204 204 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
205 205 {
206 206 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
207 207 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
208 208 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
209 209 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
210 210 }
211 211 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
212 212 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
213 213 }
214 214
215 215 //***
216 216 // F0
217 217 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits
218 218 swf_f0_ready = true;
219 219 // change f0 buffer
220 220 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
221 221 current_ring_node_f0 = current_ring_node_f0->next;
222 222 if ( (waveform_picker_regs->status & 0x01) == 0x01)
223 223 {
224 224
225 225 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
226 226 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
227 227 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
228 228 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
229 229 }
230 230 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
231 231 {
232 232 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
233 233 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
234 234 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
235 235 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
236 236 }
237 237 }
238 238
239 239 //***
240 240 // F2
241 241 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits
242 242 swf_f2_ready = true;
243 243 // change f2 buffer
244 244 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
245 245 current_ring_node_f2 = current_ring_node_f2->next;
246 246 if ( (waveform_picker_regs->status & 0x10) == 0x10)
247 247 {
248 248 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
249 249 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
250 250 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
251 251 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
252 252 }
253 253 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
254 254 {
255 255 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
256 256 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
257 257 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
258 258 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
259 259 }
260 260 }
261 261 }
262 262
263 263 inline void waveforms_isr_sbm2( void )
264 264 {
265 265 rtems_status_code status;
266 266
267 267 //***
268 268 // F2
269 269 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
270 270 // (1) change the receiving buffer for the waveform picker
271 271 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
272 272 current_ring_node_f2 = current_ring_node_f2->next;
273 273 if ( (waveform_picker_regs->status & 0x10) == 0x10)
274 274 {
275 275 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
276 276 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
277 277 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
278 278 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
279 279 }
280 280 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
281 281 {
282 282 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
283 283 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
284 284 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
285 285 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
286 286 }
287 287 // (2) send an event for the waveforms transmission
288 288 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
289 289 }
290 290
291 291 //***
292 292 // F0
293 293 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit
294 294 swf_f0_ready = true;
295 295 // change f0 buffer
296 296 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
297 297 current_ring_node_f0 = current_ring_node_f0->next;
298 298 if ( (waveform_picker_regs->status & 0x01) == 0x01)
299 299 {
300 300
301 301 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
302 302 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
303 303 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
304 304 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
305 305 }
306 306 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
307 307 {
308 308 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
309 309 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
310 310 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
311 311 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
312 312 }
313 313 }
314 314
315 315 //***
316 316 // F1
317 317 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit
318 318 swf_f1_ready = true;
319 319 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
320 320 current_ring_node_f1 = current_ring_node_f1->next;
321 321 if ( (waveform_picker_regs->status & 0x04) == 0x04)
322 322 {
323 323 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
324 324 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
325 325 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
326 326 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
327 327 }
328 328 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
329 329 {
330 330 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
331 331 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
332 332 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
333 333 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
334 334 }
335 335 }
336 336 }
337 337
338 338 rtems_isr waveforms_isr( rtems_vector_number vector )
339 339 {
340 340 /** This is the interrupt sub routine called by the waveform picker core.
341 341 *
342 342 * This ISR launch different actions depending mainly on two pieces of information:
343 343 * 1. the values read in the registers of the waveform picker.
344 344 * 2. the current LFR mode.
345 345 *
346 346 */
347 347
348 348 // STATUS
349 349 // new error error buffer full
350 350 // 15 14 13 12 11 10 9 8
351 351 // f3 f2 f1 f0 f3 f2 f1 f0
352 352 //
353 353 // ready buffer
354 354 // 7 6 5 4 3 2 1 0
355 355 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
356 356
357 357 rtems_status_code spare_status;
358 358
359 359 waveforms_isr_f3();
360 360
361 361 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
362 362 {
363 363 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
364 364 }
365 365
366 366 switch(lfrCurrentMode)
367 367 {
368 368 //********
369 369 // STANDBY
370 370 case(LFR_MODE_STANDBY):
371 371 break;
372 372
373 373 //******
374 374 // NORMAL
375 375 case(LFR_MODE_NORMAL):
376 376 waveforms_isr_normal();
377 377 break;
378 378
379 379 //******
380 380 // BURST
381 381 case(LFR_MODE_BURST):
382 382 waveforms_isr_burst();
383 383 break;
384 384
385 385 //*****
386 386 // SBM1
387 387 case(LFR_MODE_SBM1):
388 388 waveforms_isr_sbm1();
389 389 break;
390 390
391 391 //*****
392 392 // SBM2
393 393 case(LFR_MODE_SBM2):
394 394 waveforms_isr_sbm2();
395 395 break;
396 396
397 397 //********
398 398 // DEFAULT
399 399 default:
400 400 break;
401 401 }
402 402 }
403 403
404 404 //************
405 405 // RTEMS TASKS
406 406
407 407 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
408 408 {
409 409 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
410 410 *
411 411 * @param unused is the starting argument of the RTEMS task
412 412 *
413 413 * The following data packets are sent by this task:
414 414 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
415 415 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
416 416 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
417 417 *
418 418 */
419 419
420 420 rtems_event_set event_out;
421 421 rtems_id queue_id;
422 422 rtems_status_code status;
423 423 bool resynchronisationEngaged;
424 424 ring_node *ring_node_wf_snap_extracted_ptr;
425 425
426 426 ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted;
427 427
428 428 resynchronisationEngaged = false;
429 429
430 430 status = get_message_queue_id_send( &queue_id );
431 431 if (status != RTEMS_SUCCESSFUL)
432 432 {
433 433 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
434 434 }
435 435
436 436 BOOT_PRINTF("in WFRM ***\n")
437 437
438 438 while(1){
439 439 // wait for an RTEMS_EVENT
440 440 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
441 441 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
442 442 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
443 443 if(resynchronisationEngaged == false)
444 444 { // engage resynchronisation
445 snapshot_resynchronization( (unsigned char *) ring_node_to_send_swf_f0->coarseTime );
445 // snapshot_resynchronization( (unsigned char *) ring_node_to_send_swf_f0->coarseTime );
446 446 resynchronisationEngaged = true;
447 447 }
448 448 else
449 449 { // reset delta_snapshot to the nominal value
450 450 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
451 set_wfp_delta_snapshot();
451 // set_wfp_delta_snapshot();
452 452 resynchronisationEngaged = false;
453 453 }
454 454 //
455 455
456 456 if (event_out == RTEMS_EVENT_MODE_NORMAL)
457 457 {
458 458 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
459 459 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
460 460 ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1;
461 461 ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2;
462 462 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
463 463 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) );
464 464 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) );
465 465 }
466 466 if (event_out == RTEMS_EVENT_MODE_SBM1)
467 467 {
468 468 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
469 469 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
470 470 ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1;
471 471 ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2;
472 472 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
473 473 status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) );
474 474 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) );
475 475 }
476 476 if (event_out == RTEMS_EVENT_MODE_SBM2)
477 477 {
478 478 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
479 479 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
480 480 ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1;
481 481 ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2;
482 482 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
483 483 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) );
484 484 status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) );
485 485 }
486 486 }
487 487 }
488 488
489 489 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
490 490 {
491 491 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
492 492 *
493 493 * @param unused is the starting argument of the RTEMS task
494 494 *
495 495 * The following data packet is sent by this task:
496 496 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
497 497 *
498 498 */
499 499
500 500 rtems_event_set event_out;
501 501 rtems_id queue_id;
502 502 rtems_status_code status;
503 503 ring_node ring_node_cwf3_light;
504 504
505 505 status = get_message_queue_id_send( &queue_id );
506 506 if (status != RTEMS_SUCCESSFUL)
507 507 {
508 508 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
509 509 }
510 510
511 511 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
512 512
513 513 // init the ring_node_cwf3_light structure
514 514 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
515 515 ring_node_cwf3_light.coarseTime = 0x00;
516 516 ring_node_cwf3_light.fineTime = 0x00;
517 517 ring_node_cwf3_light.next = NULL;
518 518 ring_node_cwf3_light.previous = NULL;
519 519 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
520 520 ring_node_cwf3_light.status = 0x00;
521 521
522 522 BOOT_PRINTF("in CWF3 ***\n")
523 523
524 524 while(1){
525 525 // wait for an RTEMS_EVENT
526 526 rtems_event_receive( RTEMS_EVENT_0,
527 527 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
528 528 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
529 529 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
530 530 {
531 531 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
532 532 {
533 533 PRINTF("send CWF_LONG_F3\n")
534 534 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
535 535 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
536 536 }
537 537 else
538 538 {
539 539 PRINTF("send CWF_F3 (light)\n")
540 540 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_F3;
541 541 send_waveform_CWF3_light( ring_node_to_send_cwf_f3, &ring_node_cwf3_light, queue_id );
542 542 }
543 543
544 544 }
545 545 else
546 546 {
547 547 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
548 548 }
549 549 }
550 550 }
551 551
552 552 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
553 553 {
554 554 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
555 555 *
556 556 * @param unused is the starting argument of the RTEMS task
557 557 *
558 558 * The following data packet is sent by this function:
559 559 * - TM_LFR_SCIENCE_BURST_CWF_F2
560 560 * - TM_LFR_SCIENCE_SBM2_CWF_F2
561 561 *
562 562 */
563 563
564 564 rtems_event_set event_out;
565 565 rtems_id queue_id;
566 566 rtems_status_code status;
567 567
568 568 status = get_message_queue_id_send( &queue_id );
569 569 if (status != RTEMS_SUCCESSFUL)
570 570 {
571 571 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
572 572 }
573 573
574 574 BOOT_PRINTF("in CWF2 ***\n")
575 575
576 576 while(1){
577 577 // wait for an RTEMS_EVENT
578 578 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
579 579 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
580 580 if (event_out == RTEMS_EVENT_MODE_BURST)
581 581 {
582 582 // send_waveform_CWF( ring_node_to_send_cwf_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
583 583 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
584 584 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
585 585 }
586 586 if (event_out == RTEMS_EVENT_MODE_SBM2)
587 587 {
588 588 // send_waveform_CWF( ring_node_to_send_cwf_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
589 589 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
590 590 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
591 591 // launch snapshot extraction if needed
592 592 if (extractSWF == true)
593 593 {
594 594 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
595 595 // extract the snapshot
596 596 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
597 597 // send the snapshot when built
598 598 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
599 599 extractSWF = false;
600 600 }
601 601 if (swf_f0_ready && swf_f1_ready)
602 602 {
603 603 extractSWF = true;
604 604 swf_f0_ready = false;
605 605 swf_f1_ready = false;
606 606 }
607 607 }
608 608 }
609 609 }
610 610
611 611 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
612 612 {
613 613 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
614 614 *
615 615 * @param unused is the starting argument of the RTEMS task
616 616 *
617 617 * The following data packet is sent by this function:
618 618 * - TM_LFR_SCIENCE_SBM1_CWF_F1
619 619 *
620 620 */
621 621
622 622 rtems_event_set event_out;
623 623 rtems_id queue_id;
624 624 rtems_status_code status;
625 625
626 626 // init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
627 627
628 628 status = get_message_queue_id_send( &queue_id );
629 629 if (status != RTEMS_SUCCESSFUL)
630 630 {
631 631 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
632 632 }
633 633
634 634 BOOT_PRINTF("in CWF1 ***\n")
635 635
636 636 while(1){
637 637 // wait for an RTEMS_EVENT
638 638 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
639 639 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
640 640 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
641 641 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f1, sizeof( ring_node* ) );
642 642 // launch snapshot extraction if needed
643 643 if (extractSWF == true)
644 644 {
645 645 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
646 646 // launch the snapshot extraction
647 647 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
648 648 extractSWF = false;
649 649 }
650 650 if (swf_f0_ready == true)
651 651 {
652 652 extractSWF = true;
653 653 swf_f0_ready = false; // this step shall be executed only one time
654 654 }
655 655 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
656 656 {
657 657 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
658 658 swf_f1_ready = false;
659 659 swf_f2_ready = false;
660 660 }
661 661 }
662 662 }
663 663
664 664 rtems_task swbd_task(rtems_task_argument argument)
665 665 {
666 666 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
667 667 *
668 668 * @param unused is the starting argument of the RTEMS task
669 669 *
670 670 */
671 671
672 672 rtems_event_set event_out;
673 673
674 674 BOOT_PRINTF("in SWBD ***\n")
675 675
676 676 while(1){
677 677 // wait for an RTEMS_EVENT
678 678 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
679 679 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
680 680 if (event_out == RTEMS_EVENT_MODE_SBM1)
681 681 {
682 682 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
683 683 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
684 684 }
685 685 else
686 686 {
687 687 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
688 688 }
689 689 }
690 690 }
691 691
692 692 //******************
693 693 // general functions
694 694
695 695 void WFP_init_rings( void )
696 696 {
697 697 // F0 RING
698 698 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
699 699 // F1 RING
700 700 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
701 701 // F2 RING
702 702 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
703 703 // F3 RING
704 704 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER );
705 705
706 706 ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted;
707 707
708 708 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
709 709 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
710 710 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
711 711 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
712 712 DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0)
713 713 DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1)
714 714 DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2)
715 715 DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3)
716 716
717 717 }
718 718
719 719 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
720 720 {
721 721 unsigned char i;
722 722
723 723 //***************
724 724 // BUFFER ADDRESS
725 725 for(i=0; i<nbNodes; i++)
726 726 {
727 727 ring[i].coarseTime = 0x00;
728 728 ring[i].fineTime = 0x00;
729 729 ring[i].sid = 0x00;
730 730 ring[i].status = 0x00;
731 731 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
732 732 }
733 733
734 734 //*****
735 735 // NEXT
736 736 ring[nbNodes-1].next = (ring_node*) &ring[ 0 ];
737 737 for(i=0; i<nbNodes-1; i++)
738 738 {
739 739 ring[i].next = (ring_node*) &ring[ i + 1 ];
740 740 }
741 741
742 742 //*********
743 743 // PREVIOUS
744 744 ring[0].previous = (ring_node*) &ring[ nbNodes - 1 ];
745 745 for(i=1; i<nbNodes; i++)
746 746 {
747 747 ring[i].previous = (ring_node*) &ring[ i - 1 ];
748 748 }
749 749 }
750 750
751 751 void WFP_reset_current_ring_nodes( void )
752 752 {
753 753 current_ring_node_f0 = waveform_ring_f0;
754 754 ring_node_to_send_swf_f0 = waveform_ring_f0;
755 755
756 756 current_ring_node_f1 = waveform_ring_f1;
757 757 ring_node_to_send_cwf_f1 = waveform_ring_f1;
758 758 ring_node_to_send_swf_f1 = waveform_ring_f1;
759 759
760 760 current_ring_node_f2 = waveform_ring_f2;
761 761 ring_node_to_send_cwf_f2 = waveform_ring_f2;
762 762 ring_node_to_send_swf_f2 = waveform_ring_f2;
763 763
764 764 current_ring_node_f3 = waveform_ring_f3;
765 765 ring_node_to_send_cwf_f3 = waveform_ring_f3;
766 766 }
767 767
768 768 int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id )
769 769 {
770 770 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
771 771 *
772 772 * @param waveform points to the buffer containing the data that will be send.
773 773 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
774 774 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
775 775 * contain information to setup the transmission of the data packets.
776 776 *
777 777 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
778 778 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
779 779 *
780 780 */
781 781
782 782 unsigned int i;
783 783 int ret;
784 784 rtems_status_code status;
785 785 spw_ioctl_pkt_send spw_ioctl_send_CWF;
786 786 char *sample;
787 787 int *dataPtr;
788 788
789 789 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
790 790 spw_ioctl_send_CWF.options = 0;
791 791
792 792 ret = LFR_DEFAULT;
793 793
794 794 dataPtr = (int*) ring_node_to_send->buffer_address;
795 795
796 796 ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime;
797 797 ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime;
798 798
799 799 //**********************
800 800 // BUILD CWF3_light DATA
801 801 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
802 802 {
803 803 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
804 804 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
805 805 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
806 806 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
807 807 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
808 808 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
809 809 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
810 810 }
811 811
812 812 // SEND PACKET
813 813 status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) );
814 814 if (status != RTEMS_SUCCESSFUL) {
815 815 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
816 816 ret = LFR_DEFAULT;
817 817 }
818 818
819 819 return ret;
820 820 }
821 821
822 822 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
823 823 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
824 824 {
825 825 unsigned long long int acquisitionTimeAsLong;
826 826 unsigned char localAcquisitionTime[6];
827 827 double deltaT;
828 828
829 829 deltaT = 0.;
830 830
831 831 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
832 832 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
833 833 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
834 834 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
835 835 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
836 836 localAcquisitionTime[5] = (unsigned char) ( fineTime );
837 837
838 838 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
839 839 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
840 840 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
841 841 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
842 842 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
843 843 + ( (unsigned long long int) localAcquisitionTime[5] );
844 844
845 845 switch( sid )
846 846 {
847 847 case SID_NORM_SWF_F0:
848 848 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
849 849 break;
850 850
851 851 case SID_NORM_SWF_F1:
852 852 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
853 853 break;
854 854
855 855 case SID_NORM_SWF_F2:
856 856 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
857 857 break;
858 858
859 859 case SID_SBM1_CWF_F1:
860 860 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
861 861 break;
862 862
863 863 case SID_SBM2_CWF_F2:
864 864 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
865 865 break;
866 866
867 867 case SID_BURST_CWF_F2:
868 868 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
869 869 break;
870 870
871 871 case SID_NORM_CWF_F3:
872 872 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
873 873 break;
874 874
875 875 case SID_NORM_CWF_LONG_F3:
876 876 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
877 877 break;
878 878
879 879 default:
880 880 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid)
881 881 deltaT = 0.;
882 882 break;
883 883 }
884 884
885 885 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
886 886 //
887 887 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
888 888 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
889 889 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
890 890 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
891 891 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
892 892 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
893 893
894 894 }
895 895
896 896 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
897 897 {
898 898 unsigned int i;
899 899 unsigned long long int centerTime_asLong;
900 900 unsigned long long int acquisitionTimeF0_asLong;
901 901 unsigned long long int acquisitionTime_asLong;
902 902 unsigned long long int bufferAcquisitionTime_asLong;
903 903 unsigned char *ptr1;
904 904 unsigned char *ptr2;
905 905 unsigned char *timeCharPtr;
906 906 unsigned char nb_ring_nodes;
907 907 unsigned long long int frequency_asLong;
908 908 unsigned long long int nbTicksPerSample_asLong;
909 909 unsigned long long int nbSamplesPart1_asLong;
910 910 unsigned long long int sampleOffset_asLong;
911 911
912 912 unsigned int deltaT_F0;
913 913 unsigned int deltaT_F1;
914 914 unsigned long long int deltaT_F2;
915 915
916 916 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
917 917 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
918 918 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
919 919 sampleOffset_asLong = 0x00;
920 920
921 921 // (1) get the f0 acquisition time
922 922 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
923 923
924 924 // (2) compute the central reference time
925 925 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
926 926
927 927 // (3) compute the acquisition time of the current snapshot
928 928 switch(frequencyChannel)
929 929 {
930 930 case 1: // 1 is for F1 = 4096 Hz
931 931 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
932 932 nb_ring_nodes = NB_RING_NODES_F1;
933 933 frequency_asLong = 4096;
934 934 nbTicksPerSample_asLong = 16; // 65536 / 4096;
935 935 break;
936 936 case 2: // 2 is for F2 = 256 Hz
937 937 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
938 938 nb_ring_nodes = NB_RING_NODES_F2;
939 939 frequency_asLong = 256;
940 940 nbTicksPerSample_asLong = 256; // 65536 / 256;
941 941 break;
942 942 default:
943 943 acquisitionTime_asLong = centerTime_asLong;
944 944 frequency_asLong = 256;
945 945 nbTicksPerSample_asLong = 256;
946 946 break;
947 947 }
948 948
949 949 //****************************************************************************
950 950 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
951 951 for (i=0; i<nb_ring_nodes; i++)
952 952 {
953 953 PRINTF1("%d ... ", i)
954 954 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) ring_node_to_send->coarseTime );
955 955 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
956 956 {
957 957 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
958 958 break;
959 959 }
960 960 ring_node_to_send = ring_node_to_send->previous;
961 961 }
962 962
963 963 // (5) compute the number of samples to take in the current buffer
964 964 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
965 965 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
966 966 PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong)
967 967
968 968 // (6) compute the final acquisition time
969 969 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
970 970 sampleOffset_asLong * nbTicksPerSample_asLong;
971 971
972 972 // (7) copy the acquisition time at the beginning of the extrated snapshot
973 973 ptr1 = (unsigned char*) &acquisitionTime_asLong;
974 974 // fine time
975 975 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime;
976 976 ptr2[2] = ptr1[ 4 + 2 ];
977 977 ptr2[3] = ptr1[ 5 + 2 ];
978 978 // coarse time
979 979 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime;
980 980 ptr2[0] = ptr1[ 0 + 2 ];
981 981 ptr2[1] = ptr1[ 1 + 2 ];
982 982 ptr2[2] = ptr1[ 2 + 2 ];
983 983 ptr2[3] = ptr1[ 3 + 2 ];
984 984
985 985 // re set the synchronization bit
986 986 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
987 987 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
988 988
989 989 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
990 990 {
991 991 nbSamplesPart1_asLong = 0;
992 992 }
993 993 // copy the part 1 of the snapshot in the extracted buffer
994 994 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
995 995 {
996 996 wf_snap_extracted[i] =
997 997 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
998 998 }
999 999 // copy the part 2 of the snapshot in the extracted buffer
1000 1000 ring_node_to_send = ring_node_to_send->next;
1001 1001 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1002 1002 {
1003 1003 wf_snap_extracted[i] =
1004 1004 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
1005 1005 }
1006 1006 }
1007 1007
1008 1008 void snapshot_resynchronization( unsigned char *timePtr )
1009 1009 {
1010 1010 unsigned long long int acquisitionTime;
1011 1011 unsigned long long int centerTime;
1012 1012 unsigned long long int previousTick;
1013 1013 unsigned long long int nextTick;
1014 1014 unsigned long long int deltaPreviousTick;
1015 1015 unsigned long long int deltaNextTick;
1016 1016 unsigned int deltaTickInF2;
1017 1017 double deltaPrevious;
1018 1018 double deltaNext;
1019 1019
1020 1020 acquisitionTime = get_acquisition_time( timePtr );
1021 1021
1022 1022 // compute center time
1023 1023 centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1024 1024 previousTick = centerTime - (centerTime & 0xffff);
1025 1025 nextTick = previousTick + 65536;
1026 1026
1027 1027 deltaPreviousTick = centerTime - previousTick;
1028 1028 deltaNextTick = nextTick - centerTime;
1029 1029
1030 1030 deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.;
1031 1031 deltaNext = ((double) deltaNextTick) / 65536. * 1000.;
1032 1032
1033 1033 printf("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext);
1034 1034 printf("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick);
1035 1035
1036 1036 // which tick is the closest
1037 1037 if (deltaPreviousTick > deltaNextTick)
1038 1038 {
1039 1039 deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here
1040 1040 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
1041 1041 printf("correction of = + %u\n", deltaTickInF2);
1042 1042 }
1043 1043 else
1044 1044 {
1045 1045 deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here
1046 1046 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2;
1047 1047 printf("correction of = - %u\n", deltaTickInF2);
1048 1048 }
1049 1049 }
1050 1050
1051 1051 //**************
1052 1052 // wfp registers
1053 1053 void reset_wfp_burst_enable( void )
1054 1054 {
1055 1055 /** This function resets the waveform picker burst_enable register.
1056 1056 *
1057 1057 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1058 1058 *
1059 1059 */
1060 1060
1061 1061 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1062 1062 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80;
1063 1063 }
1064 1064
1065 1065 void reset_wfp_status( void )
1066 1066 {
1067 1067 /** This function resets the waveform picker status register.
1068 1068 *
1069 1069 * All status bits are set to 0 [new_err full_err full].
1070 1070 *
1071 1071 */
1072 1072
1073 1073 waveform_picker_regs->status = 0xffff;
1074 1074 }
1075 1075
1076 1076 void reset_wfp_buffer_addresses( void )
1077 1077 {
1078 1078 // F0
1079 1079 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; // 0x08
1080 1080 current_ring_node_f0 = current_ring_node_f0->next;
1081 1081 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1082 1082 // F1
1083 1083 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; // 0x10
1084 1084 current_ring_node_f1 = current_ring_node_f1->next;
1085 1085 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1086 1086 // F2
1087 1087 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; // 0x18
1088 1088 current_ring_node_f2 = current_ring_node_f2->next;
1089 1089 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1090 1090 // F3
1091 1091 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; // 0x20
1092 1092 current_ring_node_f3 = current_ring_node_f3->next;
1093 1093 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1094 1094 }
1095 1095
1096 1096 void reset_waveform_picker_regs( void )
1097 1097 {
1098 1098 /** This function resets the waveform picker module registers.
1099 1099 *
1100 1100 * The registers affected by this function are located at the following offset addresses:
1101 1101 * - 0x00 data_shaping
1102 1102 * - 0x04 run_burst_enable
1103 1103 * - 0x08 addr_data_f0
1104 1104 * - 0x0C addr_data_f1
1105 1105 * - 0x10 addr_data_f2
1106 1106 * - 0x14 addr_data_f3
1107 1107 * - 0x18 status
1108 1108 * - 0x1C delta_snapshot
1109 1109 * - 0x20 delta_f0
1110 1110 * - 0x24 delta_f0_2
1111 1111 * - 0x28 delta_f1
1112 1112 * - 0x2c delta_f2
1113 1113 * - 0x30 nb_data_by_buffer
1114 1114 * - 0x34 nb_snapshot_param
1115 1115 * - 0x38 start_date
1116 1116 * - 0x3c nb_word_in_buffer
1117 1117 *
1118 1118 */
1119 1119
1120 1120 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1121 1121
1122 1122 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1123 1123
1124 1124 reset_wfp_buffer_addresses();
1125 1125
1126 1126 reset_wfp_status(); // 0x18
1127 1127
1128 1128 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
1129 1129
1130 1130 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1131 1131
1132 1132 set_wfp_delta_f1(); // 0x28
1133 1133
1134 1134 set_wfp_delta_f2(); // 0x2c
1135 1135
1136 1136 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1137 1137 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1138 1138 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1139 1139 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1140 1140 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1141 1141 // 2688 = 8 * 336
1142 1142 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1143 1143 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1144 1144 waveform_picker_regs->start_date = 0x7fffffff; // 0x38
1145 1145 //
1146 1146 // coarse time and fine time registers are not initialized, they are volatile
1147 1147 //
1148 1148 waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1149 1149 }
1150 1150
1151 1151 void set_wfp_data_shaping( void )
1152 1152 {
1153 1153 /** This function sets the data_shaping register of the waveform picker module.
1154 1154 *
1155 1155 * The value is read from one field of the parameter_dump_packet structure:\n
1156 1156 * bw_sp0_sp1_r0_r1
1157 1157 *
1158 1158 */
1159 1159
1160 1160 unsigned char data_shaping;
1161 1161
1162 1162 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1163 1163 // waveform picker : [R1 R0 SP1 SP0 BW]
1164 1164
1165 1165 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1166 1166
1167 1167 waveform_picker_regs->data_shaping =
1168 1168 ( (data_shaping & 0x10) >> 4 ) // BW
1169 1169 + ( (data_shaping & 0x08) >> 2 ) // SP0
1170 1170 + ( (data_shaping & 0x04) ) // SP1
1171 1171 + ( (data_shaping & 0x02) << 2 ) // R0
1172 1172 + ( (data_shaping & 0x01) << 4 ); // R1
1173 1173 }
1174 1174
1175 1175 void set_wfp_burst_enable_register( unsigned char mode )
1176 1176 {
1177 1177 /** This function sets the waveform picker burst_enable register depending on the mode.
1178 1178 *
1179 1179 * @param mode is the LFR mode to launch.
1180 1180 *
1181 1181 * The burst bits shall be before the enable bits.
1182 1182 *
1183 1183 */
1184 1184
1185 1185 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1186 1186 // the burst bits shall be set first, before the enable bits
1187 1187 switch(mode) {
1188 1188 case(LFR_MODE_NORMAL):
1189 1189 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1190 1190 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1191 1191 break;
1192 1192 case(LFR_MODE_BURST):
1193 1193 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1194 1194 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1195 1195 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1196 1196 break;
1197 1197 case(LFR_MODE_SBM1):
1198 1198 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1199 1199 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1200 1200 break;
1201 1201 case(LFR_MODE_SBM2):
1202 1202 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1203 1203 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1204 1204 break;
1205 1205 default:
1206 1206 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1207 1207 break;
1208 1208 }
1209 1209 }
1210 1210
1211 1211 void set_wfp_delta_snapshot( void )
1212 1212 {
1213 1213 /** This function sets the delta_snapshot register of the waveform picker module.
1214 1214 *
1215 1215 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1216 1216 * - sy_lfr_n_swf_p[0]
1217 1217 * - sy_lfr_n_swf_p[1]
1218 1218 *
1219 1219 */
1220 1220
1221 1221 unsigned int delta_snapshot;
1222 1222 unsigned int delta_snapshot_in_T2;
1223 1223
1224 1224 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1225 1225 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1226 1226
1227 1227 delta_snapshot_in_T2 = delta_snapshot * 256;
1228 1228 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1229 1229 }
1230 1230
1231 1231 void set_wfp_delta_f0_f0_2( void )
1232 1232 {
1233 1233 unsigned int delta_snapshot;
1234 1234 unsigned int nb_samples_per_snapshot;
1235 1235 float delta_f0_in_float;
1236 1236
1237 1237 delta_snapshot = waveform_picker_regs->delta_snapshot;
1238 1238 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1239 1239 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1240 1240
1241 1241 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1242 1242 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1243 1243 }
1244 1244
1245 1245 void set_wfp_delta_f1( void )
1246 1246 {
1247 1247 unsigned int delta_snapshot;
1248 1248 unsigned int nb_samples_per_snapshot;
1249 1249 float delta_f1_in_float;
1250 1250
1251 1251 delta_snapshot = waveform_picker_regs->delta_snapshot;
1252 1252 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1253 1253 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1254 1254
1255 1255 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1256 1256 }
1257 1257
1258 1258 void set_wfp_delta_f2()
1259 1259 {
1260 1260 unsigned int delta_snapshot;
1261 1261 unsigned int nb_samples_per_snapshot;
1262 1262
1263 1263 delta_snapshot = waveform_picker_regs->delta_snapshot;
1264 1264 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1265 1265
1266 1266 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1267 1267 }
1268 1268
1269 1269 //*****************
1270 1270 // local parameters
1271 1271
1272 1272 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1273 1273 {
1274 1274 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1275 1275 *
1276 1276 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1277 1277 * @param sid is the source identifier of the packet being updated.
1278 1278 *
1279 1279 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1280 1280 * The sequence counters shall wrap around from 2^14 to zero.
1281 1281 * The sequence counter shall start at zero at startup.
1282 1282 *
1283 1283 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1284 1284 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1285 1285 *
1286 1286 */
1287 1287
1288 1288 unsigned short *sequence_cnt;
1289 1289 unsigned short segmentation_grouping_flag;
1290 1290 unsigned short new_packet_sequence_control;
1291 1291 rtems_mode initial_mode_set;
1292 1292 rtems_mode current_mode_set;
1293 1293 rtems_status_code status;
1294 1294
1295 1295 //******************************************
1296 1296 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1297 1297 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1298 1298
1299 1299 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1300 1300 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1301 1301 || (sid == SID_BURST_CWF_F2)
1302 1302 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1303 1303 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1304 1304 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1305 1305 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1306 1306 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1307 1307 {
1308 1308 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1309 1309 }
1310 1310 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1311 1311 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1312 1312 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1313 1313 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1314 1314 {
1315 1315 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1316 1316 }
1317 1317 else
1318 1318 {
1319 1319 sequence_cnt = (unsigned short *) NULL;
1320 1320 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1321 1321 }
1322 1322
1323 1323 if (sequence_cnt != NULL)
1324 1324 {
1325 1325 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1326 1326 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1327 1327
1328 1328 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1329 1329
1330 1330 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1331 1331 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1332 1332
1333 1333 // increment the sequence counter
1334 1334 if ( *sequence_cnt < SEQ_CNT_MAX)
1335 1335 {
1336 1336 *sequence_cnt = *sequence_cnt + 1;
1337 1337 }
1338 1338 else
1339 1339 {
1340 1340 *sequence_cnt = 0;
1341 1341 }
1342 1342 }
1343 1343
1344 1344 //***********************************
1345 1345 // RESET THE MODE OF THE CALLING TASK
1346 1346 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1347 1347 }
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
This diff has been collapsed as it changes many lines, (670 lines changed) Show them Hide them
1 NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now