##// END OF EJS Templates
Bug 117
paul -
r149:60ce8c978d3f 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: Fri Jun 13 07:44:08 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 09:16:01 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=9 -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,95 +1,95
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose
4 CONFIG += console verbose
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
8
8
9 # flight software version
9 # flight software version
10 SWVERSION=-1-0
10 SWVERSION=-1-0
11 DEFINES += SW_VERSION_N1=1 # major
11 DEFINES += SW_VERSION_N1=1 # major
12 DEFINES += SW_VERSION_N2=0 # minor
12 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N3=0 # patch
13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=9 # internal
14 DEFINES += SW_VERSION_N4=10 # internal
15
15
16 contains( CONFIG, debug_tch ) {
16 contains( CONFIG, debug_tch ) {
17 DEFINES += DEBUG_TCH
17 DEFINES += DEBUG_TCH
18 }
18 }
19
19
20 contains( CONFIG, vhdl_dev ) {
20 contains( CONFIG, vhdl_dev ) {
21 DEFINES += VHDL_DEV
21 DEFINES += VHDL_DEV
22 }
22 }
23
23
24 contains( CONFIG, verbose ) {
24 contains( CONFIG, verbose ) {
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 }
26 }
27
27
28 contains( CONFIG, debug_messages ) {
28 contains( CONFIG, debug_messages ) {
29 DEFINES += DEBUG_MESSAGES
29 DEFINES += DEBUG_MESSAGES
30 }
30 }
31
31
32 contains( CONFIG, cpu_usage_report ) {
32 contains( CONFIG, cpu_usage_report ) {
33 DEFINES += PRINT_TASK_STATISTICS
33 DEFINES += PRINT_TASK_STATISTICS
34 }
34 }
35
35
36 contains( CONFIG, stack_report ) {
36 contains( CONFIG, stack_report ) {
37 DEFINES += PRINT_STACK_REPORT
37 DEFINES += PRINT_STACK_REPORT
38 }
38 }
39
39
40 contains( CONFIG, boot_messages ) {
40 contains( CONFIG, boot_messages ) {
41 DEFINES += BOOT_MESSAGES
41 DEFINES += BOOT_MESSAGES
42 }
42 }
43
43
44 #doxygen.target = doxygen
44 #doxygen.target = doxygen
45 #doxygen.commands = doxygen ../doc/Doxyfile
45 #doxygen.commands = doxygen ../doc/Doxyfile
46 #QMAKE_EXTRA_TARGETS += doxygen
46 #QMAKE_EXTRA_TARGETS += doxygen
47
47
48 TARGET = fsw
48 TARGET = fsw
49
49
50 INCLUDEPATH += \
50 INCLUDEPATH += \
51 ../src \
51 ../src \
52 ../header \
52 ../header \
53 ../header/processing \
53 ../header/processing \
54 ../src/LFR_basic-parameters
54 ../src/LFR_basic-parameters
55
55
56 SOURCES += \
56 SOURCES += \
57 ../src/wf_handler.c \
57 ../src/wf_handler.c \
58 ../src/tc_handler.c \
58 ../src/tc_handler.c \
59 ../src/fsw_misc.c \
59 ../src/fsw_misc.c \
60 ../src/fsw_init.c \
60 ../src/fsw_init.c \
61 ../src/fsw_globals.c \
61 ../src/fsw_globals.c \
62 ../src/fsw_spacewire.c \
62 ../src/fsw_spacewire.c \
63 ../src/tc_load_dump_parameters.c \
63 ../src/tc_load_dump_parameters.c \
64 ../src/tm_lfr_tc_exe.c \
64 ../src/tm_lfr_tc_exe.c \
65 ../src/tc_acceptance.c \
65 ../src/tc_acceptance.c \
66 ../src/processing/fsw_processing.c \
66 ../src/processing/fsw_processing.c \
67 ../src/processing/avf0_prc0.c \
67 ../src/processing/avf0_prc0.c \
68 ../src/processing/avf1_prc1.c \
68 ../src/processing/avf1_prc1.c \
69 ../src/processing/avf2_prc2.c \
69 ../src/processing/avf2_prc2.c \
70 ../src/lfr_cpu_usage_report.c \
70 ../src/lfr_cpu_usage_report.c \
71 ../src/LFR_basic-parameters/basic_parameters.c
71 ../src/LFR_basic-parameters/basic_parameters.c
72
72
73 HEADERS += \
73 HEADERS += \
74 ../header/wf_handler.h \
74 ../header/wf_handler.h \
75 ../header/tc_handler.h \
75 ../header/tc_handler.h \
76 ../header/grlib_regs.h \
76 ../header/grlib_regs.h \
77 ../header/fsw_params.h \
77 ../header/fsw_params.h \
78 ../header/fsw_misc.h \
78 ../header/fsw_misc.h \
79 ../header/fsw_init.h \
79 ../header/fsw_init.h \
80 ../header/ccsds_types.h \
80 ../header/ccsds_types.h \
81 ../header/fsw_spacewire.h \
81 ../header/fsw_spacewire.h \
82 ../header/tc_load_dump_parameters.h \
82 ../header/tc_load_dump_parameters.h \
83 ../header/tm_lfr_tc_exe.h \
83 ../header/tm_lfr_tc_exe.h \
84 ../header/tc_acceptance.h \
84 ../header/tc_acceptance.h \
85 ../header/fsw_params_nb_bytes.h \
85 ../header/fsw_params_nb_bytes.h \
86 ../header/fsw_params_processing.h \
86 ../header/fsw_params_processing.h \
87 ../header/processing/fsw_processing.h \
87 ../header/processing/fsw_processing.h \
88 ../header/processing/avf0_prc0.h \
88 ../header/processing/avf0_prc0.h \
89 ../header/processing/avf1_prc1.h \
89 ../header/processing/avf1_prc1.h \
90 ../header/processing/avf2_prc2.h \
90 ../header/processing/avf2_prc2.h \
91 ../header/fsw_params_wf_handler.h \
91 ../header/fsw_params_wf_handler.h \
92 ../header/lfr_cpu_usage_report.h \
92 ../header/lfr_cpu_usage_report.h \
93 ../src/LFR_basic-parameters/basic_parameters.h \
93 ../src/LFR_basic-parameters/basic_parameters.h \
94 ../src/LFR_basic-parameters/basic_parameters_params.h
94 ../src/LFR_basic-parameters/basic_parameters_params.h
95
95
@@ -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-13T09:37:55. -->
3 <!-- Written by QtCreator 3.0.1, 2014-06-16T07:35:26. -->
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,48 +1,49
1 #ifndef FSW_MISC_H_INCLUDED
1 #ifndef FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6 #include <grspw.h>
6 #include <grspw.h>
7
7
8 #include "fsw_params.h"
8 #include "fsw_params.h"
9 #include "fsw_spacewire.h"
9 #include "fsw_spacewire.h"
10 #include "lfr_cpu_usage_report.h"
10 #include "lfr_cpu_usage_report.h"
11
11
12 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
12 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
13 rtems_id HK_id; // id of the HK rate monotonic period
13 rtems_id HK_id; // id of the HK rate monotonic period
14
14
15 //extern rtems_name misc_name[5];
15 //extern rtems_name misc_name[5];
16 //time_management_regs_t *time_management_regs;
16 //time_management_regs_t *time_management_regs;
17 //extern Packet_TM_LFR_HK_t housekeeping_packet;
17 //extern Packet_TM_LFR_HK_t housekeeping_packet;
18
18
19 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
19 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
20 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
20 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
21 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
23 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
23 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
24
24
25 // SERIAL LINK
25 // SERIAL LINK
26 int send_console_outputs_on_apbuart_port( void );
26 int send_console_outputs_on_apbuart_port( void );
27 int enable_apbuart_transmitter( void );
27 int enable_apbuart_transmitter( void );
28 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
28 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
29
29
30 // RTEMS TASKS
30 // RTEMS TASKS
31 rtems_task stat_task( rtems_task_argument argument );
31 rtems_task stat_task( rtems_task_argument argument );
32 rtems_task hous_task( rtems_task_argument argument );
32 rtems_task hous_task( rtems_task_argument argument );
33 rtems_task dumb_task( rtems_task_argument unused );
33 rtems_task dumb_task( rtems_task_argument unused );
34
34
35 void init_housekeeping_parameters( void );
35 void init_housekeeping_parameters( void );
36 void increment_seq_counter( unsigned char *packet_sequence_control);
36 void increment_seq_counter(unsigned short *packetSequenceControl);
37 void getTime( unsigned char *time);
37 void getTime( unsigned char *time);
38 unsigned long long int getTimeAsUnsignedLongLongInt( );
38 unsigned long long int getTimeAsUnsignedLongLongInt( );
39 void send_dumb_hk( void );
39 void send_dumb_hk( void );
40 void get_v_e1_e2_f3 (unsigned char *spacecraft_potential);
40 void get_v_e1_e2_f3 (unsigned char *spacecraft_potential);
41 void get_cpu_load( unsigned char *resource_statistics );
41 void get_cpu_load( unsigned char *resource_statistics );
42
42
43 extern int sched_yield( void );
43 extern int sched_yield( void );
44 extern int rtems_cpu_usage_reset();
44 extern int rtems_cpu_usage_reset();
45 extern ring_node *current_ring_node_f3;
45 extern ring_node *current_ring_node_f3;
46 extern ring_node *ring_node_to_send_cwf_f3;
46 extern ring_node *ring_node_to_send_cwf_f3;
47 extern unsigned short sequenceCounterHK;
47
48
48 #endif // FSW_MISC_H_INCLUDED
49 #endif // FSW_MISC_H_INCLUDED
@@ -1,251 +1,255
1 #ifndef FSW_PARAMS_H_INCLUDED
1 #ifndef FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
3
3
4 #include "grlib_regs.h"
4 #include "grlib_regs.h"
5 #include "fsw_params_processing.h"
5 #include "fsw_params_processing.h"
6 #include "fsw_params_nb_bytes.h"
6 #include "fsw_params_nb_bytes.h"
7 #include "tm_byte_positions.h"
7 #include "tm_byte_positions.h"
8 #include "ccsds_types.h"
8 #include "ccsds_types.h"
9
9
10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 #define UART_DEVICE_NAME "/dev/console"
11 #define UART_DEVICE_NAME "/dev/console"
12
12
13 typedef struct ring_node
13 typedef struct ring_node
14 {
14 {
15 struct ring_node *previous;
15 struct ring_node *previous;
16 int buffer_address;
16 int buffer_address;
17 struct ring_node *next;
17 struct ring_node *next;
18 unsigned int status;
18 unsigned int status;
19 } ring_node;
19 } ring_node;
20
20
21 //************************
21 //************************
22 // flight software version
22 // flight software version
23 // this parameters is handled by the Qt project options
23 // this parameters is handled by the Qt project options
24
24
25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 #define TIME_OFFSET 2
28 #define TIME_OFFSET 2
29 #define TIME_OFFSET_IN_BYTES 8
29 #define TIME_OFFSET_IN_BYTES 8
30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 #define NB_BYTES_SWF_BLK (2 * 6)
31 #define NB_BYTES_SWF_BLK (2 * 6)
32 #define NB_WORDS_SWF_BLK 3
32 #define NB_WORDS_SWF_BLK 3
33 #define NB_BYTES_CWF3_LIGHT_BLK 6
33 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 #define NB_RING_NODES_F0 3 // AT LEAST 3
35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 #define NB_RING_NODES_F1 5 // AT LEAST 3
36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 #define NB_RING_NODES_F2 5 // AT LEAST 3
37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 #define NB_RING_NODES_F3 3 // AT LEAST 3
38 #define NB_RING_NODES_F3 3 // AT LEAST 3
39
39
40 //**********
40 //**********
41 // LFR MODES
41 // LFR MODES
42 #define LFR_MODE_STANDBY 0
42 #define LFR_MODE_STANDBY 0
43 #define LFR_MODE_NORMAL 1
43 #define LFR_MODE_NORMAL 1
44 #define LFR_MODE_BURST 2
44 #define LFR_MODE_BURST 2
45 #define LFR_MODE_SBM1 3
45 #define LFR_MODE_SBM1 3
46 #define LFR_MODE_SBM2 4
46 #define LFR_MODE_SBM2 4
47
47
48 #define TDS_MODE_LFM 5
48 #define TDS_MODE_LFM 5
49 #define TDS_MODE_STANDBY 0
49 #define TDS_MODE_STANDBY 0
50 #define TDS_MODE_NORMAL 1
50 #define TDS_MODE_NORMAL 1
51 #define TDS_MODE_BURST 2
51 #define TDS_MODE_BURST 2
52 #define TDS_MODE_SBM1 3
52 #define TDS_MODE_SBM1 3
53 #define TDS_MODE_SBM2 4
53 #define TDS_MODE_SBM2 4
54
54
55 #define THR_MODE_STANDBY 0
55 #define THR_MODE_STANDBY 0
56 #define THR_MODE_NORMAL 1
56 #define THR_MODE_NORMAL 1
57 #define THR_MODE_BURST 2
57 #define THR_MODE_BURST 2
58
58
59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
74 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
74 #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15
75 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
75 #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16
76 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
76 #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17
77 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
77 #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18
78 #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19
79 #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20
80 #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21
81 #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22
78
82
79 //****************************
83 //****************************
80 // LFR DEFAULT MODE PARAMETERS
84 // LFR DEFAULT MODE PARAMETERS
81 // COMMON
85 // COMMON
82 #define DEFAULT_SY_LFR_COMMON0 0x00
86 #define DEFAULT_SY_LFR_COMMON0 0x00
83 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
87 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
84 // NORM
88 // NORM
85 #define SY_LFR_N_SWF_L 2048 // nb sample
89 #define SY_LFR_N_SWF_L 2048 // nb sample
86 #define SY_LFR_N_SWF_P 300 // sec
90 #define SY_LFR_N_SWF_P 300 // sec
87 #define SY_LFR_N_ASM_P 3600 // sec
91 #define SY_LFR_N_ASM_P 3600 // sec
88 #define SY_LFR_N_BP_P0 4 // sec
92 #define SY_LFR_N_BP_P0 4 // sec
89 #define SY_LFR_N_BP_P1 20 // sec
93 #define SY_LFR_N_BP_P1 20 // sec
90 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
94 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
91 #define MIN_DELTA_SNAPSHOT 16 // sec
95 #define MIN_DELTA_SNAPSHOT 16 // sec
92 // BURST
96 // BURST
93 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
97 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
94 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
98 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
95 // SBM1
99 // SBM1
96 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
100 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
97 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
101 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
98 // SBM2
102 // SBM2
99 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
103 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
100 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
104 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
101 // ADDITIONAL PARAMETERS
105 // ADDITIONAL PARAMETERS
102 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
106 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
103 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
107 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
104 // STATUS WORD
108 // STATUS WORD
105 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
109 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
106 #define DEFAULT_STATUS_WORD_BYTE1 0x00
110 #define DEFAULT_STATUS_WORD_BYTE1 0x00
107 //
111 //
108 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
112 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
109 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
113 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
110 //****************************
114 //****************************
111
115
112 //*****************************
116 //*****************************
113 // APB REGISTERS BASE ADDRESSES
117 // APB REGISTERS BASE ADDRESSES
114 #define REGS_ADDR_APBUART 0x80000100
118 #define REGS_ADDR_APBUART 0x80000100
115 #define REGS_ADDR_GPTIMER 0x80000300
119 #define REGS_ADDR_GPTIMER 0x80000300
116 #define REGS_ADDR_GRSPW 0x80000500
120 #define REGS_ADDR_GRSPW 0x80000500
117 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
121 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
118 #define REGS_ADDR_GRGPIO 0x80000b00
122 #define REGS_ADDR_GRGPIO 0x80000b00
119
123
120 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
124 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
121 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
125 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
122 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
126 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
123
127
124 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
128 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
125 #define APBUART_CTRL_REG_MASK_TE 0x00000002
129 #define APBUART_CTRL_REG_MASK_TE 0x00000002
126 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
130 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
127
131
128 //**********
132 //**********
129 // IRQ LINES
133 // IRQ LINES
130 #define IRQ_SM_SIMULATOR 9
134 #define IRQ_SM_SIMULATOR 9
131 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
135 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
132 #define IRQ_WAVEFORM_PICKER 14
136 #define IRQ_WAVEFORM_PICKER 14
133 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
137 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
134 #define IRQ_SPECTRAL_MATRIX 6
138 #define IRQ_SPECTRAL_MATRIX 6
135 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
139 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
136
140
137 //*****
141 //*****
138 // TIME
142 // TIME
139 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
143 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
140 #define TIMER_SM_SIMULATOR 1
144 #define TIMER_SM_SIMULATOR 1
141 #define HK_PERIOD 100 // 100 * 10ms => 1s
145 #define HK_PERIOD 100 // 100 * 10ms => 1s
142 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
146 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
143 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
147 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
144
148
145 //**********
149 //**********
146 // LPP CODES
150 // LPP CODES
147 #define LFR_SUCCESSFUL 0
151 #define LFR_SUCCESSFUL 0
148 #define LFR_DEFAULT 1
152 #define LFR_DEFAULT 1
149 #define LFR_EXE_ERROR 2
153 #define LFR_EXE_ERROR 2
150
154
151 //******
155 //******
152 // RTEMS
156 // RTEMS
153 #define TASKID_RECV 1
157 #define TASKID_RECV 1
154 #define TASKID_ACTN 2
158 #define TASKID_ACTN 2
155 #define TASKID_SPIQ 3
159 #define TASKID_SPIQ 3
156 #define TASKID_STAT 4
160 #define TASKID_STAT 4
157 #define TASKID_AVF0 5
161 #define TASKID_AVF0 5
158 #define TASKID_SWBD 6
162 #define TASKID_SWBD 6
159 #define TASKID_WFRM 7
163 #define TASKID_WFRM 7
160 #define TASKID_DUMB 8
164 #define TASKID_DUMB 8
161 #define TASKID_HOUS 9
165 #define TASKID_HOUS 9
162 #define TASKID_PRC0 10
166 #define TASKID_PRC0 10
163 #define TASKID_CWF3 11
167 #define TASKID_CWF3 11
164 #define TASKID_CWF2 12
168 #define TASKID_CWF2 12
165 #define TASKID_CWF1 13
169 #define TASKID_CWF1 13
166 #define TASKID_SEND 14
170 #define TASKID_SEND 14
167 #define TASKID_WTDG 15
171 #define TASKID_WTDG 15
168 #define TASKID_AVF1 16
172 #define TASKID_AVF1 16
169 #define TASKID_PRC1 17
173 #define TASKID_PRC1 17
170 #define TASKID_AVF2 18
174 #define TASKID_AVF2 18
171 #define TASKID_PRC2 19
175 #define TASKID_PRC2 19
172
176
173 #define TASK_PRIORITY_SPIQ 5
177 #define TASK_PRIORITY_SPIQ 5
174 #define TASK_PRIORITY_WTDG 20
178 #define TASK_PRIORITY_WTDG 20
175 #define TASK_PRIORITY_HOUS 30
179 #define TASK_PRIORITY_HOUS 30
176 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
180 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
177 #define TASK_PRIORITY_CWF2 35 //
181 #define TASK_PRIORITY_CWF2 35 //
178 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
182 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
179 #define TASK_PRIORITY_WFRM 40
183 #define TASK_PRIORITY_WFRM 40
180 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
184 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
181 #define TASK_PRIORITY_SEND 45
185 #define TASK_PRIORITY_SEND 45
182 #define TASK_PRIORITY_RECV 50
186 #define TASK_PRIORITY_RECV 50
183 #define TASK_PRIORITY_ACTN 50
187 #define TASK_PRIORITY_ACTN 50
184 #define TASK_PRIORITY_AVF0 60
188 #define TASK_PRIORITY_AVF0 60
185 #define TASK_PRIORITY_AVF1 70
189 #define TASK_PRIORITY_AVF1 70
186 #define TASK_PRIORITY_PRC0 100
190 #define TASK_PRIORITY_PRC0 100
187 #define TASK_PRIORITY_PRC1 100
191 #define TASK_PRIORITY_PRC1 100
188 #define TASK_PRIORITY_AVF2 110
192 #define TASK_PRIORITY_AVF2 110
189 #define TASK_PRIORITY_PRC2 110
193 #define TASK_PRIORITY_PRC2 110
190 #define TASK_PRIORITY_STAT 200
194 #define TASK_PRIORITY_STAT 200
191 #define TASK_PRIORITY_DUMB 200
195 #define TASK_PRIORITY_DUMB 200
192
196
193 #define MSG_QUEUE_COUNT_RECV 10
197 #define MSG_QUEUE_COUNT_RECV 10
194 #define MSG_QUEUE_COUNT_SEND 50
198 #define MSG_QUEUE_COUNT_SEND 50
195 #define MSG_QUEUE_COUNT_PRC0 10
199 #define MSG_QUEUE_COUNT_PRC0 10
196 #define MSG_QUEUE_COUNT_PRC1 10
200 #define MSG_QUEUE_COUNT_PRC1 10
197 #define MSG_QUEUE_COUNT_PRC2 5
201 #define MSG_QUEUE_COUNT_PRC2 5
198 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
202 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
199 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
203 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
200 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
204 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
201 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
205 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
202 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
206 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
203
207
204 #define QUEUE_RECV 0
208 #define QUEUE_RECV 0
205 #define QUEUE_SEND 1
209 #define QUEUE_SEND 1
206 #define QUEUE_PRC0 2
210 #define QUEUE_PRC0 2
207 #define QUEUE_PRC1 3
211 #define QUEUE_PRC1 3
208 #define QUEUE_PRC2 4
212 #define QUEUE_PRC2 4
209
213
210 //*******
214 //*******
211 // MACROS
215 // MACROS
212 #ifdef PRINT_MESSAGES_ON_CONSOLE
216 #ifdef PRINT_MESSAGES_ON_CONSOLE
213 #define PRINTF(x) printf(x);
217 #define PRINTF(x) printf(x);
214 #define PRINTF1(x,y) printf(x,y);
218 #define PRINTF1(x,y) printf(x,y);
215 #define PRINTF2(x,y,z) printf(x,y,z);
219 #define PRINTF2(x,y,z) printf(x,y,z);
216 #else
220 #else
217 #define PRINTF(x) ;
221 #define PRINTF(x) ;
218 #define PRINTF1(x,y) ;
222 #define PRINTF1(x,y) ;
219 #define PRINTF2(x,y,z) ;
223 #define PRINTF2(x,y,z) ;
220 #endif
224 #endif
221
225
222 #ifdef BOOT_MESSAGES
226 #ifdef BOOT_MESSAGES
223 #define BOOT_PRINTF(x) printf(x);
227 #define BOOT_PRINTF(x) printf(x);
224 #define BOOT_PRINTF1(x,y) printf(x,y);
228 #define BOOT_PRINTF1(x,y) printf(x,y);
225 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
229 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
226 #else
230 #else
227 #define BOOT_PRINTF(x) ;
231 #define BOOT_PRINTF(x) ;
228 #define BOOT_PRINTF1(x,y) ;
232 #define BOOT_PRINTF1(x,y) ;
229 #define BOOT_PRINTF2(x,y,z) ;
233 #define BOOT_PRINTF2(x,y,z) ;
230 #endif
234 #endif
231
235
232 #ifdef DEBUG_MESSAGES
236 #ifdef DEBUG_MESSAGES
233 #define DEBUG_PRINTF(x) printf(x);
237 #define DEBUG_PRINTF(x) printf(x);
234 #define DEBUG_PRINTF1(x,y) printf(x,y);
238 #define DEBUG_PRINTF1(x,y) printf(x,y);
235 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
239 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
236 #else
240 #else
237 #define DEBUG_PRINTF(x) ;
241 #define DEBUG_PRINTF(x) ;
238 #define DEBUG_PRINTF1(x,y) ;
242 #define DEBUG_PRINTF1(x,y) ;
239 #define DEBUG_PRINTF2(x,y,z) ;
243 #define DEBUG_PRINTF2(x,y,z) ;
240 #endif
244 #endif
241
245
242 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
246 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
243
247
244 struct param_local_str{
248 struct param_local_str{
245 unsigned int local_sbm1_nb_cwf_sent;
249 unsigned int local_sbm1_nb_cwf_sent;
246 unsigned int local_sbm1_nb_cwf_max;
250 unsigned int local_sbm1_nb_cwf_max;
247 unsigned int local_sbm2_nb_cwf_sent;
251 unsigned int local_sbm2_nb_cwf_sent;
248 unsigned int local_sbm2_nb_cwf_max;
252 unsigned int local_sbm2_nb_cwf_max;
249 };
253 };
250
254
251 #endif // FSW_PARAMS_H_INCLUDED
255 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,242 +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);
104 unsigned char getSID( rtems_event_set event );
104
105
105 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 );
106 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 );
107
108
108 //***************************************
109 //***************************************
109 // DEFINITIONS OF STATIC INLINE FUNCTIONS
110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
110 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_f0, float *averaged_spec_mat_f1,
111 ring_node_sm *ring_node_tab[],
112 ring_node_sm *ring_node_tab[],
112 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
113 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
113 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,
114 float divider );
115 float divider );
115 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,
116 float divider,
117 float divider,
117 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
118 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);
119
120
120 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
121 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
121 ring_node_sm *ring_node_tab[],
122 ring_node_sm *ring_node_tab[],
122 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
123 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
123 {
124 {
124 float sum;
125 float sum;
125 unsigned int i;
126 unsigned int i;
126
127
127 for(i=0; i<TOTAL_SIZE_SM; i++)
128 for(i=0; i<TOTAL_SIZE_SM; i++)
128 {
129 {
129 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
130 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
130 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
131 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
131 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
132 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
132 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
133 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
133 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
134 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
134 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
137
138
138 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
139 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
139 {
140 {
140 averaged_spec_mat_f0[ i ] = sum;
141 averaged_spec_mat_f0[ i ] = sum;
141 averaged_spec_mat_f1[ i ] = sum;
142 averaged_spec_mat_f1[ i ] = sum;
142 }
143 }
143 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
144 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
144 {
145 {
145 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
146 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
146 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
147 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
147 }
148 }
148 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
149 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
149 {
150 {
150 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
151 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
151 averaged_spec_mat_f1[ i ] = sum;
152 averaged_spec_mat_f1[ i ] = sum;
152 }
153 }
153 else
154 else
154 {
155 {
155 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
156 }
157 }
157 }
158 }
158 }
159 }
159
160
160 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 )
161 {
162 {
162 int frequencyBin;
163 int frequencyBin;
163 int asmComponent;
164 int asmComponent;
164 unsigned int offsetAveragedSpecMatReorganized;
165 unsigned int offsetAveragedSpecMatReorganized;
165 unsigned int offsetAveragedSpecMat;
166 unsigned int offsetAveragedSpecMat;
166
167
167 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
168 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
168 {
169 {
169 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
170 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
170 {
171 {
171 offsetAveragedSpecMatReorganized =
172 offsetAveragedSpecMatReorganized =
172 frequencyBin * NB_VALUES_PER_SM
173 frequencyBin * NB_VALUES_PER_SM
173 + asmComponent;
174 + asmComponent;
174 offsetAveragedSpecMat =
175 offsetAveragedSpecMat =
175 asmComponent * NB_BINS_PER_SM
176 asmComponent * NB_BINS_PER_SM
176 + frequencyBin;
177 + frequencyBin;
177 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
178 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
178 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
179 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
179 }
180 }
180 }
181 }
181 }
182 }
182
183
183 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,
184 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
185 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
185 {
186 {
186 int frequencyBin;
187 int frequencyBin;
187 int asmComponent;
188 int asmComponent;
188 int offsetASM;
189 int offsetASM;
189 int offsetCompressed;
190 int offsetCompressed;
190 int k;
191 int k;
191
192
192 // build data
193 // build data
193 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
194 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
194 {
195 {
195 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
196 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
196 {
197 {
197 offsetCompressed = // NO TIME OFFSET
198 offsetCompressed = // NO TIME OFFSET
198 frequencyBin * NB_VALUES_PER_SM
199 frequencyBin * NB_VALUES_PER_SM
199 + asmComponent;
200 + asmComponent;
200 offsetASM = // NO TIME OFFSET
201 offsetASM = // NO TIME OFFSET
201 asmComponent * NB_BINS_PER_SM
202 asmComponent * NB_BINS_PER_SM
202 + ASMIndexStart
203 + ASMIndexStart
203 + frequencyBin * nbBinsToAverage;
204 + frequencyBin * nbBinsToAverage;
204 compressed_spec_mat[ offsetCompressed ] = 0;
205 compressed_spec_mat[ offsetCompressed ] = 0;
205 for ( k = 0; k < nbBinsToAverage; k++ )
206 for ( k = 0; k < nbBinsToAverage; k++ )
206 {
207 {
207 compressed_spec_mat[offsetCompressed ] =
208 compressed_spec_mat[offsetCompressed ] =
208 ( compressed_spec_mat[ offsetCompressed ]
209 ( compressed_spec_mat[ offsetCompressed ]
209 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
210 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
210 }
211 }
211 }
212 }
212 }
213 }
213 }
214 }
214
215
215 void ASM_convert( volatile float *input_matrix, char *output_matrix)
216 void ASM_convert( volatile float *input_matrix, char *output_matrix)
216 {
217 {
217 unsigned int frequencyBin;
218 unsigned int frequencyBin;
218 unsigned int asmComponent;
219 unsigned int asmComponent;
219 char * pt_char_input;
220 char * pt_char_input;
220 char * pt_char_output;
221 char * pt_char_output;
221 unsigned int offsetInput;
222 unsigned int offsetInput;
222 unsigned int offsetOutput;
223 unsigned int offsetOutput;
223
224
224 pt_char_input = (char*) &input_matrix;
225 pt_char_input = (char*) &input_matrix;
225 pt_char_output = (char*) &output_matrix;
226 pt_char_output = (char*) &output_matrix;
226
227
227 // convert all other data
228 // convert all other data
228 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
229 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
229 {
230 {
230 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
231 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
231 {
232 {
232 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
233 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
233 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
234 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
234 pt_char_input = (char*) &input_matrix [ offsetInput ];
235 pt_char_input = (char*) &input_matrix [ offsetInput ];
235 pt_char_output = (char*) &output_matrix[ offsetOutput ];
236 pt_char_output = (char*) &output_matrix[ offsetOutput ];
236 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
237 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
238 }
239 }
239 }
240 }
240 }
241 }
241
242
242 #endif // FSW_PROCESSING_H_INCLUDED
243 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,46 +1,48
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "wf_handler.h"
8 #include "wf_handler.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "fsw_misc.h"
10 #include "fsw_misc.h"
11
11
12 extern unsigned short sequenceCounterParameterDump;
13
12 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
14 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
13 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
15 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
14 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
16 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
15 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
17 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
16 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
18 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
17 int action_dump_par(rtems_id queue_id );
19 int action_dump_par(rtems_id queue_id );
18
20
19 // NORMAL
21 // NORMAL
20 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
22 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
21 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
23 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
22 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
24 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
23 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
25 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
24 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
26 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
25 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
27 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
26
28
27 // BURST
29 // BURST
28 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
30 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
31 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
30
32
31 // SBM1
33 // SBM1
32 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
34 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
33 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
35 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
34
36
35 // SBM2
37 // SBM2
36 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
38 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
37 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
39 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
38
40
39 // TC_LFR_UPDATE_INFO
41 // TC_LFR_UPDATE_INFO
40 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
42 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
41 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
43 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
42 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
44 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
43
45
44 void init_parameter_dump( void );
46 void init_parameter_dump( void );
45
47
46 #endif // TC_LOAD_DUMP_PARAMETERS_H
48 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,73 +1,75
1 /** Global variables of the LFR flight software.
1 /** Global variables of the LFR flight software.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * Among global variables, there are:
6 * Among global variables, there are:
7 * - RTEMS names and id.
7 * - RTEMS names and id.
8 * - APB configuration registers.
8 * - APB configuration registers.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
11 * - variable related to LFR modes parameters.
11 * - variable related to LFR modes parameters.
12 * - the global HK packet buffer.
12 * - the global HK packet buffer.
13 * - the global dump parameter buffer.
13 * - the global dump parameter buffer.
14 *
14 *
15 */
15 */
16
16
17 #include <rtems.h>
17 #include <rtems.h>
18 #include <grspw.h>
18 #include <grspw.h>
19
19
20 #include "ccsds_types.h"
20 #include "ccsds_types.h"
21 #include "grlib_regs.h"
21 #include "grlib_regs.h"
22 #include "fsw_params.h"
22 #include "fsw_params.h"
23 #include "fsw_params_wf_handler.h"
23 #include "fsw_params_wf_handler.h"
24
24
25 // RTEMS GLOBAL VARIABLES
25 // RTEMS GLOBAL VARIABLES
26 rtems_name misc_name[5];
26 rtems_name misc_name[5];
27 rtems_id misc_id[5];
27 rtems_id misc_id[5];
28 rtems_name Task_name[20]; /* array of task names */
28 rtems_name Task_name[20]; /* array of task names */
29 rtems_id Task_id[20]; /* array of task ids */
29 rtems_id Task_id[20]; /* array of task ids */
30 unsigned int maxCount;
30 unsigned int maxCount;
31 int fdSPW = 0;
31 int fdSPW = 0;
32 int fdUART = 0;
32 int fdUART = 0;
33 unsigned char lfrCurrentMode;
33 unsigned char lfrCurrentMode;
34
34
35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
39 // F0 F1 F2 F3
39 // F0 F1 F2 F3
40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
45
45
46 //***********************************
46 //***********************************
47 // SPECTRAL MATRICES GLOBAL VARIABLES
47 // SPECTRAL MATRICES GLOBAL VARIABLES
48
48
49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53
53
54 // APB CONFIGURATION REGISTERS
54 // APB CONFIGURATION REGISTERS
55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
57 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
57 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
59
59
60 // MODE PARAMETERS
60 // MODE PARAMETERS
61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
62 struct param_local_str param_local;
62 struct param_local_str param_local;
63
63
64 // HK PACKETS
64 // HK PACKETS
65 Packet_TM_LFR_HK_t housekeeping_packet;
65 Packet_TM_LFR_HK_t housekeeping_packet;
66 // sequence counters are incremented by APID (PID + CAT) and destination ID
66 // sequence counters are incremented by APID (PID + CAT) and destination ID
67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
70 unsigned short sequenceCounterHK;
71 unsigned short sequenceCounterParameterDump;
70 spw_stats spacewire_stats;
72 spw_stats spacewire_stats;
71 spw_stats spacewire_stats_backup;
73 spw_stats spacewire_stats_backup;
72
74
73
75
@@ -1,780 +1,782
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 #endif
42 #endif
43
43
44 #include <rtems/confdefs.h>
44 #include <rtems/confdefs.h>
45
45
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef RTEMS_DRVMGR_STARTUP
48 #ifdef LEON3
48 #ifdef LEON3
49 /* Add Timer and UART Driver */
49 /* Add Timer and UART Driver */
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #endif
52 #endif
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 #endif
55 #endif
56 #endif
56 #endif
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 #include <drvmgr/drvmgr_confdefs.h>
58 #include <drvmgr/drvmgr_confdefs.h>
59 #endif
59 #endif
60
60
61 #include "fsw_init.h"
61 #include "fsw_init.h"
62 #include "fsw_config.c"
62 #include "fsw_config.c"
63
63
64 rtems_task Init( rtems_task_argument ignored )
64 rtems_task Init( rtems_task_argument ignored )
65 {
65 {
66 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 /** This is the RTEMS INIT taks, it the first task launched by the system.
67 *
67 *
68 * @param unused is the starting argument of the RTEMS task
68 * @param unused is the starting argument of the RTEMS task
69 *
69 *
70 * The INIT task create and run all other RTEMS tasks.
70 * The INIT task create and run all other RTEMS tasks.
71 *
71 *
72 */
72 */
73
73
74 unsigned char *vhdlVersion;
74 unsigned char *vhdlVersion;
75
75
76 reset_local_time();
76 reset_local_time();
77
77
78 rtems_cpu_usage_reset();
78 rtems_cpu_usage_reset();
79
79
80 rtems_status_code status;
80 rtems_status_code status;
81 rtems_status_code status_spw;
81 rtems_status_code status_spw;
82 rtems_isr_entry old_isr_handler;
82 rtems_isr_entry old_isr_handler;
83
83
84 // UART settings
84 // UART settings
85 send_console_outputs_on_apbuart_port();
85 send_console_outputs_on_apbuart_port();
86 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
86 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
87 enable_apbuart_transmitter();
87 enable_apbuart_transmitter();
88 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
88 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
89
89
90 PRINTF("\n\n\n\n\n")
90 PRINTF("\n\n\n\n\n")
91 PRINTF("*************************\n")
91 PRINTF("*************************\n")
92 PRINTF("** LFR Flight Software **\n")
92 PRINTF("** LFR Flight Software **\n")
93 PRINTF1("** %d.", SW_VERSION_N1)
93 PRINTF1("** %d.", SW_VERSION_N1)
94 PRINTF1("%d." , SW_VERSION_N2)
94 PRINTF1("%d." , SW_VERSION_N2)
95 PRINTF1("%d." , SW_VERSION_N3)
95 PRINTF1("%d." , SW_VERSION_N3)
96 PRINTF1("%d **\n", SW_VERSION_N4)
96 PRINTF1("%d **\n", SW_VERSION_N4)
97
97
98 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
98 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
99 PRINTF("** VHDL **\n")
99 PRINTF("** VHDL **\n")
100 PRINTF1("** %d.", vhdlVersion[1])
100 PRINTF1("** %d.", vhdlVersion[1])
101 PRINTF1("%d." , vhdlVersion[2])
101 PRINTF1("%d." , vhdlVersion[2])
102 PRINTF1("%d **\n", vhdlVersion[3])
102 PRINTF1("%d **\n", vhdlVersion[3])
103 PRINTF("*************************\n")
103 PRINTF("*************************\n")
104 PRINTF("\n\n")
104 PRINTF("\n\n")
105
105
106 init_parameter_dump();
106 init_parameter_dump();
107 init_local_mode_parameters();
107 init_local_mode_parameters();
108 init_housekeeping_parameters();
108 init_housekeeping_parameters();
109
109
110 // waveform picker initialization
110 // waveform picker initialization
111 WFP_init_rings(); // initialize the waveform rings
111 WFP_init_rings(); // initialize the waveform rings
112 WFP_reset_current_ring_nodes();
112 WFP_reset_current_ring_nodes();
113 reset_waveform_picker_regs();
113 reset_waveform_picker_regs();
114
114
115 // spectral matrices initialization
115 // spectral matrices initialization
116 SM_init_rings(); // initialize spectral matrices rings
116 SM_init_rings(); // initialize spectral matrices rings
117 SM_reset_current_ring_nodes();
117 SM_reset_current_ring_nodes();
118 reset_spectral_matrix_regs();
118 reset_spectral_matrix_regs();
119
119
120 updateLFRCurrentMode();
120 updateLFRCurrentMode();
121
121
122 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
122 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
123
123
124 create_names(); // create all names
124 create_names(); // create all names
125
125
126 status = create_message_queues(); // create message queues
126 status = create_message_queues(); // create message queues
127 if (status != RTEMS_SUCCESSFUL)
127 if (status != RTEMS_SUCCESSFUL)
128 {
128 {
129 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
129 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
130 }
130 }
131
131
132 status = create_all_tasks(); // create all tasks
132 status = create_all_tasks(); // create all tasks
133 if (status != RTEMS_SUCCESSFUL)
133 if (status != RTEMS_SUCCESSFUL)
134 {
134 {
135 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
135 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
136 }
136 }
137
137
138 // **************************
138 // **************************
139 // <SPACEWIRE INITIALIZATION>
139 // <SPACEWIRE INITIALIZATION>
140 grspw_timecode_callback = &timecode_irq_handler;
140 grspw_timecode_callback = &timecode_irq_handler;
141
141
142 status_spw = spacewire_open_link(); // (1) open the link
142 status_spw = spacewire_open_link(); // (1) open the link
143 if ( status_spw != RTEMS_SUCCESSFUL )
143 if ( status_spw != RTEMS_SUCCESSFUL )
144 {
144 {
145 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
145 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
146 }
146 }
147
147
148 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
148 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
149 {
149 {
150 status_spw = spacewire_configure_link( fdSPW );
150 status_spw = spacewire_configure_link( fdSPW );
151 if ( status_spw != RTEMS_SUCCESSFUL )
151 if ( status_spw != RTEMS_SUCCESSFUL )
152 {
152 {
153 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
153 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
154 }
154 }
155 }
155 }
156
156
157 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
157 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
158 {
158 {
159 status_spw = spacewire_start_link( fdSPW );
159 status_spw = spacewire_start_link( fdSPW );
160 if ( status_spw != RTEMS_SUCCESSFUL )
160 if ( status_spw != RTEMS_SUCCESSFUL )
161 {
161 {
162 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
162 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
163 }
163 }
164 }
164 }
165 // </SPACEWIRE INITIALIZATION>
165 // </SPACEWIRE INITIALIZATION>
166 // ***************************
166 // ***************************
167
167
168 status = start_all_tasks(); // start all tasks
168 status = start_all_tasks(); // start all tasks
169 if (status != RTEMS_SUCCESSFUL)
169 if (status != RTEMS_SUCCESSFUL)
170 {
170 {
171 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
171 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
172 }
172 }
173
173
174 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
174 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
175 status = start_recv_send_tasks();
175 status = start_recv_send_tasks();
176 if ( status != RTEMS_SUCCESSFUL )
176 if ( status != RTEMS_SUCCESSFUL )
177 {
177 {
178 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
178 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
179 }
179 }
180
180
181 // suspend science tasks, they will be restarted later depending on the mode
181 // suspend science tasks, they will be restarted later depending on the mode
182 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
182 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
183 if (status != RTEMS_SUCCESSFUL)
183 if (status != RTEMS_SUCCESSFUL)
184 {
184 {
185 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
185 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
186 }
186 }
187
187
188 //******************************
188 //******************************
189 // <SPECTRAL MATRICES SIMULATOR>
189 // <SPECTRAL MATRICES SIMULATOR>
190 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
190 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
191 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
191 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
192 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
192 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
193 // </SPECTRAL MATRICES SIMULATOR>
193 // </SPECTRAL MATRICES SIMULATOR>
194 //*******************************
194 //*******************************
195
195
196 // configure IRQ handling for the waveform picker unit
196 // configure IRQ handling for the waveform picker unit
197 status = rtems_interrupt_catch( waveforms_isr,
197 status = rtems_interrupt_catch( waveforms_isr,
198 IRQ_SPARC_WAVEFORM_PICKER,
198 IRQ_SPARC_WAVEFORM_PICKER,
199 &old_isr_handler) ;
199 &old_isr_handler) ;
200 // configure IRQ handling for the spectral matrices unit
200 // configure IRQ handling for the spectral matrices unit
201 status = rtems_interrupt_catch( spectral_matrices_isr,
201 status = rtems_interrupt_catch( spectral_matrices_isr,
202 IRQ_SPARC_SPECTRAL_MATRIX,
202 IRQ_SPARC_SPECTRAL_MATRIX,
203 &old_isr_handler) ;
203 &old_isr_handler) ;
204
204
205 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
205 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
206 if ( status_spw != RTEMS_SUCCESSFUL )
206 if ( status_spw != RTEMS_SUCCESSFUL )
207 {
207 {
208 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
208 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
209 if ( status != RTEMS_SUCCESSFUL ) {
209 if ( status != RTEMS_SUCCESSFUL ) {
210 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
210 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
211 }
211 }
212 }
212 }
213
213
214 BOOT_PRINTF("delete INIT\n")
214 BOOT_PRINTF("delete INIT\n")
215
215
216 send_dumb_hk();
216 send_dumb_hk();
217
217
218 status = rtems_task_delete(RTEMS_SELF);
218 status = rtems_task_delete(RTEMS_SELF);
219
219
220 }
220 }
221
221
222 void init_local_mode_parameters( void )
222 void init_local_mode_parameters( void )
223 {
223 {
224 /** This function initialize the param_local global variable with default values.
224 /** This function initialize the param_local global variable with default values.
225 *
225 *
226 */
226 */
227
227
228 unsigned int i;
228 unsigned int i;
229
229
230 // LOCAL PARAMETERS
230 // LOCAL PARAMETERS
231
231
232 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
232 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
233 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
233 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
234 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
234 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
235
235
236 // init sequence counters
236 // init sequence counters
237
237
238 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
238 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
239 {
239 {
240 sequenceCounters_TC_EXE[i] = 0x00;
240 sequenceCounters_TC_EXE[i] = 0x00;
241 }
241 }
242 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
242 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
243 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
243 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
244 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
245 sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
244 }
246 }
245
247
246 void reset_local_time( void )
248 void reset_local_time( void )
247 {
249 {
248 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
250 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
249 }
251 }
250
252
251 void create_names( void ) // create all names for tasks and queues
253 void create_names( void ) // create all names for tasks and queues
252 {
254 {
253 /** This function creates all RTEMS names used in the software for tasks and queues.
255 /** This function creates all RTEMS names used in the software for tasks and queues.
254 *
256 *
255 * @return RTEMS directive status codes:
257 * @return RTEMS directive status codes:
256 * - RTEMS_SUCCESSFUL - successful completion
258 * - RTEMS_SUCCESSFUL - successful completion
257 *
259 *
258 */
260 */
259
261
260 // task names
262 // task names
261 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
263 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
262 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
264 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
263 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
265 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
264 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
266 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
265 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
267 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
266 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
268 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
267 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
269 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
268 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
270 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
269 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
271 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
270 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
272 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
271 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
273 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
272 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
274 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
273 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
275 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
274 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
276 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
275 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
277 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
276 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
278 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
277 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
279 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
278 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
280 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
279 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
281 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
280
282
281 // rate monotonic period names
283 // rate monotonic period names
282 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
284 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
283
285
284 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
286 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
285 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
287 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
286 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
288 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
287 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
289 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
288 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
290 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
289 }
291 }
290
292
291 int create_all_tasks( void ) // create all tasks which run in the software
293 int create_all_tasks( void ) // create all tasks which run in the software
292 {
294 {
293 /** This function creates all RTEMS tasks used in the software.
295 /** This function creates all RTEMS tasks used in the software.
294 *
296 *
295 * @return RTEMS directive status codes:
297 * @return RTEMS directive status codes:
296 * - RTEMS_SUCCESSFUL - task created successfully
298 * - RTEMS_SUCCESSFUL - task created successfully
297 * - RTEMS_INVALID_ADDRESS - id is NULL
299 * - RTEMS_INVALID_ADDRESS - id is NULL
298 * - RTEMS_INVALID_NAME - invalid task name
300 * - RTEMS_INVALID_NAME - invalid task name
299 * - RTEMS_INVALID_PRIORITY - invalid task priority
301 * - RTEMS_INVALID_PRIORITY - invalid task priority
300 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
302 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
301 * - RTEMS_TOO_MANY - too many tasks created
303 * - RTEMS_TOO_MANY - too many tasks created
302 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
304 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
303 * - RTEMS_TOO_MANY - too many global objects
305 * - RTEMS_TOO_MANY - too many global objects
304 *
306 *
305 */
307 */
306
308
307 rtems_status_code status;
309 rtems_status_code status;
308
310
309 //**********
311 //**********
310 // SPACEWIRE
312 // SPACEWIRE
311 // RECV
313 // RECV
312 status = rtems_task_create(
314 status = rtems_task_create(
313 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
315 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
314 RTEMS_DEFAULT_MODES,
316 RTEMS_DEFAULT_MODES,
315 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
316 );
318 );
317 if (status == RTEMS_SUCCESSFUL) // SEND
319 if (status == RTEMS_SUCCESSFUL) // SEND
318 {
320 {
319 status = rtems_task_create(
321 status = rtems_task_create(
320 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
322 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
321 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
323 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
322 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
324 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
323 );
325 );
324 }
326 }
325 if (status == RTEMS_SUCCESSFUL) // WTDG
327 if (status == RTEMS_SUCCESSFUL) // WTDG
326 {
328 {
327 status = rtems_task_create(
329 status = rtems_task_create(
328 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
330 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
329 RTEMS_DEFAULT_MODES,
331 RTEMS_DEFAULT_MODES,
330 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
332 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
331 );
333 );
332 }
334 }
333 if (status == RTEMS_SUCCESSFUL) // ACTN
335 if (status == RTEMS_SUCCESSFUL) // ACTN
334 {
336 {
335 status = rtems_task_create(
337 status = rtems_task_create(
336 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
338 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
337 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
339 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
338 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
340 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
339 );
341 );
340 }
342 }
341 if (status == RTEMS_SUCCESSFUL) // SPIQ
343 if (status == RTEMS_SUCCESSFUL) // SPIQ
342 {
344 {
343 status = rtems_task_create(
345 status = rtems_task_create(
344 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
346 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
345 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
346 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
348 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
347 );
349 );
348 }
350 }
349
351
350 //******************
352 //******************
351 // SPECTRAL MATRICES
353 // SPECTRAL MATRICES
352 if (status == RTEMS_SUCCESSFUL) // AVF0
354 if (status == RTEMS_SUCCESSFUL) // AVF0
353 {
355 {
354 status = rtems_task_create(
356 status = rtems_task_create(
355 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
357 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
356 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
358 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
357 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
358 );
360 );
359 }
361 }
360 if (status == RTEMS_SUCCESSFUL) // PRC0
362 if (status == RTEMS_SUCCESSFUL) // PRC0
361 {
363 {
362 status = rtems_task_create(
364 status = rtems_task_create(
363 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
365 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
364 RTEMS_DEFAULT_MODES,
366 RTEMS_DEFAULT_MODES,
365 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
367 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
366 );
368 );
367 }
369 }
368 if (status == RTEMS_SUCCESSFUL) // AVF1
370 if (status == RTEMS_SUCCESSFUL) // AVF1
369 {
371 {
370 status = rtems_task_create(
372 status = rtems_task_create(
371 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
373 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
372 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
374 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
373 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
375 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
374 );
376 );
375 }
377 }
376 if (status == RTEMS_SUCCESSFUL) // PRC1
378 if (status == RTEMS_SUCCESSFUL) // PRC1
377 {
379 {
378 status = rtems_task_create(
380 status = rtems_task_create(
379 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
381 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
380 RTEMS_DEFAULT_MODES,
382 RTEMS_DEFAULT_MODES,
381 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
383 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
382 );
384 );
383 }
385 }
384 if (status == RTEMS_SUCCESSFUL) // AVF2
386 if (status == RTEMS_SUCCESSFUL) // AVF2
385 {
387 {
386 status = rtems_task_create(
388 status = rtems_task_create(
387 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
389 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
388 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
390 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
389 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
391 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
390 );
392 );
391 }
393 }
392 if (status == RTEMS_SUCCESSFUL) // PRC2
394 if (status == RTEMS_SUCCESSFUL) // PRC2
393 {
395 {
394 status = rtems_task_create(
396 status = rtems_task_create(
395 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
397 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
396 RTEMS_DEFAULT_MODES,
398 RTEMS_DEFAULT_MODES,
397 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
399 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
398 );
400 );
399 }
401 }
400
402
401 //****************
403 //****************
402 // WAVEFORM PICKER
404 // WAVEFORM PICKER
403 if (status == RTEMS_SUCCESSFUL) // WFRM
405 if (status == RTEMS_SUCCESSFUL) // WFRM
404 {
406 {
405 status = rtems_task_create(
407 status = rtems_task_create(
406 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
408 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
407 RTEMS_DEFAULT_MODES,
409 RTEMS_DEFAULT_MODES,
408 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
409 );
411 );
410 }
412 }
411 if (status == RTEMS_SUCCESSFUL) // CWF3
413 if (status == RTEMS_SUCCESSFUL) // CWF3
412 {
414 {
413 status = rtems_task_create(
415 status = rtems_task_create(
414 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
416 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
415 RTEMS_DEFAULT_MODES,
417 RTEMS_DEFAULT_MODES,
416 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
418 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
417 );
419 );
418 }
420 }
419 if (status == RTEMS_SUCCESSFUL) // CWF2
421 if (status == RTEMS_SUCCESSFUL) // CWF2
420 {
422 {
421 status = rtems_task_create(
423 status = rtems_task_create(
422 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
424 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
423 RTEMS_DEFAULT_MODES,
425 RTEMS_DEFAULT_MODES,
424 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
425 );
427 );
426 }
428 }
427 if (status == RTEMS_SUCCESSFUL) // CWF1
429 if (status == RTEMS_SUCCESSFUL) // CWF1
428 {
430 {
429 status = rtems_task_create(
431 status = rtems_task_create(
430 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
432 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
431 RTEMS_DEFAULT_MODES,
433 RTEMS_DEFAULT_MODES,
432 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
434 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
433 );
435 );
434 }
436 }
435 if (status == RTEMS_SUCCESSFUL) // SWBD
437 if (status == RTEMS_SUCCESSFUL) // SWBD
436 {
438 {
437 status = rtems_task_create(
439 status = rtems_task_create(
438 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
440 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
439 RTEMS_DEFAULT_MODES,
441 RTEMS_DEFAULT_MODES,
440 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
442 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
441 );
443 );
442 }
444 }
443
445
444 //*****
446 //*****
445 // MISC
447 // MISC
446 if (status == RTEMS_SUCCESSFUL) // STAT
448 if (status == RTEMS_SUCCESSFUL) // STAT
447 {
449 {
448 status = rtems_task_create(
450 status = rtems_task_create(
449 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
451 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
450 RTEMS_DEFAULT_MODES,
452 RTEMS_DEFAULT_MODES,
451 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
453 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
452 );
454 );
453 }
455 }
454 if (status == RTEMS_SUCCESSFUL) // DUMB
456 if (status == RTEMS_SUCCESSFUL) // DUMB
455 {
457 {
456 status = rtems_task_create(
458 status = rtems_task_create(
457 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
459 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
458 RTEMS_DEFAULT_MODES,
460 RTEMS_DEFAULT_MODES,
459 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
461 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
460 );
462 );
461 }
463 }
462 if (status == RTEMS_SUCCESSFUL) // HOUS
464 if (status == RTEMS_SUCCESSFUL) // HOUS
463 {
465 {
464 status = rtems_task_create(
466 status = rtems_task_create(
465 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
467 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
466 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
467 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
469 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
468 );
470 );
469 }
471 }
470
472
471 return status;
473 return status;
472 }
474 }
473
475
474 int start_recv_send_tasks( void )
476 int start_recv_send_tasks( void )
475 {
477 {
476 rtems_status_code status;
478 rtems_status_code status;
477
479
478 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
480 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
479 if (status!=RTEMS_SUCCESSFUL) {
481 if (status!=RTEMS_SUCCESSFUL) {
480 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
482 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
481 }
483 }
482
484
483 if (status == RTEMS_SUCCESSFUL) // SEND
485 if (status == RTEMS_SUCCESSFUL) // SEND
484 {
486 {
485 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
487 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
486 if (status!=RTEMS_SUCCESSFUL) {
488 if (status!=RTEMS_SUCCESSFUL) {
487 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
489 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
488 }
490 }
489 }
491 }
490
492
491 return status;
493 return status;
492 }
494 }
493
495
494 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
496 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
495 {
497 {
496 /** This function starts all RTEMS tasks used in the software.
498 /** This function starts all RTEMS tasks used in the software.
497 *
499 *
498 * @return RTEMS directive status codes:
500 * @return RTEMS directive status codes:
499 * - RTEMS_SUCCESSFUL - ask started successfully
501 * - RTEMS_SUCCESSFUL - ask started successfully
500 * - RTEMS_INVALID_ADDRESS - invalid task entry point
502 * - RTEMS_INVALID_ADDRESS - invalid task entry point
501 * - RTEMS_INVALID_ID - invalid task id
503 * - RTEMS_INVALID_ID - invalid task id
502 * - RTEMS_INCORRECT_STATE - task not in the dormant state
504 * - RTEMS_INCORRECT_STATE - task not in the dormant state
503 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
505 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
504 *
506 *
505 */
507 */
506 // starts all the tasks fot eh flight software
508 // starts all the tasks fot eh flight software
507
509
508 rtems_status_code status;
510 rtems_status_code status;
509
511
510 //**********
512 //**********
511 // SPACEWIRE
513 // SPACEWIRE
512 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
514 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
513 if (status!=RTEMS_SUCCESSFUL) {
515 if (status!=RTEMS_SUCCESSFUL) {
514 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
516 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
515 }
517 }
516
518
517 if (status == RTEMS_SUCCESSFUL) // WTDG
519 if (status == RTEMS_SUCCESSFUL) // WTDG
518 {
520 {
519 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
521 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
520 if (status!=RTEMS_SUCCESSFUL) {
522 if (status!=RTEMS_SUCCESSFUL) {
521 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
523 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
522 }
524 }
523 }
525 }
524
526
525 if (status == RTEMS_SUCCESSFUL) // ACTN
527 if (status == RTEMS_SUCCESSFUL) // ACTN
526 {
528 {
527 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
529 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
528 if (status!=RTEMS_SUCCESSFUL) {
530 if (status!=RTEMS_SUCCESSFUL) {
529 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
531 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
530 }
532 }
531 }
533 }
532
534
533 //******************
535 //******************
534 // SPECTRAL MATRICES
536 // SPECTRAL MATRICES
535 if (status == RTEMS_SUCCESSFUL) // AVF0
537 if (status == RTEMS_SUCCESSFUL) // AVF0
536 {
538 {
537 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
539 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
538 if (status!=RTEMS_SUCCESSFUL) {
540 if (status!=RTEMS_SUCCESSFUL) {
539 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
541 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
540 }
542 }
541 }
543 }
542 if (status == RTEMS_SUCCESSFUL) // PRC0
544 if (status == RTEMS_SUCCESSFUL) // PRC0
543 {
545 {
544 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
546 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
545 if (status!=RTEMS_SUCCESSFUL) {
547 if (status!=RTEMS_SUCCESSFUL) {
546 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
548 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
547 }
549 }
548 }
550 }
549 if (status == RTEMS_SUCCESSFUL) // AVF1
551 if (status == RTEMS_SUCCESSFUL) // AVF1
550 {
552 {
551 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
553 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
552 if (status!=RTEMS_SUCCESSFUL) {
554 if (status!=RTEMS_SUCCESSFUL) {
553 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
555 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
554 }
556 }
555 }
557 }
556 if (status == RTEMS_SUCCESSFUL) // PRC1
558 if (status == RTEMS_SUCCESSFUL) // PRC1
557 {
559 {
558 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
560 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
559 if (status!=RTEMS_SUCCESSFUL) {
561 if (status!=RTEMS_SUCCESSFUL) {
560 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
562 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
561 }
563 }
562 }
564 }
563 if (status == RTEMS_SUCCESSFUL) // AVF2
565 if (status == RTEMS_SUCCESSFUL) // AVF2
564 {
566 {
565 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
567 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
566 if (status!=RTEMS_SUCCESSFUL) {
568 if (status!=RTEMS_SUCCESSFUL) {
567 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
569 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
568 }
570 }
569 }
571 }
570 if (status == RTEMS_SUCCESSFUL) // PRC2
572 if (status == RTEMS_SUCCESSFUL) // PRC2
571 {
573 {
572 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
574 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
573 if (status!=RTEMS_SUCCESSFUL) {
575 if (status!=RTEMS_SUCCESSFUL) {
574 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
576 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
575 }
577 }
576 }
578 }
577
579
578 //****************
580 //****************
579 // WAVEFORM PICKER
581 // WAVEFORM PICKER
580 if (status == RTEMS_SUCCESSFUL) // WFRM
582 if (status == RTEMS_SUCCESSFUL) // WFRM
581 {
583 {
582 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
584 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
583 if (status!=RTEMS_SUCCESSFUL) {
585 if (status!=RTEMS_SUCCESSFUL) {
584 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
586 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
585 }
587 }
586 }
588 }
587 if (status == RTEMS_SUCCESSFUL) // CWF3
589 if (status == RTEMS_SUCCESSFUL) // CWF3
588 {
590 {
589 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
591 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
590 if (status!=RTEMS_SUCCESSFUL) {
592 if (status!=RTEMS_SUCCESSFUL) {
591 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
593 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
592 }
594 }
593 }
595 }
594 if (status == RTEMS_SUCCESSFUL) // CWF2
596 if (status == RTEMS_SUCCESSFUL) // CWF2
595 {
597 {
596 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
598 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
597 if (status!=RTEMS_SUCCESSFUL) {
599 if (status!=RTEMS_SUCCESSFUL) {
598 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
600 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
599 }
601 }
600 }
602 }
601 if (status == RTEMS_SUCCESSFUL) // CWF1
603 if (status == RTEMS_SUCCESSFUL) // CWF1
602 {
604 {
603 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
605 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
604 if (status!=RTEMS_SUCCESSFUL) {
606 if (status!=RTEMS_SUCCESSFUL) {
605 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
607 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
606 }
608 }
607 }
609 }
608 if (status == RTEMS_SUCCESSFUL) // SWBD
610 if (status == RTEMS_SUCCESSFUL) // SWBD
609 {
611 {
610 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
612 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
611 if (status!=RTEMS_SUCCESSFUL) {
613 if (status!=RTEMS_SUCCESSFUL) {
612 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
614 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
613 }
615 }
614 }
616 }
615
617
616 //*****
618 //*****
617 // MISC
619 // MISC
618 if (status == RTEMS_SUCCESSFUL) // HOUS
620 if (status == RTEMS_SUCCESSFUL) // HOUS
619 {
621 {
620 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
622 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
621 if (status!=RTEMS_SUCCESSFUL) {
623 if (status!=RTEMS_SUCCESSFUL) {
622 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
624 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
623 }
625 }
624 }
626 }
625 if (status == RTEMS_SUCCESSFUL) // DUMB
627 if (status == RTEMS_SUCCESSFUL) // DUMB
626 {
628 {
627 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
629 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
628 if (status!=RTEMS_SUCCESSFUL) {
630 if (status!=RTEMS_SUCCESSFUL) {
629 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
631 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
630 }
632 }
631 }
633 }
632 if (status == RTEMS_SUCCESSFUL) // STAT
634 if (status == RTEMS_SUCCESSFUL) // STAT
633 {
635 {
634 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
636 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
635 if (status!=RTEMS_SUCCESSFUL) {
637 if (status!=RTEMS_SUCCESSFUL) {
636 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
638 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
637 }
639 }
638 }
640 }
639
641
640 return status;
642 return status;
641 }
643 }
642
644
643 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
645 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
644 {
646 {
645 rtems_status_code status_recv;
647 rtems_status_code status_recv;
646 rtems_status_code status_send;
648 rtems_status_code status_send;
647 rtems_status_code status_q_p0;
649 rtems_status_code status_q_p0;
648 rtems_status_code status_q_p1;
650 rtems_status_code status_q_p1;
649 rtems_status_code status_q_p2;
651 rtems_status_code status_q_p2;
650 rtems_status_code ret;
652 rtems_status_code ret;
651 rtems_id queue_id;
653 rtems_id queue_id;
652
654
653 //****************************************
655 //****************************************
654 // create the queue for handling valid TCs
656 // create the queue for handling valid TCs
655 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
657 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
656 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
658 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
657 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
659 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
658 if ( status_recv != RTEMS_SUCCESSFUL ) {
660 if ( status_recv != RTEMS_SUCCESSFUL ) {
659 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
661 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
660 }
662 }
661
663
662 //************************************************
664 //************************************************
663 // create the queue for handling TM packet sending
665 // create the queue for handling TM packet sending
664 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
666 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
665 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
667 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
666 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
668 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
667 if ( status_send != RTEMS_SUCCESSFUL ) {
669 if ( status_send != RTEMS_SUCCESSFUL ) {
668 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
670 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
669 }
671 }
670
672
671 //*****************************************************************************
673 //*****************************************************************************
672 // create the queue for handling averaged spectral matrices for processing @ f0
674 // create the queue for handling averaged spectral matrices for processing @ f0
673 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
675 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
674 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
676 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
675 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
677 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
676 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
678 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
677 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
679 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
678 }
680 }
679
681
680 //*****************************************************************************
682 //*****************************************************************************
681 // create the queue for handling averaged spectral matrices for processing @ f1
683 // create the queue for handling averaged spectral matrices for processing @ f1
682 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
684 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
683 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
685 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
684 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
686 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
685 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
687 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
686 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
688 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
687 }
689 }
688
690
689 //*****************************************************************************
691 //*****************************************************************************
690 // create the queue for handling averaged spectral matrices for processing @ f2
692 // create the queue for handling averaged spectral matrices for processing @ f2
691 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
693 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
692 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
694 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
693 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
695 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
694 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
696 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
695 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
697 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
696 }
698 }
697
699
698 if ( status_recv != RTEMS_SUCCESSFUL )
700 if ( status_recv != RTEMS_SUCCESSFUL )
699 {
701 {
700 ret = status_recv;
702 ret = status_recv;
701 }
703 }
702 else if( status_send != RTEMS_SUCCESSFUL )
704 else if( status_send != RTEMS_SUCCESSFUL )
703 {
705 {
704 ret = status_send;
706 ret = status_send;
705 }
707 }
706 else if( status_q_p0 != RTEMS_SUCCESSFUL )
708 else if( status_q_p0 != RTEMS_SUCCESSFUL )
707 {
709 {
708 ret = status_q_p0;
710 ret = status_q_p0;
709 }
711 }
710 else if( status_q_p1 != RTEMS_SUCCESSFUL )
712 else if( status_q_p1 != RTEMS_SUCCESSFUL )
711 {
713 {
712 ret = status_q_p1;
714 ret = status_q_p1;
713 }
715 }
714 else
716 else
715 {
717 {
716 ret = status_q_p2;
718 ret = status_q_p2;
717 }
719 }
718
720
719 return ret;
721 return ret;
720 }
722 }
721
723
722 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
724 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
723 {
725 {
724 rtems_status_code status;
726 rtems_status_code status;
725 rtems_name queue_name;
727 rtems_name queue_name;
726
728
727 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
729 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
728
730
729 status = rtems_message_queue_ident( queue_name, 0, queue_id );
731 status = rtems_message_queue_ident( queue_name, 0, queue_id );
730
732
731 return status;
733 return status;
732 }
734 }
733
735
734 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
736 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
735 {
737 {
736 rtems_status_code status;
738 rtems_status_code status;
737 rtems_name queue_name;
739 rtems_name queue_name;
738
740
739 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
741 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
740
742
741 status = rtems_message_queue_ident( queue_name, 0, queue_id );
743 status = rtems_message_queue_ident( queue_name, 0, queue_id );
742
744
743 return status;
745 return status;
744 }
746 }
745
747
746 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
748 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
747 {
749 {
748 rtems_status_code status;
750 rtems_status_code status;
749 rtems_name queue_name;
751 rtems_name queue_name;
750
752
751 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
753 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
752
754
753 status = rtems_message_queue_ident( queue_name, 0, queue_id );
755 status = rtems_message_queue_ident( queue_name, 0, queue_id );
754
756
755 return status;
757 return status;
756 }
758 }
757
759
758 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
760 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
759 {
761 {
760 rtems_status_code status;
762 rtems_status_code status;
761 rtems_name queue_name;
763 rtems_name queue_name;
762
764
763 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
765 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
764
766
765 status = rtems_message_queue_ident( queue_name, 0, queue_id );
767 status = rtems_message_queue_ident( queue_name, 0, queue_id );
766
768
767 return status;
769 return status;
768 }
770 }
769
771
770 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
772 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
771 {
773 {
772 rtems_status_code status;
774 rtems_status_code status;
773 rtems_name queue_name;
775 rtems_name queue_name;
774
776
775 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
777 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
776
778
777 status = rtems_message_queue_ident( queue_name, 0, queue_id );
779 status = rtems_message_queue_ident( queue_name, 0, queue_id );
778
780
779 return status;
781 return status;
780 }
782 }
@@ -1,586 +1,615
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 increment_seq_counter( housekeeping_packet.packetSequenceControl );
214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterHK >> 8;
215 housekeeping_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterHK;
216 increment_seq_counter( &sequenceCounterHK );
217
215 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);
216 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);
217 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);
218 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
221 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
219 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);
220 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
223 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
221
224
222 spacewire_update_statistics();
225 spacewire_update_statistics();
223
226
224 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 );
225 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
228 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
226
229
227 // SEND PACKET
230 // SEND PACKET
228 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
231 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
229 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);
230 if (status != RTEMS_SUCCESSFUL) {
233 if (status != RTEMS_SUCCESSFUL) {
231 PRINTF1("in HOUS *** ERR send: %d\n", status)
234 PRINTF1("in HOUS *** ERR send: %d\n", status)
232 }
235 }
233 }
236 }
234 }
237 }
235
238
236 PRINTF("in HOUS *** deleting task\n")
239 PRINTF("in HOUS *** deleting task\n")
237
240
238 status = rtems_task_delete( RTEMS_SELF ); // should not return
241 status = rtems_task_delete( RTEMS_SELF ); // should not return
239 printf( "rtems_task_delete returned with status of %d.\n", status );
242 printf( "rtems_task_delete returned with status of %d.\n", status );
240 return;
243 return;
241 }
244 }
242
245
243 rtems_task dumb_task( rtems_task_argument unused )
246 rtems_task dumb_task( rtems_task_argument unused )
244 {
247 {
245 /** 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.
246 *
249 *
247 * @param unused is the starting argument of the RTEMS task
250 * @param unused is the starting argument of the RTEMS task
248 *
251 *
249 * 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.
250 *
253 *
251 */
254 */
252
255
253 unsigned int i;
256 unsigned int i;
254 unsigned int intEventOut;
257 unsigned int intEventOut;
255 unsigned int coarse_time = 0;
258 unsigned int coarse_time = 0;
256 unsigned int fine_time = 0;
259 unsigned int fine_time = 0;
257 rtems_event_set event_out;
260 rtems_event_set event_out;
258
261
259 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
262 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
260 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
261 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
262 "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
263 "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
264 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
265 "ERR HK", // RTEMS_EVENT_6
268 "ERR HK", // RTEMS_EVENT_6
266 "ready for dump", // RTEMS_EVENT_7
269 "ready for dump", // RTEMS_EVENT_7
267 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
270 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
268 "tick" // RTEMS_EVENT_9
271 "tick" // RTEMS_EVENT_9
269 };
272 };
270
273
271 BOOT_PRINTF("in DUMB *** \n")
274 BOOT_PRINTF("in DUMB *** \n")
272
275
273 while(1){
276 while(1){
274 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
277 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
275 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
278 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
276 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
279 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
277 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
280 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
278 intEventOut = (unsigned int) event_out;
281 intEventOut = (unsigned int) event_out;
279 for ( i=0; i<32; i++)
282 for ( i=0; i<32; i++)
280 {
283 {
281 if ( ((intEventOut >> i) & 0x0001) != 0)
284 if ( ((intEventOut >> i) & 0x0001) != 0)
282 {
285 {
283 coarse_time = time_management_regs->coarse_time;
286 coarse_time = time_management_regs->coarse_time;
284 fine_time = time_management_regs->fine_time;
287 fine_time = time_management_regs->fine_time;
285 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
288 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
286 if (i==8)
289 if (i==8)
287 {
290 {
288 PRINTF1("status = %x\n", spectral_matrix_regs->status)
291 PRINTF1("status = %x\n", spectral_matrix_regs->status)
289 }
292 }
290 }
293 }
291 }
294 }
292 }
295 }
293 }
296 }
294
297
295 //*****************************
298 //*****************************
296 // init housekeeping parameters
299 // init housekeeping parameters
297
300
298 void init_housekeeping_parameters( void )
301 void init_housekeeping_parameters( void )
299 {
302 {
300 /** This function initialize the housekeeping_packet global variable with default values.
303 /** This function initialize the housekeeping_packet global variable with default values.
301 *
304 *
302 */
305 */
303
306
304 unsigned int i = 0;
307 unsigned int i = 0;
305 unsigned char *parameters;
308 unsigned char *parameters;
306
309
307 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
310 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
308 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
311 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
309 {
312 {
310 parameters[i] = 0x00;
313 parameters[i] = 0x00;
311 }
314 }
312 // init status word
315 // init status word
313 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
316 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
314 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
317 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
315 // init software version
318 // init software version
316 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
319 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
317 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
320 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
318 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
321 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
319 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
322 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
320 // init fpga version
323 // init fpga version
321 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
324 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
322 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
325 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
323 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
326 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
324 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
327 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
325 }
328 }
326
329
327 void increment_seq_counter( unsigned char *packet_sequence_control)
330 void increment_seq_counter_old( unsigned char *packet_sequence_control)
328 {
331 {
329 /** This function increment the sequence counter psased in argument.
332 /** This function increment the sequence counter psased in argument.
330 *
333 *
331 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
334 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
332 *
335 *
333 */
336 */
334
337
335 unsigned short sequence_cnt;
338 unsigned short sequence_cnt;
336 unsigned short segmentation_grouping_flag;
339 unsigned short segmentation_grouping_flag;
337 unsigned short new_packet_sequence_control;
340 unsigned short new_packet_sequence_control;
338
341
339 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
342 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
340 sequence_cnt = (unsigned short) (
343 sequence_cnt = (unsigned short) (
341 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
344 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
342 + packet_sequence_control[1]
345 + packet_sequence_control[1]
343 );
346 );
344
347
345 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
348 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
346
349
347 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
350 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
348 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
351 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
349
352
350 if ( sequence_cnt < SEQ_CNT_MAX)
353 if ( sequence_cnt < SEQ_CNT_MAX)
351 {
354 {
352 sequence_cnt = sequence_cnt + 1;
355 sequence_cnt = sequence_cnt + 1;
353 }
356 }
354 else
357 else
355 {
358 {
356 sequence_cnt = 0;
359 sequence_cnt = 0;
357 }
360 }
358 }
361 }
359
362
363 void increment_seq_counter( unsigned short *packetSequenceControl )
364 {
365 /** This function increment the sequence counter psased in argument.
366 *
367 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
368 *
369 */
370
371 unsigned short sequence_cnt;
372 unsigned short segmentation_grouping_flag;
373
374 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
375 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
376
377 if ( sequence_cnt < SEQ_CNT_MAX)
378 {
379 sequence_cnt = sequence_cnt + 1;
380 }
381 else
382 {
383 sequence_cnt = 0;
384 }
385
386 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
387 }
388
360 void getTime( unsigned char *time)
389 void getTime( unsigned char *time)
361 {
390 {
362 /** This function write the current local time in the time buffer passed in argument.
391 /** This function write the current local time in the time buffer passed in argument.
363 *
392 *
364 */
393 */
365
394
366 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
395 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
367 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
396 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
368 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
397 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
369 time[3] = (unsigned char) (time_management_regs->coarse_time);
398 time[3] = (unsigned char) (time_management_regs->coarse_time);
370 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
399 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
371 time[5] = (unsigned char) (time_management_regs->fine_time);
400 time[5] = (unsigned char) (time_management_regs->fine_time);
372 }
401 }
373
402
374 unsigned long long int getTimeAsUnsignedLongLongInt( )
403 unsigned long long int getTimeAsUnsignedLongLongInt( )
375 {
404 {
376 /** This function write the current local time in the time buffer passed in argument.
405 /** This function write the current local time in the time buffer passed in argument.
377 *
406 *
378 */
407 */
379 unsigned long long int time;
408 unsigned long long int time;
380
409
381 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
410 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
382 + time_management_regs->fine_time;
411 + time_management_regs->fine_time;
383
412
384 return time;
413 return time;
385 }
414 }
386
415
387 void send_dumb_hk( void )
416 void send_dumb_hk( void )
388 {
417 {
389 Packet_TM_LFR_HK_t dummy_hk_packet;
418 Packet_TM_LFR_HK_t dummy_hk_packet;
390 unsigned char *parameters;
419 unsigned char *parameters;
391 unsigned int i;
420 unsigned int i;
392 rtems_id queue_id;
421 rtems_id queue_id;
393
422
394 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
423 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
395 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
424 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
396 dummy_hk_packet.reserved = DEFAULT_RESERVED;
425 dummy_hk_packet.reserved = DEFAULT_RESERVED;
397 dummy_hk_packet.userApplication = CCSDS_USER_APP;
426 dummy_hk_packet.userApplication = CCSDS_USER_APP;
398 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
427 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
399 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
428 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
400 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
429 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
401 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
430 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
402 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
431 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
403 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
432 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
404 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
433 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
405 dummy_hk_packet.serviceType = TM_TYPE_HK;
434 dummy_hk_packet.serviceType = TM_TYPE_HK;
406 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
435 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
407 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
436 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
408 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
437 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
409 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
438 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
410 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
439 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
411 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
440 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
412 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
441 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
413 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
442 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
414 dummy_hk_packet.sid = SID_HK;
443 dummy_hk_packet.sid = SID_HK;
415
444
416 // init status word
445 // init status word
417 dummy_hk_packet.lfr_status_word[0] = 0xff;
446 dummy_hk_packet.lfr_status_word[0] = 0xff;
418 dummy_hk_packet.lfr_status_word[1] = 0xff;
447 dummy_hk_packet.lfr_status_word[1] = 0xff;
419 // init software version
448 // init software version
420 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
449 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
421 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
450 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
422 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
451 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
423 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
452 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
424 // init fpga version
453 // init fpga version
425 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
454 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
426 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
455 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
427 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
456 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
428 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
457 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
429
458
430 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
459 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
431
460
432 for (i=0; i<100; i++)
461 for (i=0; i<100; i++)
433 {
462 {
434 parameters[i] = 0xff;
463 parameters[i] = 0xff;
435 }
464 }
436
465
437 get_message_queue_id_send( &queue_id );
466 get_message_queue_id_send( &queue_id );
438
467
439 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
468 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
440 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
469 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
441 }
470 }
442
471
443 void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential )
472 void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential )
444 {
473 {
445 unsigned int coarseTime;
474 unsigned int coarseTime;
446 unsigned int acquisitionTime;
475 unsigned int acquisitionTime;
447 unsigned int deltaT = 0;
476 unsigned int deltaT = 0;
448 unsigned char *bufferPtr;
477 unsigned char *bufferPtr;
449
478
450 unsigned int offset_in_samples;
479 unsigned int offset_in_samples;
451 unsigned int offset_in_bytes;
480 unsigned int offset_in_bytes;
452 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
481 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
453
482
454 if (lfrCurrentMode == LFR_MODE_STANDBY)
483 if (lfrCurrentMode == LFR_MODE_STANDBY)
455 {
484 {
456 spacecraft_potential[0] = 0x00;
485 spacecraft_potential[0] = 0x00;
457 spacecraft_potential[1] = 0x00;
486 spacecraft_potential[1] = 0x00;
458 spacecraft_potential[2] = 0x00;
487 spacecraft_potential[2] = 0x00;
459 spacecraft_potential[3] = 0x00;
488 spacecraft_potential[3] = 0x00;
460 spacecraft_potential[4] = 0x00;
489 spacecraft_potential[4] = 0x00;
461 spacecraft_potential[5] = 0x00;
490 spacecraft_potential[5] = 0x00;
462 }
491 }
463 else
492 else
464 {
493 {
465 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
494 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
466 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
495 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
467 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
496 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
468 + (unsigned int) ( bufferPtr[3] << 16 )
497 + (unsigned int) ( bufferPtr[3] << 16 )
469 + (unsigned int) ( bufferPtr[0] << 8 )
498 + (unsigned int) ( bufferPtr[0] << 8 )
470 + (unsigned int) ( bufferPtr[1] );
499 + (unsigned int) ( bufferPtr[1] );
471 if ( coarseTime > acquisitionTime )
500 if ( coarseTime > acquisitionTime )
472 {
501 {
473 deltaT = coarseTime - acquisitionTime;
502 deltaT = coarseTime - acquisitionTime;
474 offset_in_samples = (deltaT-1) * f3 ;
503 offset_in_samples = (deltaT-1) * f3 ;
475 }
504 }
476 else if( coarseTime == acquisitionTime )
505 else if( coarseTime == acquisitionTime )
477 {
506 {
478 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
507 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
479 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
508 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
480 }
509 }
481 else
510 else
482 {
511 {
483 offset_in_samples = 0;
512 offset_in_samples = 0;
484 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
513 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
485 }
514 }
486
515
487 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
516 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
488 {
517 {
489 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
518 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
490 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
519 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
491 }
520 }
492 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
521 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
493 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
522 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
494 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
523 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
495 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
524 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
496 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
525 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
497 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
526 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
498 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
527 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
499 }
528 }
500 }
529 }
501
530
502 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
531 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
503 {
532 {
504 unsigned int coarseTime;
533 unsigned int coarseTime;
505 unsigned int acquisitionTime;
534 unsigned int acquisitionTime;
506 unsigned int deltaT = 0;
535 unsigned int deltaT = 0;
507 unsigned char *bufferPtr;
536 unsigned char *bufferPtr;
508
537
509 unsigned int offset_in_samples;
538 unsigned int offset_in_samples;
510 unsigned int offset_in_bytes;
539 unsigned int offset_in_bytes;
511 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
540 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
512
541
513 if (lfrCurrentMode == LFR_MODE_STANDBY)
542 if (lfrCurrentMode == LFR_MODE_STANDBY)
514 {
543 {
515 spacecraft_potential[0] = 0x00;
544 spacecraft_potential[0] = 0x00;
516 spacecraft_potential[1] = 0x00;
545 spacecraft_potential[1] = 0x00;
517 spacecraft_potential[2] = 0x00;
546 spacecraft_potential[2] = 0x00;
518 spacecraft_potential[3] = 0x00;
547 spacecraft_potential[3] = 0x00;
519 spacecraft_potential[4] = 0x00;
548 spacecraft_potential[4] = 0x00;
520 spacecraft_potential[5] = 0x00;
549 spacecraft_potential[5] = 0x00;
521 }
550 }
522 else
551 else
523 {
552 {
524 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
553 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
525 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
554 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
526 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
555 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
527 + (unsigned int) ( bufferPtr[1] << 16 )
556 + (unsigned int) ( bufferPtr[1] << 16 )
528 + (unsigned int) ( bufferPtr[2] << 8 )
557 + (unsigned int) ( bufferPtr[2] << 8 )
529 + (unsigned int) ( bufferPtr[3] );
558 + (unsigned int) ( bufferPtr[3] );
530 if ( coarseTime > acquisitionTime )
559 if ( coarseTime > acquisitionTime )
531 {
560 {
532 deltaT = coarseTime - acquisitionTime;
561 deltaT = coarseTime - acquisitionTime;
533 offset_in_samples = (deltaT-1) * f3 ;
562 offset_in_samples = (deltaT-1) * f3 ;
534 }
563 }
535 else if( coarseTime == acquisitionTime )
564 else if( coarseTime == acquisitionTime )
536 {
565 {
537 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
566 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
538 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
567 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
539 }
568 }
540 else
569 else
541 {
570 {
542 offset_in_samples = 0;
571 offset_in_samples = 0;
543 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
572 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
544 }
573 }
545
574
546 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
575 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
547 {
576 {
548 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
577 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
549 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
578 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
550 }
579 }
551 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
580 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
552 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
581 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
553 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
582 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
554 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
583 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
555 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
584 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
556 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
585 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
557 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
586 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
558 }
587 }
559 }
588 }
560
589
561 void get_cpu_load( unsigned char *resource_statistics )
590 void get_cpu_load( unsigned char *resource_statistics )
562 {
591 {
563 unsigned char cpu_load;
592 unsigned char cpu_load;
564
593
565 cpu_load = lfr_rtems_cpu_usage_report();
594 cpu_load = lfr_rtems_cpu_usage_report();
566
595
567 // HK_LFR_CPU_LOAD
596 // HK_LFR_CPU_LOAD
568 resource_statistics[0] = cpu_load;
597 resource_statistics[0] = cpu_load;
569
598
570 // HK_LFR_CPU_LOAD_MAX
599 // HK_LFR_CPU_LOAD_MAX
571 if (cpu_load > resource_statistics[1])
600 if (cpu_load > resource_statistics[1])
572 {
601 {
573 resource_statistics[1] = cpu_load;
602 resource_statistics[1] = cpu_load;
574 }
603 }
575
604
576 // CPU_LOAD_AVE
605 // CPU_LOAD_AVE
577 resource_statistics[2] = 0;
606 resource_statistics[2] = 0;
578
607
579 #ifndef PRINT_TASK_STATISTICS
608 #ifndef PRINT_TASK_STATISTICS
580 rtems_cpu_usage_reset();
609 rtems_cpu_usage_reset();
581 #endif
610 #endif
582
611
583 }
612 }
584
613
585
614
586
615
@@ -1,371 +1,379
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "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 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
70 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++ )
71 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
72 {
72 {
73 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
73 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;
74 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
75 }
75 }
76
76
77 // compute the average and store it in the averaged_sm_f1 buffer
77 // compute the average and store it in the averaged_sm_f1 buffer
78 SM_average( current_ring_node_asm_norm_f0->matrix,
78 SM_average( current_ring_node_asm_norm_f0->matrix,
79 current_ring_node_asm_burst_sbm_f0->matrix,
79 current_ring_node_asm_burst_sbm_f0->matrix,
80 ring_node_tab,
80 ring_node_tab,
81 nb_norm_bp1, nb_sbm_bp1 );
81 nb_norm_bp1, nb_sbm_bp1 );
82
82
83 // update nb_average
83 // update nb_average
84 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
84 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
85 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
85 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
86 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
86 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
89
89
90 //****************************************
90 //****************************************
91 // initialize the mesage for the MATR task
91 // initialize the mesage for the MATR task
92 msgForMATR.event = 0x00; // this composite event will be sent to 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;
93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
94 msgForMATR.norm = current_ring_node_asm_norm_f0;
94 msgForMATR.norm = current_ring_node_asm_norm_f0;
95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
97 msgForMATR.coarseTime = time_management_regs->coarse_time;
97 msgForMATR.coarseTime = time_management_regs->coarse_time;
98 msgForMATR.fineTime = time_management_regs->fine_time;
98 msgForMATR.fineTime = time_management_regs->fine_time;
99
99
100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 {
101 {
102 nb_sbm_bp1 = 0;
102 nb_sbm_bp1 = 0;
103 // set another ring for the ASM storage
103 // set another ring for the ASM storage
104 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
104 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
105 if ( (lfrCurrentMode == LFR_MODE_BURST)
105 if ( lfrCurrentMode == LFR_MODE_BURST )
106 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
107 {
106 {
108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
107 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
108 }
109 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
110 {
111 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
109 }
112 }
110 }
113 }
111
114
112 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
115 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
113 {
116 {
114 nb_sbm_bp2 = 0;
117 nb_sbm_bp2 = 0;
115 if ( (lfrCurrentMode == LFR_MODE_BURST)
118 if ( lfrCurrentMode == LFR_MODE_BURST )
116 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
117 {
119 {
118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
120 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
121 }
122 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
123 {
124 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
119 }
125 }
120 }
126 }
121
127
122 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
128 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
123 {
129 {
124 nb_norm_bp1 = 0;
130 nb_norm_bp1 = 0;
125 // set another ring for the ASM storage
131 // set another ring for the ASM storage
126 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
132 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
127 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
133 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
128 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
134 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
129 {
135 {
130 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
136 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
131 }
137 }
132 }
138 }
133
139
134 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
140 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
135 {
141 {
136 nb_norm_bp2 = 0;
142 nb_norm_bp2 = 0;
137 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
143 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
138 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
144 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
139 {
145 {
140 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
146 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
141 }
147 }
142 }
148 }
143
149
144 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
150 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
145 {
151 {
146 nb_norm_asm = 0;
152 nb_norm_asm = 0;
147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
153 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
154 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 {
155 {
150 // PRINTF1("%lld\n", localTime)
156 // PRINTF1("%lld\n", localTime)
151 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
157 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
152 }
158 }
153 }
159 }
154
160
155 //*************************
161 //*************************
156 // send the message to MATR
162 // send the message to MATR
157 if (msgForMATR.event != 0x00)
163 if (msgForMATR.event != 0x00)
158 {
164 {
159 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
165 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
160 }
166 }
161
167
162 if (status != RTEMS_SUCCESSFUL) {
168 if (status != RTEMS_SUCCESSFUL) {
163 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
169 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
164 }
170 }
165 }
171 }
166 }
172 }
167
173
168 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
174 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
169 {
175 {
170 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
176 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
171 size_t size; // size of the incoming TC packet
177 size_t size; // size of the incoming TC packet
172 asm_msg *incomingMsg;
178 asm_msg *incomingMsg;
173 //
179 //
180 unsigned char sid;
174 spw_ioctl_pkt_send spw_ioctl_send_ASM;
181 spw_ioctl_pkt_send spw_ioctl_send_ASM;
175 rtems_status_code status;
182 rtems_status_code status;
176 rtems_id queue_id;
183 rtems_id queue_id;
177 rtems_id queue_id_q_p0;
184 rtems_id queue_id_q_p0;
178 Header_TM_LFR_SCIENCE_ASM_t headerASM;
185 Header_TM_LFR_SCIENCE_ASM_t headerASM;
179 bp_packet_with_spare packet_norm_bp1_f0;
186 bp_packet_with_spare packet_norm_bp1_f0;
180 bp_packet packet_norm_bp2_f0;
187 bp_packet packet_norm_bp2_f0;
181 bp_packet packet_sbm_bp1_f0;
188 bp_packet packet_sbm_bp1_f0;
182 bp_packet packet_sbm_bp2_f0;
189 bp_packet packet_sbm_bp2_f0;
183
190
184 unsigned long long int localTime;
191 unsigned long long int localTime;
185
192
186 ASM_init_header( &headerASM );
193 ASM_init_header( &headerASM );
187
194
188 //*************
195 //*************
189 // NORM headers
196 // NORM headers
190 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
197 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
191 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
198 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
192 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
199 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
193 BP_init_header( &packet_norm_bp2_f0.header,
200 BP_init_header( &packet_norm_bp2_f0.header,
194 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
201 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
195 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
202 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
196
203
197 //****************************
204 //****************************
198 // BURST SBM1 and SBM2 headers
205 // BURST SBM1 and SBM2 headers
199 if ( lfrRequestedMode == LFR_MODE_BURST )
206 if ( lfrRequestedMode == LFR_MODE_BURST )
200 {
207 {
201 BP_init_header( &packet_sbm_bp1_f0.header,
208 BP_init_header( &packet_sbm_bp1_f0.header,
202 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
209 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
203 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
210 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
204 BP_init_header( &packet_sbm_bp2_f0.header,
211 BP_init_header( &packet_sbm_bp2_f0.header,
205 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
212 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
213 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
207 }
214 }
208 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
215 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
209 {
216 {
210 BP_init_header( &packet_sbm_bp1_f0.header,
217 BP_init_header( &packet_sbm_bp1_f0.header,
211 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
218 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
212 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
219 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
213 BP_init_header( &packet_sbm_bp2_f0.header,
220 BP_init_header( &packet_sbm_bp2_f0.header,
214 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
221 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
216 }
223 }
217 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
224 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
218 {
225 {
219 BP_init_header( &packet_sbm_bp1_f0.header,
226 BP_init_header( &packet_sbm_bp1_f0.header,
220 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
227 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
221 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
228 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
222 BP_init_header( &packet_sbm_bp2_f0.header,
229 BP_init_header( &packet_sbm_bp2_f0.header,
223 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
224 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
225 }
232 }
226 else
233 else
227 {
234 {
228 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
235 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
229 }
236 }
230
237
231 status = get_message_queue_id_send( &queue_id );
238 status = get_message_queue_id_send( &queue_id );
232 if (status != RTEMS_SUCCESSFUL)
239 if (status != RTEMS_SUCCESSFUL)
233 {
240 {
234 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
241 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
235 }
242 }
236 status = get_message_queue_id_prc0( &queue_id_q_p0);
243 status = get_message_queue_id_prc0( &queue_id_q_p0);
237 if (status != RTEMS_SUCCESSFUL)
244 if (status != RTEMS_SUCCESSFUL)
238 {
245 {
239 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
246 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
240 }
247 }
241
248
242 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
249 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
243
250
244 while(1){
251 while(1){
245 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
252 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
246 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
253 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
247
254
248 incomingMsg = (asm_msg*) incomingData;
255 incomingMsg = (asm_msg*) incomingData;
249
256
250 localTime = getTimeAsUnsignedLongLongInt( );
257 localTime = getTimeAsUnsignedLongLongInt( );
251
258
252 //****************
259 //****************
253 //****************
260 //****************
254 // BURST SBM1 SBM2
261 // BURST SBM1 SBM2
255 //****************
262 //****************
256 //****************
263 //****************
257 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
264 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
258 {
265 {
266 sid = getSID( incomingMsg->event );
259 // 1) compress the matrix for Basic Parameters calculation
267 // 1) compress the matrix for Basic Parameters calculation
260 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
268 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
261 nb_sm_before_f0.burst_sbm_bp1,
269 nb_sm_before_f0.burst_sbm_bp1,
262 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
270 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
263 ASM_F0_INDICE_START);
271 ASM_F0_INDICE_START);
264 // 2) compute the BP1 set
272 // 2) compute the BP1 set
265 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
273 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
266 // 3) send the BP1 set
274 // 3) send the BP1 set
267 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
275 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
268 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
276 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
269 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
277 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
270 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
278 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
271 SID_SBM1_BP1_F0);
279 sid);
272 // 4) compute the BP2 set if needed
280 // 4) compute the BP2 set if needed
273 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
281 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
274 {
282 {
275 // 1) compute the BP2 set
283 // 1) compute the BP2 set
276
284
277 // 2) send the BP2 set
285 // 2) send the BP2 set
278 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
286 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
279 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
287 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
280 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
288 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
281 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
282 SID_SBM1_BP2_F0);
290 sid);
283 }
291 }
284 }
292 }
285
293
286 //*****
294 //*****
287 //*****
295 //*****
288 // NORM
296 // NORM
289 //*****
297 //*****
290 //*****
298 //*****
291 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
299 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
292 {
300 {
293 // 1) compress the matrix for Basic Parameters calculation
301 // 1) compress the matrix for Basic Parameters calculation
294 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
302 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
295 nb_sm_before_f0.norm_bp1,
303 nb_sm_before_f0.norm_bp1,
296 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
304 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
297 ASM_F0_INDICE_START );
305 ASM_F0_INDICE_START );
298 // 2) compute the BP1 set
306 // 2) compute the BP1 set
299 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
307 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
300 // 3) send the BP1 set
308 // 3) send the BP1 set
301 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
309 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
302 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
310 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
303 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
311 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
304 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
312 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
305 SID_NORM_BP1_F0 );
313 SID_NORM_BP1_F0 );
306 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
314 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
307 {
315 {
308 // 1) compute the BP2 set using the same ASM as the one used for BP1
316 // 1) compute the BP2 set using the same ASM as the one used for BP1
309
317
310 // 2) send the BP2 set
318 // 2) send the BP2 set
311 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
319 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
312 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
320 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
313 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
321 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
314 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
322 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
315 SID_NORM_BP2_F0);
323 SID_NORM_BP2_F0);
316 }
324 }
317 }
325 }
318
326
319 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
327 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
320 {
328 {
321 // 1) reorganize the ASM and divide
329 // 1) reorganize the ASM and divide
322 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
330 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
323 asm_f0_reorganized,
331 asm_f0_reorganized,
324 nb_sm_before_f0.norm_bp1 );
332 nb_sm_before_f0.norm_bp1 );
325 // 2) convert the float array in a char array
333 // 2) convert the float array in a char array
326 ASM_convert( asm_f0_reorganized, asm_f0_char);
334 ASM_convert( asm_f0_reorganized, asm_f0_char);
327 // 3) send the spectral matrix packets
335 // 3) send the spectral matrix packets
328 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
336 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
329 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
337 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
330 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
338 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
331 }
339 }
332
340
333 }
341 }
334 }
342 }
335
343
336 //**********
344 //**********
337 // FUNCTIONS
345 // FUNCTIONS
338
346
339 void reset_nb_sm_f0( unsigned char lfrMode )
347 void reset_nb_sm_f0( unsigned char lfrMode )
340 {
348 {
341 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
349 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
342 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
350 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
343 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;
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;
344 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
352 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
345 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
353 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
346 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
354 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
347 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
355 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
348 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
356 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
349 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
357 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
350
358
351 if (lfrMode == LFR_MODE_SBM1)
359 if (lfrMode == LFR_MODE_SBM1)
352 {
360 {
353 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
361 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
354 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
362 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
355 }
363 }
356 else if (lfrMode == LFR_MODE_SBM2)
364 else if (lfrMode == LFR_MODE_SBM2)
357 {
365 {
358 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
366 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
359 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
367 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
360 }
368 }
361 else if (lfrMode == LFR_MODE_BURST)
369 else if (lfrMode == LFR_MODE_BURST)
362 {
370 {
363 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
371 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
364 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
372 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
365 }
373 }
366 else
374 else
367 {
375 {
368 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
376 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
369 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
377 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
370 }
378 }
371 }
379 }
@@ -1,349 +1,359
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 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
67 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++ )
68 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
69 {
69 {
70 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
70 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;
71 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
72 }
72 }
73
73
74 // compute the average and store it in the averaged_sm_f1 buffer
74 // compute the average and store it in the averaged_sm_f1 buffer
75 SM_average( current_ring_node_asm_norm_f1->matrix,
75 SM_average( current_ring_node_asm_norm_f1->matrix,
76 current_ring_node_asm_burst_sbm_f1->matrix,
76 current_ring_node_asm_burst_sbm_f1->matrix,
77 ring_node_tab,
77 ring_node_tab,
78 nb_norm_bp1, nb_sbm_bp1 );
78 nb_norm_bp1, nb_sbm_bp1 );
79
79
80 // update nb_average
80 // update nb_average
81 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
81 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
82 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
82 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
83 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
83 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
84 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
84 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
85 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
85 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
86
86
87 //****************************************
87 //****************************************
88 // initialize the mesage for the MATR task
88 // initialize the mesage for the MATR task
89 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 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;
90 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
91 msgForMATR.norm = current_ring_node_asm_norm_f1;
91 msgForMATR.norm = current_ring_node_asm_norm_f1;
92 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
92 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
93 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
93 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
94 msgForMATR.coarseTime = time_management_regs->coarse_time;
94 msgForMATR.coarseTime = time_management_regs->coarse_time;
95 msgForMATR.fineTime = time_management_regs->fine_time;
95 msgForMATR.fineTime = time_management_regs->fine_time;
96
96
97 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
97 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 {
98 {
99 nb_sbm_bp1 = 0;
99 nb_sbm_bp1 = 0;
100 // set another ring for the ASM storage
100 // set another ring for the ASM storage
101 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
101 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
102 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
102 if ( lfrCurrentMode == LFR_MODE_BURST )
103 {
103 {
104 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
104 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
105 }
106 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
107 {
108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
105 }
109 }
106 }
110 }
107
111
108 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
112 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
109 {
113 {
110 nb_sbm_bp2 = 0;
114 nb_sbm_bp2 = 0;
111 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
115 if ( lfrCurrentMode == LFR_MODE_BURST )
112 {
116 {
113 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
117 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
118 }
119 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
120 {
121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
114 }
122 }
115 }
123 }
116
124
117 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
125 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
118 {
126 {
119 nb_norm_bp1 = 0;
127 nb_norm_bp1 = 0;
120 // set another ring for the ASM storage
128 // set another ring for the ASM storage
121 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
129 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
122 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
130 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
123 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
131 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
124 {
132 {
125 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
133 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
126 }
134 }
127 }
135 }
128
136
129 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
137 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
130 {
138 {
131 nb_norm_bp2 = 0;
139 nb_norm_bp2 = 0;
132 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
140 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
133 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
141 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
134 {
142 {
135 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
143 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
136 }
144 }
137 }
145 }
138
146
139 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
147 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
140 {
148 {
141 nb_norm_asm = 0;
149 nb_norm_asm = 0;
142 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
150 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
143 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
151 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
144 {
152 {
145 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
153 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
146 }
154 }
147 }
155 }
148
156
149 //*************************
157 //*************************
150 // send the message to MATR
158 // send the message to MATR
151 if (msgForMATR.event != 0x00)
159 if (msgForMATR.event != 0x00)
152 {
160 {
153 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
161 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
154 }
162 }
155
163
156 if (status != RTEMS_SUCCESSFUL) {
164 if (status != RTEMS_SUCCESSFUL) {
157 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
165 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
158 }
166 }
159 }
167 }
160 }
168 }
161
169
162 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
170 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
163 {
171 {
164 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
172 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
165 size_t size; // size of the incoming TC packet
173 size_t size; // size of the incoming TC packet
166 asm_msg *incomingMsg;
174 asm_msg *incomingMsg;
167 //
175 //
176 unsigned char sid;
168 spw_ioctl_pkt_send spw_ioctl_send_ASM;
177 spw_ioctl_pkt_send spw_ioctl_send_ASM;
169 rtems_status_code status;
178 rtems_status_code status;
170 rtems_id queue_id_send;
179 rtems_id queue_id_send;
171 rtems_id queue_id_q_p1;
180 rtems_id queue_id_q_p1;
172 Header_TM_LFR_SCIENCE_ASM_t headerASM;
181 Header_TM_LFR_SCIENCE_ASM_t headerASM;
173 bp_packet_with_spare packet_norm_bp1;
182 bp_packet_with_spare packet_norm_bp1;
174 bp_packet packet_norm_bp2;
183 bp_packet packet_norm_bp2;
175 bp_packet packet_sbm_bp1;
184 bp_packet packet_sbm_bp1;
176 bp_packet packet_sbm_bp2;
185 bp_packet packet_sbm_bp2;
177
186
178 unsigned long long int localTime;
187 unsigned long long int localTime;
179
188
180 ASM_init_header( &headerASM );
189 ASM_init_header( &headerASM );
181
190
182 //*************
191 //*************
183 // NORM headers
192 // NORM headers
184 BP_init_header_with_spare( &packet_norm_bp1.header,
193 BP_init_header_with_spare( &packet_norm_bp1.header,
185 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
194 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
186 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
195 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
187 BP_init_header( &packet_norm_bp2.header,
196 BP_init_header( &packet_norm_bp2.header,
188 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
197 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
189 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
198 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
190
199
191 //***********************
200 //***********************
192 // BURST and SBM2 headers
201 // BURST and SBM2 headers
193 if ( lfrRequestedMode == LFR_MODE_BURST )
202 if ( lfrRequestedMode == LFR_MODE_BURST )
194 {
203 {
195 BP_init_header( &packet_sbm_bp1.header,
204 BP_init_header( &packet_sbm_bp1.header,
196 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
205 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
197 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
198 BP_init_header( &packet_sbm_bp2.header,
207 BP_init_header( &packet_sbm_bp2.header,
199 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
208 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
200 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
209 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
201 }
210 }
202 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
211 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
203 {
212 {
204 BP_init_header( &packet_sbm_bp1.header,
213 BP_init_header( &packet_sbm_bp1.header,
205 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
214 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
207 BP_init_header( &packet_sbm_bp2.header,
216 BP_init_header( &packet_sbm_bp2.header,
208 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
217 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
209 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
218 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
210 }
219 }
211 else
220 else
212 {
221 {
213 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
222 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
214 }
223 }
215
224
216 status = get_message_queue_id_send( &queue_id_send );
225 status = get_message_queue_id_send( &queue_id_send );
217 if (status != RTEMS_SUCCESSFUL)
226 if (status != RTEMS_SUCCESSFUL)
218 {
227 {
219 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
228 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
220 }
229 }
221 status = get_message_queue_id_prc1( &queue_id_q_p1);
230 status = get_message_queue_id_prc1( &queue_id_q_p1);
222 if (status != RTEMS_SUCCESSFUL)
231 if (status != RTEMS_SUCCESSFUL)
223 {
232 {
224 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
233 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
225 }
234 }
226
235
227 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
236 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
228
237
229 while(1){
238 while(1){
230 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
239 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
231 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
240 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
232
241
233 incomingMsg = (asm_msg*) incomingData;
242 incomingMsg = (asm_msg*) incomingData;
234
243
235 localTime = getTimeAsUnsignedLongLongInt( );
244 localTime = getTimeAsUnsignedLongLongInt( );
236 //***********
245 //***********
237 //***********
246 //***********
238 // BURST SBM2
247 // BURST SBM2
239 //***********
248 //***********
240 //***********
249 //***********
241 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
250 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
242 {
251 {
252 sid = getSID( incomingMsg->event );
243 // 1) compress the matrix for Basic Parameters calculation
253 // 1) compress the matrix for Basic Parameters calculation
244 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
254 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
245 nb_sm_before_f1.burst_sbm_bp1,
255 nb_sm_before_f1.burst_sbm_bp1,
246 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
256 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
247 ASM_F1_INDICE_START);
257 ASM_F1_INDICE_START);
248 // 2) compute the BP1 set
258 // 2) compute the BP1 set
249
259
250 // 3) send the BP1 set
260 // 3) send the BP1 set
251 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
261 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
252 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
262 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
253 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
263 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
254 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
264 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
255 SID_SBM2_BP1_F1 );
265 sid );
256 // 4) compute the BP2 set if needed
266 // 4) compute the BP2 set if needed
257 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
267 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
258 {
268 {
259 // 1) compute the BP2 set
269 // 1) compute the BP2 set
260
270
261 // 2) send the BP2 set
271 // 2) send the BP2 set
262 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
272 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
263 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
273 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
264 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
274 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
265 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
275 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
266 SID_SBM2_BP2_F1 );
276 sid );
267 }
277 }
268 }
278 }
269
279
270 //*****
280 //*****
271 //*****
281 //*****
272 // NORM
282 // NORM
273 //*****
283 //*****
274 //*****
284 //*****
275 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
285 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
276 {
286 {
277 // 1) compress the matrix for Basic Parameters calculation
287 // 1) compress the matrix for Basic Parameters calculation
278 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
288 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
279 nb_sm_before_f1.norm_bp1,
289 nb_sm_before_f1.norm_bp1,
280 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
290 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
281 ASM_F0_INDICE_START );
291 ASM_F0_INDICE_START );
282 // 2) compute the BP1 set
292 // 2) compute the BP1 set
283
293
284 // 3) send the BP1 set
294 // 3) send the BP1 set
285 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
295 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
286 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
287 BP_send( (char *) &packet_norm_bp1, queue_id_send,
297 BP_send( (char *) &packet_norm_bp1, queue_id_send,
288 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
298 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
289 SID_NORM_BP1_F1 );
299 SID_NORM_BP1_F1 );
290 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
300 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
291 {
301 {
292 // 1) compute the BP2 set
302 // 1) compute the BP2 set
293
303
294 // 2) send the BP2 set
304 // 2) send the BP2 set
295 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
305 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
306 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
297 BP_send( (char *) &packet_norm_bp2, queue_id_send,
307 BP_send( (char *) &packet_norm_bp2, queue_id_send,
298 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
308 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
299 SID_NORM_BP2_F1 );
309 SID_NORM_BP2_F1 );
300 }
310 }
301 }
311 }
302
312
303 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
313 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
304 {
314 {
305 // 1) reorganize the ASM and divide
315 // 1) reorganize the ASM and divide
306 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
316 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
307 asm_f1_reorganized,
317 asm_f1_reorganized,
308 nb_sm_before_f1.norm_bp1 );
318 nb_sm_before_f1.norm_bp1 );
309 // 2) convert the float array in a char array
319 // 2) convert the float array in a char array
310 ASM_convert( asm_f1_reorganized, asm_f1_char);
320 ASM_convert( asm_f1_reorganized, asm_f1_char);
311 // 3) send the spectral matrix packets
321 // 3) send the spectral matrix packets
312 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
322 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
313 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
323 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
314 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
324 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
315 }
325 }
316
326
317 }
327 }
318 }
328 }
319
329
320 //**********
330 //**********
321 // FUNCTIONS
331 // FUNCTIONS
322
332
323 void reset_nb_sm_f1( unsigned char lfrMode )
333 void reset_nb_sm_f1( unsigned char lfrMode )
324 {
334 {
325 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
335 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
326 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
336 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
327 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;
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;
328 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
338 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
329 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
339 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
330 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
340 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
331 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
341 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
332
342
333 if (lfrMode == LFR_MODE_SBM2)
343 if (lfrMode == LFR_MODE_SBM2)
334 {
344 {
335 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
345 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
336 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
346 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
337 }
347 }
338 else if (lfrMode == LFR_MODE_BURST)
348 else if (lfrMode == LFR_MODE_BURST)
339 {
349 {
340 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
350 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
341 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
351 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
342 }
352 }
343 else
353 else
344 {
354 {
345 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
355 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
346 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
356 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
347 }
357 }
348 }
358 }
349
359
@@ -1,632 +1,678
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
38
39 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
39 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
40
40
41 switch(status)
41 switch(status)
42 {
42 {
43 case 0:
43 case 0:
44 break;
44 break;
45 case 3:
45 case 3:
46 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_0_coarse_time );
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 );
47 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_1_coarse_time );
48 if ( time_0 < time_1 )
48 if ( time_0 < time_1 )
49 {
49 {
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);
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);
51 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
51 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;
52 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);
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);
54 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
54 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;
55 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
56 }
56 }
57 else
57 else
58 {
58 {
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);
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);
60 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
60 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;
61 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);
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);
63 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
63 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;
64 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
65 }
65 }
66 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x03; // [0011]
66 spectral_matrix_regs->status = 0x03; // [0011]
67 break;
67 break;
68 case 1:
68 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);
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);
70 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
70 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;
71 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
72 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x01; // [0001]
72 spectral_matrix_regs->status = 0x01; // [0001]
73 break;
73 break;
74 case 2:
74 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);
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);
76 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
76 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;
77 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
78 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x02; // [0010]
78 spectral_matrix_regs->status = 0x02; // [0010]
79 break;
79 break;
80 }
80 }
81 }
81 }
82
82
83 void spectral_matrices_isr_f1( void )
83 void spectral_matrices_isr_f1( void )
84 {
84 {
85 unsigned char status;
85 unsigned char status;
86 unsigned long long int time_0;
86 unsigned long long int time_0;
87 unsigned long long int time_1;
87 unsigned long long int time_1;
88
88
89 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
89 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
90
90
91 switch(status)
91 switch(status)
92 {
92 {
93 case 0:
93 case 0:
94 break;
94 break;
95 case 3:
95 case 3:
96 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_0_coarse_time );
96 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_0_coarse_time );
97 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_1_coarse_time );
97 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_1_coarse_time );
98 if ( time_0 < time_1 )
98 if ( time_0 < time_1 )
99 {
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);
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;
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;
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);
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;
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;
105 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
106 }
106 }
107 else
107 else
108 {
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);
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;
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;
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);
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;
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;
114 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
115 }
115 }
116 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x0c; // [1100]
116 spectral_matrix_regs->status = 0x0c; // [1100]
117 break;
117 break;
118 case 1:
118 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);
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);
120 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
120 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;
121 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
122 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x07; // [0100]
122 spectral_matrix_regs->status = 0x04; // [0100]
123 break;
123 break;
124 case 2:
124 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);
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);
126 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
126 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;
127 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
128 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x08; // [1000]
128 spectral_matrix_regs->status = 0x08; // [1000]
129 break;
129 break;
130 }
130 }
131 }
131 }
132
132
133 void spectral_matrices_isr_f2( void )
133 void spectral_matrices_isr_f2( void )
134 {
134 {
135 unsigned char status;
135 unsigned char status;
136
136
137 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
137 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
138
138
139 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
139 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
140
140
141 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
141 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
142
142
143 switch(status)
143 switch(status)
144 {
144 {
145 case 0:
145 case 0:
146 break;
146 case 3:
147 case 3:
148 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
149 spectral_matrix_regs->status = 0x30; // [0011 0000]
150 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
151 {
152 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 }
147 break;
154 break;
148 case 1:
155 case 1:
149 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
156 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
150 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x10; // [0001 0000]
157 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 {
160 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 }
151 break;
162 break;
152 case 2:
163 case 2:
153 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;
154 spectral_matrix_regs->status = 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)
167 {
168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
169 }
155 break;
170 break;
156 }
171 }
157
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 {
160 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 }
162 }
172 }
163
173
164 void spectral_matrix_isr_error_handler( void )
174 void spectral_matrix_isr_error_handler( void )
165 {
175 {
166 spectral_matrix_regs->status = 0x7c0; // [0111 1100 0000]
176 spectral_matrix_regs->status = 0x7c0; // [0111 1100 0000]
167 }
177 }
168
178
169 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
179 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
170 {
180 {
171 // STATUS REGISTER
181 // STATUS REGISTER
172 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
182 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
173 // 10 9 8
183 // 10 9 8
174 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
184 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
175 // 7 6 5 4 3 2 1 0
185 // 7 6 5 4 3 2 1 0
176
186
177 spectral_matrices_isr_f0();
187 spectral_matrices_isr_f0();
178
188
179 spectral_matrices_isr_f1();
189 spectral_matrices_isr_f1();
180
190
181 spectral_matrices_isr_f2();
191 spectral_matrices_isr_f2();
182
192
183 spectral_matrix_isr_error_handler();
193 // spectral_matrix_isr_error_handler();
184 }
194 }
185
195
186 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
196 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
187 {
197 {
188 //***
198 //***
189 // F0
199 // F0
190 nb_sm_f0 = nb_sm_f0 + 1;
200 nb_sm_f0 = nb_sm_f0 + 1;
191 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
201 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
192 {
202 {
193 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
203 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
194 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
204 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
195 {
205 {
196 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
206 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
197 }
207 }
198 nb_sm_f0 = 0;
208 nb_sm_f0 = 0;
199 }
209 }
200
210
201 //***
211 //***
202 // F1
212 // F1
203 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
213 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
204 if (nb_sm_f0_aux_f1 == 6)
214 if (nb_sm_f0_aux_f1 == 6)
205 {
215 {
206 nb_sm_f0_aux_f1 = 0;
216 nb_sm_f0_aux_f1 = 0;
207 nb_sm_f1 = nb_sm_f1 + 1;
217 nb_sm_f1 = nb_sm_f1 + 1;
208 }
218 }
209 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
219 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
210 {
220 {
211 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
221 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
212 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
222 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
213 {
223 {
214 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
224 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
215 }
225 }
216 nb_sm_f1 = 0;
226 nb_sm_f1 = 0;
217 }
227 }
218
228
219 //***
229 //***
220 // F2
230 // F2
221 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
231 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
222 if (nb_sm_f0_aux_f2 == 96)
232 if (nb_sm_f0_aux_f2 == 96)
223 {
233 {
224 nb_sm_f0_aux_f2 = 0;
234 nb_sm_f0_aux_f2 = 0;
225 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
235 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
226 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
236 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
227 {
237 {
228 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
238 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
229 }
239 }
230 }
240 }
231 }
241 }
232
242
233 //******************
243 //******************
234 // Spectral Matrices
244 // Spectral Matrices
235
245
236 void reset_nb_sm( void )
246 void reset_nb_sm( void )
237 {
247 {
238 nb_sm_f0 = 0;
248 nb_sm_f0 = 0;
239 nb_sm_f0_aux_f1 = 0;
249 nb_sm_f0_aux_f1 = 0;
240 nb_sm_f0_aux_f2 = 0;
250 nb_sm_f0_aux_f2 = 0;
241
251
242 nb_sm_f1 = 0;
252 nb_sm_f1 = 0;
243 }
253 }
244
254
245 void SM_init_rings( void )
255 void SM_init_rings( void )
246 {
256 {
247 unsigned char i;
257 unsigned char i;
248
258
249 // F0 RING
259 // F0 RING
250 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
260 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
251 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
261 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
252 sm_ring_f0[0].buffer_address =
262 sm_ring_f0[0].buffer_address =
253 (int) &sm_f0[ 0 ];
263 (int) &sm_f0[ 0 ];
254
264
255 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
265 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
256 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
266 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
257 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
267 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
258 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
268 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
259
269
260 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
270 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
261 {
271 {
262 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
272 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
263 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
273 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
264 sm_ring_f0[i].buffer_address =
274 sm_ring_f0[i].buffer_address =
265 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
275 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
266 }
276 }
267
277
268 // F1 RING
278 // F1 RING
269 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
279 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
270 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
280 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
271 sm_ring_f1[0].buffer_address =
281 sm_ring_f1[0].buffer_address =
272 (int) &sm_f1[ 0 ];
282 (int) &sm_f1[ 0 ];
273
283
274 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
284 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
275 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
285 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
276 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
286 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
277 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
287 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
278
288
279 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
289 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
280 {
290 {
281 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
291 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
282 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
292 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
283 sm_ring_f1[i].buffer_address =
293 sm_ring_f1[i].buffer_address =
284 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
294 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
285 }
295 }
286
296
287 // F2 RING
297 // F2 RING
288 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
298 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
289 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
299 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
290 sm_ring_f2[0].buffer_address =
300 sm_ring_f2[0].buffer_address =
291 (int) &sm_f2[ 0 ];
301 (int) &sm_f2[ 0 ];
292
302
293 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
303 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
294 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
304 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
295 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
305 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
296 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
306 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
297
307
298 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
308 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
299 {
309 {
300 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
310 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
301 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
311 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
302 sm_ring_f2[i].buffer_address =
312 sm_ring_f2[i].buffer_address =
303 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
313 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
304 }
314 }
305
315
306 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
316 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
307 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
317 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
308 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
318 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
309
319
310 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
320 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
311 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
321 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
312 }
322 }
313
323
314 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
324 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
315 {
325 {
316 unsigned char i;
326 unsigned char i;
317
327
318 //***************
328 //***************
319 // BUFFER ADDRESS
329 // BUFFER ADDRESS
320 for(i=0; i<nbNodes; i++)
330 for(i=0; i<nbNodes; i++)
321 {
331 {
322 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
332 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
323 }
333 }
324
334
325 //*****
335 //*****
326 // NEXT
336 // NEXT
327 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
337 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
328 for(i=0; i<nbNodes-1; i++)
338 for(i=0; i<nbNodes-1; i++)
329 {
339 {
330 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
340 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
331 }
341 }
332
342
333 //*********
343 //*********
334 // PREVIOUS
344 // PREVIOUS
335 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
345 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
336 for(i=1; i<nbNodes; i++)
346 for(i=1; i<nbNodes; i++)
337 {
347 {
338 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
348 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
339 }
349 }
340 }
350 }
341
351
342 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
352 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
343 {
353 {
344 unsigned char i;
354 unsigned char i;
345
355
346 ring[ nbNodes - 1 ].next
356 ring[ nbNodes - 1 ].next
347 = (ring_node_asm*) &ring[ 0 ];
357 = (ring_node_asm*) &ring[ 0 ];
348
358
349 for(i=0; i<nbNodes-1; i++)
359 for(i=0; i<nbNodes-1; i++)
350 {
360 {
351 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
361 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
352 }
362 }
353 }
363 }
354
364
355 void SM_reset_current_ring_nodes( void )
365 void SM_reset_current_ring_nodes( void )
356 {
366 {
357 current_ring_node_sm_f0 = sm_ring_f0[0].next;
367 current_ring_node_sm_f0 = sm_ring_f0[0].next;
358 current_ring_node_sm_f1 = sm_ring_f1[0].next;
368 current_ring_node_sm_f1 = sm_ring_f1[0].next;
359 current_ring_node_sm_f2 = sm_ring_f2[0].next;
369 current_ring_node_sm_f2 = sm_ring_f2[0].next;
360
370
361 ring_node_for_averaging_sm_f0 = sm_ring_f0;
371 ring_node_for_averaging_sm_f0 = sm_ring_f0;
362 ring_node_for_averaging_sm_f1 = sm_ring_f1;
372 ring_node_for_averaging_sm_f1 = sm_ring_f1;
363 ring_node_for_averaging_sm_f2 = sm_ring_f2;
373 ring_node_for_averaging_sm_f2 = sm_ring_f2;
364 }
374 }
365
375
366 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
376 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
367 {
377 {
368 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
378 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
369 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
379 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
370 header->reserved = 0x00;
380 header->reserved = 0x00;
371 header->userApplication = CCSDS_USER_APP;
381 header->userApplication = CCSDS_USER_APP;
372 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
382 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
373 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
383 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
374 header->packetSequenceControl[0] = 0xc0;
384 header->packetSequenceControl[0] = 0xc0;
375 header->packetSequenceControl[1] = 0x00;
385 header->packetSequenceControl[1] = 0x00;
376 header->packetLength[0] = 0x00;
386 header->packetLength[0] = 0x00;
377 header->packetLength[1] = 0x00;
387 header->packetLength[1] = 0x00;
378 // DATA FIELD HEADER
388 // DATA FIELD HEADER
379 header->spare1_pusVersion_spare2 = 0x10;
389 header->spare1_pusVersion_spare2 = 0x10;
380 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
390 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
381 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
391 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
382 header->destinationID = TM_DESTINATION_ID_GROUND;
392 header->destinationID = TM_DESTINATION_ID_GROUND;
383 // AUXILIARY DATA HEADER
393 // AUXILIARY DATA HEADER
384 header->sid = 0x00;
394 header->sid = 0x00;
385 header->biaStatusInfo = 0x00;
395 header->biaStatusInfo = 0x00;
386 header->pa_lfr_pkt_cnt_asm = 0x00;
396 header->pa_lfr_pkt_cnt_asm = 0x00;
387 header->pa_lfr_pkt_nr_asm = 0x00;
397 header->pa_lfr_pkt_nr_asm = 0x00;
388 header->time[0] = 0x00;
398 header->time[0] = 0x00;
389 header->time[0] = 0x00;
399 header->time[0] = 0x00;
390 header->time[0] = 0x00;
400 header->time[0] = 0x00;
391 header->time[0] = 0x00;
401 header->time[0] = 0x00;
392 header->time[0] = 0x00;
402 header->time[0] = 0x00;
393 header->time[0] = 0x00;
403 header->time[0] = 0x00;
394 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
404 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
395 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
405 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
396 }
406 }
397
407
398 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
408 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
399 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
409 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
400 {
410 {
401 unsigned int i;
411 unsigned int i;
402 unsigned int length = 0;
412 unsigned int length = 0;
403 rtems_status_code status;
413 rtems_status_code status;
404
414
405 for (i=0; i<2; i++)
415 for (i=0; i<2; i++)
406 {
416 {
407 // (1) BUILD THE DATA
417 // (1) BUILD THE DATA
408 switch(sid)
418 switch(sid)
409 {
419 {
410 case SID_NORM_ASM_F0:
420 case SID_NORM_ASM_F0:
411 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
421 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
412 spw_ioctl_send->data = &spectral_matrix[
422 spw_ioctl_send->data = &spectral_matrix[
413 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
423 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
414 ];
424 ];
415 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
425 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
416 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
426 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
417 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
427 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
418 break;
428 break;
419 case SID_NORM_ASM_F1:
429 case SID_NORM_ASM_F1:
420 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
430 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
421 spw_ioctl_send->data = &spectral_matrix[
431 spw_ioctl_send->data = &spectral_matrix[
422 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
432 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
423 ];
433 ];
424 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
434 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
425 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
435 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
426 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
436 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
427 break;
437 break;
428 case SID_NORM_ASM_F2:
438 case SID_NORM_ASM_F2:
429 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
439 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
430 spw_ioctl_send->data = &spectral_matrix[
440 spw_ioctl_send->data = &spectral_matrix[
431 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
441 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
432 ];
442 ];
433 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
443 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
434 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
444 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
435 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
445 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
436 break;
446 break;
437 default:
447 default:
438 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
448 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
439 break;
449 break;
440 }
450 }
441 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
451 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
442 spw_ioctl_send->hdr = (char *) header;
452 spw_ioctl_send->hdr = (char *) header;
443 spw_ioctl_send->options = 0;
453 spw_ioctl_send->options = 0;
444
454
445 // (2) BUILD THE HEADER
455 // (2) BUILD THE HEADER
446 increment_seq_counter_source_id( header->packetSequenceControl, sid );
456 increment_seq_counter_source_id( header->packetSequenceControl, sid );
447 header->packetLength[0] = (unsigned char) (length>>8);
457 header->packetLength[0] = (unsigned char) (length>>8);
448 header->packetLength[1] = (unsigned char) (length);
458 header->packetLength[1] = (unsigned char) (length);
449 header->sid = (unsigned char) sid; // SID
459 header->sid = (unsigned char) sid; // SID
450 header->pa_lfr_pkt_cnt_asm = 2;
460 header->pa_lfr_pkt_cnt_asm = 2;
451 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
461 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
452
462
453 // (3) SET PACKET TIME
463 // (3) SET PACKET TIME
454 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
464 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
455 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
465 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
456 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
466 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
457 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
467 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
458 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
468 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
459 header->time[5] = (unsigned char) (time_management_regs->fine_time);
469 header->time[5] = (unsigned char) (time_management_regs->fine_time);
460 //
470 //
461 header->acquisitionTime[0] = header->time[0];
471 header->acquisitionTime[0] = header->time[0];
462 header->acquisitionTime[1] = header->time[1];
472 header->acquisitionTime[1] = header->time[1];
463 header->acquisitionTime[2] = header->time[2];
473 header->acquisitionTime[2] = header->time[2];
464 header->acquisitionTime[3] = header->time[3];
474 header->acquisitionTime[3] = header->time[3];
465 header->acquisitionTime[4] = header->time[4];
475 header->acquisitionTime[4] = header->time[4];
466 header->acquisitionTime[5] = header->time[5];
476 header->acquisitionTime[5] = header->time[5];
467
477
468 // (4) SEND PACKET
478 // (4) SEND PACKET
469 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
479 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
470 if (status != RTEMS_SUCCESSFUL) {
480 if (status != RTEMS_SUCCESSFUL) {
471 printf("in ASM_send *** ERR %d\n", (int) status);
481 printf("in ASM_send *** ERR %d\n", (int) status);
472 }
482 }
473 }
483 }
474 }
484 }
475
485
476 //*****************
486 //*****************
477 // Basic Parameters
487 // Basic Parameters
478
488
479 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
489 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
480 unsigned int apid, unsigned char sid,
490 unsigned int apid, unsigned char sid,
481 unsigned int packetLength, unsigned char blkNr )
491 unsigned int packetLength, unsigned char blkNr )
482 {
492 {
483 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
493 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
484 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
494 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
485 header->reserved = 0x00;
495 header->reserved = 0x00;
486 header->userApplication = CCSDS_USER_APP;
496 header->userApplication = CCSDS_USER_APP;
487 header->packetID[0] = (unsigned char) (apid >> 8);
497 header->packetID[0] = (unsigned char) (apid >> 8);
488 header->packetID[1] = (unsigned char) (apid);
498 header->packetID[1] = (unsigned char) (apid);
489 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
499 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
490 header->packetSequenceControl[1] = 0x00;
500 header->packetSequenceControl[1] = 0x00;
491 header->packetLength[0] = (unsigned char) (packetLength >> 8);
501 header->packetLength[0] = (unsigned char) (packetLength >> 8);
492 header->packetLength[1] = (unsigned char) (packetLength);
502 header->packetLength[1] = (unsigned char) (packetLength);
493 // DATA FIELD HEADER
503 // DATA FIELD HEADER
494 header->spare1_pusVersion_spare2 = 0x10;
504 header->spare1_pusVersion_spare2 = 0x10;
495 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
505 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
496 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
506 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
497 header->destinationID = TM_DESTINATION_ID_GROUND;
507 header->destinationID = TM_DESTINATION_ID_GROUND;
498 // AUXILIARY DATA HEADER
508 // AUXILIARY DATA HEADER
499 header->sid = sid;
509 header->sid = sid;
500 header->biaStatusInfo = 0x00;
510 header->biaStatusInfo = 0x00;
501 header->time[0] = 0x00;
511 header->time[0] = 0x00;
502 header->time[0] = 0x00;
512 header->time[0] = 0x00;
503 header->time[0] = 0x00;
513 header->time[0] = 0x00;
504 header->time[0] = 0x00;
514 header->time[0] = 0x00;
505 header->time[0] = 0x00;
515 header->time[0] = 0x00;
506 header->time[0] = 0x00;
516 header->time[0] = 0x00;
507 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
517 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
508 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
518 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
509 }
519 }
510
520
511 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
521 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
512 unsigned int apid, unsigned char sid,
522 unsigned int apid, unsigned char sid,
513 unsigned int packetLength , unsigned char blkNr)
523 unsigned int packetLength , unsigned char blkNr)
514 {
524 {
515 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
525 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
516 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
526 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
517 header->reserved = 0x00;
527 header->reserved = 0x00;
518 header->userApplication = CCSDS_USER_APP;
528 header->userApplication = CCSDS_USER_APP;
519 header->packetID[0] = (unsigned char) (apid >> 8);
529 header->packetID[0] = (unsigned char) (apid >> 8);
520 header->packetID[1] = (unsigned char) (apid);
530 header->packetID[1] = (unsigned char) (apid);
521 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
531 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
522 header->packetSequenceControl[1] = 0x00;
532 header->packetSequenceControl[1] = 0x00;
523 header->packetLength[0] = (unsigned char) (packetLength >> 8);
533 header->packetLength[0] = (unsigned char) (packetLength >> 8);
524 header->packetLength[1] = (unsigned char) (packetLength);
534 header->packetLength[1] = (unsigned char) (packetLength);
525 // DATA FIELD HEADER
535 // DATA FIELD HEADER
526 header->spare1_pusVersion_spare2 = 0x10;
536 header->spare1_pusVersion_spare2 = 0x10;
527 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
537 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
528 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
538 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
529 header->destinationID = TM_DESTINATION_ID_GROUND;
539 header->destinationID = TM_DESTINATION_ID_GROUND;
530 // AUXILIARY DATA HEADER
540 // AUXILIARY DATA HEADER
531 header->sid = sid;
541 header->sid = sid;
532 header->biaStatusInfo = 0x00;
542 header->biaStatusInfo = 0x00;
533 header->time[0] = 0x00;
543 header->time[0] = 0x00;
534 header->time[0] = 0x00;
544 header->time[0] = 0x00;
535 header->time[0] = 0x00;
545 header->time[0] = 0x00;
536 header->time[0] = 0x00;
546 header->time[0] = 0x00;
537 header->time[0] = 0x00;
547 header->time[0] = 0x00;
538 header->time[0] = 0x00;
548 header->time[0] = 0x00;
539 header->source_data_spare = 0x00;
549 header->source_data_spare = 0x00;
540 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
550 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
541 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
551 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
542 }
552 }
543
553
544 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
554 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
545 {
555 {
546 rtems_status_code status;
556 rtems_status_code status;
547
557
548 // SET THE SEQUENCE_CNT PARAMETER
558 // SET THE SEQUENCE_CNT PARAMETER
549 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
559 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
550 // SEND PACKET
560 // SEND PACKET
551 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
561 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
552 if (status != RTEMS_SUCCESSFUL)
562 if (status != RTEMS_SUCCESSFUL)
553 {
563 {
554 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
564 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
555 }
565 }
556 }
566 }
557
567
558 //******************
568 //******************
559 // general functions
569 // general functions
560
570
561 void reset_spectral_matrix_regs( void )
571 void reset_spectral_matrix_regs( void )
562 {
572 {
563 /** This function resets the spectral matrices module registers.
573 /** This function resets the spectral matrices module registers.
564 *
574 *
565 * The registers affected by this function are located at the following offset addresses:
575 * The registers affected by this function are located at the following offset addresses:
566 *
576 *
567 * - 0x00 config
577 * - 0x00 config
568 * - 0x04 status
578 * - 0x04 status
569 * - 0x08 matrixF0_Address0
579 * - 0x08 matrixF0_Address0
570 * - 0x10 matrixFO_Address1
580 * - 0x10 matrixFO_Address1
571 * - 0x14 matrixF1_Address
581 * - 0x14 matrixF1_Address
572 * - 0x18 matrixF2_Address
582 * - 0x18 matrixF2_Address
573 *
583 *
574 */
584 */
575
585
576 spectral_matrix_regs->config = 0x00;
586 spectral_matrix_regs->config = 0x00;
577 spectral_matrix_regs->status = 0x00;
587 spectral_matrix_regs->status = 0x00;
578
588
579 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
589 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
580 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
590 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
581 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
591 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
582 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
592 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
583 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
593 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
584 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
594 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
585 }
595 }
586
596
587 void set_time( unsigned char *time, unsigned char * timeInBuffer )
597 void set_time( unsigned char *time, unsigned char * timeInBuffer )
588 {
598 {
589 // time[0] = timeInBuffer[2];
599 // time[0] = timeInBuffer[2];
590 // time[1] = timeInBuffer[3];
600 // time[1] = timeInBuffer[3];
591 // time[2] = timeInBuffer[0];
601 // time[2] = timeInBuffer[0];
592 // time[3] = timeInBuffer[1];
602 // time[3] = timeInBuffer[1];
593 // time[4] = timeInBuffer[6];
603 // time[4] = timeInBuffer[6];
594 // time[5] = timeInBuffer[7];
604 // time[5] = timeInBuffer[7];
595
605
596 time[0] = timeInBuffer[0];
606 time[0] = timeInBuffer[0];
597 time[1] = timeInBuffer[1];
607 time[1] = timeInBuffer[1];
598 time[2] = timeInBuffer[2];
608 time[2] = timeInBuffer[2];
599 time[3] = timeInBuffer[3];
609 time[3] = timeInBuffer[3];
600 time[4] = timeInBuffer[6];
610 time[4] = timeInBuffer[6];
601 time[5] = timeInBuffer[7];
611 time[5] = timeInBuffer[7];
602 }
612 }
603
613
604 unsigned long long int get_acquisition_time( unsigned char *timePtr )
614 unsigned long long int get_acquisition_time( unsigned char *timePtr )
605 {
615 {
606 unsigned long long int acquisitionTimeAslong;
616 unsigned long long int acquisitionTimeAslong;
607 acquisitionTimeAslong = 0x00;
617 acquisitionTimeAslong = 0x00;
608 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
618 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
609 + ( (unsigned long long int) timePtr[1] << 32 )
619 + ( (unsigned long long int) timePtr[1] << 32 )
610 + ( timePtr[2] << 24 )
620 + ( timePtr[2] << 24 )
611 + ( timePtr[3] << 16 )
621 + ( timePtr[3] << 16 )
612 + ( timePtr[4] << 8 )
622 + ( timePtr[4] << 8 )
613 + ( timePtr[5] );
623 + ( timePtr[5] );
614 return acquisitionTimeAslong;
624 return acquisitionTimeAslong;
615 }
625 }
616
626
617 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
627 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
618 ring_node_sm *node_for_averaging, ring_node_sm *ringNode )
628 ring_node_sm *node_for_averaging, ring_node_sm *ringNode )
619 {
629 {
620 *nb_sm = *nb_sm + 1;
630 *nb_sm = *nb_sm + 1;
621 if (*nb_sm == nb_sm_before_avf)
631 if (*nb_sm == nb_sm_before_avf)
622 {
632 {
623 node_for_averaging = ringNode;
633 node_for_averaging = ringNode;
624 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
634 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
625 {
635 {
626 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
636 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
627 }
637 }
628 *nb_sm = 0;
638 *nb_sm = 0;
629 }
639 }
630 }
640 }
631
641
642 unsigned char getSID( rtems_event_set event )
643 {
644 unsigned char sid;
632
645
646 rtems_event_set eventSetBURST;
647 rtems_event_set eventSetSBM;
648
649 //******
650 // BURST
651 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
652 | RTEMS_EVENT_BURST_BP1_F1
653 | RTEMS_EVENT_BURST_BP2_F0
654 | RTEMS_EVENT_BURST_BP2_F1;
655
656 //****
657 // SBM
658 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
659 | RTEMS_EVENT_SBM_BP1_F1
660 | RTEMS_EVENT_SBM_BP2_F0
661 | RTEMS_EVENT_SBM_BP2_F1;
662
663 if (event & eventSetBURST)
664 {
665 sid = SID_BURST_BP1_F0;
666 }
667 else if (event & eventSetSBM)
668 {
669 sid = SID_SBM1_BP1_F0;
670 }
671 else
672 {
673 sid = 0;
674 }
675
676 return sid;
677 }
678
@@ -1,878 +1,881
1 /** Functions to load and dump parameters in the LFR registers.
1 /** Functions to load and dump parameters in the LFR registers.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TC related to parameter loading and dumping.\n
6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 * TC_LFR_LOAD_COMMON_PAR\n
7 * TC_LFR_LOAD_COMMON_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
12 *
12 *
13 */
13 */
14
14
15 #include "tc_load_dump_parameters.h"
15 #include "tc_load_dump_parameters.h"
16
16
17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 {
18 {
19 /** This function updates the LFR registers with the incoming common parameters.
19 /** This function updates the LFR registers with the incoming common parameters.
20 *
20 *
21 * @param TC points to the TeleCommand packet that is being processed
21 * @param TC points to the TeleCommand packet that is being processed
22 *
22 *
23 *
23 *
24 */
24 */
25
25
26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 set_wfp_data_shaping( );
28 set_wfp_data_shaping( );
29 return LFR_SUCCESSFUL;
29 return LFR_SUCCESSFUL;
30 }
30 }
31
31
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 {
33 {
34 /** This function updates the LFR registers with the incoming normal parameters.
34 /** This function updates the LFR registers with the incoming normal parameters.
35 *
35 *
36 * @param TC points to the TeleCommand packet that is being processed
36 * @param TC points to the TeleCommand packet that is being processed
37 * @param queue_id is the id of the queue which handles TM related to this execution step
37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 *
38 *
39 */
39 */
40
40
41 int result;
41 int result;
42 int flag;
42 int flag;
43 rtems_status_code status;
43 rtems_status_code status;
44 unsigned char sy_lfr_n_bp_p0;
44 unsigned char sy_lfr_n_bp_p0;
45 unsigned char sy_lfr_n_bp_p1;
45 unsigned char sy_lfr_n_bp_p1;
46 unsigned int sy_lfr_n_asm_p;
46 unsigned int sy_lfr_n_asm_p;
47 float aux;
47 float aux;
48
48
49 flag = LFR_SUCCESSFUL;
49 flag = LFR_SUCCESSFUL;
50
50
51 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
51 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
52 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
52 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
53 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
53 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
54 flag = LFR_DEFAULT;
54 flag = LFR_DEFAULT;
55 }
55 }
56
56
57 //***************
57 //***************
58 // sy_lfr_n_swf_l
58 // sy_lfr_n_swf_l
59 if (flag == LFR_SUCCESSFUL)
59 if (flag == LFR_SUCCESSFUL)
60 {
60 {
61 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
61 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
62 if (result != LFR_SUCCESSFUL)
62 if (result != LFR_SUCCESSFUL)
63 {
63 {
64 flag = LFR_DEFAULT;
64 flag = LFR_DEFAULT;
65 }
65 }
66 }
66 }
67
67
68 //***************
68 //***************
69 // sy_lfr_n_swf_p
69 // sy_lfr_n_swf_p
70 if (flag == LFR_SUCCESSFUL)
70 if (flag == LFR_SUCCESSFUL)
71 {
71 {
72 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
72 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
73 if (result != LFR_SUCCESSFUL)
73 if (result != LFR_SUCCESSFUL)
74 {
74 {
75 flag = LFR_DEFAULT;
75 flag = LFR_DEFAULT;
76 }
76 }
77 }
77 }
78
78
79 //****************************************************************
79 //****************************************************************
80 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
80 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
81 if (flag == LFR_SUCCESSFUL)
81 if (flag == LFR_SUCCESSFUL)
82 {
82 {
83 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
83 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
84 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
84 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
85 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
85 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
86 if (aux != 0)
86 if (aux != 0)
87 {
87 {
88 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
88 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
89 flag = LFR_DEFAULT;
89 flag = LFR_DEFAULT;
90 }
90 }
91 }
91 }
92
92
93 //***************
93 //***************
94 // sy_lfr_n_bp_p0
94 // sy_lfr_n_bp_p0
95 if (flag == LFR_SUCCESSFUL)
95 if (flag == LFR_SUCCESSFUL)
96 {
96 {
97 result = set_sy_lfr_n_bp_p0( TC, queue_id );
97 result = set_sy_lfr_n_bp_p0( TC, queue_id );
98 if (result != LFR_SUCCESSFUL)
98 if (result != LFR_SUCCESSFUL)
99 {
99 {
100 flag = LFR_DEFAULT;
100 flag = LFR_DEFAULT;
101 }
101 }
102 }
102 }
103
103
104 //****************************************************************
104 //****************************************************************
105 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
105 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
106 if (flag == LFR_SUCCESSFUL)
106 if (flag == LFR_SUCCESSFUL)
107 {
107 {
108 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
108 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
109 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
109 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
110 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
110 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
111 if (aux != 0)
111 if (aux != 0)
112 {
112 {
113 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
113 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
114 flag = LFR_DEFAULT;
114 flag = LFR_DEFAULT;
115 }
115 }
116 }
116 }
117
117
118 //***************
118 //***************
119 // sy_lfr_n_bp_p1
119 // sy_lfr_n_bp_p1
120 if (flag == LFR_SUCCESSFUL)
120 if (flag == LFR_SUCCESSFUL)
121 {
121 {
122 result = set_sy_lfr_n_bp_p1( TC, queue_id );
122 result = set_sy_lfr_n_bp_p1( TC, queue_id );
123 if (result != LFR_SUCCESSFUL)
123 if (result != LFR_SUCCESSFUL)
124 {
124 {
125 flag = LFR_DEFAULT;
125 flag = LFR_DEFAULT;
126 }
126 }
127 }
127 }
128
128
129 //****************************************************************
129 //****************************************************************
130 // check the consistency between sy_lfr_n_asm_p and sy_lfr_n_bp_p0
130 // check the consistency between sy_lfr_n_asm_p and sy_lfr_n_bp_p0
131 if (flag == LFR_SUCCESSFUL)
131 if (flag == LFR_SUCCESSFUL)
132 {
132 {
133 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
133 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
134 sy_lfr_n_asm_p =
134 sy_lfr_n_asm_p =
135 TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ] * 256
135 TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ] * 256
136 + TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P + 1 ];
136 + TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P + 1 ];
137 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
137 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
138 if (aux != 0)
138 if (aux != 0)
139 {
139 {
140 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
140 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
141 flag = LFR_DEFAULT;
141 flag = LFR_DEFAULT;
142 }
142 }
143 }
143 }
144
144
145 //***************
145 //***************
146 // sy_lfr_n_asm_p
146 // sy_lfr_n_asm_p
147 if (flag == LFR_SUCCESSFUL)
147 if (flag == LFR_SUCCESSFUL)
148 {
148 {
149 result = set_sy_lfr_n_asm_p( TC, queue_id );
149 result = set_sy_lfr_n_asm_p( TC, queue_id );
150 if (result != LFR_SUCCESSFUL)
150 if (result != LFR_SUCCESSFUL)
151 {
151 {
152 flag = LFR_DEFAULT;
152 flag = LFR_DEFAULT;
153 }
153 }
154 }
154 }
155
155
156 //*********************
156 //*********************
157 // sy_lfr_n_cwf_long_f3
157 // sy_lfr_n_cwf_long_f3
158 if (flag == LFR_SUCCESSFUL)
158 if (flag == LFR_SUCCESSFUL)
159 {
159 {
160 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
160 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
161 if (result != LFR_SUCCESSFUL)
161 if (result != LFR_SUCCESSFUL)
162 {
162 {
163 flag = LFR_DEFAULT;
163 flag = LFR_DEFAULT;
164 }
164 }
165 }
165 }
166
166
167 return flag;
167 return flag;
168 }
168 }
169
169
170 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
170 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
171 {
171 {
172 /** This function updates the LFR registers with the incoming burst parameters.
172 /** This function updates the LFR registers with the incoming burst parameters.
173 *
173 *
174 * @param TC points to the TeleCommand packet that is being processed
174 * @param TC points to the TeleCommand packet that is being processed
175 * @param queue_id is the id of the queue which handles TM related to this execution step
175 * @param queue_id is the id of the queue which handles TM related to this execution step
176 *
176 *
177 */
177 */
178
178
179 int result;
179 int result;
180 int flag;
180 int flag;
181 rtems_status_code status;
181 rtems_status_code status;
182 unsigned char sy_lfr_b_bp_p0;
182 unsigned char sy_lfr_b_bp_p0;
183 unsigned char sy_lfr_b_bp_p1;
183 unsigned char sy_lfr_b_bp_p1;
184 float aux;
184 float aux;
185
185
186 flag = LFR_SUCCESSFUL;
186 flag = LFR_SUCCESSFUL;
187
187
188 if ( lfrCurrentMode == LFR_MODE_BURST ) {
188 if ( lfrCurrentMode == LFR_MODE_BURST ) {
189 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
189 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 result = LFR_DEFAULT;
190 result = LFR_DEFAULT;
191 }
191 }
192
192
193 //****************************************************************
193 //****************************************************************
194 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
194 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
195 if (flag == LFR_SUCCESSFUL)
195 if (flag == LFR_SUCCESSFUL)
196 {
196 {
197 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
197 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
198 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
198 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
199 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
199 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
200 if (aux != 0)
200 if (aux != 0)
201 {
201 {
202 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
202 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
203 flag = LFR_DEFAULT;
203 flag = LFR_DEFAULT;
204 }
204 }
205 }
205 }
206
206
207 //***************
207 //***************
208 // sy_lfr_b_bp_p0
208 // sy_lfr_b_bp_p0
209 if (flag == LFR_SUCCESSFUL)
209 if (flag == LFR_SUCCESSFUL)
210 {
210 {
211 result = set_sy_lfr_b_bp_p0( TC, queue_id );
211 result = set_sy_lfr_b_bp_p0( TC, queue_id );
212 if (result != LFR_SUCCESSFUL)
212 if (result != LFR_SUCCESSFUL)
213 {
213 {
214 flag = LFR_DEFAULT;
214 flag = LFR_DEFAULT;
215 }
215 }
216 }
216 }
217
217
218 //***************
218 //***************
219 // sy_lfr_b_bp_p1
219 // sy_lfr_b_bp_p1
220 if (flag == LFR_SUCCESSFUL)
220 if (flag == LFR_SUCCESSFUL)
221 {
221 {
222 result = set_sy_lfr_b_bp_p1( TC, queue_id );
222 result = set_sy_lfr_b_bp_p1( TC, queue_id );
223 if (result != LFR_SUCCESSFUL)
223 if (result != LFR_SUCCESSFUL)
224 {
224 {
225 flag = LFR_DEFAULT;
225 flag = LFR_DEFAULT;
226 }
226 }
227 }
227 }
228
228
229 return flag;
229 return flag;
230 }
230 }
231
231
232 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
232 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
233 {
233 {
234 /** This function updates the LFR registers with the incoming sbm1 parameters.
234 /** This function updates the LFR registers with the incoming sbm1 parameters.
235 *
235 *
236 * @param TC points to the TeleCommand packet that is being processed
236 * @param TC points to the TeleCommand packet that is being processed
237 * @param queue_id is the id of the queue which handles TM related to this execution step
237 * @param queue_id is the id of the queue which handles TM related to this execution step
238 *
238 *
239 */
239 */
240
240
241 int result;
241 int result;
242 int flag;
242 int flag;
243 rtems_status_code status;
243 rtems_status_code status;
244 unsigned char sy_lfr_s1_bp_p0;
244 unsigned char sy_lfr_s1_bp_p0;
245 unsigned char sy_lfr_s1_bp_p1;
245 unsigned char sy_lfr_s1_bp_p1;
246 float aux;
246 float aux;
247
247
248 flag = LFR_SUCCESSFUL;
248 flag = LFR_SUCCESSFUL;
249
249
250 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
250 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
251 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
251 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
252 result = LFR_DEFAULT;
252 result = LFR_DEFAULT;
253 }
253 }
254
254
255 //******************************************************************
255 //******************************************************************
256 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
256 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
257 if (flag == LFR_SUCCESSFUL)
257 if (flag == LFR_SUCCESSFUL)
258 {
258 {
259 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
259 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
260 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
260 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
261 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
261 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
262 if (aux != 0)
262 if (aux != 0)
263 {
263 {
264 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
264 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
265 flag = LFR_DEFAULT;
265 flag = LFR_DEFAULT;
266 }
266 }
267 }
267 }
268
268
269 //***************
269 //***************
270 // sy_lfr_s1_bp_p0
270 // sy_lfr_s1_bp_p0
271 if (flag == LFR_SUCCESSFUL)
271 if (flag == LFR_SUCCESSFUL)
272 {
272 {
273 result = set_sy_lfr_s1_bp_p0( TC, queue_id );
273 result = set_sy_lfr_s1_bp_p0( TC, queue_id );
274 if (result != LFR_SUCCESSFUL)
274 if (result != LFR_SUCCESSFUL)
275 {
275 {
276 flag = LFR_DEFAULT;
276 flag = LFR_DEFAULT;
277 }
277 }
278 }
278 }
279
279
280 //***************
280 //***************
281 // sy_lfr_s1_bp_p1
281 // sy_lfr_s1_bp_p1
282 if (flag == LFR_SUCCESSFUL)
282 if (flag == LFR_SUCCESSFUL)
283 {
283 {
284 result = set_sy_lfr_s1_bp_p1( TC, queue_id );
284 result = set_sy_lfr_s1_bp_p1( TC, queue_id );
285 if (result != LFR_SUCCESSFUL)
285 if (result != LFR_SUCCESSFUL)
286 {
286 {
287 flag = LFR_DEFAULT;
287 flag = LFR_DEFAULT;
288 }
288 }
289 }
289 }
290
290
291 return flag;
291 return flag;
292 }
292 }
293
293
294 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
294 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
295 {
295 {
296 /** This function updates the LFR registers with the incoming sbm2 parameters.
296 /** This function updates the LFR registers with the incoming sbm2 parameters.
297 *
297 *
298 * @param TC points to the TeleCommand packet that is being processed
298 * @param TC points to the TeleCommand packet that is being processed
299 * @param queue_id is the id of the queue which handles TM related to this execution step
299 * @param queue_id is the id of the queue which handles TM related to this execution step
300 *
300 *
301 */
301 */
302
302
303 int result;
303 int result;
304 int flag;
304 int flag;
305 rtems_status_code status;
305 rtems_status_code status;
306 unsigned char sy_lfr_s2_bp_p0;
306 unsigned char sy_lfr_s2_bp_p0;
307 unsigned char sy_lfr_s2_bp_p1;
307 unsigned char sy_lfr_s2_bp_p1;
308 float aux;
308 float aux;
309
309
310 flag = LFR_SUCCESSFUL;
310 flag = LFR_SUCCESSFUL;
311
311
312 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
312 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
313 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
313 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
314 result = LFR_DEFAULT;
314 result = LFR_DEFAULT;
315 }
315 }
316
316
317 //******************************************************************
317 //******************************************************************
318 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
318 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
319 if (flag == LFR_SUCCESSFUL)
319 if (flag == LFR_SUCCESSFUL)
320 {
320 {
321 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
321 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
322 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
322 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
323 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
323 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
324 if (aux != 0)
324 if (aux != 0)
325 {
325 {
326 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
326 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
327 flag = LFR_DEFAULT;
327 flag = LFR_DEFAULT;
328 }
328 }
329 }
329 }
330
330
331 //***************
331 //***************
332 // sy_lfr_s2_bp_p0
332 // sy_lfr_s2_bp_p0
333 if (flag == LFR_SUCCESSFUL)
333 if (flag == LFR_SUCCESSFUL)
334 {
334 {
335 result = set_sy_lfr_s2_bp_p0( TC, queue_id );
335 result = set_sy_lfr_s2_bp_p0( TC, queue_id );
336 if (result != LFR_SUCCESSFUL)
336 if (result != LFR_SUCCESSFUL)
337 {
337 {
338 flag = LFR_DEFAULT;
338 flag = LFR_DEFAULT;
339 }
339 }
340 }
340 }
341
341
342 //***************
342 //***************
343 // sy_lfr_s2_bp_p1
343 // sy_lfr_s2_bp_p1
344 if (flag == LFR_SUCCESSFUL)
344 if (flag == LFR_SUCCESSFUL)
345 {
345 {
346 result = set_sy_lfr_s2_bp_p1( TC, queue_id );
346 result = set_sy_lfr_s2_bp_p1( TC, queue_id );
347 if (result != LFR_SUCCESSFUL)
347 if (result != LFR_SUCCESSFUL)
348 {
348 {
349 flag = LFR_DEFAULT;
349 flag = LFR_DEFAULT;
350 }
350 }
351 }
351 }
352
352
353 return flag;
353 return flag;
354 }
354 }
355
355
356 int action_dump_par( rtems_id queue_id )
356 int action_dump_par( rtems_id queue_id )
357 {
357 {
358 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
358 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
359 *
359 *
360 * @param queue_id is the id of the queue which handles TM related to this execution step.
360 * @param queue_id is the id of the queue which handles TM related to this execution step.
361 *
361 *
362 * @return RTEMS directive status codes:
362 * @return RTEMS directive status codes:
363 * - RTEMS_SUCCESSFUL - message sent successfully
363 * - RTEMS_SUCCESSFUL - message sent successfully
364 * - RTEMS_INVALID_ID - invalid queue id
364 * - RTEMS_INVALID_ID - invalid queue id
365 * - RTEMS_INVALID_SIZE - invalid message size
365 * - RTEMS_INVALID_SIZE - invalid message size
366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
367 * - RTEMS_UNSATISFIED - out of message buffers
367 * - RTEMS_UNSATISFIED - out of message buffers
368 * - RTEMS_TOO_MANY - queue s limit has been reached
368 * - RTEMS_TOO_MANY - queue s limit has been reached
369 *
369 *
370 */
370 */
371
371
372 int status;
372 int status;
373
373
374 // UPDATE TIME
374 // UPDATE TIME
375 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
375 parameter_dump_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterParameterDump >> 8;
376 parameter_dump_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterParameterDump;
377 increment_seq_counter( &sequenceCounterParameterDump );
378
376 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
379 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
377 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
380 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
378 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
381 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
379 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
382 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
380 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
383 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
381 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
384 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
382 // SEND DATA
385 // SEND DATA
383 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
386 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
384 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
387 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
385 if (status != RTEMS_SUCCESSFUL) {
388 if (status != RTEMS_SUCCESSFUL) {
386 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
389 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
387 }
390 }
388
391
389 return status;
392 return status;
390 }
393 }
391
394
392 //***********************
395 //***********************
393 // NORMAL MODE PARAMETERS
396 // NORMAL MODE PARAMETERS
394
397
395 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
398 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
396 {
399 {
397 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
400 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
398 *
401 *
399 * @param TC points to the TeleCommand packet that is being processed
402 * @param TC points to the TeleCommand packet that is being processed
400 * @param queue_id is the id of the queue which handles TM related to this execution step
403 * @param queue_id is the id of the queue which handles TM related to this execution step
401 *
404 *
402 */
405 */
403
406
404 unsigned int tmp;
407 unsigned int tmp;
405 int result;
408 int result;
406 unsigned char msb;
409 unsigned char msb;
407 unsigned char lsb;
410 unsigned char lsb;
408 rtems_status_code status;
411 rtems_status_code status;
409
412
410 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
413 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
411 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
414 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
412
415
413 tmp = ( unsigned int ) floor(
416 tmp = ( unsigned int ) floor(
414 ( ( msb*256 ) + lsb ) / 16
417 ( ( msb*256 ) + lsb ) / 16
415 ) * 16;
418 ) * 16;
416
419
417 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
420 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
418 { // 2048 is the maximum limit due to the size of the buffers
421 { // 2048 is the maximum limit due to the size of the buffers
419 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
422 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
420 result = WRONG_APP_DATA;
423 result = WRONG_APP_DATA;
421 }
424 }
422 else if (tmp != 2048)
425 else if (tmp != 2048)
423 {
426 {
424 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
427 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
425 result = FUNCT_NOT_IMPL;
428 result = FUNCT_NOT_IMPL;
426 }
429 }
427 else
430 else
428 {
431 {
429 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
432 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
430 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
433 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
431 result = LFR_SUCCESSFUL;
434 result = LFR_SUCCESSFUL;
432 }
435 }
433
436
434 return result;
437 return result;
435 }
438 }
436
439
437 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
440 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
438 {
441 {
439 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
442 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
440 *
443 *
441 * @param TC points to the TeleCommand packet that is being processed
444 * @param TC points to the TeleCommand packet that is being processed
442 * @param queue_id is the id of the queue which handles TM related to this execution step
445 * @param queue_id is the id of the queue which handles TM related to this execution step
443 *
446 *
444 */
447 */
445
448
446 unsigned int tmp;
449 unsigned int tmp;
447 int result;
450 int result;
448 unsigned char msb;
451 unsigned char msb;
449 unsigned char lsb;
452 unsigned char lsb;
450 rtems_status_code status;
453 rtems_status_code status;
451
454
452 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
455 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
453 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
456 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
454
457
455 tmp = msb * 256 + lsb;
458 tmp = msb * 256 + lsb;
456
459
457 if ( tmp < 16 )
460 if ( tmp < 16 )
458 {
461 {
459 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
462 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
460 result = WRONG_APP_DATA;
463 result = WRONG_APP_DATA;
461 }
464 }
462 else
465 else
463 {
466 {
464 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
467 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
465 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
468 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
466 result = LFR_SUCCESSFUL;
469 result = LFR_SUCCESSFUL;
467 }
470 }
468
471
469 return result;
472 return result;
470 }
473 }
471
474
472 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
475 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
473 {
476 {
474 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
477 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
475 *
478 *
476 * @param TC points to the TeleCommand packet that is being processed
479 * @param TC points to the TeleCommand packet that is being processed
477 * @param queue_id is the id of the queue which handles TM related to this execution step
480 * @param queue_id is the id of the queue which handles TM related to this execution step
478 *
481 *
479 */
482 */
480
483
481 int result;
484 int result;
482 unsigned char msb;
485 unsigned char msb;
483 unsigned char lsb;
486 unsigned char lsb;
484
487
485 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
488 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
486 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
489 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
487
490
488 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
491 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
489 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
492 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
490 result = LFR_SUCCESSFUL;
493 result = LFR_SUCCESSFUL;
491
494
492 return result;
495 return result;
493 }
496 }
494
497
495 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
498 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
496 {
499 {
497 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
500 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
498 *
501 *
499 * @param TC points to the TeleCommand packet that is being processed
502 * @param TC points to the TeleCommand packet that is being processed
500 * @param queue_id is the id of the queue which handles TM related to this execution step
503 * @param queue_id is the id of the queue which handles TM related to this execution step
501 *
504 *
502 */
505 */
503
506
504 int status;
507 int status;
505 unsigned char val;
508 unsigned char val;
506
509
507 status = LFR_SUCCESSFUL;
510 status = LFR_SUCCESSFUL;
508
511
509 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
512 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
510
513
511 if (val < SY_LFR_N_BP_P0)
514 if (val < SY_LFR_N_BP_P0)
512 {
515 {
513 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, val );
516 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, val );
514 status = WRONG_APP_DATA;
517 status = WRONG_APP_DATA;
515 }
518 }
516 else
519 else
517 {
520 {
518 parameter_dump_packet.sy_lfr_n_bp_p0 = val;
521 parameter_dump_packet.sy_lfr_n_bp_p0 = val;
519 }
522 }
520
523
521 return status;
524 return status;
522 }
525 }
523
526
524 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
527 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
525 {
528 {
526 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
529 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
527 *
530 *
528 * @param TC points to the TeleCommand packet that is being processed
531 * @param TC points to the TeleCommand packet that is being processed
529 * @param queue_id is the id of the queue which handles TM related to this execution step
532 * @param queue_id is the id of the queue which handles TM related to this execution step
530 *
533 *
531 */
534 */
532
535
533 int status;
536 int status;
534 unsigned char val;
537 unsigned char val;
535
538
536 status = LFR_SUCCESSFUL;
539 status = LFR_SUCCESSFUL;
537
540
538 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
541 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
539
542
540 if (val < SY_LFR_N_BP_P1)
543 if (val < SY_LFR_N_BP_P1)
541 {
544 {
542 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, val );
545 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, val );
543 status = WRONG_APP_DATA;
546 status = WRONG_APP_DATA;
544 }
547 }
545 else
548 else
546 {
549 {
547 parameter_dump_packet.sy_lfr_n_bp_p1 = val;
550 parameter_dump_packet.sy_lfr_n_bp_p1 = val;
548 }
551 }
549
552
550 return status;
553 return status;
551 }
554 }
552
555
553 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
556 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
554 {
557 {
555 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
558 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
556 *
559 *
557 * @param TC points to the TeleCommand packet that is being processed
560 * @param TC points to the TeleCommand packet that is being processed
558 * @param queue_id is the id of the queue which handles TM related to this execution step
561 * @param queue_id is the id of the queue which handles TM related to this execution step
559 *
562 *
560 */
563 */
561
564
562 int status;
565 int status;
563
566
564 status = LFR_SUCCESSFUL;
567 status = LFR_SUCCESSFUL;
565
568
566 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
569 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
567
570
568 return status;
571 return status;
569 }
572 }
570
573
571 //**********************
574 //**********************
572 // BURST MODE PARAMETERS
575 // BURST MODE PARAMETERS
573 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
576 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
574 {
577 {
575 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
578 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
576 *
579 *
577 * @param TC points to the TeleCommand packet that is being processed
580 * @param TC points to the TeleCommand packet that is being processed
578 * @param queue_id is the id of the queue which handles TM related to this execution step
581 * @param queue_id is the id of the queue which handles TM related to this execution step
579 *
582 *
580 */
583 */
581
584
582 int status;
585 int status;
583 unsigned char val;
586 unsigned char val;
584
587
585 status = LFR_SUCCESSFUL;
588 status = LFR_SUCCESSFUL;
586
589
587 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
590 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
588
591
589 if (val < DEFAULT_SY_LFR_B_BP_P0 )
592 if (val < DEFAULT_SY_LFR_B_BP_P0 )
590 {
593 {
591 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, val );
594 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, val );
592 status = WRONG_APP_DATA;
595 status = WRONG_APP_DATA;
593 }
596 }
594 else
597 else
595 {
598 {
596 parameter_dump_packet.sy_lfr_b_bp_p0 = val;
599 parameter_dump_packet.sy_lfr_b_bp_p0 = val;
597 }
600 }
598
601
599 return status;
602 return status;
600 }
603 }
601
604
602 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
605 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
603 {
606 {
604 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
607 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
605 *
608 *
606 * @param TC points to the TeleCommand packet that is being processed
609 * @param TC points to the TeleCommand packet that is being processed
607 * @param queue_id is the id of the queue which handles TM related to this execution step
610 * @param queue_id is the id of the queue which handles TM related to this execution step
608 *
611 *
609 */
612 */
610
613
611 int status;
614 int status;
612 unsigned char val;
615 unsigned char val;
613
616
614 status = LFR_SUCCESSFUL;
617 status = LFR_SUCCESSFUL;
615
618
616 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
619 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
617
620
618 if (val < DEFAULT_SY_LFR_B_BP_P1 )
621 if (val < DEFAULT_SY_LFR_B_BP_P1 )
619 {
622 {
620 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, val );
623 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, val );
621 status = WRONG_APP_DATA;
624 status = WRONG_APP_DATA;
622 }
625 }
623 else
626 else
624 {
627 {
625 parameter_dump_packet.sy_lfr_b_bp_p1 = val;
628 parameter_dump_packet.sy_lfr_b_bp_p1 = val;
626 }
629 }
627
630
628 return status;
631 return status;
629 }
632 }
630
633
631 //*********************
634 //*********************
632 // SBM1 MODE PARAMETERS
635 // SBM1 MODE PARAMETERS
633 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
636 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
634 {
637 {
635 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
638 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
636 *
639 *
637 * @param TC points to the TeleCommand packet that is being processed
640 * @param TC points to the TeleCommand packet that is being processed
638 * @param queue_id is the id of the queue which handles TM related to this execution step
641 * @param queue_id is the id of the queue which handles TM related to this execution step
639 *
642 *
640 */
643 */
641
644
642 int status;
645 int status;
643 unsigned char val;
646 unsigned char val;
644
647
645 status = LFR_SUCCESSFUL;
648 status = LFR_SUCCESSFUL;
646
649
647 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
650 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
648
651
649 if (val < DEFAULT_SY_LFR_S1_BP_P0 )
652 if (val < DEFAULT_SY_LFR_S1_BP_P0 )
650 {
653 {
651 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, val );
654 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, val );
652 status = WRONG_APP_DATA;
655 status = WRONG_APP_DATA;
653 }
656 }
654 else
657 else
655 {
658 {
656 parameter_dump_packet.sy_lfr_s1_bp_p0 = val;
659 parameter_dump_packet.sy_lfr_s1_bp_p0 = val;
657 }
660 }
658
661
659 return status;
662 return status;
660 }
663 }
661
664
662 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
665 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
663 {
666 {
664 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
667 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
665 *
668 *
666 * @param TC points to the TeleCommand packet that is being processed
669 * @param TC points to the TeleCommand packet that is being processed
667 * @param queue_id is the id of the queue which handles TM related to this execution step
670 * @param queue_id is the id of the queue which handles TM related to this execution step
668 *
671 *
669 */
672 */
670
673
671 int status;
674 int status;
672 unsigned char val;
675 unsigned char val;
673
676
674 status = LFR_SUCCESSFUL;
677 status = LFR_SUCCESSFUL;
675
678
676 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
679 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
677
680
678 if (val < DEFAULT_SY_LFR_S1_BP_P1 )
681 if (val < DEFAULT_SY_LFR_S1_BP_P1 )
679 {
682 {
680 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, val );
683 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, val );
681 status = WRONG_APP_DATA;
684 status = WRONG_APP_DATA;
682 }
685 }
683 else
686 else
684 {
687 {
685 parameter_dump_packet.sy_lfr_s1_bp_p1 = val;
688 parameter_dump_packet.sy_lfr_s1_bp_p1 = val;
686 }
689 }
687
690
688 return status;
691 return status;
689 }
692 }
690
693
691 //*********************
694 //*********************
692 // SBM2 MODE PARAMETERS
695 // SBM2 MODE PARAMETERS
693 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
696 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
694 {
697 {
695 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
698 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
696 *
699 *
697 * @param TC points to the TeleCommand packet that is being processed
700 * @param TC points to the TeleCommand packet that is being processed
698 * @param queue_id is the id of the queue which handles TM related to this execution step
701 * @param queue_id is the id of the queue which handles TM related to this execution step
699 *
702 *
700 */
703 */
701
704
702 int status;
705 int status;
703 unsigned char val;
706 unsigned char val;
704
707
705 status = LFR_SUCCESSFUL;
708 status = LFR_SUCCESSFUL;
706
709
707 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
710 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
708
711
709 if (val < DEFAULT_SY_LFR_S2_BP_P0 )
712 if (val < DEFAULT_SY_LFR_S2_BP_P0 )
710 {
713 {
711 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, val );
714 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, val );
712 status = WRONG_APP_DATA;
715 status = WRONG_APP_DATA;
713 }
716 }
714 else
717 else
715 {
718 {
716 parameter_dump_packet.sy_lfr_s2_bp_p0 = val;
719 parameter_dump_packet.sy_lfr_s2_bp_p0 = val;
717 }
720 }
718
721
719 return status;
722 return status;
720 }
723 }
721
724
722 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
725 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
723 {
726 {
724 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
727 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
725 *
728 *
726 * @param TC points to the TeleCommand packet that is being processed
729 * @param TC points to the TeleCommand packet that is being processed
727 * @param queue_id is the id of the queue which handles TM related to this execution step
730 * @param queue_id is the id of the queue which handles TM related to this execution step
728 *
731 *
729 */
732 */
730
733
731 int status;
734 int status;
732 unsigned char val;
735 unsigned char val;
733
736
734 status = LFR_SUCCESSFUL;
737 status = LFR_SUCCESSFUL;
735
738
736 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
739 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
737
740
738 if (val < DEFAULT_SY_LFR_S2_BP_P1 )
741 if (val < DEFAULT_SY_LFR_S2_BP_P1 )
739 {
742 {
740 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, val );
743 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, val );
741 status = WRONG_APP_DATA;
744 status = WRONG_APP_DATA;
742 }
745 }
743 else
746 else
744 {
747 {
745 parameter_dump_packet.sy_lfr_s2_bp_p1 = val;
748 parameter_dump_packet.sy_lfr_s2_bp_p1 = val;
746 }
749 }
747
750
748 return status;
751 return status;
749 }
752 }
750
753
751
754
752 //*******************
755 //*******************
753 // TC_LFR_UPDATE_INFO
756 // TC_LFR_UPDATE_INFO
754 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
757 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
755 {
758 {
756 unsigned int status;
759 unsigned int status;
757
760
758 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
761 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
759 || (mode == LFR_MODE_BURST)
762 || (mode == LFR_MODE_BURST)
760 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
763 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
761 {
764 {
762 status = LFR_SUCCESSFUL;
765 status = LFR_SUCCESSFUL;
763 }
766 }
764 else
767 else
765 {
768 {
766 status = LFR_DEFAULT;
769 status = LFR_DEFAULT;
767 }
770 }
768
771
769 return status;
772 return status;
770 }
773 }
771
774
772 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
775 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
773 {
776 {
774 unsigned int status;
777 unsigned int status;
775
778
776 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
779 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
777 || (mode == TDS_MODE_BURST)
780 || (mode == TDS_MODE_BURST)
778 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
781 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
779 || (mode == TDS_MODE_LFM))
782 || (mode == TDS_MODE_LFM))
780 {
783 {
781 status = LFR_SUCCESSFUL;
784 status = LFR_SUCCESSFUL;
782 }
785 }
783 else
786 else
784 {
787 {
785 status = LFR_DEFAULT;
788 status = LFR_DEFAULT;
786 }
789 }
787
790
788 return status;
791 return status;
789 }
792 }
790
793
791 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
794 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
792 {
795 {
793 unsigned int status;
796 unsigned int status;
794
797
795 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
798 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
796 || (mode == THR_MODE_BURST))
799 || (mode == THR_MODE_BURST))
797 {
800 {
798 status = LFR_SUCCESSFUL;
801 status = LFR_SUCCESSFUL;
799 }
802 }
800 else
803 else
801 {
804 {
802 status = LFR_DEFAULT;
805 status = LFR_DEFAULT;
803 }
806 }
804
807
805 return status;
808 return status;
806 }
809 }
807
810
808 //**********
811 //**********
809 // init dump
812 // init dump
810
813
811 void init_parameter_dump( void )
814 void init_parameter_dump( void )
812 {
815 {
813 /** This function initialize the parameter_dump_packet global variable with default values.
816 /** This function initialize the parameter_dump_packet global variable with default values.
814 *
817 *
815 */
818 */
816
819
817 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
820 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
818 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
821 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
819 parameter_dump_packet.reserved = CCSDS_RESERVED;
822 parameter_dump_packet.reserved = CCSDS_RESERVED;
820 parameter_dump_packet.userApplication = CCSDS_USER_APP;
823 parameter_dump_packet.userApplication = CCSDS_USER_APP;
821 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
824 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
822 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
825 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
823 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
826 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
824 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
827 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
825 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
828 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
826 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
829 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
827 // DATA FIELD HEADER
830 // DATA FIELD HEADER
828 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
831 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
829 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
832 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
830 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
833 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
831 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
834 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
832 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
835 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
833 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
836 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
834 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
837 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
835 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
838 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
836 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
839 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
837 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
840 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
838 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
841 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
839
842
840 //******************
843 //******************
841 // COMMON PARAMETERS
844 // COMMON PARAMETERS
842 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
845 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
843 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
846 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
844
847
845 //******************
848 //******************
846 // NORMAL PARAMETERS
849 // NORMAL PARAMETERS
847 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
850 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
848 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
851 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
849 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
852 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
850 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
853 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
851 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
854 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
852 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
855 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
853 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
856 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
854 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
857 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
855 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
858 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
856
859
857 //*****************
860 //*****************
858 // BURST PARAMETERS
861 // BURST PARAMETERS
859 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
862 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
860 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
863 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
861
864
862 //****************
865 //****************
863 // SBM1 PARAMETERS
866 // SBM1 PARAMETERS
864 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
867 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
865 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
868 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
866
869
867 //****************
870 //****************
868 // SBM2 PARAMETERS
871 // SBM2 PARAMETERS
869 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
872 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
870 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
873 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
871 }
874 }
872
875
873
876
874
877
875
878
876
879
877
880
878
881
General Comments 0
You need to be logged in to leave comments. Login now