##// END OF EJS Templates
There is a message queue between AVFO and MATR...
paul -
r118:7b69e91ff96b VHDLib206
parent child
Show More
@@ -1,253 +1,253
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 3 13:43:01 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Apr 15 07:45:50 2014
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 #############################################################################
7 #############################################################################
8
8
9 ####### Compiler, tools and options
9 ####### Compiler, tools and options
10
10
11 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
14 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../../LFR_basic-parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/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_processing.c \
48 ../src/fsw_processing.c \
49 ../src/fsw_misc.c \
49 ../src/fsw_misc.c \
50 ../src/fsw_init.c \
50 ../src/fsw_init.c \
51 ../src/fsw_globals.c \
51 ../src/fsw_globals.c \
52 ../src/fsw_spacewire.c \
52 ../src/fsw_spacewire.c \
53 ../src/tc_load_dump_parameters.c \
53 ../src/tc_load_dump_parameters.c \
54 ../src/tm_lfr_tc_exe.c \
54 ../src/tm_lfr_tc_exe.c \
55 ../src/tc_acceptance.c \
55 ../src/tc_acceptance.c \
56 ../../LFR_basic-parameters/basic_parameters.c
56 ../src/basic_parameters/basic_parameters.c
57 OBJECTS = obj/wf_handler.o \
57 OBJECTS = obj/wf_handler.o \
58 obj/tc_handler.o \
58 obj/tc_handler.o \
59 obj/fsw_processing.o \
59 obj/fsw_processing.o \
60 obj/fsw_misc.o \
60 obj/fsw_misc.o \
61 obj/fsw_init.o \
61 obj/fsw_init.o \
62 obj/fsw_globals.o \
62 obj/fsw_globals.o \
63 obj/fsw_spacewire.o \
63 obj/fsw_spacewire.o \
64 obj/tc_load_dump_parameters.o \
64 obj/tc_load_dump_parameters.o \
65 obj/tm_lfr_tc_exe.o \
65 obj/tm_lfr_tc_exe.o \
66 obj/tc_acceptance.o \
66 obj/tc_acceptance.o \
67 obj/basic_parameters.o
67 obj/basic_parameters.o
68 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
68 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
69 /usr/lib64/qt4/mkspecs/common/linux.conf \
69 /usr/lib64/qt4/mkspecs/common/linux.conf \
70 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
70 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
71 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
71 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
72 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
72 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
73 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
73 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
74 /usr/lib64/qt4/mkspecs/qconfig.pri \
74 /usr/lib64/qt4/mkspecs/qconfig.pri \
75 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
75 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
76 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
76 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
77 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
77 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
78 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
78 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
79 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
79 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
80 sparc.pri \
80 sparc.pri \
81 /usr/lib64/qt4/mkspecs/features/release.prf \
81 /usr/lib64/qt4/mkspecs/features/release.prf \
82 /usr/lib64/qt4/mkspecs/features/default_post.prf \
82 /usr/lib64/qt4/mkspecs/features/default_post.prf \
83 /usr/lib64/qt4/mkspecs/features/shared.prf \
83 /usr/lib64/qt4/mkspecs/features/shared.prf \
84 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
84 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
85 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
85 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
86 /usr/lib64/qt4/mkspecs/features/resources.prf \
86 /usr/lib64/qt4/mkspecs/features/resources.prf \
87 /usr/lib64/qt4/mkspecs/features/uic.prf \
87 /usr/lib64/qt4/mkspecs/features/uic.prf \
88 /usr/lib64/qt4/mkspecs/features/yacc.prf \
88 /usr/lib64/qt4/mkspecs/features/yacc.prf \
89 /usr/lib64/qt4/mkspecs/features/lex.prf \
89 /usr/lib64/qt4/mkspecs/features/lex.prf \
90 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
90 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
91 fsw-qt.pro
91 fsw-qt.pro
92 QMAKE_TARGET = fsw
92 QMAKE_TARGET = fsw
93 DESTDIR = bin/
93 DESTDIR = bin/
94 TARGET = bin/fsw
94 TARGET = bin/fsw
95
95
96 first: all
96 first: all
97 ####### Implicit rules
97 ####### Implicit rules
98
98
99 .SUFFIXES: .o .c .cpp .cc .cxx .C
99 .SUFFIXES: .o .c .cpp .cc .cxx .C
100
100
101 .cpp.o:
101 .cpp.o:
102 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
102 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
103
103
104 .cc.o:
104 .cc.o:
105 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
105 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
106
106
107 .cxx.o:
107 .cxx.o:
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
109
109
110 .C.o:
110 .C.o:
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
112
112
113 .c.o:
113 .c.o:
114 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
114 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
115
115
116 ####### Build rules
116 ####### Build rules
117
117
118 all: Makefile $(TARGET)
118 all: Makefile $(TARGET)
119
119
120 $(TARGET): $(OBJECTS)
120 $(TARGET): $(OBJECTS)
121 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
121 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
122 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
122 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
123
123
124 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
124 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
125 /usr/lib64/qt4/mkspecs/common/linux.conf \
125 /usr/lib64/qt4/mkspecs/common/linux.conf \
126 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
126 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
127 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
127 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
128 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
128 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
129 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
129 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
130 /usr/lib64/qt4/mkspecs/qconfig.pri \
130 /usr/lib64/qt4/mkspecs/qconfig.pri \
131 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
131 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
132 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
132 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
133 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
133 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
134 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
134 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
135 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
135 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
136 sparc.pri \
136 sparc.pri \
137 /usr/lib64/qt4/mkspecs/features/release.prf \
137 /usr/lib64/qt4/mkspecs/features/release.prf \
138 /usr/lib64/qt4/mkspecs/features/default_post.prf \
138 /usr/lib64/qt4/mkspecs/features/default_post.prf \
139 /usr/lib64/qt4/mkspecs/features/shared.prf \
139 /usr/lib64/qt4/mkspecs/features/shared.prf \
140 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
140 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
141 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
141 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
142 /usr/lib64/qt4/mkspecs/features/resources.prf \
142 /usr/lib64/qt4/mkspecs/features/resources.prf \
143 /usr/lib64/qt4/mkspecs/features/uic.prf \
143 /usr/lib64/qt4/mkspecs/features/uic.prf \
144 /usr/lib64/qt4/mkspecs/features/yacc.prf \
144 /usr/lib64/qt4/mkspecs/features/yacc.prf \
145 /usr/lib64/qt4/mkspecs/features/lex.prf \
145 /usr/lib64/qt4/mkspecs/features/lex.prf \
146 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
146 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
147 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
147 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
148 /usr/lib64/qt4/mkspecs/common/unix.conf:
148 /usr/lib64/qt4/mkspecs/common/unix.conf:
149 /usr/lib64/qt4/mkspecs/common/linux.conf:
149 /usr/lib64/qt4/mkspecs/common/linux.conf:
150 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
150 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
151 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
151 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
152 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
152 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
153 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
153 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
154 /usr/lib64/qt4/mkspecs/qconfig.pri:
154 /usr/lib64/qt4/mkspecs/qconfig.pri:
155 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
155 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
156 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
156 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
157 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
157 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
158 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
158 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
159 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
159 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
160 sparc.pri:
160 sparc.pri:
161 /usr/lib64/qt4/mkspecs/features/release.prf:
161 /usr/lib64/qt4/mkspecs/features/release.prf:
162 /usr/lib64/qt4/mkspecs/features/default_post.prf:
162 /usr/lib64/qt4/mkspecs/features/default_post.prf:
163 /usr/lib64/qt4/mkspecs/features/shared.prf:
163 /usr/lib64/qt4/mkspecs/features/shared.prf:
164 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
164 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
165 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
165 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
166 /usr/lib64/qt4/mkspecs/features/resources.prf:
166 /usr/lib64/qt4/mkspecs/features/resources.prf:
167 /usr/lib64/qt4/mkspecs/features/uic.prf:
167 /usr/lib64/qt4/mkspecs/features/uic.prf:
168 /usr/lib64/qt4/mkspecs/features/yacc.prf:
168 /usr/lib64/qt4/mkspecs/features/yacc.prf:
169 /usr/lib64/qt4/mkspecs/features/lex.prf:
169 /usr/lib64/qt4/mkspecs/features/lex.prf:
170 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
170 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
171 qmake: FORCE
171 qmake: FORCE
172 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
172 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
173
173
174 dist:
174 dist:
175 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
175 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
176 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
176 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
177
177
178
178
179 clean:compiler_clean
179 clean:compiler_clean
180 -$(DEL_FILE) $(OBJECTS)
180 -$(DEL_FILE) $(OBJECTS)
181 -$(DEL_FILE) *~ core *.core
181 -$(DEL_FILE) *~ core *.core
182
182
183
183
184 ####### Sub-libraries
184 ####### Sub-libraries
185
185
186 distclean: clean
186 distclean: clean
187 -$(DEL_FILE) $(TARGET)
187 -$(DEL_FILE) $(TARGET)
188 -$(DEL_FILE) Makefile
188 -$(DEL_FILE) Makefile
189
189
190
190
191 grmon:
191 grmon:
192 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
192 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
193
193
194 check: first
194 check: first
195
195
196 compiler_rcc_make_all:
196 compiler_rcc_make_all:
197 compiler_rcc_clean:
197 compiler_rcc_clean:
198 compiler_uic_make_all:
198 compiler_uic_make_all:
199 compiler_uic_clean:
199 compiler_uic_clean:
200 compiler_image_collection_make_all: qmake_image_collection.cpp
200 compiler_image_collection_make_all: qmake_image_collection.cpp
201 compiler_image_collection_clean:
201 compiler_image_collection_clean:
202 -$(DEL_FILE) qmake_image_collection.cpp
202 -$(DEL_FILE) qmake_image_collection.cpp
203 compiler_yacc_decl_make_all:
203 compiler_yacc_decl_make_all:
204 compiler_yacc_decl_clean:
204 compiler_yacc_decl_clean:
205 compiler_yacc_impl_make_all:
205 compiler_yacc_impl_make_all:
206 compiler_yacc_impl_clean:
206 compiler_yacc_impl_clean:
207 compiler_lex_make_all:
207 compiler_lex_make_all:
208 compiler_lex_clean:
208 compiler_lex_clean:
209 compiler_clean:
209 compiler_clean:
210
210
211 ####### Compile
211 ####### Compile
212
212
213 obj/wf_handler.o: ../src/wf_handler.c
213 obj/wf_handler.o: ../src/wf_handler.c
214 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
214 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
215
215
216 obj/tc_handler.o: ../src/tc_handler.c
216 obj/tc_handler.o: ../src/tc_handler.c
217 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
217 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
218
218
219 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
219 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
220 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
221
221
222 obj/fsw_misc.o: ../src/fsw_misc.c
222 obj/fsw_misc.o: ../src/fsw_misc.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
223 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
224
224
225 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
225 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
226 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
227
227
228 obj/fsw_globals.o: ../src/fsw_globals.c
228 obj/fsw_globals.o: ../src/fsw_globals.c
229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
229 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
230
230
231 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
231 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
232 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
233
233
234 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
234 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
235 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
236
236
237 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
237 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
238 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
239
239
240 obj/tc_acceptance.o: ../src/tc_acceptance.c
240 obj/tc_acceptance.o: ../src/tc_acceptance.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
242
242
243 obj/basic_parameters.o: ../../LFR_basic-parameters/basic_parameters.c ../../LFR_basic-parameters/basic_parameters.h
243 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../../LFR_basic-parameters/basic_parameters.c
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
245
245
246 ####### Install
246 ####### Install
247
247
248 install: FORCE
248 install: FORCE
249
249
250 uninstall: FORCE
250 uninstall: FORCE
251
251
252 FORCE:
252 FORCE:
253
253
@@ -1,85 +1,85
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 CONFIG += console verbose cpu_usage_report
4 CONFIG += console verbose cpu_usage_report
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
8
8
9 # flight software version
9 # flight software version
10 SWVERSION=-1-0
10 SWVERSION=-1-0
11 DEFINES += SW_VERSION_N1=1 # major
11 DEFINES += SW_VERSION_N1=1 # major
12 DEFINES += SW_VERSION_N2=0 # minor
12 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N3=0 # patch
13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=6 # internal
14 DEFINES += SW_VERSION_N4=6 # internal
15
15
16 contains( CONFIG, debug_tch ) {
16 contains( CONFIG, debug_tch ) {
17 DEFINES += DEBUG_TCH
17 DEFINES += DEBUG_TCH
18 }
18 }
19
19
20 contains( CONFIG, vhdl_dev ) {
20 contains( CONFIG, vhdl_dev ) {
21 DEFINES += VHDL_DEV
21 DEFINES += VHDL_DEV
22 }
22 }
23
23
24 contains( CONFIG, verbose ) {
24 contains( CONFIG, verbose ) {
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 }
26 }
27
27
28 contains( CONFIG, debug_messages ) {
28 contains( CONFIG, debug_messages ) {
29 DEFINES += DEBUG_MESSAGES
29 DEFINES += DEBUG_MESSAGES
30 }
30 }
31
31
32 contains( CONFIG, cpu_usage_report ) {
32 contains( CONFIG, cpu_usage_report ) {
33 DEFINES += PRINT_TASK_STATISTICS
33 DEFINES += PRINT_TASK_STATISTICS
34 }
34 }
35
35
36 contains( CONFIG, stack_report ) {
36 contains( CONFIG, stack_report ) {
37 DEFINES += PRINT_STACK_REPORT
37 DEFINES += PRINT_STACK_REPORT
38 }
38 }
39
39
40 contains( CONFIG, boot_messages ) {
40 contains( CONFIG, boot_messages ) {
41 DEFINES += BOOT_MESSAGES
41 DEFINES += BOOT_MESSAGES
42 }
42 }
43
43
44 #doxygen.target = doxygen
44 #doxygen.target = doxygen
45 #doxygen.commands = doxygen ../doc/Doxyfile
45 #doxygen.commands = doxygen ../doc/Doxyfile
46 #QMAKE_EXTRA_TARGETS += doxygen
46 #QMAKE_EXTRA_TARGETS += doxygen
47
47
48 TARGET = fsw
48 TARGET = fsw
49
49
50 INCLUDEPATH += \
50 INCLUDEPATH += \
51 ../src \
51 ../src \
52 ../header \
52 ../header \
53 ../../LFR_basic-parameters
53 ../src/basic_parameters
54
54
55 SOURCES += \
55 SOURCES += \
56 ../src/wf_handler.c \
56 ../src/wf_handler.c \
57 ../src/tc_handler.c \
57 ../src/tc_handler.c \
58 ../src/fsw_processing.c \
58 ../src/fsw_processing.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 ../../LFR_basic-parameters/basic_parameters.c
66 ../src/basic_parameters/basic_parameters.c
67
67
68
68
69 HEADERS += \
69 HEADERS += \
70 ../header/wf_handler.h \
70 ../header/wf_handler.h \
71 ../header/tc_handler.h \
71 ../header/tc_handler.h \
72 ../header/grlib_regs.h \
72 ../header/grlib_regs.h \
73 ../header/fsw_processing.h \
73 ../header/fsw_processing.h \
74 ../header/fsw_params.h \
74 ../header/fsw_params.h \
75 ../header/fsw_misc.h \
75 ../header/fsw_misc.h \
76 ../header/fsw_init.h \
76 ../header/fsw_init.h \
77 ../header/ccsds_types.h \
77 ../header/ccsds_types.h \
78 ../header/fsw_params_processing.h \
78 ../header/fsw_params_processing.h \
79 ../header/fsw_spacewire.h \
79 ../header/fsw_spacewire.h \
80 ../header/tc_load_dump_parameters.h \
80 ../header/tc_load_dump_parameters.h \
81 ../header/tm_lfr_tc_exe.h \
81 ../header/tm_lfr_tc_exe.h \
82 ../header/tc_acceptance.h \
82 ../header/tc_acceptance.h \
83 ../header/fsw_params_nb_bytes.h \
83 ../header/fsw_params_nb_bytes.h \
84 ../../LFR_basic-parameters/basic_parameters.h
84 ../src/basic_parameters/basic_parameters.h
85
85
@@ -1,339 +1,339
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-11T12:08:35. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-16T10:43:41. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">1</value>
7 <value type="int">1</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</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e04e3924-0bd8-4708-be18-f1474e45608e}</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">false</value>
180 <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</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.Target.1</variable>
190 <variable>ProjectExplorer.Project.Target.1</variable>
191 <valuemap type="QVariantMap">
191 <valuemap type="QVariantMap">
192 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
192 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
193 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
193 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
194 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
194 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
195 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
195 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
196 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
196 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
197 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
197 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
198 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
198 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
199 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
199 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
200 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
200 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
201 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
201 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
202 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
202 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
203 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
203 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
204 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
204 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
205 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
205 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
206 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
206 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
207 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
207 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
208 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
208 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
209 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
209 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
210 </valuemap>
210 </valuemap>
211 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
211 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
212 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
212 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
213 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
213 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
214 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
214 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
215 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
215 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
216 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
216 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
217 <value type="QString">-w</value>
217 <value type="QString">-w</value>
218 <value type="QString">-r</value>
218 <value type="QString">-r</value>
219 </valuelist>
219 </valuelist>
220 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
220 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
221 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
221 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
222 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
222 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
223 </valuemap>
223 </valuemap>
224 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
224 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
225 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
225 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
226 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
226 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
228 </valuemap>
228 </valuemap>
229 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
229 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
230 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
230 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
231 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
231 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
232 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
232 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
233 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
233 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
234 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
234 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
235 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
235 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
236 <value type="QString">-w</value>
236 <value type="QString">-w</value>
237 <value type="QString">-r</value>
237 <value type="QString">-r</value>
238 </valuelist>
238 </valuelist>
239 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
239 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
240 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
240 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
241 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
241 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
242 </valuemap>
242 </valuemap>
243 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
243 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
244 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
244 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
245 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
245 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
246 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
246 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
247 </valuemap>
247 </valuemap>
248 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
248 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
249 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
249 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
250 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
250 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
251 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
251 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
252 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
252 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
253 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
253 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
254 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
254 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
255 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
255 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
256 </valuemap>
256 </valuemap>
257 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
257 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
258 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
258 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
259 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
259 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
260 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
260 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
261 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
261 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
262 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
262 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
263 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
263 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
264 </valuemap>
264 </valuemap>
265 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
265 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
266 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
266 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
267 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
267 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
268 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
268 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
269 </valuemap>
269 </valuemap>
270 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
270 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
271 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
271 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
272 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
272 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
273 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
273 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
274 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
274 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
275 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
275 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
276 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
276 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
277 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
277 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
278 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
278 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
279 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
279 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
280 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
280 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
281 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
281 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
282 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
282 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
283 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
283 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
284 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
284 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
285 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
285 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
286 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
286 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
287 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
287 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
288 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
288 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
289 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
289 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
290 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
290 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
291 <value type="int">0</value>
291 <value type="int">0</value>
292 <value type="int">1</value>
292 <value type="int">1</value>
293 <value type="int">2</value>
293 <value type="int">2</value>
294 <value type="int">3</value>
294 <value type="int">3</value>
295 <value type="int">4</value>
295 <value type="int">4</value>
296 <value type="int">5</value>
296 <value type="int">5</value>
297 <value type="int">6</value>
297 <value type="int">6</value>
298 <value type="int">7</value>
298 <value type="int">7</value>
299 <value type="int">8</value>
299 <value type="int">8</value>
300 <value type="int">9</value>
300 <value type="int">9</value>
301 <value type="int">10</value>
301 <value type="int">10</value>
302 <value type="int">11</value>
302 <value type="int">11</value>
303 <value type="int">12</value>
303 <value type="int">12</value>
304 <value type="int">13</value>
304 <value type="int">13</value>
305 <value type="int">14</value>
305 <value type="int">14</value>
306 </valuelist>
306 </valuelist>
307 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
307 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
308 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
308 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
309 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
309 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
310 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
310 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
311 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
311 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
312 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
312 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
313 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
313 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
314 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
314 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
315 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
315 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
316 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
316 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
317 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
317 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
318 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
318 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
319 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
319 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
320 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
320 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
321 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
321 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
322 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
322 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
323 </valuemap>
323 </valuemap>
324 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
324 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
325 </valuemap>
325 </valuemap>
326 </data>
326 </data>
327 <data>
327 <data>
328 <variable>ProjectExplorer.Project.TargetCount</variable>
328 <variable>ProjectExplorer.Project.TargetCount</variable>
329 <value type="int">2</value>
329 <value type="int">2</value>
330 </data>
330 </data>
331 <data>
331 <data>
332 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
332 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
333 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
333 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
334 </data>
334 </data>
335 <data>
335 <data>
336 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
336 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
337 <value type="int">15</value>
337 <value type="int">15</value>
338 </data>
338 </data>
339 </qtcreator>
339 </qtcreator>
@@ -1,41 +1,42
1 #ifndef FSW_INIT_H_INCLUDED
1 #ifndef FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9 #include "fsw_processing.h"
9 #include "fsw_processing.h"
10 #include "tc_handler.h"
10 #include "tc_handler.h"
11 #include "wf_handler.h"
11 #include "wf_handler.h"
12
12
13 #include "fsw_spacewire.h"
13 #include "fsw_spacewire.h"
14
14
15 extern rtems_name Task_name[20]; /* array of task names */
15 extern rtems_name Task_name[20]; /* array of task names */
16 extern rtems_id Task_id[20]; /* array of task ids */
16 extern rtems_id Task_id[20]; /* array of task ids */
17
17
18 // RTEMS TASKS
18 // RTEMS TASKS
19 rtems_task Init( rtems_task_argument argument);
19 rtems_task Init( rtems_task_argument argument);
20
20
21 // OTHER functions
21 // OTHER functions
22 void create_names( void );
22 void create_names( void );
23 int create_all_tasks( void );
23 int create_all_tasks( void );
24 int start_all_tasks( void );
24 int start_all_tasks( void );
25 //
25 //
26 rtems_status_code create_message_queues( void );
26 rtems_status_code create_message_queues( void );
27 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
27 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
28 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
28 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
29 rtems_status_code get_message_queue_id_matr( rtems_id *queue_id );
29 //
30 //
30 int start_recv_send_tasks( void );
31 int start_recv_send_tasks( void );
31 //
32 //
32 void init_local_mode_parameters( void );
33 void init_local_mode_parameters( void );
33 void reset_local_time( void );
34 void reset_local_time( void );
34
35
35 extern int rtems_cpu_usage_report( void );
36 extern int rtems_cpu_usage_report( void );
36 extern int rtems_cpu_usage_reset( void );
37 extern int rtems_cpu_usage_reset( void );
37 extern void rtems_stack_checker_report_usage( void );
38 extern void rtems_stack_checker_report_usage( void );
38
39
39 extern int sched_yield( void );
40 extern int sched_yield( void );
40
41
41 #endif // FSW_INIT_H_INCLUDED
42 #endif // FSW_INIT_H_INCLUDED
@@ -1,40 +1,42
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
10
11 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
11 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
12 rtems_id HK_id; // id of the HK rate monotonic period
12 rtems_id HK_id; // id of the HK rate monotonic period
13
13
14 //extern rtems_name misc_name[5];
14 //extern rtems_name misc_name[5];
15 //time_management_regs_t *time_management_regs;
15 //time_management_regs_t *time_management_regs;
16 //extern Packet_TM_LFR_HK_t housekeeping_packet;
16 //extern Packet_TM_LFR_HK_t housekeeping_packet;
17
17
18 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
18 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
20 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
20 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
22 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
23
23
24 // SERIAL LINK
24 // SERIAL LINK
25 int send_console_outputs_on_apbuart_port( void );
25 int send_console_outputs_on_apbuart_port( void );
26 int enable_apbuart_transmitter( void );
26 int enable_apbuart_transmitter( void );
27 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
27 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
28
28
29 // RTEMS TASKS
29 // RTEMS TASKS
30 rtems_task stat_task( rtems_task_argument argument );
30 rtems_task stat_task( rtems_task_argument argument );
31 rtems_task hous_task( rtems_task_argument argument );
31 rtems_task hous_task( rtems_task_argument argument );
32 rtems_task dumb_task( rtems_task_argument unused );
32 rtems_task dumb_task( rtems_task_argument unused );
33
33
34 void init_housekeeping_parameters( void );
34 void init_housekeeping_parameters( void );
35 void increment_seq_counter( unsigned char *packet_sequence_control);
35 void increment_seq_counter( unsigned char *packet_sequence_control);
36 void getTime( unsigned char *time);
36 void getTime( unsigned char *time);
37 unsigned long long int getTimeAsUnsignedLongLongInt( );
37 unsigned long long int getTimeAsUnsignedLongLongInt( );
38 void send_dumb_hk( void );
38 void send_dumb_hk( void );
39
39
40 extern int sched_yield( void );
41
40 #endif // FSW_MISC_H_INCLUDED
42 #endif // FSW_MISC_H_INCLUDED
@@ -1,252 +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 typedef struct {
21 typedef struct {
22 unsigned int f0;
22 unsigned int f0;
23 unsigned int norm_bp1_f0;
23 unsigned int norm_bp1_f0;
24 unsigned int norm_bp2_f0;
24 unsigned int norm_bp2_f0;
25 unsigned int norm_asm_f0;
25 unsigned int norm_asm_f0;
26 unsigned int sbm_bp1_f0;
26 unsigned int sbm_bp1_f0;
27 unsigned int sbm_bp2_f0;
27 unsigned int sbm_bp2_f0;
28 } nb_sm_t;
28 } nb_sm_t;
29
29
30 typedef struct {
30 typedef struct {
31 unsigned int norm_bp1_f0;
31 unsigned int norm_bp1_f0;
32 unsigned int norm_bp2_f0;
32 unsigned int norm_bp2_f0;
33 unsigned int norm_asm_f0;
33 unsigned int norm_asm_f0;
34 unsigned int burst_sbm_bp1_f0;
34 unsigned int burst_sbm_bp1_f0;
35 unsigned int burst_sbm_bp2_f0;
35 unsigned int burst_sbm_bp2_f0;
36 unsigned int burst_bp1_f0;
36 unsigned int burst_bp1_f0;
37 unsigned int burst_bp2_f0;
37 unsigned int burst_bp2_f0;
38 unsigned int sbm1_bp1_f0;
38 unsigned int sbm1_bp1_f0;
39 unsigned int sbm1_bp2_f0;
39 unsigned int sbm1_bp2_f0;
40 unsigned int sbm2_bp1_f0;
40 unsigned int sbm2_bp1_f0;
41 unsigned int sbm2_bp2_f0;
41 unsigned int sbm2_bp2_f0;
42 } nb_sm_before_bp_t;
42 } nb_sm_before_bp_t;
43
43
44 //************************
44 //************************
45 // flight software version
45 // flight software version
46 // this parameters is handled by the Qt project options
46 // this parameters is handled by the Qt project options
47
47
48 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
48 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
49 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
49 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
50 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
50 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
51 #define TIME_OFFSET 2
51 #define TIME_OFFSET 2
52 #define TIME_OFFSET_IN_BYTES 8
52 #define TIME_OFFSET_IN_BYTES 8
53 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
53 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
54 #define NB_BYTES_SWF_BLK (2 * 6)
54 #define NB_BYTES_SWF_BLK (2 * 6)
55 #define NB_WORDS_SWF_BLK 3
55 #define NB_WORDS_SWF_BLK 3
56 #define NB_BYTES_CWF3_LIGHT_BLK 6
56 #define NB_BYTES_CWF3_LIGHT_BLK 6
57 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
57 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
58 #define NB_RING_NODES_F0 3 // AT LEAST 3
58 #define NB_RING_NODES_F0 3 // AT LEAST 3
59 #define NB_RING_NODES_F1 5 // AT LEAST 3
59 #define NB_RING_NODES_F1 5 // AT LEAST 3
60 #define NB_RING_NODES_F2 5 // AT LEAST 3
60 #define NB_RING_NODES_F2 5 // AT LEAST 3
61
61
62 //**********
62 //**********
63 // LFR MODES
63 // LFR MODES
64 #define LFR_MODE_STANDBY 0
64 #define LFR_MODE_STANDBY 0
65 #define LFR_MODE_NORMAL 1
65 #define LFR_MODE_NORMAL 1
66 #define LFR_MODE_BURST 2
66 #define LFR_MODE_BURST 2
67 #define LFR_MODE_SBM1 3
67 #define LFR_MODE_SBM1 3
68 #define LFR_MODE_SBM2 4
68 #define LFR_MODE_SBM2 4
69
69
70 #define TDS_MODE_LFM 5
70 #define TDS_MODE_LFM 5
71 #define TDS_MODE_STANDBY 0
71 #define TDS_MODE_STANDBY 0
72 #define TDS_MODE_NORMAL 1
72 #define TDS_MODE_NORMAL 1
73 #define TDS_MODE_BURST 2
73 #define TDS_MODE_BURST 2
74 #define TDS_MODE_SBM1 3
74 #define TDS_MODE_SBM1 3
75 #define TDS_MODE_SBM2 4
75 #define TDS_MODE_SBM2 4
76
76
77 #define THR_MODE_STANDBY 0
77 #define THR_MODE_STANDBY 0
78 #define THR_MODE_NORMAL 1
78 #define THR_MODE_NORMAL 1
79 #define THR_MODE_BURST 2
79 #define THR_MODE_BURST 2
80
80
81 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
81 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
82 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
82 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
83 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
83 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
84 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
84 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
85 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
85 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
86 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
86 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
87 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
87 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
88 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
88 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
89 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
89 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
90 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_9
90 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_9
91 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_10
91 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_10
92
92
93 //****************************
93 //****************************
94 // LFR DEFAULT MODE PARAMETERS
94 // LFR DEFAULT MODE PARAMETERS
95 // COMMON
95 // COMMON
96 #define DEFAULT_SY_LFR_COMMON0 0x00
96 #define DEFAULT_SY_LFR_COMMON0 0x00
97 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
97 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
98 // NORM
98 // NORM
99 #define SY_LFR_N_SWF_L 2048 // nb sample
99 #define SY_LFR_N_SWF_L 2048 // nb sample
100 #define SY_LFR_N_SWF_P 300 // sec
100 #define SY_LFR_N_SWF_P 300 // sec
101 #define SY_LFR_N_ASM_P 3600 // sec
101 #define SY_LFR_N_ASM_P 3600 // sec
102 #define SY_LFR_N_BP_P0 4 // sec
102 #define SY_LFR_N_BP_P0 4 // sec
103 #define SY_LFR_N_BP_P1 20 // sec
103 #define SY_LFR_N_BP_P1 20 // sec
104 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
104 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
105 #define MIN_DELTA_SNAPSHOT 16 // sec
105 #define MIN_DELTA_SNAPSHOT 16 // sec
106 // BURST
106 // BURST
107 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
107 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
108 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
108 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
109 // SBM1
109 // SBM1
110 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
110 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
111 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
111 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
112 // SBM2
112 // SBM2
113 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
113 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
114 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
114 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
115 // ADDITIONAL PARAMETERS
115 // ADDITIONAL PARAMETERS
116 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
116 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
117 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
117 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
118 // STATUS WORD
118 // STATUS WORD
119 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
119 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
120 #define DEFAULT_STATUS_WORD_BYTE1 0x00
120 #define DEFAULT_STATUS_WORD_BYTE1 0x00
121 //
121 //
122 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
122 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
123 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
123 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
124 //****************************
124 //****************************
125
125
126 //*****************************
126 //*****************************
127 // APB REGISTERS BASE ADDRESSES
127 // APB REGISTERS BASE ADDRESSES
128 #define REGS_ADDR_APBUART 0x80000100
128 #define REGS_ADDR_APBUART 0x80000100
129 #define REGS_ADDR_GPTIMER 0x80000300
129 #define REGS_ADDR_GPTIMER 0x80000300
130 #define REGS_ADDR_GRSPW 0x80000500
130 #define REGS_ADDR_GRSPW 0x80000500
131 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
131 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
132 #define REGS_ADDR_GRGPIO 0x80000b00
132 #define REGS_ADDR_GRGPIO 0x80000b00
133
133
134 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
134 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
135 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
135 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
136
136
137 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
137 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
138 #define APBUART_CTRL_REG_MASK_TE 0x00000002
138 #define APBUART_CTRL_REG_MASK_TE 0x00000002
139 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
139 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
140
140
141 //**********
141 //**********
142 // IRQ LINES
142 // IRQ LINES
143 #define IRQ_SM_SIMULATOR 9
143 #define IRQ_SM_SIMULATOR 9
144 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
144 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
145 #define IRQ_WAVEFORM_PICKER 14
145 #define IRQ_WAVEFORM_PICKER 14
146 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
146 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
147 #define IRQ_SPECTRAL_MATRIX 6
147 #define IRQ_SPECTRAL_MATRIX 6
148 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
148 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
149
149
150 //*****
150 //*****
151 // TIME
151 // TIME
152 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
152 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
153 #define TIMER_SM_SIMULATOR 1
153 #define TIMER_SM_SIMULATOR 1
154 #define HK_PERIOD 100 // 100 * 10ms => 1s
154 #define HK_PERIOD 100 // 100 * 10ms => 1s
155 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
155 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
156 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
156 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
157
157
158 //**********
158 //**********
159 // LPP CODES
159 // LPP CODES
160 #define LFR_SUCCESSFUL 0
160 #define LFR_SUCCESSFUL 0
161 #define LFR_DEFAULT 1
161 #define LFR_DEFAULT 1
162 #define LFR_EXE_ERROR 2
162 #define LFR_EXE_ERROR 2
163
163
164 //******
164 //******
165 // RTEMS
165 // RTEMS
166 #define TASKID_RECV 1
166 #define TASKID_RECV 1
167 #define TASKID_ACTN 2
167 #define TASKID_ACTN 2
168 #define TASKID_SPIQ 3
168 #define TASKID_SPIQ 3
169 #define TASKID_SMIQ 4
169 #define TASKID_SMIQ 4
170 #define TASKID_STAT 5
170 #define TASKID_STAT 5
171 #define TASKID_AVF0 6
171 #define TASKID_AVF0 6
172 #define TASKID_SWBD 7
172 #define TASKID_SWBD 7
173 #define TASKID_WFRM 8
173 #define TASKID_WFRM 8
174 #define TASKID_DUMB 9
174 #define TASKID_DUMB 9
175 #define TASKID_HOUS 10
175 #define TASKID_HOUS 10
176 #define TASKID_MATR 11
176 #define TASKID_MATR 11
177 #define TASKID_CWF3 12
177 #define TASKID_CWF3 12
178 #define TASKID_CWF2 13
178 #define TASKID_CWF2 13
179 #define TASKID_CWF1 14
179 #define TASKID_CWF1 14
180 #define TASKID_SEND 15
180 #define TASKID_SEND 15
181 #define TASKID_WTDG 16
181 #define TASKID_WTDG 16
182
182
183 #define TASK_PRIORITY_SPIQ 5
183 #define TASK_PRIORITY_SPIQ 5
184 #define TASK_PRIORITY_SMIQ 10
184 #define TASK_PRIORITY_SMIQ 10
185 #define TASK_PRIORITY_WTDG 20
185 #define TASK_PRIORITY_WTDG 20
186 #define TASK_PRIORITY_HOUS 30
186 #define TASK_PRIORITY_HOUS 30
187 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
187 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
188 #define TASK_PRIORITY_CWF2 35 //
188 #define TASK_PRIORITY_CWF2 35 //
189 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
189 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
190 #define TASK_PRIORITY_WFRM 40
190 #define TASK_PRIORITY_WFRM 40
191 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
191 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
192 #define TASK_PRIORITY_SEND 45
192 #define TASK_PRIORITY_SEND 45
193 #define TASK_PRIORITY_RECV 50
193 #define TASK_PRIORITY_RECV 50
194 #define TASK_PRIORITY_ACTN 50
194 #define TASK_PRIORITY_ACTN 50
195 #define TASK_PRIORITY_AVF0 60
195 #define TASK_PRIORITY_AVF0 60
196 #define TASK_PRIORITY_BPF0 60
196 #define TASK_PRIORITY_BPF0 60
197 #define TASK_PRIORITY_MATR 100
197 #define TASK_PRIORITY_MATR 100
198 #define TASK_PRIORITY_STAT 200
198 #define TASK_PRIORITY_STAT 200
199 #define TASK_PRIORITY_DUMB 200
199 #define TASK_PRIORITY_DUMB 200
200
200
201 #define ACTION_MSG_QUEUE_COUNT 10
201 #define MSG_QUEUE_COUNT_RECV 10
202 #define ACTION_MSG_PKTS_COUNT 50
202 #define MSG_QUEUE_COUNT_SEND 50
203 //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
203 #define MSG_QUEUE_COUNT_MATR 10
204 #define ACTION_MSG_PKTS_MAX_SIZE 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
204 //#define MSG_QUEUE_SIZE_SEND (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
205 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
205 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
206 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
207 #define MSG_QUEUE_SIZE_MATR 20 // two pointers and one rtems_event + 2 integers
206
208
207 #define QUEUE_RECV 0
209 #define QUEUE_RECV 0
208 #define QUEUE_SEND 1
210 #define QUEUE_SEND 1
211 #define QUEUE_MATR 2
209
212
210 //*******
213 //*******
211 // MACROS
214 // MACROS
212 #ifdef PRINT_MESSAGES_ON_CONSOLE
215 #ifdef PRINT_MESSAGES_ON_CONSOLE
213 #define PRINTF(x) printf(x);
216 #define PRINTF(x) printf(x);
214 #define PRINTF1(x,y) printf(x,y);
217 #define PRINTF1(x,y) printf(x,y);
215 #define PRINTF2(x,y,z) printf(x,y,z);
218 #define PRINTF2(x,y,z) printf(x,y,z);
216 #else
219 #else
217 #define PRINTF(x) ;
220 #define PRINTF(x) ;
218 #define PRINTF1(x,y) ;
221 #define PRINTF1(x,y) ;
219 #define PRINTF2(x,y,z) ;
222 #define PRINTF2(x,y,z) ;
220 #endif
223 #endif
221
224
222 #ifdef BOOT_MESSAGES
225 #ifdef BOOT_MESSAGES
223 #define BOOT_PRINTF(x) printf(x);
226 #define BOOT_PRINTF(x) printf(x);
224 #define BOOT_PRINTF1(x,y) printf(x,y);
227 #define BOOT_PRINTF1(x,y) printf(x,y);
225 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
228 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
226 #else
229 #else
227 #define BOOT_PRINTF(x) ;
230 #define BOOT_PRINTF(x) ;
228 #define BOOT_PRINTF1(x,y) ;
231 #define BOOT_PRINTF1(x,y) ;
229 #define BOOT_PRINTF2(x,y,z) ;
232 #define BOOT_PRINTF2(x,y,z) ;
230 #endif
233 #endif
231
234
232 #ifdef DEBUG_MESSAGES
235 #ifdef DEBUG_MESSAGES
233 #define DEBUG_PRINTF(x) printf(x);
236 #define DEBUG_PRINTF(x) printf(x);
234 #define DEBUG_PRINTF1(x,y) printf(x,y);
237 #define DEBUG_PRINTF1(x,y) printf(x,y);
235 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
238 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
236 #else
239 #else
237 #define DEBUG_PRINTF(x) ;
240 #define DEBUG_PRINTF(x) ;
238 #define DEBUG_PRINTF1(x,y) ;
241 #define DEBUG_PRINTF1(x,y) ;
239 #define DEBUG_PRINTF2(x,y,z) ;
242 #define DEBUG_PRINTF2(x,y,z) ;
240 #endif
243 #endif
241
244
242 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
245 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
243
246
244 struct param_local_str{
247 struct param_local_str{
245 unsigned int local_sbm1_nb_cwf_sent;
248 unsigned int local_sbm1_nb_cwf_sent;
246 unsigned int local_sbm1_nb_cwf_max;
249 unsigned int local_sbm1_nb_cwf_max;
247 unsigned int local_sbm2_nb_cwf_sent;
250 unsigned int local_sbm2_nb_cwf_sent;
248 unsigned int local_sbm2_nb_cwf_max;
251 unsigned int local_sbm2_nb_cwf_max;
249 unsigned int local_nb_interrupt_f0_MAX;
252 unsigned int local_nb_interrupt_f0_MAX;
250 };
253 };
251
254
252 #endif // FSW_PARAMS_H_INCLUDED
255 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,66 +1,67
1 #ifndef FSW_PARAMS_PROCESSING_H
1 #ifndef FSW_PARAMS_PROCESSING_H
2 #define FSW_PARAMS_PROCESSING_H
2 #define FSW_PARAMS_PROCESSING_H
3
3
4 #define NB_BINS_PER_SM 128
4 #define NB_BINS_PER_SM 128
5 #define NB_VALUES_PER_SM 25
5 #define NB_VALUES_PER_SM 25
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
11 //
11 //
12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 3
12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 3
13 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
13 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
14 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
14 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
15 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
15 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
16 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
16 //
17 //
17 #define NB_BINS_PER_ASM_F0 88
18 #define NB_BINS_PER_ASM_F0 88
18 #define NB_BINS_PER_PKT_ASM_F0 44
19 #define NB_BINS_PER_PKT_ASM_F0 44
19 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
20 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
20 #define ASM_F0_INDICE_START 17 // 88 bins
21 #define ASM_F0_INDICE_START 17 // 88 bins
21 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
22 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
22 //
23 //
23 #define NB_BINS_PER_ASM_F1 104
24 #define NB_BINS_PER_ASM_F1 104
24 #define NB_BINS_PER_PKT_ASM_F1 52
25 #define NB_BINS_PER_PKT_ASM_F1 52
25 #define TOTAL_SIZE_ASM_F1 2600 // 25 * 104
26 #define TOTAL_SIZE_ASM_F1 2600 // 25 * 104
26 #define ASM_F1_INDICE_START 6 // 104 bins
27 #define ASM_F1_INDICE_START 6 // 104 bins
27 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
28 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
28 //
29 //
29 #define NB_BINS_PER_ASM_F2 96
30 #define NB_BINS_PER_ASM_F2 96
30 #define NB_BINS_PER_PKT_ASM_F2 48
31 #define NB_BINS_PER_PKT_ASM_F2 48
31 #define TOTAL_SIZE_ASM_F2 2400 // 25 * 96
32 #define TOTAL_SIZE_ASM_F2 2400 // 25 * 96
32 #define ASM_F2_INDICE_START 7 // 96 bins
33 #define ASM_F2_INDICE_START 7 // 96 bins
33 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
34 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
34 //
35 //
35 #define NB_BINS_COMPRESSED_SM_F0 11
36 #define NB_BINS_COMPRESSED_SM_F0 11
36 #define NB_BINS_COMPRESSED_SM_F1 13
37 #define NB_BINS_COMPRESSED_SM_F1 13
37 #define NB_BINS_COMPRESSED_SM_F2 12
38 #define NB_BINS_COMPRESSED_SM_F2 12
38 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
39 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
39
40
40 //
41 //
41 #define NB_BINS_TO_AVERAGE_ASM_F0 8
42 #define NB_BINS_TO_AVERAGE_ASM_F0 8
42 #define NB_BINS_TO_AVERAGE_ASM_F1 8
43 #define NB_BINS_TO_AVERAGE_ASM_F1 8
43 #define NB_BINS_TO_AVERAGE_ASM_F2 8
44 #define NB_BINS_TO_AVERAGE_ASM_F2 8
44 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
45 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
45 //
46 //
46 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
47 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
47 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
48 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
48 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
49 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
49 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
50 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
50 // NORM
51 // NORM
51 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
52 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
52 #define NB_SM_BEFORE_NORM_BP2_F0 1920 // 96 * 20
53 #define NB_SM_BEFORE_NORM_BP2_F0 1920 // 96 * 20
53 #define NB_SM_BEFORE_NORM_ASM_F0 384 // 384 matrices at f0 = 4.00 second
54 #define NB_SM_BEFORE_NORM_ASM_F0 384 // 384 matrices at f0 = 4.00 second
54 // BURST
55 // BURST
55 #define NB_SM_BEFORE_BURST_BP1_F0 96 // 96 matrices at f0 = 1.00 second
56 #define NB_SM_BEFORE_BURST_BP1_F0 96 // 96 matrices at f0 = 1.00 second
56 #define NB_SM_BEFORE_BURST_BP2_F0 480 // 480 matrices at f0 = 5.00 second
57 #define NB_SM_BEFORE_BURST_BP2_F0 480 // 480 matrices at f0 = 5.00 second
57 // SBM1
58 // SBM1
58 #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second
59 #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second
59 #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second
60 #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second
60 // SBM2
61 // SBM2
61 #define NB_SM_BEFORE_SBM2_BP1_F0 96 // 96 matrices at f0 = 1.00 second
62 #define NB_SM_BEFORE_SBM2_BP1_F0 96 // 96 matrices at f0 = 1.00 second
62 #define NB_SM_BEFORE_SBM2_BP2_F0 480 // 480 matrices at f0 = 5.00 second
63 #define NB_SM_BEFORE_SBM2_BP2_F0 480 // 480 matrices at f0 = 5.00 second
63 // GENERAL
64 // GENERAL
64 #define NB_SM_BEFORE_AVF0 8
65 #define NB_SM_BEFORE_AVF0 8
65
66
66 #endif // FSW_PARAMS_PROCESSING_H
67 #endif // FSW_PARAMS_PROCESSING_H
@@ -1,109 +1,120
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 *previous;
26 struct ring_node_asm *previous;
27 struct ring_node_asm *next;
27 struct ring_node_asm *next;
28 float asm_burst_sbm_f0[ TIME_OFFSET + TOTAL_SIZE_SM ];
28 float matrix[ TOTAL_SIZE_SM ];
29 unsigned int status;
29 unsigned int status;
30 } ring_node_asm;
30 } ring_node_asm;
31
31
32 typedef struct bp_packet
32 typedef struct bp_packet
33 {
33 {
34 Header_TM_LFR_SCIENCE_BP_t header;
34 Header_TM_LFR_SCIENCE_BP_t header;
35 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
35 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
36 } bp_packet;
36 } bp_packet;
37
37
38 typedef struct bp_packet_with_spare
38 typedef struct bp_packet_with_spare
39 {
39 {
40 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
40 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
41 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
41 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
42 } bp_packet_with_spare;
42 } bp_packet_with_spare;
43
43
44 typedef struct asm_msg
45 {
46 ring_node_asm *norm_f0;
47 ring_node_asm *burst_sbmf0;
48 rtems_event_set event;
49 unsigned int coarseTime;
50 unsigned int fineTime;
51 } asm_msg;
52
44 extern nb_sm_t nb_sm;
53 extern nb_sm_t nb_sm;
45 extern nb_sm_before_bp_t nb_sm_before_bp;
54 extern nb_sm_before_bp_t nb_sm_before_bp;
46
55
47 extern volatile int sm_f0[ ];
56 extern volatile int sm_f0[ ];
48 extern volatile int sm_f1[ ];
57 extern volatile int sm_f1[ ];
49 extern volatile int sm_f2[ ];
58 extern volatile int sm_f2[ ];
50
59
51 // parameters
60 // parameters
52 extern struct param_local_str param_local;
61 extern struct param_local_str param_local;
53
62
54 // registers
63 // registers
55 extern time_management_regs_t *time_management_regs;
64 extern time_management_regs_t *time_management_regs;
56 extern spectral_matrix_regs_t *spectral_matrix_regs;
65 extern spectral_matrix_regs_t *spectral_matrix_regs;
57
66
58 extern rtems_name misc_name[5];
67 extern rtems_name misc_name[5];
59 extern rtems_id Task_id[20]; /* array of task ids */
68 extern rtems_id Task_id[20]; /* array of task ids */
60
69
61 // ISR
70 // ISR
62 void reset_nb_sm_f0( unsigned char lfrMode );
71 void reset_nb_sm_f0( unsigned char lfrMode );
63 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
72 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
64 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
73 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
65
74
66 // RTEMS TASKS
75 // RTEMS TASKS
67 rtems_task smiq_task( rtems_task_argument argument ); // added to test the spectral matrix simulator
76 rtems_task smiq_task( rtems_task_argument argument ); // added to test the spectral matrix simulator
68 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
77 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
69 rtems_task matr_task( rtems_task_argument lfrRequestedMode );
78 rtems_task matr_task( rtems_task_argument lfrRequestedMode );
70
79
71 //******************
80 //******************
72 // Spectral Matrices
81 // Spectral Matrices
73 void SM_init_rings( void );
82 void SM_init_rings( void );
74 void ASM_init_ring( void );
83 void ASM_init_rings( void );
75 void SM_reset_current_ring_nodes( void );
84 void SM_reset_current_ring_nodes( void );
76 void ASM_reset_current_ring_node( void );
85 void ASM_reset_current_ring_node( void );
77 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
86 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
78 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
87 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
79 ring_node_sm *ring_node_tab[],
88 ring_node_sm *ring_node_tab[],
80 unsigned int firstTimeF0, unsigned int firstTimeF1 );
89 unsigned int firstTimeF0, unsigned int firstTimeF1 );
81 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
90 void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
82 float divider );
91 float divider );
83 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
92 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
84 float divider,
93 float divider,
85 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
94 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
86 void ASM_convert(volatile float *input_matrix, char *output_matrix);
95 void ASM_convert(volatile float *input_matrix, char *output_matrix);
87 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
96 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
88 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
97 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
89
98
90 //*****************
99 //*****************
91 // Basic Parameters
100 // Basic Parameters
92
101
93 void BP_reset_current_ring_nodes( void );
102 void BP_reset_current_ring_nodes( void );
94 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
103 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
95 unsigned int apid, unsigned char sid,
104 unsigned int apid, unsigned char sid,
96 unsigned int packetLength , unsigned char blkNr);
105 unsigned int packetLength , unsigned char blkNr);
97 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
106 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
98 unsigned int apid, unsigned char sid,
107 unsigned int apid, unsigned char sid,
99 unsigned int packetLength, unsigned char blkNr );
108 unsigned int packetLength, unsigned char blkNr );
100 void BP_send(char *data,
109 void BP_send(char *data,
101 rtems_id queue_id ,
110 rtems_id queue_id ,
102 unsigned int nbBytesToSend );
111 unsigned int nbBytesToSend );
103
112
104 //******************
113 //******************
105 // general functions
114 // general functions
106 void reset_spectral_matrix_regs( void );
115 void reset_spectral_matrix_regs( void );
107 void set_time(unsigned char *time, unsigned char *timeInBuffer );
116 void set_time(unsigned char *time, unsigned char *timeInBuffer );
108
117
118 extern rtems_status_code get_message_queue_id_matr( rtems_id *queue_id );
119
109 #endif // FSW_PROCESSING_H_INCLUDED
120 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,60 +1,60
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "tc_load_dump_parameters.h"
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
8 #include "tc_acceptance.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 // MODE PARAMETERS
13 // MODE PARAMETERS
14 extern unsigned int maxCount;
14 extern unsigned int maxCount;
15
15
16 //****
16 //****
17 // ISR
17 // ISR
18 rtems_isr commutation_isr1( rtems_vector_number vector );
18 rtems_isr commutation_isr1( rtems_vector_number vector );
19 rtems_isr commutation_isr2( rtems_vector_number vector );
19 rtems_isr commutation_isr2( rtems_vector_number vector );
20
20
21 //***********
21 //***********
22 // RTEMS TASK
22 // RTEMS TASK
23 rtems_task actn_task( rtems_task_argument unused );
23 rtems_task actn_task( rtems_task_argument unused );
24
24
25 //***********
25 //***********
26 // TC ACTIONS
26 // TC ACTIONS
27 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
27 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
28 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
28 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
29 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
30 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
30 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
31 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
31 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
32 int action_update_time( ccsdsTelecommandPacket_t *TC);
32 int action_update_time( ccsdsTelecommandPacket_t *TC);
33
33
34 // mode transition
34 // mode transition
35 int check_mode_value( unsigned char requestedMode );
35 int check_mode_value( unsigned char requestedMode );
36 int check_mode_transition( unsigned char requestedMode );
36 int check_mode_transition( unsigned char requestedMode );
37 int check_transition_date( unsigned int transitionCoarseTime );
37 int check_transition_date( unsigned int transitionCoarseTime );
38 int stop_current_mode( void );
38 int stop_current_mode( void );
39 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
39 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
40 int restart_science_tasks(unsigned char lfrRequestedMode );
40 int restart_science_tasks(unsigned char lfrRequestedMode );
41 int suspend_science_tasks();
41 int suspend_science_tasks();
42 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
42 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
43 void launch_spectral_matrix( unsigned char mode );
43 void launch_spectral_matrix( void );
44 void launch_spectral_matrix_simu( void );
44 void set_irq_on_new_ready_matrix(unsigned char value );
45 void set_irq_on_new_ready_matrix(unsigned char value );
45 void set_run_matrix_spectral( unsigned char value );
46 void set_run_matrix_spectral( unsigned char value );
46 void launch_spectral_matrix_simu( unsigned char mode );
47
47
48 // other functions
48 // other functions
49 void updateLFRCurrentMode();
49 void updateLFRCurrentMode();
50 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
50 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
51 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
51 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
52 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
52 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
53
53
54 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
54 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
55 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
55 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
56
56
57 #endif // TC_HANDLER_H_INCLUDED
57 #endif // TC_HANDLER_H_INCLUDED
58
58
59
59
60
60
@@ -1,645 +1,674
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_PERIODS 5
36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 3
39 #ifdef PRINT_STACK_REPORT
39 #ifdef PRINT_STACK_REPORT
40 #define CONFIGURE_STACK_CHECKER_ENABLED
40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #endif
41 #endif
42
42
43 #include <rtems/confdefs.h>
43 #include <rtems/confdefs.h>
44
44
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 #ifdef RTEMS_DRVMGR_STARTUP
46 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef LEON3
47 #ifdef LEON3
48 /* Add Timer and UART Driver */
48 /* Add Timer and UART Driver */
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #endif
51 #endif
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #endif
54 #endif
55 #endif
55 #endif
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #include <drvmgr/drvmgr_confdefs.h>
57 #include <drvmgr/drvmgr_confdefs.h>
58 #endif
58 #endif
59
59
60 #include "fsw_init.h"
60 #include "fsw_init.h"
61 #include "fsw_config.c"
61 #include "fsw_config.c"
62
62
63 rtems_task Init( rtems_task_argument ignored )
63 rtems_task Init( rtems_task_argument ignored )
64 {
64 {
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 *
66 *
67 * @param unused is the starting argument of the RTEMS task
67 * @param unused is the starting argument of the RTEMS task
68 *
68 *
69 * The INIT task create and run all other RTEMS tasks.
69 * The INIT task create and run all other RTEMS tasks.
70 *
70 *
71 */
71 */
72
72
73 reset_local_time();
73 reset_local_time();
74
74
75 rtems_status_code status;
75 rtems_status_code status;
76 rtems_status_code status_spw;
76 rtems_status_code status_spw;
77 rtems_isr_entry old_isr_handler;
77 rtems_isr_entry old_isr_handler;
78
78
79 // UART settings
79 // UART settings
80 send_console_outputs_on_apbuart_port();
80 send_console_outputs_on_apbuart_port();
81 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
81 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
82 enable_apbuart_transmitter();
82 enable_apbuart_transmitter();
83 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
83 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
84
84
85 PRINTF("\n\n\n\n\n")
85 PRINTF("\n\n\n\n\n")
86 PRINTF("*************************\n")
86 PRINTF("*************************\n")
87 PRINTF("** LFR Flight Software **\n")
87 PRINTF("** LFR Flight Software **\n")
88 PRINTF1("** %d.", SW_VERSION_N1)
88 PRINTF1("** %d.", SW_VERSION_N1)
89 PRINTF1("%d.", SW_VERSION_N2)
89 PRINTF1("%d.", SW_VERSION_N2)
90 PRINTF1("%d.", SW_VERSION_N3)
90 PRINTF1("%d.", SW_VERSION_N3)
91 PRINTF1("%d **\n", SW_VERSION_N4)
91 PRINTF1("%d **\n", SW_VERSION_N4)
92 PRINTF("*************************\n")
92 PRINTF("*************************\n")
93 PRINTF("\n\n")
93 PRINTF("\n\n")
94
94
95 init_parameter_dump();
95 init_parameter_dump();
96 init_local_mode_parameters();
96 init_local_mode_parameters();
97 init_housekeeping_parameters();
97 init_housekeeping_parameters();
98
98
99 init_waveform_rings(); // initialize the waveform rings
99 init_waveform_rings(); // initialize the waveform rings
100 SM_init_rings(); // initialize spectral matrices rings
100 SM_init_rings(); // initialize spectral matrices rings
101 ASM_init_ring(); // initialize the average spectral matrix ring (just for burst, sbm1 and sbm2 asm @ f0 storage)
101 ASM_init_rings(); // initialize the average spectral matrix ring (just for burst, sbm1 and sbm2 asm @ f0 storage)
102
102
103 reset_wfp_burst_enable();
103 reset_wfp_burst_enable();
104 reset_wfp_status();
104 reset_wfp_status();
105 set_wfp_data_shaping();
105 set_wfp_data_shaping();
106
106
107 updateLFRCurrentMode();
107 updateLFRCurrentMode();
108
108
109 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
109 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
110
110
111 create_names(); // create all names
111 create_names(); // create all names
112
112
113 status = create_message_queues(); // create message queues
113 status = create_message_queues(); // create message queues
114 if (status != RTEMS_SUCCESSFUL)
114 if (status != RTEMS_SUCCESSFUL)
115 {
115 {
116 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
116 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
117 }
117 }
118
118
119 status = create_all_tasks(); // create all tasks
119 status = create_all_tasks(); // create all tasks
120 if (status != RTEMS_SUCCESSFUL)
120 if (status != RTEMS_SUCCESSFUL)
121 {
121 {
122 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
122 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
123 }
123 }
124
124
125 // **************************
125 // **************************
126 // <SPACEWIRE INITIALIZATION>
126 // <SPACEWIRE INITIALIZATION>
127 grspw_timecode_callback = &timecode_irq_handler;
127 grspw_timecode_callback = &timecode_irq_handler;
128
128
129 status_spw = spacewire_open_link(); // (1) open the link
129 status_spw = spacewire_open_link(); // (1) open the link
130 if ( status_spw != RTEMS_SUCCESSFUL )
130 if ( status_spw != RTEMS_SUCCESSFUL )
131 {
131 {
132 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
132 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
133 }
133 }
134
134
135 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
135 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
136 {
136 {
137 status_spw = spacewire_configure_link( fdSPW );
137 status_spw = spacewire_configure_link( fdSPW );
138 if ( status_spw != RTEMS_SUCCESSFUL )
138 if ( status_spw != RTEMS_SUCCESSFUL )
139 {
139 {
140 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
140 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
141 }
141 }
142 }
142 }
143
143
144 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
144 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
145 {
145 {
146 status_spw = spacewire_start_link( fdSPW );
146 status_spw = spacewire_start_link( fdSPW );
147 if ( status_spw != RTEMS_SUCCESSFUL )
147 if ( status_spw != RTEMS_SUCCESSFUL )
148 {
148 {
149 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
149 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
150 }
150 }
151 }
151 }
152 // </SPACEWIRE INITIALIZATION>
152 // </SPACEWIRE INITIALIZATION>
153 // ***************************
153 // ***************************
154
154
155 status = start_all_tasks(); // start all tasks
155 status = start_all_tasks(); // start all tasks
156 if (status != RTEMS_SUCCESSFUL)
156 if (status != RTEMS_SUCCESSFUL)
157 {
157 {
158 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
158 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
159 }
159 }
160
160
161 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
161 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
162 status = start_recv_send_tasks();
162 status = start_recv_send_tasks();
163 if ( status != RTEMS_SUCCESSFUL )
163 if ( status != RTEMS_SUCCESSFUL )
164 {
164 {
165 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
165 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
166 }
166 }
167
167
168 // suspend science tasks, they will be restarted later depending on the mode
168 // suspend science tasks, they will be restarted later depending on the mode
169 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
169 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
170 if (status != RTEMS_SUCCESSFUL)
170 if (status != RTEMS_SUCCESSFUL)
171 {
171 {
172 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
172 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
173 }
173 }
174
174
175 //******************************
175 //******************************
176 // <SPECTRAL MATRICES SIMULATOR>
176 // <SPECTRAL MATRICES SIMULATOR>
177 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
177 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
178 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
178 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
179 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
179 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
180 // </SPECTRAL MATRICES SIMULATOR>
180 // </SPECTRAL MATRICES SIMULATOR>
181 //*******************************
181 //*******************************
182
182
183 // configure IRQ handling for the waveform picker unit
183 // configure IRQ handling for the waveform picker unit
184 status = rtems_interrupt_catch( waveforms_isr,
184 status = rtems_interrupt_catch( waveforms_isr,
185 IRQ_SPARC_WAVEFORM_PICKER,
185 IRQ_SPARC_WAVEFORM_PICKER,
186 &old_isr_handler) ;
186 &old_isr_handler) ;
187 // configure IRQ handling for the spectral matrices unit
187 // configure IRQ handling for the spectral matrices unit
188 status = rtems_interrupt_catch( spectral_matrices_isr,
188 status = rtems_interrupt_catch( spectral_matrices_isr,
189 IRQ_SPARC_SPECTRAL_MATRIX,
189 IRQ_SPARC_SPECTRAL_MATRIX,
190 &old_isr_handler) ;
190 &old_isr_handler) ;
191
191
192 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
192 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
193 if ( status_spw != RTEMS_SUCCESSFUL )
193 if ( status_spw != RTEMS_SUCCESSFUL )
194 {
194 {
195 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
195 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
196 if ( status != RTEMS_SUCCESSFUL ) {
196 if ( status != RTEMS_SUCCESSFUL ) {
197 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
197 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
198 }
198 }
199 }
199 }
200
200
201 BOOT_PRINTF("delete INIT\n")
201 BOOT_PRINTF("delete INIT\n")
202
202
203 send_dumb_hk();
203 send_dumb_hk();
204
204
205 status = rtems_task_delete(RTEMS_SELF);
205 status = rtems_task_delete(RTEMS_SELF);
206
206
207 }
207 }
208
208
209 void init_local_mode_parameters( void )
209 void init_local_mode_parameters( void )
210 {
210 {
211 /** This function initialize the param_local global variable with default values.
211 /** This function initialize the param_local global variable with default values.
212 *
212 *
213 */
213 */
214
214
215 unsigned int i;
215 unsigned int i;
216
216
217 // LOCAL PARAMETERS
217 // LOCAL PARAMETERS
218 set_local_nb_interrupt_f0_MAX();
218 set_local_nb_interrupt_f0_MAX();
219
219
220 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
220 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
221 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
221 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
222 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
222 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
223
223
224 // init sequence counters
224 // init sequence counters
225
225
226 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
226 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
227 {
227 {
228 sequenceCounters_TC_EXE[i] = 0x00;
228 sequenceCounters_TC_EXE[i] = 0x00;
229 }
229 }
230 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
230 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
231 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
231 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
232 }
232 }
233
233
234 void reset_local_time( void )
234 void reset_local_time( void )
235 {
235 {
236 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
236 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
237 }
237 }
238
238
239 void create_names( void ) // create all names for tasks and queues
239 void create_names( void ) // create all names for tasks and queues
240 {
240 {
241 /** This function creates all RTEMS names used in the software for tasks and queues.
241 /** This function creates all RTEMS names used in the software for tasks and queues.
242 *
242 *
243 * @return RTEMS directive status codes:
243 * @return RTEMS directive status codes:
244 * - RTEMS_SUCCESSFUL - successful completion
244 * - RTEMS_SUCCESSFUL - successful completion
245 *
245 *
246 */
246 */
247
247
248 // task names
248 // task names
249 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
249 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
250 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
250 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
251 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
251 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
252 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
252 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
253 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
253 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
254 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
254 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
255 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
255 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
256 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
256 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
257 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
257 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
258 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
258 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
259 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
259 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
260 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
260 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
261 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
261 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
262 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
262 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
263 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
263 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
264 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
264 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
265
265
266 // rate monotonic period names
266 // rate monotonic period names
267 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
267 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
268
268
269 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
269 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
270 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
270 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
271 misc_name[QUEUE_MATR] = rtems_build_name( 'Q', '_', 'M', 'R' );
271 }
272 }
272
273
273 int create_all_tasks( void ) // create all tasks which run in the software
274 int create_all_tasks( void ) // create all tasks which run in the software
274 {
275 {
275 /** This function creates all RTEMS tasks used in the software.
276 /** This function creates all RTEMS tasks used in the software.
276 *
277 *
277 * @return RTEMS directive status codes:
278 * @return RTEMS directive status codes:
278 * - RTEMS_SUCCESSFUL - task created successfully
279 * - RTEMS_SUCCESSFUL - task created successfully
279 * - RTEMS_INVALID_ADDRESS - id is NULL
280 * - RTEMS_INVALID_ADDRESS - id is NULL
280 * - RTEMS_INVALID_NAME - invalid task name
281 * - RTEMS_INVALID_NAME - invalid task name
281 * - RTEMS_INVALID_PRIORITY - invalid task priority
282 * - RTEMS_INVALID_PRIORITY - invalid task priority
282 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
283 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
283 * - RTEMS_TOO_MANY - too many tasks created
284 * - RTEMS_TOO_MANY - too many tasks created
284 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
285 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
285 * - RTEMS_TOO_MANY - too many global objects
286 * - RTEMS_TOO_MANY - too many global objects
286 *
287 *
287 */
288 */
288
289
289 rtems_status_code status;
290 rtems_status_code status;
290
291
291 //**********
292 //**********
292 // SPACEWIRE
293 // SPACEWIRE
293 // RECV
294 // RECV
294 status = rtems_task_create(
295 status = rtems_task_create(
295 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
296 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
296 RTEMS_DEFAULT_MODES,
297 RTEMS_DEFAULT_MODES,
297 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
298 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
298 );
299 );
299 if (status == RTEMS_SUCCESSFUL) // SEND
300 if (status == RTEMS_SUCCESSFUL) // SEND
300 {
301 {
301 status = rtems_task_create(
302 status = rtems_task_create(
302 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
303 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
303 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
304 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
304 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
305 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
305 );
306 );
306 }
307 }
307 if (status == RTEMS_SUCCESSFUL) // WTDG
308 if (status == RTEMS_SUCCESSFUL) // WTDG
308 {
309 {
309 status = rtems_task_create(
310 status = rtems_task_create(
310 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
311 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
311 RTEMS_DEFAULT_MODES,
312 RTEMS_DEFAULT_MODES,
312 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
313 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
313 );
314 );
314 }
315 }
315 if (status == RTEMS_SUCCESSFUL) // ACTN
316 if (status == RTEMS_SUCCESSFUL) // ACTN
316 {
317 {
317 status = rtems_task_create(
318 status = rtems_task_create(
318 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
319 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
319 RTEMS_DEFAULT_MODES,
320 RTEMS_DEFAULT_MODES,
320 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
321 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
321 );
322 );
322 }
323 }
323 if (status == RTEMS_SUCCESSFUL) // SPIQ
324 if (status == RTEMS_SUCCESSFUL) // SPIQ
324 {
325 {
325 status = rtems_task_create(
326 status = rtems_task_create(
326 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
327 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
327 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
328 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
328 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
329 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
329 );
330 );
330 }
331 }
331
332
332 //******************
333 //******************
333 // SPECTRAL MATRICES
334 // SPECTRAL MATRICES
334 if (status == RTEMS_SUCCESSFUL) // SMIQ
335 if (status == RTEMS_SUCCESSFUL) // SMIQ
335 {
336 {
336 status = rtems_task_create(
337 status = rtems_task_create(
337 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
338 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
338 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
339 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
339 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
340 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
340 );
341 );
341 }
342 }
342 if (status == RTEMS_SUCCESSFUL) // AVF0
343 if (status == RTEMS_SUCCESSFUL) // AVF0
343 {
344 {
344 status = rtems_task_create(
345 status = rtems_task_create(
345 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
346 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
346 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
348 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
348 );
349 );
349 }
350 }
350 if (status == RTEMS_SUCCESSFUL) // MATR
351 if (status == RTEMS_SUCCESSFUL) // MATR
351 {
352 {
352 status = rtems_task_create(
353 status = rtems_task_create(
353 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
354 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE * 2,
354 RTEMS_DEFAULT_MODES,
355 RTEMS_DEFAULT_MODES,
355 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
356 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
356 );
357 );
357 }
358 }
358
359
359 //****************
360 //****************
360 // WAVEFORM PICKER
361 // WAVEFORM PICKER
361 if (status == RTEMS_SUCCESSFUL) // WFRM
362 if (status == RTEMS_SUCCESSFUL) // WFRM
362 {
363 {
363 status = rtems_task_create(
364 status = rtems_task_create(
364 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
365 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
365 RTEMS_DEFAULT_MODES,
366 RTEMS_DEFAULT_MODES,
366 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
367 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
367 );
368 );
368 }
369 }
369 if (status == RTEMS_SUCCESSFUL) // CWF3
370 if (status == RTEMS_SUCCESSFUL) // CWF3
370 {
371 {
371 status = rtems_task_create(
372 status = rtems_task_create(
372 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
373 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
373 RTEMS_DEFAULT_MODES,
374 RTEMS_DEFAULT_MODES,
374 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
375 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
375 );
376 );
376 }
377 }
377 if (status == RTEMS_SUCCESSFUL) // CWF2
378 if (status == RTEMS_SUCCESSFUL) // CWF2
378 {
379 {
379 status = rtems_task_create(
380 status = rtems_task_create(
380 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
381 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
381 RTEMS_DEFAULT_MODES,
382 RTEMS_DEFAULT_MODES,
382 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
383 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
383 );
384 );
384 }
385 }
385 if (status == RTEMS_SUCCESSFUL) // CWF1
386 if (status == RTEMS_SUCCESSFUL) // CWF1
386 {
387 {
387 status = rtems_task_create(
388 status = rtems_task_create(
388 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
389 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
389 RTEMS_DEFAULT_MODES,
390 RTEMS_DEFAULT_MODES,
390 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
391 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
391 );
392 );
392 }
393 }
393 if (status == RTEMS_SUCCESSFUL) // SWBD
394 if (status == RTEMS_SUCCESSFUL) // SWBD
394 {
395 {
395 status = rtems_task_create(
396 status = rtems_task_create(
396 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
397 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
397 RTEMS_DEFAULT_MODES,
398 RTEMS_DEFAULT_MODES,
398 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
399 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
399 );
400 );
400 }
401 }
401
402
402 //*****
403 //*****
403 // MISC
404 // MISC
404 if (status == RTEMS_SUCCESSFUL) // STAT
405 if (status == RTEMS_SUCCESSFUL) // STAT
405 {
406 {
406 status = rtems_task_create(
407 status = rtems_task_create(
407 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
408 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
408 RTEMS_DEFAULT_MODES,
409 RTEMS_DEFAULT_MODES,
409 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
410 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
410 );
411 );
411 }
412 }
412 if (status == RTEMS_SUCCESSFUL) // DUMB
413 if (status == RTEMS_SUCCESSFUL) // DUMB
413 {
414 {
414 status = rtems_task_create(
415 status = rtems_task_create(
415 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
416 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
416 RTEMS_DEFAULT_MODES,
417 RTEMS_DEFAULT_MODES,
417 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
418 );
419 );
419 }
420 }
420 if (status == RTEMS_SUCCESSFUL) // HOUS
421 if (status == RTEMS_SUCCESSFUL) // HOUS
421 {
422 {
422 status = rtems_task_create(
423 status = rtems_task_create(
423 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
424 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
424 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
425 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
425 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
426 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
426 );
427 );
427 }
428 }
428
429
429 return status;
430 return status;
430 }
431 }
431
432
432 int start_recv_send_tasks( void )
433 int start_recv_send_tasks( void )
433 {
434 {
434 rtems_status_code status;
435 rtems_status_code status;
435
436
436 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
437 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
437 if (status!=RTEMS_SUCCESSFUL) {
438 if (status!=RTEMS_SUCCESSFUL) {
438 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
439 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
439 }
440 }
440
441
441 if (status == RTEMS_SUCCESSFUL) // SEND
442 if (status == RTEMS_SUCCESSFUL) // SEND
442 {
443 {
443 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
444 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
444 if (status!=RTEMS_SUCCESSFUL) {
445 if (status!=RTEMS_SUCCESSFUL) {
445 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
446 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
446 }
447 }
447 }
448 }
448
449
449 return status;
450 return status;
450 }
451 }
451
452
452 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
453 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
453 {
454 {
454 /** This function starts all RTEMS tasks used in the software.
455 /** This function starts all RTEMS tasks used in the software.
455 *
456 *
456 * @return RTEMS directive status codes:
457 * @return RTEMS directive status codes:
457 * - RTEMS_SUCCESSFUL - ask started successfully
458 * - RTEMS_SUCCESSFUL - ask started successfully
458 * - RTEMS_INVALID_ADDRESS - invalid task entry point
459 * - RTEMS_INVALID_ADDRESS - invalid task entry point
459 * - RTEMS_INVALID_ID - invalid task id
460 * - RTEMS_INVALID_ID - invalid task id
460 * - RTEMS_INCORRECT_STATE - task not in the dormant state
461 * - RTEMS_INCORRECT_STATE - task not in the dormant state
461 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
462 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
462 *
463 *
463 */
464 */
464 // starts all the tasks fot eh flight software
465 // starts all the tasks fot eh flight software
465
466
466 rtems_status_code status;
467 rtems_status_code status;
467
468
468 //**********
469 //**********
469 // SPACEWIRE
470 // SPACEWIRE
470 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
471 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
471 if (status!=RTEMS_SUCCESSFUL) {
472 if (status!=RTEMS_SUCCESSFUL) {
472 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
473 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
473 }
474 }
474
475
475 if (status == RTEMS_SUCCESSFUL) // WTDG
476 if (status == RTEMS_SUCCESSFUL) // WTDG
476 {
477 {
477 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
478 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
478 if (status!=RTEMS_SUCCESSFUL) {
479 if (status!=RTEMS_SUCCESSFUL) {
479 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
480 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
480 }
481 }
481 }
482 }
482
483
483 if (status == RTEMS_SUCCESSFUL) // ACTN
484 if (status == RTEMS_SUCCESSFUL) // ACTN
484 {
485 {
485 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
486 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
486 if (status!=RTEMS_SUCCESSFUL) {
487 if (status!=RTEMS_SUCCESSFUL) {
487 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
488 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
488 }
489 }
489 }
490 }
490
491
491 //******************
492 //******************
492 // SPECTRAL MATRICES
493 // SPECTRAL MATRICES
493 if (status == RTEMS_SUCCESSFUL) // SMIQ
494 if (status == RTEMS_SUCCESSFUL) // SMIQ
494 {
495 {
495 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
496 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
496 if (status!=RTEMS_SUCCESSFUL) {
497 if (status!=RTEMS_SUCCESSFUL) {
497 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
498 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
498 }
499 }
499 }
500 }
500
501
501 if (status == RTEMS_SUCCESSFUL) // AVF0
502 if (status == RTEMS_SUCCESSFUL) // AVF0
502 {
503 {
503 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
504 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
504 if (status!=RTEMS_SUCCESSFUL) {
505 if (status!=RTEMS_SUCCESSFUL) {
505 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
506 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
506 }
507 }
507 }
508 }
508
509
509 if (status == RTEMS_SUCCESSFUL) // MATR
510 if (status == RTEMS_SUCCESSFUL) // MATR
510 {
511 {
511 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
512 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
512 if (status!=RTEMS_SUCCESSFUL) {
513 if (status!=RTEMS_SUCCESSFUL) {
513 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
514 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
514 }
515 }
515 }
516 }
516
517
517 //****************
518 //****************
518 // WAVEFORM PICKER
519 // WAVEFORM PICKER
519 if (status == RTEMS_SUCCESSFUL) // WFRM
520 if (status == RTEMS_SUCCESSFUL) // WFRM
520 {
521 {
521 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
522 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
522 if (status!=RTEMS_SUCCESSFUL) {
523 if (status!=RTEMS_SUCCESSFUL) {
523 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
524 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
524 }
525 }
525 }
526 }
526
527
527 if (status == RTEMS_SUCCESSFUL) // CWF3
528 if (status == RTEMS_SUCCESSFUL) // CWF3
528 {
529 {
529 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
530 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
530 if (status!=RTEMS_SUCCESSFUL) {
531 if (status!=RTEMS_SUCCESSFUL) {
531 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
532 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
532 }
533 }
533 }
534 }
534
535
535 if (status == RTEMS_SUCCESSFUL) // CWF2
536 if (status == RTEMS_SUCCESSFUL) // CWF2
536 {
537 {
537 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
538 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
538 if (status!=RTEMS_SUCCESSFUL) {
539 if (status!=RTEMS_SUCCESSFUL) {
539 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
540 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
540 }
541 }
541 }
542 }
542
543
543 if (status == RTEMS_SUCCESSFUL) // CWF1
544 if (status == RTEMS_SUCCESSFUL) // CWF1
544 {
545 {
545 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
546 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
546 if (status!=RTEMS_SUCCESSFUL) {
547 if (status!=RTEMS_SUCCESSFUL) {
547 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
548 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
548 }
549 }
549 }
550 }
550
551
551 if (status == RTEMS_SUCCESSFUL) // SWBD
552 if (status == RTEMS_SUCCESSFUL) // SWBD
552 {
553 {
553 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
554 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
554 if (status!=RTEMS_SUCCESSFUL) {
555 if (status!=RTEMS_SUCCESSFUL) {
555 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
556 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
556 }
557 }
557 }
558 }
558
559
559 //*****
560 //*****
560 // MISC
561 // MISC
561 if (status == RTEMS_SUCCESSFUL) // HOUS
562 if (status == RTEMS_SUCCESSFUL) // HOUS
562 {
563 {
563 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
564 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
564 if (status!=RTEMS_SUCCESSFUL) {
565 if (status!=RTEMS_SUCCESSFUL) {
565 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
566 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
566 }
567 }
567 }
568 }
568
569
569 if (status == RTEMS_SUCCESSFUL) // DUMB
570 if (status == RTEMS_SUCCESSFUL) // DUMB
570 {
571 {
571 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
572 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
572 if (status!=RTEMS_SUCCESSFUL) {
573 if (status!=RTEMS_SUCCESSFUL) {
573 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
574 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
574 }
575 }
575 }
576 }
576
577
577 if (status == RTEMS_SUCCESSFUL) // STAT
578 if (status == RTEMS_SUCCESSFUL) // STAT
578 {
579 {
579 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
580 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
580 if (status!=RTEMS_SUCCESSFUL) {
581 if (status!=RTEMS_SUCCESSFUL) {
581 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
582 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
582 }
583 }
583 }
584 }
584
585
585 return status;
586 return status;
586 }
587 }
587
588
588 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
589 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
589 {
590 {
590 rtems_status_code status_recv;
591 rtems_status_code status_recv;
591 rtems_status_code status_send;
592 rtems_status_code status_send;
593 rtems_status_code status_matr;
592 rtems_status_code ret;
594 rtems_status_code ret;
593 rtems_id queue_id;
595 rtems_id queue_id;
594
596
597 //****************************************
595 // create the queue for handling valid TCs
598 // create the queue for handling valid TCs
596 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
599 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
597 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
600 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
598 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
601 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
599 if ( status_recv != RTEMS_SUCCESSFUL ) {
602 if ( status_recv != RTEMS_SUCCESSFUL ) {
600 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
603 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
601 }
604 }
602
605
606 //************************************************
603 // create the queue for handling TM packet sending
607 // create the queue for handling TM packet sending
604 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
608 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
605 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
609 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
606 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
610 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
607 if ( status_send != RTEMS_SUCCESSFUL ) {
611 if ( status_send != RTEMS_SUCCESSFUL ) {
608 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
612 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
609 }
613 }
610
614
615 //************************************************************************
616 // create the queue for handling averaged spectral matrices for processing
617 status_matr = rtems_message_queue_create( misc_name[QUEUE_MATR],
618 MSG_QUEUE_COUNT_MATR, MSG_QUEUE_SIZE_MATR,
619 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
620 if ( status_send != RTEMS_SUCCESSFUL ) {
621 PRINTF1("in create_message_queues *** ERR creating MATR queue, %d\n", status_matr)
622 }
623
611 if ( status_recv != RTEMS_SUCCESSFUL )
624 if ( status_recv != RTEMS_SUCCESSFUL )
612 {
625 {
613 ret = status_recv;
626 ret = status_recv;
614 }
627 }
628 else if( status_send != RTEMS_SUCCESSFUL )
629 {
630 ret = status_send;
631 }
615 else
632 else
616 {
633 {
617 ret = status_send;
634 ret = status_matr;
618 }
635 }
619
636
620 return ret;
637 return ret;
621 }
638 }
622
639
623 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
640 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
624 {
641 {
625 rtems_status_code status;
642 rtems_status_code status;
626 rtems_name queue_name;
643 rtems_name queue_name;
627
644
628 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
645 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
629
646
630 status = rtems_message_queue_ident( queue_name, 0, queue_id );
647 status = rtems_message_queue_ident( queue_name, 0, queue_id );
631
648
632 return status;
649 return status;
633 }
650 }
634
651
635 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
652 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
636 {
653 {
637 rtems_status_code status;
654 rtems_status_code status;
638 rtems_name queue_name;
655 rtems_name queue_name;
639
656
640 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
657 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
641
658
642 status = rtems_message_queue_ident( queue_name, 0, queue_id );
659 status = rtems_message_queue_ident( queue_name, 0, queue_id );
643
660
644 return status;
661 return status;
645 }
662 }
663
664 rtems_status_code get_message_queue_id_matr( rtems_id *queue_id )
665 {
666 rtems_status_code status;
667 rtems_name queue_name;
668
669 queue_name = rtems_build_name( 'Q', '_', 'M', 'R' );
670
671 status = rtems_message_queue_ident( queue_name, 0, queue_id );
672
673 return status;
674 }
@@ -1,889 +1,892
1 /** 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
11
12 #include "fsw_processing_globals.c"
12 #include "fsw_processing_globals.c"
13
13
14 //************************
14 //************************
15 // spectral matrices rings
15 // spectral matrices rings
16 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
16 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
17 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
17 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
18 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
18 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
19 ring_node_sm *current_ring_node_sm_f0;
19 ring_node_sm *current_ring_node_sm_f0;
20 ring_node_sm *ring_node_for_averaging_sm_f0;
20 ring_node_sm *ring_node_for_averaging_sm_f0;
21 ring_node_sm *current_ring_node_sm_f1;
21 ring_node_sm *current_ring_node_sm_f1;
22 ring_node_sm *current_ring_node_sm_f2;
22 ring_node_sm *current_ring_node_sm_f2;
23
23
24 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
24 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
25 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ];
25 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
26 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
26 ring_node_asm *ring_node_for_processing_asm_burst_sbm_f0;
27 ring_node_asm *current_ring_node_asm_norm_f0;
27
28
28 //*****
29 float asm_norm_f0 [ TOTAL_SIZE_SM ];
29 // NORM
30 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
30 // F0
31 float asm_norm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
32 float asm_f0_reorganized [ TIME_OFFSET + TOTAL_SIZE_SM ];
33 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
31 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
34 float compressed_sm_norm_f0[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
32 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
35
33 float compressed_sm_sbm [ TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
36 //*****
37 // SBM1
38 float asm_sbm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
39 float compressed_sm_sbm[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
40
41 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ];
42 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ];
43 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F2 ];
44
34
45 //***********************************************************
35 //***********************************************************
46 // Interrupt Service Routine for spectral matrices processing
36 // Interrupt Service Routine for spectral matrices processing
47 void reset_nb_sm_f0( unsigned char lfrMode )
37 void reset_nb_sm_f0( unsigned char lfrMode )
48 {
38 {
49 nb_sm.f0 = 0;
39 nb_sm.f0 = 0;
50 nb_sm.norm_bp1_f0 = 0;
40 nb_sm.norm_bp1_f0 = 0;
51 nb_sm.norm_bp2_f0 = 0;
41 nb_sm.norm_bp2_f0 = 0;
52 nb_sm.norm_asm_f0 = 0;
42 nb_sm.norm_asm_f0 = 0;
53 nb_sm.sbm_bp1_f0 = 0;
43 nb_sm.sbm_bp1_f0 = 0;
54 nb_sm.sbm_bp2_f0 = 0;
44 nb_sm.sbm_bp2_f0 = 0;
55
45
56 nb_sm_before_bp.norm_bp1_f0 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
46 nb_sm_before_bp.norm_bp1_f0 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
57 nb_sm_before_bp.norm_bp2_f0 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
47 nb_sm_before_bp.norm_bp2_f0 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
58 nb_sm_before_bp.norm_asm_f0 = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
48 nb_sm_before_bp.norm_asm_f0 = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
59 nb_sm_before_bp.sbm1_bp1_f0 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
49 nb_sm_before_bp.sbm1_bp1_f0 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
60 nb_sm_before_bp.sbm1_bp2_f0 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
50 nb_sm_before_bp.sbm1_bp2_f0 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
61 nb_sm_before_bp.sbm2_bp1_f0 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
51 nb_sm_before_bp.sbm2_bp1_f0 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
62 nb_sm_before_bp.sbm2_bp2_f0 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
52 nb_sm_before_bp.sbm2_bp2_f0 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
63 nb_sm_before_bp.burst_bp1_f0 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
53 nb_sm_before_bp.burst_bp1_f0 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
64 nb_sm_before_bp.burst_bp2_f0 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
54 nb_sm_before_bp.burst_bp2_f0 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
65
55
66 if (lfrMode == LFR_MODE_SBM1)
56 if (lfrMode == LFR_MODE_SBM1)
67 {
57 {
68 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm1_bp1_f0;
58 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm1_bp1_f0;
69 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm1_bp2_f0;
59 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm1_bp2_f0;
70 }
60 }
71 else if (lfrMode == LFR_MODE_SBM2)
61 else if (lfrMode == LFR_MODE_SBM2)
72 {
62 {
73 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm2_bp1_f0;
63 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm2_bp1_f0;
74 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm2_bp2_f0;
64 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm2_bp2_f0;
75 }
65 }
76 else if (lfrMode == LFR_MODE_BURST)
66 else if (lfrMode == LFR_MODE_BURST)
77 {
67 {
78 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0;
68 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0;
79 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0;
69 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0;
80 }
70 }
81 else
71 else
82 {
72 {
83 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0;
73 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0;
84 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0;
74 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0;
85 }
75 }
86 }
76 }
87
77
88 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
78 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
89 {
79 {
80 ring_node_sm *previous_ring_node_sm_f0;
81
90 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
82 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
91
83
92 // if ( (spectral_matrix_regs->status & 0x1) == 0x01)
84 previous_ring_node_sm_f0 = current_ring_node_sm_f0;
93 // {
85
94 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
86 if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1
95 // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
87 {
96 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
88 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
97 // nb_sm_f0 = nb_sm_f0 + 1;
89 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
98 // }
90 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
99 // else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
91 nb_sm.f0 = nb_sm.f0 + 1;
100 // {
92 }
101 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
102 // spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
103 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
104 // nb_sm_f0 = nb_sm_f0 + 1;
105 // }
106
93
107 // if ( (spectral_matrix_regs->status & 0x30) != 0x00)
94 //************************
108 // {
95 // reset status error bits
109 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
96 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
110 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
97 {
111 // }
98 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
112
99 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
113 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
100 }
114
101
115 // if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
102 //**************************************
116 // {
103 // reset ready matrix bits for f0_0, f1 and f2
117 // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
104 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010
118 // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
105
119 // {
106 if (nb_sm.f0 == NB_SM_BEFORE_AVF0)
120 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
107 {
121 // }
108 ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0;
122 // nb_sm_f0 = 0;
109 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
123 // }
110 {
124 // else
111 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
125 // {
112 }
126 // nb_sm.nb_sm_f0 = nb_sm.nb_sm_f0 + 1;
113 nb_sm.f0 = 0;
127 // }
114 }
115
128 }
116 }
129
117
130 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
118 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
131 {
119 {
132 if (nb_sm.f0 == (NB_SM_BEFORE_AVF0-1) )
120 if (nb_sm.f0 == (NB_SM_BEFORE_AVF0-1) )
133 {
121 {
134 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
122 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
135 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
123 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
136 {
124 {
137 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
125 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
138 }
126 }
139 nb_sm.f0 = 0;
127 nb_sm.f0 = 0;
140 }
128 }
141 else
129 else
142 {
130 {
143 nb_sm.f0 = nb_sm.f0 + 1;
131 nb_sm.f0 = nb_sm.f0 + 1;
144 }
132 }
145 }
133 }
146
134
147 //************
135 //************
148 // RTEMS TASKS
136 // RTEMS TASKS
149
137
150 rtems_task smiq_task( rtems_task_argument argument ) // process the Spectral Matrices IRQ
138 rtems_task smiq_task( rtems_task_argument argument ) // process the Spectral Matrices IRQ
151 {
139 {
152 rtems_event_set event_out;
140 rtems_event_set event_out;
153
141
154 BOOT_PRINTF("in SMIQ *** \n")
142 BOOT_PRINTF("in SMIQ *** \n")
155
143
156 while(1){
144 while(1){
157 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
145 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
158 }
146 }
159 }
147 }
160
148
161 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
149 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
162 {
150 {
163 int i;
151 int i;
164
152
165 rtems_event_set event_out;
153 rtems_event_set event_out;
166 rtems_event_set event_for_matr;
167 rtems_status_code status;
154 rtems_status_code status;
155 rtems_id queue_id_matr;
156 asm_msg msgForMATR;
168 ring_node_sm *ring_node_tab[8];
157 ring_node_sm *ring_node_tab[8];
169 unsigned long long int localTime;
170
158
171 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
159 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
172
160
173 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", lfrRequestedMode)
161 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", lfrRequestedMode)
174
162
163 status = get_message_queue_id_matr( &queue_id_matr );
164 if (status != RTEMS_SUCCESSFUL)
165 {
166 PRINTF1("in MATR *** ERR get_message_queue_id_matr %d\n", status)
167 }
168
175 while(1){
169 while(1){
176 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
170 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
177 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
171 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
178 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
172 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
179 {
173 {
180 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
174 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
181 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
175 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
182 }
176 }
183
177
184 localTime = getTimeAsUnsignedLongLongInt( );
185
186 // compute the average and store it in the averaged_sm_f1 buffer
178 // compute the average and store it in the averaged_sm_f1 buffer
187 SM_average( asm_norm_f0, current_ring_node_asm_burst_sbm_f0->asm_burst_sbm_f0,
179 SM_average( current_ring_node_asm_norm_f0->matrix,
188 ring_node_tab,
180 current_ring_node_asm_burst_sbm_f0->matrix,
189 nb_sm.norm_bp1_f0, nb_sm.sbm_bp1_f0 );
181 ring_node_tab,
190
182 nb_sm.norm_bp1_f0, nb_sm.sbm_bp1_f0 );
191 localTime = getTimeAsUnsignedLongLongInt( ) - localTime;
192
183
193 // update nb_average
184 // update nb_average
194 nb_sm.norm_bp1_f0 = nb_sm.norm_bp1_f0 + NB_SM_BEFORE_AVF0;
185 nb_sm.norm_bp1_f0 = nb_sm.norm_bp1_f0 + NB_SM_BEFORE_AVF0;
195 nb_sm.norm_bp2_f0 = nb_sm.norm_bp2_f0 + NB_SM_BEFORE_AVF0;
186 nb_sm.norm_bp2_f0 = nb_sm.norm_bp2_f0 + NB_SM_BEFORE_AVF0;
196 nb_sm.norm_asm_f0 = nb_sm.norm_asm_f0 + NB_SM_BEFORE_AVF0;
187 nb_sm.norm_asm_f0 = nb_sm.norm_asm_f0 + NB_SM_BEFORE_AVF0;
197 nb_sm.sbm_bp1_f0 = nb_sm.sbm_bp1_f0 + NB_SM_BEFORE_AVF0;
188 nb_sm.sbm_bp1_f0 = nb_sm.sbm_bp1_f0 + NB_SM_BEFORE_AVF0;
198 nb_sm.sbm_bp2_f0 = nb_sm.sbm_bp2_f0 + NB_SM_BEFORE_AVF0;
189 nb_sm.sbm_bp2_f0 = nb_sm.sbm_bp2_f0 + NB_SM_BEFORE_AVF0;
199
190
200 //***********************************************************
191 //****************************************
201 // build a composite event that will be sent to the MATR task
192 // initialize the mesage for the MATR task
202 event_for_matr = 0x00;
193 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
194 msgForMATR.burst_sbmf0 = current_ring_node_asm_burst_sbm_f0;
195 msgForMATR.norm_f0 = current_ring_node_asm_norm_f0;
196 msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
197 msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
203
198
204 if (nb_sm.sbm_bp1_f0 == nb_sm_before_bp.burst_sbm_bp1_f0)
199 if (nb_sm.sbm_bp1_f0 == nb_sm_before_bp.burst_sbm_bp1_f0)
205 {
200 {
206 nb_sm.sbm_bp1_f0 = 0;
201 nb_sm.sbm_bp1_f0 = 0;
207 // the ring node is ready for BP calculations
208 ring_node_for_processing_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0;
209 // set another ring for the ASM storage
202 // set another ring for the ASM storage
210 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
203 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
211 if ( (lfrCurrentMode == LFR_MODE_BURST)
204 if ( (lfrCurrentMode == LFR_MODE_BURST)
212 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
205 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
213 {
206 {
214 event_for_matr = event_for_matr | RTEMS_EVENT_BURST_SBM_BP1_F0;
207 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
215 }
208 }
216 }
209 }
217
210
218 if (nb_sm.sbm_bp2_f0 == nb_sm_before_bp.burst_sbm_bp2_f0)
211 if (nb_sm.sbm_bp2_f0 == nb_sm_before_bp.burst_sbm_bp2_f0)
219 {
212 {
220 nb_sm.sbm_bp2_f0 = 0;
213 nb_sm.sbm_bp2_f0 = 0;
221 if ( (lfrCurrentMode == LFR_MODE_BURST)
214 if ( (lfrCurrentMode == LFR_MODE_BURST)
222 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
215 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
223 {
216 {
224 event_for_matr = event_for_matr | RTEMS_EVENT_BURST_SBM_BP2_F0;
217 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
225 }
218 }
226 }
219 }
227
220
228 if (nb_sm.norm_bp1_f0 == nb_sm_before_bp.norm_bp1_f0)
221 if (nb_sm.norm_bp1_f0 == nb_sm_before_bp.norm_bp1_f0)
229 {
222 {
230 nb_sm.norm_bp1_f0 = 0;
223 nb_sm.norm_bp1_f0 = 0;
224 // set another ring for the ASM storage
225 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
231 if (lfrCurrentMode == LFR_MODE_NORMAL)
226 if (lfrCurrentMode == LFR_MODE_NORMAL)
232 {
227 {
233 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP1_F0;
228 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
234 }
229 }
235 }
230 }
236
231
237 if (nb_sm.norm_bp2_f0 == nb_sm_before_bp.norm_bp2_f0)
232 if (nb_sm.norm_bp2_f0 == nb_sm_before_bp.norm_bp2_f0)
238 {
233 {
239 nb_sm.norm_bp2_f0 = 0;
234 nb_sm.norm_bp2_f0 = 0;
240 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
235 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
241 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
236 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
242 {
237 {
243 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP2_F0;
238 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
244 }
239 }
245 }
240 }
246
241
247 if (nb_sm.norm_asm_f0 == nb_sm_before_bp.norm_asm_f0)
242 if (nb_sm.norm_asm_f0 == nb_sm_before_bp.norm_asm_f0)
248 {
243 {
249 nb_sm.norm_asm_f0 = 0;
244 nb_sm.norm_asm_f0 = 0;
250 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
245 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
251 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
246 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
252 {
247 {
253 // PRINTF1("%lld\n", localTime)
248 // PRINTF1("%lld\n", localTime)
254 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_ASM_F0;
249 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
255 }
250 }
256 }
251 }
257
252
258 //*********************************
253 //*************************
259 // send the composite event to MATR
254 // send the message to MATR
260 status = rtems_event_send( Task_id[TASKID_MATR], event_for_matr );
255 if (msgForMATR.event != 0x00)
256 {
257 status = rtems_message_queue_send( queue_id_matr, (char *) & msgForMATR, MSG_QUEUE_SIZE_MATR);
258 }
259
261 if (status != RTEMS_SUCCESSFUL) {
260 if (status != RTEMS_SUCCESSFUL) {
262 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
261 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
263 }
262 }
264 }
263 }
265 }
264 }
266
265
267 rtems_task matr_task( rtems_task_argument lfrRequestedMode )
266 rtems_task matr_task( rtems_task_argument lfrRequestedMode )
268 {
267 {
268 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
269 size_t size; // size of the incoming TC packet
270 asm_msg *incomingMsg;
271 //
269 spw_ioctl_pkt_send spw_ioctl_send_ASM;
272 spw_ioctl_pkt_send spw_ioctl_send_ASM;
270 rtems_event_set event_out;
271 rtems_status_code status;
273 rtems_status_code status;
272 rtems_id queue_id;
274 rtems_id queue_id;
275 rtems_id queue_id_matr;
273 Header_TM_LFR_SCIENCE_ASM_t headerASM;
276 Header_TM_LFR_SCIENCE_ASM_t headerASM;
274 bp_packet_with_spare current_node_norm_bp1_f0;
277 bp_packet_with_spare current_node_norm_bp1_f0;
275 bp_packet current_node_norm_bp2_f0;
278 bp_packet current_node_norm_bp2_f0;
276 bp_packet current_node_sbm_bp1_f0;
279 bp_packet current_node_sbm_bp1_f0;
277 bp_packet current_node_sbm_bp2_f0;
280 bp_packet current_node_sbm_bp2_f0;
281
278 unsigned long long int localTime;
282 unsigned long long int localTime;
279
283
280 ASM_init_header( &headerASM );
284 ASM_init_header( &headerASM );
281
285
282 //*************
286 //*************
283 // NORM headers
287 // NORM headers
284 BP_init_header_with_spare( &current_node_norm_bp1_f0.header,
288 BP_init_header_with_spare( &current_node_norm_bp1_f0.header,
285 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
289 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
286 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
290 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
287 BP_init_header( &current_node_norm_bp2_f0.header,
291 BP_init_header( &current_node_norm_bp2_f0.header,
288 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
292 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
289 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
293 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
290
294
291 //****************************
295 //****************************
292 // BURST SBM1 and SBM2 headers
296 // BURST SBM1 and SBM2 headers
293 if ( (lfrRequestedMode == LFR_MODE_BURST)
297 if ( (lfrRequestedMode == LFR_MODE_BURST)
294 || (lfrRequestedMode == LFR_MODE_NORMAL) || (lfrRequestedMode == LFR_MODE_STANDBY) )
298 || (lfrRequestedMode == LFR_MODE_NORMAL) || (lfrRequestedMode == LFR_MODE_STANDBY) )
295 {
299 {
296 BP_init_header( &current_node_sbm_bp1_f0.header,
300 BP_init_header( &current_node_sbm_bp1_f0.header,
297 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
301 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
298 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
302 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
299 BP_init_header( &current_node_sbm_bp2_f0.header,
303 BP_init_header( &current_node_sbm_bp2_f0.header,
300 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
304 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
301 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
305 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
302 }
306 }
303 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
307 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
304 {
308 {
305 BP_init_header( &current_node_sbm_bp1_f0.header,
309 BP_init_header( &current_node_sbm_bp1_f0.header,
306 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
310 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
307 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
311 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
308 BP_init_header( &current_node_sbm_bp2_f0.header,
312 BP_init_header( &current_node_sbm_bp2_f0.header,
309 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
313 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
310 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
314 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
311 }
315 }
312 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
316 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
313 {
317 {
314 BP_init_header( &current_node_sbm_bp1_f0.header,
318 BP_init_header( &current_node_sbm_bp1_f0.header,
315 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
319 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
316 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
320 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
317 BP_init_header( &current_node_sbm_bp2_f0.header,
321 BP_init_header( &current_node_sbm_bp2_f0.header,
318 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
322 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
319 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
323 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
320 }
324 }
321 else
325 else
322 {
326 {
323 PRINTF1("ERR *** in MATR *** unexpected lfrRequestedMode passed as argument = %d\n", (unsigned int) lfrRequestedMode)
327 PRINTF1("ERR *** in MATR *** unexpected lfrRequestedMode passed as argument = %d\n", (unsigned int) lfrRequestedMode)
324 }
328 }
325
329
326 status = get_message_queue_id_send( &queue_id );
330 status = get_message_queue_id_send( &queue_id );
327 if (status != RTEMS_SUCCESSFUL)
331 if (status != RTEMS_SUCCESSFUL)
328 {
332 {
329 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
333 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
330 }
334 }
335 status = get_message_queue_id_matr( &queue_id_matr);
336 if (status != RTEMS_SUCCESSFUL)
337 {
338 PRINTF1("in MATR *** ERR get_message_queue_id_matr %d\n", status)
339 }
331
340
332 BOOT_PRINTF1("in MATR *** lfrRequestedMode = %d\n", lfrRequestedMode)
341 BOOT_PRINTF1("in MATR *** lfrRequestedMode = %d\n", lfrRequestedMode)
333
342
334 while(1){
343 while(1){
335 rtems_event_receive( RTEMS_EVENT_NORM_BP1_F0 | RTEMS_EVENT_NORM_BP2_F0 | RTEMS_EVENT_NORM_ASM_F0
344 status = rtems_message_queue_receive( queue_id_matr, incomingData, &size, //************************************
336 | RTEMS_EVENT_BURST_SBM_BP1_F0 | RTEMS_EVENT_BURST_SBM_BP2_F0,
345 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
337 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
346
347 incomingMsg = (asm_msg*) incomingData;
348
338 localTime = getTimeAsUnsignedLongLongInt( );
349 localTime = getTimeAsUnsignedLongLongInt( );
339 //****************
350 //****************
340 //****************
351 //****************
341 // BURST SBM1 SBM2
352 // BURST SBM1 SBM2
342 //****************
353 //****************
343 //****************
354 //****************
344 if ( event_out & RTEMS_EVENT_BURST_SBM_BP1_F0 )
355 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
345 {
356 {
346 // 1) compress the matrix for Basic Parameters calculation
357 // 1) compress the matrix for Basic Parameters calculation
347 ASM_compress_reorganize_and_divide( current_ring_node_asm_burst_sbm_f0->asm_burst_sbm_f0, compressed_sm_sbm,
358 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbmf0->matrix, compressed_sm_sbm,
348 nb_sm_before_bp.burst_sbm_bp1_f0,
359 nb_sm_before_bp.burst_sbm_bp1_f0,
349 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
360 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
350 ASM_F0_INDICE_START);
361 ASM_F0_INDICE_START);
351 // 2) compute the BP1 set
362 // 2) compute the BP1 set
352
363
353 // 3) send the BP1 set
364 // 3) send the BP1 set
354 set_time( current_node_sbm_bp1_f0.header.time, (unsigned char *) &compressed_sm_sbm );
365 set_time( current_node_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
355 set_time( current_node_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_sbm );
366 set_time( current_node_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
356 BP_send( (char *) &current_node_sbm_bp1_f0.header, queue_id,
367 BP_send( (char *) &current_node_sbm_bp1_f0.header, queue_id,
357 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
368 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
358 // 4) compute the BP2 set if needed
369 // 4) compute the BP2 set if needed
359 if ( event_out & RTEMS_EVENT_BURST_SBM_BP2_F0 )
370 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
360 {
371 {
361 // 1) compute the BP2 set
372 // 1) compute the BP2 set
362
373
363 // 2) send the BP2 set
374 // 2) send the BP2 set
364 set_time( current_node_sbm_bp2_f0.header.time, (unsigned char *) &compressed_sm_sbm );
375 set_time( current_node_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
365 set_time( current_node_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_sbm );
376 set_time( current_node_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
366 BP_send( (char *) &current_node_sbm_bp2_f0.header, queue_id,
377 BP_send( (char *) &current_node_sbm_bp2_f0.header, queue_id,
367 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
378 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
368 }
379 }
369 }
380 }
370
381
371 //*****
382 //*****
372 //*****
383 //*****
373 // NORM
384 // NORM
374 //*****
385 //*****
375 //*****
386 //*****
376 if (event_out & RTEMS_EVENT_NORM_BP1_F0)
387 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
377 {
388 {
378 // 1) compress the matrix for Basic Parameters calculation
389 // 1) compress the matrix for Basic Parameters calculation
379 ASM_compress_reorganize_and_divide( asm_norm_f0, compressed_sm_norm_f0,
390 ASM_compress_reorganize_and_divide( incomingMsg->norm_f0->matrix, compressed_sm_norm_f0,
380 nb_sm_before_bp.norm_bp1_f0,
391 nb_sm_before_bp.norm_bp1_f0,
381 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
392 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
382 ASM_F0_INDICE_START );
393 ASM_F0_INDICE_START );
383 // 2) compute the BP1 set
394 // 2) compute the BP1 set
384
395
385 // 3) send the BP1 set
396 // 3) send the BP1 set
386 set_time( current_node_norm_bp1_f0.header.time, (unsigned char *) &compressed_sm_norm_f0 );
397 set_time( current_node_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
387 set_time( current_node_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_norm_f0 );
398 set_time( current_node_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
388 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
399 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
389 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
400 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
390 if (event_out & RTEMS_EVENT_NORM_BP2_F0)
401 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
391 {
402 {
392 // 1) compute the BP2 set
403 // 1) compute the BP2 set
393
404
394 // 2) send the BP2 set
405 // 2) send the BP2 set
395 set_time( current_node_norm_bp2_f0.header.time, (unsigned char *) &compressed_sm_norm_f0 );
406 set_time( current_node_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
396 set_time( current_node_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_norm_f0 );
407 set_time( current_node_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
397 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
408 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
398 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
409 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
399 }
410 }
400 }
411 }
401
412
402 if (event_out & RTEMS_EVENT_NORM_ASM_F0)
413 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
403 {
414 {
404 // 1) reorganize the ASM and divide
415 // 1) reorganize the ASM and divide
405 ASM_reorganize_and_divide( asm_norm_f0, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
416 ASM_reorganize_and_divide( incomingMsg->norm_f0->matrix, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
406 // 2) convert the float array in a char array
417 // 2) convert the float array in a char array
407 ASM_convert( asm_f0_reorganized, asm_f0_char);
418 ASM_convert( asm_f0_reorganized, asm_f0_char);
408 // 3) send the spectral matrix packets
419 // 3) send the spectral matrix packets
420 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
421 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
409 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
422 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
410 // localTime = getTimeAsUnsignedLongLongInt( ) - localTime;
411 // PRINTF1("in MATR *** %lld\n", localTime)
412 }
423 }
413
424
414 }
425 }
415 }
426 }
416
427
417 //******************
428 //******************
418 // Spectral Matrices
429 // Spectral Matrices
419
430
420 void SM_init_rings( void )
431 void SM_init_rings( void )
421 {
432 {
422 unsigned char i;
433 unsigned char i;
423
434
424 // F0 RING
435 // F0 RING
425 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
436 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
426 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
437 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
427 sm_ring_f0[0].buffer_address =
438 sm_ring_f0[0].buffer_address =
428 (int) &sm_f0[ 0 ];
439 (int) &sm_f0[ 0 ];
429
440
430 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
441 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
431 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
442 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
432 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
443 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
433 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
444 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
434
445
435 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
446 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
436 {
447 {
437 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
448 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
438 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
449 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
439 sm_ring_f0[i].buffer_address =
450 sm_ring_f0[i].buffer_address =
440 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
451 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
441 }
452 }
442
453
443 // F1 RING
454 // F1 RING
444 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
455 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
445 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
456 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
446 sm_ring_f1[0].buffer_address =
457 sm_ring_f1[0].buffer_address =
447 (int) &sm_f1[ 0 ];
458 (int) &sm_f1[ 0 ];
448
459
449 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
460 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
450 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
461 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
451 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
462 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
452 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
463 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
453
464
454 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
465 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
455 {
466 {
456 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
467 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
457 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
468 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
458 sm_ring_f1[i].buffer_address =
469 sm_ring_f1[i].buffer_address =
459 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
470 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
460 }
471 }
461
472
462 // F2 RING
473 // F2 RING
463 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
474 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
464 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
475 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
465 sm_ring_f2[0].buffer_address =
476 sm_ring_f2[0].buffer_address =
466 (int) &sm_f2[ 0 ];
477 (int) &sm_f2[ 0 ];
467
478
468 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
479 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
469 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
480 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
470 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
481 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
471 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
482 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
472
483
473 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
484 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
474 {
485 {
475 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
486 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
476 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
487 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
477 sm_ring_f2[i].buffer_address =
488 sm_ring_f2[i].buffer_address =
478 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
489 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
479 }
490 }
480
491
481 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
492 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
482 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
493 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
483 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
494 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
484
495
485 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
496 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
486 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
497 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
487 }
498 }
488
499
489 void ASM_init_ring( void )
500 void ASM_init_rings( void )
490 {
501 {
491 unsigned char i;
502 unsigned char i;
492
503
504 //*************
505 // BURST_SBM_F0
493 asm_ring_burst_sbm_f0[0].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[1];
506 asm_ring_burst_sbm_f0[0].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[1];
494 asm_ring_burst_sbm_f0[0].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1];
507 asm_ring_burst_sbm_f0[0].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1];
495
508
496 asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].next
509 asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].next
497 = (ring_node_asm*) &asm_ring_burst_sbm_f0[0];
510 = (ring_node_asm*) &asm_ring_burst_sbm_f0[0];
498 asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].previous
511 asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].previous
499 = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-2];
512 = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-2];
500
513
501 for(i=1; i<NB_RING_NODES_ASM_BURST_SBM_F0-1; i++)
514 for(i=1; i<NB_RING_NODES_ASM_BURST_SBM_F0-1; i++)
502 {
515 {
503 asm_ring_burst_sbm_f0[i].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[i+1];
516 asm_ring_burst_sbm_f0[i].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[i+1];
504 asm_ring_burst_sbm_f0[i].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[i-1];
517 asm_ring_burst_sbm_f0[i].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[i-1];
505 }
518 }
519
520 //*************
521 // NORM_F0
522 asm_ring_norm_f0[0].next = (ring_node_asm*) &asm_ring_norm_f0[1];
523 asm_ring_norm_f0[0].previous = (ring_node_asm*) &asm_ring_norm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1];
524
525 asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-1].next
526 = (ring_node_asm*) &asm_ring_norm_f0[0];
527 asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-1].previous
528 = (ring_node_asm*) &asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-2];
529
530 for(i=1; i<NB_RING_NODES_ASM_NORM_F0-1; i++)
531 {
532 asm_ring_norm_f0[i].next = (ring_node_asm*) &asm_ring_norm_f0[i+1];
533 asm_ring_norm_f0[i].previous = (ring_node_asm*) &asm_ring_norm_f0[i-1];
534 }
506 }
535 }
507
536
508 void SM_reset_current_ring_nodes( void )
537 void SM_reset_current_ring_nodes( void )
509 {
538 {
510 current_ring_node_sm_f0 = sm_ring_f0;
539 current_ring_node_sm_f0 = sm_ring_f0;
511 current_ring_node_sm_f1 = sm_ring_f1;
540 current_ring_node_sm_f1 = sm_ring_f1;
512 current_ring_node_sm_f2 = sm_ring_f2;
541 current_ring_node_sm_f2 = sm_ring_f2;
513
542
514 ring_node_for_averaging_sm_f0 = sm_ring_f0;
543 ring_node_for_averaging_sm_f0 = sm_ring_f0;
515 }
544 }
516
545
517 void ASM_reset_current_ring_node( void )
546 void ASM_reset_current_ring_node( void )
518 {
547 {
519 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
548 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
520 ring_node_for_processing_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
549 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
521 }
550 }
522
551
523 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
552 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
524 {
553 {
525 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
554 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
526 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
555 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
527 header->reserved = 0x00;
556 header->reserved = 0x00;
528 header->userApplication = CCSDS_USER_APP;
557 header->userApplication = CCSDS_USER_APP;
529 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
558 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
530 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
559 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
531 header->packetSequenceControl[0] = 0xc0;
560 header->packetSequenceControl[0] = 0xc0;
532 header->packetSequenceControl[1] = 0x00;
561 header->packetSequenceControl[1] = 0x00;
533 header->packetLength[0] = 0x00;
562 header->packetLength[0] = 0x00;
534 header->packetLength[1] = 0x00;
563 header->packetLength[1] = 0x00;
535 // DATA FIELD HEADER
564 // DATA FIELD HEADER
536 header->spare1_pusVersion_spare2 = 0x10;
565 header->spare1_pusVersion_spare2 = 0x10;
537 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
566 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
538 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
567 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
539 header->destinationID = TM_DESTINATION_ID_GROUND;
568 header->destinationID = TM_DESTINATION_ID_GROUND;
540 // AUXILIARY DATA HEADER
569 // AUXILIARY DATA HEADER
541 header->sid = 0x00;
570 header->sid = 0x00;
542 header->biaStatusInfo = 0x00;
571 header->biaStatusInfo = 0x00;
543 header->pa_lfr_pkt_cnt_asm = 0x00;
572 header->pa_lfr_pkt_cnt_asm = 0x00;
544 header->pa_lfr_pkt_nr_asm = 0x00;
573 header->pa_lfr_pkt_nr_asm = 0x00;
545 header->time[0] = 0x00;
574 header->time[0] = 0x00;
546 header->time[0] = 0x00;
575 header->time[0] = 0x00;
547 header->time[0] = 0x00;
576 header->time[0] = 0x00;
548 header->time[0] = 0x00;
577 header->time[0] = 0x00;
549 header->time[0] = 0x00;
578 header->time[0] = 0x00;
550 header->time[0] = 0x00;
579 header->time[0] = 0x00;
551 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
580 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
552 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
581 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
553 }
582 }
554
583
555 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
584 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
556 ring_node_sm *ring_node_tab[],
585 ring_node_sm *ring_node_tab[],
557 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
586 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
558 {
587 {
559 float sum;
588 float sum;
560 unsigned int i;
589 unsigned int i;
561 unsigned char *ptr;
562
590
563 for(i=0; i<TOTAL_SIZE_SM; i++)
591 for(i=0; i<TOTAL_SIZE_SM; i++)
564 {
592 {
565 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
593 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
566 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
594 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
567 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
595 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
568 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
596 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
569 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
597 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
570 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
598 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
571 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
599 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
572 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
600 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
573
601
574 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
602 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
575 {
603 {
576 averaged_spec_mat_f0[ TIME_OFFSET + i ] = sum;
604 averaged_spec_mat_f0[ i ] = sum;
577 averaged_spec_mat_f1[ TIME_OFFSET + i ] = sum;
605 averaged_spec_mat_f1[ i ] = sum;
578 }
606 }
579 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
607 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
580 {
608 {
581 averaged_spec_mat_f0[ TIME_OFFSET + i ] = ( averaged_spec_mat_f0[ TIME_OFFSET + i ] + sum );
609 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
582 averaged_spec_mat_f1[ TIME_OFFSET + i ] = ( averaged_spec_mat_f1[ TIME_OFFSET + i ] + sum );
610 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
583 }
611 }
584 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
612 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
585 {
613 {
586 averaged_spec_mat_f0[ TIME_OFFSET + i ] = ( averaged_spec_mat_f0[ TIME_OFFSET + i ] + sum );
614 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
587 averaged_spec_mat_f1[ TIME_OFFSET + i ] = sum;
615 averaged_spec_mat_f1[ i ] = sum;
588 }
616 }
589 else
617 else
590 {
618 {
591 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
619 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
592 }
620 }
593 }
621 }
594 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
595 {
596 ptr = (unsigned char *) averaged_spec_mat_f0;
597 ptr[0] = (unsigned char) (time_management_regs->coarse_time >> 24);
598 ptr[1] = (unsigned char) (time_management_regs->coarse_time >> 16);
599 ptr[2] = (unsigned char) (time_management_regs->coarse_time >> 8 );
600 ptr[3] = (unsigned char) (time_management_regs->coarse_time );
601 ptr[4] = (unsigned char) (time_management_regs->fine_time >> 24);
602 ptr[5] = (unsigned char) (time_management_regs->fine_time >> 16);
603 ptr[6] = (unsigned char) (time_management_regs->fine_time >> 8 );
604 ptr[7] = (unsigned char) (time_management_regs->fine_time );
605 ptr = (unsigned char *) averaged_spec_mat_f1;
606 ptr[0] = (unsigned char) (time_management_regs->coarse_time >> 24);
607 ptr[1] = (unsigned char) (time_management_regs->coarse_time >> 16);
608 ptr[2] = (unsigned char) (time_management_regs->coarse_time >> 8 );
609 ptr[3] = (unsigned char) (time_management_regs->coarse_time );
610 ptr[4] = (unsigned char) (time_management_regs->fine_time >> 24);
611 ptr[5] = (unsigned char) (time_management_regs->fine_time >> 16);
612 ptr[6] = (unsigned char) (time_management_regs->fine_time >> 8 );
613 ptr[7] = (unsigned char) (time_management_regs->fine_time );
614 }
615 }
622 }
616
623
617 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
624 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
618 {
625 {
619 int frequencyBin;
626 int frequencyBin;
620 int asmComponent;
627 int asmComponent;
621
628 unsigned int offsetAveragedSpecMatReorganized;
622 // copy the time information
629 unsigned int offsetAveragedSpecMat;
623 averaged_spec_mat_reorganized[ 0 ] = averaged_spec_mat[ 0 ];
624 averaged_spec_mat_reorganized[ 1 ] = averaged_spec_mat[ 1 ];
625
630
626 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
631 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
627 {
632 {
628 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
633 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
629 {
634 {
630 averaged_spec_mat_reorganized[ TIME_OFFSET + frequencyBin * NB_VALUES_PER_SM + asmComponent ] =
635 offsetAveragedSpecMatReorganized =
631 averaged_spec_mat[ TIME_OFFSET + asmComponent * NB_BINS_PER_SM + frequencyBin ] / divider;
636 frequencyBin * NB_VALUES_PER_SM
637 + asmComponent;
638 offsetAveragedSpecMat =
639 asmComponent * NB_BINS_PER_SM
640 + frequencyBin;
641 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
642 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
632 }
643 }
633 }
644 }
634 }
645 }
635
646
636 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
647 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
637 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
648 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
638 {
649 {
639 int frequencyBin;
650 int frequencyBin;
640 int asmComponent;
651 int asmComponent;
641 int offsetASM;
652 int offsetASM;
642 int offsetCompressed;
653 int offsetCompressed;
643 int k;
654 int k;
644
655
645 // copy the time information
646 compressed_spec_mat[ 0 ] = averaged_spec_mat[ 0 ];
647 compressed_spec_mat[ 1 ] = averaged_spec_mat[ 1 ];
648
649 // build data
656 // build data
650 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
657 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
651 {
658 {
652 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
659 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
653 {
660 {
654 offsetCompressed = TIME_OFFSET
661 offsetCompressed = // NO TIME OFFSET
655 + frequencyBin * NB_VALUES_PER_SM
662 frequencyBin * NB_VALUES_PER_SM
656 + asmComponent;
663 + asmComponent;
657 offsetASM = TIME_OFFSET
664 offsetASM = // NO TIME OFFSET
658 + asmComponent * NB_BINS_PER_SM
665 asmComponent * NB_BINS_PER_SM
659 + ASMIndexStart
666 + ASMIndexStart
660 + frequencyBin * nbBinsToAverage;
667 + frequencyBin * nbBinsToAverage;
661 compressed_spec_mat[ offsetCompressed ] = 0;
668 compressed_spec_mat[ offsetCompressed ] = 0;
662 for ( k = 0; k < nbBinsToAverage; k++ )
669 for ( k = 0; k < nbBinsToAverage; k++ )
663 {
670 {
664 compressed_spec_mat[offsetCompressed ] =
671 compressed_spec_mat[offsetCompressed ] =
665 ( compressed_spec_mat[ offsetCompressed ]
672 ( compressed_spec_mat[ offsetCompressed ]
666 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
673 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
667 }
674 }
668 }
675 }
669 }
676 }
670 }
677 }
671
678
672 void ASM_convert( volatile float *input_matrix, char *output_matrix)
679 void ASM_convert( volatile float *input_matrix, char *output_matrix)
673 {
680 {
674 unsigned int i;
675 unsigned int frequencyBin;
681 unsigned int frequencyBin;
676 unsigned int asmComponent;
682 unsigned int asmComponent;
677 char * pt_char_input;
683 char * pt_char_input;
678 char * pt_char_output;
684 char * pt_char_output;
685 unsigned int offsetInput;
686 unsigned int offsetOutput;
679
687
680 pt_char_input = (char*) &input_matrix;
688 pt_char_input = (char*) &input_matrix;
681 pt_char_output = (char*) &output_matrix;
689 pt_char_output = (char*) &output_matrix;
682
690
683 // copy the time information
684 for (i=0; i<TIME_OFFSET_IN_BYTES; i++)
685 {
686 pt_char_output[ i ] = pt_char_output[ i ];
687 }
688
689 // convert all other data
691 // convert all other data
690 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
692 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
691 {
693 {
692 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
694 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
693 {
695 {
694 pt_char_input = (char*) &input_matrix [ (frequencyBin*NB_VALUES_PER_SM) + asmComponent + TIME_OFFSET ];
696 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
695 pt_char_output = (char*) &output_matrix[ 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) + TIME_OFFSET_IN_BYTES ];
697 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
698 pt_char_input = (char*) &input_matrix [ offsetInput ];
699 pt_char_output = (char*) &output_matrix[ offsetOutput ];
696 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
700 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
697 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
701 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
698 }
702 }
699 }
703 }
700 }
704 }
701
705
702 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
706 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
703 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
707 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
704 {
708 {
705 unsigned int i;
709 unsigned int i;
706 unsigned int length = 0;
710 unsigned int length = 0;
707 rtems_status_code status;
711 rtems_status_code status;
708
712
709 for (i=0; i<2; i++)
713 for (i=0; i<2; i++)
710 {
714 {
711 // (1) BUILD THE DATA
715 // (1) BUILD THE DATA
712 switch(sid)
716 switch(sid)
713 {
717 {
714 case SID_NORM_ASM_F0:
718 case SID_NORM_ASM_F0:
715 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2;
719 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2;
716 spw_ioctl_send->data = &spectral_matrix[
720 spw_ioctl_send->data = &spectral_matrix[
717 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
721 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
718 + TIME_OFFSET_IN_BYTES
719 ];
722 ];
720 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
723 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
721 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
724 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
722 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
725 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
723 break;
726 break;
724 case SID_NORM_ASM_F1:
727 case SID_NORM_ASM_F1:
725 break;
728 break;
726 case SID_NORM_ASM_F2:
729 case SID_NORM_ASM_F2:
727 break;
730 break;
728 default:
731 default:
729 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
732 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
730 break;
733 break;
731 }
734 }
732 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
735 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
733 spw_ioctl_send->hdr = (char *) header;
736 spw_ioctl_send->hdr = (char *) header;
734 spw_ioctl_send->options = 0;
737 spw_ioctl_send->options = 0;
735
738
736 // (2) BUILD THE HEADER
739 // (2) BUILD THE HEADER
737 header->packetLength[0] = (unsigned char) (length>>8);
740 header->packetLength[0] = (unsigned char) (length>>8);
738 header->packetLength[1] = (unsigned char) (length);
741 header->packetLength[1] = (unsigned char) (length);
739 header->sid = (unsigned char) sid; // SID
742 header->sid = (unsigned char) sid; // SID
740 header->pa_lfr_pkt_cnt_asm = 2;
743 header->pa_lfr_pkt_cnt_asm = 2;
741 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
744 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
742
745
743 // (3) SET PACKET TIME
746 // (3) SET PACKET TIME
744 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
747 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
745 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
748 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
746 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
749 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
747 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
750 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
748 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
751 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
749 header->time[5] = (unsigned char) (time_management_regs->fine_time);
752 header->time[5] = (unsigned char) (time_management_regs->fine_time);
750 //
753 //
751 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
754 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
752 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
755 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
753 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
756 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
754 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
757 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
755 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
758 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
756 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
759 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
757
760
758 // (4) SEND PACKET
761 // (4) SEND PACKET
759 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
762 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
760 if (status != RTEMS_SUCCESSFUL) {
763 if (status != RTEMS_SUCCESSFUL) {
761 printf("in ASM_send *** ERR %d\n", (int) status);
764 printf("in ASM_send *** ERR %d\n", (int) status);
762 }
765 }
763 }
766 }
764 }
767 }
765
768
766 //*****************
769 //*****************
767 // Basic Parameters
770 // Basic Parameters
768
771
769 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
772 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
770 unsigned int apid, unsigned char sid,
773 unsigned int apid, unsigned char sid,
771 unsigned int packetLength, unsigned char blkNr )
774 unsigned int packetLength, unsigned char blkNr )
772 {
775 {
773 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
776 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
774 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
777 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
775 header->reserved = 0x00;
778 header->reserved = 0x00;
776 header->userApplication = CCSDS_USER_APP;
779 header->userApplication = CCSDS_USER_APP;
777 header->packetID[0] = (unsigned char) (apid >> 8);
780 header->packetID[0] = (unsigned char) (apid >> 8);
778 header->packetID[1] = (unsigned char) (apid);
781 header->packetID[1] = (unsigned char) (apid);
779 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
782 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
780 header->packetSequenceControl[1] = 0x00;
783 header->packetSequenceControl[1] = 0x00;
781 header->packetLength[0] = (unsigned char) (packetLength >> 8);
784 header->packetLength[0] = (unsigned char) (packetLength >> 8);
782 header->packetLength[1] = (unsigned char) (packetLength);
785 header->packetLength[1] = (unsigned char) (packetLength);
783 // DATA FIELD HEADER
786 // DATA FIELD HEADER
784 header->spare1_pusVersion_spare2 = 0x10;
787 header->spare1_pusVersion_spare2 = 0x10;
785 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
788 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
786 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
789 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
787 header->destinationID = TM_DESTINATION_ID_GROUND;
790 header->destinationID = TM_DESTINATION_ID_GROUND;
788 // AUXILIARY DATA HEADER
791 // AUXILIARY DATA HEADER
789 header->sid = sid;
792 header->sid = sid;
790 header->biaStatusInfo = 0x00;
793 header->biaStatusInfo = 0x00;
791 header->time[0] = 0x00;
794 header->time[0] = 0x00;
792 header->time[0] = 0x00;
795 header->time[0] = 0x00;
793 header->time[0] = 0x00;
796 header->time[0] = 0x00;
794 header->time[0] = 0x00;
797 header->time[0] = 0x00;
795 header->time[0] = 0x00;
798 header->time[0] = 0x00;
796 header->time[0] = 0x00;
799 header->time[0] = 0x00;
797 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
800 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
798 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
801 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
799 }
802 }
800
803
801 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
804 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
802 unsigned int apid, unsigned char sid,
805 unsigned int apid, unsigned char sid,
803 unsigned int packetLength , unsigned char blkNr)
806 unsigned int packetLength , unsigned char blkNr)
804 {
807 {
805 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
808 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
806 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
809 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
807 header->reserved = 0x00;
810 header->reserved = 0x00;
808 header->userApplication = CCSDS_USER_APP;
811 header->userApplication = CCSDS_USER_APP;
809 header->packetID[0] = (unsigned char) (apid >> 8);
812 header->packetID[0] = (unsigned char) (apid >> 8);
810 header->packetID[1] = (unsigned char) (apid);
813 header->packetID[1] = (unsigned char) (apid);
811 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
814 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
812 header->packetSequenceControl[1] = 0x00;
815 header->packetSequenceControl[1] = 0x00;
813 header->packetLength[0] = (unsigned char) (packetLength >> 8);
816 header->packetLength[0] = (unsigned char) (packetLength >> 8);
814 header->packetLength[1] = (unsigned char) (packetLength);
817 header->packetLength[1] = (unsigned char) (packetLength);
815 // DATA FIELD HEADER
818 // DATA FIELD HEADER
816 header->spare1_pusVersion_spare2 = 0x10;
819 header->spare1_pusVersion_spare2 = 0x10;
817 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
820 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
818 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
821 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
819 header->destinationID = TM_DESTINATION_ID_GROUND;
822 header->destinationID = TM_DESTINATION_ID_GROUND;
820 // AUXILIARY DATA HEADER
823 // AUXILIARY DATA HEADER
821 header->sid = sid;
824 header->sid = sid;
822 header->biaStatusInfo = 0x00;
825 header->biaStatusInfo = 0x00;
823 header->time[0] = 0x00;
826 header->time[0] = 0x00;
824 header->time[0] = 0x00;
827 header->time[0] = 0x00;
825 header->time[0] = 0x00;
828 header->time[0] = 0x00;
826 header->time[0] = 0x00;
829 header->time[0] = 0x00;
827 header->time[0] = 0x00;
830 header->time[0] = 0x00;
828 header->time[0] = 0x00;
831 header->time[0] = 0x00;
829 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
832 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
830 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
833 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
831 }
834 }
832
835
833 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
836 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend )
834 {
837 {
835 rtems_status_code status;
838 rtems_status_code status;
836
839
837 // SEND PACKET
840 // SEND PACKET
838 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
841 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
839 if (status != RTEMS_SUCCESSFUL)
842 if (status != RTEMS_SUCCESSFUL)
840 {
843 {
841 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
844 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
842 }
845 }
843 }
846 }
844
847
845 //******************
848 //******************
846 // general functions
849 // general functions
847
850
848 void reset_spectral_matrix_regs( void )
851 void reset_spectral_matrix_regs( void )
849 {
852 {
850 /** This function resets the spectral matrices module registers.
853 /** This function resets the spectral matrices module registers.
851 *
854 *
852 * The registers affected by this function are located at the following offset addresses:
855 * The registers affected by this function are located at the following offset addresses:
853 *
856 *
854 * - 0x00 config
857 * - 0x00 config
855 * - 0x04 status
858 * - 0x04 status
856 * - 0x08 matrixF0_Address0
859 * - 0x08 matrixF0_Address0
857 * - 0x10 matrixFO_Address1
860 * - 0x10 matrixFO_Address1
858 * - 0x14 matrixF1_Address
861 * - 0x14 matrixF1_Address
859 * - 0x18 matrixF2_Address
862 * - 0x18 matrixF2_Address
860 *
863 *
861 */
864 */
862
865
863 spectral_matrix_regs->config = 0x00;
866 spectral_matrix_regs->config = 0x00;
864 spectral_matrix_regs->status = 0x00;
867 spectral_matrix_regs->status = 0x00;
865
868
866 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
869 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
867 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
870 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
868 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
871 spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address;
869 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
872 spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address;
870 }
873 }
871
874
872 void set_time( unsigned char *time, unsigned char * timeInBuffer )
875 void set_time( unsigned char *time, unsigned char * timeInBuffer )
873 {
876 {
874 // time[0] = timeInBuffer[2];
877 // time[0] = timeInBuffer[2];
875 // time[1] = timeInBuffer[3];
878 // time[1] = timeInBuffer[3];
876 // time[2] = timeInBuffer[0];
879 // time[2] = timeInBuffer[0];
877 // time[3] = timeInBuffer[1];
880 // time[3] = timeInBuffer[1];
878 // time[4] = timeInBuffer[6];
881 // time[4] = timeInBuffer[6];
879 // time[5] = timeInBuffer[7];
882 // time[5] = timeInBuffer[7];
880
883
881 time[0] = timeInBuffer[0];
884 time[0] = timeInBuffer[0];
882 time[1] = timeInBuffer[1];
885 time[1] = timeInBuffer[1];
883 time[2] = timeInBuffer[2];
886 time[2] = timeInBuffer[2];
884 time[3] = timeInBuffer[3];
887 time[3] = timeInBuffer[3];
885 time[4] = timeInBuffer[6];
888 time[4] = timeInBuffer[6];
886 time[5] = timeInBuffer[7];
889 time[5] = timeInBuffer[7];
887 }
890 }
888
891
889
892
@@ -1,610 +1,610
1 /** Functions related to the SpaceWire interface.
1 /** Functions related to the SpaceWire interface.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle SpaceWire transmissions:
6 * A group of functions to handle SpaceWire transmissions:
7 * - configuration of the SpaceWire link
7 * - configuration of the SpaceWire link
8 * - SpaceWire related interruption requests processing
8 * - SpaceWire related interruption requests processing
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
11 *
11 *
12 */
12 */
13
13
14 #include "fsw_spacewire.h"
14 #include "fsw_spacewire.h"
15
15
16 rtems_name semq_name;
16 rtems_name semq_name;
17 rtems_id semq_id;
17 rtems_id semq_id;
18
18
19 //***********
19 //***********
20 // RTEMS TASK
20 // RTEMS TASK
21 rtems_task spiq_task(rtems_task_argument unused)
21 rtems_task spiq_task(rtems_task_argument unused)
22 {
22 {
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
24 *
24 *
25 * @param unused is the starting argument of the RTEMS task
25 * @param unused is the starting argument of the RTEMS task
26 *
26 *
27 */
27 */
28
28
29 rtems_event_set event_out;
29 rtems_event_set event_out;
30 rtems_status_code status;
30 rtems_status_code status;
31 int linkStatus;
31 int linkStatus;
32
32
33 BOOT_PRINTF("in SPIQ *** \n")
33 BOOT_PRINTF("in SPIQ *** \n")
34
34
35 while(true){
35 while(true){
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
38
38
39 // [0] SUSPEND RECV AND SEND TASKS
39 // [0] SUSPEND RECV AND SEND TASKS
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
41 if ( status != RTEMS_SUCCESSFUL ) {
41 if ( status != RTEMS_SUCCESSFUL ) {
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
43 }
43 }
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
45 if ( status != RTEMS_SUCCESSFUL ) {
45 if ( status != RTEMS_SUCCESSFUL ) {
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
47 }
47 }
48
48
49 // [1] CHECK THE LINK
49 // [1] CHECK THE LINK
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
51 if ( linkStatus != 5) {
51 if ( linkStatus != 5) {
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
54 }
54 }
55
55
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
59 {
59 {
60 spacewire_compute_stats_offsets();
60 spacewire_compute_stats_offsets();
61 status = spacewire_reset_link( );
61 status = spacewire_reset_link( );
62 }
62 }
63 else // [2.b] in run state, start the link
63 else // [2.b] in run state, start the link
64 {
64 {
65 status = spacewire_stop_start_link( fdSPW ); // start the link
65 status = spacewire_stop_start_link( fdSPW ); // start the link
66 if ( status != RTEMS_SUCCESSFUL)
66 if ( status != RTEMS_SUCCESSFUL)
67 {
67 {
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
69 }
69 }
70 }
70 }
71
71
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
74 {
74 {
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
76 if ( status != RTEMS_SUCCESSFUL ) {
76 if ( status != RTEMS_SUCCESSFUL ) {
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
78 }
78 }
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
80 if ( status != RTEMS_SUCCESSFUL ) {
80 if ( status != RTEMS_SUCCESSFUL ) {
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
82 }
82 }
83 }
83 }
84 else // [3.b] the link is not in run state, go in STANDBY mode
84 else // [3.b] the link is not in run state, go in STANDBY mode
85 {
85 {
86 status = stop_current_mode();
86 status = stop_current_mode();
87 if ( status != RTEMS_SUCCESSFUL ) {
87 if ( status != RTEMS_SUCCESSFUL ) {
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
89 }
89 }
90 status = enter_mode( LFR_MODE_STANDBY, 0 );
90 status = enter_mode( LFR_MODE_STANDBY, 0 );
91 if ( status != RTEMS_SUCCESSFUL ) {
91 if ( status != RTEMS_SUCCESSFUL ) {
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
93 }
93 }
94 // wake the WTDG task up to wait for the link recovery
94 // wake the WTDG task up to wait for the link recovery
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
96 status = rtems_task_suspend( RTEMS_SELF );
96 status = rtems_task_suspend( RTEMS_SELF );
97 }
97 }
98 }
98 }
99 }
99 }
100
100
101 rtems_task recv_task( rtems_task_argument unused )
101 rtems_task recv_task( rtems_task_argument unused )
102 {
102 {
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
104 *
104 *
105 * @param unused is the starting argument of the RTEMS task
105 * @param unused is the starting argument of the RTEMS task
106 *
106 *
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
108 * 1. It reads the incoming data.
108 * 1. It reads the incoming data.
109 * 2. Launches the acceptance procedure.
109 * 2. Launches the acceptance procedure.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
111 *
111 *
112 */
112 */
113
113
114 int len;
114 int len;
115 ccsdsTelecommandPacket_t currentTC;
115 ccsdsTelecommandPacket_t currentTC;
116 unsigned char computed_CRC[ 2 ];
116 unsigned char computed_CRC[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
118 unsigned char destinationID;
118 unsigned char destinationID;
119 unsigned int estimatedPacketLength;
119 unsigned int estimatedPacketLength;
120 unsigned int parserCode;
120 unsigned int parserCode;
121 rtems_status_code status;
121 rtems_status_code status;
122 rtems_id queue_recv_id;
122 rtems_id queue_recv_id;
123 rtems_id queue_send_id;
123 rtems_id queue_send_id;
124
124
125 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
125 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
126
126
127 status = get_message_queue_id_recv( &queue_recv_id );
127 status = get_message_queue_id_recv( &queue_recv_id );
128 if (status != RTEMS_SUCCESSFUL)
128 if (status != RTEMS_SUCCESSFUL)
129 {
129 {
130 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
130 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
131 }
131 }
132
132
133 status = get_message_queue_id_send( &queue_send_id );
133 status = get_message_queue_id_send( &queue_send_id );
134 if (status != RTEMS_SUCCESSFUL)
134 if (status != RTEMS_SUCCESSFUL)
135 {
135 {
136 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
136 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
137 }
137 }
138
138
139 BOOT_PRINTF("in RECV *** \n")
139 BOOT_PRINTF("in RECV *** \n")
140
140
141 while(1)
141 while(1)
142 {
142 {
143 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
143 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
144 if (len == -1){ // error during the read call
144 if (len == -1){ // error during the read call
145 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
145 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
146 }
146 }
147 else {
147 else {
148 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
148 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
149 PRINTF("in RECV *** packet lenght too short\n")
149 PRINTF("in RECV *** packet lenght too short\n")
150 }
150 }
151 else {
151 else {
152 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
152 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
155 // CHECK THE TC
155 // CHECK THE TC
156 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
156 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
157 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
157 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
158 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
158 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
159 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
159 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
160 || (parserCode == WRONG_SRC_ID) )
160 || (parserCode == WRONG_SRC_ID) )
161 { // send TM_LFR_TC_EXE_CORRUPTED
161 { // send TM_LFR_TC_EXE_CORRUPTED
162 PRINTF1("TC corrupted received, with code: %d\n", parserCode)
162 PRINTF1("TC corrupted received, with code: %d\n", parserCode)
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 &&
164 &&
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 )
166 )
167 {
167 {
168 if ( parserCode == WRONG_SRC_ID )
168 if ( parserCode == WRONG_SRC_ID )
169 {
169 {
170 destinationID = SID_TC_GROUND;
170 destinationID = SID_TC_GROUND;
171 }
171 }
172 else
172 else
173 {
173 {
174 destinationID = currentTC.sourceID;
174 destinationID = currentTC.sourceID;
175 }
175 }
176 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
176 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
177 computed_CRC, currentTC_LEN_RCV,
177 computed_CRC, currentTC_LEN_RCV,
178 destinationID );
178 destinationID );
179 }
179 }
180 }
180 }
181 else
181 else
182 { // send valid TC to the action launcher
182 { // send valid TC to the action launcher
183 status = rtems_message_queue_send( queue_recv_id, &currentTC,
183 status = rtems_message_queue_send( queue_recv_id, &currentTC,
184 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
184 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
185 }
185 }
186 }
186 }
187 }
187 }
188 }
188 }
189 }
189 }
190
190
191 rtems_task send_task( rtems_task_argument argument)
191 rtems_task send_task( rtems_task_argument argument)
192 {
192 {
193 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
193 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
194 *
194 *
195 * @param unused is the starting argument of the RTEMS task
195 * @param unused is the starting argument of the RTEMS task
196 *
196 *
197 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
197 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
198 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
198 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
199 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
199 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
200 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
200 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
201 * data it contains.
201 * data it contains.
202 *
202 *
203 */
203 */
204
204
205 rtems_status_code status; // RTEMS status code
205 rtems_status_code status; // RTEMS status code
206 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
206 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
207 spw_ioctl_pkt_send *spw_ioctl_send;
207 spw_ioctl_pkt_send *spw_ioctl_send;
208 size_t size; // size of the incoming TC packet
208 size_t size; // size of the incoming TC packet
209 u_int32_t count;
209 u_int32_t count;
210 rtems_id queue_id;
210 rtems_id queue_id;
211
211
212 status = get_message_queue_id_send( &queue_id );
212 status = get_message_queue_id_send( &queue_id );
213 if (status != RTEMS_SUCCESSFUL)
213 if (status != RTEMS_SUCCESSFUL)
214 {
214 {
215 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
215 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
216 }
216 }
217
217
218 BOOT_PRINTF("in SEND *** \n")
218 BOOT_PRINTF("in SEND *** \n")
219
219
220 while(1)
220 while(1)
221 {
221 {
222 status = rtems_message_queue_receive( queue_id, incomingData, &size,
222 status = rtems_message_queue_receive( queue_id, incomingData, &size,
223 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
223 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
224
224
225 if (status!=RTEMS_SUCCESSFUL)
225 if (status!=RTEMS_SUCCESSFUL)
226 {
226 {
227 PRINTF1("in SEND *** (1) ERR = %d\n", status)
227 PRINTF1("in SEND *** (1) ERR = %d\n", status)
228 }
228 }
229 else
229 else
230 {
230 {
231 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
231 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
232 {
232 {
233 status = write( fdSPW, incomingData, size );
233 status = write( fdSPW, incomingData, size );
234 if (status == -1){
234 if (status == -1){
235 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
235 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
236 }
236 }
237 }
237 }
238 else // the incoming message is a spw_ioctl_pkt_send structure
238 else // the incoming message is a spw_ioctl_pkt_send structure
239 {
239 {
240 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
240 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
241 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
241 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
242 if (status == -1){
242 if (status == -1){
243 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
243 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
244 }
244 }
245 }
245 }
246 }
246 }
247
247
248 status = rtems_message_queue_get_number_pending( queue_id, &count );
248 status = rtems_message_queue_get_number_pending( queue_id, &count );
249 if (status != RTEMS_SUCCESSFUL)
249 if (status != RTEMS_SUCCESSFUL)
250 {
250 {
251 PRINTF1("in SEND *** (3) ERR = %d\n", status)
251 PRINTF1("in SEND *** (3) ERR = %d\n", status)
252 }
252 }
253 else
253 else
254 {
254 {
255 if (count > maxCount)
255 if (count > maxCount)
256 {
256 {
257 maxCount = count;
257 maxCount = count;
258 }
258 }
259 }
259 }
260 }
260 }
261 }
261 }
262
262
263 rtems_task wtdg_task( rtems_task_argument argument )
263 rtems_task wtdg_task( rtems_task_argument argument )
264 {
264 {
265 rtems_event_set event_out;
265 rtems_event_set event_out;
266 rtems_status_code status;
266 rtems_status_code status;
267 int linkStatus;
267 int linkStatus;
268
268
269 BOOT_PRINTF("in WTDG ***\n")
269 BOOT_PRINTF("in WTDG ***\n")
270
270
271 while(1)
271 while(1)
272 {
272 {
273 // wait for an RTEMS_EVENT
273 // wait for an RTEMS_EVENT
274 rtems_event_receive( RTEMS_EVENT_0,
274 rtems_event_receive( RTEMS_EVENT_0,
275 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
275 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
276 PRINTF("in WTDG *** wait for the link\n")
276 PRINTF("in WTDG *** wait for the link\n")
277 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
277 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
278 while( linkStatus != 5) // wait for the link
278 while( linkStatus != 5) // wait for the link
279 {
279 {
280 rtems_task_wake_after( 10 );
280 rtems_task_wake_after( 10 );
281 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
281 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
282 }
282 }
283
283
284 status = spacewire_stop_start_link( fdSPW );
284 status = spacewire_stop_start_link( fdSPW );
285
285
286 if (status != RTEMS_SUCCESSFUL)
286 if (status != RTEMS_SUCCESSFUL)
287 {
287 {
288 PRINTF1("in WTDG *** ERR link not started %d\n", status)
288 PRINTF1("in WTDG *** ERR link not started %d\n", status)
289 }
289 }
290 else
290 else
291 {
291 {
292 PRINTF("in WTDG *** OK link started\n")
292 PRINTF("in WTDG *** OK link started\n")
293 }
293 }
294
294
295 // restart the SPIQ task
295 // restart the SPIQ task
296 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
296 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
297 if ( status != RTEMS_SUCCESSFUL ) {
297 if ( status != RTEMS_SUCCESSFUL ) {
298 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
298 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
299 }
299 }
300
300
301 // restart RECV and SEND
301 // restart RECV and SEND
302 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
302 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
303 if ( status != RTEMS_SUCCESSFUL ) {
303 if ( status != RTEMS_SUCCESSFUL ) {
304 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
304 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
305 }
305 }
306 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
306 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
307 if ( status != RTEMS_SUCCESSFUL ) {
307 if ( status != RTEMS_SUCCESSFUL ) {
308 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
308 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
309 }
309 }
310 }
310 }
311 }
311 }
312
312
313 //****************
313 //****************
314 // OTHER FUNCTIONS
314 // OTHER FUNCTIONS
315 int spacewire_open_link( void )
315 int spacewire_open_link( void )
316 {
316 {
317 /** This function opens the SpaceWire link.
317 /** This function opens the SpaceWire link.
318 *
318 *
319 * @return a valid file descriptor in case of success, -1 in case of a failure
319 * @return a valid file descriptor in case of success, -1 in case of a failure
320 *
320 *
321 */
321 */
322 rtems_status_code status;
322 rtems_status_code status;
323
323
324 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
324 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
325 if ( fdSPW < 0 ) {
325 if ( fdSPW < 0 ) {
326 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
326 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
327 }
327 }
328 else
328 else
329 {
329 {
330 status = RTEMS_SUCCESSFUL;
330 status = RTEMS_SUCCESSFUL;
331 }
331 }
332
332
333 return status;
333 return status;
334 }
334 }
335
335
336 int spacewire_start_link( int fd )
336 int spacewire_start_link( int fd )
337 {
337 {
338 rtems_status_code status;
338 rtems_status_code status;
339
339
340 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
340 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
341 // -1 default hardcoded driver timeout
341 // -1 default hardcoded driver timeout
342
342
343 return status;
343 return status;
344 }
344 }
345
345
346 int spacewire_stop_start_link( int fd )
346 int spacewire_stop_start_link( int fd )
347 {
347 {
348 rtems_status_code status;
348 rtems_status_code status;
349
349
350 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
350 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
351 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
351 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
352 // -1 default hardcoded driver timeout
352 // -1 default hardcoded driver timeout
353
353
354 return status;
354 return status;
355 }
355 }
356
356
357 int spacewire_configure_link( int fd )
357 int spacewire_configure_link( int fd )
358 {
358 {
359 /** This function configures the SpaceWire link.
359 /** This function configures the SpaceWire link.
360 *
360 *
361 * @return GR-RTEMS-DRIVER directive status codes:
361 * @return GR-RTEMS-DRIVER directive status codes:
362 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
362 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
363 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
363 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
364 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
364 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
365 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
365 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
366 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
366 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
367 * - 5 EIO - Error when writing to grswp hardware registers.
367 * - 5 EIO - Error when writing to grswp hardware registers.
368 * - 2 ENOENT - No such file or directory
368 * - 2 ENOENT - No such file or directory
369 */
369 */
370
370
371 rtems_status_code status;
371 rtems_status_code status;
372
372
373 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
373 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
374 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
374 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
375
375
376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
377 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
377 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
378 //
378 //
379 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
379 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
380 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
380 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
381 //
381 //
382 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
382 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
383 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
383 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
384 //
384 //
385 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
385 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
386 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
386 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
387 //
387 //
388 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
388 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
390 //
390 //
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
392 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
392 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
393 //
393 //
394 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
394 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
395 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
395 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
396
396
397 return status;
397 return status;
398 }
398 }
399
399
400 int spacewire_reset_link( void )
400 int spacewire_reset_link( void )
401 {
401 {
402 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
402 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
403 *
403 *
404 * @return RTEMS directive status code:
404 * @return RTEMS directive status code:
405 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
405 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
406 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
406 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
407 *
407 *
408 */
408 */
409
409
410 rtems_status_code status_spw;
410 rtems_status_code status_spw;
411 int i;
411 int i;
412
412
413 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
413 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
414 {
414 {
415 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
415 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
416
416
417 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
417 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
418
418
419 status_spw = spacewire_stop_start_link( fdSPW );
419 status_spw = spacewire_stop_start_link( fdSPW );
420 if ( status_spw != RTEMS_SUCCESSFUL )
420 if ( status_spw != RTEMS_SUCCESSFUL )
421 {
421 {
422 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
422 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
423 }
423 }
424
424
425 if ( status_spw == RTEMS_SUCCESSFUL)
425 if ( status_spw == RTEMS_SUCCESSFUL)
426 {
426 {
427 break;
427 break;
428 }
428 }
429 }
429 }
430
430
431 return status_spw;
431 return status_spw;
432 }
432 }
433
433
434 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
434 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
435 {
435 {
436 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
436 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
437 *
437 *
438 * @param val is the value, 0 or 1, used to set the value of the NP bit.
438 * @param val is the value, 0 or 1, used to set the value of the NP bit.
439 * @param regAddr is the address of the GRSPW control register.
439 * @param regAddr is the address of the GRSPW control register.
440 *
440 *
441 * NP is the bit 20 of the GRSPW control register.
441 * NP is the bit 20 of the GRSPW control register.
442 *
442 *
443 */
443 */
444
444
445 unsigned int *spwptr = (unsigned int*) regAddr;
445 unsigned int *spwptr = (unsigned int*) regAddr;
446
446
447 if (val == 1) {
447 if (val == 1) {
448 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
448 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
449 }
449 }
450 if (val== 0) {
450 if (val== 0) {
451 *spwptr = *spwptr & 0xffdfffff;
451 *spwptr = *spwptr & 0xffdfffff;
452 }
452 }
453 }
453 }
454
454
455 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
455 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
456 {
456 {
457 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
457 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
458 *
458 *
459 * @param val is the value, 0 or 1, used to set the value of the RE bit.
459 * @param val is the value, 0 or 1, used to set the value of the RE bit.
460 * @param regAddr is the address of the GRSPW control register.
460 * @param regAddr is the address of the GRSPW control register.
461 *
461 *
462 * RE is the bit 16 of the GRSPW control register.
462 * RE is the bit 16 of the GRSPW control register.
463 *
463 *
464 */
464 */
465
465
466 unsigned int *spwptr = (unsigned int*) regAddr;
466 unsigned int *spwptr = (unsigned int*) regAddr;
467
467
468 if (val == 1)
468 if (val == 1)
469 {
469 {
470 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
470 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
471 }
471 }
472 if (val== 0)
472 if (val== 0)
473 {
473 {
474 *spwptr = *spwptr & 0xfffdffff;
474 *spwptr = *spwptr & 0xfffdffff;
475 }
475 }
476 }
476 }
477
477
478 void spacewire_compute_stats_offsets( void )
478 void spacewire_compute_stats_offsets( void )
479 {
479 {
480 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
480 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
481 *
481 *
482 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
482 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
483 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
483 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
484 * during the open systel call).
484 * during the open systel call).
485 *
485 *
486 */
486 */
487
487
488 spw_stats spacewire_stats_grspw;
488 spw_stats spacewire_stats_grspw;
489 rtems_status_code status;
489 rtems_status_code status;
490
490
491 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
491 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
492
492
493 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
493 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
494 + spacewire_stats.packets_received;
494 + spacewire_stats.packets_received;
495 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
495 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
496 + spacewire_stats.packets_sent;
496 + spacewire_stats.packets_sent;
497 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
497 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
498 + spacewire_stats.parity_err;
498 + spacewire_stats.parity_err;
499 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
499 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
500 + spacewire_stats.disconnect_err;
500 + spacewire_stats.disconnect_err;
501 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
501 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
502 + spacewire_stats.escape_err;
502 + spacewire_stats.escape_err;
503 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
503 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
504 + spacewire_stats.credit_err;
504 + spacewire_stats.credit_err;
505 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
505 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
506 + spacewire_stats.write_sync_err;
506 + spacewire_stats.write_sync_err;
507 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
507 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
508 + spacewire_stats.rx_rmap_header_crc_err;
508 + spacewire_stats.rx_rmap_header_crc_err;
509 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
509 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
510 + spacewire_stats.rx_rmap_data_crc_err;
510 + spacewire_stats.rx_rmap_data_crc_err;
511 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
511 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
512 + spacewire_stats.early_ep;
512 + spacewire_stats.early_ep;
513 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
513 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
514 + spacewire_stats.invalid_address;
514 + spacewire_stats.invalid_address;
515 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
515 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
516 + spacewire_stats.rx_eep_err;
516 + spacewire_stats.rx_eep_err;
517 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
517 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
518 + spacewire_stats.rx_truncated;
518 + spacewire_stats.rx_truncated;
519 }
519 }
520
520
521 void spacewire_update_statistics( void )
521 void spacewire_update_statistics( void )
522 {
522 {
523 rtems_status_code status;
523 rtems_status_code status;
524 spw_stats spacewire_stats_grspw;
524 spw_stats spacewire_stats_grspw;
525
525
526 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
526 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
527
527
528 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
528 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
529 + spacewire_stats_grspw.packets_received;
529 + spacewire_stats_grspw.packets_received;
530 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
530 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
531 + spacewire_stats_grspw.packets_sent;
531 + spacewire_stats_grspw.packets_sent;
532 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
532 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
533 + spacewire_stats_grspw.parity_err;
533 + spacewire_stats_grspw.parity_err;
534 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
534 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
535 + spacewire_stats_grspw.disconnect_err;
535 + spacewire_stats_grspw.disconnect_err;
536 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
536 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
537 + spacewire_stats_grspw.escape_err;
537 + spacewire_stats_grspw.escape_err;
538 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
538 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
539 + spacewire_stats_grspw.credit_err;
539 + spacewire_stats_grspw.credit_err;
540 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
540 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
541 + spacewire_stats_grspw.write_sync_err;
541 + spacewire_stats_grspw.write_sync_err;
542 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
542 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
543 + spacewire_stats_grspw.rx_rmap_header_crc_err;
543 + spacewire_stats_grspw.rx_rmap_header_crc_err;
544 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
544 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
545 + spacewire_stats_grspw.rx_rmap_data_crc_err;
545 + spacewire_stats_grspw.rx_rmap_data_crc_err;
546 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
546 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
547 + spacewire_stats_grspw.early_ep;
547 + spacewire_stats_grspw.early_ep;
548 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
548 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
549 + spacewire_stats_grspw.invalid_address;
549 + spacewire_stats_grspw.invalid_address;
550 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
550 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
551 + spacewire_stats_grspw.rx_eep_err;
551 + spacewire_stats_grspw.rx_eep_err;
552 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
552 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
553 + spacewire_stats_grspw.rx_truncated;
553 + spacewire_stats_grspw.rx_truncated;
554 //spacewire_stats.tx_link_err;
554 //spacewire_stats.tx_link_err;
555
555
556 //****************************
556 //****************************
557 // DPU_SPACEWIRE_IF_STATISTICS
557 // DPU_SPACEWIRE_IF_STATISTICS
558 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
558 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
559 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
559 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
560 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
560 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
561 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
561 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
562 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
562 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
563 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
563 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
564
564
565 //******************************************
565 //******************************************
566 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
566 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
567 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
567 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
568 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
568 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
569 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
569 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
570 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
570 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
571 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
571 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
572
572
573 //*********************************************
573 //*********************************************
574 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
574 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
575 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
575 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
576 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
576 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
577 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
577 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
578 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
578 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
579 }
579 }
580
580
581 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
581 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
582 {
582 {
583 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 );
583 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 );
584 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
584 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
585
585
586 grgpio_regs->io_port_direction_register =
586 grgpio_regs->io_port_direction_register =
587 grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled
587 grgpio_regs->io_port_direction_register | 0x08; // [0001 1000], 0 = output disabled, 1 = output enabled
588
588
589 if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 )
589 if ( (grgpio_regs->io_port_output_register & 0x08) == 0x08 )
590 {
590 {
591 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7;
591 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xf7;
592 }
592 }
593 else
593 else
594 {
594 {
595 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08;
595 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x08;
596 }
596 }
597 }
597 }
598
598
599 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
599 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
600 {
600 {
601 int linkStatus;
601 int linkStatus;
602 rtems_status_code status;
602 rtems_status_code status;
603
603
604 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
604 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
605
605
606 if ( linkStatus == 5) {
606 if ( linkStatus == 5) {
607 PRINTF("in spacewire_reset_link *** link is running\n")
607 PRINTF("in spacewire_reset_link *** link is running\n")
608 status = RTEMS_SUCCESSFUL;
608 status = RTEMS_SUCCESSFUL;
609 }
609 }
610 }
610 }
@@ -1,886 +1,888
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14
14
15 //***********
15 //***********
16 // RTEMS TASK
16 // RTEMS TASK
17
17
18 rtems_task actn_task( rtems_task_argument unused )
18 rtems_task actn_task( rtems_task_argument unused )
19 {
19 {
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 *
21 *
22 * @param unused is the starting argument of the RTEMS task
22 * @param unused is the starting argument of the RTEMS task
23 *
23 *
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * on the incoming TeleCommand.
25 * on the incoming TeleCommand.
26 *
26 *
27 */
27 */
28
28
29 int result;
29 int result;
30 rtems_status_code status; // RTEMS status code
30 rtems_status_code status; // RTEMS status code
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 size_t size; // size of the incoming TC packet
32 size_t size; // size of the incoming TC packet
33 unsigned char subtype; // subtype of the current TC packet
33 unsigned char subtype; // subtype of the current TC packet
34 unsigned char time[6];
34 unsigned char time[6];
35 rtems_id queue_rcv_id;
35 rtems_id queue_rcv_id;
36 rtems_id queue_snd_id;
36 rtems_id queue_snd_id;
37
37
38 status = get_message_queue_id_recv( &queue_rcv_id );
38 status = get_message_queue_id_recv( &queue_rcv_id );
39 if (status != RTEMS_SUCCESSFUL)
39 if (status != RTEMS_SUCCESSFUL)
40 {
40 {
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 }
42 }
43
43
44 status = get_message_queue_id_send( &queue_snd_id );
44 status = get_message_queue_id_send( &queue_snd_id );
45 if (status != RTEMS_SUCCESSFUL)
45 if (status != RTEMS_SUCCESSFUL)
46 {
46 {
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 }
48 }
49
49
50 result = LFR_SUCCESSFUL;
50 result = LFR_SUCCESSFUL;
51 subtype = 0; // subtype of the current TC packet
51 subtype = 0; // subtype of the current TC packet
52
52
53 BOOT_PRINTF("in ACTN *** \n")
53 BOOT_PRINTF("in ACTN *** \n")
54
54
55 while(1)
55 while(1)
56 {
56 {
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 getTime( time ); // set time to the current time
59 getTime( time ); // set time to the current time
60 if (status!=RTEMS_SUCCESSFUL)
60 if (status!=RTEMS_SUCCESSFUL)
61 {
61 {
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 }
63 }
64 else
64 else
65 {
65 {
66 subtype = TC.serviceSubType;
66 subtype = TC.serviceSubType;
67 switch(subtype)
67 switch(subtype)
68 {
68 {
69 case TC_SUBTYPE_RESET:
69 case TC_SUBTYPE_RESET:
70 result = action_reset( &TC, queue_snd_id, time );
70 result = action_reset( &TC, queue_snd_id, time );
71 close_action( &TC, result, queue_snd_id );
71 close_action( &TC, result, queue_snd_id );
72 break;
72 break;
73 //
73 //
74 case TC_SUBTYPE_LOAD_COMM:
74 case TC_SUBTYPE_LOAD_COMM:
75 result = action_load_common_par( &TC );
75 result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 //
78 //
79 case TC_SUBTYPE_LOAD_NORM:
79 case TC_SUBTYPE_LOAD_NORM:
80 result = action_load_normal_par( &TC, queue_snd_id, time );
80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 close_action( &TC, result, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
82 break;
82 break;
83 //
83 //
84 case TC_SUBTYPE_LOAD_BURST:
84 case TC_SUBTYPE_LOAD_BURST:
85 result = action_load_burst_par( &TC, queue_snd_id, time );
85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 close_action( &TC, result, queue_snd_id );
86 close_action( &TC, result, queue_snd_id );
87 break;
87 break;
88 //
88 //
89 case TC_SUBTYPE_LOAD_SBM1:
89 case TC_SUBTYPE_LOAD_SBM1:
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 close_action( &TC, result, queue_snd_id );
91 close_action( &TC, result, queue_snd_id );
92 break;
92 break;
93 //
93 //
94 case TC_SUBTYPE_LOAD_SBM2:
94 case TC_SUBTYPE_LOAD_SBM2:
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 //
98 //
99 case TC_SUBTYPE_DUMP:
99 case TC_SUBTYPE_DUMP:
100 result = action_dump_par( queue_snd_id );
100 result = action_dump_par( queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
102 break;
103 //
103 //
104 case TC_SUBTYPE_ENTER:
104 case TC_SUBTYPE_ENTER:
105 result = action_enter_mode( &TC, queue_snd_id );
105 result = action_enter_mode( &TC, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
107 break;
107 break;
108 //
108 //
109 case TC_SUBTYPE_UPDT_INFO:
109 case TC_SUBTYPE_UPDT_INFO:
110 result = action_update_info( &TC, queue_snd_id );
110 result = action_update_info( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 break;
112 break;
113 //
113 //
114 case TC_SUBTYPE_EN_CAL:
114 case TC_SUBTYPE_EN_CAL:
115 result = action_enable_calibration( &TC, queue_snd_id, time );
115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 //
118 //
119 case TC_SUBTYPE_DIS_CAL:
119 case TC_SUBTYPE_DIS_CAL:
120 result = action_disable_calibration( &TC, queue_snd_id, time );
120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
121 close_action( &TC, result, queue_snd_id );
122 break;
122 break;
123 //
123 //
124 case TC_SUBTYPE_UPDT_TIME:
124 case TC_SUBTYPE_UPDT_TIME:
125 result = action_update_time( &TC );
125 result = action_update_time( &TC );
126 close_action( &TC, result, queue_snd_id );
126 close_action( &TC, result, queue_snd_id );
127 break;
127 break;
128 //
128 //
129 default:
129 default:
130 break;
130 break;
131 }
131 }
132 }
132 }
133 }
133 }
134 }
134 }
135
135
136 //***********
136 //***********
137 // TC ACTIONS
137 // TC ACTIONS
138
138
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 {
140 {
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 *
142 *
143 * @param TC points to the TeleCommand packet that is being processed
143 * @param TC points to the TeleCommand packet that is being processed
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 *
145 *
146 */
146 */
147
147
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 return LFR_DEFAULT;
149 return LFR_DEFAULT;
150 }
150 }
151
151
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
153 {
153 {
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 *
155 *
156 * @param TC points to the TeleCommand packet that is being processed
156 * @param TC points to the TeleCommand packet that is being processed
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 *
158 *
159 */
159 */
160
160
161 rtems_status_code status;
161 rtems_status_code status;
162 unsigned char requestedMode;
162 unsigned char requestedMode;
163 unsigned int *transitionCoarseTime_ptr;
163 unsigned int *transitionCoarseTime_ptr;
164 unsigned int transitionCoarseTime;
164 unsigned int transitionCoarseTime;
165 unsigned char * bytePosPtr;
165 unsigned char * bytePosPtr;
166
166
167 bytePosPtr = (unsigned char *) &TC->packetID;
167 bytePosPtr = (unsigned char *) &TC->packetID;
168
168
169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
172
172
173 status = check_mode_value( requestedMode );
173 status = check_mode_value( requestedMode );
174
174
175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
176 {
176 {
177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
178 }
178 }
179 else // the mode value is consistent, check the transition
179 else // the mode value is consistent, check the transition
180 {
180 {
181 status = check_mode_transition(requestedMode);
181 status = check_mode_transition(requestedMode);
182 if (status != LFR_SUCCESSFUL)
182 if (status != LFR_SUCCESSFUL)
183 {
183 {
184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
184 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
185 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
186 }
186 }
187 }
187 }
188
188
189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
189 if ( status == LFR_SUCCESSFUL ) // the transition is valid, enter the mode
190 {
190 {
191 status = check_transition_date( transitionCoarseTime );
191 status = check_transition_date( transitionCoarseTime );
192 if (status != LFR_SUCCESSFUL)
192 if (status != LFR_SUCCESSFUL)
193 {
193 {
194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
198 }
198 }
199 }
199 }
200
200
201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
201 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
202 {
202 {
203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
203 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
204 status = enter_mode( requestedMode, transitionCoarseTime );
204 status = enter_mode( requestedMode, transitionCoarseTime );
205 }
205 }
206
206
207 return status;
207 return status;
208 }
208 }
209
209
210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
210 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
211 {
211 {
212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
212 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
213 *
213 *
214 * @param TC points to the TeleCommand packet that is being processed
214 * @param TC points to the TeleCommand packet that is being processed
215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
215 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
216 *
216 *
217 * @return LFR directive status code:
217 * @return LFR directive status code:
218 * - LFR_DEFAULT
218 * - LFR_DEFAULT
219 * - LFR_SUCCESSFUL
219 * - LFR_SUCCESSFUL
220 *
220 *
221 */
221 */
222
222
223 unsigned int val;
223 unsigned int val;
224 int result;
224 int result;
225 unsigned int status;
225 unsigned int status;
226 unsigned char mode;
226 unsigned char mode;
227 unsigned char * bytePosPtr;
227 unsigned char * bytePosPtr;
228
228
229 bytePosPtr = (unsigned char *) &TC->packetID;
229 bytePosPtr = (unsigned char *) &TC->packetID;
230
230
231 // check LFR mode
231 // check LFR mode
232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
233 status = check_update_info_hk_lfr_mode( mode );
233 status = check_update_info_hk_lfr_mode( mode );
234 if (status == LFR_SUCCESSFUL) // check TDS mode
234 if (status == LFR_SUCCESSFUL) // check TDS mode
235 {
235 {
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
237 status = check_update_info_hk_tds_mode( mode );
237 status = check_update_info_hk_tds_mode( mode );
238 }
238 }
239 if (status == LFR_SUCCESSFUL) // check THR mode
239 if (status == LFR_SUCCESSFUL) // check THR mode
240 {
240 {
241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
242 status = check_update_info_hk_thr_mode( mode );
242 status = check_update_info_hk_thr_mode( mode );
243 }
243 }
244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
245 {
245 {
246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
246 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
247 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
248 val++;
248 val++;
249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
249 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
250 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
251 }
251 }
252
252
253 result = status;
253 result = status;
254
254
255 return result;
255 return result;
256 }
256 }
257
257
258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
258 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
259 {
259 {
260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
260 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
261 *
261 *
262 * @param TC points to the TeleCommand packet that is being processed
262 * @param TC points to the TeleCommand packet that is being processed
263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
263 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
264 *
264 *
265 */
265 */
266
266
267 int result;
267 int result;
268 unsigned char lfrMode;
268 unsigned char lfrMode;
269
269
270 result = LFR_DEFAULT;
270 result = LFR_DEFAULT;
271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
271 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
272
272
273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
273 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
274 result = LFR_DEFAULT;
274 result = LFR_DEFAULT;
275
275
276 return result;
276 return result;
277 }
277 }
278
278
279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
279 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
280 {
280 {
281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
281 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
282 *
282 *
283 * @param TC points to the TeleCommand packet that is being processed
283 * @param TC points to the TeleCommand packet that is being processed
284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
284 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
285 *
285 *
286 */
286 */
287
287
288 int result;
288 int result;
289 unsigned char lfrMode;
289 unsigned char lfrMode;
290
290
291 result = LFR_DEFAULT;
291 result = LFR_DEFAULT;
292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
292 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
293
293
294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
294 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
295 result = LFR_DEFAULT;
295 result = LFR_DEFAULT;
296
296
297 return result;
297 return result;
298 }
298 }
299
299
300 int action_update_time(ccsdsTelecommandPacket_t *TC)
300 int action_update_time(ccsdsTelecommandPacket_t *TC)
301 {
301 {
302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
302 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
303 *
303 *
304 * @param TC points to the TeleCommand packet that is being processed
304 * @param TC points to the TeleCommand packet that is being processed
305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
305 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
306 *
306 *
307 * @return LFR_SUCCESSFUL
307 * @return LFR_SUCCESSFUL
308 *
308 *
309 */
309 */
310
310
311 unsigned int val;
311 unsigned int val;
312
312
313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
313 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
314 + (TC->dataAndCRC[1] << 16)
314 + (TC->dataAndCRC[1] << 16)
315 + (TC->dataAndCRC[2] << 8)
315 + (TC->dataAndCRC[2] << 8)
316 + TC->dataAndCRC[3];
316 + TC->dataAndCRC[3];
317
317
318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
318 PRINTF1("time received: %x\n", time_management_regs->coarse_time_load)
319
319
320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
320 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
321 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
322 val++;
322 val++;
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
323 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
324 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
325 // time_management_regs->ctrl = time_management_regs->ctrl | 1; // force tick
326
326
327 return LFR_SUCCESSFUL;
327 return LFR_SUCCESSFUL;
328 }
328 }
329
329
330 //*******************
330 //*******************
331 // ENTERING THE MODES
331 // ENTERING THE MODES
332 int check_mode_value( unsigned char requestedMode )
332 int check_mode_value( unsigned char requestedMode )
333 {
333 {
334 int status;
334 int status;
335
335
336 if ( (requestedMode != LFR_MODE_STANDBY)
336 if ( (requestedMode != LFR_MODE_STANDBY)
337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
337 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
338 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
339 {
339 {
340 status = LFR_DEFAULT;
340 status = LFR_DEFAULT;
341 }
341 }
342 else
342 else
343 {
343 {
344 status = LFR_SUCCESSFUL;
344 status = LFR_SUCCESSFUL;
345 }
345 }
346
346
347 return status;
347 return status;
348 }
348 }
349
349
350 int check_mode_transition( unsigned char requestedMode )
350 int check_mode_transition( unsigned char requestedMode )
351 {
351 {
352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
352 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
353 *
353 *
354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
354 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
355 *
355 *
356 * @return LFR directive status codes:
356 * @return LFR directive status codes:
357 * - LFR_SUCCESSFUL - the transition is authorized
357 * - LFR_SUCCESSFUL - the transition is authorized
358 * - LFR_DEFAULT - the transition is not authorized
358 * - LFR_DEFAULT - the transition is not authorized
359 *
359 *
360 */
360 */
361
361
362 int status;
362 int status;
363
363
364 switch (requestedMode)
364 switch (requestedMode)
365 {
365 {
366 case LFR_MODE_STANDBY:
366 case LFR_MODE_STANDBY:
367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
367 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
368 status = LFR_DEFAULT;
368 status = LFR_DEFAULT;
369 }
369 }
370 else
370 else
371 {
371 {
372 status = LFR_SUCCESSFUL;
372 status = LFR_SUCCESSFUL;
373 }
373 }
374 break;
374 break;
375 case LFR_MODE_NORMAL:
375 case LFR_MODE_NORMAL:
376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
376 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
377 status = LFR_DEFAULT;
377 status = LFR_DEFAULT;
378 }
378 }
379 else {
379 else {
380 status = LFR_SUCCESSFUL;
380 status = LFR_SUCCESSFUL;
381 }
381 }
382 break;
382 break;
383 case LFR_MODE_BURST:
383 case LFR_MODE_BURST:
384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
384 if ( lfrCurrentMode == LFR_MODE_BURST ) {
385 status = LFR_DEFAULT;
385 status = LFR_DEFAULT;
386 }
386 }
387 else {
387 else {
388 status = LFR_SUCCESSFUL;
388 status = LFR_SUCCESSFUL;
389 }
389 }
390 break;
390 break;
391 case LFR_MODE_SBM1:
391 case LFR_MODE_SBM1:
392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
392 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
393 status = LFR_DEFAULT;
393 status = LFR_DEFAULT;
394 }
394 }
395 else {
395 else {
396 status = LFR_SUCCESSFUL;
396 status = LFR_SUCCESSFUL;
397 }
397 }
398 break;
398 break;
399 case LFR_MODE_SBM2:
399 case LFR_MODE_SBM2:
400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
400 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
401 status = LFR_DEFAULT;
401 status = LFR_DEFAULT;
402 }
402 }
403 else {
403 else {
404 status = LFR_SUCCESSFUL;
404 status = LFR_SUCCESSFUL;
405 }
405 }
406 break;
406 break;
407 default:
407 default:
408 status = LFR_DEFAULT;
408 status = LFR_DEFAULT;
409 break;
409 break;
410 }
410 }
411
411
412 return status;
412 return status;
413 }
413 }
414
414
415 int check_transition_date( unsigned int transitionCoarseTime )
415 int check_transition_date( unsigned int transitionCoarseTime )
416 {
416 {
417 int status;
417 int status;
418 unsigned int localCoarseTime;
418 unsigned int localCoarseTime;
419 unsigned int deltaCoarseTime;
419 unsigned int deltaCoarseTime;
420
420
421 status = LFR_SUCCESSFUL;
421 status = LFR_SUCCESSFUL;
422
422
423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
423 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
424 {
424 {
425 status = LFR_SUCCESSFUL;
425 status = LFR_SUCCESSFUL;
426 }
426 }
427 else
427 else
428 {
428 {
429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
430
430
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
432 {
432 {
433 status = LFR_DEFAULT;
433 status = LFR_DEFAULT;
434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
435 }
435 }
436
436
437 if (status == LFR_SUCCESSFUL)
437 if (status == LFR_SUCCESSFUL)
438 {
438 {
439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
439 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
440 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
441 {
441 {
442 status = LFR_DEFAULT;
442 status = LFR_DEFAULT;
443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
443 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
444 }
444 }
445 }
445 }
446 }
446 }
447
447
448 return status;
448 return status;
449 }
449 }
450
450
451 int stop_current_mode( void )
451 int stop_current_mode( void )
452 {
452 {
453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
453 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
454 *
454 *
455 * @return RTEMS directive status codes:
455 * @return RTEMS directive status codes:
456 * - RTEMS_SUCCESSFUL - task restarted successfully
456 * - RTEMS_SUCCESSFUL - task restarted successfully
457 * - RTEMS_INVALID_ID - task id invalid
457 * - RTEMS_INVALID_ID - task id invalid
458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
458 * - RTEMS_ALREADY_SUSPENDED - task already suspended
459 *
459 *
460 */
460 */
461
461
462 rtems_status_code status;
462 rtems_status_code status;
463
463
464 status = RTEMS_SUCCESSFUL;
464 status = RTEMS_SUCCESSFUL;
465
465
466 // (1) mask interruptions
466 // (1) mask interruptions
467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
467 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
468 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
469
469
470 // (2) clear interruptions
470 // (2) clear interruptions
471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
471 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
472 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
473
473
474 // (3) reset waveform picker registers
474 // (3) reset waveform picker registers
475 reset_wfp_burst_enable(); // reset burst and enable bits
475 reset_wfp_burst_enable(); // reset burst and enable bits
476 reset_wfp_status(); // reset all the status bits
476 reset_wfp_status(); // reset all the status bits
477
477
478 // (4) reset spectral matrices registers
478 // (4) reset spectral matrices registers
479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
479 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
480 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
481 reset_extractSWF(); // reset the extractSWF flag to false
481 reset_extractSWF(); // reset the extractSWF flag to false
482
482
483 // <Spectral Matrices simulator>
483 // <Spectral Matrices simulator>
484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
484 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
485 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
486 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
487 // </Spectral Matrices simulator>
487 // </Spectral Matrices simulator>
488
488
489 // suspend several tasks
489 // suspend several tasks
490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
490 if (lfrCurrentMode != LFR_MODE_STANDBY) {
491 status = suspend_science_tasks();
491 status = suspend_science_tasks();
492 }
492 }
493
493
494 if (status != RTEMS_SUCCESSFUL)
494 if (status != RTEMS_SUCCESSFUL)
495 {
495 {
496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
496 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
497 }
497 }
498
498
499 return status;
499 return status;
500 }
500 }
501
501
502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
502 int enter_mode( unsigned char mode, unsigned int transitionCoarseTime )
503 {
503 {
504 /** This function is launched after a mode transition validation.
504 /** This function is launched after a mode transition validation.
505 *
505 *
506 * @param mode is the mode in which LFR will be put.
506 * @param mode is the mode in which LFR will be put.
507 *
507 *
508 * @return RTEMS directive status codes:
508 * @return RTEMS directive status codes:
509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
509 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
510 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
511 *
511 *
512 */
512 */
513
513
514 rtems_status_code status;
514 rtems_status_code status;
515
515
516 //**********************
516 //**********************
517 // STOP THE CURRENT MODE
517 // STOP THE CURRENT MODE
518 status = stop_current_mode();
518 status = stop_current_mode();
519 if (status != RTEMS_SUCCESSFUL)
519 if (status != RTEMS_SUCCESSFUL)
520 {
520 {
521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
521 PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode)
522 }
522 }
523
523
524 //*************************
524 //*************************
525 // ENTER THE REQUESTED MODE
525 // ENTER THE REQUESTED MODE
526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
526 if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST)
527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
527 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) )
528 {
528 {
529 #ifdef PRINT_TASK_STATISTICS
529 #ifdef PRINT_TASK_STATISTICS
530 rtems_cpu_usage_reset();
530 rtems_cpu_usage_reset();
531 maxCount = 0;
531 maxCount = 0;
532 #endif
532 #endif
533 status = restart_science_tasks( mode );
533 status = restart_science_tasks( mode );
534 launch_waveform_picker( mode, transitionCoarseTime );
534 launch_waveform_picker( mode, transitionCoarseTime );
535 launch_spectral_matrix_simu( mode );
535 // launch_spectral_matrix( );
536 // launch_spectral_matrix_simu( );
536 }
537 }
537 else if ( mode == LFR_MODE_STANDBY )
538 else if ( mode == LFR_MODE_STANDBY )
538 {
539 {
539 #ifdef PRINT_TASK_STATISTICS
540 #ifdef PRINT_TASK_STATISTICS
540 rtems_cpu_usage_report();
541 rtems_cpu_usage_report();
541 #endif
542 #endif
542
543
543 #ifdef PRINT_STACK_REPORT
544 #ifdef PRINT_STACK_REPORT
545 PRINTF("stack report selected\n")
544 rtems_stack_checker_report_usage();
546 rtems_stack_checker_report_usage();
545 #endif
547 #endif
546 PRINTF1("maxCount = %d\n", maxCount)
548 PRINTF1("maxCount = %d\n", maxCount)
547 }
549 }
548 else
550 else
549 {
551 {
550 status = RTEMS_UNSATISFIED;
552 status = RTEMS_UNSATISFIED;
551 }
553 }
552
554
553 if (status != RTEMS_SUCCESSFUL)
555 if (status != RTEMS_SUCCESSFUL)
554 {
556 {
555 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
557 PRINTF1("ERR *** in enter_mode *** status = %d\n", status)
556 status = RTEMS_UNSATISFIED;
558 status = RTEMS_UNSATISFIED;
557 }
559 }
558
560
559 return status;
561 return status;
560 }
562 }
561
563
562 int restart_science_tasks(unsigned char lfrRequestedMode )
564 int restart_science_tasks(unsigned char lfrRequestedMode )
563 {
565 {
564 /** This function is used to restart all science tasks.
566 /** This function is used to restart all science tasks.
565 *
567 *
566 * @return RTEMS directive status codes:
568 * @return RTEMS directive status codes:
567 * - RTEMS_SUCCESSFUL - task restarted successfully
569 * - RTEMS_SUCCESSFUL - task restarted successfully
568 * - RTEMS_INVALID_ID - task id invalid
570 * - RTEMS_INVALID_ID - task id invalid
569 * - RTEMS_INCORRECT_STATE - task never started
571 * - RTEMS_INCORRECT_STATE - task never started
570 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
572 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
571 *
573 *
572 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
574 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
573 *
575 *
574 */
576 */
575
577
576 rtems_status_code status[7];
578 rtems_status_code status[7];
577 rtems_status_code ret;
579 rtems_status_code ret;
578
580
579 ret = RTEMS_SUCCESSFUL;
581 ret = RTEMS_SUCCESSFUL;
580
582
581 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
583 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
582 if (status[0] != RTEMS_SUCCESSFUL)
584 if (status[0] != RTEMS_SUCCESSFUL)
583 {
585 {
584 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
586 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
585 }
587 }
586
588
587 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
589 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
588 if (status[2] != RTEMS_SUCCESSFUL)
590 if (status[2] != RTEMS_SUCCESSFUL)
589 {
591 {
590 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
592 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
591 }
593 }
592
594
593 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
595 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
594 if (status[3] != RTEMS_SUCCESSFUL)
596 if (status[3] != RTEMS_SUCCESSFUL)
595 {
597 {
596 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
598 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
597 }
599 }
598
600
599 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
601 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
600 if (status[4] != RTEMS_SUCCESSFUL)
602 if (status[4] != RTEMS_SUCCESSFUL)
601 {
603 {
602 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
604 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
603 }
605 }
604
606
605 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
607 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
606 if (status[5] != RTEMS_SUCCESSFUL)
608 if (status[5] != RTEMS_SUCCESSFUL)
607 {
609 {
608 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
610 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
609 }
611 }
610
612
611 status[6] = rtems_task_restart( Task_id[TASKID_MATR], lfrRequestedMode );
613 status[6] = rtems_task_restart( Task_id[TASKID_MATR], lfrRequestedMode );
612 if (status[6] != RTEMS_SUCCESSFUL)
614 if (status[6] != RTEMS_SUCCESSFUL)
613 {
615 {
614 PRINTF1("in restart_science_task *** 6 ERR %d\n", status[6])
616 PRINTF1("in restart_science_task *** 6 ERR %d\n", status[6])
615 }
617 }
616
618
617 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
619 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
618 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) ||
620 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) ||
619 (status[5] != RTEMS_SUCCESSFUL) || (status[6] != RTEMS_SUCCESSFUL) )
621 (status[5] != RTEMS_SUCCESSFUL) || (status[6] != RTEMS_SUCCESSFUL) )
620 {
622 {
621 ret = RTEMS_UNSATISFIED;
623 ret = RTEMS_UNSATISFIED;
622 }
624 }
623
625
624 return ret;
626 return ret;
625 }
627 }
626
628
627 int suspend_science_tasks()
629 int suspend_science_tasks()
628 {
630 {
629 /** This function suspends the science tasks.
631 /** This function suspends the science tasks.
630 *
632 *
631 * @return RTEMS directive status codes:
633 * @return RTEMS directive status codes:
632 * - RTEMS_SUCCESSFUL - task restarted successfully
634 * - RTEMS_SUCCESSFUL - task restarted successfully
633 * - RTEMS_INVALID_ID - task id invalid
635 * - RTEMS_INVALID_ID - task id invalid
634 * - RTEMS_ALREADY_SUSPENDED - task already suspended
636 * - RTEMS_ALREADY_SUSPENDED - task already suspended
635 *
637 *
636 */
638 */
637
639
638 rtems_status_code status;
640 rtems_status_code status;
639
641
640 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
642 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
641 if (status != RTEMS_SUCCESSFUL)
643 if (status != RTEMS_SUCCESSFUL)
642 {
644 {
643 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
645 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
644 }
646 }
645
647
646 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
648 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
647 {
649 {
648 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
650 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
649 if (status != RTEMS_SUCCESSFUL)
651 if (status != RTEMS_SUCCESSFUL)
650 {
652 {
651 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
653 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
652 }
654 }
653 }
655 }
654
656
655 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
657 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
656 {
658 {
657 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
659 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
658 if (status != RTEMS_SUCCESSFUL)
660 if (status != RTEMS_SUCCESSFUL)
659 {
661 {
660 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
662 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
661 }
663 }
662 }
664 }
663
665
664 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
666 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
665 {
667 {
666 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
668 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
667 if (status != RTEMS_SUCCESSFUL)
669 if (status != RTEMS_SUCCESSFUL)
668 {
670 {
669 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
671 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
670 }
672 }
671 }
673 }
672
674
673 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
675 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
674 {
676 {
675 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
677 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
676 if (status != RTEMS_SUCCESSFUL)
678 if (status != RTEMS_SUCCESSFUL)
677 {
679 {
678 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
680 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
679 }
681 }
680 }
682 }
681
683
682 return status;
684 return status;
683 }
685 }
684
686
685 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
687 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
686 {
688 {
687 reset_current_ring_nodes();
689 reset_current_ring_nodes();
688 reset_waveform_picker_regs();
690 reset_waveform_picker_regs();
689 set_wfp_burst_enable_register( mode );
691 set_wfp_burst_enable_register( mode );
690
692
691 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
693 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
692 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
694 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
693
695
694 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
696 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
695 if (transitionCoarseTime == 0)
697 if (transitionCoarseTime == 0)
696 {
698 {
697 waveform_picker_regs->start_date = time_management_regs->coarse_time;
699 waveform_picker_regs->start_date = time_management_regs->coarse_time;
698 }
700 }
699 else
701 else
700 {
702 {
701 waveform_picker_regs->start_date = transitionCoarseTime;
703 waveform_picker_regs->start_date = transitionCoarseTime;
702 }
704 }
703 }
705 }
704
706
705 void launch_spectral_matrix( unsigned char mode )
707 void launch_spectral_matrix( void )
706 {
708 {
707 SM_reset_current_ring_nodes();
709 SM_reset_current_ring_nodes();
708 ASM_reset_current_ring_node();
710 ASM_reset_current_ring_node();
709 reset_spectral_matrix_regs();
711 reset_spectral_matrix_regs();
710
712
711 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
713 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
712 grgpio_regs->io_port_direction_register =
714 grgpio_regs->io_port_direction_register =
713 grgpio_regs->io_port_direction_register | 0x01; // [0001 1000], 0 = output disabled, 1 = output enabled
715 grgpio_regs->io_port_direction_register | 0x01; // [0000 0001], 0 = output disabled, 1 = output enabled
714 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x00; // set the bit 0 to 1
716 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfffffffe; // set the bit 0 to 0
715 set_irq_on_new_ready_matrix( 1 );
717 set_irq_on_new_ready_matrix( 1 );
716 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
718 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
717 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
719 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
718 set_run_matrix_spectral( 1 );
720 set_run_matrix_spectral( 1 );
719
721
720 }
722 }
721
723
724 void launch_spectral_matrix_simu( void )
725 {
726 SM_reset_current_ring_nodes();
727 ASM_reset_current_ring_node();
728 reset_spectral_matrix_regs();
729
730 // Spectral Matrices simulator
731 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
732 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
733 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
734 set_local_nb_interrupt_f0_MAX();
735 }
736
722 void set_irq_on_new_ready_matrix( unsigned char value )
737 void set_irq_on_new_ready_matrix( unsigned char value )
723 {
738 {
724 if (value == 1)
739 if (value == 1)
725 {
740 {
726 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
741 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
727 }
742 }
728 else
743 else
729 {
744 {
730 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
745 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
731 }
746 }
732 }
747 }
733
748
734 void set_run_matrix_spectral( unsigned char value )
749 void set_run_matrix_spectral( unsigned char value )
735 {
750 {
736 if (value == 1)
751 if (value == 1)
737 {
752 {
738 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
753 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // [0100] set run_matrix spectral to 1
739 }
754 }
740 else
755 else
741 {
756 {
742 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
757 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // [1011] set run_matrix spectral to 0
743 }
758 }
744 }
759 }
745
760
746 void launch_spectral_matrix_simu( unsigned char mode )
747 {
748 SM_reset_current_ring_nodes();
749 ASM_reset_current_ring_node();
750 reset_spectral_matrix_regs();
751
752 // Spectral Matrices simulator
753 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
754 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
755 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
756 set_local_nb_interrupt_f0_MAX();
757 }
758
759 //****************
761 //****************
760 // CLOSING ACTIONS
762 // CLOSING ACTIONS
761 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
763 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
762 {
764 {
763 /** This function is used to update the HK packets statistics after a successful TC execution.
765 /** This function is used to update the HK packets statistics after a successful TC execution.
764 *
766 *
765 * @param TC points to the TC being processed
767 * @param TC points to the TC being processed
766 * @param time is the time used to date the TC execution
768 * @param time is the time used to date the TC execution
767 *
769 *
768 */
770 */
769
771
770 unsigned int val;
772 unsigned int val;
771
773
772 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
774 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
773 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
775 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
774 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
776 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
775 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
777 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
776 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
778 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
777 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
779 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
778 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
780 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
779 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
781 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
780 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
782 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
781 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
783 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
782 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
784 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
783 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
785 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
784
786
785 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
787 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
786 val++;
788 val++;
787 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
789 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
788 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
790 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
789 }
791 }
790
792
791 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
793 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
792 {
794 {
793 /** This function is used to update the HK packets statistics after a TC rejection.
795 /** This function is used to update the HK packets statistics after a TC rejection.
794 *
796 *
795 * @param TC points to the TC being processed
797 * @param TC points to the TC being processed
796 * @param time is the time used to date the TC rejection
798 * @param time is the time used to date the TC rejection
797 *
799 *
798 */
800 */
799
801
800 unsigned int val;
802 unsigned int val;
801
803
802 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
804 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
803 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
805 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
804 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
806 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
805 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
807 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
806 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
808 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
807 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
809 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
808 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
810 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
809 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
811 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
810 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
812 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
811 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
813 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
812 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
814 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
813 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
815 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
814
816
815 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
817 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
816 val++;
818 val++;
817 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
819 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
818 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
820 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
819 }
821 }
820
822
821 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
823 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
822 {
824 {
823 /** This function is the last step of the TC execution workflow.
825 /** This function is the last step of the TC execution workflow.
824 *
826 *
825 * @param TC points to the TC being processed
827 * @param TC points to the TC being processed
826 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
828 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
827 * @param queue_id is the id of the RTEMS message queue used to send TM packets
829 * @param queue_id is the id of the RTEMS message queue used to send TM packets
828 * @param time is the time used to date the TC execution
830 * @param time is the time used to date the TC execution
829 *
831 *
830 */
832 */
831
833
832 unsigned char requestedMode;
834 unsigned char requestedMode;
833
835
834 if (result == LFR_SUCCESSFUL)
836 if (result == LFR_SUCCESSFUL)
835 {
837 {
836 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
838 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
837 &
839 &
838 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
840 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
839 )
841 )
840 {
842 {
841 send_tm_lfr_tc_exe_success( TC, queue_id );
843 send_tm_lfr_tc_exe_success( TC, queue_id );
842 }
844 }
843 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
845 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
844 {
846 {
845 //**********************************
847 //**********************************
846 // UPDATE THE LFRMODE LOCAL VARIABLE
848 // UPDATE THE LFRMODE LOCAL VARIABLE
847 requestedMode = TC->dataAndCRC[1];
849 requestedMode = TC->dataAndCRC[1];
848 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
850 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
849 updateLFRCurrentMode();
851 updateLFRCurrentMode();
850 }
852 }
851 }
853 }
852 else if (result == LFR_EXE_ERROR)
854 else if (result == LFR_EXE_ERROR)
853 {
855 {
854 send_tm_lfr_tc_exe_error( TC, queue_id );
856 send_tm_lfr_tc_exe_error( TC, queue_id );
855 }
857 }
856 }
858 }
857
859
858 //***************************
860 //***************************
859 // Interrupt Service Routines
861 // Interrupt Service Routines
860 rtems_isr commutation_isr1( rtems_vector_number vector )
862 rtems_isr commutation_isr1( rtems_vector_number vector )
861 {
863 {
862 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
864 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
863 printf("In commutation_isr1 *** Error sending event to DUMB\n");
865 printf("In commutation_isr1 *** Error sending event to DUMB\n");
864 }
866 }
865 }
867 }
866
868
867 rtems_isr commutation_isr2( rtems_vector_number vector )
869 rtems_isr commutation_isr2( rtems_vector_number vector )
868 {
870 {
869 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
871 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
870 printf("In commutation_isr2 *** Error sending event to DUMB\n");
872 printf("In commutation_isr2 *** Error sending event to DUMB\n");
871 }
873 }
872 }
874 }
873
875
874 //****************
876 //****************
875 // OTHER FUNCTIONS
877 // OTHER FUNCTIONS
876 void updateLFRCurrentMode()
878 void updateLFRCurrentMode()
877 {
879 {
878 /** This function updates the value of the global variable lfrCurrentMode.
880 /** This function updates the value of the global variable lfrCurrentMode.
879 *
881 *
880 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
882 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
881 *
883 *
882 */
884 */
883 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
885 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
884 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
886 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
885 }
887 }
886
888
@@ -1,759 +1,776
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 float aux;
47 float aux;
47
48
48 flag = LFR_SUCCESSFUL;
49 flag = LFR_SUCCESSFUL;
49
50
50 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
51 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
51 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
52 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
52 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
53 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
53 flag = LFR_DEFAULT;
54 flag = LFR_DEFAULT;
54 }
55 }
55
56
56 //***************
57 //***************
57 // sy_lfr_n_swf_l
58 // sy_lfr_n_swf_l
58 if (flag == LFR_SUCCESSFUL)
59 if (flag == LFR_SUCCESSFUL)
59 {
60 {
60 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
61 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
61 if (result != LFR_SUCCESSFUL)
62 if (result != LFR_SUCCESSFUL)
62 {
63 {
63 flag = LFR_DEFAULT;
64 flag = LFR_DEFAULT;
64 }
65 }
65 }
66 }
66
67
67 //***************
68 //***************
68 // sy_lfr_n_swf_p
69 // sy_lfr_n_swf_p
69 if (flag == LFR_SUCCESSFUL)
70 if (flag == LFR_SUCCESSFUL)
70 {
71 {
71 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
72 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
72 if (result != LFR_SUCCESSFUL)
73 if (result != LFR_SUCCESSFUL)
73 {
74 {
74 flag = LFR_DEFAULT;
75 flag = LFR_DEFAULT;
75 }
76 }
76 }
77 }
77
78
78 //***************
79 // sy_lfr_n_asm_p
80 if (flag == LFR_SUCCESSFUL)
81 {
82 result = set_sy_lfr_n_asm_p( TC, queue_id );
83 if (result != LFR_SUCCESSFUL)
84 {
85 flag = LFR_DEFAULT;
86 }
87 }
88
89 //****************************************************************
79 //****************************************************************
90 // 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
91 if (flag == LFR_SUCCESSFUL)
81 if (flag == LFR_SUCCESSFUL)
92 {
82 {
93 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 ];
94 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 ];
95 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);
96 if (aux != 0)
86 if (aux != 0)
97 {
87 {
98 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 );
99 flag = LFR_DEFAULT;
89 flag = LFR_DEFAULT;
100 }
90 }
101 }
91 }
102
92
103 //***************
93 //***************
104 // sy_lfr_n_bp_p0
94 // sy_lfr_n_bp_p0
105 if (flag == LFR_SUCCESSFUL)
95 if (flag == LFR_SUCCESSFUL)
106 {
96 {
107 result = set_sy_lfr_n_bp_p0( TC, queue_id );
97 result = set_sy_lfr_n_bp_p0( TC, queue_id );
108 if (result != LFR_SUCCESSFUL)
98 if (result != LFR_SUCCESSFUL)
109 {
99 {
110 flag = LFR_DEFAULT;
100 flag = LFR_DEFAULT;
111 }
101 }
112 }
102 }
113
103
114 //***************
104 //***************
115 // sy_lfr_n_bp_p1
105 // sy_lfr_n_bp_p1
116 if (flag == LFR_SUCCESSFUL)
106 if (flag == LFR_SUCCESSFUL)
117 {
107 {
118 result = set_sy_lfr_n_bp_p1( TC, queue_id );
108 result = set_sy_lfr_n_bp_p1( TC, queue_id );
119 if (result != LFR_SUCCESSFUL)
109 if (result != LFR_SUCCESSFUL)
120 {
110 {
121 flag = LFR_DEFAULT;
111 flag = LFR_DEFAULT;
122 }
112 }
123 }
113 }
124
114
115 //****************************************************************
116 // check the consistency between sy_lfr_n_asm_p and sy_lfr_n_bp_p0
117 if (flag == LFR_SUCCESSFUL)
118 {
119 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
120 sy_lfr_n_asm_p =
121 TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ] * 256
122 + TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P + 1 ];
123 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
124 if (aux != 0)
125 {
126 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
127 flag = LFR_DEFAULT;
128 }
129 }
130
131 //***************
132 // sy_lfr_n_asm_p
133 if (flag == LFR_SUCCESSFUL)
134 {
135 result = set_sy_lfr_n_asm_p( TC, queue_id );
136 if (result != LFR_SUCCESSFUL)
137 {
138 flag = LFR_DEFAULT;
139 }
140 }
141
125 //*********************
142 //*********************
126 // sy_lfr_n_cwf_long_f3
143 // sy_lfr_n_cwf_long_f3
127 if (flag == LFR_SUCCESSFUL)
144 if (flag == LFR_SUCCESSFUL)
128 {
145 {
129 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
146 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
130 if (result != LFR_SUCCESSFUL)
147 if (result != LFR_SUCCESSFUL)
131 {
148 {
132 flag = LFR_DEFAULT;
149 flag = LFR_DEFAULT;
133 }
150 }
134 }
151 }
135
152
136 return flag;
153 return flag;
137 }
154 }
138
155
139 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
156 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 {
157 {
141 /** This function updates the LFR registers with the incoming burst parameters.
158 /** This function updates the LFR registers with the incoming burst parameters.
142 *
159 *
143 * @param TC points to the TeleCommand packet that is being processed
160 * @param TC points to the TeleCommand packet that is being processed
144 * @param queue_id is the id of the queue which handles TM related to this execution step
161 * @param queue_id is the id of the queue which handles TM related to this execution step
145 *
162 *
146 */
163 */
147
164
148 int result;
165 int result;
149 int flag;
166 int flag;
150 rtems_status_code status;
167 rtems_status_code status;
151 unsigned char sy_lfr_b_bp_p0;
168 unsigned char sy_lfr_b_bp_p0;
152 unsigned char sy_lfr_b_bp_p1;
169 unsigned char sy_lfr_b_bp_p1;
153 float aux;
170 float aux;
154
171
155 flag = LFR_SUCCESSFUL;
172 flag = LFR_SUCCESSFUL;
156
173
157 if ( lfrCurrentMode == LFR_MODE_BURST ) {
174 if ( lfrCurrentMode == LFR_MODE_BURST ) {
158 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
175 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
159 result = LFR_DEFAULT;
176 result = LFR_DEFAULT;
160 }
177 }
161
178
162 //****************************************************************
179 //****************************************************************
163 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
180 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
164 if (flag == LFR_SUCCESSFUL)
181 if (flag == LFR_SUCCESSFUL)
165 {
182 {
166 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
183 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
167 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
184 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
168 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
185 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
169 if (aux != 0)
186 if (aux != 0)
170 {
187 {
171 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
188 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
172 flag = LFR_DEFAULT;
189 flag = LFR_DEFAULT;
173 }
190 }
174 }
191 }
175
192
176 //***************
193 //***************
177 // sy_lfr_b_bp_p0
194 // sy_lfr_b_bp_p0
178 if (flag == LFR_SUCCESSFUL)
195 if (flag == LFR_SUCCESSFUL)
179 {
196 {
180 result = set_sy_lfr_b_bp_p0( TC, queue_id );
197 result = set_sy_lfr_b_bp_p0( TC, queue_id );
181 if (result != LFR_SUCCESSFUL)
198 if (result != LFR_SUCCESSFUL)
182 {
199 {
183 flag = LFR_DEFAULT;
200 flag = LFR_DEFAULT;
184 }
201 }
185 }
202 }
186
203
187 //***************
204 //***************
188 // sy_lfr_b_bp_p1
205 // sy_lfr_b_bp_p1
189 if (flag == LFR_SUCCESSFUL)
206 if (flag == LFR_SUCCESSFUL)
190 {
207 {
191 result = set_sy_lfr_b_bp_p1( TC, queue_id );
208 result = set_sy_lfr_b_bp_p1( TC, queue_id );
192 if (result != LFR_SUCCESSFUL)
209 if (result != LFR_SUCCESSFUL)
193 {
210 {
194 flag = LFR_DEFAULT;
211 flag = LFR_DEFAULT;
195 }
212 }
196 }
213 }
197
214
198 return flag;
215 return flag;
199 }
216 }
200
217
201 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
218 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
202 {
219 {
203 /** This function updates the LFR registers with the incoming sbm1 parameters.
220 /** This function updates the LFR registers with the incoming sbm1 parameters.
204 *
221 *
205 * @param TC points to the TeleCommand packet that is being processed
222 * @param TC points to the TeleCommand packet that is being processed
206 * @param queue_id is the id of the queue which handles TM related to this execution step
223 * @param queue_id is the id of the queue which handles TM related to this execution step
207 *
224 *
208 */
225 */
209
226
210 int result;
227 int result;
211 int flag;
228 int flag;
212 rtems_status_code status;
229 rtems_status_code status;
213 unsigned char sy_lfr_s1_bp_p0;
230 unsigned char sy_lfr_s1_bp_p0;
214 unsigned char sy_lfr_s1_bp_p1;
231 unsigned char sy_lfr_s1_bp_p1;
215 float aux;
232 float aux;
216
233
217 flag = LFR_SUCCESSFUL;
234 flag = LFR_SUCCESSFUL;
218
235
219 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
236 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
220 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
237 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
221 result = LFR_DEFAULT;
238 result = LFR_DEFAULT;
222 }
239 }
223
240
224 //******************************************************************
241 //******************************************************************
225 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
242 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
226 if (flag == LFR_SUCCESSFUL)
243 if (flag == LFR_SUCCESSFUL)
227 {
244 {
228 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
245 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
229 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
246 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
230 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));
247 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
231 if (aux != 0)
248 if (aux != 0)
232 {
249 {
233 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
250 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
234 flag = LFR_DEFAULT;
251 flag = LFR_DEFAULT;
235 }
252 }
236 }
253 }
237
254
238 //***************
255 //***************
239 // sy_lfr_s1_bp_p0
256 // sy_lfr_s1_bp_p0
240 if (flag == LFR_SUCCESSFUL)
257 if (flag == LFR_SUCCESSFUL)
241 {
258 {
242 result = set_sy_lfr_s1_bp_p0( TC, queue_id );
259 result = set_sy_lfr_s1_bp_p0( TC, queue_id );
243 if (result != LFR_SUCCESSFUL)
260 if (result != LFR_SUCCESSFUL)
244 {
261 {
245 flag = LFR_DEFAULT;
262 flag = LFR_DEFAULT;
246 }
263 }
247 }
264 }
248
265
249 //***************
266 //***************
250 // sy_lfr_s1_bp_p1
267 // sy_lfr_s1_bp_p1
251 if (flag == LFR_SUCCESSFUL)
268 if (flag == LFR_SUCCESSFUL)
252 {
269 {
253 result = set_sy_lfr_s1_bp_p1( TC, queue_id );
270 result = set_sy_lfr_s1_bp_p1( TC, queue_id );
254 if (result != LFR_SUCCESSFUL)
271 if (result != LFR_SUCCESSFUL)
255 {
272 {
256 flag = LFR_DEFAULT;
273 flag = LFR_DEFAULT;
257 }
274 }
258 }
275 }
259
276
260 return flag;
277 return flag;
261 }
278 }
262
279
263 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
280 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
264 {
281 {
265 /** This function updates the LFR registers with the incoming sbm2 parameters.
282 /** This function updates the LFR registers with the incoming sbm2 parameters.
266 *
283 *
267 * @param TC points to the TeleCommand packet that is being processed
284 * @param TC points to the TeleCommand packet that is being processed
268 * @param queue_id is the id of the queue which handles TM related to this execution step
285 * @param queue_id is the id of the queue which handles TM related to this execution step
269 *
286 *
270 */
287 */
271
288
272 int result;
289 int result;
273 int flag;
290 int flag;
274 rtems_status_code status;
291 rtems_status_code status;
275 unsigned char sy_lfr_s2_bp_p0;
292 unsigned char sy_lfr_s2_bp_p0;
276 unsigned char sy_lfr_s2_bp_p1;
293 unsigned char sy_lfr_s2_bp_p1;
277 float aux;
294 float aux;
278
295
279 flag = LFR_SUCCESSFUL;
296 flag = LFR_SUCCESSFUL;
280
297
281 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
298 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
282 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
299 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
283 result = LFR_DEFAULT;
300 result = LFR_DEFAULT;
284 }
301 }
285
302
286 //******************************************************************
303 //******************************************************************
287 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
304 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
288 if (flag == LFR_SUCCESSFUL)
305 if (flag == LFR_SUCCESSFUL)
289 {
306 {
290 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
307 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
291 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
308 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
292 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
309 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
293 if (aux != 0)
310 if (aux != 0)
294 {
311 {
295 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
312 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
296 flag = LFR_DEFAULT;
313 flag = LFR_DEFAULT;
297 }
314 }
298 }
315 }
299
316
300 //***************
317 //***************
301 // sy_lfr_s2_bp_p0
318 // sy_lfr_s2_bp_p0
302 if (flag == LFR_SUCCESSFUL)
319 if (flag == LFR_SUCCESSFUL)
303 {
320 {
304 result = set_sy_lfr_s2_bp_p0( TC, queue_id );
321 result = set_sy_lfr_s2_bp_p0( TC, queue_id );
305 if (result != LFR_SUCCESSFUL)
322 if (result != LFR_SUCCESSFUL)
306 {
323 {
307 flag = LFR_DEFAULT;
324 flag = LFR_DEFAULT;
308 }
325 }
309 }
326 }
310
327
311 //***************
328 //***************
312 // sy_lfr_s2_bp_p1
329 // sy_lfr_s2_bp_p1
313 if (flag == LFR_SUCCESSFUL)
330 if (flag == LFR_SUCCESSFUL)
314 {
331 {
315 result = set_sy_lfr_s2_bp_p1( TC, queue_id );
332 result = set_sy_lfr_s2_bp_p1( TC, queue_id );
316 if (result != LFR_SUCCESSFUL)
333 if (result != LFR_SUCCESSFUL)
317 {
334 {
318 flag = LFR_DEFAULT;
335 flag = LFR_DEFAULT;
319 }
336 }
320 }
337 }
321
338
322 return flag;
339 return flag;
323 }
340 }
324
341
325 int action_dump_par( rtems_id queue_id )
342 int action_dump_par( rtems_id queue_id )
326 {
343 {
327 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
344 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
328 *
345 *
329 * @param queue_id is the id of the queue which handles TM related to this execution step.
346 * @param queue_id is the id of the queue which handles TM related to this execution step.
330 *
347 *
331 * @return RTEMS directive status codes:
348 * @return RTEMS directive status codes:
332 * - RTEMS_SUCCESSFUL - message sent successfully
349 * - RTEMS_SUCCESSFUL - message sent successfully
333 * - RTEMS_INVALID_ID - invalid queue id
350 * - RTEMS_INVALID_ID - invalid queue id
334 * - RTEMS_INVALID_SIZE - invalid message size
351 * - RTEMS_INVALID_SIZE - invalid message size
335 * - RTEMS_INVALID_ADDRESS - buffer is NULL
352 * - RTEMS_INVALID_ADDRESS - buffer is NULL
336 * - RTEMS_UNSATISFIED - out of message buffers
353 * - RTEMS_UNSATISFIED - out of message buffers
337 * - RTEMS_TOO_MANY - queue s limit has been reached
354 * - RTEMS_TOO_MANY - queue s limit has been reached
338 *
355 *
339 */
356 */
340
357
341 int status;
358 int status;
342
359
343 // UPDATE TIME
360 // UPDATE TIME
344 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
361 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
345 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
362 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
346 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
363 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
347 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
364 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
348 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
365 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
349 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
366 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
350 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
367 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
351 // SEND DATA
368 // SEND DATA
352 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
369 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
353 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
370 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
354 if (status != RTEMS_SUCCESSFUL) {
371 if (status != RTEMS_SUCCESSFUL) {
355 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
372 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
356 }
373 }
357
374
358 return status;
375 return status;
359 }
376 }
360
377
361 //***********************
378 //***********************
362 // NORMAL MODE PARAMETERS
379 // NORMAL MODE PARAMETERS
363
380
364 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
381 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
365 {
382 {
366 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
383 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
367 *
384 *
368 * @param TC points to the TeleCommand packet that is being processed
385 * @param TC points to the TeleCommand packet that is being processed
369 * @param queue_id is the id of the queue which handles TM related to this execution step
386 * @param queue_id is the id of the queue which handles TM related to this execution step
370 *
387 *
371 */
388 */
372
389
373 unsigned int tmp;
390 unsigned int tmp;
374 int result;
391 int result;
375 unsigned char msb;
392 unsigned char msb;
376 unsigned char lsb;
393 unsigned char lsb;
377 rtems_status_code status;
394 rtems_status_code status;
378
395
379 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
396 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
380 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
397 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
381
398
382 tmp = ( unsigned int ) floor(
399 tmp = ( unsigned int ) floor(
383 ( ( msb*256 ) + lsb ) / 16
400 ( ( msb*256 ) + lsb ) / 16
384 ) * 16;
401 ) * 16;
385
402
386 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
403 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
387 { // 2048 is the maximum limit due to the size of the buffers
404 { // 2048 is the maximum limit due to the size of the buffers
388 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
405 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
389 result = WRONG_APP_DATA;
406 result = WRONG_APP_DATA;
390 }
407 }
391 else if (tmp != 2048)
408 else if (tmp != 2048)
392 {
409 {
393 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
410 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
394 result = FUNCT_NOT_IMPL;
411 result = FUNCT_NOT_IMPL;
395 }
412 }
396 else
413 else
397 {
414 {
398 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
415 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
399 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
416 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
400 result = LFR_SUCCESSFUL;
417 result = LFR_SUCCESSFUL;
401 }
418 }
402
419
403 return result;
420 return result;
404 }
421 }
405
422
406 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
423 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
407 {
424 {
408 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
425 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
409 *
426 *
410 * @param TC points to the TeleCommand packet that is being processed
427 * @param TC points to the TeleCommand packet that is being processed
411 * @param queue_id is the id of the queue which handles TM related to this execution step
428 * @param queue_id is the id of the queue which handles TM related to this execution step
412 *
429 *
413 */
430 */
414
431
415 unsigned int tmp;
432 unsigned int tmp;
416 int result;
433 int result;
417 unsigned char msb;
434 unsigned char msb;
418 unsigned char lsb;
435 unsigned char lsb;
419 rtems_status_code status;
436 rtems_status_code status;
420
437
421 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
438 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
422 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
439 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
423
440
424 tmp = msb * 256 + lsb;
441 tmp = msb * 256 + lsb;
425
442
426 if ( tmp < 16 )
443 if ( tmp < 16 )
427 {
444 {
428 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
445 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
429 result = WRONG_APP_DATA;
446 result = WRONG_APP_DATA;
430 }
447 }
431 else
448 else
432 {
449 {
433 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
450 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
434 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
451 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
435 result = LFR_SUCCESSFUL;
452 result = LFR_SUCCESSFUL;
436 }
453 }
437
454
438 return result;
455 return result;
439 }
456 }
440
457
441 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
458 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
442 {
459 {
443 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
460 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
444 *
461 *
445 * @param TC points to the TeleCommand packet that is being processed
462 * @param TC points to the TeleCommand packet that is being processed
446 * @param queue_id is the id of the queue which handles TM related to this execution step
463 * @param queue_id is the id of the queue which handles TM related to this execution step
447 *
464 *
448 */
465 */
449
466
450 int result;
467 int result;
451 unsigned char msb;
468 unsigned char msb;
452 unsigned char lsb;
469 unsigned char lsb;
453
470
454 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
471 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
455 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
472 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
456
473
457 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
474 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
458 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
475 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
459 result = LFR_SUCCESSFUL;
476 result = LFR_SUCCESSFUL;
460
477
461 return result;
478 return result;
462 }
479 }
463
480
464 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
481 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
465 {
482 {
466 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
483 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
467 *
484 *
468 * @param TC points to the TeleCommand packet that is being processed
485 * @param TC points to the TeleCommand packet that is being processed
469 * @param queue_id is the id of the queue which handles TM related to this execution step
486 * @param queue_id is the id of the queue which handles TM related to this execution step
470 *
487 *
471 */
488 */
472
489
473 int status;
490 int status;
474
491
475 status = LFR_SUCCESSFUL;
492 status = LFR_SUCCESSFUL;
476
493
477 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
494 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
478
495
479 return status;
496 return status;
480 }
497 }
481
498
482 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
499 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
483 {
500 {
484 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
501 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
485 *
502 *
486 * @param TC points to the TeleCommand packet that is being processed
503 * @param TC points to the TeleCommand packet that is being processed
487 * @param queue_id is the id of the queue which handles TM related to this execution step
504 * @param queue_id is the id of the queue which handles TM related to this execution step
488 *
505 *
489 */
506 */
490
507
491 int status;
508 int status;
492
509
493 status = LFR_SUCCESSFUL;
510 status = LFR_SUCCESSFUL;
494
511
495 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
512 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
496
513
497 return status;
514 return status;
498 }
515 }
499
516
500 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
517 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
501 {
518 {
502 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
519 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
503 *
520 *
504 * @param TC points to the TeleCommand packet that is being processed
521 * @param TC points to the TeleCommand packet that is being processed
505 * @param queue_id is the id of the queue which handles TM related to this execution step
522 * @param queue_id is the id of the queue which handles TM related to this execution step
506 *
523 *
507 */
524 */
508
525
509 int status;
526 int status;
510
527
511 status = LFR_SUCCESSFUL;
528 status = LFR_SUCCESSFUL;
512
529
513 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
530 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
514
531
515 return status;
532 return status;
516 }
533 }
517
534
518 //**********************
535 //**********************
519 // BURST MODE PARAMETERS
536 // BURST MODE PARAMETERS
520 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
537 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
521 {
538 {
522 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
539 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
523 *
540 *
524 * @param TC points to the TeleCommand packet that is being processed
541 * @param TC points to the TeleCommand packet that is being processed
525 * @param queue_id is the id of the queue which handles TM related to this execution step
542 * @param queue_id is the id of the queue which handles TM related to this execution step
526 *
543 *
527 */
544 */
528
545
529 int status;
546 int status;
530
547
531 status = LFR_SUCCESSFUL;
548 status = LFR_SUCCESSFUL;
532
549
533 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
550 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
534
551
535 return status;
552 return status;
536 }
553 }
537
554
538 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
555 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
539 {
556 {
540 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
557 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
541 *
558 *
542 * @param TC points to the TeleCommand packet that is being processed
559 * @param TC points to the TeleCommand packet that is being processed
543 * @param queue_id is the id of the queue which handles TM related to this execution step
560 * @param queue_id is the id of the queue which handles TM related to this execution step
544 *
561 *
545 */
562 */
546
563
547 int status;
564 int status;
548
565
549 status = LFR_SUCCESSFUL;
566 status = LFR_SUCCESSFUL;
550
567
551 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
568 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
552
569
553 return status;
570 return status;
554 }
571 }
555
572
556 //*********************
573 //*********************
557 // SBM1 MODE PARAMETERS
574 // SBM1 MODE PARAMETERS
558 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
575 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
559 {
576 {
560 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
577 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
561 *
578 *
562 * @param TC points to the TeleCommand packet that is being processed
579 * @param TC points to the TeleCommand packet that is being processed
563 * @param queue_id is the id of the queue which handles TM related to this execution step
580 * @param queue_id is the id of the queue which handles TM related to this execution step
564 *
581 *
565 */
582 */
566
583
567 int status;
584 int status;
568
585
569 status = LFR_SUCCESSFUL;
586 status = LFR_SUCCESSFUL;
570
587
571 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
588 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
572
589
573 return status;
590 return status;
574 }
591 }
575
592
576 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
593 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
577 {
594 {
578 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
595 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
579 *
596 *
580 * @param TC points to the TeleCommand packet that is being processed
597 * @param TC points to the TeleCommand packet that is being processed
581 * @param queue_id is the id of the queue which handles TM related to this execution step
598 * @param queue_id is the id of the queue which handles TM related to this execution step
582 *
599 *
583 */
600 */
584
601
585 int status;
602 int status;
586
603
587 status = LFR_SUCCESSFUL;
604 status = LFR_SUCCESSFUL;
588
605
589 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
606 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
590
607
591 return status;
608 return status;
592 }
609 }
593
610
594 //*********************
611 //*********************
595 // SBM2 MODE PARAMETERS
612 // SBM2 MODE PARAMETERS
596 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
613 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
597 {
614 {
598 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
615 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
599 *
616 *
600 * @param TC points to the TeleCommand packet that is being processed
617 * @param TC points to the TeleCommand packet that is being processed
601 * @param queue_id is the id of the queue which handles TM related to this execution step
618 * @param queue_id is the id of the queue which handles TM related to this execution step
602 *
619 *
603 */
620 */
604
621
605 int status;
622 int status;
606
623
607 status = LFR_SUCCESSFUL;
624 status = LFR_SUCCESSFUL;
608
625
609 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
626 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
610
627
611 return status;
628 return status;
612 }
629 }
613
630
614 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
631 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
615 {
632 {
616 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
633 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
617 *
634 *
618 * @param TC points to the TeleCommand packet that is being processed
635 * @param TC points to the TeleCommand packet that is being processed
619 * @param queue_id is the id of the queue which handles TM related to this execution step
636 * @param queue_id is the id of the queue which handles TM related to this execution step
620 *
637 *
621 */
638 */
622
639
623 int status;
640 int status;
624
641
625 status = LFR_SUCCESSFUL;
642 status = LFR_SUCCESSFUL;
626
643
627 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
644 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
628
645
629 return status;
646 return status;
630 }
647 }
631
648
632
649
633 //*******************
650 //*******************
634 // TC_LFR_UPDATE_INFO
651 // TC_LFR_UPDATE_INFO
635 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
652 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
636 {
653 {
637 unsigned int status;
654 unsigned int status;
638
655
639 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
656 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
640 || (mode == LFR_MODE_BURST)
657 || (mode == LFR_MODE_BURST)
641 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
658 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
642 {
659 {
643 status = LFR_SUCCESSFUL;
660 status = LFR_SUCCESSFUL;
644 }
661 }
645 else
662 else
646 {
663 {
647 status = LFR_DEFAULT;
664 status = LFR_DEFAULT;
648 }
665 }
649
666
650 return status;
667 return status;
651 }
668 }
652
669
653 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
670 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
654 {
671 {
655 unsigned int status;
672 unsigned int status;
656
673
657 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
674 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
658 || (mode == TDS_MODE_BURST)
675 || (mode == TDS_MODE_BURST)
659 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
676 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
660 || (mode == TDS_MODE_LFM))
677 || (mode == TDS_MODE_LFM))
661 {
678 {
662 status = LFR_SUCCESSFUL;
679 status = LFR_SUCCESSFUL;
663 }
680 }
664 else
681 else
665 {
682 {
666 status = LFR_DEFAULT;
683 status = LFR_DEFAULT;
667 }
684 }
668
685
669 return status;
686 return status;
670 }
687 }
671
688
672 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
689 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
673 {
690 {
674 unsigned int status;
691 unsigned int status;
675
692
676 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
693 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
677 || (mode == THR_MODE_BURST))
694 || (mode == THR_MODE_BURST))
678 {
695 {
679 status = LFR_SUCCESSFUL;
696 status = LFR_SUCCESSFUL;
680 }
697 }
681 else
698 else
682 {
699 {
683 status = LFR_DEFAULT;
700 status = LFR_DEFAULT;
684 }
701 }
685
702
686 return status;
703 return status;
687 }
704 }
688
705
689 //**********
706 //**********
690 // init dump
707 // init dump
691
708
692 void init_parameter_dump( void )
709 void init_parameter_dump( void )
693 {
710 {
694 /** This function initialize the parameter_dump_packet global variable with default values.
711 /** This function initialize the parameter_dump_packet global variable with default values.
695 *
712 *
696 */
713 */
697
714
698 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
715 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
699 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
716 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
700 parameter_dump_packet.reserved = CCSDS_RESERVED;
717 parameter_dump_packet.reserved = CCSDS_RESERVED;
701 parameter_dump_packet.userApplication = CCSDS_USER_APP;
718 parameter_dump_packet.userApplication = CCSDS_USER_APP;
702 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
719 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
703 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
720 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
704 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
721 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
705 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
722 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
706 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
723 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
707 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
724 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
708 // DATA FIELD HEADER
725 // DATA FIELD HEADER
709 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
726 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
710 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
727 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
711 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
728 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
712 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
729 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
713 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
730 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
714 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
731 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
715 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
732 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
716 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
733 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
717 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
734 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
718 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
735 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
719 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
736 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
720
737
721 //******************
738 //******************
722 // COMMON PARAMETERS
739 // COMMON PARAMETERS
723 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
740 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
724 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
741 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
725
742
726 //******************
743 //******************
727 // NORMAL PARAMETERS
744 // NORMAL PARAMETERS
728 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
745 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
729 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
746 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
730 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
747 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
731 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
748 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
732 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
749 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
733 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
750 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
734 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
751 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
735 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
752 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
736 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
753 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
737
754
738 //*****************
755 //*****************
739 // BURST PARAMETERS
756 // BURST PARAMETERS
740 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
757 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
741 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
758 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
742
759
743 //****************
760 //****************
744 // SBM1 PARAMETERS
761 // SBM1 PARAMETERS
745 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
762 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
746 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
763 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
747
764
748 //****************
765 //****************
749 // SBM2 PARAMETERS
766 // SBM2 PARAMETERS
750 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
767 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
751 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
768 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
752 }
769 }
753
770
754
771
755
772
756
773
757
774
758
775
759
776
@@ -1,1351 +1,1339
1 /** Functions and tasks related to waveform packet generation.
1 /** Functions and tasks related to waveform packet generation.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
7 *
8 */
8 */
9
9
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11
11
12 //*****************
12 //*****************
13 // waveform headers
13 // waveform headers
14 // SWF
14 // SWF
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 // CWF
18 // CWF
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24
24
25 //**************
25 //**************
26 // waveform ring
26 // waveform ring
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 ring_node *current_ring_node_f0;
30 ring_node *current_ring_node_f0;
31 ring_node *ring_node_to_send_swf_f0;
31 ring_node *ring_node_to_send_swf_f0;
32 ring_node *current_ring_node_f1;
32 ring_node *current_ring_node_f1;
33 ring_node *ring_node_to_send_swf_f1;
33 ring_node *ring_node_to_send_swf_f1;
34 ring_node *ring_node_to_send_cwf_f1;
34 ring_node *ring_node_to_send_cwf_f1;
35 ring_node *current_ring_node_f2;
35 ring_node *current_ring_node_f2;
36 ring_node *ring_node_to_send_swf_f2;
36 ring_node *ring_node_to_send_swf_f2;
37 ring_node *ring_node_to_send_cwf_f2;
37 ring_node *ring_node_to_send_cwf_f2;
38
38
39 bool extractSWF = false;
39 bool extractSWF = false;
40 bool swf_f0_ready = false;
40 bool swf_f0_ready = false;
41 bool swf_f1_ready = false;
41 bool swf_f1_ready = false;
42 bool swf_f2_ready = false;
42 bool swf_f2_ready = false;
43
43
44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
45
45
46 //*********************
46 //*********************
47 // Interrupt SubRoutine
47 // Interrupt SubRoutine
48
48
49 void reset_extractSWF( void )
49 void reset_extractSWF( void )
50 {
50 {
51 extractSWF = false;
51 extractSWF = false;
52 swf_f0_ready = false;
52 swf_f0_ready = false;
53 swf_f1_ready = false;
53 swf_f1_ready = false;
54 swf_f2_ready = false;
54 swf_f2_ready = false;
55 }
55 }
56
56
57 rtems_isr waveforms_isr( rtems_vector_number vector )
57 rtems_isr waveforms_isr( rtems_vector_number vector )
58 {
58 {
59 /** This is the interrupt sub routine called by the waveform picker core.
59 /** This is the interrupt sub routine called by the waveform picker core.
60 *
60 *
61 * This ISR launch different actions depending mainly on two pieces of information:
61 * This ISR launch different actions depending mainly on two pieces of information:
62 * 1. the values read in the registers of the waveform picker.
62 * 1. the values read in the registers of the waveform picker.
63 * 2. the current LFR mode.
63 * 2. the current LFR mode.
64 *
64 *
65 */
65 */
66
66
67 rtems_status_code status;
67 rtems_status_code status;
68 static unsigned char nb_swf = 0;
69
68
70 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
69 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
71 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
70 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
72 { // in modes other than STANDBY and BURST, send the CWF_F3 data
71 { // in modes other than STANDBY and BURST, send the CWF_F3 data
73 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
72 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
74 // (1) change the receiving buffer for the waveform picker
73 // (1) change the receiving buffer for the waveform picker
75 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
74 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
76 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
75 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
77 }
76 }
78 else {
77 else {
79 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
78 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
80 }
79 }
81 // (2) send an event for the waveforms transmission
80 // (2) send an event for the waveforms transmission
82 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
81 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
82 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
84 }
83 }
85 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
84 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
86 }
85 }
87 }
86 }
88
87
89 switch(lfrCurrentMode)
88 switch(lfrCurrentMode)
90 {
89 {
91 //********
90 //********
92 // STANDBY
91 // STANDBY
93 case(LFR_MODE_STANDBY):
92 case(LFR_MODE_STANDBY):
94 break;
93 break;
95
94
96 //******
95 //******
97 // NORMAL
96 // NORMAL
98 case(LFR_MODE_NORMAL):
97 case(LFR_MODE_NORMAL):
99 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
98 if ( (waveform_picker_regs->status & 0xff8) != 0x00) // [1000] check the error bits
100 {
99 {
101 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
100 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
102 }
101 }
103 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
102 if ( (waveform_picker_regs->status & 0x07) == 0x07) // [0111] check the f2, f1, f0 full bits
104 {
103 {
105 // change F0 ring node
104 // change F0 ring node
106 ring_node_to_send_swf_f0 = current_ring_node_f0;
105 ring_node_to_send_swf_f0 = current_ring_node_f0;
107 current_ring_node_f0 = current_ring_node_f0->next;
106 current_ring_node_f0 = current_ring_node_f0->next;
108 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
107 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
109 // change F1 ring node
108 // change F1 ring node
110 ring_node_to_send_swf_f1 = current_ring_node_f1;
109 ring_node_to_send_swf_f1 = current_ring_node_f1;
111 current_ring_node_f1 = current_ring_node_f1->next;
110 current_ring_node_f1 = current_ring_node_f1->next;
112 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
111 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
113 // change F2 ring node
112 // change F2 ring node
114 ring_node_to_send_swf_f2 = current_ring_node_f2;
113 ring_node_to_send_swf_f2 = current_ring_node_f2;
115 current_ring_node_f2 = current_ring_node_f2->next;
114 current_ring_node_f2 = current_ring_node_f2->next;
116 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
115 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
117 //
116 //
118 // if (nb_swf < 2)
117 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
119 if (true)
120 {
118 {
121 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
119 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
122 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
123 }
124 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
125 nb_swf = nb_swf + 1;
126 }
120 }
127 else
121 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
128 {
129 reset_wfp_burst_enable();
130 nb_swf = 0;
131 }
132
133 }
122 }
134
135 break;
123 break;
136
124
137 //******
125 //******
138 // BURST
126 // BURST
139 case(LFR_MODE_BURST):
127 case(LFR_MODE_BURST):
140 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
128 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
141 // (1) change the receiving buffer for the waveform picker
129 // (1) change the receiving buffer for the waveform picker
142 ring_node_to_send_cwf_f2 = current_ring_node_f2;
130 ring_node_to_send_cwf_f2 = current_ring_node_f2;
143 current_ring_node_f2 = current_ring_node_f2->next;
131 current_ring_node_f2 = current_ring_node_f2->next;
144 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
132 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
145 // (2) send an event for the waveforms transmission
133 // (2) send an event for the waveforms transmission
146 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
134 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
147 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
135 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
148 }
136 }
149 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
137 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
150 }
138 }
151 break;
139 break;
152
140
153 //*****
141 //*****
154 // SBM1
142 // SBM1
155 case(LFR_MODE_SBM1):
143 case(LFR_MODE_SBM1):
156 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
144 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
157 // (1) change the receiving buffer for the waveform picker
145 // (1) change the receiving buffer for the waveform picker
158 ring_node_to_send_cwf_f1 = current_ring_node_f1;
146 ring_node_to_send_cwf_f1 = current_ring_node_f1;
159 current_ring_node_f1 = current_ring_node_f1->next;
147 current_ring_node_f1 = current_ring_node_f1->next;
160 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
148 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
161 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
149 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
162 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
150 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
163 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
151 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
164 }
152 }
165 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
153 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
166 swf_f0_ready = true;
154 swf_f0_ready = true;
167 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
155 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
168 }
156 }
169 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
157 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
170 swf_f2_ready = true;
158 swf_f2_ready = true;
171 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
159 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
172 }
160 }
173 break;
161 break;
174
162
175 //*****
163 //*****
176 // SBM2
164 // SBM2
177 case(LFR_MODE_SBM2):
165 case(LFR_MODE_SBM2):
178 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
166 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
179 // (1) change the receiving buffer for the waveform picker
167 // (1) change the receiving buffer for the waveform picker
180 ring_node_to_send_cwf_f2 = current_ring_node_f2;
168 ring_node_to_send_cwf_f2 = current_ring_node_f2;
181 current_ring_node_f2 = current_ring_node_f2->next;
169 current_ring_node_f2 = current_ring_node_f2->next;
182 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
170 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
183 // (2) send an event for the waveforms transmission
171 // (2) send an event for the waveforms transmission
184 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
172 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
185 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
173 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
186 }
174 }
187 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
175 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
188 swf_f0_ready = true;
176 swf_f0_ready = true;
189 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
177 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
190 }
178 }
191 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
179 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
192 swf_f1_ready = true;
180 swf_f1_ready = true;
193 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
194 }
182 }
195 break;
183 break;
196
184
197 //********
185 //********
198 // DEFAULT
186 // DEFAULT
199 default:
187 default:
200 break;
188 break;
201 }
189 }
202 }
190 }
203
191
204 //************
192 //************
205 // RTEMS TASKS
193 // RTEMS TASKS
206
194
207 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
195 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
208 {
196 {
209 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
197 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
210 *
198 *
211 * @param unused is the starting argument of the RTEMS task
199 * @param unused is the starting argument of the RTEMS task
212 *
200 *
213 * The following data packets are sent by this task:
201 * The following data packets are sent by this task:
214 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
202 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
215 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
203 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
216 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
204 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
217 *
205 *
218 */
206 */
219
207
220 rtems_event_set event_out;
208 rtems_event_set event_out;
221 rtems_id queue_id;
209 rtems_id queue_id;
222 rtems_status_code status;
210 rtems_status_code status;
223
211
224 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
212 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
225 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
213 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
226 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
214 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
227
215
228 init_waveforms();
216 init_waveforms();
229
217
230 status = get_message_queue_id_send( &queue_id );
218 status = get_message_queue_id_send( &queue_id );
231 if (status != RTEMS_SUCCESSFUL)
219 if (status != RTEMS_SUCCESSFUL)
232 {
220 {
233 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
221 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
234 }
222 }
235
223
236 BOOT_PRINTF("in WFRM ***\n")
224 BOOT_PRINTF("in WFRM ***\n")
237
225
238 while(1){
226 while(1){
239 // wait for an RTEMS_EVENT
227 // wait for an RTEMS_EVENT
240 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
228 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
241 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
229 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
242 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
230 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
243 if (event_out == RTEMS_EVENT_MODE_NORMAL)
231 if (event_out == RTEMS_EVENT_MODE_NORMAL)
244 {
232 {
245 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
233 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
246 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
234 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
247 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
235 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
248 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
236 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
249 }
237 }
250 if (event_out == RTEMS_EVENT_MODE_SBM1)
238 if (event_out == RTEMS_EVENT_MODE_SBM1)
251 {
239 {
252 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
240 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
253 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
241 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
254 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
242 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
255 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
243 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
256 }
244 }
257 if (event_out == RTEMS_EVENT_MODE_SBM2)
245 if (event_out == RTEMS_EVENT_MODE_SBM2)
258 {
246 {
259 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
247 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
260 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
248 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
261 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
249 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
262 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
250 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
263 }
251 }
264 }
252 }
265 }
253 }
266
254
267 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
255 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
268 {
256 {
269 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
257 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
270 *
258 *
271 * @param unused is the starting argument of the RTEMS task
259 * @param unused is the starting argument of the RTEMS task
272 *
260 *
273 * The following data packet is sent by this task:
261 * The following data packet is sent by this task:
274 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
262 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
275 *
263 *
276 */
264 */
277
265
278 rtems_event_set event_out;
266 rtems_event_set event_out;
279 rtems_id queue_id;
267 rtems_id queue_id;
280 rtems_status_code status;
268 rtems_status_code status;
281
269
282 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
270 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
283 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
271 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
284
272
285 status = get_message_queue_id_send( &queue_id );
273 status = get_message_queue_id_send( &queue_id );
286 if (status != RTEMS_SUCCESSFUL)
274 if (status != RTEMS_SUCCESSFUL)
287 {
275 {
288 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
276 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
289 }
277 }
290
278
291 BOOT_PRINTF("in CWF3 ***\n")
279 BOOT_PRINTF("in CWF3 ***\n")
292
280
293 while(1){
281 while(1){
294 // wait for an RTEMS_EVENT
282 // wait for an RTEMS_EVENT
295 rtems_event_receive( RTEMS_EVENT_0,
283 rtems_event_receive( RTEMS_EVENT_0,
296 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
284 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
297 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
285 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
298 {
286 {
299 PRINTF("send CWF_LONG_F3\n")
287 PRINTF("send CWF_LONG_F3\n")
300 }
288 }
301 else
289 else
302 {
290 {
303 PRINTF("send CWF_F3 (light)\n")
291 PRINTF("send CWF_F3 (light)\n")
304 }
292 }
305 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
293 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
306 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
294 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
307 {
295 {
308 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
296 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
309 }
297 }
310 else
298 else
311 {
299 {
312 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
300 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
313 }
301 }
314 }
302 }
315 else
303 else
316 {
304 {
317 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
305 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
318 {
306 {
319 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
307 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
320 }
308 }
321 else
309 else
322 {
310 {
323 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
311 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
324 }
312 }
325
313
326 }
314 }
327 }
315 }
328 }
316 }
329
317
330 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
318 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
331 {
319 {
332 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
320 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
333 *
321 *
334 * @param unused is the starting argument of the RTEMS task
322 * @param unused is the starting argument of the RTEMS task
335 *
323 *
336 * The following data packet is sent by this function:
324 * The following data packet is sent by this function:
337 * - TM_LFR_SCIENCE_BURST_CWF_F2
325 * - TM_LFR_SCIENCE_BURST_CWF_F2
338 * - TM_LFR_SCIENCE_SBM2_CWF_F2
326 * - TM_LFR_SCIENCE_SBM2_CWF_F2
339 *
327 *
340 */
328 */
341
329
342 rtems_event_set event_out;
330 rtems_event_set event_out;
343 rtems_id queue_id;
331 rtems_id queue_id;
344 rtems_status_code status;
332 rtems_status_code status;
345
333
346 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
334 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
347 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
335 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
348
336
349 status = get_message_queue_id_send( &queue_id );
337 status = get_message_queue_id_send( &queue_id );
350 if (status != RTEMS_SUCCESSFUL)
338 if (status != RTEMS_SUCCESSFUL)
351 {
339 {
352 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
340 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
353 }
341 }
354
342
355 BOOT_PRINTF("in CWF2 ***\n")
343 BOOT_PRINTF("in CWF2 ***\n")
356
344
357 while(1){
345 while(1){
358 // wait for an RTEMS_EVENT
346 // wait for an RTEMS_EVENT
359 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
347 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
360 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
348 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
361 if (event_out == RTEMS_EVENT_MODE_BURST)
349 if (event_out == RTEMS_EVENT_MODE_BURST)
362 {
350 {
363 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
351 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
364 }
352 }
365 if (event_out == RTEMS_EVENT_MODE_SBM2)
353 if (event_out == RTEMS_EVENT_MODE_SBM2)
366 {
354 {
367 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
355 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
368 // launch snapshot extraction if needed
356 // launch snapshot extraction if needed
369 if (extractSWF == true)
357 if (extractSWF == true)
370 {
358 {
371 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
359 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
372 // extract the snapshot
360 // extract the snapshot
373 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
361 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
374 // send the snapshot when built
362 // send the snapshot when built
375 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
363 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
376 extractSWF = false;
364 extractSWF = false;
377 }
365 }
378 if (swf_f0_ready && swf_f1_ready)
366 if (swf_f0_ready && swf_f1_ready)
379 {
367 {
380 extractSWF = true;
368 extractSWF = true;
381 swf_f0_ready = false;
369 swf_f0_ready = false;
382 swf_f1_ready = false;
370 swf_f1_ready = false;
383 }
371 }
384 }
372 }
385 }
373 }
386 }
374 }
387
375
388 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
376 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
389 {
377 {
390 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
378 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
391 *
379 *
392 * @param unused is the starting argument of the RTEMS task
380 * @param unused is the starting argument of the RTEMS task
393 *
381 *
394 * The following data packet is sent by this function:
382 * The following data packet is sent by this function:
395 * - TM_LFR_SCIENCE_SBM1_CWF_F1
383 * - TM_LFR_SCIENCE_SBM1_CWF_F1
396 *
384 *
397 */
385 */
398
386
399 rtems_event_set event_out;
387 rtems_event_set event_out;
400 rtems_id queue_id;
388 rtems_id queue_id;
401 rtems_status_code status;
389 rtems_status_code status;
402
390
403 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
391 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
404
392
405 status = get_message_queue_id_send( &queue_id );
393 status = get_message_queue_id_send( &queue_id );
406 if (status != RTEMS_SUCCESSFUL)
394 if (status != RTEMS_SUCCESSFUL)
407 {
395 {
408 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
396 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
409 }
397 }
410
398
411 BOOT_PRINTF("in CWF1 ***\n")
399 BOOT_PRINTF("in CWF1 ***\n")
412
400
413 while(1){
401 while(1){
414 // wait for an RTEMS_EVENT
402 // wait for an RTEMS_EVENT
415 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
403 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
416 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
404 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
417 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
405 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
418 // launch snapshot extraction if needed
406 // launch snapshot extraction if needed
419 if (extractSWF == true)
407 if (extractSWF == true)
420 {
408 {
421 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
409 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
422 // launch the snapshot extraction
410 // launch the snapshot extraction
423 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
411 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
424 extractSWF = false;
412 extractSWF = false;
425 }
413 }
426 if (swf_f0_ready == true)
414 if (swf_f0_ready == true)
427 {
415 {
428 extractSWF = true;
416 extractSWF = true;
429 swf_f0_ready = false; // this step shall be executed only one time
417 swf_f0_ready = false; // this step shall be executed only one time
430 }
418 }
431 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
419 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
432 {
420 {
433 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
421 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
434 swf_f1_ready = false;
422 swf_f1_ready = false;
435 swf_f2_ready = false;
423 swf_f2_ready = false;
436 }
424 }
437 }
425 }
438 }
426 }
439
427
440 rtems_task swbd_task(rtems_task_argument argument)
428 rtems_task swbd_task(rtems_task_argument argument)
441 {
429 {
442 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
430 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
443 *
431 *
444 * @param unused is the starting argument of the RTEMS task
432 * @param unused is the starting argument of the RTEMS task
445 *
433 *
446 */
434 */
447
435
448 rtems_event_set event_out;
436 rtems_event_set event_out;
449
437
450 BOOT_PRINTF("in SWBD ***\n")
438 BOOT_PRINTF("in SWBD ***\n")
451
439
452 while(1){
440 while(1){
453 // wait for an RTEMS_EVENT
441 // wait for an RTEMS_EVENT
454 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
442 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
455 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
443 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
456 if (event_out == RTEMS_EVENT_MODE_SBM1)
444 if (event_out == RTEMS_EVENT_MODE_SBM1)
457 {
445 {
458 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
446 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
459 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
447 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
460 }
448 }
461 else
449 else
462 {
450 {
463 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
451 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
464 }
452 }
465 }
453 }
466 }
454 }
467
455
468 //******************
456 //******************
469 // general functions
457 // general functions
470 void init_waveforms( void )
458 void init_waveforms( void )
471 {
459 {
472 int i = 0;
460 int i = 0;
473
461
474 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
462 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
475 {
463 {
476 //***
464 //***
477 // F0
465 // F0
478 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
466 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
479 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
467 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
480 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
468 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
481
469
482 //***
470 //***
483 // F1
471 // F1
484 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
472 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
485 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
473 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
486 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
474 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
487
475
488 //***
476 //***
489 // F2
477 // F2
490 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
478 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
491 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
479 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
492 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
480 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
493
481
494 //***
482 //***
495 // F3
483 // F3
496 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
484 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
497 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
485 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
498 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
486 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
499 }
487 }
500 }
488 }
501
489
502 void init_waveform_rings( void )
490 void init_waveform_rings( void )
503 {
491 {
504 unsigned char i;
492 unsigned char i;
505
493
506 // F0 RING
494 // F0 RING
507 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
495 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
508 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
496 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
509 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
497 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
510
498
511 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
499 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
512 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
500 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
513 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
501 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
514
502
515 for(i=1; i<NB_RING_NODES_F0-1; i++)
503 for(i=1; i<NB_RING_NODES_F0-1; i++)
516 {
504 {
517 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
505 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
518 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
506 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
519 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
507 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
520 }
508 }
521
509
522 // F1 RING
510 // F1 RING
523 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
511 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
524 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
512 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
525 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
513 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
526
514
527 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
515 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
528 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
516 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
529 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
517 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
530
518
531 for(i=1; i<NB_RING_NODES_F1-1; i++)
519 for(i=1; i<NB_RING_NODES_F1-1; i++)
532 {
520 {
533 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
521 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
534 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
522 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
535 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
523 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
536 }
524 }
537
525
538 // F2 RING
526 // F2 RING
539 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
527 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
540 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
528 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
541 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
529 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
542
530
543 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
531 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
544 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
532 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
545 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
533 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
546
534
547 for(i=1; i<NB_RING_NODES_F2-1; i++)
535 for(i=1; i<NB_RING_NODES_F2-1; i++)
548 {
536 {
549 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
537 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
550 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
538 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
551 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
539 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
552 }
540 }
553
541
554 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
542 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
555 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
543 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
556 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
544 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
557
545
558 }
546 }
559
547
560 void reset_current_ring_nodes( void )
548 void reset_current_ring_nodes( void )
561 {
549 {
562 current_ring_node_f0 = waveform_ring_f0;
550 current_ring_node_f0 = waveform_ring_f0;
563 ring_node_to_send_swf_f0 = waveform_ring_f0;
551 ring_node_to_send_swf_f0 = waveform_ring_f0;
564
552
565 current_ring_node_f1 = waveform_ring_f1;
553 current_ring_node_f1 = waveform_ring_f1;
566 ring_node_to_send_cwf_f1 = waveform_ring_f1;
554 ring_node_to_send_cwf_f1 = waveform_ring_f1;
567 ring_node_to_send_swf_f1 = waveform_ring_f1;
555 ring_node_to_send_swf_f1 = waveform_ring_f1;
568
556
569 current_ring_node_f2 = waveform_ring_f2;
557 current_ring_node_f2 = waveform_ring_f2;
570 ring_node_to_send_cwf_f2 = waveform_ring_f2;
558 ring_node_to_send_cwf_f2 = waveform_ring_f2;
571 ring_node_to_send_swf_f2 = waveform_ring_f2;
559 ring_node_to_send_swf_f2 = waveform_ring_f2;
572 }
560 }
573
561
574 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
562 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
575 {
563 {
576 unsigned char i;
564 unsigned char i;
577
565
578 for (i=0; i<7; i++)
566 for (i=0; i<7; i++)
579 {
567 {
580 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
568 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
581 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
569 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
582 headerSWF[ i ].reserved = DEFAULT_RESERVED;
570 headerSWF[ i ].reserved = DEFAULT_RESERVED;
583 headerSWF[ i ].userApplication = CCSDS_USER_APP;
571 headerSWF[ i ].userApplication = CCSDS_USER_APP;
584 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
572 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
585 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
573 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
586 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
574 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
587 if (i == 6)
575 if (i == 6)
588 {
576 {
589 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
577 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
590 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
578 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
591 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
579 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
592 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
580 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
593 }
581 }
594 else
582 else
595 {
583 {
596 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
584 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
597 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
585 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
598 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
586 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
599 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
587 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
600 }
588 }
601 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
589 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
602 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
590 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
603 headerSWF[ i ].pktNr = i+1; // PKT_NR
591 headerSWF[ i ].pktNr = i+1; // PKT_NR
604 // DATA FIELD HEADER
592 // DATA FIELD HEADER
605 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
593 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
606 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
594 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
607 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
595 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
608 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
596 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
609 // AUXILIARY DATA HEADER
597 // AUXILIARY DATA HEADER
610 headerSWF[ i ].time[0] = 0x00;
598 headerSWF[ i ].time[0] = 0x00;
611 headerSWF[ i ].time[0] = 0x00;
599 headerSWF[ i ].time[0] = 0x00;
612 headerSWF[ i ].time[0] = 0x00;
600 headerSWF[ i ].time[0] = 0x00;
613 headerSWF[ i ].time[0] = 0x00;
601 headerSWF[ i ].time[0] = 0x00;
614 headerSWF[ i ].time[0] = 0x00;
602 headerSWF[ i ].time[0] = 0x00;
615 headerSWF[ i ].time[0] = 0x00;
603 headerSWF[ i ].time[0] = 0x00;
616 headerSWF[ i ].sid = sid;
604 headerSWF[ i ].sid = sid;
617 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
605 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
618 }
606 }
619 return LFR_SUCCESSFUL;
607 return LFR_SUCCESSFUL;
620 }
608 }
621
609
622 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
610 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
623 {
611 {
624 unsigned int i;
612 unsigned int i;
625
613
626 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
614 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
627 {
615 {
628 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
616 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
629 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
617 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
630 headerCWF[ i ].reserved = DEFAULT_RESERVED;
618 headerCWF[ i ].reserved = DEFAULT_RESERVED;
631 headerCWF[ i ].userApplication = CCSDS_USER_APP;
619 headerCWF[ i ].userApplication = CCSDS_USER_APP;
632 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
620 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
633 {
621 {
634 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
622 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
635 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
623 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
636 }
624 }
637 else
625 else
638 {
626 {
639 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
627 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
640 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
628 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
641 }
629 }
642 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
630 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
643 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
631 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
644 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
632 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
645 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
633 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
646 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
634 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
647 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
635 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
648 // DATA FIELD HEADER
636 // DATA FIELD HEADER
649 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
637 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
650 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
638 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
651 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
639 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
652 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
640 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
653 // AUXILIARY DATA HEADER
641 // AUXILIARY DATA HEADER
654 headerCWF[ i ].sid = sid;
642 headerCWF[ i ].sid = sid;
655 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
643 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
656 headerCWF[ i ].time[0] = 0x00;
644 headerCWF[ i ].time[0] = 0x00;
657 headerCWF[ i ].time[0] = 0x00;
645 headerCWF[ i ].time[0] = 0x00;
658 headerCWF[ i ].time[0] = 0x00;
646 headerCWF[ i ].time[0] = 0x00;
659 headerCWF[ i ].time[0] = 0x00;
647 headerCWF[ i ].time[0] = 0x00;
660 headerCWF[ i ].time[0] = 0x00;
648 headerCWF[ i ].time[0] = 0x00;
661 headerCWF[ i ].time[0] = 0x00;
649 headerCWF[ i ].time[0] = 0x00;
662 }
650 }
663 return LFR_SUCCESSFUL;
651 return LFR_SUCCESSFUL;
664 }
652 }
665
653
666 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
654 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
667 {
655 {
668 unsigned int i;
656 unsigned int i;
669
657
670 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
658 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
671 {
659 {
672 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
660 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
673 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
661 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
674 headerCWF[ i ].reserved = DEFAULT_RESERVED;
662 headerCWF[ i ].reserved = DEFAULT_RESERVED;
675 headerCWF[ i ].userApplication = CCSDS_USER_APP;
663 headerCWF[ i ].userApplication = CCSDS_USER_APP;
676
664
677 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
665 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
678 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
666 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
679
667
680 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
668 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
681 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
669 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
682 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
670 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
683 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
671 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
684 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
672 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
685
673
686 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
674 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
687 // DATA FIELD HEADER
675 // DATA FIELD HEADER
688 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
676 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
689 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
677 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
690 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
678 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
691 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
679 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
692 // AUXILIARY DATA HEADER
680 // AUXILIARY DATA HEADER
693 headerCWF[ i ].sid = SID_NORM_CWF_F3;
681 headerCWF[ i ].sid = SID_NORM_CWF_F3;
694 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
682 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
695 headerCWF[ i ].time[0] = 0x00;
683 headerCWF[ i ].time[0] = 0x00;
696 headerCWF[ i ].time[0] = 0x00;
684 headerCWF[ i ].time[0] = 0x00;
697 headerCWF[ i ].time[0] = 0x00;
685 headerCWF[ i ].time[0] = 0x00;
698 headerCWF[ i ].time[0] = 0x00;
686 headerCWF[ i ].time[0] = 0x00;
699 headerCWF[ i ].time[0] = 0x00;
687 headerCWF[ i ].time[0] = 0x00;
700 headerCWF[ i ].time[0] = 0x00;
688 headerCWF[ i ].time[0] = 0x00;
701 }
689 }
702 return LFR_SUCCESSFUL;
690 return LFR_SUCCESSFUL;
703 }
691 }
704
692
705 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
693 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
706 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
694 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
707 {
695 {
708 /** This function sends SWF CCSDS packets (F2, F1 or F0).
696 /** This function sends SWF CCSDS packets (F2, F1 or F0).
709 *
697 *
710 * @param waveform points to the buffer containing the data that will be send.
698 * @param waveform points to the buffer containing the data that will be send.
711 * @param sid is the source identifier of the data that will be sent.
699 * @param sid is the source identifier of the data that will be sent.
712 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
700 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
713 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
701 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
714 * contain information to setup the transmission of the data packets.
702 * contain information to setup the transmission of the data packets.
715 *
703 *
716 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
704 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
717 *
705 *
718 */
706 */
719
707
720 unsigned int i;
708 unsigned int i;
721 int ret;
709 int ret;
722 unsigned int coarseTime;
710 unsigned int coarseTime;
723 unsigned int fineTime;
711 unsigned int fineTime;
724 rtems_status_code status;
712 rtems_status_code status;
725 spw_ioctl_pkt_send spw_ioctl_send_SWF;
713 spw_ioctl_pkt_send spw_ioctl_send_SWF;
726
714
727 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
715 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
728 spw_ioctl_send_SWF.options = 0;
716 spw_ioctl_send_SWF.options = 0;
729
717
730 ret = LFR_DEFAULT;
718 ret = LFR_DEFAULT;
731
719
732 coarseTime = waveform[0];
720 coarseTime = waveform[0];
733 fineTime = waveform[1];
721 fineTime = waveform[1];
734
722
735 for (i=0; i<7; i++) // send waveform
723 for (i=0; i<7; i++) // send waveform
736 {
724 {
737 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
725 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
738 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
726 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
739 // BUILD THE DATA
727 // BUILD THE DATA
740 if (i==6) {
728 if (i==6) {
741 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
729 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
742 }
730 }
743 else {
731 else {
744 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
732 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
745 }
733 }
746 // SET PACKET SEQUENCE COUNTER
734 // SET PACKET SEQUENCE COUNTER
747 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
735 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
748 // SET PACKET TIME
736 // SET PACKET TIME
749 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
737 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
750 //
738 //
751 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
739 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
752 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
740 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
753 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
741 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
754 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
742 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
755 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
743 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
756 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
744 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
757 // SEND PACKET
745 // SEND PACKET
758 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
746 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
759 if (status != RTEMS_SUCCESSFUL) {
747 if (status != RTEMS_SUCCESSFUL) {
760 printf("%d-%d, ERR %d\n", sid, i, (int) status);
748 printf("%d-%d, ERR %d\n", sid, i, (int) status);
761 ret = LFR_DEFAULT;
749 ret = LFR_DEFAULT;
762 }
750 }
763 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
751 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
764 }
752 }
765
753
766 return ret;
754 return ret;
767 }
755 }
768
756
769 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
757 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
770 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
758 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
771 {
759 {
772 /** This function sends CWF CCSDS packets (F2, F1 or F0).
760 /** This function sends CWF CCSDS packets (F2, F1 or F0).
773 *
761 *
774 * @param waveform points to the buffer containing the data that will be send.
762 * @param waveform points to the buffer containing the data that will be send.
775 * @param sid is the source identifier of the data that will be sent.
763 * @param sid is the source identifier of the data that will be sent.
776 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
764 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
777 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
765 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
778 * contain information to setup the transmission of the data packets.
766 * contain information to setup the transmission of the data packets.
779 *
767 *
780 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
768 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
781 *
769 *
782 */
770 */
783
771
784 unsigned int i;
772 unsigned int i;
785 int ret;
773 int ret;
786 unsigned int coarseTime;
774 unsigned int coarseTime;
787 unsigned int fineTime;
775 unsigned int fineTime;
788 rtems_status_code status;
776 rtems_status_code status;
789 spw_ioctl_pkt_send spw_ioctl_send_CWF;
777 spw_ioctl_pkt_send spw_ioctl_send_CWF;
790
778
791 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
779 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
792 spw_ioctl_send_CWF.options = 0;
780 spw_ioctl_send_CWF.options = 0;
793
781
794 ret = LFR_DEFAULT;
782 ret = LFR_DEFAULT;
795
783
796 coarseTime = waveform[0];
784 coarseTime = waveform[0];
797 fineTime = waveform[1];
785 fineTime = waveform[1];
798
786
799 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
787 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
800 {
788 {
801 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
789 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET];
802 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
790 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
803 // BUILD THE DATA
791 // BUILD THE DATA
804 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
792 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
805 // SET PACKET SEQUENCE COUNTER
793 // SET PACKET SEQUENCE COUNTER
806 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
794 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
807 // SET PACKET TIME
795 // SET PACKET TIME
808 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
796 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
809 //
797 //
810 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
798 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
811 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
799 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
812 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
800 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
813 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
801 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
814 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
802 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
815 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
803 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
816 // SEND PACKET
804 // SEND PACKET
817 if (sid == SID_NORM_CWF_LONG_F3)
805 if (sid == SID_NORM_CWF_LONG_F3)
818 {
806 {
819 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
807 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
820 if (status != RTEMS_SUCCESSFUL) {
808 if (status != RTEMS_SUCCESSFUL) {
821 printf("%d-%d, ERR %d\n", sid, i, (int) status);
809 printf("%d-%d, ERR %d\n", sid, i, (int) status);
822 ret = LFR_DEFAULT;
810 ret = LFR_DEFAULT;
823 }
811 }
824 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
812 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
825 }
813 }
826 else
814 else
827 {
815 {
828 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
816 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
829 if (status != RTEMS_SUCCESSFUL) {
817 if (status != RTEMS_SUCCESSFUL) {
830 printf("%d-%d, ERR %d\n", sid, i, (int) status);
818 printf("%d-%d, ERR %d\n", sid, i, (int) status);
831 ret = LFR_DEFAULT;
819 ret = LFR_DEFAULT;
832 }
820 }
833 }
821 }
834 }
822 }
835
823
836 return ret;
824 return ret;
837 }
825 }
838
826
839 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
827 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
840 {
828 {
841 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
829 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
842 *
830 *
843 * @param waveform points to the buffer containing the data that will be send.
831 * @param waveform points to the buffer containing the data that will be send.
844 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
832 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
845 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
833 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
846 * contain information to setup the transmission of the data packets.
834 * contain information to setup the transmission of the data packets.
847 *
835 *
848 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
836 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
849 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
837 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
850 *
838 *
851 */
839 */
852
840
853 unsigned int i;
841 unsigned int i;
854 int ret;
842 int ret;
855 unsigned int coarseTime;
843 unsigned int coarseTime;
856 unsigned int fineTime;
844 unsigned int fineTime;
857 rtems_status_code status;
845 rtems_status_code status;
858 spw_ioctl_pkt_send spw_ioctl_send_CWF;
846 spw_ioctl_pkt_send spw_ioctl_send_CWF;
859 char *sample;
847 char *sample;
860
848
861 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
849 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
862 spw_ioctl_send_CWF.options = 0;
850 spw_ioctl_send_CWF.options = 0;
863
851
864 ret = LFR_DEFAULT;
852 ret = LFR_DEFAULT;
865
853
866 //**********************
854 //**********************
867 // BUILD CWF3_light DATA
855 // BUILD CWF3_light DATA
868 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
856 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
869 {
857 {
870 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
858 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
859 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ];
872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
860 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ];
873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
861 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ];
874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
862 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ];
875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
863 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ];
876 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
864 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ];
877 }
865 }
878
866
879 coarseTime = waveform[0];
867 coarseTime = waveform[0];
880 fineTime = waveform[1];
868 fineTime = waveform[1];
881
869
882 //*********************
870 //*********************
883 // SEND CWF3_light DATA
871 // SEND CWF3_light DATA
884 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
872 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
885 {
873 {
886 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
874 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES];
887 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
875 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
888 // BUILD THE DATA
876 // BUILD THE DATA
889 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
877 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
890 // SET PACKET SEQUENCE COUNTER
878 // SET PACKET SEQUENCE COUNTER
891 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
879 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
892 // SET PACKET TIME
880 // SET PACKET TIME
893 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
881 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
894 //
882 //
895 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
883 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
896 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
884 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
897 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
885 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
898 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
886 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
899 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
887 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
900 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
888 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
901 // SEND PACKET
889 // SEND PACKET
902 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
890 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
903 if (status != RTEMS_SUCCESSFUL) {
891 if (status != RTEMS_SUCCESSFUL) {
904 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
892 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
905 ret = LFR_DEFAULT;
893 ret = LFR_DEFAULT;
906 }
894 }
907 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
895 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
908 }
896 }
909
897
910 return ret;
898 return ret;
911 }
899 }
912
900
913 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
901 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
914 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
902 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
915 {
903 {
916 unsigned long long int acquisitionTimeAsLong;
904 unsigned long long int acquisitionTimeAsLong;
917 unsigned char localAcquisitionTime[6];
905 unsigned char localAcquisitionTime[6];
918 double deltaT;
906 double deltaT;
919
907
920 deltaT = 0.;
908 deltaT = 0.;
921
909
922 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
910 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 );
923 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
911 localAcquisitionTime[1] = (unsigned char) ( coarseTime );
924 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
912 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 );
925 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
913 localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 );
926 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
914 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 );
927 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
915 localAcquisitionTime[5] = (unsigned char) ( fineTime >> 16 );
928
916
929 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
917 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
930 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
918 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
931 + ( localAcquisitionTime[2] << 24 )
919 + ( localAcquisitionTime[2] << 24 )
932 + ( localAcquisitionTime[3] << 16 )
920 + ( localAcquisitionTime[3] << 16 )
933 + ( localAcquisitionTime[4] << 8 )
921 + ( localAcquisitionTime[4] << 8 )
934 + ( localAcquisitionTime[5] );
922 + ( localAcquisitionTime[5] );
935
923
936 switch( sid )
924 switch( sid )
937 {
925 {
938 case SID_NORM_SWF_F0:
926 case SID_NORM_SWF_F0:
939 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
927 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
940 break;
928 break;
941
929
942 case SID_NORM_SWF_F1:
930 case SID_NORM_SWF_F1:
943 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
931 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
944 break;
932 break;
945
933
946 case SID_NORM_SWF_F2:
934 case SID_NORM_SWF_F2:
947 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
935 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
948 break;
936 break;
949
937
950 case SID_SBM1_CWF_F1:
938 case SID_SBM1_CWF_F1:
951 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
939 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
952 break;
940 break;
953
941
954 case SID_SBM2_CWF_F2:
942 case SID_SBM2_CWF_F2:
955 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
943 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
956 break;
944 break;
957
945
958 case SID_BURST_CWF_F2:
946 case SID_BURST_CWF_F2:
959 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
947 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
960 break;
948 break;
961
949
962 case SID_NORM_CWF_F3:
950 case SID_NORM_CWF_F3:
963 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
951 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
964 break;
952 break;
965
953
966 case SID_NORM_CWF_LONG_F3:
954 case SID_NORM_CWF_LONG_F3:
967 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
955 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
968 break;
956 break;
969
957
970 default:
958 default:
971 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
959 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
972 deltaT = 0.;
960 deltaT = 0.;
973 break;
961 break;
974 }
962 }
975
963
976 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
964 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
977 //
965 //
978 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
966 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
979 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
967 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
980 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
968 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
981 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
969 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
982 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
970 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
983 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
971 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
984
972
985 }
973 }
986
974
987 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
975 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
988 {
976 {
989 unsigned int i;
977 unsigned int i;
990 unsigned long long int centerTime_asLong;
978 unsigned long long int centerTime_asLong;
991 unsigned long long int acquisitionTimeF0_asLong;
979 unsigned long long int acquisitionTimeF0_asLong;
992 unsigned long long int acquisitionTime_asLong;
980 unsigned long long int acquisitionTime_asLong;
993 unsigned long long int bufferAcquisitionTime_asLong;
981 unsigned long long int bufferAcquisitionTime_asLong;
994 unsigned char *ptr1;
982 unsigned char *ptr1;
995 unsigned char *ptr2;
983 unsigned char *ptr2;
996 unsigned char nb_ring_nodes;
984 unsigned char nb_ring_nodes;
997 unsigned long long int frequency_asLong;
985 unsigned long long int frequency_asLong;
998 unsigned long long int nbTicksPerSample_asLong;
986 unsigned long long int nbTicksPerSample_asLong;
999 unsigned long long int nbSamplesPart1_asLong;
987 unsigned long long int nbSamplesPart1_asLong;
1000 unsigned long long int sampleOffset_asLong;
988 unsigned long long int sampleOffset_asLong;
1001
989
1002 unsigned int deltaT_F0;
990 unsigned int deltaT_F0;
1003 unsigned int deltaT_F1;
991 unsigned int deltaT_F1;
1004 unsigned long long int deltaT_F2;
992 unsigned long long int deltaT_F2;
1005
993
1006 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
994 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1007 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
995 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1008 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
996 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1009 sampleOffset_asLong = 0x00;
997 sampleOffset_asLong = 0x00;
1010
998
1011 // (1) get the f0 acquisition time
999 // (1) get the f0 acquisition time
1012 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1000 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1013
1001
1014 // (2) compute the central reference time
1002 // (2) compute the central reference time
1015 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1003 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1016
1004
1017 // (3) compute the acquisition time of the current snapshot
1005 // (3) compute the acquisition time of the current snapshot
1018 switch(frequencyChannel)
1006 switch(frequencyChannel)
1019 {
1007 {
1020 case 1: // 1 is for F1 = 4096 Hz
1008 case 1: // 1 is for F1 = 4096 Hz
1021 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1009 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1022 nb_ring_nodes = NB_RING_NODES_F1;
1010 nb_ring_nodes = NB_RING_NODES_F1;
1023 frequency_asLong = 4096;
1011 frequency_asLong = 4096;
1024 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1012 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1025 break;
1013 break;
1026 case 2: // 2 is for F2 = 256 Hz
1014 case 2: // 2 is for F2 = 256 Hz
1027 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1015 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1028 nb_ring_nodes = NB_RING_NODES_F2;
1016 nb_ring_nodes = NB_RING_NODES_F2;
1029 frequency_asLong = 256;
1017 frequency_asLong = 256;
1030 nbTicksPerSample_asLong = 256; // 65536 / 256;
1018 nbTicksPerSample_asLong = 256; // 65536 / 256;
1031 break;
1019 break;
1032 default:
1020 default:
1033 acquisitionTime_asLong = centerTime_asLong;
1021 acquisitionTime_asLong = centerTime_asLong;
1034 frequency_asLong = 256;
1022 frequency_asLong = 256;
1035 nbTicksPerSample_asLong = 256;
1023 nbTicksPerSample_asLong = 256;
1036 break;
1024 break;
1037 }
1025 }
1038
1026
1039 //****************************************************************************
1027 //****************************************************************************
1040 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1028 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1041 for (i=0; i<nb_ring_nodes; i++)
1029 for (i=0; i<nb_ring_nodes; i++)
1042 {
1030 {
1043 PRINTF1("%d ... ", i)
1031 PRINTF1("%d ... ", i)
1044 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1032 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1045 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1033 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1046 {
1034 {
1047 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1035 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1048 break;
1036 break;
1049 }
1037 }
1050 ring_node_to_send = ring_node_to_send->previous;
1038 ring_node_to_send = ring_node_to_send->previous;
1051 }
1039 }
1052
1040
1053 // (5) compute the number of samples to take in the current buffer
1041 // (5) compute the number of samples to take in the current buffer
1054 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1042 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1055 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1043 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1056 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1044 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1057
1045
1058 // (6) compute the final acquisition time
1046 // (6) compute the final acquisition time
1059 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1047 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1060 sampleOffset_asLong * nbTicksPerSample_asLong;
1048 sampleOffset_asLong * nbTicksPerSample_asLong;
1061
1049
1062 // (7) copy the acquisition time at the beginning of the extrated snapshot
1050 // (7) copy the acquisition time at the beginning of the extrated snapshot
1063 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1051 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1064 ptr2 = (unsigned char*) wf_snap_extracted;
1052 ptr2 = (unsigned char*) wf_snap_extracted;
1065 ptr2[0] = ptr1[ 2 + 2 ];
1053 ptr2[0] = ptr1[ 2 + 2 ];
1066 ptr2[1] = ptr1[ 3 + 2 ];
1054 ptr2[1] = ptr1[ 3 + 2 ];
1067 ptr2[2] = ptr1[ 0 + 2 ];
1055 ptr2[2] = ptr1[ 0 + 2 ];
1068 ptr2[3] = ptr1[ 1 + 2 ];
1056 ptr2[3] = ptr1[ 1 + 2 ];
1069 ptr2[4] = ptr1[ 4 + 2 ];
1057 ptr2[4] = ptr1[ 4 + 2 ];
1070 ptr2[5] = ptr1[ 5 + 2 ];
1058 ptr2[5] = ptr1[ 5 + 2 ];
1071
1059
1072 // re set the synchronization bit
1060 // re set the synchronization bit
1073
1061
1074
1062
1075 // copy the part 1 of the snapshot in the extracted buffer
1063 // copy the part 1 of the snapshot in the extracted buffer
1076 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1064 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1077 {
1065 {
1078 wf_snap_extracted[i + TIME_OFFSET] =
1066 wf_snap_extracted[i + TIME_OFFSET] =
1079 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1067 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1080 }
1068 }
1081 // copy the part 2 of the snapshot in the extracted buffer
1069 // copy the part 2 of the snapshot in the extracted buffer
1082 ring_node_to_send = ring_node_to_send->next;
1070 ring_node_to_send = ring_node_to_send->next;
1083 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1071 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1084 {
1072 {
1085 wf_snap_extracted[i + TIME_OFFSET] =
1073 wf_snap_extracted[i + TIME_OFFSET] =
1086 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1074 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
1087 }
1075 }
1088 }
1076 }
1089
1077
1090 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1078 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1091 {
1079 {
1092 unsigned char *acquisitionTimeCharPtr;
1080 unsigned char *acquisitionTimeCharPtr;
1093
1081
1094 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1082 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1095
1083
1096 *acquisitionTimeAslong = 0x00;
1084 *acquisitionTimeAslong = 0x00;
1097 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1085 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1098 + ( acquisitionTimeCharPtr[1] << 16 )
1086 + ( acquisitionTimeCharPtr[1] << 16 )
1099 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1087 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1100 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1088 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1101 + ( acquisitionTimeCharPtr[4] << 8 )
1089 + ( acquisitionTimeCharPtr[4] << 8 )
1102 + ( acquisitionTimeCharPtr[5] );
1090 + ( acquisitionTimeCharPtr[5] );
1103 }
1091 }
1104
1092
1105 //**************
1093 //**************
1106 // wfp registers
1094 // wfp registers
1107 void reset_wfp_burst_enable(void)
1095 void reset_wfp_burst_enable(void)
1108 {
1096 {
1109 /** This function resets the waveform picker burst_enable register.
1097 /** This function resets the waveform picker burst_enable register.
1110 *
1098 *
1111 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1099 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1112 *
1100 *
1113 */
1101 */
1114
1102
1115 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1103 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1116 }
1104 }
1117
1105
1118 void reset_wfp_status( void )
1106 void reset_wfp_status( void )
1119 {
1107 {
1120 /** This function resets the waveform picker status register.
1108 /** This function resets the waveform picker status register.
1121 *
1109 *
1122 * All status bits are set to 0 [new_err full_err full].
1110 * All status bits are set to 0 [new_err full_err full].
1123 *
1111 *
1124 */
1112 */
1125
1113
1126 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1114 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1127 }
1115 }
1128
1116
1129 void reset_waveform_picker_regs(void)
1117 void reset_waveform_picker_regs(void)
1130 {
1118 {
1131 /** This function resets the waveform picker module registers.
1119 /** This function resets the waveform picker module registers.
1132 *
1120 *
1133 * The registers affected by this function are located at the following offset addresses:
1121 * The registers affected by this function are located at the following offset addresses:
1134 * - 0x00 data_shaping
1122 * - 0x00 data_shaping
1135 * - 0x04 run_burst_enable
1123 * - 0x04 run_burst_enable
1136 * - 0x08 addr_data_f0
1124 * - 0x08 addr_data_f0
1137 * - 0x0C addr_data_f1
1125 * - 0x0C addr_data_f1
1138 * - 0x10 addr_data_f2
1126 * - 0x10 addr_data_f2
1139 * - 0x14 addr_data_f3
1127 * - 0x14 addr_data_f3
1140 * - 0x18 status
1128 * - 0x18 status
1141 * - 0x1C delta_snapshot
1129 * - 0x1C delta_snapshot
1142 * - 0x20 delta_f0
1130 * - 0x20 delta_f0
1143 * - 0x24 delta_f0_2
1131 * - 0x24 delta_f0_2
1144 * - 0x28 delta_f1
1132 * - 0x28 delta_f1
1145 * - 0x2c delta_f2
1133 * - 0x2c delta_f2
1146 * - 0x30 nb_data_by_buffer
1134 * - 0x30 nb_data_by_buffer
1147 * - 0x34 nb_snapshot_param
1135 * - 0x34 nb_snapshot_param
1148 * - 0x38 start_date
1136 * - 0x38 start_date
1149 * - 0x3c nb_word_in_buffer
1137 * - 0x3c nb_word_in_buffer
1150 *
1138 *
1151 */
1139 */
1152
1140
1153 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1141 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1154 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1142 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1155 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1143 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1156 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1144 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1157 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1145 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1158 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1146 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1159 reset_wfp_status(); // 0x18
1147 reset_wfp_status(); // 0x18
1160 //
1148 //
1161 set_wfp_delta_snapshot(); // 0x1c
1149 set_wfp_delta_snapshot(); // 0x1c
1162 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1150 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1163 set_wfp_delta_f1(); // 0x28
1151 set_wfp_delta_f1(); // 0x28
1164 set_wfp_delta_f2(); // 0x2c
1152 set_wfp_delta_f2(); // 0x2c
1165 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1153 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1166 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1154 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1167 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1155 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1168 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1156 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1169 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1157 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1170 // 2688 = 8 * 336
1158 // 2688 = 8 * 336
1171 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1159 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1172 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1160 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1173 waveform_picker_regs->start_date = 0x00; // 0x38
1161 waveform_picker_regs->start_date = 0x00; // 0x38
1174 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1162 waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066
1175 }
1163 }
1176
1164
1177 void set_wfp_data_shaping( void )
1165 void set_wfp_data_shaping( void )
1178 {
1166 {
1179 /** This function sets the data_shaping register of the waveform picker module.
1167 /** This function sets the data_shaping register of the waveform picker module.
1180 *
1168 *
1181 * The value is read from one field of the parameter_dump_packet structure:\n
1169 * The value is read from one field of the parameter_dump_packet structure:\n
1182 * bw_sp0_sp1_r0_r1
1170 * bw_sp0_sp1_r0_r1
1183 *
1171 *
1184 */
1172 */
1185
1173
1186 unsigned char data_shaping;
1174 unsigned char data_shaping;
1187
1175
1188 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1176 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1189 // waveform picker : [R1 R0 SP1 SP0 BW]
1177 // waveform picker : [R1 R0 SP1 SP0 BW]
1190
1178
1191 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1179 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1192
1180
1193 waveform_picker_regs->data_shaping =
1181 waveform_picker_regs->data_shaping =
1194 ( (data_shaping & 0x10) >> 4 ) // BW
1182 ( (data_shaping & 0x10) >> 4 ) // BW
1195 + ( (data_shaping & 0x08) >> 2 ) // SP0
1183 + ( (data_shaping & 0x08) >> 2 ) // SP0
1196 + ( (data_shaping & 0x04) ) // SP1
1184 + ( (data_shaping & 0x04) ) // SP1
1197 + ( (data_shaping & 0x02) << 2 ) // R0
1185 + ( (data_shaping & 0x02) << 2 ) // R0
1198 + ( (data_shaping & 0x01) << 4 ); // R1
1186 + ( (data_shaping & 0x01) << 4 ); // R1
1199 }
1187 }
1200
1188
1201 void set_wfp_burst_enable_register( unsigned char mode )
1189 void set_wfp_burst_enable_register( unsigned char mode )
1202 {
1190 {
1203 /** This function sets the waveform picker burst_enable register depending on the mode.
1191 /** This function sets the waveform picker burst_enable register depending on the mode.
1204 *
1192 *
1205 * @param mode is the LFR mode to launch.
1193 * @param mode is the LFR mode to launch.
1206 *
1194 *
1207 * The burst bits shall be before the enable bits.
1195 * The burst bits shall be before the enable bits.
1208 *
1196 *
1209 */
1197 */
1210
1198
1211 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1199 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1212 // the burst bits shall be set first, before the enable bits
1200 // the burst bits shall be set first, before the enable bits
1213 switch(mode) {
1201 switch(mode) {
1214 case(LFR_MODE_NORMAL):
1202 case(LFR_MODE_NORMAL):
1215 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1203 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1216 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1204 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1217 break;
1205 break;
1218 case(LFR_MODE_BURST):
1206 case(LFR_MODE_BURST):
1219 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1207 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1220 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1208 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1221 break;
1209 break;
1222 case(LFR_MODE_SBM1):
1210 case(LFR_MODE_SBM1):
1223 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1211 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1224 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1212 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1225 break;
1213 break;
1226 case(LFR_MODE_SBM2):
1214 case(LFR_MODE_SBM2):
1227 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1215 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1228 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1216 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1229 break;
1217 break;
1230 default:
1218 default:
1231 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1219 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1232 break;
1220 break;
1233 }
1221 }
1234 }
1222 }
1235
1223
1236 void set_wfp_delta_snapshot( void )
1224 void set_wfp_delta_snapshot( void )
1237 {
1225 {
1238 /** This function sets the delta_snapshot register of the waveform picker module.
1226 /** This function sets the delta_snapshot register of the waveform picker module.
1239 *
1227 *
1240 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1228 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1241 * - sy_lfr_n_swf_p[0]
1229 * - sy_lfr_n_swf_p[0]
1242 * - sy_lfr_n_swf_p[1]
1230 * - sy_lfr_n_swf_p[1]
1243 *
1231 *
1244 */
1232 */
1245
1233
1246 unsigned int delta_snapshot;
1234 unsigned int delta_snapshot;
1247 unsigned int delta_snapshot_in_T2;
1235 unsigned int delta_snapshot_in_T2;
1248
1236
1249 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1237 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1250 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1238 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1251
1239
1252 delta_snapshot_in_T2 = delta_snapshot * 256;
1240 delta_snapshot_in_T2 = delta_snapshot * 256;
1253 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1241 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2; // max 4 bytes
1254 }
1242 }
1255
1243
1256 void set_wfp_delta_f0_f0_2( void )
1244 void set_wfp_delta_f0_f0_2( void )
1257 {
1245 {
1258 unsigned int delta_snapshot;
1246 unsigned int delta_snapshot;
1259 unsigned int nb_samples_per_snapshot;
1247 unsigned int nb_samples_per_snapshot;
1260 float delta_f0_in_float;
1248 float delta_f0_in_float;
1261
1249
1262 delta_snapshot = waveform_picker_regs->delta_snapshot;
1250 delta_snapshot = waveform_picker_regs->delta_snapshot;
1263 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1251 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1264 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1252 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1265
1253
1266 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1254 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1267 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1255 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1268 }
1256 }
1269
1257
1270 void set_wfp_delta_f1( void )
1258 void set_wfp_delta_f1( void )
1271 {
1259 {
1272 unsigned int delta_snapshot;
1260 unsigned int delta_snapshot;
1273 unsigned int nb_samples_per_snapshot;
1261 unsigned int nb_samples_per_snapshot;
1274 float delta_f1_in_float;
1262 float delta_f1_in_float;
1275
1263
1276 delta_snapshot = waveform_picker_regs->delta_snapshot;
1264 delta_snapshot = waveform_picker_regs->delta_snapshot;
1277 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1265 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1278 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1266 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1279
1267
1280 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1268 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1281 }
1269 }
1282
1270
1283 void set_wfp_delta_f2()
1271 void set_wfp_delta_f2()
1284 {
1272 {
1285 unsigned int delta_snapshot;
1273 unsigned int delta_snapshot;
1286 unsigned int nb_samples_per_snapshot;
1274 unsigned int nb_samples_per_snapshot;
1287
1275
1288 delta_snapshot = waveform_picker_regs->delta_snapshot;
1276 delta_snapshot = waveform_picker_regs->delta_snapshot;
1289 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1277 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1290
1278
1291 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1279 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1292 }
1280 }
1293
1281
1294 //*****************
1282 //*****************
1295 // local parameters
1283 // local parameters
1296 void set_local_nb_interrupt_f0_MAX( void )
1284 void set_local_nb_interrupt_f0_MAX( void )
1297 {
1285 {
1298 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1286 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1299 *
1287 *
1300 * This parameter is used for the SM validation only.\n
1288 * This parameter is used for the SM validation only.\n
1301 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1289 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1302 * module before launching a basic processing.
1290 * module before launching a basic processing.
1303 *
1291 *
1304 */
1292 */
1305
1293
1306 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1294 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1307 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1295 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1308 }
1296 }
1309
1297
1310 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1298 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1311 {
1299 {
1312 unsigned short *sequence_cnt;
1300 unsigned short *sequence_cnt;
1313 unsigned short segmentation_grouping_flag;
1301 unsigned short segmentation_grouping_flag;
1314 unsigned short new_packet_sequence_control;
1302 unsigned short new_packet_sequence_control;
1315
1303
1316 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1304 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1317 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1305 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1318 {
1306 {
1319 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1307 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1320 }
1308 }
1321 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1309 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1322 {
1310 {
1323 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1311 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1324 }
1312 }
1325 else
1313 else
1326 {
1314 {
1327 sequence_cnt = NULL;
1315 sequence_cnt = NULL;
1328 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1316 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1329 }
1317 }
1330
1318
1331 if (sequence_cnt != NULL)
1319 if (sequence_cnt != NULL)
1332 {
1320 {
1333 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1321 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1334 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1322 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1335
1323
1336 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1324 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1337
1325
1338 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1326 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1339 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1327 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1340
1328
1341 // increment the sequence counter for the next packet
1329 // increment the sequence counter for the next packet
1342 if ( *sequence_cnt < SEQ_CNT_MAX)
1330 if ( *sequence_cnt < SEQ_CNT_MAX)
1343 {
1331 {
1344 *sequence_cnt = *sequence_cnt + 1;
1332 *sequence_cnt = *sequence_cnt + 1;
1345 }
1333 }
1346 else
1334 else
1347 {
1335 {
1348 *sequence_cnt = 0;
1336 *sequence_cnt = 0;
1349 }
1337 }
1350 }
1338 }
1351 }
1339 }
General Comments 0
You need to be logged in to leave comments. Login now