##// END OF EJS Templates
Sync
paul -
r125:de367ad91bd0 VHDLib206
parent child
Show More
@@ -1,271 +1,271
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Sun Apr 27 14:59:58 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Sun Apr 27 16:27:36 2014
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 #############################################################################
7 #############################################################################
8
8
9 ####### Compiler, tools and options
9 ####### Compiler, tools and options
10
10
11 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS -DBOOT_MESSAGES
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES -DPRINT_TASK_STATISTICS -DBOOT_MESSAGES
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters -I../src/avf_prc
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters -I../src/avf_prc
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
20 AR = sparc-rtems-ar rcs
20 AR = sparc-rtems-ar rcs
21 RANLIB =
21 RANLIB =
22 QMAKE = /usr/bin/qmake-qt4
22 QMAKE = /usr/bin/qmake-qt4
23 TAR = tar -cf
23 TAR = tar -cf
24 COMPRESS = gzip -9f
24 COMPRESS = gzip -9f
25 COPY = cp -f
25 COPY = cp -f
26 SED = sed
26 SED = sed
27 COPY_FILE = $(COPY)
27 COPY_FILE = $(COPY)
28 COPY_DIR = $(COPY) -r
28 COPY_DIR = $(COPY) -r
29 STRIP = sparc-rtems-strip
29 STRIP = sparc-rtems-strip
30 INSTALL_FILE = install -m 644 -p
30 INSTALL_FILE = install -m 644 -p
31 INSTALL_DIR = $(COPY_DIR)
31 INSTALL_DIR = $(COPY_DIR)
32 INSTALL_PROGRAM = install -m 755 -p
32 INSTALL_PROGRAM = install -m 755 -p
33 DEL_FILE = rm -f
33 DEL_FILE = rm -f
34 SYMLINK = ln -f -s
34 SYMLINK = ln -f -s
35 DEL_DIR = rmdir
35 DEL_DIR = rmdir
36 MOVE = mv -f
36 MOVE = mv -f
37 CHK_DIR_EXISTS= test -d
37 CHK_DIR_EXISTS= test -d
38 MKDIR = mkdir -p
38 MKDIR = mkdir -p
39
39
40 ####### Output directory
40 ####### Output directory
41
41
42 OBJECTS_DIR = obj/
42 OBJECTS_DIR = obj/
43
43
44 ####### Files
44 ####### Files
45
45
46 SOURCES = ../src/wf_handler.c \
46 SOURCES = ../src/wf_handler.c \
47 ../src/tc_handler.c \
47 ../src/tc_handler.c \
48 ../src/fsw_misc.c \
48 ../src/fsw_misc.c \
49 ../src/fsw_init.c \
49 ../src/fsw_init.c \
50 ../src/fsw_globals.c \
50 ../src/fsw_globals.c \
51 ../src/fsw_spacewire.c \
51 ../src/fsw_spacewire.c \
52 ../src/tc_load_dump_parameters.c \
52 ../src/tc_load_dump_parameters.c \
53 ../src/tm_lfr_tc_exe.c \
53 ../src/tm_lfr_tc_exe.c \
54 ../src/tc_acceptance.c \
54 ../src/tc_acceptance.c \
55 ../src/basic_parameters/basic_parameters.c \
55 ../src/basic_parameters/basic_parameters.c \
56 ../src/avf_prc/fsw_processing.c \
56 ../src/avf_prc/fsw_processing.c \
57 ../src/avf_prc/avf0_prc0.c \
57 ../src/avf_prc/avf0_prc0.c \
58 ../src/avf_prc/avf1_prc1.c \
58 ../src/avf_prc/avf1_prc1.c \
59 ../src/avf_prc/avf2_prc2.c
59 ../src/avf_prc/avf2_prc2.c
60 OBJECTS = obj/wf_handler.o \
60 OBJECTS = obj/wf_handler.o \
61 obj/tc_handler.o \
61 obj/tc_handler.o \
62 obj/fsw_misc.o \
62 obj/fsw_misc.o \
63 obj/fsw_init.o \
63 obj/fsw_init.o \
64 obj/fsw_globals.o \
64 obj/fsw_globals.o \
65 obj/fsw_spacewire.o \
65 obj/fsw_spacewire.o \
66 obj/tc_load_dump_parameters.o \
66 obj/tc_load_dump_parameters.o \
67 obj/tm_lfr_tc_exe.o \
67 obj/tm_lfr_tc_exe.o \
68 obj/tc_acceptance.o \
68 obj/tc_acceptance.o \
69 obj/basic_parameters.o \
69 obj/basic_parameters.o \
70 obj/fsw_processing.o \
70 obj/fsw_processing.o \
71 obj/avf0_prc0.o \
71 obj/avf0_prc0.o \
72 obj/avf1_prc1.o \
72 obj/avf1_prc1.o \
73 obj/avf2_prc2.o
73 obj/avf2_prc2.o
74 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
74 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
75 /usr/lib64/qt4/mkspecs/common/linux.conf \
75 /usr/lib64/qt4/mkspecs/common/linux.conf \
76 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
76 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
77 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
77 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
78 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
78 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
79 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
79 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
80 /usr/lib64/qt4/mkspecs/qconfig.pri \
80 /usr/lib64/qt4/mkspecs/qconfig.pri \
81 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
81 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
82 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
82 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
83 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
83 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
84 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
84 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
85 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
85 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
86 sparc.pri \
86 sparc.pri \
87 /usr/lib64/qt4/mkspecs/features/release.prf \
87 /usr/lib64/qt4/mkspecs/features/release.prf \
88 /usr/lib64/qt4/mkspecs/features/default_post.prf \
88 /usr/lib64/qt4/mkspecs/features/default_post.prf \
89 /usr/lib64/qt4/mkspecs/features/shared.prf \
89 /usr/lib64/qt4/mkspecs/features/shared.prf \
90 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
90 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
91 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
91 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
92 /usr/lib64/qt4/mkspecs/features/resources.prf \
92 /usr/lib64/qt4/mkspecs/features/resources.prf \
93 /usr/lib64/qt4/mkspecs/features/uic.prf \
93 /usr/lib64/qt4/mkspecs/features/uic.prf \
94 /usr/lib64/qt4/mkspecs/features/yacc.prf \
94 /usr/lib64/qt4/mkspecs/features/yacc.prf \
95 /usr/lib64/qt4/mkspecs/features/lex.prf \
95 /usr/lib64/qt4/mkspecs/features/lex.prf \
96 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
96 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
97 fsw-qt.pro
97 fsw-qt.pro
98 QMAKE_TARGET = fsw
98 QMAKE_TARGET = fsw
99 DESTDIR = bin/
99 DESTDIR = bin/
100 TARGET = bin/fsw
100 TARGET = bin/fsw
101
101
102 first: all
102 first: all
103 ####### Implicit rules
103 ####### Implicit rules
104
104
105 .SUFFIXES: .o .c .cpp .cc .cxx .C
105 .SUFFIXES: .o .c .cpp .cc .cxx .C
106
106
107 .cpp.o:
107 .cpp.o:
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
109
109
110 .cc.o:
110 .cc.o:
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112
112
113 .cxx.o:
113 .cxx.o:
114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
115
115
116 .C.o:
116 .C.o:
117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
118
118
119 .c.o:
119 .c.o:
120 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
120 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
121
121
122 ####### Build rules
122 ####### Build rules
123
123
124 all: Makefile $(TARGET)
124 all: Makefile $(TARGET)
125
125
126 $(TARGET): $(OBJECTS)
126 $(TARGET): $(OBJECTS)
127 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
127 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
128 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
128 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
129
129
130 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
130 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
131 /usr/lib64/qt4/mkspecs/common/linux.conf \
131 /usr/lib64/qt4/mkspecs/common/linux.conf \
132 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
132 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
133 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
133 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
134 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
134 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
135 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
135 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
136 /usr/lib64/qt4/mkspecs/qconfig.pri \
136 /usr/lib64/qt4/mkspecs/qconfig.pri \
137 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
137 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
138 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
138 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
139 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
139 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
140 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
140 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
141 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
141 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
142 sparc.pri \
142 sparc.pri \
143 /usr/lib64/qt4/mkspecs/features/release.prf \
143 /usr/lib64/qt4/mkspecs/features/release.prf \
144 /usr/lib64/qt4/mkspecs/features/default_post.prf \
144 /usr/lib64/qt4/mkspecs/features/default_post.prf \
145 /usr/lib64/qt4/mkspecs/features/shared.prf \
145 /usr/lib64/qt4/mkspecs/features/shared.prf \
146 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
146 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
147 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
147 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
148 /usr/lib64/qt4/mkspecs/features/resources.prf \
148 /usr/lib64/qt4/mkspecs/features/resources.prf \
149 /usr/lib64/qt4/mkspecs/features/uic.prf \
149 /usr/lib64/qt4/mkspecs/features/uic.prf \
150 /usr/lib64/qt4/mkspecs/features/yacc.prf \
150 /usr/lib64/qt4/mkspecs/features/yacc.prf \
151 /usr/lib64/qt4/mkspecs/features/lex.prf \
151 /usr/lib64/qt4/mkspecs/features/lex.prf \
152 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
152 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
153 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
153 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
154 /usr/lib64/qt4/mkspecs/common/unix.conf:
154 /usr/lib64/qt4/mkspecs/common/unix.conf:
155 /usr/lib64/qt4/mkspecs/common/linux.conf:
155 /usr/lib64/qt4/mkspecs/common/linux.conf:
156 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
156 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
157 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
157 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
158 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
158 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
159 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
159 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
160 /usr/lib64/qt4/mkspecs/qconfig.pri:
160 /usr/lib64/qt4/mkspecs/qconfig.pri:
161 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
161 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
162 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
162 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
163 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
163 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
164 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
164 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
165 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
165 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
166 sparc.pri:
166 sparc.pri:
167 /usr/lib64/qt4/mkspecs/features/release.prf:
167 /usr/lib64/qt4/mkspecs/features/release.prf:
168 /usr/lib64/qt4/mkspecs/features/default_post.prf:
168 /usr/lib64/qt4/mkspecs/features/default_post.prf:
169 /usr/lib64/qt4/mkspecs/features/shared.prf:
169 /usr/lib64/qt4/mkspecs/features/shared.prf:
170 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
170 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
171 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
171 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
172 /usr/lib64/qt4/mkspecs/features/resources.prf:
172 /usr/lib64/qt4/mkspecs/features/resources.prf:
173 /usr/lib64/qt4/mkspecs/features/uic.prf:
173 /usr/lib64/qt4/mkspecs/features/uic.prf:
174 /usr/lib64/qt4/mkspecs/features/yacc.prf:
174 /usr/lib64/qt4/mkspecs/features/yacc.prf:
175 /usr/lib64/qt4/mkspecs/features/lex.prf:
175 /usr/lib64/qt4/mkspecs/features/lex.prf:
176 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
176 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
177 qmake: FORCE
177 qmake: FORCE
178 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
178 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
179
179
180 dist:
180 dist:
181 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
181 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
182 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
182 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
183
183
184
184
185 clean:compiler_clean
185 clean:compiler_clean
186 -$(DEL_FILE) $(OBJECTS)
186 -$(DEL_FILE) $(OBJECTS)
187 -$(DEL_FILE) *~ core *.core
187 -$(DEL_FILE) *~ core *.core
188
188
189
189
190 ####### Sub-libraries
190 ####### Sub-libraries
191
191
192 distclean: clean
192 distclean: clean
193 -$(DEL_FILE) $(TARGET)
193 -$(DEL_FILE) $(TARGET)
194 -$(DEL_FILE) Makefile
194 -$(DEL_FILE) Makefile
195
195
196
196
197 grmon:
197 grmon:
198 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
198 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
199
199
200 check: first
200 check: first
201
201
202 compiler_rcc_make_all:
202 compiler_rcc_make_all:
203 compiler_rcc_clean:
203 compiler_rcc_clean:
204 compiler_uic_make_all:
204 compiler_uic_make_all:
205 compiler_uic_clean:
205 compiler_uic_clean:
206 compiler_image_collection_make_all: qmake_image_collection.cpp
206 compiler_image_collection_make_all: qmake_image_collection.cpp
207 compiler_image_collection_clean:
207 compiler_image_collection_clean:
208 -$(DEL_FILE) qmake_image_collection.cpp
208 -$(DEL_FILE) qmake_image_collection.cpp
209 compiler_yacc_decl_make_all:
209 compiler_yacc_decl_make_all:
210 compiler_yacc_decl_clean:
210 compiler_yacc_decl_clean:
211 compiler_yacc_impl_make_all:
211 compiler_yacc_impl_make_all:
212 compiler_yacc_impl_clean:
212 compiler_yacc_impl_clean:
213 compiler_lex_make_all:
213 compiler_lex_make_all:
214 compiler_lex_clean:
214 compiler_lex_clean:
215 compiler_clean:
215 compiler_clean:
216
216
217 ####### Compile
217 ####### Compile
218
218
219 obj/wf_handler.o: ../src/wf_handler.c
219 obj/wf_handler.o: ../src/wf_handler.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
221
221
222 obj/tc_handler.o: ../src/tc_handler.c
222 obj/tc_handler.o: ../src/tc_handler.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
224
224
225 obj/fsw_misc.o: ../src/fsw_misc.c
225 obj/fsw_misc.o: ../src/fsw_misc.c
226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
227
227
228 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
228 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
230
230
231 obj/fsw_globals.o: ../src/fsw_globals.c
231 obj/fsw_globals.o: ../src/fsw_globals.c
232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
233
233
234 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
234 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
236
236
237 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
237 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
239
239
240 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
240 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
242
242
243 obj/tc_acceptance.o: ../src/tc_acceptance.c
243 obj/tc_acceptance.o: ../src/tc_acceptance.c
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
245
245
246 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
246 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
247 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
247 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
248
248
249 obj/fsw_processing.o: ../src/avf_prc/fsw_processing.c ../src/avf_prc/fsw_processing.h
249 obj/fsw_processing.o: ../src/avf_prc/fsw_processing.c ../src/avf_prc/fsw_processing.h
250 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/avf_prc/fsw_processing.c
250 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/avf_prc/fsw_processing.c
251
251
252 obj/avf0_prc0.o: ../src/avf_prc/avf0_prc0.c ../src/avf_prc/avf0_prc0.h \
252 obj/avf0_prc0.o: ../src/avf_prc/avf0_prc0.c ../src/avf_prc/avf0_prc0.h \
253 ../src/avf_prc/fsw_processing.h
253 ../src/avf_prc/fsw_processing.h
254 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/avf_prc/avf0_prc0.c
254 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/avf_prc/avf0_prc0.c
255
255
256 obj/avf1_prc1.o: ../src/avf_prc/avf1_prc1.c ../src/avf_prc/avf1_prc1.h \
256 obj/avf1_prc1.o: ../src/avf_prc/avf1_prc1.c ../src/avf_prc/avf1_prc1.h \
257 ../src/avf_prc/fsw_processing.h
257 ../src/avf_prc/fsw_processing.h
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/avf_prc/avf1_prc1.c
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/avf_prc/avf1_prc1.c
259
259
260 obj/avf2_prc2.o: ../src/avf_prc/avf2_prc2.c ../src/avf_prc/avf2_prc2.h \
260 obj/avf2_prc2.o: ../src/avf_prc/avf2_prc2.c ../src/avf_prc/avf2_prc2.h \
261 ../src/avf_prc/fsw_processing.h
261 ../src/avf_prc/fsw_processing.h
262 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/avf_prc/avf2_prc2.c
262 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/avf_prc/avf2_prc2.c
263
263
264 ####### Install
264 ####### Install
265
265
266 install: FORCE
266 install: FORCE
267
267
268 uninstall: FORCE
268 uninstall: FORCE
269
269
270 FORCE:
270 FORCE:
271
271
@@ -1,92 +1,92
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose cpu_usage_report boot_messages
4 CONFIG += console verbose cpu_usage_report boot_messages debug_messages
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
8
8
9 # flight software version
9 # flight software version
10 SWVERSION=-1-0
10 SWVERSION=-1-0
11 DEFINES += SW_VERSION_N1=1 # major
11 DEFINES += SW_VERSION_N1=1 # major
12 DEFINES += SW_VERSION_N2=0 # minor
12 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N3=0 # patch
13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=6 # internal
14 DEFINES += SW_VERSION_N4=6 # internal
15
15
16 contains( CONFIG, debug_tch ) {
16 contains( CONFIG, debug_tch ) {
17 DEFINES += DEBUG_TCH
17 DEFINES += DEBUG_TCH
18 }
18 }
19
19
20 contains( CONFIG, vhdl_dev ) {
20 contains( CONFIG, vhdl_dev ) {
21 DEFINES += VHDL_DEV
21 DEFINES += VHDL_DEV
22 }
22 }
23
23
24 contains( CONFIG, verbose ) {
24 contains( CONFIG, verbose ) {
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 }
26 }
27
27
28 contains( CONFIG, debug_messages ) {
28 contains( CONFIG, debug_messages ) {
29 DEFINES += DEBUG_MESSAGES
29 DEFINES += DEBUG_MESSAGES
30 }
30 }
31
31
32 contains( CONFIG, cpu_usage_report ) {
32 contains( CONFIG, cpu_usage_report ) {
33 DEFINES += PRINT_TASK_STATISTICS
33 DEFINES += PRINT_TASK_STATISTICS
34 }
34 }
35
35
36 contains( CONFIG, stack_report ) {
36 contains( CONFIG, stack_report ) {
37 DEFINES += PRINT_STACK_REPORT
37 DEFINES += PRINT_STACK_REPORT
38 }
38 }
39
39
40 contains( CONFIG, boot_messages ) {
40 contains( CONFIG, boot_messages ) {
41 DEFINES += BOOT_MESSAGES
41 DEFINES += BOOT_MESSAGES
42 }
42 }
43
43
44 #doxygen.target = doxygen
44 #doxygen.target = doxygen
45 #doxygen.commands = doxygen ../doc/Doxyfile
45 #doxygen.commands = doxygen ../doc/Doxyfile
46 #QMAKE_EXTRA_TARGETS += doxygen
46 #QMAKE_EXTRA_TARGETS += doxygen
47
47
48 TARGET = fsw
48 TARGET = fsw
49
49
50 INCLUDEPATH += \
50 INCLUDEPATH += \
51 ../src \
51 ../src \
52 ../header \
52 ../header \
53 ../src/basic_parameters \
53 ../src/basic_parameters \
54 ../src/avf_prc
54 ../src/avf_prc
55
55
56 SOURCES += \
56 SOURCES += \
57 ../src/wf_handler.c \
57 ../src/wf_handler.c \
58 ../src/tc_handler.c \
58 ../src/tc_handler.c \
59 ../src/fsw_misc.c \
59 ../src/fsw_misc.c \
60 ../src/fsw_init.c \
60 ../src/fsw_init.c \
61 ../src/fsw_globals.c \
61 ../src/fsw_globals.c \
62 ../src/fsw_spacewire.c \
62 ../src/fsw_spacewire.c \
63 ../src/tc_load_dump_parameters.c \
63 ../src/tc_load_dump_parameters.c \
64 ../src/tm_lfr_tc_exe.c \
64 ../src/tm_lfr_tc_exe.c \
65 ../src/tc_acceptance.c \
65 ../src/tc_acceptance.c \
66 ../src/basic_parameters/basic_parameters.c \
66 ../src/basic_parameters/basic_parameters.c \
67 ../src/avf_prc/fsw_processing.c \
67 ../src/avf_prc/fsw_processing.c \
68 ../src/avf_prc/avf0_prc0.c \
68 ../src/avf_prc/avf0_prc0.c \
69 ../src/avf_prc/avf1_prc1.c \
69 ../src/avf_prc/avf1_prc1.c \
70 ../src/avf_prc/avf2_prc2.c
70 ../src/avf_prc/avf2_prc2.c
71
71
72
72
73 HEADERS += \
73 HEADERS += \
74 ../header/wf_handler.h \
74 ../header/wf_handler.h \
75 ../header/tc_handler.h \
75 ../header/tc_handler.h \
76 ../header/grlib_regs.h \
76 ../header/grlib_regs.h \
77 ../header/fsw_params.h \
77 ../header/fsw_params.h \
78 ../header/fsw_misc.h \
78 ../header/fsw_misc.h \
79 ../header/fsw_init.h \
79 ../header/fsw_init.h \
80 ../header/ccsds_types.h \
80 ../header/ccsds_types.h \
81 ../header/fsw_params_processing.h \
81 ../header/fsw_params_processing.h \
82 ../header/fsw_spacewire.h \
82 ../header/fsw_spacewire.h \
83 ../header/tc_load_dump_parameters.h \
83 ../header/tc_load_dump_parameters.h \
84 ../header/tm_lfr_tc_exe.h \
84 ../header/tm_lfr_tc_exe.h \
85 ../header/tc_acceptance.h \
85 ../header/tc_acceptance.h \
86 ../header/fsw_params_nb_bytes.h \
86 ../header/fsw_params_nb_bytes.h \
87 ../src/basic_parameters/basic_parameters.h \
87 ../src/basic_parameters/basic_parameters.h \
88 ../src/avf_prc/fsw_processing.h \
88 ../src/avf_prc/fsw_processing.h \
89 ../src/avf_prc/avf0_prc0.h \
89 ../src/avf_prc/avf0_prc0.h \
90 ../src/avf_prc/avf1_prc1.h \
90 ../src/avf_prc/avf1_prc1.h \
91 ../src/avf_prc/avf2_prc2.h
91 ../src/avf_prc/avf2_prc2.h
92
92
@@ -1,201 +1,201
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-27T15:09:47. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-27T16:41:56. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">0</value>
7 <value type="int">0</value>
8 </data>
8 </data>
9 <data>
9 <data>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 <valuemap type="QVariantMap">
11 <valuemap type="QVariantMap">
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 <value type="QString" key="language">Cpp</value>
16 <value type="QString" key="language">Cpp</value>
17 <valuemap type="QVariantMap" key="value">
17 <valuemap type="QVariantMap" key="value">
18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 </valuemap>
19 </valuemap>
20 </valuemap>
20 </valuemap>
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 <value type="QString" key="language">QmlJS</value>
22 <value type="QString" key="language">QmlJS</value>
23 <valuemap type="QVariantMap" key="value">
23 <valuemap type="QVariantMap" key="value">
24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 </valuemap>
25 </valuemap>
26 </valuemap>
26 </valuemap>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 <value type="int" key="EditorConfiguration.TabSize">8</value>
38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 </valuemap>
45 </valuemap>
46 </data>
46 </data>
47 <data>
47 <data>
48 <variable>ProjectExplorer.Project.PluginSettings</variable>
48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 <valuemap type="QVariantMap"/>
49 <valuemap type="QVariantMap"/>
50 </data>
50 </data>
51 <data>
51 <data>
52 <variable>ProjectExplorer.Project.Target.0</variable>
52 <variable>ProjectExplorer.Project.Target.0</variable>
53 <valuemap type="QVariantMap">
53 <valuemap type="QVariantMap">
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.3 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{be73cf6a-f9d8-4d5a-8adf-adc2d83e2e44}</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{be73cf6a-f9d8-4d5a-8adf-adc2d83e2e44}</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 </valuemap>
72 </valuemap>
73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 <value type="QString">-w</value>
79 <value type="QString">-w</value>
80 <value type="QString">-r</value>
80 <value type="QString">-r</value>
81 </valuelist>
81 </valuelist>
82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 </valuemap>
85 </valuemap>
86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 </valuemap>
90 </valuemap>
91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 <value type="QString">-w</value>
98 <value type="QString">-w</value>
99 <value type="QString">-r</value>
99 <value type="QString">-r</value>
100 </valuelist>
100 </valuelist>
101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 </valuemap>
104 </valuemap>
105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 </valuemap>
109 </valuemap>
110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 </valuemap>
118 </valuemap>
119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 </valuemap>
126 </valuemap>
127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 </valuemap>
131 </valuemap>
132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 <value type="int">0</value>
153 <value type="int">0</value>
154 <value type="int">1</value>
154 <value type="int">1</value>
155 <value type="int">2</value>
155 <value type="int">2</value>
156 <value type="int">3</value>
156 <value type="int">3</value>
157 <value type="int">4</value>
157 <value type="int">4</value>
158 <value type="int">5</value>
158 <value type="int">5</value>
159 <value type="int">6</value>
159 <value type="int">6</value>
160 <value type="int">7</value>
160 <value type="int">7</value>
161 <value type="int">8</value>
161 <value type="int">8</value>
162 <value type="int">9</value>
162 <value type="int">9</value>
163 <value type="int">10</value>
163 <value type="int">10</value>
164 <value type="int">11</value>
164 <value type="int">11</value>
165 <value type="int">12</value>
165 <value type="int">12</value>
166 <value type="int">13</value>
166 <value type="int">13</value>
167 <value type="int">14</value>
167 <value type="int">14</value>
168 </valuelist>
168 </valuelist>
169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 </valuemap>
185 </valuemap>
186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 </valuemap>
187 </valuemap>
188 </data>
188 </data>
189 <data>
189 <data>
190 <variable>ProjectExplorer.Project.TargetCount</variable>
190 <variable>ProjectExplorer.Project.TargetCount</variable>
191 <value type="int">1</value>
191 <value type="int">1</value>
192 </data>
192 </data>
193 <data>
193 <data>
194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
195 <value type="QByteArray">{cdbf9cdc-1e84-406e-889b-c4feef49e75c}</value>
195 <value type="QByteArray">{cdbf9cdc-1e84-406e-889b-c4feef49e75c}</value>
196 </data>
196 </data>
197 <data>
197 <data>
198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
199 <value type="int">15</value>
199 <value type="int">15</value>
200 </data>
200 </data>
201 </qtcreator>
201 </qtcreator>
@@ -1,358 +1,398
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf0_prc0.h"
10 #include "avf0_prc0.h"
11
11
12 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
12 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
13 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
13 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
14 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
15 ring_node_asm *current_ring_node_asm_norm_f0;
15 ring_node_asm *current_ring_node_asm_norm_f0;
16
16
17 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
17 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
18 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
19 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
20 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
20 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
21
21
22 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
22 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
23
23
24 void reset_nb_sm_f0( unsigned char lfrMode )
24 void reset_nb_sm_f0( unsigned char lfrMode )
25 {
25 {
26 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
26 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
27 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
27 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
28 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
28 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
29 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
29 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
30 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
30 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
31 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
31 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
32 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
32 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
33 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
33 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
34 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
34 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
35
35
36 if (lfrMode == LFR_MODE_SBM1)
36 if (lfrMode == LFR_MODE_SBM1)
37 {
37 {
38 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
38 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
39 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
39 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
40 }
40 }
41 else if (lfrMode == LFR_MODE_SBM2)
41 else if (lfrMode == LFR_MODE_SBM2)
42 {
42 {
43 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
43 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
44 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
44 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
45 }
45 }
46 else if (lfrMode == LFR_MODE_BURST)
46 else if (lfrMode == LFR_MODE_BURST)
47 {
47 {
48 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
48 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
49 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
49 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
50 }
50 }
51 else
51 else
52 {
52 {
53 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
53 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
54 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
54 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
55 }
55 }
56 }
56 }
57
57
58 void SM_average_f0( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
59 ring_node_sm *ring_node_tab[],
60 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
61 {
62 float sum;
63 unsigned int i;
64
65 for(i=0; i<TOTAL_SIZE_SM; i++)
66 {
67 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
68 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
69 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
70 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
71 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
72 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
73 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
74 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
75
76 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
77 {
78 averaged_spec_mat_f0[ i ] = sum;
79 averaged_spec_mat_f1[ i ] = sum;
80 }
81 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
82 {
83 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
84 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
85 }
86 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
87 {
88 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
89 averaged_spec_mat_f1[ i ] = sum;
90 }
91 else
92 {
93 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
94 }
95 }
96 }
97
58 //************
98 //************
59 // RTEMS TASKS
99 // RTEMS TASKS
60
100
61 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
101 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
62 {
102 {
63 int i;
103 int i;
64
104
65 rtems_event_set event_out;
105 rtems_event_set event_out;
66 rtems_status_code status;
106 rtems_status_code status;
67 rtems_id queue_id_prc0;
107 rtems_id queue_id_prc0;
68 asm_msg msgForMATR;
108 asm_msg msgForMATR;
69 ring_node_sm *ring_node_tab[8];
109 ring_node_sm *ring_node_tab[8];
70
110
71 unsigned int nb_norm_bp1;
111 unsigned int nb_norm_bp1;
72 unsigned int nb_norm_bp2;
112 unsigned int nb_norm_bp2;
73 unsigned int nb_norm_asm;
113 unsigned int nb_norm_asm;
74 unsigned int nb_sbm_bp1;
114 unsigned int nb_sbm_bp1;
75 unsigned int nb_sbm_bp2;
115 unsigned int nb_sbm_bp2;
76
116
77 nb_norm_bp1 = 0;
117 nb_norm_bp1 = 0;
78 nb_norm_bp2 = 0;
118 nb_norm_bp2 = 0;
79 nb_norm_asm = 0;
119 nb_norm_asm = 0;
80 nb_sbm_bp1 = 0;
120 nb_sbm_bp1 = 0;
81 nb_sbm_bp2 = 0;
121 nb_sbm_bp2 = 0;
82
122
83 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
123 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
84 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
124 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
85 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
125 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
86 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
126 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
87 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
127 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
88
128
89 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
129 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
90
130
91 status = get_message_queue_id_prc0( &queue_id_prc0 );
131 status = get_message_queue_id_prc0( &queue_id_prc0 );
92 if (status != RTEMS_SUCCESSFUL)
132 if (status != RTEMS_SUCCESSFUL)
93 {
133 {
94 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
134 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
95 }
135 }
96
136
97 while(1){
137 while(1){
98 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
138 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
99 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
139 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
100 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
140 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
101 {
141 {
102 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
142 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
103 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
143 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
104 }
144 }
105
145
106 // compute the average and store it in the averaged_sm_f1 buffer
146 // compute the average and store it in the averaged_sm_f1 buffer
107 SM_average( current_ring_node_asm_norm_f0->matrix,
147 SM_average_f0( current_ring_node_asm_norm_f0->matrix,
108 current_ring_node_asm_burst_sbm_f0->matrix,
148 current_ring_node_asm_burst_sbm_f0->matrix,
109 ring_node_tab,
149 ring_node_tab,
110 nb_norm_bp1, nb_sbm_bp1 );
150 nb_norm_bp1, nb_sbm_bp1 );
111
151
112 // update nb_average
152 // update nb_average
113 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
153 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
114 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
154 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
115 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
155 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
116 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
156 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
117 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
157 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
118
158
119 //****************************************
159 //****************************************
120 // initialize the mesage for the MATR task
160 // initialize the mesage for the MATR task
121 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
161 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
122 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
162 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
123 msgForMATR.norm = current_ring_node_asm_norm_f0;
163 msgForMATR.norm = current_ring_node_asm_norm_f0;
124 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
164 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
125 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
165 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
126 msgForMATR.coarseTime = time_management_regs->coarse_time;
166 msgForMATR.coarseTime = time_management_regs->coarse_time;
127 msgForMATR.fineTime = time_management_regs->fine_time;
167 msgForMATR.fineTime = time_management_regs->fine_time;
128
168
129 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
169 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
130 {
170 {
131 nb_sbm_bp1 = 0;
171 nb_sbm_bp1 = 0;
132 // set another ring for the ASM storage
172 // set another ring for the ASM storage
133 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
173 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
134 if ( (lfrCurrentMode == LFR_MODE_BURST)
174 if ( (lfrCurrentMode == LFR_MODE_BURST)
135 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
175 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
136 {
176 {
137 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
177 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
138 }
178 }
139 }
179 }
140
180
141 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
181 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
142 {
182 {
143 nb_sbm_bp2 = 0;
183 nb_sbm_bp2 = 0;
144 if ( (lfrCurrentMode == LFR_MODE_BURST)
184 if ( (lfrCurrentMode == LFR_MODE_BURST)
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
185 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
146 {
186 {
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
187 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
148 }
188 }
149 }
189 }
150
190
151 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
191 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
152 {
192 {
153 nb_norm_bp1 = 0;
193 nb_norm_bp1 = 0;
154 // set another ring for the ASM storage
194 // set another ring for the ASM storage
155 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
195 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
156 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
196 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
157 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
197 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
158 {
198 {
159 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
199 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
160 }
200 }
161 }
201 }
162
202
163 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
203 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
164 {
204 {
165 nb_norm_bp2 = 0;
205 nb_norm_bp2 = 0;
166 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
206 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
167 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
207 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
168 {
208 {
169 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
209 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
170 }
210 }
171 }
211 }
172
212
173 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
213 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
174 {
214 {
175 nb_norm_asm = 0;
215 nb_norm_asm = 0;
176 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
216 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
177 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
217 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
178 {
218 {
179 // PRINTF1("%lld\n", localTime)
219 // PRINTF1("%lld\n", localTime)
180 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
220 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
181 }
221 }
182 }
222 }
183
223
184 //*************************
224 //*************************
185 // send the message to MATR
225 // send the message to MATR
186 if (msgForMATR.event != 0x00)
226 if (msgForMATR.event != 0x00)
187 {
227 {
188 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
228 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
189 }
229 }
190
230
191 if (status != RTEMS_SUCCESSFUL) {
231 if (status != RTEMS_SUCCESSFUL) {
192 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
232 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
193 }
233 }
194 }
234 }
195 }
235 }
196
236
197 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
237 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
198 {
238 {
199 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
239 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
200 size_t size; // size of the incoming TC packet
240 size_t size; // size of the incoming TC packet
201 asm_msg *incomingMsg;
241 asm_msg *incomingMsg;
202 //
242 //
203 spw_ioctl_pkt_send spw_ioctl_send_ASM;
243 spw_ioctl_pkt_send spw_ioctl_send_ASM;
204 rtems_status_code status;
244 rtems_status_code status;
205 rtems_id queue_id;
245 rtems_id queue_id;
206 rtems_id queue_id_q_p0;
246 rtems_id queue_id_q_p0;
207 Header_TM_LFR_SCIENCE_ASM_t headerASM;
247 Header_TM_LFR_SCIENCE_ASM_t headerASM;
208 bp_packet_with_spare packet_norm_bp1_f0;
248 bp_packet_with_spare packet_norm_bp1_f0;
209 bp_packet packet_norm_bp2_f0;
249 bp_packet packet_norm_bp2_f0;
210 bp_packet packet_sbm_bp1_f0;
250 bp_packet packet_sbm_bp1_f0;
211 bp_packet packet_sbm_bp2_f0;
251 bp_packet packet_sbm_bp2_f0;
212
252
213 unsigned long long int localTime;
253 unsigned long long int localTime;
214
254
215 ASM_init_header( &headerASM );
255 ASM_init_header( &headerASM );
216
256
217 //*************
257 //*************
218 // NORM headers
258 // NORM headers
219 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
259 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
220 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
260 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
261 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
222 BP_init_header( &packet_norm_bp2_f0.header,
262 BP_init_header( &packet_norm_bp2_f0.header,
223 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
263 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
224 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
264 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
225
265
226 //****************************
266 //****************************
227 // BURST SBM1 and SBM2 headers
267 // BURST SBM1 and SBM2 headers
228 if ( lfrRequestedMode == LFR_MODE_BURST )
268 if ( lfrRequestedMode == LFR_MODE_BURST )
229 {
269 {
230 BP_init_header( &packet_sbm_bp1_f0.header,
270 BP_init_header( &packet_sbm_bp1_f0.header,
231 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
271 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
272 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
233 BP_init_header( &packet_sbm_bp2_f0.header,
273 BP_init_header( &packet_sbm_bp2_f0.header,
234 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
274 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
235 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
275 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
236 }
276 }
237 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
277 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
238 {
278 {
239 BP_init_header( &packet_sbm_bp1_f0.header,
279 BP_init_header( &packet_sbm_bp1_f0.header,
240 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
280 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
241 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
281 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
242 BP_init_header( &packet_sbm_bp2_f0.header,
282 BP_init_header( &packet_sbm_bp2_f0.header,
243 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
283 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
244 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
284 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
245 }
285 }
246 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
286 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
247 {
287 {
248 BP_init_header( &packet_sbm_bp1_f0.header,
288 BP_init_header( &packet_sbm_bp1_f0.header,
249 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
289 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
250 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
290 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
251 BP_init_header( &packet_sbm_bp2_f0.header,
291 BP_init_header( &packet_sbm_bp2_f0.header,
252 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
292 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
253 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
293 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
254 }
294 }
255 else
295 else
256 {
296 {
257 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
297 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
258 }
298 }
259
299
260 status = get_message_queue_id_send( &queue_id );
300 status = get_message_queue_id_send( &queue_id );
261 if (status != RTEMS_SUCCESSFUL)
301 if (status != RTEMS_SUCCESSFUL)
262 {
302 {
263 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
303 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
264 }
304 }
265 status = get_message_queue_id_prc0( &queue_id_q_p0);
305 status = get_message_queue_id_prc0( &queue_id_q_p0);
266 if (status != RTEMS_SUCCESSFUL)
306 if (status != RTEMS_SUCCESSFUL)
267 {
307 {
268 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
308 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
269 }
309 }
270
310
271 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
311 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
272
312
273 while(1){
313 while(1){
274 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
314 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
275 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
315 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
276
316
277 incomingMsg = (asm_msg*) incomingData;
317 incomingMsg = (asm_msg*) incomingData;
278
318
279 localTime = getTimeAsUnsignedLongLongInt( );
319 localTime = getTimeAsUnsignedLongLongInt( );
280 //****************
320 //****************
281 //****************
321 //****************
282 // BURST SBM1 SBM2
322 // BURST SBM1 SBM2
283 //****************
323 //****************
284 //****************
324 //****************
285 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
325 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
286 {
326 {
287 // 1) compress the matrix for Basic Parameters calculation
327 // 1) compress the matrix for Basic Parameters calculation
288 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
328 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
289 nb_sm_before_f0.burst_sbm_bp1,
329 nb_sm_before_f0.burst_sbm_bp1,
290 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
330 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
291 ASM_F0_INDICE_START);
331 ASM_F0_INDICE_START);
292 // 2) compute the BP1 set
332 // 2) compute the BP1 set
293
333
294 // 3) send the BP1 set
334 // 3) send the BP1 set
295 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
335 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
336 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
297 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
337 BP_send( (char *) &packet_sbm_bp1_f0.header, queue_id,
298 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
338 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
299 // 4) compute the BP2 set if needed
339 // 4) compute the BP2 set if needed
300 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
340 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
301 {
341 {
302 // 1) compute the BP2 set
342 // 1) compute the BP2 set
303
343
304 // 2) send the BP2 set
344 // 2) send the BP2 set
305 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
345 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
346 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
307 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
347 BP_send( (char *) &packet_sbm_bp2_f0.header, queue_id,
308 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
348 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
309 }
349 }
310 }
350 }
311
351
312 //*****
352 //*****
313 //*****
353 //*****
314 // NORM
354 // NORM
315 //*****
355 //*****
316 //*****
356 //*****
317 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
357 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
318 {
358 {
319 // 1) compress the matrix for Basic Parameters calculation
359 // 1) compress the matrix for Basic Parameters calculation
320 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
360 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
321 nb_sm_before_f0.norm_bp1,
361 nb_sm_before_f0.norm_bp1,
322 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
362 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
323 ASM_F0_INDICE_START );
363 ASM_F0_INDICE_START );
324 // 2) compute the BP1 set
364 // 2) compute the BP1 set
325
365
326 // 3) send the BP1 set
366 // 3) send the BP1 set
327 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
367 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
328 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
368 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
329 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
369 BP_send( (char *) &packet_norm_bp1_f0.header, queue_id,
330 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
370 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
331 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
371 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
332 {
372 {
333 // 1) compute the BP2 set using the same ASM as the one used for BP1
373 // 1) compute the BP2 set using the same ASM as the one used for BP1
334
374
335 // 2) send the BP2 set
375 // 2) send the BP2 set
336 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
376 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
337 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
377 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
338 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
378 BP_send( (char *) &packet_norm_bp2_f0.header, queue_id,
339 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
379 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
340 }
380 }
341 }
381 }
342
382
343 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
383 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
344 {
384 {
345 // 1) reorganize the ASM and divide
385 // 1) reorganize the ASM and divide
346 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
386 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
347 asm_f0_reorganized,
387 asm_f0_reorganized,
348 nb_sm_before_f0.norm_bp1 );
388 nb_sm_before_f0.norm_bp1 );
349 // 2) convert the float array in a char array
389 // 2) convert the float array in a char array
350 ASM_convert( asm_f0_reorganized, asm_f0_char);
390 ASM_convert( asm_f0_reorganized, asm_f0_char);
351 // 3) send the spectral matrix packets
391 // 3) send the spectral matrix packets
352 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
392 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
353 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
393 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
354 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
394 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
355 }
395 }
356
396
357 }
397 }
358 }
398 }
@@ -1,30 +1,32
1 #ifndef AVF0_PRC0_H
1 #ifndef AVF0_PRC0_H
2 #define AVF0_PRC0_H
2 #define AVF0_PRC0_H
3
3
4 #include "fsw_processing.h"
4 #include "fsw_processing.h"
5
5
6 typedef struct {
6 typedef struct {
7 unsigned int norm_bp1;
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
13 unsigned int burst_bp2;
14 unsigned int sbm1_bp1;
14 unsigned int sbm1_bp1;
15 unsigned int sbm1_bp2;
15 unsigned int sbm1_bp2;
16 unsigned int sbm2_bp1;
16 unsigned int sbm2_bp1;
17 unsigned int sbm2_bp2;
17 unsigned int sbm2_bp2;
18 } nb_sm_before_bp_asm_f0;
18 } nb_sm_before_bp_asm_f0;
19
19
20 extern struct ring_node_sm *current_ring_node_sm_f0;
21 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
20 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
22
21
23 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
22 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
24
23
25 void reset_nb_sm_f0( unsigned char lfrMode );
24 void reset_nb_sm_f0( unsigned char lfrMode );
25 void SM_average_f0( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
26 ring_node_sm *ring_node_tab[],
27 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
26
28
27 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
29 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
28 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
30 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
29
31
30 #endif // AVF0_PRC0_H
32 #endif // AVF0_PRC0_H
@@ -1,339 +1,379
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf1_prc1.h"
10 #include "avf1_prc1.h"
11
11
12 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
12 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
13 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
13 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
14 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
15 ring_node_asm *current_ring_node_asm_norm_f1;
15 ring_node_asm *current_ring_node_asm_norm_f1;
16
16
17 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
17 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
18 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
19 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
20 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
20 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
21
21
22 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
22 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
23
23
24 void reset_nb_sm_f1( unsigned char lfrMode )
24 void reset_nb_sm_f1( unsigned char lfrMode )
25 {
25 {
26 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
26 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
27 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
27 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
28 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
28 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
29 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
29 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
30 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
30 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
31 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
31 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
32 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
32 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
33
33
34 if (lfrMode == LFR_MODE_SBM2)
34 if (lfrMode == LFR_MODE_SBM2)
35 {
35 {
36 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
36 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
37 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
37 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
38 }
38 }
39 else if (lfrMode == LFR_MODE_BURST)
39 else if (lfrMode == LFR_MODE_BURST)
40 {
40 {
41 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
41 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
42 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
42 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
43 }
43 }
44 else
44 else
45 {
45 {
46 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
46 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
47 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
47 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
48 }
48 }
49 }
49 }
50
50
51 void SM_average_f1( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
52 ring_node_sm *ring_node_tab[],
53 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
54 {
55 float sum;
56 unsigned int i;
57
58 for(i=0; i<TOTAL_SIZE_SM; i++)
59 {
60 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
61 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
62 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
63 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
64 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
65 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
66 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
67 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
68
69 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
70 {
71 averaged_spec_mat_f0[ i ] = sum;
72 averaged_spec_mat_f1[ i ] = sum;
73 }
74 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
75 {
76 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
77 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
78 }
79 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
80 {
81 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
82 averaged_spec_mat_f1[ i ] = sum;
83 }
84 else
85 {
86 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
87 }
88 }
89 }
90
51 //************
91 //************
52 // RTEMS TASKS
92 // RTEMS TASKS
53
93
54 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
94 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
55 {
95 {
56 int i;
96 int i;
57
97
58 rtems_event_set event_out;
98 rtems_event_set event_out;
59 rtems_status_code status;
99 rtems_status_code status;
60 rtems_id queue_id_prc1;
100 rtems_id queue_id_prc1;
61 asm_msg msgForMATR;
101 asm_msg msgForMATR;
62 ring_node_sm *ring_node_tab[8];
102 ring_node_sm *ring_node_tab[8];
63
103
64 unsigned int nb_norm_bp1;
104 unsigned int nb_norm_bp1;
65 unsigned int nb_norm_bp2;
105 unsigned int nb_norm_bp2;
66 unsigned int nb_norm_asm;
106 unsigned int nb_norm_asm;
67 unsigned int nb_sbm_bp1;
107 unsigned int nb_sbm_bp1;
68 unsigned int nb_sbm_bp2;
108 unsigned int nb_sbm_bp2;
69
109
70 nb_norm_bp1 = 0;
110 nb_norm_bp1 = 0;
71 nb_norm_bp2 = 0;
111 nb_norm_bp2 = 0;
72 nb_norm_asm = 0;
112 nb_norm_asm = 0;
73 nb_sbm_bp1 = 0;
113 nb_sbm_bp1 = 0;
74 nb_sbm_bp2 = 0;
114 nb_sbm_bp2 = 0;
75
115
76 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
116 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
77 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
117 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
78 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
118 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
79 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
119 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
80 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
120 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
81
121
82 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
122 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
83
123
84 status = get_message_queue_id_prc1( &queue_id_prc1 );
124 status = get_message_queue_id_prc1( &queue_id_prc1 );
85 if (status != RTEMS_SUCCESSFUL)
125 if (status != RTEMS_SUCCESSFUL)
86 {
126 {
87 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
127 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
88 }
128 }
89
129
90 while(1){
130 while(1){
91 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
131 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
92 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
132 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
93 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
133 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
94 {
134 {
95 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
135 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
96 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
136 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
97 }
137 }
98
138
99 // compute the average and store it in the averaged_sm_f1 buffer
139 // compute the average and store it in the averaged_sm_f1 buffer
100 SM_average( current_ring_node_asm_norm_f1->matrix,
140 SM_average_f1( current_ring_node_asm_norm_f1->matrix,
101 current_ring_node_asm_burst_sbm_f1->matrix,
141 current_ring_node_asm_burst_sbm_f1->matrix,
102 ring_node_tab,
142 ring_node_tab,
103 nb_norm_bp1, nb_sbm_bp1 );
143 nb_norm_bp1, nb_sbm_bp1 );
104
144
105 // update nb_average
145 // update nb_average
106 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
146 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
107 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
147 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
108 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
148 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
149 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
110 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
150 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
111
151
112 //****************************************
152 //****************************************
113 // initialize the mesage for the MATR task
153 // initialize the mesage for the MATR task
114 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
154 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
115 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
155 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
116 msgForMATR.norm = current_ring_node_asm_norm_f1;
156 msgForMATR.norm = current_ring_node_asm_norm_f1;
117 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
157 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
118 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
158 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
119 msgForMATR.coarseTime = time_management_regs->coarse_time;
159 msgForMATR.coarseTime = time_management_regs->coarse_time;
120 msgForMATR.fineTime = time_management_regs->fine_time;
160 msgForMATR.fineTime = time_management_regs->fine_time;
121
161
122 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
162 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
123 {
163 {
124 nb_sbm_bp1 = 0;
164 nb_sbm_bp1 = 0;
125 // set another ring for the ASM storage
165 // set another ring for the ASM storage
126 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
166 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
127 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
167 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
128 {
168 {
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
169 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
130 }
170 }
131 }
171 }
132
172
133 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
173 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
134 {
174 {
135 nb_sbm_bp2 = 0;
175 nb_sbm_bp2 = 0;
136 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
176 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
137 {
177 {
138 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
178 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
139 }
179 }
140 }
180 }
141
181
142 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
182 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
143 {
183 {
144 nb_norm_bp1 = 0;
184 nb_norm_bp1 = 0;
145 // set another ring for the ASM storage
185 // set another ring for the ASM storage
146 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
186 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
187 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
188 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 {
189 {
150 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
190 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
151 }
191 }
152 }
192 }
153
193
154 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
194 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
155 {
195 {
156 nb_norm_bp2 = 0;
196 nb_norm_bp2 = 0;
157 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
197 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
158 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
198 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
159 {
199 {
160 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
200 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
161 }
201 }
162 }
202 }
163
203
164 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
204 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
165 {
205 {
166 nb_norm_asm = 0;
206 nb_norm_asm = 0;
167 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
207 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
168 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
208 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
169 {
209 {
170 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
210 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
171 }
211 }
172 }
212 }
173
213
174 //*************************
214 //*************************
175 // send the message to MATR
215 // send the message to MATR
176 if (msgForMATR.event != 0x00)
216 if (msgForMATR.event != 0x00)
177 {
217 {
178 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
218 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
179 }
219 }
180
220
181 if (status != RTEMS_SUCCESSFUL) {
221 if (status != RTEMS_SUCCESSFUL) {
182 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
222 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
183 }
223 }
184 }
224 }
185 }
225 }
186
226
187 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
227 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
188 {
228 {
189 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
229 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
190 size_t size; // size of the incoming TC packet
230 size_t size; // size of the incoming TC packet
191 asm_msg *incomingMsg;
231 asm_msg *incomingMsg;
192 //
232 //
193 spw_ioctl_pkt_send spw_ioctl_send_ASM;
233 spw_ioctl_pkt_send spw_ioctl_send_ASM;
194 rtems_status_code status;
234 rtems_status_code status;
195 rtems_id queue_id_send;
235 rtems_id queue_id_send;
196 rtems_id queue_id_q_p1;
236 rtems_id queue_id_q_p1;
197 Header_TM_LFR_SCIENCE_ASM_t headerASM;
237 Header_TM_LFR_SCIENCE_ASM_t headerASM;
198 bp_packet_with_spare packet_norm_bp1;
238 bp_packet_with_spare packet_norm_bp1;
199 bp_packet packet_norm_bp2;
239 bp_packet packet_norm_bp2;
200 bp_packet packet_sbm_bp1;
240 bp_packet packet_sbm_bp1;
201 bp_packet packet_sbm_bp2;
241 bp_packet packet_sbm_bp2;
202
242
203 unsigned long long int localTime;
243 unsigned long long int localTime;
204
244
205 ASM_init_header( &headerASM );
245 ASM_init_header( &headerASM );
206
246
207 //*************
247 //*************
208 // NORM headers
248 // NORM headers
209 BP_init_header_with_spare( &packet_norm_bp1.header,
249 BP_init_header_with_spare( &packet_norm_bp1.header,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
250 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
211 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
251 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
212 BP_init_header( &packet_norm_bp2.header,
252 BP_init_header( &packet_norm_bp2.header,
213 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
253 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
214 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
254 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
215
255
216 //***********************
256 //***********************
217 // BURST and SBM2 headers
257 // BURST and SBM2 headers
218 if ( lfrRequestedMode == LFR_MODE_BURST )
258 if ( lfrRequestedMode == LFR_MODE_BURST )
219 {
259 {
220 BP_init_header( &packet_sbm_bp1.header,
260 BP_init_header( &packet_sbm_bp1.header,
221 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
261 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
262 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
223 BP_init_header( &packet_sbm_bp2.header,
263 BP_init_header( &packet_sbm_bp2.header,
224 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
264 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
225 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
265 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F1);
226 }
266 }
227 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
267 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
228 {
268 {
229 BP_init_header( &packet_sbm_bp1.header,
269 BP_init_header( &packet_sbm_bp1.header,
230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
270 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
271 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
232 BP_init_header( &packet_sbm_bp2.header,
272 BP_init_header( &packet_sbm_bp2.header,
233 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
273 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
234 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
274 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
235 }
275 }
236 else
276 else
237 {
277 {
238 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
278 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
239 }
279 }
240
280
241 status = get_message_queue_id_send( &queue_id_send );
281 status = get_message_queue_id_send( &queue_id_send );
242 if (status != RTEMS_SUCCESSFUL)
282 if (status != RTEMS_SUCCESSFUL)
243 {
283 {
244 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
284 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
245 }
285 }
246 status = get_message_queue_id_prc1( &queue_id_q_p1);
286 status = get_message_queue_id_prc1( &queue_id_q_p1);
247 if (status != RTEMS_SUCCESSFUL)
287 if (status != RTEMS_SUCCESSFUL)
248 {
288 {
249 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
289 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
250 }
290 }
251
291
252 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
292 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
253
293
254 while(1){
294 while(1){
255 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
295 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
256 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
296 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
257
297
258 incomingMsg = (asm_msg*) incomingData;
298 incomingMsg = (asm_msg*) incomingData;
259
299
260 localTime = getTimeAsUnsignedLongLongInt( );
300 localTime = getTimeAsUnsignedLongLongInt( );
261 //***********
301 //***********
262 //***********
302 //***********
263 // BURST SBM2
303 // BURST SBM2
264 //***********
304 //***********
265 //***********
305 //***********
266 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
306 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
267 {
307 {
268 // 1) compress the matrix for Basic Parameters calculation
308 // 1) compress the matrix for Basic Parameters calculation
269 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
309 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
270 nb_sm_before_f1.burst_sbm_bp1,
310 nb_sm_before_f1.burst_sbm_bp1,
271 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
311 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
272 ASM_F1_INDICE_START);
312 ASM_F1_INDICE_START);
273 // 2) compute the BP1 set
313 // 2) compute the BP1 set
274
314
275 // 3) send the BP1 set
315 // 3) send the BP1 set
276 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
316 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
277 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
317 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
278 BP_send( (char *) &packet_sbm_bp1.header, queue_id_send,
318 BP_send( (char *) &packet_sbm_bp1.header, queue_id_send,
279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA);
319 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA);
280 // 4) compute the BP2 set if needed
320 // 4) compute the BP2 set if needed
281 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
321 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
282 {
322 {
283 // 1) compute the BP2 set
323 // 1) compute the BP2 set
284
324
285 // 2) send the BP2 set
325 // 2) send the BP2 set
286 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
326 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
287 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
327 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
288 BP_send( (char *) &packet_sbm_bp2.header, queue_id_send,
328 BP_send( (char *) &packet_sbm_bp2.header, queue_id_send,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA);
329 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA);
290 }
330 }
291 }
331 }
292
332
293 //*****
333 //*****
294 //*****
334 //*****
295 // NORM
335 // NORM
296 //*****
336 //*****
297 //*****
337 //*****
298 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
338 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
299 {
339 {
300 // 1) compress the matrix for Basic Parameters calculation
340 // 1) compress the matrix for Basic Parameters calculation
301 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
341 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
302 nb_sm_before_f1.norm_bp1,
342 nb_sm_before_f1.norm_bp1,
303 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
343 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 ASM_F0_INDICE_START );
344 ASM_F0_INDICE_START );
305 // 2) compute the BP1 set
345 // 2) compute the BP1 set
306
346
307 // 3) send the BP1 set
347 // 3) send the BP1 set
308 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
348 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
309 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
349 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
310 BP_send( (char *) &packet_norm_bp1.header, queue_id_send,
350 BP_send( (char *) &packet_norm_bp1.header, queue_id_send,
311 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA);
351 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA);
312 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
352 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
313 {
353 {
314 // 1) compute the BP2 set
354 // 1) compute the BP2 set
315
355
316 // 2) send the BP2 set
356 // 2) send the BP2 set
317 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
357 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
318 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
358 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
319 BP_send( (char *) &packet_norm_bp2.header, queue_id_send,
359 BP_send( (char *) &packet_norm_bp2.header, queue_id_send,
320 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA);
360 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA);
321 }
361 }
322 }
362 }
323
363
324 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
364 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
325 {
365 {
326 // 1) reorganize the ASM and divide
366 // 1) reorganize the ASM and divide
327 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
367 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
328 asm_f1_reorganized,
368 asm_f1_reorganized,
329 nb_sm_before_f1.norm_bp1 );
369 nb_sm_before_f1.norm_bp1 );
330 // 2) convert the float array in a char array
370 // 2) convert the float array in a char array
331 ASM_convert( asm_f1_reorganized, asm_f1_char);
371 ASM_convert( asm_f1_reorganized, asm_f1_char);
332 // 3) send the spectral matrix packets
372 // 3) send the spectral matrix packets
333 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
373 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
334 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
374 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
335 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
375 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
336 }
376 }
337
377
338 }
378 }
339 }
379 }
@@ -1,28 +1,30
1 #ifndef AVF1_PRC1_H
1 #ifndef AVF1_PRC1_H
2 #define AVF1_PRC1_H
2 #define AVF1_PRC1_H
3
3
4 #include "fsw_processing.h"
4 #include "fsw_processing.h"
5
5
6 typedef struct {
6 typedef struct {
7 unsigned int norm_bp1;
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
9 unsigned int norm_asm;
10 unsigned int burst_sbm_bp1;
10 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp2;
11 unsigned int burst_sbm_bp2;
12 unsigned int burst_bp1;
12 unsigned int burst_bp1;
13 unsigned int burst_bp2;
13 unsigned int burst_bp2;
14 unsigned int sbm2_bp1;
14 unsigned int sbm2_bp1;
15 unsigned int sbm2_bp2;
15 unsigned int sbm2_bp2;
16 } nb_sm_before_bp_asm_f1;
16 } nb_sm_before_bp_asm_f1;
17
17
18 extern struct ring_node_sm *current_ring_node_sm_f1;
19 extern struct ring_node_sm *ring_node_for_averaging_sm_f1;
18 extern struct ring_node_sm *ring_node_for_averaging_sm_f1;
20
19
21 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
20 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
22
21
23 void reset_nb_sm_f1( unsigned char lfrMode );
22 void reset_nb_sm_f1( unsigned char lfrMode );
23 void SM_average_f1( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
24 ring_node_sm *ring_node_tab[],
25 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
24
26
25 rtems_task avf1_task( rtems_task_argument lfrRequestedMode );
27 rtems_task avf1_task( rtems_task_argument lfrRequestedMode );
26 rtems_task prc1_task( rtems_task_argument lfrRequestedMode );
28 rtems_task prc1_task( rtems_task_argument lfrRequestedMode );
27
29
28 #endif // AVF1_PRC1_H
30 #endif // AVF1_PRC1_H
@@ -1,240 +1,240
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing at f2 = 256 Hz, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing at f2 = 256 Hz, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf2_prc2.h"
10 #include "avf2_prc2.h"
11
11
12 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
12 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
13 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
13 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
14 ring_node_asm *current_ring_node_asm_burst_sbm_f2;
14 ring_node_asm *current_ring_node_asm_burst_sbm_f2;
15 ring_node_asm *current_ring_node_asm_norm_f2;
15 ring_node_asm *current_ring_node_asm_norm_f2;
16
16
17 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
17 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
18 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
18 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
19 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
19 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
20 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
20 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
21
21
22 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
22 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
23
23
24 void reset_nb_sm_f2( void )
24 void reset_nb_sm_f2( void )
25 {
25 {
26 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
26 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
27 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
27 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
28 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
28 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
29 }
29 }
30
30
31 void SM_average_f2( float *averaged_spec_mat_f2,
31 void SM_average_f2( float *averaged_spec_mat_f2,
32 ring_node_sm *ring_node,
32 ring_node_sm *ring_node,
33 unsigned int nbAverageNormF2 )
33 unsigned int nbAverageNormF2 )
34 {
34 {
35 float sum;
35 float sum;
36 unsigned int i;
36 unsigned int i;
37
37
38 for(i=0; i<TOTAL_SIZE_SM; i++)
38 for(i=0; i<TOTAL_SIZE_SM; i++)
39 {
39 {
40 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
40 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
41 if ( (nbAverageNormF2 == 0) )
41 if ( (nbAverageNormF2 == 0) )
42 {
42 {
43 averaged_spec_mat_f2[ i ] = sum;
43 averaged_spec_mat_f2[ i ] = sum;
44 }
44 }
45 else
45 else
46 {
46 {
47 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
47 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
48 }
48 }
49 }
49 }
50 }
50 }
51
51
52 //************
52 //************
53 // RTEMS TASKS
53 // RTEMS TASKS
54
54
55 rtems_task avf2_task( rtems_task_argument lfrRequestedMode )
55 rtems_task avf2_task( rtems_task_argument lfrRequestedMode )
56 {
56 {
57 rtems_event_set event_out;
57 // rtems_event_set event_out;
58 rtems_status_code status;
58 // rtems_status_code status;
59 rtems_id queue_id_prc2;
59 // rtems_id queue_id_prc2;
60 asm_msg msgForMATR;
60 // asm_msg msgForMATR;
61
61
62 unsigned int nb_norm_bp1;
62 // unsigned int nb_norm_bp1;
63 unsigned int nb_norm_bp2;
63 // unsigned int nb_norm_bp2;
64 unsigned int nb_norm_asm;
64 // unsigned int nb_norm_asm;
65
65
66 nb_norm_bp1 = 0;
66 // nb_norm_bp1 = 0;
67 nb_norm_bp2 = 0;
67 // nb_norm_bp2 = 0;
68 nb_norm_asm = 0;
68 // nb_norm_asm = 0;
69
69
70 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
70 // reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
71
71
72 BOOT_PRINTF1("in AVF2 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
72 // BOOT_PRINTF1("in AVF2 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
73
73
74 status = get_message_queue_id_prc2( &queue_id_prc2 );
74 // status = get_message_queue_id_prc2( &queue_id_prc2 );
75 if (status != RTEMS_SUCCESSFUL)
75 // if (status != RTEMS_SUCCESSFUL)
76 {
76 // {
77 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
77 // PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
78 }
78 // }
79
79
80 while(1){
80 // while(1){
81 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
81 // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
82
82
83 // compute the average and store it in the averaged_sm_f2 buffer
83 // // compute the average and store it in the averaged_sm_f2 buffer
84 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
84 // SM_average_f2( current_ring_node_asm_norm_f2->matrix,
85 ring_node_for_averaging_sm_f2,
85 // ring_node_for_averaging_sm_f2,
86 nb_norm_bp1 );
86 // nb_norm_bp1 );
87
87
88 // update nb_average
88 // // update nb_average
89 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
89 // nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
90 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
90 // nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
91 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
91 // nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
92
92
93 //****************************************
93 // //****************************************
94 // initialize the mesage for the MATR task
94 // // initialize the mesage for the MATR task
95 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
95 // msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
96 msgForMATR.burst_sbm = NULL;
96 // msgForMATR.burst_sbm = NULL;
97 msgForMATR.norm = current_ring_node_asm_norm_f2;
97 // msgForMATR.norm = current_ring_node_asm_norm_f2;
98 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
98 //// msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
99 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
99 //// msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
100 msgForMATR.coarseTime = time_management_regs->coarse_time;
100 // msgForMATR.coarseTime = time_management_regs->coarse_time;
101 msgForMATR.fineTime = time_management_regs->fine_time;
101 // msgForMATR.fineTime = time_management_regs->fine_time;
102
102
103 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
103 // if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
104 {
104 // {
105 nb_norm_bp1 = 0;
105 // nb_norm_bp1 = 0;
106 // set another ring for the ASM storage
106 // // set another ring for the ASM storage
107 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
107 // current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
108 if ( lfrCurrentMode == LFR_MODE_NORMAL )
108 // if ( lfrCurrentMode == LFR_MODE_NORMAL )
109 {
109 // {
110 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
110 // msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
111 }
111 // }
112 }
112 // }
113
113
114 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
114 // if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
115 {
115 // {
116 nb_norm_bp2 = 0;
116 // nb_norm_bp2 = 0;
117 if ( lfrCurrentMode == LFR_MODE_NORMAL )
117 // if ( lfrCurrentMode == LFR_MODE_NORMAL )
118 {
118 // {
119 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
119 // msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
120 }
120 // }
121 }
121 // }
122
122
123 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
123 // if (nb_norm_asm == nb_sm_before_f2.norm_asm)
124 {
124 // {
125 nb_norm_asm = 0;
125 // nb_norm_asm = 0;
126 if ( lfrCurrentMode == LFR_MODE_NORMAL )
126 // if ( lfrCurrentMode == LFR_MODE_NORMAL )
127 {
127 // {
128 // PRINTF1("%lld\n", localTime)
128 //// PRINTF1("%lld\n", localTime)
129 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
129 // msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
130 }
130 // }
131 }
131 // }
132
132
133 //*************************
133 // //*************************
134 // send the message to MATR
134 // // send the message to MATR
135 if (msgForMATR.event != 0x00)
135 // if (msgForMATR.event != 0x00)
136 {
136 // {
137 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
137 // status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
138 }
138 // }
139
139
140 if (status != RTEMS_SUCCESSFUL) {
140 // if (status != RTEMS_SUCCESSFUL) {
141 printf("in AVF2 *** Error sending message to MATR, code %d\n", status);
141 // printf("in AVF2 *** Error sending message to MATR, code %d\n", status);
142 }
142 // }
143 }
143 // }
144 }
144 }
145
145
146 rtems_task prc2_task( rtems_task_argument argument )
146 rtems_task prc2_task( rtems_task_argument argument )
147 {
147 {
148 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
148 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
149 size_t size; // size of the incoming TC packet
149 size_t size; // size of the incoming TC packet
150 asm_msg *incomingMsg;
150 asm_msg *incomingMsg;
151 //
151 //
152 spw_ioctl_pkt_send spw_ioctl_send_ASM;
152 spw_ioctl_pkt_send spw_ioctl_send_ASM;
153 rtems_status_code status;
153 rtems_status_code status;
154 rtems_id queue_id;
154 rtems_id queue_id;
155 rtems_id queue_id_q_p2;
155 rtems_id queue_id_q_p2;
156 Header_TM_LFR_SCIENCE_ASM_t headerASM;
156 Header_TM_LFR_SCIENCE_ASM_t headerASM;
157 bp_packet packet_norm_bp1_f2;
157 bp_packet packet_norm_bp1_f2;
158 bp_packet packet_norm_bp2_f2;
158 bp_packet packet_norm_bp2_f2;
159
159
160 unsigned long long int localTime;
160 unsigned long long int localTime;
161
161
162 ASM_init_header( &headerASM );
162 ASM_init_header( &headerASM );
163
163
164 //*************
164 //*************
165 // NORM headers
165 // NORM headers
166 BP_init_header( &packet_norm_bp1_f2.header,
166 BP_init_header( &packet_norm_bp1_f2.header,
167 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
167 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
168 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
168 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
169 BP_init_header( &packet_norm_bp2_f2.header,
169 BP_init_header( &packet_norm_bp2_f2.header,
170 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
170 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
171 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
171 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
172
172
173 status = get_message_queue_id_send( &queue_id );
173 status = get_message_queue_id_send( &queue_id );
174 if (status != RTEMS_SUCCESSFUL)
174 if (status != RTEMS_SUCCESSFUL)
175 {
175 {
176 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
176 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
177 }
177 }
178 status = get_message_queue_id_prc2( &queue_id_q_p2);
178 status = get_message_queue_id_prc2( &queue_id_q_p2);
179 if (status != RTEMS_SUCCESSFUL)
179 if (status != RTEMS_SUCCESSFUL)
180 {
180 {
181 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
181 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
182 }
182 }
183
183
184 BOOT_PRINTF("in PRC2 ***\n")
184 BOOT_PRINTF("in PRC2 ***\n")
185
185
186 while(1){
186 while(1){
187 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
187 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
188 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
188 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
189
189
190 incomingMsg = (asm_msg*) incomingData;
190 incomingMsg = (asm_msg*) incomingData;
191
191
192 localTime = getTimeAsUnsignedLongLongInt( );
192 localTime = getTimeAsUnsignedLongLongInt( );
193
193
194 //*****
194 //*****
195 //*****
195 //*****
196 // NORM
196 // NORM
197 //*****
197 //*****
198 //*****
198 //*****
199 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
199 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
200 {
200 {
201 // 1) compress the matrix for Basic Parameters calculation
201 // 1) compress the matrix for Basic Parameters calculation
202 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
202 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
203 nb_sm_before_f2.norm_bp1,
203 nb_sm_before_f2.norm_bp1,
204 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
204 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
205 ASM_F2_INDICE_START );
205 ASM_F2_INDICE_START );
206 // 2) compute the BP1 set
206 // 2) compute the BP1 set
207
207
208 // 3) send the BP1 set
208 // 3) send the BP1 set
209 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
209 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
210 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
210 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
211 BP_send( (char *) &packet_norm_bp1_f2.header, queue_id,
211 BP_send( (char *) &packet_norm_bp1_f2.header, queue_id,
212 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA);
212 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA);
213 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
213 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
214 {
214 {
215 // 1) compute the BP2 set using the same ASM as the one used for BP1
215 // 1) compute the BP2 set using the same ASM as the one used for BP1
216
216
217 // 2) send the BP2 set
217 // 2) send the BP2 set
218 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
218 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
219 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
219 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
220 BP_send( (char *) &packet_norm_bp2_f2.header, queue_id,
220 BP_send( (char *) &packet_norm_bp2_f2.header, queue_id,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA);
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA);
222 }
222 }
223 }
223 }
224
224
225 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
225 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
226 {
226 {
227 // 1) reorganize the ASM and divide
227 // 1) reorganize the ASM and divide
228 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
228 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
229 asm_f2_reorganized,
229 asm_f2_reorganized,
230 nb_sm_before_f2.norm_bp1 );
230 nb_sm_before_f2.norm_bp1 );
231 // 2) convert the float array in a char array
231 // 2) convert the float array in a char array
232 ASM_convert( asm_f2_reorganized, asm_f2_char);
232 ASM_convert( asm_f2_reorganized, asm_f2_char);
233 // 3) send the spectral matrix packets
233 // 3) send the spectral matrix packets
234 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
234 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
235 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
235 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
236 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
236 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
237 }
237 }
238
238
239 }
239 }
240 }
240 }
@@ -1,24 +1,23
1 #ifndef AVF2_PRC2_H
1 #ifndef AVF2_PRC2_H
2 #define AVF2_PRC2_H
2 #define AVF2_PRC2_H
3
3
4 #include "fsw_processing.h"
4 #include "fsw_processing.h"
5
5
6 typedef struct {
6 typedef struct {
7 unsigned int norm_bp1;
7 unsigned int norm_bp1;
8 unsigned int norm_bp2;
8 unsigned int norm_bp2;
9 unsigned int norm_asm;
9 unsigned int norm_asm;
10 } nb_sm_before_bp_asm_f2;
10 } nb_sm_before_bp_asm_f2;
11
11
12 extern struct ring_node_sm *current_ring_node_sm_f2;
13 extern struct ring_node_sm *ring_node_for_averaging_sm_f2;
12 extern struct ring_node_sm *ring_node_for_averaging_sm_f2;
14
13
15 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
14 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
16
15
17 void reset_nb_sm_f2(void );
16 void reset_nb_sm_f2(void );
18 void SM_average_f2( float *averaged_spec_mat_f2, ring_node_sm *ring_node, unsigned int nbAverageNormF2 );
17 void SM_average_f2( float *averaged_spec_mat_f2, ring_node_sm *ring_node, unsigned int nbAverageNormF2 );
19
18
20 // RTEMS TASKS
19 // RTEMS TASKS
21 rtems_task avf2_task( rtems_task_argument lfrRequestedMode );
20 rtems_task avf2_task( rtems_task_argument lfrRequestedMode );
22 rtems_task prc2_task(rtems_task_argument argument );
21 rtems_task prc2_task(rtems_task_argument argument );
23
22
24 #endif // AVF2_PRC2_H
23 #endif // AVF2_PRC2_H
@@ -1,570 +1,532
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "fsw_processing.h"
10 #include "fsw_processing.h"
11 #include "fsw_processing_globals.c"
11 #include "fsw_processing_globals.c"
12
12
13 unsigned int nb_sm_f0;
13 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0_aux_f1;
14 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f1;
15 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f0_aux_f2;
16 unsigned int nb_sm_f0_aux_f2;
17
17
18 //************************
18 //************************
19 // spectral matrices rings
19 // spectral matrices rings
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 ring_node_sm *current_ring_node_sm_f0;
23 ring_node_sm *current_ring_node_sm_f0;
24 ring_node_sm *current_ring_node_sm_f1;
24 ring_node_sm *current_ring_node_sm_f1;
25 ring_node_sm *current_ring_node_sm_f2;
25 ring_node_sm *current_ring_node_sm_f2;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
29
29
30 //***********************************************************
30 //***********************************************************
31 // Interrupt Service Routine for spectral matrices processing
31 // Interrupt Service Routine for spectral matrices processing
32
32
33 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
33 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
34 {
34 {
35 ring_node_sm *previous_ring_node_sm_f0;
35 // ring_node_sm *previous_ring_node_sm_f0;
36
36
37 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
37 //// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
38
38
39 previous_ring_node_sm_f0 = current_ring_node_sm_f0;
39 // previous_ring_node_sm_f0 = current_ring_node_sm_f0;
40
40
41 if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1
41 // if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1
42 {
42 // {
43 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
43 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
44 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
44 // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
45 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
45 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
46 nb_sm_f0 = nb_sm_f0 + 1;
46 // nb_sm_f0 = nb_sm_f0 + 1;
47 }
47 // }
48
48
49 //************************
49 // //************************
50 // reset status error bits
50 // // reset status error bits
51 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
51 // if ( (spectral_matrix_regs->status & 0x30) != 0x00)
52 {
52 // {
53 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
53 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
54 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
54 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
55 }
55 // }
56
56
57 //**************************************
57 // //**************************************
58 // reset ready matrix bits for f0_0, f1 and f2
58 // // reset ready matrix bits for f0_0, f1 and f2
59 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010
59 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010
60
60
61 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
61 // if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
62 {
62 // {
63 ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0;
63 // ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0;
64 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
64 // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
65 {
65 // {
66 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
66 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
67 }
67 // }
68 nb_sm_f0 = 0;
68 // nb_sm_f0 = 0;
69 }
69 // }
70
70
71 }
71 }
72
72
73 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
73 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
74 {
74 {
75 //***
75 //***
76 // F0
76 // F0
77 nb_sm_f0 = nb_sm_f0 + 1;
77 nb_sm_f0 = nb_sm_f0 + 1;
78 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
78 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
79 {
79 {
80 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
80 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
81 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
81 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
82 {
82 {
83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
84 }
84 }
85 nb_sm_f0 = 0;
85 nb_sm_f0 = 0;
86 }
86 }
87
87
88 //***
88 //***
89 // F1
89 // F1
90 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
90 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
91 if (nb_sm_f0_aux_f1 == 6)
91 if (nb_sm_f0_aux_f1 == 6)
92 {
92 {
93 nb_sm_f0_aux_f1 = 0;
93 nb_sm_f0_aux_f1 = 0;
94 nb_sm_f1 = nb_sm_f1 + 1;
94 nb_sm_f1 = nb_sm_f1 + 1;
95 }
95 }
96 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
96 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
97 {
97 {
98 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
98 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
99 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
99 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
100 {
100 {
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
102 }
102 }
103 nb_sm_f1 = 0;
103 nb_sm_f1 = 0;
104 }
104 }
105
105
106 //***
106 //***
107 // F2
107 // F2
108 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
108 // nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
109 if (nb_sm_f0_aux_f2 == 96)
109 // if (nb_sm_f0_aux_f2 == 96)
110 {
110 // {
111 nb_sm_f0_aux_f2 = 0;
111 // nb_sm_f0_aux_f2 = 0;
112 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
112 // ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
113 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
113 // if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
114 {
114 // {
115 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
115 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
116 }
116 // }
117 }
117 // }
118 }
118 }
119
119
120 //******************
120 //******************
121 // Spectral Matrices
121 // Spectral Matrices
122
122
123 void reset_nb_sm( void )
123 void reset_nb_sm( void )
124 {
124 {
125 nb_sm_f0 = 0;
125 nb_sm_f0 = 0;
126 nb_sm_f0_aux_f1 = 0;
126 nb_sm_f0_aux_f1 = 0;
127 nb_sm_f0_aux_f2 = 0;
127 nb_sm_f0_aux_f2 = 0;
128
128
129 nb_sm_f1 = 0;
129 nb_sm_f1 = 0;
130 }
130 }
131
131
132 void SM_init_rings( void )
132 void SM_init_rings( void )
133 {
133 {
134 unsigned char i;
134 unsigned char i;
135
135
136 // F0 RING
136 // F0 RING
137 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
137 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
138 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
138 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
139 sm_ring_f0[0].buffer_address =
139 sm_ring_f0[0].buffer_address =
140 (int) &sm_f0[ 0 ];
140 (int) &sm_f0[ 0 ];
141
141
142 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
142 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
143 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
143 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
144 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
144 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
145 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
145 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
146
146
147 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
147 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
148 {
148 {
149 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
149 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
150 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
150 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
151 sm_ring_f0[i].buffer_address =
151 sm_ring_f0[i].buffer_address =
152 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
152 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
153 }
153 }
154
154
155 // F1 RING
155 // F1 RING
156 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
156 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
157 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
157 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
158 sm_ring_f1[0].buffer_address =
158 sm_ring_f1[0].buffer_address =
159 (int) &sm_f1[ 0 ];
159 (int) &sm_f1[ 0 ];
160
160
161 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
161 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
162 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
162 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
163 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
163 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
164 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
164 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
165
165
166 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
166 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
167 {
167 {
168 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
168 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
169 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
169 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
170 sm_ring_f1[i].buffer_address =
170 sm_ring_f1[i].buffer_address =
171 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
171 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
172 }
172 }
173
173
174 // F2 RING
174 // F2 RING
175 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
175 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
176 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
176 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
177 sm_ring_f2[0].buffer_address =
177 sm_ring_f2[0].buffer_address =
178 (int) &sm_f2[ 0 ];
178 (int) &sm_f2[ 0 ];
179
179
180 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
180 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
181 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
181 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
182 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
182 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
183 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
183 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
184
184
185 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
185 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
186 {
186 {
187 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
187 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
188 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
188 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
189 sm_ring_f2[i].buffer_address =
189 sm_ring_f2[i].buffer_address =
190 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
190 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
191 }
191 }
192
192
193 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
193 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
194 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
194 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
195 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
195 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
196
196
197 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
197 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
198 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
198 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
199 }
199 }
200
200
201 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
201 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
202 {
202 {
203 unsigned char i;
203 unsigned char i;
204
204
205 ring[ nbNodes - 1 ].next
205 ring[ nbNodes - 1 ].next
206 = (ring_node_asm*) &ring[ 0 ];
206 = (ring_node_asm*) &ring[ 0 ];
207
207
208 for(i=0; i<nbNodes-1; i++)
208 for(i=0; i<nbNodes-1; i++)
209 {
209 {
210 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
210 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
211 }
211 }
212 }
212 }
213
213
214 void SM_reset_current_ring_nodes( void )
214 void SM_reset_current_ring_nodes( void )
215 {
215 {
216 current_ring_node_sm_f0 = sm_ring_f0;
216 current_ring_node_sm_f0 = sm_ring_f0;
217 current_ring_node_sm_f1 = sm_ring_f1;
217 current_ring_node_sm_f1 = sm_ring_f1;
218 current_ring_node_sm_f2 = sm_ring_f2;
218 current_ring_node_sm_f2 = sm_ring_f2;
219
219
220 ring_node_for_averaging_sm_f0 = sm_ring_f0;
220 ring_node_for_averaging_sm_f0 = sm_ring_f0;
221 ring_node_for_averaging_sm_f1 = sm_ring_f1;
222 ring_node_for_averaging_sm_f2 = sm_ring_f2;
221 }
223 }
222
224
223 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
225 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
224 {
226 {
225 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
227 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
226 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
228 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
227 header->reserved = 0x00;
229 header->reserved = 0x00;
228 header->userApplication = CCSDS_USER_APP;
230 header->userApplication = CCSDS_USER_APP;
229 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
231 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
230 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
232 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
231 header->packetSequenceControl[0] = 0xc0;
233 header->packetSequenceControl[0] = 0xc0;
232 header->packetSequenceControl[1] = 0x00;
234 header->packetSequenceControl[1] = 0x00;
233 header->packetLength[0] = 0x00;
235 header->packetLength[0] = 0x00;
234 header->packetLength[1] = 0x00;
236 header->packetLength[1] = 0x00;
235 // DATA FIELD HEADER
237 // DATA FIELD HEADER
236 header->spare1_pusVersion_spare2 = 0x10;
238 header->spare1_pusVersion_spare2 = 0x10;
237 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
239 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
238 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
240 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
239 header->destinationID = TM_DESTINATION_ID_GROUND;
241 header->destinationID = TM_DESTINATION_ID_GROUND;
240 // AUXILIARY DATA HEADER
242 // AUXILIARY DATA HEADER
241 header->sid = 0x00;
243 header->sid = 0x00;
242 header->biaStatusInfo = 0x00;
244 header->biaStatusInfo = 0x00;
243 header->pa_lfr_pkt_cnt_asm = 0x00;
245 header->pa_lfr_pkt_cnt_asm = 0x00;
244 header->pa_lfr_pkt_nr_asm = 0x00;
246 header->pa_lfr_pkt_nr_asm = 0x00;
245 header->time[0] = 0x00;
247 header->time[0] = 0x00;
246 header->time[0] = 0x00;
248 header->time[0] = 0x00;
247 header->time[0] = 0x00;
249 header->time[0] = 0x00;
248 header->time[0] = 0x00;
250 header->time[0] = 0x00;
249 header->time[0] = 0x00;
251 header->time[0] = 0x00;
250 header->time[0] = 0x00;
252 header->time[0] = 0x00;
251 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
253 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
252 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
254 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
253 }
255 }
254
256
255 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
256 ring_node_sm *ring_node_tab[],
257 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
258 {
259 float sum;
260 unsigned int i;
261
262 for(i=0; i<TOTAL_SIZE_SM; i++)
263 {
264 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
265 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
266 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
267 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
268 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
269 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
270 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
271 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
272
273 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
274 {
275 averaged_spec_mat_f0[ i ] = sum;
276 averaged_spec_mat_f1[ i ] = sum;
277 }
278 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
279 {
280 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
281 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
282 }
283 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
284 {
285 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
286 averaged_spec_mat_f1[ i ] = sum;
287 }
288 else
289 {
290 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
291 }
292 }
293 }
294
295 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
257 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
296 {
258 {
297 int frequencyBin;
259 int frequencyBin;
298 int asmComponent;
260 int asmComponent;
299 unsigned int offsetAveragedSpecMatReorganized;
261 unsigned int offsetAveragedSpecMatReorganized;
300 unsigned int offsetAveragedSpecMat;
262 unsigned int offsetAveragedSpecMat;
301
263
302 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
264 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
303 {
265 {
304 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
266 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
305 {
267 {
306 offsetAveragedSpecMatReorganized =
268 offsetAveragedSpecMatReorganized =
307 frequencyBin * NB_VALUES_PER_SM
269 frequencyBin * NB_VALUES_PER_SM
308 + asmComponent;
270 + asmComponent;
309 offsetAveragedSpecMat =
271 offsetAveragedSpecMat =
310 asmComponent * NB_BINS_PER_SM
272 asmComponent * NB_BINS_PER_SM
311 + frequencyBin;
273 + frequencyBin;
312 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
274 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
313 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
275 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
314 }
276 }
315 }
277 }
316 }
278 }
317
279
318 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
280 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
319 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
281 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
320 {
282 {
321 int frequencyBin;
283 int frequencyBin;
322 int asmComponent;
284 int asmComponent;
323 int offsetASM;
285 int offsetASM;
324 int offsetCompressed;
286 int offsetCompressed;
325 int k;
287 int k;
326
288
327 // build data
289 // build data
328 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
290 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
329 {
291 {
330 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
292 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
331 {
293 {
332 offsetCompressed = // NO TIME OFFSET
294 offsetCompressed = // NO TIME OFFSET
333 frequencyBin * NB_VALUES_PER_SM
295 frequencyBin * NB_VALUES_PER_SM
334 + asmComponent;
296 + asmComponent;
335 offsetASM = // NO TIME OFFSET
297 offsetASM = // NO TIME OFFSET
336 asmComponent * NB_BINS_PER_SM
298 asmComponent * NB_BINS_PER_SM
337 + ASMIndexStart
299 + ASMIndexStart
338 + frequencyBin * nbBinsToAverage;
300 + frequencyBin * nbBinsToAverage;
339 compressed_spec_mat[ offsetCompressed ] = 0;
301 compressed_spec_mat[ offsetCompressed ] = 0;
340 for ( k = 0; k < nbBinsToAverage; k++ )
302 for ( k = 0; k < nbBinsToAverage; k++ )
341 {
303 {
342 compressed_spec_mat[offsetCompressed ] =
304 compressed_spec_mat[offsetCompressed ] =
343 ( compressed_spec_mat[ offsetCompressed ]
305 ( compressed_spec_mat[ offsetCompressed ]
344 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
306 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
345 }
307 }
346 }
308 }
347 }
309 }
348 }
310 }
349
311
350 void ASM_convert( volatile float *input_matrix, char *output_matrix)
312 void ASM_convert( volatile float *input_matrix, char *output_matrix)
351 {
313 {
352 unsigned int frequencyBin;
314 unsigned int frequencyBin;
353 unsigned int asmComponent;
315 unsigned int asmComponent;
354 char * pt_char_input;
316 char * pt_char_input;
355 char * pt_char_output;
317 char * pt_char_output;
356 unsigned int offsetInput;
318 unsigned int offsetInput;
357 unsigned int offsetOutput;
319 unsigned int offsetOutput;
358
320
359 pt_char_input = (char*) &input_matrix;
321 pt_char_input = (char*) &input_matrix;
360 pt_char_output = (char*) &output_matrix;
322 pt_char_output = (char*) &output_matrix;
361
323
362 // convert all other data
324 // convert all other data
363 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
325 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
364 {
326 {
365 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
327 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
366 {
328 {
367 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
329 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
368 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
330 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
369 pt_char_input = (char*) &input_matrix [ offsetInput ];
331 pt_char_input = (char*) &input_matrix [ offsetInput ];
370 pt_char_output = (char*) &output_matrix[ offsetOutput ];
332 pt_char_output = (char*) &output_matrix[ offsetOutput ];
371 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
333 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
372 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
334 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
373 }
335 }
374 }
336 }
375 }
337 }
376
338
377 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
339 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
378 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
340 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
379 {
341 {
380 unsigned int i;
342 unsigned int i;
381 unsigned int length = 0;
343 unsigned int length = 0;
382 rtems_status_code status;
344 rtems_status_code status;
383
345
384 for (i=0; i<2; i++)
346 for (i=0; i<2; i++)
385 {
347 {
386 // (1) BUILD THE DATA
348 // (1) BUILD THE DATA
387 switch(sid)
349 switch(sid)
388 {
350 {
389 case SID_NORM_ASM_F0:
351 case SID_NORM_ASM_F0:
390 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
352 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
391 spw_ioctl_send->data = &spectral_matrix[
353 spw_ioctl_send->data = &spectral_matrix[
392 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
354 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
393 ];
355 ];
394 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
356 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
395 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
357 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
396 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
358 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
397 break;
359 break;
398 case SID_NORM_ASM_F1:
360 case SID_NORM_ASM_F1:
399 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
361 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
400 spw_ioctl_send->data = &spectral_matrix[
362 spw_ioctl_send->data = &spectral_matrix[
401 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
363 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
402 ];
364 ];
403 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
365 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
404 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
366 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
405 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
367 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
406 break;
368 break;
407 case SID_NORM_ASM_F2:
369 case SID_NORM_ASM_F2:
408 break;
370 break;
409 default:
371 default:
410 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
372 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
411 break;
373 break;
412 }
374 }
413 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
375 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
414 spw_ioctl_send->hdr = (char *) header;
376 spw_ioctl_send->hdr = (char *) header;
415 spw_ioctl_send->options = 0;
377 spw_ioctl_send->options = 0;
416
378
417 // (2) BUILD THE HEADER
379 // (2) BUILD THE HEADER
418 header->packetLength[0] = (unsigned char) (length>>8);
380 header->packetLength[0] = (unsigned char) (length>>8);
419 header->packetLength[1] = (unsigned char) (length);
381 header->packetLength[1] = (unsigned char) (length);
420 header->sid = (unsigned char) sid; // SID
382 header->sid = (unsigned char) sid; // SID
421 header->pa_lfr_pkt_cnt_asm = 2;
383 header->pa_lfr_pkt_cnt_asm = 2;
422 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
384 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
423
385
424 // (3) SET PACKET TIME
386 // (3) SET PACKET TIME
425 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
387 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
426 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
388 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
427 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
389 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
428 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
390 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
429 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
391 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
430 header->time[5] = (unsigned char) (time_management_regs->fine_time);
392 header->time[5] = (unsigned char) (time_management_regs->fine_time);
431 //
393 //
432 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
394 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
433 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
395 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
434 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
396 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
435 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
397 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
436 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
398 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
437 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
399 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
438
400
439 // (4) SEND PACKET
401 // (4) SEND PACKET
440 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
402 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
441 if (status != RTEMS_SUCCESSFUL) {
403 if (status != RTEMS_SUCCESSFUL) {
442 printf("in ASM_send *** ERR %d\n", (int) status);
404 printf("in ASM_send *** ERR %d\n", (int) status);
443 }
405 }
444 }
406 }
445 }
407 }
446
408
447 //*****************
409 //*****************
448 // Basic Parameters
410 // Basic Parameters
449
411
450 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
412 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
451 unsigned int apid, unsigned char sid,
413 unsigned int apid, unsigned char sid,
452 unsigned int packetLength, unsigned char blkNr )
414 unsigned int packetLength, unsigned char blkNr )
453 {
415 {
454 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
416 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
455 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
417 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
456 header->reserved = 0x00;
418 header->reserved = 0x00;
457 header->userApplication = CCSDS_USER_APP;
419 header->userApplication = CCSDS_USER_APP;
458 header->packetID[0] = (unsigned char) (apid >> 8);
420 header->packetID[0] = (unsigned char) (apid >> 8);
459 header->packetID[1] = (unsigned char) (apid);
421 header->packetID[1] = (unsigned char) (apid);
460 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
422 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
461 header->packetSequenceControl[1] = 0x00;
423 header->packetSequenceControl[1] = 0x00;
462 header->packetLength[0] = (unsigned char) (packetLength >> 8);
424 header->packetLength[0] = (unsigned char) (packetLength >> 8);
463 header->packetLength[1] = (unsigned char) (packetLength);
425 header->packetLength[1] = (unsigned char) (packetLength);
464 // DATA FIELD HEADER
426 // DATA FIELD HEADER
465 header->spare1_pusVersion_spare2 = 0x10;
427 header->spare1_pusVersion_spare2 = 0x10;
466 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
428 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
467 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
429 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
468 header->destinationID = TM_DESTINATION_ID_GROUND;
430 header->destinationID = TM_DESTINATION_ID_GROUND;
469 // AUXILIARY DATA HEADER
431 // AUXILIARY DATA HEADER
470 header->sid = sid;
432 header->sid = sid;
471 header->biaStatusInfo = 0x00;
433 header->biaStatusInfo = 0x00;
472 header->time[0] = 0x00;
434 header->time[0] = 0x00;
473 header->time[0] = 0x00;
435 header->time[0] = 0x00;
474 header->time[0] = 0x00;
436 header->time[0] = 0x00;
475 header->time[0] = 0x00;
437 header->time[0] = 0x00;
476 header->time[0] = 0x00;
438 header->time[0] = 0x00;
477 header->time[0] = 0x00;
439 header->time[0] = 0x00;
478 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
440 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
479 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
441 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
480 }
442 }
481
443
482 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
444 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
483 unsigned int apid, unsigned char sid,
445 unsigned int apid, unsigned char sid,
484 unsigned int packetLength , unsigned char blkNr)
446 unsigned int packetLength , unsigned char blkNr)
485 {
447 {
486 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
448 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
487 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
449 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
488 header->reserved = 0x00;
450 header->reserved = 0x00;
489 header->userApplication = CCSDS_USER_APP;
451 header->userApplication = CCSDS_USER_APP;
490 header->packetID[0] = (unsigned char) (apid >> 8);
452 header->packetID[0] = (unsigned char) (apid >> 8);
491 header->packetID[1] = (unsigned char) (apid);
453 header->packetID[1] = (unsigned char) (apid);
492 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
454 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
493 header->packetSequenceControl[1] = 0x00;
455 header->packetSequenceControl[1] = 0x00;
494 header->packetLength[0] = (unsigned char) (packetLength >> 8);
456 header->packetLength[0] = (unsigned char) (packetLength >> 8);
495 header->packetLength[1] = (unsigned char) (packetLength);
457 header->packetLength[1] = (unsigned char) (packetLength);
496 // DATA FIELD HEADER
458 // DATA FIELD HEADER
497 header->spare1_pusVersion_spare2 = 0x10;
459 header->spare1_pusVersion_spare2 = 0x10;
498 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
460 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
499 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
461 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
500 header->destinationID = TM_DESTINATION_ID_GROUND;
462 header->destinationID = TM_DESTINATION_ID_GROUND;
501 // AUXILIARY DATA HEADER
463 // AUXILIARY DATA HEADER
502 header->sid = sid;
464 header->sid = sid;
503 header->biaStatusInfo = 0x00;
465 header->biaStatusInfo = 0x00;
504 header->time[0] = 0x00;
466 header->time[0] = 0x00;
505 header->time[0] = 0x00;
467 header->time[0] = 0x00;
506 header->time[0] = 0x00;
468 header->time[0] = 0x00;
507 header->time[0] = 0x00;
469 header->time[0] = 0x00;
508 header->time[0] = 0x00;
470 header->time[0] = 0x00;
509 header->time[0] = 0x00;
471 header->time[0] = 0x00;
510 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
472 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
511 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
473 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
512 }
474 }
513
475
514 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
476 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
515 {
477 {
516 rtems_status_code status;
478 rtems_status_code status;
517
479
518 // SEND PACKET
480 // SEND PACKET
519 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
481 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
520 if (status != RTEMS_SUCCESSFUL)
482 if (status != RTEMS_SUCCESSFUL)
521 {
483 {
522 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
484 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
523 }
485 }
524 }
486 }
525
487
526 //******************
488 //******************
527 // general functions
489 // general functions
528
490
529 void reset_spectral_matrix_regs( void )
491 void reset_spectral_matrix_regs( void )
530 {
492 {
531 /** This function resets the spectral matrices module registers.
493 /** This function resets the spectral matrices module registers.
532 *
494 *
533 * The registers affected by this function are located at the following offset addresses:
495 * The registers affected by this function are located at the following offset addresses:
534 *
496 *
535 * - 0x00 config
497 * - 0x00 config
536 * - 0x04 status
498 * - 0x04 status
537 * - 0x08 matrixF0_Address0
499 * - 0x08 matrixF0_Address0
538 * - 0x10 matrixFO_Address1
500 * - 0x10 matrixFO_Address1
539 * - 0x14 matrixF1_Address
501 * - 0x14 matrixF1_Address
540 * - 0x18 matrixF2_Address
502 * - 0x18 matrixF2_Address
541 *
503 *
542 */
504 */
543
505
544 spectral_matrix_regs->config = 0x00;
506 spectral_matrix_regs->config = 0x00;
545 spectral_matrix_regs->status = 0x00;
507 spectral_matrix_regs->status = 0x00;
546
508
547 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
509 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
548 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
510 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
549 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
511 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
550 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
512 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
551 }
513 }
552
514
553 void set_time( unsigned char *time, unsigned char * timeInBuffer )
515 void set_time( unsigned char *time, unsigned char * timeInBuffer )
554 {
516 {
555 // time[0] = timeInBuffer[2];
517 // time[0] = timeInBuffer[2];
556 // time[1] = timeInBuffer[3];
518 // time[1] = timeInBuffer[3];
557 // time[2] = timeInBuffer[0];
519 // time[2] = timeInBuffer[0];
558 // time[3] = timeInBuffer[1];
520 // time[3] = timeInBuffer[1];
559 // time[4] = timeInBuffer[6];
521 // time[4] = timeInBuffer[6];
560 // time[5] = timeInBuffer[7];
522 // time[5] = timeInBuffer[7];
561
523
562 time[0] = timeInBuffer[0];
524 time[0] = timeInBuffer[0];
563 time[1] = timeInBuffer[1];
525 time[1] = timeInBuffer[1];
564 time[2] = timeInBuffer[2];
526 time[2] = timeInBuffer[2];
565 time[3] = timeInBuffer[3];
527 time[3] = timeInBuffer[3];
566 time[4] = timeInBuffer[6];
528 time[4] = timeInBuffer[6];
567 time[5] = timeInBuffer[7];
529 time[5] = timeInBuffer[7];
568 }
530 }
569
531
570
532
@@ -1,108 +1,105
1 #ifndef FSW_PROCESSING_H_INCLUDED
1 #ifndef FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
2 #define FSW_PROCESSING_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <math.h>
6 #include <math.h>
7 #include <stdlib.h> // abs() is in the stdlib
7 #include <stdlib.h> // abs() is in the stdlib
8 #include <stdio.h> // printf()
8 #include <stdio.h> // printf()
9 #include <math.h>
9 #include <math.h>
10
10
11 #include "fsw_params.h"
11 #include "fsw_params.h"
12 #include "fsw_spacewire.h"
12 #include "fsw_spacewire.h"
13
13
14 typedef struct ring_node_sm
14 typedef struct ring_node_sm
15 {
15 {
16 struct ring_node_sm *previous;
16 struct ring_node_sm *previous;
17 struct ring_node_sm *next;
17 struct ring_node_sm *next;
18 int buffer_address;
18 int buffer_address;
19 unsigned int status;
19 unsigned int status;
20 unsigned int coarseTime;
20 unsigned int coarseTime;
21 unsigned int fineTime;
21 unsigned int fineTime;
22 } ring_node_sm;
22 } ring_node_sm;
23
23
24 typedef struct ring_node_asm
24 typedef struct ring_node_asm
25 {
25 {
26 struct ring_node_asm *next;
26 struct ring_node_asm *next;
27 float matrix[ TOTAL_SIZE_SM ];
27 float matrix[ TOTAL_SIZE_SM ];
28 unsigned int status;
28 unsigned int status;
29 } ring_node_asm;
29 } ring_node_asm;
30
30
31 typedef struct bp_packet
31 typedef struct bp_packet
32 {
32 {
33 Header_TM_LFR_SCIENCE_BP_t header;
33 Header_TM_LFR_SCIENCE_BP_t header;
34 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
34 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
35 } bp_packet;
35 } bp_packet;
36
36
37 typedef struct bp_packet_with_spare
37 typedef struct bp_packet_with_spare
38 {
38 {
39 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
39 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
40 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
40 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
41 } bp_packet_with_spare;
41 } bp_packet_with_spare;
42
42
43 typedef struct asm_msg
43 typedef struct asm_msg
44 {
44 {
45 ring_node_asm *norm;
45 ring_node_asm *norm;
46 ring_node_asm *burst_sbm;
46 ring_node_asm *burst_sbm;
47 rtems_event_set event;
47 rtems_event_set event;
48 unsigned int coarseTime;
48 unsigned int coarseTime;
49 unsigned int fineTime;
49 unsigned int fineTime;
50 } asm_msg;
50 } asm_msg;
51
51
52 extern volatile int sm_f0[ ];
52 extern volatile int sm_f0[ ];
53 extern volatile int sm_f1[ ];
53 extern volatile int sm_f1[ ];
54 extern volatile int sm_f2[ ];
54 extern volatile int sm_f2[ ];
55
55
56 // parameters
56 // parameters
57 extern struct param_local_str param_local;
57 extern struct param_local_str param_local;
58
58
59 // registers
59 // registers
60 extern time_management_regs_t *time_management_regs;
60 extern time_management_regs_t *time_management_regs;
61 extern spectral_matrix_regs_t *spectral_matrix_regs;
61 extern spectral_matrix_regs_t *spectral_matrix_regs;
62
62
63 extern rtems_name misc_name[5];
63 extern rtems_name misc_name[5];
64 extern rtems_id Task_id[20]; /* array of task ids */
64 extern rtems_id Task_id[20]; /* array of task ids */
65
65
66 // ISR
66 // ISR
67 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
67 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
68 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
68 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
69
69
70 //******************
70 //******************
71 // Spectral Matrices
71 // Spectral Matrices
72 void reset_nb_sm( void );
72 void reset_nb_sm( void );
73 void SM_init_rings( void );
73 void SM_init_rings( void );
74 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
74 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
75 void SM_reset_current_ring_nodes( void );
75 void SM_reset_current_ring_nodes( void );
76 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
76 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
77 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
78 ring_node_sm *ring_node_tab[],
79 unsigned int firstTimeF0, unsigned int firstTimeF1 );
80 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
77 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
81 float divider );
78 float divider );
82 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
79 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
83 float divider,
80 float divider,
84 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
81 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
85 void ASM_convert(volatile float *input_matrix, char *output_matrix);
82 void ASM_convert(volatile float *input_matrix, char *output_matrix);
86 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
83 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
87 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
84 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
88
85
89 //*****************
86 //*****************
90 // Basic Parameters
87 // Basic Parameters
91
88
92 void BP_reset_current_ring_nodes( void );
89 void BP_reset_current_ring_nodes( void );
93 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
90 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
94 unsigned int apid, unsigned char sid,
91 unsigned int apid, unsigned char sid,
95 unsigned int packetLength , unsigned char blkNr);
92 unsigned int packetLength , unsigned char blkNr);
96 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
93 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
97 unsigned int apid, unsigned char sid,
94 unsigned int apid, unsigned char sid,
98 unsigned int packetLength, unsigned char blkNr );
95 unsigned int packetLength, unsigned char blkNr );
99 void BP_send(char *data,
96 void BP_send(char *data,
100 rtems_id queue_id ,
97 rtems_id queue_id ,
101 unsigned int nbBytesToSend );
98 unsigned int nbBytesToSend );
102
99
103 //******************
100 //******************
104 // general functions
101 // general functions
105 void reset_spectral_matrix_regs( void );
102 void reset_spectral_matrix_regs( void );
106 void set_time(unsigned char *time, unsigned char *timeInBuffer );
103 void set_time(unsigned char *time, unsigned char *timeInBuffer );
107
104
108 #endif // FSW_PROCESSING_H_INCLUDED
105 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,767 +1,767
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_PERIODS 5
36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #ifdef PRINT_STACK_REPORT
39 #ifdef PRINT_STACK_REPORT
40 #define CONFIGURE_STACK_CHECKER_ENABLED
40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #endif
41 #endif
42
42
43 #include <rtems/confdefs.h>
43 #include <rtems/confdefs.h>
44
44
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 #ifdef RTEMS_DRVMGR_STARTUP
46 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef LEON3
47 #ifdef LEON3
48 /* Add Timer and UART Driver */
48 /* Add Timer and UART Driver */
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #endif
51 #endif
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #endif
54 #endif
55 #endif
55 #endif
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #include <drvmgr/drvmgr_confdefs.h>
57 #include <drvmgr/drvmgr_confdefs.h>
58 #endif
58 #endif
59
59
60 #include "fsw_init.h"
60 #include "fsw_init.h"
61 #include "fsw_config.c"
61 #include "fsw_config.c"
62
62
63 rtems_task Init( rtems_task_argument ignored )
63 rtems_task Init( rtems_task_argument ignored )
64 {
64 {
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 *
66 *
67 * @param unused is the starting argument of the RTEMS task
67 * @param unused is the starting argument of the RTEMS task
68 *
68 *
69 * The INIT task create and run all other RTEMS tasks.
69 * The INIT task create and run all other RTEMS tasks.
70 *
70 *
71 */
71 */
72
72
73 reset_local_time();
73 reset_local_time();
74
74
75 rtems_status_code status;
75 rtems_status_code status;
76 rtems_status_code status_spw;
76 rtems_status_code status_spw;
77 rtems_isr_entry old_isr_handler;
77 rtems_isr_entry old_isr_handler;
78
78
79 // UART settings
79 // UART settings
80 send_console_outputs_on_apbuart_port();
80 send_console_outputs_on_apbuart_port();
81 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
81 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
82 enable_apbuart_transmitter();
82 enable_apbuart_transmitter();
83 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
83 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
84
84
85 PRINTF("\n\n\n\n\n")
85 PRINTF("\n\n\n\n\n")
86 PRINTF("*************************\n")
86 PRINTF("*************************\n")
87 PRINTF("** LFR Flight Software **\n")
87 PRINTF("** LFR Flight Software **\n")
88 PRINTF1("** %d.", SW_VERSION_N1)
88 PRINTF1("** %d.", SW_VERSION_N1)
89 PRINTF1("%d." , SW_VERSION_N2)
89 PRINTF1("%d." , SW_VERSION_N2)
90 PRINTF1("%d." , SW_VERSION_N3)
90 PRINTF1("%d." , SW_VERSION_N3)
91 PRINTF1("%d **\n", SW_VERSION_N4)
91 PRINTF1("%d **\n", SW_VERSION_N4)
92 PRINTF("*************************\n")
92 PRINTF("*************************\n")
93 PRINTF("\n\n")
93 PRINTF("\n\n")
94
94
95 init_parameter_dump();
95 init_parameter_dump();
96 init_local_mode_parameters();
96 init_local_mode_parameters();
97 init_housekeeping_parameters();
97 init_housekeeping_parameters();
98
98
99 init_waveform_rings(); // initialize the waveform rings
99 init_waveform_rings(); // initialize the waveform rings
100 SM_init_rings(); // initialize spectral matrices rings
100 SM_init_rings(); // initialize spectral matrices rings
101
101
102 reset_wfp_burst_enable();
102 reset_wfp_burst_enable();
103 reset_wfp_status();
103 reset_wfp_status();
104 set_wfp_data_shaping();
104 set_wfp_data_shaping();
105
105
106 updateLFRCurrentMode();
106 updateLFRCurrentMode();
107
107
108 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
108 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
109
109
110 create_names(); // create all names
110 create_names(); // create all names
111
111
112 status = create_message_queues(); // create message queues
112 status = create_message_queues(); // create message queues
113 if (status != RTEMS_SUCCESSFUL)
113 if (status != RTEMS_SUCCESSFUL)
114 {
114 {
115 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
115 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
116 }
116 }
117
117
118 status = create_all_tasks(); // create all tasks
118 status = create_all_tasks(); // create all tasks
119 if (status != RTEMS_SUCCESSFUL)
119 if (status != RTEMS_SUCCESSFUL)
120 {
120 {
121 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
121 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
122 }
122 }
123
123
124 // **************************
124 // **************************
125 // <SPACEWIRE INITIALIZATION>
125 // <SPACEWIRE INITIALIZATION>
126 grspw_timecode_callback = &timecode_irq_handler;
126 grspw_timecode_callback = &timecode_irq_handler;
127
127
128 status_spw = spacewire_open_link(); // (1) open the link
128 status_spw = spacewire_open_link(); // (1) open the link
129 if ( status_spw != RTEMS_SUCCESSFUL )
129 if ( status_spw != RTEMS_SUCCESSFUL )
130 {
130 {
131 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
131 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
132 }
132 }
133
133
134 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
134 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
135 {
135 {
136 status_spw = spacewire_configure_link( fdSPW );
136 status_spw = spacewire_configure_link( fdSPW );
137 if ( status_spw != RTEMS_SUCCESSFUL )
137 if ( status_spw != RTEMS_SUCCESSFUL )
138 {
138 {
139 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
139 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
140 }
140 }
141 }
141 }
142
142
143 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
143 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
144 {
144 {
145 status_spw = spacewire_start_link( fdSPW );
145 status_spw = spacewire_start_link( fdSPW );
146 if ( status_spw != RTEMS_SUCCESSFUL )
146 if ( status_spw != RTEMS_SUCCESSFUL )
147 {
147 {
148 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
148 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
149 }
149 }
150 }
150 }
151 // </SPACEWIRE INITIALIZATION>
151 // </SPACEWIRE INITIALIZATION>
152 // ***************************
152 // ***************************
153
153
154 status = start_all_tasks(); // start all tasks
154 status = start_all_tasks(); // start all tasks
155 if (status != RTEMS_SUCCESSFUL)
155 if (status != RTEMS_SUCCESSFUL)
156 {
156 {
157 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
157 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
158 }
158 }
159
159
160 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
160 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
161 status = start_recv_send_tasks();
161 status = start_recv_send_tasks();
162 if ( status != RTEMS_SUCCESSFUL )
162 if ( status != RTEMS_SUCCESSFUL )
163 {
163 {
164 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
164 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
165 }
165 }
166
166
167 // suspend science tasks, they will be restarted later depending on the mode
167 // suspend science tasks, they will be restarted later depending on the mode
168 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
168 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
169 if (status != RTEMS_SUCCESSFUL)
169 if (status != RTEMS_SUCCESSFUL)
170 {
170 {
171 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
171 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
172 }
172 }
173
173
174 //******************************
174 //******************************
175 // <SPECTRAL MATRICES SIMULATOR>
175 // <SPECTRAL MATRICES SIMULATOR>
176 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
176 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
177 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
177 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
178 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
178 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
179 // </SPECTRAL MATRICES SIMULATOR>
179 // </SPECTRAL MATRICES SIMULATOR>
180 //*******************************
180 //*******************************
181
181
182 // configure IRQ handling for the waveform picker unit
182 // configure IRQ handling for the waveform picker unit
183 status = rtems_interrupt_catch( waveforms_isr,
183 status = rtems_interrupt_catch( waveforms_isr,
184 IRQ_SPARC_WAVEFORM_PICKER,
184 IRQ_SPARC_WAVEFORM_PICKER,
185 &old_isr_handler) ;
185 &old_isr_handler) ;
186 // configure IRQ handling for the spectral matrices unit
186 // configure IRQ handling for the spectral matrices unit
187 status = rtems_interrupt_catch( spectral_matrices_isr,
187 status = rtems_interrupt_catch( spectral_matrices_isr,
188 IRQ_SPARC_SPECTRAL_MATRIX,
188 IRQ_SPARC_SPECTRAL_MATRIX,
189 &old_isr_handler) ;
189 &old_isr_handler) ;
190
190
191 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
191 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
192 if ( status_spw != RTEMS_SUCCESSFUL )
192 if ( status_spw != RTEMS_SUCCESSFUL )
193 {
193 {
194 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
194 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
195 if ( status != RTEMS_SUCCESSFUL ) {
195 if ( status != RTEMS_SUCCESSFUL ) {
196 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
196 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
197 }
197 }
198 }
198 }
199
199
200 BOOT_PRINTF("delete INIT\n")
200 BOOT_PRINTF("delete INIT\n")
201
201
202 send_dumb_hk();
202 send_dumb_hk();
203
203
204 status = rtems_task_delete(RTEMS_SELF);
204 status = rtems_task_delete(RTEMS_SELF);
205
205
206 }
206 }
207
207
208 void init_local_mode_parameters( void )
208 void init_local_mode_parameters( void )
209 {
209 {
210 /** This function initialize the param_local global variable with default values.
210 /** This function initialize the param_local global variable with default values.
211 *
211 *
212 */
212 */
213
213
214 unsigned int i;
214 unsigned int i;
215
215
216 // LOCAL PARAMETERS
216 // LOCAL PARAMETERS
217 set_local_nb_interrupt_f0_MAX();
217 set_local_nb_interrupt_f0_MAX();
218
218
219 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
219 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
220 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
220 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
221 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
221 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
222
222
223 // init sequence counters
223 // init sequence counters
224
224
225 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
225 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
226 {
226 {
227 sequenceCounters_TC_EXE[i] = 0x00;
227 sequenceCounters_TC_EXE[i] = 0x00;
228 }
228 }
229 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
229 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
230 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
230 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
231 }
231 }
232
232
233 void reset_local_time( void )
233 void reset_local_time( void )
234 {
234 {
235 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
235 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
236 }
236 }
237
237
238 void create_names( void ) // create all names for tasks and queues
238 void create_names( void ) // create all names for tasks and queues
239 {
239 {
240 /** This function creates all RTEMS names used in the software for tasks and queues.
240 /** This function creates all RTEMS names used in the software for tasks and queues.
241 *
241 *
242 * @return RTEMS directive status codes:
242 * @return RTEMS directive status codes:
243 * - RTEMS_SUCCESSFUL - successful completion
243 * - RTEMS_SUCCESSFUL - successful completion
244 *
244 *
245 */
245 */
246
246
247 // task names
247 // task names
248 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
248 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
249 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
249 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
250 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
250 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
251 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
251 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
252 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
252 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
253 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
253 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
254 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
254 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
255 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
255 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
256 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
256 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
257 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
257 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
258 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
258 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
259 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
259 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
260 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
260 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
261 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
261 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
262 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
262 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
263 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
263 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
264 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
264 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
265 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
265 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
266 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
266 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
267
267
268 // rate monotonic period names
268 // rate monotonic period names
269 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
269 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
270
270
271 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
271 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
272 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
272 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
273 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
273 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
274 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
274 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
275 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
275 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
276 }
276 }
277
277
278 int create_all_tasks( void ) // create all tasks which run in the software
278 int create_all_tasks( void ) // create all tasks which run in the software
279 {
279 {
280 /** This function creates all RTEMS tasks used in the software.
280 /** This function creates all RTEMS tasks used in the software.
281 *
281 *
282 * @return RTEMS directive status codes:
282 * @return RTEMS directive status codes:
283 * - RTEMS_SUCCESSFUL - task created successfully
283 * - RTEMS_SUCCESSFUL - task created successfully
284 * - RTEMS_INVALID_ADDRESS - id is NULL
284 * - RTEMS_INVALID_ADDRESS - id is NULL
285 * - RTEMS_INVALID_NAME - invalid task name
285 * - RTEMS_INVALID_NAME - invalid task name
286 * - RTEMS_INVALID_PRIORITY - invalid task priority
286 * - RTEMS_INVALID_PRIORITY - invalid task priority
287 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
287 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
288 * - RTEMS_TOO_MANY - too many tasks created
288 * - RTEMS_TOO_MANY - too many tasks created
289 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
289 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
290 * - RTEMS_TOO_MANY - too many global objects
290 * - RTEMS_TOO_MANY - too many global objects
291 *
291 *
292 */
292 */
293
293
294 rtems_status_code status;
294 rtems_status_code status;
295
295
296 //**********
296 //**********
297 // SPACEWIRE
297 // SPACEWIRE
298 // RECV
298 // RECV
299 status = rtems_task_create(
299 status = rtems_task_create(
300 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
300 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
301 RTEMS_DEFAULT_MODES,
301 RTEMS_DEFAULT_MODES,
302 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
302 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
303 );
303 );
304 if (status == RTEMS_SUCCESSFUL) // SEND
304 if (status == RTEMS_SUCCESSFUL) // SEND
305 {
305 {
306 status = rtems_task_create(
306 status = rtems_task_create(
307 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
307 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
308 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
308 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
309 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
309 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
310 );
310 );
311 }
311 }
312 if (status == RTEMS_SUCCESSFUL) // WTDG
312 if (status == RTEMS_SUCCESSFUL) // WTDG
313 {
313 {
314 status = rtems_task_create(
314 status = rtems_task_create(
315 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
315 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
316 RTEMS_DEFAULT_MODES,
316 RTEMS_DEFAULT_MODES,
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
318 );
318 );
319 }
319 }
320 if (status == RTEMS_SUCCESSFUL) // ACTN
320 if (status == RTEMS_SUCCESSFUL) // ACTN
321 {
321 {
322 status = rtems_task_create(
322 status = rtems_task_create(
323 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
323 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
324 RTEMS_DEFAULT_MODES,
324 RTEMS_DEFAULT_MODES,
325 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
325 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
326 );
326 );
327 }
327 }
328 if (status == RTEMS_SUCCESSFUL) // SPIQ
328 if (status == RTEMS_SUCCESSFUL) // SPIQ
329 {
329 {
330 status = rtems_task_create(
330 status = rtems_task_create(
331 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
331 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
332 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
332 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
333 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
333 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
334 );
334 );
335 }
335 }
336
336
337 //******************
337 //******************
338 // SPECTRAL MATRICES
338 // SPECTRAL MATRICES
339 if (status == RTEMS_SUCCESSFUL) // AVF0
339 if (status == RTEMS_SUCCESSFUL) // AVF0
340 {
340 {
341 status = rtems_task_create(
341 status = rtems_task_create(
342 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
342 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
343 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
343 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
344 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
344 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
345 );
345 );
346 }
346 }
347 if (status == RTEMS_SUCCESSFUL) // PRC0
347 if (status == RTEMS_SUCCESSFUL) // PRC0
348 {
348 {
349 status = rtems_task_create(
349 status = rtems_task_create(
350 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
350 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
351 RTEMS_DEFAULT_MODES,
351 RTEMS_DEFAULT_MODES,
352 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
352 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
353 );
353 );
354 }
354 }
355 if (status == RTEMS_SUCCESSFUL) // AVF1
355 if (status == RTEMS_SUCCESSFUL) // AVF1
356 {
356 {
357 status = rtems_task_create(
357 status = rtems_task_create(
358 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
358 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
359 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
359 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
360 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
360 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
361 );
361 );
362 }
362 }
363 if (status == RTEMS_SUCCESSFUL) // PRC1
363 if (status == RTEMS_SUCCESSFUL) // PRC1
364 {
364 {
365 status = rtems_task_create(
365 status = rtems_task_create(
366 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
366 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
367 RTEMS_DEFAULT_MODES,
367 RTEMS_DEFAULT_MODES,
368 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
368 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
369 );
369 );
370 }
370 }
371 if (status == RTEMS_SUCCESSFUL) // AVF2
371 if (status == RTEMS_SUCCESSFUL) // AVF2
372 {
372 {
373 status = rtems_task_create(
373 status = rtems_task_create(
374 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
374 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
375 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
375 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
376 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
376 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
377 );
377 );
378 }
378 }
379 if (status == RTEMS_SUCCESSFUL) // PRC2
379 if (status == RTEMS_SUCCESSFUL) // PRC2
380 {
380 {
381 status = rtems_task_create(
381 status = rtems_task_create(
382 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
382 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
383 RTEMS_DEFAULT_MODES,
383 RTEMS_DEFAULT_MODES,
384 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
384 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
385 );
385 );
386 }
386 }
387
387
388 //****************
388 //****************
389 // WAVEFORM PICKER
389 // WAVEFORM PICKER
390 if (status == RTEMS_SUCCESSFUL) // WFRM
390 if (status == RTEMS_SUCCESSFUL) // WFRM
391 {
391 {
392 status = rtems_task_create(
392 status = rtems_task_create(
393 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
393 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
394 RTEMS_DEFAULT_MODES,
394 RTEMS_DEFAULT_MODES,
395 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
395 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
396 );
396 );
397 }
397 }
398 if (status == RTEMS_SUCCESSFUL) // CWF3
398 if (status == RTEMS_SUCCESSFUL) // CWF3
399 {
399 {
400 status = rtems_task_create(
400 status = rtems_task_create(
401 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
401 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
402 RTEMS_DEFAULT_MODES,
402 RTEMS_DEFAULT_MODES,
403 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
403 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
404 );
404 );
405 }
405 }
406 if (status == RTEMS_SUCCESSFUL) // CWF2
406 if (status == RTEMS_SUCCESSFUL) // CWF2
407 {
407 {
408 status = rtems_task_create(
408 status = rtems_task_create(
409 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
409 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
410 RTEMS_DEFAULT_MODES,
410 RTEMS_DEFAULT_MODES,
411 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
411 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
412 );
412 );
413 }
413 }
414 if (status == RTEMS_SUCCESSFUL) // CWF1
414 if (status == RTEMS_SUCCESSFUL) // CWF1
415 {
415 {
416 status = rtems_task_create(
416 status = rtems_task_create(
417 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
417 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
418 RTEMS_DEFAULT_MODES,
418 RTEMS_DEFAULT_MODES,
419 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
419 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
420 );
420 );
421 }
421 }
422 if (status == RTEMS_SUCCESSFUL) // SWBD
422 if (status == RTEMS_SUCCESSFUL) // SWBD
423 {
423 {
424 status = rtems_task_create(
424 status = rtems_task_create(
425 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
425 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
426 RTEMS_DEFAULT_MODES,
426 RTEMS_DEFAULT_MODES,
427 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
427 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
428 );
428 );
429 }
429 }
430
430
431 //*****
431 //*****
432 // MISC
432 // MISC
433 if (status == RTEMS_SUCCESSFUL) // STAT
433 if (status == RTEMS_SUCCESSFUL) // STAT
434 {
434 {
435 status = rtems_task_create(
435 status = rtems_task_create(
436 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
436 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
437 RTEMS_DEFAULT_MODES,
437 RTEMS_DEFAULT_MODES,
438 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
438 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
439 );
439 );
440 }
440 }
441 if (status == RTEMS_SUCCESSFUL) // DUMB
441 if (status == RTEMS_SUCCESSFUL) // DUMB
442 {
442 {
443 status = rtems_task_create(
443 status = rtems_task_create(
444 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
444 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
445 RTEMS_DEFAULT_MODES,
445 RTEMS_DEFAULT_MODES,
446 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
446 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
447 );
447 );
448 }
448 }
449 if (status == RTEMS_SUCCESSFUL) // HOUS
449 if (status == RTEMS_SUCCESSFUL) // HOUS
450 {
450 {
451 status = rtems_task_create(
451 status = rtems_task_create(
452 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
452 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
453 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
453 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
454 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
454 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
455 );
455 );
456 }
456 }
457
457
458 return status;
458 return status;
459 }
459 }
460
460
461 int start_recv_send_tasks( void )
461 int start_recv_send_tasks( void )
462 {
462 {
463 rtems_status_code status;
463 rtems_status_code status;
464
464
465 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
465 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
466 if (status!=RTEMS_SUCCESSFUL) {
466 if (status!=RTEMS_SUCCESSFUL) {
467 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
467 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
468 }
468 }
469
469
470 if (status == RTEMS_SUCCESSFUL) // SEND
470 if (status == RTEMS_SUCCESSFUL) // SEND
471 {
471 {
472 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
472 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
473 if (status!=RTEMS_SUCCESSFUL) {
473 if (status!=RTEMS_SUCCESSFUL) {
474 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
474 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
475 }
475 }
476 }
476 }
477
477
478 return status;
478 return status;
479 }
479 }
480
480
481 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
481 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
482 {
482 {
483 /** This function starts all RTEMS tasks used in the software.
483 /** This function starts all RTEMS tasks used in the software.
484 *
484 *
485 * @return RTEMS directive status codes:
485 * @return RTEMS directive status codes:
486 * - RTEMS_SUCCESSFUL - ask started successfully
486 * - RTEMS_SUCCESSFUL - ask started successfully
487 * - RTEMS_INVALID_ADDRESS - invalid task entry point
487 * - RTEMS_INVALID_ADDRESS - invalid task entry point
488 * - RTEMS_INVALID_ID - invalid task id
488 * - RTEMS_INVALID_ID - invalid task id
489 * - RTEMS_INCORRECT_STATE - task not in the dormant state
489 * - RTEMS_INCORRECT_STATE - task not in the dormant state
490 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
490 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
491 *
491 *
492 */
492 */
493 // starts all the tasks fot eh flight software
493 // starts all the tasks fot eh flight software
494
494
495 rtems_status_code status;
495 rtems_status_code status;
496
496
497 //**********
497 //**********
498 // SPACEWIRE
498 // SPACEWIRE
499 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
499 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
500 if (status!=RTEMS_SUCCESSFUL) {
500 if (status!=RTEMS_SUCCESSFUL) {
501 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
501 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
502 }
502 }
503
503
504 if (status == RTEMS_SUCCESSFUL) // WTDG
504 if (status == RTEMS_SUCCESSFUL) // WTDG
505 {
505 {
506 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
506 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
507 if (status!=RTEMS_SUCCESSFUL) {
507 if (status!=RTEMS_SUCCESSFUL) {
508 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
508 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
509 }
509 }
510 }
510 }
511
511
512 if (status == RTEMS_SUCCESSFUL) // ACTN
512 if (status == RTEMS_SUCCESSFUL) // ACTN
513 {
513 {
514 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
514 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
515 if (status!=RTEMS_SUCCESSFUL) {
515 if (status!=RTEMS_SUCCESSFUL) {
516 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
516 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
517 }
517 }
518 }
518 }
519
519
520 //******************
520 //******************
521 // SPECTRAL MATRICES
521 // SPECTRAL MATRICES
522 if (status == RTEMS_SUCCESSFUL) // AVF0
522 if (status == RTEMS_SUCCESSFUL) // AVF0
523 {
523 {
524 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
524 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
525 if (status!=RTEMS_SUCCESSFUL) {
525 if (status!=RTEMS_SUCCESSFUL) {
526 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
526 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
527 }
527 }
528 }
528 }
529 if (status == RTEMS_SUCCESSFUL) // PRC0
529 if (status == RTEMS_SUCCESSFUL) // PRC0
530 {
530 {
531 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
531 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
532 if (status!=RTEMS_SUCCESSFUL) {
532 if (status!=RTEMS_SUCCESSFUL) {
533 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
533 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
534 }
534 }
535 }
535 }
536 if (status == RTEMS_SUCCESSFUL) // AVF1
536 if (status == RTEMS_SUCCESSFUL) // AVF1
537 {
537 {
538 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
538 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
539 if (status!=RTEMS_SUCCESSFUL) {
539 if (status!=RTEMS_SUCCESSFUL) {
540 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
540 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
541 }
541 }
542 }
542 }
543 if (status == RTEMS_SUCCESSFUL) // PRC1
543 if (status == RTEMS_SUCCESSFUL) // PRC1
544 {
544 {
545 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
545 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
546 if (status!=RTEMS_SUCCESSFUL) {
546 if (status!=RTEMS_SUCCESSFUL) {
547 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
547 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
548 }
548 }
549 }
549 }
550 if (status == RTEMS_SUCCESSFUL) // AVF2
550 // if (status == RTEMS_SUCCESSFUL) // AVF2
551 {
551 // {
552 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
552 // status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
553 if (status!=RTEMS_SUCCESSFUL) {
553 // if (status!=RTEMS_SUCCESSFUL) {
554 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
554 // BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
555 }
555 // }
556 }
556 // }
557 if (status == RTEMS_SUCCESSFUL) // PRC2
557 // if (status == RTEMS_SUCCESSFUL) // PRC2
558 {
558 // {
559 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
559 // status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
560 if (status!=RTEMS_SUCCESSFUL) {
560 // if (status!=RTEMS_SUCCESSFUL) {
561 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
561 // BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
562 }
562 // }
563 }
563 // }
564
564
565 //****************
565 //****************
566 // WAVEFORM PICKER
566 // WAVEFORM PICKER
567 if (status == RTEMS_SUCCESSFUL) // WFRM
567 if (status == RTEMS_SUCCESSFUL) // WFRM
568 {
568 {
569 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
569 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
570 if (status!=RTEMS_SUCCESSFUL) {
570 if (status!=RTEMS_SUCCESSFUL) {
571 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
571 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
572 }
572 }
573 }
573 }
574 if (status == RTEMS_SUCCESSFUL) // CWF3
574 if (status == RTEMS_SUCCESSFUL) // CWF3
575 {
575 {
576 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
576 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
577 if (status!=RTEMS_SUCCESSFUL) {
577 if (status!=RTEMS_SUCCESSFUL) {
578 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
578 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
579 }
579 }
580 }
580 }
581 if (status == RTEMS_SUCCESSFUL) // CWF2
581 if (status == RTEMS_SUCCESSFUL) // CWF2
582 {
582 {
583 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
583 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
584 if (status!=RTEMS_SUCCESSFUL) {
584 if (status!=RTEMS_SUCCESSFUL) {
585 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
585 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
586 }
586 }
587 }
587 }
588 if (status == RTEMS_SUCCESSFUL) // CWF1
588 if (status == RTEMS_SUCCESSFUL) // CWF1
589 {
589 {
590 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
590 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
591 if (status!=RTEMS_SUCCESSFUL) {
591 if (status!=RTEMS_SUCCESSFUL) {
592 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
592 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
593 }
593 }
594 }
594 }
595 if (status == RTEMS_SUCCESSFUL) // SWBD
595 if (status == RTEMS_SUCCESSFUL) // SWBD
596 {
596 {
597 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
597 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
598 if (status!=RTEMS_SUCCESSFUL) {
598 if (status!=RTEMS_SUCCESSFUL) {
599 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
599 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
600 }
600 }
601 }
601 }
602
602
603 //*****
603 //*****
604 // MISC
604 // MISC
605 if (status == RTEMS_SUCCESSFUL) // HOUS
605 if (status == RTEMS_SUCCESSFUL) // HOUS
606 {
606 {
607 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
607 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
608 if (status!=RTEMS_SUCCESSFUL) {
608 if (status!=RTEMS_SUCCESSFUL) {
609 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
609 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
610 }
610 }
611 }
611 }
612 if (status == RTEMS_SUCCESSFUL) // DUMB
612 if (status == RTEMS_SUCCESSFUL) // DUMB
613 {
613 {
614 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
614 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
615 if (status!=RTEMS_SUCCESSFUL) {
615 if (status!=RTEMS_SUCCESSFUL) {
616 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
616 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
617 }
617 }
618 }
618 }
619 if (status == RTEMS_SUCCESSFUL) // STAT
619 if (status == RTEMS_SUCCESSFUL) // STAT
620 {
620 {
621 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
621 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
622 if (status!=RTEMS_SUCCESSFUL) {
622 if (status!=RTEMS_SUCCESSFUL) {
623 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
623 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
624 }
624 }
625 }
625 }
626
626
627 return status;
627 return status;
628 }
628 }
629
629
630 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
630 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
631 {
631 {
632 rtems_status_code status_recv;
632 rtems_status_code status_recv;
633 rtems_status_code status_send;
633 rtems_status_code status_send;
634 rtems_status_code status_q_p0;
634 rtems_status_code status_q_p0;
635 rtems_status_code status_q_p1;
635 rtems_status_code status_q_p1;
636 rtems_status_code status_q_p2;
636 rtems_status_code status_q_p2;
637 rtems_status_code ret;
637 rtems_status_code ret;
638 rtems_id queue_id;
638 rtems_id queue_id;
639
639
640 //****************************************
640 //****************************************
641 // create the queue for handling valid TCs
641 // create the queue for handling valid TCs
642 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
642 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
643 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
643 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
644 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
644 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
645 if ( status_recv != RTEMS_SUCCESSFUL ) {
645 if ( status_recv != RTEMS_SUCCESSFUL ) {
646 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
646 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
647 }
647 }
648
648
649 //************************************************
649 //************************************************
650 // create the queue for handling TM packet sending
650 // create the queue for handling TM packet sending
651 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
651 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
652 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
652 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
653 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
653 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
654 if ( status_send != RTEMS_SUCCESSFUL ) {
654 if ( status_send != RTEMS_SUCCESSFUL ) {
655 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
655 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
656 }
656 }
657
657
658 //*****************************************************************************
658 //*****************************************************************************
659 // create the queue for handling averaged spectral matrices for processing @ f0
659 // create the queue for handling averaged spectral matrices for processing @ f0
660 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
660 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
661 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
661 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
662 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
662 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
663 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
663 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
664 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
664 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
665 }
665 }
666
666
667 //*****************************************************************************
667 //*****************************************************************************
668 // create the queue for handling averaged spectral matrices for processing @ f1
668 // create the queue for handling averaged spectral matrices for processing @ f1
669 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
669 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
670 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
670 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
671 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
671 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
672 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
672 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
673 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
673 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
674 }
674 }
675
675
676 //*****************************************************************************
676 //*****************************************************************************
677 // create the queue for handling averaged spectral matrices for processing @ f2
677 // create the queue for handling averaged spectral matrices for processing @ f2
678 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
678 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
679 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
679 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
680 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
680 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
681 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
681 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
682 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
682 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
683 }
683 }
684
684
685 if ( status_recv != RTEMS_SUCCESSFUL )
685 if ( status_recv != RTEMS_SUCCESSFUL )
686 {
686 {
687 ret = status_recv;
687 ret = status_recv;
688 }
688 }
689 else if( status_send != RTEMS_SUCCESSFUL )
689 else if( status_send != RTEMS_SUCCESSFUL )
690 {
690 {
691 ret = status_send;
691 ret = status_send;
692 }
692 }
693 else if( status_q_p0 != RTEMS_SUCCESSFUL )
693 else if( status_q_p0 != RTEMS_SUCCESSFUL )
694 {
694 {
695 ret = status_q_p0;
695 ret = status_q_p0;
696 }
696 }
697 else if( status_q_p1 != RTEMS_SUCCESSFUL )
697 else if( status_q_p1 != RTEMS_SUCCESSFUL )
698 {
698 {
699 ret = status_q_p1;
699 ret = status_q_p1;
700 }
700 }
701 else
701 else
702 {
702 {
703 ret = status_q_p2;
703 ret = status_q_p2;
704 }
704 }
705
705
706 return ret;
706 return ret;
707 }
707 }
708
708
709 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
709 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
710 {
710 {
711 rtems_status_code status;
711 rtems_status_code status;
712 rtems_name queue_name;
712 rtems_name queue_name;
713
713
714 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
714 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
715
715
716 status = rtems_message_queue_ident( queue_name, 0, queue_id );
716 status = rtems_message_queue_ident( queue_name, 0, queue_id );
717
717
718 return status;
718 return status;
719 }
719 }
720
720
721 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
721 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
722 {
722 {
723 rtems_status_code status;
723 rtems_status_code status;
724 rtems_name queue_name;
724 rtems_name queue_name;
725
725
726 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
726 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
727
727
728 status = rtems_message_queue_ident( queue_name, 0, queue_id );
728 status = rtems_message_queue_ident( queue_name, 0, queue_id );
729
729
730 return status;
730 return status;
731 }
731 }
732
732
733 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
733 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
734 {
734 {
735 rtems_status_code status;
735 rtems_status_code status;
736 rtems_name queue_name;
736 rtems_name queue_name;
737
737
738 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
738 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
739
739
740 status = rtems_message_queue_ident( queue_name, 0, queue_id );
740 status = rtems_message_queue_ident( queue_name, 0, queue_id );
741
741
742 return status;
742 return status;
743 }
743 }
744
744
745 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
745 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
746 {
746 {
747 rtems_status_code status;
747 rtems_status_code status;
748 rtems_name queue_name;
748 rtems_name queue_name;
749
749
750 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
750 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
751
751
752 status = rtems_message_queue_ident( queue_name, 0, queue_id );
752 status = rtems_message_queue_ident( queue_name, 0, queue_id );
753
753
754 return status;
754 return status;
755 }
755 }
756
756
757 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
757 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
758 {
758 {
759 rtems_status_code status;
759 rtems_status_code status;
760 rtems_name queue_name;
760 rtems_name queue_name;
761
761
762 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
762 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
763
763
764 status = rtems_message_queue_ident( queue_name, 0, queue_id );
764 status = rtems_message_queue_ident( queue_name, 0, queue_id );
765
765
766 return status;
766 return status;
767 }
767 }
@@ -1,950 +1,949
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14
14
15 //***********
15 //***********
16 // RTEMS TASK
16 // RTEMS TASK
17
17
18 rtems_task actn_task( rtems_task_argument unused )
18 rtems_task actn_task( rtems_task_argument unused )
19 {
19 {
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 *
21 *
22 * @param unused is the starting argument of the RTEMS task
22 * @param unused is the starting argument of the RTEMS task
23 *
23 *
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * on the incoming TeleCommand.
25 * on the incoming TeleCommand.
26 *
26 *
27 */
27 */
28
28
29 int result;
29 int result;
30 rtems_status_code status; // RTEMS status code
30 rtems_status_code status; // RTEMS status code
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 size_t size; // size of the incoming TC packet
32 size_t size; // size of the incoming TC packet
33 unsigned char subtype; // subtype of the current TC packet
33 unsigned char subtype; // subtype of the current TC packet
34 unsigned char time[6];
34 unsigned char time[6];
35 rtems_id queue_rcv_id;
35 rtems_id queue_rcv_id;
36 rtems_id queue_snd_id;
36 rtems_id queue_snd_id;
37
37
38 status = get_message_queue_id_recv( &queue_rcv_id );
38 status = get_message_queue_id_recv( &queue_rcv_id );
39 if (status != RTEMS_SUCCESSFUL)
39 if (status != RTEMS_SUCCESSFUL)
40 {
40 {
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 }
42 }
43
43
44 status = get_message_queue_id_send( &queue_snd_id );
44 status = get_message_queue_id_send( &queue_snd_id );
45 if (status != RTEMS_SUCCESSFUL)
45 if (status != RTEMS_SUCCESSFUL)
46 {
46 {
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 }
48 }
49
49
50 result = LFR_SUCCESSFUL;
50 result = LFR_SUCCESSFUL;
51 subtype = 0; // subtype of the current TC packet
51 subtype = 0; // subtype of the current TC packet
52
52
53 BOOT_PRINTF("in ACTN *** \n")
53 BOOT_PRINTF("in ACTN *** \n")
54
54
55 while(1)
55 while(1)
56 {
56 {
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 getTime( time ); // set time to the current time
59 getTime( time ); // set time to the current time
60 if (status!=RTEMS_SUCCESSFUL)
60 if (status!=RTEMS_SUCCESSFUL)
61 {
61 {
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 }
63 }
64 else
64 else
65 {
65 {
66 subtype = TC.serviceSubType;
66 subtype = TC.serviceSubType;
67 switch(subtype)
67 switch(subtype)
68 {
68 {
69 case TC_SUBTYPE_RESET:
69 case TC_SUBTYPE_RESET:
70 result = action_reset( &TC, queue_snd_id, time );
70 result = action_reset( &TC, queue_snd_id, time );
71 close_action( &TC, result, queue_snd_id );
71 close_action( &TC, result, queue_snd_id );
72 break;
72 break;
73 //
73 //
74 case TC_SUBTYPE_LOAD_COMM:
74 case TC_SUBTYPE_LOAD_COMM:
75 result = action_load_common_par( &TC );
75 result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 //
78 //
79 case TC_SUBTYPE_LOAD_NORM:
79 case TC_SUBTYPE_LOAD_NORM:
80 result = action_load_normal_par( &TC, queue_snd_id, time );
80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 close_action( &TC, result, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
82 break;
82 break;
83 //
83 //
84 case TC_SUBTYPE_LOAD_BURST:
84 case TC_SUBTYPE_LOAD_BURST:
85 result = action_load_burst_par( &TC, queue_snd_id, time );
85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 close_action( &TC, result, queue_snd_id );
86 close_action( &TC, result, queue_snd_id );
87 break;
87 break;
88 //
88 //
89 case TC_SUBTYPE_LOAD_SBM1:
89 case TC_SUBTYPE_LOAD_SBM1:
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 close_action( &TC, result, queue_snd_id );
91 close_action( &TC, result, queue_snd_id );
92 break;
92 break;
93 //
93 //
94 case TC_SUBTYPE_LOAD_SBM2:
94 case TC_SUBTYPE_LOAD_SBM2:
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 //
98 //
99 case TC_SUBTYPE_DUMP:
99 case TC_SUBTYPE_DUMP:
100 result = action_dump_par( queue_snd_id );
100 result = action_dump_par( queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
102 break;
103 //
103 //
104 case TC_SUBTYPE_ENTER:
104 case TC_SUBTYPE_ENTER:
105 result = action_enter_mode( &TC, queue_snd_id );
105 result = action_enter_mode( &TC, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
107 break;
107 break;
108 //
108 //
109 case TC_SUBTYPE_UPDT_INFO:
109 case TC_SUBTYPE_UPDT_INFO:
110 result = action_update_info( &TC, queue_snd_id );
110 result = action_update_info( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 break;
112 break;
113 //
113 //
114 case TC_SUBTYPE_EN_CAL:
114 case TC_SUBTYPE_EN_CAL:
115 result = action_enable_calibration( &TC, queue_snd_id, time );
115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 //
118 //
119 case TC_SUBTYPE_DIS_CAL:
119 case TC_SUBTYPE_DIS_CAL:
120 result = action_disable_calibration( &TC, queue_snd_id, time );
120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
121 close_action( &TC, result, queue_snd_id );
122 break;
122 break;
123 //
123 //
124 case TC_SUBTYPE_UPDT_TIME:
124 case TC_SUBTYPE_UPDT_TIME:
125 result = action_update_time( &TC );
125 result = action_update_time( &TC );
126 close_action( &TC, result, queue_snd_id );
126 close_action( &TC, result, queue_snd_id );
127 break;
127 break;
128 //
128 //
129 default:
129 default:
130 break;
130 break;
131 }
131 }
132 }
132 }
133 }
133 }
134 }
134 }
135
135
136 //***********
136 //***********
137 // TC ACTIONS
137 // TC ACTIONS
138
138
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 {
140 {
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 *
142 *
143 * @param TC points to the TeleCommand packet that is being processed
143 * @param TC points to the TeleCommand packet that is being processed
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
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 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 return LFR_DEFAULT;
149 return LFR_DEFAULT;
150 }
150 }
151
151
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
153 {
153 {
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 *
155 *
156 * @param TC points to the TeleCommand packet that is being processed
156 * @param TC points to the TeleCommand packet that is being processed
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
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 rtems_status_code status;
161 rtems_status_code status;
162 unsigned char requestedMode;
162 unsigned char requestedMode;
163 unsigned int *transitionCoarseTime_ptr;
163 unsigned int *transitionCoarseTime_ptr;
164 unsigned int transitionCoarseTime;
164 unsigned int transitionCoarseTime;
165 unsigned char * bytePosPtr;
165 unsigned char * bytePosPtr;
166
166
167 bytePosPtr = (unsigned char *) &TC->packetID;
167 bytePosPtr = (unsigned char *) &TC->packetID;
168
168
169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
172
172
173 status = check_mode_value( requestedMode );
173 status = check_mode_value( requestedMode );
174
174
175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
176 {
176 {
177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
178 }
178 }
179 else // the mode value is consistent, check the transition
179 else // the mode value is consistent, check the transition
180 {
180 {
181 status = check_mode_transition(requestedMode);
181 status = check_mode_transition(requestedMode);
182 if (status != LFR_SUCCESSFUL)
182 if (status != LFR_SUCCESSFUL)
183 {
183 {
184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
186 }
186 }
187 }
187 }
188
188
189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
190 {
190 {
191 status = check_transition_date( transitionCoarseTime );
191 status = check_transition_date( transitionCoarseTime );
192 if (status != LFR_SUCCESSFUL)
192 if (status != LFR_SUCCESSFUL)
193 {
193 {
194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
198 }
198 }
199 }
199 }
200
200
201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
202 {
202 {
203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
204 status = enter_mode( requestedMode, transitionCoarseTime );
204 status = enter_mode( requestedMode, transitionCoarseTime );
205 }
205 }
206
206
207 return status;
207 return status;
208 }
208 }
209
209
210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
211 {
211 {
212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
213 *
213 *
214 * @param TC points to the TeleCommand packet that is being processed
214 * @param TC points to the TeleCommand packet that is being processed
215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
216 *
216 *
217 * @return LFR directive status code:
217 * @return LFR directive status code:
218 * - LFR_DEFAULT
218 * - LFR_DEFAULT
219 * - LFR_SUCCESSFUL
219 * - LFR_SUCCESSFUL
220 *
220 *
221 */
221 */
222
222
223 unsigned int val;
223 unsigned int val;
224 int result;
224 int result;
225 unsigned int status;
225 unsigned int status;
226 unsigned char mode;
226 unsigned char mode;
227 unsigned char * bytePosPtr;
227 unsigned char * bytePosPtr;
228
228
229 bytePosPtr = (unsigned char *) &TC->packetID;
229 bytePosPtr = (unsigned char *) &TC->packetID;
230
230
231 // check LFR mode
231 // check LFR mode
232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
233 status = check_update_info_hk_lfr_mode( mode );
233 status = check_update_info_hk_lfr_mode( mode );
234 if (status == LFR_SUCCESSFUL) // check TDS mode
234 if (status == LFR_SUCCESSFUL) // check TDS mode
235 {
235 {
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
237 status = check_update_info_hk_tds_mode( mode );
237 status = check_update_info_hk_tds_mode( mode );
238 }
238 }
239 if (status == LFR_SUCCESSFUL) // check THR mode
239 if (status == LFR_SUCCESSFUL) // check THR mode
240 {
240 {
241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
242 status = check_update_info_hk_thr_mode( mode );
242 status = check_update_info_hk_thr_mode( mode );
243 }
243 }
244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
245 {
245 {
246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
248 val++;
248 val++;
249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
251 }
251 }
252
252
253 result = status;
253 result = status;
254
254
255 return result;
255 return result;
256 }
256 }
257
257
258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
259 {
259 {
260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
261 *
261 *
262 * @param TC points to the TeleCommand packet that is being processed
262 * @param TC points to the TeleCommand packet that is being processed
263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
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 int result;
267 int result;
268 unsigned char lfrMode;
268 unsigned char lfrMode;
269
269
270 result = LFR_DEFAULT;
270 result = LFR_DEFAULT;
271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
272
272
273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
274 result = LFR_DEFAULT;
274 result = LFR_DEFAULT;
275
275
276 return result;
276 return result;
277 }
277 }
278
278
279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
280 {
280 {
281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
282 *
282 *
283 * @param TC points to the TeleCommand packet that is being processed
283 * @param TC points to the TeleCommand packet that is being processed
284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
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 int result;
288 int result;
289 unsigned char lfrMode;
289 unsigned char lfrMode;
290
290
291 result = LFR_DEFAULT;
291 result = LFR_DEFAULT;
292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
293
293
294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
295 result = LFR_DEFAULT;
295 result = LFR_DEFAULT;
296
296
297 return result;
297 return result;
298 }
298 }
299
299
300 int action_update_time(ccsdsTelecommandPacket_t *TC)
300 int action_update_time(ccsdsTelecommandPacket_t *TC)
301 {
301 {
302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
303 *
303 *
304 * @param TC points to the TeleCommand packet that is being processed
304 * @param TC points to the TeleCommand packet that is being processed
305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
306 *
306 *
307 * @return LFR_SUCCESSFUL
307 * @return LFR_SUCCESSFUL
308 *
308 *
309 */
309 */
310
310
311 unsigned int val;
311 unsigned int val;
312
312
313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
314 + (TC->dataAndCRC[1] << 16)
314 + (TC->dataAndCRC[1] << 16)
315 + (TC->dataAndCRC[2] << 8)
315 + (TC->dataAndCRC[2] << 8)
316 + TC->dataAndCRC[3];
316 + TC->dataAndCRC[3];
317
317
318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
319
319
320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
322 val++;
322 val++;
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
326
326
327 return LFR_SUCCESSFUL;
327 return LFR_SUCCESSFUL;
328 }
328 }
329
329
330 //*******************
330 //*******************
331 // ENTERING THE MODES
331 // ENTERING THE MODES
332 int check_mode_value( unsigned char requestedMode )
332 int check_mode_value( unsigned char requestedMode )
333 {
333 {
334 int status;
334 int status;
335
335
336 if ( (requestedMode != LFR_MODE_STANDBY)
336 if ( (requestedMode != LFR_MODE_STANDBY)
337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
339 {
339 {
340 status = LFR_DEFAULT;
340 status = LFR_DEFAULT;
341 }
341 }
342 else
342 else
343 {
343 {
344 status = LFR_SUCCESSFUL;
344 status = LFR_SUCCESSFUL;
345 }
345 }
346
346
347 return status;
347 return status;
348 }
348 }
349
349
350 int check_mode_transition( unsigned char requestedMode )
350 int check_mode_transition( unsigned char requestedMode )
351 {
351 {
352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
353 *
353 *
354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
355 *
355 *
356 * @return LFR directive status codes:
356 * @return LFR directive status codes:
357 * - LFR_SUCCESSFUL - the transition is authorized
357 * - LFR_SUCCESSFUL - the transition is authorized
358 * - LFR_DEFAULT - the transition is not authorized
358 * - LFR_DEFAULT - the transition is not authorized
359 *
359 *
360 */
360 */
361
361
362 int status;
362 int status;
363
363
364 switch (requestedMode)
364 switch (requestedMode)
365 {
365 {
366 case LFR_MODE_STANDBY:
366 case LFR_MODE_STANDBY:
367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
368 status = LFR_DEFAULT;
368 status = LFR_DEFAULT;
369 }
369 }
370 else
370 else
371 {
371 {
372 status = LFR_SUCCESSFUL;
372 status = LFR_SUCCESSFUL;
373 }
373 }
374 break;
374 break;
375 case LFR_MODE_NORMAL:
375 case LFR_MODE_NORMAL:
376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
377 status = LFR_DEFAULT;
377 status = LFR_DEFAULT;
378 }
378 }
379 else {
379 else {
380 status = LFR_SUCCESSFUL;
380 status = LFR_SUCCESSFUL;
381 }
381 }
382 break;
382 break;
383 case LFR_MODE_BURST:
383 case LFR_MODE_BURST:
384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
385 status = LFR_DEFAULT;
385 status = LFR_DEFAULT;
386 }
386 }
387 else {
387 else {
388 status = LFR_SUCCESSFUL;
388 status = LFR_SUCCESSFUL;
389 }
389 }
390 break;
390 break;
391 case LFR_MODE_SBM1:
391 case LFR_MODE_SBM1:
392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
393 status = LFR_DEFAULT;
393 status = LFR_DEFAULT;
394 }
394 }
395 else {
395 else {
396 status = LFR_SUCCESSFUL;
396 status = LFR_SUCCESSFUL;
397 }
397 }
398 break;
398 break;
399 case LFR_MODE_SBM2:
399 case LFR_MODE_SBM2:
400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
401 status = LFR_DEFAULT;
401 status = LFR_DEFAULT;
402 }
402 }
403 else {
403 else {
404 status = LFR_SUCCESSFUL;
404 status = LFR_SUCCESSFUL;
405 }
405 }
406 break;
406 break;
407 default:
407 default:
408 status = LFR_DEFAULT;
408 status = LFR_DEFAULT;
409 break;
409 break;
410 }
410 }
411
411
412 return status;
412 return status;
413 }
413 }
414
414
415 int check_transition_date( unsigned int transitionCoarseTime )
415 int check_transition_date( unsigned int transitionCoarseTime )
416 {
416 {
417 int status;
417 int status;
418 unsigned int localCoarseTime;
418 unsigned int localCoarseTime;
419 unsigned int deltaCoarseTime;
419 unsigned int deltaCoarseTime;
420
420
421 status = LFR_SUCCESSFUL;
421 status = LFR_SUCCESSFUL;
422
422
423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
424 {
424 {
425 status = LFR_SUCCESSFUL;
425 status = LFR_SUCCESSFUL;
426 }
426 }
427 else
427 else
428 {
428 {
429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
430
430
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
432 {
432 {
433 status = LFR_DEFAULT;
433 status = LFR_DEFAULT;
434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
435 }
435 }
436
436
437 if (status == LFR_SUCCESSFUL)
437 if (status == LFR_SUCCESSFUL)
438 {
438 {
439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
441 {
441 {
442 status = LFR_DEFAULT;
442 status = LFR_DEFAULT;
443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
444 }
444 }
445 }
445 }
446 }
446 }
447
447
448 return status;
448 return status;
449 }
449 }
450
450
451 int stop_current_mode( void )
451 int stop_current_mode( void )
452 {
452 {
453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
454 *
454 *
455 * @return RTEMS directive status codes:
455 * @return RTEMS directive status codes:
456 * - RTEMS_SUCCESSFUL - task restarted successfully
456 * - RTEMS_SUCCESSFUL - task restarted successfully
457 * - RTEMS_INVALID_ID - task id invalid
457 * - RTEMS_INVALID_ID - task id invalid
458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
459 *
459 *
460 */
460 */
461
461
462 rtems_status_code status;
462 rtems_status_code status;
463
463
464 status = RTEMS_SUCCESSFUL;
464 status = RTEMS_SUCCESSFUL;
465
465
466 // (1) mask interruptions
466 // (1) mask interruptions
467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
469
469
470 // (2) clear interruptions
470 // (2) clear interruptions
471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
473
473
474 // (3) reset waveform picker registers
474 // (3) reset waveform picker registers
475 reset_wfp_burst_enable(); // reset burst and enable bits
475 reset_wfp_burst_enable(); // reset burst and enable bits
476 reset_wfp_status(); // reset all the status bits
476 reset_wfp_status(); // reset all the status bits
477
477
478 // (4) reset spectral matrices registers
478 // (4) reset spectral matrices registers
479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
481 reset_extractSWF(); // reset the extractSWF flag to false
481 reset_extractSWF(); // reset the extractSWF flag to false
482
482
483 // <Spectral Matrices simulator>
483 // <Spectral Matrices simulator>
484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
487 // </Spectral Matrices simulator>
487 // </Spectral Matrices simulator>
488
488
489 // suspend several tasks
489 // suspend several tasks
490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
491 status = suspend_science_tasks();
491 status = suspend_science_tasks();
492 }
492 }
493
493
494 if (status != RTEMS_SUCCESSFUL)
494 if (status != RTEMS_SUCCESSFUL)
495 {
495 {
496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
497 }
497 }
498
498
499 return status;
499 return status;
500 }
500 }
501
501
502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
503 {
503 {
504 /** This function is launched after a mode transition validation.
504 /** This function is launched after a mode transition validation.
505 *
505 *
506 * @param mode is the mode in which LFR will be put.
506 * @param mode is the mode in which LFR will be put.
507 *
507 *
508 * @return RTEMS directive status codes:
508 * @return RTEMS directive status codes:
509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
511 *
511 *
512 */
512 */
513
513
514 rtems_status_code status;
514 rtems_status_code status;
515
515
516 //**********************
516 //**********************
517 // STOP THE CURRENT MODE
517 // STOP THE CURRENT MODE
518 status = stop_current_mode();
518 status = stop_current_mode();
519 if (status != RTEMS_SUCCESSFUL)
519 if (status != RTEMS_SUCCESSFUL)
520 {
520 {
521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
522 }
522 }
523
523
524 //*************************
524 //*************************
525 // ENTER THE REQUESTED MODE
525 // ENTER THE REQUESTED MODE
526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
528 {
528 {
529 #ifdef PRINT_TASK_STATISTICS
529 #ifdef PRINT_TASK_STATISTICS
530 rtems_cpu_usage_reset();
530 rtems_cpu_usage_reset();
531 maxCount = 0;
531 maxCount = 0;
532 #endif
532 #endif
533 status = restart_science_tasks( mode );
533 status = restart_science_tasks( mode );
534 launch_waveform_picker( mode, transitionCoarseTime );
534 launch_waveform_picker( mode, transitionCoarseTime );
535 // launch_spectral_matrix( );
535 // launch_spectral_matrix( );
536 launch_spectral_matrix_simu( );
536 launch_spectral_matrix_simu( );
537 }
537 }
538 else if ( mode == LFR_MODE_STANDBY )
538 else if ( mode == LFR_MODE_STANDBY )
539 {
539 {
540 #ifdef PRINT_TASK_STATISTICS
540 #ifdef PRINT_TASK_STATISTICS
541 rtems_cpu_usage_report();
541 rtems_cpu_usage_report();
542 #endif
542 #endif
543
543
544 #ifdef PRINT_STACK_REPORT
544 #ifdef PRINT_STACK_REPORT
545 PRINTF("stack report selected\n")
545 PRINTF("stack report selected\n")
546 rtems_stack_checker_report_usage();
546 rtems_stack_checker_report_usage();
547 #endif
547 #endif
548 PRINTF1("maxCount = %d\n", maxCount)
548 PRINTF1("maxCount = %d\n", maxCount)
549 }
549 }
550 else
550 else
551 {
551 {
552 status = RTEMS_UNSATISFIED;
552 status = RTEMS_UNSATISFIED;
553 }
553 }
554
554
555 if (status != RTEMS_SUCCESSFUL)
555 if (status != RTEMS_SUCCESSFUL)
556 {
556 {
557 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
557 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
558 status = RTEMS_UNSATISFIED;
558 status = RTEMS_UNSATISFIED;
559 }
559 }
560
560
561 return status;
561 return status;
562 }
562 }
563
563
564 int restart_science_tasks(unsigned char lfrRequestedMode )
564 int restart_science_tasks(unsigned char lfrRequestedMode )
565 {
565 {
566 /** This function is used to restart all science tasks.
566 /** This function is used to restart all science tasks.
567 *
567 *
568 * @return RTEMS directive status codes:
568 * @return RTEMS directive status codes:
569 * - RTEMS_SUCCESSFUL - task restarted successfully
569 * - RTEMS_SUCCESSFUL - task restarted successfully
570 * - RTEMS_INVALID_ID - task id invalid
570 * - RTEMS_INVALID_ID - task id invalid
571 * - RTEMS_INCORRECT_STATE - task never started
571 * - RTEMS_INCORRECT_STATE - task never started
572 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
572 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
573 *
573 *
574 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
574 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
575 *
575 *
576 */
576 */
577
577
578 rtems_status_code status[10];
578 rtems_status_code status[10];
579 rtems_status_code ret;
579 rtems_status_code ret;
580
580
581 ret = RTEMS_SUCCESSFUL;
581 ret = RTEMS_SUCCESSFUL;
582
582
583 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
583 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
584 if (status[0] != RTEMS_SUCCESSFUL)
584 if (status[0] != RTEMS_SUCCESSFUL)
585 {
585 {
586 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
586 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
587 }
587 }
588
588
589 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
589 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
590 if (status[1] != RTEMS_SUCCESSFUL)
590 if (status[1] != RTEMS_SUCCESSFUL)
591 {
591 {
592 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
592 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
593 }
593 }
594
594
595 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
595 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
596 if (status[2] != RTEMS_SUCCESSFUL)
596 if (status[2] != RTEMS_SUCCESSFUL)
597 {
597 {
598 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
598 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
599 }
599 }
600
600
601 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
601 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
602 if (status[3] != RTEMS_SUCCESSFUL)
602 if (status[3] != RTEMS_SUCCESSFUL)
603 {
603 {
604 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
604 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
605 }
605 }
606
606
607 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
607 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
608 if (status[4] != RTEMS_SUCCESSFUL)
608 if (status[4] != RTEMS_SUCCESSFUL)
609 {
609 {
610 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
610 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
611 }
611 }
612
612
613 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
613 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
614 if (status[5] != RTEMS_SUCCESSFUL)
614 if (status[5] != RTEMS_SUCCESSFUL)
615 {
615 {
616 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
616 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
617 }
617 }
618
618
619 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
619 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
620 if (status[6] != RTEMS_SUCCESSFUL)
620 if (status[6] != RTEMS_SUCCESSFUL)
621 {
621 {
622 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
622 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
623 }
623 }
624
624
625 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
625 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
626 if (status[7] != RTEMS_SUCCESSFUL)
626 if (status[7] != RTEMS_SUCCESSFUL)
627 {
627 {
628 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
628 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
629 }
629 }
630
630
631 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
631 // status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
632 if (status[8] != RTEMS_SUCCESSFUL)
632 // if (status[8] != RTEMS_SUCCESSFUL)
633 {
633 // {
634 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
634 // PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
635 }
635 // }
636
636
637 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
637 // status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
638 if (status[9] != RTEMS_SUCCESSFUL)
638 // if (status[9] != RTEMS_SUCCESSFUL)
639 {
639 // {
640 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
640 // PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
641 }
641 // }
642
642
643 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
643 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
644 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
644 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
645 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
645 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
646 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
646 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) )
647 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL))
648 {
647 {
649 ret = RTEMS_UNSATISFIED;
648 ret = RTEMS_UNSATISFIED;
650 }
649 }
651
650
652 return ret;
651 return ret;
653 }
652 }
654
653
655 int suspend_science_tasks()
654 int suspend_science_tasks()
656 {
655 {
657 /** This function suspends the science tasks.
656 /** This function suspends the science tasks.
658 *
657 *
659 * @return RTEMS directive status codes:
658 * @return RTEMS directive status codes:
660 * - RTEMS_SUCCESSFUL - task restarted successfully
659 * - RTEMS_SUCCESSFUL - task restarted successfully
661 * - RTEMS_INVALID_ID - task id invalid
660 * - RTEMS_INVALID_ID - task id invalid
662 * - RTEMS_ALREADY_SUSPENDED - task already suspended
661 * - RTEMS_ALREADY_SUSPENDED - task already suspended
663 *
662 *
664 */
663 */
665
664
666 rtems_status_code status;
665 rtems_status_code status;
667
666
668 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
667 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
669 if (status != RTEMS_SUCCESSFUL)
668 if (status != RTEMS_SUCCESSFUL)
670 {
669 {
671 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
670 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
672 }
671 }
673 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
672 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
674 {
673 {
675 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
674 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
676 if (status != RTEMS_SUCCESSFUL)
675 if (status != RTEMS_SUCCESSFUL)
677 {
676 {
678 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
677 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
679 }
678 }
680 }
679 }
681 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
680 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
682 {
681 {
683 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
682 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
684 if (status != RTEMS_SUCCESSFUL)
683 if (status != RTEMS_SUCCESSFUL)
685 {
684 {
686 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
685 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
687 }
686 }
688 }
687 }
689 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
688 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
690 {
689 {
691 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
690 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
692 if (status != RTEMS_SUCCESSFUL)
691 if (status != RTEMS_SUCCESSFUL)
693 {
692 {
694 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
693 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
695 }
694 }
696 }
695 }
697 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
696 // if (status == RTEMS_SUCCESSFUL) // suspend AVF2
698 {
697 // {
699 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
698 // status = rtems_task_suspend( Task_id[TASKID_AVF2] );
700 if (status != RTEMS_SUCCESSFUL)
699 // if (status != RTEMS_SUCCESSFUL)
701 {
700 // {
702 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
701 // PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
703 }
702 // }
704 }
703 // }
705 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
704 // if (status == RTEMS_SUCCESSFUL) // suspend PRC2
706 {
705 // {
707 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
706 // status = rtems_task_suspend( Task_id[TASKID_PRC2] );
708 if (status != RTEMS_SUCCESSFUL)
707 // if (status != RTEMS_SUCCESSFUL)
709 {
708 // {
710 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
709 // PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
711 }
710 // }
712 }
711 // }
713 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
712 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
714 {
713 {
715 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
714 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
716 if (status != RTEMS_SUCCESSFUL)
715 if (status != RTEMS_SUCCESSFUL)
717 {
716 {
718 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
717 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
719 }
718 }
720 }
719 }
721 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
720 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
722 {
721 {
723 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
722 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
724 if (status != RTEMS_SUCCESSFUL)
723 if (status != RTEMS_SUCCESSFUL)
725 {
724 {
726 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
725 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
727 }
726 }
728 }
727 }
729 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
728 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
730 {
729 {
731 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
730 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
732 if (status != RTEMS_SUCCESSFUL)
731 if (status != RTEMS_SUCCESSFUL)
733 {
732 {
734 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
733 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
735 }
734 }
736 }
735 }
737 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
736 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
738 {
737 {
739 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
738 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
740 if (status != RTEMS_SUCCESSFUL)
739 if (status != RTEMS_SUCCESSFUL)
741 {
740 {
742 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
741 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
743 }
742 }
744 }
743 }
745
744
746 return status;
745 return status;
747 }
746 }
748
747
749 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
748 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
750 {
749 {
751 reset_current_ring_nodes();
750 reset_current_ring_nodes();
752 reset_waveform_picker_regs();
751 reset_waveform_picker_regs();
753 set_wfp_burst_enable_register( mode );
752 set_wfp_burst_enable_register( mode );
754
753
755 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
754 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
756 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
755 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
757
756
758 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
757 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
759 if (transitionCoarseTime == 0)
758 if (transitionCoarseTime == 0)
760 {
759 {
761 waveform_picker_regs->start_date = time_management_regs->coarse_time;
760 waveform_picker_regs->start_date = time_management_regs->coarse_time;
762 }
761 }
763 else
762 else
764 {
763 {
765 waveform_picker_regs->start_date = transitionCoarseTime;
764 waveform_picker_regs->start_date = transitionCoarseTime;
766 }
765 }
767 }
766 }
768
767
769 void launch_spectral_matrix( void )
768 void launch_spectral_matrix( void )
770 {
769 {
771 SM_reset_current_ring_nodes();
770 SM_reset_current_ring_nodes();
772 reset_spectral_matrix_regs();
771 reset_spectral_matrix_regs();
773 reset_nb_sm();
772 reset_nb_sm();
774
773
775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
774 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
776 grgpio_regs->io_port_direction_register =
775 grgpio_regs->io_port_direction_register =
777 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
776 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
778 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
777 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
779 set_irq_on_new_ready_matrix( 1 );
778 set_irq_on_new_ready_matrix( 1 );
780 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
779 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
781 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
780 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
782 set_run_matrix_spectral( 1 );
781 set_run_matrix_spectral( 1 );
783
782
784 }
783 }
785
784
786 void launch_spectral_matrix_simu( void )
785 void launch_spectral_matrix_simu( void )
787 {
786 {
788 SM_reset_current_ring_nodes();
787 SM_reset_current_ring_nodes();
789 reset_spectral_matrix_regs();
788 reset_spectral_matrix_regs();
790 reset_nb_sm();
789 reset_nb_sm();
791
790
792 // Spectral Matrices simulator
791 // Spectral Matrices simulator
793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
792 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
794 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
793 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
794 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
796 set_local_nb_interrupt_f0_MAX();
795 set_local_nb_interrupt_f0_MAX();
797 }
796 }
798
797
799 void set_irq_on_new_ready_matrix( unsigned char value )
798 void set_irq_on_new_ready_matrix( unsigned char value )
800 {
799 {
801 if (value == 1)
800 if (value == 1)
802 {
801 {
803 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
802 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
804 }
803 }
805 else
804 else
806 {
805 {
807 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
806 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
808 }
807 }
809 }
808 }
810
809
811 void set_run_matrix_spectral( unsigned char value )
810 void set_run_matrix_spectral( unsigned char value )
812 {
811 {
813 if (value == 1)
812 if (value == 1)
814 {
813 {
815 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
814 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
816 }
815 }
817 else
816 else
818 {
817 {
819 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
818 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
820 }
819 }
821 }
820 }
822
821
823 //****************
822 //****************
824 // CLOSING ACTIONS
823 // CLOSING ACTIONS
825 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
824 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
826 {
825 {
827 /** This function is used to update the HK packets statistics after a successful TC execution.
826 /** This function is used to update the HK packets statistics after a successful TC execution.
828 *
827 *
829 * @param TC points to the TC being processed
828 * @param TC points to the TC being processed
830 * @param time is the time used to date the TC execution
829 * @param time is the time used to date the TC execution
831 *
830 *
832 */
831 */
833
832
834 unsigned int val;
833 unsigned int val;
835
834
836 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
835 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
837 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
836 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
838 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
837 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
839 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
838 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
839 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
841 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
842 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
841 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
843 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
842 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
844 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
843 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
845 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
844 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
846 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
845 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
847 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
846 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
848
847
849 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
848 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
850 val++;
849 val++;
851 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
850 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
852 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
851 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
853 }
852 }
854
853
855 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
854 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
856 {
855 {
857 /** This function is used to update the HK packets statistics after a TC rejection.
856 /** This function is used to update the HK packets statistics after a TC rejection.
858 *
857 *
859 * @param TC points to the TC being processed
858 * @param TC points to the TC being processed
860 * @param time is the time used to date the TC rejection
859 * @param time is the time used to date the TC rejection
861 *
860 *
862 */
861 */
863
862
864 unsigned int val;
863 unsigned int val;
865
864
866 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
865 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
867 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
866 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
868 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
867 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
869 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
868 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
869 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
871 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
872 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
871 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
873 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
872 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
874 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
873 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
875 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
874 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
876 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
875 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
877 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
876 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
878
877
879 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
878 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
880 val++;
879 val++;
881 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
880 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
882 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
881 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
883 }
882 }
884
883
885 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
884 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
886 {
885 {
887 /** This function is the last step of the TC execution workflow.
886 /** This function is the last step of the TC execution workflow.
888 *
887 *
889 * @param TC points to the TC being processed
888 * @param TC points to the TC being processed
890 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
889 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
891 * @param queue_id is the id of the RTEMS message queue used to send TM packets
890 * @param queue_id is the id of the RTEMS message queue used to send TM packets
892 * @param time is the time used to date the TC execution
891 * @param time is the time used to date the TC execution
893 *
892 *
894 */
893 */
895
894
896 unsigned char requestedMode;
895 unsigned char requestedMode;
897
896
898 if (result == LFR_SUCCESSFUL)
897 if (result == LFR_SUCCESSFUL)
899 {
898 {
900 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
899 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
901 &
900 &
902 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
901 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
903 )
902 )
904 {
903 {
905 send_tm_lfr_tc_exe_success( TC, queue_id );
904 send_tm_lfr_tc_exe_success( TC, queue_id );
906 }
905 }
907 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
906 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
908 {
907 {
909 //**********************************
908 //**********************************
910 // UPDATE THE LFRMODE LOCAL VARIABLE
909 // UPDATE THE LFRMODE LOCAL VARIABLE
911 requestedMode = TC->dataAndCRC[1];
910 requestedMode = TC->dataAndCRC[1];
912 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
911 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
913 updateLFRCurrentMode();
912 updateLFRCurrentMode();
914 }
913 }
915 }
914 }
916 else if (result == LFR_EXE_ERROR)
915 else if (result == LFR_EXE_ERROR)
917 {
916 {
918 send_tm_lfr_tc_exe_error( TC, queue_id );
917 send_tm_lfr_tc_exe_error( TC, queue_id );
919 }
918 }
920 }
919 }
921
920
922 //***************************
921 //***************************
923 // Interrupt Service Routines
922 // Interrupt Service Routines
924 rtems_isr commutation_isr1( rtems_vector_number vector )
923 rtems_isr commutation_isr1( rtems_vector_number vector )
925 {
924 {
926 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
925 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
927 printf("In commutation_isr1 *** Error sending event to DUMB\n");
926 printf("In commutation_isr1 *** Error sending event to DUMB\n");
928 }
927 }
929 }
928 }
930
929
931 rtems_isr commutation_isr2( rtems_vector_number vector )
930 rtems_isr commutation_isr2( rtems_vector_number vector )
932 {
931 {
933 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
932 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
934 printf("In commutation_isr2 *** Error sending event to DUMB\n");
933 printf("In commutation_isr2 *** Error sending event to DUMB\n");
935 }
934 }
936 }
935 }
937
936
938 //****************
937 //****************
939 // OTHER FUNCTIONS
938 // OTHER FUNCTIONS
940 void updateLFRCurrentMode()
939 void updateLFRCurrentMode()
941 {
940 {
942 /** This function updates the value of the global variable lfrCurrentMode.
941 /** This function updates the value of the global variable lfrCurrentMode.
943 *
942 *
944 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
943 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
945 *
944 *
946 */
945 */
947 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
946 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
948 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
947 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
949 }
948 }
950
949
General Comments 0
You need to be logged in to leave comments. Login now