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