@@ -1,11 +1,12 | |||
|
1 | 1 | syntax: glob |
|
2 | 2 | |
|
3 | 3 | *~ |
|
4 | 4 | *.o |
|
5 | *.gcno | |
|
5 | 6 | *.zip |
|
6 | 7 | tests/*.err |
|
7 | 8 | doc |
|
8 | 9 | *.srec |
|
9 | 10 | FSW-qt/bin/fsw |
|
10 | 11 | src/LFR_basic-parameters |
|
11 | 12 |
@@ -1,273 +1,273 | |||
|
1 | 1 | ############################################################################# |
|
2 | 2 | # Makefile for building: bin/fsw |
|
3 |
# Generated by qmake (2.01a) (Qt 4.8.6) on: T |
|
|
3 | # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue Oct 7 15:14:40 2014 | |
|
4 | 4 | # Project: fsw-qt.pro |
|
5 | 5 | # Template: app |
|
6 | 6 | # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
7 | 7 | ############################################################################# |
|
8 | 8 | |
|
9 | 9 | ####### Compiler, tools and options |
|
10 | 10 | |
|
11 | 11 | CC = sparc-rtems-gcc |
|
12 | 12 | CXX = sparc-rtems-g++ |
|
13 | 13 | DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DLPP_DPU_DESTID -DPRINT_MESSAGES_ON_CONSOLE |
|
14 | 14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
15 | 15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
16 | 16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters |
|
17 | 17 | LINK = sparc-rtems-g++ |
|
18 | 18 | LFLAGS = |
|
19 | 19 | LIBS = $(SUBLIBS) |
|
20 | 20 | AR = sparc-rtems-ar rcs |
|
21 | 21 | RANLIB = |
|
22 | 22 | QMAKE = /usr/bin/qmake-qt4 |
|
23 | 23 | TAR = tar -cf |
|
24 | 24 | COMPRESS = gzip -9f |
|
25 | 25 | COPY = cp -f |
|
26 | 26 | SED = sed |
|
27 | 27 | COPY_FILE = $(COPY) |
|
28 | 28 | COPY_DIR = $(COPY) -r |
|
29 | 29 | STRIP = sparc-rtems-strip |
|
30 | 30 | INSTALL_FILE = install -m 644 -p |
|
31 | 31 | INSTALL_DIR = $(COPY_DIR) |
|
32 | 32 | INSTALL_PROGRAM = install -m 755 -p |
|
33 | 33 | DEL_FILE = rm -f |
|
34 | 34 | SYMLINK = ln -f -s |
|
35 | 35 | DEL_DIR = rmdir |
|
36 | 36 | MOVE = mv -f |
|
37 | 37 | CHK_DIR_EXISTS= test -d |
|
38 | 38 | MKDIR = mkdir -p |
|
39 | 39 | |
|
40 | 40 | ####### Output directory |
|
41 | 41 | |
|
42 | 42 | OBJECTS_DIR = obj/ |
|
43 | 43 | |
|
44 | 44 | ####### Files |
|
45 | 45 | |
|
46 | 46 | SOURCES = ../src/wf_handler.c \ |
|
47 | 47 | ../src/tc_handler.c \ |
|
48 | 48 | ../src/fsw_misc.c \ |
|
49 | 49 | ../src/fsw_init.c \ |
|
50 | 50 | ../src/fsw_globals.c \ |
|
51 | 51 | ../src/fsw_spacewire.c \ |
|
52 | 52 | ../src/tc_load_dump_parameters.c \ |
|
53 | 53 | ../src/tm_lfr_tc_exe.c \ |
|
54 | 54 | ../src/tc_acceptance.c \ |
|
55 | 55 | ../src/processing/fsw_processing.c \ |
|
56 | 56 | ../src/processing/avf0_prc0.c \ |
|
57 | 57 | ../src/processing/avf1_prc1.c \ |
|
58 | 58 | ../src/processing/avf2_prc2.c \ |
|
59 | 59 | ../src/lfr_cpu_usage_report.c \ |
|
60 | 60 | ../src/LFR_basic-parameters/basic_parameters.c |
|
61 | 61 | OBJECTS = obj/wf_handler.o \ |
|
62 | 62 | obj/tc_handler.o \ |
|
63 | 63 | obj/fsw_misc.o \ |
|
64 | 64 | obj/fsw_init.o \ |
|
65 | 65 | obj/fsw_globals.o \ |
|
66 | 66 | obj/fsw_spacewire.o \ |
|
67 | 67 | obj/tc_load_dump_parameters.o \ |
|
68 | 68 | obj/tm_lfr_tc_exe.o \ |
|
69 | 69 | obj/tc_acceptance.o \ |
|
70 | 70 | obj/fsw_processing.o \ |
|
71 | 71 | obj/avf0_prc0.o \ |
|
72 | 72 | obj/avf1_prc1.o \ |
|
73 | 73 | obj/avf2_prc2.o \ |
|
74 | 74 | obj/lfr_cpu_usage_report.o \ |
|
75 | 75 | obj/basic_parameters.o |
|
76 | 76 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
77 | 77 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
78 | 78 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
79 | 79 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
80 | 80 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
81 | 81 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
82 | 82 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
83 | 83 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
84 | 84 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
85 | 85 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
86 | 86 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
87 | 87 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
88 | 88 | sparc.pri \ |
|
89 | 89 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
90 | 90 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
91 | 91 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
92 | 92 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
93 | 93 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
94 | 94 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
95 | 95 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
96 | 96 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
97 | 97 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
98 | 98 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ |
|
99 | 99 | fsw-qt.pro |
|
100 | 100 | QMAKE_TARGET = fsw |
|
101 | 101 | DESTDIR = bin/ |
|
102 | 102 | TARGET = bin/fsw |
|
103 | 103 | |
|
104 | 104 | first: all |
|
105 | 105 | ####### Implicit rules |
|
106 | 106 | |
|
107 | 107 | .SUFFIXES: .o .c .cpp .cc .cxx .C |
|
108 | 108 | |
|
109 | 109 | .cpp.o: |
|
110 | 110 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
111 | 111 | |
|
112 | 112 | .cc.o: |
|
113 | 113 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
114 | 114 | |
|
115 | 115 | .cxx.o: |
|
116 | 116 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
117 | 117 | |
|
118 | 118 | .C.o: |
|
119 | 119 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
120 | 120 | |
|
121 | 121 | .c.o: |
|
122 | 122 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" |
|
123 | 123 | |
|
124 | 124 | ####### Build rules |
|
125 | 125 | |
|
126 | 126 | all: Makefile $(TARGET) |
|
127 | 127 | |
|
128 | 128 | $(TARGET): $(OBJECTS) |
|
129 | 129 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ |
|
130 | 130 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) |
|
131 | 131 | |
|
132 | 132 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
133 | 133 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
134 | 134 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
135 | 135 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
136 | 136 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
137 | 137 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
138 | 138 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
139 | 139 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
140 | 140 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
141 | 141 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
142 | 142 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
143 | 143 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
144 | 144 | sparc.pri \ |
|
145 | 145 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
146 | 146 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
147 | 147 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
148 | 148 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
149 | 149 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
150 | 150 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
151 | 151 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
152 | 152 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
153 | 153 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
154 | 154 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf |
|
155 | 155 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
156 | 156 | /usr/lib64/qt4/mkspecs/common/unix.conf: |
|
157 | 157 | /usr/lib64/qt4/mkspecs/common/linux.conf: |
|
158 | 158 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: |
|
159 | 159 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: |
|
160 | 160 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: |
|
161 | 161 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: |
|
162 | 162 | /usr/lib64/qt4/mkspecs/qconfig.pri: |
|
163 | 163 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: |
|
164 | 164 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: |
|
165 | 165 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: |
|
166 | 166 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: |
|
167 | 167 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: |
|
168 | 168 | sparc.pri: |
|
169 | 169 | /usr/lib64/qt4/mkspecs/features/release.prf: |
|
170 | 170 | /usr/lib64/qt4/mkspecs/features/default_post.prf: |
|
171 | 171 | /usr/lib64/qt4/mkspecs/features/shared.prf: |
|
172 | 172 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: |
|
173 | 173 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: |
|
174 | 174 | /usr/lib64/qt4/mkspecs/features/resources.prf: |
|
175 | 175 | /usr/lib64/qt4/mkspecs/features/uic.prf: |
|
176 | 176 | /usr/lib64/qt4/mkspecs/features/yacc.prf: |
|
177 | 177 | /usr/lib64/qt4/mkspecs/features/lex.prf: |
|
178 | 178 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: |
|
179 | 179 | qmake: FORCE |
|
180 | 180 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
181 | 181 | |
|
182 | 182 | dist: |
|
183 | 183 | @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 |
|
184 | 184 | $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0 |
|
185 | 185 | |
|
186 | 186 | |
|
187 | 187 | clean:compiler_clean |
|
188 | 188 | -$(DEL_FILE) $(OBJECTS) |
|
189 | 189 | -$(DEL_FILE) *~ core *.core |
|
190 | 190 | |
|
191 | 191 | |
|
192 | 192 | ####### Sub-libraries |
|
193 | 193 | |
|
194 | 194 | distclean: clean |
|
195 | 195 | -$(DEL_FILE) $(TARGET) |
|
196 | 196 | -$(DEL_FILE) Makefile |
|
197 | 197 | |
|
198 | 198 | |
|
199 | 199 | grmon: |
|
200 | 200 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u |
|
201 | 201 | |
|
202 | 202 | check: first |
|
203 | 203 | |
|
204 | 204 | compiler_rcc_make_all: |
|
205 | 205 | compiler_rcc_clean: |
|
206 | 206 | compiler_uic_make_all: |
|
207 | 207 | compiler_uic_clean: |
|
208 | 208 | compiler_image_collection_make_all: qmake_image_collection.cpp |
|
209 | 209 | compiler_image_collection_clean: |
|
210 | 210 | -$(DEL_FILE) qmake_image_collection.cpp |
|
211 | 211 | compiler_yacc_decl_make_all: |
|
212 | 212 | compiler_yacc_decl_clean: |
|
213 | 213 | compiler_yacc_impl_make_all: |
|
214 | 214 | compiler_yacc_impl_clean: |
|
215 | 215 | compiler_lex_make_all: |
|
216 | 216 | compiler_lex_clean: |
|
217 | 217 | compiler_clean: |
|
218 | 218 | |
|
219 | 219 | ####### Compile |
|
220 | 220 | |
|
221 | 221 | obj/wf_handler.o: ../src/wf_handler.c |
|
222 | 222 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c |
|
223 | 223 | |
|
224 | 224 | obj/tc_handler.o: ../src/tc_handler.c |
|
225 | 225 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c |
|
226 | 226 | |
|
227 | 227 | obj/fsw_misc.o: ../src/fsw_misc.c |
|
228 | 228 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c |
|
229 | 229 | |
|
230 | 230 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c |
|
231 | 231 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c |
|
232 | 232 | |
|
233 | 233 | obj/fsw_globals.o: ../src/fsw_globals.c |
|
234 | 234 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c |
|
235 | 235 | |
|
236 | 236 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c |
|
237 | 237 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c |
|
238 | 238 | |
|
239 | 239 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c |
|
240 | 240 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c |
|
241 | 241 | |
|
242 | 242 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c |
|
243 | 243 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c |
|
244 | 244 | |
|
245 | 245 | obj/tc_acceptance.o: ../src/tc_acceptance.c |
|
246 | 246 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c |
|
247 | 247 | |
|
248 | 248 | obj/fsw_processing.o: ../src/processing/fsw_processing.c |
|
249 | 249 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c |
|
250 | 250 | |
|
251 | 251 | obj/avf0_prc0.o: ../src/processing/avf0_prc0.c |
|
252 | 252 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c |
|
253 | 253 | |
|
254 | 254 | obj/avf1_prc1.o: ../src/processing/avf1_prc1.c |
|
255 | 255 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c |
|
256 | 256 | |
|
257 | 257 | obj/avf2_prc2.o: ../src/processing/avf2_prc2.c |
|
258 | 258 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c |
|
259 | 259 | |
|
260 | 260 | obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c |
|
261 | 261 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c |
|
262 | 262 | |
|
263 | 263 | obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c |
|
264 | 264 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c |
|
265 | 265 | |
|
266 | 266 | ####### Install |
|
267 | 267 | |
|
268 | 268 | install: FORCE |
|
269 | 269 | |
|
270 | 270 | uninstall: FORCE |
|
271 | 271 | |
|
272 | 272 | FORCE: |
|
273 | 273 |
@@ -1,100 +1,108 | |||
|
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 | 4 | # lpp_dpu_destid |
|
5 | 5 | CONFIG += console verbose lpp_dpu_destid |
|
6 | 6 | CONFIG -= qt |
|
7 | 7 | |
|
8 | 8 | include(./sparc.pri) |
|
9 | 9 | |
|
10 | 10 | # flight software version |
|
11 | 11 | SWVERSION=-1-0 |
|
12 | 12 | DEFINES += SW_VERSION_N1=2 # major |
|
13 | 13 | DEFINES += SW_VERSION_N2=0 # minor |
|
14 | 14 | DEFINES += SW_VERSION_N3=1 # patch |
|
15 | 15 | DEFINES += SW_VERSION_N4=1 # internal |
|
16 | 16 | |
|
17 | # <GCOV> | |
|
18 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage | |
|
19 | #QMAKE_LFLAGS_RELEASE += | |
|
20 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc | |
|
21 | # </GCOV> | |
|
22 | ||
|
23 | # <CHANGE BEFORE FLIGHT> | |
|
17 | 24 | contains( CONFIG, lpp_dpu_destid ) { |
|
18 | 25 | DEFINES += LPP_DPU_DESTID |
|
19 | 26 | } |
|
27 | # </CHANGE BEFORE FLIGHT> | |
|
20 | 28 | |
|
21 | 29 | contains( CONFIG, debug_tch ) { |
|
22 | 30 | DEFINES += DEBUG_TCH |
|
23 | 31 | } |
|
24 | 32 | |
|
25 | 33 | contains( CONFIG, vhdl_dev ) { |
|
26 | 34 | DEFINES += VHDL_DEV |
|
27 | 35 | } |
|
28 | 36 | |
|
29 | 37 | contains( CONFIG, verbose ) { |
|
30 | 38 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
31 | 39 | } |
|
32 | 40 | |
|
33 | 41 | contains( CONFIG, debug_messages ) { |
|
34 | 42 | DEFINES += DEBUG_MESSAGES |
|
35 | 43 | } |
|
36 | 44 | |
|
37 | 45 | contains( CONFIG, cpu_usage_report ) { |
|
38 | 46 | DEFINES += PRINT_TASK_STATISTICS |
|
39 | 47 | } |
|
40 | 48 | |
|
41 | 49 | contains( CONFIG, stack_report ) { |
|
42 | 50 | DEFINES += PRINT_STACK_REPORT |
|
43 | 51 | } |
|
44 | 52 | |
|
45 | 53 | contains( CONFIG, boot_messages ) { |
|
46 | 54 | DEFINES += BOOT_MESSAGES |
|
47 | 55 | } |
|
48 | 56 | |
|
49 | 57 | #doxygen.target = doxygen |
|
50 | 58 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
51 | 59 | #QMAKE_EXTRA_TARGETS += doxygen |
|
52 | 60 | |
|
53 | 61 | TARGET = fsw |
|
54 | 62 | |
|
55 | 63 | INCLUDEPATH += \ |
|
56 | 64 | ../src \ |
|
57 | 65 | ../header \ |
|
58 | 66 | ../header/processing \ |
|
59 | 67 | ../src/LFR_basic-parameters |
|
60 | 68 | |
|
61 | 69 | SOURCES += \ |
|
62 | 70 | ../src/wf_handler.c \ |
|
63 | 71 | ../src/tc_handler.c \ |
|
64 | 72 | ../src/fsw_misc.c \ |
|
65 | 73 | ../src/fsw_init.c \ |
|
66 | 74 | ../src/fsw_globals.c \ |
|
67 | 75 | ../src/fsw_spacewire.c \ |
|
68 | 76 | ../src/tc_load_dump_parameters.c \ |
|
69 | 77 | ../src/tm_lfr_tc_exe.c \ |
|
70 | 78 | ../src/tc_acceptance.c \ |
|
71 | 79 | ../src/processing/fsw_processing.c \ |
|
72 | 80 | ../src/processing/avf0_prc0.c \ |
|
73 | 81 | ../src/processing/avf1_prc1.c \ |
|
74 | 82 | ../src/processing/avf2_prc2.c \ |
|
75 | 83 | ../src/lfr_cpu_usage_report.c \ |
|
76 | 84 | ../src/LFR_basic-parameters/basic_parameters.c |
|
77 | 85 | |
|
78 | 86 | HEADERS += \ |
|
79 | 87 | ../header/wf_handler.h \ |
|
80 | 88 | ../header/tc_handler.h \ |
|
81 | 89 | ../header/grlib_regs.h \ |
|
82 | 90 | ../header/fsw_params.h \ |
|
83 | 91 | ../header/fsw_misc.h \ |
|
84 | 92 | ../header/fsw_init.h \ |
|
85 | 93 | ../header/ccsds_types.h \ |
|
86 | 94 | ../header/fsw_spacewire.h \ |
|
87 | 95 | ../header/tc_load_dump_parameters.h \ |
|
88 | 96 | ../header/tm_lfr_tc_exe.h \ |
|
89 | 97 | ../header/tc_acceptance.h \ |
|
90 | 98 | ../header/fsw_params_nb_bytes.h \ |
|
91 | 99 | ../header/fsw_params_processing.h \ |
|
92 | 100 | ../header/processing/fsw_processing.h \ |
|
93 | 101 | ../header/processing/avf0_prc0.h \ |
|
94 | 102 | ../header/processing/avf1_prc1.h \ |
|
95 | 103 | ../header/processing/avf2_prc2.h \ |
|
96 | 104 | ../header/fsw_params_wf_handler.h \ |
|
97 | 105 | ../header/lfr_cpu_usage_report.h \ |
|
98 | 106 | ../src/LFR_basic-parameters/basic_parameters.h \ |
|
99 | 107 | ../src/LFR_basic-parameters/basic_parameters_params.h |
|
100 | 108 |
@@ -1,208 +1,208 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by QtCreator 3.2.0, 2014- |
|
|
3 | <!-- Written by QtCreator 3.2.0, 2014-10-06T16:01:42. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | 6 | <variable>EnvironmentId</variable> |
|
7 | 7 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> |
|
8 | 8 | </data> |
|
9 | 9 | <data> |
|
10 | 10 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
11 | 11 | <value type="int">0</value> |
|
12 | 12 | </data> |
|
13 | 13 | <data> |
|
14 | 14 | <variable>ProjectExplorer.Project.EditorSettings</variable> |
|
15 | 15 | <valuemap type="QVariantMap"> |
|
16 | 16 | <value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
|
17 | 17 | <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
|
18 | 18 | <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
|
19 | 19 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
|
20 | 20 | <value type="QString" key="language">Cpp</value> |
|
21 | 21 | <valuemap type="QVariantMap" key="value"> |
|
22 | 22 | <value type="QByteArray" key="CurrentPreferences">CppGlobal</value> |
|
23 | 23 | </valuemap> |
|
24 | 24 | </valuemap> |
|
25 | 25 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
|
26 | 26 | <value type="QString" key="language">QmlJS</value> |
|
27 | 27 | <valuemap type="QVariantMap" key="value"> |
|
28 | 28 | <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> |
|
29 | 29 | </valuemap> |
|
30 | 30 | </valuemap> |
|
31 | 31 | <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
|
32 | 32 | <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> |
|
33 | 33 | <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
|
34 | 34 | <value type="int" key="EditorConfiguration.IndentSize">4</value> |
|
35 | 35 | <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> |
|
36 | 36 | <value type="int" key="EditorConfiguration.MarginColumn">80</value> |
|
37 | 37 | <value type="bool" key="EditorConfiguration.MouseHiding">true</value> |
|
38 | 38 | <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
|
39 | 39 | <value type="int" key="EditorConfiguration.PaddingMode">1</value> |
|
40 | 40 | <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
|
41 | 41 | <value type="bool" key="EditorConfiguration.ShowMargin">false</value> |
|
42 | 42 | <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
|
43 | 43 | <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
|
44 | 44 | <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
|
45 | 45 | <value type="int" key="EditorConfiguration.TabSize">8</value> |
|
46 | 46 | <value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
|
47 | 47 | <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
|
48 | 48 | <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
|
49 | 49 | <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
|
50 | 50 | <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
|
51 | 51 | <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
|
52 | 52 | </valuemap> |
|
53 | 53 | </data> |
|
54 | 54 | <data> |
|
55 | 55 | <variable>ProjectExplorer.Project.PluginSettings</variable> |
|
56 | 56 | <valuemap type="QVariantMap"/> |
|
57 | 57 | </data> |
|
58 | 58 | <data> |
|
59 | 59 | <variable>ProjectExplorer.Project.Target.0</variable> |
|
60 | 60 | <valuemap type="QVariantMap"> |
|
61 | 61 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
62 | 62 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
63 | 63 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value> |
|
64 | 64 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
65 | 65 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
66 | 66 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
67 | 67 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
68 | 68 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> |
|
69 | 69 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
70 | 70 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
71 | 71 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
72 | 72 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
73 | 73 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
74 | 74 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
75 | 75 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
76 | 76 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value> |
|
77 | 77 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
78 | 78 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
79 | 79 | </valuemap> |
|
80 | 80 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
81 | 81 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
82 | 82 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
83 | 83 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
84 | 84 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
85 | 85 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
86 | 86 | <value type="QString">-w</value> |
|
87 | 87 | <value type="QString">-r</value> |
|
88 | 88 | </valuelist> |
|
89 | 89 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
90 | 90 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
91 | 91 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
92 | 92 | </valuemap> |
|
93 | 93 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
94 | 94 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
95 | 95 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
96 | 96 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
97 | 97 | </valuemap> |
|
98 | 98 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
99 | 99 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
100 | 100 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
101 | 101 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
102 | 102 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
103 | 103 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
104 | 104 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
105 | 105 | <value type="QString">-w</value> |
|
106 | 106 | <value type="QString">-r</value> |
|
107 | 107 | </valuelist> |
|
108 | 108 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
109 | 109 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
110 | 110 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
111 | 111 | </valuemap> |
|
112 | 112 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
113 | 113 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
114 | 114 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
115 | 115 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
116 | 116 | </valuemap> |
|
117 | 117 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
118 | 118 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
119 | 119 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
120 | 120 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
121 | 121 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
122 | 122 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
123 | 123 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
124 | 124 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
125 | 125 | </valuemap> |
|
126 | 126 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
127 | 127 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
128 | 128 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
129 | 129 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
130 | 130 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
131 | 131 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
132 | 132 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
133 | 133 | </valuemap> |
|
134 | 134 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
135 | 135 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
136 | 136 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
137 | 137 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
138 | 138 | </valuemap> |
|
139 | 139 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
140 | 140 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
141 | 141 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
142 | 142 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
143 | 143 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
144 | 144 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
145 | 145 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
146 | 146 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
147 | 147 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
148 | 148 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
149 | 149 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
150 | 150 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
151 | 151 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
152 | 152 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
153 | 153 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
154 | 154 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
155 | 155 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
156 | 156 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
157 | 157 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
158 | 158 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
159 | 159 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
160 | 160 | <value type="int">0</value> |
|
161 | 161 | <value type="int">1</value> |
|
162 | 162 | <value type="int">2</value> |
|
163 | 163 | <value type="int">3</value> |
|
164 | 164 | <value type="int">4</value> |
|
165 | 165 | <value type="int">5</value> |
|
166 | 166 | <value type="int">6</value> |
|
167 | 167 | <value type="int">7</value> |
|
168 | 168 | <value type="int">8</value> |
|
169 | 169 | <value type="int">9</value> |
|
170 | 170 | <value type="int">10</value> |
|
171 | 171 | <value type="int">11</value> |
|
172 | 172 | <value type="int">12</value> |
|
173 | 173 | <value type="int">13</value> |
|
174 | 174 | <value type="int">14</value> |
|
175 | 175 | </valuelist> |
|
176 | 176 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
177 | 177 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
178 | 178 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
179 | 179 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
180 | 180 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
181 | 181 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
182 | 182 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
183 | 183 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
184 | 184 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
185 | 185 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
186 | 186 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
187 | 187 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> |
|
188 | 188 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> |
|
189 | 189 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
190 | 190 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
191 | 191 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
192 | 192 | </valuemap> |
|
193 | 193 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
194 | 194 | </valuemap> |
|
195 | 195 | </data> |
|
196 | 196 | <data> |
|
197 | 197 | <variable>ProjectExplorer.Project.TargetCount</variable> |
|
198 | 198 | <value type="int">1</value> |
|
199 | 199 | </data> |
|
200 | 200 | <data> |
|
201 | 201 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
|
202 | 202 | <value type="int">16</value> |
|
203 | 203 | </data> |
|
204 | 204 | <data> |
|
205 | 205 | <variable>Version</variable> |
|
206 | 206 | <value type="int">16</value> |
|
207 | 207 | </data> |
|
208 | 208 | </qtcreator> |
@@ -1,255 +1,256 | |||
|
1 | 1 | #ifndef FSW_PARAMS_H_INCLUDED |
|
2 | 2 | #define FSW_PARAMS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include "grlib_regs.h" |
|
5 | 5 | #include "fsw_params_processing.h" |
|
6 | 6 | #include "fsw_params_nb_bytes.h" |
|
7 | 7 | #include "tm_byte_positions.h" |
|
8 | 8 | #include "ccsds_types.h" |
|
9 | 9 | |
|
10 | 10 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
11 | 11 | #define UART_DEVICE_NAME "/dev/console" |
|
12 | 12 | |
|
13 | 13 | typedef struct ring_node |
|
14 | 14 | { |
|
15 | 15 | struct ring_node *previous; |
|
16 | 16 | int buffer_address; |
|
17 | 17 | struct ring_node *next; |
|
18 | 18 | unsigned int status; |
|
19 | 19 | } ring_node; |
|
20 | 20 | |
|
21 | 21 | //************************ |
|
22 | 22 | // flight software version |
|
23 | 23 | // this parameters is handled by the Qt project options |
|
24 | 24 | |
|
25 | 25 | #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk |
|
26 | 26 | #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk |
|
27 | 27 | #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688 |
|
28 | 28 | #define TIME_OFFSET 2 |
|
29 | 29 | #define TIME_OFFSET_IN_BYTES 8 |
|
30 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 | |
|
30 | //#define WAVEFORM_EXTENDED_HEADER_OFFSET 22 | |
|
31 | 31 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
32 | 32 | #define NB_WORDS_SWF_BLK 3 |
|
33 | 33 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
34 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 | |
|
34 | //#define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 | |
|
35 | 35 | #define NB_RING_NODES_F0 3 // AT LEAST 3 |
|
36 | 36 | #define NB_RING_NODES_F1 5 // AT LEAST 3 |
|
37 | 37 | #define NB_RING_NODES_F2 5 // AT LEAST 3 |
|
38 | 38 | #define NB_RING_NODES_F3 3 // AT LEAST 3 |
|
39 | 39 | |
|
40 | 40 | //********** |
|
41 | 41 | // LFR MODES |
|
42 | 42 | #define LFR_MODE_STANDBY 0 |
|
43 | 43 | #define LFR_MODE_NORMAL 1 |
|
44 | 44 | #define LFR_MODE_BURST 2 |
|
45 | 45 | #define LFR_MODE_SBM1 3 |
|
46 | 46 | #define LFR_MODE_SBM2 4 |
|
47 | 47 | |
|
48 | 48 | #define TDS_MODE_LFM 5 |
|
49 | 49 | #define TDS_MODE_STANDBY 0 |
|
50 | 50 | #define TDS_MODE_NORMAL 1 |
|
51 | 51 | #define TDS_MODE_BURST 2 |
|
52 | 52 | #define TDS_MODE_SBM1 3 |
|
53 | 53 | #define TDS_MODE_SBM2 4 |
|
54 | 54 | |
|
55 | 55 | #define THR_MODE_STANDBY 0 |
|
56 | 56 | #define THR_MODE_NORMAL 1 |
|
57 | 57 | #define THR_MODE_BURST 2 |
|
58 | 58 | |
|
59 | 59 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
60 | 60 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
61 | 61 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
62 | 62 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
63 | 63 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
64 | 64 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
65 | 65 | #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6 |
|
66 | 66 | #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7 |
|
67 | 67 | #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode |
|
68 | 68 | #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9 |
|
69 | 69 | #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10 |
|
70 | 70 | #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode |
|
71 | 71 | #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12 |
|
72 | 72 | #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13 |
|
73 | 73 | #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode |
|
74 | 74 | #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15 |
|
75 | 75 | #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16 |
|
76 | 76 | #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17 |
|
77 | 77 | #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18 |
|
78 | 78 | #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19 |
|
79 | 79 | #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20 |
|
80 | 80 | #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21 |
|
81 | 81 | #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22 |
|
82 | 82 | |
|
83 | 83 | //**************************** |
|
84 | 84 | // LFR DEFAULT MODE PARAMETERS |
|
85 | 85 | // COMMON |
|
86 | 86 | #define DEFAULT_SY_LFR_COMMON0 0x00 |
|
87 | 87 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 |
|
88 | 88 | // NORM |
|
89 | 89 | #define DFLT_SY_LFR_N_SWF_L 2048 // nb sample |
|
90 | 90 | #define DFLT_SY_LFR_N_SWF_P 300 // sec |
|
91 | 91 | #define DFLT_SY_LFR_N_ASM_P 3600 // sec |
|
92 | 92 | #define DFLT_SY_LFR_N_BP_P0 4 // sec |
|
93 | 93 | #define DFLT_SY_LFR_N_BP_P1 20 // sec |
|
94 | 94 | #define DFLT_SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 |
|
95 | 95 | #define MIN_DELTA_SNAPSHOT 16 // sec |
|
96 | 96 | // BURST |
|
97 | 97 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec |
|
98 | 98 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec |
|
99 | 99 | // SBM1 |
|
100 | 100 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec |
|
101 | 101 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec |
|
102 | 102 | // SBM2 |
|
103 | 103 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec |
|
104 | 104 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec |
|
105 | 105 | // ADDITIONAL PARAMETERS |
|
106 | 106 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms |
|
107 | 107 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s |
|
108 | 108 | // STATUS WORD |
|
109 | 109 | #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits |
|
110 | 110 | #define DEFAULT_STATUS_WORD_BYTE1 0x00 |
|
111 | 111 | // |
|
112 | 112 | #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s |
|
113 | 113 | #define SY_LFR_DPU_CONNECT_ATTEMPT 3 |
|
114 | 114 | //**************************** |
|
115 | 115 | |
|
116 | 116 | //***************************** |
|
117 | 117 | // APB REGISTERS BASE ADDRESSES |
|
118 | 118 | #define REGS_ADDR_APBUART 0x80000100 |
|
119 | 119 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
120 | 120 | #define REGS_ADDR_GRSPW 0x80000500 |
|
121 | 121 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
122 | 122 | #define REGS_ADDR_GRGPIO 0x80000b00 |
|
123 | 123 | |
|
124 | 124 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 |
|
125 | 125 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50 |
|
126 | 126 | #define REGS_ADDR_VHDL_VERSION 0x80000ff0 |
|
127 | 127 | |
|
128 | 128 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
129 | 129 | #define APBUART_CTRL_REG_MASK_TE 0x00000002 |
|
130 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) | |
|
130 | // scaler value = system_clock_frequency / ( baud_rate * 8 ) - 1 | |
|
131 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 | |
|
131 | 132 | |
|
132 | 133 | //********** |
|
133 | 134 | // IRQ LINES |
|
134 | 135 | #define IRQ_SM_SIMULATOR 9 |
|
135 | 136 | #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
136 | 137 | #define IRQ_WAVEFORM_PICKER 14 |
|
137 | 138 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
138 | 139 | #define IRQ_SPECTRAL_MATRIX 6 |
|
139 | 140 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
140 | 141 | |
|
141 | 142 | //***** |
|
142 | 143 | // TIME |
|
143 | 144 | #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416 |
|
144 | 145 | #define TIMER_SM_SIMULATOR 1 |
|
145 | 146 | #define HK_PERIOD 100 // 100 * 10ms => 1s |
|
146 | 147 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000 |
|
147 | 148 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s |
|
148 | 149 | |
|
149 | 150 | //********** |
|
150 | 151 | // LPP CODES |
|
151 | 152 | #define LFR_SUCCESSFUL 0 |
|
152 | 153 | #define LFR_DEFAULT 1 |
|
153 | 154 | #define LFR_EXE_ERROR 2 |
|
154 | 155 | |
|
155 | 156 | //****** |
|
156 | 157 | // RTEMS |
|
157 | 158 | #define TASKID_RECV 1 |
|
158 | 159 | #define TASKID_ACTN 2 |
|
159 | 160 | #define TASKID_SPIQ 3 |
|
160 | 161 | #define TASKID_STAT 4 |
|
161 | 162 | #define TASKID_AVF0 5 |
|
162 | 163 | #define TASKID_SWBD 6 |
|
163 | 164 | #define TASKID_WFRM 7 |
|
164 | 165 | #define TASKID_DUMB 8 |
|
165 | 166 | #define TASKID_HOUS 9 |
|
166 | 167 | #define TASKID_PRC0 10 |
|
167 | 168 | #define TASKID_CWF3 11 |
|
168 | 169 | #define TASKID_CWF2 12 |
|
169 | 170 | #define TASKID_CWF1 13 |
|
170 | 171 | #define TASKID_SEND 14 |
|
171 | 172 | #define TASKID_WTDG 15 |
|
172 | 173 | #define TASKID_AVF1 16 |
|
173 | 174 | #define TASKID_PRC1 17 |
|
174 | 175 | #define TASKID_AVF2 18 |
|
175 | 176 | #define TASKID_PRC2 19 |
|
176 | 177 | |
|
177 | 178 | #define TASK_PRIORITY_SPIQ 5 |
|
178 | 179 | #define TASK_PRIORITY_WTDG 20 |
|
179 | 180 | #define TASK_PRIORITY_HOUS 30 |
|
180 | 181 | #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together |
|
181 | 182 | #define TASK_PRIORITY_CWF2 35 // |
|
182 | 183 | #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it |
|
183 | 184 | #define TASK_PRIORITY_WFRM 40 |
|
184 | 185 | #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 |
|
185 | 186 | #define TASK_PRIORITY_SEND 45 |
|
186 | 187 | #define TASK_PRIORITY_RECV 50 |
|
187 | 188 | #define TASK_PRIORITY_ACTN 50 |
|
188 | 189 | #define TASK_PRIORITY_AVF0 60 |
|
189 | 190 | #define TASK_PRIORITY_AVF1 70 |
|
190 | 191 | #define TASK_PRIORITY_PRC0 100 |
|
191 | 192 | #define TASK_PRIORITY_PRC1 100 |
|
192 | 193 | #define TASK_PRIORITY_AVF2 110 |
|
193 | 194 | #define TASK_PRIORITY_PRC2 110 |
|
194 | 195 | #define TASK_PRIORITY_STAT 200 |
|
195 | 196 | #define TASK_PRIORITY_DUMB 200 |
|
196 | 197 | |
|
197 | 198 | #define MSG_QUEUE_COUNT_RECV 10 |
|
198 | 199 | #define MSG_QUEUE_COUNT_SEND 50 |
|
199 | 200 | #define MSG_QUEUE_COUNT_PRC0 10 |
|
200 | 201 | #define MSG_QUEUE_COUNT_PRC1 10 |
|
201 | 202 | #define MSG_QUEUE_COUNT_PRC2 5 |
|
202 | 203 | #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1 |
|
203 | 204 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
204 | 205 | #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers |
|
205 | 206 | #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers |
|
206 | 207 | #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers |
|
207 | 208 | |
|
208 | 209 | #define QUEUE_RECV 0 |
|
209 | 210 | #define QUEUE_SEND 1 |
|
210 | 211 | #define QUEUE_PRC0 2 |
|
211 | 212 | #define QUEUE_PRC1 3 |
|
212 | 213 | #define QUEUE_PRC2 4 |
|
213 | 214 | |
|
214 | 215 | //******* |
|
215 | 216 | // MACROS |
|
216 | 217 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
217 | 218 | #define PRINTF(x) printf(x); |
|
218 | 219 | #define PRINTF1(x,y) printf(x,y); |
|
219 | 220 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
220 | 221 | #else |
|
221 | 222 | #define PRINTF(x) ; |
|
222 | 223 | #define PRINTF1(x,y) ; |
|
223 | 224 | #define PRINTF2(x,y,z) ; |
|
224 | 225 | #endif |
|
225 | 226 | |
|
226 | 227 | #ifdef BOOT_MESSAGES |
|
227 | 228 | #define BOOT_PRINTF(x) printf(x); |
|
228 | 229 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
229 | 230 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
230 | 231 | #else |
|
231 | 232 | #define BOOT_PRINTF(x) ; |
|
232 | 233 | #define BOOT_PRINTF1(x,y) ; |
|
233 | 234 | #define BOOT_PRINTF2(x,y,z) ; |
|
234 | 235 | #endif |
|
235 | 236 | |
|
236 | 237 | #ifdef DEBUG_MESSAGES |
|
237 | 238 | #define DEBUG_PRINTF(x) printf(x); |
|
238 | 239 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
239 | 240 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
240 | 241 | #else |
|
241 | 242 | #define DEBUG_PRINTF(x) ; |
|
242 | 243 | #define DEBUG_PRINTF1(x,y) ; |
|
243 | 244 | #define DEBUG_PRINTF2(x,y,z) ; |
|
244 | 245 | #endif |
|
245 | 246 | |
|
246 | 247 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
247 | 248 | |
|
248 | 249 | struct param_local_str{ |
|
249 | 250 | unsigned int local_sbm1_nb_cwf_sent; |
|
250 | 251 | unsigned int local_sbm1_nb_cwf_max; |
|
251 | 252 | unsigned int local_sbm2_nb_cwf_sent; |
|
252 | 253 | unsigned int local_sbm2_nb_cwf_max; |
|
253 | 254 | }; |
|
254 | 255 | |
|
255 | 256 | #endif // FSW_PARAMS_H_INCLUDED |
@@ -1,92 +1,92 | |||
|
1 | 1 | #ifndef WF_HANDLER_H_INCLUDED |
|
2 | 2 | #define WF_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <grspw.h> |
|
6 | 6 | #include <stdio.h> |
|
7 | 7 | #include <math.h> |
|
8 | 8 | |
|
9 | 9 | #include "fsw_params.h" |
|
10 | 10 | #include "fsw_spacewire.h" |
|
11 | 11 | #include "fsw_misc.h" |
|
12 | 12 | #include "fsw_params_wf_handler.h" |
|
13 | 13 | |
|
14 | 14 | #define pi 3.1415 |
|
15 | 15 | |
|
16 | 16 | extern int fdSPW; |
|
17 | 17 | |
|
18 | 18 | //***************** |
|
19 | 19 | // waveform buffers |
|
20 | 20 | extern volatile int wf_snap_f0[ ]; |
|
21 | 21 | extern volatile int wf_snap_f1[ ]; |
|
22 | 22 | extern volatile int wf_snap_f2[ ]; |
|
23 | 23 | extern volatile int wf_cont_f3[ ]; |
|
24 | 24 | extern char wf_cont_f3_light[ ]; |
|
25 | 25 | |
|
26 | 26 | extern waveform_picker_regs_new_t *waveform_picker_regs; |
|
27 | 27 | extern time_management_regs_t *time_management_regs; |
|
28 | 28 | extern Packet_TM_LFR_HK_t housekeeping_packet; |
|
29 | 29 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
30 | 30 | extern struct param_local_str param_local; |
|
31 | 31 | |
|
32 | 32 | extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
33 | 33 | extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
34 | 34 | |
|
35 | 35 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
36 | 36 | |
|
37 | 37 | extern unsigned char lfrCurrentMode; |
|
38 | 38 | |
|
39 | 39 | //********** |
|
40 | 40 | // RTEMS_ISR |
|
41 | 41 | void reset_extractSWF( void ); |
|
42 | 42 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
43 | 43 | |
|
44 | 44 | //*********** |
|
45 | 45 | // RTEMS_TASK |
|
46 | 46 | rtems_task wfrm_task( rtems_task_argument argument ); |
|
47 | 47 | rtems_task cwf3_task( rtems_task_argument argument ); |
|
48 | 48 | rtems_task cwf2_task( rtems_task_argument argument ); |
|
49 | 49 | rtems_task cwf1_task( rtems_task_argument argument ); |
|
50 | 50 | rtems_task swbd_task( rtems_task_argument argument ); |
|
51 | 51 | |
|
52 | 52 | //****************** |
|
53 | 53 | // general functions |
|
54 | 54 | void WFP_init_rings( void ); |
|
55 | 55 | void init_waveform_ring( ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] ); |
|
56 | 56 | void WFP_reset_current_ring_nodes( void ); |
|
57 | 57 | // |
|
58 | 58 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF ); |
|
59 | 59 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
60 | 60 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
61 | 61 | // |
|
62 | 62 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ); |
|
63 | 63 | int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
64 | 64 | int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
65 | 65 | int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); |
|
66 | 66 | // |
|
67 | 67 | void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime, |
|
68 | 68 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); |
|
69 | 69 | void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel ); |
|
70 | void build_acquisition_time( unsigned long long int * acquisitionTimeAslong, ring_node *current_ring_node ); | |
|
70 | void snapshot_resynchronization( unsigned char *timePtr ); | |
|
71 | 71 | // |
|
72 | 72 | rtems_id get_pkts_queue_id( void ); |
|
73 | 73 | |
|
74 | 74 | //************** |
|
75 | 75 | // wfp registers |
|
76 | 76 | // RESET |
|
77 | 77 | void reset_wfp_burst_enable( void ); |
|
78 | 78 | void reset_wfp_status(void); |
|
79 | 79 | void reset_waveform_picker_regs( void ); |
|
80 | 80 | // SET |
|
81 | 81 | void set_wfp_data_shaping(void); |
|
82 | 82 | void set_wfp_burst_enable_register( unsigned char mode ); |
|
83 | 83 | void set_wfp_delta_snapshot( void ); |
|
84 | 84 | void set_wfp_delta_f0_f0_2( void ); |
|
85 | 85 | void set_wfp_delta_f1( void ); |
|
86 | 86 | void set_wfp_delta_f2( void ); |
|
87 | 87 | |
|
88 | 88 | //***************** |
|
89 | 89 | // local parameters |
|
90 | 90 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); |
|
91 | 91 | |
|
92 | 92 | #endif // WF_HANDLER_H_INCLUDED |
@@ -1,947 +1,949 | |||
|
1 | 1 | /** Functions and tasks related to TeleCommand handling. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TeleCommands:\n |
|
7 | 7 | * action launching\n |
|
8 | 8 | * TC parsing\n |
|
9 | 9 | * ... |
|
10 | 10 | * |
|
11 | 11 | */ |
|
12 | 12 | |
|
13 | 13 | #include "tc_handler.h" |
|
14 | 14 | |
|
15 | 15 | //*********** |
|
16 | 16 | // RTEMS TASK |
|
17 | 17 | |
|
18 | 18 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | 19 | { |
|
20 | 20 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | 21 | * |
|
22 | 22 | * @param unused is the starting argument of the RTEMS task |
|
23 | 23 | * |
|
24 | 24 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | 25 | * on the incoming TeleCommand. |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | int result; |
|
30 | 30 | rtems_status_code status; // RTEMS status code |
|
31 | 31 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | 32 | size_t size; // size of the incoming TC packet |
|
33 | 33 | unsigned char subtype; // subtype of the current TC packet |
|
34 | 34 | unsigned char time[6]; |
|
35 | 35 | rtems_id queue_rcv_id; |
|
36 | 36 | rtems_id queue_snd_id; |
|
37 | 37 | |
|
38 | 38 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | 39 | if (status != RTEMS_SUCCESSFUL) |
|
40 | 40 | { |
|
41 | 41 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | 45 | if (status != RTEMS_SUCCESSFUL) |
|
46 | 46 | { |
|
47 | 47 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | result = LFR_SUCCESSFUL; |
|
51 | 51 | subtype = 0; // subtype of the current TC packet |
|
52 | 52 | |
|
53 | 53 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | 54 | |
|
55 | 55 | while(1) |
|
56 | 56 | { |
|
57 | 57 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | 58 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | 59 | getTime( time ); // set time to the current time |
|
60 | 60 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | 61 | { |
|
62 | 62 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | subtype = TC.serviceSubType; |
|
67 | 67 | switch(subtype) |
|
68 | 68 | { |
|
69 | 69 | case TC_SUBTYPE_RESET: |
|
70 | 70 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | 71 | close_action( &TC, result, queue_snd_id ); |
|
72 | 72 | break; |
|
73 | 73 | // |
|
74 | 74 | case TC_SUBTYPE_LOAD_COMM: |
|
75 | 75 | result = action_load_common_par( &TC ); |
|
76 | 76 | close_action( &TC, result, queue_snd_id ); |
|
77 | 77 | break; |
|
78 | 78 | // |
|
79 | 79 | case TC_SUBTYPE_LOAD_NORM: |
|
80 | 80 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
81 | 81 | close_action( &TC, result, queue_snd_id ); |
|
82 | 82 | break; |
|
83 | 83 | // |
|
84 | 84 | case TC_SUBTYPE_LOAD_BURST: |
|
85 | 85 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
86 | 86 | close_action( &TC, result, queue_snd_id ); |
|
87 | 87 | break; |
|
88 | 88 | // |
|
89 | 89 | case TC_SUBTYPE_LOAD_SBM1: |
|
90 | 90 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
91 | 91 | close_action( &TC, result, queue_snd_id ); |
|
92 | 92 | break; |
|
93 | 93 | // |
|
94 | 94 | case TC_SUBTYPE_LOAD_SBM2: |
|
95 | 95 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
96 | 96 | close_action( &TC, result, queue_snd_id ); |
|
97 | 97 | break; |
|
98 | 98 | // |
|
99 | 99 | case TC_SUBTYPE_DUMP: |
|
100 | 100 | result = action_dump_par( queue_snd_id ); |
|
101 | 101 | close_action( &TC, result, queue_snd_id ); |
|
102 | 102 | break; |
|
103 | 103 | // |
|
104 | 104 | case TC_SUBTYPE_ENTER: |
|
105 | 105 | result = action_enter_mode( &TC, queue_snd_id ); |
|
106 | 106 | close_action( &TC, result, queue_snd_id ); |
|
107 | 107 | break; |
|
108 | 108 | // |
|
109 | 109 | case TC_SUBTYPE_UPDT_INFO: |
|
110 | 110 | result = action_update_info( &TC, queue_snd_id ); |
|
111 | 111 | close_action( &TC, result, queue_snd_id ); |
|
112 | 112 | break; |
|
113 | 113 | // |
|
114 | 114 | case TC_SUBTYPE_EN_CAL: |
|
115 | 115 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
116 | 116 | close_action( &TC, result, queue_snd_id ); |
|
117 | 117 | break; |
|
118 | 118 | // |
|
119 | 119 | case TC_SUBTYPE_DIS_CAL: |
|
120 | 120 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
121 | 121 | close_action( &TC, result, queue_snd_id ); |
|
122 | 122 | break; |
|
123 | 123 | // |
|
124 | 124 | case TC_SUBTYPE_UPDT_TIME: |
|
125 | 125 | result = action_update_time( &TC ); |
|
126 | 126 | close_action( &TC, result, queue_snd_id ); |
|
127 | 127 | break; |
|
128 | 128 | // |
|
129 | 129 | default: |
|
130 | 130 | break; |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | } |
|
135 | 135 | |
|
136 | 136 | //*********** |
|
137 | 137 | // TC ACTIONS |
|
138 | 138 | |
|
139 | 139 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | 140 | { |
|
141 | 141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | 142 | * |
|
143 | 143 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | 144 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | 145 | * |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | printf("this is the end!!!\n"); | |
|
149 | exit(0); | |
|
148 | 150 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
149 | 151 | return LFR_DEFAULT; |
|
150 | 152 | } |
|
151 | 153 | |
|
152 | 154 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
153 | 155 | { |
|
154 | 156 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
155 | 157 | * |
|
156 | 158 | * @param TC points to the TeleCommand packet that is being processed |
|
157 | 159 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
158 | 160 | * |
|
159 | 161 | */ |
|
160 | 162 | |
|
161 | 163 | rtems_status_code status; |
|
162 | 164 | unsigned char requestedMode; |
|
163 | 165 | unsigned int *transitionCoarseTime_ptr; |
|
164 | 166 | unsigned int transitionCoarseTime; |
|
165 | 167 | unsigned char * bytePosPtr; |
|
166 | 168 | |
|
167 | 169 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
168 | 170 | |
|
169 | 171 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
170 | 172 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
171 | 173 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
172 | 174 | |
|
173 | 175 | status = check_mode_value( requestedMode ); |
|
174 | 176 | |
|
175 | 177 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
176 | 178 | { |
|
177 | 179 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
178 | 180 | } |
|
179 | 181 | else // the mode value is consistent, check the transition |
|
180 | 182 | { |
|
181 | 183 | status = check_mode_transition(requestedMode); |
|
182 | 184 | if (status != LFR_SUCCESSFUL) |
|
183 | 185 | { |
|
184 | 186 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
185 | 187 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
186 | 188 | } |
|
187 | 189 | } |
|
188 | 190 | |
|
189 | 191 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode |
|
190 | 192 | { |
|
191 | 193 | status = check_transition_date( transitionCoarseTime ); |
|
192 | 194 | if (status != LFR_SUCCESSFUL) |
|
193 | 195 | { |
|
194 | 196 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
195 | 197 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
196 | 198 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
197 | 199 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
198 | 200 | } |
|
199 | 201 | } |
|
200 | 202 | |
|
201 | 203 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
202 | 204 | { |
|
203 | 205 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
204 | 206 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
205 | 207 | } |
|
206 | 208 | |
|
207 | 209 | return status; |
|
208 | 210 | } |
|
209 | 211 | |
|
210 | 212 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
211 | 213 | { |
|
212 | 214 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
213 | 215 | * |
|
214 | 216 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | 217 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
216 | 218 | * |
|
217 | 219 | * @return LFR directive status code: |
|
218 | 220 | * - LFR_DEFAULT |
|
219 | 221 | * - LFR_SUCCESSFUL |
|
220 | 222 | * |
|
221 | 223 | */ |
|
222 | 224 | |
|
223 | 225 | unsigned int val; |
|
224 | 226 | int result; |
|
225 | 227 | unsigned int status; |
|
226 | 228 | unsigned char mode; |
|
227 | 229 | unsigned char * bytePosPtr; |
|
228 | 230 | |
|
229 | 231 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
230 | 232 | |
|
231 | 233 | // check LFR mode |
|
232 | 234 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
233 | 235 | status = check_update_info_hk_lfr_mode( mode ); |
|
234 | 236 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
235 | 237 | { |
|
236 | 238 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
237 | 239 | status = check_update_info_hk_tds_mode( mode ); |
|
238 | 240 | } |
|
239 | 241 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
240 | 242 | { |
|
241 | 243 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
242 | 244 | status = check_update_info_hk_thr_mode( mode ); |
|
243 | 245 | } |
|
244 | 246 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
245 | 247 | { |
|
246 | 248 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
247 | 249 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
248 | 250 | val++; |
|
249 | 251 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
250 | 252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
251 | 253 | } |
|
252 | 254 | |
|
253 | 255 | result = status; |
|
254 | 256 | |
|
255 | 257 | return result; |
|
256 | 258 | } |
|
257 | 259 | |
|
258 | 260 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
259 | 261 | { |
|
260 | 262 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
261 | 263 | * |
|
262 | 264 | * @param TC points to the TeleCommand packet that is being processed |
|
263 | 265 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
264 | 266 | * |
|
265 | 267 | */ |
|
266 | 268 | |
|
267 | 269 | int result; |
|
268 | 270 | unsigned char lfrMode; |
|
269 | 271 | |
|
270 | 272 | result = LFR_DEFAULT; |
|
271 | 273 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
272 | 274 | |
|
273 | 275 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
274 | 276 | result = LFR_DEFAULT; |
|
275 | 277 | |
|
276 | 278 | return result; |
|
277 | 279 | } |
|
278 | 280 | |
|
279 | 281 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
280 | 282 | { |
|
281 | 283 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
282 | 284 | * |
|
283 | 285 | * @param TC points to the TeleCommand packet that is being processed |
|
284 | 286 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
285 | 287 | * |
|
286 | 288 | */ |
|
287 | 289 | |
|
288 | 290 | int result; |
|
289 | 291 | unsigned char lfrMode; |
|
290 | 292 | |
|
291 | 293 | result = LFR_DEFAULT; |
|
292 | 294 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
293 | 295 | |
|
294 | 296 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
295 | 297 | result = LFR_DEFAULT; |
|
296 | 298 | |
|
297 | 299 | return result; |
|
298 | 300 | } |
|
299 | 301 | |
|
300 | 302 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
301 | 303 | { |
|
302 | 304 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
303 | 305 | * |
|
304 | 306 | * @param TC points to the TeleCommand packet that is being processed |
|
305 | 307 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
306 | 308 | * |
|
307 | 309 | * @return LFR_SUCCESSFUL |
|
308 | 310 | * |
|
309 | 311 | */ |
|
310 | 312 | |
|
311 | 313 | unsigned int val; |
|
312 | 314 | |
|
313 | 315 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
314 | 316 | + (TC->dataAndCRC[1] << 16) |
|
315 | 317 | + (TC->dataAndCRC[2] << 8) |
|
316 | 318 | + TC->dataAndCRC[3]; |
|
317 | 319 | |
|
318 | 320 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
319 | 321 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
320 | 322 | val++; |
|
321 | 323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
322 | 324 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
323 | 325 | |
|
324 | 326 | return LFR_SUCCESSFUL; |
|
325 | 327 | } |
|
326 | 328 | |
|
327 | 329 | //******************* |
|
328 | 330 | // ENTERING THE MODES |
|
329 | 331 | int check_mode_value( unsigned char requestedMode ) |
|
330 | 332 | { |
|
331 | 333 | int status; |
|
332 | 334 | |
|
333 | 335 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
334 | 336 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
335 | 337 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
336 | 338 | { |
|
337 | 339 | status = LFR_DEFAULT; |
|
338 | 340 | } |
|
339 | 341 | else |
|
340 | 342 | { |
|
341 | 343 | status = LFR_SUCCESSFUL; |
|
342 | 344 | } |
|
343 | 345 | |
|
344 | 346 | return status; |
|
345 | 347 | } |
|
346 | 348 | |
|
347 | 349 | int check_mode_transition( unsigned char requestedMode ) |
|
348 | 350 | { |
|
349 | 351 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
350 | 352 | * |
|
351 | 353 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
352 | 354 | * |
|
353 | 355 | * @return LFR directive status codes: |
|
354 | 356 | * - LFR_SUCCESSFUL - the transition is authorized |
|
355 | 357 | * - LFR_DEFAULT - the transition is not authorized |
|
356 | 358 | * |
|
357 | 359 | */ |
|
358 | 360 | |
|
359 | 361 | int status; |
|
360 | 362 | |
|
361 | 363 | switch (requestedMode) |
|
362 | 364 | { |
|
363 | 365 | case LFR_MODE_STANDBY: |
|
364 | 366 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
365 | 367 | status = LFR_DEFAULT; |
|
366 | 368 | } |
|
367 | 369 | else |
|
368 | 370 | { |
|
369 | 371 | status = LFR_SUCCESSFUL; |
|
370 | 372 | } |
|
371 | 373 | break; |
|
372 | 374 | case LFR_MODE_NORMAL: |
|
373 | 375 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
374 | 376 | status = LFR_DEFAULT; |
|
375 | 377 | } |
|
376 | 378 | else { |
|
377 | 379 | status = LFR_SUCCESSFUL; |
|
378 | 380 | } |
|
379 | 381 | break; |
|
380 | 382 | case LFR_MODE_BURST: |
|
381 | 383 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
382 | 384 | status = LFR_DEFAULT; |
|
383 | 385 | } |
|
384 | 386 | else { |
|
385 | 387 | status = LFR_SUCCESSFUL; |
|
386 | 388 | } |
|
387 | 389 | break; |
|
388 | 390 | case LFR_MODE_SBM1: |
|
389 | 391 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
390 | 392 | status = LFR_DEFAULT; |
|
391 | 393 | } |
|
392 | 394 | else { |
|
393 | 395 | status = LFR_SUCCESSFUL; |
|
394 | 396 | } |
|
395 | 397 | break; |
|
396 | 398 | case LFR_MODE_SBM2: |
|
397 | 399 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
398 | 400 | status = LFR_DEFAULT; |
|
399 | 401 | } |
|
400 | 402 | else { |
|
401 | 403 | status = LFR_SUCCESSFUL; |
|
402 | 404 | } |
|
403 | 405 | break; |
|
404 | 406 | default: |
|
405 | 407 | status = LFR_DEFAULT; |
|
406 | 408 | break; |
|
407 | 409 | } |
|
408 | 410 | |
|
409 | 411 | return status; |
|
410 | 412 | } |
|
411 | 413 | |
|
412 | 414 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
413 | 415 | { |
|
414 | 416 | int status; |
|
415 | 417 | unsigned int localCoarseTime; |
|
416 | 418 | unsigned int deltaCoarseTime; |
|
417 | 419 | |
|
418 | 420 | status = LFR_SUCCESSFUL; |
|
419 | 421 | |
|
420 | 422 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
421 | 423 | { |
|
422 | 424 | status = LFR_SUCCESSFUL; |
|
423 | 425 | } |
|
424 | 426 | else |
|
425 | 427 | { |
|
426 | 428 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
427 | 429 | |
|
428 | 430 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
429 | 431 | { |
|
430 | 432 | status = LFR_DEFAULT; |
|
431 | 433 | PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime) |
|
432 | 434 | } |
|
433 | 435 | |
|
434 | 436 | if (status == LFR_SUCCESSFUL) |
|
435 | 437 | { |
|
436 | 438 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
437 | 439 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
438 | 440 | { |
|
439 | 441 | status = LFR_DEFAULT; |
|
440 | 442 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
441 | 443 | } |
|
442 | 444 | } |
|
443 | 445 | } |
|
444 | 446 | |
|
445 | 447 | return status; |
|
446 | 448 | } |
|
447 | 449 | |
|
448 | 450 | int stop_current_mode( void ) |
|
449 | 451 | { |
|
450 | 452 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
451 | 453 | * |
|
452 | 454 | * @return RTEMS directive status codes: |
|
453 | 455 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
454 | 456 | * - RTEMS_INVALID_ID - task id invalid |
|
455 | 457 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
456 | 458 | * |
|
457 | 459 | */ |
|
458 | 460 | |
|
459 | 461 | rtems_status_code status; |
|
460 | 462 | |
|
461 | 463 | status = RTEMS_SUCCESSFUL; |
|
462 | 464 | |
|
463 | 465 | // (1) mask interruptions |
|
464 | 466 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
465 | 467 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
466 | 468 | |
|
467 | 469 | // (2) clear interruptions |
|
468 | 470 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
469 | 471 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
470 | 472 | |
|
471 | 473 | // (3) reset waveform picker registers |
|
472 | 474 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
473 | 475 | reset_wfp_status(); // reset all the status bits |
|
474 | 476 | |
|
475 | 477 | // (4) reset spectral matrices registers |
|
476 | 478 | set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices |
|
477 | 479 | set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0 |
|
478 | 480 | reset_extractSWF(); // reset the extractSWF flag to false |
|
479 | 481 | |
|
480 | 482 | // <Spectral Matrices simulator> |
|
481 | 483 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
482 | 484 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
483 | 485 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
484 | 486 | // </Spectral Matrices simulator> |
|
485 | 487 | |
|
486 | 488 | // suspend several tasks |
|
487 | 489 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
488 | 490 | status = suspend_science_tasks(); |
|
489 | 491 | } |
|
490 | 492 | |
|
491 | 493 | if (status != RTEMS_SUCCESSFUL) |
|
492 | 494 | { |
|
493 | 495 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
494 | 496 | } |
|
495 | 497 | |
|
496 | 498 | return status; |
|
497 | 499 | } |
|
498 | 500 | |
|
499 | 501 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
500 | 502 | { |
|
501 | 503 | /** This function is launched after a mode transition validation. |
|
502 | 504 | * |
|
503 | 505 | * @param mode is the mode in which LFR will be put. |
|
504 | 506 | * |
|
505 | 507 | * @return RTEMS directive status codes: |
|
506 | 508 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
507 | 509 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
508 | 510 | * |
|
509 | 511 | */ |
|
510 | 512 | |
|
511 | 513 | rtems_status_code status; |
|
512 | 514 | |
|
513 | 515 | //********************** |
|
514 | 516 | // STOP THE CURRENT MODE |
|
515 | 517 | status = stop_current_mode(); |
|
516 | 518 | if (status != RTEMS_SUCCESSFUL) |
|
517 | 519 | { |
|
518 | 520 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
519 | 521 | } |
|
520 | 522 | |
|
521 | 523 | //************************* |
|
522 | 524 | // ENTER THE REQUESTED MODE |
|
523 | 525 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
524 | 526 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
525 | 527 | { |
|
526 | 528 | #ifdef PRINT_TASK_STATISTICS |
|
527 | 529 | rtems_cpu_usage_reset(); |
|
528 | 530 | maxCount = 0; |
|
529 | 531 | #endif |
|
530 | 532 | status = restart_science_tasks( mode ); |
|
531 | 533 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
532 | 534 | launch_spectral_matrix( ); |
|
533 | 535 | // launch_spectral_matrix_simu( ); |
|
534 | 536 | } |
|
535 | 537 | else if ( mode == LFR_MODE_STANDBY ) |
|
536 | 538 | { |
|
537 | 539 | #ifdef PRINT_TASK_STATISTICS |
|
538 | 540 | rtems_cpu_usage_report(); |
|
539 | 541 | #endif |
|
540 | 542 | |
|
541 | 543 | #ifdef PRINT_STACK_REPORT |
|
542 | 544 | PRINTF("stack report selected\n") |
|
543 | 545 | rtems_stack_checker_report_usage(); |
|
544 | 546 | #endif |
|
545 | 547 | PRINTF1("maxCount = %d\n", maxCount) |
|
546 | 548 | } |
|
547 | 549 | else |
|
548 | 550 | { |
|
549 | 551 | status = RTEMS_UNSATISFIED; |
|
550 | 552 | } |
|
551 | 553 | |
|
552 | 554 | if (status != RTEMS_SUCCESSFUL) |
|
553 | 555 | { |
|
554 | 556 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
555 | 557 | status = RTEMS_UNSATISFIED; |
|
556 | 558 | } |
|
557 | 559 | |
|
558 | 560 | return status; |
|
559 | 561 | } |
|
560 | 562 | |
|
561 | 563 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
562 | 564 | { |
|
563 | 565 | /** This function is used to restart all science tasks. |
|
564 | 566 | * |
|
565 | 567 | * @return RTEMS directive status codes: |
|
566 | 568 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
567 | 569 | * - RTEMS_INVALID_ID - task id invalid |
|
568 | 570 | * - RTEMS_INCORRECT_STATE - task never started |
|
569 | 571 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
570 | 572 | * |
|
571 | 573 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
572 | 574 | * |
|
573 | 575 | */ |
|
574 | 576 | |
|
575 | 577 | rtems_status_code status[10]; |
|
576 | 578 | rtems_status_code ret; |
|
577 | 579 | |
|
578 | 580 | ret = RTEMS_SUCCESSFUL; |
|
579 | 581 | |
|
580 | 582 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
581 | 583 | if (status[0] != RTEMS_SUCCESSFUL) |
|
582 | 584 | { |
|
583 | 585 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
584 | 586 | } |
|
585 | 587 | |
|
586 | 588 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
587 | 589 | if (status[1] != RTEMS_SUCCESSFUL) |
|
588 | 590 | { |
|
589 | 591 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
590 | 592 | } |
|
591 | 593 | |
|
592 | 594 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
593 | 595 | if (status[2] != RTEMS_SUCCESSFUL) |
|
594 | 596 | { |
|
595 | 597 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
596 | 598 | } |
|
597 | 599 | |
|
598 | 600 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
599 | 601 | if (status[3] != RTEMS_SUCCESSFUL) |
|
600 | 602 | { |
|
601 | 603 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
602 | 604 | } |
|
603 | 605 | |
|
604 | 606 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
605 | 607 | if (status[4] != RTEMS_SUCCESSFUL) |
|
606 | 608 | { |
|
607 | 609 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
608 | 610 | } |
|
609 | 611 | |
|
610 | 612 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
611 | 613 | if (status[5] != RTEMS_SUCCESSFUL) |
|
612 | 614 | { |
|
613 | 615 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
614 | 616 | } |
|
615 | 617 | |
|
616 | 618 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
617 | 619 | if (status[6] != RTEMS_SUCCESSFUL) |
|
618 | 620 | { |
|
619 | 621 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
620 | 622 | } |
|
621 | 623 | |
|
622 | 624 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
623 | 625 | if (status[7] != RTEMS_SUCCESSFUL) |
|
624 | 626 | { |
|
625 | 627 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
626 | 628 | } |
|
627 | 629 | |
|
628 | 630 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
629 | 631 | if (status[8] != RTEMS_SUCCESSFUL) |
|
630 | 632 | { |
|
631 | 633 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
632 | 634 | } |
|
633 | 635 | |
|
634 | 636 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
635 | 637 | if (status[9] != RTEMS_SUCCESSFUL) |
|
636 | 638 | { |
|
637 | 639 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
638 | 640 | } |
|
639 | 641 | |
|
640 | 642 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
641 | 643 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
642 | 644 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
643 | 645 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
644 | 646 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
645 | 647 | { |
|
646 | 648 | ret = RTEMS_UNSATISFIED; |
|
647 | 649 | } |
|
648 | 650 | |
|
649 | 651 | return ret; |
|
650 | 652 | } |
|
651 | 653 | |
|
652 | 654 | int suspend_science_tasks() |
|
653 | 655 | { |
|
654 | 656 | /** This function suspends the science tasks. |
|
655 | 657 | * |
|
656 | 658 | * @return RTEMS directive status codes: |
|
657 | 659 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
658 | 660 | * - RTEMS_INVALID_ID - task id invalid |
|
659 | 661 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
660 | 662 | * |
|
661 | 663 | */ |
|
662 | 664 | |
|
663 | 665 | rtems_status_code status; |
|
664 | 666 | |
|
665 | 667 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
666 | 668 | if (status != RTEMS_SUCCESSFUL) |
|
667 | 669 | { |
|
668 | 670 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
669 | 671 | } |
|
670 | 672 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
671 | 673 | { |
|
672 | 674 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
673 | 675 | if (status != RTEMS_SUCCESSFUL) |
|
674 | 676 | { |
|
675 | 677 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
676 | 678 | } |
|
677 | 679 | } |
|
678 | 680 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
679 | 681 | { |
|
680 | 682 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
681 | 683 | if (status != RTEMS_SUCCESSFUL) |
|
682 | 684 | { |
|
683 | 685 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
684 | 686 | } |
|
685 | 687 | } |
|
686 | 688 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
687 | 689 | { |
|
688 | 690 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
689 | 691 | if (status != RTEMS_SUCCESSFUL) |
|
690 | 692 | { |
|
691 | 693 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
692 | 694 | } |
|
693 | 695 | } |
|
694 | 696 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
695 | 697 | { |
|
696 | 698 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
697 | 699 | if (status != RTEMS_SUCCESSFUL) |
|
698 | 700 | { |
|
699 | 701 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
700 | 702 | } |
|
701 | 703 | } |
|
702 | 704 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
703 | 705 | { |
|
704 | 706 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
705 | 707 | if (status != RTEMS_SUCCESSFUL) |
|
706 | 708 | { |
|
707 | 709 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
708 | 710 | } |
|
709 | 711 | } |
|
710 | 712 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
711 | 713 | { |
|
712 | 714 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
713 | 715 | if (status != RTEMS_SUCCESSFUL) |
|
714 | 716 | { |
|
715 | 717 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
716 | 718 | } |
|
717 | 719 | } |
|
718 | 720 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
719 | 721 | { |
|
720 | 722 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
721 | 723 | if (status != RTEMS_SUCCESSFUL) |
|
722 | 724 | { |
|
723 | 725 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
724 | 726 | } |
|
725 | 727 | } |
|
726 | 728 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
727 | 729 | { |
|
728 | 730 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
729 | 731 | if (status != RTEMS_SUCCESSFUL) |
|
730 | 732 | { |
|
731 | 733 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
732 | 734 | } |
|
733 | 735 | } |
|
734 | 736 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
735 | 737 | { |
|
736 | 738 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
737 | 739 | if (status != RTEMS_SUCCESSFUL) |
|
738 | 740 | { |
|
739 | 741 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
740 | 742 | } |
|
741 | 743 | } |
|
742 | 744 | |
|
743 | 745 | return status; |
|
744 | 746 | } |
|
745 | 747 | |
|
746 | 748 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
747 | 749 | { |
|
748 | 750 | WFP_reset_current_ring_nodes(); |
|
749 | 751 | reset_waveform_picker_regs(); |
|
750 | 752 | set_wfp_burst_enable_register( mode ); |
|
751 | 753 | |
|
752 | 754 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
753 | 755 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
754 | 756 | |
|
755 | 757 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] |
|
756 | 758 | if (transitionCoarseTime == 0) |
|
757 | 759 | { |
|
758 | 760 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
759 | 761 | } |
|
760 | 762 | else |
|
761 | 763 | { |
|
762 | 764 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
763 | 765 | } |
|
764 | 766 | |
|
765 | 767 | PRINTF1("commutation coarse time = %d\n", transitionCoarseTime) |
|
766 | 768 | } |
|
767 | 769 | |
|
768 | 770 | void launch_spectral_matrix( void ) |
|
769 | 771 | { |
|
770 | 772 | SM_reset_current_ring_nodes(); |
|
771 | 773 | reset_spectral_matrix_regs(); |
|
772 | 774 | reset_nb_sm(); |
|
773 | 775 | |
|
774 | 776 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
775 | 777 | grgpio_regs->io_port_direction_register = |
|
776 | 778 | grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled |
|
777 | 779 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0 |
|
778 | 780 | set_irq_on_new_ready_matrix( 1 ); |
|
779 | 781 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
780 | 782 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
781 | 783 | set_run_matrix_spectral( 1 ); |
|
782 | 784 | } |
|
783 | 785 | |
|
784 | 786 | void launch_spectral_matrix_simu( void ) |
|
785 | 787 | { |
|
786 | 788 | SM_reset_current_ring_nodes(); |
|
787 | 789 | reset_spectral_matrix_regs(); |
|
788 | 790 | reset_nb_sm(); |
|
789 | 791 | |
|
790 | 792 | // Spectral Matrices simulator |
|
791 | 793 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
792 | 794 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
793 | 795 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
794 | 796 | } |
|
795 | 797 | |
|
796 | 798 | void set_irq_on_new_ready_matrix( unsigned char value ) |
|
797 | 799 | { |
|
798 | 800 | if (value == 1) |
|
799 | 801 | { |
|
800 | 802 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
801 | 803 | } |
|
802 | 804 | else |
|
803 | 805 | { |
|
804 | 806 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
805 | 807 | } |
|
806 | 808 | } |
|
807 | 809 | |
|
808 | 810 | void set_run_matrix_spectral( unsigned char value ) |
|
809 | 811 | { |
|
810 | 812 | if (value == 1) |
|
811 | 813 | { |
|
812 | 814 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1 |
|
813 | 815 | } |
|
814 | 816 | else |
|
815 | 817 | { |
|
816 | 818 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0 |
|
817 | 819 | } |
|
818 | 820 | } |
|
819 | 821 | |
|
820 | 822 | //**************** |
|
821 | 823 | // CLOSING ACTIONS |
|
822 | 824 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
823 | 825 | { |
|
824 | 826 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
825 | 827 | * |
|
826 | 828 | * @param TC points to the TC being processed |
|
827 | 829 | * @param time is the time used to date the TC execution |
|
828 | 830 | * |
|
829 | 831 | */ |
|
830 | 832 | |
|
831 | 833 | unsigned int val; |
|
832 | 834 | |
|
833 | 835 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
834 | 836 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
835 | 837 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
836 | 838 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
837 | 839 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
838 | 840 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
839 | 841 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
840 | 842 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
841 | 843 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
842 | 844 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
843 | 845 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
844 | 846 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
845 | 847 | |
|
846 | 848 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
847 | 849 | val++; |
|
848 | 850 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
849 | 851 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
850 | 852 | } |
|
851 | 853 | |
|
852 | 854 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
853 | 855 | { |
|
854 | 856 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
855 | 857 | * |
|
856 | 858 | * @param TC points to the TC being processed |
|
857 | 859 | * @param time is the time used to date the TC rejection |
|
858 | 860 | * |
|
859 | 861 | */ |
|
860 | 862 | |
|
861 | 863 | unsigned int val; |
|
862 | 864 | |
|
863 | 865 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
864 | 866 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
865 | 867 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
866 | 868 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
867 | 869 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
868 | 870 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
869 | 871 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
870 | 872 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
871 | 873 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
872 | 874 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
873 | 875 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
874 | 876 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
875 | 877 | |
|
876 | 878 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
877 | 879 | val++; |
|
878 | 880 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
879 | 881 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
880 | 882 | } |
|
881 | 883 | |
|
882 | 884 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
883 | 885 | { |
|
884 | 886 | /** This function is the last step of the TC execution workflow. |
|
885 | 887 | * |
|
886 | 888 | * @param TC points to the TC being processed |
|
887 | 889 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
888 | 890 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
889 | 891 | * @param time is the time used to date the TC execution |
|
890 | 892 | * |
|
891 | 893 | */ |
|
892 | 894 | |
|
893 | 895 | unsigned char requestedMode; |
|
894 | 896 | |
|
895 | 897 | if (result == LFR_SUCCESSFUL) |
|
896 | 898 | { |
|
897 | 899 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
898 | 900 | & |
|
899 | 901 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
900 | 902 | ) |
|
901 | 903 | { |
|
902 | 904 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
903 | 905 | } |
|
904 | 906 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
905 | 907 | { |
|
906 | 908 | //********************************** |
|
907 | 909 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
908 | 910 | requestedMode = TC->dataAndCRC[1]; |
|
909 | 911 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
910 | 912 | updateLFRCurrentMode(); |
|
911 | 913 | } |
|
912 | 914 | } |
|
913 | 915 | else if (result == LFR_EXE_ERROR) |
|
914 | 916 | { |
|
915 | 917 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
916 | 918 | } |
|
917 | 919 | } |
|
918 | 920 | |
|
919 | 921 | //*************************** |
|
920 | 922 | // Interrupt Service Routines |
|
921 | 923 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
922 | 924 | { |
|
923 | 925 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
924 | 926 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
925 | 927 | } |
|
926 | 928 | } |
|
927 | 929 | |
|
928 | 930 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
929 | 931 | { |
|
930 | 932 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
931 | 933 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
932 | 934 | } |
|
933 | 935 | } |
|
934 | 936 | |
|
935 | 937 | //**************** |
|
936 | 938 | // OTHER FUNCTIONS |
|
937 | 939 | void updateLFRCurrentMode() |
|
938 | 940 | { |
|
939 | 941 | /** This function updates the value of the global variable lfrCurrentMode. |
|
940 | 942 | * |
|
941 | 943 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
942 | 944 | * |
|
943 | 945 | */ |
|
944 | 946 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
945 | 947 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
946 | 948 | } |
|
947 | 949 |
@@ -1,1323 +1,1367 | |||
|
1 | 1 | /** Functions and tasks related to waveform packet generation. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "wf_handler.h" |
|
11 | 11 | |
|
12 | 12 | //***************** |
|
13 | 13 | // waveform headers |
|
14 | 14 | // SWF |
|
15 | 15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; |
|
16 | 16 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; |
|
17 | 17 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; |
|
18 | 18 | // CWF |
|
19 | 19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
20 | 20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
21 | 21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
22 | 22 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
23 | 23 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ]; |
|
24 | 24 | |
|
25 | 25 | //************** |
|
26 | 26 | // waveform ring |
|
27 | 27 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
28 | 28 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
29 | 29 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
30 | 30 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; |
|
31 | 31 | ring_node *current_ring_node_f0; |
|
32 | 32 | ring_node *ring_node_to_send_swf_f0; |
|
33 | 33 | ring_node *current_ring_node_f1; |
|
34 | 34 | ring_node *ring_node_to_send_swf_f1; |
|
35 | 35 | ring_node *ring_node_to_send_cwf_f1; |
|
36 | 36 | ring_node *current_ring_node_f2; |
|
37 | 37 | ring_node *ring_node_to_send_swf_f2; |
|
38 | 38 | ring_node *ring_node_to_send_cwf_f2; |
|
39 | 39 | ring_node *current_ring_node_f3; |
|
40 | 40 | ring_node *ring_node_to_send_cwf_f3; |
|
41 | 41 | |
|
42 | 42 | bool extractSWF = false; |
|
43 | 43 | bool swf_f0_ready = false; |
|
44 | 44 | bool swf_f1_ready = false; |
|
45 | 45 | bool swf_f2_ready = false; |
|
46 | 46 | |
|
47 | 47 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
48 | 48 | |
|
49 | 49 | //********************* |
|
50 | 50 | // Interrupt SubRoutine |
|
51 | 51 | |
|
52 | 52 | void reset_extractSWF( void ) |
|
53 | 53 | { |
|
54 | 54 | extractSWF = false; |
|
55 | 55 | swf_f0_ready = false; |
|
56 | 56 | swf_f1_ready = false; |
|
57 | 57 | swf_f2_ready = false; |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
61 | 61 | { |
|
62 | 62 | /** This is the interrupt sub routine called by the waveform picker core. |
|
63 | 63 | * |
|
64 | 64 | * This ISR launch different actions depending mainly on two pieces of information: |
|
65 | 65 | * 1. the values read in the registers of the waveform picker. |
|
66 | 66 | * 2. the current LFR mode. |
|
67 | 67 | * |
|
68 | 68 | */ |
|
69 | 69 | |
|
70 | 70 | rtems_status_code status; |
|
71 | 71 | rtems_status_code spare_status; |
|
72 | 72 | |
|
73 | 73 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet |
|
74 | 74 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
75 | 75 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
76 | 76 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
77 | 77 | // (1) change the receiving buffer for the waveform picker |
|
78 | 78 | ring_node_to_send_cwf_f3 = current_ring_node_f3; |
|
79 | 79 | current_ring_node_f3 = current_ring_node_f3->next; |
|
80 | 80 | waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; |
|
81 | 81 | // (2) send an event for the waveforms transmission |
|
82 | 82 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
83 | 83 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
84 | 84 | } |
|
85 | 85 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2); |
|
86 | 86 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
87 | 87 | } |
|
88 | 88 | } |
|
89 | 89 | |
|
90 | 90 | switch(lfrCurrentMode) |
|
91 | 91 | { |
|
92 | 92 | //******** |
|
93 | 93 | // STANDBY |
|
94 | 94 | case(LFR_MODE_STANDBY): |
|
95 | 95 | break; |
|
96 | 96 | |
|
97 | 97 | //****** |
|
98 | 98 | // NORMAL |
|
99 | 99 | case(LFR_MODE_NORMAL): |
|
100 | 100 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits |
|
101 | 101 | { |
|
102 | 102 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
103 | 103 | } |
|
104 | 104 | if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits |
|
105 | 105 | { |
|
106 | 106 | // change F0 ring node |
|
107 | 107 | ring_node_to_send_swf_f0 = current_ring_node_f0; |
|
108 | 108 | current_ring_node_f0 = current_ring_node_f0->next; |
|
109 | 109 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; |
|
110 | 110 | // change F1 ring node |
|
111 | 111 | ring_node_to_send_swf_f1 = current_ring_node_f1; |
|
112 | 112 | current_ring_node_f1 = current_ring_node_f1->next; |
|
113 | 113 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
114 | 114 | // change F2 ring node |
|
115 | 115 | ring_node_to_send_swf_f2 = current_ring_node_f2; |
|
116 | 116 | current_ring_node_f2 = current_ring_node_f2->next; |
|
117 | 117 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
118 | 118 | // |
|
119 | 119 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) |
|
120 | 120 | { |
|
121 | 121 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
122 | 122 | } |
|
123 | 123 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] |
|
124 | 124 | } |
|
125 | 125 | break; |
|
126 | 126 | |
|
127 | 127 | //****** |
|
128 | 128 | // BURST |
|
129 | 129 | case(LFR_MODE_BURST): |
|
130 | 130 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
131 | 131 | // (1) change the receiving buffer for the waveform picker |
|
132 | 132 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
133 | 133 | current_ring_node_f2 = current_ring_node_f2->next; |
|
134 | 134 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
135 | 135 | // (2) send an event for the waveforms transmission |
|
136 | 136 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
137 | 137 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
138 | 138 | } |
|
139 | 139 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
140 | 140 | } |
|
141 | 141 | break; |
|
142 | 142 | |
|
143 | 143 | //***** |
|
144 | 144 | // SBM1 |
|
145 | 145 | case(LFR_MODE_SBM1): |
|
146 | 146 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
147 | 147 | // (1) change the receiving buffer for the waveform picker |
|
148 | 148 | ring_node_to_send_cwf_f1 = current_ring_node_f1; |
|
149 | 149 | current_ring_node_f1 = current_ring_node_f1->next; |
|
150 | 150 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
151 | 151 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
152 | 152 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
153 | 153 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0 |
|
154 | 154 | } |
|
155 | 155 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
156 | 156 | swf_f0_ready = true; |
|
157 | 157 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
158 | 158 | } |
|
159 | 159 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit |
|
160 | 160 | swf_f2_ready = true; |
|
161 | 161 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 |
|
162 | 162 | } |
|
163 | 163 | break; |
|
164 | 164 | |
|
165 | 165 | //***** |
|
166 | 166 | // SBM2 |
|
167 | 167 | case(LFR_MODE_SBM2): |
|
168 | 168 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
169 | 169 | // (1) change the receiving buffer for the waveform picker |
|
170 | 170 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
171 | 171 | current_ring_node_f2 = current_ring_node_f2->next; |
|
172 | 172 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
173 | 173 | // (2) send an event for the waveforms transmission |
|
174 | 174 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
175 | 175 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
176 | 176 | } |
|
177 | 177 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
178 | 178 | swf_f0_ready = true; |
|
179 | 179 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
180 | 180 | } |
|
181 | 181 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
182 | 182 | swf_f1_ready = true; |
|
183 | 183 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0 |
|
184 | 184 | } |
|
185 | 185 | break; |
|
186 | 186 | |
|
187 | 187 | //******** |
|
188 | 188 | // DEFAULT |
|
189 | 189 | default: |
|
190 | 190 | break; |
|
191 | 191 | } |
|
192 | 192 | } |
|
193 | 193 | |
|
194 | 194 | //************ |
|
195 | 195 | // RTEMS TASKS |
|
196 | 196 | |
|
197 | 197 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
198 | 198 | { |
|
199 | 199 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
200 | 200 | * |
|
201 | 201 | * @param unused is the starting argument of the RTEMS task |
|
202 | 202 | * |
|
203 | 203 | * The following data packets are sent by this task: |
|
204 | 204 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
205 | 205 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
206 | 206 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
207 | 207 | * |
|
208 | 208 | */ |
|
209 | 209 | |
|
210 | 210 | rtems_event_set event_out; |
|
211 | 211 | rtems_id queue_id; |
|
212 | 212 | rtems_status_code status; |
|
213 | bool resynchronisationEngaged; | |
|
214 | ||
|
215 | resynchronisationEngaged = false; | |
|
213 | 216 | |
|
214 | 217 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
215 | 218 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
216 | 219 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
217 | 220 | |
|
218 | 221 | status = get_message_queue_id_send( &queue_id ); |
|
219 | 222 | if (status != RTEMS_SUCCESSFUL) |
|
220 | 223 | { |
|
221 | 224 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
222 | 225 | } |
|
223 | 226 | |
|
224 | 227 | BOOT_PRINTF("in WFRM ***\n") |
|
225 | 228 | |
|
226 | 229 | while(1){ |
|
227 | 230 | // wait for an RTEMS_EVENT |
|
228 | 231 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
229 | 232 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
230 | 233 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
234 | if(resynchronisationEngaged == false) | |
|
235 | { // engage resynchronisation | |
|
236 | snapshot_resynchronization( (unsigned char *) ring_node_to_send_swf_f0->buffer_address); | |
|
237 | resynchronisationEngaged = true; | |
|
238 | } | |
|
239 | else | |
|
240 | { // reset delta_snapshot to the nominal value | |
|
241 | PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n") | |
|
242 | set_wfp_delta_snapshot(); | |
|
243 | resynchronisationEngaged = false; | |
|
244 | } | |
|
245 | // | |
|
246 | ||
|
231 | 247 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
232 | 248 | { |
|
233 | 249 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
234 | 250 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
235 | 251 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
236 | 252 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
237 | 253 | } |
|
238 | 254 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
239 | 255 | { |
|
240 | 256 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
241 | 257 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
242 | 258 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
243 | 259 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
244 | 260 | } |
|
245 | 261 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
246 | 262 | { |
|
247 | 263 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
248 | 264 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
249 | 265 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
250 | 266 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
251 | 267 | } |
|
252 | 268 | } |
|
253 | 269 | } |
|
254 | 270 | |
|
255 | 271 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
256 | 272 | { |
|
257 | 273 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
258 | 274 | * |
|
259 | 275 | * @param unused is the starting argument of the RTEMS task |
|
260 | 276 | * |
|
261 | 277 | * The following data packet is sent by this task: |
|
262 | 278 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
263 | 279 | * |
|
264 | 280 | */ |
|
265 | 281 | |
|
266 | 282 | rtems_event_set event_out; |
|
267 | 283 | rtems_id queue_id; |
|
268 | 284 | rtems_status_code status; |
|
269 | 285 | |
|
270 | 286 | init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 ); |
|
271 | 287 | init_header_continuous_cwf3_light_table( headerCWF_F3_light ); |
|
272 | 288 | |
|
273 | 289 | status = get_message_queue_id_send( &queue_id ); |
|
274 | 290 | if (status != RTEMS_SUCCESSFUL) |
|
275 | 291 | { |
|
276 | 292 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
277 | 293 | } |
|
278 | 294 | |
|
279 | 295 | BOOT_PRINTF("in CWF3 ***\n") |
|
280 | 296 | |
|
281 | 297 | while(1){ |
|
282 | 298 | // wait for an RTEMS_EVENT |
|
283 | 299 | rtems_event_receive( RTEMS_EVENT_0, |
|
284 | 300 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
285 | 301 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
286 | 302 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
287 | 303 | { |
|
288 | 304 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
289 | 305 | { |
|
290 | 306 | PRINTF("send CWF_LONG_F3\n") |
|
291 | 307 | send_waveform_CWF( |
|
292 | 308 | (volatile int*) ring_node_to_send_cwf_f3->buffer_address, |
|
293 | 309 | SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
294 | 310 | } |
|
295 | 311 | else |
|
296 | 312 | { |
|
297 | 313 | PRINTF("send CWF_F3 (light)\n") |
|
298 | 314 | send_waveform_CWF3_light( |
|
299 | 315 | (volatile int*) ring_node_to_send_cwf_f3->buffer_address, |
|
300 | 316 | headerCWF_F3_light, queue_id ); |
|
301 | 317 | } |
|
302 | 318 | |
|
303 | 319 | } |
|
304 | 320 | else |
|
305 | 321 | { |
|
306 | 322 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
307 | 323 | } |
|
308 | 324 | } |
|
309 | 325 | } |
|
310 | 326 | |
|
311 | 327 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
312 | 328 | { |
|
313 | 329 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
314 | 330 | * |
|
315 | 331 | * @param unused is the starting argument of the RTEMS task |
|
316 | 332 | * |
|
317 | 333 | * The following data packet is sent by this function: |
|
318 | 334 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
319 | 335 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
320 | 336 | * |
|
321 | 337 | */ |
|
322 | 338 | |
|
323 | 339 | rtems_event_set event_out; |
|
324 | 340 | rtems_id queue_id; |
|
325 | 341 | rtems_status_code status; |
|
326 | 342 | |
|
327 | 343 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
328 | 344 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
329 | 345 | |
|
330 | 346 | status = get_message_queue_id_send( &queue_id ); |
|
331 | 347 | if (status != RTEMS_SUCCESSFUL) |
|
332 | 348 | { |
|
333 | 349 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
334 | 350 | } |
|
335 | 351 | |
|
336 | 352 | BOOT_PRINTF("in CWF2 ***\n") |
|
337 | 353 | |
|
338 | 354 | while(1){ |
|
339 | 355 | // wait for an RTEMS_EVENT |
|
340 | 356 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
341 | 357 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
342 | 358 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
343 | 359 | { |
|
344 | 360 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
345 | 361 | } |
|
346 | 362 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
347 | 363 | { |
|
348 | 364 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
349 | 365 | // launch snapshot extraction if needed |
|
350 | 366 | if (extractSWF == true) |
|
351 | 367 | { |
|
352 | 368 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
353 | 369 | // extract the snapshot |
|
354 | 370 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); |
|
355 | 371 | // send the snapshot when built |
|
356 | 372 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
357 | 373 | extractSWF = false; |
|
358 | 374 | } |
|
359 | 375 | if (swf_f0_ready && swf_f1_ready) |
|
360 | 376 | { |
|
361 | 377 | extractSWF = true; |
|
362 | 378 | swf_f0_ready = false; |
|
363 | 379 | swf_f1_ready = false; |
|
364 | 380 | } |
|
365 | 381 | } |
|
366 | 382 | } |
|
367 | 383 | } |
|
368 | 384 | |
|
369 | 385 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
370 | 386 | { |
|
371 | 387 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
372 | 388 | * |
|
373 | 389 | * @param unused is the starting argument of the RTEMS task |
|
374 | 390 | * |
|
375 | 391 | * The following data packet is sent by this function: |
|
376 | 392 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
377 | 393 | * |
|
378 | 394 | */ |
|
379 | 395 | |
|
380 | 396 | rtems_event_set event_out; |
|
381 | 397 | rtems_id queue_id; |
|
382 | 398 | rtems_status_code status; |
|
383 | 399 | |
|
384 | 400 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
385 | 401 | |
|
386 | 402 | status = get_message_queue_id_send( &queue_id ); |
|
387 | 403 | if (status != RTEMS_SUCCESSFUL) |
|
388 | 404 | { |
|
389 | 405 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
390 | 406 | } |
|
391 | 407 | |
|
392 | 408 | BOOT_PRINTF("in CWF1 ***\n") |
|
393 | 409 | |
|
394 | 410 | while(1){ |
|
395 | 411 | // wait for an RTEMS_EVENT |
|
396 | 412 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
397 | 413 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
398 | 414 | send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
399 | 415 | // launch snapshot extraction if needed |
|
400 | 416 | if (extractSWF == true) |
|
401 | 417 | { |
|
402 | 418 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1; |
|
403 | 419 | // launch the snapshot extraction |
|
404 | 420 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); |
|
405 | 421 | extractSWF = false; |
|
406 | 422 | } |
|
407 | 423 | if (swf_f0_ready == true) |
|
408 | 424 | { |
|
409 | 425 | extractSWF = true; |
|
410 | 426 | swf_f0_ready = false; // this step shall be executed only one time |
|
411 | 427 | } |
|
412 | 428 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction |
|
413 | 429 | { |
|
414 | 430 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); |
|
415 | 431 | swf_f1_ready = false; |
|
416 | 432 | swf_f2_ready = false; |
|
417 | 433 | } |
|
418 | 434 | } |
|
419 | 435 | } |
|
420 | 436 | |
|
421 | 437 | rtems_task swbd_task(rtems_task_argument argument) |
|
422 | 438 | { |
|
423 | 439 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
424 | 440 | * |
|
425 | 441 | * @param unused is the starting argument of the RTEMS task |
|
426 | 442 | * |
|
427 | 443 | */ |
|
428 | 444 | |
|
429 | 445 | rtems_event_set event_out; |
|
430 | 446 | |
|
431 | 447 | BOOT_PRINTF("in SWBD ***\n") |
|
432 | 448 | |
|
433 | 449 | while(1){ |
|
434 | 450 | // wait for an RTEMS_EVENT |
|
435 | 451 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
436 | 452 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
437 | 453 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
438 | 454 | { |
|
439 | 455 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 ); |
|
440 | 456 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
441 | 457 | } |
|
442 | 458 | else |
|
443 | 459 | { |
|
444 | 460 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
445 | 461 | } |
|
446 | 462 | } |
|
447 | 463 | } |
|
448 | 464 | |
|
449 | 465 | //****************** |
|
450 | 466 | // general functions |
|
451 | 467 | |
|
452 | 468 | void WFP_init_rings( void ) |
|
453 | 469 | { |
|
454 | 470 | // F0 RING |
|
455 | 471 | init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 ); |
|
456 | 472 | // F1 RING |
|
457 | 473 | init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 ); |
|
458 | 474 | // F2 RING |
|
459 | 475 | init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 ); |
|
460 | 476 | // F3 RING |
|
461 | 477 | init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 ); |
|
462 | 478 | |
|
463 | 479 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
464 | 480 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
465 | 481 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
466 | 482 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
467 | 483 | } |
|
468 | 484 | |
|
469 | 485 | void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] ) |
|
470 | 486 | { |
|
471 | 487 | unsigned char i; |
|
472 | 488 | |
|
473 | 489 | waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ]; |
|
474 | 490 | waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ]; |
|
475 | 491 | waveform_ring[0].buffer_address = (int) &wfrm[0]; |
|
476 | 492 | |
|
477 | 493 | waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ]; |
|
478 | 494 | waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ]; |
|
479 | 495 | waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ]; |
|
480 | 496 | |
|
481 | 497 | for(i=1; i<nbNodes-1; i++) |
|
482 | 498 | { |
|
483 | 499 | waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ]; |
|
484 | 500 | waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ]; |
|
485 | 501 | waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ]; |
|
486 | 502 | } |
|
487 | 503 | } |
|
488 | 504 | |
|
489 | 505 | void WFP_reset_current_ring_nodes( void ) |
|
490 | 506 | { |
|
491 | 507 | current_ring_node_f0 = waveform_ring_f0; |
|
492 | 508 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
493 | 509 | |
|
494 | 510 | current_ring_node_f1 = waveform_ring_f1; |
|
495 | 511 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
496 | 512 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
497 | 513 | |
|
498 | 514 | current_ring_node_f2 = waveform_ring_f2; |
|
499 | 515 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
500 | 516 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
501 | 517 | |
|
502 | 518 | current_ring_node_f3 = waveform_ring_f3; |
|
503 | 519 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
504 | 520 | } |
|
505 | 521 | |
|
506 | 522 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
507 | 523 | { |
|
508 | 524 | unsigned char i; |
|
509 | 525 | int return_value; |
|
510 | 526 | |
|
511 | 527 | return_value = LFR_SUCCESSFUL; |
|
512 | 528 | |
|
513 | 529 | for (i=0; i<7; i++) |
|
514 | 530 | { |
|
515 | 531 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
516 | 532 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
517 | 533 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
518 | 534 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
519 | 535 | headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
520 | 536 | headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
521 | 537 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
522 | 538 | if (i == 6) |
|
523 | 539 | { |
|
524 | 540 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
525 | 541 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
526 | 542 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
527 | 543 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
528 | 544 | } |
|
529 | 545 | else |
|
530 | 546 | { |
|
531 | 547 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
532 | 548 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
533 | 549 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
534 | 550 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
535 | 551 | } |
|
536 | 552 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
537 | 553 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
538 | 554 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
539 | 555 | // DATA FIELD HEADER |
|
540 | 556 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
541 | 557 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
542 | 558 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
543 | 559 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
544 | 560 | // AUXILIARY DATA HEADER |
|
545 | 561 | headerSWF[ i ].time[0] = 0x00; |
|
546 | 562 | headerSWF[ i ].time[0] = 0x00; |
|
547 | 563 | headerSWF[ i ].time[0] = 0x00; |
|
548 | 564 | headerSWF[ i ].time[0] = 0x00; |
|
549 | 565 | headerSWF[ i ].time[0] = 0x00; |
|
550 | 566 | headerSWF[ i ].time[0] = 0x00; |
|
551 | 567 | headerSWF[ i ].sid = sid; |
|
552 | 568 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
553 | 569 | } |
|
554 | 570 | |
|
555 | 571 | return return_value; |
|
556 | 572 | } |
|
557 | 573 | |
|
558 | 574 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
559 | 575 | { |
|
560 | 576 | unsigned int i; |
|
561 | 577 | int return_value; |
|
562 | 578 | |
|
563 | 579 | return_value = LFR_SUCCESSFUL; |
|
564 | 580 | |
|
565 | 581 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) |
|
566 | 582 | { |
|
567 | 583 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
568 | 584 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
569 | 585 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
570 | 586 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
571 | 587 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
572 | 588 | { |
|
573 | 589 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
574 | 590 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
575 | 591 | } |
|
576 | 592 | else |
|
577 | 593 | { |
|
578 | 594 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
579 | 595 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
580 | 596 | } |
|
581 | 597 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
582 | 598 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
583 | 599 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
584 | 600 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
585 | 601 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
586 | 602 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
587 | 603 | // DATA FIELD HEADER |
|
588 | 604 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
589 | 605 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
590 | 606 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
591 | 607 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
592 | 608 | // AUXILIARY DATA HEADER |
|
593 | 609 | headerCWF[ i ].sid = sid; |
|
594 | 610 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
595 | 611 | headerCWF[ i ].time[0] = 0x00; |
|
596 | 612 | headerCWF[ i ].time[0] = 0x00; |
|
597 | 613 | headerCWF[ i ].time[0] = 0x00; |
|
598 | 614 | headerCWF[ i ].time[0] = 0x00; |
|
599 | 615 | headerCWF[ i ].time[0] = 0x00; |
|
600 | 616 | headerCWF[ i ].time[0] = 0x00; |
|
601 | 617 | } |
|
602 | 618 | |
|
603 | 619 | return return_value; |
|
604 | 620 | } |
|
605 | 621 | |
|
606 | 622 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
607 | 623 | { |
|
608 | 624 | unsigned int i; |
|
609 | 625 | int return_value; |
|
610 | 626 | |
|
611 | 627 | return_value = LFR_SUCCESSFUL; |
|
612 | 628 | |
|
613 | 629 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) |
|
614 | 630 | { |
|
615 | 631 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
616 | 632 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
617 | 633 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
618 | 634 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
619 | 635 | |
|
620 | 636 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
621 | 637 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
622 | 638 | |
|
623 | 639 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
624 | 640 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
625 | 641 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
626 | 642 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
627 | 643 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
628 | 644 | |
|
629 | 645 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
630 | 646 | // DATA FIELD HEADER |
|
631 | 647 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
632 | 648 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
633 | 649 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
634 | 650 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
635 | 651 | // AUXILIARY DATA HEADER |
|
636 | 652 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
637 | 653 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
638 | 654 | headerCWF[ i ].time[0] = 0x00; |
|
639 | 655 | headerCWF[ i ].time[0] = 0x00; |
|
640 | 656 | headerCWF[ i ].time[0] = 0x00; |
|
641 | 657 | headerCWF[ i ].time[0] = 0x00; |
|
642 | 658 | headerCWF[ i ].time[0] = 0x00; |
|
643 | 659 | headerCWF[ i ].time[0] = 0x00; |
|
644 | 660 | } |
|
645 | 661 | |
|
646 | 662 | return return_value; |
|
647 | 663 | } |
|
648 | 664 | |
|
649 | 665 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
650 | 666 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
651 | 667 | { |
|
652 | 668 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
653 | 669 | * |
|
654 | 670 | * @param waveform points to the buffer containing the data that will be send. |
|
655 | 671 | * @param sid is the source identifier of the data that will be sent. |
|
656 | 672 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
657 | 673 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
658 | 674 | * contain information to setup the transmission of the data packets. |
|
659 | 675 | * |
|
660 | 676 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
661 | 677 | * |
|
662 | 678 | */ |
|
663 | 679 | |
|
664 | 680 | unsigned int i; |
|
665 | 681 | int ret; |
|
666 | 682 | unsigned int coarseTime; |
|
667 | 683 | unsigned int fineTime; |
|
668 | 684 | rtems_status_code status; |
|
669 | 685 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
670 | 686 | |
|
671 | 687 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header |
|
672 | 688 | spw_ioctl_send_SWF.options = 0; |
|
673 | 689 | |
|
674 | 690 | ret = LFR_DEFAULT; |
|
675 | 691 | |
|
676 | 692 | coarseTime = waveform[0]; |
|
677 | 693 | fineTime = waveform[1]; |
|
678 | 694 | |
|
679 | 695 | for (i=0; i<7; i++) // send waveform |
|
680 | 696 | { |
|
681 | 697 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
682 | 698 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
683 | 699 | // BUILD THE DATA |
|
684 | 700 | if (i==6) { |
|
685 | 701 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
686 | 702 | } |
|
687 | 703 | else { |
|
688 | 704 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
689 | 705 | } |
|
690 | 706 | // SET PACKET SEQUENCE COUNTER |
|
691 | 707 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); |
|
692 | 708 | // SET PACKET TIME |
|
693 | 709 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime ); |
|
694 | 710 | // |
|
695 | 711 | headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0]; |
|
696 | 712 | headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1]; |
|
697 | 713 | headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2]; |
|
698 | 714 | headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3]; |
|
699 | 715 | headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4]; |
|
700 | 716 | headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5]; |
|
701 | 717 | // SEND PACKET |
|
702 | 718 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
703 | 719 | if (status != RTEMS_SUCCESSFUL) { |
|
704 | 720 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
705 | 721 | ret = LFR_DEFAULT; |
|
706 | 722 | } |
|
707 | 723 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds |
|
708 | 724 | } |
|
709 | 725 | |
|
710 | 726 | return ret; |
|
711 | 727 | } |
|
712 | 728 | |
|
713 | 729 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
714 | 730 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
715 | 731 | { |
|
716 | 732 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
717 | 733 | * |
|
718 | 734 | * @param waveform points to the buffer containing the data that will be send. |
|
719 | 735 | * @param sid is the source identifier of the data that will be sent. |
|
720 | 736 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
721 | 737 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
722 | 738 | * contain information to setup the transmission of the data packets. |
|
723 | 739 | * |
|
724 | 740 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
725 | 741 | * |
|
726 | 742 | */ |
|
727 | 743 | |
|
728 | 744 | unsigned int i; |
|
729 | 745 | int ret; |
|
730 | 746 | unsigned int coarseTime; |
|
731 | 747 | unsigned int fineTime; |
|
732 | 748 | rtems_status_code status; |
|
733 | 749 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
734 | 750 | |
|
735 | 751 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
736 | 752 | spw_ioctl_send_CWF.options = 0; |
|
737 | 753 | |
|
738 | 754 | ret = LFR_DEFAULT; |
|
739 | 755 | |
|
740 | 756 | coarseTime = waveform[0]; |
|
741 | 757 | fineTime = waveform[1]; |
|
742 | 758 | |
|
743 | 759 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
744 | 760 | { |
|
745 | 761 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
746 | 762 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
747 | 763 | // BUILD THE DATA |
|
748 | 764 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
749 | 765 | // SET PACKET SEQUENCE COUNTER |
|
750 | 766 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); |
|
751 | 767 | // SET PACKET TIME |
|
752 | 768 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime); |
|
753 | 769 | // |
|
754 | 770 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
755 | 771 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
756 | 772 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
757 | 773 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
758 | 774 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
759 | 775 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
760 | 776 | // SEND PACKET |
|
761 | 777 | if (sid == SID_NORM_CWF_LONG_F3) |
|
762 | 778 | { |
|
763 | 779 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
764 | 780 | if (status != RTEMS_SUCCESSFUL) { |
|
765 | 781 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
766 | 782 | ret = LFR_DEFAULT; |
|
767 | 783 | } |
|
768 | 784 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
769 | 785 | } |
|
770 | 786 | else |
|
771 | 787 | { |
|
772 | 788 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
773 | 789 | if (status != RTEMS_SUCCESSFUL) { |
|
774 | 790 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
775 | 791 | ret = LFR_DEFAULT; |
|
776 | 792 | } |
|
777 | 793 | } |
|
778 | 794 | } |
|
779 | 795 | |
|
780 | 796 | return ret; |
|
781 | 797 | } |
|
782 | 798 | |
|
783 | 799 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
784 | 800 | { |
|
785 | 801 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
786 | 802 | * |
|
787 | 803 | * @param waveform points to the buffer containing the data that will be send. |
|
788 | 804 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
789 | 805 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
790 | 806 | * contain information to setup the transmission of the data packets. |
|
791 | 807 | * |
|
792 | 808 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
793 | 809 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
794 | 810 | * |
|
795 | 811 | */ |
|
796 | 812 | |
|
797 | 813 | unsigned int i; |
|
798 | 814 | int ret; |
|
799 | 815 | unsigned int coarseTime; |
|
800 | 816 | unsigned int fineTime; |
|
801 | 817 | rtems_status_code status; |
|
802 | 818 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
803 | 819 | char *sample; |
|
804 | 820 | |
|
805 | 821 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
806 | 822 | spw_ioctl_send_CWF.options = 0; |
|
807 | 823 | |
|
808 | 824 | ret = LFR_DEFAULT; |
|
809 | 825 | |
|
810 | 826 | //********************** |
|
811 | 827 | // BUILD CWF3_light DATA |
|
812 | 828 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
813 | 829 | { |
|
814 | 830 | sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
815 | 831 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; |
|
816 | 832 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; |
|
817 | 833 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; |
|
818 | 834 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; |
|
819 | 835 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; |
|
820 | 836 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; |
|
821 | 837 | } |
|
822 | 838 | |
|
823 | 839 | coarseTime = waveform[0]; |
|
824 | 840 | fineTime = waveform[1]; |
|
825 | 841 | |
|
826 | 842 | //********************* |
|
827 | 843 | // SEND CWF3_light DATA |
|
828 | 844 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
829 | 845 | { |
|
830 | 846 | 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]; |
|
831 | 847 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
832 | 848 | // BUILD THE DATA |
|
833 | 849 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
834 | 850 | // SET PACKET SEQUENCE COUNTER |
|
835 | 851 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); |
|
836 | 852 | // SET PACKET TIME |
|
837 | 853 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime ); |
|
838 | 854 | // |
|
839 | 855 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
840 | 856 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
841 | 857 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
842 | 858 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
843 | 859 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
844 | 860 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
845 | 861 | // SEND PACKET |
|
846 | 862 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
847 | 863 | if (status != RTEMS_SUCCESSFUL) { |
|
848 | 864 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
849 | 865 | ret = LFR_DEFAULT; |
|
850 | 866 | } |
|
851 | 867 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
852 | 868 | } |
|
853 | 869 | |
|
854 | 870 | return ret; |
|
855 | 871 | } |
|
856 | 872 | |
|
857 | 873 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
858 | 874 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
859 | 875 | { |
|
860 | 876 | unsigned long long int acquisitionTimeAsLong; |
|
861 | 877 | unsigned char localAcquisitionTime[6]; |
|
862 | 878 | double deltaT; |
|
863 | 879 | |
|
864 | 880 | deltaT = 0.; |
|
865 | 881 | |
|
866 | 882 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); |
|
867 | 883 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); |
|
868 | 884 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); |
|
869 | 885 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); |
|
870 | 886 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); |
|
871 | 887 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); |
|
872 | 888 | |
|
873 | 889 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
874 | 890 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
875 | 891 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) |
|
876 | 892 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) |
|
877 | 893 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) |
|
878 | 894 | + ( (unsigned long long int) localAcquisitionTime[5] ); |
|
879 | 895 | |
|
880 | 896 | switch( sid ) |
|
881 | 897 | { |
|
882 | 898 | case SID_NORM_SWF_F0: |
|
883 | 899 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
884 | 900 | break; |
|
885 | 901 | |
|
886 | 902 | case SID_NORM_SWF_F1: |
|
887 | 903 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
888 | 904 | break; |
|
889 | 905 | |
|
890 | 906 | case SID_NORM_SWF_F2: |
|
891 | 907 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
892 | 908 | break; |
|
893 | 909 | |
|
894 | 910 | case SID_SBM1_CWF_F1: |
|
895 | 911 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
896 | 912 | break; |
|
897 | 913 | |
|
898 | 914 | case SID_SBM2_CWF_F2: |
|
899 | 915 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
900 | 916 | break; |
|
901 | 917 | |
|
902 | 918 | case SID_BURST_CWF_F2: |
|
903 | 919 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
904 | 920 | break; |
|
905 | 921 | |
|
906 | 922 | case SID_NORM_CWF_F3: |
|
907 | 923 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
908 | 924 | break; |
|
909 | 925 | |
|
910 | 926 | case SID_NORM_CWF_LONG_F3: |
|
911 | 927 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
912 | 928 | break; |
|
913 | 929 | |
|
914 | 930 | default: |
|
915 | 931 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid) |
|
916 | 932 | deltaT = 0.; |
|
917 | 933 | break; |
|
918 | 934 | } |
|
919 | 935 | |
|
920 | 936 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
921 | 937 | // |
|
922 | 938 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
923 | 939 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
924 | 940 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
925 | 941 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
926 | 942 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
927 | 943 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
928 | 944 | |
|
929 | 945 | } |
|
930 | 946 | |
|
931 | 947 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel ) |
|
932 | 948 | { |
|
933 | 949 | unsigned int i; |
|
934 | 950 | unsigned long long int centerTime_asLong; |
|
935 | 951 | unsigned long long int acquisitionTimeF0_asLong; |
|
936 | 952 | unsigned long long int acquisitionTime_asLong; |
|
937 | 953 | unsigned long long int bufferAcquisitionTime_asLong; |
|
938 | 954 | unsigned char *ptr1; |
|
939 | 955 | unsigned char *ptr2; |
|
940 | 956 | unsigned char *timeCharPtr; |
|
941 | 957 | unsigned char nb_ring_nodes; |
|
942 | 958 | unsigned long long int frequency_asLong; |
|
943 | 959 | unsigned long long int nbTicksPerSample_asLong; |
|
944 | 960 | unsigned long long int nbSamplesPart1_asLong; |
|
945 | 961 | unsigned long long int sampleOffset_asLong; |
|
946 | 962 | |
|
947 | 963 | unsigned int deltaT_F0; |
|
948 | 964 | unsigned int deltaT_F1; |
|
949 | 965 | unsigned long long int deltaT_F2; |
|
950 | 966 | |
|
951 | 967 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
952 | 968 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
953 | 969 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
954 | 970 | sampleOffset_asLong = 0x00; |
|
955 | 971 | |
|
956 | 972 | // (1) get the f0 acquisition time |
|
957 | build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 ); | |
|
973 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) current_ring_node_f0->buffer_address ); | |
|
958 | 974 | |
|
959 | 975 | // (2) compute the central reference time |
|
960 | 976 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
961 | 977 | |
|
962 | 978 | // (3) compute the acquisition time of the current snapshot |
|
963 | 979 | switch(frequencyChannel) |
|
964 | 980 | { |
|
965 | 981 | case 1: // 1 is for F1 = 4096 Hz |
|
966 | 982 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
967 | 983 | nb_ring_nodes = NB_RING_NODES_F1; |
|
968 | 984 | frequency_asLong = 4096; |
|
969 | 985 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
970 | 986 | break; |
|
971 | 987 | case 2: // 2 is for F2 = 256 Hz |
|
972 | 988 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
973 | 989 | nb_ring_nodes = NB_RING_NODES_F2; |
|
974 | 990 | frequency_asLong = 256; |
|
975 | 991 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
976 | 992 | break; |
|
977 | 993 | default: |
|
978 | 994 | acquisitionTime_asLong = centerTime_asLong; |
|
979 | 995 | frequency_asLong = 256; |
|
980 | 996 | nbTicksPerSample_asLong = 256; |
|
981 | 997 | break; |
|
982 | 998 | } |
|
983 | 999 | |
|
984 | 1000 | //**************************************************************************** |
|
985 | 1001 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
986 | 1002 | for (i=0; i<nb_ring_nodes; i++) |
|
987 | 1003 | { |
|
988 | 1004 | PRINTF1("%d ... ", i) |
|
989 | build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send ); | |
|
1005 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) ring_node_to_send->buffer_address ); | |
|
990 | 1006 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
991 | 1007 | { |
|
992 | 1008 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
993 | 1009 | break; |
|
994 | 1010 | } |
|
995 | 1011 | ring_node_to_send = ring_node_to_send->previous; |
|
996 | 1012 | } |
|
997 | 1013 | |
|
998 | 1014 | // (5) compute the number of samples to take in the current buffer |
|
999 | 1015 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
1000 | 1016 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
1001 | 1017 | PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
1002 | 1018 | |
|
1003 | 1019 | // (6) compute the final acquisition time |
|
1004 | 1020 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
1005 | 1021 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
1006 | 1022 | |
|
1007 | 1023 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
1008 | 1024 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
1009 | 1025 | ptr2 = (unsigned char*) wf_snap_extracted; |
|
1010 | 1026 | ptr2[0] = ptr1[ 0 + 2 ]; |
|
1011 | 1027 | ptr2[1] = ptr1[ 1 + 2 ]; |
|
1012 | 1028 | ptr2[2] = ptr1[ 2 + 2 ]; |
|
1013 | 1029 | ptr2[3] = ptr1[ 3 + 2 ]; |
|
1014 | 1030 | ptr2[6] = ptr1[ 4 + 2 ]; |
|
1015 | 1031 | ptr2[7] = ptr1[ 5 + 2 ]; |
|
1016 | 1032 | |
|
1017 | 1033 | // re set the synchronization bit |
|
1018 | 1034 | timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address; |
|
1019 | 1035 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] |
|
1020 | 1036 | |
|
1021 | 1037 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
1022 | 1038 | { |
|
1023 | 1039 | nbSamplesPart1_asLong = 0; |
|
1024 | 1040 | } |
|
1025 | 1041 | // copy the part 1 of the snapshot in the extracted buffer |
|
1026 | 1042 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1027 | 1043 | { |
|
1028 | 1044 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1029 | 1045 | ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
1030 | 1046 | } |
|
1031 | 1047 | // copy the part 2 of the snapshot in the extracted buffer |
|
1032 | 1048 | ring_node_to_send = ring_node_to_send->next; |
|
1033 | 1049 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1034 | 1050 | { |
|
1035 | 1051 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1036 | 1052 | ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET]; |
|
1037 | 1053 | } |
|
1038 | 1054 | } |
|
1039 | 1055 | |
|
1040 | void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) | |
|
1056 | void snapshot_resynchronization( unsigned char *timePtr ) | |
|
1041 | 1057 | { |
|
1042 |
unsigned |
|
|
1058 | unsigned long long int acquisitionTime; | |
|
1059 | unsigned long long int centerTime; | |
|
1060 | unsigned long long int previousTick; | |
|
1061 | unsigned long long int nextTick; | |
|
1062 | unsigned long long int deltaPreviousTick; | |
|
1063 | unsigned long long int deltaNextTick; | |
|
1064 | unsigned int deltaTickInF2; | |
|
1065 | double deltaPrevious; | |
|
1066 | double deltaNext; | |
|
1043 | 1067 | |
|
1044 | acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address; | |
|
1068 | acquisitionTime = get_acquisition_time( timePtr ); | |
|
1069 | ||
|
1070 | // compute center time | |
|
1071 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
|
1072 | previousTick = centerTime - (centerTime & 0xffff); | |
|
1073 | nextTick = previousTick + 65536; | |
|
1045 | 1074 | |
|
1046 | *acquisitionTimeAslong = 0x00; | |
|
1047 | *acquisitionTimeAslong = ( (unsigned long long int) (acquisitionTimeCharPtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit | |
|
1048 | + ( (unsigned long long int) acquisitionTimeCharPtr[1] << 32 ) | |
|
1049 | + ( (unsigned long long int) acquisitionTimeCharPtr[2] << 24 ) | |
|
1050 | + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 16 ) | |
|
1051 | + ( (unsigned long long int) acquisitionTimeCharPtr[6] << 8 ) | |
|
1052 | + ( (unsigned long long int) acquisitionTimeCharPtr[7] ); | |
|
1075 | deltaPreviousTick = centerTime - previousTick; | |
|
1076 | deltaNextTick = nextTick - centerTime; | |
|
1077 | ||
|
1078 | deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.; | |
|
1079 | deltaNext = ((double) deltaNextTick) / 65536. * 1000.; | |
|
1080 | ||
|
1081 | printf("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext); | |
|
1082 | printf("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick); | |
|
1083 | ||
|
1084 | // which tick is the closest | |
|
1085 | if (deltaPreviousTick > deltaNextTick) | |
|
1086 | { | |
|
1087 | deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here | |
|
1088 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; | |
|
1089 | printf("correction of = + %u\n", deltaTickInF2); | |
|
1090 | } | |
|
1091 | else | |
|
1092 | { | |
|
1093 | deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here | |
|
1094 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2; | |
|
1095 | printf("correction of = - %u\n", deltaTickInF2); | |
|
1096 | } | |
|
1053 | 1097 | } |
|
1054 | 1098 | |
|
1055 | 1099 | //************** |
|
1056 | 1100 | // wfp registers |
|
1057 | 1101 | void reset_wfp_burst_enable(void) |
|
1058 | 1102 | { |
|
1059 | 1103 | /** This function resets the waveform picker burst_enable register. |
|
1060 | 1104 | * |
|
1061 | 1105 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1062 | 1106 | * |
|
1063 | 1107 | */ |
|
1064 | 1108 | |
|
1065 | 1109 | waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1066 | 1110 | } |
|
1067 | 1111 | |
|
1068 | 1112 | void reset_wfp_status( void ) |
|
1069 | 1113 | { |
|
1070 | 1114 | /** This function resets the waveform picker status register. |
|
1071 | 1115 | * |
|
1072 | 1116 | * All status bits are set to 0 [new_err full_err full]. |
|
1073 | 1117 | * |
|
1074 | 1118 | */ |
|
1075 | 1119 | |
|
1076 | 1120 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1077 | 1121 | } |
|
1078 | 1122 | |
|
1079 | 1123 | void reset_waveform_picker_regs(void) |
|
1080 | 1124 | { |
|
1081 | 1125 | /** This function resets the waveform picker module registers. |
|
1082 | 1126 | * |
|
1083 | 1127 | * The registers affected by this function are located at the following offset addresses: |
|
1084 | 1128 | * - 0x00 data_shaping |
|
1085 | 1129 | * - 0x04 run_burst_enable |
|
1086 | 1130 | * - 0x08 addr_data_f0 |
|
1087 | 1131 | * - 0x0C addr_data_f1 |
|
1088 | 1132 | * - 0x10 addr_data_f2 |
|
1089 | 1133 | * - 0x14 addr_data_f3 |
|
1090 | 1134 | * - 0x18 status |
|
1091 | 1135 | * - 0x1C delta_snapshot |
|
1092 | 1136 | * - 0x20 delta_f0 |
|
1093 | 1137 | * - 0x24 delta_f0_2 |
|
1094 | 1138 | * - 0x28 delta_f1 |
|
1095 | 1139 | * - 0x2c delta_f2 |
|
1096 | 1140 | * - 0x30 nb_data_by_buffer |
|
1097 | 1141 | * - 0x34 nb_snapshot_param |
|
1098 | 1142 | * - 0x38 start_date |
|
1099 | 1143 | * - 0x3c nb_word_in_buffer |
|
1100 | 1144 | * |
|
1101 | 1145 | */ |
|
1102 | 1146 | |
|
1103 | 1147 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1104 | 1148 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1105 | 1149 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08 |
|
1106 | 1150 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c |
|
1107 | 1151 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 |
|
1108 | 1152 | waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14 |
|
1109 | 1153 | reset_wfp_status(); // 0x18 |
|
1110 | 1154 | // |
|
1111 | 1155 | set_wfp_delta_snapshot(); // 0x1c |
|
1112 | 1156 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1113 | 1157 | set_wfp_delta_f1(); // 0x28 |
|
1114 | 1158 | set_wfp_delta_f2(); // 0x2c |
|
1115 | 1159 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1116 | 1160 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1117 | 1161 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1118 | 1162 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1119 | 1163 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1120 | 1164 | // 2688 = 8 * 336 |
|
1121 | 1165 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1122 | 1166 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1123 | 1167 | waveform_picker_regs->start_date = 0x00; // 0x38 |
|
1124 | 1168 | waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066 |
|
1125 | 1169 | } |
|
1126 | 1170 | |
|
1127 | 1171 | void set_wfp_data_shaping( void ) |
|
1128 | 1172 | { |
|
1129 | 1173 | /** This function sets the data_shaping register of the waveform picker module. |
|
1130 | 1174 | * |
|
1131 | 1175 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1132 | 1176 | * bw_sp0_sp1_r0_r1 |
|
1133 | 1177 | * |
|
1134 | 1178 | */ |
|
1135 | 1179 | |
|
1136 | 1180 | unsigned char data_shaping; |
|
1137 | 1181 | |
|
1138 | 1182 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1139 | 1183 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1140 | 1184 | |
|
1141 | 1185 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
1142 | 1186 | |
|
1143 | 1187 | waveform_picker_regs->data_shaping = |
|
1144 | 1188 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
1145 | 1189 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
1146 | 1190 | + ( (data_shaping & 0x04) ) // SP1 |
|
1147 | 1191 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
1148 | 1192 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
1149 | 1193 | } |
|
1150 | 1194 | |
|
1151 | 1195 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1152 | 1196 | { |
|
1153 | 1197 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1154 | 1198 | * |
|
1155 | 1199 | * @param mode is the LFR mode to launch. |
|
1156 | 1200 | * |
|
1157 | 1201 | * The burst bits shall be before the enable bits. |
|
1158 | 1202 | * |
|
1159 | 1203 | */ |
|
1160 | 1204 | |
|
1161 | 1205 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1162 | 1206 | // the burst bits shall be set first, before the enable bits |
|
1163 | 1207 | switch(mode) { |
|
1164 | 1208 | case(LFR_MODE_NORMAL): |
|
1165 | 1209 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1166 | 1210 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1167 | 1211 | break; |
|
1168 | 1212 | case(LFR_MODE_BURST): |
|
1169 | 1213 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1170 | 1214 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1171 | 1215 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 |
|
1172 | 1216 | break; |
|
1173 | 1217 | case(LFR_MODE_SBM1): |
|
1174 | 1218 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1175 | 1219 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1176 | 1220 | break; |
|
1177 | 1221 | case(LFR_MODE_SBM2): |
|
1178 | 1222 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1179 | 1223 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1180 | 1224 | break; |
|
1181 | 1225 | default: |
|
1182 | 1226 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1183 | 1227 | break; |
|
1184 | 1228 | } |
|
1185 | 1229 | } |
|
1186 | 1230 | |
|
1187 | 1231 | void set_wfp_delta_snapshot( void ) |
|
1188 | 1232 | { |
|
1189 | 1233 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1190 | 1234 | * |
|
1191 | 1235 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1192 | 1236 | * - sy_lfr_n_swf_p[0] |
|
1193 | 1237 | * - sy_lfr_n_swf_p[1] |
|
1194 | 1238 | * |
|
1195 | 1239 | */ |
|
1196 | 1240 | |
|
1197 | 1241 | unsigned int delta_snapshot; |
|
1198 | 1242 | unsigned int delta_snapshot_in_T2; |
|
1199 | 1243 | |
|
1200 | 1244 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1201 | 1245 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1202 | 1246 | |
|
1203 | 1247 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1204 | 1248 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1205 | 1249 | } |
|
1206 | 1250 | |
|
1207 | 1251 | void set_wfp_delta_f0_f0_2( void ) |
|
1208 | 1252 | { |
|
1209 | 1253 | unsigned int delta_snapshot; |
|
1210 | 1254 | unsigned int nb_samples_per_snapshot; |
|
1211 | 1255 | float delta_f0_in_float; |
|
1212 | 1256 | |
|
1213 | 1257 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1214 | 1258 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1215 | 1259 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1216 | 1260 | |
|
1217 | 1261 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1218 | 1262 | waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits |
|
1219 | 1263 | } |
|
1220 | 1264 | |
|
1221 | 1265 | void set_wfp_delta_f1( void ) |
|
1222 | 1266 | { |
|
1223 | 1267 | unsigned int delta_snapshot; |
|
1224 | 1268 | unsigned int nb_samples_per_snapshot; |
|
1225 | 1269 | float delta_f1_in_float; |
|
1226 | 1270 | |
|
1227 | 1271 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1228 | 1272 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1229 | 1273 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1230 | 1274 | |
|
1231 | 1275 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1232 | 1276 | } |
|
1233 | 1277 | |
|
1234 | 1278 | void set_wfp_delta_f2() |
|
1235 | 1279 | { |
|
1236 | 1280 | unsigned int delta_snapshot; |
|
1237 | 1281 | unsigned int nb_samples_per_snapshot; |
|
1238 | 1282 | |
|
1239 | 1283 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1240 | 1284 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1241 | 1285 | |
|
1242 | 1286 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1243 | 1287 | } |
|
1244 | 1288 | |
|
1245 | 1289 | //***************** |
|
1246 | 1290 | // local parameters |
|
1247 | 1291 | |
|
1248 | 1292 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1249 | 1293 | { |
|
1250 | 1294 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1251 | 1295 | * |
|
1252 | 1296 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1253 | 1297 | * @param sid is the source identifier of the packet being updated. |
|
1254 | 1298 | * |
|
1255 | 1299 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1256 | 1300 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1257 | 1301 | * The sequence counter shall start at zero at startup. |
|
1258 | 1302 | * |
|
1259 | 1303 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1260 | 1304 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1261 | 1305 | * |
|
1262 | 1306 | */ |
|
1263 | 1307 | |
|
1264 | 1308 | unsigned short *sequence_cnt; |
|
1265 | 1309 | unsigned short segmentation_grouping_flag; |
|
1266 | 1310 | unsigned short new_packet_sequence_control; |
|
1267 | 1311 | rtems_mode initial_mode_set; |
|
1268 | 1312 | rtems_mode current_mode_set; |
|
1269 | 1313 | rtems_status_code status; |
|
1270 | 1314 | |
|
1271 | 1315 | //****************************************** |
|
1272 | 1316 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1273 | 1317 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1274 | 1318 | |
|
1275 | 1319 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1276 | 1320 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1277 | 1321 | || (sid == SID_BURST_CWF_F2) |
|
1278 | 1322 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1279 | 1323 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1280 | 1324 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1281 | 1325 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1282 | 1326 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1283 | 1327 | { |
|
1284 | 1328 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1285 | 1329 | } |
|
1286 | 1330 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1287 | 1331 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1288 | 1332 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1289 | 1333 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1290 | 1334 | { |
|
1291 | 1335 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1292 | 1336 | } |
|
1293 | 1337 | else |
|
1294 | 1338 | { |
|
1295 | 1339 | sequence_cnt = (unsigned short *) NULL; |
|
1296 | 1340 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1297 | 1341 | } |
|
1298 | 1342 | |
|
1299 | 1343 | if (sequence_cnt != NULL) |
|
1300 | 1344 | { |
|
1301 | 1345 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1302 | 1346 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1303 | 1347 | |
|
1304 | 1348 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1305 | 1349 | |
|
1306 | 1350 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1307 | 1351 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1308 | 1352 | |
|
1309 | 1353 | // increment the sequence counter |
|
1310 | 1354 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1311 | 1355 | { |
|
1312 | 1356 | *sequence_cnt = *sequence_cnt + 1; |
|
1313 | 1357 | } |
|
1314 | 1358 | else |
|
1315 | 1359 | { |
|
1316 | 1360 | *sequence_cnt = 0; |
|
1317 | 1361 | } |
|
1318 | 1362 | } |
|
1319 | 1363 | |
|
1320 | 1364 | //*********************************** |
|
1321 | 1365 | // RESET THE MODE OF THE CALLING TASK |
|
1322 | 1366 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1323 | 1367 | } |
General Comments 0
You need to be logged in to leave comments.
Login now