##// END OF EJS Templates
Rev 1.0.0.6
paul -
r128:66da3a6b53f0 VHDLib206
parent child
Show More
@@ -1,1 +1,1
1 294fc10efc0eadddaba53149ef6dd1e60a0587c6 src/basic_parameters
1 b0a4fa20a3c7bd7e9ca1a1c4fda85d3269653bc8 src/basic_parameters
@@ -1,268 +1,268
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Apr 29 14:02:09 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri May 2 15:40:46 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 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -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/basic_parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_misc.c \
49 49 ../src/fsw_init.c \
50 50 ../src/fsw_globals.c \
51 51 ../src/fsw_spacewire.c \
52 52 ../src/tc_load_dump_parameters.c \
53 53 ../src/tm_lfr_tc_exe.c \
54 54 ../src/tc_acceptance.c \
55 55 ../src/basic_parameters/basic_parameters.c \
56 56 ../src/processing/fsw_processing.c \
57 57 ../src/processing/avf0_prc0.c \
58 58 ../src/processing/avf1_prc1.c \
59 59 ../src/processing/avf2_prc2.c
60 60 OBJECTS = obj/wf_handler.o \
61 61 obj/tc_handler.o \
62 62 obj/fsw_misc.o \
63 63 obj/fsw_init.o \
64 64 obj/fsw_globals.o \
65 65 obj/fsw_spacewire.o \
66 66 obj/tc_load_dump_parameters.o \
67 67 obj/tm_lfr_tc_exe.o \
68 68 obj/tc_acceptance.o \
69 69 obj/basic_parameters.o \
70 70 obj/fsw_processing.o \
71 71 obj/avf0_prc0.o \
72 72 obj/avf1_prc1.o \
73 73 obj/avf2_prc2.o
74 74 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
75 75 /usr/lib64/qt4/mkspecs/common/linux.conf \
76 76 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
77 77 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
78 78 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/qconfig.pri \
81 81 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
82 82 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
83 83 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
84 84 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
85 85 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
86 86 sparc.pri \
87 87 /usr/lib64/qt4/mkspecs/features/release.prf \
88 88 /usr/lib64/qt4/mkspecs/features/default_post.prf \
89 89 /usr/lib64/qt4/mkspecs/features/shared.prf \
90 90 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
91 91 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
92 92 /usr/lib64/qt4/mkspecs/features/resources.prf \
93 93 /usr/lib64/qt4/mkspecs/features/uic.prf \
94 94 /usr/lib64/qt4/mkspecs/features/yacc.prf \
95 95 /usr/lib64/qt4/mkspecs/features/lex.prf \
96 96 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
97 97 fsw-qt.pro
98 98 QMAKE_TARGET = fsw
99 99 DESTDIR = bin/
100 100 TARGET = bin/fsw
101 101
102 102 first: all
103 103 ####### Implicit rules
104 104
105 105 .SUFFIXES: .o .c .cpp .cc .cxx .C
106 106
107 107 .cpp.o:
108 108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
109 109
110 110 .cc.o:
111 111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112 112
113 113 .cxx.o:
114 114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
115 115
116 116 .C.o:
117 117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
118 118
119 119 .c.o:
120 120 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
121 121
122 122 ####### Build rules
123 123
124 124 all: Makefile $(TARGET)
125 125
126 126 $(TARGET): $(OBJECTS)
127 127 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
128 128 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
129 129
130 130 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
131 131 /usr/lib64/qt4/mkspecs/common/linux.conf \
132 132 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
133 133 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
134 134 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/qconfig.pri \
137 137 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
138 138 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
139 139 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
140 140 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
141 141 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
142 142 sparc.pri \
143 143 /usr/lib64/qt4/mkspecs/features/release.prf \
144 144 /usr/lib64/qt4/mkspecs/features/default_post.prf \
145 145 /usr/lib64/qt4/mkspecs/features/shared.prf \
146 146 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
147 147 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
148 148 /usr/lib64/qt4/mkspecs/features/resources.prf \
149 149 /usr/lib64/qt4/mkspecs/features/uic.prf \
150 150 /usr/lib64/qt4/mkspecs/features/yacc.prf \
151 151 /usr/lib64/qt4/mkspecs/features/lex.prf \
152 152 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
153 153 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
154 154 /usr/lib64/qt4/mkspecs/common/unix.conf:
155 155 /usr/lib64/qt4/mkspecs/common/linux.conf:
156 156 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
157 157 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
158 158 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/qconfig.pri:
161 161 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
162 162 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
163 163 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
164 164 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
165 165 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
166 166 sparc.pri:
167 167 /usr/lib64/qt4/mkspecs/features/release.prf:
168 168 /usr/lib64/qt4/mkspecs/features/default_post.prf:
169 169 /usr/lib64/qt4/mkspecs/features/shared.prf:
170 170 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
171 171 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
172 172 /usr/lib64/qt4/mkspecs/features/resources.prf:
173 173 /usr/lib64/qt4/mkspecs/features/uic.prf:
174 174 /usr/lib64/qt4/mkspecs/features/yacc.prf:
175 175 /usr/lib64/qt4/mkspecs/features/lex.prf:
176 176 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
177 177 qmake: FORCE
178 178 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
179 179
180 180 dist:
181 181 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
182 182 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
183 183
184 184
185 185 clean:compiler_clean
186 186 -$(DEL_FILE) $(OBJECTS)
187 187 -$(DEL_FILE) *~ core *.core
188 188
189 189
190 190 ####### Sub-libraries
191 191
192 192 distclean: clean
193 193 -$(DEL_FILE) $(TARGET)
194 194 -$(DEL_FILE) Makefile
195 195
196 196
197 197 grmon:
198 198 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
199 199
200 200 check: first
201 201
202 202 compiler_rcc_make_all:
203 203 compiler_rcc_clean:
204 204 compiler_uic_make_all:
205 205 compiler_uic_clean:
206 206 compiler_image_collection_make_all: qmake_image_collection.cpp
207 207 compiler_image_collection_clean:
208 208 -$(DEL_FILE) qmake_image_collection.cpp
209 209 compiler_yacc_decl_make_all:
210 210 compiler_yacc_decl_clean:
211 211 compiler_yacc_impl_make_all:
212 212 compiler_yacc_impl_clean:
213 213 compiler_lex_make_all:
214 214 compiler_lex_clean:
215 215 compiler_clean:
216 216
217 217 ####### Compile
218 218
219 219 obj/wf_handler.o: ../src/wf_handler.c
220 220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
221 221
222 222 obj/tc_handler.o: ../src/tc_handler.c
223 223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
224 224
225 225 obj/fsw_misc.o: ../src/fsw_misc.c
226 226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
227 227
228 228 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
229 229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
230 230
231 231 obj/fsw_globals.o: ../src/fsw_globals.c
232 232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
233 233
234 234 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
235 235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
236 236
237 237 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
238 238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
239 239
240 240 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
241 241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
242 242
243 243 obj/tc_acceptance.o: ../src/tc_acceptance.c
244 244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
245 245
246 246 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
247 247 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
248 248
249 249 obj/fsw_processing.o: ../src/processing/fsw_processing.c
250 250 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
251 251
252 252 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
253 253 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
254 254
255 255 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
256 256 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
257 257
258 258 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
259 259 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
260 260
261 261 ####### Install
262 262
263 263 install: FORCE
264 264
265 265 uninstall: FORCE
266 266
267 267 FORCE:
268 268
@@ -1,91 +1,91
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose cpu_usage_report
4 CONFIG += console verbose
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-1-0
11 11 DEFINES += SW_VERSION_N1=1 # major
12 12 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 14 DEFINES += SW_VERSION_N4=6 # internal
15 15
16 16 contains( CONFIG, debug_tch ) {
17 17 DEFINES += DEBUG_TCH
18 18 }
19 19
20 20 contains( CONFIG, vhdl_dev ) {
21 21 DEFINES += VHDL_DEV
22 22 }
23 23
24 24 contains( CONFIG, verbose ) {
25 25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 26 }
27 27
28 28 contains( CONFIG, debug_messages ) {
29 29 DEFINES += DEBUG_MESSAGES
30 30 }
31 31
32 32 contains( CONFIG, cpu_usage_report ) {
33 33 DEFINES += PRINT_TASK_STATISTICS
34 34 }
35 35
36 36 contains( CONFIG, stack_report ) {
37 37 DEFINES += PRINT_STACK_REPORT
38 38 }
39 39
40 40 contains( CONFIG, boot_messages ) {
41 41 DEFINES += BOOT_MESSAGES
42 42 }
43 43
44 44 #doxygen.target = doxygen
45 45 #doxygen.commands = doxygen ../doc/Doxyfile
46 46 #QMAKE_EXTRA_TARGETS += doxygen
47 47
48 48 TARGET = fsw
49 49
50 50 INCLUDEPATH += \
51 51 ../src \
52 52 ../header \
53 53 ../header/processing \
54 54 ../src/basic_parameters
55 55
56 56 SOURCES += \
57 57 ../src/wf_handler.c \
58 58 ../src/tc_handler.c \
59 59 ../src/fsw_misc.c \
60 60 ../src/fsw_init.c \
61 61 ../src/fsw_globals.c \
62 62 ../src/fsw_spacewire.c \
63 63 ../src/tc_load_dump_parameters.c \
64 64 ../src/tm_lfr_tc_exe.c \
65 65 ../src/tc_acceptance.c \
66 66 ../src/basic_parameters/basic_parameters.c \
67 67 ../src/processing/fsw_processing.c \
68 68 ../src/processing/avf0_prc0.c \
69 69 ../src/processing/avf1_prc1.c \
70 70 ../src/processing/avf2_prc2.c
71 71
72 72 HEADERS += \
73 73 ../header/wf_handler.h \
74 74 ../header/tc_handler.h \
75 75 ../header/grlib_regs.h \
76 76 ../header/fsw_params.h \
77 77 ../header/fsw_misc.h \
78 78 ../header/fsw_init.h \
79 79 ../header/ccsds_types.h \
80 80 ../header/fsw_spacewire.h \
81 81 ../header/tc_load_dump_parameters.h \
82 82 ../header/tm_lfr_tc_exe.h \
83 83 ../header/tc_acceptance.h \
84 84 ../header/fsw_params_nb_bytes.h \
85 85 ../src/basic_parameters/basic_parameters.h \
86 86 ../header/fsw_params_processing.h \
87 87 ../header/processing/fsw_processing.h \
88 88 ../header/processing/avf0_prc0.h \
89 89 ../header/processing/avf1_prc1.h \
90 90 ../header/processing/avf2_prc2.h
91 91
@@ -1,201 +1,201
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-29T15:43:03. -->
3 <!-- Written by QtCreator 3.0.1, 2014-05-02T15:40:56. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 118 </valuemap>
119 119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 126 </valuemap>
127 127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 131 </valuemap>
132 132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 153 <value type="int">0</value>
154 154 <value type="int">1</value>
155 155 <value type="int">2</value>
156 156 <value type="int">3</value>
157 157 <value type="int">4</value>
158 158 <value type="int">5</value>
159 159 <value type="int">6</value>
160 160 <value type="int">7</value>
161 161 <value type="int">8</value>
162 162 <value type="int">9</value>
163 163 <value type="int">10</value>
164 164 <value type="int">11</value>
165 165 <value type="int">12</value>
166 166 <value type="int">13</value>
167 167 <value type="int">14</value>
168 168 </valuelist>
169 169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
181 181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
182 182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 187 </valuemap>
188 188 </data>
189 189 <data>
190 190 <variable>ProjectExplorer.Project.TargetCount</variable>
191 191 <value type="int">1</value>
192 192 </data>
193 193 <data>
194 194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
195 195 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
196 196 </data>
197 197 <data>
198 198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
199 199 <value type="int">15</value>
200 200 </data>
201 201 </qtcreator>
@@ -1,35 +1,36
1 1 #ifndef AVF0_PRC0_H_INCLUDED
2 2 #define AVF0_PRC0_H_INCLUDED
3 3
4 4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5 6
6 7 typedef struct {
7 8 unsigned int norm_bp1;
8 9 unsigned int norm_bp2;
9 10 unsigned int norm_asm;
10 11 unsigned int burst_sbm_bp1;
11 12 unsigned int burst_sbm_bp2;
12 13 unsigned int burst_bp1;
13 14 unsigned int burst_bp2;
14 15 unsigned int sbm1_bp1;
15 16 unsigned int sbm1_bp2;
16 17 unsigned int sbm2_bp1;
17 18 unsigned int sbm2_bp2;
18 19 } nb_sm_before_bp_asm_f0;
19 20
20 21 //************
21 22 // RTEMS TASKS
22 23 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
23 24 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
24 25
25 26 //**********
26 27 // FUNCTIONS
27 28
28 29 void reset_nb_sm_f0( unsigned char lfrMode );
29 30
30 31 //*******
31 32 // EXTERN
32 33 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
33 34 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
34 35
35 36 #endif // AVF0_PRC0_H_INCLUDED
@@ -1,433 +1,434
1 1 /** General usage functions and RTEMS tasks.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 */
7 7
8 8 #include "fsw_misc.h"
9 9
10 10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 12 {
13 13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 14 *
15 15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 18 * @param interrupt_level is the interrupt level that the timer drives.
19 19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 20 *
21 21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 22 *
23 23 */
24 24
25 25 rtems_status_code status;
26 26 rtems_isr_entry old_isr_handler;
27 27
28 28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29 29
30 30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 31 if (status!=RTEMS_SUCCESSFUL)
32 32 {
33 33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 34 }
35 35
36 36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
37 37 }
38 38
39 39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
40 40 {
41 41 /** This function starts a GPTIMER timer.
42 42 *
43 43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 45 *
46 46 */
47 47
48 48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 53 }
54 54
55 55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
56 56 {
57 57 /** This function stops a GPTIMER timer.
58 58 *
59 59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 61 *
62 62 */
63 63
64 64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 67 }
68 68
69 69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
70 70 {
71 71 /** This function sets the clock divider of a GPTIMER timer.
72 72 *
73 73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 76 *
77 77 */
78 78
79 79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 80 }
81 81
82 82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
83 83 {
84 84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
85 85
86 86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
87 87
88 88 return 0;
89 89 }
90 90
91 91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
92 92 {
93 93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
94 94
95 95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
96 96
97 97 return 0;
98 98 }
99 99
100 100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
101 101 {
102 102 /** This function sets the scaler reload register of the apbuart module
103 103 *
104 104 * @param regs is the address of the apbuart registers in memory
105 105 * @param value is the value that will be stored in the scaler register
106 106 *
107 107 * The value shall be set by the software to get data on the serial interface.
108 108 *
109 109 */
110 110
111 111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
112 112
113 113 apbuart_regs->scaler = value;
114 114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
115 115 }
116 116
117 117 //************
118 118 // RTEMS TASKS
119 119
120 120 rtems_task stat_task(rtems_task_argument argument)
121 121 {
122 122 int i;
123 123 int j;
124 124 i = 0;
125 125 j = 0;
126 126 BOOT_PRINTF("in STAT *** \n")
127 127 while(1){
128 128 rtems_task_wake_after(1000);
129 129 PRINTF1("%d\n", j)
130 130 if (i == CPU_USAGE_REPORT_PERIOD) {
131 131 // #ifdef PRINT_TASK_STATISTICS
132 132 // rtems_cpu_usage_report();
133 133 // rtems_cpu_usage_reset();
134 134 // #endif
135 135 i = 0;
136 136 }
137 137 else i++;
138 138 j++;
139 139 }
140 140 }
141 141
142 142 rtems_task hous_task(rtems_task_argument argument)
143 143 {
144 144 rtems_status_code status;
145 145 rtems_id queue_id;
146 146 rtems_rate_monotonic_period_status period_status;
147 147
148 148 status = get_message_queue_id_send( &queue_id );
149 149 if (status != RTEMS_SUCCESSFUL)
150 150 {
151 151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 152 }
153 153
154 154 BOOT_PRINTF("in HOUS ***\n")
155 155
156 156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 158 if( status != RTEMS_SUCCESSFUL ) {
159 159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
160 160 }
161 161 }
162 162
163 163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 174 housekeeping_packet.serviceType = TM_TYPE_HK;
175 175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 177 housekeeping_packet.sid = SID_HK;
178 178
179 179 status = rtems_rate_monotonic_cancel(HK_id);
180 180 if( status != RTEMS_SUCCESSFUL ) {
181 181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 182 }
183 183 else {
184 184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 185 }
186 186
187 187 // startup phase
188 188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 192 {
193 193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 194 {
195 195 break; // break if LFR is synchronized
196 196 }
197 197 else
198 198 {
199 199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 sched_yield();
200 // sched_yield();
201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
201 202 }
202 203 }
203 204 status = rtems_rate_monotonic_cancel(HK_id);
204 205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
205 206
206 207 while(1){ // launch the rate monotonic task
207 208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
208 209 if ( status != RTEMS_SUCCESSFUL ) {
209 210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
210 211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
211 212 }
212 213 else {
213 214 increment_seq_counter( housekeeping_packet.packetSequenceControl );
214 215 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
215 216 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
216 217 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
217 218 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
218 219 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
219 220 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
220 221
221 222 spacewire_update_statistics();
222 223
223 224 // SEND PACKET
224 225 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
225 226 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
226 227 if (status != RTEMS_SUCCESSFUL) {
227 228 PRINTF1("in HOUS *** ERR send: %d\n", status)
228 229 }
229 230 }
230 231 }
231 232
232 233 PRINTF("in HOUS *** deleting task\n")
233 234
234 235 status = rtems_task_delete( RTEMS_SELF ); // should not return
235 236 printf( "rtems_task_delete returned with status of %d.\n", status );
236 237 return;
237 238 }
238 239
239 240 rtems_task dumb_task( rtems_task_argument unused )
240 241 {
241 242 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
242 243 *
243 244 * @param unused is the starting argument of the RTEMS task
244 245 *
245 246 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
246 247 *
247 248 */
248 249
249 250 unsigned int i;
250 251 unsigned int intEventOut;
251 252 unsigned int coarse_time = 0;
252 253 unsigned int fine_time = 0;
253 254 rtems_event_set event_out;
254 255
255 256 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
256 257 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
257 258 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
258 259 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
259 260 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
260 261 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
261 262 "ERR HK", // RTEMS_EVENT_6
262 263 "ready for dump", // RTEMS_EVENT_7
263 264 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
264 265 "tick" // RTEMS_EVENT_9
265 266 };
266 267
267 268 BOOT_PRINTF("in DUMB *** \n")
268 269
269 270 while(1){
270 271 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
271 272 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
272 273 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
273 274 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
274 275 intEventOut = (unsigned int) event_out;
275 276 for ( i=0; i<32; i++)
276 277 {
277 278 if ( ((intEventOut >> i) & 0x0001) != 0)
278 279 {
279 280 coarse_time = time_management_regs->coarse_time;
280 281 fine_time = time_management_regs->fine_time;
281 282 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
282 283 }
283 284 }
284 285 }
285 286 }
286 287
287 288 //*****************************
288 289 // init housekeeping parameters
289 290
290 291 void init_housekeeping_parameters( void )
291 292 {
292 293 /** This function initialize the housekeeping_packet global variable with default values.
293 294 *
294 295 */
295 296
296 297 unsigned int i = 0;
297 298 unsigned char *parameters;
298 299
299 300 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
300 301 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
301 302 {
302 303 parameters[i] = 0x00;
303 304 }
304 305 // init status word
305 306 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
306 307 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
307 308 // init software version
308 309 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
309 310 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
310 311 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
311 312 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
312 313 // init fpga version
313 314 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
314 315 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
315 316 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
316 317 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
317 318 }
318 319
319 320 void increment_seq_counter( unsigned char *packet_sequence_control)
320 321 {
321 322 /** This function increment the sequence counter psased in argument.
322 323 *
323 324 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
324 325 *
325 326 */
326 327
327 328 unsigned short sequence_cnt;
328 329 unsigned short segmentation_grouping_flag;
329 330 unsigned short new_packet_sequence_control;
330 331
331 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
332 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
332 333 sequence_cnt = (unsigned short) (
333 334 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
334 335 + packet_sequence_control[1]
335 336 );
336 337
337 338 if ( sequence_cnt < SEQ_CNT_MAX)
338 339 {
339 340 sequence_cnt = sequence_cnt + 1;
340 341 }
341 342 else
342 343 {
343 344 sequence_cnt = 0;
344 345 }
345 346
346 347 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
347 348
348 349 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
349 350 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
350 351 }
351 352
352 353 void getTime( unsigned char *time)
353 354 {
354 355 /** This function write the current local time in the time buffer passed in argument.
355 356 *
356 357 */
357 358
358 359 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
359 360 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
360 361 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
361 362 time[3] = (unsigned char) (time_management_regs->coarse_time);
362 363 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
363 364 time[5] = (unsigned char) (time_management_regs->fine_time);
364 365 }
365 366
366 367 unsigned long long int getTimeAsUnsignedLongLongInt( )
367 368 {
368 369 /** This function write the current local time in the time buffer passed in argument.
369 370 *
370 371 */
371 372 unsigned long long int time;
372 373
373 374 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
374 375 + time_management_regs->fine_time;
375 376
376 377 return time;
377 378 }
378 379
379 380 void send_dumb_hk( void )
380 381 {
381 382 Packet_TM_LFR_HK_t dummy_hk_packet;
382 383 unsigned char *parameters;
383 384 unsigned int i;
384 385 rtems_id queue_id;
385 386
386 387 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
387 388 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
388 389 dummy_hk_packet.reserved = DEFAULT_RESERVED;
389 390 dummy_hk_packet.userApplication = CCSDS_USER_APP;
390 391 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
391 392 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
392 393 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
393 394 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
394 395 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
395 396 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
396 397 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
397 398 dummy_hk_packet.serviceType = TM_TYPE_HK;
398 399 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
399 400 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
400 401 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
401 402 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
402 403 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
403 404 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
404 405 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
405 406 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
406 407 dummy_hk_packet.sid = SID_HK;
407 408
408 409 // init status word
409 410 dummy_hk_packet.lfr_status_word[0] = 0xff;
410 411 dummy_hk_packet.lfr_status_word[1] = 0xff;
411 412 // init software version
412 413 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
413 414 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
414 415 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
415 416 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
416 417 // init fpga version
417 418 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
418 419 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
419 420 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
420 421 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
421 422
422 423 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
423 424
424 425 for (i=0; i<100; i++)
425 426 {
426 427 parameters[i] = 0xff;
427 428 }
428 429
429 430 get_message_queue_id_send( &queue_id );
430 431
431 432 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
432 433 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
433 434 }
@@ -1,364 +1,366
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include "avf0_prc0.h"
11 11 #include "fsw_processing.h"
12 12
13 13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
14 14
15 15 //***
16 16 // F0
17 17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
18 18 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
19 19
20 20 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
21 21 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
22 22 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
23 23 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
24 unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
25 unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
24 26
25 27 //************
26 28 // RTEMS TASKS
27 29
28 30 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
29 31 {
30 32 int i;
31 33
32 34 rtems_event_set event_out;
33 35 rtems_status_code status;
34 36 rtems_id queue_id_prc0;
35 37 asm_msg msgForMATR;
36 38 ring_node_sm *ring_node_tab[8];
37 39 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
38 40 ring_node_asm *current_ring_node_asm_norm_f0;
39 41
40 42 unsigned int nb_norm_bp1;
41 43 unsigned int nb_norm_bp2;
42 44 unsigned int nb_norm_asm;
43 45 unsigned int nb_sbm_bp1;
44 46 unsigned int nb_sbm_bp2;
45 47
46 48 nb_norm_bp1 = 0;
47 49 nb_norm_bp2 = 0;
48 50 nb_norm_asm = 0;
49 51 nb_sbm_bp1 = 0;
50 52 nb_sbm_bp2 = 0;
51 53
52 54 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
53 55 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
54 56 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
55 57 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
56 58 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
57 59
58 60 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
59 61
60 62 status = get_message_queue_id_prc0( &queue_id_prc0 );
61 63 if (status != RTEMS_SUCCESSFUL)
62 64 {
63 65 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
64 66 }
65 67
66 68 while(1){
67 69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
68 70 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
69 71 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
70 72 {
71 73 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
72 74 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
73 75 }
74 76
75 77 // compute the average and store it in the averaged_sm_f1 buffer
76 78 SM_average( current_ring_node_asm_norm_f0->matrix,
77 79 current_ring_node_asm_burst_sbm_f0->matrix,
78 80 ring_node_tab,
79 81 nb_norm_bp1, nb_sbm_bp1 );
80 82
81 83 // update nb_average
82 84 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
83 85 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
84 86 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
85 87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
86 88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
87 89
88 90 //****************************************
89 91 // initialize the mesage for the MATR task
90 92 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
91 93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
92 94 msgForMATR.norm = current_ring_node_asm_norm_f0;
93 95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
94 96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
95 97 msgForMATR.coarseTime = time_management_regs->coarse_time;
96 98 msgForMATR.fineTime = time_management_regs->fine_time;
97 99
98 100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
99 101 {
100 102 nb_sbm_bp1 = 0;
101 103 // set another ring for the ASM storage
102 104 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
103 105 if ( (lfrCurrentMode == LFR_MODE_BURST)
104 106 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
105 107 {
106 108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
107 109 }
108 110 }
109 111
110 112 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
111 113 {
112 114 nb_sbm_bp2 = 0;
113 115 if ( (lfrCurrentMode == LFR_MODE_BURST)
114 116 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
115 117 {
116 118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
117 119 }
118 120 }
119 121
120 122 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
121 123 {
122 124 nb_norm_bp1 = 0;
123 125 // set another ring for the ASM storage
124 126 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
125 127 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
126 128 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
127 129 {
128 130 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
129 131 }
130 132 }
131 133
132 134 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
133 135 {
134 136 nb_norm_bp2 = 0;
135 137 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
136 138 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
137 139 {
138 140 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
139 141 }
140 142 }
141 143
142 144 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
143 145 {
144 146 nb_norm_asm = 0;
145 147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
146 148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
147 149 {
148 150 // PRINTF1("%lld\n", localTime)
149 151 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
150 152 }
151 153 }
152 154
153 155 //*************************
154 156 // send the message to MATR
155 157 if (msgForMATR.event != 0x00)
156 158 {
157 159 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
158 160 }
159 161
160 162 if (status != RTEMS_SUCCESSFUL) {
161 163 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
162 164 }
163 165 }
164 166 }
165 167
166 168 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
167 169 {
168 170 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
169 171 size_t size; // size of the incoming TC packet
170 172 asm_msg *incomingMsg;
171 173 //
172 174 spw_ioctl_pkt_send spw_ioctl_send_ASM;
173 175 rtems_status_code status;
174 176 rtems_id queue_id;
175 177 rtems_id queue_id_q_p0;
176 178 Header_TM_LFR_SCIENCE_ASM_t headerASM;
177 179 bp_packet_with_spare packet_norm_bp1_f0;
178 180 bp_packet packet_norm_bp2_f0;
179 181 bp_packet packet_sbm_bp1_f0;
180 182 bp_packet packet_sbm_bp2_f0;
181 183
182 184 unsigned long long int localTime;
183 185
184 186 ASM_init_header( &headerASM );
185 187
186 188 //*************
187 189 // NORM headers
188 190 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
189 191 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
190 192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
191 193 BP_init_header( &packet_norm_bp2_f0.header,
192 194 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
193 195 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
194 196
195 197 //****************************
196 198 // BURST SBM1 and SBM2 headers
197 199 if ( lfrRequestedMode == LFR_MODE_BURST )
198 200 {
199 201 BP_init_header( &packet_sbm_bp1_f0.header,
200 202 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
201 203 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
202 204 BP_init_header( &packet_sbm_bp2_f0.header,
203 205 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
204 206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
205 207 }
206 208 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
207 209 {
208 210 BP_init_header( &packet_sbm_bp1_f0.header,
209 211 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
210 212 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
211 213 BP_init_header( &packet_sbm_bp2_f0.header,
212 214 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
213 215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
214 216 }
215 217 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
216 218 {
217 219 BP_init_header( &packet_sbm_bp1_f0.header,
218 220 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
219 221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
220 222 BP_init_header( &packet_sbm_bp2_f0.header,
221 223 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
222 224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
223 225 }
224 226 else
225 227 {
226 228 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
227 229 }
228 230
229 231 status = get_message_queue_id_send( &queue_id );
230 232 if (status != RTEMS_SUCCESSFUL)
231 233 {
232 234 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
233 235 }
234 236 status = get_message_queue_id_prc0( &queue_id_q_p0);
235 237 if (status != RTEMS_SUCCESSFUL)
236 238 {
237 239 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
238 240 }
239 241
240 242 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
241 243
242 244 while(1){
243 245 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
244 246 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
245 247
246 248 incomingMsg = (asm_msg*) incomingData;
247 249
248 250 localTime = getTimeAsUnsignedLongLongInt( );
249 251 //****************
250 252 //****************
251 253 // BURST SBM1 SBM2
252 254 //****************
253 255 //****************
254 256 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
255 257 {
256 258 // 1) compress the matrix for Basic Parameters calculation
257 259 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
258 260 nb_sm_before_f0.burst_sbm_bp1,
259 261 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
260 262 ASM_F0_INDICE_START);
261 263 // 2) compute the BP1 set
262
264 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
263 265 // 3) send the BP1 set
264 266 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
265 267 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
266 268 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
267 269 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
268 270 // 4) compute the BP2 set if needed
269 271 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
270 272 {
271 273 // 1) compute the BP2 set
272 274
273 275 // 2) send the BP2 set
274 276 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
275 277 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
276 278 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
277 279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
278 280 }
279 281 }
280 282
281 283 //*****
282 284 //*****
283 285 // NORM
284 286 //*****
285 287 //*****
286 288 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
287 289 {
288 290 // 1) compress the matrix for Basic Parameters calculation
289 291 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
290 292 nb_sm_before_f0.norm_bp1,
291 293 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
292 294 ASM_F0_INDICE_START );
293 295 // 2) compute the BP1 set
294
296 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
295 297 // 3) send the BP1 set
296 298 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
297 299 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
298 300 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
299 301 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
300 302 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
301 303 {
302 304 // 1) compute the BP2 set using the same ASM as the one used for BP1
303 305
304 306 // 2) send the BP2 set
305 307 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 308 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
307 309 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
308 310 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
309 311 }
310 312 }
311 313
312 314 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
313 315 {
314 316 // 1) reorganize the ASM and divide
315 317 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
316 318 asm_f0_reorganized,
317 319 nb_sm_before_f0.norm_bp1 );
318 320 // 2) convert the float array in a char array
319 321 ASM_convert( asm_f0_reorganized, asm_f0_char);
320 322 // 3) send the spectral matrix packets
321 323 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
322 324 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
323 325 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
324 326 }
325 327
326 328 }
327 329 }
328 330
329 331 //**********
330 332 // FUNCTIONS
331 333
332 334 void reset_nb_sm_f0( unsigned char lfrMode )
333 335 {
334 336 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
335 337 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
336 338 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
337 339 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
338 340 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
339 341 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
340 342 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
341 343 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
342 344 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
343 345
344 346 if (lfrMode == LFR_MODE_SBM1)
345 347 {
346 348 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
347 349 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
348 350 }
349 351 else if (lfrMode == LFR_MODE_SBM2)
350 352 {
351 353 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
352 354 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
353 355 }
354 356 else if (lfrMode == LFR_MODE_BURST)
355 357 {
356 358 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
357 359 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
358 360 }
359 361 else
360 362 {
361 363 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
362 364 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
363 365 }
364 366 }
@@ -1,1339 +1,1338
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 //*****************
13 13 // waveform headers
14 14 // SWF
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 18 // CWF
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24 24
25 25 //**************
26 26 // waveform ring
27 27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 30 ring_node *current_ring_node_f0;
31 31 ring_node *ring_node_to_send_swf_f0;
32 32 ring_node *current_ring_node_f1;
33 33 ring_node *ring_node_to_send_swf_f1;
34 34 ring_node *ring_node_to_send_cwf_f1;
35 35 ring_node *current_ring_node_f2;
36 36 ring_node *ring_node_to_send_swf_f2;
37 37 ring_node *ring_node_to_send_cwf_f2;
38 38
39 39 bool extractSWF = false;
40 40 bool swf_f0_ready = false;
41 41 bool swf_f1_ready = false;
42 42 bool swf_f2_ready = false;
43 43
44 44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
45 45
46 46 //*********************
47 47 // Interrupt SubRoutine
48 48
49 49 void reset_extractSWF( void )
50 50 {
51 51 extractSWF = false;
52 52 swf_f0_ready = false;
53 53 swf_f1_ready = false;
54 54 swf_f2_ready = false;
55 55 }
56 56
57 57 rtems_isr waveforms_isr( rtems_vector_number vector )
58 58 {
59 59 /** This is the interrupt sub routine called by the waveform picker core.
60 60 *
61 61 * This ISR launch different actions depending mainly on two pieces of information:
62 62 * 1. the values read in the registers of the waveform picker.
63 63 * 2. the current LFR mode.
64 64 *
65 65 */
66 66
67 67 rtems_status_code status;
68 68
69 69 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
70 70 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
71 71 { // in modes other than STANDBY and BURST, send the CWF_F3 data
72 72 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
73 73 // (1) change the receiving buffer for the waveform picker
74 74 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
75 75 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
76 76 }
77 77 else {
78 78 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
79 79 }
80 80 // (2) send an event for the waveforms transmission
81 81 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
82 82 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
83 83 }
84 84 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
85 85 }
86 86 }
87 87
88 88 switch(lfrCurrentMode)
89 89 {
90 90 //********
91 91 // STANDBY
92 92 case(LFR_MODE_STANDBY):
93 93 break;
94 94
95 95 //******
96 96 // NORMAL
97 97 case(LFR_MODE_NORMAL):
98 98 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
99 99 {
100 100 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
101 101 }
102 102 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
103 103 {
104 104 // change F0 ring node
105 105 ring_node_to_send_swf_f0 = current_ring_node_f0;
106 106 current_ring_node_f0 = current_ring_node_f0->next;
107 107 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
108 108 // change F1 ring node
109 109 ring_node_to_send_swf_f1 = current_ring_node_f1;
110 110 current_ring_node_f1 = current_ring_node_f1->next;
111 111 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
112 112 // change F2 ring node
113 113 ring_node_to_send_swf_f2 = current_ring_node_f2;
114 114 current_ring_node_f2 = current_ring_node_f2->next;
115 115 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
116 116 //
117 117 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
118 118 {
119 119 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
120 120 }
121 121 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
122 122 }
123 123 break;
124 124
125 125 //******
126 126 // BURST
127 127 case(LFR_MODE_BURST):
128 128 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
129 129 // (1) change the receiving buffer for the waveform picker
130 130 ring_node_to_send_cwf_f2 = current_ring_node_f2;
131 131 current_ring_node_f2 = current_ring_node_f2->next;
132 132 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
133 133 // (2) send an event for the waveforms transmission
134 134 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
135 135 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
136 136 }
137 137 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
138 138 }
139 139 break;
140 140
141 141 //*****
142 142 // SBM1
143 143 case(LFR_MODE_SBM1):
144 144 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
145 145 // (1) change the receiving buffer for the waveform picker
146 146 ring_node_to_send_cwf_f1 = current_ring_node_f1;
147 147 current_ring_node_f1 = current_ring_node_f1->next;
148 148 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
149 149 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
150 150 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
151 151 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
152 152 }
153 153 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
154 154 swf_f0_ready = true;
155 155 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
156 156 }
157 157 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
158 158 swf_f2_ready = true;
159 159 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
160 160 }
161 161 break;
162 162
163 163 //*****
164 164 // SBM2
165 165 case(LFR_MODE_SBM2):
166 166 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
167 167 // (1) change the receiving buffer for the waveform picker
168 168 ring_node_to_send_cwf_f2 = current_ring_node_f2;
169 169 current_ring_node_f2 = current_ring_node_f2->next;
170 170 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
171 171 // (2) send an event for the waveforms transmission
172 172 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
173 173 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
174 174 }
175 175 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
176 176 swf_f0_ready = true;
177 177 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
178 178 }
179 179 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
180 180 swf_f1_ready = true;
181 181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
182 182 }
183 183 break;
184 184
185 185 //********
186 186 // DEFAULT
187 187 default:
188 188 break;
189 189 }
190 190 }
191 191
192 192 //************
193 193 // RTEMS TASKS
194 194
195 195 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
196 196 {
197 197 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
198 198 *
199 199 * @param unused is the starting argument of the RTEMS task
200 200 *
201 201 * The following data packets are sent by this task:
202 202 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
203 203 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
204 204 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
205 205 *
206 206 */
207 207
208 208 rtems_event_set event_out;
209 209 rtems_id queue_id;
210 210 rtems_status_code status;
211 211
212 212 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
213 213 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
214 214 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
215 215
216 216 init_waveforms();
217 217
218 218 status = get_message_queue_id_send( &queue_id );
219 219 if (status != RTEMS_SUCCESSFUL)
220 220 {
221 221 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
222 222 }
223 223
224 224 BOOT_PRINTF("in WFRM ***\n")
225 225
226 226 while(1){
227 227 // wait for an RTEMS_EVENT
228 228 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
229 229 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
230 230 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
231 231 if (event_out == RTEMS_EVENT_MODE_NORMAL)
232 232 {
233 233 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
234 234 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
235 235 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
236 236 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
237 237 }
238 238 if (event_out == RTEMS_EVENT_MODE_SBM1)
239 239 {
240 240 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
241 241 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
242 242 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
243 243 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
244 244 }
245 245 if (event_out == RTEMS_EVENT_MODE_SBM2)
246 246 {
247 247 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
248 248 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
249 249 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
250 250 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
251 251 }
252 252 }
253 253 }
254 254
255 255 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
256 256 {
257 257 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
258 258 *
259 259 * @param unused is the starting argument of the RTEMS task
260 260 *
261 261 * The following data packet is sent by this task:
262 262 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
263 263 *
264 264 */
265 265
266 266 rtems_event_set event_out;
267 267 rtems_id queue_id;
268 268 rtems_status_code status;
269 269
270 270 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
271 271 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
272 272
273 273 status = get_message_queue_id_send( &queue_id );
274 274 if (status != RTEMS_SUCCESSFUL)
275 275 {
276 276 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
277 277 }
278 278
279 279 BOOT_PRINTF("in CWF3 ***\n")
280 280
281 281 while(1){
282 282 // wait for an RTEMS_EVENT
283 283 rtems_event_receive( RTEMS_EVENT_0,
284 284 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
285 285 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
286 286 {
287 287 PRINTF("send CWF_LONG_F3\n")
288 288 }
289 289 else
290 290 {
291 291 PRINTF("send CWF_F3 (light)\n")
292 292 }
293 293 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
294 294 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
295 295 {
296 296 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
297 297 }
298 298 else
299 299 {
300 300 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
301 301 }
302 302 }
303 303 else
304 304 {
305 305 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
306 306 {
307 307 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
308 308 }
309 309 else
310 310 {
311 311 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
312 312 }
313 313
314 314 }
315 315 }
316 316 }
317 317
318 318 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
319 319 {
320 320 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
321 321 *
322 322 * @param unused is the starting argument of the RTEMS task
323 323 *
324 324 * The following data packet is sent by this function:
325 325 * - TM_LFR_SCIENCE_BURST_CWF_F2
326 326 * - TM_LFR_SCIENCE_SBM2_CWF_F2
327 327 *
328 328 */
329 329
330 330 rtems_event_set event_out;
331 331 rtems_id queue_id;
332 332 rtems_status_code status;
333 333
334 334 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
335 335 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
336 336
337 337 status = get_message_queue_id_send( &queue_id );
338 338 if (status != RTEMS_SUCCESSFUL)
339 339 {
340 340 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
341 341 }
342 342
343 343 BOOT_PRINTF("in CWF2 ***\n")
344 344
345 345 while(1){
346 346 // wait for an RTEMS_EVENT
347 347 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
348 348 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
349 349 if (event_out == RTEMS_EVENT_MODE_BURST)
350 350 {
351 351 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
352 352 }
353 353 if (event_out == RTEMS_EVENT_MODE_SBM2)
354 354 {
355 355 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
356 356 // launch snapshot extraction if needed
357 357 if (extractSWF == true)
358 358 {
359 359 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
360 360 // extract the snapshot
361 361 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
362 362 // send the snapshot when built
363 363 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
364 364 extractSWF = false;
365 365 }
366 366 if (swf_f0_ready && swf_f1_ready)
367 367 {
368 368 extractSWF = true;
369 369 swf_f0_ready = false;
370 370 swf_f1_ready = false;
371 371 }
372 372 }
373 373 }
374 374 }
375 375
376 376 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
377 377 {
378 378 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
379 379 *
380 380 * @param unused is the starting argument of the RTEMS task
381 381 *
382 382 * The following data packet is sent by this function:
383 383 * - TM_LFR_SCIENCE_SBM1_CWF_F1
384 384 *
385 385 */
386 386
387 387 rtems_event_set event_out;
388 388 rtems_id queue_id;
389 389 rtems_status_code status;
390 390
391 391 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
392 392
393 393 status = get_message_queue_id_send( &queue_id );
394 394 if (status != RTEMS_SUCCESSFUL)
395 395 {
396 396 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
397 397 }
398 398
399 399 BOOT_PRINTF("in CWF1 ***\n")
400 400
401 401 while(1){
402 402 // wait for an RTEMS_EVENT
403 403 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
404 404 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
405 405 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
406 406 // launch snapshot extraction if needed
407 407 if (extractSWF == true)
408 408 {
409 409 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
410 410 // launch the snapshot extraction
411 411 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
412 412 extractSWF = false;
413 413 }
414 414 if (swf_f0_ready == true)
415 415 {
416 416 extractSWF = true;
417 417 swf_f0_ready = false; // this step shall be executed only one time
418 418 }
419 419 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
420 420 {
421 421 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
422 422 swf_f1_ready = false;
423 423 swf_f2_ready = false;
424 424 }
425 425 }
426 426 }
427 427
428 428 rtems_task swbd_task(rtems_task_argument argument)
429 429 {
430 430 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
431 431 *
432 432 * @param unused is the starting argument of the RTEMS task
433 433 *
434 434 */
435 435
436 436 rtems_event_set event_out;
437 437
438 438 BOOT_PRINTF("in SWBD ***\n")
439 439
440 440 while(1){
441 441 // wait for an RTEMS_EVENT
442 442 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
443 443 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
444 444 if (event_out == RTEMS_EVENT_MODE_SBM1)
445 445 {
446 446 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
447 447 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
448 448 }
449 449 else
450 450 {
451 451 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
452 452 }
453 453 }
454 454 }
455 455
456 456 //******************
457 457 // general functions
458 458 void init_waveforms( void )
459 459 {
460 460 int i = 0;
461 461
462 462 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
463 463 {
464 464 //***
465 465 // F0
466 466 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
467 467 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
468 468 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
469 469
470 470 //***
471 471 // F1
472 472 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
473 473 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
474 474 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
475 475
476 476 //***
477 477 // F2
478 478 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
479 479 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
480 480 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
481 481
482 482 //***
483 483 // F3
484 484 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
485 485 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
486 486 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
487 487 }
488 488 }
489 489
490 490 void init_waveform_rings( void )
491 491 {
492 492 unsigned char i;
493 493
494 494 // F0 RING
495 495 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
496 496 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
497 497 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
498 498
499 499 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
500 500 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
501 501 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
502 502
503 503 for(i=1; i<NB_RING_NODES_F0-1; i++)
504 504 {
505 505 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
506 506 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
507 507 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
508 508 }
509 509
510 510 // F1 RING
511 511 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
512 512 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
513 513 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
514 514
515 515 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
516 516 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
517 517 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
518 518
519 519 for(i=1; i<NB_RING_NODES_F1-1; i++)
520 520 {
521 521 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
522 522 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
523 523 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
524 524 }
525 525
526 526 // F2 RING
527 527 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
528 528 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
529 529 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
530 530
531 531 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
532 532 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
533 533 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
534 534
535 535 for(i=1; i<NB_RING_NODES_F2-1; i++)
536 536 {
537 537 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
538 538 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
539 539 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
540 540 }
541 541
542 542 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
543 543 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
544 544 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
545 545
546 546 }
547 547
548 548 void reset_current_ring_nodes( void )
549 549 {
550 550 current_ring_node_f0 = waveform_ring_f0;
551 551 ring_node_to_send_swf_f0 = waveform_ring_f0;
552 552
553 553 current_ring_node_f1 = waveform_ring_f1;
554 554 ring_node_to_send_cwf_f1 = waveform_ring_f1;
555 555 ring_node_to_send_swf_f1 = waveform_ring_f1;
556 556
557 557 current_ring_node_f2 = waveform_ring_f2;
558 558 ring_node_to_send_cwf_f2 = waveform_ring_f2;
559 559 ring_node_to_send_swf_f2 = waveform_ring_f2;
560 560 }
561 561
562 562 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
563 563 {
564 564 unsigned char i;
565 565
566 566 for (i=0; i<7; i++)
567 567 {
568 568 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
569 569 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
570 570 headerSWF[ i ].reserved = DEFAULT_RESERVED;
571 571 headerSWF[ i ].userApplication = CCSDS_USER_APP;
572 572 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
573 573 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
574 574 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
575 575 if (i == 6)
576 576 {
577 577 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
578 578 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
579 579 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
580 580 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
581 581 }
582 582 else
583 583 {
584 584 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
585 585 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
586 586 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
587 587 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
588 588 }
589 589 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
590 590 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
591 591 headerSWF[ i ].pktNr = i+1; // PKT_NR
592 592 // DATA FIELD HEADER
593 593 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
594 594 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
595 595 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
596 596 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
597 597 // AUXILIARY DATA HEADER
598 598 headerSWF[ i ].time[0] = 0x00;
599 599 headerSWF[ i ].time[0] = 0x00;
600 600 headerSWF[ i ].time[0] = 0x00;
601 601 headerSWF[ i ].time[0] = 0x00;
602 602 headerSWF[ i ].time[0] = 0x00;
603 603 headerSWF[ i ].time[0] = 0x00;
604 604 headerSWF[ i ].sid = sid;
605 605 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
606 606 }
607 607 return LFR_SUCCESSFUL;
608 608 }
609 609
610 610 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
611 611 {
612 612 unsigned int i;
613 613
614 614 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
615 615 {
616 616 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
617 617 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
618 618 headerCWF[ i ].reserved = DEFAULT_RESERVED;
619 619 headerCWF[ i ].userApplication = CCSDS_USER_APP;
620 620 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
621 621 {
622 622 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
623 623 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
624 624 }
625 625 else
626 626 {
627 627 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
628 628 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
629 629 }
630 630 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
631 631 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
632 632 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
633 633 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
634 634 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
635 635 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
636 636 // DATA FIELD HEADER
637 637 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
638 638 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
639 639 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
640 640 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
641 641 // AUXILIARY DATA HEADER
642 642 headerCWF[ i ].sid = sid;
643 643 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
644 644 headerCWF[ i ].time[0] = 0x00;
645 645 headerCWF[ i ].time[0] = 0x00;
646 646 headerCWF[ i ].time[0] = 0x00;
647 647 headerCWF[ i ].time[0] = 0x00;
648 648 headerCWF[ i ].time[0] = 0x00;
649 649 headerCWF[ i ].time[0] = 0x00;
650 650 }
651 651 return LFR_SUCCESSFUL;
652 652 }
653 653
654 654 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
655 655 {
656 656 unsigned int i;
657 657
658 658 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
659 659 {
660 660 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
661 661 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
662 662 headerCWF[ i ].reserved = DEFAULT_RESERVED;
663 663 headerCWF[ i ].userApplication = CCSDS_USER_APP;
664 664
665 665 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
666 666 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
667 667
668 668 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
669 669 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
670 670 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
671 671 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
672 672 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
673 673
674 674 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
675 675 // DATA FIELD HEADER
676 676 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
677 677 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
678 678 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
679 679 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
680 680 // AUXILIARY DATA HEADER
681 681 headerCWF[ i ].sid = SID_NORM_CWF_F3;
682 682 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
683 683 headerCWF[ i ].time[0] = 0x00;
684 684 headerCWF[ i ].time[0] = 0x00;
685 685 headerCWF[ i ].time[0] = 0x00;
686 686 headerCWF[ i ].time[0] = 0x00;
687 687 headerCWF[ i ].time[0] = 0x00;
688 688 headerCWF[ i ].time[0] = 0x00;
689 689 }
690 690 return LFR_SUCCESSFUL;
691 691 }
692 692
693 693 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
694 694 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
695 695 {
696 696 /** This function sends SWF CCSDS packets (F2, F1 or F0).
697 697 *
698 698 * @param waveform points to the buffer containing the data that will be send.
699 699 * @param sid is the source identifier of the data that will be sent.
700 700 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
701 701 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
702 702 * contain information to setup the transmission of the data packets.
703 703 *
704 704 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
705 705 *
706 706 */
707 707
708 708 unsigned int i;
709 709 int ret;
710 710 unsigned int coarseTime;
711 711 unsigned int fineTime;
712 712 rtems_status_code status;
713 713 spw_ioctl_pkt_send spw_ioctl_send_SWF;
714 714
715 715 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
716 716 spw_ioctl_send_SWF.options = 0;
717 717
718 718 ret = LFR_DEFAULT;
719 719
720 720 coarseTime = waveform[0];
721 721 fineTime = waveform[1];
722 722
723 723 for (i=0; i<7; i++) // send waveform
724 724 {
725 725 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
726 726 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
727 727 // BUILD THE DATA
728 728 if (i==6) {
729 729 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
730 730 }
731 731 else {
732 732 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
733 733 }
734 734 // SET PACKET SEQUENCE COUNTER
735 735 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
736 736 // SET PACKET TIME
737 737 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
738 738 //
739 739 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
740 740 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
741 741 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
742 742 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
743 743 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
744 744 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
745 745 // SEND PACKET
746 746 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
747 747 if (status != RTEMS_SUCCESSFUL) {
748 748 printf("%d-%d, ERR %d\n", sid, i, (int) status);
749 749 ret = LFR_DEFAULT;
750 750 }
751 751 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
752 752 }
753 753
754 754 return ret;
755 755 }
756 756
757 757 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
758 758 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
759 759 {
760 760 /** This function sends CWF CCSDS packets (F2, F1 or F0).
761 761 *
762 762 * @param waveform points to the buffer containing the data that will be send.
763 763 * @param sid is the source identifier of the data that will be sent.
764 764 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
765 765 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
766 766 * contain information to setup the transmission of the data packets.
767 767 *
768 768 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
769 769 *
770 770 */
771 771
772 772 unsigned int i;
773 773 int ret;
774 774 unsigned int coarseTime;
775 775 unsigned int fineTime;
776 776 rtems_status_code status;
777 777 spw_ioctl_pkt_send spw_ioctl_send_CWF;
778 778
779 779 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
780 780 spw_ioctl_send_CWF.options = 0;
781 781
782 782 ret = LFR_DEFAULT;
783 783
784 784 coarseTime = waveform[0];
785 785 fineTime = waveform[1];
786 786
787 787 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
788 788 {
789 789 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
790 790 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
791 791 // BUILD THE DATA
792 792 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
793 793 // SET PACKET SEQUENCE COUNTER
794 794 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
795 795 // SET PACKET TIME
796 796 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
797 797 //
798 798 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
799 799 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
800 800 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
801 801 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
802 802 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
803 803 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
804 804 // SEND PACKET
805 805 if (sid == SID_NORM_CWF_LONG_F3)
806 806 {
807 807 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
808 808 if (status != RTEMS_SUCCESSFUL) {
809 809 printf("%d-%d, ERR %d\n", sid, i, (int) status);
810 810 ret = LFR_DEFAULT;
811 811 }
812 812 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
813 813 }
814 814 else
815 815 {
816 816 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
817 817 if (status != RTEMS_SUCCESSFUL) {
818 818 printf("%d-%d, ERR %d\n", sid, i, (int) status);
819 819 ret = LFR_DEFAULT;
820 820 }
821 821 }
822 822 }
823 823
824 824 return ret;
825 825 }
826 826
827 827 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
828 828 {
829 829 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
830 830 *
831 831 * @param waveform points to the buffer containing the data that will be send.
832 832 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
833 833 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
834 834 * contain information to setup the transmission of the data packets.
835 835 *
836 836 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
837 837 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
838 838 *
839 839 */
840 840
841 841 unsigned int i;
842 842 int ret;
843 843 unsigned int coarseTime;
844 844 unsigned int fineTime;
845 845 rtems_status_code status;
846 846 spw_ioctl_pkt_send spw_ioctl_send_CWF;
847 847 char *sample;
848 848
849 849 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
850 850 spw_ioctl_send_CWF.options = 0;
851 851
852 852 ret = LFR_DEFAULT;
853 853
854 854 //**********************
855 855 // BUILD CWF3_light DATA
856 856 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
857 857 {
858 858 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
859 859 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
860 860 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
861 861 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
862 862 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
863 863 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
864 864 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
865 865 }
866 866
867 867 coarseTime = waveform[0];
868 868 fineTime = waveform[1];
869 869
870 870 //*********************
871 871 // SEND CWF3_light DATA
872 872 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
873 873 {
874 874 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
875 875 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
876 876 // BUILD THE DATA
877 877 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
878 878 // SET PACKET SEQUENCE COUNTER
879 879 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
880 880 // SET PACKET TIME
881 881 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
882 882 //
883 883 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
884 884 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
885 885 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
886 886 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
887 887 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
888 888 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
889 889 // SEND PACKET
890 890 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
891 891 if (status != RTEMS_SUCCESSFUL) {
892 892 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
893 893 ret = LFR_DEFAULT;
894 894 }
895 895 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
896 896 }
897 897
898 898 return ret;
899 899 }
900 900
901 901 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
902 902 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
903 903 {
904 904 unsigned long long int acquisitionTimeAsLong;
905 905 unsigned char localAcquisitionTime[6];
906 906 double deltaT;
907 907
908 908 deltaT = 0.;
909 909
910 910 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
911 911 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
912 912 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
913 913 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
914 914 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
915 915 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
916 916
917 917 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
918 918 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
919 919 + ( localAcquisitionTime[2] << 24 )
920 920 + ( localAcquisitionTime[3] << 16 )
921 921 + ( localAcquisitionTime[4] << 8 )
922 922 + ( localAcquisitionTime[5] );
923 923
924 924 switch( sid )
925 925 {
926 926 case SID_NORM_SWF_F0:
927 927 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
928 928 break;
929 929
930 930 case SID_NORM_SWF_F1:
931 931 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
932 932 break;
933 933
934 934 case SID_NORM_SWF_F2:
935 935 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
936 936 break;
937 937
938 938 case SID_SBM1_CWF_F1:
939 939 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
940 940 break;
941 941
942 942 case SID_SBM2_CWF_F2:
943 943 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
944 944 break;
945 945
946 946 case SID_BURST_CWF_F2:
947 947 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
948 948 break;
949 949
950 950 case SID_NORM_CWF_F3:
951 951 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
952 952 break;
953 953
954 954 case SID_NORM_CWF_LONG_F3:
955 955 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
956 956 break;
957 957
958 958 default:
959 959 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
960 960 deltaT = 0.;
961 961 break;
962 962 }
963 963
964 964 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
965 965 //
966 966 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
967 967 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
968 968 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
969 969 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
970 970 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
971 971 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
972 972
973 973 }
974 974
975 975 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
976 976 {
977 977 unsigned int i;
978 978 unsigned long long int centerTime_asLong;
979 979 unsigned long long int acquisitionTimeF0_asLong;
980 980 unsigned long long int acquisitionTime_asLong;
981 981 unsigned long long int bufferAcquisitionTime_asLong;
982 982 unsigned char *ptr1;
983 983 unsigned char *ptr2;
984 984 unsigned char nb_ring_nodes;
985 985 unsigned long long int frequency_asLong;
986 986 unsigned long long int nbTicksPerSample_asLong;
987 987 unsigned long long int nbSamplesPart1_asLong;
988 988 unsigned long long int sampleOffset_asLong;
989 989
990 990 unsigned int deltaT_F0;
991 991 unsigned int deltaT_F1;
992 992 unsigned long long int deltaT_F2;
993 993
994 994 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
995 995 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
996 996 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
997 997 sampleOffset_asLong = 0x00;
998 998
999 999 // (1) get the f0 acquisition time
1000 1000 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1001 1001
1002 1002 // (2) compute the central reference time
1003 1003 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1004 1004
1005 1005 // (3) compute the acquisition time of the current snapshot
1006 1006 switch(frequencyChannel)
1007 1007 {
1008 1008 case 1: // 1 is for F1 = 4096 Hz
1009 1009 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1010 1010 nb_ring_nodes = NB_RING_NODES_F1;
1011 1011 frequency_asLong = 4096;
1012 1012 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1013 1013 break;
1014 1014 case 2: // 2 is for F2 = 256 Hz
1015 1015 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1016 1016 nb_ring_nodes = NB_RING_NODES_F2;
1017 1017 frequency_asLong = 256;
1018 1018 nbTicksPerSample_asLong = 256; // 65536 / 256;
1019 1019 break;
1020 1020 default:
1021 1021 acquisitionTime_asLong = centerTime_asLong;
1022 1022 frequency_asLong = 256;
1023 1023 nbTicksPerSample_asLong = 256;
1024 1024 break;
1025 1025 }
1026 1026
1027 1027 //****************************************************************************
1028 1028 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1029 1029 for (i=0; i<nb_ring_nodes; i++)
1030 1030 {
1031 1031 PRINTF1("%d ... ", i)
1032 1032 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1033 1033 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1034 1034 {
1035 1035 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1036 1036 break;
1037 1037 }
1038 1038 ring_node_to_send = ring_node_to_send->previous;
1039 1039 }
1040 1040
1041 1041 // (5) compute the number of samples to take in the current buffer
1042 1042 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1043 1043 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1044 1044 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1045 1045
1046 1046 // (6) compute the final acquisition time
1047 1047 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1048 1048 sampleOffset_asLong * nbTicksPerSample_asLong;
1049 1049
1050 1050 // (7) copy the acquisition time at the beginning of the extrated snapshot
1051 1051 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1052 1052 ptr2 = (unsigned char*) wf_snap_extracted;
1053 1053 ptr2[0] = ptr1[ 2 + 2 ];
1054 1054 ptr2[1] = ptr1[ 3 + 2 ];
1055 1055 ptr2[2] = ptr1[ 0 + 2 ];
1056 1056 ptr2[3] = ptr1[ 1 + 2 ];
1057 1057 ptr2[4] = ptr1[ 4 + 2 ];
1058 1058 ptr2[5] = ptr1[ 5 + 2 ];
1059 1059
1060 1060 // re set the synchronization bit
1061 1061
1062 1062
1063 1063 // copy the part 1 of the snapshot in the extracted buffer
1064 1064 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1065 1065 {
1066 1066 wf_snap_extracted[i + TIME_OFFSET] =
1067 1067 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1068 1068 }
1069 1069 // copy the part 2 of the snapshot in the extracted buffer
1070 1070 ring_node_to_send = ring_node_to_send->next;
1071 1071 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1072 1072 {
1073 1073 wf_snap_extracted[i + TIME_OFFSET] =
1074 1074 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1075 1075 }
1076 1076 }
1077 1077
1078 1078 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1079 1079 {
1080 1080 unsigned char *acquisitionTimeCharPtr;
1081 1081
1082 1082 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1083 1083
1084 1084 *acquisitionTimeAslong = 0x00;
1085 1085 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1086 1086 + ( acquisitionTimeCharPtr[1] << 16 )
1087 1087 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1088 1088 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1089 1089 + ( acquisitionTimeCharPtr[4] << 8 )
1090 1090 + ( acquisitionTimeCharPtr[5] );
1091 1091 }
1092 1092
1093 1093 //**************
1094 1094 // wfp registers
1095 1095 void reset_wfp_burst_enable(void)
1096 1096 {
1097 1097 /** This function resets the waveform picker burst_enable register.
1098 1098 *
1099 1099 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1100 1100 *
1101 1101 */
1102 1102
1103 1103 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1104 1104 }
1105 1105
1106 1106 void reset_wfp_status( void )
1107 1107 {
1108 1108 /** This function resets the waveform picker status register.
1109 1109 *
1110 1110 * All status bits are set to 0 [new_err full_err full].
1111 1111 *
1112 1112 */
1113 1113
1114 1114 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1115 1115 }
1116 1116
1117 1117 void reset_waveform_picker_regs(void)
1118 1118 {
1119 1119 /** This function resets the waveform picker module registers.
1120 1120 *
1121 1121 * The registers affected by this function are located at the following offset addresses:
1122 1122 * - 0x00 data_shaping
1123 1123 * - 0x04 run_burst_enable
1124 1124 * - 0x08 addr_data_f0
1125 1125 * - 0x0C addr_data_f1
1126 1126 * - 0x10 addr_data_f2
1127 1127 * - 0x14 addr_data_f3
1128 1128 * - 0x18 status
1129 1129 * - 0x1C delta_snapshot
1130 1130 * - 0x20 delta_f0
1131 1131 * - 0x24 delta_f0_2
1132 1132 * - 0x28 delta_f1
1133 1133 * - 0x2c delta_f2
1134 1134 * - 0x30 nb_data_by_buffer
1135 1135 * - 0x34 nb_snapshot_param
1136 1136 * - 0x38 start_date
1137 1137 * - 0x3c nb_word_in_buffer
1138 1138 *
1139 1139 */
1140 1140
1141 1141 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1142 1142 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1143 1143 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1144 1144 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1145 1145 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1146 1146 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1147 1147 reset_wfp_status(); // 0x18
1148 1148 //
1149 1149 set_wfp_delta_snapshot(); // 0x1c
1150 1150 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1151 1151 set_wfp_delta_f1(); // 0x28
1152 1152 set_wfp_delta_f2(); // 0x2c
1153 1153 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1154 1154 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1155 1155 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1156 1156 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1157 1157 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1158 1158 // 2688 = 8 * 336
1159 1159 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1160 1160 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1161 1161 waveform_picker_regs->start_date = 0x00; // 0x38
1162 1162 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1163 1163 }
1164 1164
1165 1165 void set_wfp_data_shaping( void )
1166 1166 {
1167 1167 /** This function sets the data_shaping register of the waveform picker module.
1168 1168 *
1169 1169 * The value is read from one field of the parameter_dump_packet structure:\n
1170 1170 * bw_sp0_sp1_r0_r1
1171 1171 *
1172 1172 */
1173 1173
1174 1174 unsigned char data_shaping;
1175 1175
1176 1176 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1177 1177 // waveform picker : [R1 R0 SP1 SP0 BW]
1178 1178
1179 1179 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1180 1180
1181 1181 waveform_picker_regs->data_shaping =
1182 1182 ( (data_shaping & 0x10) >> 4 ) // BW
1183 1183 + ( (data_shaping & 0x08) >> 2 ) // SP0
1184 1184 + ( (data_shaping & 0x04) ) // SP1
1185 1185 + ( (data_shaping & 0x02) << 2 ) // R0
1186 1186 + ( (data_shaping & 0x01) << 4 ); // R1
1187 1187 }
1188 1188
1189 1189 void set_wfp_burst_enable_register( unsigned char mode )
1190 1190 {
1191 1191 /** This function sets the waveform picker burst_enable register depending on the mode.
1192 1192 *
1193 1193 * @param mode is the LFR mode to launch.
1194 1194 *
1195 1195 * The burst bits shall be before the enable bits.
1196 1196 *
1197 1197 */
1198 1198
1199 1199 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1200 1200 // the burst bits shall be set first, before the enable bits
1201 1201 switch(mode) {
1202 1202 case(LFR_MODE_NORMAL):
1203 1203 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1204 1204 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1205 1205 break;
1206 1206 case(LFR_MODE_BURST):
1207 1207 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1208 1208 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1209 1209 break;
1210 1210 case(LFR_MODE_SBM1):
1211 1211 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1212 1212 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1213 1213 break;
1214 1214 case(LFR_MODE_SBM2):
1215 1215 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1216 1216 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1217 1217 break;
1218 1218 default:
1219 1219 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1220 1220 break;
1221 1221 }
1222 1222 }
1223 1223
1224 1224 void set_wfp_delta_snapshot( void )
1225 1225 {
1226 1226 /** This function sets the delta_snapshot register of the waveform picker module.
1227 1227 *
1228 1228 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1229 1229 * - sy_lfr_n_swf_p[0]
1230 1230 * - sy_lfr_n_swf_p[1]
1231 1231 *
1232 1232 */
1233 1233
1234 1234 unsigned int delta_snapshot;
1235 1235 unsigned int delta_snapshot_in_T2;
1236 1236
1237 1237 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1238 1238 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1239 1239
1240 1240 delta_snapshot_in_T2 = delta_snapshot * 256;
1241 1241 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1242 1242 }
1243 1243
1244 1244 void set_wfp_delta_f0_f0_2( void )
1245 1245 {
1246 1246 unsigned int delta_snapshot;
1247 1247 unsigned int nb_samples_per_snapshot;
1248 1248 float delta_f0_in_float;
1249 1249
1250 1250 delta_snapshot = waveform_picker_regs->delta_snapshot;
1251 1251 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1252 1252 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1253 1253
1254 1254 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1255 1255 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1256 1256 }
1257 1257
1258 1258 void set_wfp_delta_f1( void )
1259 1259 {
1260 1260 unsigned int delta_snapshot;
1261 1261 unsigned int nb_samples_per_snapshot;
1262 1262 float delta_f1_in_float;
1263 1263
1264 1264 delta_snapshot = waveform_picker_regs->delta_snapshot;
1265 1265 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1266 1266 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1267 1267
1268 1268 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1269 1269 }
1270 1270
1271 1271 void set_wfp_delta_f2()
1272 1272 {
1273 1273 unsigned int delta_snapshot;
1274 1274 unsigned int nb_samples_per_snapshot;
1275 1275
1276 1276 delta_snapshot = waveform_picker_regs->delta_snapshot;
1277 1277 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1278 1278
1279 1279 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1280 1280 }
1281 1281
1282 1282 //*****************
1283 1283 // local parameters
1284 1284 void set_local_nb_interrupt_f0_MAX( void )
1285 1285 {
1286 1286 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1287 1287 *
1288 1288 * This parameter is used for the SM validation only.\n
1289 1289 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1290 1290 * module before launching a basic processing.
1291 1291 *
1292 1292 */
1293 1293
1294 1294 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1295 1295 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1296 1296 }
1297 1297
1298 1298 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1299 1299 {
1300 1300 unsigned short *sequence_cnt;
1301 1301 unsigned short segmentation_grouping_flag;
1302 1302 unsigned short new_packet_sequence_control;
1303 1303
1304 1304 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1305 1305 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1306 1306 {
1307 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1307 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1308 1308 }
1309 1309 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1310 1310 {
1311 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1311 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1312 1312 }
1313 1313 else
1314 1314 {
1315 sequence_cnt = NULL;
1315 sequence_cnt = (unsigned short *) NULL;
1316 1316 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1317 1317 }
1318 1318
1319 1319 if (sequence_cnt != NULL)
1320 1320 {
1321 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1322 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1323
1324 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1325
1326 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1327 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1328
1329 // increment the sequence counter for the next packet
1321 // increment the sequence counter
1330 1322 if ( *sequence_cnt < SEQ_CNT_MAX)
1331 1323 {
1332 1324 *sequence_cnt = *sequence_cnt + 1;
1333 1325 }
1334 1326 else
1335 1327 {
1336 1328 *sequence_cnt = 0;
1337 1329 }
1330 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1331 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1332
1333 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1334
1335 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1336 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1338 1337 }
1339 1338 }
General Comments 0
You need to be logged in to leave comments. Login now