##// END OF EJS Templates
updates for the compliance with the spectral matrix VHDL design
paul -
r150:035669d03c81 VHDLib206
parent child
Show More
@@ -1,273 +1,273
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 09:16:01 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 15:44:22 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=10 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=10 -DPRINT_MESSAGES_ON_CONSOLE
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../header/processing -I../src/LFR_basic-parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
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/processing/fsw_processing.c \
55 ../src/processing/fsw_processing.c \
56 ../src/processing/avf0_prc0.c \
56 ../src/processing/avf0_prc0.c \
57 ../src/processing/avf1_prc1.c \
57 ../src/processing/avf1_prc1.c \
58 ../src/processing/avf2_prc2.c \
58 ../src/processing/avf2_prc2.c \
59 ../src/lfr_cpu_usage_report.c \
59 ../src/lfr_cpu_usage_report.c \
60 ../src/LFR_basic-parameters/basic_parameters.c
60 ../src/LFR_basic-parameters/basic_parameters.c
61 OBJECTS = obj/wf_handler.o \
61 OBJECTS = obj/wf_handler.o \
62 obj/tc_handler.o \
62 obj/tc_handler.o \
63 obj/fsw_misc.o \
63 obj/fsw_misc.o \
64 obj/fsw_init.o \
64 obj/fsw_init.o \
65 obj/fsw_globals.o \
65 obj/fsw_globals.o \
66 obj/fsw_spacewire.o \
66 obj/fsw_spacewire.o \
67 obj/tc_load_dump_parameters.o \
67 obj/tc_load_dump_parameters.o \
68 obj/tm_lfr_tc_exe.o \
68 obj/tm_lfr_tc_exe.o \
69 obj/tc_acceptance.o \
69 obj/tc_acceptance.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 obj/lfr_cpu_usage_report.o \
74 obj/lfr_cpu_usage_report.o \
75 obj/basic_parameters.o
75 obj/basic_parameters.o
76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 /usr/lib64/qt4/mkspecs/common/linux.conf \
77 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 /usr/lib64/qt4/mkspecs/qconfig.pri \
82 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 sparc.pri \
88 sparc.pri \
89 /usr/lib64/qt4/mkspecs/features/release.prf \
89 /usr/lib64/qt4/mkspecs/features/release.prf \
90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 /usr/lib64/qt4/mkspecs/features/shared.prf \
91 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 /usr/lib64/qt4/mkspecs/features/resources.prf \
94 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 /usr/lib64/qt4/mkspecs/features/uic.prf \
95 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 /usr/lib64/qt4/mkspecs/features/lex.prf \
97 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 fsw-qt.pro
99 fsw-qt.pro
100 QMAKE_TARGET = fsw
100 QMAKE_TARGET = fsw
101 DESTDIR = bin/
101 DESTDIR = bin/
102 TARGET = bin/fsw
102 TARGET = bin/fsw
103
103
104 first: all
104 first: all
105 ####### Implicit rules
105 ####### Implicit rules
106
106
107 .SUFFIXES: .o .c .cpp .cc .cxx .C
107 .SUFFIXES: .o .c .cpp .cc .cxx .C
108
108
109 .cpp.o:
109 .cpp.o:
110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111
111
112 .cc.o:
112 .cc.o:
113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114
114
115 .cxx.o:
115 .cxx.o:
116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117
117
118 .C.o:
118 .C.o:
119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120
120
121 .c.o:
121 .c.o:
122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123
123
124 ####### Build rules
124 ####### Build rules
125
125
126 all: Makefile $(TARGET)
126 all: Makefile $(TARGET)
127
127
128 $(TARGET): $(OBJECTS)
128 $(TARGET): $(OBJECTS)
129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131
131
132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 /usr/lib64/qt4/mkspecs/common/linux.conf \
133 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 /usr/lib64/qt4/mkspecs/qconfig.pri \
138 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 sparc.pri \
144 sparc.pri \
145 /usr/lib64/qt4/mkspecs/features/release.prf \
145 /usr/lib64/qt4/mkspecs/features/release.prf \
146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 /usr/lib64/qt4/mkspecs/features/shared.prf \
147 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 /usr/lib64/qt4/mkspecs/features/resources.prf \
150 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 /usr/lib64/qt4/mkspecs/features/uic.prf \
151 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 /usr/lib64/qt4/mkspecs/features/lex.prf \
153 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 /usr/lib64/qt4/mkspecs/common/unix.conf:
156 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 /usr/lib64/qt4/mkspecs/common/linux.conf:
157 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 /usr/lib64/qt4/mkspecs/qconfig.pri:
162 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 sparc.pri:
168 sparc.pri:
169 /usr/lib64/qt4/mkspecs/features/release.prf:
169 /usr/lib64/qt4/mkspecs/features/release.prf:
170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 /usr/lib64/qt4/mkspecs/features/shared.prf:
171 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 /usr/lib64/qt4/mkspecs/features/resources.prf:
174 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 /usr/lib64/qt4/mkspecs/features/uic.prf:
175 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 /usr/lib64/qt4/mkspecs/features/lex.prf:
177 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 qmake: FORCE
179 qmake: FORCE
180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181
181
182 dist:
182 dist:
183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
185
185
186
186
187 clean:compiler_clean
187 clean:compiler_clean
188 -$(DEL_FILE) $(OBJECTS)
188 -$(DEL_FILE) $(OBJECTS)
189 -$(DEL_FILE) *~ core *.core
189 -$(DEL_FILE) *~ core *.core
190
190
191
191
192 ####### Sub-libraries
192 ####### Sub-libraries
193
193
194 distclean: clean
194 distclean: clean
195 -$(DEL_FILE) $(TARGET)
195 -$(DEL_FILE) $(TARGET)
196 -$(DEL_FILE) Makefile
196 -$(DEL_FILE) Makefile
197
197
198
198
199 grmon:
199 grmon:
200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201
201
202 check: first
202 check: first
203
203
204 compiler_rcc_make_all:
204 compiler_rcc_make_all:
205 compiler_rcc_clean:
205 compiler_rcc_clean:
206 compiler_uic_make_all:
206 compiler_uic_make_all:
207 compiler_uic_clean:
207 compiler_uic_clean:
208 compiler_image_collection_make_all: qmake_image_collection.cpp
208 compiler_image_collection_make_all: qmake_image_collection.cpp
209 compiler_image_collection_clean:
209 compiler_image_collection_clean:
210 -$(DEL_FILE) qmake_image_collection.cpp
210 -$(DEL_FILE) qmake_image_collection.cpp
211 compiler_yacc_decl_make_all:
211 compiler_yacc_decl_make_all:
212 compiler_yacc_decl_clean:
212 compiler_yacc_decl_clean:
213 compiler_yacc_impl_make_all:
213 compiler_yacc_impl_make_all:
214 compiler_yacc_impl_clean:
214 compiler_yacc_impl_clean:
215 compiler_lex_make_all:
215 compiler_lex_make_all:
216 compiler_lex_clean:
216 compiler_lex_clean:
217 compiler_clean:
217 compiler_clean:
218
218
219 ####### Compile
219 ####### Compile
220
220
221 obj/wf_handler.o: ../src/wf_handler.c
221 obj/wf_handler.o: ../src/wf_handler.c
222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223
223
224 obj/tc_handler.o: ../src/tc_handler.c
224 obj/tc_handler.o: ../src/tc_handler.c
225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226
226
227 obj/fsw_misc.o: ../src/fsw_misc.c
227 obj/fsw_misc.o: ../src/fsw_misc.c
228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229
229
230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232
232
233 obj/fsw_globals.o: ../src/fsw_globals.c
233 obj/fsw_globals.o: ../src/fsw_globals.c
234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235
235
236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238
238
239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241
241
242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244
244
245 obj/tc_acceptance.o: ../src/tc_acceptance.c
245 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247
247
248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250
250
251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253
253
254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256
256
257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259
259
260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262
262
263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265
265
266 ####### Install
266 ####### Install
267
267
268 install: FORCE
268 install: FORCE
269
269
270 uninstall: FORCE
270 uninstall: FORCE
271
271
272 FORCE:
272 FORCE:
273
273
@@ -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-06-16T07:35:26. -->
3 <!-- Written by QtCreator 3.0.1, 2014-06-16T15:53:55. -->
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.2 in PATH (System)</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</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">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
195 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</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,109 +1,109
1 #ifndef GRLIB_REGS_H_INCLUDED
1 #ifndef GRLIB_REGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
3
3
4 #define NB_GPTIMER 3
4 #define NB_GPTIMER 3
5
5
6 struct apbuart_regs_str{
6 struct apbuart_regs_str{
7 volatile unsigned int data;
7 volatile unsigned int data;
8 volatile unsigned int status;
8 volatile unsigned int status;
9 volatile unsigned int ctrl;
9 volatile unsigned int ctrl;
10 volatile unsigned int scaler;
10 volatile unsigned int scaler;
11 volatile unsigned int fifoDebug;
11 volatile unsigned int fifoDebug;
12 };
12 };
13
13
14 struct grgpio_regs_str{
14 struct grgpio_regs_str{
15 volatile int io_port_data_register;
15 volatile int io_port_data_register;
16 int io_port_output_register;
16 int io_port_output_register;
17 int io_port_direction_register;
17 int io_port_direction_register;
18 int interrupt_mak_register;
18 int interrupt_mak_register;
19 int interrupt_polarity_register;
19 int interrupt_polarity_register;
20 int interrupt_edge_register;
20 int interrupt_edge_register;
21 int bypass_register;
21 int bypass_register;
22 int reserved;
22 int reserved;
23 // 0x20-0x3c interrupt map register(s)
23 // 0x20-0x3c interrupt map register(s)
24 };
24 };
25
25
26 typedef struct {
26 typedef struct {
27 volatile unsigned int counter;
27 volatile unsigned int counter;
28 volatile unsigned int reload;
28 volatile unsigned int reload;
29 volatile unsigned int ctrl;
29 volatile unsigned int ctrl;
30 volatile unsigned int unused;
30 volatile unsigned int unused;
31 } timer_regs_t;
31 } timer_regs_t;
32
32
33 typedef struct {
33 typedef struct {
34 volatile unsigned int scaler_value;
34 volatile unsigned int scaler_value;
35 volatile unsigned int scaler_reload;
35 volatile unsigned int scaler_reload;
36 volatile unsigned int conf;
36 volatile unsigned int conf;
37 volatile unsigned int unused0;
37 volatile unsigned int unused0;
38 timer_regs_t timer[NB_GPTIMER];
38 timer_regs_t timer[NB_GPTIMER];
39 } gptimer_regs_t;
39 } gptimer_regs_t;
40
40
41 typedef struct {
41 typedef struct {
42 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
42 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
43 volatile int coarse_time_load;
43 volatile int coarse_time_load;
44 volatile int coarse_time;
44 volatile int coarse_time;
45 volatile int fine_time;
45 volatile int fine_time;
46 } time_management_regs_t;
46 } time_management_regs_t;
47
47
48 typedef struct {
48 typedef struct {
49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
50 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
50 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
51 volatile int addr_data_f0; // 0x08 10 ***
51 volatile int addr_data_f0; // 0x08 10 ***
52 volatile int addr_data_f1; // 0x0c 11 ***
52 volatile int addr_data_f1; // 0x0c 11 ***
53 volatile int addr_data_f2; // 0x10 100 ***
53 volatile int addr_data_f2; // 0x10 100 ***
54 volatile int addr_data_f3; // 0x14 101 ***
54 volatile int addr_data_f3; // 0x14 101 ***
55 volatile int status; // 0x18 110 ***
55 volatile int status; // 0x18 110 ***
56 volatile int delta_snapshot; // 0x1c 111 ***
56 volatile int delta_snapshot; // 0x1c 111 ***
57 volatile int delta_f2_f1; // 0x20 0000 ***
57 volatile int delta_f2_f1; // 0x20 0000 ***
58 volatile int delta_f2_f0; // 0x24 0001 ***
58 volatile int delta_f2_f0; // 0x24 0001 ***
59 volatile int nb_burst_available;// 0x28 0010 ***
59 volatile int nb_burst_available;// 0x28 0010 ***
60 volatile int nb_snapshot_param; // 0x2c 0011 ***
60 volatile int nb_snapshot_param; // 0x2c 0011 ***
61 } waveform_picker_regs_t;
61 } waveform_picker_regs_t;
62
62
63 typedef struct{
63 typedef struct{
64 int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
64 int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
65 int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
65 int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
66 int addr_data_f0; // 0x08
66 int addr_data_f0; // 0x08
67 int addr_data_f1; // 0x0c
67 int addr_data_f1; // 0x0c
68 int addr_data_f2; // 0x10
68 int addr_data_f2; // 0x10
69 int addr_data_f3; // 0x14
69 int addr_data_f3; // 0x14
70 volatile int status; // 0x18
70 volatile int status; // 0x18
71 int delta_snapshot; // 0x1c
71 int delta_snapshot; // 0x1c
72 int delta_f0; // 0x20
72 int delta_f0; // 0x20
73 int delta_f0_2; // 0x24
73 int delta_f0_2; // 0x24
74 int delta_f1; // 0x28
74 int delta_f1; // 0x28
75 int delta_f2; // 0x2c
75 int delta_f2; // 0x2c
76 int nb_data_by_buffer; // 0x30
76 int nb_data_by_buffer; // 0x30
77 int snapshot_param; // 0x34
77 int snapshot_param; // 0x34
78 int start_date; // 0x38
78 int start_date; // 0x38
79 int nb_word_in_buffer; // 0x3c
79 int nb_word_in_buffer; // 0x3c
80 } waveform_picker_regs_new_t;
80 } waveform_picker_regs_new_t;
81
81
82 typedef struct {
82 typedef struct {
83 volatile int config; // 0x00
83 volatile int config; // 0x00
84 volatile int status; // 0x04
84 volatile int status; // 0x04
85 volatile int f0_0_address; // 0x08
85 volatile int f0_0_address; // 0x08
86 volatile int f0_1_address; // 0x0C
86 volatile int f0_1_address; // 0x0C
87 //
87 //
88 volatile int f1_0_address; // 0x10
88 volatile int f1_0_address; // 0x10
89 volatile int f1_1_address; // 0x14
89 volatile int f1_1_address; // 0x14
90 volatile int f2_0_address; // 0x18
90 volatile int f2_0_address; // 0x18
91 volatile int f2_1_address; // 0x1C
91 volatile int f2_1_address; // 0x1C
92 //
92 //
93 volatile int f0_0_coarse_time; // 0x20
93 volatile unsigned int f0_0_coarse_time; // 0x20
94 volatile int f0_0_fine_time; // 0x24
94 volatile unsigned int f0_0_fine_time; // 0x24
95 volatile int f0_1_coarse_time; // 0x28
95 volatile unsigned int f0_1_coarse_time; // 0x28
96 volatile int f0_1_fine_time; // 0x2C
96 volatile unsigned int f0_1_fine_time; // 0x2C
97 //
97 //
98 volatile int f1_0_coarse_time; // 0x30
98 volatile unsigned int f1_0_coarse_time; // 0x30
99 volatile int f1_0_fine_time; // 0x34
99 volatile unsigned int f1_0_fine_time; // 0x34
100 volatile int f1_1_coarse_time; // 0x38
100 volatile unsigned int f1_1_coarse_time; // 0x38
101 volatile int f1_1_time_time; // 0x3C
101 volatile unsigned int f1_1_time_time; // 0x3C
102 //
102 //
103 volatile int f2_0_coarse_time; // 0x40
103 volatile unsigned int f2_0_coarse_time; // 0x40
104 volatile int f2_0_fine_time; // 0x44
104 volatile unsigned int f2_0_fine_time; // 0x44
105 volatile int f2_1_coarse_time; // 0x48
105 volatile unsigned int f2_1_coarse_time; // 0x48
106 volatile int f2_1_time_time; // 0x4C
106 volatile unsigned int f2_1_fine_time; // 0x4C
107 } spectral_matrix_regs_t;
107 } spectral_matrix_regs_t;
108
108
109 #endif // GRLIB_REGS_H_INCLUDED
109 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,36 +1,36
1 #ifndef AVF0_PRC0_H_INCLUDED
1 #ifndef AVF0_PRC0_H_INCLUDED
2 #define AVF0_PRC0_H_INCLUDED
2 #define AVF0_PRC0_H_INCLUDED
3
3
4 #include "fsw_processing.h"
4 #include "fsw_processing.h"
5 #include "basic_parameters.h"
5 #include "basic_parameters.h"
6
6
7 typedef struct {
7 typedef struct {
8 unsigned int norm_bp1;
8 unsigned int norm_bp1;
9 unsigned int norm_bp2;
9 unsigned int norm_bp2;
10 unsigned int norm_asm;
10 unsigned int norm_asm;
11 unsigned int burst_sbm_bp1;
11 unsigned int burst_sbm_bp1;
12 unsigned int burst_sbm_bp2;
12 unsigned int burst_sbm_bp2;
13 unsigned int burst_bp1;
13 unsigned int burst_bp1;
14 unsigned int burst_bp2;
14 unsigned int burst_bp2;
15 unsigned int sbm1_bp1;
15 unsigned int sbm1_bp1;
16 unsigned int sbm1_bp2;
16 unsigned int sbm1_bp2;
17 unsigned int sbm2_bp1;
17 unsigned int sbm2_bp1;
18 unsigned int sbm2_bp2;
18 unsigned int sbm2_bp2;
19 } nb_sm_before_bp_asm_f0;
19 } nb_sm_before_bp_asm_f0;
20
20
21 //************
21 //************
22 // RTEMS TASKS
22 // RTEMS TASKS
23 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
23 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
24 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
24 rtems_task prc0_task( rtems_task_argument lfrRequestedMode );
25
25
26 //**********
26 //**********
27 // FUNCTIONS
27 // FUNCTIONS
28
28
29 void reset_nb_sm_f0( unsigned char lfrMode );
29 void reset_nb_sm_f0( unsigned char lfrMode );
30
30
31 //*******
31 //*******
32 // EXTERN
32 // EXTERN
33 extern struct ring_node_sm *ring_node_for_averaging_sm_f0;
33 extern ring_node_sm *ring_node_for_averaging_sm_f0;
34 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
34 extern rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
35
35
36 #endif // AVF0_PRC0_H_INCLUDED
36 #endif // AVF0_PRC0_H_INCLUDED
@@ -1,243 +1,243
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
31 typedef struct
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
37 typedef struct
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
43 typedef struct
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 // SM
73 // SM
74 void SM_init_rings( void );
74 void SM_init_rings( void );
75 void SM_reset_current_ring_nodes( void );
75 void SM_reset_current_ring_nodes( void );
76 void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] );
76 void SM_generic_init_ring(ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] );
77 // ASM
77 // ASM
78 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
78 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
79 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
79 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
80 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
80 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
81 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
81 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
82
82
83 //*****************
83 //*****************
84 // Basic Parameters
84 // Basic Parameters
85
85
86 void BP_reset_current_ring_nodes( void );
86 void BP_reset_current_ring_nodes( void );
87 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
87 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
88 unsigned int apid, unsigned char sid,
88 unsigned int apid, unsigned char sid,
89 unsigned int packetLength , unsigned char blkNr);
89 unsigned int packetLength , unsigned char blkNr);
90 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
90 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
91 unsigned int apid, unsigned char sid,
91 unsigned int apid, unsigned char sid,
92 unsigned int packetLength, unsigned char blkNr );
92 unsigned int packetLength, unsigned char blkNr );
93 void BP_send( char *data,
93 void BP_send( char *data,
94 rtems_id queue_id ,
94 rtems_id queue_id ,
95 unsigned int nbBytesToSend , unsigned int sid );
95 unsigned int nbBytesToSend , unsigned int sid );
96
96
97 //******************
97 //******************
98 // general functions
98 // general functions
99 void reset_spectral_matrix_regs( void );
99 void reset_spectral_matrix_regs( void );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode);
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
104 unsigned char getSID( rtems_event_set event );
104 unsigned char getSID( rtems_event_set event );
105
105
106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
107 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
107 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
108
108
109 //***************************************
109 //***************************************
110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
111 static inline void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
111 static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
112 ring_node_sm *ring_node_tab[],
112 ring_node_sm *ring_node_tab[],
113 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
113 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
114 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
114 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
115 float divider );
115 float divider );
116 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
116 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
117 float divider,
117 float divider,
118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
119 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
119 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
120
120
121 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
121 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
122 ring_node_sm *ring_node_tab[],
122 ring_node_sm *ring_node_tab[],
123 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
123 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
124 {
124 {
125 float sum;
125 float sum;
126 unsigned int i;
126 unsigned int i;
127
127
128 for(i=0; i<TOTAL_SIZE_SM; i++)
128 for(i=0; i<TOTAL_SIZE_SM; i++)
129 {
129 {
130 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
130 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
131 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
131 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
132 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
132 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
133 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
133 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
134 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
134 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
138
138
139 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
139 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
140 {
140 {
141 averaged_spec_mat_f0[ i ] = sum;
141 averaged_spec_mat_NORM[ i ] = sum;
142 averaged_spec_mat_f1[ i ] = sum;
142 averaged_spec_mat_SBM[ i ] = sum;
143 }
143 }
144 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
144 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
145 {
145 {
146 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
146 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
147 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
147 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
148 }
148 }
149 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
149 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
150 {
150 {
151 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
151 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
152 averaged_spec_mat_f1[ i ] = sum;
152 averaged_spec_mat_SBM[ i ] = sum;
153 }
153 }
154 else
154 else
155 {
155 {
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
157 }
157 }
158 }
158 }
159 }
159 }
160
160
161 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
161 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
162 {
162 {
163 int frequencyBin;
163 int frequencyBin;
164 int asmComponent;
164 int asmComponent;
165 unsigned int offsetAveragedSpecMatReorganized;
165 unsigned int offsetAveragedSpecMatReorganized;
166 unsigned int offsetAveragedSpecMat;
166 unsigned int offsetAveragedSpecMat;
167
167
168 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
168 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
169 {
169 {
170 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
170 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
171 {
171 {
172 offsetAveragedSpecMatReorganized =
172 offsetAveragedSpecMatReorganized =
173 frequencyBin * NB_VALUES_PER_SM
173 frequencyBin * NB_VALUES_PER_SM
174 + asmComponent;
174 + asmComponent;
175 offsetAveragedSpecMat =
175 offsetAveragedSpecMat =
176 asmComponent * NB_BINS_PER_SM
176 asmComponent * NB_BINS_PER_SM
177 + frequencyBin;
177 + frequencyBin;
178 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
178 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
179 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
179 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
180 }
180 }
181 }
181 }
182 }
182 }
183
183
184 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
184 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
185 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
185 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
186 {
186 {
187 int frequencyBin;
187 int frequencyBin;
188 int asmComponent;
188 int asmComponent;
189 int offsetASM;
189 int offsetASM;
190 int offsetCompressed;
190 int offsetCompressed;
191 int k;
191 int k;
192
192
193 // build data
193 // build data
194 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
194 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
195 {
195 {
196 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
196 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
197 {
197 {
198 offsetCompressed = // NO TIME OFFSET
198 offsetCompressed = // NO TIME OFFSET
199 frequencyBin * NB_VALUES_PER_SM
199 frequencyBin * NB_VALUES_PER_SM
200 + asmComponent;
200 + asmComponent;
201 offsetASM = // NO TIME OFFSET
201 offsetASM = // NO TIME OFFSET
202 asmComponent * NB_BINS_PER_SM
202 asmComponent * NB_BINS_PER_SM
203 + ASMIndexStart
203 + ASMIndexStart
204 + frequencyBin * nbBinsToAverage;
204 + frequencyBin * nbBinsToAverage;
205 compressed_spec_mat[ offsetCompressed ] = 0;
205 compressed_spec_mat[ offsetCompressed ] = 0;
206 for ( k = 0; k < nbBinsToAverage; k++ )
206 for ( k = 0; k < nbBinsToAverage; k++ )
207 {
207 {
208 compressed_spec_mat[offsetCompressed ] =
208 compressed_spec_mat[offsetCompressed ] =
209 ( compressed_spec_mat[ offsetCompressed ]
209 ( compressed_spec_mat[ offsetCompressed ]
210 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
210 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
211 }
211 }
212 }
212 }
213 }
213 }
214 }
214 }
215
215
216 void ASM_convert( volatile float *input_matrix, char *output_matrix)
216 void ASM_convert( volatile float *input_matrix, char *output_matrix)
217 {
217 {
218 unsigned int frequencyBin;
218 unsigned int frequencyBin;
219 unsigned int asmComponent;
219 unsigned int asmComponent;
220 char * pt_char_input;
220 char * pt_char_input;
221 char * pt_char_output;
221 char * pt_char_output;
222 unsigned int offsetInput;
222 unsigned int offsetInput;
223 unsigned int offsetOutput;
223 unsigned int offsetOutput;
224
224
225 pt_char_input = (char*) &input_matrix;
225 pt_char_input = (char*) &input_matrix;
226 pt_char_output = (char*) &output_matrix;
226 pt_char_output = (char*) &output_matrix;
227
227
228 // convert all other data
228 // convert all other data
229 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
229 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
230 {
230 {
231 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
231 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
232 {
232 {
233 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
233 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
234 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
234 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
235 pt_char_input = (char*) &input_matrix [ offsetInput ];
235 pt_char_input = (char*) &input_matrix [ offsetInput ];
236 pt_char_output = (char*) &output_matrix[ offsetOutput ];
236 pt_char_output = (char*) &output_matrix[ offsetOutput ];
237 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
237 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
238 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
238 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
239 }
239 }
240 }
240 }
241 }
241 }
242
242
243 #endif // FSW_PROCESSING_H_INCLUDED
243 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,615 +1,621
1 /** General usage functions and RTEMS tasks.
1 /** General usage functions and RTEMS tasks.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 */
6 */
7
7
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9
9
10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 {
12 {
13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 *
14 *
15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 * @param interrupt_level is the interrupt level that the timer drives.
18 * @param interrupt_level is the interrupt level that the timer drives.
19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 *
20 *
21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 *
22 *
23 */
23 */
24
24
25 rtems_status_code status;
25 rtems_status_code status;
26 rtems_isr_entry old_isr_handler;
26 rtems_isr_entry old_isr_handler;
27
27
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29
29
30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 if (status!=RTEMS_SUCCESSFUL)
31 if (status!=RTEMS_SUCCESSFUL)
32 {
32 {
33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 }
34 }
35
35
36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
37 }
37 }
38
38
39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
40 {
40 {
41 /** This function starts a GPTIMER timer.
41 /** This function starts a GPTIMER timer.
42 *
42 *
43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 *
45 *
46 */
46 */
47
47
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 }
53 }
54
54
55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
56 {
56 {
57 /** This function stops a GPTIMER timer.
57 /** This function stops a GPTIMER timer.
58 *
58 *
59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 *
61 *
62 */
62 */
63
63
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 }
67 }
68
68
69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
70 {
70 {
71 /** This function sets the clock divider of a GPTIMER timer.
71 /** This function sets the clock divider of a GPTIMER timer.
72 *
72 *
73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 *
76 *
77 */
77 */
78
78
79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 }
80 }
81
81
82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
83 {
83 {
84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
85
85
86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
87
87
88 return 0;
88 return 0;
89 }
89 }
90
90
91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
92 {
92 {
93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
94
94
95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
96
96
97 return 0;
97 return 0;
98 }
98 }
99
99
100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
101 {
101 {
102 /** This function sets the scaler reload register of the apbuart module
102 /** This function sets the scaler reload register of the apbuart module
103 *
103 *
104 * @param regs is the address of the apbuart registers in memory
104 * @param regs is the address of the apbuart registers in memory
105 * @param value is the value that will be stored in the scaler register
105 * @param value is the value that will be stored in the scaler register
106 *
106 *
107 * The value shall be set by the software to get data on the serial interface.
107 * The value shall be set by the software to get data on the serial interface.
108 *
108 *
109 */
109 */
110
110
111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
112
112
113 apbuart_regs->scaler = value;
113 apbuart_regs->scaler = value;
114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
115 }
115 }
116
116
117 //************
117 //************
118 // RTEMS TASKS
118 // RTEMS TASKS
119
119
120 rtems_task stat_task(rtems_task_argument argument)
120 rtems_task stat_task(rtems_task_argument argument)
121 {
121 {
122 int i;
122 int i;
123 int j;
123 int j;
124 i = 0;
124 i = 0;
125 j = 0;
125 j = 0;
126 BOOT_PRINTF("in STAT *** \n")
126 BOOT_PRINTF("in STAT *** \n")
127 while(1){
127 while(1){
128 rtems_task_wake_after(1000);
128 rtems_task_wake_after(1000);
129 PRINTF1("%d\n", j)
129 PRINTF1("%d\n", j)
130 if (i == CPU_USAGE_REPORT_PERIOD) {
130 if (i == CPU_USAGE_REPORT_PERIOD) {
131 // #ifdef PRINT_TASK_STATISTICS
131 // #ifdef PRINT_TASK_STATISTICS
132 // rtems_cpu_usage_report();
132 // rtems_cpu_usage_report();
133 // rtems_cpu_usage_reset();
133 // rtems_cpu_usage_reset();
134 // #endif
134 // #endif
135 i = 0;
135 i = 0;
136 }
136 }
137 else i++;
137 else i++;
138 j++;
138 j++;
139 }
139 }
140 }
140 }
141
141
142 rtems_task hous_task(rtems_task_argument argument)
142 rtems_task hous_task(rtems_task_argument argument)
143 {
143 {
144 rtems_status_code status;
144 rtems_status_code status;
145 rtems_id queue_id;
145 rtems_id queue_id;
146 rtems_rate_monotonic_period_status period_status;
146 rtems_rate_monotonic_period_status period_status;
147
147
148 status = get_message_queue_id_send( &queue_id );
148 status = get_message_queue_id_send( &queue_id );
149 if (status != RTEMS_SUCCESSFUL)
149 if (status != RTEMS_SUCCESSFUL)
150 {
150 {
151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 }
152 }
153
153
154 BOOT_PRINTF("in HOUS ***\n")
154 BOOT_PRINTF("in HOUS ***\n")
155
155
156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 if( status != RTEMS_SUCCESSFUL ) {
158 if( status != RTEMS_SUCCESSFUL ) {
159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
160 }
160 }
161 }
161 }
162
162
163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 housekeeping_packet.reserved = DEFAULT_RESERVED;
165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 housekeeping_packet.userApplication = CCSDS_USER_APP;
166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 housekeeping_packet.serviceType = TM_TYPE_HK;
174 housekeeping_packet.serviceType = TM_TYPE_HK;
175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 housekeeping_packet.sid = SID_HK;
177 housekeeping_packet.sid = SID_HK;
178
178
179 status = rtems_rate_monotonic_cancel(HK_id);
179 status = rtems_rate_monotonic_cancel(HK_id);
180 if( status != RTEMS_SUCCESSFUL ) {
180 if( status != RTEMS_SUCCESSFUL ) {
181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 }
182 }
183 else {
183 else {
184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 }
185 }
186
186
187 // startup phase
187 // startup phase
188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 {
192 {
193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 {
194 {
195 break; // break if LFR is synchronized
195 break; // break if LFR is synchronized
196 }
196 }
197 else
197 else
198 {
198 {
199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 // sched_yield();
200 // sched_yield();
201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
202 }
202 }
203 }
203 }
204 status = rtems_rate_monotonic_cancel(HK_id);
204 status = rtems_rate_monotonic_cancel(HK_id);
205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
206
206
207 while(1){ // launch the rate monotonic task
207 while(1){ // launch the rate monotonic task
208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 if ( status != RTEMS_SUCCESSFUL ) {
209 if ( status != RTEMS_SUCCESSFUL ) {
210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 }
212 }
213 else {
213 else {
214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterHK >> 8;
214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterHK >> 8;
215 housekeeping_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterHK;
215 housekeeping_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterHK;
216 increment_seq_counter( &sequenceCounterHK );
216 increment_seq_counter( &sequenceCounterHK );
217
217
218 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
218 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
219 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
219 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
220 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
220 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
221 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
221 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
222 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
222 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
223 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
223 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
224
224
225 spacewire_update_statistics();
225 spacewire_update_statistics();
226
226
227 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
227 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
228 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
228 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
229
229
230 // SEND PACKET
230 // SEND PACKET
231 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
231 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
232 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
232 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
233 if (status != RTEMS_SUCCESSFUL) {
233 if (status != RTEMS_SUCCESSFUL) {
234 PRINTF1("in HOUS *** ERR send: %d\n", status)
234 PRINTF1("in HOUS *** ERR send: %d\n", status)
235 }
235 }
236 }
236 }
237 }
237 }
238
238
239 PRINTF("in HOUS *** deleting task\n")
239 PRINTF("in HOUS *** deleting task\n")
240
240
241 status = rtems_task_delete( RTEMS_SELF ); // should not return
241 status = rtems_task_delete( RTEMS_SELF ); // should not return
242 printf( "rtems_task_delete returned with status of %d.\n", status );
242 printf( "rtems_task_delete returned with status of %d.\n", status );
243 return;
243 return;
244 }
244 }
245
245
246 rtems_task dumb_task( rtems_task_argument unused )
246 rtems_task dumb_task( rtems_task_argument unused )
247 {
247 {
248 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
248 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
249 *
249 *
250 * @param unused is the starting argument of the RTEMS task
250 * @param unused is the starting argument of the RTEMS task
251 *
251 *
252 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
252 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
253 *
253 *
254 */
254 */
255
255
256 unsigned int i;
256 unsigned int i;
257 unsigned int intEventOut;
257 unsigned int intEventOut;
258 unsigned int coarse_time = 0;
258 unsigned int coarse_time = 0;
259 unsigned int fine_time = 0;
259 unsigned int fine_time = 0;
260 rtems_event_set event_out;
260 rtems_event_set event_out;
261
261
262 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
262 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
266 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
266 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
268 "ERR HK", // RTEMS_EVENT_6
268 "ERR HK", // RTEMS_EVENT_6
269 "ready for dump", // RTEMS_EVENT_7
269 "ready for dump", // RTEMS_EVENT_7
270 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
270 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
271 "tick" // RTEMS_EVENT_9
271 "tick", // RTEMS_EVENT_9
272 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
273 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
272 };
274 };
273
275
274 BOOT_PRINTF("in DUMB *** \n")
276 BOOT_PRINTF("in DUMB *** \n")
275
277
276 while(1){
278 while(1){
277 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
279 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
278 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
280 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
279 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
281 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
280 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
282 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
281 intEventOut = (unsigned int) event_out;
283 intEventOut = (unsigned int) event_out;
282 for ( i=0; i<32; i++)
284 for ( i=0; i<32; i++)
283 {
285 {
284 if ( ((intEventOut >> i) & 0x0001) != 0)
286 if ( ((intEventOut >> i) & 0x0001) != 0)
285 {
287 {
286 coarse_time = time_management_regs->coarse_time;
288 coarse_time = time_management_regs->coarse_time;
287 fine_time = time_management_regs->fine_time;
289 fine_time = time_management_regs->fine_time;
288 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
290 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
289 if (i==8)
291 if (i==8)
290 {
292 {
291 PRINTF1("status = %x\n", spectral_matrix_regs->status)
293 PRINTF1("spectral_matrix_regs->status = %x\n", spectral_matrix_regs->status)
294 }
295 if (i==10)
296 {
297 PRINTF1("waveform_picker_regs->status = %x\n", waveform_picker_regs->status)
292 }
298 }
293 }
299 }
294 }
300 }
295 }
301 }
296 }
302 }
297
303
298 //*****************************
304 //*****************************
299 // init housekeeping parameters
305 // init housekeeping parameters
300
306
301 void init_housekeeping_parameters( void )
307 void init_housekeeping_parameters( void )
302 {
308 {
303 /** This function initialize the housekeeping_packet global variable with default values.
309 /** This function initialize the housekeeping_packet global variable with default values.
304 *
310 *
305 */
311 */
306
312
307 unsigned int i = 0;
313 unsigned int i = 0;
308 unsigned char *parameters;
314 unsigned char *parameters;
309
315
310 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
316 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
311 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
317 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
312 {
318 {
313 parameters[i] = 0x00;
319 parameters[i] = 0x00;
314 }
320 }
315 // init status word
321 // init status word
316 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
322 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
317 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
323 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
318 // init software version
324 // init software version
319 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
325 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
320 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
326 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
321 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
327 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
322 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
328 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
323 // init fpga version
329 // init fpga version
324 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
330 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
325 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
331 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
326 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
332 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
327 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
333 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
328 }
334 }
329
335
330 void increment_seq_counter_old( unsigned char *packet_sequence_control)
336 void increment_seq_counter_old( unsigned char *packet_sequence_control)
331 {
337 {
332 /** This function increment the sequence counter psased in argument.
338 /** This function increment the sequence counter psased in argument.
333 *
339 *
334 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
340 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
335 *
341 *
336 */
342 */
337
343
338 unsigned short sequence_cnt;
344 unsigned short sequence_cnt;
339 unsigned short segmentation_grouping_flag;
345 unsigned short segmentation_grouping_flag;
340 unsigned short new_packet_sequence_control;
346 unsigned short new_packet_sequence_control;
341
347
342 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
348 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
343 sequence_cnt = (unsigned short) (
349 sequence_cnt = (unsigned short) (
344 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
350 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
345 + packet_sequence_control[1]
351 + packet_sequence_control[1]
346 );
352 );
347
353
348 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
354 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
349
355
350 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
356 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
351 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
357 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
352
358
353 if ( sequence_cnt < SEQ_CNT_MAX)
359 if ( sequence_cnt < SEQ_CNT_MAX)
354 {
360 {
355 sequence_cnt = sequence_cnt + 1;
361 sequence_cnt = sequence_cnt + 1;
356 }
362 }
357 else
363 else
358 {
364 {
359 sequence_cnt = 0;
365 sequence_cnt = 0;
360 }
366 }
361 }
367 }
362
368
363 void increment_seq_counter( unsigned short *packetSequenceControl )
369 void increment_seq_counter( unsigned short *packetSequenceControl )
364 {
370 {
365 /** This function increment the sequence counter psased in argument.
371 /** This function increment the sequence counter psased in argument.
366 *
372 *
367 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
373 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
368 *
374 *
369 */
375 */
370
376
371 unsigned short sequence_cnt;
377 unsigned short sequence_cnt;
372 unsigned short segmentation_grouping_flag;
378 unsigned short segmentation_grouping_flag;
373
379
374 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
380 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
375 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
381 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
376
382
377 if ( sequence_cnt < SEQ_CNT_MAX)
383 if ( sequence_cnt < SEQ_CNT_MAX)
378 {
384 {
379 sequence_cnt = sequence_cnt + 1;
385 sequence_cnt = sequence_cnt + 1;
380 }
386 }
381 else
387 else
382 {
388 {
383 sequence_cnt = 0;
389 sequence_cnt = 0;
384 }
390 }
385
391
386 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
392 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
387 }
393 }
388
394
389 void getTime( unsigned char *time)
395 void getTime( unsigned char *time)
390 {
396 {
391 /** This function write the current local time in the time buffer passed in argument.
397 /** This function write the current local time in the time buffer passed in argument.
392 *
398 *
393 */
399 */
394
400
395 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
401 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
396 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
402 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
397 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
403 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
398 time[3] = (unsigned char) (time_management_regs->coarse_time);
404 time[3] = (unsigned char) (time_management_regs->coarse_time);
399 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
405 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
400 time[5] = (unsigned char) (time_management_regs->fine_time);
406 time[5] = (unsigned char) (time_management_regs->fine_time);
401 }
407 }
402
408
403 unsigned long long int getTimeAsUnsignedLongLongInt( )
409 unsigned long long int getTimeAsUnsignedLongLongInt( )
404 {
410 {
405 /** This function write the current local time in the time buffer passed in argument.
411 /** This function write the current local time in the time buffer passed in argument.
406 *
412 *
407 */
413 */
408 unsigned long long int time;
414 unsigned long long int time;
409
415
410 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
416 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
411 + time_management_regs->fine_time;
417 + time_management_regs->fine_time;
412
418
413 return time;
419 return time;
414 }
420 }
415
421
416 void send_dumb_hk( void )
422 void send_dumb_hk( void )
417 {
423 {
418 Packet_TM_LFR_HK_t dummy_hk_packet;
424 Packet_TM_LFR_HK_t dummy_hk_packet;
419 unsigned char *parameters;
425 unsigned char *parameters;
420 unsigned int i;
426 unsigned int i;
421 rtems_id queue_id;
427 rtems_id queue_id;
422
428
423 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
429 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
424 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
430 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
425 dummy_hk_packet.reserved = DEFAULT_RESERVED;
431 dummy_hk_packet.reserved = DEFAULT_RESERVED;
426 dummy_hk_packet.userApplication = CCSDS_USER_APP;
432 dummy_hk_packet.userApplication = CCSDS_USER_APP;
427 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
433 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
428 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
434 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
429 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
435 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
430 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
436 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
431 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
437 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
432 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
438 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
433 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
439 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
434 dummy_hk_packet.serviceType = TM_TYPE_HK;
440 dummy_hk_packet.serviceType = TM_TYPE_HK;
435 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
441 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
436 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
442 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
437 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
443 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
438 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
444 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
439 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
445 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
440 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
446 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
441 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
447 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
442 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
448 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
443 dummy_hk_packet.sid = SID_HK;
449 dummy_hk_packet.sid = SID_HK;
444
450
445 // init status word
451 // init status word
446 dummy_hk_packet.lfr_status_word[0] = 0xff;
452 dummy_hk_packet.lfr_status_word[0] = 0xff;
447 dummy_hk_packet.lfr_status_word[1] = 0xff;
453 dummy_hk_packet.lfr_status_word[1] = 0xff;
448 // init software version
454 // init software version
449 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
455 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
450 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
456 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
451 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
457 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
452 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
458 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
453 // init fpga version
459 // init fpga version
454 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
460 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
455 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
461 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
456 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
462 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
457 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
463 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
458
464
459 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
465 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
460
466
461 for (i=0; i<100; i++)
467 for (i=0; i<100; i++)
462 {
468 {
463 parameters[i] = 0xff;
469 parameters[i] = 0xff;
464 }
470 }
465
471
466 get_message_queue_id_send( &queue_id );
472 get_message_queue_id_send( &queue_id );
467
473
468 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
474 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
469 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
475 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
470 }
476 }
471
477
472 void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential )
478 void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential )
473 {
479 {
474 unsigned int coarseTime;
480 unsigned int coarseTime;
475 unsigned int acquisitionTime;
481 unsigned int acquisitionTime;
476 unsigned int deltaT = 0;
482 unsigned int deltaT = 0;
477 unsigned char *bufferPtr;
483 unsigned char *bufferPtr;
478
484
479 unsigned int offset_in_samples;
485 unsigned int offset_in_samples;
480 unsigned int offset_in_bytes;
486 unsigned int offset_in_bytes;
481 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
487 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
482
488
483 if (lfrCurrentMode == LFR_MODE_STANDBY)
489 if (lfrCurrentMode == LFR_MODE_STANDBY)
484 {
490 {
485 spacecraft_potential[0] = 0x00;
491 spacecraft_potential[0] = 0x00;
486 spacecraft_potential[1] = 0x00;
492 spacecraft_potential[1] = 0x00;
487 spacecraft_potential[2] = 0x00;
493 spacecraft_potential[2] = 0x00;
488 spacecraft_potential[3] = 0x00;
494 spacecraft_potential[3] = 0x00;
489 spacecraft_potential[4] = 0x00;
495 spacecraft_potential[4] = 0x00;
490 spacecraft_potential[5] = 0x00;
496 spacecraft_potential[5] = 0x00;
491 }
497 }
492 else
498 else
493 {
499 {
494 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
500 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
495 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
501 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
496 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
502 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
497 + (unsigned int) ( bufferPtr[3] << 16 )
503 + (unsigned int) ( bufferPtr[3] << 16 )
498 + (unsigned int) ( bufferPtr[0] << 8 )
504 + (unsigned int) ( bufferPtr[0] << 8 )
499 + (unsigned int) ( bufferPtr[1] );
505 + (unsigned int) ( bufferPtr[1] );
500 if ( coarseTime > acquisitionTime )
506 if ( coarseTime > acquisitionTime )
501 {
507 {
502 deltaT = coarseTime - acquisitionTime;
508 deltaT = coarseTime - acquisitionTime;
503 offset_in_samples = (deltaT-1) * f3 ;
509 offset_in_samples = (deltaT-1) * f3 ;
504 }
510 }
505 else if( coarseTime == acquisitionTime )
511 else if( coarseTime == acquisitionTime )
506 {
512 {
507 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
513 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
508 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
514 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
509 }
515 }
510 else
516 else
511 {
517 {
512 offset_in_samples = 0;
518 offset_in_samples = 0;
513 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
519 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
514 }
520 }
515
521
516 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
522 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
517 {
523 {
518 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
524 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
519 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
525 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
520 }
526 }
521 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
527 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
522 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
528 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
523 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
529 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
524 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
530 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
525 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
531 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
526 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
532 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
527 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
533 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
528 }
534 }
529 }
535 }
530
536
531 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
537 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
532 {
538 {
533 unsigned int coarseTime;
539 unsigned int coarseTime;
534 unsigned int acquisitionTime;
540 unsigned int acquisitionTime;
535 unsigned int deltaT = 0;
541 unsigned int deltaT = 0;
536 unsigned char *bufferPtr;
542 unsigned char *bufferPtr;
537
543
538 unsigned int offset_in_samples;
544 unsigned int offset_in_samples;
539 unsigned int offset_in_bytes;
545 unsigned int offset_in_bytes;
540 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
546 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
541
547
542 if (lfrCurrentMode == LFR_MODE_STANDBY)
548 if (lfrCurrentMode == LFR_MODE_STANDBY)
543 {
549 {
544 spacecraft_potential[0] = 0x00;
550 spacecraft_potential[0] = 0x00;
545 spacecraft_potential[1] = 0x00;
551 spacecraft_potential[1] = 0x00;
546 spacecraft_potential[2] = 0x00;
552 spacecraft_potential[2] = 0x00;
547 spacecraft_potential[3] = 0x00;
553 spacecraft_potential[3] = 0x00;
548 spacecraft_potential[4] = 0x00;
554 spacecraft_potential[4] = 0x00;
549 spacecraft_potential[5] = 0x00;
555 spacecraft_potential[5] = 0x00;
550 }
556 }
551 else
557 else
552 {
558 {
553 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
559 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
554 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
560 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
555 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
561 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
556 + (unsigned int) ( bufferPtr[1] << 16 )
562 + (unsigned int) ( bufferPtr[1] << 16 )
557 + (unsigned int) ( bufferPtr[2] << 8 )
563 + (unsigned int) ( bufferPtr[2] << 8 )
558 + (unsigned int) ( bufferPtr[3] );
564 + (unsigned int) ( bufferPtr[3] );
559 if ( coarseTime > acquisitionTime )
565 if ( coarseTime > acquisitionTime )
560 {
566 {
561 deltaT = coarseTime - acquisitionTime;
567 deltaT = coarseTime - acquisitionTime;
562 offset_in_samples = (deltaT-1) * f3 ;
568 offset_in_samples = (deltaT-1) * f3 ;
563 }
569 }
564 else if( coarseTime == acquisitionTime )
570 else if( coarseTime == acquisitionTime )
565 {
571 {
566 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
572 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
567 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
573 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
568 }
574 }
569 else
575 else
570 {
576 {
571 offset_in_samples = 0;
577 offset_in_samples = 0;
572 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
578 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
573 }
579 }
574
580
575 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
581 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
576 {
582 {
577 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
583 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
578 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
584 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
579 }
585 }
580 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
586 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
581 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
587 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
582 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
588 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
583 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
589 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
584 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
590 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
585 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
591 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
586 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
592 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
587 }
593 }
588 }
594 }
589
595
590 void get_cpu_load( unsigned char *resource_statistics )
596 void get_cpu_load( unsigned char *resource_statistics )
591 {
597 {
592 unsigned char cpu_load;
598 unsigned char cpu_load;
593
599
594 cpu_load = lfr_rtems_cpu_usage_report();
600 cpu_load = lfr_rtems_cpu_usage_report();
595
601
596 // HK_LFR_CPU_LOAD
602 // HK_LFR_CPU_LOAD
597 resource_statistics[0] = cpu_load;
603 resource_statistics[0] = cpu_load;
598
604
599 // HK_LFR_CPU_LOAD_MAX
605 // HK_LFR_CPU_LOAD_MAX
600 if (cpu_load > resource_statistics[1])
606 if (cpu_load > resource_statistics[1])
601 {
607 {
602 resource_statistics[1] = cpu_load;
608 resource_statistics[1] = cpu_load;
603 }
609 }
604
610
605 // CPU_LOAD_AVE
611 // CPU_LOAD_AVE
606 resource_statistics[2] = 0;
612 resource_statistics[2] = 0;
607
613
608 #ifndef PRINT_TASK_STATISTICS
614 #ifndef PRINT_TASK_STATISTICS
609 rtems_cpu_usage_reset();
615 rtems_cpu_usage_reset();
610 #endif
616 #endif
611
617
612 }
618 }
613
619
614
620
615
621
@@ -1,379 +1,380
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 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
14
14
15 //***
15 //***
16 // F0
16 // F0
17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
18 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
18 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
19
19
20 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
20 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
21 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
21 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
22 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
22 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
23 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
23 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
24 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
24 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
25 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
25 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
26
26
27 //************
27 //************
28 // RTEMS TASKS
28 // RTEMS TASKS
29
29
30 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
30 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
31 {
31 {
32 int i;
32 int i;
33
33
34 rtems_event_set event_out;
34 rtems_event_set event_out;
35 rtems_status_code status;
35 rtems_status_code status;
36 rtems_id queue_id_prc0;
36 rtems_id queue_id_prc0;
37 asm_msg msgForMATR;
37 asm_msg msgForMATR;
38 ring_node_sm *ring_node_tab[8];
38 ring_node_sm *ring_node_tab[8];
39 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
39 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
40 ring_node_asm *current_ring_node_asm_norm_f0;
40 ring_node_asm *current_ring_node_asm_norm_f0;
41
41
42 unsigned int nb_norm_bp1;
42 unsigned int nb_norm_bp1;
43 unsigned int nb_norm_bp2;
43 unsigned int nb_norm_bp2;
44 unsigned int nb_norm_asm;
44 unsigned int nb_norm_asm;
45 unsigned int nb_sbm_bp1;
45 unsigned int nb_sbm_bp1;
46 unsigned int nb_sbm_bp2;
46 unsigned int nb_sbm_bp2;
47
47
48 nb_norm_bp1 = 0;
48 nb_norm_bp1 = 0;
49 nb_norm_bp2 = 0;
49 nb_norm_bp2 = 0;
50 nb_norm_asm = 0;
50 nb_norm_asm = 0;
51 nb_sbm_bp1 = 0;
51 nb_sbm_bp1 = 0;
52 nb_sbm_bp2 = 0;
52 nb_sbm_bp2 = 0;
53
53
54 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
54 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
55 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
55 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
56 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
56 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
57 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
57 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
58 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
58 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
59
59
60 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
60 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
61
61
62 status = get_message_queue_id_prc0( &queue_id_prc0 );
62 status = get_message_queue_id_prc0( &queue_id_prc0 );
63 if (status != RTEMS_SUCCESSFUL)
63 if (status != RTEMS_SUCCESSFUL)
64 {
64 {
65 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
65 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
66 }
66 }
67
67
68 while(1){
68 while(1){
69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
70
71 //****************************************
72 // initialize the mesage for the MATR task
73 msgForMATR.norm = current_ring_node_asm_norm_f0;
74 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
75 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
76 msgForMATR.coarseTime = ring_node_for_averaging_sm_f0->coarseTime;
77 msgForMATR.fineTime = ring_node_for_averaging_sm_f0->fineTime;
78 //
79 //****************************************
80
70 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
81 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
71 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
82 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
72 {
83 {
73 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
84 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
74 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
85 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
75 }
86 }
76
87
77 // compute the average and store it in the averaged_sm_f1 buffer
88 // compute the average and store it in the averaged_sm_f1 buffer
78 SM_average( current_ring_node_asm_norm_f0->matrix,
89 SM_average( current_ring_node_asm_norm_f0->matrix,
79 current_ring_node_asm_burst_sbm_f0->matrix,
90 current_ring_node_asm_burst_sbm_f0->matrix,
80 ring_node_tab,
91 ring_node_tab,
81 nb_norm_bp1, nb_sbm_bp1 );
92 nb_norm_bp1, nb_sbm_bp1 );
82
93
83 // update nb_average
94 // update nb_average
84 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
95 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
85 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
96 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
86 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
97 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
98 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
99 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
89
100
90 //****************************************
91 // initialize the mesage for the MATR task
92 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
94 msgForMATR.norm = current_ring_node_asm_norm_f0;
95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
97 msgForMATR.coarseTime = time_management_regs->coarse_time;
98 msgForMATR.fineTime = time_management_regs->fine_time;
99
100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 {
102 {
102 nb_sbm_bp1 = 0;
103 nb_sbm_bp1 = 0;
103 // set another ring for the ASM storage
104 // set another ring for the ASM storage
104 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
105 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
105 if ( lfrCurrentMode == LFR_MODE_BURST )
106 if ( lfrCurrentMode == LFR_MODE_BURST )
106 {
107 {
107 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
108 }
109 }
109 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
110 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
110 {
111 {
111 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
112 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
112 }
113 }
113 }
114 }
114
115
115 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
116 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
116 {
117 {
117 nb_sbm_bp2 = 0;
118 nb_sbm_bp2 = 0;
118 if ( lfrCurrentMode == LFR_MODE_BURST )
119 if ( lfrCurrentMode == LFR_MODE_BURST )
119 {
120 {
120 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
121 }
122 }
122 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
123 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
123 {
124 {
124 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
125 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
125 }
126 }
126 }
127 }
127
128
128 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
129 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
129 {
130 {
130 nb_norm_bp1 = 0;
131 nb_norm_bp1 = 0;
131 // set another ring for the ASM storage
132 // set another ring for the ASM storage
132 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
133 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
133 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
134 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
134 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
135 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
135 {
136 {
136 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
137 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
137 }
138 }
138 }
139 }
139
140
140 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
141 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
141 {
142 {
142 nb_norm_bp2 = 0;
143 nb_norm_bp2 = 0;
143 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
144 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
144 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
145 {
146 {
146 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
147 }
148 }
148 }
149 }
149
150
150 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
151 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
151 {
152 {
152 nb_norm_asm = 0;
153 nb_norm_asm = 0;
153 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
154 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
154 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
155 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
155 {
156 {
156 // PRINTF1("%lld\n", localTime)
157 // PRINTF1("%lld\n", localTime)
157 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
158 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
158 }
159 }
159 }
160 }
160
161
161 //*************************
162 //*************************
162 // send the message to MATR
163 // send the message to MATR
163 if (msgForMATR.event != 0x00)
164 if (msgForMATR.event != 0x00)
164 {
165 {
165 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
166 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
166 }
167 }
167
168
168 if (status != RTEMS_SUCCESSFUL) {
169 if (status != RTEMS_SUCCESSFUL) {
169 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
170 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
170 }
171 }
171 }
172 }
172 }
173 }
173
174
174 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
175 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
175 {
176 {
176 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
177 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
177 size_t size; // size of the incoming TC packet
178 size_t size; // size of the incoming TC packet
178 asm_msg *incomingMsg;
179 asm_msg *incomingMsg;
179 //
180 //
180 unsigned char sid;
181 unsigned char sid;
181 spw_ioctl_pkt_send spw_ioctl_send_ASM;
182 spw_ioctl_pkt_send spw_ioctl_send_ASM;
182 rtems_status_code status;
183 rtems_status_code status;
183 rtems_id queue_id;
184 rtems_id queue_id;
184 rtems_id queue_id_q_p0;
185 rtems_id queue_id_q_p0;
185 Header_TM_LFR_SCIENCE_ASM_t headerASM;
186 Header_TM_LFR_SCIENCE_ASM_t headerASM;
186 bp_packet_with_spare packet_norm_bp1_f0;
187 bp_packet_with_spare packet_norm_bp1_f0;
187 bp_packet packet_norm_bp2_f0;
188 bp_packet packet_norm_bp2_f0;
188 bp_packet packet_sbm_bp1_f0;
189 bp_packet packet_sbm_bp1_f0;
189 bp_packet packet_sbm_bp2_f0;
190 bp_packet packet_sbm_bp2_f0;
190
191
191 unsigned long long int localTime;
192 unsigned long long int localTime;
192
193
193 ASM_init_header( &headerASM );
194 ASM_init_header( &headerASM );
194
195
195 //*************
196 //*************
196 // NORM headers
197 // NORM headers
197 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
198 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
198 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
199 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
199 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
200 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
200 BP_init_header( &packet_norm_bp2_f0.header,
201 BP_init_header( &packet_norm_bp2_f0.header,
201 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
202 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
202 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
203 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
203
204
204 //****************************
205 //****************************
205 // BURST SBM1 and SBM2 headers
206 // BURST SBM1 and SBM2 headers
206 if ( lfrRequestedMode == LFR_MODE_BURST )
207 if ( lfrRequestedMode == LFR_MODE_BURST )
207 {
208 {
208 BP_init_header( &packet_sbm_bp1_f0.header,
209 BP_init_header( &packet_sbm_bp1_f0.header,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
210 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
211 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
211 BP_init_header( &packet_sbm_bp2_f0.header,
212 BP_init_header( &packet_sbm_bp2_f0.header,
212 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
213 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
213 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
214 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
214 }
215 }
215 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
216 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
216 {
217 {
217 BP_init_header( &packet_sbm_bp1_f0.header,
218 BP_init_header( &packet_sbm_bp1_f0.header,
218 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
219 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
219 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
220 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
220 BP_init_header( &packet_sbm_bp2_f0.header,
221 BP_init_header( &packet_sbm_bp2_f0.header,
221 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
222 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
223 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
223 }
224 }
224 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
225 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
225 {
226 {
226 BP_init_header( &packet_sbm_bp1_f0.header,
227 BP_init_header( &packet_sbm_bp1_f0.header,
227 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
228 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
228 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
229 BP_init_header( &packet_sbm_bp2_f0.header,
230 BP_init_header( &packet_sbm_bp2_f0.header,
230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
231 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
232 }
233 }
233 else
234 else
234 {
235 {
235 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
236 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
236 }
237 }
237
238
238 status = get_message_queue_id_send( &queue_id );
239 status = get_message_queue_id_send( &queue_id );
239 if (status != RTEMS_SUCCESSFUL)
240 if (status != RTEMS_SUCCESSFUL)
240 {
241 {
241 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
242 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
242 }
243 }
243 status = get_message_queue_id_prc0( &queue_id_q_p0);
244 status = get_message_queue_id_prc0( &queue_id_q_p0);
244 if (status != RTEMS_SUCCESSFUL)
245 if (status != RTEMS_SUCCESSFUL)
245 {
246 {
246 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
247 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
247 }
248 }
248
249
249 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
250 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
250
251
251 while(1){
252 while(1){
252 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
253 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
253 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
254 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
254
255
255 incomingMsg = (asm_msg*) incomingData;
256 incomingMsg = (asm_msg*) incomingData;
256
257
257 localTime = getTimeAsUnsignedLongLongInt( );
258 localTime = getTimeAsUnsignedLongLongInt( );
258
259
259 //****************
260 //****************
260 //****************
261 //****************
261 // BURST SBM1 SBM2
262 // BURST SBM1 SBM2
262 //****************
263 //****************
263 //****************
264 //****************
264 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
265 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
265 {
266 {
266 sid = getSID( incomingMsg->event );
267 sid = getSID( incomingMsg->event );
267 // 1) compress the matrix for Basic Parameters calculation
268 // 1) compress the matrix for Basic Parameters calculation
268 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
269 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
269 nb_sm_before_f0.burst_sbm_bp1,
270 nb_sm_before_f0.burst_sbm_bp1,
270 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
271 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
271 ASM_F0_INDICE_START);
272 ASM_F0_INDICE_START);
272 // 2) compute the BP1 set
273 // 2) compute the BP1 set
273 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
274 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
274 // 3) send the BP1 set
275 // 3) send the BP1 set
275 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
276 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
276 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
277 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
277 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
278 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
278 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
279 sid);
280 sid);
280 // 4) compute the BP2 set if needed
281 // 4) compute the BP2 set if needed
281 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
282 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
282 {
283 {
283 // 1) compute the BP2 set
284 // 1) compute the BP2 set
284
285
285 // 2) send the BP2 set
286 // 2) send the BP2 set
286 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
287 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
287 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
288 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
288 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
289 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
290 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
290 sid);
291 sid);
291 }
292 }
292 }
293 }
293
294
294 //*****
295 //*****
295 //*****
296 //*****
296 // NORM
297 // NORM
297 //*****
298 //*****
298 //*****
299 //*****
299 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
300 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
300 {
301 {
301 // 1) compress the matrix for Basic Parameters calculation
302 // 1) compress the matrix for Basic Parameters calculation
302 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
303 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
303 nb_sm_before_f0.norm_bp1,
304 nb_sm_before_f0.norm_bp1,
304 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
305 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
305 ASM_F0_INDICE_START );
306 ASM_F0_INDICE_START );
306 // 2) compute the BP1 set
307 // 2) compute the BP1 set
307 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
308 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
308 // 3) send the BP1 set
309 // 3) send the BP1 set
309 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
310 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
310 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
311 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
311 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
312 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
312 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
313 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
313 SID_NORM_BP1_F0 );
314 SID_NORM_BP1_F0 );
314 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
315 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
315 {
316 {
316 // 1) compute the BP2 set using the same ASM as the one used for BP1
317 // 1) compute the BP2 set using the same ASM as the one used for BP1
317
318
318 // 2) send the BP2 set
319 // 2) send the BP2 set
319 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
320 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
320 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
321 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
321 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
322 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
322 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
323 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
323 SID_NORM_BP2_F0);
324 SID_NORM_BP2_F0);
324 }
325 }
325 }
326 }
326
327
327 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
328 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
328 {
329 {
329 // 1) reorganize the ASM and divide
330 // 1) reorganize the ASM and divide
330 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
331 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
331 asm_f0_reorganized,
332 asm_f0_reorganized,
332 nb_sm_before_f0.norm_bp1 );
333 nb_sm_before_f0.norm_bp1 );
333 // 2) convert the float array in a char array
334 // 2) convert the float array in a char array
334 ASM_convert( asm_f0_reorganized, asm_f0_char);
335 ASM_convert( asm_f0_reorganized, asm_f0_char);
335 // 3) send the spectral matrix packets
336 // 3) send the spectral matrix packets
336 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
337 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
337 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
338 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
338 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
339 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
339 }
340 }
340
341
341 }
342 }
342 }
343 }
343
344
344 //**********
345 //**********
345 // FUNCTIONS
346 // FUNCTIONS
346
347
347 void reset_nb_sm_f0( unsigned char lfrMode )
348 void reset_nb_sm_f0( unsigned char lfrMode )
348 {
349 {
349 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
350 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
350 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
351 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
351 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;
352 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;
352 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
353 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
353 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
354 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
354 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
355 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
355 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
356 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
356 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
357 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
357 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
358 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
358
359
359 if (lfrMode == LFR_MODE_SBM1)
360 if (lfrMode == LFR_MODE_SBM1)
360 {
361 {
361 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
362 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
362 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
363 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
363 }
364 }
364 else if (lfrMode == LFR_MODE_SBM2)
365 else if (lfrMode == LFR_MODE_SBM2)
365 {
366 {
366 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
367 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
367 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
368 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
368 }
369 }
369 else if (lfrMode == LFR_MODE_BURST)
370 else if (lfrMode == LFR_MODE_BURST)
370 {
371 {
371 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
372 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
372 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
373 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
373 }
374 }
374 else
375 else
375 {
376 {
376 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
377 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
377 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
378 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
378 }
379 }
379 }
380 }
@@ -1,359 +1,360
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 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
13
13
14 //***
14 //***
15 // F1
15 // F1
16 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
16 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
17 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
17 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
18
18
19 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
19 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
20 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
20 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
21 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
21 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
22 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
22 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
23
23
24 //************
24 //************
25 // RTEMS TASKS
25 // RTEMS TASKS
26
26
27 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
27 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
28 {
28 {
29 int i;
29 int i;
30
30
31 rtems_event_set event_out;
31 rtems_event_set event_out;
32 rtems_status_code status;
32 rtems_status_code status;
33 rtems_id queue_id_prc1;
33 rtems_id queue_id_prc1;
34 asm_msg msgForMATR;
34 asm_msg msgForMATR;
35 ring_node_sm *ring_node_tab[8];
35 ring_node_sm *ring_node_tab[8];
36 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
36 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
37 ring_node_asm *current_ring_node_asm_norm_f1;
37 ring_node_asm *current_ring_node_asm_norm_f1;
38
38
39 unsigned int nb_norm_bp1;
39 unsigned int nb_norm_bp1;
40 unsigned int nb_norm_bp2;
40 unsigned int nb_norm_bp2;
41 unsigned int nb_norm_asm;
41 unsigned int nb_norm_asm;
42 unsigned int nb_sbm_bp1;
42 unsigned int nb_sbm_bp1;
43 unsigned int nb_sbm_bp2;
43 unsigned int nb_sbm_bp2;
44
44
45 nb_norm_bp1 = 0;
45 nb_norm_bp1 = 0;
46 nb_norm_bp2 = 0;
46 nb_norm_bp2 = 0;
47 nb_norm_asm = 0;
47 nb_norm_asm = 0;
48 nb_sbm_bp1 = 0;
48 nb_sbm_bp1 = 0;
49 nb_sbm_bp2 = 0;
49 nb_sbm_bp2 = 0;
50
50
51 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
51 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
52 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
52 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
53 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
53 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
54 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
54 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
55 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
55 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
56
56
57 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
57 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
58
58
59 status = get_message_queue_id_prc1( &queue_id_prc1 );
59 status = get_message_queue_id_prc1( &queue_id_prc1 );
60 if (status != RTEMS_SUCCESSFUL)
60 if (status != RTEMS_SUCCESSFUL)
61 {
61 {
62 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
62 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
63 }
63 }
64
64
65 while(1){
65 while(1){
66 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
66 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
67
68 //****************************************
69 // initialize the mesage for the MATR task
70 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
71 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
72 msgForMATR.norm = current_ring_node_asm_norm_f1;
73 msgForMATR.coarseTime = ring_node_for_averaging_sm_f1->coarseTime;
74 msgForMATR.fineTime = ring_node_for_averaging_sm_f1->fineTime;
75 //
76 //****************************************
77
67 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
78 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
68 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
79 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
69 {
80 {
70 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
81 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
71 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
82 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
72 }
83 }
73
84
74 // compute the average and store it in the averaged_sm_f1 buffer
85 // compute the average and store it in the averaged_sm_f1 buffer
75 SM_average( current_ring_node_asm_norm_f1->matrix,
86 SM_average( current_ring_node_asm_norm_f1->matrix,
76 current_ring_node_asm_burst_sbm_f1->matrix,
87 current_ring_node_asm_burst_sbm_f1->matrix,
77 ring_node_tab,
88 ring_node_tab,
78 nb_norm_bp1, nb_sbm_bp1 );
89 nb_norm_bp1, nb_sbm_bp1 );
79
90
80 // update nb_average
91 // update nb_average
81 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
92 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
82 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
93 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
83 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
94 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
84 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
95 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
85 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
96 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
86
97
87 //****************************************
88 // initialize the mesage for the MATR task
89 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
90 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
91 msgForMATR.norm = current_ring_node_asm_norm_f1;
92 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
93 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
94 msgForMATR.coarseTime = time_management_regs->coarse_time;
95 msgForMATR.fineTime = time_management_regs->fine_time;
96
97 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 {
99 {
99 nb_sbm_bp1 = 0;
100 nb_sbm_bp1 = 0;
100 // set another ring for the ASM storage
101 // set another ring for the ASM storage
101 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
102 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
102 if ( lfrCurrentMode == LFR_MODE_BURST )
103 if ( lfrCurrentMode == LFR_MODE_BURST )
103 {
104 {
104 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
105 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
105 }
106 }
106 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
107 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
107 {
108 {
108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
109 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
109 }
110 }
110 }
111 }
111
112
112 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
113 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
113 {
114 {
114 nb_sbm_bp2 = 0;
115 nb_sbm_bp2 = 0;
115 if ( lfrCurrentMode == LFR_MODE_BURST )
116 if ( lfrCurrentMode == LFR_MODE_BURST )
116 {
117 {
117 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
118 }
119 }
119 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
120 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
120 {
121 {
121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
122 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
122 }
123 }
123 }
124 }
124
125
125 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
126 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
126 {
127 {
127 nb_norm_bp1 = 0;
128 nb_norm_bp1 = 0;
128 // set another ring for the ASM storage
129 // set another ring for the ASM storage
129 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
130 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
130 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
131 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
131 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
132 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
132 {
133 {
133 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
134 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
134 }
135 }
135 }
136 }
136
137
137 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
138 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
138 {
139 {
139 nb_norm_bp2 = 0;
140 nb_norm_bp2 = 0;
140 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
141 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
141 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
142 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
142 {
143 {
143 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
144 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
144 }
145 }
145 }
146 }
146
147
147 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
148 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
148 {
149 {
149 nb_norm_asm = 0;
150 nb_norm_asm = 0;
150 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
151 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
151 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
152 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
152 {
153 {
153 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
154 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
154 }
155 }
155 }
156 }
156
157
157 //*************************
158 //*************************
158 // send the message to MATR
159 // send the message to MATR
159 if (msgForMATR.event != 0x00)
160 if (msgForMATR.event != 0x00)
160 {
161 {
161 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
162 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
162 }
163 }
163
164
164 if (status != RTEMS_SUCCESSFUL) {
165 if (status != RTEMS_SUCCESSFUL) {
165 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
166 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
166 }
167 }
167 }
168 }
168 }
169 }
169
170
170 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
171 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
171 {
172 {
172 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
173 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
173 size_t size; // size of the incoming TC packet
174 size_t size; // size of the incoming TC packet
174 asm_msg *incomingMsg;
175 asm_msg *incomingMsg;
175 //
176 //
176 unsigned char sid;
177 unsigned char sid;
177 spw_ioctl_pkt_send spw_ioctl_send_ASM;
178 spw_ioctl_pkt_send spw_ioctl_send_ASM;
178 rtems_status_code status;
179 rtems_status_code status;
179 rtems_id queue_id_send;
180 rtems_id queue_id_send;
180 rtems_id queue_id_q_p1;
181 rtems_id queue_id_q_p1;
181 Header_TM_LFR_SCIENCE_ASM_t headerASM;
182 Header_TM_LFR_SCIENCE_ASM_t headerASM;
182 bp_packet_with_spare packet_norm_bp1;
183 bp_packet_with_spare packet_norm_bp1;
183 bp_packet packet_norm_bp2;
184 bp_packet packet_norm_bp2;
184 bp_packet packet_sbm_bp1;
185 bp_packet packet_sbm_bp1;
185 bp_packet packet_sbm_bp2;
186 bp_packet packet_sbm_bp2;
186
187
187 unsigned long long int localTime;
188 unsigned long long int localTime;
188
189
189 ASM_init_header( &headerASM );
190 ASM_init_header( &headerASM );
190
191
191 //*************
192 //*************
192 // NORM headers
193 // NORM headers
193 BP_init_header_with_spare( &packet_norm_bp1.header,
194 BP_init_header_with_spare( &packet_norm_bp1.header,
194 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
195 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
195 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
196 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
196 BP_init_header( &packet_norm_bp2.header,
197 BP_init_header( &packet_norm_bp2.header,
197 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
198 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
198 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
199 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
199
200
200 //***********************
201 //***********************
201 // BURST and SBM2 headers
202 // BURST and SBM2 headers
202 if ( lfrRequestedMode == LFR_MODE_BURST )
203 if ( lfrRequestedMode == LFR_MODE_BURST )
203 {
204 {
204 BP_init_header( &packet_sbm_bp1.header,
205 BP_init_header( &packet_sbm_bp1.header,
205 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
206 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
207 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
207 BP_init_header( &packet_sbm_bp2.header,
208 BP_init_header( &packet_sbm_bp2.header,
208 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
209 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
210 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
210 }
211 }
211 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
212 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
212 {
213 {
213 BP_init_header( &packet_sbm_bp1.header,
214 BP_init_header( &packet_sbm_bp1.header,
214 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
215 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
216 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
216 BP_init_header( &packet_sbm_bp2.header,
217 BP_init_header( &packet_sbm_bp2.header,
217 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
218 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
218 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
219 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
219 }
220 }
220 else
221 else
221 {
222 {
222 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
223 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
223 }
224 }
224
225
225 status = get_message_queue_id_send( &queue_id_send );
226 status = get_message_queue_id_send( &queue_id_send );
226 if (status != RTEMS_SUCCESSFUL)
227 if (status != RTEMS_SUCCESSFUL)
227 {
228 {
228 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
229 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
229 }
230 }
230 status = get_message_queue_id_prc1( &queue_id_q_p1);
231 status = get_message_queue_id_prc1( &queue_id_q_p1);
231 if (status != RTEMS_SUCCESSFUL)
232 if (status != RTEMS_SUCCESSFUL)
232 {
233 {
233 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
234 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
234 }
235 }
235
236
236 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
237 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
237
238
238 while(1){
239 while(1){
239 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
240 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
240 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
241 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
241
242
242 incomingMsg = (asm_msg*) incomingData;
243 incomingMsg = (asm_msg*) incomingData;
243
244
244 localTime = getTimeAsUnsignedLongLongInt( );
245 localTime = getTimeAsUnsignedLongLongInt( );
245 //***********
246 //***********
246 //***********
247 //***********
247 // BURST SBM2
248 // BURST SBM2
248 //***********
249 //***********
249 //***********
250 //***********
250 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
251 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
251 {
252 {
252 sid = getSID( incomingMsg->event );
253 sid = getSID( incomingMsg->event );
253 // 1) compress the matrix for Basic Parameters calculation
254 // 1) compress the matrix for Basic Parameters calculation
254 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
255 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
255 nb_sm_before_f1.burst_sbm_bp1,
256 nb_sm_before_f1.burst_sbm_bp1,
256 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
257 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
257 ASM_F1_INDICE_START);
258 ASM_F1_INDICE_START);
258 // 2) compute the BP1 set
259 // 2) compute the BP1 set
259
260
260 // 3) send the BP1 set
261 // 3) send the BP1 set
261 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
262 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
262 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
263 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
263 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
264 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
264 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
265 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
265 sid );
266 sid );
266 // 4) compute the BP2 set if needed
267 // 4) compute the BP2 set if needed
267 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
268 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
268 {
269 {
269 // 1) compute the BP2 set
270 // 1) compute the BP2 set
270
271
271 // 2) send the BP2 set
272 // 2) send the BP2 set
272 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
273 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
273 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
274 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
274 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
275 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
275 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
276 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
276 sid );
277 sid );
277 }
278 }
278 }
279 }
279
280
280 //*****
281 //*****
281 //*****
282 //*****
282 // NORM
283 // NORM
283 //*****
284 //*****
284 //*****
285 //*****
285 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
286 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
286 {
287 {
287 // 1) compress the matrix for Basic Parameters calculation
288 // 1) compress the matrix for Basic Parameters calculation
288 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
289 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
289 nb_sm_before_f1.norm_bp1,
290 nb_sm_before_f1.norm_bp1,
290 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
291 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
291 ASM_F0_INDICE_START );
292 ASM_F0_INDICE_START );
292 // 2) compute the BP1 set
293 // 2) compute the BP1 set
293
294
294 // 3) send the BP1 set
295 // 3) send the BP1 set
295 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
297 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
297 BP_send( (char *) &packet_norm_bp1, queue_id_send,
298 BP_send( (char *) &packet_norm_bp1, queue_id_send,
298 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
299 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
299 SID_NORM_BP1_F1 );
300 SID_NORM_BP1_F1 );
300 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
301 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
301 {
302 {
302 // 1) compute the BP2 set
303 // 1) compute the BP2 set
303
304
304 // 2) send the BP2 set
305 // 2) send the BP2 set
305 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
306 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
307 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
307 BP_send( (char *) &packet_norm_bp2, queue_id_send,
308 BP_send( (char *) &packet_norm_bp2, queue_id_send,
308 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
309 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
309 SID_NORM_BP2_F1 );
310 SID_NORM_BP2_F1 );
310 }
311 }
311 }
312 }
312
313
313 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
314 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
314 {
315 {
315 // 1) reorganize the ASM and divide
316 // 1) reorganize the ASM and divide
316 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
317 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
317 asm_f1_reorganized,
318 asm_f1_reorganized,
318 nb_sm_before_f1.norm_bp1 );
319 nb_sm_before_f1.norm_bp1 );
319 // 2) convert the float array in a char array
320 // 2) convert the float array in a char array
320 ASM_convert( asm_f1_reorganized, asm_f1_char);
321 ASM_convert( asm_f1_reorganized, asm_f1_char);
321 // 3) send the spectral matrix packets
322 // 3) send the spectral matrix packets
322 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
323 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
323 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
324 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
324 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
325 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
325 }
326 }
326
327
327 }
328 }
328 }
329 }
329
330
330 //**********
331 //**********
331 // FUNCTIONS
332 // FUNCTIONS
332
333
333 void reset_nb_sm_f1( unsigned char lfrMode )
334 void reset_nb_sm_f1( unsigned char lfrMode )
334 {
335 {
335 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
336 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
336 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
337 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
337 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;
338 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;
338 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
339 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
339 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
340 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
340 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
341 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
341 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
342 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
342
343
343 if (lfrMode == LFR_MODE_SBM2)
344 if (lfrMode == LFR_MODE_SBM2)
344 {
345 {
345 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
346 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
346 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
347 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
347 }
348 }
348 else if (lfrMode == LFR_MODE_BURST)
349 else if (lfrMode == LFR_MODE_BURST)
349 {
350 {
350 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
351 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
351 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
352 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
352 }
353 }
353 else
354 else
354 {
355 {
355 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
356 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
356 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
357 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
357 }
358 }
358 }
359 }
359
360
@@ -1,253 +1,253
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 "avf2_prc2.h"
10 #include "avf2_prc2.h"
11
11
12 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
12 nb_sm_before_bp_asm_f2 nb_sm_before_f2;
13
13
14 //***
14 //***
15 // F2
15 // F2
16 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
16 ring_node_asm asm_ring_norm_f2 [ NB_RING_NODES_ASM_NORM_F2 ];
17 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
17 ring_node_asm asm_ring_burst_sbm_f2[ NB_RING_NODES_ASM_BURST_SBM_F2 ];
18
18
19 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
19 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
20 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
20 char asm_f2_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
21 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
21 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
22 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
22 float compressed_sm_sbm_f2 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 ];
23
23
24 //************
24 //************
25 // RTEMS TASKS
25 // RTEMS TASKS
26
26
27 //***
27 //***
28 // F2
28 // F2
29 rtems_task avf2_task( rtems_task_argument argument )
29 rtems_task avf2_task( rtems_task_argument argument )
30 {
30 {
31 rtems_event_set event_out;
31 rtems_event_set event_out;
32 rtems_status_code status;
32 rtems_status_code status;
33 rtems_id queue_id_prc2;
33 rtems_id queue_id_prc2;
34 asm_msg msgForMATR;
34 asm_msg msgForMATR;
35 ring_node_asm *current_ring_node_asm_norm_f2;
35 ring_node_asm *current_ring_node_asm_norm_f2;
36
36
37 unsigned int nb_norm_bp1;
37 unsigned int nb_norm_bp1;
38 unsigned int nb_norm_bp2;
38 unsigned int nb_norm_bp2;
39 unsigned int nb_norm_asm;
39 unsigned int nb_norm_asm;
40
40
41 nb_norm_bp1 = 0;
41 nb_norm_bp1 = 0;
42 nb_norm_bp2 = 0;
42 nb_norm_bp2 = 0;
43 nb_norm_asm = 0;
43 nb_norm_asm = 0;
44
44
45 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
45 reset_nb_sm_f2( ); // reset the sm counters that drive the BP and ASM computations / transmissions
46 ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 );
46 ASM_generic_init_ring( asm_ring_norm_f2, NB_RING_NODES_ASM_NORM_F2 );
47 current_ring_node_asm_norm_f2 = asm_ring_norm_f2;
47 current_ring_node_asm_norm_f2 = asm_ring_norm_f2;
48
48
49 BOOT_PRINTF("in AVF2 ***\n")
49 BOOT_PRINTF("in AVF2 ***\n")
50
50
51 status = get_message_queue_id_prc2( &queue_id_prc2 );
51 status = get_message_queue_id_prc2( &queue_id_prc2 );
52 if (status != RTEMS_SUCCESSFUL)
52 if (status != RTEMS_SUCCESSFUL)
53 {
53 {
54 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
54 PRINTF1("in AVF2 *** ERR get_message_queue_id_prc2 %d\n", status)
55 }
55 }
56
56
57 while(1){
57 while(1){
58 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
58 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
59
59
60 //****************************************
61 // initialize the mesage for the MATR task
62 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
63 msgForMATR.burst_sbm = NULL;
64 msgForMATR.norm = current_ring_node_asm_norm_f2;
65 msgForMATR.coarseTime = ring_node_for_averaging_sm_f2->coarseTime;
66 msgForMATR.fineTime = ring_node_for_averaging_sm_f2->fineTime;
67 //
68 //****************************************
69
60 // compute the average and store it in the averaged_sm_f2 buffer
70 // compute the average and store it in the averaged_sm_f2 buffer
61 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
71 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
62 ring_node_for_averaging_sm_f2,
72 ring_node_for_averaging_sm_f2,
63 nb_norm_bp1 );
73 nb_norm_bp1 );
64
74
65 // update nb_average
75 // update nb_average
66 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
76 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF2;
67 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
77 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF2;
68 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
78 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF2;
69
79
70 //****************************************
71 // initialize the mesage for the MATR task
72 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
73 msgForMATR.burst_sbm = NULL;
74 msgForMATR.norm = current_ring_node_asm_norm_f2;
75 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
76 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
77 msgForMATR.coarseTime = time_management_regs->coarse_time;
78 msgForMATR.fineTime = time_management_regs->fine_time;
79
80 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
80 if (nb_norm_bp1 == nb_sm_before_f2.norm_bp1)
81 {
81 {
82 nb_norm_bp1 = 0;
82 nb_norm_bp1 = 0;
83 // set another ring for the ASM storage
83 // set another ring for the ASM storage
84 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
84 current_ring_node_asm_norm_f2 = current_ring_node_asm_norm_f2->next;
85 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
85 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
86 || (lfrCurrentMode == LFR_MODE_SBM2) )
86 || (lfrCurrentMode == LFR_MODE_SBM2) )
87 {
87 {
88 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2;
88 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F2;
89 }
89 }
90 }
90 }
91
91
92 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
92 if (nb_norm_bp2 == nb_sm_before_f2.norm_bp2)
93 {
93 {
94 nb_norm_bp2 = 0;
94 nb_norm_bp2 = 0;
95 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
95 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
96 || (lfrCurrentMode == LFR_MODE_SBM2) )
96 || (lfrCurrentMode == LFR_MODE_SBM2) )
97 {
97 {
98 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
98 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F2;
99 }
99 }
100 }
100 }
101
101
102 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
102 if (nb_norm_asm == nb_sm_before_f2.norm_asm)
103 {
103 {
104 nb_norm_asm = 0;
104 nb_norm_asm = 0;
105 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
105 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1)
106 || (lfrCurrentMode == LFR_MODE_SBM2) )
106 || (lfrCurrentMode == LFR_MODE_SBM2) )
107 {
107 {
108 // PRINTF1("%lld\n", localTime)
108 // PRINTF1("%lld\n", localTime)
109 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
109 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F2;
110 }
110 }
111 }
111 }
112
112
113 //*************************
113 //*************************
114 // send the message to MATR
114 // send the message to MATR
115 if (msgForMATR.event != 0x00)
115 if (msgForMATR.event != 0x00)
116 {
116 {
117 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
117 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
118 }
118 }
119
119
120 if (status != RTEMS_SUCCESSFUL) {
120 if (status != RTEMS_SUCCESSFUL) {
121 printf("in AVF2 *** Error sending message to MATR, code %d\n", status);
121 printf("in AVF2 *** Error sending message to MATR, code %d\n", status);
122 }
122 }
123 }
123 }
124 }
124 }
125
125
126 rtems_task prc2_task( rtems_task_argument argument )
126 rtems_task prc2_task( rtems_task_argument argument )
127 {
127 {
128 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
128 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
129 size_t size; // size of the incoming TC packet
129 size_t size; // size of the incoming TC packet
130 asm_msg *incomingMsg;
130 asm_msg *incomingMsg;
131 //
131 //
132 spw_ioctl_pkt_send spw_ioctl_send_ASM;
132 spw_ioctl_pkt_send spw_ioctl_send_ASM;
133 rtems_status_code status;
133 rtems_status_code status;
134 rtems_id queue_id;
134 rtems_id queue_id;
135 rtems_id queue_id_q_p2;
135 rtems_id queue_id_q_p2;
136 Header_TM_LFR_SCIENCE_ASM_t headerASM;
136 Header_TM_LFR_SCIENCE_ASM_t headerASM;
137 bp_packet packet_norm_bp1_f2;
137 bp_packet packet_norm_bp1_f2;
138 bp_packet packet_norm_bp2_f2;
138 bp_packet packet_norm_bp2_f2;
139
139
140 unsigned long long int localTime;
140 unsigned long long int localTime;
141
141
142 ASM_init_header( &headerASM );
142 ASM_init_header( &headerASM );
143
143
144 //*************
144 //*************
145 // NORM headers
145 // NORM headers
146 BP_init_header( &packet_norm_bp1_f2.header,
146 BP_init_header( &packet_norm_bp1_f2.header,
147 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
147 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F2,
148 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
148 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2, NB_BINS_COMPRESSED_SM_F2 );
149 BP_init_header( &packet_norm_bp2_f2.header,
149 BP_init_header( &packet_norm_bp2_f2.header,
150 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
150 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F2,
151 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
151 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2, NB_BINS_COMPRESSED_SM_F2 );
152
152
153 status = get_message_queue_id_send( &queue_id );
153 status = get_message_queue_id_send( &queue_id );
154 if (status != RTEMS_SUCCESSFUL)
154 if (status != RTEMS_SUCCESSFUL)
155 {
155 {
156 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
156 PRINTF1("in PRC2 *** ERR get_message_queue_id_send %d\n", status)
157 }
157 }
158 status = get_message_queue_id_prc2( &queue_id_q_p2);
158 status = get_message_queue_id_prc2( &queue_id_q_p2);
159 if (status != RTEMS_SUCCESSFUL)
159 if (status != RTEMS_SUCCESSFUL)
160 {
160 {
161 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
161 PRINTF1("in PRC2 *** ERR get_message_queue_id_prc2 %d\n", status)
162 }
162 }
163
163
164 BOOT_PRINTF("in PRC2 ***\n")
164 BOOT_PRINTF("in PRC2 ***\n")
165
165
166 while(1){
166 while(1){
167 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
167 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
168 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
168 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
169
169
170 incomingMsg = (asm_msg*) incomingData;
170 incomingMsg = (asm_msg*) incomingData;
171
171
172 localTime = getTimeAsUnsignedLongLongInt( );
172 localTime = getTimeAsUnsignedLongLongInt( );
173
173
174 //*****
174 //*****
175 //*****
175 //*****
176 // NORM
176 // NORM
177 //*****
177 //*****
178 //*****
178 //*****
179 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
179 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
180 {
180 {
181 // 1) compress the matrix for Basic Parameters calculation
181 // 1) compress the matrix for Basic Parameters calculation
182 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
182 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
183 nb_sm_before_f2.norm_bp1,
183 nb_sm_before_f2.norm_bp1,
184 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
184 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
185 ASM_F2_INDICE_START );
185 ASM_F2_INDICE_START );
186 // 2) compute the BP1 set
186 // 2) compute the BP1 set
187
187
188 // 3) send the BP1 set
188 // 3) send the BP1 set
189 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
189 set_time( packet_norm_bp1_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
190 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
190 set_time( packet_norm_bp1_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
191 BP_send( (char *) &packet_norm_bp1_f2, queue_id,
191 BP_send( (char *) &packet_norm_bp1_f2, queue_id,
192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
193 SID_NORM_BP1_F2 );
193 SID_NORM_BP1_F2 );
194 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
194 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
195 {
195 {
196 // 1) compute the BP2 set using the same ASM as the one used for BP1
196 // 1) compute the BP2 set using the same ASM as the one used for BP1
197
197
198 // 2) send the BP2 set
198 // 2) send the BP2 set
199 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
199 set_time( packet_norm_bp2_f2.header.time, (unsigned char *) &incomingMsg->coarseTime );
200 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
200 set_time( packet_norm_bp2_f2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
201 BP_send( (char *) &packet_norm_bp2_f2, queue_id,
201 BP_send( (char *) &packet_norm_bp2_f2, queue_id,
202 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
202 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
203 SID_NORM_BP2_F2 );
203 SID_NORM_BP2_F2 );
204 }
204 }
205 }
205 }
206
206
207 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
207 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
208 {
208 {
209 // 1) reorganize the ASM and divide
209 // 1) reorganize the ASM and divide
210 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
210 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
211 asm_f2_reorganized,
211 asm_f2_reorganized,
212 nb_sm_before_f2.norm_bp1 );
212 nb_sm_before_f2.norm_bp1 );
213 // 2) convert the float array in a char array
213 // 2) convert the float array in a char array
214 ASM_convert( asm_f2_reorganized, asm_f2_char);
214 ASM_convert( asm_f2_reorganized, asm_f2_char);
215 // 3) send the spectral matrix packets
215 // 3) send the spectral matrix packets
216 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
216 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
217 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
217 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
218 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
218 ASM_send( &headerASM, asm_f2_char, SID_NORM_ASM_F2, &spw_ioctl_send_ASM, queue_id);
219 }
219 }
220
220
221 }
221 }
222 }
222 }
223
223
224 //**********
224 //**********
225 // FUNCTIONS
225 // FUNCTIONS
226
226
227 void reset_nb_sm_f2( void )
227 void reset_nb_sm_f2( void )
228 {
228 {
229 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
229 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
230 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
230 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
231 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];
231 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
232 }
232 }
233
233
234 void SM_average_f2( float *averaged_spec_mat_f2,
234 void SM_average_f2( float *averaged_spec_mat_f2,
235 ring_node_sm *ring_node,
235 ring_node_sm *ring_node,
236 unsigned int nbAverageNormF2 )
236 unsigned int nbAverageNormF2 )
237 {
237 {
238 float sum;
238 float sum;
239 unsigned int i;
239 unsigned int i;
240
240
241 for(i=0; i<TOTAL_SIZE_SM; i++)
241 for(i=0; i<TOTAL_SIZE_SM; i++)
242 {
242 {
243 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
243 sum = ( (int *) (ring_node->buffer_address) ) [ i ];
244 if ( (nbAverageNormF2 == 0) )
244 if ( (nbAverageNormF2 == 0) )
245 {
245 {
246 averaged_spec_mat_f2[ i ] = sum;
246 averaged_spec_mat_f2[ i ] = sum;
247 }
247 }
248 else
248 else
249 {
249 {
250 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
250 averaged_spec_mat_f2[ i ] = ( averaged_spec_mat_f2[ i ] + sum );
251 }
251 }
252 }
252 }
253 }
253 }
@@ -1,678 +1,689
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 void spectral_matrices_isr_f0( void )
33 void spectral_matrices_isr_f0( void )
34 {
34 {
35 unsigned char status;
35 unsigned char status;
36 unsigned long long int time_0;
36 unsigned long long int time_0;
37 unsigned long long int time_1;
37 unsigned long long int time_1;
38 unsigned long long int syncBit0;
39 unsigned long long int syncBit1;
38
40
39 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
40
42
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47
41 switch(status)
48 switch(status)
42 {
49 {
43 case 0:
50 case 0:
44 break;
51 break;
45 case 3:
52 case 3:
46 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_0_coarse_time );
47 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_1_coarse_time );
48 if ( time_0 < time_1 )
53 if ( time_0 < time_1 )
49 {
54 {
50 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
51 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
57 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
52 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
58 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
53 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
54 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
55 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
56 }
63 }
57 else
64 else
58 {
65 {
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
60 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
63 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
64 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
65 }
74 }
66 spectral_matrix_regs->status = 0x03; // [0011]
75 spectral_matrix_regs->status = 0x03; // [0011]
67 break;
76 break;
68 case 1:
77 case 1:
69 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
70 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
71 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
72 spectral_matrix_regs->status = 0x01; // [0001]
82 spectral_matrix_regs->status = 0x01; // [0001]
73 break;
83 break;
74 case 2:
84 case 2:
75 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
76 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
77 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
78 spectral_matrix_regs->status = 0x02; // [0010]
89 spectral_matrix_regs->status = 0x02; // [0010]
79 break;
90 break;
80 }
91 }
81 }
92 }
82
93
83 void spectral_matrices_isr_f1( void )
94 void spectral_matrices_isr_f1( void )
84 {
95 {
85 unsigned char status;
96 unsigned char status;
86 unsigned long long int time_0;
97 unsigned long long int time;
87 unsigned long long int time_1;
98 unsigned long long int syncBit;
88
99
89 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
100 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
90
101
91 switch(status)
102 switch(status)
92 {
103 {
93 case 0:
104 case 0:
94 break;
105 break;
95 case 3:
106 case 3:
96 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_0_coarse_time );
107 // UNEXPECTED VALUE
97 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_1_coarse_time );
108 spectral_matrix_regs->status = 0xc0; // [1100]
98 if ( time_0 < time_1 )
109 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
99 {
100 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
101 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
102 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
103 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
104 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
105 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
106 }
107 else
108 {
109 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
110 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
111 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
112 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
113 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
114 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
115 }
116 spectral_matrix_regs->status = 0x0c; // [1100]
117 break;
110 break;
118 case 1:
111 case 1:
119 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
112 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
113 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
114 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
115 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
120 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
116 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
121 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
117 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
122 spectral_matrix_regs->status = 0x04; // [0100]
118 spectral_matrix_regs->status = 0x04; // [0100]
123 break;
119 break;
124 case 2:
120 case 2:
125 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
121 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
122 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
123 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
124 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
126 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
125 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
127 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
126 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
128 spectral_matrix_regs->status = 0x08; // [1000]
127 spectral_matrix_regs->status = 0x08; // [1000]
129 break;
128 break;
130 }
129 }
131 }
130 }
132
131
133 void spectral_matrices_isr_f2( void )
132 void spectral_matrices_isr_f2( void )
134 {
133 {
135 unsigned char status;
134 unsigned char status;
136
135
137 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
136 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
138
137
139 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
138 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
140
139
141 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
140 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
142
141
143 switch(status)
142 switch(status)
144 {
143 {
145 case 0:
144 case 0:
146 break;
145 break;
147 case 3:
146 case 3:
148 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
147 // UNEXPECTED VALUE
149 spectral_matrix_regs->status = 0x30; // [0011 0000]
148 spectral_matrix_regs->status = 0x30; // [0011 0000]
150 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
151 {
152 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 }
154 break;
150 break;
155 case 1:
151 case 1:
152 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
153 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
156 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
154 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
157 spectral_matrix_regs->status = 0x10; // [0001 0000]
155 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
156 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 {
157 {
160 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
158 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 }
159 }
162 break;
160 break;
163 case 2:
161 case 2:
162 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
163 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
167 {
167 {
168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
169 }
169 }
170 break;
170 break;
171 }
171 }
172 }
172 }
173
173
174 void spectral_matrix_isr_error_handler( void )
174 void spectral_matrix_isr_error_handler( void )
175 {
175 {
176 spectral_matrix_regs->status = 0x7c0; // [0111 1100 0000]
176 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
177 {
178 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
179 }
177 }
180 }
178
181
179 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
182 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
180 {
183 {
181 // STATUS REGISTER
184 // STATUS REGISTER
182 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
185 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
183 // 10 9 8
186 // 10 9 8
184 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
187 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
185 // 7 6 5 4 3 2 1 0
188 // 7 6 5 4 3 2 1 0
186
189
187 spectral_matrices_isr_f0();
190 spectral_matrices_isr_f0();
188
191
189 spectral_matrices_isr_f1();
192 spectral_matrices_isr_f1();
190
193
191 spectral_matrices_isr_f2();
194 spectral_matrices_isr_f2();
192
195
193 // spectral_matrix_isr_error_handler();
196 // spectral_matrix_isr_error_handler();
194 }
197 }
195
198
196 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
199 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
197 {
200 {
198 //***
201 //***
199 // F0
202 // F0
200 nb_sm_f0 = nb_sm_f0 + 1;
203 nb_sm_f0 = nb_sm_f0 + 1;
201 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
204 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
202 {
205 {
203 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
206 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
204 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
207 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
205 {
208 {
206 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
209 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
207 }
210 }
208 nb_sm_f0 = 0;
211 nb_sm_f0 = 0;
209 }
212 }
210
213
211 //***
214 //***
212 // F1
215 // F1
213 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
216 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
214 if (nb_sm_f0_aux_f1 == 6)
217 if (nb_sm_f0_aux_f1 == 6)
215 {
218 {
216 nb_sm_f0_aux_f1 = 0;
219 nb_sm_f0_aux_f1 = 0;
217 nb_sm_f1 = nb_sm_f1 + 1;
220 nb_sm_f1 = nb_sm_f1 + 1;
218 }
221 }
219 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
222 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
220 {
223 {
221 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
224 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
222 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
225 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
223 {
226 {
224 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
227 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
225 }
228 }
226 nb_sm_f1 = 0;
229 nb_sm_f1 = 0;
227 }
230 }
228
231
229 //***
232 //***
230 // F2
233 // F2
231 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
234 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
232 if (nb_sm_f0_aux_f2 == 96)
235 if (nb_sm_f0_aux_f2 == 96)
233 {
236 {
234 nb_sm_f0_aux_f2 = 0;
237 nb_sm_f0_aux_f2 = 0;
235 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
238 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
236 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
239 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
237 {
240 {
238 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
241 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
239 }
242 }
240 }
243 }
241 }
244 }
242
245
243 //******************
246 //******************
244 // Spectral Matrices
247 // Spectral Matrices
245
248
246 void reset_nb_sm( void )
249 void reset_nb_sm( void )
247 {
250 {
248 nb_sm_f0 = 0;
251 nb_sm_f0 = 0;
249 nb_sm_f0_aux_f1 = 0;
252 nb_sm_f0_aux_f1 = 0;
250 nb_sm_f0_aux_f2 = 0;
253 nb_sm_f0_aux_f2 = 0;
251
254
252 nb_sm_f1 = 0;
255 nb_sm_f1 = 0;
253 }
256 }
254
257
255 void SM_init_rings( void )
258 void SM_init_rings( void )
256 {
259 {
257 unsigned char i;
260 unsigned char i;
258
261
259 // F0 RING
262 // F0 RING
260 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
263 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
261 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
264 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
262 sm_ring_f0[0].buffer_address =
265 sm_ring_f0[0].buffer_address =
263 (int) &sm_f0[ 0 ];
266 (int) &sm_f0[ 0 ];
264
267
265 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
268 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
266 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
269 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
267 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
270 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
268 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
271 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
269
272
270 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
273 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
271 {
274 {
272 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
275 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
273 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
276 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
274 sm_ring_f0[i].buffer_address =
277 sm_ring_f0[i].buffer_address =
275 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
278 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
276 }
279 }
277
280
278 // F1 RING
281 // F1 RING
279 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
282 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
280 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
283 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
281 sm_ring_f1[0].buffer_address =
284 sm_ring_f1[0].buffer_address =
282 (int) &sm_f1[ 0 ];
285 (int) &sm_f1[ 0 ];
283
286
284 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
287 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
285 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
288 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
286 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
289 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
287 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
290 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
288
291
289 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
292 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
290 {
293 {
291 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
294 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
292 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
295 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
293 sm_ring_f1[i].buffer_address =
296 sm_ring_f1[i].buffer_address =
294 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
297 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
295 }
298 }
296
299
297 // F2 RING
300 // F2 RING
298 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
301 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
299 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
302 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
300 sm_ring_f2[0].buffer_address =
303 sm_ring_f2[0].buffer_address =
301 (int) &sm_f2[ 0 ];
304 (int) &sm_f2[ 0 ];
302
305
303 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
306 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
304 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
307 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
305 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
308 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
306 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
309 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
307
310
308 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
311 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
309 {
312 {
310 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
313 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
311 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
314 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
312 sm_ring_f2[i].buffer_address =
315 sm_ring_f2[i].buffer_address =
313 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
316 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
314 }
317 }
315
318
316 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
319 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
317 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
320 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
318 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
321 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
319
322
320 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
323 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
321 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
324 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
322 }
325 }
323
326
324 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
327 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
325 {
328 {
326 unsigned char i;
329 unsigned char i;
327
330
328 //***************
331 //***************
329 // BUFFER ADDRESS
332 // BUFFER ADDRESS
330 for(i=0; i<nbNodes; i++)
333 for(i=0; i<nbNodes; i++)
331 {
334 {
332 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
335 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
333 }
336 }
334
337
335 //*****
338 //*****
336 // NEXT
339 // NEXT
337 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
340 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
338 for(i=0; i<nbNodes-1; i++)
341 for(i=0; i<nbNodes-1; i++)
339 {
342 {
340 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
343 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
341 }
344 }
342
345
343 //*********
346 //*********
344 // PREVIOUS
347 // PREVIOUS
345 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
348 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
346 for(i=1; i<nbNodes; i++)
349 for(i=1; i<nbNodes; i++)
347 {
350 {
348 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
351 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
349 }
352 }
350 }
353 }
351
354
352 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
355 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
353 {
356 {
354 unsigned char i;
357 unsigned char i;
355
358
356 ring[ nbNodes - 1 ].next
359 ring[ nbNodes - 1 ].next
357 = (ring_node_asm*) &ring[ 0 ];
360 = (ring_node_asm*) &ring[ 0 ];
358
361
359 for(i=0; i<nbNodes-1; i++)
362 for(i=0; i<nbNodes-1; i++)
360 {
363 {
361 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
364 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
362 }
365 }
363 }
366 }
364
367
365 void SM_reset_current_ring_nodes( void )
368 void SM_reset_current_ring_nodes( void )
366 {
369 {
367 current_ring_node_sm_f0 = sm_ring_f0[0].next;
370 current_ring_node_sm_f0 = sm_ring_f0[0].next;
368 current_ring_node_sm_f1 = sm_ring_f1[0].next;
371 current_ring_node_sm_f1 = sm_ring_f1[0].next;
369 current_ring_node_sm_f2 = sm_ring_f2[0].next;
372 current_ring_node_sm_f2 = sm_ring_f2[0].next;
370
373
371 ring_node_for_averaging_sm_f0 = sm_ring_f0;
374 ring_node_for_averaging_sm_f0 = sm_ring_f0;
372 ring_node_for_averaging_sm_f1 = sm_ring_f1;
375 ring_node_for_averaging_sm_f1 = sm_ring_f1;
373 ring_node_for_averaging_sm_f2 = sm_ring_f2;
376 ring_node_for_averaging_sm_f2 = sm_ring_f2;
374 }
377 }
375
378
376 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
379 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
377 {
380 {
378 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
381 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
379 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
382 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
380 header->reserved = 0x00;
383 header->reserved = 0x00;
381 header->userApplication = CCSDS_USER_APP;
384 header->userApplication = CCSDS_USER_APP;
382 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
385 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
383 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
386 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
384 header->packetSequenceControl[0] = 0xc0;
387 header->packetSequenceControl[0] = 0xc0;
385 header->packetSequenceControl[1] = 0x00;
388 header->packetSequenceControl[1] = 0x00;
386 header->packetLength[0] = 0x00;
389 header->packetLength[0] = 0x00;
387 header->packetLength[1] = 0x00;
390 header->packetLength[1] = 0x00;
388 // DATA FIELD HEADER
391 // DATA FIELD HEADER
389 header->spare1_pusVersion_spare2 = 0x10;
392 header->spare1_pusVersion_spare2 = 0x10;
390 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
393 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
391 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
394 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
392 header->destinationID = TM_DESTINATION_ID_GROUND;
395 header->destinationID = TM_DESTINATION_ID_GROUND;
393 // AUXILIARY DATA HEADER
396 // AUXILIARY DATA HEADER
394 header->sid = 0x00;
397 header->sid = 0x00;
395 header->biaStatusInfo = 0x00;
398 header->biaStatusInfo = 0x00;
396 header->pa_lfr_pkt_cnt_asm = 0x00;
399 header->pa_lfr_pkt_cnt_asm = 0x00;
397 header->pa_lfr_pkt_nr_asm = 0x00;
400 header->pa_lfr_pkt_nr_asm = 0x00;
398 header->time[0] = 0x00;
401 header->time[0] = 0x00;
399 header->time[0] = 0x00;
402 header->time[0] = 0x00;
400 header->time[0] = 0x00;
403 header->time[0] = 0x00;
401 header->time[0] = 0x00;
404 header->time[0] = 0x00;
402 header->time[0] = 0x00;
405 header->time[0] = 0x00;
403 header->time[0] = 0x00;
406 header->time[0] = 0x00;
404 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
407 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
405 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
408 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
406 }
409 }
407
410
408 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
411 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
409 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
412 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
410 {
413 {
411 unsigned int i;
414 unsigned int i;
412 unsigned int length = 0;
415 unsigned int length = 0;
413 rtems_status_code status;
416 rtems_status_code status;
414
417
415 for (i=0; i<2; i++)
418 for (i=0; i<2; i++)
416 {
419 {
417 // (1) BUILD THE DATA
420 // (1) BUILD THE DATA
418 switch(sid)
421 switch(sid)
419 {
422 {
420 case SID_NORM_ASM_F0:
423 case SID_NORM_ASM_F0:
421 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
424 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
422 spw_ioctl_send->data = &spectral_matrix[
425 spw_ioctl_send->data = &spectral_matrix[
423 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
426 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
424 ];
427 ];
425 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
428 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
426 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
429 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
427 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
430 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
428 break;
431 break;
429 case SID_NORM_ASM_F1:
432 case SID_NORM_ASM_F1:
430 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
433 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
431 spw_ioctl_send->data = &spectral_matrix[
434 spw_ioctl_send->data = &spectral_matrix[
432 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
435 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
433 ];
436 ];
434 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
437 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
435 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
438 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
436 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
439 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
437 break;
440 break;
438 case SID_NORM_ASM_F2:
441 case SID_NORM_ASM_F2:
439 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
442 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
440 spw_ioctl_send->data = &spectral_matrix[
443 spw_ioctl_send->data = &spectral_matrix[
441 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
444 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
442 ];
445 ];
443 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
446 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
444 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
447 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
445 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
448 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
446 break;
449 break;
447 default:
450 default:
448 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
451 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
449 break;
452 break;
450 }
453 }
451 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
454 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
452 spw_ioctl_send->hdr = (char *) header;
455 spw_ioctl_send->hdr = (char *) header;
453 spw_ioctl_send->options = 0;
456 spw_ioctl_send->options = 0;
454
457
455 // (2) BUILD THE HEADER
458 // (2) BUILD THE HEADER
456 increment_seq_counter_source_id( header->packetSequenceControl, sid );
459 increment_seq_counter_source_id( header->packetSequenceControl, sid );
457 header->packetLength[0] = (unsigned char) (length>>8);
460 header->packetLength[0] = (unsigned char) (length>>8);
458 header->packetLength[1] = (unsigned char) (length);
461 header->packetLength[1] = (unsigned char) (length);
459 header->sid = (unsigned char) sid; // SID
462 header->sid = (unsigned char) sid; // SID
460 header->pa_lfr_pkt_cnt_asm = 2;
463 header->pa_lfr_pkt_cnt_asm = 2;
461 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
464 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
462
465
463 // (3) SET PACKET TIME
466 // (3) SET PACKET TIME
464 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
467 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
465 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
468 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
466 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
469 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
467 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
470 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
468 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
471 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
469 header->time[5] = (unsigned char) (time_management_regs->fine_time);
472 header->time[5] = (unsigned char) (time_management_regs->fine_time);
470 //
473 //
471 header->acquisitionTime[0] = header->time[0];
474 header->acquisitionTime[0] = header->time[0];
472 header->acquisitionTime[1] = header->time[1];
475 header->acquisitionTime[1] = header->time[1];
473 header->acquisitionTime[2] = header->time[2];
476 header->acquisitionTime[2] = header->time[2];
474 header->acquisitionTime[3] = header->time[3];
477 header->acquisitionTime[3] = header->time[3];
475 header->acquisitionTime[4] = header->time[4];
478 header->acquisitionTime[4] = header->time[4];
476 header->acquisitionTime[5] = header->time[5];
479 header->acquisitionTime[5] = header->time[5];
477
480
478 // (4) SEND PACKET
481 // (4) SEND PACKET
479 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
482 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
480 if (status != RTEMS_SUCCESSFUL) {
483 if (status != RTEMS_SUCCESSFUL) {
481 printf("in ASM_send *** ERR %d\n", (int) status);
484 printf("in ASM_send *** ERR %d\n", (int) status);
482 }
485 }
483 }
486 }
484 }
487 }
485
488
486 //*****************
489 //*****************
487 // Basic Parameters
490 // Basic Parameters
488
491
489 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
492 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
490 unsigned int apid, unsigned char sid,
493 unsigned int apid, unsigned char sid,
491 unsigned int packetLength, unsigned char blkNr )
494 unsigned int packetLength, unsigned char blkNr )
492 {
495 {
493 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
496 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
494 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
497 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
495 header->reserved = 0x00;
498 header->reserved = 0x00;
496 header->userApplication = CCSDS_USER_APP;
499 header->userApplication = CCSDS_USER_APP;
497 header->packetID[0] = (unsigned char) (apid >> 8);
500 header->packetID[0] = (unsigned char) (apid >> 8);
498 header->packetID[1] = (unsigned char) (apid);
501 header->packetID[1] = (unsigned char) (apid);
499 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
502 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
500 header->packetSequenceControl[1] = 0x00;
503 header->packetSequenceControl[1] = 0x00;
501 header->packetLength[0] = (unsigned char) (packetLength >> 8);
504 header->packetLength[0] = (unsigned char) (packetLength >> 8);
502 header->packetLength[1] = (unsigned char) (packetLength);
505 header->packetLength[1] = (unsigned char) (packetLength);
503 // DATA FIELD HEADER
506 // DATA FIELD HEADER
504 header->spare1_pusVersion_spare2 = 0x10;
507 header->spare1_pusVersion_spare2 = 0x10;
505 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
508 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
506 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
509 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
507 header->destinationID = TM_DESTINATION_ID_GROUND;
510 header->destinationID = TM_DESTINATION_ID_GROUND;
508 // AUXILIARY DATA HEADER
511 // AUXILIARY DATA HEADER
509 header->sid = sid;
512 header->sid = sid;
510 header->biaStatusInfo = 0x00;
513 header->biaStatusInfo = 0x00;
511 header->time[0] = 0x00;
514 header->time[0] = 0x00;
512 header->time[0] = 0x00;
515 header->time[0] = 0x00;
513 header->time[0] = 0x00;
516 header->time[0] = 0x00;
514 header->time[0] = 0x00;
517 header->time[0] = 0x00;
515 header->time[0] = 0x00;
518 header->time[0] = 0x00;
516 header->time[0] = 0x00;
519 header->time[0] = 0x00;
517 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
520 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
518 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
521 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
519 }
522 }
520
523
521 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
524 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
522 unsigned int apid, unsigned char sid,
525 unsigned int apid, unsigned char sid,
523 unsigned int packetLength , unsigned char blkNr)
526 unsigned int packetLength , unsigned char blkNr)
524 {
527 {
525 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
528 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
526 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
529 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
527 header->reserved = 0x00;
530 header->reserved = 0x00;
528 header->userApplication = CCSDS_USER_APP;
531 header->userApplication = CCSDS_USER_APP;
529 header->packetID[0] = (unsigned char) (apid >> 8);
532 header->packetID[0] = (unsigned char) (apid >> 8);
530 header->packetID[1] = (unsigned char) (apid);
533 header->packetID[1] = (unsigned char) (apid);
531 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
534 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
532 header->packetSequenceControl[1] = 0x00;
535 header->packetSequenceControl[1] = 0x00;
533 header->packetLength[0] = (unsigned char) (packetLength >> 8);
536 header->packetLength[0] = (unsigned char) (packetLength >> 8);
534 header->packetLength[1] = (unsigned char) (packetLength);
537 header->packetLength[1] = (unsigned char) (packetLength);
535 // DATA FIELD HEADER
538 // DATA FIELD HEADER
536 header->spare1_pusVersion_spare2 = 0x10;
539 header->spare1_pusVersion_spare2 = 0x10;
537 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
540 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
538 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
541 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
539 header->destinationID = TM_DESTINATION_ID_GROUND;
542 header->destinationID = TM_DESTINATION_ID_GROUND;
540 // AUXILIARY DATA HEADER
543 // AUXILIARY DATA HEADER
541 header->sid = sid;
544 header->sid = sid;
542 header->biaStatusInfo = 0x00;
545 header->biaStatusInfo = 0x00;
543 header->time[0] = 0x00;
546 header->time[0] = 0x00;
544 header->time[0] = 0x00;
547 header->time[0] = 0x00;
545 header->time[0] = 0x00;
548 header->time[0] = 0x00;
546 header->time[0] = 0x00;
549 header->time[0] = 0x00;
547 header->time[0] = 0x00;
550 header->time[0] = 0x00;
548 header->time[0] = 0x00;
551 header->time[0] = 0x00;
549 header->source_data_spare = 0x00;
552 header->source_data_spare = 0x00;
550 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
553 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
551 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
554 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
552 }
555 }
553
556
554 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
557 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
555 {
558 {
556 rtems_status_code status;
559 rtems_status_code status;
557
560
558 // SET THE SEQUENCE_CNT PARAMETER
561 // SET THE SEQUENCE_CNT PARAMETER
559 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
562 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
560 // SEND PACKET
563 // SEND PACKET
561 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
564 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
562 if (status != RTEMS_SUCCESSFUL)
565 if (status != RTEMS_SUCCESSFUL)
563 {
566 {
564 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
567 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
565 }
568 }
566 }
569 }
567
570
568 //******************
571 //******************
569 // general functions
572 // general functions
570
573
571 void reset_spectral_matrix_regs( void )
574 void reset_spectral_matrix_regs( void )
572 {
575 {
573 /** This function resets the spectral matrices module registers.
576 /** This function resets the spectral matrices module registers.
574 *
577 *
575 * The registers affected by this function are located at the following offset addresses:
578 * The registers affected by this function are located at the following offset addresses:
576 *
579 *
577 * - 0x00 config
580 * - 0x00 config
578 * - 0x04 status
581 * - 0x04 status
579 * - 0x08 matrixF0_Address0
582 * - 0x08 matrixF0_Address0
580 * - 0x10 matrixFO_Address1
583 * - 0x10 matrixFO_Address1
581 * - 0x14 matrixF1_Address
584 * - 0x14 matrixF1_Address
582 * - 0x18 matrixF2_Address
585 * - 0x18 matrixF2_Address
583 *
586 *
584 */
587 */
585
588
586 spectral_matrix_regs->config = 0x00;
589 spectral_matrix_regs->config = 0x00;
587 spectral_matrix_regs->status = 0x00;
590 spectral_matrix_regs->status = 0x00;
588
591
589 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
592 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
590 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
593 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
591 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
594 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
592 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
595 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
593 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
596 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
594 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
597 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
595 }
598 }
596
599
597 void set_time( unsigned char *time, unsigned char * timeInBuffer )
600 void set_time( unsigned char *time, unsigned char * timeInBuffer )
598 {
601 {
599 // time[0] = timeInBuffer[2];
600 // time[1] = timeInBuffer[3];
601 // time[2] = timeInBuffer[0];
602 // time[3] = timeInBuffer[1];
603 // time[4] = timeInBuffer[6];
604 // time[5] = timeInBuffer[7];
605
606 time[0] = timeInBuffer[0];
602 time[0] = timeInBuffer[0];
607 time[1] = timeInBuffer[1];
603 time[1] = timeInBuffer[1];
608 time[2] = timeInBuffer[2];
604 time[2] = timeInBuffer[2];
609 time[3] = timeInBuffer[3];
605 time[3] = timeInBuffer[3];
610 time[4] = timeInBuffer[6];
606 time[4] = timeInBuffer[6];
611 time[5] = timeInBuffer[7];
607 time[5] = timeInBuffer[7];
612 }
608 }
613
609
614 unsigned long long int get_acquisition_time( unsigned char *timePtr )
610 unsigned long long int get_acquisition_time( unsigned char *timePtr )
615 {
611 {
616 unsigned long long int acquisitionTimeAslong;
612 unsigned long long int acquisitionTimeAslong;
617 acquisitionTimeAslong = 0x00;
613 acquisitionTimeAslong = 0x00;
618 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
614 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
619 + ( (unsigned long long int) timePtr[1] << 32 )
615 + ( (unsigned long long int) timePtr[1] << 32 )
620 + ( timePtr[2] << 24 )
616 + ( timePtr[2] << 24 )
621 + ( timePtr[3] << 16 )
617 + ( timePtr[3] << 16 )
622 + ( timePtr[4] << 8 )
618 + ( timePtr[6] << 8 )
623 + ( timePtr[5] );
619 + ( timePtr[7] );
624 return acquisitionTimeAslong;
620 return acquisitionTimeAslong;
625 }
621 }
626
622
627 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
623 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
628 ring_node_sm *node_for_averaging, ring_node_sm *ringNode )
624 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
625 unsigned long long int time )
629 {
626 {
627 unsigned char *timePtr;
628 unsigned char *coarseTimePtr;
629 unsigned char *fineTimePtr;
630
631 timePtr = (unsigned char *) &time;
632 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
633 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
634
630 *nb_sm = *nb_sm + 1;
635 *nb_sm = *nb_sm + 1;
631 if (*nb_sm == nb_sm_before_avf)
636 if (*nb_sm == nb_sm_before_avf)
632 {
637 {
633 node_for_averaging = ringNode;
638 node_for_averaging = ringNode;
639 coarseTimePtr[0] = timePtr[2];
640 coarseTimePtr[1] = timePtr[3];
641 coarseTimePtr[2] = timePtr[4];
642 coarseTimePtr[3] = timePtr[5];
643 fineTimePtr[2] = timePtr[6];
644 fineTimePtr[3] = timePtr[7];
634 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
645 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
635 {
646 {
636 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
647 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
637 }
648 }
638 *nb_sm = 0;
649 *nb_sm = 0;
639 }
650 }
640 }
651 }
641
652
642 unsigned char getSID( rtems_event_set event )
653 unsigned char getSID( rtems_event_set event )
643 {
654 {
644 unsigned char sid;
655 unsigned char sid;
645
656
646 rtems_event_set eventSetBURST;
657 rtems_event_set eventSetBURST;
647 rtems_event_set eventSetSBM;
658 rtems_event_set eventSetSBM;
648
659
649 //******
660 //******
650 // BURST
661 // BURST
651 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
662 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
652 | RTEMS_EVENT_BURST_BP1_F1
663 | RTEMS_EVENT_BURST_BP1_F1
653 | RTEMS_EVENT_BURST_BP2_F0
664 | RTEMS_EVENT_BURST_BP2_F0
654 | RTEMS_EVENT_BURST_BP2_F1;
665 | RTEMS_EVENT_BURST_BP2_F1;
655
666
656 //****
667 //****
657 // SBM
668 // SBM
658 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
669 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
659 | RTEMS_EVENT_SBM_BP1_F1
670 | RTEMS_EVENT_SBM_BP1_F1
660 | RTEMS_EVENT_SBM_BP2_F0
671 | RTEMS_EVENT_SBM_BP2_F0
661 | RTEMS_EVENT_SBM_BP2_F1;
672 | RTEMS_EVENT_SBM_BP2_F1;
662
673
663 if (event & eventSetBURST)
674 if (event & eventSetBURST)
664 {
675 {
665 sid = SID_BURST_BP1_F0;
676 sid = SID_BURST_BP1_F0;
666 }
677 }
667 else if (event & eventSetSBM)
678 else if (event & eventSetSBM)
668 {
679 {
669 sid = SID_SBM1_BP1_F0;
680 sid = SID_SBM1_BP1_F0;
670 }
681 }
671 else
682 else
672 {
683 {
673 sid = 0;
684 sid = 0;
674 }
685 }
675
686
676 return sid;
687 return sid;
677 }
688 }
678
689
@@ -1,949 +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) )
647 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
648 {
648 {
649 ret = RTEMS_UNSATISFIED;
649 ret = RTEMS_UNSATISFIED;
650 }
650 }
651
651
652 return ret;
652 return ret;
653 }
653 }
654
654
655 int suspend_science_tasks()
655 int suspend_science_tasks()
656 {
656 {
657 /** This function suspends the science tasks.
657 /** This function suspends the science tasks.
658 *
658 *
659 * @return RTEMS directive status codes:
659 * @return RTEMS directive status codes:
660 * - RTEMS_SUCCESSFUL - task restarted successfully
660 * - RTEMS_SUCCESSFUL - task restarted successfully
661 * - RTEMS_INVALID_ID - task id invalid
661 * - RTEMS_INVALID_ID - task id invalid
662 * - RTEMS_ALREADY_SUSPENDED - task already suspended
662 * - RTEMS_ALREADY_SUSPENDED - task already suspended
663 *
663 *
664 */
664 */
665
665
666 rtems_status_code status;
666 rtems_status_code status;
667
667
668 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
668 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
669 if (status != RTEMS_SUCCESSFUL)
669 if (status != RTEMS_SUCCESSFUL)
670 {
670 {
671 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
671 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
672 }
672 }
673 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
673 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
674 {
674 {
675 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
675 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
676 if (status != RTEMS_SUCCESSFUL)
676 if (status != RTEMS_SUCCESSFUL)
677 {
677 {
678 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
678 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
679 }
679 }
680 }
680 }
681 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
681 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
682 {
682 {
683 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
683 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
684 if (status != RTEMS_SUCCESSFUL)
684 if (status != RTEMS_SUCCESSFUL)
685 {
685 {
686 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
686 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
687 }
687 }
688 }
688 }
689 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
689 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
690 {
690 {
691 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
691 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
692 if (status != RTEMS_SUCCESSFUL)
692 if (status != RTEMS_SUCCESSFUL)
693 {
693 {
694 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
694 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
695 }
695 }
696 }
696 }
697 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
697 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
698 {
698 {
699 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
699 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
700 if (status != RTEMS_SUCCESSFUL)
700 if (status != RTEMS_SUCCESSFUL)
701 {
701 {
702 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
702 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
703 }
703 }
704 }
704 }
705 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
705 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
706 {
706 {
707 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
707 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
708 if (status != RTEMS_SUCCESSFUL)
708 if (status != RTEMS_SUCCESSFUL)
709 {
709 {
710 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
710 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
711 }
711 }
712 }
712 }
713 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
713 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
714 {
714 {
715 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
715 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
716 if (status != RTEMS_SUCCESSFUL)
716 if (status != RTEMS_SUCCESSFUL)
717 {
717 {
718 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
718 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
719 }
719 }
720 }
720 }
721 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
721 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
722 {
722 {
723 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
723 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
724 if (status != RTEMS_SUCCESSFUL)
724 if (status != RTEMS_SUCCESSFUL)
725 {
725 {
726 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
726 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
727 }
727 }
728 }
728 }
729 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
729 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
730 {
730 {
731 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
731 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
732 if (status != RTEMS_SUCCESSFUL)
732 if (status != RTEMS_SUCCESSFUL)
733 {
733 {
734 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
734 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
735 }
735 }
736 }
736 }
737 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
737 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
738 {
738 {
739 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
739 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
740 if (status != RTEMS_SUCCESSFUL)
740 if (status != RTEMS_SUCCESSFUL)
741 {
741 {
742 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
742 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
743 }
743 }
744 }
744 }
745
745
746 return status;
746 return status;
747 }
747 }
748
748
749 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
749 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
750 {
750 {
751 WFP_reset_current_ring_nodes();
751 WFP_reset_current_ring_nodes();
752 reset_waveform_picker_regs();
752 reset_waveform_picker_regs();
753 set_wfp_burst_enable_register( mode );
753 set_wfp_burst_enable_register( mode );
754
754
755 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
755 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
756 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
756 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
757
757
758 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
758 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
759 if (transitionCoarseTime == 0)
759 if (transitionCoarseTime == 0)
760 {
760 {
761 waveform_picker_regs->start_date = time_management_regs->coarse_time;
761 waveform_picker_regs->start_date = time_management_regs->coarse_time;
762 }
762 }
763 else
763 else
764 {
764 {
765 waveform_picker_regs->start_date = transitionCoarseTime;
765 waveform_picker_regs->start_date = transitionCoarseTime;
766 }
766 }
767 }
767 }
768
768
769 void launch_spectral_matrix( void )
769 void launch_spectral_matrix( void )
770 {
770 {
771 SM_reset_current_ring_nodes();
771 SM_reset_current_ring_nodes();
772 reset_spectral_matrix_regs();
772 reset_spectral_matrix_regs();
773 reset_nb_sm();
773 reset_nb_sm();
774
774
775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
775 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
776 grgpio_regs->io_port_direction_register =
776 grgpio_regs->io_port_direction_register =
777 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
777 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
778 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 );
779 set_irq_on_new_ready_matrix( 1 );
780 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
780 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
781 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
781 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
782 set_run_matrix_spectral( 1 );
782 set_run_matrix_spectral( 1 );
783
783
784 }
784 }
785
785
786 void launch_spectral_matrix_simu( void )
786 void launch_spectral_matrix_simu( void )
787 {
787 {
788 SM_reset_current_ring_nodes();
788 SM_reset_current_ring_nodes();
789 reset_spectral_matrix_regs();
789 reset_spectral_matrix_regs();
790 reset_nb_sm();
790 reset_nb_sm();
791
791
792 // Spectral Matrices simulator
792 // Spectral Matrices simulator
793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
793 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
794 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
794 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
795 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
796 }
796 }
797
797
798 void set_irq_on_new_ready_matrix( unsigned char value )
798 void set_irq_on_new_ready_matrix( unsigned char value )
799 {
799 {
800 if (value == 1)
800 if (value == 1)
801 {
801 {
802 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
802 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
803 }
803 }
804 else
804 else
805 {
805 {
806 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
806 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
807 }
807 }
808 }
808 }
809
809
810 void set_run_matrix_spectral( unsigned char value )
810 void set_run_matrix_spectral( unsigned char value )
811 {
811 {
812 if (value == 1)
812 if (value == 1)
813 {
813 {
814 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
815 }
815 }
816 else
816 else
817 {
817 {
818 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
819 }
819 }
820 }
820 }
821
821
822 //****************
822 //****************
823 // CLOSING ACTIONS
823 // CLOSING ACTIONS
824 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
824 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
825 {
825 {
826 /** 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.
827 *
827 *
828 * @param TC points to the TC being processed
828 * @param TC points to the TC being processed
829 * @param time is the time used to date the TC execution
829 * @param time is the time used to date the TC execution
830 *
830 *
831 */
831 */
832
832
833 unsigned int val;
833 unsigned int val;
834
834
835 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];
836 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];
837 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
837 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
838 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
838 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
839 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
839 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
840 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
841 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
841 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
842 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
842 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
843 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
843 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
844 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
844 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
845 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
845 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
846 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
846 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
847
847
848 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];
849 val++;
849 val++;
850 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);
851 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
851 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
852 }
852 }
853
853
854 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
854 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
855 {
855 {
856 /** 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.
857 *
857 *
858 * @param TC points to the TC being processed
858 * @param TC points to the TC being processed
859 * @param time is the time used to date the TC rejection
859 * @param time is the time used to date the TC rejection
860 *
860 *
861 */
861 */
862
862
863 unsigned int val;
863 unsigned int val;
864
864
865 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];
866 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];
867 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
867 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
868 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
868 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
869 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
869 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
870 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
871 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
871 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
872 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
872 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
873 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
873 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
874 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
874 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
875 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
875 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
876 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
876 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
877
877
878 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];
879 val++;
879 val++;
880 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);
881 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
881 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
882 }
882 }
883
883
884 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 )
885 {
885 {
886 /** This function is the last step of the TC execution workflow.
886 /** This function is the last step of the TC execution workflow.
887 *
887 *
888 * @param TC points to the TC being processed
888 * @param TC points to the TC being processed
889 * @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)
890 * @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
891 * @param time is the time used to date the TC execution
891 * @param time is the time used to date the TC execution
892 *
892 *
893 */
893 */
894
894
895 unsigned char requestedMode;
895 unsigned char requestedMode;
896
896
897 if (result == LFR_SUCCESSFUL)
897 if (result == LFR_SUCCESSFUL)
898 {
898 {
899 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) )
900 &
900 &
901 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
901 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
902 )
902 )
903 {
903 {
904 send_tm_lfr_tc_exe_success( TC, queue_id );
904 send_tm_lfr_tc_exe_success( TC, queue_id );
905 }
905 }
906 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
906 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
907 {
907 {
908 //**********************************
908 //**********************************
909 // UPDATE THE LFRMODE LOCAL VARIABLE
909 // UPDATE THE LFRMODE LOCAL VARIABLE
910 requestedMode = TC->dataAndCRC[1];
910 requestedMode = TC->dataAndCRC[1];
911 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
911 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
912 updateLFRCurrentMode();
912 updateLFRCurrentMode();
913 }
913 }
914 }
914 }
915 else if (result == LFR_EXE_ERROR)
915 else if (result == LFR_EXE_ERROR)
916 {
916 {
917 send_tm_lfr_tc_exe_error( TC, queue_id );
917 send_tm_lfr_tc_exe_error( TC, queue_id );
918 }
918 }
919 }
919 }
920
920
921 //***************************
921 //***************************
922 // Interrupt Service Routines
922 // Interrupt Service Routines
923 rtems_isr commutation_isr1( rtems_vector_number vector )
923 rtems_isr commutation_isr1( rtems_vector_number vector )
924 {
924 {
925 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) {
926 printf("In commutation_isr1 *** Error sending event to DUMB\n");
926 printf("In commutation_isr1 *** Error sending event to DUMB\n");
927 }
927 }
928 }
928 }
929
929
930 rtems_isr commutation_isr2( rtems_vector_number vector )
930 rtems_isr commutation_isr2( rtems_vector_number vector )
931 {
931 {
932 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) {
933 printf("In commutation_isr2 *** Error sending event to DUMB\n");
933 printf("In commutation_isr2 *** Error sending event to DUMB\n");
934 }
934 }
935 }
935 }
936
936
937 //****************
937 //****************
938 // OTHER FUNCTIONS
938 // OTHER FUNCTIONS
939 void updateLFRCurrentMode()
939 void updateLFRCurrentMode()
940 {
940 {
941 /** This function updates the value of the global variable lfrCurrentMode.
941 /** This function updates the value of the global variable lfrCurrentMode.
942 *
942 *
943 * 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.
944 *
944 *
945 */
945 */
946 // 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
947 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
947 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
948 }
948 }
949
949
General Comments 0
You need to be logged in to leave comments. Login now