@@ -1,253 +1,253 | |||
|
1 | 1 | ############################################################################# |
|
2 | 2 | # Makefile for building: bin/fsw |
|
3 |
# Generated by qmake (2.01a) (Qt 4.8.5) on: T |
|
|
3 | # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Apr 15 07:45:50 2014 | |
|
4 | 4 | # Project: fsw-qt.pro |
|
5 | 5 | # Template: app |
|
6 | 6 | # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
7 | 7 | ############################################################################# |
|
8 | 8 | |
|
9 | 9 | ####### Compiler, tools and options |
|
10 | 10 | |
|
11 | 11 | CC = sparc-rtems-gcc |
|
12 | 12 | CXX = sparc-rtems-g++ |
|
13 | 13 | DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS |
|
14 | 14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
15 | 15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
16 |
INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../ |
|
|
16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters | |
|
17 | 17 | LINK = sparc-rtems-g++ |
|
18 | 18 | LFLAGS = |
|
19 | 19 | LIBS = $(SUBLIBS) |
|
20 | 20 | AR = sparc-rtems-ar rcs |
|
21 | 21 | RANLIB = |
|
22 | 22 | QMAKE = /usr/bin/qmake-qt4 |
|
23 | 23 | TAR = tar -cf |
|
24 | 24 | COMPRESS = gzip -9f |
|
25 | 25 | COPY = cp -f |
|
26 | 26 | SED = sed |
|
27 | 27 | COPY_FILE = $(COPY) |
|
28 | 28 | COPY_DIR = $(COPY) -r |
|
29 | 29 | STRIP = sparc-rtems-strip |
|
30 | 30 | INSTALL_FILE = install -m 644 -p |
|
31 | 31 | INSTALL_DIR = $(COPY_DIR) |
|
32 | 32 | INSTALL_PROGRAM = install -m 755 -p |
|
33 | 33 | DEL_FILE = rm -f |
|
34 | 34 | SYMLINK = ln -f -s |
|
35 | 35 | DEL_DIR = rmdir |
|
36 | 36 | MOVE = mv -f |
|
37 | 37 | CHK_DIR_EXISTS= test -d |
|
38 | 38 | MKDIR = mkdir -p |
|
39 | 39 | |
|
40 | 40 | ####### Output directory |
|
41 | 41 | |
|
42 | 42 | OBJECTS_DIR = obj/ |
|
43 | 43 | |
|
44 | 44 | ####### Files |
|
45 | 45 | |
|
46 | 46 | SOURCES = ../src/wf_handler.c \ |
|
47 | 47 | ../src/tc_handler.c \ |
|
48 | 48 | ../src/fsw_processing.c \ |
|
49 | 49 | ../src/fsw_misc.c \ |
|
50 | 50 | ../src/fsw_init.c \ |
|
51 | 51 | ../src/fsw_globals.c \ |
|
52 | 52 | ../src/fsw_spacewire.c \ |
|
53 | 53 | ../src/tc_load_dump_parameters.c \ |
|
54 | 54 | ../src/tm_lfr_tc_exe.c \ |
|
55 | 55 | ../src/tc_acceptance.c \ |
|
56 |
../ |
|
|
56 | ../src/basic_parameters/basic_parameters.c | |
|
57 | 57 | OBJECTS = obj/wf_handler.o \ |
|
58 | 58 | obj/tc_handler.o \ |
|
59 | 59 | obj/fsw_processing.o \ |
|
60 | 60 | obj/fsw_misc.o \ |
|
61 | 61 | obj/fsw_init.o \ |
|
62 | 62 | obj/fsw_globals.o \ |
|
63 | 63 | obj/fsw_spacewire.o \ |
|
64 | 64 | obj/tc_load_dump_parameters.o \ |
|
65 | 65 | obj/tm_lfr_tc_exe.o \ |
|
66 | 66 | obj/tc_acceptance.o \ |
|
67 | 67 | obj/basic_parameters.o |
|
68 | 68 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
69 | 69 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
70 | 70 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
71 | 71 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
72 | 72 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
73 | 73 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
74 | 74 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
75 | 75 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
76 | 76 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
77 | 77 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
78 | 78 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
79 | 79 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
80 | 80 | sparc.pri \ |
|
81 | 81 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
82 | 82 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
83 | 83 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
84 | 84 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
85 | 85 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
86 | 86 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
87 | 87 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
88 | 88 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
89 | 89 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
90 | 90 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ |
|
91 | 91 | fsw-qt.pro |
|
92 | 92 | QMAKE_TARGET = fsw |
|
93 | 93 | DESTDIR = bin/ |
|
94 | 94 | TARGET = bin/fsw |
|
95 | 95 | |
|
96 | 96 | first: all |
|
97 | 97 | ####### Implicit rules |
|
98 | 98 | |
|
99 | 99 | .SUFFIXES: .o .c .cpp .cc .cxx .C |
|
100 | 100 | |
|
101 | 101 | .cpp.o: |
|
102 | 102 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
103 | 103 | |
|
104 | 104 | .cc.o: |
|
105 | 105 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
106 | 106 | |
|
107 | 107 | .cxx.o: |
|
108 | 108 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
109 | 109 | |
|
110 | 110 | .C.o: |
|
111 | 111 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
112 | 112 | |
|
113 | 113 | .c.o: |
|
114 | 114 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" |
|
115 | 115 | |
|
116 | 116 | ####### Build rules |
|
117 | 117 | |
|
118 | 118 | all: Makefile $(TARGET) |
|
119 | 119 | |
|
120 | 120 | $(TARGET): $(OBJECTS) |
|
121 | 121 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ |
|
122 | 122 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) |
|
123 | 123 | |
|
124 | 124 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
125 | 125 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
126 | 126 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
127 | 127 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
128 | 128 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
129 | 129 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
130 | 130 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
131 | 131 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
132 | 132 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
133 | 133 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
134 | 134 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
135 | 135 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
136 | 136 | sparc.pri \ |
|
137 | 137 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
138 | 138 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
139 | 139 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
140 | 140 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
141 | 141 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
142 | 142 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
143 | 143 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
144 | 144 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
145 | 145 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
146 | 146 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf |
|
147 | 147 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
148 | 148 | /usr/lib64/qt4/mkspecs/common/unix.conf: |
|
149 | 149 | /usr/lib64/qt4/mkspecs/common/linux.conf: |
|
150 | 150 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: |
|
151 | 151 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: |
|
152 | 152 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: |
|
153 | 153 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: |
|
154 | 154 | /usr/lib64/qt4/mkspecs/qconfig.pri: |
|
155 | 155 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: |
|
156 | 156 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: |
|
157 | 157 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: |
|
158 | 158 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: |
|
159 | 159 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: |
|
160 | 160 | sparc.pri: |
|
161 | 161 | /usr/lib64/qt4/mkspecs/features/release.prf: |
|
162 | 162 | /usr/lib64/qt4/mkspecs/features/default_post.prf: |
|
163 | 163 | /usr/lib64/qt4/mkspecs/features/shared.prf: |
|
164 | 164 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: |
|
165 | 165 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: |
|
166 | 166 | /usr/lib64/qt4/mkspecs/features/resources.prf: |
|
167 | 167 | /usr/lib64/qt4/mkspecs/features/uic.prf: |
|
168 | 168 | /usr/lib64/qt4/mkspecs/features/yacc.prf: |
|
169 | 169 | /usr/lib64/qt4/mkspecs/features/lex.prf: |
|
170 | 170 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: |
|
171 | 171 | qmake: FORCE |
|
172 | 172 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
173 | 173 | |
|
174 | 174 | dist: |
|
175 | 175 | @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 |
|
176 | 176 | $(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 |
|
177 | 177 | |
|
178 | 178 | |
|
179 | 179 | clean:compiler_clean |
|
180 | 180 | -$(DEL_FILE) $(OBJECTS) |
|
181 | 181 | -$(DEL_FILE) *~ core *.core |
|
182 | 182 | |
|
183 | 183 | |
|
184 | 184 | ####### Sub-libraries |
|
185 | 185 | |
|
186 | 186 | distclean: clean |
|
187 | 187 | -$(DEL_FILE) $(TARGET) |
|
188 | 188 | -$(DEL_FILE) Makefile |
|
189 | 189 | |
|
190 | 190 | |
|
191 | 191 | grmon: |
|
192 | 192 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u |
|
193 | 193 | |
|
194 | 194 | check: first |
|
195 | 195 | |
|
196 | 196 | compiler_rcc_make_all: |
|
197 | 197 | compiler_rcc_clean: |
|
198 | 198 | compiler_uic_make_all: |
|
199 | 199 | compiler_uic_clean: |
|
200 | 200 | compiler_image_collection_make_all: qmake_image_collection.cpp |
|
201 | 201 | compiler_image_collection_clean: |
|
202 | 202 | -$(DEL_FILE) qmake_image_collection.cpp |
|
203 | 203 | compiler_yacc_decl_make_all: |
|
204 | 204 | compiler_yacc_decl_clean: |
|
205 | 205 | compiler_yacc_impl_make_all: |
|
206 | 206 | compiler_yacc_impl_clean: |
|
207 | 207 | compiler_lex_make_all: |
|
208 | 208 | compiler_lex_clean: |
|
209 | 209 | compiler_clean: |
|
210 | 210 | |
|
211 | 211 | ####### Compile |
|
212 | 212 | |
|
213 | 213 | obj/wf_handler.o: ../src/wf_handler.c |
|
214 | 214 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c |
|
215 | 215 | |
|
216 | 216 | obj/tc_handler.o: ../src/tc_handler.c |
|
217 | 217 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c |
|
218 | 218 | |
|
219 | 219 | obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c |
|
220 | 220 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c |
|
221 | 221 | |
|
222 | 222 | obj/fsw_misc.o: ../src/fsw_misc.c |
|
223 | 223 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c |
|
224 | 224 | |
|
225 | 225 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c |
|
226 | 226 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c |
|
227 | 227 | |
|
228 | 228 | obj/fsw_globals.o: ../src/fsw_globals.c |
|
229 | 229 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c |
|
230 | 230 | |
|
231 | 231 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c |
|
232 | 232 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c |
|
233 | 233 | |
|
234 | 234 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c |
|
235 | 235 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c |
|
236 | 236 | |
|
237 | 237 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c |
|
238 | 238 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c |
|
239 | 239 | |
|
240 | 240 | obj/tc_acceptance.o: ../src/tc_acceptance.c |
|
241 | 241 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c |
|
242 | 242 | |
|
243 |
obj/basic_parameters.o: ../ |
|
|
244 |
$(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../ |
|
|
243 | obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h | |
|
244 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c | |
|
245 | 245 | |
|
246 | 246 | ####### Install |
|
247 | 247 | |
|
248 | 248 | install: FORCE |
|
249 | 249 | |
|
250 | 250 | uninstall: FORCE |
|
251 | 251 | |
|
252 | 252 | FORCE: |
|
253 | 253 |
@@ -1,85 +1,85 | |||
|
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 cpu_usage_report |
|
5 | 5 | CONFIG -= qt |
|
6 | 6 | |
|
7 | 7 | include(./sparc.pri) |
|
8 | 8 | |
|
9 | 9 | # flight software version |
|
10 | 10 | SWVERSION=-1-0 |
|
11 | 11 | DEFINES += SW_VERSION_N1=1 # major |
|
12 | 12 | DEFINES += SW_VERSION_N2=0 # minor |
|
13 | 13 | DEFINES += SW_VERSION_N3=0 # patch |
|
14 | 14 | DEFINES += SW_VERSION_N4=6 # internal |
|
15 | 15 | |
|
16 | 16 | contains( CONFIG, debug_tch ) { |
|
17 | 17 | DEFINES += DEBUG_TCH |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | 20 | contains( CONFIG, vhdl_dev ) { |
|
21 | 21 | DEFINES += VHDL_DEV |
|
22 | 22 | } |
|
23 | 23 | |
|
24 | 24 | contains( CONFIG, verbose ) { |
|
25 | 25 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | 28 | contains( CONFIG, debug_messages ) { |
|
29 | 29 | DEFINES += DEBUG_MESSAGES |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | contains( CONFIG, cpu_usage_report ) { |
|
33 | 33 | DEFINES += PRINT_TASK_STATISTICS |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | contains( CONFIG, stack_report ) { |
|
37 | 37 | DEFINES += PRINT_STACK_REPORT |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | contains( CONFIG, boot_messages ) { |
|
41 | 41 | DEFINES += BOOT_MESSAGES |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | #doxygen.target = doxygen |
|
45 | 45 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
46 | 46 | #QMAKE_EXTRA_TARGETS += doxygen |
|
47 | 47 | |
|
48 | 48 | TARGET = fsw |
|
49 | 49 | |
|
50 | 50 | INCLUDEPATH += \ |
|
51 | 51 | ../src \ |
|
52 | 52 | ../header \ |
|
53 |
../ |
|
|
53 | ../src/basic_parameters | |
|
54 | 54 | |
|
55 | 55 | SOURCES += \ |
|
56 | 56 | ../src/wf_handler.c \ |
|
57 | 57 | ../src/tc_handler.c \ |
|
58 | 58 | ../src/fsw_processing.c \ |
|
59 | 59 | ../src/fsw_misc.c \ |
|
60 | 60 | ../src/fsw_init.c \ |
|
61 | 61 | ../src/fsw_globals.c \ |
|
62 | 62 | ../src/fsw_spacewire.c \ |
|
63 | 63 | ../src/tc_load_dump_parameters.c \ |
|
64 | 64 | ../src/tm_lfr_tc_exe.c \ |
|
65 | 65 | ../src/tc_acceptance.c \ |
|
66 |
../ |
|
|
66 | ../src/basic_parameters/basic_parameters.c | |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | HEADERS += \ |
|
70 | 70 | ../header/wf_handler.h \ |
|
71 | 71 | ../header/tc_handler.h \ |
|
72 | 72 | ../header/grlib_regs.h \ |
|
73 | 73 | ../header/fsw_processing.h \ |
|
74 | 74 | ../header/fsw_params.h \ |
|
75 | 75 | ../header/fsw_misc.h \ |
|
76 | 76 | ../header/fsw_init.h \ |
|
77 | 77 | ../header/ccsds_types.h \ |
|
78 | 78 | ../header/fsw_params_processing.h \ |
|
79 | 79 | ../header/fsw_spacewire.h \ |
|
80 | 80 | ../header/tc_load_dump_parameters.h \ |
|
81 | 81 | ../header/tm_lfr_tc_exe.h \ |
|
82 | 82 | ../header/tc_acceptance.h \ |
|
83 | 83 | ../header/fsw_params_nb_bytes.h \ |
|
84 |
../ |
|
|
84 | ../src/basic_parameters/basic_parameters.h | |
|
85 | 85 |
@@ -1,339 +1,339 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by QtCreator 3.0.1, 2014-04-1 |
|
|
3 | <!-- Written by QtCreator 3.0.1, 2014-04-16T10:43:41. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
|
7 | 7 | <value type="int">1</value> |
|
8 | 8 | </data> |
|
9 | 9 | <data> |
|
10 | 10 | <variable>ProjectExplorer.Project.EditorSettings</variable> |
|
11 | 11 | <valuemap type="QVariantMap"> |
|
12 | 12 | <value type="bool" key="EditorConfiguration.AutoIndent">true</value> |
|
13 | 13 | <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> |
|
14 | 14 | <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> |
|
15 | 15 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> |
|
16 | 16 | <value type="QString" key="language">Cpp</value> |
|
17 | 17 | <valuemap type="QVariantMap" key="value"> |
|
18 | 18 | <value type="QByteArray" key="CurrentPreferences">CppGlobal</value> |
|
19 | 19 | </valuemap> |
|
20 | 20 | </valuemap> |
|
21 | 21 | <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> |
|
22 | 22 | <value type="QString" key="language">QmlJS</value> |
|
23 | 23 | <valuemap type="QVariantMap" key="value"> |
|
24 | 24 | <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> |
|
25 | 25 | </valuemap> |
|
26 | 26 | </valuemap> |
|
27 | 27 | <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> |
|
28 | 28 | <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> |
|
29 | 29 | <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> |
|
30 | 30 | <value type="int" key="EditorConfiguration.IndentSize">4</value> |
|
31 | 31 | <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> |
|
32 | 32 | <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> |
|
33 | 33 | <value type="int" key="EditorConfiguration.PaddingMode">1</value> |
|
34 | 34 | <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> |
|
35 | 35 | <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> |
|
36 | 36 | <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> |
|
37 | 37 | <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> |
|
38 | 38 | <value type="int" key="EditorConfiguration.TabSize">8</value> |
|
39 | 39 | <value type="bool" key="EditorConfiguration.UseGlobal">true</value> |
|
40 | 40 | <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> |
|
41 | 41 | <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> |
|
42 | 42 | <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> |
|
43 | 43 | <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> |
|
44 | 44 | <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> |
|
45 | 45 | </valuemap> |
|
46 | 46 | </data> |
|
47 | 47 | <data> |
|
48 | 48 | <variable>ProjectExplorer.Project.PluginSettings</variable> |
|
49 | 49 | <valuemap type="QVariantMap"/> |
|
50 | 50 | </data> |
|
51 | 51 | <data> |
|
52 | 52 | <variable>ProjectExplorer.Project.Target.0</variable> |
|
53 | 53 | <valuemap type="QVariantMap"> |
|
54 | 54 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> |
|
55 | 55 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> |
|
56 | 56 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</value> |
|
57 | 57 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
58 | 58 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
59 | 59 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
60 | 60 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
61 | 61 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> |
|
62 | 62 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
63 | 63 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
64 | 64 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
65 | 65 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
66 | 66 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
67 | 67 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
68 | 68 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
69 | 69 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value> |
|
70 | 70 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
71 | 71 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
72 | 72 | </valuemap> |
|
73 | 73 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
74 | 74 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
75 | 75 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
76 | 76 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
77 | 77 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
78 | 78 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
79 | 79 | <value type="QString">-w</value> |
|
80 | 80 | <value type="QString">-r</value> |
|
81 | 81 | </valuelist> |
|
82 | 82 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
83 | 83 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
84 | 84 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
85 | 85 | </valuemap> |
|
86 | 86 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
87 | 87 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
88 | 88 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
89 | 89 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
90 | 90 | </valuemap> |
|
91 | 91 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
92 | 92 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
93 | 93 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
94 | 94 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
95 | 95 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
96 | 96 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
97 | 97 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
98 | 98 | <value type="QString">-w</value> |
|
99 | 99 | <value type="QString">-r</value> |
|
100 | 100 | </valuelist> |
|
101 | 101 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
102 | 102 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
103 | 103 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
104 | 104 | </valuemap> |
|
105 | 105 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
106 | 106 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
107 | 107 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
108 | 108 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
109 | 109 | </valuemap> |
|
110 | 110 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
111 | 111 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
112 | 112 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
113 | 113 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
114 | 114 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
115 | 115 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
116 | 116 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
117 | 117 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
118 | 118 | </valuemap> |
|
119 | 119 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
120 | 120 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
121 | 121 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
122 | 122 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
123 | 123 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
124 | 124 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
125 | 125 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
126 | 126 | </valuemap> |
|
127 | 127 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
128 | 128 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
129 | 129 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
130 | 130 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
131 | 131 | </valuemap> |
|
132 | 132 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
133 | 133 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
134 | 134 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
135 | 135 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
136 | 136 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
137 | 137 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
138 | 138 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
139 | 139 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
140 | 140 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
141 | 141 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
142 | 142 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
143 | 143 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
144 | 144 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
145 | 145 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
146 | 146 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
147 | 147 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
148 | 148 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
149 | 149 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
150 | 150 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
151 | 151 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
152 | 152 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
153 | 153 | <value type="int">0</value> |
|
154 | 154 | <value type="int">1</value> |
|
155 | 155 | <value type="int">2</value> |
|
156 | 156 | <value type="int">3</value> |
|
157 | 157 | <value type="int">4</value> |
|
158 | 158 | <value type="int">5</value> |
|
159 | 159 | <value type="int">6</value> |
|
160 | 160 | <value type="int">7</value> |
|
161 | 161 | <value type="int">8</value> |
|
162 | 162 | <value type="int">9</value> |
|
163 | 163 | <value type="int">10</value> |
|
164 | 164 | <value type="int">11</value> |
|
165 | 165 | <value type="int">12</value> |
|
166 | 166 | <value type="int">13</value> |
|
167 | 167 | <value type="int">14</value> |
|
168 | 168 | </valuelist> |
|
169 | 169 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
170 | 170 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
171 | 171 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
172 | 172 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
173 | 173 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
174 | 174 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
175 | 175 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
176 | 176 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
177 | 177 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
178 | 178 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
179 | 179 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
180 | 180 | <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> |
|
181 | 181 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> |
|
182 | 182 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
183 | 183 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
184 | 184 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
185 | 185 | </valuemap> |
|
186 | 186 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
187 | 187 | </valuemap> |
|
188 | 188 | </data> |
|
189 | 189 | <data> |
|
190 | 190 | <variable>ProjectExplorer.Project.Target.1</variable> |
|
191 | 191 | <valuemap type="QVariantMap"> |
|
192 | 192 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
193 | 193 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value> |
|
194 | 194 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value> |
|
195 | 195 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
|
196 | 196 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
|
197 | 197 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
|
198 | 198 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
|
199 | 199 | <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> |
|
200 | 200 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
201 | 201 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
202 | 202 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
203 | 203 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> |
|
204 | 204 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
205 | 205 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> |
|
206 | 206 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> |
|
207 | 207 | <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value> |
|
208 | 208 | <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> |
|
209 | 209 | <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> |
|
210 | 210 | </valuemap> |
|
211 | 211 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> |
|
212 | 212 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
213 | 213 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
214 | 214 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
215 | 215 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
216 | 216 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
217 | 217 | <value type="QString">-w</value> |
|
218 | 218 | <value type="QString">-r</value> |
|
219 | 219 | </valuelist> |
|
220 | 220 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
|
221 | 221 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
|
222 | 222 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
223 | 223 | </valuemap> |
|
224 | 224 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> |
|
225 | 225 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> |
|
226 | 226 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
227 | 227 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> |
|
228 | 228 | </valuemap> |
|
229 | 229 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> |
|
230 | 230 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
|
231 | 231 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
|
232 | 232 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
|
233 | 233 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
234 | 234 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
|
235 | 235 | <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> |
|
236 | 236 | <value type="QString">-w</value> |
|
237 | 237 | <value type="QString">-r</value> |
|
238 | 238 | </valuelist> |
|
239 | 239 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
|
240 | 240 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
|
241 | 241 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
|
242 | 242 | </valuemap> |
|
243 | 243 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> |
|
244 | 244 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> |
|
245 | 245 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
246 | 246 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> |
|
247 | 247 | </valuemap> |
|
248 | 248 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> |
|
249 | 249 | <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> |
|
250 | 250 | <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> |
|
251 | 251 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> |
|
252 | 252 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
253 | 253 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> |
|
254 | 254 | <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> |
|
255 | 255 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
|
256 | 256 | </valuemap> |
|
257 | 257 | <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> |
|
258 | 258 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> |
|
259 | 259 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
|
260 | 260 | <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> |
|
261 | 261 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> |
|
262 | 262 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
263 | 263 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> |
|
264 | 264 | </valuemap> |
|
265 | 265 | <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> |
|
266 | 266 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value> |
|
267 | 267 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
268 | 268 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> |
|
269 | 269 | </valuemap> |
|
270 | 270 | <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> |
|
271 | 271 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> |
|
272 | 272 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> |
|
273 | 273 | <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> |
|
274 | 274 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> |
|
275 | 275 | <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> |
|
276 | 276 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> |
|
277 | 277 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> |
|
278 | 278 | <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> |
|
279 | 279 | <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> |
|
280 | 280 | <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> |
|
281 | 281 | <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> |
|
282 | 282 | <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value> |
|
283 | 283 | <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> |
|
284 | 284 | <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> |
|
285 | 285 | <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value> |
|
286 | 286 | <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> |
|
287 | 287 | <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> |
|
288 | 288 | <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> |
|
289 | 289 | <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> |
|
290 | 290 | <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> |
|
291 | 291 | <value type="int">0</value> |
|
292 | 292 | <value type="int">1</value> |
|
293 | 293 | <value type="int">2</value> |
|
294 | 294 | <value type="int">3</value> |
|
295 | 295 | <value type="int">4</value> |
|
296 | 296 | <value type="int">5</value> |
|
297 | 297 | <value type="int">6</value> |
|
298 | 298 | <value type="int">7</value> |
|
299 | 299 | <value type="int">8</value> |
|
300 | 300 | <value type="int">9</value> |
|
301 | 301 | <value type="int">10</value> |
|
302 | 302 | <value type="int">11</value> |
|
303 | 303 | <value type="int">12</value> |
|
304 | 304 | <value type="int">13</value> |
|
305 | 305 | <value type="int">14</value> |
|
306 | 306 | </valuelist> |
|
307 | 307 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
|
308 | 308 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
|
309 | 309 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value> |
|
310 | 310 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
|
311 | 311 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value> |
|
312 | 312 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> |
|
313 | 313 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value> |
|
314 | 314 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
|
315 | 315 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
|
316 | 316 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
|
317 | 317 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
|
318 | 318 | <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> |
|
319 | 319 | <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value> |
|
320 | 320 | <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> |
|
321 | 321 | <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> |
|
322 | 322 | <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> |
|
323 | 323 | </valuemap> |
|
324 | 324 | <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> |
|
325 | 325 | </valuemap> |
|
326 | 326 | </data> |
|
327 | 327 | <data> |
|
328 | 328 | <variable>ProjectExplorer.Project.TargetCount</variable> |
|
329 | 329 | <value type="int">2</value> |
|
330 | 330 | </data> |
|
331 | 331 | <data> |
|
332 | 332 | <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> |
|
333 | 333 | <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value> |
|
334 | 334 | </data> |
|
335 | 335 | <data> |
|
336 | 336 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> |
|
337 | 337 | <value type="int">15</value> |
|
338 | 338 | </data> |
|
339 | 339 | </qtcreator> |
@@ -1,41 +1,42 | |||
|
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 | #include "tc_handler.h" |
|
11 | 11 | #include "wf_handler.h" |
|
12 | 12 | |
|
13 | 13 | #include "fsw_spacewire.h" |
|
14 | 14 | |
|
15 | 15 | extern rtems_name Task_name[20]; /* array of task names */ |
|
16 | 16 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
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 | rtems_status_code get_message_queue_id_matr( rtems_id *queue_id ); | |
|
29 | 30 | // |
|
30 | 31 | int start_recv_send_tasks( void ); |
|
31 | 32 | // |
|
32 | 33 | void init_local_mode_parameters( void ); |
|
33 | 34 | void reset_local_time( void ); |
|
34 | 35 | |
|
35 | 36 | extern int rtems_cpu_usage_report( void ); |
|
36 | 37 | extern int rtems_cpu_usage_reset( void ); |
|
37 | 38 | extern void rtems_stack_checker_report_usage( void ); |
|
38 | 39 | |
|
39 | 40 | extern int sched_yield( void ); |
|
40 | 41 | |
|
41 | 42 | #endif // FSW_INIT_H_INCLUDED |
@@ -1,40 +1,42 | |||
|
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 | |
|
11 | 11 | rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic |
|
12 | 12 | rtems_id HK_id; // id of the HK rate monotonic period |
|
13 | 13 | |
|
14 | 14 | //extern rtems_name misc_name[5]; |
|
15 | 15 | //time_management_regs_t *time_management_regs; |
|
16 | 16 | //extern Packet_TM_LFR_HK_t housekeeping_packet; |
|
17 | 17 | |
|
18 | 18 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
19 | 19 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
20 | 20 | void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
21 | 21 | void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
22 | 22 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider); |
|
23 | 23 | |
|
24 | 24 | // SERIAL LINK |
|
25 | 25 | int send_console_outputs_on_apbuart_port( void ); |
|
26 | 26 | int enable_apbuart_transmitter( void ); |
|
27 | 27 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
28 | 28 | |
|
29 | 29 | // RTEMS TASKS |
|
30 | 30 | rtems_task stat_task( rtems_task_argument argument ); |
|
31 | 31 | rtems_task hous_task( rtems_task_argument argument ); |
|
32 | 32 | rtems_task dumb_task( rtems_task_argument unused ); |
|
33 | 33 | |
|
34 | 34 | void init_housekeeping_parameters( void ); |
|
35 | 35 | void increment_seq_counter( unsigned char *packet_sequence_control); |
|
36 | 36 | void getTime( unsigned char *time); |
|
37 | 37 | unsigned long long int getTimeAsUnsignedLongLongInt( ); |
|
38 | 38 | void send_dumb_hk( void ); |
|
39 | 39 | |
|
40 | extern int sched_yield( void ); | |
|
41 | ||
|
40 | 42 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,252 +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 | typedef struct { |
|
22 | 22 | unsigned int f0; |
|
23 | 23 | unsigned int norm_bp1_f0; |
|
24 | 24 | unsigned int norm_bp2_f0; |
|
25 | 25 | unsigned int norm_asm_f0; |
|
26 | 26 | unsigned int sbm_bp1_f0; |
|
27 | 27 | unsigned int sbm_bp2_f0; |
|
28 | 28 | } nb_sm_t; |
|
29 | 29 | |
|
30 | 30 | typedef struct { |
|
31 | 31 | unsigned int norm_bp1_f0; |
|
32 | 32 | unsigned int norm_bp2_f0; |
|
33 | 33 | unsigned int norm_asm_f0; |
|
34 | 34 | unsigned int burst_sbm_bp1_f0; |
|
35 | 35 | unsigned int burst_sbm_bp2_f0; |
|
36 | 36 | unsigned int burst_bp1_f0; |
|
37 | 37 | unsigned int burst_bp2_f0; |
|
38 | 38 | unsigned int sbm1_bp1_f0; |
|
39 | 39 | unsigned int sbm1_bp2_f0; |
|
40 | 40 | unsigned int sbm2_bp1_f0; |
|
41 | 41 | unsigned int sbm2_bp2_f0; |
|
42 | 42 | } nb_sm_before_bp_t; |
|
43 | 43 | |
|
44 | 44 | //************************ |
|
45 | 45 | // flight software version |
|
46 | 46 | // this parameters is handled by the Qt project options |
|
47 | 47 | |
|
48 | 48 | #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk |
|
49 | 49 | #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk |
|
50 | 50 | #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688 |
|
51 | 51 | #define TIME_OFFSET 2 |
|
52 | 52 | #define TIME_OFFSET_IN_BYTES 8 |
|
53 | 53 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 |
|
54 | 54 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
55 | 55 | #define NB_WORDS_SWF_BLK 3 |
|
56 | 56 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
57 | 57 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 |
|
58 | 58 | #define NB_RING_NODES_F0 3 // AT LEAST 3 |
|
59 | 59 | #define NB_RING_NODES_F1 5 // AT LEAST 3 |
|
60 | 60 | #define NB_RING_NODES_F2 5 // AT LEAST 3 |
|
61 | 61 | |
|
62 | 62 | //********** |
|
63 | 63 | // LFR MODES |
|
64 | 64 | #define LFR_MODE_STANDBY 0 |
|
65 | 65 | #define LFR_MODE_NORMAL 1 |
|
66 | 66 | #define LFR_MODE_BURST 2 |
|
67 | 67 | #define LFR_MODE_SBM1 3 |
|
68 | 68 | #define LFR_MODE_SBM2 4 |
|
69 | 69 | |
|
70 | 70 | #define TDS_MODE_LFM 5 |
|
71 | 71 | #define TDS_MODE_STANDBY 0 |
|
72 | 72 | #define TDS_MODE_NORMAL 1 |
|
73 | 73 | #define TDS_MODE_BURST 2 |
|
74 | 74 | #define TDS_MODE_SBM1 3 |
|
75 | 75 | #define TDS_MODE_SBM2 4 |
|
76 | 76 | |
|
77 | 77 | #define THR_MODE_STANDBY 0 |
|
78 | 78 | #define THR_MODE_NORMAL 1 |
|
79 | 79 | #define THR_MODE_BURST 2 |
|
80 | 80 | |
|
81 | 81 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
82 | 82 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
83 | 83 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
84 | 84 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
85 | 85 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
86 | 86 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
87 | 87 | #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6 |
|
88 | 88 | #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7 |
|
89 | 89 | #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 |
|
90 | 90 | #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_9 |
|
91 | 91 | #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_10 |
|
92 | 92 | |
|
93 | 93 | //**************************** |
|
94 | 94 | // LFR DEFAULT MODE PARAMETERS |
|
95 | 95 | // COMMON |
|
96 | 96 | #define DEFAULT_SY_LFR_COMMON0 0x00 |
|
97 | 97 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 |
|
98 | 98 | // NORM |
|
99 | 99 | #define SY_LFR_N_SWF_L 2048 // nb sample |
|
100 | 100 | #define SY_LFR_N_SWF_P 300 // sec |
|
101 | 101 | #define SY_LFR_N_ASM_P 3600 // sec |
|
102 | 102 | #define SY_LFR_N_BP_P0 4 // sec |
|
103 | 103 | #define SY_LFR_N_BP_P1 20 // sec |
|
104 | 104 | #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 |
|
105 | 105 | #define MIN_DELTA_SNAPSHOT 16 // sec |
|
106 | 106 | // BURST |
|
107 | 107 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec |
|
108 | 108 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec |
|
109 | 109 | // SBM1 |
|
110 | 110 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec |
|
111 | 111 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec |
|
112 | 112 | // SBM2 |
|
113 | 113 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec |
|
114 | 114 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec |
|
115 | 115 | // ADDITIONAL PARAMETERS |
|
116 | 116 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms |
|
117 | 117 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s |
|
118 | 118 | // STATUS WORD |
|
119 | 119 | #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits |
|
120 | 120 | #define DEFAULT_STATUS_WORD_BYTE1 0x00 |
|
121 | 121 | // |
|
122 | 122 | #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s |
|
123 | 123 | #define SY_LFR_DPU_CONNECT_ATTEMPT 3 |
|
124 | 124 | //**************************** |
|
125 | 125 | |
|
126 | 126 | //***************************** |
|
127 | 127 | // APB REGISTERS BASE ADDRESSES |
|
128 | 128 | #define REGS_ADDR_APBUART 0x80000100 |
|
129 | 129 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
130 | 130 | #define REGS_ADDR_GRSPW 0x80000500 |
|
131 | 131 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
132 | 132 | #define REGS_ADDR_GRGPIO 0x80000b00 |
|
133 | 133 | |
|
134 | 134 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 |
|
135 | 135 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40 |
|
136 | 136 | |
|
137 | 137 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
138 | 138 | #define APBUART_CTRL_REG_MASK_TE 0x00000002 |
|
139 | 139 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) |
|
140 | 140 | |
|
141 | 141 | //********** |
|
142 | 142 | // IRQ LINES |
|
143 | 143 | #define IRQ_SM_SIMULATOR 9 |
|
144 | 144 | #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
145 | 145 | #define IRQ_WAVEFORM_PICKER 14 |
|
146 | 146 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
147 | 147 | #define IRQ_SPECTRAL_MATRIX 6 |
|
148 | 148 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
149 | 149 | |
|
150 | 150 | //***** |
|
151 | 151 | // TIME |
|
152 | 152 | #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416 |
|
153 | 153 | #define TIMER_SM_SIMULATOR 1 |
|
154 | 154 | #define HK_PERIOD 100 // 100 * 10ms => 1s |
|
155 | 155 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000 |
|
156 | 156 | #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s |
|
157 | 157 | |
|
158 | 158 | //********** |
|
159 | 159 | // LPP CODES |
|
160 | 160 | #define LFR_SUCCESSFUL 0 |
|
161 | 161 | #define LFR_DEFAULT 1 |
|
162 | 162 | #define LFR_EXE_ERROR 2 |
|
163 | 163 | |
|
164 | 164 | //****** |
|
165 | 165 | // RTEMS |
|
166 | 166 | #define TASKID_RECV 1 |
|
167 | 167 | #define TASKID_ACTN 2 |
|
168 | 168 | #define TASKID_SPIQ 3 |
|
169 | 169 | #define TASKID_SMIQ 4 |
|
170 | 170 | #define TASKID_STAT 5 |
|
171 | 171 | #define TASKID_AVF0 6 |
|
172 | 172 | #define TASKID_SWBD 7 |
|
173 | 173 | #define TASKID_WFRM 8 |
|
174 | 174 | #define TASKID_DUMB 9 |
|
175 | 175 | #define TASKID_HOUS 10 |
|
176 | 176 | #define TASKID_MATR 11 |
|
177 | 177 | #define TASKID_CWF3 12 |
|
178 | 178 | #define TASKID_CWF2 13 |
|
179 | 179 | #define TASKID_CWF1 14 |
|
180 | 180 | #define TASKID_SEND 15 |
|
181 | 181 | #define TASKID_WTDG 16 |
|
182 | 182 | |
|
183 | 183 | #define TASK_PRIORITY_SPIQ 5 |
|
184 | 184 | #define TASK_PRIORITY_SMIQ 10 |
|
185 | 185 | #define TASK_PRIORITY_WTDG 20 |
|
186 | 186 | #define TASK_PRIORITY_HOUS 30 |
|
187 | 187 | #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together |
|
188 | 188 | #define TASK_PRIORITY_CWF2 35 // |
|
189 | 189 | #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it |
|
190 | 190 | #define TASK_PRIORITY_WFRM 40 |
|
191 | 191 | #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1 |
|
192 | 192 | #define TASK_PRIORITY_SEND 45 |
|
193 | 193 | #define TASK_PRIORITY_RECV 50 |
|
194 | 194 | #define TASK_PRIORITY_ACTN 50 |
|
195 | 195 | #define TASK_PRIORITY_AVF0 60 |
|
196 | 196 | #define TASK_PRIORITY_BPF0 60 |
|
197 | 197 | #define TASK_PRIORITY_MATR 100 |
|
198 | 198 | #define TASK_PRIORITY_STAT 200 |
|
199 | 199 | #define TASK_PRIORITY_DUMB 200 |
|
200 | 200 | |
|
201 |
#define |
|
|
202 |
#define |
|
|
203 | //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) | |
|
204 | #define ACTION_MSG_PKTS_MAX_SIZE 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1 | |
|
201 | #define MSG_QUEUE_COUNT_RECV 10 | |
|
202 | #define MSG_QUEUE_COUNT_SEND 50 | |
|
203 | #define MSG_QUEUE_COUNT_MATR 10 | |
|
204 | //#define MSG_QUEUE_SIZE_SEND (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) | |
|
205 | #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1 | |
|
205 | 206 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
207 | #define MSG_QUEUE_SIZE_MATR 20 // two pointers and one rtems_event + 2 integers | |
|
206 | 208 | |
|
207 | 209 | #define QUEUE_RECV 0 |
|
208 | 210 | #define QUEUE_SEND 1 |
|
211 | #define QUEUE_MATR 2 | |
|
209 | 212 | |
|
210 | 213 | //******* |
|
211 | 214 | // MACROS |
|
212 | 215 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
213 | 216 | #define PRINTF(x) printf(x); |
|
214 | 217 | #define PRINTF1(x,y) printf(x,y); |
|
215 | 218 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
216 | 219 | #else |
|
217 | 220 | #define PRINTF(x) ; |
|
218 | 221 | #define PRINTF1(x,y) ; |
|
219 | 222 | #define PRINTF2(x,y,z) ; |
|
220 | 223 | #endif |
|
221 | 224 | |
|
222 | 225 | #ifdef BOOT_MESSAGES |
|
223 | 226 | #define BOOT_PRINTF(x) printf(x); |
|
224 | 227 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
225 | 228 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
226 | 229 | #else |
|
227 | 230 | #define BOOT_PRINTF(x) ; |
|
228 | 231 | #define BOOT_PRINTF1(x,y) ; |
|
229 | 232 | #define BOOT_PRINTF2(x,y,z) ; |
|
230 | 233 | #endif |
|
231 | 234 | |
|
232 | 235 | #ifdef DEBUG_MESSAGES |
|
233 | 236 | #define DEBUG_PRINTF(x) printf(x); |
|
234 | 237 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
235 | 238 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
236 | 239 | #else |
|
237 | 240 | #define DEBUG_PRINTF(x) ; |
|
238 | 241 | #define DEBUG_PRINTF1(x,y) ; |
|
239 | 242 | #define DEBUG_PRINTF2(x,y,z) ; |
|
240 | 243 | #endif |
|
241 | 244 | |
|
242 | 245 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
243 | 246 | |
|
244 | 247 | struct param_local_str{ |
|
245 | 248 | unsigned int local_sbm1_nb_cwf_sent; |
|
246 | 249 | unsigned int local_sbm1_nb_cwf_max; |
|
247 | 250 | unsigned int local_sbm2_nb_cwf_sent; |
|
248 | 251 | unsigned int local_sbm2_nb_cwf_max; |
|
249 | 252 | unsigned int local_nb_interrupt_f0_MAX; |
|
250 | 253 | }; |
|
251 | 254 | |
|
252 | 255 | #endif // FSW_PARAMS_H_INCLUDED |
@@ -1,66 +1,67 | |||
|
1 | 1 | #ifndef FSW_PARAMS_PROCESSING_H |
|
2 | 2 | #define FSW_PARAMS_PROCESSING_H |
|
3 | 3 | |
|
4 | 4 | #define NB_BINS_PER_SM 128 |
|
5 | 5 | #define NB_VALUES_PER_SM 25 |
|
6 | 6 | #define TOTAL_SIZE_SM 3200 // 25 * 128 |
|
7 | 7 | #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99 |
|
8 | 8 | #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117 |
|
9 | 9 | #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108 |
|
10 | 10 | #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198 |
|
11 | 11 | // |
|
12 | 12 | #define NB_RING_NODES_SM_F0 12 // AT LEAST 3 |
|
13 | 13 | #define NB_RING_NODES_SM_F1 3 // AT LEAST 3 |
|
14 | 14 | #define NB_RING_NODES_SM_F2 3 // AT LEAST 3 |
|
15 | 15 | #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3 |
|
16 | #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3 | |
|
16 | 17 | // |
|
17 | 18 | #define NB_BINS_PER_ASM_F0 88 |
|
18 | 19 | #define NB_BINS_PER_PKT_ASM_F0 44 |
|
19 | 20 | #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2 |
|
20 | 21 | #define ASM_F0_INDICE_START 17 // 88 bins |
|
21 | 22 | #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins |
|
22 | 23 | // |
|
23 | 24 | #define NB_BINS_PER_ASM_F1 104 |
|
24 | 25 | #define NB_BINS_PER_PKT_ASM_F1 52 |
|
25 | 26 | #define TOTAL_SIZE_ASM_F1 2600 // 25 * 104 |
|
26 | 27 | #define ASM_F1_INDICE_START 6 // 104 bins |
|
27 | 28 | #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins |
|
28 | 29 | // |
|
29 | 30 | #define NB_BINS_PER_ASM_F2 96 |
|
30 | 31 | #define NB_BINS_PER_PKT_ASM_F2 48 |
|
31 | 32 | #define TOTAL_SIZE_ASM_F2 2400 // 25 * 96 |
|
32 | 33 | #define ASM_F2_INDICE_START 7 // 96 bins |
|
33 | 34 | #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins |
|
34 | 35 | // |
|
35 | 36 | #define NB_BINS_COMPRESSED_SM_F0 11 |
|
36 | 37 | #define NB_BINS_COMPRESSED_SM_F1 13 |
|
37 | 38 | #define NB_BINS_COMPRESSED_SM_F2 12 |
|
38 | 39 | #define NB_BINS_COMPRESSED_SM_SBM_F0 22 |
|
39 | 40 | |
|
40 | 41 | // |
|
41 | 42 | #define NB_BINS_TO_AVERAGE_ASM_F0 8 |
|
42 | 43 | #define NB_BINS_TO_AVERAGE_ASM_F1 8 |
|
43 | 44 | #define NB_BINS_TO_AVERAGE_ASM_F2 8 |
|
44 | 45 | #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4 |
|
45 | 46 | // |
|
46 | 47 | #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS |
|
47 | 48 | #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS |
|
48 | 49 | #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS |
|
49 | 50 | #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS |
|
50 | 51 | // NORM |
|
51 | 52 | #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4 |
|
52 | 53 | #define NB_SM_BEFORE_NORM_BP2_F0 1920 // 96 * 20 |
|
53 | 54 | #define NB_SM_BEFORE_NORM_ASM_F0 384 // 384 matrices at f0 = 4.00 second |
|
54 | 55 | // BURST |
|
55 | 56 | #define NB_SM_BEFORE_BURST_BP1_F0 96 // 96 matrices at f0 = 1.00 second |
|
56 | 57 | #define NB_SM_BEFORE_BURST_BP2_F0 480 // 480 matrices at f0 = 5.00 second |
|
57 | 58 | // SBM1 |
|
58 | 59 | #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second |
|
59 | 60 | #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second |
|
60 | 61 | // SBM2 |
|
61 | 62 | #define NB_SM_BEFORE_SBM2_BP1_F0 96 // 96 matrices at f0 = 1.00 second |
|
62 | 63 | #define NB_SM_BEFORE_SBM2_BP2_F0 480 // 480 matrices at f0 = 5.00 second |
|
63 | 64 | // GENERAL |
|
64 | 65 | #define NB_SM_BEFORE_AVF0 8 |
|
65 | 66 | |
|
66 | 67 | #endif // FSW_PARAMS_PROCESSING_H |
@@ -1,109 +1,120 | |||
|
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 *previous; |
|
27 | 27 | struct ring_node_asm *next; |
|
28 |
float |
|
|
28 | float matrix[ TOTAL_SIZE_SM ]; | |
|
29 | 29 | unsigned int status; |
|
30 | 30 | } ring_node_asm; |
|
31 | 31 | |
|
32 | 32 | typedef struct bp_packet |
|
33 | 33 | { |
|
34 | 34 | Header_TM_LFR_SCIENCE_BP_t header; |
|
35 | 35 | unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
36 | 36 | } bp_packet; |
|
37 | 37 | |
|
38 | 38 | typedef struct bp_packet_with_spare |
|
39 | 39 | { |
|
40 | 40 | Header_TM_LFR_SCIENCE_BP_with_spare_t header; |
|
41 | 41 | unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 |
|
42 | 42 | } bp_packet_with_spare; |
|
43 | 43 | |
|
44 | typedef struct asm_msg | |
|
45 | { | |
|
46 | ring_node_asm *norm_f0; | |
|
47 | ring_node_asm *burst_sbmf0; | |
|
48 | rtems_event_set event; | |
|
49 | unsigned int coarseTime; | |
|
50 | unsigned int fineTime; | |
|
51 | } asm_msg; | |
|
52 | ||
|
44 | 53 | extern nb_sm_t nb_sm; |
|
45 | 54 | extern nb_sm_before_bp_t nb_sm_before_bp; |
|
46 | 55 | |
|
47 | 56 | extern volatile int sm_f0[ ]; |
|
48 | 57 | extern volatile int sm_f1[ ]; |
|
49 | 58 | extern volatile int sm_f2[ ]; |
|
50 | 59 | |
|
51 | 60 | // parameters |
|
52 | 61 | extern struct param_local_str param_local; |
|
53 | 62 | |
|
54 | 63 | // registers |
|
55 | 64 | extern time_management_regs_t *time_management_regs; |
|
56 | 65 | extern spectral_matrix_regs_t *spectral_matrix_regs; |
|
57 | 66 | |
|
58 | 67 | extern rtems_name misc_name[5]; |
|
59 | 68 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
60 | 69 | |
|
61 | 70 | // ISR |
|
62 | 71 | void reset_nb_sm_f0( unsigned char lfrMode ); |
|
63 | 72 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
64 | 73 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); |
|
65 | 74 | |
|
66 | 75 | // RTEMS TASKS |
|
67 | 76 | rtems_task smiq_task( rtems_task_argument argument ); // added to test the spectral matrix simulator |
|
68 | 77 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ); |
|
69 | 78 | rtems_task matr_task( rtems_task_argument lfrRequestedMode ); |
|
70 | 79 | |
|
71 | 80 | //****************** |
|
72 | 81 | // Spectral Matrices |
|
73 | 82 | void SM_init_rings( void ); |
|
74 | void ASM_init_ring( void ); | |
|
83 | void ASM_init_rings( void ); | |
|
75 | 84 | void SM_reset_current_ring_nodes( void ); |
|
76 | 85 | void ASM_reset_current_ring_node( void ); |
|
77 | 86 | void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header); |
|
78 | 87 | void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, |
|
79 | 88 | ring_node_sm *ring_node_tab[], |
|
80 | 89 | unsigned int firstTimeF0, unsigned int firstTimeF1 ); |
|
81 | 90 | void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, |
|
82 | 91 | float divider ); |
|
83 | 92 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, |
|
84 | 93 | float divider, |
|
85 | 94 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
86 | 95 | void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
87 | 96 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
88 | 97 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id); |
|
89 | 98 | |
|
90 | 99 | //***************** |
|
91 | 100 | // Basic Parameters |
|
92 | 101 | |
|
93 | 102 | void BP_reset_current_ring_nodes( void ); |
|
94 | 103 | void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header, |
|
95 | 104 | unsigned int apid, unsigned char sid, |
|
96 | 105 | unsigned int packetLength , unsigned char blkNr); |
|
97 | 106 | void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, |
|
98 | 107 | unsigned int apid, unsigned char sid, |
|
99 | 108 | unsigned int packetLength, unsigned char blkNr ); |
|
100 | 109 | void BP_send(char *data, |
|
101 | 110 | rtems_id queue_id , |
|
102 | 111 | unsigned int nbBytesToSend ); |
|
103 | 112 | |
|
104 | 113 | //****************** |
|
105 | 114 | // general functions |
|
106 | 115 | void reset_spectral_matrix_regs( void ); |
|
107 | 116 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); |
|
108 | 117 | |
|
118 | extern rtems_status_code get_message_queue_id_matr( rtems_id *queue_id ); | |
|
119 | ||
|
109 | 120 | #endif // FSW_PROCESSING_H_INCLUDED |
@@ -1,60 +1,60 | |||
|
1 | 1 | #ifndef TC_HANDLER_H_INCLUDED |
|
2 | 2 | #define 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 | #include "wf_handler.h" |
|
11 | 11 | #include "fsw_processing.h" |
|
12 | 12 | |
|
13 | 13 | // MODE PARAMETERS |
|
14 | 14 | extern unsigned int maxCount; |
|
15 | 15 | |
|
16 | 16 | //**** |
|
17 | 17 | // ISR |
|
18 | 18 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
19 | 19 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
20 | 20 | |
|
21 | 21 | //*********** |
|
22 | 22 | // RTEMS TASK |
|
23 | 23 | rtems_task actn_task( rtems_task_argument unused ); |
|
24 | 24 | |
|
25 | 25 | //*********** |
|
26 | 26 | // TC ACTIONS |
|
27 | 27 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
28 | 28 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
29 | 29 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
30 | 30 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
31 | 31 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
32 | 32 | int action_update_time( ccsdsTelecommandPacket_t *TC); |
|
33 | 33 | |
|
34 | 34 | // mode transition |
|
35 | 35 | int check_mode_value( unsigned char requestedMode ); |
|
36 | 36 | int check_mode_transition( unsigned char requestedMode ); |
|
37 | 37 | int check_transition_date( unsigned int transitionCoarseTime ); |
|
38 | 38 | int stop_current_mode( void ); |
|
39 | 39 | int enter_mode( unsigned char mode , unsigned int transitionCoarseTime ); |
|
40 | 40 | int restart_science_tasks(unsigned char lfrRequestedMode ); |
|
41 | 41 | int suspend_science_tasks(); |
|
42 | 42 | void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime); |
|
43 |
void launch_spectral_matrix( |
|
|
43 | void launch_spectral_matrix( void ); | |
|
44 | void launch_spectral_matrix_simu( void ); | |
|
44 | 45 | void set_irq_on_new_ready_matrix(unsigned char value ); |
|
45 | 46 | void set_run_matrix_spectral( unsigned char value ); |
|
46 | void launch_spectral_matrix_simu( unsigned char mode ); | |
|
47 | 47 | |
|
48 | 48 | // other functions |
|
49 | 49 | void updateLFRCurrentMode(); |
|
50 | 50 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
51 | 51 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
52 | 52 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); |
|
53 | 53 | |
|
54 | 54 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
55 | 55 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
56 | 56 | |
|
57 | 57 | #endif // TC_HANDLER_H_INCLUDED |
|
58 | 58 | |
|
59 | 59 | |
|
60 | 60 |
@@ -1,645 +1,674 | |||
|
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 |
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES |
|
|
38 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 3 | |
|
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 "fsw_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 | reset_local_time(); |
|
74 | 74 | |
|
75 | 75 | rtems_status_code status; |
|
76 | 76 | rtems_status_code status_spw; |
|
77 | 77 | rtems_isr_entry old_isr_handler; |
|
78 | 78 | |
|
79 | 79 | // UART settings |
|
80 | 80 | send_console_outputs_on_apbuart_port(); |
|
81 | 81 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
82 | 82 | enable_apbuart_transmitter(); |
|
83 | 83 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
84 | 84 | |
|
85 | 85 | PRINTF("\n\n\n\n\n") |
|
86 | 86 | PRINTF("*************************\n") |
|
87 | 87 | PRINTF("** LFR Flight Software **\n") |
|
88 | 88 | PRINTF1("** %d.", SW_VERSION_N1) |
|
89 | 89 | PRINTF1("%d.", SW_VERSION_N2) |
|
90 | 90 | PRINTF1("%d.", SW_VERSION_N3) |
|
91 | 91 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
92 | 92 | PRINTF("*************************\n") |
|
93 | 93 | PRINTF("\n\n") |
|
94 | 94 | |
|
95 | 95 | init_parameter_dump(); |
|
96 | 96 | init_local_mode_parameters(); |
|
97 | 97 | init_housekeeping_parameters(); |
|
98 | 98 | |
|
99 | 99 | init_waveform_rings(); // initialize the waveform rings |
|
100 | 100 | SM_init_rings(); // initialize spectral matrices rings |
|
101 |
ASM_init_ring(); |
|
|
101 | ASM_init_rings(); // initialize the average spectral matrix ring (just for burst, sbm1 and sbm2 asm @ f0 storage) | |
|
102 | 102 | |
|
103 | 103 | reset_wfp_burst_enable(); |
|
104 | 104 | reset_wfp_status(); |
|
105 | 105 | set_wfp_data_shaping(); |
|
106 | 106 | |
|
107 | 107 | updateLFRCurrentMode(); |
|
108 | 108 | |
|
109 | 109 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
110 | 110 | |
|
111 | 111 | create_names(); // create all names |
|
112 | 112 | |
|
113 | 113 | status = create_message_queues(); // create message queues |
|
114 | 114 | if (status != RTEMS_SUCCESSFUL) |
|
115 | 115 | { |
|
116 | 116 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | status = create_all_tasks(); // create all tasks |
|
120 | 120 | if (status != RTEMS_SUCCESSFUL) |
|
121 | 121 | { |
|
122 | 122 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) |
|
123 | 123 | } |
|
124 | 124 | |
|
125 | 125 | // ************************** |
|
126 | 126 | // <SPACEWIRE INITIALIZATION> |
|
127 | 127 | grspw_timecode_callback = &timecode_irq_handler; |
|
128 | 128 | |
|
129 | 129 | status_spw = spacewire_open_link(); // (1) open the link |
|
130 | 130 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
131 | 131 | { |
|
132 | 132 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
136 | 136 | { |
|
137 | 137 | status_spw = spacewire_configure_link( fdSPW ); |
|
138 | 138 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
139 | 139 | { |
|
140 | 140 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
141 | 141 | } |
|
142 | 142 | } |
|
143 | 143 | |
|
144 | 144 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
145 | 145 | { |
|
146 | 146 | status_spw = spacewire_start_link( fdSPW ); |
|
147 | 147 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
148 | 148 | { |
|
149 | 149 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
150 | 150 | } |
|
151 | 151 | } |
|
152 | 152 | // </SPACEWIRE INITIALIZATION> |
|
153 | 153 | // *************************** |
|
154 | 154 | |
|
155 | 155 | status = start_all_tasks(); // start all tasks |
|
156 | 156 | if (status != RTEMS_SUCCESSFUL) |
|
157 | 157 | { |
|
158 | 158 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
159 | 159 | } |
|
160 | 160 | |
|
161 | 161 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
162 | 162 | status = start_recv_send_tasks(); |
|
163 | 163 | if ( status != RTEMS_SUCCESSFUL ) |
|
164 | 164 | { |
|
165 | 165 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
166 | 166 | } |
|
167 | 167 | |
|
168 | 168 | // suspend science tasks, they will be restarted later depending on the mode |
|
169 | 169 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
170 | 170 | if (status != RTEMS_SUCCESSFUL) |
|
171 | 171 | { |
|
172 | 172 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | //****************************** |
|
176 | 176 | // <SPECTRAL MATRICES SIMULATOR> |
|
177 | 177 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); |
|
178 | 178 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
179 | 179 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); |
|
180 | 180 | // </SPECTRAL MATRICES SIMULATOR> |
|
181 | 181 | //******************************* |
|
182 | 182 | |
|
183 | 183 | // configure IRQ handling for the waveform picker unit |
|
184 | 184 | status = rtems_interrupt_catch( waveforms_isr, |
|
185 | 185 | IRQ_SPARC_WAVEFORM_PICKER, |
|
186 | 186 | &old_isr_handler) ; |
|
187 | 187 | // configure IRQ handling for the spectral matrices unit |
|
188 | 188 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
189 | 189 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
190 | 190 | &old_isr_handler) ; |
|
191 | 191 | |
|
192 | 192 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
193 | 193 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
194 | 194 | { |
|
195 | 195 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
196 | 196 | if ( status != RTEMS_SUCCESSFUL ) { |
|
197 | 197 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
198 | 198 | } |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | BOOT_PRINTF("delete INIT\n") |
|
202 | 202 | |
|
203 | 203 | send_dumb_hk(); |
|
204 | 204 | |
|
205 | 205 | status = rtems_task_delete(RTEMS_SELF); |
|
206 | 206 | |
|
207 | 207 | } |
|
208 | 208 | |
|
209 | 209 | void init_local_mode_parameters( void ) |
|
210 | 210 | { |
|
211 | 211 | /** This function initialize the param_local global variable with default values. |
|
212 | 212 | * |
|
213 | 213 | */ |
|
214 | 214 | |
|
215 | 215 | unsigned int i; |
|
216 | 216 | |
|
217 | 217 | // LOCAL PARAMETERS |
|
218 | 218 | set_local_nb_interrupt_f0_MAX(); |
|
219 | 219 | |
|
220 | 220 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
221 | 221 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
222 | 222 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
223 | 223 | |
|
224 | 224 | // init sequence counters |
|
225 | 225 | |
|
226 | 226 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
227 | 227 | { |
|
228 | 228 | sequenceCounters_TC_EXE[i] = 0x00; |
|
229 | 229 | } |
|
230 | 230 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
231 | 231 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
232 | 232 | } |
|
233 | 233 | |
|
234 | 234 | void reset_local_time( void ) |
|
235 | 235 | { |
|
236 | 236 | time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000 |
|
237 | 237 | } |
|
238 | 238 | |
|
239 | 239 | void create_names( void ) // create all names for tasks and queues |
|
240 | 240 | { |
|
241 | 241 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
242 | 242 | * |
|
243 | 243 | * @return RTEMS directive status codes: |
|
244 | 244 | * - RTEMS_SUCCESSFUL - successful completion |
|
245 | 245 | * |
|
246 | 246 | */ |
|
247 | 247 | |
|
248 | 248 | // task names |
|
249 | 249 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
250 | 250 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
251 | 251 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
252 | 252 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
253 | 253 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
254 | 254 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
255 | 255 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
256 | 256 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
257 | 257 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
258 | 258 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
259 | 259 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); |
|
260 | 260 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
261 | 261 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
262 | 262 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
263 | 263 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
264 | 264 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
265 | 265 | |
|
266 | 266 | // rate monotonic period names |
|
267 | 267 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
268 | 268 | |
|
269 | 269 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
270 | 270 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
271 | misc_name[QUEUE_MATR] = rtems_build_name( 'Q', '_', 'M', 'R' ); | |
|
271 | 272 | } |
|
272 | 273 | |
|
273 | 274 | int create_all_tasks( void ) // create all tasks which run in the software |
|
274 | 275 | { |
|
275 | 276 | /** This function creates all RTEMS tasks used in the software. |
|
276 | 277 | * |
|
277 | 278 | * @return RTEMS directive status codes: |
|
278 | 279 | * - RTEMS_SUCCESSFUL - task created successfully |
|
279 | 280 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
280 | 281 | * - RTEMS_INVALID_NAME - invalid task name |
|
281 | 282 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
282 | 283 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
283 | 284 | * - RTEMS_TOO_MANY - too many tasks created |
|
284 | 285 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
285 | 286 | * - RTEMS_TOO_MANY - too many global objects |
|
286 | 287 | * |
|
287 | 288 | */ |
|
288 | 289 | |
|
289 | 290 | rtems_status_code status; |
|
290 | 291 | |
|
291 | 292 | //********** |
|
292 | 293 | // SPACEWIRE |
|
293 | 294 | // RECV |
|
294 | 295 | status = rtems_task_create( |
|
295 | 296 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
296 | 297 | RTEMS_DEFAULT_MODES, |
|
297 | 298 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
298 | 299 | ); |
|
299 | 300 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
300 | 301 | { |
|
301 | 302 | status = rtems_task_create( |
|
302 | 303 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, |
|
303 | 304 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
304 | 305 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] |
|
305 | 306 | ); |
|
306 | 307 | } |
|
307 | 308 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
308 | 309 | { |
|
309 | 310 | status = rtems_task_create( |
|
310 | 311 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
311 | 312 | RTEMS_DEFAULT_MODES, |
|
312 | 313 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
313 | 314 | ); |
|
314 | 315 | } |
|
315 | 316 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
316 | 317 | { |
|
317 | 318 | status = rtems_task_create( |
|
318 | 319 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
319 | 320 | RTEMS_DEFAULT_MODES, |
|
320 | 321 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
321 | 322 | ); |
|
322 | 323 | } |
|
323 | 324 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
324 | 325 | { |
|
325 | 326 | status = rtems_task_create( |
|
326 | 327 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
327 | 328 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
328 | 329 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
329 | 330 | ); |
|
330 | 331 | } |
|
331 | 332 | |
|
332 | 333 | //****************** |
|
333 | 334 | // SPECTRAL MATRICES |
|
334 | 335 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
335 | 336 | { |
|
336 | 337 | status = rtems_task_create( |
|
337 | 338 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
338 | 339 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
339 | 340 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] |
|
340 | 341 | ); |
|
341 | 342 | } |
|
342 | 343 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
343 | 344 | { |
|
344 | 345 | status = rtems_task_create( |
|
345 | 346 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
346 | 347 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
347 | 348 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
348 | 349 | ); |
|
349 | 350 | } |
|
350 | 351 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
351 | 352 | { |
|
352 | 353 | status = rtems_task_create( |
|
353 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, | |
|
354 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE * 2, | |
|
354 | 355 | RTEMS_DEFAULT_MODES, |
|
355 | 356 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] |
|
356 | 357 | ); |
|
357 | 358 | } |
|
358 | 359 | |
|
359 | 360 | //**************** |
|
360 | 361 | // WAVEFORM PICKER |
|
361 | 362 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
362 | 363 | { |
|
363 | 364 | status = rtems_task_create( |
|
364 | 365 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
365 | 366 | RTEMS_DEFAULT_MODES, |
|
366 | 367 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
367 | 368 | ); |
|
368 | 369 | } |
|
369 | 370 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
370 | 371 | { |
|
371 | 372 | status = rtems_task_create( |
|
372 | 373 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
373 | 374 | RTEMS_DEFAULT_MODES, |
|
374 | 375 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
375 | 376 | ); |
|
376 | 377 | } |
|
377 | 378 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
378 | 379 | { |
|
379 | 380 | status = rtems_task_create( |
|
380 | 381 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
381 | 382 | RTEMS_DEFAULT_MODES, |
|
382 | 383 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
383 | 384 | ); |
|
384 | 385 | } |
|
385 | 386 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
386 | 387 | { |
|
387 | 388 | status = rtems_task_create( |
|
388 | 389 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
389 | 390 | RTEMS_DEFAULT_MODES, |
|
390 | 391 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
391 | 392 | ); |
|
392 | 393 | } |
|
393 | 394 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
394 | 395 | { |
|
395 | 396 | status = rtems_task_create( |
|
396 | 397 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
397 | 398 | RTEMS_DEFAULT_MODES, |
|
398 | 399 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
399 | 400 | ); |
|
400 | 401 | } |
|
401 | 402 | |
|
402 | 403 | //***** |
|
403 | 404 | // MISC |
|
404 | 405 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
405 | 406 | { |
|
406 | 407 | status = rtems_task_create( |
|
407 | 408 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
408 | 409 | RTEMS_DEFAULT_MODES, |
|
409 | 410 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
410 | 411 | ); |
|
411 | 412 | } |
|
412 | 413 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
413 | 414 | { |
|
414 | 415 | status = rtems_task_create( |
|
415 | 416 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
416 | 417 | RTEMS_DEFAULT_MODES, |
|
417 | 418 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
418 | 419 | ); |
|
419 | 420 | } |
|
420 | 421 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
421 | 422 | { |
|
422 | 423 | status = rtems_task_create( |
|
423 | 424 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
424 | 425 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
425 | 426 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] |
|
426 | 427 | ); |
|
427 | 428 | } |
|
428 | 429 | |
|
429 | 430 | return status; |
|
430 | 431 | } |
|
431 | 432 | |
|
432 | 433 | int start_recv_send_tasks( void ) |
|
433 | 434 | { |
|
434 | 435 | rtems_status_code status; |
|
435 | 436 | |
|
436 | 437 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
437 | 438 | if (status!=RTEMS_SUCCESSFUL) { |
|
438 | 439 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
439 | 440 | } |
|
440 | 441 | |
|
441 | 442 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
442 | 443 | { |
|
443 | 444 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
444 | 445 | if (status!=RTEMS_SUCCESSFUL) { |
|
445 | 446 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
446 | 447 | } |
|
447 | 448 | } |
|
448 | 449 | |
|
449 | 450 | return status; |
|
450 | 451 | } |
|
451 | 452 | |
|
452 | 453 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
453 | 454 | { |
|
454 | 455 | /** This function starts all RTEMS tasks used in the software. |
|
455 | 456 | * |
|
456 | 457 | * @return RTEMS directive status codes: |
|
457 | 458 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
458 | 459 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
459 | 460 | * - RTEMS_INVALID_ID - invalid task id |
|
460 | 461 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
461 | 462 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
462 | 463 | * |
|
463 | 464 | */ |
|
464 | 465 | // starts all the tasks fot eh flight software |
|
465 | 466 | |
|
466 | 467 | rtems_status_code status; |
|
467 | 468 | |
|
468 | 469 | //********** |
|
469 | 470 | // SPACEWIRE |
|
470 | 471 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
471 | 472 | if (status!=RTEMS_SUCCESSFUL) { |
|
472 | 473 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
473 | 474 | } |
|
474 | 475 | |
|
475 | 476 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
476 | 477 | { |
|
477 | 478 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
478 | 479 | if (status!=RTEMS_SUCCESSFUL) { |
|
479 | 480 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
480 | 481 | } |
|
481 | 482 | } |
|
482 | 483 | |
|
483 | 484 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
484 | 485 | { |
|
485 | 486 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
486 | 487 | if (status!=RTEMS_SUCCESSFUL) { |
|
487 | 488 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
488 | 489 | } |
|
489 | 490 | } |
|
490 | 491 | |
|
491 | 492 | //****************** |
|
492 | 493 | // SPECTRAL MATRICES |
|
493 | 494 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
494 | 495 | { |
|
495 | 496 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); |
|
496 | 497 | if (status!=RTEMS_SUCCESSFUL) { |
|
497 | 498 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") |
|
498 | 499 | } |
|
499 | 500 | } |
|
500 | 501 | |
|
501 | 502 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
502 | 503 | { |
|
503 | 504 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); |
|
504 | 505 | if (status!=RTEMS_SUCCESSFUL) { |
|
505 | 506 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
506 | 507 | } |
|
507 | 508 | } |
|
508 | 509 | |
|
509 | 510 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
510 | 511 | { |
|
511 | 512 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); |
|
512 | 513 | if (status!=RTEMS_SUCCESSFUL) { |
|
513 | 514 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") |
|
514 | 515 | } |
|
515 | 516 | } |
|
516 | 517 | |
|
517 | 518 | //**************** |
|
518 | 519 | // WAVEFORM PICKER |
|
519 | 520 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
520 | 521 | { |
|
521 | 522 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
522 | 523 | if (status!=RTEMS_SUCCESSFUL) { |
|
523 | 524 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
524 | 525 | } |
|
525 | 526 | } |
|
526 | 527 | |
|
527 | 528 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
528 | 529 | { |
|
529 | 530 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
530 | 531 | if (status!=RTEMS_SUCCESSFUL) { |
|
531 | 532 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
532 | 533 | } |
|
533 | 534 | } |
|
534 | 535 | |
|
535 | 536 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
536 | 537 | { |
|
537 | 538 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
538 | 539 | if (status!=RTEMS_SUCCESSFUL) { |
|
539 | 540 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
540 | 541 | } |
|
541 | 542 | } |
|
542 | 543 | |
|
543 | 544 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
544 | 545 | { |
|
545 | 546 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
546 | 547 | if (status!=RTEMS_SUCCESSFUL) { |
|
547 | 548 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
548 | 549 | } |
|
549 | 550 | } |
|
550 | 551 | |
|
551 | 552 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
552 | 553 | { |
|
553 | 554 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
554 | 555 | if (status!=RTEMS_SUCCESSFUL) { |
|
555 | 556 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
556 | 557 | } |
|
557 | 558 | } |
|
558 | 559 | |
|
559 | 560 | //***** |
|
560 | 561 | // MISC |
|
561 | 562 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
562 | 563 | { |
|
563 | 564 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
564 | 565 | if (status!=RTEMS_SUCCESSFUL) { |
|
565 | 566 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
566 | 567 | } |
|
567 | 568 | } |
|
568 | 569 | |
|
569 | 570 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
570 | 571 | { |
|
571 | 572 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
572 | 573 | if (status!=RTEMS_SUCCESSFUL) { |
|
573 | 574 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
574 | 575 | } |
|
575 | 576 | } |
|
576 | 577 | |
|
577 | 578 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
578 | 579 | { |
|
579 | 580 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
580 | 581 | if (status!=RTEMS_SUCCESSFUL) { |
|
581 | 582 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
582 | 583 | } |
|
583 | 584 | } |
|
584 | 585 | |
|
585 | 586 | return status; |
|
586 | 587 | } |
|
587 | 588 | |
|
588 | 589 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
589 | 590 | { |
|
590 | 591 | rtems_status_code status_recv; |
|
591 | 592 | rtems_status_code status_send; |
|
593 | rtems_status_code status_matr; | |
|
592 | 594 | rtems_status_code ret; |
|
593 | 595 | rtems_id queue_id; |
|
594 | 596 | |
|
597 | //**************************************** | |
|
595 | 598 | // create the queue for handling valid TCs |
|
596 | 599 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
597 |
|
|
|
600 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
|
598 | 601 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
599 | 602 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
600 | 603 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
601 | 604 | } |
|
602 | 605 | |
|
606 | //************************************************ | |
|
603 | 607 | // create the queue for handling TM packet sending |
|
604 | 608 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
605 |
|
|
|
609 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
|
606 | 610 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
607 | 611 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
608 | 612 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
609 | 613 | } |
|
610 | 614 | |
|
615 | //************************************************************************ | |
|
616 | // create the queue for handling averaged spectral matrices for processing | |
|
617 | status_matr = rtems_message_queue_create( misc_name[QUEUE_MATR], | |
|
618 | MSG_QUEUE_COUNT_MATR, MSG_QUEUE_SIZE_MATR, | |
|
619 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
|
620 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
|
621 | PRINTF1("in create_message_queues *** ERR creating MATR queue, %d\n", status_matr) | |
|
622 | } | |
|
623 | ||
|
611 | 624 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
612 | 625 | { |
|
613 | 626 | ret = status_recv; |
|
614 | 627 | } |
|
628 | else if( status_send != RTEMS_SUCCESSFUL ) | |
|
629 | { | |
|
630 | ret = status_send; | |
|
631 | } | |
|
615 | 632 | else |
|
616 | 633 | { |
|
617 |
ret = status_ |
|
|
634 | ret = status_matr; | |
|
618 | 635 | } |
|
619 | 636 | |
|
620 | 637 | return ret; |
|
621 | 638 | } |
|
622 | 639 | |
|
623 | 640 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
624 | 641 | { |
|
625 | 642 | rtems_status_code status; |
|
626 | 643 | rtems_name queue_name; |
|
627 | 644 | |
|
628 | 645 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
629 | 646 | |
|
630 | 647 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
631 | 648 | |
|
632 | 649 | return status; |
|
633 | 650 | } |
|
634 | 651 | |
|
635 | 652 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
636 | 653 | { |
|
637 | 654 | rtems_status_code status; |
|
638 | 655 | rtems_name queue_name; |
|
639 | 656 | |
|
640 | 657 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
641 | 658 | |
|
642 | 659 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
643 | 660 | |
|
644 | 661 | return status; |
|
645 | 662 | } |
|
663 | ||
|
664 | rtems_status_code get_message_queue_id_matr( rtems_id *queue_id ) | |
|
665 | { | |
|
666 | rtems_status_code status; | |
|
667 | rtems_name queue_name; | |
|
668 | ||
|
669 | queue_name = rtems_build_name( 'Q', '_', 'M', 'R' ); | |
|
670 | ||
|
671 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
|
672 | ||
|
673 | return status; | |
|
674 | } |
@@ -1,889 +1,892 | |||
|
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 | |
|
12 | 12 | #include "fsw_processing_globals.c" |
|
13 | 13 | |
|
14 | 14 | //************************ |
|
15 | 15 | // spectral matrices rings |
|
16 | 16 | ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ]; |
|
17 | 17 | ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ]; |
|
18 | 18 | ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ]; |
|
19 | 19 | ring_node_sm *current_ring_node_sm_f0; |
|
20 | 20 | ring_node_sm *ring_node_for_averaging_sm_f0; |
|
21 | 21 | ring_node_sm *current_ring_node_sm_f1; |
|
22 | 22 | ring_node_sm *current_ring_node_sm_f2; |
|
23 | 23 | |
|
24 | 24 | ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ]; |
|
25 | ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ]; | |
|
25 | 26 | ring_node_asm *current_ring_node_asm_burst_sbm_f0; |
|
26 |
ring_node_asm *ring_node_ |
|
|
27 | ring_node_asm *current_ring_node_asm_norm_f0; | |
|
27 | 28 | |
|
28 | //***** | |
|
29 | // NORM | |
|
30 | // F0 | |
|
31 | float asm_norm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ]; | |
|
32 | float asm_f0_reorganized [ TIME_OFFSET + TOTAL_SIZE_SM ]; | |
|
29 | float asm_norm_f0 [ TOTAL_SIZE_SM ]; | |
|
30 | float asm_f0_reorganized [ TOTAL_SIZE_SM ]; | |
|
33 | 31 | char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ]; |
|
34 |
float compressed_sm_norm_f0[ |
|
|
35 | ||
|
36 | //***** | |
|
37 | // SBM1 | |
|
38 | float asm_sbm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ]; | |
|
39 | float compressed_sm_sbm[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ]; | |
|
40 | ||
|
41 | unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ]; | |
|
42 | unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ]; | |
|
43 | unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F2 ]; | |
|
32 | float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_F0 ]; | |
|
33 | float compressed_sm_sbm [ TOTAL_SIZE_COMPRESSED_ASM_SBM1 ]; | |
|
44 | 34 | |
|
45 | 35 | //*********************************************************** |
|
46 | 36 | // Interrupt Service Routine for spectral matrices processing |
|
47 | 37 | void reset_nb_sm_f0( unsigned char lfrMode ) |
|
48 | 38 | { |
|
49 | 39 | nb_sm.f0 = 0; |
|
50 | 40 | nb_sm.norm_bp1_f0 = 0; |
|
51 | 41 | nb_sm.norm_bp2_f0 = 0; |
|
52 | 42 | nb_sm.norm_asm_f0 = 0; |
|
53 | 43 | nb_sm.sbm_bp1_f0 = 0; |
|
54 | 44 | nb_sm.sbm_bp2_f0 = 0; |
|
55 | 45 | |
|
56 | 46 | nb_sm_before_bp.norm_bp1_f0 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96; |
|
57 | 47 | nb_sm_before_bp.norm_bp2_f0 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96; |
|
58 | 48 | nb_sm_before_bp.norm_asm_f0 = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96; |
|
59 | 49 | nb_sm_before_bp.sbm1_bp1_f0 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; |
|
60 | 50 | nb_sm_before_bp.sbm1_bp2_f0 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96; |
|
61 | 51 | nb_sm_before_bp.sbm2_bp1_f0 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96; |
|
62 | 52 | nb_sm_before_bp.sbm2_bp2_f0 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96; |
|
63 | 53 | nb_sm_before_bp.burst_bp1_f0 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96; |
|
64 | 54 | nb_sm_before_bp.burst_bp2_f0 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96; |
|
65 | 55 | |
|
66 | 56 | if (lfrMode == LFR_MODE_SBM1) |
|
67 | 57 | { |
|
68 | 58 | nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm1_bp1_f0; |
|
69 | 59 | nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm1_bp2_f0; |
|
70 | 60 | } |
|
71 | 61 | else if (lfrMode == LFR_MODE_SBM2) |
|
72 | 62 | { |
|
73 | 63 | nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm2_bp1_f0; |
|
74 | 64 | nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm2_bp2_f0; |
|
75 | 65 | } |
|
76 | 66 | else if (lfrMode == LFR_MODE_BURST) |
|
77 | 67 | { |
|
78 | 68 | nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0; |
|
79 | 69 | nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0; |
|
80 | 70 | } |
|
81 | 71 | else |
|
82 | 72 | { |
|
83 | 73 | nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0; |
|
84 | 74 | nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0; |
|
85 | 75 | } |
|
86 | 76 | } |
|
87 | 77 | |
|
88 | 78 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
89 | 79 | { |
|
80 | ring_node_sm *previous_ring_node_sm_f0; | |
|
81 | ||
|
90 | 82 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); |
|
91 | 83 | |
|
92 | // if ( (spectral_matrix_regs->status & 0x1) == 0x01) | |
|
93 | // { | |
|
94 | // current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
|
95 | // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; | |
|
96 | // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110 | |
|
97 | // nb_sm_f0 = nb_sm_f0 + 1; | |
|
98 | // } | |
|
99 | // else if ( (spectral_matrix_regs->status & 0x2) == 0x02) | |
|
100 |
|
|
|
101 | // current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
|
102 | // spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address; | |
|
103 | // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101 | |
|
104 | // nb_sm_f0 = nb_sm_f0 + 1; | |
|
105 | // } | |
|
84 | previous_ring_node_sm_f0 = current_ring_node_sm_f0; | |
|
85 | ||
|
86 | if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1 | |
|
87 | { | |
|
88 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
|
89 | spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; | |
|
90 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101 | |
|
91 | nb_sm.f0 = nb_sm.f0 + 1; | |
|
92 | } | |
|
106 | 93 | |
|
107 | // if ( (spectral_matrix_regs->status & 0x30) != 0x00) | |
|
108 | // { | |
|
109 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
|
110 | // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111 | |
|
111 | // } | |
|
112 | ||
|
113 | // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011 | |
|
94 | //************************ | |
|
95 | // reset status error bits | |
|
96 | if ( (spectral_matrix_regs->status & 0x30) != 0x00) | |
|
97 | { | |
|
98 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
|
99 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111 | |
|
100 | } | |
|
114 | 101 | |
|
115 | // if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) ) | |
|
116 | // { | |
|
117 | // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; | |
|
118 | // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
|
119 | // { | |
|
120 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
121 | // } | |
|
122 | // nb_sm_f0 = 0; | |
|
123 | // } | |
|
124 | // else | |
|
125 | // { | |
|
126 |
|
|
|
127 |
|
|
|
102 | //************************************** | |
|
103 | // reset ready matrix bits for f0_0, f1 and f2 | |
|
104 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010 | |
|
105 | ||
|
106 | if (nb_sm.f0 == NB_SM_BEFORE_AVF0) | |
|
107 | { | |
|
108 | ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0; | |
|
109 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
|
110 | { | |
|
111 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
|
112 | } | |
|
113 | nb_sm.f0 = 0; | |
|
114 | } | |
|
115 | ||
|
128 | 116 | } |
|
129 | 117 | |
|
130 | 118 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
131 | 119 | { |
|
132 | 120 | if (nb_sm.f0 == (NB_SM_BEFORE_AVF0-1) ) |
|
133 | 121 | { |
|
134 | 122 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; |
|
135 | 123 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
136 | 124 | { |
|
137 | 125 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
138 | 126 | } |
|
139 | 127 | nb_sm.f0 = 0; |
|
140 | 128 | } |
|
141 | 129 | else |
|
142 | 130 | { |
|
143 | 131 | nb_sm.f0 = nb_sm.f0 + 1; |
|
144 | 132 | } |
|
145 | 133 | } |
|
146 | 134 | |
|
147 | 135 | //************ |
|
148 | 136 | // RTEMS TASKS |
|
149 | 137 | |
|
150 | 138 | rtems_task smiq_task( rtems_task_argument argument ) // process the Spectral Matrices IRQ |
|
151 | 139 | { |
|
152 | 140 | rtems_event_set event_out; |
|
153 | 141 | |
|
154 | 142 | BOOT_PRINTF("in SMIQ *** \n") |
|
155 | 143 | |
|
156 | 144 | while(1){ |
|
157 | 145 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
158 | 146 | } |
|
159 | 147 | } |
|
160 | 148 | |
|
161 | 149 | rtems_task avf0_task( rtems_task_argument lfrRequestedMode ) |
|
162 | 150 | { |
|
163 | 151 | int i; |
|
164 | 152 | |
|
165 | 153 | rtems_event_set event_out; |
|
166 | rtems_event_set event_for_matr; | |
|
167 | 154 | rtems_status_code status; |
|
155 | rtems_id queue_id_matr; | |
|
156 | asm_msg msgForMATR; | |
|
168 | 157 | ring_node_sm *ring_node_tab[8]; |
|
169 | unsigned long long int localTime; | |
|
170 | 158 | |
|
171 | 159 | reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions |
|
172 | 160 | |
|
173 | 161 | BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", lfrRequestedMode) |
|
174 | 162 | |
|
163 | status = get_message_queue_id_matr( &queue_id_matr ); | |
|
164 | if (status != RTEMS_SUCCESSFUL) | |
|
165 | { | |
|
166 | PRINTF1("in MATR *** ERR get_message_queue_id_matr %d\n", status) | |
|
167 | } | |
|
168 | ||
|
175 | 169 | while(1){ |
|
176 | 170 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
177 | 171 | ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0; |
|
178 | 172 | for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ ) |
|
179 | 173 | { |
|
180 | 174 | ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous; |
|
181 | 175 | ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0; |
|
182 | 176 | } |
|
183 | 177 | |
|
184 | localTime = getTimeAsUnsignedLongLongInt( ); | |
|
185 | ||
|
186 | 178 | // compute the average and store it in the averaged_sm_f1 buffer |
|
187 |
SM_average( |
|
|
179 | SM_average( current_ring_node_asm_norm_f0->matrix, | |
|
180 | current_ring_node_asm_burst_sbm_f0->matrix, | |
|
188 | 181 |
|
|
189 | 182 |
|
|
190 | 183 | |
|
191 | localTime = getTimeAsUnsignedLongLongInt( ) - localTime; | |
|
192 | ||
|
193 | 184 | // update nb_average |
|
194 | 185 | nb_sm.norm_bp1_f0 = nb_sm.norm_bp1_f0 + NB_SM_BEFORE_AVF0; |
|
195 | 186 | nb_sm.norm_bp2_f0 = nb_sm.norm_bp2_f0 + NB_SM_BEFORE_AVF0; |
|
196 | 187 | nb_sm.norm_asm_f0 = nb_sm.norm_asm_f0 + NB_SM_BEFORE_AVF0; |
|
197 | 188 | nb_sm.sbm_bp1_f0 = nb_sm.sbm_bp1_f0 + NB_SM_BEFORE_AVF0; |
|
198 | 189 | nb_sm.sbm_bp2_f0 = nb_sm.sbm_bp2_f0 + NB_SM_BEFORE_AVF0; |
|
199 | 190 | |
|
200 |
//**************************************** |
|
|
201 |
// |
|
|
202 | event_for_matr = 0x00; | |
|
191 | //**************************************** | |
|
192 | // initialize the mesage for the MATR task | |
|
193 | msgForMATR.event = 0x00; // this composite event will be sent to the MATR task | |
|
194 | msgForMATR.burst_sbmf0 = current_ring_node_asm_burst_sbm_f0; | |
|
195 | msgForMATR.norm_f0 = current_ring_node_asm_norm_f0; | |
|
196 | msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0]; | |
|
197 | msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1]; | |
|
203 | 198 | |
|
204 | 199 | if (nb_sm.sbm_bp1_f0 == nb_sm_before_bp.burst_sbm_bp1_f0) |
|
205 | 200 | { |
|
206 | 201 | nb_sm.sbm_bp1_f0 = 0; |
|
207 | // the ring node is ready for BP calculations | |
|
208 | ring_node_for_processing_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0; | |
|
209 | 202 | // set another ring for the ASM storage |
|
210 | 203 | current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next; |
|
211 | 204 | if ( (lfrCurrentMode == LFR_MODE_BURST) |
|
212 | 205 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
213 | 206 | { |
|
214 |
event |
|
|
207 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0; | |
|
215 | 208 | } |
|
216 | 209 | } |
|
217 | 210 | |
|
218 | 211 | if (nb_sm.sbm_bp2_f0 == nb_sm_before_bp.burst_sbm_bp2_f0) |
|
219 | 212 | { |
|
220 | 213 | nb_sm.sbm_bp2_f0 = 0; |
|
221 | 214 | if ( (lfrCurrentMode == LFR_MODE_BURST) |
|
222 | 215 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
223 | 216 | { |
|
224 |
event |
|
|
217 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0; | |
|
225 | 218 | } |
|
226 | 219 | } |
|
227 | 220 | |
|
228 | 221 | if (nb_sm.norm_bp1_f0 == nb_sm_before_bp.norm_bp1_f0) |
|
229 | 222 | { |
|
230 | 223 | nb_sm.norm_bp1_f0 = 0; |
|
224 | // set another ring for the ASM storage | |
|
225 | current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next; | |
|
231 | 226 | if (lfrCurrentMode == LFR_MODE_NORMAL) |
|
232 | 227 | { |
|
233 |
event |
|
|
228 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0; | |
|
234 | 229 | } |
|
235 | 230 | } |
|
236 | 231 | |
|
237 | 232 | if (nb_sm.norm_bp2_f0 == nb_sm_before_bp.norm_bp2_f0) |
|
238 | 233 | { |
|
239 | 234 | nb_sm.norm_bp2_f0 = 0; |
|
240 | 235 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
241 | 236 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
242 | 237 | { |
|
243 |
event |
|
|
238 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0; | |
|
244 | 239 | } |
|
245 | 240 | } |
|
246 | 241 | |
|
247 | 242 | if (nb_sm.norm_asm_f0 == nb_sm_before_bp.norm_asm_f0) |
|
248 | 243 | { |
|
249 | 244 | nb_sm.norm_asm_f0 = 0; |
|
250 | 245 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
251 | 246 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
252 | 247 | { |
|
253 | 248 | // PRINTF1("%lld\n", localTime) |
|
254 |
event |
|
|
249 | msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0; | |
|
255 | 250 | } |
|
256 | 251 | } |
|
257 | 252 | |
|
258 |
//************************* |
|
|
259 |
// send the |
|
|
260 | status = rtems_event_send( Task_id[TASKID_MATR], event_for_matr ); | |
|
253 | //************************* | |
|
254 | // send the message to MATR | |
|
255 | if (msgForMATR.event != 0x00) | |
|
256 | { | |
|
257 | status = rtems_message_queue_send( queue_id_matr, (char *) & msgForMATR, MSG_QUEUE_SIZE_MATR); | |
|
258 | } | |
|
259 | ||
|
261 | 260 | if (status != RTEMS_SUCCESSFUL) { |
|
262 |
printf("in AVF0 *** Error sending |
|
|
261 | printf("in AVF0 *** Error sending message to MATR, code %d\n", status); | |
|
263 | 262 | } |
|
264 | 263 | } |
|
265 | 264 | } |
|
266 | 265 | |
|
267 | 266 | rtems_task matr_task( rtems_task_argument lfrRequestedMode ) |
|
268 | 267 | { |
|
268 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
|
269 | size_t size; // size of the incoming TC packet | |
|
270 | asm_msg *incomingMsg; | |
|
271 | // | |
|
269 | 272 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
270 | rtems_event_set event_out; | |
|
271 | 273 | rtems_status_code status; |
|
272 | 274 | rtems_id queue_id; |
|
275 | rtems_id queue_id_matr; | |
|
273 | 276 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
274 | 277 | bp_packet_with_spare current_node_norm_bp1_f0; |
|
275 | 278 | bp_packet current_node_norm_bp2_f0; |
|
276 | 279 | bp_packet current_node_sbm_bp1_f0; |
|
277 | 280 | bp_packet current_node_sbm_bp2_f0; |
|
281 | ||
|
278 | 282 | unsigned long long int localTime; |
|
279 | 283 | |
|
280 | 284 | ASM_init_header( &headerASM ); |
|
281 | 285 | |
|
282 | 286 | //************* |
|
283 | 287 | // NORM headers |
|
284 | 288 | BP_init_header_with_spare( ¤t_node_norm_bp1_f0.header, |
|
285 | 289 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0, |
|
286 | 290 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 ); |
|
287 | 291 | BP_init_header( ¤t_node_norm_bp2_f0.header, |
|
288 | 292 | APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0, |
|
289 | 293 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0); |
|
290 | 294 | |
|
291 | 295 | //**************************** |
|
292 | 296 | // BURST SBM1 and SBM2 headers |
|
293 | 297 | if ( (lfrRequestedMode == LFR_MODE_BURST) |
|
294 | 298 | || (lfrRequestedMode == LFR_MODE_NORMAL) || (lfrRequestedMode == LFR_MODE_STANDBY) ) |
|
295 | 299 | { |
|
296 | 300 | BP_init_header( ¤t_node_sbm_bp1_f0.header, |
|
297 | 301 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0, |
|
298 | 302 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
299 | 303 | BP_init_header( ¤t_node_sbm_bp2_f0.header, |
|
300 | 304 | APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0, |
|
301 | 305 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
302 | 306 | } |
|
303 | 307 | else if ( lfrRequestedMode == LFR_MODE_SBM1 ) |
|
304 | 308 | { |
|
305 | 309 | BP_init_header( ¤t_node_sbm_bp1_f0.header, |
|
306 | 310 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0, |
|
307 | 311 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
308 | 312 | BP_init_header( ¤t_node_sbm_bp2_f0.header, |
|
309 | 313 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0, |
|
310 | 314 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
311 | 315 | } |
|
312 | 316 | else if ( lfrRequestedMode == LFR_MODE_SBM2 ) |
|
313 | 317 | { |
|
314 | 318 | BP_init_header( ¤t_node_sbm_bp1_f0.header, |
|
315 | 319 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0, |
|
316 | 320 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
317 | 321 | BP_init_header( ¤t_node_sbm_bp2_f0.header, |
|
318 | 322 | APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0, |
|
319 | 323 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0); |
|
320 | 324 | } |
|
321 | 325 | else |
|
322 | 326 | { |
|
323 | 327 | PRINTF1("ERR *** in MATR *** unexpected lfrRequestedMode passed as argument = %d\n", (unsigned int) lfrRequestedMode) |
|
324 | 328 | } |
|
325 | 329 | |
|
326 | 330 | status = get_message_queue_id_send( &queue_id ); |
|
327 | 331 | if (status != RTEMS_SUCCESSFUL) |
|
328 | 332 | { |
|
329 | 333 | PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status) |
|
330 | 334 | } |
|
335 | status = get_message_queue_id_matr( &queue_id_matr); | |
|
336 | if (status != RTEMS_SUCCESSFUL) | |
|
337 | { | |
|
338 | PRINTF1("in MATR *** ERR get_message_queue_id_matr %d\n", status) | |
|
339 | } | |
|
331 | 340 | |
|
332 | 341 | BOOT_PRINTF1("in MATR *** lfrRequestedMode = %d\n", lfrRequestedMode) |
|
333 | 342 | |
|
334 | 343 | while(1){ |
|
335 | rtems_event_receive( RTEMS_EVENT_NORM_BP1_F0 | RTEMS_EVENT_NORM_BP2_F0 | RTEMS_EVENT_NORM_ASM_F0 | |
|
336 | | RTEMS_EVENT_BURST_SBM_BP1_F0 | RTEMS_EVENT_BURST_SBM_BP2_F0, | |
|
337 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
|
344 | status = rtems_message_queue_receive( queue_id_matr, incomingData, &size, //************************************ | |
|
345 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0 | |
|
346 | ||
|
347 | incomingMsg = (asm_msg*) incomingData; | |
|
348 | ||
|
338 | 349 | localTime = getTimeAsUnsignedLongLongInt( ); |
|
339 | 350 | //**************** |
|
340 | 351 | //**************** |
|
341 | 352 | // BURST SBM1 SBM2 |
|
342 | 353 | //**************** |
|
343 | 354 | //**************** |
|
344 |
if ( |
|
|
355 | if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 ) | |
|
345 | 356 | { |
|
346 | 357 | // 1) compress the matrix for Basic Parameters calculation |
|
347 |
ASM_compress_reorganize_and_divide( |
|
|
358 | ASM_compress_reorganize_and_divide( incomingMsg->burst_sbmf0->matrix, compressed_sm_sbm, | |
|
348 | 359 | nb_sm_before_bp.burst_sbm_bp1_f0, |
|
349 | 360 | NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0, |
|
350 | 361 | ASM_F0_INDICE_START); |
|
351 | 362 | // 2) compute the BP1 set |
|
352 | 363 | |
|
353 | 364 | // 3) send the BP1 set |
|
354 |
set_time( current_node_sbm_bp1_f0.header.time, (unsigned char *) & |
|
|
355 |
set_time( current_node_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) & |
|
|
365 | set_time( current_node_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); | |
|
366 | set_time( current_node_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); | |
|
356 | 367 | BP_send( (char *) ¤t_node_sbm_bp1_f0.header, queue_id, |
|
357 | 368 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA); |
|
358 | 369 | // 4) compute the BP2 set if needed |
|
359 |
if ( event |
|
|
370 | if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 ) | |
|
360 | 371 | { |
|
361 | 372 | // 1) compute the BP2 set |
|
362 | 373 | |
|
363 | 374 | // 2) send the BP2 set |
|
364 |
set_time( current_node_sbm_bp2_f0.header.time, (unsigned char *) & |
|
|
365 |
set_time( current_node_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) & |
|
|
375 | set_time( current_node_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); | |
|
376 | set_time( current_node_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); | |
|
366 | 377 | BP_send( (char *) ¤t_node_sbm_bp2_f0.header, queue_id, |
|
367 | 378 | PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA); |
|
368 | 379 | } |
|
369 | 380 | } |
|
370 | 381 | |
|
371 | 382 | //***** |
|
372 | 383 | //***** |
|
373 | 384 | // NORM |
|
374 | 385 | //***** |
|
375 | 386 | //***** |
|
376 |
if (event |
|
|
387 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0) | |
|
377 | 388 | { |
|
378 | 389 | // 1) compress the matrix for Basic Parameters calculation |
|
379 |
ASM_compress_reorganize_and_divide( |
|
|
390 | ASM_compress_reorganize_and_divide( incomingMsg->norm_f0->matrix, compressed_sm_norm_f0, | |
|
380 | 391 | nb_sm_before_bp.norm_bp1_f0, |
|
381 | 392 | NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0, |
|
382 | 393 | ASM_F0_INDICE_START ); |
|
383 | 394 | // 2) compute the BP1 set |
|
384 | 395 | |
|
385 | 396 | // 3) send the BP1 set |
|
386 |
set_time( current_node_norm_bp1_f0.header.time, (unsigned char *) & |
|
|
387 |
set_time( current_node_norm_bp1_f0.header.acquisitionTime, (unsigned char *) & |
|
|
397 | set_time( current_node_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); | |
|
398 | set_time( current_node_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); | |
|
388 | 399 | BP_send( (char *) ¤t_node_norm_bp1_f0.header, queue_id, |
|
389 | 400 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA); |
|
390 |
if (event |
|
|
401 | if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0) | |
|
391 | 402 | { |
|
392 | 403 | // 1) compute the BP2 set |
|
393 | 404 | |
|
394 | 405 | // 2) send the BP2 set |
|
395 |
set_time( current_node_norm_bp2_f0.header.time, (unsigned char *) & |
|
|
396 |
set_time( current_node_norm_bp2_f0.header.acquisitionTime, (unsigned char *) & |
|
|
406 | set_time( current_node_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime ); | |
|
407 | set_time( current_node_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime ); | |
|
397 | 408 | BP_send( (char *) ¤t_node_norm_bp2_f0.header, queue_id, |
|
398 | 409 | PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA); |
|
399 | 410 | } |
|
400 | 411 | } |
|
401 | 412 | |
|
402 |
if (event |
|
|
413 | if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0) | |
|
403 | 414 | { |
|
404 | 415 | // 1) reorganize the ASM and divide |
|
405 |
ASM_reorganize_and_divide( |
|
|
416 | ASM_reorganize_and_divide( incomingMsg->norm_f0->matrix, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 ); | |
|
406 | 417 | // 2) convert the float array in a char array |
|
407 | 418 | ASM_convert( asm_f0_reorganized, asm_f0_char); |
|
408 | 419 | // 3) send the spectral matrix packets |
|
420 | set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime ); | |
|
421 | set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime ); | |
|
409 | 422 | ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); |
|
410 | // localTime = getTimeAsUnsignedLongLongInt( ) - localTime; | |
|
411 | // PRINTF1("in MATR *** %lld\n", localTime) | |
|
412 | 423 | } |
|
413 | 424 | |
|
414 | 425 | } |
|
415 | 426 | } |
|
416 | 427 | |
|
417 | 428 | //****************** |
|
418 | 429 | // Spectral Matrices |
|
419 | 430 | |
|
420 | 431 | void SM_init_rings( void ) |
|
421 | 432 | { |
|
422 | 433 | unsigned char i; |
|
423 | 434 | |
|
424 | 435 | // F0 RING |
|
425 | 436 | sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1]; |
|
426 | 437 | sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1]; |
|
427 | 438 | sm_ring_f0[0].buffer_address = |
|
428 | 439 | (int) &sm_f0[ 0 ]; |
|
429 | 440 | |
|
430 | 441 | sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0]; |
|
431 | 442 | sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2]; |
|
432 | 443 | sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address = |
|
433 | 444 | (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ]; |
|
434 | 445 | |
|
435 | 446 | for(i=1; i<NB_RING_NODES_SM_F0-1; i++) |
|
436 | 447 | { |
|
437 | 448 | sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1]; |
|
438 | 449 | sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1]; |
|
439 | 450 | sm_ring_f0[i].buffer_address = |
|
440 | 451 | (int) &sm_f0[ i * TOTAL_SIZE_SM ]; |
|
441 | 452 | } |
|
442 | 453 | |
|
443 | 454 | // F1 RING |
|
444 | 455 | sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1]; |
|
445 | 456 | sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1]; |
|
446 | 457 | sm_ring_f1[0].buffer_address = |
|
447 | 458 | (int) &sm_f1[ 0 ]; |
|
448 | 459 | |
|
449 | 460 | sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0]; |
|
450 | 461 | sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2]; |
|
451 | 462 | sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address = |
|
452 | 463 | (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ]; |
|
453 | 464 | |
|
454 | 465 | for(i=1; i<NB_RING_NODES_SM_F1-1; i++) |
|
455 | 466 | { |
|
456 | 467 | sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1]; |
|
457 | 468 | sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1]; |
|
458 | 469 | sm_ring_f1[i].buffer_address = |
|
459 | 470 | (int) &sm_f1[ i * TOTAL_SIZE_SM ]; |
|
460 | 471 | } |
|
461 | 472 | |
|
462 | 473 | // F2 RING |
|
463 | 474 | sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1]; |
|
464 | 475 | sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1]; |
|
465 | 476 | sm_ring_f2[0].buffer_address = |
|
466 | 477 | (int) &sm_f2[ 0 ]; |
|
467 | 478 | |
|
468 | 479 | sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0]; |
|
469 | 480 | sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2]; |
|
470 | 481 | sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address = |
|
471 | 482 | (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ]; |
|
472 | 483 | |
|
473 | 484 | for(i=1; i<NB_RING_NODES_SM_F2-1; i++) |
|
474 | 485 | { |
|
475 | 486 | sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1]; |
|
476 | 487 | sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1]; |
|
477 | 488 | sm_ring_f2[i].buffer_address = |
|
478 | 489 | (int) &sm_f2[ i * TOTAL_SIZE_SM ]; |
|
479 | 490 | } |
|
480 | 491 | |
|
481 | 492 | DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) |
|
482 | 493 | DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) |
|
483 | 494 | DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) |
|
484 | 495 | |
|
485 | 496 | spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address; |
|
486 | 497 | DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0) |
|
487 | 498 | } |
|
488 | 499 | |
|
489 | void ASM_init_ring( void ) | |
|
500 | void ASM_init_rings( void ) | |
|
490 | 501 | { |
|
491 | 502 | unsigned char i; |
|
492 | 503 | |
|
504 | //************* | |
|
505 | // BURST_SBM_F0 | |
|
493 | 506 | asm_ring_burst_sbm_f0[0].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[1]; |
|
494 | 507 | asm_ring_burst_sbm_f0[0].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1]; |
|
495 | 508 | |
|
496 | 509 | asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].next |
|
497 | 510 | = (ring_node_asm*) &asm_ring_burst_sbm_f0[0]; |
|
498 | 511 | asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].previous |
|
499 | 512 | = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-2]; |
|
500 | 513 | |
|
501 | 514 | for(i=1; i<NB_RING_NODES_ASM_BURST_SBM_F0-1; i++) |
|
502 | 515 | { |
|
503 | 516 | asm_ring_burst_sbm_f0[i].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[i+1]; |
|
504 | 517 | asm_ring_burst_sbm_f0[i].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[i-1]; |
|
505 | 518 | } |
|
519 | ||
|
520 | //************* | |
|
521 | // NORM_F0 | |
|
522 | asm_ring_norm_f0[0].next = (ring_node_asm*) &asm_ring_norm_f0[1]; | |
|
523 | asm_ring_norm_f0[0].previous = (ring_node_asm*) &asm_ring_norm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1]; | |
|
524 | ||
|
525 | asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-1].next | |
|
526 | = (ring_node_asm*) &asm_ring_norm_f0[0]; | |
|
527 | asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-1].previous | |
|
528 | = (ring_node_asm*) &asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-2]; | |
|
529 | ||
|
530 | for(i=1; i<NB_RING_NODES_ASM_NORM_F0-1; i++) | |
|
531 | { | |
|
532 | asm_ring_norm_f0[i].next = (ring_node_asm*) &asm_ring_norm_f0[i+1]; | |
|
533 | asm_ring_norm_f0[i].previous = (ring_node_asm*) &asm_ring_norm_f0[i-1]; | |
|
534 | } | |
|
506 | 535 | } |
|
507 | 536 | |
|
508 | 537 | void SM_reset_current_ring_nodes( void ) |
|
509 | 538 | { |
|
510 | 539 | current_ring_node_sm_f0 = sm_ring_f0; |
|
511 | 540 | current_ring_node_sm_f1 = sm_ring_f1; |
|
512 | 541 | current_ring_node_sm_f2 = sm_ring_f2; |
|
513 | 542 | |
|
514 | 543 | ring_node_for_averaging_sm_f0 = sm_ring_f0; |
|
515 | 544 | } |
|
516 | 545 | |
|
517 | 546 | void ASM_reset_current_ring_node( void ) |
|
518 | 547 | { |
|
548 | current_ring_node_asm_norm_f0 = asm_ring_norm_f0; | |
|
519 | 549 |
current_ring_node_asm_burst_sbm_f0 |
|
520 | ring_node_for_processing_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0; | |
|
521 | 550 | } |
|
522 | 551 | |
|
523 | 552 | void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header) |
|
524 | 553 | { |
|
525 | 554 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
526 | 555 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
527 | 556 | header->reserved = 0x00; |
|
528 | 557 | header->userApplication = CCSDS_USER_APP; |
|
529 | 558 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
530 | 559 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
531 | 560 | header->packetSequenceControl[0] = 0xc0; |
|
532 | 561 | header->packetSequenceControl[1] = 0x00; |
|
533 | 562 | header->packetLength[0] = 0x00; |
|
534 | 563 | header->packetLength[1] = 0x00; |
|
535 | 564 | // DATA FIELD HEADER |
|
536 | 565 | header->spare1_pusVersion_spare2 = 0x10; |
|
537 | 566 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
538 | 567 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
539 | 568 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
540 | 569 | // AUXILIARY DATA HEADER |
|
541 | 570 | header->sid = 0x00; |
|
542 | 571 | header->biaStatusInfo = 0x00; |
|
543 | 572 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
544 | 573 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
545 | 574 | header->time[0] = 0x00; |
|
546 | 575 | header->time[0] = 0x00; |
|
547 | 576 | header->time[0] = 0x00; |
|
548 | 577 | header->time[0] = 0x00; |
|
549 | 578 | header->time[0] = 0x00; |
|
550 | 579 | header->time[0] = 0x00; |
|
551 | 580 | header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB |
|
552 | 581 | header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB |
|
553 | 582 | } |
|
554 | 583 | |
|
555 | 584 | void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1, |
|
556 | 585 | ring_node_sm *ring_node_tab[], |
|
557 | 586 | unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 ) |
|
558 | 587 | { |
|
559 | 588 | float sum; |
|
560 | 589 | unsigned int i; |
|
561 | unsigned char *ptr; | |
|
562 | 590 | |
|
563 | 591 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
564 | 592 | { |
|
565 | 593 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] |
|
566 | 594 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] |
|
567 | 595 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] |
|
568 | 596 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] |
|
569 | 597 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] |
|
570 | 598 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] |
|
571 | 599 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] |
|
572 | 600 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; |
|
573 | 601 | |
|
574 | 602 | if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) ) |
|
575 | 603 | { |
|
576 |
averaged_spec_mat_f0[ |
|
|
577 |
averaged_spec_mat_f1[ |
|
|
604 | averaged_spec_mat_f0[ i ] = sum; | |
|
605 | averaged_spec_mat_f1[ i ] = sum; | |
|
578 | 606 | } |
|
579 | 607 | else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) ) |
|
580 | 608 | { |
|
581 |
averaged_spec_mat_f0[ |
|
|
582 |
averaged_spec_mat_f1[ |
|
|
609 | averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); | |
|
610 | averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum ); | |
|
583 | 611 | } |
|
584 | 612 | else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) ) |
|
585 | 613 | { |
|
586 |
averaged_spec_mat_f0[ |
|
|
587 |
averaged_spec_mat_f1[ |
|
|
614 | averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum ); | |
|
615 | averaged_spec_mat_f1[ i ] = sum; | |
|
588 | 616 | } |
|
589 | 617 | else |
|
590 | 618 | { |
|
591 | 619 | PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0) |
|
592 | 620 | } |
|
593 | 621 | } |
|
594 | if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) ) | |
|
595 | { | |
|
596 | ptr = (unsigned char *) averaged_spec_mat_f0; | |
|
597 | ptr[0] = (unsigned char) (time_management_regs->coarse_time >> 24); | |
|
598 | ptr[1] = (unsigned char) (time_management_regs->coarse_time >> 16); | |
|
599 | ptr[2] = (unsigned char) (time_management_regs->coarse_time >> 8 ); | |
|
600 | ptr[3] = (unsigned char) (time_management_regs->coarse_time ); | |
|
601 | ptr[4] = (unsigned char) (time_management_regs->fine_time >> 24); | |
|
602 | ptr[5] = (unsigned char) (time_management_regs->fine_time >> 16); | |
|
603 | ptr[6] = (unsigned char) (time_management_regs->fine_time >> 8 ); | |
|
604 | ptr[7] = (unsigned char) (time_management_regs->fine_time ); | |
|
605 | ptr = (unsigned char *) averaged_spec_mat_f1; | |
|
606 | ptr[0] = (unsigned char) (time_management_regs->coarse_time >> 24); | |
|
607 | ptr[1] = (unsigned char) (time_management_regs->coarse_time >> 16); | |
|
608 | ptr[2] = (unsigned char) (time_management_regs->coarse_time >> 8 ); | |
|
609 | ptr[3] = (unsigned char) (time_management_regs->coarse_time ); | |
|
610 | ptr[4] = (unsigned char) (time_management_regs->fine_time >> 24); | |
|
611 | ptr[5] = (unsigned char) (time_management_regs->fine_time >> 16); | |
|
612 | ptr[6] = (unsigned char) (time_management_regs->fine_time >> 8 ); | |
|
613 | ptr[7] = (unsigned char) (time_management_regs->fine_time ); | |
|
614 | } | |
|
615 | 622 | } |
|
616 | 623 | |
|
617 | 624 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
618 | 625 | { |
|
619 | 626 | int frequencyBin; |
|
620 | 627 | int asmComponent; |
|
621 | ||
|
622 | // copy the time information | |
|
623 | averaged_spec_mat_reorganized[ 0 ] = averaged_spec_mat[ 0 ]; | |
|
624 | averaged_spec_mat_reorganized[ 1 ] = averaged_spec_mat[ 1 ]; | |
|
628 | unsigned int offsetAveragedSpecMatReorganized; | |
|
629 | unsigned int offsetAveragedSpecMat; | |
|
625 | 630 | |
|
626 | 631 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
627 | 632 | { |
|
628 | 633 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
629 | 634 | { |
|
630 | averaged_spec_mat_reorganized[ TIME_OFFSET + frequencyBin * NB_VALUES_PER_SM + asmComponent ] = | |
|
631 | averaged_spec_mat[ TIME_OFFSET + asmComponent * NB_BINS_PER_SM + frequencyBin ] / divider; | |
|
635 | offsetAveragedSpecMatReorganized = | |
|
636 | frequencyBin * NB_VALUES_PER_SM | |
|
637 | + asmComponent; | |
|
638 | offsetAveragedSpecMat = | |
|
639 | asmComponent * NB_BINS_PER_SM | |
|
640 | + frequencyBin; | |
|
641 | averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] = | |
|
642 | averaged_spec_mat[ offsetAveragedSpecMat ] / divider; | |
|
632 | 643 | } |
|
633 | 644 | } |
|
634 | 645 | } |
|
635 | 646 | |
|
636 | 647 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
637 | 648 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
638 | 649 | { |
|
639 | 650 | int frequencyBin; |
|
640 | 651 | int asmComponent; |
|
641 | 652 | int offsetASM; |
|
642 | 653 | int offsetCompressed; |
|
643 | 654 | int k; |
|
644 | 655 | |
|
645 | // copy the time information | |
|
646 | compressed_spec_mat[ 0 ] = averaged_spec_mat[ 0 ]; | |
|
647 | compressed_spec_mat[ 1 ] = averaged_spec_mat[ 1 ]; | |
|
648 | ||
|
649 | 656 | // build data |
|
650 | 657 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
651 | 658 | { |
|
652 | 659 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
653 | 660 | { |
|
654 |
offsetCompressed = |
|
|
655 |
|
|
|
661 | offsetCompressed = // NO TIME OFFSET | |
|
662 | frequencyBin * NB_VALUES_PER_SM | |
|
656 | 663 | + asmComponent; |
|
657 |
offsetASM = |
|
|
658 |
|
|
|
664 | offsetASM = // NO TIME OFFSET | |
|
665 | asmComponent * NB_BINS_PER_SM | |
|
659 | 666 | + ASMIndexStart |
|
660 | 667 | + frequencyBin * nbBinsToAverage; |
|
661 | 668 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
662 | 669 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
663 | 670 | { |
|
664 | 671 | compressed_spec_mat[offsetCompressed ] = |
|
665 | 672 | ( compressed_spec_mat[ offsetCompressed ] |
|
666 | 673 | + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage); |
|
667 | 674 | } |
|
668 | 675 | } |
|
669 | 676 | } |
|
670 | 677 | } |
|
671 | 678 | |
|
672 | 679 | void ASM_convert( volatile float *input_matrix, char *output_matrix) |
|
673 | 680 | { |
|
674 | unsigned int i; | |
|
675 | 681 | unsigned int frequencyBin; |
|
676 | 682 | unsigned int asmComponent; |
|
677 | 683 | char * pt_char_input; |
|
678 | 684 | char * pt_char_output; |
|
685 | unsigned int offsetInput; | |
|
686 | unsigned int offsetOutput; | |
|
679 | 687 | |
|
680 | 688 | pt_char_input = (char*) &input_matrix; |
|
681 | 689 | pt_char_output = (char*) &output_matrix; |
|
682 | 690 | |
|
683 | // copy the time information | |
|
684 | for (i=0; i<TIME_OFFSET_IN_BYTES; i++) | |
|
685 | { | |
|
686 | pt_char_output[ i ] = pt_char_output[ i ]; | |
|
687 | } | |
|
688 | ||
|
689 | 691 | // convert all other data |
|
690 | 692 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) |
|
691 | 693 | { |
|
692 | 694 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) |
|
693 | 695 | { |
|
694 |
|
|
|
695 |
|
|
|
696 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; | |
|
697 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; | |
|
698 | pt_char_input = (char*) &input_matrix [ offsetInput ]; | |
|
699 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; | |
|
696 | 700 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
697 | 701 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
698 | 702 | } |
|
699 | 703 | } |
|
700 | 704 | } |
|
701 | 705 | |
|
702 | 706 | void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
703 | 707 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id) |
|
704 | 708 | { |
|
705 | 709 | unsigned int i; |
|
706 | 710 | unsigned int length = 0; |
|
707 | 711 | rtems_status_code status; |
|
708 | 712 | |
|
709 | 713 | for (i=0; i<2; i++) |
|
710 | 714 | { |
|
711 | 715 | // (1) BUILD THE DATA |
|
712 | 716 | switch(sid) |
|
713 | 717 | { |
|
714 | 718 | case SID_NORM_ASM_F0: |
|
715 | 719 | spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; |
|
716 | 720 | spw_ioctl_send->data = &spectral_matrix[ |
|
717 | 721 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2 |
|
718 | + TIME_OFFSET_IN_BYTES | |
|
719 | 722 | ]; |
|
720 | 723 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0; |
|
721 | 724 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB |
|
722 | 725 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB |
|
723 | 726 | break; |
|
724 | 727 | case SID_NORM_ASM_F1: |
|
725 | 728 | break; |
|
726 | 729 | case SID_NORM_ASM_F2: |
|
727 | 730 | break; |
|
728 | 731 | default: |
|
729 | 732 | PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid) |
|
730 | 733 | break; |
|
731 | 734 | } |
|
732 | 735 | spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
733 | 736 | spw_ioctl_send->hdr = (char *) header; |
|
734 | 737 | spw_ioctl_send->options = 0; |
|
735 | 738 | |
|
736 | 739 | // (2) BUILD THE HEADER |
|
737 | 740 | header->packetLength[0] = (unsigned char) (length>>8); |
|
738 | 741 | header->packetLength[1] = (unsigned char) (length); |
|
739 | 742 | header->sid = (unsigned char) sid; // SID |
|
740 | 743 | header->pa_lfr_pkt_cnt_asm = 2; |
|
741 | 744 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
742 | 745 | |
|
743 | 746 | // (3) SET PACKET TIME |
|
744 | 747 | header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
745 | 748 | header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
746 | 749 | header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
747 | 750 | header->time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
748 | 751 | header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
749 | 752 | header->time[5] = (unsigned char) (time_management_regs->fine_time); |
|
750 | 753 | // |
|
751 | 754 | header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
752 | 755 | header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
753 | 756 | header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
754 | 757 | header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); |
|
755 | 758 | header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
756 | 759 | header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); |
|
757 | 760 | |
|
758 | 761 | // (4) SEND PACKET |
|
759 | 762 | status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
760 | 763 | if (status != RTEMS_SUCCESSFUL) { |
|
761 | 764 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
762 | 765 | } |
|
763 | 766 | } |
|
764 | 767 | } |
|
765 | 768 | |
|
766 | 769 | //***************** |
|
767 | 770 | // Basic Parameters |
|
768 | 771 | |
|
769 | 772 | void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header, |
|
770 | 773 | unsigned int apid, unsigned char sid, |
|
771 | 774 | unsigned int packetLength, unsigned char blkNr ) |
|
772 | 775 | { |
|
773 | 776 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
774 | 777 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
775 | 778 | header->reserved = 0x00; |
|
776 | 779 | header->userApplication = CCSDS_USER_APP; |
|
777 | 780 | header->packetID[0] = (unsigned char) (apid >> 8); |
|
778 | 781 | header->packetID[1] = (unsigned char) (apid); |
|
779 | 782 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
780 | 783 | header->packetSequenceControl[1] = 0x00; |
|
781 | 784 | header->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
782 | 785 | header->packetLength[1] = (unsigned char) (packetLength); |
|
783 | 786 | // DATA FIELD HEADER |
|
784 | 787 | header->spare1_pusVersion_spare2 = 0x10; |
|
785 | 788 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
786 | 789 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
787 | 790 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
788 | 791 | // AUXILIARY DATA HEADER |
|
789 | 792 | header->sid = sid; |
|
790 | 793 | header->biaStatusInfo = 0x00; |
|
791 | 794 | header->time[0] = 0x00; |
|
792 | 795 | header->time[0] = 0x00; |
|
793 | 796 | header->time[0] = 0x00; |
|
794 | 797 | header->time[0] = 0x00; |
|
795 | 798 | header->time[0] = 0x00; |
|
796 | 799 | header->time[0] = 0x00; |
|
797 | 800 | header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
798 | 801 | header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
799 | 802 | } |
|
800 | 803 | |
|
801 | 804 | void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header, |
|
802 | 805 | unsigned int apid, unsigned char sid, |
|
803 | 806 | unsigned int packetLength , unsigned char blkNr) |
|
804 | 807 | { |
|
805 | 808 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
806 | 809 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
807 | 810 | header->reserved = 0x00; |
|
808 | 811 | header->userApplication = CCSDS_USER_APP; |
|
809 | 812 | header->packetID[0] = (unsigned char) (apid >> 8); |
|
810 | 813 | header->packetID[1] = (unsigned char) (apid); |
|
811 | 814 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
812 | 815 | header->packetSequenceControl[1] = 0x00; |
|
813 | 816 | header->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
814 | 817 | header->packetLength[1] = (unsigned char) (packetLength); |
|
815 | 818 | // DATA FIELD HEADER |
|
816 | 819 | header->spare1_pusVersion_spare2 = 0x10; |
|
817 | 820 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
818 | 821 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
819 | 822 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
820 | 823 | // AUXILIARY DATA HEADER |
|
821 | 824 | header->sid = sid; |
|
822 | 825 | header->biaStatusInfo = 0x00; |
|
823 | 826 | header->time[0] = 0x00; |
|
824 | 827 | header->time[0] = 0x00; |
|
825 | 828 | header->time[0] = 0x00; |
|
826 | 829 | header->time[0] = 0x00; |
|
827 | 830 | header->time[0] = 0x00; |
|
828 | 831 | header->time[0] = 0x00; |
|
829 | 832 | header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
830 | 833 | header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
831 | 834 | } |
|
832 | 835 | |
|
833 | 836 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend ) |
|
834 | 837 | { |
|
835 | 838 | rtems_status_code status; |
|
836 | 839 | |
|
837 | 840 | // SEND PACKET |
|
838 | 841 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
839 | 842 | if (status != RTEMS_SUCCESSFUL) |
|
840 | 843 | { |
|
841 | 844 | printf("ERR *** in BP_send *** ERR %d\n", (int) status); |
|
842 | 845 | } |
|
843 | 846 | } |
|
844 | 847 | |
|
845 | 848 | //****************** |
|
846 | 849 | // general functions |
|
847 | 850 | |
|
848 | 851 | void reset_spectral_matrix_regs( void ) |
|
849 | 852 | { |
|
850 | 853 | /** This function resets the spectral matrices module registers. |
|
851 | 854 | * |
|
852 | 855 | * The registers affected by this function are located at the following offset addresses: |
|
853 | 856 | * |
|
854 | 857 | * - 0x00 config |
|
855 | 858 | * - 0x04 status |
|
856 | 859 | * - 0x08 matrixF0_Address0 |
|
857 | 860 | * - 0x10 matrixFO_Address1 |
|
858 | 861 | * - 0x14 matrixF1_Address |
|
859 | 862 | * - 0x18 matrixF2_Address |
|
860 | 863 | * |
|
861 | 864 | */ |
|
862 | 865 | |
|
863 | 866 | spectral_matrix_regs->config = 0x00; |
|
864 | 867 | spectral_matrix_regs->status = 0x00; |
|
865 | 868 | |
|
866 | 869 | spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; |
|
867 | 870 | spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address; |
|
868 | 871 | spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address; |
|
869 | 872 | spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address; |
|
870 | 873 | } |
|
871 | 874 | |
|
872 | 875 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) |
|
873 | 876 | { |
|
874 | 877 | // time[0] = timeInBuffer[2]; |
|
875 | 878 | // time[1] = timeInBuffer[3]; |
|
876 | 879 | // time[2] = timeInBuffer[0]; |
|
877 | 880 | // time[3] = timeInBuffer[1]; |
|
878 | 881 | // time[4] = timeInBuffer[6]; |
|
879 | 882 | // time[5] = timeInBuffer[7]; |
|
880 | 883 | |
|
881 | 884 | time[0] = timeInBuffer[0]; |
|
882 | 885 | time[1] = timeInBuffer[1]; |
|
883 | 886 | time[2] = timeInBuffer[2]; |
|
884 | 887 | time[3] = timeInBuffer[3]; |
|
885 | 888 | time[4] = timeInBuffer[6]; |
|
886 | 889 | time[5] = timeInBuffer[7]; |
|
887 | 890 | } |
|
888 | 891 | |
|
889 | 892 |
@@ -1,610 +1,610 | |||
|
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_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 |
char incomingData[ |
|
|
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_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 ) |
|
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( fdSPW, 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_start_link( int fd ) |
|
347 | 347 | { |
|
348 | 348 | rtems_status_code status; |
|
349 | 349 | |
|
350 | 350 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
351 | 351 | status = ioctl( fdSPW, 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 | 377 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
378 | 378 | // |
|
379 | 379 | 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 | 380 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
381 | 381 | // |
|
382 | 382 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
383 | 383 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
384 | 384 | // |
|
385 | 385 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
386 | 386 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
387 | 387 | // |
|
388 | 388 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks |
|
389 | 389 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
390 | 390 | // |
|
391 | 391 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
392 | 392 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
393 | 393 | // |
|
394 | 394 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
395 | 395 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
396 | 396 | |
|
397 | 397 | return status; |
|
398 | 398 | } |
|
399 | 399 | |
|
400 | 400 | int spacewire_reset_link( void ) |
|
401 | 401 | { |
|
402 | 402 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
403 | 403 | * |
|
404 | 404 | * @return RTEMS directive status code: |
|
405 | 405 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
406 | 406 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
407 | 407 | * |
|
408 | 408 | */ |
|
409 | 409 | |
|
410 | 410 | rtems_status_code status_spw; |
|
411 | 411 | int i; |
|
412 | 412 | |
|
413 | 413 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
414 | 414 | { |
|
415 | 415 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
416 | 416 | |
|
417 | 417 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
418 | 418 | |
|
419 | 419 | status_spw = spacewire_stop_start_link( fdSPW ); |
|
420 | 420 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
421 | 421 | { |
|
422 | 422 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
423 | 423 | } |
|
424 | 424 | |
|
425 | 425 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
426 | 426 | { |
|
427 | 427 | break; |
|
428 | 428 | } |
|
429 | 429 | } |
|
430 | 430 | |
|
431 | 431 | return status_spw; |
|
432 | 432 | } |
|
433 | 433 | |
|
434 | 434 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
435 | 435 | { |
|
436 | 436 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
437 | 437 | * |
|
438 | 438 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
439 | 439 | * @param regAddr is the address of the GRSPW control register. |
|
440 | 440 | * |
|
441 | 441 | * NP is the bit 20 of the GRSPW control register. |
|
442 | 442 | * |
|
443 | 443 | */ |
|
444 | 444 | |
|
445 | 445 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
446 | 446 | |
|
447 | 447 | if (val == 1) { |
|
448 | 448 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
449 | 449 | } |
|
450 | 450 | if (val== 0) { |
|
451 | 451 | *spwptr = *spwptr & 0xffdfffff; |
|
452 | 452 | } |
|
453 | 453 | } |
|
454 | 454 | |
|
455 | 455 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
456 | 456 | { |
|
457 | 457 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
458 | 458 | * |
|
459 | 459 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
460 | 460 | * @param regAddr is the address of the GRSPW control register. |
|
461 | 461 | * |
|
462 | 462 | * RE is the bit 16 of the GRSPW control register. |
|
463 | 463 | * |
|
464 | 464 | */ |
|
465 | 465 | |
|
466 | 466 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
467 | 467 | |
|
468 | 468 | if (val == 1) |
|
469 | 469 | { |
|
470 | 470 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
471 | 471 | } |
|
472 | 472 | if (val== 0) |
|
473 | 473 | { |
|
474 | 474 | *spwptr = *spwptr & 0xfffdffff; |
|
475 | 475 | } |
|
476 | 476 | } |
|
477 | 477 | |
|
478 | 478 | void spacewire_compute_stats_offsets( void ) |
|
479 | 479 | { |
|
480 | 480 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
481 | 481 | * |
|
482 | 482 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
483 | 483 | * 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 | 484 | * during the open systel call). |
|
485 | 485 | * |
|
486 | 486 | */ |
|
487 | 487 | |
|
488 | 488 | spw_stats spacewire_stats_grspw; |
|
489 | 489 | rtems_status_code status; |
|
490 | 490 | |
|
491 | 491 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
492 | 492 | |
|
493 | 493 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
494 | 494 | + spacewire_stats.packets_received; |
|
495 | 495 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
496 | 496 | + spacewire_stats.packets_sent; |
|
497 | 497 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
498 | 498 | + spacewire_stats.parity_err; |
|
499 | 499 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
500 | 500 | + spacewire_stats.disconnect_err; |
|
501 | 501 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
502 | 502 | + spacewire_stats.escape_err; |
|
503 | 503 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
504 | 504 | + spacewire_stats.credit_err; |
|
505 | 505 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
506 | 506 | + spacewire_stats.write_sync_err; |
|
507 | 507 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
508 | 508 | + spacewire_stats.rx_rmap_header_crc_err; |
|
509 | 509 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
510 | 510 | + spacewire_stats.rx_rmap_data_crc_err; |
|
511 | 511 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
512 | 512 | + spacewire_stats.early_ep; |
|
513 | 513 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
514 | 514 | + spacewire_stats.invalid_address; |
|
515 | 515 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
516 | 516 | + spacewire_stats.rx_eep_err; |
|
517 | 517 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
518 | 518 | + spacewire_stats.rx_truncated; |
|
519 | 519 | } |
|
520 | 520 | |
|
521 | 521 | void spacewire_update_statistics( void ) |
|
522 | 522 | { |
|
523 | 523 | rtems_status_code status; |
|
524 | 524 | spw_stats spacewire_stats_grspw; |
|
525 | 525 | |
|
526 | 526 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
527 | 527 | |
|
528 | 528 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
529 | 529 | + spacewire_stats_grspw.packets_received; |
|
530 | 530 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
531 | 531 | + spacewire_stats_grspw.packets_sent; |
|
532 | 532 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
533 | 533 | + spacewire_stats_grspw.parity_err; |
|
534 | 534 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
535 | 535 | + spacewire_stats_grspw.disconnect_err; |
|
536 | 536 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
537 | 537 | + spacewire_stats_grspw.escape_err; |
|
538 | 538 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
539 | 539 | + spacewire_stats_grspw.credit_err; |
|
540 | 540 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
541 | 541 | + spacewire_stats_grspw.write_sync_err; |
|
542 | 542 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
543 | 543 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
544 | 544 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
545 | 545 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
546 | 546 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
547 | 547 | + spacewire_stats_grspw.early_ep; |
|
548 | 548 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
549 | 549 | + spacewire_stats_grspw.invalid_address; |
|
550 | 550 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
551 | 551 | + spacewire_stats_grspw.rx_eep_err; |
|
552 | 552 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
553 | 553 | + spacewire_stats_grspw.rx_truncated; |
|
554 | 554 | //spacewire_stats.tx_link_err; |
|
555 | 555 | |
|
556 | 556 | //**************************** |
|
557 | 557 | // DPU_SPACEWIRE_IF_STATISTICS |
|
558 | 558 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
559 | 559 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
560 | 560 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
561 | 561 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
562 | 562 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
563 | 563 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
564 | 564 | |
|
565 | 565 | //****************************************** |
|
566 | 566 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
567 | 567 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
568 | 568 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
569 | 569 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
570 | 570 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
571 | 571 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
572 | 572 | |
|
573 | 573 | //********************************************* |
|
574 | 574 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
575 | 575 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
576 | 576 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
577 | 577 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
578 | 578 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
579 | 579 | } |
|
580 | 580 | |
|
581 | 581 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
582 | 582 | { |
|
583 | 583 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 ); |
|
584 | 584 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
585 | 585 | |
|
586 | 586 | grgpio_regs->io_port_direction_register = |
|
587 | 587 | grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled |
|
588 | 588 | |
|
589 | 589 | if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 ) |
|
590 | 590 | { |
|
591 | 591 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7; |
|
592 | 592 | } |
|
593 | 593 | else |
|
594 | 594 | { |
|
595 | 595 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08; |
|
596 | 596 | } |
|
597 | 597 | } |
|
598 | 598 | |
|
599 | 599 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
600 | 600 | { |
|
601 | 601 | int linkStatus; |
|
602 | 602 | rtems_status_code status; |
|
603 | 603 | |
|
604 | 604 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
605 | 605 | |
|
606 | 606 | if ( linkStatus == 5) { |
|
607 | 607 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
608 | 608 | status = RTEMS_SUCCESSFUL; |
|
609 | 609 | } |
|
610 | 610 | } |
@@ -1,886 +1,888 | |||
|
1 | 1 | /** Functions and tasks related to TeleCommand handling. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TeleCommands:\n |
|
7 | 7 | * action launching\n |
|
8 | 8 | * TC parsing\n |
|
9 | 9 | * ... |
|
10 | 10 | * |
|
11 | 11 | */ |
|
12 | 12 | |
|
13 | 13 | #include "tc_handler.h" |
|
14 | 14 | |
|
15 | 15 | //*********** |
|
16 | 16 | // RTEMS TASK |
|
17 | 17 | |
|
18 | 18 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | 19 | { |
|
20 | 20 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | 21 | * |
|
22 | 22 | * @param unused is the starting argument of the RTEMS task |
|
23 | 23 | * |
|
24 | 24 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | 25 | * on the incoming TeleCommand. |
|
26 | 26 | * |
|
27 | 27 | */ |
|
28 | 28 | |
|
29 | 29 | int result; |
|
30 | 30 | rtems_status_code status; // RTEMS status code |
|
31 | 31 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | 32 | size_t size; // size of the incoming TC packet |
|
33 | 33 | unsigned char subtype; // subtype of the current TC packet |
|
34 | 34 | unsigned char time[6]; |
|
35 | 35 | rtems_id queue_rcv_id; |
|
36 | 36 | rtems_id queue_snd_id; |
|
37 | 37 | |
|
38 | 38 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | 39 | if (status != RTEMS_SUCCESSFUL) |
|
40 | 40 | { |
|
41 | 41 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | 45 | if (status != RTEMS_SUCCESSFUL) |
|
46 | 46 | { |
|
47 | 47 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | result = LFR_SUCCESSFUL; |
|
51 | 51 | subtype = 0; // subtype of the current TC packet |
|
52 | 52 | |
|
53 | 53 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | 54 | |
|
55 | 55 | while(1) |
|
56 | 56 | { |
|
57 | 57 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | 58 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | 59 | getTime( time ); // set time to the current time |
|
60 | 60 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | 61 | { |
|
62 | 62 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | 63 | } |
|
64 | 64 | else |
|
65 | 65 | { |
|
66 | 66 | subtype = TC.serviceSubType; |
|
67 | 67 | switch(subtype) |
|
68 | 68 | { |
|
69 | 69 | case TC_SUBTYPE_RESET: |
|
70 | 70 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | 71 | close_action( &TC, result, queue_snd_id ); |
|
72 | 72 | break; |
|
73 | 73 | // |
|
74 | 74 | case TC_SUBTYPE_LOAD_COMM: |
|
75 | 75 | result = action_load_common_par( &TC ); |
|
76 | 76 | close_action( &TC, result, queue_snd_id ); |
|
77 | 77 | break; |
|
78 | 78 | // |
|
79 | 79 | case TC_SUBTYPE_LOAD_NORM: |
|
80 | 80 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
81 | 81 | close_action( &TC, result, queue_snd_id ); |
|
82 | 82 | break; |
|
83 | 83 | // |
|
84 | 84 | case TC_SUBTYPE_LOAD_BURST: |
|
85 | 85 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
86 | 86 | close_action( &TC, result, queue_snd_id ); |
|
87 | 87 | break; |
|
88 | 88 | // |
|
89 | 89 | case TC_SUBTYPE_LOAD_SBM1: |
|
90 | 90 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
91 | 91 | close_action( &TC, result, queue_snd_id ); |
|
92 | 92 | break; |
|
93 | 93 | // |
|
94 | 94 | case TC_SUBTYPE_LOAD_SBM2: |
|
95 | 95 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
96 | 96 | close_action( &TC, result, queue_snd_id ); |
|
97 | 97 | break; |
|
98 | 98 | // |
|
99 | 99 | case TC_SUBTYPE_DUMP: |
|
100 | 100 | result = action_dump_par( queue_snd_id ); |
|
101 | 101 | close_action( &TC, result, queue_snd_id ); |
|
102 | 102 | break; |
|
103 | 103 | // |
|
104 | 104 | case TC_SUBTYPE_ENTER: |
|
105 | 105 | result = action_enter_mode( &TC, queue_snd_id ); |
|
106 | 106 | close_action( &TC, result, queue_snd_id ); |
|
107 | 107 | break; |
|
108 | 108 | // |
|
109 | 109 | case TC_SUBTYPE_UPDT_INFO: |
|
110 | 110 | result = action_update_info( &TC, queue_snd_id ); |
|
111 | 111 | close_action( &TC, result, queue_snd_id ); |
|
112 | 112 | break; |
|
113 | 113 | // |
|
114 | 114 | case TC_SUBTYPE_EN_CAL: |
|
115 | 115 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
116 | 116 | close_action( &TC, result, queue_snd_id ); |
|
117 | 117 | break; |
|
118 | 118 | // |
|
119 | 119 | case TC_SUBTYPE_DIS_CAL: |
|
120 | 120 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
121 | 121 | close_action( &TC, result, queue_snd_id ); |
|
122 | 122 | break; |
|
123 | 123 | // |
|
124 | 124 | case TC_SUBTYPE_UPDT_TIME: |
|
125 | 125 | result = action_update_time( &TC ); |
|
126 | 126 | close_action( &TC, result, queue_snd_id ); |
|
127 | 127 | break; |
|
128 | 128 | // |
|
129 | 129 | default: |
|
130 | 130 | break; |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | } |
|
135 | 135 | |
|
136 | 136 | //*********** |
|
137 | 137 | // TC ACTIONS |
|
138 | 138 | |
|
139 | 139 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | 140 | { |
|
141 | 141 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | 142 | * |
|
143 | 143 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | 144 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | 145 | * |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
149 | 149 | return LFR_DEFAULT; |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
153 | 153 | { |
|
154 | 154 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
155 | 155 | * |
|
156 | 156 | * @param TC points to the TeleCommand packet that is being processed |
|
157 | 157 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
158 | 158 | * |
|
159 | 159 | */ |
|
160 | 160 | |
|
161 | 161 | rtems_status_code status; |
|
162 | 162 | unsigned char requestedMode; |
|
163 | 163 | unsigned int *transitionCoarseTime_ptr; |
|
164 | 164 | unsigned int transitionCoarseTime; |
|
165 | 165 | unsigned char * bytePosPtr; |
|
166 | 166 | |
|
167 | 167 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
168 | 168 | |
|
169 | 169 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
170 | 170 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
171 | 171 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
172 | 172 | |
|
173 | 173 | status = check_mode_value( requestedMode ); |
|
174 | 174 | |
|
175 | 175 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
176 | 176 | { |
|
177 | 177 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
178 | 178 | } |
|
179 | 179 | else // the mode value is consistent, check the transition |
|
180 | 180 | { |
|
181 | 181 | status = check_mode_transition(requestedMode); |
|
182 | 182 | if (status != LFR_SUCCESSFUL) |
|
183 | 183 | { |
|
184 | 184 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
185 | 185 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | |
|
189 | 189 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode |
|
190 | 190 | { |
|
191 | 191 | status = check_transition_date( transitionCoarseTime ); |
|
192 | 192 | if (status != LFR_SUCCESSFUL) |
|
193 | 193 | { |
|
194 | 194 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
195 | 195 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
196 | 196 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
197 | 197 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
198 | 198 | } |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
202 | 202 | { |
|
203 | 203 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
204 | 204 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | return status; |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
211 | 211 | { |
|
212 | 212 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
213 | 213 | * |
|
214 | 214 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | 215 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
216 | 216 | * |
|
217 | 217 | * @return LFR directive status code: |
|
218 | 218 | * - LFR_DEFAULT |
|
219 | 219 | * - LFR_SUCCESSFUL |
|
220 | 220 | * |
|
221 | 221 | */ |
|
222 | 222 | |
|
223 | 223 | unsigned int val; |
|
224 | 224 | int result; |
|
225 | 225 | unsigned int status; |
|
226 | 226 | unsigned char mode; |
|
227 | 227 | unsigned char * bytePosPtr; |
|
228 | 228 | |
|
229 | 229 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
230 | 230 | |
|
231 | 231 | // check LFR mode |
|
232 | 232 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
233 | 233 | status = check_update_info_hk_lfr_mode( mode ); |
|
234 | 234 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
235 | 235 | { |
|
236 | 236 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
237 | 237 | status = check_update_info_hk_tds_mode( mode ); |
|
238 | 238 | } |
|
239 | 239 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
240 | 240 | { |
|
241 | 241 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
242 | 242 | status = check_update_info_hk_thr_mode( mode ); |
|
243 | 243 | } |
|
244 | 244 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
245 | 245 | { |
|
246 | 246 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
247 | 247 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
248 | 248 | val++; |
|
249 | 249 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
250 | 250 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
251 | 251 | } |
|
252 | 252 | |
|
253 | 253 | result = status; |
|
254 | 254 | |
|
255 | 255 | return result; |
|
256 | 256 | } |
|
257 | 257 | |
|
258 | 258 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
259 | 259 | { |
|
260 | 260 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
261 | 261 | * |
|
262 | 262 | * @param TC points to the TeleCommand packet that is being processed |
|
263 | 263 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
264 | 264 | * |
|
265 | 265 | */ |
|
266 | 266 | |
|
267 | 267 | int result; |
|
268 | 268 | unsigned char lfrMode; |
|
269 | 269 | |
|
270 | 270 | result = LFR_DEFAULT; |
|
271 | 271 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
272 | 272 | |
|
273 | 273 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
274 | 274 | result = LFR_DEFAULT; |
|
275 | 275 | |
|
276 | 276 | return result; |
|
277 | 277 | } |
|
278 | 278 | |
|
279 | 279 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
280 | 280 | { |
|
281 | 281 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
282 | 282 | * |
|
283 | 283 | * @param TC points to the TeleCommand packet that is being processed |
|
284 | 284 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
285 | 285 | * |
|
286 | 286 | */ |
|
287 | 287 | |
|
288 | 288 | int result; |
|
289 | 289 | unsigned char lfrMode; |
|
290 | 290 | |
|
291 | 291 | result = LFR_DEFAULT; |
|
292 | 292 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
293 | 293 | |
|
294 | 294 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
295 | 295 | result = LFR_DEFAULT; |
|
296 | 296 | |
|
297 | 297 | return result; |
|
298 | 298 | } |
|
299 | 299 | |
|
300 | 300 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
301 | 301 | { |
|
302 | 302 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
303 | 303 | * |
|
304 | 304 | * @param TC points to the TeleCommand packet that is being processed |
|
305 | 305 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
306 | 306 | * |
|
307 | 307 | * @return LFR_SUCCESSFUL |
|
308 | 308 | * |
|
309 | 309 | */ |
|
310 | 310 | |
|
311 | 311 | unsigned int val; |
|
312 | 312 | |
|
313 | 313 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
314 | 314 | + (TC->dataAndCRC[1] << 16) |
|
315 | 315 | + (TC->dataAndCRC[2] << 8) |
|
316 | 316 | + TC->dataAndCRC[3]; |
|
317 | 317 | |
|
318 | 318 | PRINTF1("time received: %x\n", time_management_regs->coarse_time_load) |
|
319 | 319 | |
|
320 | 320 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
321 | 321 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
322 | 322 | val++; |
|
323 | 323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
324 | 324 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
325 | 325 | // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick |
|
326 | 326 | |
|
327 | 327 | return LFR_SUCCESSFUL; |
|
328 | 328 | } |
|
329 | 329 | |
|
330 | 330 | //******************* |
|
331 | 331 | // ENTERING THE MODES |
|
332 | 332 | int check_mode_value( unsigned char requestedMode ) |
|
333 | 333 | { |
|
334 | 334 | int status; |
|
335 | 335 | |
|
336 | 336 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
337 | 337 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
338 | 338 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
339 | 339 | { |
|
340 | 340 | status = LFR_DEFAULT; |
|
341 | 341 | } |
|
342 | 342 | else |
|
343 | 343 | { |
|
344 | 344 | status = LFR_SUCCESSFUL; |
|
345 | 345 | } |
|
346 | 346 | |
|
347 | 347 | return status; |
|
348 | 348 | } |
|
349 | 349 | |
|
350 | 350 | int check_mode_transition( unsigned char requestedMode ) |
|
351 | 351 | { |
|
352 | 352 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
353 | 353 | * |
|
354 | 354 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
355 | 355 | * |
|
356 | 356 | * @return LFR directive status codes: |
|
357 | 357 | * - LFR_SUCCESSFUL - the transition is authorized |
|
358 | 358 | * - LFR_DEFAULT - the transition is not authorized |
|
359 | 359 | * |
|
360 | 360 | */ |
|
361 | 361 | |
|
362 | 362 | int status; |
|
363 | 363 | |
|
364 | 364 | switch (requestedMode) |
|
365 | 365 | { |
|
366 | 366 | case LFR_MODE_STANDBY: |
|
367 | 367 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
368 | 368 | status = LFR_DEFAULT; |
|
369 | 369 | } |
|
370 | 370 | else |
|
371 | 371 | { |
|
372 | 372 | status = LFR_SUCCESSFUL; |
|
373 | 373 | } |
|
374 | 374 | break; |
|
375 | 375 | case LFR_MODE_NORMAL: |
|
376 | 376 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
377 | 377 | status = LFR_DEFAULT; |
|
378 | 378 | } |
|
379 | 379 | else { |
|
380 | 380 | status = LFR_SUCCESSFUL; |
|
381 | 381 | } |
|
382 | 382 | break; |
|
383 | 383 | case LFR_MODE_BURST: |
|
384 | 384 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
385 | 385 | status = LFR_DEFAULT; |
|
386 | 386 | } |
|
387 | 387 | else { |
|
388 | 388 | status = LFR_SUCCESSFUL; |
|
389 | 389 | } |
|
390 | 390 | break; |
|
391 | 391 | case LFR_MODE_SBM1: |
|
392 | 392 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
393 | 393 | status = LFR_DEFAULT; |
|
394 | 394 | } |
|
395 | 395 | else { |
|
396 | 396 | status = LFR_SUCCESSFUL; |
|
397 | 397 | } |
|
398 | 398 | break; |
|
399 | 399 | case LFR_MODE_SBM2: |
|
400 | 400 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
401 | 401 | status = LFR_DEFAULT; |
|
402 | 402 | } |
|
403 | 403 | else { |
|
404 | 404 | status = LFR_SUCCESSFUL; |
|
405 | 405 | } |
|
406 | 406 | break; |
|
407 | 407 | default: |
|
408 | 408 | status = LFR_DEFAULT; |
|
409 | 409 | break; |
|
410 | 410 | } |
|
411 | 411 | |
|
412 | 412 | return status; |
|
413 | 413 | } |
|
414 | 414 | |
|
415 | 415 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
416 | 416 | { |
|
417 | 417 | int status; |
|
418 | 418 | unsigned int localCoarseTime; |
|
419 | 419 | unsigned int deltaCoarseTime; |
|
420 | 420 | |
|
421 | 421 | status = LFR_SUCCESSFUL; |
|
422 | 422 | |
|
423 | 423 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
424 | 424 | { |
|
425 | 425 | status = LFR_SUCCESSFUL; |
|
426 | 426 | } |
|
427 | 427 | else |
|
428 | 428 | { |
|
429 | 429 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
430 | 430 | |
|
431 | 431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
432 | 432 | { |
|
433 | 433 | status = LFR_DEFAULT; |
|
434 | 434 | PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime) |
|
435 | 435 | } |
|
436 | 436 | |
|
437 | 437 | if (status == LFR_SUCCESSFUL) |
|
438 | 438 | { |
|
439 | 439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
440 | 440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
441 | 441 | { |
|
442 | 442 | status = LFR_DEFAULT; |
|
443 | 443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
444 | 444 | } |
|
445 | 445 | } |
|
446 | 446 | } |
|
447 | 447 | |
|
448 | 448 | return status; |
|
449 | 449 | } |
|
450 | 450 | |
|
451 | 451 | int stop_current_mode( void ) |
|
452 | 452 | { |
|
453 | 453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
454 | 454 | * |
|
455 | 455 | * @return RTEMS directive status codes: |
|
456 | 456 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
457 | 457 | * - RTEMS_INVALID_ID - task id invalid |
|
458 | 458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
459 | 459 | * |
|
460 | 460 | */ |
|
461 | 461 | |
|
462 | 462 | rtems_status_code status; |
|
463 | 463 | |
|
464 | 464 | status = RTEMS_SUCCESSFUL; |
|
465 | 465 | |
|
466 | 466 | // (1) mask interruptions |
|
467 | 467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
468 | 468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
469 | 469 | |
|
470 | 470 | // (2) clear interruptions |
|
471 | 471 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
472 | 472 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
473 | 473 | |
|
474 | 474 | // (3) reset waveform picker registers |
|
475 | 475 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
476 | 476 | reset_wfp_status(); // reset all the status bits |
|
477 | 477 | |
|
478 | 478 | // (4) reset spectral matrices registers |
|
479 | 479 | set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices |
|
480 | 480 | set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0 |
|
481 | 481 | reset_extractSWF(); // reset the extractSWF flag to false |
|
482 | 482 | |
|
483 | 483 | // <Spectral Matrices simulator> |
|
484 | 484 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
485 | 485 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
486 | 486 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
487 | 487 | // </Spectral Matrices simulator> |
|
488 | 488 | |
|
489 | 489 | // suspend several tasks |
|
490 | 490 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
491 | 491 | status = suspend_science_tasks(); |
|
492 | 492 | } |
|
493 | 493 | |
|
494 | 494 | if (status != RTEMS_SUCCESSFUL) |
|
495 | 495 | { |
|
496 | 496 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
497 | 497 | } |
|
498 | 498 | |
|
499 | 499 | return status; |
|
500 | 500 | } |
|
501 | 501 | |
|
502 | 502 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
503 | 503 | { |
|
504 | 504 | /** This function is launched after a mode transition validation. |
|
505 | 505 | * |
|
506 | 506 | * @param mode is the mode in which LFR will be put. |
|
507 | 507 | * |
|
508 | 508 | * @return RTEMS directive status codes: |
|
509 | 509 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
510 | 510 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
511 | 511 | * |
|
512 | 512 | */ |
|
513 | 513 | |
|
514 | 514 | rtems_status_code status; |
|
515 | 515 | |
|
516 | 516 | //********************** |
|
517 | 517 | // STOP THE CURRENT MODE |
|
518 | 518 | status = stop_current_mode(); |
|
519 | 519 | if (status != RTEMS_SUCCESSFUL) |
|
520 | 520 | { |
|
521 | 521 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
522 | 522 | } |
|
523 | 523 | |
|
524 | 524 | //************************* |
|
525 | 525 | // ENTER THE REQUESTED MODE |
|
526 | 526 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
527 | 527 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
528 | 528 | { |
|
529 | 529 | #ifdef PRINT_TASK_STATISTICS |
|
530 | 530 | rtems_cpu_usage_reset(); |
|
531 | 531 | maxCount = 0; |
|
532 | 532 | #endif |
|
533 | 533 | status = restart_science_tasks( mode ); |
|
534 | 534 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
535 |
launch_spectral_matrix |
|
|
535 | // launch_spectral_matrix( ); | |
|
536 | // launch_spectral_matrix_simu( ); | |
|
536 | 537 | } |
|
537 | 538 | else if ( mode == LFR_MODE_STANDBY ) |
|
538 | 539 | { |
|
539 | 540 | #ifdef PRINT_TASK_STATISTICS |
|
540 | 541 | rtems_cpu_usage_report(); |
|
541 | 542 | #endif |
|
542 | 543 | |
|
543 | 544 | #ifdef PRINT_STACK_REPORT |
|
545 | PRINTF("stack report selected\n") | |
|
544 | 546 | rtems_stack_checker_report_usage(); |
|
545 | 547 | #endif |
|
546 | 548 | PRINTF1("maxCount = %d\n", maxCount) |
|
547 | 549 | } |
|
548 | 550 | else |
|
549 | 551 | { |
|
550 | 552 | status = RTEMS_UNSATISFIED; |
|
551 | 553 | } |
|
552 | 554 | |
|
553 | 555 | if (status != RTEMS_SUCCESSFUL) |
|
554 | 556 | { |
|
555 | 557 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
556 | 558 | status = RTEMS_UNSATISFIED; |
|
557 | 559 | } |
|
558 | 560 | |
|
559 | 561 | return status; |
|
560 | 562 | } |
|
561 | 563 | |
|
562 | 564 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
563 | 565 | { |
|
564 | 566 | /** This function is used to restart all science tasks. |
|
565 | 567 | * |
|
566 | 568 | * @return RTEMS directive status codes: |
|
567 | 569 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
568 | 570 | * - RTEMS_INVALID_ID - task id invalid |
|
569 | 571 | * - RTEMS_INCORRECT_STATE - task never started |
|
570 | 572 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
571 | 573 | * |
|
572 | 574 | * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1 |
|
573 | 575 | * |
|
574 | 576 | */ |
|
575 | 577 | |
|
576 | 578 | rtems_status_code status[7]; |
|
577 | 579 | rtems_status_code ret; |
|
578 | 580 | |
|
579 | 581 | ret = RTEMS_SUCCESSFUL; |
|
580 | 582 | |
|
581 | 583 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
582 | 584 | if (status[0] != RTEMS_SUCCESSFUL) |
|
583 | 585 | { |
|
584 | 586 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) |
|
585 | 587 | } |
|
586 | 588 | |
|
587 | 589 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
588 | 590 | if (status[2] != RTEMS_SUCCESSFUL) |
|
589 | 591 | { |
|
590 | 592 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) |
|
591 | 593 | } |
|
592 | 594 | |
|
593 | 595 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
594 | 596 | if (status[3] != RTEMS_SUCCESSFUL) |
|
595 | 597 | { |
|
596 | 598 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) |
|
597 | 599 | } |
|
598 | 600 | |
|
599 | 601 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
600 | 602 | if (status[4] != RTEMS_SUCCESSFUL) |
|
601 | 603 | { |
|
602 | 604 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) |
|
603 | 605 | } |
|
604 | 606 | |
|
605 | 607 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
606 | 608 | if (status[5] != RTEMS_SUCCESSFUL) |
|
607 | 609 | { |
|
608 | 610 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) |
|
609 | 611 | } |
|
610 | 612 | |
|
611 | 613 | status[6] = rtems_task_restart( Task_id[TASKID_MATR], lfrRequestedMode ); |
|
612 | 614 | if (status[6] != RTEMS_SUCCESSFUL) |
|
613 | 615 | { |
|
614 | 616 | PRINTF1("in restart_science_task *** 6 ERR %d\n", status[6]) |
|
615 | 617 | } |
|
616 | 618 | |
|
617 | 619 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || |
|
618 | 620 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || |
|
619 | 621 | (status[5] != RTEMS_SUCCESSFUL) || (status[6] != RTEMS_SUCCESSFUL) ) |
|
620 | 622 | { |
|
621 | 623 | ret = RTEMS_UNSATISFIED; |
|
622 | 624 | } |
|
623 | 625 | |
|
624 | 626 | return ret; |
|
625 | 627 | } |
|
626 | 628 | |
|
627 | 629 | int suspend_science_tasks() |
|
628 | 630 | { |
|
629 | 631 | /** This function suspends the science tasks. |
|
630 | 632 | * |
|
631 | 633 | * @return RTEMS directive status codes: |
|
632 | 634 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
633 | 635 | * - RTEMS_INVALID_ID - task id invalid |
|
634 | 636 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
635 | 637 | * |
|
636 | 638 | */ |
|
637 | 639 | |
|
638 | 640 | rtems_status_code status; |
|
639 | 641 | |
|
640 | 642 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); |
|
641 | 643 | if (status != RTEMS_SUCCESSFUL) |
|
642 | 644 | { |
|
643 | 645 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
644 | 646 | } |
|
645 | 647 | |
|
646 | 648 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
647 | 649 | { |
|
648 | 650 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
649 | 651 | if (status != RTEMS_SUCCESSFUL) |
|
650 | 652 | { |
|
651 | 653 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
652 | 654 | } |
|
653 | 655 | } |
|
654 | 656 | |
|
655 | 657 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
656 | 658 | { |
|
657 | 659 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
658 | 660 | if (status != RTEMS_SUCCESSFUL) |
|
659 | 661 | { |
|
660 | 662 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
661 | 663 | } |
|
662 | 664 | } |
|
663 | 665 | |
|
664 | 666 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
665 | 667 | { |
|
666 | 668 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
667 | 669 | if (status != RTEMS_SUCCESSFUL) |
|
668 | 670 | { |
|
669 | 671 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
670 | 672 | } |
|
671 | 673 | } |
|
672 | 674 | |
|
673 | 675 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
674 | 676 | { |
|
675 | 677 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
676 | 678 | if (status != RTEMS_SUCCESSFUL) |
|
677 | 679 | { |
|
678 | 680 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
679 | 681 | } |
|
680 | 682 | } |
|
681 | 683 | |
|
682 | 684 | return status; |
|
683 | 685 | } |
|
684 | 686 | |
|
685 | 687 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
686 | 688 | { |
|
687 | 689 | reset_current_ring_nodes(); |
|
688 | 690 | reset_waveform_picker_regs(); |
|
689 | 691 | set_wfp_burst_enable_register( mode ); |
|
690 | 692 | |
|
691 | 693 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
692 | 694 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
693 | 695 | |
|
694 | 696 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000] |
|
695 | 697 | if (transitionCoarseTime == 0) |
|
696 | 698 | { |
|
697 | 699 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
698 | 700 | } |
|
699 | 701 | else |
|
700 | 702 | { |
|
701 | 703 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
702 | 704 | } |
|
703 | 705 | } |
|
704 | 706 | |
|
705 |
void launch_spectral_matrix( |
|
|
707 | void launch_spectral_matrix( void ) | |
|
706 | 708 | { |
|
707 | 709 | SM_reset_current_ring_nodes(); |
|
708 | 710 | ASM_reset_current_ring_node(); |
|
709 | 711 | reset_spectral_matrix_regs(); |
|
710 | 712 | |
|
711 | 713 | struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO; |
|
712 | 714 | grgpio_regs->io_port_direction_register = |
|
713 |
grgpio_regs->io_port_direction_register | 0x01; // [000 |
|
|
714 |
grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register |
|
|
715 | grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled | |
|
716 | grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0 | |
|
715 | 717 | set_irq_on_new_ready_matrix( 1 ); |
|
716 | 718 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
717 | 719 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
718 | 720 | set_run_matrix_spectral( 1 ); |
|
719 | 721 | |
|
720 | 722 | } |
|
721 | 723 | |
|
724 | void launch_spectral_matrix_simu( void ) | |
|
725 | { | |
|
726 | SM_reset_current_ring_nodes(); | |
|
727 | ASM_reset_current_ring_node(); | |
|
728 | reset_spectral_matrix_regs(); | |
|
729 | ||
|
730 | // Spectral Matrices simulator | |
|
731 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
|
732 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
|
733 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
|
734 | set_local_nb_interrupt_f0_MAX(); | |
|
735 | } | |
|
736 | ||
|
722 | 737 | void set_irq_on_new_ready_matrix( unsigned char value ) |
|
723 | 738 | { |
|
724 | 739 | if (value == 1) |
|
725 | 740 | { |
|
726 | 741 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
727 | 742 | } |
|
728 | 743 | else |
|
729 | 744 | { |
|
730 | 745 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
731 | 746 | } |
|
732 | 747 | } |
|
733 | 748 | |
|
734 | 749 | void set_run_matrix_spectral( unsigned char value ) |
|
735 | 750 | { |
|
736 | 751 | if (value == 1) |
|
737 | 752 | { |
|
738 | 753 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1 |
|
739 | 754 | } |
|
740 | 755 | else |
|
741 | 756 | { |
|
742 | 757 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0 |
|
743 | 758 | } |
|
744 | 759 | } |
|
745 | 760 | |
|
746 | void launch_spectral_matrix_simu( unsigned char mode ) | |
|
747 | { | |
|
748 | SM_reset_current_ring_nodes(); | |
|
749 | ASM_reset_current_ring_node(); | |
|
750 | reset_spectral_matrix_regs(); | |
|
751 | ||
|
752 | // Spectral Matrices simulator | |
|
753 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
|
754 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
|
755 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
|
756 | set_local_nb_interrupt_f0_MAX(); | |
|
757 | } | |
|
758 | ||
|
759 | 761 | //**************** |
|
760 | 762 | // CLOSING ACTIONS |
|
761 | 763 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
762 | 764 | { |
|
763 | 765 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
764 | 766 | * |
|
765 | 767 | * @param TC points to the TC being processed |
|
766 | 768 | * @param time is the time used to date the TC execution |
|
767 | 769 | * |
|
768 | 770 | */ |
|
769 | 771 | |
|
770 | 772 | unsigned int val; |
|
771 | 773 | |
|
772 | 774 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
773 | 775 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
774 | 776 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
775 | 777 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
776 | 778 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
777 | 779 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
778 | 780 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
779 | 781 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
780 | 782 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
781 | 783 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
782 | 784 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
783 | 785 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
784 | 786 | |
|
785 | 787 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
786 | 788 | val++; |
|
787 | 789 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
788 | 790 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
789 | 791 | } |
|
790 | 792 | |
|
791 | 793 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
792 | 794 | { |
|
793 | 795 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
794 | 796 | * |
|
795 | 797 | * @param TC points to the TC being processed |
|
796 | 798 | * @param time is the time used to date the TC rejection |
|
797 | 799 | * |
|
798 | 800 | */ |
|
799 | 801 | |
|
800 | 802 | unsigned int val; |
|
801 | 803 | |
|
802 | 804 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
803 | 805 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
804 | 806 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
805 | 807 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
806 | 808 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
807 | 809 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
808 | 810 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
809 | 811 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
810 | 812 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
811 | 813 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
812 | 814 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
813 | 815 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
814 | 816 | |
|
815 | 817 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
816 | 818 | val++; |
|
817 | 819 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
818 | 820 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
819 | 821 | } |
|
820 | 822 | |
|
821 | 823 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
822 | 824 | { |
|
823 | 825 | /** This function is the last step of the TC execution workflow. |
|
824 | 826 | * |
|
825 | 827 | * @param TC points to the TC being processed |
|
826 | 828 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
827 | 829 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
828 | 830 | * @param time is the time used to date the TC execution |
|
829 | 831 | * |
|
830 | 832 | */ |
|
831 | 833 | |
|
832 | 834 | unsigned char requestedMode; |
|
833 | 835 | |
|
834 | 836 | if (result == LFR_SUCCESSFUL) |
|
835 | 837 | { |
|
836 | 838 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
837 | 839 | & |
|
838 | 840 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
839 | 841 | ) |
|
840 | 842 | { |
|
841 | 843 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
842 | 844 | } |
|
843 | 845 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
844 | 846 | { |
|
845 | 847 | //********************************** |
|
846 | 848 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
847 | 849 | requestedMode = TC->dataAndCRC[1]; |
|
848 | 850 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
849 | 851 | updateLFRCurrentMode(); |
|
850 | 852 | } |
|
851 | 853 | } |
|
852 | 854 | else if (result == LFR_EXE_ERROR) |
|
853 | 855 | { |
|
854 | 856 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
855 | 857 | } |
|
856 | 858 | } |
|
857 | 859 | |
|
858 | 860 | //*************************** |
|
859 | 861 | // Interrupt Service Routines |
|
860 | 862 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
861 | 863 | { |
|
862 | 864 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
863 | 865 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
864 | 866 | } |
|
865 | 867 | } |
|
866 | 868 | |
|
867 | 869 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
868 | 870 | { |
|
869 | 871 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
870 | 872 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
871 | 873 | } |
|
872 | 874 | } |
|
873 | 875 | |
|
874 | 876 | //**************** |
|
875 | 877 | // OTHER FUNCTIONS |
|
876 | 878 | void updateLFRCurrentMode() |
|
877 | 879 | { |
|
878 | 880 | /** This function updates the value of the global variable lfrCurrentMode. |
|
879 | 881 | * |
|
880 | 882 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
881 | 883 | * |
|
882 | 884 | */ |
|
883 | 885 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
884 | 886 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
885 | 887 | } |
|
886 | 888 |
@@ -1,759 +1,776 | |||
|
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 | unsigned char sy_lfr_n_bp_p0; |
|
45 | 45 | unsigned char sy_lfr_n_bp_p1; |
|
46 | unsigned int sy_lfr_n_asm_p; | |
|
46 | 47 | float aux; |
|
47 | 48 | |
|
48 | 49 | flag = LFR_SUCCESSFUL; |
|
49 | 50 | |
|
50 | 51 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
51 | 52 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
52 | 53 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
53 | 54 | flag = LFR_DEFAULT; |
|
54 | 55 | } |
|
55 | 56 | |
|
56 | 57 | //*************** |
|
57 | 58 | // sy_lfr_n_swf_l |
|
58 | 59 | if (flag == LFR_SUCCESSFUL) |
|
59 | 60 | { |
|
60 | 61 | result = set_sy_lfr_n_swf_l( TC, queue_id, time ); |
|
61 | 62 | if (result != LFR_SUCCESSFUL) |
|
62 | 63 | { |
|
63 | 64 | flag = LFR_DEFAULT; |
|
64 | 65 | } |
|
65 | 66 | } |
|
66 | 67 | |
|
67 | 68 | //*************** |
|
68 | 69 | // sy_lfr_n_swf_p |
|
69 | 70 | if (flag == LFR_SUCCESSFUL) |
|
70 | 71 | { |
|
71 | 72 | result = set_sy_lfr_n_swf_p( TC, queue_id, time ); |
|
72 | 73 | if (result != LFR_SUCCESSFUL) |
|
73 | 74 | { |
|
74 | 75 | flag = LFR_DEFAULT; |
|
75 | 76 | } |
|
76 | 77 | } |
|
77 | 78 | |
|
78 | //*************** | |
|
79 | // sy_lfr_n_asm_p | |
|
80 | if (flag == LFR_SUCCESSFUL) | |
|
81 | { | |
|
82 | result = set_sy_lfr_n_asm_p( TC, queue_id ); | |
|
83 | if (result != LFR_SUCCESSFUL) | |
|
84 | { | |
|
85 | flag = LFR_DEFAULT; | |
|
86 | } | |
|
87 | } | |
|
88 | ||
|
89 | 79 | //**************************************************************** |
|
90 | 80 | // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1 |
|
91 | 81 | if (flag == LFR_SUCCESSFUL) |
|
92 | 82 | { |
|
93 | 83 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
94 | 84 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
95 | 85 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
96 | 86 | if (aux != 0) |
|
97 | 87 | { |
|
98 | 88 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
99 | 89 | flag = LFR_DEFAULT; |
|
100 | 90 | } |
|
101 | 91 | } |
|
102 | 92 | |
|
103 | 93 | //*************** |
|
104 | 94 | // sy_lfr_n_bp_p0 |
|
105 | 95 | if (flag == LFR_SUCCESSFUL) |
|
106 | 96 | { |
|
107 | 97 | result = set_sy_lfr_n_bp_p0( TC, queue_id ); |
|
108 | 98 | if (result != LFR_SUCCESSFUL) |
|
109 | 99 | { |
|
110 | 100 | flag = LFR_DEFAULT; |
|
111 | 101 | } |
|
112 | 102 | } |
|
113 | 103 | |
|
114 | 104 | //*************** |
|
115 | 105 | // sy_lfr_n_bp_p1 |
|
116 | 106 | if (flag == LFR_SUCCESSFUL) |
|
117 | 107 | { |
|
118 | 108 | result = set_sy_lfr_n_bp_p1( TC, queue_id ); |
|
119 | 109 | if (result != LFR_SUCCESSFUL) |
|
120 | 110 | { |
|
121 | 111 | flag = LFR_DEFAULT; |
|
122 | 112 | } |
|
123 | 113 | } |
|
124 | 114 | |
|
115 | //**************************************************************** | |
|
116 | // check the consistency between sy_lfr_n_asm_p and sy_lfr_n_bp_p0 | |
|
117 | if (flag == LFR_SUCCESSFUL) | |
|
118 | { | |
|
119 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
|
120 | sy_lfr_n_asm_p = | |
|
121 | TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ] * 256 | |
|
122 | + TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P + 1 ]; | |
|
123 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
|
124 | if (aux != 0) | |
|
125 | { | |
|
126 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
|
127 | flag = LFR_DEFAULT; | |
|
128 | } | |
|
129 | } | |
|
130 | ||
|
131 | //*************** | |
|
132 | // sy_lfr_n_asm_p | |
|
133 | if (flag == LFR_SUCCESSFUL) | |
|
134 | { | |
|
135 | result = set_sy_lfr_n_asm_p( TC, queue_id ); | |
|
136 | if (result != LFR_SUCCESSFUL) | |
|
137 | { | |
|
138 | flag = LFR_DEFAULT; | |
|
139 | } | |
|
140 | } | |
|
141 | ||
|
125 | 142 | //********************* |
|
126 | 143 | // sy_lfr_n_cwf_long_f3 |
|
127 | 144 | if (flag == LFR_SUCCESSFUL) |
|
128 | 145 | { |
|
129 | 146 | result = set_sy_lfr_n_cwf_long_f3( TC, queue_id ); |
|
130 | 147 | if (result != LFR_SUCCESSFUL) |
|
131 | 148 | { |
|
132 | 149 | flag = LFR_DEFAULT; |
|
133 | 150 | } |
|
134 | 151 | } |
|
135 | 152 | |
|
136 | 153 | return flag; |
|
137 | 154 | } |
|
138 | 155 | |
|
139 | 156 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | 157 | { |
|
141 | 158 | /** This function updates the LFR registers with the incoming burst parameters. |
|
142 | 159 | * |
|
143 | 160 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | 161 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
145 | 162 | * |
|
146 | 163 | */ |
|
147 | 164 | |
|
148 | 165 | int result; |
|
149 | 166 | int flag; |
|
150 | 167 | rtems_status_code status; |
|
151 | 168 | unsigned char sy_lfr_b_bp_p0; |
|
152 | 169 | unsigned char sy_lfr_b_bp_p1; |
|
153 | 170 | float aux; |
|
154 | 171 | |
|
155 | 172 | flag = LFR_SUCCESSFUL; |
|
156 | 173 | |
|
157 | 174 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
158 | 175 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
159 | 176 | result = LFR_DEFAULT; |
|
160 | 177 | } |
|
161 | 178 | |
|
162 | 179 | //**************************************************************** |
|
163 | 180 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
164 | 181 | if (flag == LFR_SUCCESSFUL) |
|
165 | 182 | { |
|
166 | 183 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
167 | 184 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
168 | 185 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
169 | 186 | if (aux != 0) |
|
170 | 187 | { |
|
171 | 188 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
172 | 189 | flag = LFR_DEFAULT; |
|
173 | 190 | } |
|
174 | 191 | } |
|
175 | 192 | |
|
176 | 193 | //*************** |
|
177 | 194 | // sy_lfr_b_bp_p0 |
|
178 | 195 | if (flag == LFR_SUCCESSFUL) |
|
179 | 196 | { |
|
180 | 197 | result = set_sy_lfr_b_bp_p0( TC, queue_id ); |
|
181 | 198 | if (result != LFR_SUCCESSFUL) |
|
182 | 199 | { |
|
183 | 200 | flag = LFR_DEFAULT; |
|
184 | 201 | } |
|
185 | 202 | } |
|
186 | 203 | |
|
187 | 204 | //*************** |
|
188 | 205 | // sy_lfr_b_bp_p1 |
|
189 | 206 | if (flag == LFR_SUCCESSFUL) |
|
190 | 207 | { |
|
191 | 208 | result = set_sy_lfr_b_bp_p1( TC, queue_id ); |
|
192 | 209 | if (result != LFR_SUCCESSFUL) |
|
193 | 210 | { |
|
194 | 211 | flag = LFR_DEFAULT; |
|
195 | 212 | } |
|
196 | 213 | } |
|
197 | 214 | |
|
198 | 215 | return flag; |
|
199 | 216 | } |
|
200 | 217 | |
|
201 | 218 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
202 | 219 | { |
|
203 | 220 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
204 | 221 | * |
|
205 | 222 | * @param TC points to the TeleCommand packet that is being processed |
|
206 | 223 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
207 | 224 | * |
|
208 | 225 | */ |
|
209 | 226 | |
|
210 | 227 | int result; |
|
211 | 228 | int flag; |
|
212 | 229 | rtems_status_code status; |
|
213 | 230 | unsigned char sy_lfr_s1_bp_p0; |
|
214 | 231 | unsigned char sy_lfr_s1_bp_p1; |
|
215 | 232 | float aux; |
|
216 | 233 | |
|
217 | 234 | flag = LFR_SUCCESSFUL; |
|
218 | 235 | |
|
219 | 236 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
220 | 237 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
221 | 238 | result = LFR_DEFAULT; |
|
222 | 239 | } |
|
223 | 240 | |
|
224 | 241 | //****************************************************************** |
|
225 | 242 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
226 | 243 | if (flag == LFR_SUCCESSFUL) |
|
227 | 244 | { |
|
228 | 245 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
229 | 246 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
230 | 247 | 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)); |
|
231 | 248 | if (aux != 0) |
|
232 | 249 | { |
|
233 | 250 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
234 | 251 | flag = LFR_DEFAULT; |
|
235 | 252 | } |
|
236 | 253 | } |
|
237 | 254 | |
|
238 | 255 | //*************** |
|
239 | 256 | // sy_lfr_s1_bp_p0 |
|
240 | 257 | if (flag == LFR_SUCCESSFUL) |
|
241 | 258 | { |
|
242 | 259 | result = set_sy_lfr_s1_bp_p0( TC, queue_id ); |
|
243 | 260 | if (result != LFR_SUCCESSFUL) |
|
244 | 261 | { |
|
245 | 262 | flag = LFR_DEFAULT; |
|
246 | 263 | } |
|
247 | 264 | } |
|
248 | 265 | |
|
249 | 266 | //*************** |
|
250 | 267 | // sy_lfr_s1_bp_p1 |
|
251 | 268 | if (flag == LFR_SUCCESSFUL) |
|
252 | 269 | { |
|
253 | 270 | result = set_sy_lfr_s1_bp_p1( TC, queue_id ); |
|
254 | 271 | if (result != LFR_SUCCESSFUL) |
|
255 | 272 | { |
|
256 | 273 | flag = LFR_DEFAULT; |
|
257 | 274 | } |
|
258 | 275 | } |
|
259 | 276 | |
|
260 | 277 | return flag; |
|
261 | 278 | } |
|
262 | 279 | |
|
263 | 280 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
264 | 281 | { |
|
265 | 282 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
266 | 283 | * |
|
267 | 284 | * @param TC points to the TeleCommand packet that is being processed |
|
268 | 285 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
269 | 286 | * |
|
270 | 287 | */ |
|
271 | 288 | |
|
272 | 289 | int result; |
|
273 | 290 | int flag; |
|
274 | 291 | rtems_status_code status; |
|
275 | 292 | unsigned char sy_lfr_s2_bp_p0; |
|
276 | 293 | unsigned char sy_lfr_s2_bp_p1; |
|
277 | 294 | float aux; |
|
278 | 295 | |
|
279 | 296 | flag = LFR_SUCCESSFUL; |
|
280 | 297 | |
|
281 | 298 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
282 | 299 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
283 | 300 | result = LFR_DEFAULT; |
|
284 | 301 | } |
|
285 | 302 | |
|
286 | 303 | //****************************************************************** |
|
287 | 304 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
288 | 305 | if (flag == LFR_SUCCESSFUL) |
|
289 | 306 | { |
|
290 | 307 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
291 | 308 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
292 | 309 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
293 | 310 | if (aux != 0) |
|
294 | 311 | { |
|
295 | 312 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
296 | 313 | flag = LFR_DEFAULT; |
|
297 | 314 | } |
|
298 | 315 | } |
|
299 | 316 | |
|
300 | 317 | //*************** |
|
301 | 318 | // sy_lfr_s2_bp_p0 |
|
302 | 319 | if (flag == LFR_SUCCESSFUL) |
|
303 | 320 | { |
|
304 | 321 | result = set_sy_lfr_s2_bp_p0( TC, queue_id ); |
|
305 | 322 | if (result != LFR_SUCCESSFUL) |
|
306 | 323 | { |
|
307 | 324 | flag = LFR_DEFAULT; |
|
308 | 325 | } |
|
309 | 326 | } |
|
310 | 327 | |
|
311 | 328 | //*************** |
|
312 | 329 | // sy_lfr_s2_bp_p1 |
|
313 | 330 | if (flag == LFR_SUCCESSFUL) |
|
314 | 331 | { |
|
315 | 332 | result = set_sy_lfr_s2_bp_p1( TC, queue_id ); |
|
316 | 333 | if (result != LFR_SUCCESSFUL) |
|
317 | 334 | { |
|
318 | 335 | flag = LFR_DEFAULT; |
|
319 | 336 | } |
|
320 | 337 | } |
|
321 | 338 | |
|
322 | 339 | return flag; |
|
323 | 340 | } |
|
324 | 341 | |
|
325 | 342 | int action_dump_par( rtems_id queue_id ) |
|
326 | 343 | { |
|
327 | 344 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
328 | 345 | * |
|
329 | 346 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
330 | 347 | * |
|
331 | 348 | * @return RTEMS directive status codes: |
|
332 | 349 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
333 | 350 | * - RTEMS_INVALID_ID - invalid queue id |
|
334 | 351 | * - RTEMS_INVALID_SIZE - invalid message size |
|
335 | 352 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
336 | 353 | * - RTEMS_UNSATISFIED - out of message buffers |
|
337 | 354 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
338 | 355 | * |
|
339 | 356 | */ |
|
340 | 357 | |
|
341 | 358 | int status; |
|
342 | 359 | |
|
343 | 360 | // UPDATE TIME |
|
344 | 361 | increment_seq_counter( parameter_dump_packet.packetSequenceControl ); |
|
345 | 362 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
346 | 363 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
347 | 364 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
348 | 365 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
349 | 366 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
350 | 367 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
351 | 368 | // SEND DATA |
|
352 | 369 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
353 | 370 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
354 | 371 | if (status != RTEMS_SUCCESSFUL) { |
|
355 | 372 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
356 | 373 | } |
|
357 | 374 | |
|
358 | 375 | return status; |
|
359 | 376 | } |
|
360 | 377 | |
|
361 | 378 | //*********************** |
|
362 | 379 | // NORMAL MODE PARAMETERS |
|
363 | 380 | |
|
364 | 381 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) |
|
365 | 382 | { |
|
366 | 383 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
367 | 384 | * |
|
368 | 385 | * @param TC points to the TeleCommand packet that is being processed |
|
369 | 386 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
370 | 387 | * |
|
371 | 388 | */ |
|
372 | 389 | |
|
373 | 390 | unsigned int tmp; |
|
374 | 391 | int result; |
|
375 | 392 | unsigned char msb; |
|
376 | 393 | unsigned char lsb; |
|
377 | 394 | rtems_status_code status; |
|
378 | 395 | |
|
379 | 396 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
380 | 397 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
381 | 398 | |
|
382 | 399 | tmp = ( unsigned int ) floor( |
|
383 | 400 | ( ( msb*256 ) + lsb ) / 16 |
|
384 | 401 | ) * 16; |
|
385 | 402 | |
|
386 | 403 | if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16 |
|
387 | 404 | { // 2048 is the maximum limit due to the size of the buffers |
|
388 | 405 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb ); |
|
389 | 406 | result = WRONG_APP_DATA; |
|
390 | 407 | } |
|
391 | 408 | else if (tmp != 2048) |
|
392 | 409 | { |
|
393 | 410 | status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
394 | 411 | result = FUNCT_NOT_IMPL; |
|
395 | 412 | } |
|
396 | 413 | else |
|
397 | 414 | { |
|
398 | 415 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8); |
|
399 | 416 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp ); |
|
400 | 417 | result = LFR_SUCCESSFUL; |
|
401 | 418 | } |
|
402 | 419 | |
|
403 | 420 | return result; |
|
404 | 421 | } |
|
405 | 422 | |
|
406 | 423 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time) |
|
407 | 424 | { |
|
408 | 425 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
409 | 426 | * |
|
410 | 427 | * @param TC points to the TeleCommand packet that is being processed |
|
411 | 428 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
412 | 429 | * |
|
413 | 430 | */ |
|
414 | 431 | |
|
415 | 432 | unsigned int tmp; |
|
416 | 433 | int result; |
|
417 | 434 | unsigned char msb; |
|
418 | 435 | unsigned char lsb; |
|
419 | 436 | rtems_status_code status; |
|
420 | 437 | |
|
421 | 438 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
422 | 439 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
423 | 440 | |
|
424 | 441 | tmp = msb * 256 + lsb; |
|
425 | 442 | |
|
426 | 443 | if ( tmp < 16 ) |
|
427 | 444 | { |
|
428 | 445 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb ); |
|
429 | 446 | result = WRONG_APP_DATA; |
|
430 | 447 | } |
|
431 | 448 | else |
|
432 | 449 | { |
|
433 | 450 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8); |
|
434 | 451 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp ); |
|
435 | 452 | result = LFR_SUCCESSFUL; |
|
436 | 453 | } |
|
437 | 454 | |
|
438 | 455 | return result; |
|
439 | 456 | } |
|
440 | 457 | |
|
441 | 458 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
442 | 459 | { |
|
443 | 460 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
444 | 461 | * |
|
445 | 462 | * @param TC points to the TeleCommand packet that is being processed |
|
446 | 463 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
447 | 464 | * |
|
448 | 465 | */ |
|
449 | 466 | |
|
450 | 467 | int result; |
|
451 | 468 | unsigned char msb; |
|
452 | 469 | unsigned char lsb; |
|
453 | 470 | |
|
454 | 471 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
455 | 472 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
456 | 473 | |
|
457 | 474 | parameter_dump_packet.sy_lfr_n_asm_p[0] = msb; |
|
458 | 475 | parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb; |
|
459 | 476 | result = LFR_SUCCESSFUL; |
|
460 | 477 | |
|
461 | 478 | return result; |
|
462 | 479 | } |
|
463 | 480 | |
|
464 | 481 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
465 | 482 | { |
|
466 | 483 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0). |
|
467 | 484 | * |
|
468 | 485 | * @param TC points to the TeleCommand packet that is being processed |
|
469 | 486 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
470 | 487 | * |
|
471 | 488 | */ |
|
472 | 489 | |
|
473 | 490 | int status; |
|
474 | 491 | |
|
475 | 492 | status = LFR_SUCCESSFUL; |
|
476 | 493 | |
|
477 | 494 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
478 | 495 | |
|
479 | 496 | return status; |
|
480 | 497 | } |
|
481 | 498 | |
|
482 | 499 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
483 | 500 | { |
|
484 | 501 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
485 | 502 | * |
|
486 | 503 | * @param TC points to the TeleCommand packet that is being processed |
|
487 | 504 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
488 | 505 | * |
|
489 | 506 | */ |
|
490 | 507 | |
|
491 | 508 | int status; |
|
492 | 509 | |
|
493 | 510 | status = LFR_SUCCESSFUL; |
|
494 | 511 | |
|
495 | 512 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
496 | 513 | |
|
497 | 514 | return status; |
|
498 | 515 | } |
|
499 | 516 | |
|
500 | 517 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
501 | 518 | { |
|
502 | 519 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
503 | 520 | * |
|
504 | 521 | * @param TC points to the TeleCommand packet that is being processed |
|
505 | 522 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
506 | 523 | * |
|
507 | 524 | */ |
|
508 | 525 | |
|
509 | 526 | int status; |
|
510 | 527 | |
|
511 | 528 | status = LFR_SUCCESSFUL; |
|
512 | 529 | |
|
513 | 530 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
514 | 531 | |
|
515 | 532 | return status; |
|
516 | 533 | } |
|
517 | 534 | |
|
518 | 535 | //********************** |
|
519 | 536 | // BURST MODE PARAMETERS |
|
520 | 537 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
521 | 538 | { |
|
522 | 539 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
523 | 540 | * |
|
524 | 541 | * @param TC points to the TeleCommand packet that is being processed |
|
525 | 542 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
526 | 543 | * |
|
527 | 544 | */ |
|
528 | 545 | |
|
529 | 546 | int status; |
|
530 | 547 | |
|
531 | 548 | status = LFR_SUCCESSFUL; |
|
532 | 549 | |
|
533 | 550 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
534 | 551 | |
|
535 | 552 | return status; |
|
536 | 553 | } |
|
537 | 554 | |
|
538 | 555 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
539 | 556 | { |
|
540 | 557 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
541 | 558 | * |
|
542 | 559 | * @param TC points to the TeleCommand packet that is being processed |
|
543 | 560 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
544 | 561 | * |
|
545 | 562 | */ |
|
546 | 563 | |
|
547 | 564 | int status; |
|
548 | 565 | |
|
549 | 566 | status = LFR_SUCCESSFUL; |
|
550 | 567 | |
|
551 | 568 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
552 | 569 | |
|
553 | 570 | return status; |
|
554 | 571 | } |
|
555 | 572 | |
|
556 | 573 | //********************* |
|
557 | 574 | // SBM1 MODE PARAMETERS |
|
558 | 575 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
559 | 576 | { |
|
560 | 577 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
561 | 578 | * |
|
562 | 579 | * @param TC points to the TeleCommand packet that is being processed |
|
563 | 580 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
564 | 581 | * |
|
565 | 582 | */ |
|
566 | 583 | |
|
567 | 584 | int status; |
|
568 | 585 | |
|
569 | 586 | status = LFR_SUCCESSFUL; |
|
570 | 587 | |
|
571 | 588 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
572 | 589 | |
|
573 | 590 | return status; |
|
574 | 591 | } |
|
575 | 592 | |
|
576 | 593 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
577 | 594 | { |
|
578 | 595 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
579 | 596 | * |
|
580 | 597 | * @param TC points to the TeleCommand packet that is being processed |
|
581 | 598 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
582 | 599 | * |
|
583 | 600 | */ |
|
584 | 601 | |
|
585 | 602 | int status; |
|
586 | 603 | |
|
587 | 604 | status = LFR_SUCCESSFUL; |
|
588 | 605 | |
|
589 | 606 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
590 | 607 | |
|
591 | 608 | return status; |
|
592 | 609 | } |
|
593 | 610 | |
|
594 | 611 | //********************* |
|
595 | 612 | // SBM2 MODE PARAMETERS |
|
596 | 613 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
597 | 614 | { |
|
598 | 615 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
599 | 616 | * |
|
600 | 617 | * @param TC points to the TeleCommand packet that is being processed |
|
601 | 618 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
602 | 619 | * |
|
603 | 620 | */ |
|
604 | 621 | |
|
605 | 622 | int status; |
|
606 | 623 | |
|
607 | 624 | status = LFR_SUCCESSFUL; |
|
608 | 625 | |
|
609 | 626 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
610 | 627 | |
|
611 | 628 | return status; |
|
612 | 629 | } |
|
613 | 630 | |
|
614 | 631 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
615 | 632 | { |
|
616 | 633 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
617 | 634 | * |
|
618 | 635 | * @param TC points to the TeleCommand packet that is being processed |
|
619 | 636 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
620 | 637 | * |
|
621 | 638 | */ |
|
622 | 639 | |
|
623 | 640 | int status; |
|
624 | 641 | |
|
625 | 642 | status = LFR_SUCCESSFUL; |
|
626 | 643 | |
|
627 | 644 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
628 | 645 | |
|
629 | 646 | return status; |
|
630 | 647 | } |
|
631 | 648 | |
|
632 | 649 | |
|
633 | 650 | //******************* |
|
634 | 651 | // TC_LFR_UPDATE_INFO |
|
635 | 652 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
636 | 653 | { |
|
637 | 654 | unsigned int status; |
|
638 | 655 | |
|
639 | 656 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
640 | 657 | || (mode == LFR_MODE_BURST) |
|
641 | 658 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
642 | 659 | { |
|
643 | 660 | status = LFR_SUCCESSFUL; |
|
644 | 661 | } |
|
645 | 662 | else |
|
646 | 663 | { |
|
647 | 664 | status = LFR_DEFAULT; |
|
648 | 665 | } |
|
649 | 666 | |
|
650 | 667 | return status; |
|
651 | 668 | } |
|
652 | 669 | |
|
653 | 670 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
654 | 671 | { |
|
655 | 672 | unsigned int status; |
|
656 | 673 | |
|
657 | 674 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
658 | 675 | || (mode == TDS_MODE_BURST) |
|
659 | 676 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
660 | 677 | || (mode == TDS_MODE_LFM)) |
|
661 | 678 | { |
|
662 | 679 | status = LFR_SUCCESSFUL; |
|
663 | 680 | } |
|
664 | 681 | else |
|
665 | 682 | { |
|
666 | 683 | status = LFR_DEFAULT; |
|
667 | 684 | } |
|
668 | 685 | |
|
669 | 686 | return status; |
|
670 | 687 | } |
|
671 | 688 | |
|
672 | 689 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
673 | 690 | { |
|
674 | 691 | unsigned int status; |
|
675 | 692 | |
|
676 | 693 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
677 | 694 | || (mode == THR_MODE_BURST)) |
|
678 | 695 | { |
|
679 | 696 | status = LFR_SUCCESSFUL; |
|
680 | 697 | } |
|
681 | 698 | else |
|
682 | 699 | { |
|
683 | 700 | status = LFR_DEFAULT; |
|
684 | 701 | } |
|
685 | 702 | |
|
686 | 703 | return status; |
|
687 | 704 | } |
|
688 | 705 | |
|
689 | 706 | //********** |
|
690 | 707 | // init dump |
|
691 | 708 | |
|
692 | 709 | void init_parameter_dump( void ) |
|
693 | 710 | { |
|
694 | 711 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
695 | 712 | * |
|
696 | 713 | */ |
|
697 | 714 | |
|
698 | 715 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
699 | 716 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
700 | 717 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
701 | 718 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
702 | 719 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
703 | 720 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
704 | 721 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
705 | 722 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
706 | 723 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
707 | 724 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
708 | 725 | // DATA FIELD HEADER |
|
709 | 726 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
710 | 727 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
711 | 728 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
712 | 729 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
713 | 730 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
714 | 731 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
715 | 732 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
716 | 733 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
717 | 734 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
718 | 735 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
719 | 736 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
720 | 737 | |
|
721 | 738 | //****************** |
|
722 | 739 | // COMMON PARAMETERS |
|
723 | 740 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; |
|
724 | 741 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; |
|
725 | 742 | |
|
726 | 743 | //****************** |
|
727 | 744 | // NORMAL PARAMETERS |
|
728 | 745 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8); |
|
729 | 746 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L ); |
|
730 | 747 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8); |
|
731 | 748 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P ); |
|
732 | 749 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8); |
|
733 | 750 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P ); |
|
734 | 751 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0; |
|
735 | 752 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1; |
|
736 | 753 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3; |
|
737 | 754 | |
|
738 | 755 | //***************** |
|
739 | 756 | // BURST PARAMETERS |
|
740 | 757 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
741 | 758 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
742 | 759 | |
|
743 | 760 | //**************** |
|
744 | 761 | // SBM1 PARAMETERS |
|
745 | 762 | 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 |
|
746 | 763 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
747 | 764 | |
|
748 | 765 | //**************** |
|
749 | 766 | // SBM2 PARAMETERS |
|
750 | 767 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
751 | 768 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
752 | 769 | } |
|
753 | 770 | |
|
754 | 771 | |
|
755 | 772 | |
|
756 | 773 | |
|
757 | 774 | |
|
758 | 775 | |
|
759 | 776 |
@@ -1,1351 +1,1339 | |||
|
1 | 1 | /** Functions and tasks related to waveform packet generation. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
7 | 7 | * |
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | #include "wf_handler.h" |
|
11 | 11 | |
|
12 | 12 | //***************** |
|
13 | 13 | // waveform headers |
|
14 | 14 | // SWF |
|
15 | 15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; |
|
16 | 16 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; |
|
17 | 17 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; |
|
18 | 18 | // CWF |
|
19 | 19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
20 | 20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
21 | 21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
22 | 22 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ]; |
|
23 | 23 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ]; |
|
24 | 24 | |
|
25 | 25 | //************** |
|
26 | 26 | // waveform ring |
|
27 | 27 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
28 | 28 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
29 | 29 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
30 | 30 | ring_node *current_ring_node_f0; |
|
31 | 31 | ring_node *ring_node_to_send_swf_f0; |
|
32 | 32 | ring_node *current_ring_node_f1; |
|
33 | 33 | ring_node *ring_node_to_send_swf_f1; |
|
34 | 34 | ring_node *ring_node_to_send_cwf_f1; |
|
35 | 35 | ring_node *current_ring_node_f2; |
|
36 | 36 | ring_node *ring_node_to_send_swf_f2; |
|
37 | 37 | ring_node *ring_node_to_send_cwf_f2; |
|
38 | 38 | |
|
39 | 39 | bool extractSWF = false; |
|
40 | 40 | bool swf_f0_ready = false; |
|
41 | 41 | bool swf_f1_ready = false; |
|
42 | 42 | bool swf_f2_ready = false; |
|
43 | 43 | |
|
44 | 44 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
45 | 45 | |
|
46 | 46 | //********************* |
|
47 | 47 | // Interrupt SubRoutine |
|
48 | 48 | |
|
49 | 49 | void reset_extractSWF( void ) |
|
50 | 50 | { |
|
51 | 51 | extractSWF = false; |
|
52 | 52 | swf_f0_ready = false; |
|
53 | 53 | swf_f1_ready = false; |
|
54 | 54 | swf_f2_ready = false; |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
58 | 58 | { |
|
59 | 59 | /** This is the interrupt sub routine called by the waveform picker core. |
|
60 | 60 | * |
|
61 | 61 | * This ISR launch different actions depending mainly on two pieces of information: |
|
62 | 62 | * 1. the values read in the registers of the waveform picker. |
|
63 | 63 | * 2. the current LFR mode. |
|
64 | 64 | * |
|
65 | 65 | */ |
|
66 | 66 | |
|
67 | 67 | rtems_status_code status; |
|
68 | static unsigned char nb_swf = 0; | |
|
69 | 68 | |
|
70 | 69 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
71 | 70 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
72 | 71 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
73 | 72 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
74 | 73 | // (1) change the receiving buffer for the waveform picker |
|
75 | 74 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { |
|
76 | 75 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b); |
|
77 | 76 | } |
|
78 | 77 | else { |
|
79 | 78 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); |
|
80 | 79 | } |
|
81 | 80 | // (2) send an event for the waveforms transmission |
|
82 | 81 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
83 | 82 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
84 | 83 | } |
|
85 | 84 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
86 | 85 | } |
|
87 | 86 | } |
|
88 | 87 | |
|
89 | 88 | switch(lfrCurrentMode) |
|
90 | 89 | { |
|
91 | 90 | //******** |
|
92 | 91 | // STANDBY |
|
93 | 92 | case(LFR_MODE_STANDBY): |
|
94 | 93 | break; |
|
95 | 94 | |
|
96 | 95 | //****** |
|
97 | 96 | // NORMAL |
|
98 | 97 | case(LFR_MODE_NORMAL): |
|
99 | 98 | if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits |
|
100 | 99 | { |
|
101 | 100 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
102 | 101 | } |
|
103 | 102 | if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits |
|
104 | 103 | { |
|
105 | 104 | // change F0 ring node |
|
106 | 105 | ring_node_to_send_swf_f0 = current_ring_node_f0; |
|
107 | 106 | current_ring_node_f0 = current_ring_node_f0->next; |
|
108 | 107 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; |
|
109 | 108 | // change F1 ring node |
|
110 | 109 | ring_node_to_send_swf_f1 = current_ring_node_f1; |
|
111 | 110 | current_ring_node_f1 = current_ring_node_f1->next; |
|
112 | 111 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
113 | 112 | // change F2 ring node |
|
114 | 113 | ring_node_to_send_swf_f2 = current_ring_node_f2; |
|
115 | 114 | current_ring_node_f2 = current_ring_node_f2->next; |
|
116 | 115 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
117 | 116 | // |
|
118 | // if (nb_swf < 2) | |
|
119 | if (true) | |
|
117 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) | |
|
120 | 118 | { |
|
121 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
|
122 | 119 |
|
|
123 | 120 |
|
|
124 | 121 |
|
|
125 | nb_swf = nb_swf + 1; | |
|
126 | 122 |
|
|
127 | else | |
|
128 | { | |
|
129 | reset_wfp_burst_enable(); | |
|
130 | nb_swf = 0; | |
|
131 | } | |
|
132 | ||
|
133 | } | |
|
134 | ||
|
135 | 123 | break; |
|
136 | 124 | |
|
137 | 125 | //****** |
|
138 | 126 | // BURST |
|
139 | 127 | case(LFR_MODE_BURST): |
|
140 | 128 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
141 | 129 | // (1) change the receiving buffer for the waveform picker |
|
142 | 130 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
143 | 131 | current_ring_node_f2 = current_ring_node_f2->next; |
|
144 | 132 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
145 | 133 | // (2) send an event for the waveforms transmission |
|
146 | 134 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
147 | 135 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
148 | 136 | } |
|
149 | 137 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
150 | 138 | } |
|
151 | 139 | break; |
|
152 | 140 | |
|
153 | 141 | //***** |
|
154 | 142 | // SBM1 |
|
155 | 143 | case(LFR_MODE_SBM1): |
|
156 | 144 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
157 | 145 | // (1) change the receiving buffer for the waveform picker |
|
158 | 146 | ring_node_to_send_cwf_f1 = current_ring_node_f1; |
|
159 | 147 | current_ring_node_f1 = current_ring_node_f1->next; |
|
160 | 148 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; |
|
161 | 149 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
162 | 150 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
163 | 151 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0 |
|
164 | 152 | } |
|
165 | 153 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
166 | 154 | swf_f0_ready = true; |
|
167 | 155 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
168 | 156 | } |
|
169 | 157 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit |
|
170 | 158 | swf_f2_ready = true; |
|
171 | 159 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 |
|
172 | 160 | } |
|
173 | 161 | break; |
|
174 | 162 | |
|
175 | 163 | //***** |
|
176 | 164 | // SBM2 |
|
177 | 165 | case(LFR_MODE_SBM2): |
|
178 | 166 | if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit |
|
179 | 167 | // (1) change the receiving buffer for the waveform picker |
|
180 | 168 | ring_node_to_send_cwf_f2 = current_ring_node_f2; |
|
181 | 169 | current_ring_node_f2 = current_ring_node_f2->next; |
|
182 | 170 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; |
|
183 | 171 | // (2) send an event for the waveforms transmission |
|
184 | 172 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
185 | 173 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
186 | 174 | } |
|
187 | 175 | if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit |
|
188 | 176 | swf_f0_ready = true; |
|
189 | 177 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0 |
|
190 | 178 | } |
|
191 | 179 | if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit |
|
192 | 180 | swf_f1_ready = true; |
|
193 | 181 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0 |
|
194 | 182 | } |
|
195 | 183 | break; |
|
196 | 184 | |
|
197 | 185 | //******** |
|
198 | 186 | // DEFAULT |
|
199 | 187 | default: |
|
200 | 188 | break; |
|
201 | 189 | } |
|
202 | 190 | } |
|
203 | 191 | |
|
204 | 192 | //************ |
|
205 | 193 | // RTEMS TASKS |
|
206 | 194 | |
|
207 | 195 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
208 | 196 | { |
|
209 | 197 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
210 | 198 | * |
|
211 | 199 | * @param unused is the starting argument of the RTEMS task |
|
212 | 200 | * |
|
213 | 201 | * The following data packets are sent by this task: |
|
214 | 202 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
215 | 203 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
216 | 204 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
217 | 205 | * |
|
218 | 206 | */ |
|
219 | 207 | |
|
220 | 208 | rtems_event_set event_out; |
|
221 | 209 | rtems_id queue_id; |
|
222 | 210 | rtems_status_code status; |
|
223 | 211 | |
|
224 | 212 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
225 | 213 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
226 | 214 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
227 | 215 | |
|
228 | 216 | init_waveforms(); |
|
229 | 217 | |
|
230 | 218 | status = get_message_queue_id_send( &queue_id ); |
|
231 | 219 | if (status != RTEMS_SUCCESSFUL) |
|
232 | 220 | { |
|
233 | 221 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
234 | 222 | } |
|
235 | 223 | |
|
236 | 224 | BOOT_PRINTF("in WFRM ***\n") |
|
237 | 225 | |
|
238 | 226 | while(1){ |
|
239 | 227 | // wait for an RTEMS_EVENT |
|
240 | 228 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
241 | 229 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
242 | 230 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
243 | 231 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
244 | 232 | { |
|
245 | 233 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
246 | 234 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
247 | 235 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
248 | 236 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
249 | 237 | } |
|
250 | 238 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
251 | 239 | { |
|
252 | 240 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
253 | 241 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
254 | 242 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
255 | 243 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
256 | 244 | } |
|
257 | 245 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
258 | 246 | { |
|
259 | 247 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
260 | 248 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
261 | 249 | send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
262 | 250 | send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
263 | 251 | } |
|
264 | 252 | } |
|
265 | 253 | } |
|
266 | 254 | |
|
267 | 255 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
268 | 256 | { |
|
269 | 257 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
270 | 258 | * |
|
271 | 259 | * @param unused is the starting argument of the RTEMS task |
|
272 | 260 | * |
|
273 | 261 | * The following data packet is sent by this task: |
|
274 | 262 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
275 | 263 | * |
|
276 | 264 | */ |
|
277 | 265 | |
|
278 | 266 | rtems_event_set event_out; |
|
279 | 267 | rtems_id queue_id; |
|
280 | 268 | rtems_status_code status; |
|
281 | 269 | |
|
282 | 270 | init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 ); |
|
283 | 271 | init_header_continuous_cwf3_light_table( headerCWF_F3_light ); |
|
284 | 272 | |
|
285 | 273 | status = get_message_queue_id_send( &queue_id ); |
|
286 | 274 | if (status != RTEMS_SUCCESSFUL) |
|
287 | 275 | { |
|
288 | 276 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
289 | 277 | } |
|
290 | 278 | |
|
291 | 279 | BOOT_PRINTF("in CWF3 ***\n") |
|
292 | 280 | |
|
293 | 281 | while(1){ |
|
294 | 282 | // wait for an RTEMS_EVENT |
|
295 | 283 | rtems_event_receive( RTEMS_EVENT_0, |
|
296 | 284 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
297 | 285 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
298 | 286 | { |
|
299 | 287 | PRINTF("send CWF_LONG_F3\n") |
|
300 | 288 | } |
|
301 | 289 | else |
|
302 | 290 | { |
|
303 | 291 | PRINTF("send CWF_F3 (light)\n") |
|
304 | 292 | } |
|
305 | 293 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { |
|
306 | 294 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
307 | 295 | { |
|
308 | 296 | send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
309 | 297 | } |
|
310 | 298 | else |
|
311 | 299 | { |
|
312 | 300 | send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id ); |
|
313 | 301 | } |
|
314 | 302 | } |
|
315 | 303 | else |
|
316 | 304 | { |
|
317 | 305 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
318 | 306 | { |
|
319 | 307 | send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); |
|
320 | 308 | } |
|
321 | 309 | else |
|
322 | 310 | { |
|
323 | 311 | send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id ); |
|
324 | 312 | } |
|
325 | 313 | |
|
326 | 314 | } |
|
327 | 315 | } |
|
328 | 316 | } |
|
329 | 317 | |
|
330 | 318 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
331 | 319 | { |
|
332 | 320 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
333 | 321 | * |
|
334 | 322 | * @param unused is the starting argument of the RTEMS task |
|
335 | 323 | * |
|
336 | 324 | * The following data packet is sent by this function: |
|
337 | 325 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
338 | 326 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
339 | 327 | * |
|
340 | 328 | */ |
|
341 | 329 | |
|
342 | 330 | rtems_event_set event_out; |
|
343 | 331 | rtems_id queue_id; |
|
344 | 332 | rtems_status_code status; |
|
345 | 333 | |
|
346 | 334 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
347 | 335 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
348 | 336 | |
|
349 | 337 | status = get_message_queue_id_send( &queue_id ); |
|
350 | 338 | if (status != RTEMS_SUCCESSFUL) |
|
351 | 339 | { |
|
352 | 340 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
353 | 341 | } |
|
354 | 342 | |
|
355 | 343 | BOOT_PRINTF("in CWF2 ***\n") |
|
356 | 344 | |
|
357 | 345 | while(1){ |
|
358 | 346 | // wait for an RTEMS_EVENT |
|
359 | 347 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
360 | 348 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
361 | 349 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
362 | 350 | { |
|
363 | 351 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
364 | 352 | } |
|
365 | 353 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
366 | 354 | { |
|
367 | 355 | send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
368 | 356 | // launch snapshot extraction if needed |
|
369 | 357 | if (extractSWF == true) |
|
370 | 358 | { |
|
371 | 359 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
372 | 360 | // extract the snapshot |
|
373 | 361 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 ); |
|
374 | 362 | // send the snapshot when built |
|
375 | 363 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
376 | 364 | extractSWF = false; |
|
377 | 365 | } |
|
378 | 366 | if (swf_f0_ready && swf_f1_ready) |
|
379 | 367 | { |
|
380 | 368 | extractSWF = true; |
|
381 | 369 | swf_f0_ready = false; |
|
382 | 370 | swf_f1_ready = false; |
|
383 | 371 | } |
|
384 | 372 | } |
|
385 | 373 | } |
|
386 | 374 | } |
|
387 | 375 | |
|
388 | 376 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
389 | 377 | { |
|
390 | 378 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
391 | 379 | * |
|
392 | 380 | * @param unused is the starting argument of the RTEMS task |
|
393 | 381 | * |
|
394 | 382 | * The following data packet is sent by this function: |
|
395 | 383 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
396 | 384 | * |
|
397 | 385 | */ |
|
398 | 386 | |
|
399 | 387 | rtems_event_set event_out; |
|
400 | 388 | rtems_id queue_id; |
|
401 | 389 | rtems_status_code status; |
|
402 | 390 | |
|
403 | 391 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
404 | 392 | |
|
405 | 393 | status = get_message_queue_id_send( &queue_id ); |
|
406 | 394 | if (status != RTEMS_SUCCESSFUL) |
|
407 | 395 | { |
|
408 | 396 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
409 | 397 | } |
|
410 | 398 | |
|
411 | 399 | BOOT_PRINTF("in CWF1 ***\n") |
|
412 | 400 | |
|
413 | 401 | while(1){ |
|
414 | 402 | // wait for an RTEMS_EVENT |
|
415 | 403 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
416 | 404 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
417 | 405 | send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
418 | 406 | // launch snapshot extraction if needed |
|
419 | 407 | if (extractSWF == true) |
|
420 | 408 | { |
|
421 | 409 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1; |
|
422 | 410 | // launch the snapshot extraction |
|
423 | 411 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); |
|
424 | 412 | extractSWF = false; |
|
425 | 413 | } |
|
426 | 414 | if (swf_f0_ready == true) |
|
427 | 415 | { |
|
428 | 416 | extractSWF = true; |
|
429 | 417 | swf_f0_ready = false; // this step shall be executed only one time |
|
430 | 418 | } |
|
431 | 419 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction |
|
432 | 420 | { |
|
433 | 421 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); |
|
434 | 422 | swf_f1_ready = false; |
|
435 | 423 | swf_f2_ready = false; |
|
436 | 424 | } |
|
437 | 425 | } |
|
438 | 426 | } |
|
439 | 427 | |
|
440 | 428 | rtems_task swbd_task(rtems_task_argument argument) |
|
441 | 429 | { |
|
442 | 430 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
443 | 431 | * |
|
444 | 432 | * @param unused is the starting argument of the RTEMS task |
|
445 | 433 | * |
|
446 | 434 | */ |
|
447 | 435 | |
|
448 | 436 | rtems_event_set event_out; |
|
449 | 437 | |
|
450 | 438 | BOOT_PRINTF("in SWBD ***\n") |
|
451 | 439 | |
|
452 | 440 | while(1){ |
|
453 | 441 | // wait for an RTEMS_EVENT |
|
454 | 442 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
455 | 443 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
456 | 444 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
457 | 445 | { |
|
458 | 446 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 ); |
|
459 | 447 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
460 | 448 | } |
|
461 | 449 | else |
|
462 | 450 | { |
|
463 | 451 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
464 | 452 | } |
|
465 | 453 | } |
|
466 | 454 | } |
|
467 | 455 | |
|
468 | 456 | //****************** |
|
469 | 457 | // general functions |
|
470 | 458 | void init_waveforms( void ) |
|
471 | 459 | { |
|
472 | 460 | int i = 0; |
|
473 | 461 | |
|
474 | 462 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
475 | 463 | { |
|
476 | 464 | //*** |
|
477 | 465 | // F0 |
|
478 | 466 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // |
|
479 | 467 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // |
|
480 | 468 | // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // |
|
481 | 469 | |
|
482 | 470 | //*** |
|
483 | 471 | // F1 |
|
484 | 472 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111; |
|
485 | 473 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333; |
|
486 | 474 | // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
487 | 475 | |
|
488 | 476 | //*** |
|
489 | 477 | // F2 |
|
490 | 478 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333; |
|
491 | 479 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; |
|
492 | 480 | // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
493 | 481 | |
|
494 | 482 | //*** |
|
495 | 483 | // F3 |
|
496 | 484 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; |
|
497 | 485 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; |
|
498 | 486 | // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; |
|
499 | 487 | } |
|
500 | 488 | } |
|
501 | 489 | |
|
502 | 490 | void init_waveform_rings( void ) |
|
503 | 491 | { |
|
504 | 492 | unsigned char i; |
|
505 | 493 | |
|
506 | 494 | // F0 RING |
|
507 | 495 | waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1]; |
|
508 | 496 | waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1]; |
|
509 | 497 | waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0]; |
|
510 | 498 | |
|
511 | 499 | waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0]; |
|
512 | 500 | waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2]; |
|
513 | 501 | waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0]; |
|
514 | 502 | |
|
515 | 503 | for(i=1; i<NB_RING_NODES_F0-1; i++) |
|
516 | 504 | { |
|
517 | 505 | waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1]; |
|
518 | 506 | waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1]; |
|
519 | 507 | waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0]; |
|
520 | 508 | } |
|
521 | 509 | |
|
522 | 510 | // F1 RING |
|
523 | 511 | waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1]; |
|
524 | 512 | waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1]; |
|
525 | 513 | waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0]; |
|
526 | 514 | |
|
527 | 515 | waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0]; |
|
528 | 516 | waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2]; |
|
529 | 517 | waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0]; |
|
530 | 518 | |
|
531 | 519 | for(i=1; i<NB_RING_NODES_F1-1; i++) |
|
532 | 520 | { |
|
533 | 521 | waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1]; |
|
534 | 522 | waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1]; |
|
535 | 523 | waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0]; |
|
536 | 524 | } |
|
537 | 525 | |
|
538 | 526 | // F2 RING |
|
539 | 527 | waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1]; |
|
540 | 528 | waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1]; |
|
541 | 529 | waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0]; |
|
542 | 530 | |
|
543 | 531 | waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0]; |
|
544 | 532 | waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2]; |
|
545 | 533 | waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0]; |
|
546 | 534 | |
|
547 | 535 | for(i=1; i<NB_RING_NODES_F2-1; i++) |
|
548 | 536 | { |
|
549 | 537 | waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1]; |
|
550 | 538 | waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1]; |
|
551 | 539 | waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0]; |
|
552 | 540 | } |
|
553 | 541 | |
|
554 | 542 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
555 | 543 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
556 | 544 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
557 | 545 | |
|
558 | 546 | } |
|
559 | 547 | |
|
560 | 548 | void reset_current_ring_nodes( void ) |
|
561 | 549 | { |
|
562 | 550 | current_ring_node_f0 = waveform_ring_f0; |
|
563 | 551 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
564 | 552 | |
|
565 | 553 | current_ring_node_f1 = waveform_ring_f1; |
|
566 | 554 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
567 | 555 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
568 | 556 | |
|
569 | 557 | current_ring_node_f2 = waveform_ring_f2; |
|
570 | 558 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
571 | 559 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
572 | 560 | } |
|
573 | 561 | |
|
574 | 562 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
575 | 563 | { |
|
576 | 564 | unsigned char i; |
|
577 | 565 | |
|
578 | 566 | for (i=0; i<7; i++) |
|
579 | 567 | { |
|
580 | 568 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
581 | 569 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
582 | 570 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
583 | 571 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
584 | 572 | headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
585 | 573 | headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
586 | 574 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
587 | 575 | if (i == 6) |
|
588 | 576 | { |
|
589 | 577 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
590 | 578 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
591 | 579 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
592 | 580 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
593 | 581 | } |
|
594 | 582 | else |
|
595 | 583 | { |
|
596 | 584 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
597 | 585 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
598 | 586 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
599 | 587 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
600 | 588 | } |
|
601 | 589 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
602 | 590 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
603 | 591 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
604 | 592 | // DATA FIELD HEADER |
|
605 | 593 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
606 | 594 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
607 | 595 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
608 | 596 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
609 | 597 | // AUXILIARY DATA HEADER |
|
610 | 598 | headerSWF[ i ].time[0] = 0x00; |
|
611 | 599 | headerSWF[ i ].time[0] = 0x00; |
|
612 | 600 | headerSWF[ i ].time[0] = 0x00; |
|
613 | 601 | headerSWF[ i ].time[0] = 0x00; |
|
614 | 602 | headerSWF[ i ].time[0] = 0x00; |
|
615 | 603 | headerSWF[ i ].time[0] = 0x00; |
|
616 | 604 | headerSWF[ i ].sid = sid; |
|
617 | 605 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
618 | 606 | } |
|
619 | 607 | return LFR_SUCCESSFUL; |
|
620 | 608 | } |
|
621 | 609 | |
|
622 | 610 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
623 | 611 | { |
|
624 | 612 | unsigned int i; |
|
625 | 613 | |
|
626 | 614 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) |
|
627 | 615 | { |
|
628 | 616 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
629 | 617 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
630 | 618 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
631 | 619 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
632 | 620 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
633 | 621 | { |
|
634 | 622 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
635 | 623 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
636 | 624 | } |
|
637 | 625 | else |
|
638 | 626 | { |
|
639 | 627 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
640 | 628 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
641 | 629 | } |
|
642 | 630 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
643 | 631 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
644 | 632 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
645 | 633 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
646 | 634 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
647 | 635 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
648 | 636 | // DATA FIELD HEADER |
|
649 | 637 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
650 | 638 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
651 | 639 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
652 | 640 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
653 | 641 | // AUXILIARY DATA HEADER |
|
654 | 642 | headerCWF[ i ].sid = sid; |
|
655 | 643 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
656 | 644 | headerCWF[ i ].time[0] = 0x00; |
|
657 | 645 | headerCWF[ i ].time[0] = 0x00; |
|
658 | 646 | headerCWF[ i ].time[0] = 0x00; |
|
659 | 647 | headerCWF[ i ].time[0] = 0x00; |
|
660 | 648 | headerCWF[ i ].time[0] = 0x00; |
|
661 | 649 | headerCWF[ i ].time[0] = 0x00; |
|
662 | 650 | } |
|
663 | 651 | return LFR_SUCCESSFUL; |
|
664 | 652 | } |
|
665 | 653 | |
|
666 | 654 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
667 | 655 | { |
|
668 | 656 | unsigned int i; |
|
669 | 657 | |
|
670 | 658 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) |
|
671 | 659 | { |
|
672 | 660 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
673 | 661 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
674 | 662 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
675 | 663 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
676 | 664 | |
|
677 | 665 | headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
678 | 666 | headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
679 | 667 | |
|
680 | 668 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
681 | 669 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
682 | 670 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
683 | 671 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
684 | 672 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
685 | 673 | |
|
686 | 674 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
687 | 675 | // DATA FIELD HEADER |
|
688 | 676 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
689 | 677 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
690 | 678 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
691 | 679 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
692 | 680 | // AUXILIARY DATA HEADER |
|
693 | 681 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
694 | 682 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
695 | 683 | headerCWF[ i ].time[0] = 0x00; |
|
696 | 684 | headerCWF[ i ].time[0] = 0x00; |
|
697 | 685 | headerCWF[ i ].time[0] = 0x00; |
|
698 | 686 | headerCWF[ i ].time[0] = 0x00; |
|
699 | 687 | headerCWF[ i ].time[0] = 0x00; |
|
700 | 688 | headerCWF[ i ].time[0] = 0x00; |
|
701 | 689 | } |
|
702 | 690 | return LFR_SUCCESSFUL; |
|
703 | 691 | } |
|
704 | 692 | |
|
705 | 693 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
706 | 694 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
707 | 695 | { |
|
708 | 696 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
709 | 697 | * |
|
710 | 698 | * @param waveform points to the buffer containing the data that will be send. |
|
711 | 699 | * @param sid is the source identifier of the data that will be sent. |
|
712 | 700 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
713 | 701 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
714 | 702 | * contain information to setup the transmission of the data packets. |
|
715 | 703 | * |
|
716 | 704 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
717 | 705 | * |
|
718 | 706 | */ |
|
719 | 707 | |
|
720 | 708 | unsigned int i; |
|
721 | 709 | int ret; |
|
722 | 710 | unsigned int coarseTime; |
|
723 | 711 | unsigned int fineTime; |
|
724 | 712 | rtems_status_code status; |
|
725 | 713 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
726 | 714 | |
|
727 | 715 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header |
|
728 | 716 | spw_ioctl_send_SWF.options = 0; |
|
729 | 717 | |
|
730 | 718 | ret = LFR_DEFAULT; |
|
731 | 719 | |
|
732 | 720 | coarseTime = waveform[0]; |
|
733 | 721 | fineTime = waveform[1]; |
|
734 | 722 | |
|
735 | 723 | for (i=0; i<7; i++) // send waveform |
|
736 | 724 | { |
|
737 | 725 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
738 | 726 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
739 | 727 | // BUILD THE DATA |
|
740 | 728 | if (i==6) { |
|
741 | 729 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
742 | 730 | } |
|
743 | 731 | else { |
|
744 | 732 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
745 | 733 | } |
|
746 | 734 | // SET PACKET SEQUENCE COUNTER |
|
747 | 735 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); |
|
748 | 736 | // SET PACKET TIME |
|
749 | 737 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime ); |
|
750 | 738 | // |
|
751 | 739 | headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0]; |
|
752 | 740 | headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1]; |
|
753 | 741 | headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2]; |
|
754 | 742 | headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3]; |
|
755 | 743 | headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4]; |
|
756 | 744 | headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5]; |
|
757 | 745 | // SEND PACKET |
|
758 | 746 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
759 | 747 | if (status != RTEMS_SUCCESSFUL) { |
|
760 | 748 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
761 | 749 | ret = LFR_DEFAULT; |
|
762 | 750 | } |
|
763 | 751 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds |
|
764 | 752 | } |
|
765 | 753 | |
|
766 | 754 | return ret; |
|
767 | 755 | } |
|
768 | 756 | |
|
769 | 757 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
770 | 758 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
771 | 759 | { |
|
772 | 760 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
773 | 761 | * |
|
774 | 762 | * @param waveform points to the buffer containing the data that will be send. |
|
775 | 763 | * @param sid is the source identifier of the data that will be sent. |
|
776 | 764 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
777 | 765 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
778 | 766 | * contain information to setup the transmission of the data packets. |
|
779 | 767 | * |
|
780 | 768 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
781 | 769 | * |
|
782 | 770 | */ |
|
783 | 771 | |
|
784 | 772 | unsigned int i; |
|
785 | 773 | int ret; |
|
786 | 774 | unsigned int coarseTime; |
|
787 | 775 | unsigned int fineTime; |
|
788 | 776 | rtems_status_code status; |
|
789 | 777 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
790 | 778 | |
|
791 | 779 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
792 | 780 | spw_ioctl_send_CWF.options = 0; |
|
793 | 781 | |
|
794 | 782 | ret = LFR_DEFAULT; |
|
795 | 783 | |
|
796 | 784 | coarseTime = waveform[0]; |
|
797 | 785 | fineTime = waveform[1]; |
|
798 | 786 | |
|
799 | 787 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
800 | 788 | { |
|
801 | 789 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
802 | 790 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
803 | 791 | // BUILD THE DATA |
|
804 | 792 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
805 | 793 | // SET PACKET SEQUENCE COUNTER |
|
806 | 794 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); |
|
807 | 795 | // SET PACKET TIME |
|
808 | 796 | compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime); |
|
809 | 797 | // |
|
810 | 798 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
811 | 799 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
812 | 800 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
813 | 801 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
814 | 802 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
815 | 803 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
816 | 804 | // SEND PACKET |
|
817 | 805 | if (sid == SID_NORM_CWF_LONG_F3) |
|
818 | 806 | { |
|
819 | 807 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
820 | 808 | if (status != RTEMS_SUCCESSFUL) { |
|
821 | 809 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
822 | 810 | ret = LFR_DEFAULT; |
|
823 | 811 | } |
|
824 | 812 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
825 | 813 | } |
|
826 | 814 | else |
|
827 | 815 | { |
|
828 | 816 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
829 | 817 | if (status != RTEMS_SUCCESSFUL) { |
|
830 | 818 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
831 | 819 | ret = LFR_DEFAULT; |
|
832 | 820 | } |
|
833 | 821 | } |
|
834 | 822 | } |
|
835 | 823 | |
|
836 | 824 | return ret; |
|
837 | 825 | } |
|
838 | 826 | |
|
839 | 827 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
840 | 828 | { |
|
841 | 829 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
842 | 830 | * |
|
843 | 831 | * @param waveform points to the buffer containing the data that will be send. |
|
844 | 832 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
845 | 833 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
846 | 834 | * contain information to setup the transmission of the data packets. |
|
847 | 835 | * |
|
848 | 836 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
849 | 837 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
850 | 838 | * |
|
851 | 839 | */ |
|
852 | 840 | |
|
853 | 841 | unsigned int i; |
|
854 | 842 | int ret; |
|
855 | 843 | unsigned int coarseTime; |
|
856 | 844 | unsigned int fineTime; |
|
857 | 845 | rtems_status_code status; |
|
858 | 846 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
859 | 847 | char *sample; |
|
860 | 848 | |
|
861 | 849 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
862 | 850 | spw_ioctl_send_CWF.options = 0; |
|
863 | 851 | |
|
864 | 852 | ret = LFR_DEFAULT; |
|
865 | 853 | |
|
866 | 854 | //********************** |
|
867 | 855 | // BUILD CWF3_light DATA |
|
868 | 856 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
869 | 857 | { |
|
870 | 858 | sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; |
|
871 | 859 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; |
|
872 | 860 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; |
|
873 | 861 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; |
|
874 | 862 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; |
|
875 | 863 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; |
|
876 | 864 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; |
|
877 | 865 | } |
|
878 | 866 | |
|
879 | 867 | coarseTime = waveform[0]; |
|
880 | 868 | fineTime = waveform[1]; |
|
881 | 869 | |
|
882 | 870 | //********************* |
|
883 | 871 | // SEND CWF3_light DATA |
|
884 | 872 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
885 | 873 | { |
|
886 | 874 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES]; |
|
887 | 875 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
888 | 876 | // BUILD THE DATA |
|
889 | 877 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
890 | 878 | // SET PACKET SEQUENCE COUNTER |
|
891 | 879 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); |
|
892 | 880 | // SET PACKET TIME |
|
893 | 881 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime ); |
|
894 | 882 | // |
|
895 | 883 | headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0]; |
|
896 | 884 | headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1]; |
|
897 | 885 | headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2]; |
|
898 | 886 | headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3]; |
|
899 | 887 | headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4]; |
|
900 | 888 | headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5]; |
|
901 | 889 | // SEND PACKET |
|
902 | 890 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
903 | 891 | if (status != RTEMS_SUCCESSFUL) { |
|
904 | 892 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
905 | 893 | ret = LFR_DEFAULT; |
|
906 | 894 | } |
|
907 | 895 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
908 | 896 | } |
|
909 | 897 | |
|
910 | 898 | return ret; |
|
911 | 899 | } |
|
912 | 900 | |
|
913 | 901 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
914 | 902 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
915 | 903 | { |
|
916 | 904 | unsigned long long int acquisitionTimeAsLong; |
|
917 | 905 | unsigned char localAcquisitionTime[6]; |
|
918 | 906 | double deltaT; |
|
919 | 907 | |
|
920 | 908 | deltaT = 0.; |
|
921 | 909 | |
|
922 | 910 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 ); |
|
923 | 911 | localAcquisitionTime[1] = (unsigned char) ( coarseTime ); |
|
924 | 912 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 ); |
|
925 | 913 | localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 ); |
|
926 | 914 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 ); |
|
927 | 915 | localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 ); |
|
928 | 916 | |
|
929 | 917 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
930 | 918 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
931 | 919 | + ( localAcquisitionTime[2] << 24 ) |
|
932 | 920 | + ( localAcquisitionTime[3] << 16 ) |
|
933 | 921 | + ( localAcquisitionTime[4] << 8 ) |
|
934 | 922 | + ( localAcquisitionTime[5] ); |
|
935 | 923 | |
|
936 | 924 | switch( sid ) |
|
937 | 925 | { |
|
938 | 926 | case SID_NORM_SWF_F0: |
|
939 | 927 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
940 | 928 | break; |
|
941 | 929 | |
|
942 | 930 | case SID_NORM_SWF_F1: |
|
943 | 931 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
944 | 932 | break; |
|
945 | 933 | |
|
946 | 934 | case SID_NORM_SWF_F2: |
|
947 | 935 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
948 | 936 | break; |
|
949 | 937 | |
|
950 | 938 | case SID_SBM1_CWF_F1: |
|
951 | 939 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
952 | 940 | break; |
|
953 | 941 | |
|
954 | 942 | case SID_SBM2_CWF_F2: |
|
955 | 943 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
956 | 944 | break; |
|
957 | 945 | |
|
958 | 946 | case SID_BURST_CWF_F2: |
|
959 | 947 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
960 | 948 | break; |
|
961 | 949 | |
|
962 | 950 | case SID_NORM_CWF_F3: |
|
963 | 951 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
964 | 952 | break; |
|
965 | 953 | |
|
966 | 954 | case SID_NORM_CWF_LONG_F3: |
|
967 | 955 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
968 | 956 | break; |
|
969 | 957 | |
|
970 | 958 | default: |
|
971 | 959 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid) |
|
972 | 960 | deltaT = 0.; |
|
973 | 961 | break; |
|
974 | 962 | } |
|
975 | 963 | |
|
976 | 964 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
977 | 965 | // |
|
978 | 966 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
979 | 967 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
980 | 968 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
981 | 969 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
982 | 970 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
983 | 971 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
984 | 972 | |
|
985 | 973 | } |
|
986 | 974 | |
|
987 | 975 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel ) |
|
988 | 976 | { |
|
989 | 977 | unsigned int i; |
|
990 | 978 | unsigned long long int centerTime_asLong; |
|
991 | 979 | unsigned long long int acquisitionTimeF0_asLong; |
|
992 | 980 | unsigned long long int acquisitionTime_asLong; |
|
993 | 981 | unsigned long long int bufferAcquisitionTime_asLong; |
|
994 | 982 | unsigned char *ptr1; |
|
995 | 983 | unsigned char *ptr2; |
|
996 | 984 | unsigned char nb_ring_nodes; |
|
997 | 985 | unsigned long long int frequency_asLong; |
|
998 | 986 | unsigned long long int nbTicksPerSample_asLong; |
|
999 | 987 | unsigned long long int nbSamplesPart1_asLong; |
|
1000 | 988 | unsigned long long int sampleOffset_asLong; |
|
1001 | 989 | |
|
1002 | 990 | unsigned int deltaT_F0; |
|
1003 | 991 | unsigned int deltaT_F1; |
|
1004 | 992 | unsigned long long int deltaT_F2; |
|
1005 | 993 | |
|
1006 | 994 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
1007 | 995 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
1008 | 996 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
1009 | 997 | sampleOffset_asLong = 0x00; |
|
1010 | 998 | |
|
1011 | 999 | // (1) get the f0 acquisition time |
|
1012 | 1000 | build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 ); |
|
1013 | 1001 | |
|
1014 | 1002 | // (2) compute the central reference time |
|
1015 | 1003 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
1016 | 1004 | |
|
1017 | 1005 | // (3) compute the acquisition time of the current snapshot |
|
1018 | 1006 | switch(frequencyChannel) |
|
1019 | 1007 | { |
|
1020 | 1008 | case 1: // 1 is for F1 = 4096 Hz |
|
1021 | 1009 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
1022 | 1010 | nb_ring_nodes = NB_RING_NODES_F1; |
|
1023 | 1011 | frequency_asLong = 4096; |
|
1024 | 1012 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
1025 | 1013 | break; |
|
1026 | 1014 | case 2: // 2 is for F2 = 256 Hz |
|
1027 | 1015 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
1028 | 1016 | nb_ring_nodes = NB_RING_NODES_F2; |
|
1029 | 1017 | frequency_asLong = 256; |
|
1030 | 1018 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
1031 | 1019 | break; |
|
1032 | 1020 | default: |
|
1033 | 1021 | acquisitionTime_asLong = centerTime_asLong; |
|
1034 | 1022 | frequency_asLong = 256; |
|
1035 | 1023 | nbTicksPerSample_asLong = 256; |
|
1036 | 1024 | break; |
|
1037 | 1025 | } |
|
1038 | 1026 | |
|
1039 | 1027 | //**************************************************************************** |
|
1040 | 1028 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
1041 | 1029 | for (i=0; i<nb_ring_nodes; i++) |
|
1042 | 1030 | { |
|
1043 | 1031 | PRINTF1("%d ... ", i) |
|
1044 | 1032 | build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send ); |
|
1045 | 1033 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
1046 | 1034 | { |
|
1047 | 1035 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
1048 | 1036 | break; |
|
1049 | 1037 | } |
|
1050 | 1038 | ring_node_to_send = ring_node_to_send->previous; |
|
1051 | 1039 | } |
|
1052 | 1040 | |
|
1053 | 1041 | // (5) compute the number of samples to take in the current buffer |
|
1054 | 1042 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
1055 | 1043 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
1056 | 1044 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
1057 | 1045 | |
|
1058 | 1046 | // (6) compute the final acquisition time |
|
1059 | 1047 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
1060 | 1048 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
1061 | 1049 | |
|
1062 | 1050 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
1063 | 1051 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
1064 | 1052 | ptr2 = (unsigned char*) wf_snap_extracted; |
|
1065 | 1053 | ptr2[0] = ptr1[ 2 + 2 ]; |
|
1066 | 1054 | ptr2[1] = ptr1[ 3 + 2 ]; |
|
1067 | 1055 | ptr2[2] = ptr1[ 0 + 2 ]; |
|
1068 | 1056 | ptr2[3] = ptr1[ 1 + 2 ]; |
|
1069 | 1057 | ptr2[4] = ptr1[ 4 + 2 ]; |
|
1070 | 1058 | ptr2[5] = ptr1[ 5 + 2 ]; |
|
1071 | 1059 | |
|
1072 | 1060 | // re set the synchronization bit |
|
1073 | 1061 | |
|
1074 | 1062 | |
|
1075 | 1063 | // copy the part 1 of the snapshot in the extracted buffer |
|
1076 | 1064 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1077 | 1065 | { |
|
1078 | 1066 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1079 | 1067 | ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET]; |
|
1080 | 1068 | } |
|
1081 | 1069 | // copy the part 2 of the snapshot in the extracted buffer |
|
1082 | 1070 | ring_node_to_send = ring_node_to_send->next; |
|
1083 | 1071 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1084 | 1072 | { |
|
1085 | 1073 | wf_snap_extracted[i + TIME_OFFSET] = |
|
1086 | 1074 | ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET]; |
|
1087 | 1075 | } |
|
1088 | 1076 | } |
|
1089 | 1077 | |
|
1090 | 1078 | void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node ) |
|
1091 | 1079 | { |
|
1092 | 1080 | unsigned char *acquisitionTimeCharPtr; |
|
1093 | 1081 | |
|
1094 | 1082 | acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address; |
|
1095 | 1083 | |
|
1096 | 1084 | *acquisitionTimeAslong = 0x00; |
|
1097 | 1085 | *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 ) |
|
1098 | 1086 | + ( acquisitionTimeCharPtr[1] << 16 ) |
|
1099 | 1087 | + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
1100 | 1088 | + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 ) |
|
1101 | 1089 | + ( acquisitionTimeCharPtr[4] << 8 ) |
|
1102 | 1090 | + ( acquisitionTimeCharPtr[5] ); |
|
1103 | 1091 | } |
|
1104 | 1092 | |
|
1105 | 1093 | //************** |
|
1106 | 1094 | // wfp registers |
|
1107 | 1095 | void reset_wfp_burst_enable(void) |
|
1108 | 1096 | { |
|
1109 | 1097 | /** This function resets the waveform picker burst_enable register. |
|
1110 | 1098 | * |
|
1111 | 1099 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1112 | 1100 | * |
|
1113 | 1101 | */ |
|
1114 | 1102 | |
|
1115 | 1103 | waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1116 | 1104 | } |
|
1117 | 1105 | |
|
1118 | 1106 | void reset_wfp_status( void ) |
|
1119 | 1107 | { |
|
1120 | 1108 | /** This function resets the waveform picker status register. |
|
1121 | 1109 | * |
|
1122 | 1110 | * All status bits are set to 0 [new_err full_err full]. |
|
1123 | 1111 | * |
|
1124 | 1112 | */ |
|
1125 | 1113 | |
|
1126 | 1114 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1127 | 1115 | } |
|
1128 | 1116 | |
|
1129 | 1117 | void reset_waveform_picker_regs(void) |
|
1130 | 1118 | { |
|
1131 | 1119 | /** This function resets the waveform picker module registers. |
|
1132 | 1120 | * |
|
1133 | 1121 | * The registers affected by this function are located at the following offset addresses: |
|
1134 | 1122 | * - 0x00 data_shaping |
|
1135 | 1123 | * - 0x04 run_burst_enable |
|
1136 | 1124 | * - 0x08 addr_data_f0 |
|
1137 | 1125 | * - 0x0C addr_data_f1 |
|
1138 | 1126 | * - 0x10 addr_data_f2 |
|
1139 | 1127 | * - 0x14 addr_data_f3 |
|
1140 | 1128 | * - 0x18 status |
|
1141 | 1129 | * - 0x1C delta_snapshot |
|
1142 | 1130 | * - 0x20 delta_f0 |
|
1143 | 1131 | * - 0x24 delta_f0_2 |
|
1144 | 1132 | * - 0x28 delta_f1 |
|
1145 | 1133 | * - 0x2c delta_f2 |
|
1146 | 1134 | * - 0x30 nb_data_by_buffer |
|
1147 | 1135 | * - 0x34 nb_snapshot_param |
|
1148 | 1136 | * - 0x38 start_date |
|
1149 | 1137 | * - 0x3c nb_word_in_buffer |
|
1150 | 1138 | * |
|
1151 | 1139 | */ |
|
1152 | 1140 | |
|
1153 | 1141 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1154 | 1142 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1155 | 1143 | waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08 |
|
1156 | 1144 | waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c |
|
1157 | 1145 | waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 |
|
1158 | 1146 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14 |
|
1159 | 1147 | reset_wfp_status(); // 0x18 |
|
1160 | 1148 | // |
|
1161 | 1149 | set_wfp_delta_snapshot(); // 0x1c |
|
1162 | 1150 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1163 | 1151 | set_wfp_delta_f1(); // 0x28 |
|
1164 | 1152 | set_wfp_delta_f2(); // 0x2c |
|
1165 | 1153 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1166 | 1154 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1167 | 1155 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1168 | 1156 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1169 | 1157 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1170 | 1158 | // 2688 = 8 * 336 |
|
1171 | 1159 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1172 | 1160 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1173 | 1161 | waveform_picker_regs->start_date = 0x00; // 0x38 |
|
1174 | 1162 | waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066 |
|
1175 | 1163 | } |
|
1176 | 1164 | |
|
1177 | 1165 | void set_wfp_data_shaping( void ) |
|
1178 | 1166 | { |
|
1179 | 1167 | /** This function sets the data_shaping register of the waveform picker module. |
|
1180 | 1168 | * |
|
1181 | 1169 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1182 | 1170 | * bw_sp0_sp1_r0_r1 |
|
1183 | 1171 | * |
|
1184 | 1172 | */ |
|
1185 | 1173 | |
|
1186 | 1174 | unsigned char data_shaping; |
|
1187 | 1175 | |
|
1188 | 1176 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1189 | 1177 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1190 | 1178 | |
|
1191 | 1179 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
1192 | 1180 | |
|
1193 | 1181 | waveform_picker_regs->data_shaping = |
|
1194 | 1182 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
1195 | 1183 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
1196 | 1184 | + ( (data_shaping & 0x04) ) // SP1 |
|
1197 | 1185 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
1198 | 1186 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
1199 | 1187 | } |
|
1200 | 1188 | |
|
1201 | 1189 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1202 | 1190 | { |
|
1203 | 1191 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1204 | 1192 | * |
|
1205 | 1193 | * @param mode is the LFR mode to launch. |
|
1206 | 1194 | * |
|
1207 | 1195 | * The burst bits shall be before the enable bits. |
|
1208 | 1196 | * |
|
1209 | 1197 | */ |
|
1210 | 1198 | |
|
1211 | 1199 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1212 | 1200 | // the burst bits shall be set first, before the enable bits |
|
1213 | 1201 | switch(mode) { |
|
1214 | 1202 | case(LFR_MODE_NORMAL): |
|
1215 | 1203 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1216 | 1204 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1217 | 1205 | break; |
|
1218 | 1206 | case(LFR_MODE_BURST): |
|
1219 | 1207 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1220 | 1208 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1221 | 1209 | break; |
|
1222 | 1210 | case(LFR_MODE_SBM1): |
|
1223 | 1211 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1224 | 1212 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1225 | 1213 | break; |
|
1226 | 1214 | case(LFR_MODE_SBM2): |
|
1227 | 1215 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1228 | 1216 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1229 | 1217 | break; |
|
1230 | 1218 | default: |
|
1231 | 1219 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1232 | 1220 | break; |
|
1233 | 1221 | } |
|
1234 | 1222 | } |
|
1235 | 1223 | |
|
1236 | 1224 | void set_wfp_delta_snapshot( void ) |
|
1237 | 1225 | { |
|
1238 | 1226 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1239 | 1227 | * |
|
1240 | 1228 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1241 | 1229 | * - sy_lfr_n_swf_p[0] |
|
1242 | 1230 | * - sy_lfr_n_swf_p[1] |
|
1243 | 1231 | * |
|
1244 | 1232 | */ |
|
1245 | 1233 | |
|
1246 | 1234 | unsigned int delta_snapshot; |
|
1247 | 1235 | unsigned int delta_snapshot_in_T2; |
|
1248 | 1236 | |
|
1249 | 1237 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1250 | 1238 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1251 | 1239 | |
|
1252 | 1240 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1253 | 1241 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes |
|
1254 | 1242 | } |
|
1255 | 1243 | |
|
1256 | 1244 | void set_wfp_delta_f0_f0_2( void ) |
|
1257 | 1245 | { |
|
1258 | 1246 | unsigned int delta_snapshot; |
|
1259 | 1247 | unsigned int nb_samples_per_snapshot; |
|
1260 | 1248 | float delta_f0_in_float; |
|
1261 | 1249 | |
|
1262 | 1250 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1263 | 1251 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1264 | 1252 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1265 | 1253 | |
|
1266 | 1254 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1267 | 1255 | waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits |
|
1268 | 1256 | } |
|
1269 | 1257 | |
|
1270 | 1258 | void set_wfp_delta_f1( void ) |
|
1271 | 1259 | { |
|
1272 | 1260 | unsigned int delta_snapshot; |
|
1273 | 1261 | unsigned int nb_samples_per_snapshot; |
|
1274 | 1262 | float delta_f1_in_float; |
|
1275 | 1263 | |
|
1276 | 1264 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1277 | 1265 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1278 | 1266 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1279 | 1267 | |
|
1280 | 1268 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1281 | 1269 | } |
|
1282 | 1270 | |
|
1283 | 1271 | void set_wfp_delta_f2() |
|
1284 | 1272 | { |
|
1285 | 1273 | unsigned int delta_snapshot; |
|
1286 | 1274 | unsigned int nb_samples_per_snapshot; |
|
1287 | 1275 | |
|
1288 | 1276 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1289 | 1277 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1290 | 1278 | |
|
1291 | 1279 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1292 | 1280 | } |
|
1293 | 1281 | |
|
1294 | 1282 | //***************** |
|
1295 | 1283 | // local parameters |
|
1296 | 1284 | void set_local_nb_interrupt_f0_MAX( void ) |
|
1297 | 1285 | { |
|
1298 | 1286 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. |
|
1299 | 1287 | * |
|
1300 | 1288 | * This parameter is used for the SM validation only.\n |
|
1301 | 1289 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices |
|
1302 | 1290 | * module before launching a basic processing. |
|
1303 | 1291 | * |
|
1304 | 1292 | */ |
|
1305 | 1293 | |
|
1306 | 1294 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 |
|
1307 | 1295 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; |
|
1308 | 1296 | } |
|
1309 | 1297 | |
|
1310 | 1298 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1311 | 1299 | { |
|
1312 | 1300 | unsigned short *sequence_cnt; |
|
1313 | 1301 | unsigned short segmentation_grouping_flag; |
|
1314 | 1302 | unsigned short new_packet_sequence_control; |
|
1315 | 1303 | |
|
1316 | 1304 | if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2) |
|
1317 | 1305 | || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) ) |
|
1318 | 1306 | { |
|
1319 | 1307 | sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1320 | 1308 | } |
|
1321 | 1309 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) ) |
|
1322 | 1310 | { |
|
1323 | 1311 | sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1324 | 1312 | } |
|
1325 | 1313 | else |
|
1326 | 1314 | { |
|
1327 | 1315 | sequence_cnt = NULL; |
|
1328 | 1316 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1329 | 1317 | } |
|
1330 | 1318 | |
|
1331 | 1319 | if (sequence_cnt != NULL) |
|
1332 | 1320 | { |
|
1333 | 1321 | segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8; |
|
1334 | 1322 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1335 | 1323 | |
|
1336 | 1324 | new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ; |
|
1337 | 1325 | |
|
1338 | 1326 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1339 | 1327 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1340 | 1328 | |
|
1341 | 1329 | // increment the sequence counter for the next packet |
|
1342 | 1330 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1343 | 1331 | { |
|
1344 | 1332 | *sequence_cnt = *sequence_cnt + 1; |
|
1345 | 1333 | } |
|
1346 | 1334 | else |
|
1347 | 1335 | { |
|
1348 | 1336 | *sequence_cnt = 0; |
|
1349 | 1337 | } |
|
1350 | 1338 | } |
|
1351 | 1339 | } |
General Comments 0
You need to be logged in to leave comments.
Login now