@@ -1,273 +1,273 | |||
|
1 | 1 | ############################################################################# |
|
2 | 2 | # Makefile for building: bin/fsw |
|
3 |
# Generated by qmake (2.01a) (Qt 4.8.6) on: |
|
|
3 | # Generated by qmake (2.01a) (Qt 4.8.6) on: Wed Sep 24 11:10:53 2014 | |
|
4 | 4 | # Project: fsw-qt.pro |
|
5 | 5 | # Template: app |
|
6 | 6 | # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
7 | 7 | ############################################################################# |
|
8 | 8 | |
|
9 | 9 | ####### Compiler, tools and options |
|
10 | 10 | |
|
11 | 11 | CC = sparc-rtems-gcc |
|
12 | 12 | CXX = sparc-rtems-g++ |
|
13 |
DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4= |
|
|
13 | DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -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,95 +1,95 | |||
|
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 | CONFIG += console verbose |
|
5 | 5 | CONFIG -= qt |
|
6 | 6 | |
|
7 | 7 | include(./sparc.pri) |
|
8 | 8 | |
|
9 | 9 | # flight software version |
|
10 | 10 | SWVERSION=-1-0 |
|
11 | 11 | DEFINES += SW_VERSION_N1=2 # major |
|
12 | 12 | DEFINES += SW_VERSION_N2=0 # minor |
|
13 | 13 | DEFINES += SW_VERSION_N3=1 # patch |
|
14 |
DEFINES += SW_VERSION_N4= |
|
|
14 | DEFINES += SW_VERSION_N4=1 # internal | |
|
15 | 15 | |
|
16 | 16 | contains( CONFIG, debug_tch ) { |
|
17 | 17 | DEFINES += DEBUG_TCH |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | 20 | contains( CONFIG, vhdl_dev ) { |
|
21 | 21 | DEFINES += VHDL_DEV |
|
22 | 22 | } |
|
23 | 23 | |
|
24 | 24 | contains( CONFIG, verbose ) { |
|
25 | 25 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | 28 | contains( CONFIG, debug_messages ) { |
|
29 | 29 | DEFINES += DEBUG_MESSAGES |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | contains( CONFIG, cpu_usage_report ) { |
|
33 | 33 | DEFINES += PRINT_TASK_STATISTICS |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | contains( CONFIG, stack_report ) { |
|
37 | 37 | DEFINES += PRINT_STACK_REPORT |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | contains( CONFIG, boot_messages ) { |
|
41 | 41 | DEFINES += BOOT_MESSAGES |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | #doxygen.target = doxygen |
|
45 | 45 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
46 | 46 | #QMAKE_EXTRA_TARGETS += doxygen |
|
47 | 47 | |
|
48 | 48 | TARGET = fsw |
|
49 | 49 | |
|
50 | 50 | INCLUDEPATH += \ |
|
51 | 51 | ../src \ |
|
52 | 52 | ../header \ |
|
53 | 53 | ../header/processing \ |
|
54 | 54 | ../src/LFR_basic-parameters |
|
55 | 55 | |
|
56 | 56 | SOURCES += \ |
|
57 | 57 | ../src/wf_handler.c \ |
|
58 | 58 | ../src/tc_handler.c \ |
|
59 | 59 | ../src/fsw_misc.c \ |
|
60 | 60 | ../src/fsw_init.c \ |
|
61 | 61 | ../src/fsw_globals.c \ |
|
62 | 62 | ../src/fsw_spacewire.c \ |
|
63 | 63 | ../src/tc_load_dump_parameters.c \ |
|
64 | 64 | ../src/tm_lfr_tc_exe.c \ |
|
65 | 65 | ../src/tc_acceptance.c \ |
|
66 | 66 | ../src/processing/fsw_processing.c \ |
|
67 | 67 | ../src/processing/avf0_prc0.c \ |
|
68 | 68 | ../src/processing/avf1_prc1.c \ |
|
69 | 69 | ../src/processing/avf2_prc2.c \ |
|
70 | 70 | ../src/lfr_cpu_usage_report.c \ |
|
71 | 71 | ../src/LFR_basic-parameters/basic_parameters.c |
|
72 | 72 | |
|
73 | 73 | HEADERS += \ |
|
74 | 74 | ../header/wf_handler.h \ |
|
75 | 75 | ../header/tc_handler.h \ |
|
76 | 76 | ../header/grlib_regs.h \ |
|
77 | 77 | ../header/fsw_params.h \ |
|
78 | 78 | ../header/fsw_misc.h \ |
|
79 | 79 | ../header/fsw_init.h \ |
|
80 | 80 | ../header/ccsds_types.h \ |
|
81 | 81 | ../header/fsw_spacewire.h \ |
|
82 | 82 | ../header/tc_load_dump_parameters.h \ |
|
83 | 83 | ../header/tm_lfr_tc_exe.h \ |
|
84 | 84 | ../header/tc_acceptance.h \ |
|
85 | 85 | ../header/fsw_params_nb_bytes.h \ |
|
86 | 86 | ../header/fsw_params_processing.h \ |
|
87 | 87 | ../header/processing/fsw_processing.h \ |
|
88 | 88 | ../header/processing/avf0_prc0.h \ |
|
89 | 89 | ../header/processing/avf1_prc1.h \ |
|
90 | 90 | ../header/processing/avf2_prc2.h \ |
|
91 | 91 | ../header/fsw_params_wf_handler.h \ |
|
92 | 92 | ../header/lfr_cpu_usage_report.h \ |
|
93 | 93 | ../src/LFR_basic-parameters/basic_parameters.h \ |
|
94 | 94 | ../src/LFR_basic-parameters/basic_parameters_params.h |
|
95 | 95 |
@@ -1,201 +1,208 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by QtCreator 3. |
|
|
3 | <!-- Written by QtCreator 3.2.0, 2014-09-23T16:34:13. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | <variable>EnvironmentId</variable> | |
|
7 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> | |
|
8 | </data> | |
|
9 | <data> | |
|
6 | 10 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
7 | 11 | <value type="int">0</value> |
|
8 | 12 | </data> |
|
9 | 13 | <data> |
|
10 | 14 | <variable>ProjectExplorer.Project.EditorSettings</variable> |
|
11 | 15 | <valuemap type="QVariantMap"> |
|
12 | 16 | <value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
|
13 | 17 | <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
|
14 | 18 | <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
|
15 | 19 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
|
16 | 20 | <value type="QString" key="language">Cpp</value> |
|
17 | 21 | <valuemap type="QVariantMap" key="value"> |
|
18 | 22 | <value type="QByteArray" key="CurrentPreferences">CppGlobal</value> |
|
19 | 23 | </valuemap> |
|
20 | 24 | </valuemap> |
|
21 | 25 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
|
22 | 26 | <value type="QString" key="language">QmlJS</value> |
|
23 | 27 | <valuemap type="QVariantMap" key="value"> |
|
24 | 28 | <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> |
|
25 | 29 | </valuemap> |
|
26 | 30 | </valuemap> |
|
27 | 31 | <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
|
28 | 32 | <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> |
|
29 | 33 | <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
|
30 | 34 | <value type="int" key="EditorConfiguration.IndentSize">4</value> |
|
31 | 35 | <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> |
|
36 | <value type="int" key="EditorConfiguration.MarginColumn">80</value> | |
|
37 | <value type="bool" key="EditorConfiguration.MouseHiding">true</value> | |
|
32 | 38 | <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
|
33 | 39 | <value type="int" key="EditorConfiguration.PaddingMode">1</value> |
|
34 | 40 | <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
|
41 | <value type="bool" key="EditorConfiguration.ShowMargin">false</value> | |
|
35 | 42 | <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
|
36 | 43 | <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
|
37 | 44 | <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
|
38 | 45 | <value type="int" key="EditorConfiguration.TabSize">8</value> |
|
39 | 46 | <value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
|
40 | 47 | <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
|
41 | 48 | <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
|
42 | 49 | <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
|
43 | 50 | <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
|
44 | 51 | <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
|
45 | 52 | </valuemap> |
|
46 | 53 | </data> |
|
47 | 54 | <data> |
|
48 | 55 | <variable>ProjectExplorer.Project.PluginSettings</variable> |
|
49 | 56 | <valuemap type="QVariantMap"/> |
|
50 | 57 | </data> |
|
51 | 58 | <data> |
|
52 | 59 | <variable>ProjectExplorer.Project.Target.0</variable> |
|
53 | 60 | <valuemap type="QVariantMap"> |
|
54 | 61 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
55 | 62 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
56 | 63 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value> |
|
57 | 64 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
58 | 65 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
59 | 66 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
60 | 67 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
61 | 68 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> |
|
62 | 69 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
63 | 70 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
64 | 71 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
65 | 72 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
66 | 73 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
67 | 74 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
68 | 75 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
69 | 76 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value> |
|
70 | 77 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
71 | 78 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
72 | 79 | </valuemap> |
|
73 | 80 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
74 | 81 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
75 | 82 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
76 | 83 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
77 | 84 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
78 | 85 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
79 | 86 | <value type="QString">-w</value> |
|
80 | 87 | <value type="QString">-r</value> |
|
81 | 88 | </valuelist> |
|
82 | 89 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
83 | 90 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
84 | 91 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
85 | 92 | </valuemap> |
|
86 | 93 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
87 | 94 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
88 | 95 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
89 | 96 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
90 | 97 | </valuemap> |
|
91 | 98 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
92 | 99 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
93 | 100 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
94 | 101 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
95 | 102 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
96 | 103 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
97 | 104 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
98 | 105 | <value type="QString">-w</value> |
|
99 | 106 | <value type="QString">-r</value> |
|
100 | 107 | </valuelist> |
|
101 | 108 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
102 | 109 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
103 | 110 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
104 | 111 | </valuemap> |
|
105 | 112 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
106 | 113 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
107 | 114 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
108 | 115 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
109 | 116 | </valuemap> |
|
110 | 117 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
111 | 118 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
112 | 119 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
113 | 120 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
114 | 121 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
115 | 122 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
116 | 123 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
117 | 124 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
118 | 125 | </valuemap> |
|
119 | 126 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
120 | 127 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
121 | 128 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
122 | 129 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
123 | 130 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
124 | 131 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
125 | 132 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
126 | 133 | </valuemap> |
|
127 | 134 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
128 | 135 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
129 | 136 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
130 | 137 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
131 | 138 | </valuemap> |
|
132 | 139 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
133 | 140 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
134 | 141 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
135 | 142 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
136 | 143 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
137 | 144 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
138 | 145 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
139 | 146 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
140 | 147 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
141 | 148 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
142 | 149 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
143 | 150 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
144 | 151 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
145 | 152 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
146 | 153 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
147 | 154 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
148 | 155 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
149 | 156 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
150 | 157 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
151 | 158 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
152 | 159 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
153 | 160 | <value type="int">0</value> |
|
154 | 161 | <value type="int">1</value> |
|
155 | 162 | <value type="int">2</value> |
|
156 | 163 | <value type="int">3</value> |
|
157 | 164 | <value type="int">4</value> |
|
158 | 165 | <value type="int">5</value> |
|
159 | 166 | <value type="int">6</value> |
|
160 | 167 | <value type="int">7</value> |
|
161 | 168 | <value type="int">8</value> |
|
162 | 169 | <value type="int">9</value> |
|
163 | 170 | <value type="int">10</value> |
|
164 | 171 | <value type="int">11</value> |
|
165 | 172 | <value type="int">12</value> |
|
166 | 173 | <value type="int">13</value> |
|
167 | 174 | <value type="int">14</value> |
|
168 | 175 | </valuelist> |
|
169 | 176 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
170 | 177 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
171 | 178 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
172 | 179 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
173 | 180 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
174 | 181 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
175 | 182 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
176 | 183 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
177 | 184 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
178 | 185 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
179 | 186 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
180 | 187 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> |
|
181 | 188 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> |
|
182 | 189 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
183 | 190 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
184 | 191 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
185 | 192 | </valuemap> |
|
186 | 193 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
187 | 194 | </valuemap> |
|
188 | 195 | </data> |
|
189 | 196 | <data> |
|
190 | 197 | <variable>ProjectExplorer.Project.TargetCount</variable> |
|
191 | 198 | <value type="int">1</value> |
|
192 | 199 | </data> |
|
193 | 200 | <data> |
|
194 |
<variable>ProjectExplorer.Project.Updater. |
|
|
195 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> | |
|
201 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> | |
|
202 | <value type="int">16</value> | |
|
196 | 203 | </data> |
|
197 | 204 | <data> |
|
198 |
<variable> |
|
|
199 |
<value type="int">1 |
|
|
205 | <variable>Version</variable> | |
|
206 | <value type="int">16</value> | |
|
200 | 207 | </data> |
|
201 | 208 | </qtcreator> |
@@ -1,238 +1,238 | |||
|
1 | 1 | ############################################################################# |
|
2 | 2 | # Makefile for building: bin/timegen |
|
3 |
# Generated by qmake (2.01a) (Qt 4.8. |
|
|
3 | # Generated by qmake (2.01a) (Qt 4.8.6) on: Wed Sep 24 10:50:53 2014 | |
|
4 | 4 | # Project: timegen.pro |
|
5 | 5 | # Template: app |
|
6 | 6 | # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile timegen.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=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES -DBOOT_MESSAGES |
|
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. -Isrc -Iheader -I../src -I../header |
|
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/timegen_init.c \ |
|
47 | 47 | src/timegen_tc_handler.c \ |
|
48 | 48 | src/timegen_misc.c \ |
|
49 | 49 | src/timegen_spacewire.c \ |
|
50 | 50 | ../src/fsw_misc.c \ |
|
51 | 51 | ../src/fsw_globals.c \ |
|
52 | 52 | ../src/tm_lfr_tc_exe.c \ |
|
53 | 53 | ../src/tc_acceptance.c |
|
54 | 54 | OBJECTS = obj/timegen_init.o \ |
|
55 | 55 | obj/timegen_tc_handler.o \ |
|
56 | 56 | obj/timegen_misc.o \ |
|
57 | 57 | obj/timegen_spacewire.o \ |
|
58 | 58 | obj/fsw_misc.o \ |
|
59 | 59 | obj/fsw_globals.o \ |
|
60 | 60 | obj/tm_lfr_tc_exe.o \ |
|
61 | 61 | obj/tc_acceptance.o |
|
62 | 62 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
63 | 63 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
64 | 64 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
65 | 65 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
66 | 66 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
67 | 67 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
68 | 68 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
69 | 69 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
70 | 70 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
71 | 71 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
72 | 72 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
73 | 73 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
74 | 74 | sparc.pri \ |
|
75 | 75 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
76 | 76 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
77 | 77 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
78 | 78 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
79 | 79 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
80 | 80 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
81 | 81 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
82 | 82 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
83 | 83 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
84 | 84 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ |
|
85 | 85 | timegen.pro |
|
86 | 86 | QMAKE_TARGET = timegen |
|
87 | 87 | DESTDIR = bin/ |
|
88 | 88 | TARGET = bin/timegen |
|
89 | 89 | |
|
90 | 90 | first: all |
|
91 | 91 | ####### Implicit rules |
|
92 | 92 | |
|
93 | 93 | .SUFFIXES: .o .c .cpp .cc .cxx .C |
|
94 | 94 | |
|
95 | 95 | .cpp.o: |
|
96 | 96 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
97 | 97 | |
|
98 | 98 | .cc.o: |
|
99 | 99 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
100 | 100 | |
|
101 | 101 | .cxx.o: |
|
102 | 102 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
103 | 103 | |
|
104 | 104 | .C.o: |
|
105 | 105 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
106 | 106 | |
|
107 | 107 | .c.o: |
|
108 | 108 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" |
|
109 | 109 | |
|
110 | 110 | ####### Build rules |
|
111 | 111 | |
|
112 | 112 | all: Makefile $(TARGET) |
|
113 | 113 | |
|
114 | 114 | $(TARGET): $(OBJECTS) |
|
115 | 115 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ |
|
116 | 116 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) |
|
117 | 117 | |
|
118 | 118 | Makefile: timegen.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
119 | 119 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
120 | 120 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
121 | 121 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
122 | 122 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
123 | 123 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
124 | 124 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
125 | 125 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
126 | 126 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
127 | 127 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
128 | 128 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
129 | 129 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
130 | 130 | sparc.pri \ |
|
131 | 131 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
132 | 132 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
133 | 133 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
134 | 134 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
135 | 135 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
136 | 136 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
137 | 137 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
138 | 138 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
139 | 139 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
140 | 140 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf |
|
141 | 141 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile timegen.pro |
|
142 | 142 | /usr/lib64/qt4/mkspecs/common/unix.conf: |
|
143 | 143 | /usr/lib64/qt4/mkspecs/common/linux.conf: |
|
144 | 144 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: |
|
145 | 145 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: |
|
146 | 146 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: |
|
147 | 147 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: |
|
148 | 148 | /usr/lib64/qt4/mkspecs/qconfig.pri: |
|
149 | 149 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: |
|
150 | 150 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: |
|
151 | 151 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: |
|
152 | 152 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: |
|
153 | 153 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: |
|
154 | 154 | sparc.pri: |
|
155 | 155 | /usr/lib64/qt4/mkspecs/features/release.prf: |
|
156 | 156 | /usr/lib64/qt4/mkspecs/features/default_post.prf: |
|
157 | 157 | /usr/lib64/qt4/mkspecs/features/shared.prf: |
|
158 | 158 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: |
|
159 | 159 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: |
|
160 | 160 | /usr/lib64/qt4/mkspecs/features/resources.prf: |
|
161 | 161 | /usr/lib64/qt4/mkspecs/features/uic.prf: |
|
162 | 162 | /usr/lib64/qt4/mkspecs/features/yacc.prf: |
|
163 | 163 | /usr/lib64/qt4/mkspecs/features/lex.prf: |
|
164 | 164 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: |
|
165 | 165 | qmake: FORCE |
|
166 | 166 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile timegen.pro |
|
167 | 167 | |
|
168 | 168 | dist: |
|
169 | 169 | @$(CHK_DIR_EXISTS) obj/timegen1.0.0 || $(MKDIR) obj/timegen1.0.0 |
|
170 | 170 | $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/timegen1.0.0/ && (cd `dirname obj/timegen1.0.0` && $(TAR) timegen1.0.0.tar timegen1.0.0 && $(COMPRESS) timegen1.0.0.tar) && $(MOVE) `dirname obj/timegen1.0.0`/timegen1.0.0.tar.gz . && $(DEL_FILE) -r obj/timegen1.0.0 |
|
171 | 171 | |
|
172 | 172 | |
|
173 | 173 | clean:compiler_clean |
|
174 | 174 | -$(DEL_FILE) $(OBJECTS) |
|
175 | 175 | -$(DEL_FILE) *~ core *.core |
|
176 | 176 | |
|
177 | 177 | |
|
178 | 178 | ####### Sub-libraries |
|
179 | 179 | |
|
180 | 180 | distclean: clean |
|
181 | 181 | -$(DEL_FILE) $(TARGET) |
|
182 | 182 | -$(DEL_FILE) Makefile |
|
183 | 183 | |
|
184 | 184 | |
|
185 | 185 | grmon: |
|
186 | 186 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u |
|
187 | 187 | |
|
188 | 188 | check: first |
|
189 | 189 | |
|
190 | 190 | compiler_rcc_make_all: |
|
191 | 191 | compiler_rcc_clean: |
|
192 | 192 | compiler_uic_make_all: |
|
193 | 193 | compiler_uic_clean: |
|
194 | 194 | compiler_image_collection_make_all: qmake_image_collection.cpp |
|
195 | 195 | compiler_image_collection_clean: |
|
196 | 196 | -$(DEL_FILE) qmake_image_collection.cpp |
|
197 | 197 | compiler_yacc_decl_make_all: |
|
198 | 198 | compiler_yacc_decl_clean: |
|
199 | 199 | compiler_yacc_impl_make_all: |
|
200 | 200 | compiler_yacc_impl_clean: |
|
201 | 201 | compiler_lex_make_all: |
|
202 | 202 | compiler_lex_clean: |
|
203 | 203 | compiler_clean: |
|
204 | 204 | |
|
205 | 205 | ####### Compile |
|
206 | 206 | |
|
207 | 207 | obj/timegen_init.o: src/timegen_init.c |
|
208 | 208 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/timegen_init.o src/timegen_init.c |
|
209 | 209 | |
|
210 | 210 | obj/timegen_tc_handler.o: src/timegen_tc_handler.c |
|
211 | 211 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/timegen_tc_handler.o src/timegen_tc_handler.c |
|
212 | 212 | |
|
213 | 213 | obj/timegen_misc.o: src/timegen_misc.c |
|
214 | 214 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/timegen_misc.o src/timegen_misc.c |
|
215 | 215 | |
|
216 | 216 | obj/timegen_spacewire.o: src/timegen_spacewire.c |
|
217 | 217 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/timegen_spacewire.o src/timegen_spacewire.c |
|
218 | 218 | |
|
219 | 219 | obj/fsw_misc.o: ../src/fsw_misc.c |
|
220 | 220 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c |
|
221 | 221 | |
|
222 | 222 | obj/fsw_globals.o: ../src/fsw_globals.c |
|
223 | 223 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c |
|
224 | 224 | |
|
225 | 225 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c |
|
226 | 226 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c |
|
227 | 227 | |
|
228 | 228 | obj/tc_acceptance.o: ../src/tc_acceptance.c |
|
229 | 229 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c |
|
230 | 230 | |
|
231 | 231 | ####### Install |
|
232 | 232 | |
|
233 | 233 | install: FORCE |
|
234 | 234 | |
|
235 | 235 | uninstall: FORCE |
|
236 | 236 | |
|
237 | 237 | FORCE: |
|
238 | 238 |
@@ -1,41 +1,39 | |||
|
1 | 1 | #ifndef TIMEGEN_INIT_H_INCLUDED |
|
2 | 2 | #define TIMEGEN_INIT_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <leon.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "fsw_misc.h" |
|
9 | #include "fsw_processing.h" | |
|
10 | 9 | #include "wf_handler.h" |
|
11 | 10 | |
|
12 | 11 | #include "timegen_spacewire.h" |
|
13 | 12 | #include "timegen_misc.h" |
|
14 | 13 | |
|
15 | 14 | extern rtems_name Task_name[20]; /* array of task names */ |
|
16 | 15 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
16 | extern rtems_name misc_name[5]; | |
|
17 | 17 | |
|
18 | 18 | // RTEMS TASKS |
|
19 | 19 | rtems_task Init( rtems_task_argument argument); |
|
20 | 20 | |
|
21 | 21 | // OTHER functions |
|
22 | 22 | void create_names( void ); |
|
23 | 23 | int create_all_tasks( void ); |
|
24 | 24 | int start_all_tasks( void ); |
|
25 | 25 | // |
|
26 | 26 | rtems_status_code create_message_queues( void ); |
|
27 | 27 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
28 | 28 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
29 | 29 | // |
|
30 | 30 | int start_recv_send_tasks( void ); |
|
31 | 31 | // |
|
32 | 32 | void init_local_mode_parameters( void ); |
|
33 | 33 | void reset_local_time( void ); |
|
34 | 34 | |
|
35 | extern int rtems_cpu_usage_report( void ); | |
|
36 | extern int rtems_cpu_usage_reset( void ); | |
|
37 | 35 | extern void rtems_stack_checker_report_usage( void ); |
|
38 | 36 | |
|
39 | 37 | extern int sched_yield( void ); |
|
40 | 38 | |
|
41 | 39 | #endif // TIMEGEN_INIT_H_INCLUDED |
@@ -1,39 +1,41 | |||
|
1 | 1 | #ifndef TIMEGEN_MISC_H_INCLUDED |
|
2 | 2 | #define TIMEGEN_MISC_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <leon.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "TC_types.h" |
|
9 | 9 | #include "tc_acceptance.h" |
|
10 | 10 | #include "timegen_init.h" |
|
11 | 11 | |
|
12 | 12 | #define TASK_PRIORITY_UPDT 40 |
|
13 | 13 | |
|
14 | 14 | typedef struct { |
|
15 | 15 | unsigned char targetLogicalAddress; |
|
16 | 16 | unsigned char protocolIdentifier; |
|
17 | 17 | unsigned char reserved; |
|
18 | 18 | unsigned char userApplication; |
|
19 | 19 | // PACKET HEADER |
|
20 | 20 | Packet_TC_LFR_UPDATE_TIME_t update_time; |
|
21 | 21 | } Packet_TC_LFR_UPDATE_TIME_WITH_OVERHEAD_t; |
|
22 | 22 | |
|
23 | 23 | unsigned int coarseTime; |
|
24 | 24 | |
|
25 | 25 | rtems_name rtems_name_updt; |
|
26 | 26 | rtems_id rtems_id_updt; |
|
27 | rtems_name rtems_name_act_; | |
|
28 | rtems_id rtems_id_act_; | |
|
27 | 29 | |
|
28 | 30 | void timegen_timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ); |
|
29 | 31 | |
|
30 | 32 | void initCoarseTime( void ); |
|
31 | 33 | |
|
32 | 34 | rtems_task updt_task( rtems_task_argument unused ); |
|
33 | 35 | |
|
34 | 36 | int send_tc_lfr_update_time( rtems_id queue_id ); |
|
35 | 37 | |
|
36 | 38 | #endif // TIMEGEN_MISC_H_INCLUDED |
|
37 | 39 | |
|
38 | 40 | |
|
39 | 41 |
@@ -1,56 +1,34 | |||
|
1 | 1 | #ifndef TIMEGEN_TC_HANDLER_H_INCLUDED |
|
2 | 2 | #define TIMEGEN_TC_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <leon.h> |
|
6 | 6 | |
|
7 | 7 | #include "tc_load_dump_parameters.h" |
|
8 | 8 | #include "tc_acceptance.h" |
|
9 | 9 | #include "tm_lfr_tc_exe.h" |
|
10 | 10 | |
|
11 | 11 | // MODE PARAMETERS |
|
12 | 12 | extern unsigned int maxCount; |
|
13 | 13 | |
|
14 | 14 | //**** |
|
15 | 15 | // ISR |
|
16 | 16 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
17 | 17 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
18 | 18 | |
|
19 | 19 | //*********** |
|
20 | 20 | // RTEMS TASK |
|
21 |
rtems_task act |
|
|
21 | rtems_task act__task( rtems_task_argument unused ); | |
|
22 | 22 | |
|
23 | 23 | //*********** |
|
24 | 24 | // TC ACTIONS |
|
25 |
int action_ |
|
|
26 |
int action_ |
|
|
27 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
|
28 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
|
29 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
|
30 | int action_update_time(ccsdsTelecommandPacket_t *TC); | |
|
31 | ||
|
32 | // mode transition | |
|
33 | int transition_validation(unsigned char requestedMode); | |
|
34 | int stop_current_mode( void ); | |
|
35 | int enter_mode(unsigned char mode); | |
|
36 | int restart_science_tasks(); | |
|
37 | int suspend_science_tasks(); | |
|
38 | void launch_waveform_picker( unsigned char mode ); | |
|
39 | void launch_spectral_matrix( unsigned char mode ); | |
|
40 | void set_irq_on_new_ready_matrix(unsigned char value ); | |
|
41 | void set_run_matrix_spectral( unsigned char value ); | |
|
42 | void launch_spectral_matrix_simu( unsigned char mode ); | |
|
43 | ||
|
44 | // other functions | |
|
45 | void updateLFRCurrentMode(); | |
|
46 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC ); | |
|
47 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC ); | |
|
48 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); | |
|
25 | int timegen_action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
|
26 | int timegen_action_update_time(ccsdsTelecommandPacket_t *TC); | |
|
49 | 27 | |
|
50 | 28 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
51 | 29 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
52 | 30 | |
|
53 | 31 | #endif // TIMEGEN_TC_HANDLER_H_INCLUDED |
|
54 | 32 | |
|
55 | 33 | |
|
56 | 34 |
@@ -1,476 +1,432 | |||
|
1 | 1 | /** This is the RTEMS initialization module. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * This module contains two very different information: |
|
7 | 7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
8 | 8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
9 | 9 | * |
|
10 | 10 | */ |
|
11 | 11 | |
|
12 | 12 | //************************* |
|
13 | 13 | // GPL reminder to be added |
|
14 | 14 | //************************* |
|
15 | 15 | |
|
16 | 16 | #include <rtems.h> |
|
17 | 17 | |
|
18 | 18 | /* configuration information */ |
|
19 | 19 | |
|
20 | 20 | #define CONFIGURE_INIT |
|
21 | 21 | |
|
22 | 22 | #include <bsp.h> /* for device driver prototypes */ |
|
23 | 23 | |
|
24 | 24 | /* configuration information */ |
|
25 | 25 | |
|
26 | 26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
27 | 27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
28 | 28 | |
|
29 | 29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
30 | 30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
31 | 31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
32 | 32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
33 | 33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
34 | 34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
35 | 35 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
36 | 36 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
37 | 37 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
38 | 38 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 |
|
39 | 39 | #ifdef PRINT_STACK_REPORT |
|
40 | 40 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
41 | 41 | #endif |
|
42 | 42 | |
|
43 | 43 | #include <rtems/confdefs.h> |
|
44 | 44 | |
|
45 | 45 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
46 | 46 | #ifdef RTEMS_DRVMGR_STARTUP |
|
47 | 47 | #ifdef LEON3 |
|
48 | 48 | /* Add Timer and UART Driver */ |
|
49 | 49 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
50 | 50 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
51 | 51 | #endif |
|
52 | 52 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
53 | 53 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
54 | 54 | #endif |
|
55 | 55 | #endif |
|
56 | 56 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
57 | 57 | #include <drvmgr/drvmgr_confdefs.h> |
|
58 | 58 | #endif |
|
59 | 59 | |
|
60 | 60 | #include "timegen_init.h" |
|
61 | 61 | #include "fsw_config.c" |
|
62 | 62 | |
|
63 | 63 | rtems_task Init( rtems_task_argument ignored ) |
|
64 | 64 | { |
|
65 | 65 | /** This is the RTEMS INIT taks, it the first task launched by the system. |
|
66 | 66 | * |
|
67 | 67 | * @param unused is the starting argument of the RTEMS task |
|
68 | 68 | * |
|
69 | 69 | * The INIT task create and run all other RTEMS tasks. |
|
70 | 70 | * |
|
71 | 71 | */ |
|
72 | 72 | |
|
73 | 73 | rtems_status_code status; |
|
74 | 74 | rtems_status_code status_spw; |
|
75 | 75 | |
|
76 | 76 | // initCoarseTime(); |
|
77 | 77 | |
|
78 | 78 | // UART settings |
|
79 | 79 | send_console_outputs_on_apbuart_port(); |
|
80 | 80 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
81 | 81 | enable_apbuart_transmitter(); |
|
82 | 82 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
83 | 83 | |
|
84 | 84 | PRINTF("\n\n\n\n\n") |
|
85 | 85 | PRINTF("*************************\n") |
|
86 | 86 | PRINTF("** Time Generator **\n") |
|
87 | 87 | PRINTF1("** %d.", SW_VERSION_N1) |
|
88 | 88 | PRINTF1("%d.", SW_VERSION_N2) |
|
89 | 89 | PRINTF1("%d.", SW_VERSION_N3) |
|
90 | 90 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
91 | 91 | PRINTF("*************************\n") |
|
92 | 92 | PRINTF("\n\n") |
|
93 | 93 | |
|
94 | 94 | // init_local_mode_parameters(); |
|
95 | 95 | // init_housekeeping_parameters(); |
|
96 | 96 | |
|
97 | 97 | // updateLFRCurrentMode(); |
|
98 | 98 | |
|
99 | 99 | // BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
100 | 100 | |
|
101 | 101 | create_names(); // create all names |
|
102 | 102 | |
|
103 | 103 | status = create_message_queues(); // create message queues |
|
104 | 104 | if (status != RTEMS_SUCCESSFUL) |
|
105 | 105 | { |
|
106 | 106 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
107 | 107 | } |
|
108 | 108 | |
|
109 | 109 | status = create_all_tasks(); // create all tasks |
|
110 | 110 | if (status != RTEMS_SUCCESSFUL) |
|
111 | 111 | { |
|
112 | 112 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) |
|
113 | 113 | } |
|
114 | 114 | |
|
115 | 115 | // ************************** |
|
116 | 116 | // <SPACEWIRE INITIALIZATION> |
|
117 | 117 | grspw_timecode_callback = &timegen_timecode_irq_handler; |
|
118 | 118 | |
|
119 | 119 | status_spw = spacewire_open_link(); // (1) open the link |
|
120 | 120 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
121 | 121 | { |
|
122 | 122 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
123 | 123 | } |
|
124 | 124 | |
|
125 | 125 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
126 | 126 | { |
|
127 | 127 | status_spw = spacewire_configure_link( fdSPW ); |
|
128 | 128 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
129 | 129 | { |
|
130 | 130 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
135 | 135 | { |
|
136 | 136 | status_spw = spacewire_start_link( fdSPW ); |
|
137 | 137 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
138 | 138 | { |
|
139 | 139 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
140 | 140 | } |
|
141 | 141 | } |
|
142 | 142 | // </SPACEWIRE INITIALIZATION> |
|
143 | 143 | // *************************** |
|
144 | 144 | |
|
145 | 145 | status = start_all_tasks(); // start all tasks |
|
146 | 146 | if (status != RTEMS_SUCCESSFUL) |
|
147 | 147 | { |
|
148 | 148 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
149 | 149 | } |
|
150 | 150 | |
|
151 | 151 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
152 | 152 | status = start_recv_send_tasks(); |
|
153 | 153 | if ( status != RTEMS_SUCCESSFUL ) |
|
154 | 154 | { |
|
155 | 155 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
156 | 156 | } |
|
157 | 157 | |
|
158 | // suspend science tasks. they will be restarted later depending on the mode | |
|
159 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) | |
|
160 | if (status != RTEMS_SUCCESSFUL) | |
|
161 | { | |
|
162 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) | |
|
163 | } | |
|
164 | ||
|
165 | 158 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
166 | 159 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
167 | 160 | { |
|
168 | 161 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
169 | 162 | if ( status != RTEMS_SUCCESSFUL ) { |
|
170 | 163 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
171 | 164 | } |
|
172 | 165 | } |
|
173 | 166 | |
|
174 | 167 | BOOT_PRINTF("delete INIT\n") |
|
175 | 168 | |
|
176 | 169 | status = rtems_task_delete(RTEMS_SELF); |
|
177 | 170 | |
|
178 | 171 | } |
|
179 | 172 | |
|
180 | void init_local_mode_parameters( void ) | |
|
181 | { | |
|
182 | /** This function initialize the param_local global variable with default values. | |
|
183 | * | |
|
184 | */ | |
|
185 | ||
|
186 | unsigned int i; | |
|
187 | ||
|
188 | // LOCAL PARAMETERS | |
|
189 | // set_local_nb_interrupt_f0_MAX(); | |
|
190 | ||
|
191 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
|
192 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
|
193 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
|
194 | ||
|
195 | // init sequence counters | |
|
196 | ||
|
197 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
|
198 | { | |
|
199 | sequenceCounters_TC_EXE[i] = 0x00; | |
|
200 | } | |
|
201 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
|
202 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
|
203 | } | |
|
204 | ||
|
205 | 173 | void create_names( void ) // create all names for tasks and queues |
|
206 | 174 | { |
|
207 | 175 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
208 | 176 | * |
|
209 | 177 | * @return RTEMS directive status codes: |
|
210 | 178 | * - RTEMS_SUCCESSFUL - successful completion |
|
211 | 179 | * |
|
212 | 180 | */ |
|
213 | 181 | |
|
214 | 182 | // task names |
|
215 | 183 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
216 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
|
217 | 184 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
218 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); | |
|
219 | 185 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
220 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
|
221 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); | |
|
222 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
|
223 | 186 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
224 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
|
225 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); | |
|
226 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
|
227 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
|
228 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
|
229 | 187 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
230 | 188 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
231 | 189 | |
|
232 | 190 | // TIMEGEN |
|
233 | 191 | rtems_name_updt = rtems_build_name( 'U', 'P', 'D', 'T' ); |
|
234 | ||
|
235 | // rate monotonic period names | |
|
236 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
|
192 | rtems_name_act_ = rtems_build_name( 'A', 'C', 'T', '_' ); | |
|
237 | 193 | |
|
238 | 194 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
239 | 195 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
240 | 196 | } |
|
241 | 197 | |
|
242 | 198 | int create_all_tasks( void ) // create all tasks which run in the software |
|
243 | 199 | { |
|
244 | 200 | /** This function creates all RTEMS tasks used in the software. |
|
245 | 201 | * |
|
246 | 202 | * @return RTEMS directive status codes: |
|
247 | 203 | * - RTEMS_SUCCESSFUL - task created successfully |
|
248 | 204 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
249 | 205 | * - RTEMS_INVALID_NAME - invalid task name |
|
250 | 206 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
251 | 207 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
252 | 208 | * - RTEMS_TOO_MANY - too many tasks created |
|
253 | 209 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
254 | 210 | * - RTEMS_TOO_MANY - too many global objects |
|
255 | 211 | * |
|
256 | 212 | */ |
|
257 | 213 | |
|
258 | 214 | rtems_status_code status; |
|
259 | 215 | |
|
260 | 216 | //********** |
|
261 | 217 | // SPACEWIRE |
|
262 | 218 | // RECV |
|
263 | 219 | status = rtems_task_create( |
|
264 | 220 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
265 | 221 | RTEMS_DEFAULT_MODES, |
|
266 | 222 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
267 | 223 | ); |
|
268 | 224 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
269 | 225 | { |
|
270 | 226 | status = rtems_task_create( |
|
271 | 227 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, |
|
272 | 228 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
273 | 229 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] |
|
274 | 230 | ); |
|
275 | 231 | } |
|
276 | 232 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
277 | 233 | { |
|
278 | 234 | status = rtems_task_create( |
|
279 | 235 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
280 | 236 | RTEMS_DEFAULT_MODES, |
|
281 | 237 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
282 | 238 | ); |
|
283 | 239 | } |
|
284 |
if (status == RTEMS_SUCCESSFUL) // ACT |
|
|
240 | if (status == RTEMS_SUCCESSFUL) // ACT_ | |
|
285 | 241 | { |
|
286 | 242 | status = rtems_task_create( |
|
287 |
|
|
|
243 | rtems_id_act_, TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
|
288 | 244 | RTEMS_DEFAULT_MODES, |
|
289 |
RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, & |
|
|
245 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &rtems_id_act_ | |
|
290 | 246 | ); |
|
291 | 247 | } |
|
292 | 248 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
293 | 249 | { |
|
294 | 250 | status = rtems_task_create( |
|
295 | 251 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
296 | 252 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
297 | 253 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
298 | 254 | ); |
|
299 | 255 | } |
|
300 | 256 | |
|
301 | 257 | //***** |
|
302 | 258 | // MISC |
|
303 | 259 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
304 | 260 | { |
|
305 | 261 | status = rtems_task_create( |
|
306 | 262 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
307 | 263 | RTEMS_DEFAULT_MODES, |
|
308 | 264 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
309 | 265 | ); |
|
310 | 266 | } |
|
311 | 267 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
312 | 268 | { |
|
313 | 269 | status = rtems_task_create( |
|
314 | 270 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
315 | 271 | RTEMS_DEFAULT_MODES, |
|
316 | 272 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
317 | 273 | ); |
|
318 | 274 | } |
|
319 | 275 | if (status == RTEMS_SUCCESSFUL) // UPDT |
|
320 | 276 | { |
|
321 | 277 | status = rtems_task_create( |
|
322 | 278 | rtems_name_updt, TASK_PRIORITY_UPDT, RTEMS_MINIMUM_STACK_SIZE, |
|
323 | 279 | RTEMS_DEFAULT_MODES, |
|
324 | 280 | RTEMS_DEFAULT_ATTRIBUTES, &rtems_id_updt |
|
325 | 281 | ); |
|
326 | 282 | } |
|
327 | 283 | |
|
328 | 284 | return status; |
|
329 | 285 | } |
|
330 | 286 | |
|
331 | 287 | int start_recv_send_tasks( void ) |
|
332 | 288 | { |
|
333 | 289 | rtems_status_code status; |
|
334 | 290 | |
|
335 | 291 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
336 | 292 | if (status!=RTEMS_SUCCESSFUL) { |
|
337 | 293 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
338 | 294 | } |
|
339 | 295 | |
|
340 | 296 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
341 | 297 | { |
|
342 | 298 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
343 | 299 | if (status!=RTEMS_SUCCESSFUL) { |
|
344 | 300 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
345 | 301 | } |
|
346 | 302 | } |
|
347 | 303 | |
|
348 | 304 | return status; |
|
349 | 305 | } |
|
350 | 306 | |
|
351 | 307 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
352 | 308 | { |
|
353 | 309 | /** This function starts all RTEMS tasks used in the software. |
|
354 | 310 | * |
|
355 | 311 | * @return RTEMS directive status codes: |
|
356 | 312 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
357 | 313 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
358 | 314 | * - RTEMS_INVALID_ID - invalid task id |
|
359 | 315 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
360 | 316 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
361 | 317 | * |
|
362 | 318 | */ |
|
363 | 319 | // starts all the tasks fot eh flight software |
|
364 | 320 | |
|
365 | 321 | rtems_status_code status; |
|
366 | 322 | |
|
367 | 323 | //********** |
|
368 | 324 | // SPACEWIRE |
|
369 | 325 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
370 | 326 | if (status!=RTEMS_SUCCESSFUL) { |
|
371 | 327 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
372 | 328 | } |
|
373 | 329 | |
|
374 | 330 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
375 | 331 | { |
|
376 | 332 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
377 | 333 | if (status!=RTEMS_SUCCESSFUL) { |
|
378 | 334 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
379 | 335 | } |
|
380 | 336 | } |
|
381 | 337 | |
|
382 |
if (status == RTEMS_SUCCESSFUL) // ACT |
|
|
338 | if (status == RTEMS_SUCCESSFUL) // ACT_ | |
|
383 | 339 | { |
|
384 |
status = rtems_task_start( |
|
|
340 | status = rtems_task_start( rtems_id_act_, act__task, 1 ); | |
|
385 | 341 | if (status!=RTEMS_SUCCESSFUL) { |
|
386 |
BOOT_PRINTF("in INIT *** Error starting TASK_ACT |
|
|
342 | BOOT_PRINTF("in INIT *** Error starting TASK_ACT_\n") | |
|
387 | 343 | } |
|
388 | 344 | } |
|
389 | 345 | |
|
390 | 346 | //***** |
|
391 | 347 | // MISC |
|
392 | 348 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
393 | 349 | { |
|
394 | 350 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
395 | 351 | if (status!=RTEMS_SUCCESSFUL) { |
|
396 | 352 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
397 | 353 | } |
|
398 | 354 | } |
|
399 | 355 | |
|
400 | 356 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
401 | 357 | { |
|
402 | 358 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
403 | 359 | if (status!=RTEMS_SUCCESSFUL) { |
|
404 | 360 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
405 | 361 | } |
|
406 | 362 | } |
|
407 | 363 | |
|
408 | 364 | if (status == RTEMS_SUCCESSFUL) // UPDT |
|
409 | 365 | { |
|
410 | 366 | status = rtems_task_start( rtems_id_updt, updt_task, 1 ); |
|
411 | 367 | if (status!=RTEMS_SUCCESSFUL) { |
|
412 | 368 | BOOT_PRINTF("in INIT *** Error starting TASK_UPDT\n") |
|
413 | 369 | } |
|
414 | 370 | } |
|
415 | 371 | |
|
416 | 372 | return status; |
|
417 | 373 | } |
|
418 | 374 | |
|
419 | 375 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
420 | 376 | { |
|
421 | 377 | rtems_status_code status_recv; |
|
422 | 378 | rtems_status_code status_send; |
|
423 | 379 | rtems_status_code ret; |
|
424 | 380 | rtems_id queue_id; |
|
425 | 381 | |
|
426 | 382 | // create the queue for handling valid TCs |
|
427 | 383 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
428 |
|
|
|
384 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
|
429 | 385 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
430 | 386 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
431 | 387 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
432 | 388 | } |
|
433 | 389 | |
|
434 | 390 | // create the queue for handling TM packet sending |
|
435 | 391 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
436 |
|
|
|
392 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
|
437 | 393 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
438 | 394 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
439 | 395 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
440 | 396 | } |
|
441 | 397 | |
|
442 | 398 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
443 | 399 | { |
|
444 | 400 | ret = status_recv; |
|
445 | 401 | } |
|
446 | 402 | else |
|
447 | 403 | { |
|
448 | 404 | ret = status_send; |
|
449 | 405 | } |
|
450 | 406 | |
|
451 | 407 | return ret; |
|
452 | 408 | } |
|
453 | 409 | |
|
454 | 410 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
455 | 411 | { |
|
456 | 412 | rtems_status_code status; |
|
457 | 413 | rtems_name queue_name; |
|
458 | 414 | |
|
459 | 415 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
460 | 416 | |
|
461 | 417 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
462 | 418 | |
|
463 | 419 | return status; |
|
464 | 420 | } |
|
465 | 421 | |
|
466 | 422 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
467 | 423 | { |
|
468 | 424 | rtems_status_code status; |
|
469 | 425 | rtems_name queue_name; |
|
470 | 426 | |
|
471 | 427 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
472 | 428 | |
|
473 | 429 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
474 | 430 | |
|
475 | 431 | return status; |
|
476 | 432 | } |
@@ -1,601 +1,123 | |||
|
1 | 1 | /** Functions related to the SpaceWire interface. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle SpaceWire transmissions: |
|
7 | 7 | * - configuration of the SpaceWire link |
|
8 | 8 | * - SpaceWire related interruption requests processing |
|
9 | 9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
10 | 10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
11 | 11 | * |
|
12 | 12 | */ |
|
13 | 13 | |
|
14 | 14 | #include "timegen_spacewire.h" |
|
15 | 15 | |
|
16 | 16 | rtems_name semq_name; |
|
17 | 17 | rtems_id semq_id; |
|
18 | 18 | |
|
19 | 19 | //*********** |
|
20 | 20 | // RTEMS TASK |
|
21 | 21 | rtems_task spiq_task(rtems_task_argument unused) |
|
22 | 22 | { |
|
23 | 23 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
24 | 24 | * |
|
25 | 25 | * @param unused is the starting argument of the RTEMS task |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | rtems_event_set event_out; |
|
30 | 30 | rtems_status_code status; |
|
31 | 31 | int linkStatus; |
|
32 | 32 | |
|
33 | 33 | BOOT_PRINTF("in SPIQ *** \n") |
|
34 | 34 | |
|
35 | 35 | while(true){ |
|
36 | 36 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
37 | 37 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
38 | 38 | |
|
39 | 39 | // [0] SUSPEND RECV AND SEND TASKS |
|
40 | 40 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
41 | 41 | if ( status != RTEMS_SUCCESSFUL ) { |
|
42 | 42 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
43 | 43 | } |
|
44 | 44 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
45 | 45 | if ( status != RTEMS_SUCCESSFUL ) { |
|
46 | 46 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
47 | 47 | } |
|
48 | 48 | |
|
49 | 49 | // [1] CHECK THE LINK |
|
50 | 50 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
51 | 51 | if ( linkStatus != 5) { |
|
52 | 52 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
53 | 53 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
57 | 57 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
58 | 58 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
59 | 59 | { |
|
60 | 60 | spacewire_compute_stats_offsets(); |
|
61 | 61 | status = spacewire_reset_link( ); |
|
62 | 62 | } |
|
63 | 63 | else // [2.b] in run state, start the link |
|
64 | 64 | { |
|
65 | 65 | status = spacewire_stop_start_link( fdSPW ); // start the link |
|
66 | 66 | if ( status != RTEMS_SUCCESSFUL) |
|
67 | 67 | { |
|
68 | 68 | PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status) |
|
69 | 69 | } |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
73 | 73 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
74 | 74 | { |
|
75 | 75 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
76 | 76 | if ( status != RTEMS_SUCCESSFUL ) { |
|
77 | 77 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
78 | 78 | } |
|
79 | 79 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
80 | 80 | if ( status != RTEMS_SUCCESSFUL ) { |
|
81 | 81 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
82 | 82 | } |
|
83 | 83 | } |
|
84 | 84 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
85 | 85 | { |
|
86 | status = stop_current_mode(); | |
|
87 | if ( status != RTEMS_SUCCESSFUL ) { | |
|
88 | PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status) | |
|
89 | } | |
|
90 | status = enter_mode( LFR_MODE_STANDBY ); | |
|
91 | if ( status != RTEMS_SUCCESSFUL ) { | |
|
92 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) | |
|
93 | } | |
|
94 | 86 | // wake the WTDG task up to wait for the link recovery |
|
95 | 87 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
96 | 88 | status = rtems_task_suspend( RTEMS_SELF ); |
|
97 | 89 | } |
|
98 | 90 | } |
|
99 | 91 | } |
|
100 | 92 | |
|
101 | rtems_task recv_task( rtems_task_argument unused ) | |
|
102 | { | |
|
103 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
|
104 | * | |
|
105 | * @param unused is the starting argument of the RTEMS task | |
|
106 | * | |
|
107 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
|
108 | * 1. It reads the incoming data. | |
|
109 | * 2. Launches the acceptance procedure. | |
|
110 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. | |
|
111 | * | |
|
112 | */ | |
|
113 | ||
|
114 | int len; | |
|
115 | ccsdsTelecommandPacket_t currentTC; | |
|
116 | unsigned char computed_CRC[ 2 ]; | |
|
117 | unsigned char currentTC_LEN_RCV[ 2 ]; | |
|
118 | unsigned char destinationID; | |
|
119 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; | |
|
120 | unsigned int parserCode; | |
|
121 | unsigned char time[6]; | |
|
122 | rtems_status_code status; | |
|
123 | rtems_id queue_recv_id; | |
|
124 | rtems_id queue_send_id; | |
|
125 | ||
|
126 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
|
127 | ||
|
128 | status = get_message_queue_id_recv( &queue_recv_id ); | |
|
129 | if (status != RTEMS_SUCCESSFUL) | |
|
130 | { | |
|
131 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) | |
|
132 | } | |
|
133 | ||
|
134 | status = get_message_queue_id_send( &queue_send_id ); | |
|
135 | if (status != RTEMS_SUCCESSFUL) | |
|
136 | { | |
|
137 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) | |
|
138 | } | |
|
139 | ||
|
140 | BOOT_PRINTF("in RECV *** \n") | |
|
141 | ||
|
142 | while(1) | |
|
143 | { | |
|
144 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking | |
|
145 | if (len == -1){ // error during the read call | |
|
146 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) | |
|
147 | } | |
|
148 | else { | |
|
149 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
|
150 | PRINTF("in RECV *** packet lenght too short\n") | |
|
151 | } | |
|
152 | else { | |
|
153 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
|
154 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8); | |
|
155 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt ); | |
|
156 | // CHECK THE TC | |
|
157 | parserCode = tc_parser( ¤tTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ; | |
|
158 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) | |
|
159 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) | |
|
160 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) | |
|
161 | || (parserCode == WRONG_SRC_ID) ) | |
|
162 | { // send TM_LFR_TC_EXE_CORRUPTED | |
|
163 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
|
164 | && | |
|
165 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
|
166 | ) | |
|
167 | { | |
|
168 | if ( parserCode == WRONG_SRC_ID ) | |
|
169 | { | |
|
170 | destinationID = SID_TC_GROUND; | |
|
171 | } | |
|
172 | else | |
|
173 | { | |
|
174 | destinationID = currentTC.sourceID; | |
|
175 | } | |
|
176 | getTime( time ); | |
|
177 | close_action( ¤tTC, LFR_DEFAULT, queue_send_id ); | |
|
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, | |
|
179 | computed_CRC, currentTC_LEN_RCV, | |
|
180 | destinationID ); | |
|
181 | } | |
|
182 | } | |
|
183 | else | |
|
184 | { // send valid TC to the action launcher | |
|
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, | |
|
186 | currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
|
187 | } | |
|
188 | } | |
|
189 | } | |
|
190 | } | |
|
191 | } | |
|
192 | ||
|
193 | rtems_task send_task( rtems_task_argument argument) | |
|
194 | { | |
|
195 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. | |
|
196 | * | |
|
197 | * @param unused is the starting argument of the RTEMS task | |
|
198 | * | |
|
199 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: | |
|
200 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. | |
|
201 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After | |
|
202 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the | |
|
203 | * data it contains. | |
|
204 | * | |
|
205 | */ | |
|
206 | ||
|
207 | rtems_status_code status; // RTEMS status code | |
|
208 | char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer | |
|
209 | size_t size; // size of the incoming TC packet | |
|
210 | u_int32_t count; | |
|
211 | rtems_id queue_id; | |
|
212 | ||
|
213 | status = get_message_queue_id_send( &queue_id ); | |
|
214 | if (status != RTEMS_SUCCESSFUL) | |
|
215 | { | |
|
216 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
|
217 | } | |
|
218 | ||
|
219 | BOOT_PRINTF("in SEND *** \n") | |
|
220 | ||
|
221 | while(1) | |
|
222 | { | |
|
223 | status = rtems_message_queue_receive( queue_id, incomingData, &size, | |
|
224 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
|
225 | ||
|
226 | if (status!=RTEMS_SUCCESSFUL) | |
|
227 | { | |
|
228 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
|
229 | } | |
|
230 | else | |
|
231 | { | |
|
232 | status = write( fdSPW, incomingData, size ); | |
|
233 | if (status == -1){ | |
|
234 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
|
235 | } | |
|
236 | } | |
|
237 | ||
|
238 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
|
239 | if (status != RTEMS_SUCCESSFUL) | |
|
240 | { | |
|
241 | PRINTF1("in SEND *** (3) ERR = %d\n", status) | |
|
242 | } | |
|
243 | else | |
|
244 | { | |
|
245 | if (count > maxCount) | |
|
246 | { | |
|
247 | maxCount = count; | |
|
248 | } | |
|
249 | } | |
|
250 | } | |
|
251 | } | |
|
252 | ||
|
253 | rtems_task wtdg_task( rtems_task_argument argument ) | |
|
254 | { | |
|
255 | rtems_event_set event_out; | |
|
256 | rtems_status_code status; | |
|
257 | int linkStatus; | |
|
258 | ||
|
259 | BOOT_PRINTF("in WTDG ***\n") | |
|
260 | ||
|
261 | while(1) | |
|
262 | { | |
|
263 | // wait for an RTEMS_EVENT | |
|
264 | rtems_event_receive( RTEMS_EVENT_0, | |
|
265 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
|
266 | PRINTF("in WTDG *** wait for the link\n") | |
|
267 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
|
268 | while( linkStatus != 5) // wait for the link | |
|
269 | { | |
|
270 | rtems_task_wake_after( 10 ); | |
|
271 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
|
272 | } | |
|
273 | ||
|
274 | status = spacewire_stop_start_link( fdSPW ); | |
|
275 | ||
|
276 | if (status != RTEMS_SUCCESSFUL) | |
|
277 | { | |
|
278 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
|
279 | } | |
|
280 | else | |
|
281 | { | |
|
282 | PRINTF("in WTDG *** OK link started\n") | |
|
283 | } | |
|
284 | ||
|
285 | // restart the SPIQ task | |
|
286 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
|
287 | if ( status != RTEMS_SUCCESSFUL ) { | |
|
288 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
|
289 | } | |
|
290 | ||
|
291 | // restart RECV and SEND | |
|
292 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
|
293 | if ( status != RTEMS_SUCCESSFUL ) { | |
|
294 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
|
295 | } | |
|
296 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
|
297 | if ( status != RTEMS_SUCCESSFUL ) { | |
|
298 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
|
299 | } | |
|
300 | } | |
|
301 | } | |
|
302 | ||
|
303 | //**************** | |
|
304 | // OTHER FUNCTIONS | |
|
305 | int spacewire_open_link( void ) | |
|
306 | { | |
|
307 | /** This function opens the SpaceWire link. | |
|
308 | * | |
|
309 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
|
310 | * | |
|
311 | */ | |
|
312 | rtems_status_code status; | |
|
313 | ||
|
314 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
|
315 | if ( fdSPW < 0 ) { | |
|
316 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
|
317 | } | |
|
318 | else | |
|
319 | { | |
|
320 | status = RTEMS_SUCCESSFUL; | |
|
321 | } | |
|
322 | ||
|
323 | return status; | |
|
324 | } | |
|
325 | ||
|
326 | int spacewire_start_link( int fd ) | |
|
327 | { | |
|
328 | rtems_status_code status; | |
|
329 | ||
|
330 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
|
331 | // -1 default hardcoded driver timeout | |
|
332 | ||
|
333 | return status; | |
|
334 | } | |
|
335 | ||
|
336 | int spacewire_stop_start_link( int fd ) | |
|
337 | { | |
|
338 | rtems_status_code status; | |
|
339 | ||
|
340 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
|
341 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
|
342 | // -1 default hardcoded driver timeout | |
|
343 | ||
|
344 | return status; | |
|
345 | } | |
|
346 | ||
|
347 | int spacewire_configure_link( int fd ) | |
|
348 | { | |
|
349 | /** This function configures the SpaceWire link. | |
|
350 | * | |
|
351 | * @return GR-RTEMS-DRIVER directive status codes: | |
|
352 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
|
353 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
|
354 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
|
355 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
|
356 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
|
357 | * - 5 EIO - Error when writing to grswp hardware registers. | |
|
358 | * - 2 ENOENT - No such file or directory | |
|
359 | */ | |
|
360 | ||
|
361 | rtems_status_code status; | |
|
362 | ||
|
363 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
|
364 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
|
365 | ||
|
366 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
|
367 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
|
368 | // | |
|
369 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
|
370 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
|
371 | // | |
|
372 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
|
373 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
|
374 | // | |
|
375 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
|
376 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
|
377 | // | |
|
378 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks | |
|
379 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
|
380 | // | |
|
381 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
|
382 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
|
383 | // | |
|
384 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
|
385 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL\n") | |
|
386 | ||
|
387 | return status; | |
|
388 | } | |
|
389 | ||
|
390 | int spacewire_reset_link( void ) | |
|
391 | { | |
|
392 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
|
393 | * | |
|
394 | * @return RTEMS directive status code: | |
|
395 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
|
396 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
|
397 | * | |
|
398 | */ | |
|
399 | ||
|
400 | rtems_status_code status_spw; | |
|
401 | int i; | |
|
402 | ||
|
403 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
|
404 | { | |
|
405 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
|
406 | ||
|
407 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
|
408 | ||
|
409 | status_spw = spacewire_stop_start_link( fdSPW ); | |
|
410 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
|
411 | { | |
|
412 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
|
413 | } | |
|
414 | ||
|
415 | if ( status_spw == RTEMS_SUCCESSFUL) | |
|
416 | { | |
|
417 | break; | |
|
418 | } | |
|
419 | } | |
|
420 | ||
|
421 | return status_spw; | |
|
422 | } | |
|
423 | ||
|
424 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
|
425 | { | |
|
426 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
|
427 | * | |
|
428 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
|
429 | * @param regAddr is the address of the GRSPW control register. | |
|
430 | * | |
|
431 | * NP is the bit 20 of the GRSPW control register. | |
|
432 | * | |
|
433 | */ | |
|
434 | ||
|
435 | unsigned int *spwptr = (unsigned int*) regAddr; | |
|
436 | ||
|
437 | if (val == 1) { | |
|
438 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
|
439 | } | |
|
440 | if (val== 0) { | |
|
441 | *spwptr = *spwptr & 0xffdfffff; | |
|
442 | } | |
|
443 | } | |
|
444 | ||
|
445 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
|
446 | { | |
|
447 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
|
448 | * | |
|
449 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
|
450 | * @param regAddr is the address of the GRSPW control register. | |
|
451 | * | |
|
452 | * RE is the bit 16 of the GRSPW control register. | |
|
453 | * | |
|
454 | */ | |
|
455 | ||
|
456 | unsigned int *spwptr = (unsigned int*) regAddr; | |
|
457 | ||
|
458 | if (val == 1) | |
|
459 | { | |
|
460 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
|
461 | } | |
|
462 | if (val== 0) | |
|
463 | { | |
|
464 | *spwptr = *spwptr & 0xfffdffff; | |
|
465 | } | |
|
466 | } | |
|
467 | ||
|
468 | void spacewire_compute_stats_offsets( void ) | |
|
469 | { | |
|
470 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
|
471 | * | |
|
472 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
|
473 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
|
474 | * during the open systel call). | |
|
475 | * | |
|
476 | */ | |
|
477 | ||
|
478 | spw_stats spacewire_stats_grspw; | |
|
479 | rtems_status_code status; | |
|
480 | ||
|
481 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
|
482 | ||
|
483 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
|
484 | + spacewire_stats.packets_received; | |
|
485 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
|
486 | + spacewire_stats.packets_sent; | |
|
487 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
|
488 | + spacewire_stats.parity_err; | |
|
489 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
|
490 | + spacewire_stats.disconnect_err; | |
|
491 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
|
492 | + spacewire_stats.escape_err; | |
|
493 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
|
494 | + spacewire_stats.credit_err; | |
|
495 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
|
496 | + spacewire_stats.write_sync_err; | |
|
497 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
|
498 | + spacewire_stats.rx_rmap_header_crc_err; | |
|
499 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
|
500 | + spacewire_stats.rx_rmap_data_crc_err; | |
|
501 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
|
502 | + spacewire_stats.early_ep; | |
|
503 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
|
504 | + spacewire_stats.invalid_address; | |
|
505 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
|
506 | + spacewire_stats.rx_eep_err; | |
|
507 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
|
508 | + spacewire_stats.rx_truncated; | |
|
509 | } | |
|
510 | ||
|
511 | void spacewire_update_statistics( void ) | |
|
512 | { | |
|
513 | rtems_status_code status; | |
|
514 | spw_stats spacewire_stats_grspw; | |
|
515 | ||
|
516 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
|
517 | ||
|
518 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
|
519 | + spacewire_stats_grspw.packets_received; | |
|
520 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
|
521 | + spacewire_stats_grspw.packets_sent; | |
|
522 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
|
523 | + spacewire_stats_grspw.parity_err; | |
|
524 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
|
525 | + spacewire_stats_grspw.disconnect_err; | |
|
526 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
|
527 | + spacewire_stats_grspw.escape_err; | |
|
528 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
|
529 | + spacewire_stats_grspw.credit_err; | |
|
530 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
|
531 | + spacewire_stats_grspw.write_sync_err; | |
|
532 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
|
533 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
|
534 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
|
535 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
|
536 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
|
537 | + spacewire_stats_grspw.early_ep; | |
|
538 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
|
539 | + spacewire_stats_grspw.invalid_address; | |
|
540 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
|
541 | + spacewire_stats_grspw.rx_eep_err; | |
|
542 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
|
543 | + spacewire_stats_grspw.rx_truncated; | |
|
544 | //spacewire_stats.tx_link_err; | |
|
545 | ||
|
546 | //**************************** | |
|
547 | // DPU_SPACEWIRE_IF_STATISTICS | |
|
548 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
|
549 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
|
550 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
|
551 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
|
552 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
|
553 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
|
554 | ||
|
555 | //****************************************** | |
|
556 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
|
557 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
|
558 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
|
559 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
|
560 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
|
561 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
|
562 | ||
|
563 | //********************************************* | |
|
564 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
|
565 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
|
566 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
|
567 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
|
568 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
|
569 | } | |
|
570 | ||
|
571 | 93 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
572 | 94 | { |
|
573 | 95 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ); |
|
574 | 96 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
575 | 97 | |
|
576 | 98 | grgpio_regs->io_port_direction_register = |
|
577 | 99 | grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled |
|
578 | 100 | |
|
579 | 101 | if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 ) |
|
580 | 102 | { |
|
581 | 103 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7; |
|
582 | 104 | } |
|
583 | 105 | else |
|
584 | 106 | { |
|
585 | 107 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08; |
|
586 | 108 | } |
|
587 | 109 | |
|
588 | 110 | } |
|
589 | 111 | |
|
590 | 112 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
591 | 113 | { |
|
592 | 114 | int linkStatus; |
|
593 | 115 | rtems_status_code status; |
|
594 | 116 | |
|
595 | 117 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
596 | 118 | |
|
597 | 119 | if ( linkStatus == 5) { |
|
598 | 120 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
599 | 121 | status = RTEMS_SUCCESSFUL; |
|
600 | 122 | } |
|
601 | 123 | } |
This diff has been collapsed as it changes many lines, (710 lines changed) Show them Hide them | |||
@@ -1,793 +1,107 | |||
|
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 "timegen_tc_handler.h" |
|
14 | 14 | |
|
15 | 15 | //*********** |
|
16 | 16 | // RTEMS TASK |
|
17 | 17 | |
|
18 |
rtems_task act |
|
|
18 | rtems_task act__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 |
case TC_SUBTYPE_ |
|
|
70 |
|
|
|
71 | close_action( &TC, result, queue_snd_id ); | |
|
72 | break; | |
|
73 | // | |
|
74 | case TC_SUBTYPE_LOAD_COMM: | |
|
75 | // result = action_load_common_par( &TC ); | |
|
76 | close_action( &TC, result, queue_snd_id ); | |
|
77 | break; | |
|
78 | // | |
|
79 | case TC_SUBTYPE_LOAD_NORM: | |
|
80 | // result = action_load_normal_par( &TC, queue_snd_id, time ); | |
|
81 | close_action( &TC, result, queue_snd_id ); | |
|
82 | break; | |
|
83 | // | |
|
84 | case TC_SUBTYPE_LOAD_BURST: | |
|
85 | // result = action_load_burst_par( &TC, queue_snd_id, time ); | |
|
86 | close_action( &TC, result, queue_snd_id ); | |
|
87 | break; | |
|
88 | // | |
|
89 | case TC_SUBTYPE_LOAD_SBM1: | |
|
90 | // result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
|
91 | close_action( &TC, result, queue_snd_id ); | |
|
92 | break; | |
|
93 | // | |
|
94 | case TC_SUBTYPE_LOAD_SBM2: | |
|
95 | // result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
|
69 | case TC_SUBTYPE_ENTER: | |
|
70 | result = timegen_action_enter_mode( &TC, queue_snd_id, time ); | |
|
96 | 71 | close_action( &TC, result, queue_snd_id ); |
|
97 | 72 | break; |
|
98 | // | |
|
99 | case TC_SUBTYPE_DUMP: | |
|
100 | // result = action_dump_par( queue_snd_id ); | |
|
101 | close_action( &TC, result, queue_snd_id ); | |
|
102 | break; | |
|
103 | // | |
|
104 | case TC_SUBTYPE_ENTER: | |
|
105 | result = action_enter_mode( &TC, queue_snd_id, time ); | |
|
106 | close_action( &TC, result, queue_snd_id ); | |
|
107 | break; | |
|
108 | // | |
|
109 | case TC_SUBTYPE_UPDT_INFO: | |
|
110 | // result = action_update_info( &TC, queue_snd_id ); | |
|
111 | close_action( &TC, result, queue_snd_id ); | |
|
112 | break; | |
|
113 | // | |
|
114 | case TC_SUBTYPE_EN_CAL: | |
|
115 | // result = action_enable_calibration( &TC, queue_snd_id, time ); | |
|
116 | close_action( &TC, result, queue_snd_id ); | |
|
117 | break; | |
|
118 | // | |
|
119 | case TC_SUBTYPE_DIS_CAL: | |
|
120 | // result = action_disable_calibration( &TC, queue_snd_id, time ); | |
|
121 | close_action( &TC, result, queue_snd_id ); | |
|
122 | break; | |
|
123 | // | |
|
124 | 73 | case TC_SUBTYPE_UPDT_TIME: |
|
125 | result = action_update_time( &TC ); | |
|
74 | result = timegen_action_update_time( &TC ); | |
|
126 | 75 | close_action( &TC, result, queue_snd_id ); |
|
127 | 76 | break; |
|
128 | 77 | // |
|
129 | 78 | default: |
|
130 | 79 | break; |
|
131 | 80 | } |
|
132 | 81 | } |
|
133 | 82 | } |
|
134 | 83 | } |
|
135 | 84 | |
|
136 | 85 | //*********** |
|
137 | 86 | // TC ACTIONS |
|
138 | 87 | |
|
139 |
int action_ |
|
|
88 | int timegen_action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
|
140 | 89 | { |
|
141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
|
142 | * | |
|
143 | * @param TC points to the TeleCommand packet that is being processed | |
|
144 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
145 | * | |
|
146 | */ | |
|
147 | ||
|
148 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
|
149 | return LFR_DEFAULT; | |
|
150 | } | |
|
151 | ||
|
152 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
|
153 | { | |
|
154 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
|
155 | * | |
|
156 | * @param TC points to the TeleCommand packet that is being processed | |
|
157 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
158 | * | |
|
159 | */ | |
|
160 | ||
|
161 | rtems_status_code status; | |
|
162 | unsigned char requestedMode; | |
|
163 | ||
|
164 | requestedMode = TC->dataAndCRC[1]; | |
|
90 | int ret; | |
|
165 | 91 | |
|
166 | if ( (requestedMode != LFR_MODE_STANDBY) | |
|
167 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
|
168 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
|
169 | { | |
|
170 | status = RTEMS_UNSATISFIED; | |
|
171 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode ); | |
|
172 | } | |
|
173 | else | |
|
174 | { | |
|
175 | printf("in action_enter_mode *** enter mode %d\n", requestedMode); | |
|
176 | ||
|
177 | status = transition_validation(requestedMode); | |
|
92 | ret = LFR_SUCCESSFUL; | |
|
178 | 93 | |
|
179 | if ( status == LFR_SUCCESSFUL ) { | |
|
180 | if ( lfrCurrentMode != LFR_MODE_STANDBY) | |
|
181 | { | |
|
182 | status = stop_current_mode(); | |
|
183 | } | |
|
184 | if (status != RTEMS_SUCCESSFUL) | |
|
185 | { | |
|
186 | PRINTF("ERR *** in action_enter *** stop_current_mode\n") | |
|
187 | } | |
|
188 | status = enter_mode( requestedMode ); | |
|
189 | } | |
|
190 | else | |
|
191 | { | |
|
192 | PRINTF("ERR *** in action_enter *** transition rejected\n") | |
|
193 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
|
194 | } | |
|
195 | } | |
|
196 | ||
|
197 | return status; | |
|
94 | return ret; | |
|
198 | 95 | } |
|
199 | 96 | |
|
200 |
int action_update_ |
|
|
97 | int timegen_action_update_time(ccsdsTelecommandPacket_t *TC) | |
|
201 | 98 | { |
|
202 | // /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
|
203 | // * | |
|
204 | // * @param TC points to the TeleCommand packet that is being processed | |
|
205 | // * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
206 | // * | |
|
207 | // * @return LFR directive status code: | |
|
208 | // * - LFR_DEFAULT | |
|
209 | // * - LFR_SUCCESSFUL | |
|
210 | // * | |
|
211 | // */ | |
|
212 | ||
|
213 | // unsigned int val; | |
|
214 | int result; | |
|
215 | ||
|
216 | result = LFR_DEFAULT; | |
|
217 | // unsigned int status; | |
|
218 | // unsigned char mode; | |
|
219 | ||
|
220 | // // check LFR MODE | |
|
221 | // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1; | |
|
222 | // status = check_update_info_hk_lfr_mode( mode ); | |
|
223 | // if (status != LFR_DEFAULT) // check TDS mode | |
|
224 | // { | |
|
225 | // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4; | |
|
226 | // status = check_update_info_hk_tds_mode( mode ); | |
|
227 | // } | |
|
228 | // if (status != LFR_DEFAULT) // check THR mode | |
|
229 | // { | |
|
230 | // mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f); | |
|
231 | // status = check_update_info_hk_thr_mode( mode ); | |
|
232 | // } | |
|
233 | // if (status != LFR_DEFAULT) // if the parameter check is successful | |
|
234 | // { | |
|
235 | // val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
|
236 | // + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
|
237 | // val++; | |
|
238 | // housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
|
239 | // housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
|
240 | // } | |
|
241 | ||
|
242 | // result = status; | |
|
243 | ||
|
244 | return result; | |
|
245 | } | |
|
246 | ||
|
247 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
|
248 | { | |
|
249 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
|
250 | * | |
|
251 | * @param TC points to the TeleCommand packet that is being processed | |
|
252 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
253 | * | |
|
254 | */ | |
|
99 | int ret; | |
|
255 | 100 | |
|
256 | int result; | |
|
257 | unsigned char lfrMode; | |
|
258 | ||
|
259 | result = LFR_DEFAULT; | |
|
260 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
261 | ||
|
262 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
|
263 | result = LFR_DEFAULT; | |
|
264 | ||
|
265 | return result; | |
|
266 | } | |
|
267 | ||
|
268 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
|
269 | { | |
|
270 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
|
271 | * | |
|
272 | * @param TC points to the TeleCommand packet that is being processed | |
|
273 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
274 | * | |
|
275 | */ | |
|
276 | ||
|
277 | int result; | |
|
278 | unsigned char lfrMode; | |
|
279 | ||
|
280 | result = LFR_DEFAULT; | |
|
281 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
101 | ret = LFR_SUCCESSFUL; | |
|
282 | 102 | |
|
283 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
|
284 | result = LFR_DEFAULT; | |
|
285 | ||
|
286 | return result; | |
|
287 | } | |
|
288 | ||
|
289 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
|
290 | { | |
|
291 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
|
292 | * | |
|
293 | * @param TC points to the TeleCommand packet that is being processed | |
|
294 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
|
295 | * | |
|
296 | * @return LFR_SUCCESSFUL | |
|
297 | * | |
|
298 | */ | |
|
299 | ||
|
300 | unsigned int val; | |
|
301 | ||
|
302 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
|
303 | + (TC->dataAndCRC[1] << 16) | |
|
304 | + (TC->dataAndCRC[2] << 8) | |
|
305 | + TC->dataAndCRC[3]; | |
|
306 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
|
307 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
|
308 | val++; | |
|
309 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
|
310 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
|
311 | // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick | |
|
312 | ||
|
313 | return LFR_SUCCESSFUL; | |
|
103 | return ret; | |
|
314 | 104 | } |
|
315 | 105 | |
|
316 | 106 | //******************* |
|
317 | 107 | // ENTERING THE MODES |
|
318 | ||
|
319 | int transition_validation(unsigned char requestedMode) | |
|
320 | { | |
|
321 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
|
322 | * | |
|
323 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
|
324 | * | |
|
325 | * @return LFR directive status codes: | |
|
326 | * - LFR_SUCCESSFUL - the transition is authorized | |
|
327 | * - LFR_DEFAULT - the transition is not authorized | |
|
328 | * | |
|
329 | */ | |
|
330 | ||
|
331 | int status; | |
|
332 | ||
|
333 | switch (requestedMode) | |
|
334 | { | |
|
335 | case LFR_MODE_STANDBY: | |
|
336 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
|
337 | status = LFR_DEFAULT; | |
|
338 | } | |
|
339 | else | |
|
340 | { | |
|
341 | status = LFR_SUCCESSFUL; | |
|
342 | } | |
|
343 | break; | |
|
344 | case LFR_MODE_NORMAL: | |
|
345 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
|
346 | status = LFR_DEFAULT; | |
|
347 | } | |
|
348 | else { | |
|
349 | status = LFR_SUCCESSFUL; | |
|
350 | } | |
|
351 | break; | |
|
352 | case LFR_MODE_BURST: | |
|
353 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
|
354 | status = LFR_DEFAULT; | |
|
355 | } | |
|
356 | else { | |
|
357 | status = LFR_SUCCESSFUL; | |
|
358 | } | |
|
359 | break; | |
|
360 | case LFR_MODE_SBM1: | |
|
361 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
|
362 | status = LFR_DEFAULT; | |
|
363 | } | |
|
364 | else { | |
|
365 | status = LFR_SUCCESSFUL; | |
|
366 | } | |
|
367 | break; | |
|
368 | case LFR_MODE_SBM2: | |
|
369 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
|
370 | status = LFR_DEFAULT; | |
|
371 | } | |
|
372 | else { | |
|
373 | status = LFR_SUCCESSFUL; | |
|
374 | } | |
|
375 | break; | |
|
376 | default: | |
|
377 | status = LFR_DEFAULT; | |
|
378 | break; | |
|
379 | } | |
|
380 | ||
|
381 | return status; | |
|
382 | } | |
|
383 | ||
|
384 | int stop_current_mode(void) | |
|
385 | { | |
|
386 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
|
387 | * | |
|
388 | * @return RTEMS directive status codes: | |
|
389 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
|
390 | * - RTEMS_INVALID_ID - task id invalid | |
|
391 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
|
392 | * | |
|
393 | */ | |
|
394 | ||
|
395 | rtems_status_code status; | |
|
396 | ||
|
397 | status = RTEMS_SUCCESSFUL; | |
|
398 | ||
|
399 | // (1) mask interruptions | |
|
400 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
|
401 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
|
402 | ||
|
403 | // (2) clear interruptions | |
|
404 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
|
405 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
|
406 | ||
|
407 | // (3) reset registers | |
|
408 | // waveform picker | |
|
409 | // reset_wfp_burst_enable(); // reset burst and enable bits | |
|
410 | // reset_wfp_status(); // reset all the status bits | |
|
411 | // spectral matrices | |
|
412 | set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices | |
|
413 | set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0 | |
|
414 | // reset_extractSWF(); // reset the extractSWF flag to false | |
|
415 | ||
|
416 | // <Spectral Matrices simulator> | |
|
417 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator | |
|
418 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
|
419 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator | |
|
420 | // </Spectral Matrices simulator> | |
|
421 | ||
|
422 | // suspend several tasks | |
|
423 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
|
424 | status = suspend_science_tasks(); | |
|
425 | } | |
|
426 | ||
|
427 | if (status != RTEMS_SUCCESSFUL) | |
|
428 | { | |
|
429 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
|
430 | } | |
|
431 | ||
|
432 | return status; | |
|
433 | } | |
|
434 | ||
|
435 | int enter_mode(unsigned char mode ) | |
|
436 | { | |
|
437 | /** This function is launched after a mode transition validation. | |
|
438 | * | |
|
439 | * @param mode is the mode in which LFR will be put. | |
|
440 | * | |
|
441 | * @return RTEMS directive status codes: | |
|
442 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully | |
|
443 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully | |
|
444 | * | |
|
445 | */ | |
|
446 | ||
|
447 | rtems_status_code status; | |
|
448 | ||
|
449 | status = RTEMS_UNSATISFIED; | |
|
450 | ||
|
451 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); | |
|
452 | updateLFRCurrentMode(); | |
|
453 | ||
|
454 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) | |
|
455 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) | |
|
456 | { | |
|
457 | #ifdef PRINT_TASK_STATISTICS | |
|
458 | rtems_cpu_usage_reset(); | |
|
459 | maxCount = 0; | |
|
460 | #endif | |
|
461 | status = restart_science_tasks(); | |
|
462 | // launch_waveform_picker( mode ); | |
|
463 | // launch_spectral_matrix( mode ); | |
|
464 | } | |
|
465 | else if ( mode == LFR_MODE_STANDBY ) | |
|
466 | { | |
|
467 | #ifdef PRINT_TASK_STATISTICS | |
|
468 | rtems_cpu_usage_report(); | |
|
469 | #endif | |
|
470 | ||
|
471 | #ifdef PRINT_STACK_REPORT | |
|
472 | rtems_stack_checker_report_usage(); | |
|
473 | #endif | |
|
474 | status = stop_current_mode(); | |
|
475 | PRINTF1("maxCount = %d\n", maxCount) | |
|
476 | } | |
|
477 | else | |
|
478 | { | |
|
479 | status = RTEMS_UNSATISFIED; | |
|
480 | } | |
|
481 | ||
|
482 | if (status != RTEMS_SUCCESSFUL) | |
|
483 | { | |
|
484 | PRINTF1("in enter_mode *** ERR = %d\n", status) | |
|
485 | status = RTEMS_UNSATISFIED; | |
|
486 | } | |
|
487 | ||
|
488 | return status; | |
|
489 | } | |
|
490 | ||
|
491 | int restart_science_tasks() | |
|
492 | { | |
|
493 | /** This function is used to restart all science tasks. | |
|
494 | * | |
|
495 | * @return RTEMS directive status codes: | |
|
496 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
|
497 | * - RTEMS_INVALID_ID - task id invalid | |
|
498 | * - RTEMS_INCORRECT_STATE - task never started | |
|
499 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
|
500 | * | |
|
501 | * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1 | |
|
502 | * | |
|
503 | */ | |
|
504 | ||
|
505 | rtems_status_code status[6]; | |
|
506 | rtems_status_code ret; | |
|
507 | ||
|
508 | ret = RTEMS_SUCCESSFUL; | |
|
509 | ||
|
510 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); | |
|
511 | if (status[0] != RTEMS_SUCCESSFUL) | |
|
512 | { | |
|
513 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) | |
|
514 | } | |
|
515 | ||
|
516 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
|
517 | if (status[2] != RTEMS_SUCCESSFUL) | |
|
518 | { | |
|
519 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) | |
|
520 | } | |
|
521 | ||
|
522 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
|
523 | if (status[3] != RTEMS_SUCCESSFUL) | |
|
524 | { | |
|
525 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) | |
|
526 | } | |
|
527 | ||
|
528 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
|
529 | if (status[4] != RTEMS_SUCCESSFUL) | |
|
530 | { | |
|
531 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) | |
|
532 | } | |
|
533 | ||
|
534 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
|
535 | if (status[5] != RTEMS_SUCCESSFUL) | |
|
536 | { | |
|
537 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) | |
|
538 | } | |
|
539 | ||
|
540 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || | |
|
541 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
|
542 | { | |
|
543 | ret = RTEMS_UNSATISFIED; | |
|
544 | } | |
|
545 | ||
|
546 | return ret; | |
|
547 | } | |
|
548 | ||
|
549 | int suspend_science_tasks() | |
|
550 | { | |
|
551 | /** This function suspends the science tasks. | |
|
552 | * | |
|
553 | * @return RTEMS directive status codes: | |
|
554 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
|
555 | * - RTEMS_INVALID_ID - task id invalid | |
|
556 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
|
557 | * | |
|
558 | */ | |
|
559 | ||
|
560 | rtems_status_code status; | |
|
561 | ||
|
562 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); | |
|
563 | if (status != RTEMS_SUCCESSFUL) | |
|
564 | { | |
|
565 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
|
566 | } | |
|
567 | ||
|
568 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
|
569 | { | |
|
570 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
|
571 | if (status != RTEMS_SUCCESSFUL) | |
|
572 | { | |
|
573 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
|
574 | } | |
|
575 | } | |
|
576 | ||
|
577 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
|
578 | { | |
|
579 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
|
580 | if (status != RTEMS_SUCCESSFUL) | |
|
581 | { | |
|
582 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
|
583 | } | |
|
584 | } | |
|
585 | ||
|
586 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
|
587 | { | |
|
588 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
|
589 | if (status != RTEMS_SUCCESSFUL) | |
|
590 | { | |
|
591 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
|
592 | } | |
|
593 | } | |
|
594 | ||
|
595 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
|
596 | { | |
|
597 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
|
598 | if (status != RTEMS_SUCCESSFUL) | |
|
599 | { | |
|
600 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
|
601 | } | |
|
602 | } | |
|
603 | ||
|
604 | return status; | |
|
605 | } | |
|
606 | ||
|
607 | void launch_waveform_picker( unsigned char mode ) | |
|
608 | { | |
|
609 | // int startDate; | |
|
610 | ||
|
611 | // reset_current_ring_nodes(); | |
|
612 | // reset_waveform_picker_regs(); | |
|
613 | // set_wfp_burst_enable_register( mode ); | |
|
614 | ||
|
615 | // LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
|
616 | // LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
|
617 | ||
|
618 | // startDate = time_management_regs->coarse_time + 2; | |
|
619 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] | |
|
620 | // waveform_picker_regs->start_date = startDate; | |
|
621 | } | |
|
622 | ||
|
623 | void launch_spectral_matrix( unsigned char mode ) | |
|
624 | { | |
|
625 | // reset_nb_sm_f0(); | |
|
626 | // reset_current_sm_ring_nodes(); | |
|
627 | // reset_spectral_matrix_regs(); | |
|
628 | ||
|
629 | //#ifdef VHDL_DEV | |
|
630 | // set_irq_on_new_ready_matrix( 1 ); | |
|
631 | // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
|
632 | // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
|
633 | // set_run_matrix_spectral( 1 ); | |
|
634 | //#else | |
|
635 | // // Spectral Matrices simulator | |
|
636 | // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
|
637 | // LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
|
638 | // LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
|
639 | //#endif | |
|
640 | } | |
|
641 | ||
|
642 | void set_irq_on_new_ready_matrix( unsigned char value ) | |
|
643 | { | |
|
644 | if (value == 1) | |
|
645 | { | |
|
646 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
|
647 | } | |
|
648 | else | |
|
649 | { | |
|
650 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
|
651 | } | |
|
652 | } | |
|
653 | ||
|
654 | void set_run_matrix_spectral( unsigned char value ) | |
|
655 | { | |
|
656 | if (value == 1) | |
|
657 | { | |
|
658 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // 0100 set run_matrix spectral to 1 | |
|
659 | } | |
|
660 | else | |
|
661 | { | |
|
662 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // 1011 set run_matrix spectral to 0 | |
|
663 | } | |
|
664 | } | |
|
665 | ||
|
666 | void launch_spectral_matrix_simu( unsigned char mode ) | |
|
667 | { | |
|
668 | // reset_nb_sm_f0(); | |
|
669 | // reset_current_sm_ring_nodes(); | |
|
670 | // reset_spectral_matrix_regs(); | |
|
671 | ||
|
672 | // // Spectral Matrices simulator | |
|
673 | // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
|
674 | // LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
|
675 | // LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
|
676 | // set_local_nb_interrupt_f0_MAX(); | |
|
677 | } | |
|
678 | ||
|
679 | //**************** | |
|
680 | // CLOSING ACTIONS | |
|
681 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC) | |
|
682 | { | |
|
683 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
|
684 | * | |
|
685 | * @param TC points to the TC being processed | |
|
686 | * @param time is the time used to date the TC execution | |
|
687 | * | |
|
688 | */ | |
|
689 | ||
|
690 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
|
691 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
|
692 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
|
693 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
|
694 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
|
695 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
|
696 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
|
697 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
|
698 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
|
699 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); | |
|
700 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
|
701 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time); | |
|
702 | } | |
|
703 | ||
|
704 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC ) | |
|
705 | { | |
|
706 | /** This function is used to update the HK packets statistics after a TC rejection. | |
|
707 | * | |
|
708 | * @param TC points to the TC being processed | |
|
709 | * @param time is the time used to date the TC rejection | |
|
710 | * | |
|
711 | */ | |
|
712 | ||
|
713 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
|
714 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
|
715 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
|
716 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
|
717 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
|
718 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
|
719 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
|
720 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
|
721 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
|
722 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time); | |
|
723 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
|
724 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time); | |
|
725 | } | |
|
726 | ||
|
727 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
|
728 | { | |
|
729 | /** This function is the last step of the TC execution workflow. | |
|
730 | * | |
|
731 | * @param TC points to the TC being processed | |
|
732 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
|
733 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
|
734 | * @param time is the time used to date the TC execution | |
|
735 | * | |
|
736 | */ | |
|
737 | ||
|
738 | unsigned int val = 0; | |
|
739 | ||
|
740 | if (result == LFR_SUCCESSFUL) | |
|
741 | { | |
|
742 | if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
|
743 | && | |
|
744 | !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
|
745 | ) | |
|
746 | { | |
|
747 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
|
748 | } | |
|
749 | update_last_TC_exe( TC ); | |
|
750 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
|
751 | val++; | |
|
752 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
|
753 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
|
754 | } | |
|
755 | else | |
|
756 | { | |
|
757 | update_last_TC_rej( TC ); | |
|
758 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
|
759 | val++; | |
|
760 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
|
761 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
|
762 | } | |
|
763 | } | |
|
764 | ||
|
765 | //*************************** | |
|
766 | // Interrupt Service Routines | |
|
767 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
|
768 | { | |
|
769 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
|
770 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | |
|
771 | } | |
|
772 | } | |
|
773 | ||
|
774 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
|
775 | { | |
|
776 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
|
777 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | |
|
778 | } | |
|
779 | } | |
|
780 | ||
|
781 | //**************** | |
|
782 | // OTHER FUNCTIONS | |
|
783 | void updateLFRCurrentMode() | |
|
784 | { | |
|
785 | /** This function updates the value of the global variable lfrCurrentMode. | |
|
786 | * | |
|
787 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
|
788 | * | |
|
789 | */ | |
|
790 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
|
791 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
|
792 | } | |
|
793 |
@@ -1,398 +1,405 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by QtCreator 3. |
|
|
3 | <!-- Written by QtCreator 3.2.0, 2014-09-24T11:08:34. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | <variable>EnvironmentId</variable> | |
|
7 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> | |
|
8 | </data> | |
|
9 | <data> | |
|
6 | 10 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
7 | 11 | <value type="int">0</value> |
|
8 | 12 | </data> |
|
9 | 13 | <data> |
|
10 | 14 | <variable>ProjectExplorer.Project.EditorSettings</variable> |
|
11 | 15 | <valuemap type="QVariantMap"> |
|
12 | 16 | <value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
|
13 | 17 | <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
|
14 | 18 | <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
|
15 | 19 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
|
16 | 20 | <value type="QString" key="language">Cpp</value> |
|
17 | 21 | <valuemap type="QVariantMap" key="value"> |
|
18 | 22 | <value type="QByteArray" key="CurrentPreferences">CppGlobal</value> |
|
19 | 23 | </valuemap> |
|
20 | 24 | </valuemap> |
|
21 | 25 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
|
22 | 26 | <value type="QString" key="language">QmlJS</value> |
|
23 | 27 | <valuemap type="QVariantMap" key="value"> |
|
24 | 28 | <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> |
|
25 | 29 | </valuemap> |
|
26 | 30 | </valuemap> |
|
27 | 31 | <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
|
28 | 32 | <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> |
|
29 | 33 | <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
|
30 | 34 | <value type="int" key="EditorConfiguration.IndentSize">4</value> |
|
31 | 35 | <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> |
|
36 | <value type="int" key="EditorConfiguration.MarginColumn">80</value> | |
|
37 | <value type="bool" key="EditorConfiguration.MouseHiding">true</value> | |
|
32 | 38 | <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
|
33 | 39 | <value type="int" key="EditorConfiguration.PaddingMode">1</value> |
|
34 | 40 | <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
|
41 | <value type="bool" key="EditorConfiguration.ShowMargin">false</value> | |
|
35 | 42 | <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
|
36 | 43 | <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
|
37 | 44 | <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
|
38 | 45 | <value type="int" key="EditorConfiguration.TabSize">8</value> |
|
39 | 46 | <value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
|
40 | 47 | <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
|
41 | 48 | <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
|
42 | 49 | <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
|
43 | 50 | <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
|
44 | 51 | <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
|
45 | 52 | </valuemap> |
|
46 | 53 | </data> |
|
47 | 54 | <data> |
|
48 | 55 | <variable>ProjectExplorer.Project.PluginSettings</variable> |
|
49 | 56 | <valuemap type="QVariantMap"/> |
|
50 | 57 | </data> |
|
51 | 58 | <data> |
|
52 | 59 | <variable>ProjectExplorer.Project.Target.0</variable> |
|
53 | 60 | <valuemap type="QVariantMap"> |
|
54 | 61 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
55 | 62 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
56 | 63 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value> |
|
57 | 64 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
58 | 65 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
59 | 66 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
60 | 67 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
61 | 68 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/DEV_PLE/TimeGenerator-qt</value> |
|
62 | 69 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
63 | 70 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
64 | 71 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
65 | 72 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
66 | 73 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
67 | 74 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
68 | 75 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
69 | 76 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> |
|
70 | 77 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
71 | 78 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
72 | 79 | </valuemap> |
|
73 | 80 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
74 | 81 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
75 | 82 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
76 | 83 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
77 | 84 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
78 | 85 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
79 | 86 | <value type="QString">-w</value> |
|
80 | 87 | <value type="QString">-r</value> |
|
81 | 88 | </valuelist> |
|
82 | 89 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
83 | 90 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
84 | 91 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
85 | 92 | </valuemap> |
|
86 | 93 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
87 | 94 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
88 | 95 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
89 | 96 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
90 | 97 | </valuemap> |
|
91 | 98 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
92 | 99 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
93 | 100 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
94 | 101 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
95 | 102 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
96 | 103 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
97 | 104 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
98 | 105 | <value type="QString">-w</value> |
|
99 | 106 | <value type="QString">-r</value> |
|
100 | 107 | </valuelist> |
|
101 | 108 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
102 | 109 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
103 | 110 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
104 | 111 | </valuemap> |
|
105 | 112 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
106 | 113 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
107 | 114 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
108 | 115 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
109 | 116 | </valuemap> |
|
110 | 117 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
111 | 118 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
112 | 119 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
113 | 120 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
114 | 121 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
115 | 122 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
116 | 123 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
117 | 124 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
118 | 125 | </valuemap> |
|
119 | 126 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
120 | 127 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
121 | 128 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
122 | 129 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
123 | 130 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
124 | 131 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
125 | 132 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
126 | 133 | </valuemap> |
|
127 | 134 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
128 | 135 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
129 | 136 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
130 | 137 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
131 | 138 | </valuemap> |
|
132 | 139 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
133 | 140 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
134 | 141 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
135 | 142 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
136 | 143 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
137 | 144 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
138 | 145 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
139 | 146 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
140 | 147 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
141 | 148 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
142 | 149 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
143 | 150 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
144 | 151 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
145 | 152 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
146 | 153 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
147 | 154 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
148 | 155 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
149 | 156 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
150 | 157 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
151 | 158 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
152 | 159 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
153 | 160 | <value type="int">0</value> |
|
154 | 161 | <value type="int">1</value> |
|
155 | 162 | <value type="int">2</value> |
|
156 | 163 | <value type="int">3</value> |
|
157 | 164 | <value type="int">4</value> |
|
158 | 165 | <value type="int">5</value> |
|
159 | 166 | <value type="int">6</value> |
|
160 | 167 | <value type="int">7</value> |
|
161 | 168 | <value type="int">8</value> |
|
162 | 169 | <value type="int">9</value> |
|
163 | 170 | <value type="int">10</value> |
|
164 | 171 | <value type="int">11</value> |
|
165 | 172 | <value type="int">12</value> |
|
166 | 173 | <value type="int">13</value> |
|
167 | 174 | <value type="int">14</value> |
|
168 | 175 | </valuelist> |
|
169 | 176 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
170 | 177 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
171 | 178 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">timegen</value> |
|
172 | 179 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
173 | 180 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/TimeGenerator-qt/timegen.pro</value> |
|
174 | 181 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
175 | 182 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">timegen.pro</value> |
|
176 | 183 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
177 | 184 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
178 | 185 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
179 | 186 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
180 | 187 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> |
|
181 | 188 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> |
|
182 | 189 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
183 | 190 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
184 | 191 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
185 | 192 | </valuemap> |
|
186 | 193 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
187 | 194 | </valuemap> |
|
188 | 195 | </data> |
|
189 | 196 | <data> |
|
190 | 197 | <variable>ProjectExplorer.Project.Target.1</variable> |
|
191 | 198 | <valuemap type="QVariantMap"> |
|
192 | 199 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> |
|
193 | 200 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> |
|
194 | 201 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</value> |
|
195 | 202 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
196 | 203 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
197 | 204 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
198 | 205 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
199 | 206 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/DEV_PLE/build-timegen-Desktop-Debug</value> |
|
200 | 207 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
201 | 208 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
202 | 209 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
203 | 210 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
204 | 211 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
205 | 212 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
206 | 213 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
207 | 214 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> |
|
208 | 215 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
209 | 216 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
210 | 217 | </valuemap> |
|
211 | 218 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
212 | 219 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
213 | 220 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
214 | 221 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
215 | 222 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
216 | 223 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
217 | 224 | <value type="QString">-w</value> |
|
218 | 225 | <value type="QString">-r</value> |
|
219 | 226 | </valuelist> |
|
220 | 227 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
221 | 228 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
222 | 229 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
223 | 230 | </valuemap> |
|
224 | 231 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
225 | 232 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
226 | 233 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
227 | 234 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
228 | 235 | </valuemap> |
|
229 | 236 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
230 | 237 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
231 | 238 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
232 | 239 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
233 | 240 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
234 | 241 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
235 | 242 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
236 | 243 | <value type="QString">-w</value> |
|
237 | 244 | <value type="QString">-r</value> |
|
238 | 245 | </valuelist> |
|
239 | 246 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
240 | 247 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
241 | 248 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
242 | 249 | </valuemap> |
|
243 | 250 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
244 | 251 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
245 | 252 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
246 | 253 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
247 | 254 | </valuemap> |
|
248 | 255 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
249 | 256 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
250 | 257 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
251 | 258 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value> |
|
252 | 259 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
253 | 260 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
254 | 261 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> |
|
255 | 262 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
256 | 263 | </valuemap> |
|
257 | 264 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> |
|
258 | 265 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/DEV_PLE/build-timegen-Desktop-Release</value> |
|
259 | 266 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
260 | 267 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
261 | 268 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
262 | 269 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
263 | 270 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
264 | 271 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
265 | 272 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
266 | 273 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> |
|
267 | 274 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
268 | 275 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
269 | 276 | </valuemap> |
|
270 | 277 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
271 | 278 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
272 | 279 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
273 | 280 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
274 | 281 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
275 | 282 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
276 | 283 | <value type="QString">-w</value> |
|
277 | 284 | <value type="QString">-r</value> |
|
278 | 285 | </valuelist> |
|
279 | 286 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
280 | 287 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
281 | 288 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
282 | 289 | </valuemap> |
|
283 | 290 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
284 | 291 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
285 | 292 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
286 | 293 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
287 | 294 | </valuemap> |
|
288 | 295 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
289 | 296 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
290 | 297 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
291 | 298 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
292 | 299 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
293 | 300 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
294 | 301 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
295 | 302 | <value type="QString">-w</value> |
|
296 | 303 | <value type="QString">-r</value> |
|
297 | 304 | </valuelist> |
|
298 | 305 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
299 | 306 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
300 | 307 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
301 | 308 | </valuemap> |
|
302 | 309 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
303 | 310 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
304 | 311 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
305 | 312 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
306 | 313 | </valuemap> |
|
307 | 314 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
308 | 315 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
309 | 316 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
310 | 317 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
311 | 318 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
312 | 319 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
313 | 320 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
314 | 321 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
315 | 322 | </valuemap> |
|
316 | 323 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value> |
|
317 | 324 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
318 | 325 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
319 | 326 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
320 | 327 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
321 | 328 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
322 | 329 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
323 | 330 | </valuemap> |
|
324 | 331 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
325 | 332 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
326 | 333 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
327 | 334 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
328 | 335 | </valuemap> |
|
329 | 336 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
330 | 337 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
331 | 338 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
332 | 339 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
333 | 340 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
334 | 341 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
335 | 342 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
336 | 343 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
337 | 344 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
338 | 345 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
339 | 346 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
340 | 347 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
341 | 348 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
342 | 349 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
343 | 350 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
344 | 351 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
345 | 352 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
346 | 353 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
347 | 354 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
348 | 355 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
349 | 356 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
350 | 357 | <value type="int">0</value> |
|
351 | 358 | <value type="int">1</value> |
|
352 | 359 | <value type="int">2</value> |
|
353 | 360 | <value type="int">3</value> |
|
354 | 361 | <value type="int">4</value> |
|
355 | 362 | <value type="int">5</value> |
|
356 | 363 | <value type="int">6</value> |
|
357 | 364 | <value type="int">7</value> |
|
358 | 365 | <value type="int">8</value> |
|
359 | 366 | <value type="int">9</value> |
|
360 | 367 | <value type="int">10</value> |
|
361 | 368 | <value type="int">11</value> |
|
362 | 369 | <value type="int">12</value> |
|
363 | 370 | <value type="int">13</value> |
|
364 | 371 | <value type="int">14</value> |
|
365 | 372 | </valuelist> |
|
366 | 373 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
367 | 374 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
368 | 375 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">timegen</value> |
|
369 | 376 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
370 | 377 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/TimeGenerator-qt/timegen.pro</value> |
|
371 | 378 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
372 | 379 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">timegen.pro</value> |
|
373 | 380 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
374 | 381 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
375 | 382 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
376 | 383 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
377 | 384 | <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> |
|
378 | 385 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> |
|
379 | 386 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
380 | 387 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
381 | 388 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
382 | 389 | </valuemap> |
|
383 | 390 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
384 | 391 | </valuemap> |
|
385 | 392 | </data> |
|
386 | 393 | <data> |
|
387 | 394 | <variable>ProjectExplorer.Project.TargetCount</variable> |
|
388 | 395 | <value type="int">2</value> |
|
389 | 396 | </data> |
|
390 | 397 | <data> |
|
391 |
<variable>ProjectExplorer.Project.Updater. |
|
|
392 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> | |
|
398 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> | |
|
399 | <value type="int">16</value> | |
|
393 | 400 | </data> |
|
394 | 401 | <data> |
|
395 |
<variable> |
|
|
396 |
<value type="int">1 |
|
|
402 | <variable>Version</variable> | |
|
403 | <value type="int">16</value> | |
|
397 | 404 | </data> |
|
398 | 405 | </qtcreator> |
@@ -1,48 +1,48 | |||
|
1 | 1 | #ifndef FSW_INIT_H_INCLUDED |
|
2 | 2 | #define FSW_INIT_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <leon.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "fsw_misc.h" |
|
9 | 9 | #include "fsw_processing.h" |
|
10 | 10 | |
|
11 | 11 | #include "tc_handler.h" |
|
12 | 12 | #include "wf_handler.h" |
|
13 | 13 | #include "fsw_spacewire.h" |
|
14 | 14 | |
|
15 | 15 | #include "avf0_prc0.h" |
|
16 | 16 | #include "avf1_prc1.h" |
|
17 | 17 | #include "avf2_prc2.h" |
|
18 | 18 | |
|
19 | 19 | extern rtems_name Task_name[20]; /* array of task names */ |
|
20 | 20 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
21 | 21 | |
|
22 | 22 | // RTEMS TASKS |
|
23 | 23 | rtems_task Init( rtems_task_argument argument); |
|
24 | 24 | |
|
25 | 25 | // OTHER functions |
|
26 | 26 | void create_names( void ); |
|
27 | 27 | int create_all_tasks( void ); |
|
28 | 28 | int start_all_tasks( void ); |
|
29 | 29 | // |
|
30 | 30 | rtems_status_code create_message_queues( void ); |
|
31 | 31 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
32 | 32 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
33 | 33 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ); |
|
34 | 34 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
35 | 35 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
36 | 36 | // |
|
37 | 37 | int start_recv_send_tasks( void ); |
|
38 | 38 | // |
|
39 | 39 | void init_local_mode_parameters( void ); |
|
40 | 40 | void reset_local_time( void ); |
|
41 | 41 | |
|
42 |
extern |
|
|
43 |
extern |
|
|
42 | extern void rtems_cpu_usage_report( void ); | |
|
43 | extern void rtems_cpu_usage_reset( void ); | |
|
44 | 44 | extern void rtems_stack_checker_report_usage( void ); |
|
45 | 45 | |
|
46 | 46 | extern int sched_yield( void ); |
|
47 | 47 | |
|
48 | 48 | #endif // FSW_INIT_H_INCLUDED |
@@ -1,49 +1,45 | |||
|
1 | 1 | #ifndef FSW_MISC_H_INCLUDED |
|
2 | 2 | #define FSW_MISC_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | #include <grspw.h> |
|
7 | 7 | |
|
8 | 8 | #include "fsw_params.h" |
|
9 | 9 | #include "fsw_spacewire.h" |
|
10 | 10 | #include "lfr_cpu_usage_report.h" |
|
11 | 11 | |
|
12 | 12 | rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic |
|
13 | 13 | rtems_id HK_id; // id of the HK rate monotonic period |
|
14 | 14 | |
|
15 | //extern rtems_name misc_name[5]; | |
|
16 | //time_management_regs_t *time_management_regs; | |
|
17 | //extern Packet_TM_LFR_HK_t housekeeping_packet; | |
|
18 | ||
|
19 | 15 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
20 | 16 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
21 | 17 | void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
22 | 18 | void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
23 | 19 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider); |
|
24 | 20 | |
|
25 | 21 | // SERIAL LINK |
|
26 | 22 | int send_console_outputs_on_apbuart_port( void ); |
|
27 | 23 | int enable_apbuart_transmitter( void ); |
|
28 | 24 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
29 | 25 | |
|
30 | 26 | // RTEMS TASKS |
|
31 | 27 | rtems_task stat_task( rtems_task_argument argument ); |
|
32 | 28 | rtems_task hous_task( rtems_task_argument argument ); |
|
33 | 29 | rtems_task dumb_task( rtems_task_argument unused ); |
|
34 | 30 | |
|
35 | 31 | void init_housekeeping_parameters( void ); |
|
36 | 32 | void increment_seq_counter(unsigned short *packetSequenceControl); |
|
37 | 33 | void getTime( unsigned char *time); |
|
38 | 34 | unsigned long long int getTimeAsUnsignedLongLongInt( ); |
|
39 | 35 | void send_dumb_hk( void ); |
|
40 | 36 | void get_v_e1_e2_f3 (unsigned char *spacecraft_potential); |
|
41 | 37 | void get_cpu_load( unsigned char *resource_statistics ); |
|
42 | 38 | |
|
43 | 39 | extern int sched_yield( void ); |
|
44 |
extern |
|
|
40 | extern void rtems_cpu_usage_reset(); | |
|
45 | 41 | extern ring_node *current_ring_node_f3; |
|
46 | 42 | extern ring_node *ring_node_to_send_cwf_f3; |
|
47 | 43 | extern unsigned short sequenceCounterHK; |
|
48 | 44 | |
|
49 | 45 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,255 +1,255 | |||
|
1 | 1 | #ifndef FSW_PARAMS_H_INCLUDED |
|
2 | 2 | #define FSW_PARAMS_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include "grlib_regs.h" |
|
5 | 5 | #include "fsw_params_processing.h" |
|
6 | 6 | #include "fsw_params_nb_bytes.h" |
|
7 | 7 | #include "tm_byte_positions.h" |
|
8 | 8 | #include "ccsds_types.h" |
|
9 | 9 | |
|
10 | 10 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
11 | 11 | #define UART_DEVICE_NAME "/dev/console" |
|
12 | 12 | |
|
13 | 13 | typedef struct ring_node |
|
14 | 14 | { |
|
15 | 15 | struct ring_node *previous; |
|
16 | 16 | int buffer_address; |
|
17 | 17 | struct ring_node *next; |
|
18 | 18 | unsigned int status; |
|
19 | 19 | } ring_node; |
|
20 | 20 | |
|
21 | 21 | //************************ |
|
22 | 22 | // flight software version |
|
23 | 23 | // this parameters is handled by the Qt project options |
|
24 | 24 | |
|
25 | 25 | #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk |
|
26 | 26 | #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk |
|
27 | 27 | #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688 |
|
28 | 28 | #define TIME_OFFSET 2 |
|
29 | 29 | #define TIME_OFFSET_IN_BYTES 8 |
|
30 | 30 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 |
|
31 | 31 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
32 | 32 | #define NB_WORDS_SWF_BLK 3 |
|
33 | 33 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
34 | 34 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 |
|
35 | 35 | #define NB_RING_NODES_F0 3 // AT LEAST 3 |
|
36 | 36 | #define NB_RING_NODES_F1 5 // AT LEAST 3 |
|
37 | 37 | #define NB_RING_NODES_F2 5 // AT LEAST 3 |
|
38 | 38 | #define NB_RING_NODES_F3 3 // AT LEAST 3 |
|
39 | 39 | |
|
40 | 40 | //********** |
|
41 | 41 | // LFR MODES |
|
42 | 42 | #define LFR_MODE_STANDBY 0 |
|
43 | 43 | #define LFR_MODE_NORMAL 1 |
|
44 | 44 | #define LFR_MODE_BURST 2 |
|
45 | 45 | #define LFR_MODE_SBM1 3 |
|
46 | 46 | #define LFR_MODE_SBM2 4 |
|
47 | 47 | |
|
48 | 48 | #define TDS_MODE_LFM 5 |
|
49 | 49 | #define TDS_MODE_STANDBY 0 |
|
50 | 50 | #define TDS_MODE_NORMAL 1 |
|
51 | 51 | #define TDS_MODE_BURST 2 |
|
52 | 52 | #define TDS_MODE_SBM1 3 |
|
53 | 53 | #define TDS_MODE_SBM2 4 |
|
54 | 54 | |
|
55 | 55 | #define THR_MODE_STANDBY 0 |
|
56 | 56 | #define THR_MODE_NORMAL 1 |
|
57 | 57 | #define THR_MODE_BURST 2 |
|
58 | 58 | |
|
59 | 59 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
60 | 60 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
61 | 61 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
62 | 62 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
63 | 63 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
64 | 64 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
65 | 65 | #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6 |
|
66 | 66 | #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7 |
|
67 | 67 | #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode |
|
68 | 68 | #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9 |
|
69 | 69 | #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10 |
|
70 | 70 | #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode |
|
71 | 71 | #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12 |
|
72 | 72 | #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13 |
|
73 | 73 | #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode |
|
74 | 74 | #define RTEMS_EVENT_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 | #define SY_LFR_N_SWF_L 2048 // nb sample | |
|
90 | #define SY_LFR_N_SWF_P 300 // sec | |
|
91 | #define SY_LFR_N_ASM_P 3600 // sec | |
|
92 | #define SY_LFR_N_BP_P0 4 // sec | |
|
93 | #define SY_LFR_N_BP_P1 20 // sec | |
|
94 | #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 | |
|
89 | #define DFLT_SY_LFR_N_SWF_L 2048 // nb sample | |
|
90 | #define DFLT_SY_LFR_N_SWF_P 300 // sec | |
|
91 | #define DFLT_SY_LFR_N_ASM_P 3600 // sec | |
|
92 | #define DFLT_SY_LFR_N_BP_P0 4 // sec | |
|
93 | #define DFLT_SY_LFR_N_BP_P1 20 // sec | |
|
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 | 130 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) |
|
131 | 131 | |
|
132 | 132 | //********** |
|
133 | 133 | // IRQ LINES |
|
134 | 134 | #define IRQ_SM_SIMULATOR 9 |
|
135 | 135 | #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
136 | 136 | #define IRQ_WAVEFORM_PICKER 14 |
|
137 | 137 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
138 | 138 | #define IRQ_SPECTRAL_MATRIX 6 |
|
139 | 139 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
140 | 140 | |
|
141 | 141 | //***** |
|
142 | 142 | // TIME |
|
143 | 143 | #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416 |
|
144 | 144 | #define TIMER_SM_SIMULATOR 1 |
|
145 | 145 | #define HK_PERIOD 100 // 100 * 10ms => 1s |
|
146 | 146 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000 |
|
147 | 147 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s |
|
148 | 148 | |
|
149 | 149 | //********** |
|
150 | 150 | // LPP CODES |
|
151 | 151 | #define LFR_SUCCESSFUL 0 |
|
152 | 152 | #define LFR_DEFAULT 1 |
|
153 | 153 | #define LFR_EXE_ERROR 2 |
|
154 | 154 | |
|
155 | 155 | //****** |
|
156 | 156 | // RTEMS |
|
157 | 157 | #define TASKID_RECV 1 |
|
158 | 158 | #define TASKID_ACTN 2 |
|
159 | 159 | #define TASKID_SPIQ 3 |
|
160 | 160 | #define TASKID_STAT 4 |
|
161 | 161 | #define TASKID_AVF0 5 |
|
162 | 162 | #define TASKID_SWBD 6 |
|
163 | 163 | #define TASKID_WFRM 7 |
|
164 | 164 | #define TASKID_DUMB 8 |
|
165 | 165 | #define TASKID_HOUS 9 |
|
166 | 166 | #define TASKID_PRC0 10 |
|
167 | 167 | #define TASKID_CWF3 11 |
|
168 | 168 | #define TASKID_CWF2 12 |
|
169 | 169 | #define TASKID_CWF1 13 |
|
170 | 170 | #define TASKID_SEND 14 |
|
171 | 171 | #define TASKID_WTDG 15 |
|
172 | 172 | #define TASKID_AVF1 16 |
|
173 | 173 | #define TASKID_PRC1 17 |
|
174 | 174 | #define TASKID_AVF2 18 |
|
175 | 175 | #define TASKID_PRC2 19 |
|
176 | 176 | |
|
177 | 177 | #define TASK_PRIORITY_SPIQ 5 |
|
178 | 178 | #define TASK_PRIORITY_WTDG 20 |
|
179 | 179 | #define TASK_PRIORITY_HOUS 30 |
|
180 | 180 | #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together |
|
181 | 181 | #define TASK_PRIORITY_CWF2 35 // |
|
182 | 182 | #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it |
|
183 | 183 | #define TASK_PRIORITY_WFRM 40 |
|
184 | 184 | #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 |
|
185 | 185 | #define TASK_PRIORITY_SEND 45 |
|
186 | 186 | #define TASK_PRIORITY_RECV 50 |
|
187 | 187 | #define TASK_PRIORITY_ACTN 50 |
|
188 | 188 | #define TASK_PRIORITY_AVF0 60 |
|
189 | 189 | #define TASK_PRIORITY_AVF1 70 |
|
190 | 190 | #define TASK_PRIORITY_PRC0 100 |
|
191 | 191 | #define TASK_PRIORITY_PRC1 100 |
|
192 | 192 | #define TASK_PRIORITY_AVF2 110 |
|
193 | 193 | #define TASK_PRIORITY_PRC2 110 |
|
194 | 194 | #define TASK_PRIORITY_STAT 200 |
|
195 | 195 | #define TASK_PRIORITY_DUMB 200 |
|
196 | 196 | |
|
197 | 197 | #define MSG_QUEUE_COUNT_RECV 10 |
|
198 | 198 | #define MSG_QUEUE_COUNT_SEND 50 |
|
199 | 199 | #define MSG_QUEUE_COUNT_PRC0 10 |
|
200 | 200 | #define MSG_QUEUE_COUNT_PRC1 10 |
|
201 | 201 | #define MSG_QUEUE_COUNT_PRC2 5 |
|
202 | 202 | #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1 |
|
203 | 203 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
204 | 204 | #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers |
|
205 | 205 | #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers |
|
206 | 206 | #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers |
|
207 | 207 | |
|
208 | 208 | #define QUEUE_RECV 0 |
|
209 | 209 | #define QUEUE_SEND 1 |
|
210 | 210 | #define QUEUE_PRC0 2 |
|
211 | 211 | #define QUEUE_PRC1 3 |
|
212 | 212 | #define QUEUE_PRC2 4 |
|
213 | 213 | |
|
214 | 214 | //******* |
|
215 | 215 | // MACROS |
|
216 | 216 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
217 | 217 | #define PRINTF(x) printf(x); |
|
218 | 218 | #define PRINTF1(x,y) printf(x,y); |
|
219 | 219 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
220 | 220 | #else |
|
221 | 221 | #define PRINTF(x) ; |
|
222 | 222 | #define PRINTF1(x,y) ; |
|
223 | 223 | #define PRINTF2(x,y,z) ; |
|
224 | 224 | #endif |
|
225 | 225 | |
|
226 | 226 | #ifdef BOOT_MESSAGES |
|
227 | 227 | #define BOOT_PRINTF(x) printf(x); |
|
228 | 228 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
229 | 229 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
230 | 230 | #else |
|
231 | 231 | #define BOOT_PRINTF(x) ; |
|
232 | 232 | #define BOOT_PRINTF1(x,y) ; |
|
233 | 233 | #define BOOT_PRINTF2(x,y,z) ; |
|
234 | 234 | #endif |
|
235 | 235 | |
|
236 | 236 | #ifdef DEBUG_MESSAGES |
|
237 | 237 | #define DEBUG_PRINTF(x) printf(x); |
|
238 | 238 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
239 | 239 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
240 | 240 | #else |
|
241 | 241 | #define DEBUG_PRINTF(x) ; |
|
242 | 242 | #define DEBUG_PRINTF1(x,y) ; |
|
243 | 243 | #define DEBUG_PRINTF2(x,y,z) ; |
|
244 | 244 | #endif |
|
245 | 245 | |
|
246 | 246 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
247 | 247 | |
|
248 | 248 | struct param_local_str{ |
|
249 | 249 | unsigned int local_sbm1_nb_cwf_sent; |
|
250 | 250 | unsigned int local_sbm1_nb_cwf_max; |
|
251 | 251 | unsigned int local_sbm2_nb_cwf_sent; |
|
252 | 252 | unsigned int local_sbm2_nb_cwf_max; |
|
253 | 253 | }; |
|
254 | 254 | |
|
255 | 255 | #endif // FSW_PARAMS_H_INCLUDED |
@@ -1,6 +1,32 | |||
|
1 | 1 | #ifndef LFR_CPU_USAGE_REPORT_H |
|
2 | 2 | #define LFR_CPU_USAGE_REPORT_H |
|
3 | 3 | |
|
4 | #ifdef HAVE_CONFIG_H | |
|
5 | #include "config.h" | |
|
6 | #endif | |
|
7 | ||
|
8 | #include <rtems.h> | |
|
9 | ||
|
10 | #include <assert.h> | |
|
11 | #include <string.h> | |
|
12 | #include <stdlib.h> | |
|
13 | #include <stdio.h> | |
|
14 | #include <ctype.h> | |
|
15 | #include <inttypes.h> | |
|
16 | ||
|
17 | #include <rtems/cpuuse.h> | |
|
18 | #include <rtems/bspIo.h> | |
|
19 | ||
|
20 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ | |
|
21 | #include <rtems/score/timestamp.h> | |
|
22 | #endif | |
|
23 | ||
|
24 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ | |
|
25 | extern Timestamp_Control CPU_usage_Uptime_at_last_reset; | |
|
26 | #else | |
|
27 | extern uint32_t CPU_usage_Ticks_at_last_reset; | |
|
28 | #endif | |
|
29 | ||
|
4 | 30 | unsigned char lfr_rtems_cpu_usage_report( void ); |
|
5 | 31 | |
|
6 | 32 | #endif // LFR_CPU_USAGE_REPORT_H |
@@ -1,243 +1,243 | |||
|
1 | 1 | #ifndef FSW_PROCESSING_H_INCLUDED |
|
2 | 2 | #define FSW_PROCESSING_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <grspw.h> |
|
6 | 6 | #include <math.h> |
|
7 | 7 | #include <stdlib.h> // abs() is in the stdlib |
|
8 | 8 | #include <stdio.h> // printf() |
|
9 | 9 | #include <math.h> |
|
10 | 10 | |
|
11 | 11 | #include "fsw_params.h" |
|
12 | 12 | #include "fsw_spacewire.h" |
|
13 | 13 | |
|
14 | 14 | typedef struct ring_node_sm |
|
15 | 15 | { |
|
16 | 16 | struct ring_node_sm *previous; |
|
17 | 17 | struct ring_node_sm *next; |
|
18 | 18 | int buffer_address; |
|
19 | 19 | unsigned int status; |
|
20 | 20 | unsigned int coarseTime; |
|
21 | 21 | unsigned int fineTime; |
|
22 | 22 | } ring_node_sm; |
|
23 | 23 | |
|
24 | 24 | typedef struct ring_node_asm |
|
25 | 25 | { |
|
26 | 26 | struct ring_node_asm *next; |
|
27 | 27 | float matrix[ TOTAL_SIZE_SM ]; |
|
28 | 28 | unsigned int status; |
|
29 | 29 | } ring_node_asm; |
|
30 | 30 | |
|
31 | 31 | typedef struct |
|
32 | 32 | { |
|
33 | 33 | Header_TM_LFR_SCIENCE_BP_t header; |
|
34 | 34 | unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
35 | 35 | } bp_packet; |
|
36 | 36 | |
|
37 | 37 | typedef struct |
|
38 | 38 | { |
|
39 | 39 | Header_TM_LFR_SCIENCE_BP_with_spare_t header; |
|
40 | 40 | unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 |
|
41 | 41 | } bp_packet_with_spare; |
|
42 | 42 | |
|
43 | 43 | typedef struct |
|
44 | 44 | { |
|
45 | 45 | ring_node_asm *norm; |
|
46 | 46 | ring_node_asm *burst_sbm; |
|
47 | 47 | rtems_event_set event; |
|
48 | 48 | unsigned int coarseTime; |
|
49 | 49 | unsigned int fineTime; |
|
50 | 50 | } asm_msg; |
|
51 | 51 | |
|
52 | 52 | extern volatile int sm_f0[ ]; |
|
53 | 53 | extern volatile int sm_f1[ ]; |
|
54 | 54 | extern volatile int sm_f2[ ]; |
|
55 | 55 | |
|
56 | 56 | // parameters |
|
57 | 57 | extern struct param_local_str param_local; |
|
58 | 58 | |
|
59 | 59 | // registers |
|
60 | 60 | extern time_management_regs_t *time_management_regs; |
|
61 | 61 | extern spectral_matrix_regs_t *spectral_matrix_regs; |
|
62 | 62 | |
|
63 | 63 | extern rtems_name misc_name[5]; |
|
64 | 64 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
65 | 65 | |
|
66 | 66 | // ISR |
|
67 | 67 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
68 | 68 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); |
|
69 | 69 | |
|
70 | 70 | //****************** |
|
71 | 71 | // Spectral Matrices |
|
72 | 72 | void reset_nb_sm( void ); |
|
73 | 73 | // SM |
|
74 | 74 | void SM_init_rings( void ); |
|
75 | 75 | void SM_reset_current_ring_nodes( void ); |
|
76 | 76 | void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] ); |
|
77 | 77 | // ASM |
|
78 | 78 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); |
|
79 | 79 | void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header); |
|
80 | 80 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
81 | 81 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); |
|
82 | 82 | |
|
83 | 83 | //***************** |
|
84 | 84 | // Basic Parameters |
|
85 | 85 | |
|
86 | 86 | void BP_reset_current_ring_nodes( void ); |
|
87 | 87 | void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header, |
|
88 | 88 | unsigned int apid, unsigned char sid, |
|
89 | 89 | unsigned int packetLength , unsigned char blkNr); |
|
90 | 90 | void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header, |
|
91 | 91 | unsigned int apid, unsigned char sid, |
|
92 | 92 | unsigned int packetLength, unsigned char blkNr ); |
|
93 | 93 | void BP_send( char *data, |
|
94 | 94 | rtems_id queue_id , |
|
95 | 95 | unsigned int nbBytesToSend , unsigned int sid ); |
|
96 | 96 | |
|
97 | 97 | //****************** |
|
98 | 98 | // general functions |
|
99 | 99 | void reset_spectral_matrix_regs( void ); |
|
100 | 100 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); |
|
101 | 101 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); |
|
102 | void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, | |
|
102 | void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id, | |
|
103 | 103 | ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time); |
|
104 | 104 | unsigned char getSID( rtems_event_set event ); |
|
105 | 105 | |
|
106 | 106 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
107 | 107 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
108 | 108 | |
|
109 | 109 | //*************************************** |
|
110 | 110 | // DEFINITIONS OF STATIC INLINE FUNCTIONS |
|
111 | 111 | static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
112 | 112 | ring_node_sm *ring_node_tab[], |
|
113 | 113 | unsigned int nbAverageNORM, unsigned int nbAverageSBM ); |
|
114 | 114 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, |
|
115 | 115 | float divider ); |
|
116 | 116 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, |
|
117 | 117 | float divider, |
|
118 | 118 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
119 | 119 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
120 | 120 | |
|
121 | 121 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
122 | 122 | ring_node_sm *ring_node_tab[], |
|
123 | 123 | unsigned int nbAverageNORM, unsigned int nbAverageSBM ) |
|
124 | 124 | { |
|
125 | 125 | float sum; |
|
126 | 126 | unsigned int i; |
|
127 | 127 | |
|
128 | 128 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
129 | 129 | { |
|
130 | 130 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] |
|
131 | 131 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] |
|
132 | 132 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] |
|
133 | 133 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] |
|
134 | 134 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] |
|
135 | 135 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] |
|
136 | 136 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] |
|
137 | 137 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; |
|
138 | 138 | |
|
139 | 139 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) |
|
140 | 140 | { |
|
141 | 141 | averaged_spec_mat_NORM[ i ] = sum; |
|
142 | 142 | averaged_spec_mat_SBM[ i ] = sum; |
|
143 | 143 | } |
|
144 | 144 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) |
|
145 | 145 | { |
|
146 | 146 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
147 | 147 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
148 | 148 | } |
|
149 | 149 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) |
|
150 | 150 | { |
|
151 | 151 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
152 | 152 | averaged_spec_mat_SBM[ i ] = sum; |
|
153 | 153 | } |
|
154 | 154 | else |
|
155 | 155 | { |
|
156 | 156 | PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) |
|
157 | 157 | } |
|
158 | 158 | } |
|
159 | 159 | } |
|
160 | 160 | |
|
161 | 161 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
162 | 162 | { |
|
163 | 163 | int frequencyBin; |
|
164 | 164 | int asmComponent; |
|
165 | 165 | unsigned int offsetAveragedSpecMatReorganized; |
|
166 | 166 | unsigned int offsetAveragedSpecMat; |
|
167 | 167 | |
|
168 | 168 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
169 | 169 | { |
|
170 | 170 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
171 | 171 | { |
|
172 | 172 | offsetAveragedSpecMatReorganized = |
|
173 | 173 | frequencyBin * NB_VALUES_PER_SM |
|
174 | 174 | + asmComponent; |
|
175 | 175 | offsetAveragedSpecMat = |
|
176 | 176 | asmComponent * NB_BINS_PER_SM |
|
177 | 177 | + frequencyBin; |
|
178 | 178 | averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] = |
|
179 | 179 | averaged_spec_mat[ offsetAveragedSpecMat ] / divider; |
|
180 | 180 | } |
|
181 | 181 | } |
|
182 | 182 | } |
|
183 | 183 | |
|
184 | 184 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
185 | 185 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
186 | 186 | { |
|
187 | 187 | int frequencyBin; |
|
188 | 188 | int asmComponent; |
|
189 | 189 | int offsetASM; |
|
190 | 190 | int offsetCompressed; |
|
191 | 191 | int k; |
|
192 | 192 | |
|
193 | 193 | // build data |
|
194 | 194 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
195 | 195 | { |
|
196 | 196 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
197 | 197 | { |
|
198 | 198 | offsetCompressed = // NO TIME OFFSET |
|
199 | 199 | frequencyBin * NB_VALUES_PER_SM |
|
200 | 200 | + asmComponent; |
|
201 | 201 | offsetASM = // NO TIME OFFSET |
|
202 | 202 | asmComponent * NB_BINS_PER_SM |
|
203 | 203 | + ASMIndexStart |
|
204 | 204 | + frequencyBin * nbBinsToAverage; |
|
205 | 205 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
206 | 206 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
207 | 207 | { |
|
208 | 208 | compressed_spec_mat[offsetCompressed ] = |
|
209 | 209 | ( compressed_spec_mat[ offsetCompressed ] |
|
210 | 210 | + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage); |
|
211 | 211 | } |
|
212 | 212 | } |
|
213 | 213 | } |
|
214 | 214 | } |
|
215 | 215 | |
|
216 | 216 | void ASM_convert( volatile float *input_matrix, char *output_matrix) |
|
217 | 217 | { |
|
218 | 218 | unsigned int frequencyBin; |
|
219 | 219 | unsigned int asmComponent; |
|
220 | 220 | char * pt_char_input; |
|
221 | 221 | char * pt_char_output; |
|
222 | 222 | unsigned int offsetInput; |
|
223 | 223 | unsigned int offsetOutput; |
|
224 | 224 | |
|
225 | 225 | pt_char_input = (char*) &input_matrix; |
|
226 | 226 | pt_char_output = (char*) &output_matrix; |
|
227 | 227 | |
|
228 | 228 | // convert all other data |
|
229 | 229 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) |
|
230 | 230 | { |
|
231 | 231 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) |
|
232 | 232 | { |
|
233 | 233 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; |
|
234 | 234 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; |
|
235 | 235 | pt_char_input = (char*) &input_matrix [ offsetInput ]; |
|
236 | 236 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; |
|
237 | 237 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
238 | 238 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
239 | 239 | } |
|
240 | 240 | } |
|
241 | 241 | } |
|
242 | 242 | |
|
243 | 243 | #endif // FSW_PROCESSING_H_INCLUDED |
@@ -1,49 +1,51 | |||
|
1 | 1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
2 | 2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "wf_handler.h" |
|
9 | 9 | #include "tm_lfr_tc_exe.h" |
|
10 | 10 | #include "fsw_misc.h" |
|
11 | 11 | |
|
12 | #define FLOAT_EQUAL_ZERO 0.001 | |
|
13 | ||
|
12 | 14 | extern unsigned short sequenceCounterParameterDump; |
|
13 | 15 | |
|
14 | 16 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
15 | 17 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
16 | 18 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
17 | 19 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
18 | 20 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
19 | 21 | int action_dump_par(rtems_id queue_id ); |
|
20 | 22 | |
|
21 | 23 | // NORMAL |
|
22 | 24 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
23 | 25 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
24 | 26 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
25 | 27 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
26 | 28 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
27 | 29 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
28 | 30 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
29 | 31 | |
|
30 | 32 | // BURST |
|
31 | 33 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
32 | 34 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
33 | 35 | |
|
34 | 36 | // SBM1 |
|
35 | 37 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
36 | 38 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
37 | 39 | |
|
38 | 40 | // SBM2 |
|
39 | 41 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
40 | 42 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
41 | 43 | |
|
42 | 44 | // TC_LFR_UPDATE_INFO |
|
43 | 45 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
44 | 46 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
45 | 47 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
46 | 48 | |
|
47 | 49 | void init_parameter_dump( void ); |
|
48 | 50 | |
|
49 | 51 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,55 +1,25 | |||
|
1 | 1 | #include <drvmgr/ambapp_bus.h> |
|
2 | 2 | |
|
3 | 3 | // GRSPW0 resources |
|
4 | 4 | struct drvmgr_key grlib_grspw_0n1_res[] = { |
|
5 | 5 | {"txBdCnt", KEY_TYPE_INT, {(unsigned int)50}}, // 7 SWF_F0, 7 SWF_F1, 7 SWF_F2, 7 CWF_F3, 7 CWF_F1 ou 7 CWF_F2 |
|
6 | 6 | {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}}, |
|
7 | 7 | {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}}, |
|
8 | 8 | {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+12}}, // 12 is for the auxiliary header, when needed |
|
9 | 9 | {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}}, |
|
10 | 10 | KEY_EMPTY |
|
11 | 11 | }; |
|
12 | 12 | |
|
13 | #if 0 | |
|
14 | /* APBUART0 */ | |
|
15 | struct drvmgr_key grlib_drv_res_apbuart0[] = | |
|
16 | { | |
|
17 | {"mode", KEY_TYPE_INT, {(unsigned int)1}}, | |
|
18 | {"syscon", KEY_TYPE_INT, {(unsigned int)1}}, | |
|
19 | KEY_EMPTY | |
|
20 | }; | |
|
21 | /* APBUART1 */ | |
|
22 | struct drvmgr_key grlib_drv_res_apbuart1[] = | |
|
23 | { | |
|
24 | {"mode", KEY_TYPE_INT, {(unsigned int)1}}, | |
|
25 | {"syscon", KEY_TYPE_INT, {(unsigned int)0}}, | |
|
26 | KEY_EMPTY | |
|
27 | }; | |
|
28 | /* LEON3 System with driver configuration for 2 APBUARTs, the | |
|
29 | * the rest of the AMBA device drivers use their defaults. | |
|
30 | */ | |
|
31 | ||
|
32 | /* Override default debug UART assignment. | |
|
33 | * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0, | |
|
34 | * CPU1=APBUART1... | |
|
35 | * 1 = APBUART[0] | |
|
36 | * 2 = APBUART[1] | |
|
37 | * 3 = APBUART[2] | |
|
38 | * ... | |
|
39 | */ | |
|
40 | //int debug_uart_index = 2; /* second UART -- APBUART[1] */ | |
|
41 | #endif | |
|
42 | ||
|
43 | 13 | // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP. |
|
44 | 14 | |
|
45 | 15 | struct drvmgr_bus_res grlib_drv_resources = { |
|
46 | 16 | .next = NULL, |
|
47 | 17 | .resource = { |
|
48 | 18 | {DRIVER_AMBAPP_GAISLER_GRSPW_ID, 0, &grlib_grspw_0n1_res[0]}, |
|
49 | 19 | // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 0, &grlib_drv_res_apbuart0[0]}, |
|
50 | 20 | // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]}, |
|
51 | 21 | RES_EMPTY /* Mark end of device resource array */ |
|
52 | 22 | } |
|
53 | 23 | }; |
|
54 | 24 | |
|
55 | 25 |
@@ -1,529 +1,530 | |||
|
1 | 1 | /** General usage functions and RTEMS tasks. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | */ |
|
7 | 7 | |
|
8 | 8 | #include "fsw_misc.h" |
|
9 | 9 | |
|
10 | 10 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
11 | 11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
12 | 12 | { |
|
13 | 13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
14 | 14 | * |
|
15 | 15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
16 | 16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
17 | 17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
18 | 18 | * @param interrupt_level is the interrupt level that the timer drives. |
|
19 | 19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
20 | 20 | * |
|
21 | 21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
22 | 22 | * |
|
23 | 23 | */ |
|
24 | 24 | |
|
25 | 25 | rtems_status_code status; |
|
26 | 26 | rtems_isr_entry old_isr_handler; |
|
27 | 27 | |
|
28 | 28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register |
|
29 | 29 | |
|
30 | 30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
31 | 31 | if (status!=RTEMS_SUCCESSFUL) |
|
32 | 32 | { |
|
33 | 33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
40 | 40 | { |
|
41 | 41 | /** This function starts a GPTIMER timer. |
|
42 | 42 | * |
|
43 | 43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
44 | 44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
45 | 45 | * |
|
46 | 46 | */ |
|
47 | 47 | |
|
48 | 48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
49 | 49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
50 | 50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
51 | 51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
52 | 52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
56 | 56 | { |
|
57 | 57 | /** This function stops a GPTIMER timer. |
|
58 | 58 | * |
|
59 | 59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
60 | 60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
61 | 61 | * |
|
62 | 62 | */ |
|
63 | 63 | |
|
64 | 64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
65 | 65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
66 | 66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) |
|
70 | 70 | { |
|
71 | 71 | /** This function sets the clock divider of a GPTIMER timer. |
|
72 | 72 | * |
|
73 | 73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
74 | 74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
75 | 75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
76 | 76 | * |
|
77 | 77 | */ |
|
78 | 78 | |
|
79 | 79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
83 | 83 | { |
|
84 | 84 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
85 | 85 | |
|
86 | 86 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
87 | 87 | |
|
88 | 88 | return 0; |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
92 | 92 | { |
|
93 | 93 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
94 | 94 | |
|
95 | 95 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; |
|
96 | 96 | |
|
97 | 97 | return 0; |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
101 | 101 | { |
|
102 | 102 | /** This function sets the scaler reload register of the apbuart module |
|
103 | 103 | * |
|
104 | 104 | * @param regs is the address of the apbuart registers in memory |
|
105 | 105 | * @param value is the value that will be stored in the scaler register |
|
106 | 106 | * |
|
107 | 107 | * The value shall be set by the software to get data on the serial interface. |
|
108 | 108 | * |
|
109 | 109 | */ |
|
110 | 110 | |
|
111 | 111 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
112 | 112 | |
|
113 | 113 | apbuart_regs->scaler = value; |
|
114 | 114 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | 117 | //************ |
|
118 | 118 | // RTEMS TASKS |
|
119 | 119 | |
|
120 | 120 | rtems_task stat_task(rtems_task_argument argument) |
|
121 | 121 | { |
|
122 | 122 | int i; |
|
123 | 123 | int j; |
|
124 | 124 | i = 0; |
|
125 | 125 | j = 0; |
|
126 | 126 | BOOT_PRINTF("in STAT *** \n") |
|
127 | 127 | while(1){ |
|
128 | 128 | rtems_task_wake_after(1000); |
|
129 | 129 | PRINTF1("%d\n", j) |
|
130 | 130 | if (i == CPU_USAGE_REPORT_PERIOD) { |
|
131 | 131 | // #ifdef PRINT_TASK_STATISTICS |
|
132 | 132 | // rtems_cpu_usage_report(); |
|
133 | 133 | // rtems_cpu_usage_reset(); |
|
134 | 134 | // #endif |
|
135 | 135 | i = 0; |
|
136 | 136 | } |
|
137 | 137 | else i++; |
|
138 | 138 | j++; |
|
139 | 139 | } |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | rtems_task hous_task(rtems_task_argument argument) |
|
143 | 143 | { |
|
144 | 144 | rtems_status_code status; |
|
145 | rtems_status_code spare_status; | |
|
145 | 146 | rtems_id queue_id; |
|
146 | 147 | rtems_rate_monotonic_period_status period_status; |
|
147 | 148 | |
|
148 | 149 | status = get_message_queue_id_send( &queue_id ); |
|
149 | 150 | if (status != RTEMS_SUCCESSFUL) |
|
150 | 151 | { |
|
151 | 152 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
152 | 153 | } |
|
153 | 154 | |
|
154 | 155 | BOOT_PRINTF("in HOUS ***\n") |
|
155 | 156 | |
|
156 | 157 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
157 | 158 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
158 | 159 | if( status != RTEMS_SUCCESSFUL ) { |
|
159 | 160 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
160 | 161 | } |
|
161 | 162 | } |
|
162 | 163 | |
|
163 | 164 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
164 | 165 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
165 | 166 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
166 | 167 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
167 | 168 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
168 | 169 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
169 | 170 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
170 | 171 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
171 | 172 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
172 | 173 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
173 | 174 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
174 | 175 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
175 | 176 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
176 | 177 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
177 | 178 | housekeeping_packet.sid = SID_HK; |
|
178 | 179 | |
|
179 | 180 | status = rtems_rate_monotonic_cancel(HK_id); |
|
180 | 181 | if( status != RTEMS_SUCCESSFUL ) { |
|
181 | 182 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
182 | 183 | } |
|
183 | 184 | else { |
|
184 | 185 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
185 | 186 | } |
|
186 | 187 | |
|
187 | 188 | // startup phase |
|
188 | 189 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
189 | 190 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
190 | 191 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
191 | 192 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
192 | 193 | { |
|
193 | 194 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization |
|
194 | 195 | { |
|
195 | 196 | break; // break if LFR is synchronized |
|
196 | 197 | } |
|
197 | 198 | else |
|
198 | 199 | { |
|
199 | 200 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
200 | 201 | // sched_yield(); |
|
201 | 202 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms |
|
202 | 203 | } |
|
203 | 204 | } |
|
204 | 205 | status = rtems_rate_monotonic_cancel(HK_id); |
|
205 | 206 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
206 | 207 | |
|
207 | 208 | while(1){ // launch the rate monotonic task |
|
208 | 209 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
209 | 210 | if ( status != RTEMS_SUCCESSFUL ) { |
|
210 | 211 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
211 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
|
212 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
|
212 | 213 | } |
|
213 | 214 | else { |
|
214 | 215 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); |
|
215 | 216 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); |
|
216 | 217 | increment_seq_counter( &sequenceCounterHK ); |
|
217 | 218 | |
|
218 | 219 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
219 | 220 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
220 | 221 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
221 | 222 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
222 | 223 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
223 | 224 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
224 | 225 | |
|
225 | 226 | spacewire_update_statistics(); |
|
226 | 227 | |
|
227 | 228 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
228 | 229 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
229 | 230 | |
|
230 | 231 | // SEND PACKET |
|
231 | 232 | status = rtems_message_queue_urgent( queue_id, &housekeeping_packet, |
|
232 | 233 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
233 | 234 | if (status != RTEMS_SUCCESSFUL) { |
|
234 | 235 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
235 | 236 | } |
|
236 | 237 | } |
|
237 | 238 | } |
|
238 | 239 | |
|
239 | 240 | PRINTF("in HOUS *** deleting task\n") |
|
240 | 241 | |
|
241 | 242 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
242 | 243 | printf( "rtems_task_delete returned with status of %d.\n", status ); |
|
243 | 244 | return; |
|
244 | 245 | } |
|
245 | 246 | |
|
246 | 247 | rtems_task dumb_task( rtems_task_argument unused ) |
|
247 | 248 | { |
|
248 | 249 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
249 | 250 | * |
|
250 | 251 | * @param unused is the starting argument of the RTEMS task |
|
251 | 252 | * |
|
252 | 253 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
253 | 254 | * |
|
254 | 255 | */ |
|
255 | 256 | |
|
256 | 257 | unsigned int i; |
|
257 | 258 | unsigned int intEventOut; |
|
258 | 259 | unsigned int coarse_time = 0; |
|
259 | 260 | unsigned int fine_time = 0; |
|
260 | 261 | rtems_event_set event_out; |
|
261 | 262 | |
|
262 | 263 | char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0 |
|
263 | 264 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
264 | 265 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 |
|
265 | 266 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
266 | 267 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
267 | 268 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 |
|
268 | 269 | "ERR HK", // RTEMS_EVENT_6 |
|
269 | 270 | "ready for dump", // RTEMS_EVENT_7 |
|
270 | 271 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 |
|
271 | 272 | "tick", // RTEMS_EVENT_9 |
|
272 | 273 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 |
|
273 | 274 | "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11 |
|
274 | 275 | }; |
|
275 | 276 | |
|
276 | 277 | BOOT_PRINTF("in DUMB *** \n") |
|
277 | 278 | |
|
278 | 279 | while(1){ |
|
279 | 280 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
280 | 281 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
281 | 282 | | RTEMS_EVENT_8 | RTEMS_EVENT_9, |
|
282 | 283 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
283 | 284 | intEventOut = (unsigned int) event_out; |
|
284 | 285 | for ( i=0; i<32; i++) |
|
285 | 286 | { |
|
286 | 287 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
287 | 288 | { |
|
288 | 289 | coarse_time = time_management_regs->coarse_time; |
|
289 | 290 | fine_time = time_management_regs->fine_time; |
|
290 | 291 | printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); |
|
291 | 292 | if (i==8) |
|
292 | 293 | { |
|
293 | PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status) | |
|
294 | 294 | } |
|
295 | 295 | if (i==10) |
|
296 | 296 | { |
|
297 | PRINTF1("waveform_picker_regs->status = %x\n", waveform_picker_regs->status) | |
|
298 | 297 | } |
|
299 | 298 | } |
|
300 | 299 | } |
|
301 | 300 | } |
|
302 | 301 | } |
|
303 | 302 | |
|
304 | 303 | //***************************** |
|
305 | 304 | // init housekeeping parameters |
|
306 | 305 | |
|
307 | 306 | void init_housekeeping_parameters( void ) |
|
308 | 307 | { |
|
309 | 308 | /** This function initialize the housekeeping_packet global variable with default values. |
|
310 | 309 | * |
|
311 | 310 | */ |
|
312 | 311 | |
|
313 | 312 | unsigned int i = 0; |
|
314 | 313 | unsigned char *parameters; |
|
315 | 314 | |
|
316 | 315 | parameters = (unsigned char*) &housekeeping_packet.lfr_status_word; |
|
317 | 316 | for(i = 0; i< SIZE_HK_PARAMETERS; i++) |
|
318 | 317 | { |
|
319 | 318 | parameters[i] = 0x00; |
|
320 | 319 | } |
|
321 | 320 | // init status word |
|
322 | 321 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
323 | 322 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
324 | 323 | // init software version |
|
325 | 324 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
326 | 325 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
327 | 326 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
328 | 327 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
329 | 328 | // init fpga version |
|
330 | 329 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
331 | 330 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
332 | 331 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
333 | 332 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
334 | 333 | } |
|
335 | 334 | |
|
336 | 335 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
337 | 336 | { |
|
338 | 337 | /** This function increment the sequence counter psased in argument. |
|
339 | 338 | * |
|
340 | 339 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
341 | 340 | * |
|
342 | 341 | */ |
|
343 | 342 | |
|
344 | 343 | unsigned short segmentation_grouping_flag; |
|
345 | 344 | unsigned short sequence_cnt; |
|
346 | 345 | |
|
347 | 346 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 |
|
348 | 347 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] |
|
349 | 348 | |
|
350 | 349 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
351 | 350 | { |
|
352 | 351 | sequence_cnt = sequence_cnt + 1; |
|
353 | 352 | } |
|
354 | 353 | else |
|
355 | 354 | { |
|
356 | 355 | sequence_cnt = 0; |
|
357 | 356 | } |
|
358 | 357 | |
|
359 | 358 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
360 | 359 | } |
|
361 | 360 | |
|
362 | 361 | void getTime( unsigned char *time) |
|
363 | 362 | { |
|
364 | 363 | /** This function write the current local time in the time buffer passed in argument. |
|
365 | 364 | * |
|
366 | 365 | */ |
|
367 | 366 | |
|
368 | 367 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
369 | 368 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
370 | 369 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
371 | 370 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
372 | 371 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
373 | 372 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
374 | 373 | } |
|
375 | 374 | |
|
376 | 375 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
377 | 376 | { |
|
378 | 377 | /** This function write the current local time in the time buffer passed in argument. |
|
379 | 378 | * |
|
380 | 379 | */ |
|
381 | 380 | unsigned long long int time; |
|
382 | 381 | |
|
383 | 382 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) |
|
384 | 383 | + time_management_regs->fine_time; |
|
385 | 384 | |
|
386 | 385 | return time; |
|
387 | 386 | } |
|
388 | 387 | |
|
389 | 388 | void send_dumb_hk( void ) |
|
390 | 389 | { |
|
391 | 390 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
392 | 391 | unsigned char *parameters; |
|
393 | 392 | unsigned int i; |
|
394 | 393 | rtems_id queue_id; |
|
395 | 394 | |
|
396 | 395 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
397 | 396 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
398 | 397 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
399 | 398 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
400 | 399 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
401 | 400 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
402 | 401 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
403 | 402 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
404 | 403 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
405 | 404 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
406 | 405 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
407 | 406 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
408 | 407 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
409 | 408 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
410 | 409 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
411 | 410 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
412 | 411 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
413 | 412 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
414 | 413 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
415 | 414 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
416 | 415 | dummy_hk_packet.sid = SID_HK; |
|
417 | 416 | |
|
418 | 417 | // init status word |
|
419 | 418 | dummy_hk_packet.lfr_status_word[0] = 0xff; |
|
420 | 419 | dummy_hk_packet.lfr_status_word[1] = 0xff; |
|
421 | 420 | // init software version |
|
422 | 421 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
423 | 422 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
424 | 423 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
425 | 424 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
426 | 425 | // init fpga version |
|
427 | 426 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); |
|
428 | 427 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
429 | 428 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
430 | 429 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
431 | 430 | |
|
432 | 431 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
433 | 432 | |
|
434 | 433 | for (i=0; i<100; i++) |
|
435 | 434 | { |
|
436 | 435 | parameters[i] = 0xff; |
|
437 | 436 | } |
|
438 | 437 | |
|
439 | 438 | get_message_queue_id_send( &queue_id ); |
|
440 | 439 | |
|
441 | 440 | rtems_message_queue_urgent( queue_id, &dummy_hk_packet, |
|
442 | 441 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
443 | 442 | } |
|
444 | 443 | |
|
445 | 444 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
446 | 445 | { |
|
447 | 446 | unsigned int coarseTime; |
|
448 | 447 | unsigned int acquisitionTime; |
|
449 | 448 | unsigned int deltaT = 0; |
|
450 | 449 | unsigned char *bufferPtr; |
|
451 | 450 | |
|
452 | 451 | unsigned int offset_in_samples; |
|
453 | 452 | unsigned int offset_in_bytes; |
|
454 | 453 | unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz |
|
455 | 454 | |
|
455 | bufferPtr = NULL; | |
|
456 | ||
|
456 | 457 | if (lfrCurrentMode == LFR_MODE_STANDBY) |
|
457 | 458 | { |
|
458 | 459 | spacecraft_potential[0] = 0x00; |
|
459 | 460 | spacecraft_potential[1] = 0x00; |
|
460 | 461 | spacecraft_potential[2] = 0x00; |
|
461 | 462 | spacecraft_potential[3] = 0x00; |
|
462 | 463 | spacecraft_potential[4] = 0x00; |
|
463 | 464 | spacecraft_potential[5] = 0x00; |
|
464 | 465 | } |
|
465 | 466 | else |
|
466 | 467 | { |
|
467 | 468 | coarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
468 | 469 | bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address; |
|
469 | 470 | acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 ) |
|
470 | 471 | + (unsigned int) ( bufferPtr[1] << 16 ) |
|
471 | 472 | + (unsigned int) ( bufferPtr[2] << 8 ) |
|
472 | 473 | + (unsigned int) ( bufferPtr[3] ); |
|
473 | 474 | if ( coarseTime > acquisitionTime ) |
|
474 | 475 | { |
|
475 | 476 | deltaT = coarseTime - acquisitionTime; |
|
476 | 477 | offset_in_samples = (deltaT-1) * f3 ; |
|
477 | 478 | } |
|
478 | 479 | else if( coarseTime == acquisitionTime ) |
|
479 | 480 | { |
|
480 | 481 | bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer |
|
481 | 482 | offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1; |
|
482 | 483 | } |
|
483 | 484 | else |
|
484 | 485 | { |
|
485 | 486 | offset_in_samples = 0; |
|
486 | 487 | PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime) |
|
487 | 488 | } |
|
488 | 489 | |
|
489 | 490 | if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) ) |
|
490 | 491 | { |
|
491 | 492 | PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples) |
|
492 | 493 | offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1; |
|
493 | 494 | } |
|
494 | 495 | offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4; |
|
495 | 496 | spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0]; |
|
496 | 497 | spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1]; |
|
497 | 498 | spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2]; |
|
498 | 499 | spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3]; |
|
499 | 500 | spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4]; |
|
500 | 501 | spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5]; |
|
501 | 502 | } |
|
502 | 503 | } |
|
503 | 504 | |
|
504 | 505 | void get_cpu_load( unsigned char *resource_statistics ) |
|
505 | 506 | { |
|
506 | 507 | unsigned char cpu_load; |
|
507 | 508 | |
|
508 | 509 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
509 | 510 | |
|
510 | 511 | // HK_LFR_CPU_LOAD |
|
511 | 512 | resource_statistics[0] = cpu_load; |
|
512 | 513 | |
|
513 | 514 | // HK_LFR_CPU_LOAD_MAX |
|
514 | 515 | if (cpu_load > resource_statistics[1]) |
|
515 | 516 | { |
|
516 | 517 | resource_statistics[1] = cpu_load; |
|
517 | 518 | } |
|
518 | 519 | |
|
519 | 520 | // CPU_LOAD_AVE |
|
520 | 521 | resource_statistics[2] = 0; |
|
521 | 522 | |
|
522 | 523 | #ifndef PRINT_TASK_STATISTICS |
|
523 | 524 | rtems_cpu_usage_reset(); |
|
524 | 525 | #endif |
|
525 | 526 | |
|
526 | 527 | } |
|
527 | 528 | |
|
528 | 529 | |
|
529 | 530 |
@@ -1,610 +1,624 | |||
|
1 | 1 | /** Functions related to the SpaceWire interface. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle SpaceWire transmissions: |
|
7 | 7 | * - configuration of the SpaceWire link |
|
8 | 8 | * - SpaceWire related interruption requests processing |
|
9 | 9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
10 | 10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
11 | 11 | * |
|
12 | 12 | */ |
|
13 | 13 | |
|
14 | 14 | #include "fsw_spacewire.h" |
|
15 | 15 | |
|
16 | 16 | rtems_name semq_name; |
|
17 | 17 | rtems_id semq_id; |
|
18 | 18 | |
|
19 | 19 | //*********** |
|
20 | 20 | // RTEMS TASK |
|
21 | 21 | rtems_task spiq_task(rtems_task_argument unused) |
|
22 | 22 | { |
|
23 | 23 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
24 | 24 | * |
|
25 | 25 | * @param unused is the starting argument of the RTEMS task |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | rtems_event_set event_out; |
|
30 | 30 | rtems_status_code status; |
|
31 | 31 | int linkStatus; |
|
32 | 32 | |
|
33 | 33 | BOOT_PRINTF("in SPIQ *** \n") |
|
34 | 34 | |
|
35 | 35 | while(true){ |
|
36 | 36 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
37 | 37 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
38 | 38 | |
|
39 | 39 | // [0] SUSPEND RECV AND SEND TASKS |
|
40 | 40 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
41 | 41 | if ( status != RTEMS_SUCCESSFUL ) { |
|
42 | 42 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
43 | 43 | } |
|
44 | 44 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
45 | 45 | if ( status != RTEMS_SUCCESSFUL ) { |
|
46 | 46 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
47 | 47 | } |
|
48 | 48 | |
|
49 | 49 | // [1] CHECK THE LINK |
|
50 | 50 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
51 | 51 | if ( linkStatus != 5) { |
|
52 | 52 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
53 | 53 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
57 | 57 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
58 | 58 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
59 | 59 | { |
|
60 | 60 | spacewire_compute_stats_offsets(); |
|
61 | 61 | status = spacewire_reset_link( ); |
|
62 | 62 | } |
|
63 | 63 | else // [2.b] in run state, start the link |
|
64 | 64 | { |
|
65 | 65 | status = spacewire_stop_and_start_link( fdSPW ); // start the link |
|
66 | 66 | if ( status != RTEMS_SUCCESSFUL) |
|
67 | 67 | { |
|
68 | 68 | PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status) |
|
69 | 69 | } |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
73 | 73 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
74 | 74 | { |
|
75 | 75 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
76 | 76 | if ( status != RTEMS_SUCCESSFUL ) { |
|
77 | 77 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
78 | 78 | } |
|
79 | 79 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
80 | 80 | if ( status != RTEMS_SUCCESSFUL ) { |
|
81 | 81 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
82 | 82 | } |
|
83 | 83 | } |
|
84 | 84 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
85 | 85 | { |
|
86 | 86 | status = stop_current_mode(); |
|
87 | 87 | if ( status != RTEMS_SUCCESSFUL ) { |
|
88 | 88 | PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status) |
|
89 | 89 | } |
|
90 | 90 | status = enter_mode( LFR_MODE_STANDBY, 0 ); |
|
91 | 91 | if ( status != RTEMS_SUCCESSFUL ) { |
|
92 | 92 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
93 | 93 | } |
|
94 | 94 | // wake the WTDG task up to wait for the link recovery |
|
95 | 95 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
96 | 96 | status = rtems_task_suspend( RTEMS_SELF ); |
|
97 | 97 | } |
|
98 | 98 | } |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | rtems_task recv_task( rtems_task_argument unused ) |
|
102 | 102 | { |
|
103 | 103 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
104 | 104 | * |
|
105 | 105 | * @param unused is the starting argument of the RTEMS task |
|
106 | 106 | * |
|
107 | 107 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
108 | 108 | * 1. It reads the incoming data. |
|
109 | 109 | * 2. Launches the acceptance procedure. |
|
110 | 110 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
111 | 111 | * |
|
112 | 112 | */ |
|
113 | 113 | |
|
114 | 114 | int len; |
|
115 | 115 | ccsdsTelecommandPacket_t currentTC; |
|
116 | 116 | unsigned char computed_CRC[ 2 ]; |
|
117 | 117 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
118 | 118 | unsigned char destinationID; |
|
119 | 119 | unsigned int estimatedPacketLength; |
|
120 | 120 | unsigned int parserCode; |
|
121 | 121 | rtems_status_code status; |
|
122 | 122 | rtems_id queue_recv_id; |
|
123 | 123 | rtems_id queue_send_id; |
|
124 | 124 | |
|
125 | 125 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
126 | 126 | |
|
127 | 127 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
128 | 128 | if (status != RTEMS_SUCCESSFUL) |
|
129 | 129 | { |
|
130 | 130 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
131 | 131 | } |
|
132 | 132 | |
|
133 | 133 | status = get_message_queue_id_send( &queue_send_id ); |
|
134 | 134 | if (status != RTEMS_SUCCESSFUL) |
|
135 | 135 | { |
|
136 | 136 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
137 | 137 | } |
|
138 | 138 | |
|
139 | 139 | BOOT_PRINTF("in RECV *** \n") |
|
140 | 140 | |
|
141 | 141 | while(1) |
|
142 | 142 | { |
|
143 | 143 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
144 | 144 | if (len == -1){ // error during the read call |
|
145 | 145 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
146 | 146 | } |
|
147 | 147 | else { |
|
148 | 148 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
149 | 149 | PRINTF("in RECV *** packet lenght too short\n") |
|
150 | 150 | } |
|
151 | 151 | else { |
|
152 | 152 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
153 | 153 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); |
|
154 | 154 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); |
|
155 | 155 | // CHECK THE TC |
|
156 | 156 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; |
|
157 | 157 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
158 | 158 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
159 | 159 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
160 | 160 | || (parserCode == WRONG_SRC_ID) ) |
|
161 | 161 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
162 | 162 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
163 | 163 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
164 | 164 | && |
|
165 | 165 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
166 | 166 | ) |
|
167 | 167 | { |
|
168 | 168 | if ( parserCode == WRONG_SRC_ID ) |
|
169 | 169 | { |
|
170 | 170 | destinationID = SID_TC_GROUND; |
|
171 | 171 | } |
|
172 | 172 | else |
|
173 | 173 | { |
|
174 | 174 | destinationID = currentTC.sourceID; |
|
175 | 175 | } |
|
176 | 176 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
177 | 177 | computed_CRC, currentTC_LEN_RCV, |
|
178 | 178 | destinationID ); |
|
179 | 179 | } |
|
180 | 180 | } |
|
181 | 181 | else |
|
182 | 182 | { // send valid TC to the action launcher |
|
183 | 183 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
184 | 184 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
185 | 185 | } |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | } |
|
189 | 189 | } |
|
190 | 190 | |
|
191 | 191 | rtems_task send_task( rtems_task_argument argument) |
|
192 | 192 | { |
|
193 | 193 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
194 | 194 | * |
|
195 | 195 | * @param unused is the starting argument of the RTEMS task |
|
196 | 196 | * |
|
197 | 197 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
198 | 198 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
199 | 199 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
200 | 200 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
201 | 201 | * data it contains. |
|
202 | 202 | * |
|
203 | 203 | */ |
|
204 | 204 | |
|
205 | 205 | rtems_status_code status; // RTEMS status code |
|
206 | 206 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
207 | 207 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
208 | 208 | size_t size; // size of the incoming TC packet |
|
209 | 209 | u_int32_t count; |
|
210 | 210 | rtems_id queue_id; |
|
211 | 211 | |
|
212 | 212 | status = get_message_queue_id_send( &queue_id ); |
|
213 | 213 | if (status != RTEMS_SUCCESSFUL) |
|
214 | 214 | { |
|
215 | 215 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
216 | 216 | } |
|
217 | 217 | |
|
218 | 218 | BOOT_PRINTF("in SEND *** \n") |
|
219 | 219 | |
|
220 | 220 | while(1) |
|
221 | 221 | { |
|
222 | 222 | status = rtems_message_queue_receive( queue_id, incomingData, &size, |
|
223 | 223 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
224 | 224 | |
|
225 | 225 | if (status!=RTEMS_SUCCESSFUL) |
|
226 | 226 | { |
|
227 | 227 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
228 | 228 | } |
|
229 | 229 | else |
|
230 | 230 | { |
|
231 | 231 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet |
|
232 | 232 | { |
|
233 | 233 | status = write( fdSPW, incomingData, size ); |
|
234 | 234 | if (status == -1){ |
|
235 | 235 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
236 | 236 | } |
|
237 | 237 | } |
|
238 | 238 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
239 | 239 | { |
|
240 | 240 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
241 | 241 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
242 | 242 | if (status == -1){ |
|
243 | 243 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
244 | 244 | } |
|
245 | 245 | } |
|
246 | 246 | } |
|
247 | 247 | |
|
248 | 248 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
249 | 249 | if (status != RTEMS_SUCCESSFUL) |
|
250 | 250 | { |
|
251 | 251 | PRINTF1("in SEND *** (3) ERR = %d\n", status) |
|
252 | 252 | } |
|
253 | 253 | else |
|
254 | 254 | { |
|
255 | 255 | if (count > maxCount) |
|
256 | 256 | { |
|
257 | 257 | maxCount = count; |
|
258 | 258 | } |
|
259 | 259 | } |
|
260 | 260 | } |
|
261 | 261 | } |
|
262 | 262 | |
|
263 | 263 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
264 | 264 | { |
|
265 | 265 | rtems_event_set event_out; |
|
266 | 266 | rtems_status_code status; |
|
267 | 267 | int linkStatus; |
|
268 | 268 | |
|
269 | 269 | BOOT_PRINTF("in WTDG ***\n") |
|
270 | 270 | |
|
271 | 271 | while(1) |
|
272 | 272 | { |
|
273 | 273 | // wait for an RTEMS_EVENT |
|
274 | 274 | rtems_event_receive( RTEMS_EVENT_0, |
|
275 | 275 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
276 | 276 | PRINTF("in WTDG *** wait for the link\n") |
|
277 | 277 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
278 | 278 | while( linkStatus != 5) // wait for the link |
|
279 | 279 | { |
|
280 | 280 | rtems_task_wake_after( 10 ); |
|
281 | 281 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
282 | 282 | } |
|
283 | 283 | |
|
284 | 284 | status = spacewire_stop_and_start_link( fdSPW ); |
|
285 | 285 | |
|
286 | 286 | if (status != RTEMS_SUCCESSFUL) |
|
287 | 287 | { |
|
288 | 288 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
289 | 289 | } |
|
290 | 290 | else |
|
291 | 291 | { |
|
292 | 292 | PRINTF("in WTDG *** OK link started\n") |
|
293 | 293 | } |
|
294 | 294 | |
|
295 | 295 | // restart the SPIQ task |
|
296 | 296 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
297 | 297 | if ( status != RTEMS_SUCCESSFUL ) { |
|
298 | 298 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
299 | 299 | } |
|
300 | 300 | |
|
301 | 301 | // restart RECV and SEND |
|
302 | 302 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
303 | 303 | if ( status != RTEMS_SUCCESSFUL ) { |
|
304 | 304 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
305 | 305 | } |
|
306 | 306 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
307 | 307 | if ( status != RTEMS_SUCCESSFUL ) { |
|
308 | 308 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
309 | 309 | } |
|
310 | 310 | } |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | //**************** |
|
314 | 314 | // OTHER FUNCTIONS |
|
315 | 315 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
316 | 316 | { |
|
317 | 317 | /** This function opens the SpaceWire link. |
|
318 | 318 | * |
|
319 | 319 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
320 | 320 | * |
|
321 | 321 | */ |
|
322 | 322 | rtems_status_code status; |
|
323 | 323 | |
|
324 | 324 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
325 | 325 | if ( fdSPW < 0 ) { |
|
326 | 326 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
327 | 327 | } |
|
328 | 328 | else |
|
329 | 329 | { |
|
330 | 330 | status = RTEMS_SUCCESSFUL; |
|
331 | 331 | } |
|
332 | 332 | |
|
333 | 333 | return status; |
|
334 | 334 | } |
|
335 | 335 | |
|
336 | 336 | int spacewire_start_link( int fd ) |
|
337 | 337 | { |
|
338 | 338 | rtems_status_code status; |
|
339 | 339 | |
|
340 | 340 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
341 | 341 | // -1 default hardcoded driver timeout |
|
342 | 342 | |
|
343 | 343 | return status; |
|
344 | 344 | } |
|
345 | 345 | |
|
346 | 346 | int spacewire_stop_and_start_link( int fd ) |
|
347 | 347 | { |
|
348 | 348 | rtems_status_code status; |
|
349 | 349 | |
|
350 | 350 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
351 | 351 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
352 | 352 | // -1 default hardcoded driver timeout |
|
353 | 353 | |
|
354 | 354 | return status; |
|
355 | 355 | } |
|
356 | 356 | |
|
357 | 357 | int spacewire_configure_link( int fd ) |
|
358 | 358 | { |
|
359 | 359 | /** This function configures the SpaceWire link. |
|
360 | 360 | * |
|
361 | 361 | * @return GR-RTEMS-DRIVER directive status codes: |
|
362 | 362 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
363 | 363 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
364 | 364 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
365 | 365 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
366 | 366 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
367 | 367 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
368 | 368 | * - 2 ENOENT - No such file or directory |
|
369 | 369 | */ |
|
370 | 370 | |
|
371 | 371 | rtems_status_code status; |
|
372 | 372 | |
|
373 | 373 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
374 | 374 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
375 | 375 | |
|
376 | 376 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
377 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
|
377 | if (status!=RTEMS_SUCCESSFUL) { | |
|
378 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
|
379 | } | |
|
378 | 380 | // |
|
379 | 381 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
380 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
|
382 | if (status!=RTEMS_SUCCESSFUL) { | |
|
383 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
|
384 | } | |
|
381 | 385 | // |
|
382 | 386 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
383 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
|
387 | if (status!=RTEMS_SUCCESSFUL) { | |
|
388 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
|
389 | } | |
|
384 | 390 | // |
|
385 | 391 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
386 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
|
392 | if (status!=RTEMS_SUCCESSFUL) { | |
|
393 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
|
394 | } | |
|
387 | 395 | // |
|
388 | 396 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks |
|
389 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
|
397 | if (status!=RTEMS_SUCCESSFUL) { | |
|
398 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
|
399 | } | |
|
390 | 400 | // |
|
391 | 401 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
392 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
|
402 | if (status!=RTEMS_SUCCESSFUL) { | |
|
403 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
|
404 | } | |
|
393 | 405 | // |
|
394 | 406 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
395 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
|
407 | if (status!=RTEMS_SUCCESSFUL) { | |
|
408 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
|
409 | } | |
|
396 | 410 | |
|
397 | 411 | return status; |
|
398 | 412 | } |
|
399 | 413 | |
|
400 | 414 | int spacewire_reset_link( void ) |
|
401 | 415 | { |
|
402 | 416 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
403 | 417 | * |
|
404 | 418 | * @return RTEMS directive status code: |
|
405 | 419 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
406 | 420 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
407 | 421 | * |
|
408 | 422 | */ |
|
409 | 423 | |
|
410 | 424 | rtems_status_code status_spw; |
|
411 | 425 | int i; |
|
412 | 426 | |
|
413 | 427 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
414 | 428 | { |
|
415 | 429 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
416 | 430 | |
|
417 | 431 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
418 | 432 | |
|
419 | 433 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
420 | 434 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
421 | 435 | { |
|
422 | 436 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
423 | 437 | } |
|
424 | 438 | |
|
425 | 439 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
426 | 440 | { |
|
427 | 441 | break; |
|
428 | 442 | } |
|
429 | 443 | } |
|
430 | 444 | |
|
431 | 445 | return status_spw; |
|
432 | 446 | } |
|
433 | 447 | |
|
434 | 448 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
435 | 449 | { |
|
436 | 450 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
437 | 451 | * |
|
438 | 452 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
439 | 453 | * @param regAddr is the address of the GRSPW control register. |
|
440 | 454 | * |
|
441 | 455 | * NP is the bit 20 of the GRSPW control register. |
|
442 | 456 | * |
|
443 | 457 | */ |
|
444 | 458 | |
|
445 | 459 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
446 | 460 | |
|
447 | 461 | if (val == 1) { |
|
448 | 462 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
449 | 463 | } |
|
450 | 464 | if (val== 0) { |
|
451 | 465 | *spwptr = *spwptr & 0xffdfffff; |
|
452 | 466 | } |
|
453 | 467 | } |
|
454 | 468 | |
|
455 | 469 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
456 | 470 | { |
|
457 | 471 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
458 | 472 | * |
|
459 | 473 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
460 | 474 | * @param regAddr is the address of the GRSPW control register. |
|
461 | 475 | * |
|
462 | 476 | * RE is the bit 16 of the GRSPW control register. |
|
463 | 477 | * |
|
464 | 478 | */ |
|
465 | 479 | |
|
466 | 480 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
467 | 481 | |
|
468 | 482 | if (val == 1) |
|
469 | 483 | { |
|
470 | 484 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
471 | 485 | } |
|
472 | 486 | if (val== 0) |
|
473 | 487 | { |
|
474 | 488 | *spwptr = *spwptr & 0xfffdffff; |
|
475 | 489 | } |
|
476 | 490 | } |
|
477 | 491 | |
|
478 | 492 | void spacewire_compute_stats_offsets( void ) |
|
479 | 493 | { |
|
480 | 494 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
481 | 495 | * |
|
482 | 496 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
483 | 497 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
484 | 498 | * during the open systel call). |
|
485 | 499 | * |
|
486 | 500 | */ |
|
487 | 501 | |
|
488 | 502 | spw_stats spacewire_stats_grspw; |
|
489 | 503 | rtems_status_code status; |
|
490 | 504 | |
|
491 | 505 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
492 | 506 | |
|
493 | 507 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
494 | 508 | + spacewire_stats.packets_received; |
|
495 | 509 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
496 | 510 | + spacewire_stats.packets_sent; |
|
497 | 511 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
498 | 512 | + spacewire_stats.parity_err; |
|
499 | 513 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
500 | 514 | + spacewire_stats.disconnect_err; |
|
501 | 515 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
502 | 516 | + spacewire_stats.escape_err; |
|
503 | 517 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
504 | 518 | + spacewire_stats.credit_err; |
|
505 | 519 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
506 | 520 | + spacewire_stats.write_sync_err; |
|
507 | 521 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
508 | 522 | + spacewire_stats.rx_rmap_header_crc_err; |
|
509 | 523 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
510 | 524 | + spacewire_stats.rx_rmap_data_crc_err; |
|
511 | 525 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
512 | 526 | + spacewire_stats.early_ep; |
|
513 | 527 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
514 | 528 | + spacewire_stats.invalid_address; |
|
515 | 529 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
516 | 530 | + spacewire_stats.rx_eep_err; |
|
517 | 531 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
518 | 532 | + spacewire_stats.rx_truncated; |
|
519 | 533 | } |
|
520 | 534 | |
|
521 | 535 | void spacewire_update_statistics( void ) |
|
522 | 536 | { |
|
523 | 537 | rtems_status_code status; |
|
524 | 538 | spw_stats spacewire_stats_grspw; |
|
525 | 539 | |
|
526 | 540 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
527 | 541 | |
|
528 | 542 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
529 | 543 | + spacewire_stats_grspw.packets_received; |
|
530 | 544 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
531 | 545 | + spacewire_stats_grspw.packets_sent; |
|
532 | 546 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
533 | 547 | + spacewire_stats_grspw.parity_err; |
|
534 | 548 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
535 | 549 | + spacewire_stats_grspw.disconnect_err; |
|
536 | 550 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
537 | 551 | + spacewire_stats_grspw.escape_err; |
|
538 | 552 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
539 | 553 | + spacewire_stats_grspw.credit_err; |
|
540 | 554 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
541 | 555 | + spacewire_stats_grspw.write_sync_err; |
|
542 | 556 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
543 | 557 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
544 | 558 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
545 | 559 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
546 | 560 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
547 | 561 | + spacewire_stats_grspw.early_ep; |
|
548 | 562 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
549 | 563 | + spacewire_stats_grspw.invalid_address; |
|
550 | 564 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
551 | 565 | + spacewire_stats_grspw.rx_eep_err; |
|
552 | 566 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
553 | 567 | + spacewire_stats_grspw.rx_truncated; |
|
554 | 568 | //spacewire_stats.tx_link_err; |
|
555 | 569 | |
|
556 | 570 | //**************************** |
|
557 | 571 | // DPU_SPACEWIRE_IF_STATISTICS |
|
558 | 572 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
559 | 573 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
560 | 574 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
561 | 575 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
562 | 576 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
563 | 577 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
564 | 578 | |
|
565 | 579 | //****************************************** |
|
566 | 580 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
567 | 581 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
568 | 582 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
569 | 583 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
570 | 584 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
571 | 585 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
572 | 586 | |
|
573 | 587 | //********************************************* |
|
574 | 588 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
575 | 589 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
576 | 590 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
577 | 591 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
578 | 592 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
579 | 593 | } |
|
580 | 594 | |
|
581 | 595 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
582 | 596 | { |
|
583 | 597 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 ); |
|
584 | 598 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
585 | 599 | |
|
586 | 600 | grgpio_regs->io_port_direction_register = |
|
587 | 601 | grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled |
|
588 | 602 | |
|
589 | 603 | if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 ) |
|
590 | 604 | { |
|
591 | 605 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7; |
|
592 | 606 | } |
|
593 | 607 | else |
|
594 | 608 | { |
|
595 | 609 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08; |
|
596 | 610 | } |
|
597 | 611 | } |
|
598 | 612 | |
|
599 | 613 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
600 | 614 | { |
|
601 | 615 | int linkStatus; |
|
602 | 616 | rtems_status_code status; |
|
603 | 617 | |
|
604 | 618 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
605 | 619 | |
|
606 | 620 | if ( linkStatus == 5) { |
|
607 | 621 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
608 | 622 | status = RTEMS_SUCCESSFUL; |
|
609 | 623 | } |
|
610 | 624 | } |
@@ -1,145 +1,115 | |||
|
1 | 1 | /* |
|
2 | 2 | * CPU Usage Reporter |
|
3 | 3 | * |
|
4 | 4 | * COPYRIGHT (c) 1989-2009 |
|
5 | 5 | * On-Line Applications Research Corporation (OAR). |
|
6 | 6 | * |
|
7 | 7 | * The license and distribution terms for this file may be |
|
8 | 8 | * found in the file LICENSE in this distribution or at |
|
9 | 9 | * http://www.rtems.com/license/LICENSE. |
|
10 | 10 | * |
|
11 | 11 | * $Id$ |
|
12 | 12 | */ |
|
13 | 13 | |
|
14 | #ifdef HAVE_CONFIG_H | |
|
15 | #include "config.h" | |
|
16 | #endif | |
|
17 | ||
|
18 | #include <rtems.h> | |
|
19 | ||
|
20 | #include <assert.h> | |
|
21 | #include <string.h> | |
|
22 | #include <stdlib.h> | |
|
23 | #include <stdio.h> | |
|
24 | #include <ctype.h> | |
|
25 | #include <inttypes.h> | |
|
26 | ||
|
27 | #include <rtems/cpuuse.h> | |
|
28 | #include <rtems/bspIo.h> | |
|
29 | ||
|
30 | 14 | #include "lfr_cpu_usage_report.h" |
|
31 | 15 | |
|
32 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ | |
|
33 | #include <rtems/score/timestamp.h> | |
|
34 | #endif | |
|
35 | ||
|
36 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ | |
|
37 | extern Timestamp_Control CPU_usage_Uptime_at_last_reset; | |
|
38 | #else | |
|
39 | extern uint32_t CPU_usage_Ticks_at_last_reset; | |
|
40 | #endif | |
|
41 | ||
|
42 | /*PAGE | |
|
43 | * | |
|
44 | * rtems_cpu_usage_report | |
|
45 | */ | |
|
46 | ||
|
47 | 16 | unsigned char lfr_rtems_cpu_usage_report( void ) |
|
48 | 17 | { |
|
49 | 18 | uint32_t api_index; |
|
50 | 19 | Thread_Control *the_thread; |
|
51 | 20 | Objects_Information *information; |
|
52 | 21 | uint32_t ival, fval; |
|
53 | 22 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ |
|
54 |
Timestamp_Control uptime |
|
|
23 | Timestamp_Control uptime; | |
|
24 | Timestamp_Control total; | |
|
25 | Timestamp_Control ran; | |
|
55 | 26 | #else |
|
56 | 27 | uint32_t total_units = 0; |
|
57 | 28 | #endif |
|
58 | 29 | |
|
59 | 30 | unsigned char cpu_load; |
|
60 | 31 | cpu_load = 0; |
|
61 | 32 | |
|
62 | 33 | /* |
|
63 | 34 | * When not using nanosecond CPU usage resolution, we have to count |
|
64 | 35 | * the number of "ticks" we gave credit for to give the user a rough |
|
65 | 36 | * guideline as to what each number means proportionally. |
|
66 | 37 | */ |
|
67 | 38 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ |
|
68 | 39 | _TOD_Get_uptime( &uptime ); |
|
69 | 40 | _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total ); |
|
70 | 41 | #else |
|
71 | 42 | for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) { |
|
72 | if ( !_Objects_Information_table[ api_index ] ) | |
|
43 | if ( !_Objects_Information_table[ api_index ] ) { } | |
|
44 | else | |
|
73 | 45 | { |
|
74 | continue; | |
|
75 | } | |
|
76 | information = _Objects_Information_table[ api_index ][ 1 ]; | |
|
77 | if ( information ) | |
|
78 | { | |
|
79 | for ( i=1 ; i <= information->maximum ; i++ ) { | |
|
80 | the_thread = (Thread_Control *)information->local_table[ i ]; | |
|
46 | information = _Objects_Information_table[ api_index ][ 1 ]; | |
|
47 | if ( information != NULL ) | |
|
48 | { | |
|
49 | for ( i=1 ; i <= information->maximum ; i++ ) { | |
|
50 | the_thread = (Thread_Control *)information->local_table[ i ]; | |
|
81 | 51 | |
|
82 | if ( the_thread ) | |
|
83 | total_units += the_thread->cpu_time_used; | |
|
52 | if ( the_thread != NULL ) | |
|
53 | total_units += the_thread->cpu_time_used; | |
|
54 | } | |
|
84 | 55 | } |
|
85 | 56 | } |
|
86 | 57 | } |
|
87 | 58 | #endif |
|
88 | 59 | |
|
89 | 60 | for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) |
|
90 | 61 | { |
|
91 | if ( !_Objects_Information_table[ api_index ] ) | |
|
92 |
|
|
|
93 | continue; | |
|
94 | } | |
|
95 | information = _Objects_Information_table[ api_index ][ 1 ]; | |
|
96 | if ( information ) | |
|
62 | if ( !_Objects_Information_table[ api_index ] ) { } | |
|
63 | else | |
|
97 | 64 | { |
|
98 | the_thread = (Thread_Control *)information->local_table[ 1 ]; | |
|
99 | ||
|
100 | if ( !the_thread ) | |
|
101 | { | |
|
102 | continue; | |
|
103 | } | |
|
104 | ||
|
105 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ | |
|
106 | /* | |
|
107 | * If this is the currently executing thread, account for time | |
|
108 | * since the last context switch. | |
|
109 | */ | |
|
110 | ran = the_thread->cpu_time_used; | |
|
111 | if ( _Thread_Executing->Object.id == the_thread->Object.id ) | |
|
65 | information = _Objects_Information_table[ api_index ][ 1 ]; | |
|
66 | if ( information != NULL ) | |
|
112 | 67 | { |
|
113 | Timestamp_Control used; | |
|
114 | _Timestamp_Subtract( | |
|
115 | &_Thread_Time_of_last_context_switch, &uptime, &used | |
|
116 | ); | |
|
117 | _Timestamp_Add_to( &ran, &used ); | |
|
118 | } | |
|
119 | _Timestamp_Divide( &ran, &total, &ival, &fval ); | |
|
120 | ||
|
121 | #else | |
|
122 | if (total_units) | |
|
123 | { | |
|
124 | uint64_t ival_64; | |
|
68 | the_thread = (Thread_Control *)information->local_table[ 1 ]; | |
|
125 | 69 | |
|
126 | ival_64 = the_thread->cpu_time_used; | |
|
127 |
|
|
|
128 | ival = ival_64 / total_units; | |
|
70 | if ( the_thread == NULL ) { } | |
|
71 | else | |
|
72 | { | |
|
73 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ | |
|
74 | /* | |
|
75 | * If this is the currently executing thread, account for time | |
|
76 | * since the last context switch. | |
|
77 | */ | |
|
78 | ran = the_thread->cpu_time_used; | |
|
79 | if ( _Thread_Executing->Object.id == the_thread->Object.id ) | |
|
80 | { | |
|
81 | Timestamp_Control used; | |
|
82 | _Timestamp_Subtract( | |
|
83 | &_Thread_Time_of_last_context_switch, &uptime, &used | |
|
84 | ); | |
|
85 | _Timestamp_Add_to( &ran, &used ); | |
|
86 | } | |
|
87 | _Timestamp_Divide( &ran, &total, &ival, &fval ); | |
|
88 | ||
|
89 | #else | |
|
90 | if (total_units != 0) | |
|
91 | { | |
|
92 | uint64_t ival_64; | |
|
93 | ||
|
94 | ival_64 = the_thread->cpu_time_used; | |
|
95 | ival_64 *= 100000; | |
|
96 | ival = ival_64 / total_units; | |
|
97 | } | |
|
98 | else | |
|
99 | { | |
|
100 | ival = 0; | |
|
101 | } | |
|
102 | ||
|
103 | fval = ival % 1000; | |
|
104 | ival /= 1000; | |
|
105 | #endif | |
|
106 | } | |
|
129 | 107 | } |
|
130 | else | |
|
131 | { | |
|
132 | ival = 0; | |
|
133 | } | |
|
134 | ||
|
135 | fval = ival % 1000; | |
|
136 | ival /= 1000; | |
|
137 | #endif | |
|
138 | 108 | } |
|
139 | 109 | } |
|
140 | 110 | cpu_load = (unsigned char) (100 - ival); |
|
141 | 111 | |
|
142 | 112 | return cpu_load; |
|
143 | 113 | } |
|
144 | 114 | |
|
145 | 115 |
@@ -1,253 +1,255 | |||
|
1 | 1 | /** Functions related to data processing. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "avf2_prc2.h" |
|
11 | 11 | |
|
12 | 12 | nb_sm_before_bp_asm_f2 nb_sm_before_f2; |
|
13 | 13 | |
|
14 | 14 | //*** |
|
15 | 15 | // F2 |
|
16 | 16 | ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ]; |
|
17 | 17 | ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ]; |
|
18 | 18 | |
|
19 | 19 | float asm_f2_reorganized [ TOTAL_SIZE_SM ]; |
|
20 | 20 | char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; |
|
21 | 21 | float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2]; |
|
22 | 22 | float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ]; |
|
23 | 23 | |
|
24 | 24 | //************ |
|
25 | 25 | // RTEMS TASKS |
|
26 | 26 | |
|
27 | 27 | //*** |
|
28 | 28 | // F2 |
|
29 | 29 | rtems_task avf2_task( rtems_task_argument argument ) |
|
30 | 30 | { |
|
31 | 31 | rtems_event_set event_out; |
|
32 | 32 | rtems_status_code status; |
|
33 | 33 | rtems_id queue_id_prc2; |
|
34 | 34 | asm_msg msgForMATR; |
|
35 | 35 | ring_node_asm *current_ring_node_asm_norm_f2; |
|
36 | 36 | |
|
37 | 37 | unsigned int nb_norm_bp1; |
|
38 | 38 | unsigned int nb_norm_bp2; |
|
39 | 39 | unsigned int nb_norm_asm; |
|
40 | 40 | |
|
41 | 41 | nb_norm_bp1 = 0; |
|
42 | 42 | nb_norm_bp2 = 0; |
|
43 | 43 | nb_norm_asm = 0; |
|
44 | 44 | |
|
45 | 45 | reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
46 | 46 | ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 ); |
|
47 | 47 | current_ring_node_asm_norm_f2 = asm_ring_norm_f2; |
|
48 | 48 | |
|
49 | 49 | BOOT_PRINTF("in AVF2 ***\n") |
|
50 | 50 | |
|
51 | 51 | status = get_message_queue_id_prc2( &queue_id_prc2 ); |
|
52 | 52 | if (status != RTEMS_SUCCESSFUL) |
|
53 | 53 | { |
|
54 | 54 | PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | while(1){ |
|
58 | 58 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
59 | 59 | |
|
60 | 60 | //**************************************** |
|
61 | 61 | // initialize the mesage for the MATR task |
|
62 | 62 | msgForMATR.event = 0x00; // this composite event will be sent to the MATR task |
|
63 | 63 | msgForMATR.burst_sbm = NULL; |
|
64 | 64 | msgForMATR.norm = current_ring_node_asm_norm_f2; |
|
65 | 65 | msgForMATR.coarseTime = ring_node_for_averaging_sm_f2->coarseTime; |
|
66 | 66 | msgForMATR.fineTime = ring_node_for_averaging_sm_f2->fineTime; |
|
67 | 67 | // |
|
68 | 68 | //**************************************** |
|
69 | 69 | |
|
70 | 70 | // compute the average and store it in the averaged_sm_f2 buffer |
|
71 | 71 | SM_average_f2( current_ring_node_asm_norm_f2->matrix, |
|
72 | 72 | ring_node_for_averaging_sm_f2, |
|
73 | 73 | nb_norm_bp1 ); |
|
74 | 74 | |
|
75 | 75 | // update nb_average |
|
76 | 76 | nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2; |
|
77 | 77 | nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2; |
|
78 | 78 | nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2; |
|
79 | 79 | |
|
80 | 80 | if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1) |
|
81 | 81 | { |
|
82 | 82 | nb_norm_bp1 = 0; |
|
83 | 83 | // set another ring for the ASM storage |
|
84 | 84 | current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next; |
|
85 | 85 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
86 | 86 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
87 | 87 | { |
|
88 | 88 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2; |
|
89 | 89 | } |
|
90 | 90 | } |
|
91 | 91 | |
|
92 | 92 | if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2) |
|
93 | 93 | { |
|
94 | 94 | nb_norm_bp2 = 0; |
|
95 | 95 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
96 | 96 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
97 | 97 | { |
|
98 | 98 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2; |
|
99 | 99 | } |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | if (nb_norm_asm == nb_sm_before_f2.norm_asm) |
|
103 | 103 | { |
|
104 | 104 | nb_norm_asm = 0; |
|
105 | 105 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) |
|
106 | 106 | || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
107 | 107 | { |
|
108 | 108 | // PRINTF1("%lld\n", localTime) |
|
109 | 109 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2; |
|
110 | 110 | } |
|
111 | 111 | } |
|
112 | 112 | |
|
113 | 113 | //************************* |
|
114 | 114 | // send the message to MATR |
|
115 | 115 | if (msgForMATR.event != 0x00) |
|
116 | 116 | { |
|
117 | 117 | status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0); |
|
118 | 118 | } |
|
119 | 119 | |
|
120 | 120 | if (status != RTEMS_SUCCESSFUL) { |
|
121 | 121 | printf("in AVF2 *** Error sending message to MATR, code %d\n", status); |
|
122 | 122 | } |
|
123 | 123 | } |
|
124 | 124 | } |
|
125 | 125 | |
|
126 | 126 | rtems_task prc2_task( rtems_task_argument argument ) |
|
127 | 127 | { |
|
128 | 128 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
129 | 129 | size_t size; // size of the incoming TC packet |
|
130 | 130 | asm_msg *incomingMsg; |
|
131 | 131 | // |
|
132 | 132 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
133 | 133 | rtems_status_code status; |
|
134 | 134 | rtems_id queue_id; |
|
135 | 135 | rtems_id queue_id_q_p2; |
|
136 | 136 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
137 | 137 | bp_packet packet_norm_bp1_f2; |
|
138 | 138 | bp_packet packet_norm_bp2_f2; |
|
139 | 139 | |
|
140 | 140 | unsigned long long int localTime; |
|
141 | 141 | |
|
142 | incomingMsg = NULL; | |
|
143 | ||
|
142 | 144 | ASM_init_header( &headerASM ); |
|
143 | 145 | |
|
144 | 146 | //************* |
|
145 | 147 | // NORM headers |
|
146 | 148 | BP_init_header( &packet_norm_bp1_f2.header, |
|
147 | 149 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2, |
|
148 | 150 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
149 | 151 | BP_init_header( &packet_norm_bp2_f2.header, |
|
150 | 152 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2, |
|
151 | 153 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 ); |
|
152 | 154 | |
|
153 | 155 | status = get_message_queue_id_send( &queue_id ); |
|
154 | 156 | if (status != RTEMS_SUCCESSFUL) |
|
155 | 157 | { |
|
156 | 158 | PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status) |
|
157 | 159 | } |
|
158 | 160 | status = get_message_queue_id_prc2( &queue_id_q_p2); |
|
159 | 161 | if (status != RTEMS_SUCCESSFUL) |
|
160 | 162 | { |
|
161 | 163 | PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status) |
|
162 | 164 | } |
|
163 | 165 | |
|
164 | 166 | BOOT_PRINTF("in PRC2 ***\n") |
|
165 | 167 | |
|
166 | 168 | while(1){ |
|
167 | 169 | status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************ |
|
168 | 170 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 |
|
169 | 171 | |
|
170 | 172 | incomingMsg = (asm_msg*) incomingData; |
|
171 | 173 | |
|
172 | 174 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
173 | 175 | |
|
174 | 176 | //***** |
|
175 | 177 | //***** |
|
176 | 178 | // NORM |
|
177 | 179 | //***** |
|
178 | 180 | //***** |
|
179 | 181 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2) |
|
180 | 182 | { |
|
181 | 183 | // 1) compress the matrix for Basic Parameters calculation |
|
182 | 184 | ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2, |
|
183 | 185 | nb_sm_before_f2.norm_bp1, |
|
184 | 186 | NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2, |
|
185 | 187 | ASM_F2_INDICE_START ); |
|
186 | 188 | // 2) compute the BP1 set |
|
187 | 189 | |
|
188 | 190 | // 3) send the BP1 set |
|
189 | 191 | set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime ); |
|
190 | 192 | set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); |
|
191 | 193 | BP_send( (char *) &packet_norm_bp1_f2, queue_id, |
|
192 | 194 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA, |
|
193 | 195 | SID_NORM_BP1_F2 ); |
|
194 | 196 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2) |
|
195 | 197 | { |
|
196 | 198 | // 1) compute the BP2 set using the same ASM as the one used for BP1 |
|
197 | 199 | |
|
198 | 200 | // 2) send the BP2 set |
|
199 | 201 | set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime ); |
|
200 | 202 | set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); |
|
201 | 203 | BP_send( (char *) &packet_norm_bp2_f2, queue_id, |
|
202 | 204 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA, |
|
203 | 205 | SID_NORM_BP2_F2 ); |
|
204 | 206 | } |
|
205 | 207 | } |
|
206 | 208 | |
|
207 | 209 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2) |
|
208 | 210 | { |
|
209 | 211 | // 1) reorganize the ASM and divide |
|
210 | 212 | ASM_reorganize_and_divide( incomingMsg->norm->matrix, |
|
211 | 213 | asm_f2_reorganized, |
|
212 | 214 | nb_sm_before_f2.norm_bp1 ); |
|
213 | 215 | // 2) convert the float array in a char array |
|
214 | 216 | ASM_convert( asm_f2_reorganized, asm_f2_char); |
|
215 | 217 | // 3) send the spectral matrix packets |
|
216 | 218 | set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); |
|
217 | 219 | set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); |
|
218 | 220 | ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id); |
|
219 | 221 | } |
|
220 | 222 | |
|
221 | 223 | } |
|
222 | 224 | } |
|
223 | 225 | |
|
224 | 226 | //********** |
|
225 | 227 | // FUNCTIONS |
|
226 | 228 | |
|
227 | 229 | void reset_nb_sm_f2( void ) |
|
228 | 230 | { |
|
229 | 231 | nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0; |
|
230 | 232 | nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1; |
|
231 | 233 | nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]; |
|
232 | 234 | } |
|
233 | 235 | |
|
234 | 236 | void SM_average_f2( float *averaged_spec_mat_f2, |
|
235 | 237 | ring_node_sm *ring_node, |
|
236 | 238 | unsigned int nbAverageNormF2 ) |
|
237 | 239 | { |
|
238 | 240 | float sum; |
|
239 | 241 | unsigned int i; |
|
240 | 242 | |
|
241 | 243 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
242 | 244 | { |
|
243 | 245 | sum = ( (int *) (ring_node->buffer_address) ) [ i ]; |
|
244 | 246 | if ( (nbAverageNormF2 == 0) ) |
|
245 | 247 | { |
|
246 | 248 | averaged_spec_mat_f2[ i ] = sum; |
|
247 | 249 | } |
|
248 | 250 | else |
|
249 | 251 | { |
|
250 | 252 | averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum ); |
|
251 | 253 | } |
|
252 | 254 | } |
|
253 | 255 | } |
@@ -1,689 +1,696 | |||
|
1 | 1 | /** Functions related to data processing. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "fsw_processing.h" |
|
11 | 11 | #include "fsw_processing_globals.c" |
|
12 | 12 | |
|
13 | 13 | unsigned int nb_sm_f0; |
|
14 | 14 | unsigned int nb_sm_f0_aux_f1; |
|
15 | 15 | unsigned int nb_sm_f1; |
|
16 | 16 | unsigned int nb_sm_f0_aux_f2; |
|
17 | 17 | |
|
18 | 18 | //************************ |
|
19 | 19 | // spectral matrices rings |
|
20 | 20 | ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ]; |
|
21 | 21 | ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ]; |
|
22 | 22 | ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ]; |
|
23 | 23 | ring_node_sm *current_ring_node_sm_f0; |
|
24 | 24 | ring_node_sm *current_ring_node_sm_f1; |
|
25 | 25 | ring_node_sm *current_ring_node_sm_f2; |
|
26 | 26 | ring_node_sm *ring_node_for_averaging_sm_f0; |
|
27 | 27 | ring_node_sm *ring_node_for_averaging_sm_f1; |
|
28 | 28 | ring_node_sm *ring_node_for_averaging_sm_f2; |
|
29 | 29 | |
|
30 | 30 | //*********************************************************** |
|
31 | 31 | // Interrupt Service Routine for spectral matrices processing |
|
32 | 32 | |
|
33 | 33 | void spectral_matrices_isr_f0( void ) |
|
34 | 34 | { |
|
35 | 35 | unsigned char status; |
|
36 | 36 | unsigned long long int time_0; |
|
37 | 37 | unsigned long long int time_1; |
|
38 | 38 | unsigned long long int syncBit0; |
|
39 | 39 | unsigned long long int syncBit1; |
|
40 | 40 | |
|
41 | 41 | status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits |
|
42 | 42 | |
|
43 | 43 | time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time ); |
|
44 | 44 | time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time ); |
|
45 | 45 | syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16; |
|
46 | 46 | syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16; |
|
47 | 47 | |
|
48 | 48 | switch(status) |
|
49 | 49 | { |
|
50 | 50 | case 0: |
|
51 | 51 | break; |
|
52 | 52 | case 3: |
|
53 | 53 | if ( time_0 < time_1 ) |
|
54 | 54 | { |
|
55 | 55 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
56 | 56 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0); |
|
57 | 57 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
58 | 58 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
59 | 59 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
60 | 60 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1); |
|
61 | 61 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
62 | 62 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
67 | 67 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1); |
|
68 | 68 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
69 | 69 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
70 | 70 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
71 | 71 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0); |
|
72 | 72 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
73 | 73 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
74 | 74 | } |
|
75 | 75 | spectral_matrix_regs->status = 0x03; // [0011] |
|
76 | 76 | break; |
|
77 | 77 | case 1: |
|
78 | 78 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
79 | 79 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0); |
|
80 | 80 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
81 | 81 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
82 | 82 | spectral_matrix_regs->status = 0x01; // [0001] |
|
83 | 83 | break; |
|
84 | 84 | case 2: |
|
85 | 85 | close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], |
|
86 | 86 | ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1); |
|
87 | 87 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
88 | 88 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
89 | 89 | spectral_matrix_regs->status = 0x02; // [0010] |
|
90 | 90 | break; |
|
91 | 91 | } |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | void spectral_matrices_isr_f1( void ) |
|
95 | 95 | { |
|
96 | 96 | unsigned char status; |
|
97 | 97 | unsigned long long int time; |
|
98 | 98 | unsigned long long int syncBit; |
|
99 | rtems_status_code status_code; | |
|
99 | 100 | |
|
100 | 101 | status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits |
|
101 | 102 | |
|
102 | 103 | switch(status) |
|
103 | 104 | { |
|
104 | 105 | case 0: |
|
105 | 106 | break; |
|
106 | 107 | case 3: |
|
107 | 108 | // UNEXPECTED VALUE |
|
108 | 109 | spectral_matrix_regs->status = 0xc0; // [1100] |
|
109 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
|
110 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
|
110 | 111 | break; |
|
111 | 112 | case 1: |
|
112 | 113 | time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time ); |
|
113 | 114 | syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16; |
|
114 | 115 | close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], |
|
115 | 116 | ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit); |
|
116 | 117 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
117 | 118 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; |
|
118 | 119 | spectral_matrix_regs->status = 0x04; // [0100] |
|
119 | 120 | break; |
|
120 | 121 | case 2: |
|
121 | 122 | time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time ); |
|
122 | 123 | syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16; |
|
123 | 124 | close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], |
|
124 | 125 | ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit); |
|
125 | 126 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
126 | 127 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
127 | 128 | spectral_matrix_regs->status = 0x08; // [1000] |
|
128 | 129 | break; |
|
129 | 130 | } |
|
130 | 131 | } |
|
131 | 132 | |
|
132 | 133 | void spectral_matrices_isr_f2( void ) |
|
133 | 134 | { |
|
134 | 135 | unsigned char status; |
|
136 | rtems_status_code status_code; | |
|
135 | 137 | |
|
136 | 138 | status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits |
|
137 | 139 | |
|
138 | 140 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; |
|
139 | 141 | |
|
140 | 142 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
141 | 143 | |
|
142 | 144 | switch(status) |
|
143 | 145 | { |
|
144 | 146 | case 0: |
|
145 | 147 | break; |
|
146 | 148 | case 3: |
|
147 | 149 | // UNEXPECTED VALUE |
|
148 | 150 | spectral_matrix_regs->status = 0x30; // [0011 0000] |
|
149 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
|
151 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
|
150 | 152 | break; |
|
151 | 153 | case 1: |
|
152 | 154 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; |
|
153 | 155 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; |
|
154 | 156 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; |
|
155 | 157 | spectral_matrix_regs->status = 0x10; // [0001 0000] |
|
156 | 158 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
157 | 159 | { |
|
158 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
160 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
159 | 161 | } |
|
160 | 162 | break; |
|
161 | 163 | case 2: |
|
162 | 164 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; |
|
163 | 165 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; |
|
164 | 166 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
165 | 167 | spectral_matrix_regs->status = 0x20; // [0010 0000] |
|
166 | 168 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
167 | 169 | { |
|
168 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
170 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
169 | 171 | } |
|
170 | 172 | break; |
|
171 | 173 | } |
|
172 | 174 | } |
|
173 | 175 | |
|
174 | 176 | void spectral_matrix_isr_error_handler( void ) |
|
175 | 177 | { |
|
178 | rtems_status_code status_code; | |
|
179 | ||
|
176 | 180 | if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000] |
|
177 | 181 | { |
|
178 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
|
182 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
|
179 | 183 | } |
|
180 | 184 | } |
|
181 | 185 | |
|
182 | 186 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
183 | 187 | { |
|
184 | 188 | // STATUS REGISTER |
|
185 | 189 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) |
|
186 | 190 | // 10 9 8 |
|
187 | 191 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 |
|
188 | 192 | // 7 6 5 4 3 2 1 0 |
|
189 | 193 | |
|
190 | 194 | spectral_matrices_isr_f0(); |
|
191 | 195 | |
|
192 | 196 | spectral_matrices_isr_f1(); |
|
193 | 197 | |
|
194 | 198 | spectral_matrices_isr_f2(); |
|
195 | 199 | |
|
196 | 200 | // spectral_matrix_isr_error_handler(); |
|
197 | 201 | } |
|
198 | 202 | |
|
199 | 203 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
200 | 204 | { |
|
205 | rtems_status_code status_code; | |
|
206 | ||
|
201 | 207 | //*** |
|
202 | 208 | // F0 |
|
203 | 209 | nb_sm_f0 = nb_sm_f0 + 1; |
|
204 | 210 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) |
|
205 | 211 | { |
|
206 | 212 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; |
|
207 | 213 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
208 | 214 | { |
|
209 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
215 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
210 | 216 | } |
|
211 | 217 | nb_sm_f0 = 0; |
|
212 | 218 | } |
|
213 | 219 | |
|
214 | 220 | //*** |
|
215 | 221 | // F1 |
|
216 | 222 | nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; |
|
217 | 223 | if (nb_sm_f0_aux_f1 == 6) |
|
218 | 224 | { |
|
219 | 225 | nb_sm_f0_aux_f1 = 0; |
|
220 | 226 | nb_sm_f1 = nb_sm_f1 + 1; |
|
221 | 227 | } |
|
222 | 228 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) |
|
223 | 229 | { |
|
224 | 230 | ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; |
|
225 | 231 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
226 | 232 | { |
|
227 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
233 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
228 | 234 | } |
|
229 | 235 | nb_sm_f1 = 0; |
|
230 | 236 | } |
|
231 | 237 | |
|
232 | 238 | //*** |
|
233 | 239 | // F2 |
|
234 | 240 | nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; |
|
235 | 241 | if (nb_sm_f0_aux_f2 == 96) |
|
236 | 242 | { |
|
237 | 243 | nb_sm_f0_aux_f2 = 0; |
|
238 | 244 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; |
|
239 | 245 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
240 | 246 | { |
|
241 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
247 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
242 | 248 | } |
|
243 | 249 | } |
|
244 | 250 | } |
|
245 | 251 | |
|
246 | 252 | //****************** |
|
247 | 253 | // Spectral Matrices |
|
248 | 254 | |
|
249 | 255 | void reset_nb_sm( void ) |
|
250 | 256 | { |
|
251 | 257 | nb_sm_f0 = 0; |
|
252 | 258 | nb_sm_f0_aux_f1 = 0; |
|
253 | 259 | nb_sm_f0_aux_f2 = 0; |
|
254 | 260 | |
|
255 | 261 | nb_sm_f1 = 0; |
|
256 | 262 | } |
|
257 | 263 | |
|
258 | 264 | void SM_init_rings( void ) |
|
259 | 265 | { |
|
260 | 266 | unsigned char i; |
|
261 | 267 | |
|
262 | 268 | // F0 RING |
|
263 | 269 | sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1]; |
|
264 | 270 | sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1]; |
|
265 | 271 | sm_ring_f0[0].buffer_address = |
|
266 | 272 | (int) &sm_f0[ 0 ]; |
|
267 | 273 | |
|
268 | 274 | sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0]; |
|
269 | 275 | sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2]; |
|
270 | 276 | sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address = |
|
271 | 277 | (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ]; |
|
272 | 278 | |
|
273 | 279 | for(i=1; i<NB_RING_NODES_SM_F0-1; i++) |
|
274 | 280 | { |
|
275 | 281 | sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1]; |
|
276 | 282 | sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1]; |
|
277 | 283 | sm_ring_f0[i].buffer_address = |
|
278 | 284 | (int) &sm_f0[ i * TOTAL_SIZE_SM ]; |
|
279 | 285 | } |
|
280 | 286 | |
|
281 | 287 | // F1 RING |
|
282 | 288 | sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1]; |
|
283 | 289 | sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1]; |
|
284 | 290 | sm_ring_f1[0].buffer_address = |
|
285 | 291 | (int) &sm_f1[ 0 ]; |
|
286 | 292 | |
|
287 | 293 | sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0]; |
|
288 | 294 | sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2]; |
|
289 | 295 | sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address = |
|
290 | 296 | (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ]; |
|
291 | 297 | |
|
292 | 298 | for(i=1; i<NB_RING_NODES_SM_F1-1; i++) |
|
293 | 299 | { |
|
294 | 300 | sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1]; |
|
295 | 301 | sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1]; |
|
296 | 302 | sm_ring_f1[i].buffer_address = |
|
297 | 303 | (int) &sm_f1[ i * TOTAL_SIZE_SM ]; |
|
298 | 304 | } |
|
299 | 305 | |
|
300 | 306 | // F2 RING |
|
301 | 307 | sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1]; |
|
302 | 308 | sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1]; |
|
303 | 309 | sm_ring_f2[0].buffer_address = |
|
304 | 310 | (int) &sm_f2[ 0 ]; |
|
305 | 311 | |
|
306 | 312 | sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0]; |
|
307 | 313 | sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2]; |
|
308 | 314 | sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address = |
|
309 | 315 | (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ]; |
|
310 | 316 | |
|
311 | 317 | for(i=1; i<NB_RING_NODES_SM_F2-1; i++) |
|
312 | 318 | { |
|
313 | 319 | sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1]; |
|
314 | 320 | sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1]; |
|
315 | 321 | sm_ring_f2[i].buffer_address = |
|
316 | 322 | (int) &sm_f2[ i * TOTAL_SIZE_SM ]; |
|
317 | 323 | } |
|
318 | 324 | |
|
319 | 325 | DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) |
|
320 | 326 | DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) |
|
321 | 327 | DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) |
|
322 | 328 | |
|
323 | 329 | spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address; |
|
324 | 330 | DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address) |
|
325 | 331 | } |
|
326 | 332 | |
|
327 | 333 | void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] ) |
|
328 | 334 | { |
|
329 | 335 | unsigned char i; |
|
330 | 336 | |
|
331 | 337 | //*************** |
|
332 | 338 | // BUFFER ADDRESS |
|
333 | 339 | for(i=0; i<nbNodes; i++) |
|
334 | 340 | { |
|
335 | 341 | ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ]; |
|
336 | 342 | } |
|
337 | 343 | |
|
338 | 344 | //***** |
|
339 | 345 | // NEXT |
|
340 | 346 | ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ]; |
|
341 | 347 | for(i=0; i<nbNodes-1; i++) |
|
342 | 348 | { |
|
343 | 349 | ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ]; |
|
344 | 350 | } |
|
345 | 351 | |
|
346 | 352 | //********* |
|
347 | 353 | // PREVIOUS |
|
348 | 354 | ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ]; |
|
349 | 355 | for(i=1; i<nbNodes; i++) |
|
350 | 356 | { |
|
351 | 357 | ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ]; |
|
352 | 358 | } |
|
353 | 359 | } |
|
354 | 360 | |
|
355 | 361 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) |
|
356 | 362 | { |
|
357 | 363 | unsigned char i; |
|
358 | 364 | |
|
359 | 365 | ring[ nbNodes - 1 ].next |
|
360 | 366 | = (ring_node_asm*) &ring[ 0 ]; |
|
361 | 367 | |
|
362 | 368 | for(i=0; i<nbNodes-1; i++) |
|
363 | 369 | { |
|
364 | 370 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; |
|
365 | 371 | } |
|
366 | 372 | } |
|
367 | 373 | |
|
368 | 374 | void SM_reset_current_ring_nodes( void ) |
|
369 | 375 | { |
|
370 | 376 | current_ring_node_sm_f0 = sm_ring_f0[0].next; |
|
371 | 377 | current_ring_node_sm_f1 = sm_ring_f1[0].next; |
|
372 | 378 | current_ring_node_sm_f2 = sm_ring_f2[0].next; |
|
373 | 379 | |
|
374 | 380 | ring_node_for_averaging_sm_f0 = sm_ring_f0; |
|
375 | 381 | ring_node_for_averaging_sm_f1 = sm_ring_f1; |
|
376 | 382 | ring_node_for_averaging_sm_f2 = sm_ring_f2; |
|
377 | 383 | } |
|
378 | 384 | |
|
379 | 385 | void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header) |
|
380 | 386 | { |
|
381 | 387 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
382 | 388 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
383 | 389 | header->reserved = 0x00; |
|
384 | 390 | header->userApplication = CCSDS_USER_APP; |
|
385 | 391 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
386 | 392 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
387 | 393 | header->packetSequenceControl[0] = 0xc0; |
|
388 | 394 | header->packetSequenceControl[1] = 0x00; |
|
389 | 395 | header->packetLength[0] = 0x00; |
|
390 | 396 | header->packetLength[1] = 0x00; |
|
391 | 397 | // DATA FIELD HEADER |
|
392 | 398 | header->spare1_pusVersion_spare2 = 0x10; |
|
393 | 399 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
394 | 400 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
395 | 401 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
396 | 402 | // AUXILIARY DATA HEADER |
|
397 | 403 | header->sid = 0x00; |
|
398 | 404 | header->biaStatusInfo = 0x00; |
|
399 | 405 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
400 | 406 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
401 | 407 | header->time[0] = 0x00; |
|
402 | 408 | header->time[0] = 0x00; |
|
403 | 409 | header->time[0] = 0x00; |
|
404 | 410 | header->time[0] = 0x00; |
|
405 | 411 | header->time[0] = 0x00; |
|
406 | 412 | header->time[0] = 0x00; |
|
407 | 413 | header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB |
|
408 | 414 | header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB |
|
409 | 415 | } |
|
410 | 416 | |
|
411 | 417 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
412 | 418 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id) |
|
413 | 419 | { |
|
414 | 420 | unsigned int i; |
|
415 | 421 | unsigned int length = 0; |
|
416 | 422 | rtems_status_code status; |
|
417 | 423 | |
|
418 | 424 | for (i=0; i<2; i++) |
|
419 | 425 | { |
|
420 | 426 | // (1) BUILD THE DATA |
|
421 | 427 | switch(sid) |
|
422 | 428 | { |
|
423 | 429 | case SID_NORM_ASM_F0: |
|
424 | 430 | spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent |
|
425 | 431 | spw_ioctl_send->data = &spectral_matrix[ |
|
426 | 432 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2 |
|
427 | 433 | ]; |
|
428 | 434 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0; |
|
429 | 435 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB |
|
430 | 436 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB |
|
431 | 437 | break; |
|
432 | 438 | case SID_NORM_ASM_F1: |
|
433 | 439 | spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent |
|
434 | 440 | spw_ioctl_send->data = &spectral_matrix[ |
|
435 | 441 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2 |
|
436 | 442 | ]; |
|
437 | 443 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1; |
|
438 | 444 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB |
|
439 | 445 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB |
|
440 | 446 | break; |
|
441 | 447 | case SID_NORM_ASM_F2: |
|
442 | 448 | spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent |
|
443 | 449 | spw_ioctl_send->data = &spectral_matrix[ |
|
444 | 450 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2 |
|
445 | 451 | ]; |
|
446 | 452 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
447 | 453 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
448 | 454 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
449 | 455 | break; |
|
450 | 456 | default: |
|
451 | 457 | PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid) |
|
452 | 458 | break; |
|
453 | 459 | } |
|
454 | 460 | spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
455 | 461 | spw_ioctl_send->hdr = (char *) header; |
|
456 | 462 | spw_ioctl_send->options = 0; |
|
457 | 463 | |
|
458 | 464 | // (2) BUILD THE HEADER |
|
459 | 465 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
460 | 466 | header->packetLength[0] = (unsigned char) (length>>8); |
|
461 | 467 | header->packetLength[1] = (unsigned char) (length); |
|
462 | 468 | header->sid = (unsigned char) sid; // SID |
|
463 | 469 | header->pa_lfr_pkt_cnt_asm = 2; |
|
464 | 470 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
465 | 471 | |
|
466 | 472 | // (3) SET PACKET TIME |
|
467 | 473 | header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
468 | 474 | header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
469 | 475 | header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
470 | 476 | header->time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
471 | 477 | header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
472 | 478 | header->time[5] = (unsigned char) (time_management_regs->fine_time); |
|
473 | 479 | // |
|
474 | 480 | header->acquisitionTime[0] = header->time[0]; |
|
475 | 481 | header->acquisitionTime[1] = header->time[1]; |
|
476 | 482 | header->acquisitionTime[2] = header->time[2]; |
|
477 | 483 | header->acquisitionTime[3] = header->time[3]; |
|
478 | 484 | header->acquisitionTime[4] = header->time[4]; |
|
479 | 485 | header->acquisitionTime[5] = header->time[5]; |
|
480 | 486 | |
|
481 | 487 | // (4) SEND PACKET |
|
482 | 488 | status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
483 | 489 | if (status != RTEMS_SUCCESSFUL) { |
|
484 | 490 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
485 | 491 | } |
|
486 | 492 | } |
|
487 | 493 | } |
|
488 | 494 | |
|
489 | 495 | //***************** |
|
490 | 496 | // Basic Parameters |
|
491 | 497 | |
|
492 | 498 | void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header, |
|
493 | 499 | unsigned int apid, unsigned char sid, |
|
494 | 500 | unsigned int packetLength, unsigned char blkNr ) |
|
495 | 501 | { |
|
496 | 502 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
497 | 503 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
498 | 504 | header->reserved = 0x00; |
|
499 | 505 | header->userApplication = CCSDS_USER_APP; |
|
500 | 506 | header->packetID[0] = (unsigned char) (apid >> 8); |
|
501 | 507 | header->packetID[1] = (unsigned char) (apid); |
|
502 | 508 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
503 | 509 | header->packetSequenceControl[1] = 0x00; |
|
504 | 510 | header->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
505 | 511 | header->packetLength[1] = (unsigned char) (packetLength); |
|
506 | 512 | // DATA FIELD HEADER |
|
507 | 513 | header->spare1_pusVersion_spare2 = 0x10; |
|
508 | 514 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
509 | 515 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
510 | 516 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
511 | 517 | // AUXILIARY DATA HEADER |
|
512 | 518 | header->sid = sid; |
|
513 | 519 | header->biaStatusInfo = 0x00; |
|
514 | 520 | header->time[0] = 0x00; |
|
515 | 521 | header->time[0] = 0x00; |
|
516 | 522 | header->time[0] = 0x00; |
|
517 | 523 | header->time[0] = 0x00; |
|
518 | 524 | header->time[0] = 0x00; |
|
519 | 525 | header->time[0] = 0x00; |
|
520 | 526 | header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
521 | 527 | header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
522 | 528 | } |
|
523 | 529 | |
|
524 | 530 | void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, |
|
525 | 531 | unsigned int apid, unsigned char sid, |
|
526 | 532 | unsigned int packetLength , unsigned char blkNr) |
|
527 | 533 | { |
|
528 | 534 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
529 | 535 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
530 | 536 | header->reserved = 0x00; |
|
531 | 537 | header->userApplication = CCSDS_USER_APP; |
|
532 | 538 | header->packetID[0] = (unsigned char) (apid >> 8); |
|
533 | 539 | header->packetID[1] = (unsigned char) (apid); |
|
534 | 540 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
535 | 541 | header->packetSequenceControl[1] = 0x00; |
|
536 | 542 | header->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
537 | 543 | header->packetLength[1] = (unsigned char) (packetLength); |
|
538 | 544 | // DATA FIELD HEADER |
|
539 | 545 | header->spare1_pusVersion_spare2 = 0x10; |
|
540 | 546 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
541 | 547 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
542 | 548 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
543 | 549 | // AUXILIARY DATA HEADER |
|
544 | 550 | header->sid = sid; |
|
545 | 551 | header->biaStatusInfo = 0x00; |
|
546 | 552 | header->time[0] = 0x00; |
|
547 | 553 | header->time[0] = 0x00; |
|
548 | 554 | header->time[0] = 0x00; |
|
549 | 555 | header->time[0] = 0x00; |
|
550 | 556 | header->time[0] = 0x00; |
|
551 | 557 | header->time[0] = 0x00; |
|
552 | 558 | header->source_data_spare = 0x00; |
|
553 | 559 | header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
554 | 560 | header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
555 | 561 | } |
|
556 | 562 | |
|
557 | 563 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) |
|
558 | 564 | { |
|
559 | 565 | rtems_status_code status; |
|
560 | 566 | |
|
561 | 567 | // SET THE SEQUENCE_CNT PARAMETER |
|
562 | 568 | increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid ); |
|
563 | 569 | // SEND PACKET |
|
564 | 570 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
565 | 571 | if (status != RTEMS_SUCCESSFUL) |
|
566 | 572 | { |
|
567 | 573 | printf("ERR *** in BP_send *** ERR %d\n", (int) status); |
|
568 | 574 | } |
|
569 | 575 | } |
|
570 | 576 | |
|
571 | 577 | //****************** |
|
572 | 578 | // general functions |
|
573 | 579 | |
|
574 | 580 | void reset_spectral_matrix_regs( void ) |
|
575 | 581 | { |
|
576 | 582 | /** This function resets the spectral matrices module registers. |
|
577 | 583 | * |
|
578 | 584 | * The registers affected by this function are located at the following offset addresses: |
|
579 | 585 | * |
|
580 | 586 | * - 0x00 config |
|
581 | 587 | * - 0x04 status |
|
582 | 588 | * - 0x08 matrixF0_Address0 |
|
583 | 589 | * - 0x10 matrixFO_Address1 |
|
584 | 590 | * - 0x14 matrixF1_Address |
|
585 | 591 | * - 0x18 matrixF2_Address |
|
586 | 592 | * |
|
587 | 593 | */ |
|
588 | 594 | |
|
589 | 595 | spectral_matrix_regs->config = 0x00; |
|
590 | 596 | spectral_matrix_regs->status = 0x00; |
|
591 | 597 | |
|
592 | 598 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; |
|
593 | 599 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
594 | 600 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; |
|
595 | 601 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
596 | 602 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; |
|
597 | 603 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
598 | 604 | } |
|
599 | 605 | |
|
600 | 606 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) |
|
601 | 607 | { |
|
602 | 608 | time[0] = timeInBuffer[0]; |
|
603 | 609 | time[1] = timeInBuffer[1]; |
|
604 | 610 | time[2] = timeInBuffer[2]; |
|
605 | 611 | time[3] = timeInBuffer[3]; |
|
606 | 612 | time[4] = timeInBuffer[6]; |
|
607 | 613 | time[5] = timeInBuffer[7]; |
|
608 | 614 | } |
|
609 | 615 | |
|
610 | 616 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) |
|
611 | 617 | { |
|
612 | 618 | unsigned long long int acquisitionTimeAslong; |
|
613 | 619 | acquisitionTimeAslong = 0x00; |
|
614 | 620 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
615 | 621 | + ( (unsigned long long int) timePtr[1] << 32 ) |
|
616 | 622 | + ( (unsigned long long int) timePtr[2] << 24 ) |
|
617 | 623 | + ( (unsigned long long int) timePtr[3] << 16 ) |
|
618 | 624 | + ( (unsigned long long int) timePtr[6] << 8 ) |
|
619 | 625 | + ( (unsigned long long int) timePtr[7] ); |
|
620 | 626 | return acquisitionTimeAslong; |
|
621 | 627 | } |
|
622 | 628 | |
|
623 | void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id, | |
|
629 | void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id, | |
|
624 | 630 | ring_node_sm *node_for_averaging, ring_node_sm *ringNode, |
|
625 | 631 | unsigned long long int time ) |
|
626 | 632 | { |
|
627 | 633 | unsigned char *timePtr; |
|
628 | 634 | unsigned char *coarseTimePtr; |
|
629 | 635 | unsigned char *fineTimePtr; |
|
636 | rtems_status_code status_code; | |
|
630 | 637 | |
|
631 | 638 | timePtr = (unsigned char *) &time; |
|
632 | 639 | coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime; |
|
633 | 640 | fineTimePtr = (unsigned char *) &node_for_averaging->fineTime; |
|
634 | 641 | |
|
635 | 642 | *nb_sm = *nb_sm + 1; |
|
636 | 643 | if (*nb_sm == nb_sm_before_avf) |
|
637 | 644 | { |
|
638 | 645 | node_for_averaging = ringNode; |
|
639 | 646 | coarseTimePtr[0] = timePtr[2]; |
|
640 | 647 | coarseTimePtr[1] = timePtr[3]; |
|
641 | 648 | coarseTimePtr[2] = timePtr[4]; |
|
642 | 649 | coarseTimePtr[3] = timePtr[5]; |
|
643 | 650 | fineTimePtr[2] = timePtr[6]; |
|
644 | 651 | fineTimePtr[3] = timePtr[7]; |
|
645 | if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
|
652 | if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
|
646 | 653 | { |
|
647 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
654 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
648 | 655 | } |
|
649 | 656 | *nb_sm = 0; |
|
650 | 657 | } |
|
651 | 658 | } |
|
652 | 659 | |
|
653 | 660 | unsigned char getSID( rtems_event_set event ) |
|
654 | 661 | { |
|
655 | 662 | unsigned char sid; |
|
656 | 663 | |
|
657 | 664 | rtems_event_set eventSetBURST; |
|
658 | 665 | rtems_event_set eventSetSBM; |
|
659 | 666 | |
|
660 | 667 | //****** |
|
661 | 668 | // BURST |
|
662 | 669 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 |
|
663 | 670 | | RTEMS_EVENT_BURST_BP1_F1 |
|
664 | 671 | | RTEMS_EVENT_BURST_BP2_F0 |
|
665 | 672 | | RTEMS_EVENT_BURST_BP2_F1; |
|
666 | 673 | |
|
667 | 674 | //**** |
|
668 | 675 | // SBM |
|
669 | 676 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 |
|
670 | 677 | | RTEMS_EVENT_SBM_BP1_F1 |
|
671 | 678 | | RTEMS_EVENT_SBM_BP2_F0 |
|
672 | 679 | | RTEMS_EVENT_SBM_BP2_F1; |
|
673 | 680 | |
|
674 | 681 | if (event & eventSetBURST) |
|
675 | 682 | { |
|
676 | 683 | sid = SID_BURST_BP1_F0; |
|
677 | 684 | } |
|
678 | 685 | else if (event & eventSetSBM) |
|
679 | 686 | { |
|
680 | 687 | sid = SID_SBM1_BP1_F0; |
|
681 | 688 | } |
|
682 | 689 | else |
|
683 | 690 | { |
|
684 | 691 | sid = 0; |
|
685 | 692 | } |
|
686 | 693 | |
|
687 | 694 | return sid; |
|
688 | 695 | } |
|
689 | 696 |
@@ -1,948 +1,949 | |||
|
1 | 1 | /** Functions and tasks related to TeleCommand handling. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TeleCommands:\n |
|
7 | 7 | * action launching\n |
|
8 | 8 | * TC parsing\n |
|
9 | 9 | * ... |
|
10 | 10 | * |
|
11 | 11 | */ |
|
12 | 12 | |
|
13 | 13 | #include "tc_handler.h" |
|
14 | 14 | |
|
15 | 15 | //*********** |
|
16 | 16 | // RTEMS TASK |
|
17 | 17 | |
|
18 | 18 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | 19 | { |
|
20 | 20 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | 21 | * |
|
22 | 22 | * @param unused is the starting argument of the RTEMS task |
|
23 | 23 | * |
|
24 | 24 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | 25 | * on the incoming TeleCommand. |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | int result; |
|
30 | 30 | rtems_status_code status; // RTEMS status code |
|
31 | 31 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | 32 | size_t size; // size of the incoming TC packet |
|
33 | 33 | unsigned char subtype; // subtype of the current TC packet |
|
34 | 34 | unsigned char time[6]; |
|
35 | 35 | rtems_id queue_rcv_id; |
|
36 | 36 | rtems_id queue_snd_id; |
|
37 | 37 | |
|
38 | 38 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | 39 | if (status != RTEMS_SUCCESSFUL) |
|
40 | 40 | { |
|
41 | 41 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | 45 | if (status != RTEMS_SUCCESSFUL) |
|
46 | 46 | { |
|
47 | 47 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | result = LFR_SUCCESSFUL; |
|
51 | 51 | subtype = 0; // subtype of the current TC packet |
|
52 | 52 | |
|
53 | 53 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | 54 | |
|
55 | 55 | while(1) |
|
56 | 56 | { |
|
57 | 57 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | 58 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | 59 | getTime( time ); // set time to the current time |
|
60 | 60 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | 61 | { |
|
62 | 62 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | subtype = TC.serviceSubType; |
|
67 | 67 | switch(subtype) |
|
68 | 68 | { |
|
69 | 69 | case TC_SUBTYPE_RESET: |
|
70 | 70 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | 71 | close_action( &TC, result, queue_snd_id ); |
|
72 | 72 | break; |
|
73 | 73 | // |
|
74 | 74 | case TC_SUBTYPE_LOAD_COMM: |
|
75 | 75 | result = action_load_common_par( &TC ); |
|
76 | 76 | close_action( &TC, result, queue_snd_id ); |
|
77 | 77 | break; |
|
78 | 78 | // |
|
79 | 79 | case TC_SUBTYPE_LOAD_NORM: |
|
80 | 80 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
81 | 81 | close_action( &TC, result, queue_snd_id ); |
|
82 | 82 | break; |
|
83 | 83 | // |
|
84 | 84 | case TC_SUBTYPE_LOAD_BURST: |
|
85 | 85 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
86 | 86 | close_action( &TC, result, queue_snd_id ); |
|
87 | 87 | break; |
|
88 | 88 | // |
|
89 | 89 | case TC_SUBTYPE_LOAD_SBM1: |
|
90 | 90 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
91 | 91 | close_action( &TC, result, queue_snd_id ); |
|
92 | 92 | break; |
|
93 | 93 | // |
|
94 | 94 | case TC_SUBTYPE_LOAD_SBM2: |
|
95 | 95 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
96 | 96 | close_action( &TC, result, queue_snd_id ); |
|
97 | 97 | break; |
|
98 | 98 | // |
|
99 | 99 | case TC_SUBTYPE_DUMP: |
|
100 | 100 | result = action_dump_par( queue_snd_id ); |
|
101 | 101 | close_action( &TC, result, queue_snd_id ); |
|
102 | 102 | break; |
|
103 | 103 | // |
|
104 | 104 | case TC_SUBTYPE_ENTER: |
|
105 | 105 | result = action_enter_mode( &TC, queue_snd_id ); |
|
106 | 106 | close_action( &TC, result, queue_snd_id ); |
|
107 | 107 | break; |
|
108 | 108 | // |
|
109 | 109 | case TC_SUBTYPE_UPDT_INFO: |
|
110 | 110 | result = action_update_info( &TC, queue_snd_id ); |
|
111 | 111 | close_action( &TC, result, queue_snd_id ); |
|
112 | 112 | break; |
|
113 | 113 | // |
|
114 | 114 | case TC_SUBTYPE_EN_CAL: |
|
115 | 115 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
116 | 116 | close_action( &TC, result, queue_snd_id ); |
|
117 | 117 | break; |
|
118 | 118 | // |
|
119 | 119 | case TC_SUBTYPE_DIS_CAL: |
|
120 | 120 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
121 | 121 | close_action( &TC, result, queue_snd_id ); |
|
122 | 122 | break; |
|
123 | 123 | // |
|
124 | 124 | case TC_SUBTYPE_UPDT_TIME: |
|
125 | 125 | result = action_update_time( &TC ); |
|
126 | 126 | close_action( &TC, result, queue_snd_id ); |
|
127 | 127 | break; |
|
128 | 128 | // |
|
129 | 129 | default: |
|
130 | 130 | break; |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | } |
|
135 | 135 | |
|
136 | 136 | //*********** |
|
137 | 137 | // TC ACTIONS |
|
138 | 138 | |
|
139 | 139 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | 140 | { |
|
141 | 141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | 142 | * |
|
143 | 143 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | 144 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | 145 | * |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
149 | 149 | return LFR_DEFAULT; |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
153 | 153 | { |
|
154 | 154 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
155 | 155 | * |
|
156 | 156 | * @param TC points to the TeleCommand packet that is being processed |
|
157 | 157 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
158 | 158 | * |
|
159 | 159 | */ |
|
160 | 160 | |
|
161 | 161 | rtems_status_code status; |
|
162 | 162 | unsigned char requestedMode; |
|
163 | 163 | unsigned int *transitionCoarseTime_ptr; |
|
164 | 164 | unsigned int transitionCoarseTime; |
|
165 | 165 | unsigned char * bytePosPtr; |
|
166 | 166 | |
|
167 | 167 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
168 | 168 | |
|
169 | 169 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
170 | 170 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
171 | 171 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
172 | 172 | |
|
173 | 173 | status = check_mode_value( requestedMode ); |
|
174 | 174 | |
|
175 | 175 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
176 | 176 | { |
|
177 | 177 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
178 | 178 | } |
|
179 | 179 | else // the mode value is consistent, check the transition |
|
180 | 180 | { |
|
181 | 181 | status = check_mode_transition(requestedMode); |
|
182 | 182 | if (status != LFR_SUCCESSFUL) |
|
183 | 183 | { |
|
184 | 184 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
185 | 185 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | |
|
189 | 189 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode |
|
190 | 190 | { |
|
191 | 191 | status = check_transition_date( transitionCoarseTime ); |
|
192 | 192 | if (status != LFR_SUCCESSFUL) |
|
193 | 193 | { |
|
194 | 194 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
195 | 195 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
196 | 196 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
197 | 197 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
198 | 198 | } |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
202 | 202 | { |
|
203 | 203 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
204 | 204 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | return status; |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
211 | 211 | { |
|
212 | 212 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
213 | 213 | * |
|
214 | 214 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | 215 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
216 | 216 | * |
|
217 | 217 | * @return LFR directive status code: |
|
218 | 218 | * - LFR_DEFAULT |
|
219 | 219 | * - LFR_SUCCESSFUL |
|
220 | 220 | * |
|
221 | 221 | */ |
|
222 | 222 | |
|
223 | 223 | unsigned int val; |
|
224 | 224 | int result; |
|
225 | 225 | unsigned int status; |
|
226 | 226 | unsigned char mode; |
|
227 | 227 | unsigned char * bytePosPtr; |
|
228 | 228 | |
|
229 | 229 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
230 | 230 | |
|
231 | 231 | // check LFR mode |
|
232 | 232 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
233 | 233 | status = check_update_info_hk_lfr_mode( mode ); |
|
234 | 234 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
235 | 235 | { |
|
236 | 236 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
237 | 237 | status = check_update_info_hk_tds_mode( mode ); |
|
238 | 238 | } |
|
239 | 239 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
240 | 240 | { |
|
241 | 241 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
242 | 242 | status = check_update_info_hk_thr_mode( mode ); |
|
243 | 243 | } |
|
244 | 244 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
245 | 245 | { |
|
246 | 246 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
247 | 247 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
248 | 248 | val++; |
|
249 | 249 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
250 | 250 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
251 | 251 | } |
|
252 | 252 | |
|
253 | 253 | result = status; |
|
254 | 254 | |
|
255 | 255 | return result; |
|
256 | 256 | } |
|
257 | 257 | |
|
258 | 258 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
259 | 259 | { |
|
260 | 260 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
261 | 261 | * |
|
262 | 262 | * @param TC points to the TeleCommand packet that is being processed |
|
263 | 263 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
264 | 264 | * |
|
265 | 265 | */ |
|
266 | 266 | |
|
267 | 267 | int result; |
|
268 | 268 | unsigned char lfrMode; |
|
269 | 269 | |
|
270 | 270 | result = LFR_DEFAULT; |
|
271 | 271 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
272 | 272 | |
|
273 | 273 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
274 | 274 | result = LFR_DEFAULT; |
|
275 | 275 | |
|
276 | 276 | return result; |
|
277 | 277 | } |
|
278 | 278 | |
|
279 | 279 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
280 | 280 | { |
|
281 | 281 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
282 | 282 | * |
|
283 | 283 | * @param TC points to the TeleCommand packet that is being processed |
|
284 | 284 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
285 | 285 | * |
|
286 | 286 | */ |
|
287 | 287 | |
|
288 | 288 | int result; |
|
289 | 289 | unsigned char lfrMode; |
|
290 | 290 | |
|
291 | 291 | result = LFR_DEFAULT; |
|
292 | 292 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
293 | 293 | |
|
294 | 294 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
295 | 295 | result = LFR_DEFAULT; |
|
296 | 296 | |
|
297 | 297 | return result; |
|
298 | 298 | } |
|
299 | 299 | |
|
300 | 300 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
301 | 301 | { |
|
302 | 302 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
303 | 303 | * |
|
304 | 304 | * @param TC points to the TeleCommand packet that is being processed |
|
305 | 305 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
306 | 306 | * |
|
307 | 307 | * @return LFR_SUCCESSFUL |
|
308 | 308 | * |
|
309 | 309 | */ |
|
310 | 310 | |
|
311 | 311 | unsigned int val; |
|
312 | 312 | |
|
313 | 313 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
314 | 314 | + (TC->dataAndCRC[1] << 16) |
|
315 | 315 | + (TC->dataAndCRC[2] << 8) |
|
316 | 316 | + TC->dataAndCRC[3]; |
|
317 | 317 | |
|
318 | 318 | PRINTF1("time received: %x\n", time_management_regs->coarse_time_load) |
|
319 | 319 | |
|
320 | 320 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
321 | 321 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
322 | 322 | val++; |
|
323 | 323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
324 | 324 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
325 | // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick | |
|
326 | 325 | |
|
327 | 326 | return LFR_SUCCESSFUL; |
|
328 | 327 | } |
|
329 | 328 | |
|
330 | 329 | //******************* |
|
331 | 330 | // ENTERING THE MODES |
|
332 | 331 | int check_mode_value( unsigned char requestedMode ) |
|
333 | 332 | { |
|
334 | 333 | int status; |
|
335 | 334 | |
|
336 | 335 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
337 | 336 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
338 | 337 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
339 | 338 | { |
|
340 | 339 | status = LFR_DEFAULT; |
|
341 | 340 | } |
|
342 | 341 | else |
|
343 | 342 | { |
|
344 | 343 | status = LFR_SUCCESSFUL; |
|
345 | 344 | } |
|
346 | 345 | |
|
347 | 346 | return status; |
|
348 | 347 | } |
|
349 | 348 | |
|
350 | 349 | int check_mode_transition( unsigned char requestedMode ) |
|
351 | 350 | { |
|
352 | 351 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
353 | 352 | * |
|
354 | 353 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
355 | 354 | * |
|
356 | 355 | * @return LFR directive status codes: |
|
357 | 356 | * - LFR_SUCCESSFUL - the transition is authorized |
|
358 | 357 | * - LFR_DEFAULT - the transition is not authorized |
|
359 | 358 | * |
|
360 | 359 | */ |
|
361 | 360 | |
|
362 | 361 | int status; |
|
363 | 362 | |
|
364 | 363 | switch (requestedMode) |
|
365 | 364 | { |
|
366 | 365 | case LFR_MODE_STANDBY: |
|
367 | 366 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
368 | 367 | status = LFR_DEFAULT; |
|
369 | 368 | } |
|
370 | 369 | else |
|
371 | 370 | { |
|
372 | 371 | status = LFR_SUCCESSFUL; |
|
373 | 372 | } |
|
374 | 373 | break; |
|
375 | 374 | case LFR_MODE_NORMAL: |
|
376 | 375 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
377 | 376 | status = LFR_DEFAULT; |
|
378 | 377 | } |
|
379 | 378 | else { |
|
380 | 379 | status = LFR_SUCCESSFUL; |
|
381 | 380 | } |
|
382 | 381 | break; |
|
383 | 382 | case LFR_MODE_BURST: |
|
384 | 383 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
385 | 384 | status = LFR_DEFAULT; |
|
386 | 385 | } |
|
387 | 386 | else { |
|
388 | 387 | status = LFR_SUCCESSFUL; |
|
389 | 388 | } |
|
390 | 389 | break; |
|
391 | 390 | case LFR_MODE_SBM1: |
|
392 | 391 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
393 | 392 | status = LFR_DEFAULT; |
|
394 | 393 | } |
|
395 | 394 | else { |
|
396 | 395 | status = LFR_SUCCESSFUL; |
|
397 | 396 | } |
|
398 | 397 | break; |
|
399 | 398 | case LFR_MODE_SBM2: |
|
400 | 399 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
401 | 400 | status = LFR_DEFAULT; |
|
402 | 401 | } |
|
403 | 402 | else { |
|
404 | 403 | status = LFR_SUCCESSFUL; |
|
405 | 404 | } |
|
406 | 405 | break; |
|
407 | 406 | default: |
|
408 | 407 | status = LFR_DEFAULT; |
|
409 | 408 | break; |
|
410 | 409 | } |
|
411 | 410 | |
|
412 | 411 | return status; |
|
413 | 412 | } |
|
414 | 413 | |
|
415 | 414 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
416 | 415 | { |
|
417 | 416 | int status; |
|
418 | 417 | unsigned int localCoarseTime; |
|
419 | 418 | unsigned int deltaCoarseTime; |
|
420 | 419 | |
|
421 | 420 | status = LFR_SUCCESSFUL; |
|
422 | 421 | |
|
423 | 422 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
424 | 423 | { |
|
425 | 424 | status = LFR_SUCCESSFUL; |
|
426 | 425 | } |
|
427 | 426 | else |
|
428 | 427 | { |
|
429 | 428 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
430 | 429 | |
|
431 | 430 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
432 | 431 | { |
|
433 | 432 | status = LFR_DEFAULT; |
|
434 | 433 | PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime) |
|
435 | 434 | } |
|
436 | 435 | |
|
437 | 436 | if (status == LFR_SUCCESSFUL) |
|
438 | 437 | { |
|
439 | 438 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
440 | 439 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
441 | 440 | { |
|
442 | 441 | status = LFR_DEFAULT; |
|
443 | 442 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
444 | 443 | } |
|
445 | 444 | } |
|
446 | 445 | } |
|
447 | 446 | |
|
448 | 447 | return status; |
|
449 | 448 | } |
|
450 | 449 | |
|
451 | 450 | int stop_current_mode( void ) |
|
452 | 451 | { |
|
453 | 452 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
454 | 453 | * |
|
455 | 454 | * @return RTEMS directive status codes: |
|
456 | 455 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
457 | 456 | * - RTEMS_INVALID_ID - task id invalid |
|
458 | 457 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
459 | 458 | * |
|
460 | 459 | */ |
|
461 | 460 | |
|
462 | 461 | rtems_status_code status; |
|
463 | 462 | |
|
464 | 463 | status = RTEMS_SUCCESSFUL; |
|
465 | 464 | |
|
466 | 465 | // (1) mask interruptions |
|
467 | 466 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
468 | 467 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
469 | 468 | |
|
470 | 469 | // (2) clear interruptions |
|
471 | 470 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
472 | 471 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
473 | 472 | |
|
474 | 473 | // (3) reset waveform picker registers |
|
475 | 474 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
476 | 475 | reset_wfp_status(); // reset all the status bits |
|
477 | 476 | |
|
478 | 477 | // (4) reset spectral matrices registers |
|
479 | 478 | set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices |
|
480 | 479 | set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0 |
|
481 | 480 | reset_extractSWF(); // reset the extractSWF flag to false |
|
482 | 481 | |
|
483 | 482 | // <Spectral Matrices simulator> |
|
484 | 483 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
485 | 484 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
486 | 485 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
487 | 486 | // </Spectral Matrices simulator> |
|
488 | 487 | |
|
489 | 488 | // suspend several tasks |
|
490 | 489 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
491 | 490 | status = suspend_science_tasks(); |
|
492 | 491 | } |
|
493 | 492 | |
|
494 | 493 | if (status != RTEMS_SUCCESSFUL) |
|
495 | 494 | { |
|
496 | 495 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
497 | 496 | } |
|
498 | 497 | |
|
499 | 498 | return status; |
|
500 | 499 | } |
|
501 | 500 | |
|
502 | 501 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
503 | 502 | { |
|
504 | 503 | /** This function is launched after a mode transition validation. |
|
505 | 504 | * |
|
506 | 505 | * @param mode is the mode in which LFR will be put. |
|
507 | 506 | * |
|
508 | 507 | * @return RTEMS directive status codes: |
|
509 | 508 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
510 | 509 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
511 | 510 | * |
|
512 | 511 | */ |
|
513 | 512 | |
|
514 | 513 | rtems_status_code status; |
|
515 | 514 | |
|
516 | 515 | //********************** |
|
517 | 516 | // STOP THE CURRENT MODE |
|
518 | 517 | status = stop_current_mode(); |
|
519 | 518 | if (status != RTEMS_SUCCESSFUL) |
|
520 | 519 | { |
|
521 | 520 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
522 | 521 | } |
|
523 | 522 | |
|
524 | 523 | //************************* |
|
525 | 524 | // ENTER THE REQUESTED MODE |
|
526 | 525 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
527 | 526 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
528 | 527 | { |
|
529 | 528 | #ifdef PRINT_TASK_STATISTICS |
|
530 | 529 | rtems_cpu_usage_reset(); |
|
531 | 530 | maxCount = 0; |
|
532 | 531 | #endif |
|
533 | 532 | status = restart_science_tasks( mode ); |
|
534 | 533 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
535 | 534 | launch_spectral_matrix( ); |
|
536 | 535 | // launch_spectral_matrix_simu( ); |
|
537 | 536 | } |
|
538 | 537 | else if ( mode == LFR_MODE_STANDBY ) |
|
539 | 538 | { |
|
540 | 539 | #ifdef PRINT_TASK_STATISTICS |
|
541 | 540 | rtems_cpu_usage_report(); |
|
542 | 541 | #endif |
|
543 | 542 | |
|
544 | 543 | #ifdef PRINT_STACK_REPORT |
|
545 | 544 | PRINTF("stack report selected\n") |
|
546 | 545 | rtems_stack_checker_report_usage(); |
|
547 | 546 | #endif |
|
548 | 547 | PRINTF1("maxCount = %d\n", maxCount) |
|
549 | 548 | } |
|
550 | 549 | else |
|
551 | 550 | { |
|
552 | 551 | status = RTEMS_UNSATISFIED; |
|
553 | 552 | } |
|
554 | 553 | |
|
555 | 554 | if (status != RTEMS_SUCCESSFUL) |
|
556 | 555 | { |
|
557 | 556 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
558 | 557 | status = RTEMS_UNSATISFIED; |
|
559 | 558 | } |
|
560 | 559 | |
|
561 | 560 | return status; |
|
562 | 561 | } |
|
563 | 562 | |
|
564 | 563 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
565 | 564 | { |
|
566 | 565 | /** This function is used to restart all science tasks. |
|
567 | 566 | * |
|
568 | 567 | * @return RTEMS directive status codes: |
|
569 | 568 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
570 | 569 | * - RTEMS_INVALID_ID - task id invalid |
|
571 | 570 | * - RTEMS_INCORRECT_STATE - task never started |
|
572 | 571 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
573 | 572 | * |
|
574 | 573 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
575 | 574 | * |
|
576 | 575 | */ |
|
577 | 576 | |
|
578 | 577 | rtems_status_code status[10]; |
|
579 | 578 | rtems_status_code ret; |
|
580 | 579 | |
|
581 | 580 | ret = RTEMS_SUCCESSFUL; |
|
582 | 581 | |
|
583 | 582 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
584 | 583 | if (status[0] != RTEMS_SUCCESSFUL) |
|
585 | 584 | { |
|
586 | 585 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
587 | 586 | } |
|
588 | 587 | |
|
589 | 588 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
590 | 589 | if (status[1] != RTEMS_SUCCESSFUL) |
|
591 | 590 | { |
|
592 | 591 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
593 | 592 | } |
|
594 | 593 | |
|
595 | 594 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
596 | 595 | if (status[2] != RTEMS_SUCCESSFUL) |
|
597 | 596 | { |
|
598 | 597 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
599 | 598 | } |
|
600 | 599 | |
|
601 | 600 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
602 | 601 | if (status[3] != RTEMS_SUCCESSFUL) |
|
603 | 602 | { |
|
604 | 603 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
605 | 604 | } |
|
606 | 605 | |
|
607 | 606 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
608 | 607 | if (status[4] != RTEMS_SUCCESSFUL) |
|
609 | 608 | { |
|
610 | 609 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
611 | 610 | } |
|
612 | 611 | |
|
613 | 612 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
614 | 613 | if (status[5] != RTEMS_SUCCESSFUL) |
|
615 | 614 | { |
|
616 | 615 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
617 | 616 | } |
|
618 | 617 | |
|
619 | 618 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
620 | 619 | if (status[6] != RTEMS_SUCCESSFUL) |
|
621 | 620 | { |
|
622 | 621 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
623 | 622 | } |
|
624 | 623 | |
|
625 | 624 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
626 | 625 | if (status[7] != RTEMS_SUCCESSFUL) |
|
627 | 626 | { |
|
628 | 627 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
629 | 628 | } |
|
630 | 629 | |
|
631 | 630 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
632 | 631 | if (status[8] != RTEMS_SUCCESSFUL) |
|
633 | 632 | { |
|
634 | 633 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
635 | 634 | } |
|
636 | 635 | |
|
637 | 636 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
638 | 637 | if (status[9] != RTEMS_SUCCESSFUL) |
|
639 | 638 | { |
|
640 | 639 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
641 | 640 | } |
|
642 | 641 | |
|
643 | 642 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
644 | 643 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
645 | 644 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
646 | 645 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
647 | 646 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
648 | 647 | { |
|
649 | 648 | ret = RTEMS_UNSATISFIED; |
|
650 | 649 | } |
|
651 | 650 | |
|
652 | 651 | return ret; |
|
653 | 652 | } |
|
654 | 653 | |
|
655 | 654 | int suspend_science_tasks() |
|
656 | 655 | { |
|
657 | 656 | /** This function suspends the science tasks. |
|
658 | 657 | * |
|
659 | 658 | * @return RTEMS directive status codes: |
|
660 | 659 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
661 | 660 | * - RTEMS_INVALID_ID - task id invalid |
|
662 | 661 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
663 | 662 | * |
|
664 | 663 | */ |
|
665 | 664 | |
|
666 | 665 | rtems_status_code status; |
|
667 | 666 | |
|
668 | 667 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
669 | 668 | if (status != RTEMS_SUCCESSFUL) |
|
670 | 669 | { |
|
671 | 670 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
672 | 671 | } |
|
673 | 672 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
674 | 673 | { |
|
675 | 674 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
676 | 675 | if (status != RTEMS_SUCCESSFUL) |
|
677 | 676 | { |
|
678 | 677 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
679 | 678 | } |
|
680 | 679 | } |
|
681 | 680 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
682 | 681 | { |
|
683 | 682 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
684 | 683 | if (status != RTEMS_SUCCESSFUL) |
|
685 | 684 | { |
|
686 | 685 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
687 | 686 | } |
|
688 | 687 | } |
|
689 | 688 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
690 | 689 | { |
|
691 | 690 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
692 | 691 | if (status != RTEMS_SUCCESSFUL) |
|
693 | 692 | { |
|
694 | 693 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
695 | 694 | } |
|
696 | 695 | } |
|
697 | 696 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
698 | 697 | { |
|
699 | 698 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
700 | 699 | if (status != RTEMS_SUCCESSFUL) |
|
701 | 700 | { |
|
702 | 701 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
703 | 702 | } |
|
704 | 703 | } |
|
705 | 704 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
706 | 705 | { |
|
707 | 706 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
708 | 707 | if (status != RTEMS_SUCCESSFUL) |
|
709 | 708 | { |
|
710 | 709 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
711 | 710 | } |
|
712 | 711 | } |
|
713 | 712 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
714 | 713 | { |
|
715 | 714 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
716 | 715 | if (status != RTEMS_SUCCESSFUL) |
|
717 | 716 | { |
|
718 | 717 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
719 | 718 | } |
|
720 | 719 | } |
|
721 | 720 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
722 | 721 | { |
|
723 | 722 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
724 | 723 | if (status != RTEMS_SUCCESSFUL) |
|
725 | 724 | { |
|
726 | 725 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
727 | 726 | } |
|
728 | 727 | } |
|
729 | 728 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
730 | 729 | { |
|
731 | 730 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
732 | 731 | if (status != RTEMS_SUCCESSFUL) |
|
733 | 732 | { |
|
734 | 733 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
735 | 734 | } |
|
736 | 735 | } |
|
737 | 736 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
738 | 737 | { |
|
739 | 738 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
740 | 739 | if (status != RTEMS_SUCCESSFUL) |
|
741 | 740 | { |
|
742 | 741 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
743 | 742 | } |
|
744 | 743 | } |
|
745 | 744 | |
|
746 | 745 | return status; |
|
747 | 746 | } |
|
748 | 747 | |
|
749 | 748 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
750 | 749 | { |
|
751 | 750 | WFP_reset_current_ring_nodes(); |
|
752 | 751 | reset_waveform_picker_regs(); |
|
753 | 752 | set_wfp_burst_enable_register( mode ); |
|
754 | 753 | |
|
755 | 754 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
756 | 755 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
757 | 756 | |
|
758 | 757 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] |
|
759 | 758 | if (transitionCoarseTime == 0) |
|
760 | 759 | { |
|
761 | 760 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
762 | 761 | } |
|
763 | 762 | else |
|
764 | 763 | { |
|
765 | 764 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
766 | 765 | } |
|
766 | ||
|
767 | PRINTF1("commutation coarse time = %d\n", transitionCoarseTime) | |
|
767 | 768 | } |
|
768 | 769 | |
|
769 | 770 | void launch_spectral_matrix( void ) |
|
770 | 771 | { |
|
771 | 772 | SM_reset_current_ring_nodes(); |
|
772 | 773 | reset_spectral_matrix_regs(); |
|
773 | 774 | reset_nb_sm(); |
|
774 | 775 | |
|
775 | 776 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
776 | 777 | grgpio_regs->io_port_direction_register = |
|
777 | 778 | grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled |
|
778 | 779 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0 |
|
779 | 780 | set_irq_on_new_ready_matrix( 1 ); |
|
780 | 781 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
781 | 782 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
782 | 783 | set_run_matrix_spectral( 1 ); |
|
783 | 784 | } |
|
784 | 785 | |
|
785 | 786 | void launch_spectral_matrix_simu( void ) |
|
786 | 787 | { |
|
787 | 788 | SM_reset_current_ring_nodes(); |
|
788 | 789 | reset_spectral_matrix_regs(); |
|
789 | 790 | reset_nb_sm(); |
|
790 | 791 | |
|
791 | 792 | // Spectral Matrices simulator |
|
792 | 793 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
793 | 794 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
794 | 795 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
795 | 796 | } |
|
796 | 797 | |
|
797 | 798 | void set_irq_on_new_ready_matrix( unsigned char value ) |
|
798 | 799 | { |
|
799 | 800 | if (value == 1) |
|
800 | 801 | { |
|
801 | 802 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
802 | 803 | } |
|
803 | 804 | else |
|
804 | 805 | { |
|
805 | 806 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
806 | 807 | } |
|
807 | 808 | } |
|
808 | 809 | |
|
809 | 810 | void set_run_matrix_spectral( unsigned char value ) |
|
810 | 811 | { |
|
811 | 812 | if (value == 1) |
|
812 | 813 | { |
|
813 | 814 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1 |
|
814 | 815 | } |
|
815 | 816 | else |
|
816 | 817 | { |
|
817 | 818 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0 |
|
818 | 819 | } |
|
819 | 820 | } |
|
820 | 821 | |
|
821 | 822 | //**************** |
|
822 | 823 | // CLOSING ACTIONS |
|
823 | 824 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
824 | 825 | { |
|
825 | 826 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
826 | 827 | * |
|
827 | 828 | * @param TC points to the TC being processed |
|
828 | 829 | * @param time is the time used to date the TC execution |
|
829 | 830 | * |
|
830 | 831 | */ |
|
831 | 832 | |
|
832 | 833 | unsigned int val; |
|
833 | 834 | |
|
834 | 835 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
835 | 836 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
836 | 837 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
837 | 838 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
838 | 839 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
839 | 840 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
840 | 841 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
841 | 842 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
842 | 843 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
843 | 844 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
844 | 845 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
845 | 846 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
846 | 847 | |
|
847 | 848 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
848 | 849 | val++; |
|
849 | 850 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
850 | 851 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
851 | 852 | } |
|
852 | 853 | |
|
853 | 854 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
854 | 855 | { |
|
855 | 856 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
856 | 857 | * |
|
857 | 858 | * @param TC points to the TC being processed |
|
858 | 859 | * @param time is the time used to date the TC rejection |
|
859 | 860 | * |
|
860 | 861 | */ |
|
861 | 862 | |
|
862 | 863 | unsigned int val; |
|
863 | 864 | |
|
864 | 865 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
865 | 866 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
866 | 867 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
867 | 868 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
868 | 869 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
869 | 870 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
870 | 871 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
871 | 872 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
872 | 873 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
873 | 874 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
874 | 875 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
875 | 876 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
876 | 877 | |
|
877 | 878 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
878 | 879 | val++; |
|
879 | 880 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
880 | 881 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
881 | 882 | } |
|
882 | 883 | |
|
883 | 884 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
884 | 885 | { |
|
885 | 886 | /** This function is the last step of the TC execution workflow. |
|
886 | 887 | * |
|
887 | 888 | * @param TC points to the TC being processed |
|
888 | 889 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
889 | 890 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
890 | 891 | * @param time is the time used to date the TC execution |
|
891 | 892 | * |
|
892 | 893 | */ |
|
893 | 894 | |
|
894 | 895 | unsigned char requestedMode; |
|
895 | 896 | |
|
896 | 897 | if (result == LFR_SUCCESSFUL) |
|
897 | 898 | { |
|
898 | 899 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
899 | 900 | & |
|
900 | 901 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
901 | 902 | ) |
|
902 | 903 | { |
|
903 | 904 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
904 | 905 | } |
|
905 | 906 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
906 | 907 | { |
|
907 | 908 | //********************************** |
|
908 | 909 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
909 | 910 | requestedMode = TC->dataAndCRC[1]; |
|
910 | 911 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
911 | 912 | updateLFRCurrentMode(); |
|
912 | 913 | } |
|
913 | 914 | } |
|
914 | 915 | else if (result == LFR_EXE_ERROR) |
|
915 | 916 | { |
|
916 | 917 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
917 | 918 | } |
|
918 | 919 | } |
|
919 | 920 | |
|
920 | 921 | //*************************** |
|
921 | 922 | // Interrupt Service Routines |
|
922 | 923 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
923 | 924 | { |
|
924 | 925 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
925 | 926 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
926 | 927 | } |
|
927 | 928 | } |
|
928 | 929 | |
|
929 | 930 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
930 | 931 | { |
|
931 | 932 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
932 | 933 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
933 | 934 | } |
|
934 | 935 | } |
|
935 | 936 | |
|
936 | 937 | //**************** |
|
937 | 938 | // OTHER FUNCTIONS |
|
938 | 939 | void updateLFRCurrentMode() |
|
939 | 940 | { |
|
940 | 941 | /** This function updates the value of the global variable lfrCurrentMode. |
|
941 | 942 | * |
|
942 | 943 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
943 | 944 | * |
|
944 | 945 | */ |
|
945 | 946 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
946 | 947 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
947 | 948 | } |
|
948 | 949 |
@@ -1,772 +1,772 | |||
|
1 | 1 | /** Functions to load and dump parameters in the LFR registers. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
7 | 7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
8 | 8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
9 | 9 | * TC_LFR_LOAD_BURST_PAR\n |
|
10 | 10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
11 | 11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
12 | 12 | * |
|
13 | 13 | */ |
|
14 | 14 | |
|
15 | 15 | #include "tc_load_dump_parameters.h" |
|
16 | 16 | |
|
17 | 17 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
18 | 18 | { |
|
19 | 19 | /** This function updates the LFR registers with the incoming common parameters. |
|
20 | 20 | * |
|
21 | 21 | * @param TC points to the TeleCommand packet that is being processed |
|
22 | 22 | * |
|
23 | 23 | * |
|
24 | 24 | */ |
|
25 | 25 | |
|
26 | 26 | parameter_dump_packet.unused0 = TC->dataAndCRC[0]; |
|
27 | 27 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1]; |
|
28 | 28 | set_wfp_data_shaping( ); |
|
29 | 29 | return LFR_SUCCESSFUL; |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
33 | 33 | { |
|
34 | 34 | /** This function updates the LFR registers with the incoming normal parameters. |
|
35 | 35 | * |
|
36 | 36 | * @param TC points to the TeleCommand packet that is being processed |
|
37 | 37 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
38 | 38 | * |
|
39 | 39 | */ |
|
40 | 40 | |
|
41 | 41 | int result; |
|
42 | 42 | int flag; |
|
43 | 43 | rtems_status_code status; |
|
44 | 44 | |
|
45 | 45 | flag = LFR_SUCCESSFUL; |
|
46 | 46 | |
|
47 | 47 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
48 | 48 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
49 | 49 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
50 | 50 | flag = LFR_DEFAULT; |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
54 | 54 | if (flag == LFR_SUCCESSFUL) |
|
55 | 55 | { |
|
56 | 56 | flag = check_common_par_consistency( TC, queue_id ); |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
60 | 60 | if (flag == LFR_SUCCESSFUL) |
|
61 | 61 | { |
|
62 | 62 | result = set_sy_lfr_n_swf_l( TC ); |
|
63 | 63 | result = set_sy_lfr_n_swf_p( TC ); |
|
64 | 64 | result = set_sy_lfr_n_bp_p0( TC ); |
|
65 | 65 | result = set_sy_lfr_n_bp_p1( TC ); |
|
66 | 66 | result = set_sy_lfr_n_asm_p( TC ); |
|
67 | 67 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | return flag; |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
74 | 74 | { |
|
75 | 75 | /** This function updates the LFR registers with the incoming burst parameters. |
|
76 | 76 | * |
|
77 | 77 | * @param TC points to the TeleCommand packet that is being processed |
|
78 | 78 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
79 | 79 | * |
|
80 | 80 | */ |
|
81 | 81 | |
|
82 | 82 | int flag; |
|
83 | 83 | rtems_status_code status; |
|
84 | 84 | unsigned char sy_lfr_b_bp_p0; |
|
85 | 85 | unsigned char sy_lfr_b_bp_p1; |
|
86 | 86 | float aux; |
|
87 | 87 | |
|
88 | 88 | flag = LFR_SUCCESSFUL; |
|
89 | 89 | |
|
90 | 90 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
91 | 91 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
92 | 92 | flag = LFR_DEFAULT; |
|
93 | 93 | } |
|
94 | 94 | |
|
95 | 95 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
96 | 96 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
97 | 97 | |
|
98 | 98 | // sy_lfr_b_bp_p0 |
|
99 | 99 | if (flag == LFR_SUCCESSFUL) |
|
100 | 100 | { |
|
101 | 101 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
102 | 102 | { |
|
103 | 103 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
104 | 104 | flag = WRONG_APP_DATA; |
|
105 | 105 | } |
|
106 | 106 | } |
|
107 | 107 | // sy_lfr_b_bp_p1 |
|
108 | 108 | if (flag == LFR_SUCCESSFUL) |
|
109 | 109 | { |
|
110 | 110 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
111 | 111 | { |
|
112 | 112 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); |
|
113 | 113 | flag = WRONG_APP_DATA; |
|
114 | 114 | } |
|
115 | 115 | } |
|
116 | 116 | //**************************************************************** |
|
117 | 117 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
118 | 118 | if (flag == LFR_SUCCESSFUL) |
|
119 | 119 | { |
|
120 | 120 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
121 | 121 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
122 | 122 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
123 |
if (aux |
|
|
123 | if (aux > FLOAT_EQUAL_ZERO) | |
|
124 | 124 | { |
|
125 | 125 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
126 | 126 | flag = LFR_DEFAULT; |
|
127 | 127 | } |
|
128 | 128 | } |
|
129 | 129 | |
|
130 | 130 | // SET HTE PARAMETERS |
|
131 | 131 | if (flag == LFR_SUCCESSFUL) |
|
132 | 132 | { |
|
133 | 133 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
134 | 134 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
135 | 135 | } |
|
136 | 136 | |
|
137 | 137 | return flag; |
|
138 | 138 | } |
|
139 | 139 | |
|
140 | 140 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
141 | 141 | { |
|
142 | 142 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
143 | 143 | * |
|
144 | 144 | * @param TC points to the TeleCommand packet that is being processed |
|
145 | 145 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
146 | 146 | * |
|
147 | 147 | */ |
|
148 | 148 | |
|
149 | 149 | int flag; |
|
150 | 150 | rtems_status_code status; |
|
151 | 151 | unsigned char sy_lfr_s1_bp_p0; |
|
152 | 152 | unsigned char sy_lfr_s1_bp_p1; |
|
153 | 153 | float aux; |
|
154 | 154 | |
|
155 | 155 | flag = LFR_SUCCESSFUL; |
|
156 | 156 | |
|
157 | 157 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
158 | 158 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
159 | 159 | flag = LFR_DEFAULT; |
|
160 | 160 | } |
|
161 | 161 | |
|
162 | 162 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
163 | 163 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
164 | 164 | |
|
165 | 165 | // sy_lfr_s1_bp_p0 |
|
166 | 166 | if (flag == LFR_SUCCESSFUL) |
|
167 | 167 | { |
|
168 | 168 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
169 | 169 | { |
|
170 | 170 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
171 | 171 | flag = WRONG_APP_DATA; |
|
172 | 172 | } |
|
173 | 173 | } |
|
174 | 174 | // sy_lfr_s1_bp_p1 |
|
175 | 175 | if (flag == LFR_SUCCESSFUL) |
|
176 | 176 | { |
|
177 | 177 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
178 | 178 | { |
|
179 | 179 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); |
|
180 | 180 | flag = WRONG_APP_DATA; |
|
181 | 181 | } |
|
182 | 182 | } |
|
183 | 183 | //****************************************************************** |
|
184 | 184 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
185 | 185 | if (flag == LFR_SUCCESSFUL) |
|
186 | 186 | { |
|
187 | 187 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); |
|
188 |
if (aux |
|
|
188 | if (aux > FLOAT_EQUAL_ZERO) | |
|
189 | 189 | { |
|
190 | 190 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
191 | 191 | flag = LFR_DEFAULT; |
|
192 | 192 | } |
|
193 | 193 | } |
|
194 | 194 | |
|
195 | 195 | // SET THE PARAMETERS |
|
196 | 196 | if (flag == LFR_SUCCESSFUL) |
|
197 | 197 | { |
|
198 | 198 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
199 | 199 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
200 | 200 | } |
|
201 | 201 | |
|
202 | 202 | return flag; |
|
203 | 203 | } |
|
204 | 204 | |
|
205 | 205 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
206 | 206 | { |
|
207 | 207 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
208 | 208 | * |
|
209 | 209 | * @param TC points to the TeleCommand packet that is being processed |
|
210 | 210 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
211 | 211 | * |
|
212 | 212 | */ |
|
213 | 213 | |
|
214 | 214 | int flag; |
|
215 | 215 | rtems_status_code status; |
|
216 | 216 | unsigned char sy_lfr_s2_bp_p0; |
|
217 | 217 | unsigned char sy_lfr_s2_bp_p1; |
|
218 | 218 | float aux; |
|
219 | 219 | |
|
220 | 220 | flag = LFR_SUCCESSFUL; |
|
221 | 221 | |
|
222 | 222 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
223 | 223 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
224 | 224 | flag = LFR_DEFAULT; |
|
225 | 225 | } |
|
226 | 226 | |
|
227 | 227 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
228 | 228 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
229 | 229 | |
|
230 | 230 | // sy_lfr_s2_bp_p0 |
|
231 | 231 | if (flag == LFR_SUCCESSFUL) |
|
232 | 232 | { |
|
233 | 233 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
234 | 234 | { |
|
235 | 235 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
236 | 236 | flag = WRONG_APP_DATA; |
|
237 | 237 | } |
|
238 | 238 | } |
|
239 | 239 | // sy_lfr_s2_bp_p1 |
|
240 | 240 | if (flag == LFR_SUCCESSFUL) |
|
241 | 241 | { |
|
242 | 242 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
243 | 243 | { |
|
244 | 244 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); |
|
245 | 245 | flag = WRONG_APP_DATA; |
|
246 | 246 | } |
|
247 | 247 | } |
|
248 | 248 | //****************************************************************** |
|
249 | 249 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
250 | 250 | if (flag == LFR_SUCCESSFUL) |
|
251 | 251 | { |
|
252 | 252 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
253 | 253 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
254 | 254 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
255 |
if (aux |
|
|
255 | if (aux > FLOAT_EQUAL_ZERO) | |
|
256 | 256 | { |
|
257 | 257 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
258 | 258 | flag = LFR_DEFAULT; |
|
259 | 259 | } |
|
260 | 260 | } |
|
261 | 261 | |
|
262 | 262 | // SET THE PARAMETERS |
|
263 | 263 | if (flag == LFR_SUCCESSFUL) |
|
264 | 264 | { |
|
265 | 265 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
266 | 266 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
267 | 267 | } |
|
268 | 268 | |
|
269 | 269 | return flag; |
|
270 | 270 | } |
|
271 | 271 | |
|
272 | 272 | int action_dump_par( rtems_id queue_id ) |
|
273 | 273 | { |
|
274 | 274 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
275 | 275 | * |
|
276 | 276 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
277 | 277 | * |
|
278 | 278 | * @return RTEMS directive status codes: |
|
279 | 279 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
280 | 280 | * - RTEMS_INVALID_ID - invalid queue id |
|
281 | 281 | * - RTEMS_INVALID_SIZE - invalid message size |
|
282 | 282 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
283 | 283 | * - RTEMS_UNSATISFIED - out of message buffers |
|
284 | 284 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
285 | 285 | * |
|
286 | 286 | */ |
|
287 | 287 | |
|
288 | 288 | int status; |
|
289 | 289 | |
|
290 | 290 | // UPDATE TIME |
|
291 | 291 | parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
292 | 292 | parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
293 | 293 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
294 | 294 | |
|
295 | 295 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
296 | 296 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
297 | 297 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
298 | 298 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
299 | 299 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
300 | 300 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
301 | 301 | // SEND DATA |
|
302 | 302 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
303 | 303 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
304 | 304 | if (status != RTEMS_SUCCESSFUL) { |
|
305 | 305 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
306 | 306 | } |
|
307 | 307 | |
|
308 | 308 | return status; |
|
309 | 309 | } |
|
310 | 310 | |
|
311 | 311 | //*********************** |
|
312 | 312 | // NORMAL MODE PARAMETERS |
|
313 | 313 | |
|
314 | 314 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
315 | 315 | { |
|
316 | 316 | unsigned char msb; |
|
317 | 317 | unsigned char lsb; |
|
318 | 318 | int flag; |
|
319 | 319 | float aux; |
|
320 | 320 | rtems_status_code status; |
|
321 | 321 | |
|
322 | 322 | unsigned int sy_lfr_n_swf_l; |
|
323 | 323 | unsigned int sy_lfr_n_swf_p; |
|
324 | 324 | unsigned int sy_lfr_n_asm_p; |
|
325 | 325 | unsigned char sy_lfr_n_bp_p0; |
|
326 | 326 | unsigned char sy_lfr_n_bp_p1; |
|
327 | 327 | unsigned char sy_lfr_n_cwf_long_f3; |
|
328 | 328 | |
|
329 | 329 | flag = LFR_SUCCESSFUL; |
|
330 | 330 | |
|
331 | 331 | //*************** |
|
332 | 332 | // get parameters |
|
333 | 333 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
334 | 334 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
335 | 335 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
336 | 336 | |
|
337 | 337 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
338 | 338 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
339 | 339 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
340 | 340 | |
|
341 | 341 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
342 | 342 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
343 | 343 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
344 | 344 | |
|
345 | 345 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
346 | 346 | |
|
347 | 347 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
348 | 348 | |
|
349 | 349 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
350 | 350 | |
|
351 | 351 | //****************** |
|
352 | 352 | // check consistency |
|
353 | 353 | // sy_lfr_n_swf_l |
|
354 | 354 | if (sy_lfr_n_swf_l != 2048) |
|
355 | 355 | { |
|
356 | 356 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
357 | 357 | flag = WRONG_APP_DATA; |
|
358 | 358 | } |
|
359 | 359 | // sy_lfr_n_swf_p |
|
360 | 360 | if (flag == LFR_SUCCESSFUL) |
|
361 | 361 | { |
|
362 | 362 | if ( sy_lfr_n_swf_p < 16 ) |
|
363 | 363 | { |
|
364 | 364 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
365 | 365 | flag = WRONG_APP_DATA; |
|
366 | 366 | } |
|
367 | 367 | } |
|
368 | 368 | // sy_lfr_n_bp_p0 |
|
369 | 369 | if (flag == LFR_SUCCESSFUL) |
|
370 | 370 | { |
|
371 | if (sy_lfr_n_bp_p0 < SY_LFR_N_BP_P0) | |
|
371 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
|
372 | 372 | { |
|
373 | 373 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
374 | 374 | flag = WRONG_APP_DATA; |
|
375 | 375 | } |
|
376 | 376 | } |
|
377 | 377 | // sy_lfr_n_asm_p |
|
378 | 378 | if (flag == LFR_SUCCESSFUL) |
|
379 | 379 | { |
|
380 | 380 | if (sy_lfr_n_asm_p == 0) |
|
381 | 381 | { |
|
382 | 382 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
383 | 383 | flag = WRONG_APP_DATA; |
|
384 | 384 | } |
|
385 | 385 | } |
|
386 | 386 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
387 | 387 | if (flag == LFR_SUCCESSFUL) |
|
388 | 388 | { |
|
389 | 389 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
390 |
if (aux |
|
|
390 | if (aux > FLOAT_EQUAL_ZERO) | |
|
391 | 391 | { |
|
392 | 392 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
393 | 393 | flag = WRONG_APP_DATA; |
|
394 | 394 | } |
|
395 | 395 | } |
|
396 | 396 | // sy_lfr_n_bp_p1 |
|
397 | 397 | if (flag == LFR_SUCCESSFUL) |
|
398 | 398 | { |
|
399 | if (sy_lfr_n_bp_p1 < SY_LFR_N_BP_P1) | |
|
399 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
|
400 | 400 | { |
|
401 | 401 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
402 | 402 | flag = WRONG_APP_DATA; |
|
403 | 403 | } |
|
404 | 404 | } |
|
405 | 405 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
406 | 406 | if (flag == LFR_SUCCESSFUL) |
|
407 | 407 | { |
|
408 | 408 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
409 |
if (aux |
|
|
409 | if (aux > FLOAT_EQUAL_ZERO) | |
|
410 | 410 | { |
|
411 | 411 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
412 | 412 | flag = LFR_DEFAULT; |
|
413 | 413 | } |
|
414 | 414 | } |
|
415 | 415 | // sy_lfr_n_cwf_long_f3 |
|
416 | 416 | |
|
417 | 417 | return flag; |
|
418 | 418 | } |
|
419 | 419 | |
|
420 | 420 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
421 | 421 | { |
|
422 | 422 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
423 | 423 | * |
|
424 | 424 | * @param TC points to the TeleCommand packet that is being processed |
|
425 | 425 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
426 | 426 | * |
|
427 | 427 | */ |
|
428 | 428 | |
|
429 | 429 | int result; |
|
430 | 430 | |
|
431 | 431 | result = LFR_SUCCESSFUL; |
|
432 | 432 | |
|
433 | 433 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
434 | 434 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
435 | 435 | |
|
436 | 436 | return result; |
|
437 | 437 | } |
|
438 | 438 | |
|
439 | 439 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
440 | 440 | { |
|
441 | 441 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
442 | 442 | * |
|
443 | 443 | * @param TC points to the TeleCommand packet that is being processed |
|
444 | 444 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
445 | 445 | * |
|
446 | 446 | */ |
|
447 | 447 | |
|
448 | 448 | int result; |
|
449 | 449 | |
|
450 | 450 | result = LFR_SUCCESSFUL; |
|
451 | 451 | |
|
452 | 452 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
453 | 453 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
454 | 454 | |
|
455 | 455 | return result; |
|
456 | 456 | } |
|
457 | 457 | |
|
458 | 458 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
459 | 459 | { |
|
460 | 460 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
461 | 461 | * |
|
462 | 462 | * @param TC points to the TeleCommand packet that is being processed |
|
463 | 463 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
464 | 464 | * |
|
465 | 465 | */ |
|
466 | 466 | |
|
467 | 467 | int result; |
|
468 | 468 | |
|
469 | 469 | result = LFR_SUCCESSFUL; |
|
470 | 470 | |
|
471 | 471 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
472 | 472 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
473 | 473 | |
|
474 | 474 | return result; |
|
475 | 475 | } |
|
476 | 476 | |
|
477 | 477 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
478 | 478 | { |
|
479 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0). | |
|
479 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
|
480 | 480 | * |
|
481 | 481 | * @param TC points to the TeleCommand packet that is being processed |
|
482 | 482 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
483 | 483 | * |
|
484 | 484 | */ |
|
485 | 485 | |
|
486 | 486 | int status; |
|
487 | 487 | |
|
488 | 488 | status = LFR_SUCCESSFUL; |
|
489 | 489 | |
|
490 | 490 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
491 | 491 | |
|
492 | 492 | return status; |
|
493 | 493 | } |
|
494 | 494 | |
|
495 | 495 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
496 | 496 | { |
|
497 | 497 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
498 | 498 | * |
|
499 | 499 | * @param TC points to the TeleCommand packet that is being processed |
|
500 | 500 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
501 | 501 | * |
|
502 | 502 | */ |
|
503 | 503 | |
|
504 | 504 | int status; |
|
505 | 505 | |
|
506 | 506 | status = LFR_SUCCESSFUL; |
|
507 | 507 | |
|
508 | 508 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
509 | 509 | |
|
510 | 510 | return status; |
|
511 | 511 | } |
|
512 | 512 | |
|
513 | 513 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
514 | 514 | { |
|
515 | 515 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
516 | 516 | * |
|
517 | 517 | * @param TC points to the TeleCommand packet that is being processed |
|
518 | 518 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
519 | 519 | * |
|
520 | 520 | */ |
|
521 | 521 | |
|
522 | 522 | int status; |
|
523 | 523 | |
|
524 | 524 | status = LFR_SUCCESSFUL; |
|
525 | 525 | |
|
526 | 526 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
527 | 527 | |
|
528 | 528 | return status; |
|
529 | 529 | } |
|
530 | 530 | |
|
531 | 531 | //********************** |
|
532 | 532 | // BURST MODE PARAMETERS |
|
533 | 533 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
534 | 534 | { |
|
535 | 535 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
536 | 536 | * |
|
537 | 537 | * @param TC points to the TeleCommand packet that is being processed |
|
538 | 538 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
539 | 539 | * |
|
540 | 540 | */ |
|
541 | 541 | |
|
542 | 542 | int status; |
|
543 | 543 | |
|
544 | 544 | status = LFR_SUCCESSFUL; |
|
545 | 545 | |
|
546 | 546 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
547 | 547 | |
|
548 | 548 | return status; |
|
549 | 549 | } |
|
550 | 550 | |
|
551 | 551 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
552 | 552 | { |
|
553 | 553 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
554 | 554 | * |
|
555 | 555 | * @param TC points to the TeleCommand packet that is being processed |
|
556 | 556 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
557 | 557 | * |
|
558 | 558 | */ |
|
559 | 559 | |
|
560 | 560 | int status; |
|
561 | 561 | |
|
562 | 562 | status = LFR_SUCCESSFUL; |
|
563 | 563 | |
|
564 | 564 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
565 | 565 | |
|
566 | 566 | return status; |
|
567 | 567 | } |
|
568 | 568 | |
|
569 | 569 | //********************* |
|
570 | 570 | // SBM1 MODE PARAMETERS |
|
571 | 571 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
572 | 572 | { |
|
573 | 573 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
574 | 574 | * |
|
575 | 575 | * @param TC points to the TeleCommand packet that is being processed |
|
576 | 576 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
577 | 577 | * |
|
578 | 578 | */ |
|
579 | 579 | |
|
580 | 580 | int status; |
|
581 | 581 | |
|
582 | 582 | status = LFR_SUCCESSFUL; |
|
583 | 583 | |
|
584 | 584 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
585 | 585 | |
|
586 | 586 | return status; |
|
587 | 587 | } |
|
588 | 588 | |
|
589 | 589 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
590 | 590 | { |
|
591 | 591 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
592 | 592 | * |
|
593 | 593 | * @param TC points to the TeleCommand packet that is being processed |
|
594 | 594 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
595 | 595 | * |
|
596 | 596 | */ |
|
597 | 597 | |
|
598 | 598 | int status; |
|
599 | 599 | |
|
600 | 600 | status = LFR_SUCCESSFUL; |
|
601 | 601 | |
|
602 | 602 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
603 | 603 | |
|
604 | 604 | return status; |
|
605 | 605 | } |
|
606 | 606 | |
|
607 | 607 | //********************* |
|
608 | 608 | // SBM2 MODE PARAMETERS |
|
609 | 609 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
610 | 610 | { |
|
611 | 611 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
612 | 612 | * |
|
613 | 613 | * @param TC points to the TeleCommand packet that is being processed |
|
614 | 614 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
615 | 615 | * |
|
616 | 616 | */ |
|
617 | 617 | |
|
618 | 618 | int status; |
|
619 | 619 | |
|
620 | 620 | status = LFR_SUCCESSFUL; |
|
621 | 621 | |
|
622 | 622 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
623 | 623 | |
|
624 | 624 | return status; |
|
625 | 625 | } |
|
626 | 626 | |
|
627 | 627 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
628 | 628 | { |
|
629 | 629 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
630 | 630 | * |
|
631 | 631 | * @param TC points to the TeleCommand packet that is being processed |
|
632 | 632 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
633 | 633 | * |
|
634 | 634 | */ |
|
635 | 635 | |
|
636 | 636 | int status; |
|
637 | 637 | |
|
638 | 638 | status = LFR_SUCCESSFUL; |
|
639 | 639 | |
|
640 | 640 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
641 | 641 | |
|
642 | 642 | return status; |
|
643 | 643 | } |
|
644 | 644 | |
|
645 | 645 | |
|
646 | 646 | //******************* |
|
647 | 647 | // TC_LFR_UPDATE_INFO |
|
648 | 648 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
649 | 649 | { |
|
650 | 650 | unsigned int status; |
|
651 | 651 | |
|
652 | 652 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
653 | 653 | || (mode == LFR_MODE_BURST) |
|
654 | 654 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
655 | 655 | { |
|
656 | 656 | status = LFR_SUCCESSFUL; |
|
657 | 657 | } |
|
658 | 658 | else |
|
659 | 659 | { |
|
660 | 660 | status = LFR_DEFAULT; |
|
661 | 661 | } |
|
662 | 662 | |
|
663 | 663 | return status; |
|
664 | 664 | } |
|
665 | 665 | |
|
666 | 666 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
667 | 667 | { |
|
668 | 668 | unsigned int status; |
|
669 | 669 | |
|
670 | 670 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
671 | 671 | || (mode == TDS_MODE_BURST) |
|
672 | 672 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
673 | 673 | || (mode == TDS_MODE_LFM)) |
|
674 | 674 | { |
|
675 | 675 | status = LFR_SUCCESSFUL; |
|
676 | 676 | } |
|
677 | 677 | else |
|
678 | 678 | { |
|
679 | 679 | status = LFR_DEFAULT; |
|
680 | 680 | } |
|
681 | 681 | |
|
682 | 682 | return status; |
|
683 | 683 | } |
|
684 | 684 | |
|
685 | 685 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
686 | 686 | { |
|
687 | 687 | unsigned int status; |
|
688 | 688 | |
|
689 | 689 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
690 | 690 | || (mode == THR_MODE_BURST)) |
|
691 | 691 | { |
|
692 | 692 | status = LFR_SUCCESSFUL; |
|
693 | 693 | } |
|
694 | 694 | else |
|
695 | 695 | { |
|
696 | 696 | status = LFR_DEFAULT; |
|
697 | 697 | } |
|
698 | 698 | |
|
699 | 699 | return status; |
|
700 | 700 | } |
|
701 | 701 | |
|
702 | 702 | //********** |
|
703 | 703 | // init dump |
|
704 | 704 | |
|
705 | 705 | void init_parameter_dump( void ) |
|
706 | 706 | { |
|
707 | 707 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
708 | 708 | * |
|
709 | 709 | */ |
|
710 | 710 | |
|
711 | 711 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
712 | 712 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
713 | 713 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
714 | 714 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
715 | 715 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
716 | 716 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
717 | 717 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
718 | 718 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
719 | 719 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
720 | 720 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
721 | 721 | // DATA FIELD HEADER |
|
722 | 722 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
723 | 723 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
724 | 724 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
725 | 725 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
726 | 726 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
727 | 727 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
728 | 728 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
729 | 729 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
730 | 730 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
731 | 731 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
732 | 732 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
733 | 733 | |
|
734 | 734 | //****************** |
|
735 | 735 | // COMMON PARAMETERS |
|
736 | 736 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; |
|
737 | 737 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; |
|
738 | 738 | |
|
739 | 739 | //****************** |
|
740 | 740 | // NORMAL PARAMETERS |
|
741 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8); | |
|
742 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L ); | |
|
743 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8); | |
|
744 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P ); | |
|
745 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8); | |
|
746 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P ); | |
|
747 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0; | |
|
748 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1; | |
|
749 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3; | |
|
741 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); | |
|
742 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
|
743 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); | |
|
744 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
|
745 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); | |
|
746 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
|
747 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
|
748 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
|
749 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
|
750 | 750 | |
|
751 | 751 | //***************** |
|
752 | 752 | // BURST PARAMETERS |
|
753 | 753 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
754 | 754 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
755 | 755 | |
|
756 | 756 | //**************** |
|
757 | 757 | // SBM1 PARAMETERS |
|
758 | 758 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
759 | 759 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
760 | 760 | |
|
761 | 761 | //**************** |
|
762 | 762 | // SBM2 PARAMETERS |
|
763 | 763 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
764 | 764 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
765 | 765 | } |
|
766 | 766 | |
|
767 | 767 | |
|
768 | 768 | |
|
769 | 769 | |
|
770 | 770 | |
|
771 | 771 | |
|
772 | 772 |
@@ -1,1310 +1,1323 | |||
|
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 | rtems_status_code spare_status; | |
|
71 | 72 | |
|
72 | 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 |
|
73 | 74 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
74 | 75 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
75 | 76 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
76 | 77 | // (1) change the receiving buffer for the waveform picker |
|
77 | 78 | ring_node_to_send_cwf_f3 = current_ring_node_f3; |
|
78 | 79 | current_ring_node_f3 = current_ring_node_f3->next; |
|
79 | 80 | waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; |
|
80 | 81 | // (2) send an event for the waveforms transmission |
|
81 | 82 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
82 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
83 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
83 | 84 | } |
|
84 | 85 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2); |
|
85 | 86 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
86 | 87 | } |
|
87 | 88 | } |
|
88 | 89 | |
|
89 | 90 | switch(lfrCurrentMode) |
|
90 | 91 | { |
|
91 | 92 | //******** |
|
92 | 93 | // STANDBY |
|
93 | 94 | case(LFR_MODE_STANDBY): |
|
94 | 95 | break; |
|
95 | 96 | |
|
96 | 97 | //****** |
|
97 | 98 | // NORMAL |
|
98 | 99 | case(LFR_MODE_NORMAL): |
|
99 | 100 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits |
|
100 | 101 | { |
|
101 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
102 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
102 | 103 | } |
|
103 | 104 | if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits |
|
104 | 105 | { |
|
105 | 106 | // change F0 ring node |
|
106 | 107 | ring_node_to_send_swf_f0 = current_ring_node_f0; |
|
107 | 108 | current_ring_node_f0 = current_ring_node_f0->next; |
|
108 | 109 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; |
|
109 | 110 | // change F1 ring node |
|
110 | 111 | ring_node_to_send_swf_f1 = current_ring_node_f1; |
|
111 | 112 | current_ring_node_f1 = current_ring_node_f1->next; |
|
112 | 113 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
113 | 114 | // change F2 ring node |
|
114 | 115 | ring_node_to_send_swf_f2 = current_ring_node_f2; |
|
115 | 116 | current_ring_node_f2 = current_ring_node_f2->next; |
|
116 | 117 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
117 | 118 | // |
|
118 | 119 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) |
|
119 | 120 | { |
|
120 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
121 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
121 | 122 | } |
|
122 | 123 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] |
|
123 | 124 | } |
|
124 | 125 | break; |
|
125 | 126 | |
|
126 | 127 | //****** |
|
127 | 128 | // BURST |
|
128 | 129 | case(LFR_MODE_BURST): |
|
129 | 130 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
130 | 131 | // (1) change the receiving buffer for the waveform picker |
|
131 | 132 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
132 | 133 | current_ring_node_f2 = current_ring_node_f2->next; |
|
133 | 134 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
134 | 135 | // (2) send an event for the waveforms transmission |
|
135 | 136 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
136 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
137 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
|
137 | 138 | } |
|
138 | 139 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
139 | 140 | } |
|
140 | 141 | break; |
|
141 | 142 | |
|
142 | 143 | //***** |
|
143 | 144 | // SBM1 |
|
144 | 145 | case(LFR_MODE_SBM1): |
|
145 | 146 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
146 | 147 | // (1) change the receiving buffer for the waveform picker |
|
147 | 148 | ring_node_to_send_cwf_f1 = current_ring_node_f1; |
|
148 | 149 | current_ring_node_f1 = current_ring_node_f1->next; |
|
149 | 150 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
150 | 151 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
151 | 152 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
152 | 153 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0 |
|
153 | 154 | } |
|
154 | 155 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
155 | 156 | swf_f0_ready = true; |
|
156 | 157 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
157 | 158 | } |
|
158 | 159 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit |
|
159 | 160 | swf_f2_ready = true; |
|
160 | 161 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 |
|
161 | 162 | } |
|
162 | 163 | break; |
|
163 | 164 | |
|
164 | 165 | //***** |
|
165 | 166 | // SBM2 |
|
166 | 167 | case(LFR_MODE_SBM2): |
|
167 | 168 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
168 | 169 | // (1) change the receiving buffer for the waveform picker |
|
169 | 170 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
170 | 171 | current_ring_node_f2 = current_ring_node_f2->next; |
|
171 | 172 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
172 | 173 | // (2) send an event for the waveforms transmission |
|
173 | 174 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
174 | 175 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
175 | 176 | } |
|
176 | 177 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
177 | 178 | swf_f0_ready = true; |
|
178 | 179 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
179 | 180 | } |
|
180 | 181 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
181 | 182 | swf_f1_ready = true; |
|
182 | 183 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0 |
|
183 | 184 | } |
|
184 | 185 | break; |
|
185 | 186 | |
|
186 | 187 | //******** |
|
187 | 188 | // DEFAULT |
|
188 | 189 | default: |
|
189 | 190 | break; |
|
190 | 191 | } |
|
191 | 192 | } |
|
192 | 193 | |
|
193 | 194 | //************ |
|
194 | 195 | // RTEMS TASKS |
|
195 | 196 | |
|
196 | 197 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
197 | 198 | { |
|
198 | 199 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
199 | 200 | * |
|
200 | 201 | * @param unused is the starting argument of the RTEMS task |
|
201 | 202 | * |
|
202 | 203 | * The following data packets are sent by this task: |
|
203 | 204 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
204 | 205 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
205 | 206 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
206 | 207 | * |
|
207 | 208 | */ |
|
208 | 209 | |
|
209 | 210 | rtems_event_set event_out; |
|
210 | 211 | rtems_id queue_id; |
|
211 | 212 | rtems_status_code status; |
|
212 | 213 | |
|
213 | 214 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
214 | 215 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
215 | 216 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
216 | 217 | |
|
217 | 218 | status = get_message_queue_id_send( &queue_id ); |
|
218 | 219 | if (status != RTEMS_SUCCESSFUL) |
|
219 | 220 | { |
|
220 | 221 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
221 | 222 | } |
|
222 | 223 | |
|
223 | 224 | BOOT_PRINTF("in WFRM ***\n") |
|
224 | 225 | |
|
225 | 226 | while(1){ |
|
226 | 227 | // wait for an RTEMS_EVENT |
|
227 | 228 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
228 | 229 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
229 | 230 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
230 | 231 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
231 | 232 | { |
|
232 | 233 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
233 | 234 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
234 | 235 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
235 | 236 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
236 | 237 | } |
|
237 | 238 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
238 | 239 | { |
|
239 | 240 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
240 | 241 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
241 | 242 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
242 | 243 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
243 | 244 | } |
|
244 | 245 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
245 | 246 | { |
|
246 | 247 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
247 | 248 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
248 | 249 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
249 | 250 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
250 | 251 | } |
|
251 | 252 | } |
|
252 | 253 | } |
|
253 | 254 | |
|
254 | 255 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
255 | 256 | { |
|
256 | 257 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
257 | 258 | * |
|
258 | 259 | * @param unused is the starting argument of the RTEMS task |
|
259 | 260 | * |
|
260 | 261 | * The following data packet is sent by this task: |
|
261 | 262 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
262 | 263 | * |
|
263 | 264 | */ |
|
264 | 265 | |
|
265 | 266 | rtems_event_set event_out; |
|
266 | 267 | rtems_id queue_id; |
|
267 | 268 | rtems_status_code status; |
|
268 | 269 | |
|
269 | 270 | init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 ); |
|
270 | 271 | init_header_continuous_cwf3_light_table( headerCWF_F3_light ); |
|
271 | 272 | |
|
272 | 273 | status = get_message_queue_id_send( &queue_id ); |
|
273 | 274 | if (status != RTEMS_SUCCESSFUL) |
|
274 | 275 | { |
|
275 | 276 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
276 | 277 | } |
|
277 | 278 | |
|
278 | 279 | BOOT_PRINTF("in CWF3 ***\n") |
|
279 | 280 | |
|
280 | 281 | while(1){ |
|
281 | 282 | // wait for an RTEMS_EVENT |
|
282 | 283 | rtems_event_receive( RTEMS_EVENT_0, |
|
283 | 284 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
284 | 285 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
285 | 286 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
286 | 287 | { |
|
287 | 288 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
288 | 289 | { |
|
289 | 290 | PRINTF("send CWF_LONG_F3\n") |
|
290 | 291 | send_waveform_CWF( |
|
291 | 292 | (volatile int*) ring_node_to_send_cwf_f3->buffer_address, |
|
292 | 293 | SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
293 | 294 | } |
|
294 | 295 | else |
|
295 | 296 | { |
|
296 | 297 | PRINTF("send CWF_F3 (light)\n") |
|
297 | 298 | send_waveform_CWF3_light( |
|
298 | 299 | (volatile int*) ring_node_to_send_cwf_f3->buffer_address, |
|
299 | 300 | headerCWF_F3_light, queue_id ); |
|
300 | 301 | } |
|
301 | 302 | |
|
302 | 303 | } |
|
303 | 304 | else |
|
304 | 305 | { |
|
305 | 306 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
306 | 307 | } |
|
307 | 308 | } |
|
308 | 309 | } |
|
309 | 310 | |
|
310 | 311 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
311 | 312 | { |
|
312 | 313 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
313 | 314 | * |
|
314 | 315 | * @param unused is the starting argument of the RTEMS task |
|
315 | 316 | * |
|
316 | 317 | * The following data packet is sent by this function: |
|
317 | 318 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
318 | 319 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
319 | 320 | * |
|
320 | 321 | */ |
|
321 | 322 | |
|
322 | 323 | rtems_event_set event_out; |
|
323 | 324 | rtems_id queue_id; |
|
324 | 325 | rtems_status_code status; |
|
325 | 326 | |
|
326 | 327 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
327 | 328 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
328 | 329 | |
|
329 | 330 | status = get_message_queue_id_send( &queue_id ); |
|
330 | 331 | if (status != RTEMS_SUCCESSFUL) |
|
331 | 332 | { |
|
332 | 333 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
333 | 334 | } |
|
334 | 335 | |
|
335 | 336 | BOOT_PRINTF("in CWF2 ***\n") |
|
336 | 337 | |
|
337 | 338 | while(1){ |
|
338 | 339 | // wait for an RTEMS_EVENT |
|
339 | 340 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
340 | 341 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
341 | 342 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
342 | 343 | { |
|
343 | 344 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
344 | 345 | } |
|
345 | 346 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
346 | 347 | { |
|
347 | 348 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
348 | 349 | // launch snapshot extraction if needed |
|
349 | 350 | if (extractSWF == true) |
|
350 | 351 | { |
|
351 | 352 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
352 | 353 | // extract the snapshot |
|
353 | 354 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); |
|
354 | 355 | // send the snapshot when built |
|
355 | 356 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
356 | 357 | extractSWF = false; |
|
357 | 358 | } |
|
358 | 359 | if (swf_f0_ready && swf_f1_ready) |
|
359 | 360 | { |
|
360 | 361 | extractSWF = true; |
|
361 | 362 | swf_f0_ready = false; |
|
362 | 363 | swf_f1_ready = false; |
|
363 | 364 | } |
|
364 | 365 | } |
|
365 | 366 | } |
|
366 | 367 | } |
|
367 | 368 | |
|
368 | 369 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
369 | 370 | { |
|
370 | 371 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
371 | 372 | * |
|
372 | 373 | * @param unused is the starting argument of the RTEMS task |
|
373 | 374 | * |
|
374 | 375 | * The following data packet is sent by this function: |
|
375 | 376 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
376 | 377 | * |
|
377 | 378 | */ |
|
378 | 379 | |
|
379 | 380 | rtems_event_set event_out; |
|
380 | 381 | rtems_id queue_id; |
|
381 | 382 | rtems_status_code status; |
|
382 | 383 | |
|
383 | 384 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
384 | 385 | |
|
385 | 386 | status = get_message_queue_id_send( &queue_id ); |
|
386 | 387 | if (status != RTEMS_SUCCESSFUL) |
|
387 | 388 | { |
|
388 | 389 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
389 | 390 | } |
|
390 | 391 | |
|
391 | 392 | BOOT_PRINTF("in CWF1 ***\n") |
|
392 | 393 | |
|
393 | 394 | while(1){ |
|
394 | 395 | // wait for an RTEMS_EVENT |
|
395 | 396 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
396 | 397 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
397 | 398 | send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
398 | 399 | // launch snapshot extraction if needed |
|
399 | 400 | if (extractSWF == true) |
|
400 | 401 | { |
|
401 | 402 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1; |
|
402 | 403 | // launch the snapshot extraction |
|
403 | 404 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); |
|
404 | 405 | extractSWF = false; |
|
405 | 406 | } |
|
406 | 407 | if (swf_f0_ready == true) |
|
407 | 408 | { |
|
408 | 409 | extractSWF = true; |
|
409 | 410 | swf_f0_ready = false; // this step shall be executed only one time |
|
410 | 411 | } |
|
411 | 412 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction |
|
412 | 413 | { |
|
413 | 414 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); |
|
414 | 415 | swf_f1_ready = false; |
|
415 | 416 | swf_f2_ready = false; |
|
416 | 417 | } |
|
417 | 418 | } |
|
418 | 419 | } |
|
419 | 420 | |
|
420 | 421 | rtems_task swbd_task(rtems_task_argument argument) |
|
421 | 422 | { |
|
422 | 423 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
423 | 424 | * |
|
424 | 425 | * @param unused is the starting argument of the RTEMS task |
|
425 | 426 | * |
|
426 | 427 | */ |
|
427 | 428 | |
|
428 | 429 | rtems_event_set event_out; |
|
429 | 430 | |
|
430 | 431 | BOOT_PRINTF("in SWBD ***\n") |
|
431 | 432 | |
|
432 | 433 | while(1){ |
|
433 | 434 | // wait for an RTEMS_EVENT |
|
434 | 435 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
435 | 436 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
436 | 437 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
437 | 438 | { |
|
438 | 439 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 ); |
|
439 | 440 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
440 | 441 | } |
|
441 | 442 | else |
|
442 | 443 | { |
|
443 | 444 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
444 | 445 | } |
|
445 | 446 | } |
|
446 | 447 | } |
|
447 | 448 | |
|
448 | 449 | //****************** |
|
449 | 450 | // general functions |
|
450 | 451 | |
|
451 | 452 | void WFP_init_rings( void ) |
|
452 | 453 | { |
|
453 | 454 | // F0 RING |
|
454 | 455 | init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 ); |
|
455 | 456 | // F1 RING |
|
456 | 457 | init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 ); |
|
457 | 458 | // F2 RING |
|
458 | 459 | init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 ); |
|
459 | 460 | // F3 RING |
|
460 | 461 | init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 ); |
|
461 | 462 | |
|
462 | 463 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
463 | 464 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
464 | 465 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
465 | 466 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
466 | 467 | } |
|
467 | 468 | |
|
468 | 469 | void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] ) |
|
469 | 470 | { |
|
470 | 471 | unsigned char i; |
|
471 | 472 | |
|
472 | 473 | waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ]; |
|
473 | 474 | waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ]; |
|
474 | 475 | waveform_ring[0].buffer_address = (int) &wfrm[0]; |
|
475 | 476 | |
|
476 | 477 | waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ]; |
|
477 | 478 | waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ]; |
|
478 | 479 | waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ]; |
|
479 | 480 | |
|
480 | 481 | for(i=1; i<nbNodes-1; i++) |
|
481 | 482 | { |
|
482 | 483 | waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ]; |
|
483 | 484 | waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ]; |
|
484 | 485 | waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ]; |
|
485 | 486 | } |
|
486 | 487 | } |
|
487 | 488 | |
|
488 | 489 | void WFP_reset_current_ring_nodes( void ) |
|
489 | 490 | { |
|
490 | 491 | current_ring_node_f0 = waveform_ring_f0; |
|
491 | 492 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
492 | 493 | |
|
493 | 494 | current_ring_node_f1 = waveform_ring_f1; |
|
494 | 495 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
495 | 496 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
496 | 497 | |
|
497 | 498 | current_ring_node_f2 = waveform_ring_f2; |
|
498 | 499 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
499 | 500 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
500 | 501 | |
|
501 | 502 | current_ring_node_f3 = waveform_ring_f3; |
|
502 | 503 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
503 | 504 | } |
|
504 | 505 | |
|
505 | 506 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
506 | 507 | { |
|
507 | 508 | unsigned char i; |
|
509 | int return_value; | |
|
510 | ||
|
511 | return_value = LFR_SUCCESSFUL; | |
|
508 | 512 | |
|
509 | 513 | for (i=0; i<7; i++) |
|
510 | 514 | { |
|
511 | 515 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
512 | 516 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
513 | 517 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
514 | 518 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
515 | 519 | headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
516 | 520 | headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
517 | 521 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
518 | 522 | if (i == 6) |
|
519 | 523 | { |
|
520 | 524 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
521 | 525 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
522 | 526 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
523 | 527 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
524 | 528 | } |
|
525 | 529 | else |
|
526 | 530 | { |
|
527 | 531 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
528 | 532 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
529 | 533 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
530 | 534 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
531 | 535 | } |
|
532 | 536 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
533 | 537 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
534 | 538 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
535 | 539 | // DATA FIELD HEADER |
|
536 | 540 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
537 | 541 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
538 | 542 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
539 | 543 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
540 | 544 | // AUXILIARY DATA HEADER |
|
541 | 545 | headerSWF[ i ].time[0] = 0x00; |
|
542 | 546 | headerSWF[ i ].time[0] = 0x00; |
|
543 | 547 | headerSWF[ i ].time[0] = 0x00; |
|
544 | 548 | headerSWF[ i ].time[0] = 0x00; |
|
545 | 549 | headerSWF[ i ].time[0] = 0x00; |
|
546 | 550 | headerSWF[ i ].time[0] = 0x00; |
|
547 | 551 | headerSWF[ i ].sid = sid; |
|
548 | 552 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
549 | 553 | } |
|
550 | return LFR_SUCCESSFUL; | |
|
554 | ||
|
555 | return return_value; | |
|
551 | 556 | } |
|
552 | 557 | |
|
553 | 558 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
554 | 559 | { |
|
555 | 560 | unsigned int i; |
|
561 | int return_value; | |
|
562 | ||
|
563 | return_value = LFR_SUCCESSFUL; | |
|
556 | 564 | |
|
557 | 565 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) |
|
558 | 566 | { |
|
559 | 567 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
560 | 568 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
561 | 569 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
562 | 570 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
563 | 571 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
564 | 572 | { |
|
565 | 573 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
566 | 574 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
567 | 575 | } |
|
568 | 576 | else |
|
569 | 577 | { |
|
570 | 578 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
571 | 579 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
572 | 580 | } |
|
573 | 581 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
574 | 582 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
575 | 583 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
576 | 584 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
577 | 585 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
578 | 586 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
579 | 587 | // DATA FIELD HEADER |
|
580 | 588 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
581 | 589 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
582 | 590 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
583 | 591 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
584 | 592 | // AUXILIARY DATA HEADER |
|
585 | 593 | headerCWF[ i ].sid = sid; |
|
586 | 594 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
587 | 595 | headerCWF[ i ].time[0] = 0x00; |
|
588 | 596 | headerCWF[ i ].time[0] = 0x00; |
|
589 | 597 | headerCWF[ i ].time[0] = 0x00; |
|
590 | 598 | headerCWF[ i ].time[0] = 0x00; |
|
591 | 599 | headerCWF[ i ].time[0] = 0x00; |
|
592 | 600 | headerCWF[ i ].time[0] = 0x00; |
|
593 | 601 | } |
|
594 | return LFR_SUCCESSFUL; | |
|
602 | ||
|
603 | return return_value; | |
|
595 | 604 | } |
|
596 | 605 | |
|
597 | 606 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
598 | 607 | { |
|
599 | 608 | unsigned int i; |
|
609 | int return_value; | |
|
610 | ||
|
611 | return_value = LFR_SUCCESSFUL; | |
|
600 | 612 | |
|
601 | 613 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) |
|
602 | 614 | { |
|
603 | 615 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
604 | 616 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
605 | 617 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
606 | 618 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
607 | 619 | |
|
608 | 620 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
609 | 621 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
610 | 622 | |
|
611 | 623 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
612 | 624 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
613 | 625 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
614 | 626 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
615 | 627 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
616 | 628 | |
|
617 | 629 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
618 | 630 | // DATA FIELD HEADER |
|
619 | 631 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
620 | 632 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
621 | 633 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
622 | 634 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
623 | 635 | // AUXILIARY DATA HEADER |
|
624 | 636 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
625 | 637 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
626 | 638 | headerCWF[ i ].time[0] = 0x00; |
|
627 | 639 | headerCWF[ i ].time[0] = 0x00; |
|
628 | 640 | headerCWF[ i ].time[0] = 0x00; |
|
629 | 641 | headerCWF[ i ].time[0] = 0x00; |
|
630 | 642 | headerCWF[ i ].time[0] = 0x00; |
|
631 | 643 | headerCWF[ i ].time[0] = 0x00; |
|
632 | 644 | } |
|
633 | return LFR_SUCCESSFUL; | |
|
645 | ||
|
646 | return return_value; | |
|
634 | 647 | } |
|
635 | 648 | |
|
636 | 649 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
637 | 650 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
638 | 651 | { |
|
639 | 652 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
640 | 653 | * |
|
641 | 654 | * @param waveform points to the buffer containing the data that will be send. |
|
642 | 655 | * @param sid is the source identifier of the data that will be sent. |
|
643 | 656 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
644 | 657 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
645 | 658 | * contain information to setup the transmission of the data packets. |
|
646 | 659 | * |
|
647 | 660 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
648 | 661 | * |
|
649 | 662 | */ |
|
650 | 663 | |
|
651 | 664 | unsigned int i; |
|
652 | 665 | int ret; |
|
653 | 666 | unsigned int coarseTime; |
|
654 | 667 | unsigned int fineTime; |
|
655 | 668 | rtems_status_code status; |
|
656 | 669 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
657 | 670 | |
|
658 | 671 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header |
|
659 | 672 | spw_ioctl_send_SWF.options = 0; |
|
660 | 673 | |
|
661 | 674 | ret = LFR_DEFAULT; |
|
662 | 675 | |
|
663 | 676 | coarseTime = waveform[0]; |
|
664 | 677 | fineTime = waveform[1]; |
|
665 | 678 | |
|
666 | 679 | for (i=0; i<7; i++) // send waveform |
|
667 | 680 | { |
|
668 | 681 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
669 | 682 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
670 | 683 | // BUILD THE DATA |
|
671 | 684 | if (i==6) { |
|
672 | 685 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
673 | 686 | } |
|
674 | 687 | else { |
|
675 | 688 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
676 | 689 | } |
|
677 | 690 | // SET PACKET SEQUENCE COUNTER |
|
678 | 691 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); |
|
679 | 692 | // SET PACKET TIME |
|
680 | 693 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime ); |
|
681 | 694 | // |
|
682 | 695 | headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0]; |
|
683 | 696 | headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1]; |
|
684 | 697 | headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2]; |
|
685 | 698 | headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3]; |
|
686 | 699 | headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4]; |
|
687 | 700 | headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5]; |
|
688 | 701 | // SEND PACKET |
|
689 | 702 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
690 | 703 | if (status != RTEMS_SUCCESSFUL) { |
|
691 | 704 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
692 | 705 | ret = LFR_DEFAULT; |
|
693 | 706 | } |
|
694 | 707 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds |
|
695 | 708 | } |
|
696 | 709 | |
|
697 | 710 | return ret; |
|
698 | 711 | } |
|
699 | 712 | |
|
700 | 713 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
701 | 714 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
702 | 715 | { |
|
703 | 716 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
704 | 717 | * |
|
705 | 718 | * @param waveform points to the buffer containing the data that will be send. |
|
706 | 719 | * @param sid is the source identifier of the data that will be sent. |
|
707 | 720 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
708 | 721 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
709 | 722 | * contain information to setup the transmission of the data packets. |
|
710 | 723 | * |
|
711 | 724 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
712 | 725 | * |
|
713 | 726 | */ |
|
714 | 727 | |
|
715 | 728 | unsigned int i; |
|
716 | 729 | int ret; |
|
717 | 730 | unsigned int coarseTime; |
|
718 | 731 | unsigned int fineTime; |
|
719 | 732 | rtems_status_code status; |
|
720 | 733 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
721 | 734 | |
|
722 | 735 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
723 | 736 | spw_ioctl_send_CWF.options = 0; |
|
724 | 737 | |
|
725 | 738 | ret = LFR_DEFAULT; |
|
726 | 739 | |
|
727 | 740 | coarseTime = waveform[0]; |
|
728 | 741 | fineTime = waveform[1]; |
|
729 | 742 | |
|
730 | 743 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
731 | 744 | { |
|
732 | 745 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
733 | 746 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
734 | 747 | // BUILD THE DATA |
|
735 | 748 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
736 | 749 | // SET PACKET SEQUENCE COUNTER |
|
737 | 750 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); |
|
738 | 751 | // SET PACKET TIME |
|
739 | 752 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime); |
|
740 | 753 | // |
|
741 | 754 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
742 | 755 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
743 | 756 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
744 | 757 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
745 | 758 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
746 | 759 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
747 | 760 | // SEND PACKET |
|
748 | 761 | if (sid == SID_NORM_CWF_LONG_F3) |
|
749 | 762 | { |
|
750 | 763 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
751 | 764 | if (status != RTEMS_SUCCESSFUL) { |
|
752 | 765 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
753 | 766 | ret = LFR_DEFAULT; |
|
754 | 767 | } |
|
755 | 768 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
756 | 769 | } |
|
757 | 770 | else |
|
758 | 771 | { |
|
759 | 772 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
760 | 773 | if (status != RTEMS_SUCCESSFUL) { |
|
761 | 774 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
762 | 775 | ret = LFR_DEFAULT; |
|
763 | 776 | } |
|
764 | 777 | } |
|
765 | 778 | } |
|
766 | 779 | |
|
767 | 780 | return ret; |
|
768 | 781 | } |
|
769 | 782 | |
|
770 | 783 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
771 | 784 | { |
|
772 | 785 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
773 | 786 | * |
|
774 | 787 | * @param waveform points to the buffer containing the data that will be send. |
|
775 | 788 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
776 | 789 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
777 | 790 | * contain information to setup the transmission of the data packets. |
|
778 | 791 | * |
|
779 | 792 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
780 | 793 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
781 | 794 | * |
|
782 | 795 | */ |
|
783 | 796 | |
|
784 | 797 | unsigned int i; |
|
785 | 798 | int ret; |
|
786 | 799 | unsigned int coarseTime; |
|
787 | 800 | unsigned int fineTime; |
|
788 | 801 | rtems_status_code status; |
|
789 | 802 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
790 | 803 | char *sample; |
|
791 | 804 | |
|
792 | 805 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
793 | 806 | spw_ioctl_send_CWF.options = 0; |
|
794 | 807 | |
|
795 | 808 | ret = LFR_DEFAULT; |
|
796 | 809 | |
|
797 | 810 | //********************** |
|
798 | 811 | // BUILD CWF3_light DATA |
|
799 | 812 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
800 | 813 | { |
|
801 | 814 | sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
802 | 815 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; |
|
803 | 816 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; |
|
804 | 817 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; |
|
805 | 818 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; |
|
806 | 819 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; |
|
807 | 820 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; |
|
808 | 821 | } |
|
809 | 822 | |
|
810 | 823 | coarseTime = waveform[0]; |
|
811 | 824 | fineTime = waveform[1]; |
|
812 | 825 | |
|
813 | 826 | //********************* |
|
814 | 827 | // SEND CWF3_light DATA |
|
815 | 828 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
816 | 829 | { |
|
817 | 830 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES]; |
|
818 | 831 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
819 | 832 | // BUILD THE DATA |
|
820 | 833 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
821 | 834 | // SET PACKET SEQUENCE COUNTER |
|
822 | 835 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); |
|
823 | 836 | // SET PACKET TIME |
|
824 | 837 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime ); |
|
825 | 838 | // |
|
826 | 839 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
827 | 840 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
828 | 841 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
829 | 842 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
830 | 843 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
831 | 844 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
832 | 845 | // SEND PACKET |
|
833 | 846 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
834 | 847 | if (status != RTEMS_SUCCESSFUL) { |
|
835 | 848 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
836 | 849 | ret = LFR_DEFAULT; |
|
837 | 850 | } |
|
838 | 851 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
839 | 852 | } |
|
840 | 853 | |
|
841 | 854 | return ret; |
|
842 | 855 | } |
|
843 | 856 | |
|
844 | 857 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
845 | 858 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
846 | 859 | { |
|
847 | 860 | unsigned long long int acquisitionTimeAsLong; |
|
848 | 861 | unsigned char localAcquisitionTime[6]; |
|
849 | 862 | double deltaT; |
|
850 | 863 | |
|
851 | 864 | deltaT = 0.; |
|
852 | 865 | |
|
853 | 866 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); |
|
854 | 867 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); |
|
855 | 868 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); |
|
856 | 869 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); |
|
857 | 870 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); |
|
858 | 871 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); |
|
859 | 872 | |
|
860 | 873 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
861 | 874 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
862 | 875 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) |
|
863 | 876 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) |
|
864 | 877 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) |
|
865 | 878 | + ( (unsigned long long int) localAcquisitionTime[5] ); |
|
866 | 879 | |
|
867 | 880 | switch( sid ) |
|
868 | 881 | { |
|
869 | 882 | case SID_NORM_SWF_F0: |
|
870 | 883 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
871 | 884 | break; |
|
872 | 885 | |
|
873 | 886 | case SID_NORM_SWF_F1: |
|
874 | 887 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
875 | 888 | break; |
|
876 | 889 | |
|
877 | 890 | case SID_NORM_SWF_F2: |
|
878 | 891 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
879 | 892 | break; |
|
880 | 893 | |
|
881 | 894 | case SID_SBM1_CWF_F1: |
|
882 | 895 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
883 | 896 | break; |
|
884 | 897 | |
|
885 | 898 | case SID_SBM2_CWF_F2: |
|
886 | 899 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
887 | 900 | break; |
|
888 | 901 | |
|
889 | 902 | case SID_BURST_CWF_F2: |
|
890 | 903 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
891 | 904 | break; |
|
892 | 905 | |
|
893 | 906 | case SID_NORM_CWF_F3: |
|
894 | 907 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
895 | 908 | break; |
|
896 | 909 | |
|
897 | 910 | case SID_NORM_CWF_LONG_F3: |
|
898 | 911 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
899 | 912 | break; |
|
900 | 913 | |
|
901 | 914 | default: |
|
902 | 915 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid) |
|
903 | 916 | deltaT = 0.; |
|
904 | 917 | break; |
|
905 | 918 | } |
|
906 | 919 | |
|
907 | 920 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
908 | 921 | // |
|
909 | 922 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
910 | 923 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
911 | 924 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
912 | 925 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
913 | 926 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
914 | 927 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
915 | 928 | |
|
916 | 929 | } |
|
917 | 930 | |
|
918 | 931 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel ) |
|
919 | 932 | { |
|
920 | 933 | unsigned int i; |
|
921 | 934 | unsigned long long int centerTime_asLong; |
|
922 | 935 | unsigned long long int acquisitionTimeF0_asLong; |
|
923 | 936 | unsigned long long int acquisitionTime_asLong; |
|
924 | 937 | unsigned long long int bufferAcquisitionTime_asLong; |
|
925 | 938 | unsigned char *ptr1; |
|
926 | 939 | unsigned char *ptr2; |
|
927 | 940 | unsigned char *timeCharPtr; |
|
928 | 941 | unsigned char nb_ring_nodes; |
|
929 | 942 | unsigned long long int frequency_asLong; |
|
930 | 943 | unsigned long long int nbTicksPerSample_asLong; |
|
931 | 944 | unsigned long long int nbSamplesPart1_asLong; |
|
932 | 945 | unsigned long long int sampleOffset_asLong; |
|
933 | 946 | |
|
934 | 947 | unsigned int deltaT_F0; |
|
935 | 948 | unsigned int deltaT_F1; |
|
936 | 949 | unsigned long long int deltaT_F2; |
|
937 | 950 | |
|
938 | 951 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
939 | 952 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
940 | 953 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
941 | 954 | sampleOffset_asLong = 0x00; |
|
942 | 955 | |
|
943 | 956 | // (1) get the f0 acquisition time |
|
944 | 957 | build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 ); |
|
945 | 958 | |
|
946 | 959 | // (2) compute the central reference time |
|
947 | 960 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
948 | 961 | |
|
949 | 962 | // (3) compute the acquisition time of the current snapshot |
|
950 | 963 | switch(frequencyChannel) |
|
951 | 964 | { |
|
952 | 965 | case 1: // 1 is for F1 = 4096 Hz |
|
953 | 966 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
954 | 967 | nb_ring_nodes = NB_RING_NODES_F1; |
|
955 | 968 | frequency_asLong = 4096; |
|
956 | 969 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
957 | 970 | break; |
|
958 | 971 | case 2: // 2 is for F2 = 256 Hz |
|
959 | 972 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
960 | 973 | nb_ring_nodes = NB_RING_NODES_F2; |
|
961 | 974 | frequency_asLong = 256; |
|
962 | 975 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
963 | 976 | break; |
|
964 | 977 | default: |
|
965 | 978 | acquisitionTime_asLong = centerTime_asLong; |
|
966 | 979 | frequency_asLong = 256; |
|
967 | 980 | nbTicksPerSample_asLong = 256; |
|
968 | 981 | break; |
|
969 | 982 | } |
|
970 | 983 | |
|
971 | 984 | //**************************************************************************** |
|
972 | 985 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
973 | 986 | for (i=0; i<nb_ring_nodes; i++) |
|
974 | 987 | { |
|
975 | 988 | PRINTF1("%d ... ", i) |
|
976 | 989 | build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send ); |
|
977 | 990 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
978 | 991 | { |
|
979 | 992 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
980 | 993 | break; |
|
981 | 994 | } |
|
982 | 995 | ring_node_to_send = ring_node_to_send->previous; |
|
983 | 996 | } |
|
984 | 997 | |
|
985 | 998 | // (5) compute the number of samples to take in the current buffer |
|
986 | 999 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
987 | 1000 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
988 | 1001 | PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
989 | 1002 | |
|
990 | 1003 | // (6) compute the final acquisition time |
|
991 | 1004 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
992 | 1005 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
993 | 1006 | |
|
994 | 1007 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
995 | 1008 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
996 | 1009 | ptr2 = (unsigned char*) wf_snap_extracted; |
|
997 | 1010 | ptr2[0] = ptr1[ 0 + 2 ]; |
|
998 | 1011 | ptr2[1] = ptr1[ 1 + 2 ]; |
|
999 | 1012 | ptr2[2] = ptr1[ 2 + 2 ]; |
|
1000 | 1013 | ptr2[3] = ptr1[ 3 + 2 ]; |
|
1001 | 1014 | ptr2[6] = ptr1[ 4 + 2 ]; |
|
1002 | 1015 | ptr2[7] = ptr1[ 5 + 2 ]; |
|
1003 | 1016 | |
|
1004 | 1017 | // re set the synchronization bit |
|
1005 | 1018 | timeCharPtr = (unsigned char*) ring_node_to_send->buffer_address; |
|
1006 | 1019 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] |
|
1007 | 1020 | |
|
1008 | 1021 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
1009 | 1022 | { |
|
1010 | 1023 | nbSamplesPart1_asLong = 0; |
|
1011 | 1024 | } |
|
1012 | 1025 | // copy the part 1 of the snapshot in the extracted buffer |
|
1013 | 1026 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1014 | 1027 | { |
|
1015 | 1028 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1016 | 1029 | ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
1017 | 1030 | } |
|
1018 | 1031 | // copy the part 2 of the snapshot in the extracted buffer |
|
1019 | 1032 | ring_node_to_send = ring_node_to_send->next; |
|
1020 | 1033 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1021 | 1034 | { |
|
1022 | 1035 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1023 | 1036 | ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET]; |
|
1024 | 1037 | } |
|
1025 | 1038 | } |
|
1026 | 1039 | |
|
1027 | 1040 | void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) |
|
1028 | 1041 | { |
|
1029 | 1042 | unsigned char *acquisitionTimeCharPtr; |
|
1030 | 1043 | |
|
1031 | 1044 | acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address; |
|
1032 | 1045 | |
|
1033 | 1046 | *acquisitionTimeAslong = 0x00; |
|
1034 | 1047 | *acquisitionTimeAslong = ( (unsigned long long int) (acquisitionTimeCharPtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
1035 | 1048 | + ( (unsigned long long int) acquisitionTimeCharPtr[1] << 32 ) |
|
1036 | 1049 | + ( (unsigned long long int) acquisitionTimeCharPtr[2] << 24 ) |
|
1037 | 1050 | + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 16 ) |
|
1038 | 1051 | + ( (unsigned long long int) acquisitionTimeCharPtr[6] << 8 ) |
|
1039 | 1052 | + ( (unsigned long long int) acquisitionTimeCharPtr[7] ); |
|
1040 | 1053 | } |
|
1041 | 1054 | |
|
1042 | 1055 | //************** |
|
1043 | 1056 | // wfp registers |
|
1044 | 1057 | void reset_wfp_burst_enable(void) |
|
1045 | 1058 | { |
|
1046 | 1059 | /** This function resets the waveform picker burst_enable register. |
|
1047 | 1060 | * |
|
1048 | 1061 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1049 | 1062 | * |
|
1050 | 1063 | */ |
|
1051 | 1064 | |
|
1052 | 1065 | waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1053 | 1066 | } |
|
1054 | 1067 | |
|
1055 | 1068 | void reset_wfp_status( void ) |
|
1056 | 1069 | { |
|
1057 | 1070 | /** This function resets the waveform picker status register. |
|
1058 | 1071 | * |
|
1059 | 1072 | * All status bits are set to 0 [new_err full_err full]. |
|
1060 | 1073 | * |
|
1061 | 1074 | */ |
|
1062 | 1075 | |
|
1063 | 1076 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1064 | 1077 | } |
|
1065 | 1078 | |
|
1066 | 1079 | void reset_waveform_picker_regs(void) |
|
1067 | 1080 | { |
|
1068 | 1081 | /** This function resets the waveform picker module registers. |
|
1069 | 1082 | * |
|
1070 | 1083 | * The registers affected by this function are located at the following offset addresses: |
|
1071 | 1084 | * - 0x00 data_shaping |
|
1072 | 1085 | * - 0x04 run_burst_enable |
|
1073 | 1086 | * - 0x08 addr_data_f0 |
|
1074 | 1087 | * - 0x0C addr_data_f1 |
|
1075 | 1088 | * - 0x10 addr_data_f2 |
|
1076 | 1089 | * - 0x14 addr_data_f3 |
|
1077 | 1090 | * - 0x18 status |
|
1078 | 1091 | * - 0x1C delta_snapshot |
|
1079 | 1092 | * - 0x20 delta_f0 |
|
1080 | 1093 | * - 0x24 delta_f0_2 |
|
1081 | 1094 | * - 0x28 delta_f1 |
|
1082 | 1095 | * - 0x2c delta_f2 |
|
1083 | 1096 | * - 0x30 nb_data_by_buffer |
|
1084 | 1097 | * - 0x34 nb_snapshot_param |
|
1085 | 1098 | * - 0x38 start_date |
|
1086 | 1099 | * - 0x3c nb_word_in_buffer |
|
1087 | 1100 | * |
|
1088 | 1101 | */ |
|
1089 | 1102 | |
|
1090 | 1103 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1091 | 1104 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1092 | 1105 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08 |
|
1093 | 1106 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c |
|
1094 | 1107 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 |
|
1095 | 1108 | waveform_picker_regs->addr_data_f3 = current_ring_node_f3->buffer_address; // 0x14 |
|
1096 | 1109 | reset_wfp_status(); // 0x18 |
|
1097 | 1110 | // |
|
1098 | 1111 | set_wfp_delta_snapshot(); // 0x1c |
|
1099 | 1112 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1100 | 1113 | set_wfp_delta_f1(); // 0x28 |
|
1101 | 1114 | set_wfp_delta_f2(); // 0x2c |
|
1102 | 1115 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1103 | 1116 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1104 | 1117 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1105 | 1118 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1106 | 1119 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1107 | 1120 | // 2688 = 8 * 336 |
|
1108 | 1121 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1109 | 1122 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1110 | 1123 | waveform_picker_regs->start_date = 0x00; // 0x38 |
|
1111 | 1124 | waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066 |
|
1112 | 1125 | } |
|
1113 | 1126 | |
|
1114 | 1127 | void set_wfp_data_shaping( void ) |
|
1115 | 1128 | { |
|
1116 | 1129 | /** This function sets the data_shaping register of the waveform picker module. |
|
1117 | 1130 | * |
|
1118 | 1131 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1119 | 1132 | * bw_sp0_sp1_r0_r1 |
|
1120 | 1133 | * |
|
1121 | 1134 | */ |
|
1122 | 1135 | |
|
1123 | 1136 | unsigned char data_shaping; |
|
1124 | 1137 | |
|
1125 | 1138 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1126 | 1139 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1127 | 1140 | |
|
1128 | 1141 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
1129 | 1142 | |
|
1130 | 1143 | waveform_picker_regs->data_shaping = |
|
1131 | 1144 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
1132 | 1145 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
1133 | 1146 | + ( (data_shaping & 0x04) ) // SP1 |
|
1134 | 1147 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
1135 | 1148 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
1136 | 1149 | } |
|
1137 | 1150 | |
|
1138 | 1151 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1139 | 1152 | { |
|
1140 | 1153 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1141 | 1154 | * |
|
1142 | 1155 | * @param mode is the LFR mode to launch. |
|
1143 | 1156 | * |
|
1144 | 1157 | * The burst bits shall be before the enable bits. |
|
1145 | 1158 | * |
|
1146 | 1159 | */ |
|
1147 | 1160 | |
|
1148 | 1161 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1149 | 1162 | // the burst bits shall be set first, before the enable bits |
|
1150 | 1163 | switch(mode) { |
|
1151 | 1164 | case(LFR_MODE_NORMAL): |
|
1152 | 1165 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1153 | 1166 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1154 | 1167 | break; |
|
1155 | 1168 | case(LFR_MODE_BURST): |
|
1156 | 1169 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1157 | 1170 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1158 | 1171 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 |
|
1159 | 1172 | break; |
|
1160 | 1173 | case(LFR_MODE_SBM1): |
|
1161 | 1174 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1162 | 1175 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1163 | 1176 | break; |
|
1164 | 1177 | case(LFR_MODE_SBM2): |
|
1165 | 1178 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1166 | 1179 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1167 | 1180 | break; |
|
1168 | 1181 | default: |
|
1169 | 1182 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1170 | 1183 | break; |
|
1171 | 1184 | } |
|
1172 | 1185 | } |
|
1173 | 1186 | |
|
1174 | 1187 | void set_wfp_delta_snapshot( void ) |
|
1175 | 1188 | { |
|
1176 | 1189 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1177 | 1190 | * |
|
1178 | 1191 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1179 | 1192 | * - sy_lfr_n_swf_p[0] |
|
1180 | 1193 | * - sy_lfr_n_swf_p[1] |
|
1181 | 1194 | * |
|
1182 | 1195 | */ |
|
1183 | 1196 | |
|
1184 | 1197 | unsigned int delta_snapshot; |
|
1185 | 1198 | unsigned int delta_snapshot_in_T2; |
|
1186 | 1199 | |
|
1187 | 1200 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1188 | 1201 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1189 | 1202 | |
|
1190 | 1203 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1191 | 1204 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1192 | 1205 | } |
|
1193 | 1206 | |
|
1194 | 1207 | void set_wfp_delta_f0_f0_2( void ) |
|
1195 | 1208 | { |
|
1196 | 1209 | unsigned int delta_snapshot; |
|
1197 | 1210 | unsigned int nb_samples_per_snapshot; |
|
1198 | 1211 | float delta_f0_in_float; |
|
1199 | 1212 | |
|
1200 | 1213 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1201 | 1214 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1202 | 1215 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1203 | 1216 | |
|
1204 | 1217 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1205 | 1218 | waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits |
|
1206 | 1219 | } |
|
1207 | 1220 | |
|
1208 | 1221 | void set_wfp_delta_f1( void ) |
|
1209 | 1222 | { |
|
1210 | 1223 | unsigned int delta_snapshot; |
|
1211 | 1224 | unsigned int nb_samples_per_snapshot; |
|
1212 | 1225 | float delta_f1_in_float; |
|
1213 | 1226 | |
|
1214 | 1227 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1215 | 1228 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1216 | 1229 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1217 | 1230 | |
|
1218 | 1231 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1219 | 1232 | } |
|
1220 | 1233 | |
|
1221 | 1234 | void set_wfp_delta_f2() |
|
1222 | 1235 | { |
|
1223 | 1236 | unsigned int delta_snapshot; |
|
1224 | 1237 | unsigned int nb_samples_per_snapshot; |
|
1225 | 1238 | |
|
1226 | 1239 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1227 | 1240 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1228 | 1241 | |
|
1229 | 1242 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1230 | 1243 | } |
|
1231 | 1244 | |
|
1232 | 1245 | //***************** |
|
1233 | 1246 | // local parameters |
|
1234 | 1247 | |
|
1235 | 1248 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1236 | 1249 | { |
|
1237 | 1250 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1238 | 1251 | * |
|
1239 | 1252 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1240 | 1253 | * @param sid is the source identifier of the packet being updated. |
|
1241 | 1254 | * |
|
1242 | 1255 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1243 | 1256 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1244 | 1257 | * The sequence counter shall start at zero at startup. |
|
1245 | 1258 | * |
|
1246 | 1259 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1247 | 1260 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1248 | 1261 | * |
|
1249 | 1262 | */ |
|
1250 | 1263 | |
|
1251 | 1264 | unsigned short *sequence_cnt; |
|
1252 | 1265 | unsigned short segmentation_grouping_flag; |
|
1253 | 1266 | unsigned short new_packet_sequence_control; |
|
1254 | 1267 | rtems_mode initial_mode_set; |
|
1255 | 1268 | rtems_mode current_mode_set; |
|
1256 | 1269 | rtems_status_code status; |
|
1257 | 1270 | |
|
1258 | 1271 | //****************************************** |
|
1259 | 1272 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1260 | 1273 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1261 | 1274 | |
|
1262 | 1275 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1263 | 1276 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1264 | 1277 | || (sid == SID_BURST_CWF_F2) |
|
1265 | 1278 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1266 | 1279 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1267 | 1280 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1268 | 1281 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1269 | 1282 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1270 | 1283 | { |
|
1271 | 1284 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1272 | 1285 | } |
|
1273 | 1286 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1274 | 1287 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1275 | 1288 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1276 | 1289 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1277 | 1290 | { |
|
1278 | 1291 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1279 | 1292 | } |
|
1280 | 1293 | else |
|
1281 | 1294 | { |
|
1282 | 1295 | sequence_cnt = (unsigned short *) NULL; |
|
1283 | 1296 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1284 | 1297 | } |
|
1285 | 1298 | |
|
1286 | 1299 | if (sequence_cnt != NULL) |
|
1287 | 1300 | { |
|
1288 | 1301 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1289 | 1302 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1290 | 1303 | |
|
1291 | 1304 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1292 | 1305 | |
|
1293 | 1306 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1294 | 1307 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1295 | 1308 | |
|
1296 | 1309 | // increment the sequence counter |
|
1297 | 1310 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1298 | 1311 | { |
|
1299 | 1312 | *sequence_cnt = *sequence_cnt + 1; |
|
1300 | 1313 | } |
|
1301 | 1314 | else |
|
1302 | 1315 | { |
|
1303 | 1316 | *sequence_cnt = 0; |
|
1304 | 1317 | } |
|
1305 | 1318 | } |
|
1306 | 1319 | |
|
1307 | 1320 | //*********************************** |
|
1308 | 1321 | // RESET THE MODE OF THE CALLING TASK |
|
1309 | 1322 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1310 | 1323 | } |
General Comments 0
You need to be logged in to leave comments.
Login now