##// END OF EJS Templates
New version of the waveform picker packet transmission...
paul -
r172:ddd72945217c VHDL_0_1_28
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: Thu Nov 6 16:03:39 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Nov 13 07:59:00 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=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DLPP_DPU_DESTID -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
13 DEFINES = -DSW_VERSION_N1=2 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=1 -DLPP_DPU_DESTID -DPRINT_MESSAGES_ON_CONSOLE
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
20 AR = sparc-rtems-ar rcs
20 AR = sparc-rtems-ar rcs
21 RANLIB =
21 RANLIB =
22 QMAKE = /usr/bin/qmake-qt4
22 QMAKE = /usr/bin/qmake-qt4
23 TAR = tar -cf
23 TAR = tar -cf
24 COMPRESS = gzip -9f
24 COMPRESS = gzip -9f
25 COPY = cp -f
25 COPY = cp -f
26 SED = sed
26 SED = sed
27 COPY_FILE = $(COPY)
27 COPY_FILE = $(COPY)
28 COPY_DIR = $(COPY) -r
28 COPY_DIR = $(COPY) -r
29 STRIP = sparc-rtems-strip
29 STRIP = sparc-rtems-strip
30 INSTALL_FILE = install -m 644 -p
30 INSTALL_FILE = install -m 644 -p
31 INSTALL_DIR = $(COPY_DIR)
31 INSTALL_DIR = $(COPY_DIR)
32 INSTALL_PROGRAM = install -m 755 -p
32 INSTALL_PROGRAM = install -m 755 -p
33 DEL_FILE = rm -f
33 DEL_FILE = rm -f
34 SYMLINK = ln -f -s
34 SYMLINK = ln -f -s
35 DEL_DIR = rmdir
35 DEL_DIR = rmdir
36 MOVE = mv -f
36 MOVE = mv -f
37 CHK_DIR_EXISTS= test -d
37 CHK_DIR_EXISTS= test -d
38 MKDIR = mkdir -p
38 MKDIR = mkdir -p
39
39
40 ####### Output directory
40 ####### Output directory
41
41
42 OBJECTS_DIR = obj/
42 OBJECTS_DIR = obj/
43
43
44 ####### Files
44 ####### Files
45
45
46 SOURCES = ../src/wf_handler.c \
46 SOURCES = ../src/wf_handler.c \
47 ../src/tc_handler.c \
47 ../src/tc_handler.c \
48 ../src/fsw_misc.c \
48 ../src/fsw_misc.c \
49 ../src/fsw_init.c \
49 ../src/fsw_init.c \
50 ../src/fsw_globals.c \
50 ../src/fsw_globals.c \
51 ../src/fsw_spacewire.c \
51 ../src/fsw_spacewire.c \
52 ../src/tc_load_dump_parameters.c \
52 ../src/tc_load_dump_parameters.c \
53 ../src/tm_lfr_tc_exe.c \
53 ../src/tm_lfr_tc_exe.c \
54 ../src/tc_acceptance.c \
54 ../src/tc_acceptance.c \
55 ../src/processing/fsw_processing.c \
55 ../src/processing/fsw_processing.c \
56 ../src/processing/avf0_prc0.c \
56 ../src/processing/avf0_prc0.c \
57 ../src/processing/avf1_prc1.c \
57 ../src/processing/avf1_prc1.c \
58 ../src/processing/avf2_prc2.c \
58 ../src/processing/avf2_prc2.c \
59 ../src/lfr_cpu_usage_report.c \
59 ../src/lfr_cpu_usage_report.c \
60 ../src/LFR_basic-parameters/basic_parameters.c
60 ../src/LFR_basic-parameters/basic_parameters.c
61 OBJECTS = obj/wf_handler.o \
61 OBJECTS = obj/wf_handler.o \
62 obj/tc_handler.o \
62 obj/tc_handler.o \
63 obj/fsw_misc.o \
63 obj/fsw_misc.o \
64 obj/fsw_init.o \
64 obj/fsw_init.o \
65 obj/fsw_globals.o \
65 obj/fsw_globals.o \
66 obj/fsw_spacewire.o \
66 obj/fsw_spacewire.o \
67 obj/tc_load_dump_parameters.o \
67 obj/tc_load_dump_parameters.o \
68 obj/tm_lfr_tc_exe.o \
68 obj/tm_lfr_tc_exe.o \
69 obj/tc_acceptance.o \
69 obj/tc_acceptance.o \
70 obj/fsw_processing.o \
70 obj/fsw_processing.o \
71 obj/avf0_prc0.o \
71 obj/avf0_prc0.o \
72 obj/avf1_prc1.o \
72 obj/avf1_prc1.o \
73 obj/avf2_prc2.o \
73 obj/avf2_prc2.o \
74 obj/lfr_cpu_usage_report.o \
74 obj/lfr_cpu_usage_report.o \
75 obj/basic_parameters.o
75 obj/basic_parameters.o
76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 /usr/lib64/qt4/mkspecs/common/linux.conf \
77 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 /usr/lib64/qt4/mkspecs/qconfig.pri \
82 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 sparc.pri \
88 sparc.pri \
89 /usr/lib64/qt4/mkspecs/features/release.prf \
89 /usr/lib64/qt4/mkspecs/features/release.prf \
90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 /usr/lib64/qt4/mkspecs/features/shared.prf \
91 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 /usr/lib64/qt4/mkspecs/features/resources.prf \
94 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 /usr/lib64/qt4/mkspecs/features/uic.prf \
95 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 /usr/lib64/qt4/mkspecs/features/lex.prf \
97 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 fsw-qt.pro
99 fsw-qt.pro
100 QMAKE_TARGET = fsw
100 QMAKE_TARGET = fsw
101 DESTDIR = bin/
101 DESTDIR = bin/
102 TARGET = bin/fsw
102 TARGET = bin/fsw
103
103
104 first: all
104 first: all
105 ####### Implicit rules
105 ####### Implicit rules
106
106
107 .SUFFIXES: .o .c .cpp .cc .cxx .C
107 .SUFFIXES: .o .c .cpp .cc .cxx .C
108
108
109 .cpp.o:
109 .cpp.o:
110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111
111
112 .cc.o:
112 .cc.o:
113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114
114
115 .cxx.o:
115 .cxx.o:
116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117
117
118 .C.o:
118 .C.o:
119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120
120
121 .c.o:
121 .c.o:
122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123
123
124 ####### Build rules
124 ####### Build rules
125
125
126 all: Makefile $(TARGET)
126 all: Makefile $(TARGET)
127
127
128 $(TARGET): $(OBJECTS)
128 $(TARGET): $(OBJECTS)
129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131
131
132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 /usr/lib64/qt4/mkspecs/common/linux.conf \
133 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 /usr/lib64/qt4/mkspecs/qconfig.pri \
138 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 sparc.pri \
144 sparc.pri \
145 /usr/lib64/qt4/mkspecs/features/release.prf \
145 /usr/lib64/qt4/mkspecs/features/release.prf \
146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 /usr/lib64/qt4/mkspecs/features/shared.prf \
147 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 /usr/lib64/qt4/mkspecs/features/resources.prf \
150 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 /usr/lib64/qt4/mkspecs/features/uic.prf \
151 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 /usr/lib64/qt4/mkspecs/features/lex.prf \
153 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 /usr/lib64/qt4/mkspecs/common/unix.conf:
156 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 /usr/lib64/qt4/mkspecs/common/linux.conf:
157 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 /usr/lib64/qt4/mkspecs/qconfig.pri:
162 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 sparc.pri:
168 sparc.pri:
169 /usr/lib64/qt4/mkspecs/features/release.prf:
169 /usr/lib64/qt4/mkspecs/features/release.prf:
170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 /usr/lib64/qt4/mkspecs/features/shared.prf:
171 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 /usr/lib64/qt4/mkspecs/features/resources.prf:
174 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 /usr/lib64/qt4/mkspecs/features/uic.prf:
175 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 /usr/lib64/qt4/mkspecs/features/lex.prf:
177 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 qmake: FORCE
179 qmake: FORCE
180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181
181
182 dist:
182 dist:
183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
185
185
186
186
187 clean:compiler_clean
187 clean:compiler_clean
188 -$(DEL_FILE) $(OBJECTS)
188 -$(DEL_FILE) $(OBJECTS)
189 -$(DEL_FILE) *~ core *.core
189 -$(DEL_FILE) *~ core *.core
190
190
191
191
192 ####### Sub-libraries
192 ####### Sub-libraries
193
193
194 distclean: clean
194 distclean: clean
195 -$(DEL_FILE) $(TARGET)
195 -$(DEL_FILE) $(TARGET)
196 -$(DEL_FILE) Makefile
196 -$(DEL_FILE) Makefile
197
197
198
198
199 grmon:
199 grmon:
200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201
201
202 check: first
202 check: first
203
203
204 compiler_rcc_make_all:
204 compiler_rcc_make_all:
205 compiler_rcc_clean:
205 compiler_rcc_clean:
206 compiler_uic_make_all:
206 compiler_uic_make_all:
207 compiler_uic_clean:
207 compiler_uic_clean:
208 compiler_image_collection_make_all: qmake_image_collection.cpp
208 compiler_image_collection_make_all: qmake_image_collection.cpp
209 compiler_image_collection_clean:
209 compiler_image_collection_clean:
210 -$(DEL_FILE) qmake_image_collection.cpp
210 -$(DEL_FILE) qmake_image_collection.cpp
211 compiler_yacc_decl_make_all:
211 compiler_yacc_decl_make_all:
212 compiler_yacc_decl_clean:
212 compiler_yacc_decl_clean:
213 compiler_yacc_impl_make_all:
213 compiler_yacc_impl_make_all:
214 compiler_yacc_impl_clean:
214 compiler_yacc_impl_clean:
215 compiler_lex_make_all:
215 compiler_lex_make_all:
216 compiler_lex_clean:
216 compiler_lex_clean:
217 compiler_clean:
217 compiler_clean:
218
218
219 ####### Compile
219 ####### Compile
220
220
221 obj/wf_handler.o: ../src/wf_handler.c
221 obj/wf_handler.o: ../src/wf_handler.c
222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223
223
224 obj/tc_handler.o: ../src/tc_handler.c
224 obj/tc_handler.o: ../src/tc_handler.c
225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226
226
227 obj/fsw_misc.o: ../src/fsw_misc.c
227 obj/fsw_misc.o: ../src/fsw_misc.c
228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229
229
230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232
232
233 obj/fsw_globals.o: ../src/fsw_globals.c
233 obj/fsw_globals.o: ../src/fsw_globals.c
234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235
235
236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238
238
239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241
241
242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244
244
245 obj/tc_acceptance.o: ../src/tc_acceptance.c
245 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247
247
248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250
250
251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253
253
254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256
256
257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259
259
260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262
262
263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265
265
266 ####### Install
266 ####### Install
267
267
268 install: FORCE
268 install: FORCE
269
269
270 uninstall: FORCE
270 uninstall: FORCE
271
271
272 FORCE:
272 FORCE:
273
273
@@ -1,107 +1,107
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 # lpp_dpu_destid
4 # lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
5 CONFIG += console verbose lpp_dpu_destid
6 CONFIG -= qt
6 CONFIG -= qt
7
7
8 include(./sparc.pri)
8 include(./sparc.pri)
9
9
10 # flight software version
10 # flight software version
11 SWVERSION=-1-0
11 SWVERSION=-1-0
12 DEFINES += SW_VERSION_N1=2 # major
12 DEFINES += SW_VERSION_N1=2 # major
13 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N2=0 # minor
14 DEFINES += SW_VERSION_N3=1 # patch
14 DEFINES += SW_VERSION_N3=1 # patch
15 DEFINES += SW_VERSION_N4=1 # internal
15 DEFINES += SW_VERSION_N4=1 # internal
16
16
17 # <GCOV>
17 # <GCOV>
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
20 # </GCOV>
20 # </GCOV>
21
21
22 # <CHANGE BEFORE FLIGHT>
22 # <CHANGE BEFORE FLIGHT>
23 contains( CONFIG, lpp_dpu_destid ) {
23 contains( CONFIG, lpp_dpu_destid ) {
24 DEFINES += LPP_DPU_DESTID
24 DEFINES += LPP_DPU_DESTID
25 }
25 }
26 # </CHANGE BEFORE FLIGHT>
26 # </CHANGE BEFORE FLIGHT>
27
27
28 contains( CONFIG, debug_tch ) {
28 contains( CONFIG, debug_tch ) {
29 DEFINES += DEBUG_TCH
29 DEFINES += DEBUG_TCH
30 }
30 }
31
31
32 contains( CONFIG, vhdl_dev ) {
32 contains( CONFIG, vhdl_dev ) {
33 DEFINES += VHDL_DEV
33 DEFINES += VHDL_DEV
34 }
34 }
35
35
36 contains( CONFIG, verbose ) {
36 contains( CONFIG, verbose ) {
37 DEFINES += PRINT_MESSAGES_ON_CONSOLE
37 DEFINES += PRINT_MESSAGES_ON_CONSOLE
38 }
38 }
39
39
40 contains( CONFIG, debug_messages ) {
40 contains( CONFIG, debug_messages ) {
41 DEFINES += DEBUG_MESSAGES
41 DEFINES += DEBUG_MESSAGES
42 }
42 }
43
43
44 contains( CONFIG, cpu_usage_report ) {
44 contains( CONFIG, cpu_usage_report ) {
45 DEFINES += PRINT_TASK_STATISTICS
45 DEFINES += PRINT_TASK_STATISTICS
46 }
46 }
47
47
48 contains( CONFIG, stack_report ) {
48 contains( CONFIG, stack_report ) {
49 DEFINES += PRINT_STACK_REPORT
49 DEFINES += PRINT_STACK_REPORT
50 }
50 }
51
51
52 contains( CONFIG, boot_messages ) {
52 contains( CONFIG, boot_messages ) {
53 DEFINES += BOOT_MESSAGES
53 DEFINES += BOOT_MESSAGES
54 }
54 }
55
55
56 #doxygen.target = doxygen
56 #doxygen.target = doxygen
57 #doxygen.commands = doxygen ../doc/Doxyfile
57 #doxygen.commands = doxygen ../doc/Doxyfile
58 #QMAKE_EXTRA_TARGETS += doxygen
58 #QMAKE_EXTRA_TARGETS += doxygen
59
59
60 TARGET = fsw
60 TARGET = fsw
61
61
62 INCLUDEPATH += \
62 INCLUDEPATH += \
63 ../src \
63 ../src \
64 ../header \
64 ../header \
65 ../header/processing \
65 ../header/processing \
66 ../src/LFR_basic-parameters
66 ../src/LFR_basic-parameters
67
67
68 SOURCES += \
68 SOURCES += \
69 ../src/wf_handler.c \
69 ../src/wf_handler.c \
70 ../src/tc_handler.c \
70 ../src/tc_handler.c \
71 ../src/fsw_misc.c \
71 ../src/fsw_misc.c \
72 ../src/fsw_init.c \
72 ../src/fsw_init.c \
73 ../src/fsw_globals.c \
73 ../src/fsw_globals.c \
74 ../src/fsw_spacewire.c \
74 ../src/fsw_spacewire.c \
75 ../src/tc_load_dump_parameters.c \
75 ../src/tc_load_dump_parameters.c \
76 ../src/tm_lfr_tc_exe.c \
76 ../src/tm_lfr_tc_exe.c \
77 ../src/tc_acceptance.c \
77 ../src/tc_acceptance.c \
78 ../src/processing/fsw_processing.c \
78 ../src/processing/fsw_processing.c \
79 ../src/processing/avf0_prc0.c \
79 ../src/processing/avf0_prc0.c \
80 ../src/processing/avf1_prc1.c \
80 ../src/processing/avf1_prc1.c \
81 ../src/processing/avf2_prc2.c \
81 ../src/processing/avf2_prc2.c \
82 ../src/lfr_cpu_usage_report.c \
82 ../src/lfr_cpu_usage_report.c \
83 ../src/LFR_basic-parameters/basic_parameters.c
83 ../src/LFR_basic-parameters/basic_parameters.c
84
84
85 HEADERS += \
85 HEADERS += \
86 ../header/wf_handler.h \
86 ../header/wf_handler.h \
87 ../header/tc_handler.h \
87 ../header/tc_handler.h \
88 ../header/grlib_regs.h \
88 ../header/grlib_regs.h \
89 ../header/fsw_params.h \
89 ../header/fsw_params.h \
90 ../header/fsw_misc.h \
90 ../header/fsw_misc.h \
91 ../header/fsw_init.h \
91 ../header/fsw_init.h \
92 ../header/ccsds_types.h \
92 ../header/ccsds_types.h \
93 ../header/fsw_spacewire.h \
93 ../header/fsw_spacewire.h \
94 ../header/tc_load_dump_parameters.h \
94 ../header/tc_load_dump_parameters.h \
95 ../header/tm_lfr_tc_exe.h \
95 ../header/tm_lfr_tc_exe.h \
96 ../header/tc_acceptance.h \
96 ../header/tc_acceptance.h \
97 ../header/fsw_params_nb_bytes.h \
97 ../header/fsw_params_nb_bytes.h \
98 ../header/fsw_params_processing.h \
98 ../header/fsw_params_processing.h \
99 ../header/processing/fsw_processing.h \
99 ../header/processing/fsw_processing.h \
100 ../header/processing/avf0_prc0.h \
100 ../header/processing/avf0_prc0.h \
101 ../header/processing/avf1_prc1.h \
101 ../header/processing/avf1_prc1.h \
102 ../header/processing/avf2_prc2.h \
102 ../header/processing/avf2_prc2.h \
103 ../header/fsw_params_wf_handler.h \
103 ../header/fsw_params_wf_handler.h \
104 ../header/lfr_cpu_usage_report.h \
104 ../header/lfr_cpu_usage_report.h \
105 ../src/LFR_basic-parameters/basic_parameters.h \
105 ../src/LFR_basic-parameters/basic_parameters.h \
106 ../src/LFR_basic-parameters/basic_parameters_params.h
106 ../src/LFR_basic-parameters/basic_parameters_params.h
107
107
@@ -1,208 +1,208
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.2.1, 2014-11-05T17:29:44. -->
3 <!-- Written by QtCreator 3.2.1, 2014-11-12T16:01:52. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>EnvironmentId</variable>
6 <variable>EnvironmentId</variable>
7 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
7 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
8 </data>
8 </data>
9 <data>
9 <data>
10 <variable>ProjectExplorer.Project.ActiveTarget</variable>
10 <variable>ProjectExplorer.Project.ActiveTarget</variable>
11 <value type="int">0</value>
11 <value type="int">0</value>
12 </data>
12 </data>
13 <data>
13 <data>
14 <variable>ProjectExplorer.Project.EditorSettings</variable>
14 <variable>ProjectExplorer.Project.EditorSettings</variable>
15 <valuemap type="QVariantMap">
15 <valuemap type="QVariantMap">
16 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
16 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
17 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
17 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
18 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
18 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
19 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
19 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
20 <value type="QString" key="language">Cpp</value>
20 <value type="QString" key="language">Cpp</value>
21 <valuemap type="QVariantMap" key="value">
21 <valuemap type="QVariantMap" key="value">
22 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
22 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
23 </valuemap>
23 </valuemap>
24 </valuemap>
24 </valuemap>
25 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
25 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
26 <value type="QString" key="language">QmlJS</value>
26 <value type="QString" key="language">QmlJS</value>
27 <valuemap type="QVariantMap" key="value">
27 <valuemap type="QVariantMap" key="value">
28 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
28 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
29 </valuemap>
29 </valuemap>
30 </valuemap>
30 </valuemap>
31 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
31 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
32 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
32 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
33 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
33 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
34 <value type="int" key="EditorConfiguration.IndentSize">4</value>
34 <value type="int" key="EditorConfiguration.IndentSize">4</value>
35 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
35 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
36 <value type="int" key="EditorConfiguration.MarginColumn">80</value>
36 <value type="int" key="EditorConfiguration.MarginColumn">80</value>
37 <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
37 <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
38 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
38 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
39 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
39 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
40 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
40 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
41 <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
41 <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
42 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
42 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
43 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
43 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
44 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
44 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
45 <value type="int" key="EditorConfiguration.TabSize">8</value>
45 <value type="int" key="EditorConfiguration.TabSize">8</value>
46 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
46 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
47 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
47 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
48 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
48 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
49 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
49 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
50 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
50 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
51 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
51 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
52 </valuemap>
52 </valuemap>
53 </data>
53 </data>
54 <data>
54 <data>
55 <variable>ProjectExplorer.Project.PluginSettings</variable>
55 <variable>ProjectExplorer.Project.PluginSettings</variable>
56 <valuemap type="QVariantMap"/>
56 <valuemap type="QVariantMap"/>
57 </data>
57 </data>
58 <data>
58 <data>
59 <variable>ProjectExplorer.Project.Target.0</variable>
59 <variable>ProjectExplorer.Project.Target.0</variable>
60 <valuemap type="QVariantMap">
60 <valuemap type="QVariantMap">
61 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
61 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
62 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
62 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
63 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
63 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
64 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
64 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
65 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
65 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
66 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
66 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
67 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
67 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
68 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
68 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
69 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
69 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
70 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
70 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
71 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
71 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
72 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
72 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
73 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
73 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
75 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
75 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
76 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
76 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
77 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
77 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
78 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
78 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
79 </valuemap>
79 </valuemap>
80 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
80 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
81 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
81 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
82 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
82 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
83 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
83 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
84 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
84 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
85 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
85 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
86 <value type="QString">-w</value>
86 <value type="QString">-w</value>
87 <value type="QString">-r</value>
87 <value type="QString">-r</value>
88 </valuelist>
88 </valuelist>
89 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
89 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
90 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
90 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
91 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
91 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
92 </valuemap>
92 </valuemap>
93 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
93 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</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">ProjectExplorer.BuildSteps.Build</value>
96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
97 </valuemap>
97 </valuemap>
98 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
98 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
99 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
99 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
100 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
100 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
101 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
101 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
102 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
102 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
103 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
103 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
104 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
104 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
105 <value type="QString">-w</value>
105 <value type="QString">-w</value>
106 <value type="QString">-r</value>
106 <value type="QString">-r</value>
107 </valuelist>
107 </valuelist>
108 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
108 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
109 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
109 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
110 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
110 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
111 </valuemap>
111 </valuemap>
112 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
112 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</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">ProjectExplorer.BuildSteps.Clean</value>
115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
116 </valuemap>
116 </valuemap>
117 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
117 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
118 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
118 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
119 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
119 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
120 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
120 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
121 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
121 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
122 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
122 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
123 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
123 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
124 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
124 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
125 </valuemap>
125 </valuemap>
126 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
126 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
127 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
127 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
128 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
128 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
129 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
129 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
132 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
132 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
133 </valuemap>
133 </valuemap>
134 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
134 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
137 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
137 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
138 </valuemap>
138 </valuemap>
139 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
139 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
140 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
140 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
141 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
141 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
142 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
142 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
143 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
143 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
144 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
144 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
145 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
145 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
146 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
146 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
147 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
147 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
148 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
148 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
149 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
149 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
150 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
150 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
151 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
151 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
152 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
152 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
153 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
153 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
154 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
154 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
155 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
155 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
156 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
156 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
157 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
157 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
158 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
158 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
159 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
159 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
160 <value type="int">0</value>
160 <value type="int">0</value>
161 <value type="int">1</value>
161 <value type="int">1</value>
162 <value type="int">2</value>
162 <value type="int">2</value>
163 <value type="int">3</value>
163 <value type="int">3</value>
164 <value type="int">4</value>
164 <value type="int">4</value>
165 <value type="int">5</value>
165 <value type="int">5</value>
166 <value type="int">6</value>
166 <value type="int">6</value>
167 <value type="int">7</value>
167 <value type="int">7</value>
168 <value type="int">8</value>
168 <value type="int">8</value>
169 <value type="int">9</value>
169 <value type="int">9</value>
170 <value type="int">10</value>
170 <value type="int">10</value>
171 <value type="int">11</value>
171 <value type="int">11</value>
172 <value type="int">12</value>
172 <value type="int">12</value>
173 <value type="int">13</value>
173 <value type="int">13</value>
174 <value type="int">14</value>
174 <value type="int">14</value>
175 </valuelist>
175 </valuelist>
176 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
176 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
177 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
177 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
178 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
178 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
179 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
179 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
180 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
180 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
181 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
181 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
182 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
182 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
183 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
183 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
184 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
184 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
185 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
185 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
186 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
186 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
187 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
187 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
188 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
188 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
189 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
189 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
190 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
190 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
191 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
191 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
192 </valuemap>
192 </valuemap>
193 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
193 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
194 </valuemap>
194 </valuemap>
195 </data>
195 </data>
196 <data>
196 <data>
197 <variable>ProjectExplorer.Project.TargetCount</variable>
197 <variable>ProjectExplorer.Project.TargetCount</variable>
198 <value type="int">1</value>
198 <value type="int">1</value>
199 </data>
199 </data>
200 <data>
200 <data>
201 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
201 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
202 <value type="int">16</value>
202 <value type="int">16</value>
203 </data>
203 </data>
204 <data>
204 <data>
205 <variable>Version</variable>
205 <variable>Version</variable>
206 <value type="int">16</value>
206 <value type="int">16</value>
207 </data>
207 </data>
208 </qtcreator>
208 </qtcreator>
@@ -1,47 +1,46
1 #ifndef FSW_MISC_H_INCLUDED
1 #ifndef FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6 #include <grspw.h>
6 #include <grspw.h>
7
7
8 #include "fsw_params.h"
8 #include "fsw_params.h"
9 #include "fsw_spacewire.h"
9 #include "fsw_spacewire.h"
10 #include "lfr_cpu_usage_report.h"
10 #include "lfr_cpu_usage_report.h"
11
11
12 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
12 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
13 rtems_id HK_id; // id of the HK rate monotonic period
13 rtems_id HK_id; // id of the HK rate monotonic period
14
14
15 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
15 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
16 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
16 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
17 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
17 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
18 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
18 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
19 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
19 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
20
20
21 // SERIAL LINK
21 // SERIAL LINK
22 int send_console_outputs_on_apbuart_port( void );
22 int send_console_outputs_on_apbuart_port( void );
23 int enable_apbuart_transmitter( void );
23 int enable_apbuart_transmitter( void );
24 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
24 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
25
25
26 // RTEMS TASKS
26 // RTEMS TASKS
27 rtems_task stat_task( rtems_task_argument argument );
27 rtems_task stat_task( rtems_task_argument argument );
28 rtems_task hous_task( rtems_task_argument argument );
28 rtems_task hous_task( rtems_task_argument argument );
29 rtems_task dumb_task( rtems_task_argument unused );
29 rtems_task dumb_task( rtems_task_argument unused );
30
30
31 void init_housekeeping_parameters( void );
31 void init_housekeeping_parameters( void );
32 void increment_seq_counter(unsigned short *packetSequenceControl);
32 void increment_seq_counter(unsigned short *packetSequenceControl);
33 void getTime( unsigned char *time);
33 void getTime( unsigned char *time);
34 unsigned long long int getTimeAsUnsignedLongLongInt( );
34 unsigned long long int getTimeAsUnsignedLongLongInt( );
35 void send_dumb_hk( void );
35 void send_dumb_hk( void );
36 void get_v_e1_e2_f3(unsigned char *spacecraft_potential);
36 void get_v_e1_e2_f3(unsigned char *spacecraft_potential);
37 void get_v_e1_e2_f3_alt(unsigned char *spacecraft_potential);
38 void get_cpu_load( unsigned char *resource_statistics );
37 void get_cpu_load( unsigned char *resource_statistics );
39
38
40 extern int sched_yield( void );
39 extern int sched_yield( void );
41 extern void rtems_cpu_usage_reset();
40 extern void rtems_cpu_usage_reset();
42 extern ring_node *current_ring_node_f3;
41 extern ring_node *current_ring_node_f3;
43 extern ring_node *ring_node_to_send_cwf_f3;
42 extern ring_node *ring_node_to_send_cwf_f3;
44 extern ring_node waveform_ring_f3[];
43 extern ring_node waveform_ring_f3[];
45 extern unsigned short sequenceCounterHK;
44 extern unsigned short sequenceCounterHK;
46
45
47 #endif // FSW_MISC_H_INCLUDED
46 #endif // FSW_MISC_H_INCLUDED
@@ -1,259 +1,260
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 struct ring_node *next;
16 struct ring_node *next;
17 unsigned int sid;
17 unsigned int coarseTime;
18 unsigned int coarseTime;
18 unsigned int fineTime;
19 unsigned int fineTime;
19 int buffer_address;
20 int buffer_address;
20 unsigned int status;
21 unsigned int status;
21 } ring_node;
22 } ring_node;
22
23
23 //************************
24 //************************
24 // flight software version
25 // flight software version
25 // this parameters is handled by the Qt project options
26 // this parameters is handled by the Qt project options
26
27
27 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
28 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
28 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
29 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
29 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
30 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
30 #define TIME_OFFSET 2
31 #define TIME_OFFSET 2
31 #define TIME_OFFSET_IN_BYTES 8
32 #define TIME_OFFSET_IN_BYTES 8
32 //#define WAVEFORM_EXTENDED_HEADER_OFFSET 22
33 //#define WAVEFORM_EXTENDED_HEADER_OFFSET 22
33 #define NB_BYTES_SWF_BLK (2 * 6)
34 #define NB_BYTES_SWF_BLK (2 * 6)
34 #define NB_WORDS_SWF_BLK 3
35 #define NB_WORDS_SWF_BLK 3
35 #define NB_BYTES_CWF3_LIGHT_BLK 6
36 #define NB_BYTES_CWF3_LIGHT_BLK 6
36 //#define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
37 //#define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
37 #define NB_RING_NODES_F0 3 // AT LEAST 3
38 #define NB_RING_NODES_F0 3 // AT LEAST 3
38 #define NB_RING_NODES_F1 5 // AT LEAST 3
39 #define NB_RING_NODES_F1 5 // AT LEAST 3
39 #define NB_RING_NODES_F2 5 // AT LEAST 3
40 #define NB_RING_NODES_F2 5 // AT LEAST 3
40 #define NB_RING_NODES_F3 3 // AT LEAST 3
41 #define NB_RING_NODES_F3 3 // AT LEAST 3
41
42
42 //**********
43 //**********
43 // LFR MODES
44 // LFR MODES
44 #define LFR_MODE_STANDBY 0
45 #define LFR_MODE_STANDBY 0
45 #define LFR_MODE_NORMAL 1
46 #define LFR_MODE_NORMAL 1
46 #define LFR_MODE_BURST 2
47 #define LFR_MODE_BURST 2
47 #define LFR_MODE_SBM1 3
48 #define LFR_MODE_SBM1 3
48 #define LFR_MODE_SBM2 4
49 #define LFR_MODE_SBM2 4
49
50
50 #define TDS_MODE_LFM 5
51 #define TDS_MODE_LFM 5
51 #define TDS_MODE_STANDBY 0
52 #define TDS_MODE_STANDBY 0
52 #define TDS_MODE_NORMAL 1
53 #define TDS_MODE_NORMAL 1
53 #define TDS_MODE_BURST 2
54 #define TDS_MODE_BURST 2
54 #define TDS_MODE_SBM1 3
55 #define TDS_MODE_SBM1 3
55 #define TDS_MODE_SBM2 4
56 #define TDS_MODE_SBM2 4
56
57
57 #define THR_MODE_STANDBY 0
58 #define THR_MODE_STANDBY 0
58 #define THR_MODE_NORMAL 1
59 #define THR_MODE_NORMAL 1
59 #define THR_MODE_BURST 2
60 #define THR_MODE_BURST 2
60
61
61 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
62 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
62 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
63 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
63 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
64 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
64 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
65 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
65 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
66 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
66 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
67 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
67 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
68 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
68 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
69 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
69 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
70 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
70 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
71 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
71 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
72 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
72 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
73 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
73 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
74 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
74 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
75 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
75 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
76 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
76 #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15
77 #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15
77 #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16
78 #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16
78 #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17
79 #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17
79 #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18
80 #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18
80 #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19
81 #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19
81 #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20
82 #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20
82 #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21
83 #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21
83 #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22
84 #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22
84
85
85 //****************************
86 //****************************
86 // LFR DEFAULT MODE PARAMETERS
87 // LFR DEFAULT MODE PARAMETERS
87 // COMMON
88 // COMMON
88 #define DEFAULT_SY_LFR_COMMON0 0x00
89 #define DEFAULT_SY_LFR_COMMON0 0x00
89 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
90 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
90 // NORM
91 // NORM
91 #define DFLT_SY_LFR_N_SWF_L 2048 // nb sample
92 #define DFLT_SY_LFR_N_SWF_L 2048 // nb sample
92 #define DFLT_SY_LFR_N_SWF_P 300 // sec
93 #define DFLT_SY_LFR_N_SWF_P 300 // sec
93 #define DFLT_SY_LFR_N_ASM_P 3600 // sec
94 #define DFLT_SY_LFR_N_ASM_P 3600 // sec
94 #define DFLT_SY_LFR_N_BP_P0 4 // sec
95 #define DFLT_SY_LFR_N_BP_P0 4 // sec
95 #define DFLT_SY_LFR_N_BP_P1 20 // sec
96 #define DFLT_SY_LFR_N_BP_P1 20 // sec
96 #define DFLT_SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
97 #define DFLT_SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
97 #define MIN_DELTA_SNAPSHOT 16 // sec
98 #define MIN_DELTA_SNAPSHOT 16 // sec
98 // BURST
99 // BURST
99 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
100 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
100 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
101 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
101 // SBM1
102 // SBM1
102 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
103 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
103 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
104 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
104 // SBM2
105 // SBM2
105 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
106 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
106 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
107 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
107 // ADDITIONAL PARAMETERS
108 // ADDITIONAL PARAMETERS
108 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
109 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
109 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
110 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
110 // STATUS WORD
111 // STATUS WORD
111 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
112 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
112 #define DEFAULT_STATUS_WORD_BYTE1 0x00
113 #define DEFAULT_STATUS_WORD_BYTE1 0x00
113 //
114 //
114 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
115 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
115 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
116 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
116 //****************************
117 //****************************
117
118
118 //*****************************
119 //*****************************
119 // APB REGISTERS BASE ADDRESSES
120 // APB REGISTERS BASE ADDRESSES
120 #define REGS_ADDR_APBUART 0x80000100
121 #define REGS_ADDR_APBUART 0x80000100
121 #define REGS_ADDR_GPTIMER 0x80000300
122 #define REGS_ADDR_GPTIMER 0x80000300
122 #define REGS_ADDR_GRSPW 0x80000500
123 #define REGS_ADDR_GRSPW 0x80000500
123 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
124 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
124 #define REGS_ADDR_GRGPIO 0x80000b00
125 #define REGS_ADDR_GRGPIO 0x80000b00
125
126
126 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
127 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
127 //#define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
128 //#define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
128 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f54 // PDB >= 0.1.28
129 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f54 // PDB >= 0.1.28
129 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
130 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
130
131
131 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
132 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
132 #define APBUART_CTRL_REG_MASK_TE 0x00000002
133 #define APBUART_CTRL_REG_MASK_TE 0x00000002
133 // scaler value = system_clock_frequency / ( baud_rate * 8 ) - 1
134 // scaler value = system_clock_frequency / ( baud_rate * 8 ) - 1
134 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400
135 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400
135
136
136 //**********
137 //**********
137 // IRQ LINES
138 // IRQ LINES
138 #define IRQ_SM_SIMULATOR 9
139 #define IRQ_SM_SIMULATOR 9
139 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
140 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
140 #define IRQ_WAVEFORM_PICKER 14
141 #define IRQ_WAVEFORM_PICKER 14
141 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
142 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
142 #define IRQ_SPECTRAL_MATRIX 6
143 #define IRQ_SPECTRAL_MATRIX 6
143 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
144 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
144
145
145 //*****
146 //*****
146 // TIME
147 // TIME
147 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
148 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
148 #define TIMER_SM_SIMULATOR 1
149 #define TIMER_SM_SIMULATOR 1
149 #define HK_PERIOD 100 // 100 * 10ms => 1s
150 #define HK_PERIOD 100 // 100 * 10ms => 1s
150 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
151 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
151 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
152 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
152
153
153 //**********
154 //**********
154 // LPP CODES
155 // LPP CODES
155 #define LFR_SUCCESSFUL 0
156 #define LFR_SUCCESSFUL 0
156 #define LFR_DEFAULT 1
157 #define LFR_DEFAULT 1
157 #define LFR_EXE_ERROR 2
158 #define LFR_EXE_ERROR 2
158
159
159 //******
160 //******
160 // RTEMS
161 // RTEMS
161 #define TASKID_RECV 1
162 #define TASKID_RECV 1
162 #define TASKID_ACTN 2
163 #define TASKID_ACTN 2
163 #define TASKID_SPIQ 3
164 #define TASKID_SPIQ 3
164 #define TASKID_STAT 4
165 #define TASKID_STAT 4
165 #define TASKID_AVF0 5
166 #define TASKID_AVF0 5
166 #define TASKID_SWBD 6
167 #define TASKID_SWBD 6
167 #define TASKID_WFRM 7
168 #define TASKID_WFRM 7
168 #define TASKID_DUMB 8
169 #define TASKID_DUMB 8
169 #define TASKID_HOUS 9
170 #define TASKID_HOUS 9
170 #define TASKID_PRC0 10
171 #define TASKID_PRC0 10
171 #define TASKID_CWF3 11
172 #define TASKID_CWF3 11
172 #define TASKID_CWF2 12
173 #define TASKID_CWF2 12
173 #define TASKID_CWF1 13
174 #define TASKID_CWF1 13
174 #define TASKID_SEND 14
175 #define TASKID_SEND 14
175 #define TASKID_WTDG 15
176 #define TASKID_WTDG 15
176 #define TASKID_AVF1 16
177 #define TASKID_AVF1 16
177 #define TASKID_PRC1 17
178 #define TASKID_PRC1 17
178 #define TASKID_AVF2 18
179 #define TASKID_AVF2 18
179 #define TASKID_PRC2 19
180 #define TASKID_PRC2 19
180
181
181 #define TASK_PRIORITY_SPIQ 5
182 #define TASK_PRIORITY_SPIQ 5
182 #define TASK_PRIORITY_WTDG 20
183 #define TASK_PRIORITY_WTDG 20
183 #define TASK_PRIORITY_HOUS 30
184 #define TASK_PRIORITY_HOUS 30
184 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
185 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
185 #define TASK_PRIORITY_CWF2 35 //
186 #define TASK_PRIORITY_CWF2 35 //
186 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
187 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
187 #define TASK_PRIORITY_WFRM 40
188 #define TASK_PRIORITY_WFRM 40
188 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
189 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
189 #define TASK_PRIORITY_SEND 45
190 #define TASK_PRIORITY_SEND 45
190 #define TASK_PRIORITY_RECV 50
191 #define TASK_PRIORITY_RECV 50
191 #define TASK_PRIORITY_ACTN 50
192 #define TASK_PRIORITY_ACTN 50
192 #define TASK_PRIORITY_AVF0 60
193 #define TASK_PRIORITY_AVF0 60
193 #define TASK_PRIORITY_AVF1 70
194 #define TASK_PRIORITY_AVF1 70
194 #define TASK_PRIORITY_PRC0 100
195 #define TASK_PRIORITY_PRC0 100
195 #define TASK_PRIORITY_PRC1 100
196 #define TASK_PRIORITY_PRC1 100
196 #define TASK_PRIORITY_AVF2 110
197 #define TASK_PRIORITY_AVF2 110
197 #define TASK_PRIORITY_PRC2 110
198 #define TASK_PRIORITY_PRC2 110
198 #define TASK_PRIORITY_STAT 200
199 #define TASK_PRIORITY_STAT 200
199 #define TASK_PRIORITY_DUMB 200
200 #define TASK_PRIORITY_DUMB 200
200
201
201 #define MSG_QUEUE_COUNT_RECV 10
202 #define MSG_QUEUE_COUNT_RECV 10
202 #define MSG_QUEUE_COUNT_SEND 50
203 #define MSG_QUEUE_COUNT_SEND 50
203 #define MSG_QUEUE_COUNT_PRC0 10
204 #define MSG_QUEUE_COUNT_PRC0 10
204 #define MSG_QUEUE_COUNT_PRC1 10
205 #define MSG_QUEUE_COUNT_PRC1 10
205 #define MSG_QUEUE_COUNT_PRC2 5
206 #define MSG_QUEUE_COUNT_PRC2 5
206 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
207 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
207 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
208 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
208 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
209 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
209 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
210 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
210 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
211 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
211
212
212 #define QUEUE_RECV 0
213 #define QUEUE_RECV 0
213 #define QUEUE_SEND 1
214 #define QUEUE_SEND 1
214 #define QUEUE_PRC0 2
215 #define QUEUE_PRC0 2
215 #define QUEUE_PRC1 3
216 #define QUEUE_PRC1 3
216 #define QUEUE_PRC2 4
217 #define QUEUE_PRC2 4
217
218
218 //*******
219 //*******
219 // MACROS
220 // MACROS
220 #ifdef PRINT_MESSAGES_ON_CONSOLE
221 #ifdef PRINT_MESSAGES_ON_CONSOLE
221 #define PRINTF(x) printf(x);
222 #define PRINTF(x) printf(x);
222 #define PRINTF1(x,y) printf(x,y);
223 #define PRINTF1(x,y) printf(x,y);
223 #define PRINTF2(x,y,z) printf(x,y,z);
224 #define PRINTF2(x,y,z) printf(x,y,z);
224 #else
225 #else
225 #define PRINTF(x) ;
226 #define PRINTF(x) ;
226 #define PRINTF1(x,y) ;
227 #define PRINTF1(x,y) ;
227 #define PRINTF2(x,y,z) ;
228 #define PRINTF2(x,y,z) ;
228 #endif
229 #endif
229
230
230 #ifdef BOOT_MESSAGES
231 #ifdef BOOT_MESSAGES
231 #define BOOT_PRINTF(x) printf(x);
232 #define BOOT_PRINTF(x) printf(x);
232 #define BOOT_PRINTF1(x,y) printf(x,y);
233 #define BOOT_PRINTF1(x,y) printf(x,y);
233 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
234 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
234 #else
235 #else
235 #define BOOT_PRINTF(x) ;
236 #define BOOT_PRINTF(x) ;
236 #define BOOT_PRINTF1(x,y) ;
237 #define BOOT_PRINTF1(x,y) ;
237 #define BOOT_PRINTF2(x,y,z) ;
238 #define BOOT_PRINTF2(x,y,z) ;
238 #endif
239 #endif
239
240
240 #ifdef DEBUG_MESSAGES
241 #ifdef DEBUG_MESSAGES
241 #define DEBUG_PRINTF(x) printf(x);
242 #define DEBUG_PRINTF(x) printf(x);
242 #define DEBUG_PRINTF1(x,y) printf(x,y);
243 #define DEBUG_PRINTF1(x,y) printf(x,y);
243 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
244 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
244 #else
245 #else
245 #define DEBUG_PRINTF(x) ;
246 #define DEBUG_PRINTF(x) ;
246 #define DEBUG_PRINTF1(x,y) ;
247 #define DEBUG_PRINTF1(x,y) ;
247 #define DEBUG_PRINTF2(x,y,z) ;
248 #define DEBUG_PRINTF2(x,y,z) ;
248 #endif
249 #endif
249
250
250 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
251 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
251
252
252 struct param_local_str{
253 struct param_local_str{
253 unsigned int local_sbm1_nb_cwf_sent;
254 unsigned int local_sbm1_nb_cwf_sent;
254 unsigned int local_sbm1_nb_cwf_max;
255 unsigned int local_sbm1_nb_cwf_max;
255 unsigned int local_sbm2_nb_cwf_sent;
256 unsigned int local_sbm2_nb_cwf_sent;
256 unsigned int local_sbm2_nb_cwf_max;
257 unsigned int local_sbm2_nb_cwf_max;
257 };
258 };
258
259
259 #endif // FSW_PARAMS_H_INCLUDED
260 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,70 +1,71
1 #ifndef FSW_PARAMS_PROCESSING_H
1 #ifndef FSW_PARAMS_PROCESSING_H
2 #define FSW_PARAMS_PROCESSING_H
2 #define FSW_PARAMS_PROCESSING_H
3
3
4 #define NB_BINS_PER_SM 128
4 #define NB_BINS_PER_SM 128
5 #define NB_VALUES_PER_SM 25
5 #define NB_VALUES_PER_SM 25
6 #define TOTAL_SIZE_SM 3200 // 25 * 128 = 0xC80
6 #define TOTAL_SIZE_SM 3200 // 25 * 128 = 0xC80
7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
7 #define TOTAL_SIZE_NORM_BP1_F0 99 // 11 * 9 = 99
8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
8 #define TOTAL_SIZE_NORM_BP1_F1 117 // 13 * 9 = 117
9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
11 //
11 //
12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 8 due to the way the averaging is done
12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 8 due to the way the averaging is done
13 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
13 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
14 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
14 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
15 #define NB_RING_NODES_ASM_F0 3 // AT LEAST 3
15 #define NB_RING_NODES_SM_F1 12 // AT LEAST 8 due to the way the averaging is done
16 #define NB_RING_NODES_SM_F1 12 // AT LEAST 8 due to the way the averaging is done
16 #define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3
17 #define NB_RING_NODES_ASM_BURST_SBM_F1 5 // AT LEAST 3
17 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
18 #define NB_RING_NODES_ASM_NORM_F1 5 // AT LEAST 3
18 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
19 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
19 #define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3
20 #define NB_RING_NODES_ASM_BURST_SBM_F2 3 // AT LEAST 3
20 #define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3
21 #define NB_RING_NODES_ASM_NORM_F2 3 // AT LEAST 3
21 //
22 //
22 #define NB_BINS_PER_ASM_F0 88
23 #define NB_BINS_PER_ASM_F0 88
23 #define NB_BINS_PER_PKT_ASM_F0 44
24 #define NB_BINS_PER_PKT_ASM_F0 44
24 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
25 #define TOTAL_SIZE_ASM_F0_IN_BYTES 4400 // 25 * 88 * 2
25 #define ASM_F0_INDICE_START 17 // 88 bins
26 #define ASM_F0_INDICE_START 17 // 88 bins
26 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
27 #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins
27 //
28 //
28 #define NB_BINS_PER_ASM_F1 104
29 #define NB_BINS_PER_ASM_F1 104
29 #define NB_BINS_PER_PKT_ASM_F1 52
30 #define NB_BINS_PER_PKT_ASM_F1 52
30 #define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2
31 #define TOTAL_SIZE_ASM_F1_IN_BYTES 5200 // 25 * 104 * 2
31 #define ASM_F1_INDICE_START 6 // 104 bins
32 #define ASM_F1_INDICE_START 6 // 104 bins
32 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
33 #define ASM_F1_INDICE_STOP 109 // 2 packets of 52 bins
33 //
34 //
34 #define NB_BINS_PER_ASM_F2 96
35 #define NB_BINS_PER_ASM_F2 96
35 #define NB_BINS_PER_PKT_ASM_F2 48
36 #define NB_BINS_PER_PKT_ASM_F2 48
36 #define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2
37 #define TOTAL_SIZE_ASM_F2_IN_BYTES 4800 // 25 * 96 * 2
37 #define ASM_F2_INDICE_START 7 // 96 bins
38 #define ASM_F2_INDICE_START 7 // 96 bins
38 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
39 #define ASM_F2_INDICE_STOP 102 // 2 packets of 48 bins
39 //
40 //
40 #define NB_BINS_COMPRESSED_SM_F0 11
41 #define NB_BINS_COMPRESSED_SM_F0 11
41 #define NB_BINS_COMPRESSED_SM_F1 13
42 #define NB_BINS_COMPRESSED_SM_F1 13
42 #define NB_BINS_COMPRESSED_SM_F2 12
43 #define NB_BINS_COMPRESSED_SM_F2 12
43 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
44 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
44 #define NB_BINS_COMPRESSED_SM_SBM_F1 26
45 #define NB_BINS_COMPRESSED_SM_SBM_F1 26
45 #define NB_BINS_COMPRESSED_SM_SBM_F2 24
46 #define NB_BINS_COMPRESSED_SM_SBM_F2 24
46 //
47 //
47 #define NB_BYTES_PER_BP1 9
48 #define NB_BYTES_PER_BP1 9
48 //
49 //
49 #define NB_BINS_TO_AVERAGE_ASM_F0 8
50 #define NB_BINS_TO_AVERAGE_ASM_F0 8
50 #define NB_BINS_TO_AVERAGE_ASM_F1 8
51 #define NB_BINS_TO_AVERAGE_ASM_F1 8
51 #define NB_BINS_TO_AVERAGE_ASM_F2 8
52 #define NB_BINS_TO_AVERAGE_ASM_F2 8
52 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
53 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
53 #define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4
54 #define NB_BINS_TO_AVERAGE_ASM_SBM_F1 4
54 #define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4
55 #define NB_BINS_TO_AVERAGE_ASM_SBM_F2 4
55 //
56 //
56 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
57 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F0 275 // 11 * 25 WORDS
57 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
58 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F1 325 // 13 * 25 WORDS
58 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS
59 #define TOTAL_SIZE_COMPRESSED_ASM_NORM_F2 300 // 12 * 25 WORDS
59 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
60 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 550 // 22 * 25 WORDS
60 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
61 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 650 // 26 * 25 WORDS
61 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS
62 #define TOTAL_SIZE_COMPRESSED_ASM_SBM_F2 600 // 24 * 25 WORDS
62 #define TOTAL_SIZE_BP1_NORM_F0 99 // 9 * 11 UNSIGNED CHAR
63 #define TOTAL_SIZE_BP1_NORM_F0 99 // 9 * 11 UNSIGNED CHAR
63 #define TOTAL_SIZE_BP1_SBM_F0 198 // 9 * 22 UNSIGNED CHAR
64 #define TOTAL_SIZE_BP1_SBM_F0 198 // 9 * 22 UNSIGNED CHAR
64 // GENERAL
65 // GENERAL
65 #define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function
66 #define NB_SM_BEFORE_AVF0 8 // must be 8 due to the SM_average() function
66 #define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function
67 #define NB_SM_BEFORE_AVF1 8 // must be 8 due to the SM_average() function
67 #define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function
68 #define NB_SM_BEFORE_AVF2 1 // must be 1 due to the SM_average_f2() function
68
69
69 #endif // FSW_PARAMS_PROCESSING_H
70 #endif // FSW_PARAMS_PROCESSING_H
70
71
@@ -1,39 +1,47
1 #ifndef FSW_SPACEWIRE_H_INCLUDED
1 #ifndef FSW_SPACEWIRE_H_INCLUDED
2 #define FSW_SPACEWIRE_H_INCLUDED
2 #define FSW_SPACEWIRE_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6
6
7 #include <fcntl.h> // for O_RDWR
7 #include <fcntl.h> // for O_RDWR
8 #include <unistd.h> // for the read call
8 #include <unistd.h> // for the read call
9 #include <sys/ioctl.h> // for the ioctl call
9 #include <sys/ioctl.h> // for the ioctl call
10 #include <errno.h>
10 #include <errno.h>
11
11
12 #include "fsw_params.h"
12 #include "fsw_params.h"
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14
14
15 extern spw_stats spacewire_stats;
15 extern spw_stats spacewire_stats;
16 extern spw_stats spacewire_stats_backup;
16 extern spw_stats spacewire_stats_backup;
17
17
18 // RTEMS TASK
18 // RTEMS TASK
19 rtems_task spiq_task( rtems_task_argument argument );
19 rtems_task spiq_task( rtems_task_argument argument );
20 rtems_task recv_task( rtems_task_argument unused );
20 rtems_task recv_task( rtems_task_argument unused );
21 rtems_task send_task( rtems_task_argument argument );
21 rtems_task send_task( rtems_task_argument argument );
22 rtems_task wtdg_task( rtems_task_argument argument );
22 rtems_task wtdg_task( rtems_task_argument argument );
23
23
24 int spacewire_open_link( void );
24 int spacewire_open_link( void );
25 int spacewire_start_link( int fd );
25 int spacewire_start_link( int fd );
26 int spacewire_stop_and_start_link( int fd );
26 int spacewire_stop_and_start_link( int fd );
27 int spacewire_configure_link(int fd );
27 int spacewire_configure_link(int fd );
28 int spacewire_reset_link( void );
28 int spacewire_reset_link( void );
29 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
29 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
30 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
30 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
31 void spacewire_compute_stats_offsets( void );
31 void spacewire_compute_stats_offsets( void );
32 void spacewire_update_statistics( void );
32 void spacewire_update_statistics( void );
33
33
34 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header );
35 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header );
36 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header );
37 int spw_send_waveform_CWF( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *header );
38 int spw_send_waveform_SWF( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_SWF_t *header );
39 int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *header );
40 void spw_send_asm( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_ASM_t *header );
41
34 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
42 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
35 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data );
43 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data );
36
44
37 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
45 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
38
46
39 #endif // FSW_SPACEWIRE_H_INCLUDED
47 #endif // FSW_SPACEWIRE_H_INCLUDED
@@ -1,244 +1,279
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[] );
77 // ASM
76 // ASM
78 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
77 void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes );
79 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
78 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,
79 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);
80 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
82
81
83 //*****************
82 //*****************
84 // Basic Parameters
83 // Basic Parameters
85
84
86 void BP_reset_current_ring_nodes( void );
85 void BP_reset_current_ring_nodes( void );
87 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
86 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
88 unsigned int apid, unsigned char sid,
87 unsigned int apid, unsigned char sid,
89 unsigned int packetLength , unsigned char blkNr);
88 unsigned int packetLength , unsigned char blkNr);
90 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
89 void BP_init_header_with_spare( Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
91 unsigned int apid, unsigned char sid,
90 unsigned int apid, unsigned char sid,
92 unsigned int packetLength, unsigned char blkNr );
91 unsigned int packetLength, unsigned char blkNr );
93 void BP_send( char *data,
92 void BP_send( char *data,
94 rtems_id queue_id ,
93 rtems_id queue_id ,
95 unsigned int nbBytesToSend , unsigned int sid );
94 unsigned int nbBytesToSend , unsigned int sid );
96
95
97 //******************
96 //******************
98 // general functions
97 // general functions
99 void reset_sm_status( void );
98 void reset_sm_status( void );
100 void reset_spectral_matrix_regs( void );
99 void reset_spectral_matrix_regs( void );
101 void set_time(unsigned char *time, unsigned char *timeInBuffer );
100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
102 unsigned long long int get_acquisition_time( unsigned char *timePtr );
101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
103 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
102 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
104 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time);
103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode, unsigned long long int time );
105 unsigned char getSID( rtems_event_set event );
104 unsigned char getSID( rtems_event_set event );
106
105
107 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
108 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
107 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
109
108
110 //***************************************
109 //***************************************
111 // DEFINITIONS OF STATIC INLINE FUNCTIONS
110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
112 static inline void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
111 static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
113 ring_node_sm *ring_node_tab[],
112 ring_node_sm *ring_node_tab[],
114 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
113 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
114 static inline void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
115 ring_node_sm *ring_node_tab[],
116 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
115 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
117 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
116 float divider );
118 float divider );
117 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
119 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
118 float divider,
120 float divider,
119 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
121 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
120 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
122 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
121
123
122 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
124 void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
123 ring_node_sm *ring_node_tab[],
125 ring_node_sm *ring_node_tab[],
124 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
126 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
125 {
127 {
126 float sum;
128 float sum;
127 unsigned int i;
129 unsigned int i;
128
130
129 for(i=0; i<TOTAL_SIZE_SM; i++)
131 for(i=0; i<TOTAL_SIZE_SM; i++)
130 {
132 {
131 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
133 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
132 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
134 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
133 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
134 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
135 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
137 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
136 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
138 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
137 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
139 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
138 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
140 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
139
141
140 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
142 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
141 {
143 {
142 averaged_spec_mat_NORM[ i ] = sum;
144 averaged_spec_mat_NORM[ i ] = sum;
143 averaged_spec_mat_SBM[ i ] = sum;
145 averaged_spec_mat_SBM[ i ] = sum;
144 }
146 }
145 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
147 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
146 {
148 {
147 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
149 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
148 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
150 averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum );
149 }
151 }
150 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
152 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
151 {
153 {
152 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
154 averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum );
153 averaged_spec_mat_SBM[ i ] = sum;
155 averaged_spec_mat_SBM[ i ] = sum;
154 }
156 }
155 else
157 else
156 {
158 {
157 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
159 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
158 }
160 }
159 }
161 }
160 }
162 }
161
163
164 void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
165 ring_node_sm *ring_node_tab[],
166 unsigned int nbAverageNORM, unsigned int nbAverageSBM )
167 {
168 float sum;
169 unsigned int i;
170
171 for(i=0; i<TOTAL_SIZE_SM; i++)
172 {
173 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ];
174
175 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
176 {
177 averaged_spec_mat_NORM[ i ] = sum;
178 averaged_spec_mat_SBM[ i ] = sum;
179 }
180 else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) )
181 {
182 averaged_spec_mat_NORM[ i ] = sum;
183 averaged_spec_mat_SBM[ i ] = sum;
184 }
185 else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) )
186 {
187 averaged_spec_mat_NORM[ i ] = sum;
188 averaged_spec_mat_SBM[ i ] = sum;
189 }
190 else
191 {
192 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM)
193 }
194 }
195 }
196
162 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
197 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
163 {
198 {
164 int frequencyBin;
199 int frequencyBin;
165 int asmComponent;
200 int asmComponent;
166 unsigned int offsetAveragedSpecMatReorganized;
201 unsigned int offsetAveragedSpecMatReorganized;
167 unsigned int offsetAveragedSpecMat;
202 unsigned int offsetAveragedSpecMat;
168
203
169 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
204 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
170 {
205 {
171 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
206 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
172 {
207 {
173 offsetAveragedSpecMatReorganized =
208 offsetAveragedSpecMatReorganized =
174 frequencyBin * NB_VALUES_PER_SM
209 frequencyBin * NB_VALUES_PER_SM
175 + asmComponent;
210 + asmComponent;
176 offsetAveragedSpecMat =
211 offsetAveragedSpecMat =
177 asmComponent * NB_BINS_PER_SM
212 asmComponent * NB_BINS_PER_SM
178 + frequencyBin;
213 + frequencyBin;
179 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
214 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
180 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
215 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
181 }
216 }
182 }
217 }
183 }
218 }
184
219
185 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
220 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
186 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
221 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
187 {
222 {
188 int frequencyBin;
223 int frequencyBin;
189 int asmComponent;
224 int asmComponent;
190 int offsetASM;
225 int offsetASM;
191 int offsetCompressed;
226 int offsetCompressed;
192 int k;
227 int k;
193
228
194 // build data
229 // build data
195 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
230 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
196 {
231 {
197 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
232 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
198 {
233 {
199 offsetCompressed = // NO TIME OFFSET
234 offsetCompressed = // NO TIME OFFSET
200 frequencyBin * NB_VALUES_PER_SM
235 frequencyBin * NB_VALUES_PER_SM
201 + asmComponent;
236 + asmComponent;
202 offsetASM = // NO TIME OFFSET
237 offsetASM = // NO TIME OFFSET
203 asmComponent * NB_BINS_PER_SM
238 asmComponent * NB_BINS_PER_SM
204 + ASMIndexStart
239 + ASMIndexStart
205 + frequencyBin * nbBinsToAverage;
240 + frequencyBin * nbBinsToAverage;
206 compressed_spec_mat[ offsetCompressed ] = 0;
241 compressed_spec_mat[ offsetCompressed ] = 0;
207 for ( k = 0; k < nbBinsToAverage; k++ )
242 for ( k = 0; k < nbBinsToAverage; k++ )
208 {
243 {
209 compressed_spec_mat[offsetCompressed ] =
244 compressed_spec_mat[offsetCompressed ] =
210 ( compressed_spec_mat[ offsetCompressed ]
245 ( compressed_spec_mat[ offsetCompressed ]
211 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
246 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
212 }
247 }
213 }
248 }
214 }
249 }
215 }
250 }
216
251
217 void ASM_convert( volatile float *input_matrix, char *output_matrix)
252 void ASM_convert( volatile float *input_matrix, char *output_matrix)
218 {
253 {
219 unsigned int frequencyBin;
254 unsigned int frequencyBin;
220 unsigned int asmComponent;
255 unsigned int asmComponent;
221 char * pt_char_input;
256 char * pt_char_input;
222 char * pt_char_output;
257 char * pt_char_output;
223 unsigned int offsetInput;
258 unsigned int offsetInput;
224 unsigned int offsetOutput;
259 unsigned int offsetOutput;
225
260
226 pt_char_input = (char*) &input_matrix;
261 pt_char_input = (char*) &input_matrix;
227 pt_char_output = (char*) &output_matrix;
262 pt_char_output = (char*) &output_matrix;
228
263
229 // convert all other data
264 // convert all other data
230 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
265 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
231 {
266 {
232 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
267 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
233 {
268 {
234 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
269 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
235 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
270 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
236 pt_char_input = (char*) &input_matrix [ offsetInput ];
271 pt_char_input = (char*) &input_matrix [ offsetInput ];
237 pt_char_output = (char*) &output_matrix[ offsetOutput ];
272 pt_char_output = (char*) &output_matrix[ offsetOutput ];
238 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
273 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
239 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
274 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
240 }
275 }
241 }
276 }
242 }
277 }
243
278
244 #endif // FSW_PROCESSING_H_INCLUDED
279 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,93 +1,88
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_buffer_f0[ ];
21 extern volatile int wf_snap_f1[ ];
21 extern volatile int wf_buffer_f1[ ];
22 extern volatile int wf_snap_f2[ ];
22 extern volatile int wf_buffer_f2[ ];
23 extern volatile int wf_cont_f3[ ];
23 extern volatile int wf_buffer_f3[ ];
24 extern char wf_cont_f3_light[ ];
24 extern char wf_cont_f3_light[ ];
25
25
26 extern waveform_picker_regs_0_1_18_t *waveform_picker_regs;
26 extern waveform_picker_regs_0_1_18_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 WFP_init_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_ring( ring_node ring[], unsigned char nbNodes, volatile int buffer[] , unsigned int bufferSize );
56 void WFP_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 );
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 );
58 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
61 //
59 //
62 int send_waveform_SWF( ring_node *ring_node_to_send, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
60 int send_waveform_CWF3_light(ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id );
63 int send_waveform_CWF( ring_node *ring_node_to_send, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 int send_waveform_CWF3_light( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 int send_ring_node_CWF( ring_node *ring_node_to_send );
66 //
61 //
67 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
62 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
68 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
63 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 );
64 void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel );
70 void snapshot_resynchronization( unsigned char *timePtr );
65 void snapshot_resynchronization( unsigned char *timePtr );
71 //
66 //
72 rtems_id get_pkts_queue_id( void );
67 rtems_id get_pkts_queue_id( void );
73
68
74 //**************
69 //**************
75 // wfp registers
70 // wfp registers
76 // RESET
71 // RESET
77 void reset_wfp_burst_enable( void );
72 void reset_wfp_burst_enable( void );
78 void reset_wfp_status( void );
73 void reset_wfp_status( void );
79 void reset_wfp_buffer_addresses( void );
74 void reset_wfp_buffer_addresses( void );
80 void reset_waveform_picker_regs( void );
75 void reset_waveform_picker_regs( void );
81 // SET
76 // SET
82 void set_wfp_data_shaping(void);
77 void set_wfp_data_shaping(void);
83 void set_wfp_burst_enable_register( unsigned char mode );
78 void set_wfp_burst_enable_register( unsigned char mode );
84 void set_wfp_delta_snapshot( void );
79 void set_wfp_delta_snapshot( void );
85 void set_wfp_delta_f0_f0_2( void );
80 void set_wfp_delta_f0_f0_2( void );
86 void set_wfp_delta_f1( void );
81 void set_wfp_delta_f1( void );
87 void set_wfp_delta_f2( void );
82 void set_wfp_delta_f2( void );
88
83
89 //*****************
84 //*****************
90 // local parameters
85 // local parameters
91 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
86 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
92
87
93 #endif // WF_HANDLER_H_INCLUDED
88 #endif // WF_HANDLER_H_INCLUDED
@@ -1,75 +1,75
1 /** Global variables of the LFR flight software.
1 /** Global variables of the LFR flight software.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * Among global variables, there are:
6 * Among global variables, there are:
7 * - RTEMS names and id.
7 * - RTEMS names and id.
8 * - APB configuration registers.
8 * - APB configuration registers.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
11 * - variable related to LFR modes parameters.
11 * - variable related to LFR modes parameters.
12 * - the global HK packet buffer.
12 * - the global HK packet buffer.
13 * - the global dump parameter buffer.
13 * - the global dump parameter buffer.
14 *
14 *
15 */
15 */
16
16
17 #include <rtems.h>
17 #include <rtems.h>
18 #include <grspw.h>
18 #include <grspw.h>
19
19
20 #include "ccsds_types.h"
20 #include "ccsds_types.h"
21 #include "grlib_regs.h"
21 #include "grlib_regs.h"
22 #include "fsw_params.h"
22 #include "fsw_params.h"
23 #include "fsw_params_wf_handler.h"
23 #include "fsw_params_wf_handler.h"
24
24
25 // RTEMS GLOBAL VARIABLES
25 // RTEMS GLOBAL VARIABLES
26 rtems_name misc_name[5];
26 rtems_name misc_name[5];
27 rtems_id misc_id[5];
27 rtems_id misc_id[5];
28 rtems_name Task_name[20]; /* array of task names */
28 rtems_name Task_name[20]; /* array of task names */
29 rtems_id Task_id[20]; /* array of task ids */
29 rtems_id Task_id[20]; /* array of task ids */
30 unsigned int maxCount;
30 unsigned int maxCount;
31 int fdSPW = 0;
31 int fdSPW = 0;
32 int fdUART = 0;
32 int fdUART = 0;
33 unsigned char lfrCurrentMode;
33 unsigned char lfrCurrentMode;
34
34
35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
39 // F0 F1 F2 F3
39 // F0 F1 F2 F3
40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
40 volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
45
45
46 //***********************************
46 //***********************************
47 // SPECTRAL MATRICES GLOBAL VARIABLES
47 // SPECTRAL MATRICES GLOBAL VARIABLES
48
48
49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53
53
54 // APB CONFIGURATION REGISTERS
54 // APB CONFIGURATION REGISTERS
55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
57 waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER;
57 waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER;
58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
59
59
60 // MODE PARAMETERS
60 // MODE PARAMETERS
61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
62 struct param_local_str param_local;
62 struct param_local_str param_local;
63
63
64 // HK PACKETS
64 // HK PACKETS
65 Packet_TM_LFR_HK_t housekeeping_packet;
65 Packet_TM_LFR_HK_t housekeeping_packet;
66 // sequence counters are incremented by APID (PID + CAT) and destination ID
66 // sequence counters are incremented by APID (PID + CAT) and destination ID
67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
70 unsigned short sequenceCounterHK;
70 unsigned short sequenceCounterHK;
71 unsigned short sequenceCounterParameterDump;
71 unsigned short sequenceCounterParameterDump;
72 spw_stats spacewire_stats;
72 spw_stats spacewire_stats;
73 spw_stats spacewire_stats_backup;
73 spw_stats spacewire_stats_backup;
74
74
75
75
@@ -1,782 +1,782
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 #endif
42 #endif
43
43
44 #include <rtems/confdefs.h>
44 #include <rtems/confdefs.h>
45
45
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef RTEMS_DRVMGR_STARTUP
48 #ifdef LEON3
48 #ifdef LEON3
49 /* Add Timer and UART Driver */
49 /* Add Timer and UART Driver */
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #endif
52 #endif
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 #endif
55 #endif
56 #endif
56 #endif
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 #include <drvmgr/drvmgr_confdefs.h>
58 #include <drvmgr/drvmgr_confdefs.h>
59 #endif
59 #endif
60
60
61 #include "fsw_init.h"
61 #include "fsw_init.h"
62 #include "fsw_config.c"
62 #include "fsw_config.c"
63
63
64 rtems_task Init( rtems_task_argument ignored )
64 rtems_task Init( rtems_task_argument ignored )
65 {
65 {
66 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 /** This is the RTEMS INIT taks, it the first task launched by the system.
67 *
67 *
68 * @param unused is the starting argument of the RTEMS task
68 * @param unused is the starting argument of the RTEMS task
69 *
69 *
70 * The INIT task create and run all other RTEMS tasks.
70 * The INIT task create and run all other RTEMS tasks.
71 *
71 *
72 */
72 */
73
73
74 unsigned char *vhdlVersion;
74 unsigned char *vhdlVersion;
75
75
76 reset_lfr();
76 reset_lfr();
77
77
78 reset_local_time();
78 reset_local_time();
79
79
80 rtems_cpu_usage_reset();
80 rtems_cpu_usage_reset();
81
81
82 rtems_status_code status;
82 rtems_status_code status;
83 rtems_status_code status_spw;
83 rtems_status_code status_spw;
84 rtems_isr_entry old_isr_handler;
84 rtems_isr_entry old_isr_handler;
85
85
86 // UART settings
86 // UART settings
87 send_console_outputs_on_apbuart_port();
87 send_console_outputs_on_apbuart_port();
88 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
88 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
89 enable_apbuart_transmitter();
89 enable_apbuart_transmitter();
90 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
90 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
91
91
92 PRINTF("\n\n\n\n\n")
92 PRINTF("\n\n\n\n\n")
93 PRINTF("*************************\n")
93 PRINTF("*************************\n")
94 PRINTF("** LFR Flight Software **\n")
94 PRINTF("** LFR Flight Software **\n")
95 PRINTF1("** %d.", SW_VERSION_N1)
95 PRINTF1("** %d.", SW_VERSION_N1)
96 PRINTF1("%d." , SW_VERSION_N2)
96 PRINTF1("%d." , SW_VERSION_N2)
97 PRINTF1("%d." , SW_VERSION_N3)
97 PRINTF1("%d." , SW_VERSION_N3)
98 PRINTF1("%d **\n", SW_VERSION_N4)
98 PRINTF1("%d **\n", SW_VERSION_N4)
99
99
100 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
100 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
101 PRINTF("** VHDL **\n")
101 PRINTF("** VHDL **\n")
102 PRINTF1("** %d.", vhdlVersion[1])
102 PRINTF1("** %d.", vhdlVersion[1])
103 PRINTF1("%d." , vhdlVersion[2])
103 PRINTF1("%d." , vhdlVersion[2])
104 PRINTF1("%d **\n", vhdlVersion[3])
104 PRINTF1("%d **\n", vhdlVersion[3])
105 PRINTF("*************************\n")
105 PRINTF("*************************\n")
106 PRINTF("\n\n")
106 PRINTF("\n\n")
107
107
108 init_parameter_dump();
108 init_parameter_dump();
109 init_local_mode_parameters();
109 init_local_mode_parameters();
110 init_housekeeping_parameters();
110 init_housekeeping_parameters();
111
111
112 // waveform picker initialization
112 // waveform picker initialization
113 WFP_init_rings(); // initialize the waveform rings
113 WFP_init_rings(); // initialize the waveform rings
114 WFP_reset_current_ring_nodes();
114 WFP_reset_current_ring_nodes();
115 reset_waveform_picker_regs();
115 reset_waveform_picker_regs();
116
116
117 // spectral matrices initialization
117 // spectral matrices initialization
118 SM_init_rings(); // initialize spectral matrices rings
118 SM_init_rings(); // initialize spectral matrices rings
119 SM_reset_current_ring_nodes();
119 SM_reset_current_ring_nodes();
120 reset_spectral_matrix_regs();
120 reset_spectral_matrix_regs();
121
121
122 updateLFRCurrentMode();
122 updateLFRCurrentMode();
123
123
124 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
124 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
125
125
126 create_names(); // create all names
126 create_names(); // create all names
127
127
128 status = create_message_queues(); // create message queues
128 status = create_message_queues(); // create message queues
129 if (status != RTEMS_SUCCESSFUL)
129 if (status != RTEMS_SUCCESSFUL)
130 {
130 {
131 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
131 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
132 }
132 }
133
133
134 status = create_all_tasks(); // create all tasks
134 status = create_all_tasks(); // create all tasks
135 if (status != RTEMS_SUCCESSFUL)
135 if (status != RTEMS_SUCCESSFUL)
136 {
136 {
137 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
137 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
138 }
138 }
139
139
140 // **************************
140 // **************************
141 // <SPACEWIRE INITIALIZATION>
141 // <SPACEWIRE INITIALIZATION>
142 grspw_timecode_callback = &timecode_irq_handler;
142 grspw_timecode_callback = &timecode_irq_handler;
143
143
144 status_spw = spacewire_open_link(); // (1) open the link
144 status_spw = spacewire_open_link(); // (1) open the link
145 if ( status_spw != RTEMS_SUCCESSFUL )
145 if ( status_spw != RTEMS_SUCCESSFUL )
146 {
146 {
147 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
147 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
148 }
148 }
149
149
150 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
150 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
151 {
151 {
152 status_spw = spacewire_configure_link( fdSPW );
152 status_spw = spacewire_configure_link( fdSPW );
153 if ( status_spw != RTEMS_SUCCESSFUL )
153 if ( status_spw != RTEMS_SUCCESSFUL )
154 {
154 {
155 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
155 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
156 }
156 }
157 }
157 }
158
158
159 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
159 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
160 {
160 {
161 status_spw = spacewire_start_link( fdSPW );
161 status_spw = spacewire_start_link( fdSPW );
162 if ( status_spw != RTEMS_SUCCESSFUL )
162 if ( status_spw != RTEMS_SUCCESSFUL )
163 {
163 {
164 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
164 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
165 }
165 }
166 }
166 }
167 // </SPACEWIRE INITIALIZATION>
167 // </SPACEWIRE INITIALIZATION>
168 // ***************************
168 // ***************************
169
169
170 status = start_all_tasks(); // start all tasks
170 status = start_all_tasks(); // start all tasks
171 if (status != RTEMS_SUCCESSFUL)
171 if (status != RTEMS_SUCCESSFUL)
172 {
172 {
173 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
173 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
174 }
174 }
175
175
176 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
176 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
177 status = start_recv_send_tasks();
177 status = start_recv_send_tasks();
178 if ( status != RTEMS_SUCCESSFUL )
178 if ( status != RTEMS_SUCCESSFUL )
179 {
179 {
180 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
180 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
181 }
181 }
182
182
183 // suspend science tasks, they will be restarted later depending on the mode
183 // suspend science tasks, they will be restarted later depending on the mode
184 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
184 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
185 if (status != RTEMS_SUCCESSFUL)
185 if (status != RTEMS_SUCCESSFUL)
186 {
186 {
187 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
187 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
188 }
188 }
189
189
190 //******************************
190 //******************************
191 // <SPECTRAL MATRICES SIMULATOR>
191 // <SPECTRAL MATRICES SIMULATOR>
192 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
192 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
193 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
193 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
194 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
194 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
195 // </SPECTRAL MATRICES SIMULATOR>
195 // </SPECTRAL MATRICES SIMULATOR>
196 //*******************************
196 //*******************************
197
197
198 // configure IRQ handling for the waveform picker unit
198 // configure IRQ handling for the waveform picker unit
199 status = rtems_interrupt_catch( waveforms_isr,
199 status = rtems_interrupt_catch( waveforms_isr,
200 IRQ_SPARC_WAVEFORM_PICKER,
200 IRQ_SPARC_WAVEFORM_PICKER,
201 &old_isr_handler) ;
201 &old_isr_handler) ;
202 // configure IRQ handling for the spectral matrices unit
202 // configure IRQ handling for the spectral matrices unit
203 status = rtems_interrupt_catch( spectral_matrices_isr,
203 status = rtems_interrupt_catch( spectral_matrices_isr,
204 IRQ_SPARC_SPECTRAL_MATRIX,
204 IRQ_SPARC_SPECTRAL_MATRIX,
205 &old_isr_handler) ;
205 &old_isr_handler) ;
206
206
207 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
207 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
208 if ( status_spw != RTEMS_SUCCESSFUL )
208 if ( status_spw != RTEMS_SUCCESSFUL )
209 {
209 {
210 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
210 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
211 if ( status != RTEMS_SUCCESSFUL ) {
211 if ( status != RTEMS_SUCCESSFUL ) {
212 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
212 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
213 }
213 }
214 }
214 }
215
215
216 BOOT_PRINTF("delete INIT\n")
216 BOOT_PRINTF("delete INIT\n")
217
217
218 status = rtems_task_delete(RTEMS_SELF);
218 status = rtems_task_delete(RTEMS_SELF);
219
219
220 }
220 }
221
221
222 void init_local_mode_parameters( void )
222 void init_local_mode_parameters( void )
223 {
223 {
224 /** This function initialize the param_local global variable with default values.
224 /** This function initialize the param_local global variable with default values.
225 *
225 *
226 */
226 */
227
227
228 unsigned int i;
228 unsigned int i;
229
229
230 // LOCAL PARAMETERS
230 // LOCAL PARAMETERS
231
231
232 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
232 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
233 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
233 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
234 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
234 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
235
235
236 // init sequence counters
236 // init sequence counters
237
237
238 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
238 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
239 {
239 {
240 sequenceCounters_TC_EXE[i] = 0x00;
240 sequenceCounters_TC_EXE[i] = 0x00;
241 }
241 }
242 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
242 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
243 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
243 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
244 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
244 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
245 sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
245 sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
246 }
246 }
247
247
248 void reset_local_time( void )
248 void reset_local_time( void )
249 {
249 {
250 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
250 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
251 }
251 }
252
252
253 void create_names( void ) // create all names for tasks and queues
253 void create_names( void ) // create all names for tasks and queues
254 {
254 {
255 /** This function creates all RTEMS names used in the software for tasks and queues.
255 /** This function creates all RTEMS names used in the software for tasks and queues.
256 *
256 *
257 * @return RTEMS directive status codes:
257 * @return RTEMS directive status codes:
258 * - RTEMS_SUCCESSFUL - successful completion
258 * - RTEMS_SUCCESSFUL - successful completion
259 *
259 *
260 */
260 */
261
261
262 // task names
262 // task names
263 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
263 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
264 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
264 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
265 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
265 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
266 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
266 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
267 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
267 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
268 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
268 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
269 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
269 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
270 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
270 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
271 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
271 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
272 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
272 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
273 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
273 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
274 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
274 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
275 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
275 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
276 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
276 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
277 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
277 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
278 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
278 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
279 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
279 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
280 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
280 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
281 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
281 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
282
282
283 // rate monotonic period names
283 // rate monotonic period names
284 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
284 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
285
285
286 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
286 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
287 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
287 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
288 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
288 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
289 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
289 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
290 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
290 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
291 }
291 }
292
292
293 int create_all_tasks( void ) // create all tasks which run in the software
293 int create_all_tasks( void ) // create all tasks which run in the software
294 {
294 {
295 /** This function creates all RTEMS tasks used in the software.
295 /** This function creates all RTEMS tasks used in the software.
296 *
296 *
297 * @return RTEMS directive status codes:
297 * @return RTEMS directive status codes:
298 * - RTEMS_SUCCESSFUL - task created successfully
298 * - RTEMS_SUCCESSFUL - task created successfully
299 * - RTEMS_INVALID_ADDRESS - id is NULL
299 * - RTEMS_INVALID_ADDRESS - id is NULL
300 * - RTEMS_INVALID_NAME - invalid task name
300 * - RTEMS_INVALID_NAME - invalid task name
301 * - RTEMS_INVALID_PRIORITY - invalid task priority
301 * - RTEMS_INVALID_PRIORITY - invalid task priority
302 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
302 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
303 * - RTEMS_TOO_MANY - too many tasks created
303 * - RTEMS_TOO_MANY - too many tasks created
304 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
304 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
305 * - RTEMS_TOO_MANY - too many global objects
305 * - RTEMS_TOO_MANY - too many global objects
306 *
306 *
307 */
307 */
308
308
309 rtems_status_code status;
309 rtems_status_code status;
310
310
311 //**********
311 //**********
312 // SPACEWIRE
312 // SPACEWIRE
313 // RECV
313 // RECV
314 status = rtems_task_create(
314 status = rtems_task_create(
315 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
315 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
316 RTEMS_DEFAULT_MODES,
316 RTEMS_DEFAULT_MODES,
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
318 );
318 );
319 if (status == RTEMS_SUCCESSFUL) // SEND
319 if (status == RTEMS_SUCCESSFUL) // SEND
320 {
320 {
321 status = rtems_task_create(
321 status = rtems_task_create(
322 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
322 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
323 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
323 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
324 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
324 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
325 );
325 );
326 }
326 }
327 if (status == RTEMS_SUCCESSFUL) // WTDG
327 if (status == RTEMS_SUCCESSFUL) // WTDG
328 {
328 {
329 status = rtems_task_create(
329 status = rtems_task_create(
330 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
330 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
331 RTEMS_DEFAULT_MODES,
331 RTEMS_DEFAULT_MODES,
332 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
332 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
333 );
333 );
334 }
334 }
335 if (status == RTEMS_SUCCESSFUL) // ACTN
335 if (status == RTEMS_SUCCESSFUL) // ACTN
336 {
336 {
337 status = rtems_task_create(
337 status = rtems_task_create(
338 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
338 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
339 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
339 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
340 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
340 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
341 );
341 );
342 }
342 }
343 if (status == RTEMS_SUCCESSFUL) // SPIQ
343 if (status == RTEMS_SUCCESSFUL) // SPIQ
344 {
344 {
345 status = rtems_task_create(
345 status = rtems_task_create(
346 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
346 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
347 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
348 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
348 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
349 );
349 );
350 }
350 }
351
351
352 //******************
352 //******************
353 // SPECTRAL MATRICES
353 // SPECTRAL MATRICES
354 if (status == RTEMS_SUCCESSFUL) // AVF0
354 if (status == RTEMS_SUCCESSFUL) // AVF0
355 {
355 {
356 status = rtems_task_create(
356 status = rtems_task_create(
357 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
357 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
358 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
358 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
360 );
360 );
361 }
361 }
362 if (status == RTEMS_SUCCESSFUL) // PRC0
362 if (status == RTEMS_SUCCESSFUL) // PRC0
363 {
363 {
364 status = rtems_task_create(
364 status = rtems_task_create(
365 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
365 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
366 RTEMS_DEFAULT_MODES,
366 RTEMS_DEFAULT_MODES,
367 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
367 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
368 );
368 );
369 }
369 }
370 if (status == RTEMS_SUCCESSFUL) // AVF1
370 if (status == RTEMS_SUCCESSFUL) // AVF1
371 {
371 {
372 status = rtems_task_create(
372 status = rtems_task_create(
373 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
373 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
374 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
374 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
375 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
375 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
376 );
376 );
377 }
377 }
378 if (status == RTEMS_SUCCESSFUL) // PRC1
378 if (status == RTEMS_SUCCESSFUL) // PRC1
379 {
379 {
380 status = rtems_task_create(
380 status = rtems_task_create(
381 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
381 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
382 RTEMS_DEFAULT_MODES,
382 RTEMS_DEFAULT_MODES,
383 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
383 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
384 );
384 );
385 }
385 }
386 if (status == RTEMS_SUCCESSFUL) // AVF2
386 if (status == RTEMS_SUCCESSFUL) // AVF2
387 {
387 {
388 status = rtems_task_create(
388 status = rtems_task_create(
389 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
389 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
390 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
390 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
391 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
391 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
392 );
392 );
393 }
393 }
394 if (status == RTEMS_SUCCESSFUL) // PRC2
394 if (status == RTEMS_SUCCESSFUL) // PRC2
395 {
395 {
396 status = rtems_task_create(
396 status = rtems_task_create(
397 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
397 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
398 RTEMS_DEFAULT_MODES,
398 RTEMS_DEFAULT_MODES,
399 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
399 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
400 );
400 );
401 }
401 }
402
402
403 //****************
403 //****************
404 // WAVEFORM PICKER
404 // WAVEFORM PICKER
405 if (status == RTEMS_SUCCESSFUL) // WFRM
405 if (status == RTEMS_SUCCESSFUL) // WFRM
406 {
406 {
407 status = rtems_task_create(
407 status = rtems_task_create(
408 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
408 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
409 RTEMS_DEFAULT_MODES,
409 RTEMS_DEFAULT_MODES,
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
411 );
411 );
412 }
412 }
413 if (status == RTEMS_SUCCESSFUL) // CWF3
413 if (status == RTEMS_SUCCESSFUL) // CWF3
414 {
414 {
415 status = rtems_task_create(
415 status = rtems_task_create(
416 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
416 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
417 RTEMS_DEFAULT_MODES,
417 RTEMS_DEFAULT_MODES,
418 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
418 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
419 );
419 );
420 }
420 }
421 if (status == RTEMS_SUCCESSFUL) // CWF2
421 if (status == RTEMS_SUCCESSFUL) // CWF2
422 {
422 {
423 status = rtems_task_create(
423 status = rtems_task_create(
424 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
424 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
425 RTEMS_DEFAULT_MODES,
425 RTEMS_DEFAULT_MODES,
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
427 );
427 );
428 }
428 }
429 if (status == RTEMS_SUCCESSFUL) // CWF1
429 if (status == RTEMS_SUCCESSFUL) // CWF1
430 {
430 {
431 status = rtems_task_create(
431 status = rtems_task_create(
432 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
432 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
433 RTEMS_DEFAULT_MODES,
433 RTEMS_DEFAULT_MODES,
434 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
434 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
435 );
435 );
436 }
436 }
437 if (status == RTEMS_SUCCESSFUL) // SWBD
437 if (status == RTEMS_SUCCESSFUL) // SWBD
438 {
438 {
439 status = rtems_task_create(
439 status = rtems_task_create(
440 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
440 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
441 RTEMS_DEFAULT_MODES,
441 RTEMS_DEFAULT_MODES,
442 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
442 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
443 );
443 );
444 }
444 }
445
445
446 //*****
446 //*****
447 // MISC
447 // MISC
448 if (status == RTEMS_SUCCESSFUL) // STAT
448 if (status == RTEMS_SUCCESSFUL) // STAT
449 {
449 {
450 status = rtems_task_create(
450 status = rtems_task_create(
451 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
451 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
452 RTEMS_DEFAULT_MODES,
452 RTEMS_DEFAULT_MODES,
453 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
453 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
454 );
454 );
455 }
455 }
456 if (status == RTEMS_SUCCESSFUL) // DUMB
456 if (status == RTEMS_SUCCESSFUL) // DUMB
457 {
457 {
458 status = rtems_task_create(
458 status = rtems_task_create(
459 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
459 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
460 RTEMS_DEFAULT_MODES,
460 RTEMS_DEFAULT_MODES,
461 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
461 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
462 );
462 );
463 }
463 }
464 if (status == RTEMS_SUCCESSFUL) // HOUS
464 if (status == RTEMS_SUCCESSFUL) // HOUS
465 {
465 {
466 status = rtems_task_create(
466 status = rtems_task_create(
467 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
467 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
470 );
470 );
471 }
471 }
472
472
473 return status;
473 return status;
474 }
474 }
475
475
476 int start_recv_send_tasks( void )
476 int start_recv_send_tasks( void )
477 {
477 {
478 rtems_status_code status;
478 rtems_status_code status;
479
479
480 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
480 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
481 if (status!=RTEMS_SUCCESSFUL) {
481 if (status!=RTEMS_SUCCESSFUL) {
482 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
482 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
483 }
483 }
484
484
485 if (status == RTEMS_SUCCESSFUL) // SEND
485 if (status == RTEMS_SUCCESSFUL) // SEND
486 {
486 {
487 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
487 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
488 if (status!=RTEMS_SUCCESSFUL) {
488 if (status!=RTEMS_SUCCESSFUL) {
489 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
489 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
490 }
490 }
491 }
491 }
492
492
493 return status;
493 return status;
494 }
494 }
495
495
496 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
496 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
497 {
497 {
498 /** This function starts all RTEMS tasks used in the software.
498 /** This function starts all RTEMS tasks used in the software.
499 *
499 *
500 * @return RTEMS directive status codes:
500 * @return RTEMS directive status codes:
501 * - RTEMS_SUCCESSFUL - ask started successfully
501 * - RTEMS_SUCCESSFUL - ask started successfully
502 * - RTEMS_INVALID_ADDRESS - invalid task entry point
502 * - RTEMS_INVALID_ADDRESS - invalid task entry point
503 * - RTEMS_INVALID_ID - invalid task id
503 * - RTEMS_INVALID_ID - invalid task id
504 * - RTEMS_INCORRECT_STATE - task not in the dormant state
504 * - RTEMS_INCORRECT_STATE - task not in the dormant state
505 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
505 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
506 *
506 *
507 */
507 */
508 // starts all the tasks fot eh flight software
508 // starts all the tasks fot eh flight software
509
509
510 rtems_status_code status;
510 rtems_status_code status;
511
511
512 //**********
512 //**********
513 // SPACEWIRE
513 // SPACEWIRE
514 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
514 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
515 if (status!=RTEMS_SUCCESSFUL) {
515 if (status!=RTEMS_SUCCESSFUL) {
516 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
516 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
517 }
517 }
518
518
519 if (status == RTEMS_SUCCESSFUL) // WTDG
519 if (status == RTEMS_SUCCESSFUL) // WTDG
520 {
520 {
521 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
521 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
522 if (status!=RTEMS_SUCCESSFUL) {
522 if (status!=RTEMS_SUCCESSFUL) {
523 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
523 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
524 }
524 }
525 }
525 }
526
526
527 if (status == RTEMS_SUCCESSFUL) // ACTN
527 if (status == RTEMS_SUCCESSFUL) // ACTN
528 {
528 {
529 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
529 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
530 if (status!=RTEMS_SUCCESSFUL) {
530 if (status!=RTEMS_SUCCESSFUL) {
531 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
531 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
532 }
532 }
533 }
533 }
534
534
535 //******************
535 //******************
536 // SPECTRAL MATRICES
536 // SPECTRAL MATRICES
537 if (status == RTEMS_SUCCESSFUL) // AVF0
537 if (status == RTEMS_SUCCESSFUL) // AVF0
538 {
538 {
539 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
539 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
540 if (status!=RTEMS_SUCCESSFUL) {
540 if (status!=RTEMS_SUCCESSFUL) {
541 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
541 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
542 }
542 }
543 }
543 }
544 if (status == RTEMS_SUCCESSFUL) // PRC0
544 if (status == RTEMS_SUCCESSFUL) // PRC0
545 {
545 {
546 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
546 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
547 if (status!=RTEMS_SUCCESSFUL) {
547 if (status!=RTEMS_SUCCESSFUL) {
548 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
548 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
549 }
549 }
550 }
550 }
551 if (status == RTEMS_SUCCESSFUL) // AVF1
551 if (status == RTEMS_SUCCESSFUL) // AVF1
552 {
552 {
553 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
553 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
554 if (status!=RTEMS_SUCCESSFUL) {
554 if (status!=RTEMS_SUCCESSFUL) {
555 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
555 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
556 }
556 }
557 }
557 }
558 if (status == RTEMS_SUCCESSFUL) // PRC1
558 if (status == RTEMS_SUCCESSFUL) // PRC1
559 {
559 {
560 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
560 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
561 if (status!=RTEMS_SUCCESSFUL) {
561 if (status!=RTEMS_SUCCESSFUL) {
562 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
562 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
563 }
563 }
564 }
564 }
565 if (status == RTEMS_SUCCESSFUL) // AVF2
565 if (status == RTEMS_SUCCESSFUL) // AVF2
566 {
566 {
567 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
567 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
568 if (status!=RTEMS_SUCCESSFUL) {
568 if (status!=RTEMS_SUCCESSFUL) {
569 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
569 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
570 }
570 }
571 }
571 }
572 if (status == RTEMS_SUCCESSFUL) // PRC2
572 if (status == RTEMS_SUCCESSFUL) // PRC2
573 {
573 {
574 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
574 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
575 if (status!=RTEMS_SUCCESSFUL) {
575 if (status!=RTEMS_SUCCESSFUL) {
576 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
576 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
577 }
577 }
578 }
578 }
579
579
580 //****************
580 //****************
581 // WAVEFORM PICKER
581 // WAVEFORM PICKER
582 if (status == RTEMS_SUCCESSFUL) // WFRM
582 if (status == RTEMS_SUCCESSFUL) // WFRM
583 {
583 {
584 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
584 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
585 if (status!=RTEMS_SUCCESSFUL) {
585 if (status!=RTEMS_SUCCESSFUL) {
586 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
586 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
587 }
587 }
588 }
588 }
589 if (status == RTEMS_SUCCESSFUL) // CWF3
589 if (status == RTEMS_SUCCESSFUL) // CWF3
590 {
590 {
591 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
591 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
592 if (status!=RTEMS_SUCCESSFUL) {
592 if (status!=RTEMS_SUCCESSFUL) {
593 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
593 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
594 }
594 }
595 }
595 }
596 if (status == RTEMS_SUCCESSFUL) // CWF2
596 if (status == RTEMS_SUCCESSFUL) // CWF2
597 {
597 {
598 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
598 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
599 if (status!=RTEMS_SUCCESSFUL) {
599 if (status!=RTEMS_SUCCESSFUL) {
600 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
600 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
601 }
601 }
602 }
602 }
603 if (status == RTEMS_SUCCESSFUL) // CWF1
603 if (status == RTEMS_SUCCESSFUL) // CWF1
604 {
604 {
605 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
605 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
606 if (status!=RTEMS_SUCCESSFUL) {
606 if (status!=RTEMS_SUCCESSFUL) {
607 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
607 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
608 }
608 }
609 }
609 }
610 if (status == RTEMS_SUCCESSFUL) // SWBD
610 if (status == RTEMS_SUCCESSFUL) // SWBD
611 {
611 {
612 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
612 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
613 if (status!=RTEMS_SUCCESSFUL) {
613 if (status!=RTEMS_SUCCESSFUL) {
614 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
614 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
615 }
615 }
616 }
616 }
617
617
618 //*****
618 //*****
619 // MISC
619 // MISC
620 if (status == RTEMS_SUCCESSFUL) // HOUS
620 if (status == RTEMS_SUCCESSFUL) // HOUS
621 {
621 {
622 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
622 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
623 if (status!=RTEMS_SUCCESSFUL) {
623 if (status!=RTEMS_SUCCESSFUL) {
624 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
624 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
625 }
625 }
626 }
626 }
627 if (status == RTEMS_SUCCESSFUL) // DUMB
627 if (status == RTEMS_SUCCESSFUL) // DUMB
628 {
628 {
629 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
629 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
630 if (status!=RTEMS_SUCCESSFUL) {
630 if (status!=RTEMS_SUCCESSFUL) {
631 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
631 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
632 }
632 }
633 }
633 }
634 if (status == RTEMS_SUCCESSFUL) // STAT
634 if (status == RTEMS_SUCCESSFUL) // STAT
635 {
635 {
636 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
636 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
637 if (status!=RTEMS_SUCCESSFUL) {
637 if (status!=RTEMS_SUCCESSFUL) {
638 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
638 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
639 }
639 }
640 }
640 }
641
641
642 return status;
642 return status;
643 }
643 }
644
644
645 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
645 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
646 {
646 {
647 rtems_status_code status_recv;
647 rtems_status_code status_recv;
648 rtems_status_code status_send;
648 rtems_status_code status_send;
649 rtems_status_code status_q_p0;
649 rtems_status_code status_q_p0;
650 rtems_status_code status_q_p1;
650 rtems_status_code status_q_p1;
651 rtems_status_code status_q_p2;
651 rtems_status_code status_q_p2;
652 rtems_status_code ret;
652 rtems_status_code ret;
653 rtems_id queue_id;
653 rtems_id queue_id;
654
654
655 //****************************************
655 //****************************************
656 // create the queue for handling valid TCs
656 // create the queue for handling valid TCs
657 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
657 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
658 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
658 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
659 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
659 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
660 if ( status_recv != RTEMS_SUCCESSFUL ) {
660 if ( status_recv != RTEMS_SUCCESSFUL ) {
661 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
661 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
662 }
662 }
663
663
664 //************************************************
664 //************************************************
665 // create the queue for handling TM packet sending
665 // create the queue for handling TM packet sending
666 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
666 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
667 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
667 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
668 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
668 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
669 if ( status_send != RTEMS_SUCCESSFUL ) {
669 if ( status_send != RTEMS_SUCCESSFUL ) {
670 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
670 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
671 }
671 }
672
672
673 //*****************************************************************************
673 //*****************************************************************************
674 // create the queue for handling averaged spectral matrices for processing @ f0
674 // create the queue for handling averaged spectral matrices for processing @ f0
675 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
675 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
676 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
676 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
677 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
677 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
678 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
678 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
679 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
679 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
680 }
680 }
681
681
682 //*****************************************************************************
682 //*****************************************************************************
683 // create the queue for handling averaged spectral matrices for processing @ f1
683 // create the queue for handling averaged spectral matrices for processing @ f1
684 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
684 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
685 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
685 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
686 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
686 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
687 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
687 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
688 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
688 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
689 }
689 }
690
690
691 //*****************************************************************************
691 //*****************************************************************************
692 // create the queue for handling averaged spectral matrices for processing @ f2
692 // create the queue for handling averaged spectral matrices for processing @ f2
693 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
693 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
694 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
694 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
695 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
695 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
696 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
696 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
697 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
697 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
698 }
698 }
699
699
700 if ( status_recv != RTEMS_SUCCESSFUL )
700 if ( status_recv != RTEMS_SUCCESSFUL )
701 {
701 {
702 ret = status_recv;
702 ret = status_recv;
703 }
703 }
704 else if( status_send != RTEMS_SUCCESSFUL )
704 else if( status_send != RTEMS_SUCCESSFUL )
705 {
705 {
706 ret = status_send;
706 ret = status_send;
707 }
707 }
708 else if( status_q_p0 != RTEMS_SUCCESSFUL )
708 else if( status_q_p0 != RTEMS_SUCCESSFUL )
709 {
709 {
710 ret = status_q_p0;
710 ret = status_q_p0;
711 }
711 }
712 else if( status_q_p1 != RTEMS_SUCCESSFUL )
712 else if( status_q_p1 != RTEMS_SUCCESSFUL )
713 {
713 {
714 ret = status_q_p1;
714 ret = status_q_p1;
715 }
715 }
716 else
716 else
717 {
717 {
718 ret = status_q_p2;
718 ret = status_q_p2;
719 }
719 }
720
720
721 return ret;
721 return ret;
722 }
722 }
723
723
724 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
724 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
725 {
725 {
726 rtems_status_code status;
726 rtems_status_code status;
727 rtems_name queue_name;
727 rtems_name queue_name;
728
728
729 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
729 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
730
730
731 status = rtems_message_queue_ident( queue_name, 0, queue_id );
731 status = rtems_message_queue_ident( queue_name, 0, queue_id );
732
732
733 return status;
733 return status;
734 }
734 }
735
735
736 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
736 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
737 {
737 {
738 rtems_status_code status;
738 rtems_status_code status;
739 rtems_name queue_name;
739 rtems_name queue_name;
740
740
741 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
741 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
742
742
743 status = rtems_message_queue_ident( queue_name, 0, queue_id );
743 status = rtems_message_queue_ident( queue_name, 0, queue_id );
744
744
745 return status;
745 return status;
746 }
746 }
747
747
748 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
748 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
749 {
749 {
750 rtems_status_code status;
750 rtems_status_code status;
751 rtems_name queue_name;
751 rtems_name queue_name;
752
752
753 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
753 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
754
754
755 status = rtems_message_queue_ident( queue_name, 0, queue_id );
755 status = rtems_message_queue_ident( queue_name, 0, queue_id );
756
756
757 return status;
757 return status;
758 }
758 }
759
759
760 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
760 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
761 {
761 {
762 rtems_status_code status;
762 rtems_status_code status;
763 rtems_name queue_name;
763 rtems_name queue_name;
764
764
765 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
765 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
766
766
767 status = rtems_message_queue_ident( queue_name, 0, queue_id );
767 status = rtems_message_queue_ident( queue_name, 0, queue_id );
768
768
769 return status;
769 return status;
770 }
770 }
771
771
772 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
772 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
773 {
773 {
774 rtems_status_code status;
774 rtems_status_code status;
775 rtems_name queue_name;
775 rtems_name queue_name;
776
776
777 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
777 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
778
778
779 status = rtems_message_queue_ident( queue_name, 0, queue_id );
779 status = rtems_message_queue_ident( queue_name, 0, queue_id );
780
780
781 return status;
781 return status;
782 }
782 }
@@ -1,635 +1,574
1 /** General usage functions and RTEMS tasks.
1 /** General usage functions and RTEMS tasks.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 */
6 */
7
7
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9
9
10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 {
12 {
13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 *
14 *
15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 * @param interrupt_level is the interrupt level that the timer drives.
18 * @param interrupt_level is the interrupt level that the timer drives.
19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 *
20 *
21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 *
22 *
23 */
23 */
24
24
25 rtems_status_code status;
25 rtems_status_code status;
26 rtems_isr_entry old_isr_handler;
26 rtems_isr_entry old_isr_handler;
27
27
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29
29
30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 if (status!=RTEMS_SUCCESSFUL)
31 if (status!=RTEMS_SUCCESSFUL)
32 {
32 {
33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 }
34 }
35
35
36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
37 }
37 }
38
38
39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
40 {
40 {
41 /** This function starts a GPTIMER timer.
41 /** This function starts a GPTIMER timer.
42 *
42 *
43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 *
45 *
46 */
46 */
47
47
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 }
53 }
54
54
55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
56 {
56 {
57 /** This function stops a GPTIMER timer.
57 /** This function stops a GPTIMER timer.
58 *
58 *
59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 *
61 *
62 */
62 */
63
63
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 }
67 }
68
68
69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
70 {
70 {
71 /** This function sets the clock divider of a GPTIMER timer.
71 /** This function sets the clock divider of a GPTIMER timer.
72 *
72 *
73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 *
76 *
77 */
77 */
78
78
79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 }
80 }
81
81
82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
83 {
83 {
84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
85
85
86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
87
87
88 return 0;
88 return 0;
89 }
89 }
90
90
91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
92 {
92 {
93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
94
94
95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
96
96
97 return 0;
97 return 0;
98 }
98 }
99
99
100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
101 {
101 {
102 /** This function sets the scaler reload register of the apbuart module
102 /** This function sets the scaler reload register of the apbuart module
103 *
103 *
104 * @param regs is the address of the apbuart registers in memory
104 * @param regs is the address of the apbuart registers in memory
105 * @param value is the value that will be stored in the scaler register
105 * @param value is the value that will be stored in the scaler register
106 *
106 *
107 * The value shall be set by the software to get data on the serial interface.
107 * The value shall be set by the software to get data on the serial interface.
108 *
108 *
109 */
109 */
110
110
111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
112
112
113 apbuart_regs->scaler = value;
113 apbuart_regs->scaler = value;
114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
115 }
115 }
116
116
117 //************
117 //************
118 // RTEMS TASKS
118 // RTEMS TASKS
119
119
120 rtems_task stat_task(rtems_task_argument argument)
120 rtems_task stat_task(rtems_task_argument argument)
121 {
121 {
122 int i;
122 int i;
123 int j;
123 int j;
124 i = 0;
124 i = 0;
125 j = 0;
125 j = 0;
126 BOOT_PRINTF("in STAT *** \n")
126 BOOT_PRINTF("in STAT *** \n")
127 while(1){
127 while(1){
128 rtems_task_wake_after(1000);
128 rtems_task_wake_after(1000);
129 PRINTF1("%d\n", j)
129 PRINTF1("%d\n", j)
130 if (i == CPU_USAGE_REPORT_PERIOD) {
130 if (i == CPU_USAGE_REPORT_PERIOD) {
131 // #ifdef PRINT_TASK_STATISTICS
131 // #ifdef PRINT_TASK_STATISTICS
132 // rtems_cpu_usage_report();
132 // rtems_cpu_usage_report();
133 // rtems_cpu_usage_reset();
133 // rtems_cpu_usage_reset();
134 // #endif
134 // #endif
135 i = 0;
135 i = 0;
136 }
136 }
137 else i++;
137 else i++;
138 j++;
138 j++;
139 }
139 }
140 }
140 }
141
141
142 rtems_task hous_task(rtems_task_argument argument)
142 rtems_task hous_task(rtems_task_argument argument)
143 {
143 {
144 rtems_status_code status;
144 rtems_status_code status;
145 rtems_status_code spare_status;
145 rtems_status_code spare_status;
146 rtems_id queue_id;
146 rtems_id queue_id;
147 rtems_rate_monotonic_period_status period_status;
147 rtems_rate_monotonic_period_status period_status;
148
148
149 status = get_message_queue_id_send( &queue_id );
149 status = get_message_queue_id_send( &queue_id );
150 if (status != RTEMS_SUCCESSFUL)
150 if (status != RTEMS_SUCCESSFUL)
151 {
151 {
152 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
153 }
153 }
154
154
155 BOOT_PRINTF("in HOUS ***\n")
155 BOOT_PRINTF("in HOUS ***\n")
156
156
157 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
158 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
159 if( status != RTEMS_SUCCESSFUL ) {
159 if( status != RTEMS_SUCCESSFUL ) {
160 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
160 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
161 }
161 }
162 }
162 }
163
163
164 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
165 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
166 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 housekeeping_packet.reserved = DEFAULT_RESERVED;
167 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 housekeeping_packet.userApplication = CCSDS_USER_APP;
168 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
169 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
170 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
171 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
172 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
173 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
174 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
175 housekeeping_packet.serviceType = TM_TYPE_HK;
175 housekeeping_packet.serviceType = TM_TYPE_HK;
176 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
177 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
178 housekeeping_packet.sid = SID_HK;
178 housekeeping_packet.sid = SID_HK;
179
179
180 status = rtems_rate_monotonic_cancel(HK_id);
180 status = rtems_rate_monotonic_cancel(HK_id);
181 if( status != RTEMS_SUCCESSFUL ) {
181 if( status != RTEMS_SUCCESSFUL ) {
182 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
183 }
183 }
184 else {
184 else {
185 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
186 }
186 }
187
187
188 // startup phase
188 // startup phase
189 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
190 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
191 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
192 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
193 {
193 {
194 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
195 {
195 {
196 break; // break if LFR is synchronized
196 break; // break if LFR is synchronized
197 }
197 }
198 else
198 else
199 {
199 {
200 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
201 // sched_yield();
201 // sched_yield();
202 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
202 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
203 }
203 }
204 }
204 }
205 status = rtems_rate_monotonic_cancel(HK_id);
205 status = rtems_rate_monotonic_cancel(HK_id);
206 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
206 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
207
207
208 while(1){ // launch the rate monotonic task
208 while(1){ // launch the rate monotonic task
209 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
210 if ( status != RTEMS_SUCCESSFUL ) {
210 if ( status != RTEMS_SUCCESSFUL ) {
211 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 PRINTF1( "in HOUS *** ERR period: %d\n", status);
212 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
213 }
213 }
214 else {
214 else {
215 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
215 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
216 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
216 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
217 increment_seq_counter( &sequenceCounterHK );
217 increment_seq_counter( &sequenceCounterHK );
218
218
219 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
219 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
220 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
220 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
221 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
221 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
222 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
222 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
223 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
223 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
224 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
224 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
225
225
226 spacewire_update_statistics();
226 spacewire_update_statistics();
227
227
228 // get_v_e1_e2_f3_alt( housekeeping_packet.hk_lfr_sc_v_f3 );
228 // get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
229 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230
230
231 // SEND PACKET
231 // SEND PACKET
232 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
232 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
233 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
233 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
234 if (status != RTEMS_SUCCESSFUL) {
234 if (status != RTEMS_SUCCESSFUL) {
235 PRINTF1("in HOUS *** ERR send: %d\n", status)
235 PRINTF1("in HOUS *** ERR send: %d\n", status)
236 }
236 }
237 }
237 }
238 }
238 }
239
239
240 PRINTF("in HOUS *** deleting task\n")
240 PRINTF("in HOUS *** deleting task\n")
241
241
242 status = rtems_task_delete( RTEMS_SELF ); // should not return
242 status = rtems_task_delete( RTEMS_SELF ); // should not return
243 printf( "rtems_task_delete returned with status of %d.\n", status );
243 printf( "rtems_task_delete returned with status of %d.\n", status );
244 return;
244 return;
245 }
245 }
246
246
247 rtems_task dumb_task( rtems_task_argument unused )
247 rtems_task dumb_task( rtems_task_argument unused )
248 {
248 {
249 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
249 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
250 *
250 *
251 * @param unused is the starting argument of the RTEMS task
251 * @param unused is the starting argument of the RTEMS task
252 *
252 *
253 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
253 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
254 *
254 *
255 */
255 */
256
256
257 unsigned int i;
257 unsigned int i;
258 unsigned int intEventOut;
258 unsigned int intEventOut;
259 unsigned int coarse_time = 0;
259 unsigned int coarse_time = 0;
260 unsigned int fine_time = 0;
260 unsigned int fine_time = 0;
261 rtems_event_set event_out;
261 rtems_event_set event_out;
262
262
263 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
263 char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0
264 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
264 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
265 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
265 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
266 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
266 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
267 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
267 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
268 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
268 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
269 "ERR HK", // RTEMS_EVENT_6
269 "ERR HK", // RTEMS_EVENT_6
270 "ready for dump", // RTEMS_EVENT_7
270 "ready for dump", // RTEMS_EVENT_7
271 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
271 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
272 "tick", // RTEMS_EVENT_9
272 "tick", // RTEMS_EVENT_9
273 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
273 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
274 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
274 "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11
275 };
275 };
276
276
277 BOOT_PRINTF("in DUMB *** \n")
277 BOOT_PRINTF("in DUMB *** \n")
278
278
279 while(1){
279 while(1){
280 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
280 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
281 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
281 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
282 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
282 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
283 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
283 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
284 intEventOut = (unsigned int) event_out;
284 intEventOut = (unsigned int) event_out;
285 for ( i=0; i<32; i++)
285 for ( i=0; i<32; i++)
286 {
286 {
287 if ( ((intEventOut >> i) & 0x0001) != 0)
287 if ( ((intEventOut >> i) & 0x0001) != 0)
288 {
288 {
289 coarse_time = time_management_regs->coarse_time;
289 coarse_time = time_management_regs->coarse_time;
290 fine_time = time_management_regs->fine_time;
290 fine_time = time_management_regs->fine_time;
291 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
291 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
292 if (i==8)
292 if (i==8)
293 {
293 {
294 }
294 }
295 if (i==10)
295 if (i==10)
296 {
296 {
297 }
297 }
298 }
298 }
299 }
299 }
300 }
300 }
301 }
301 }
302
302
303 //*****************************
303 //*****************************
304 // init housekeeping parameters
304 // init housekeeping parameters
305
305
306 void init_housekeeping_parameters( void )
306 void init_housekeeping_parameters( void )
307 {
307 {
308 /** This function initialize the housekeeping_packet global variable with default values.
308 /** This function initialize the housekeeping_packet global variable with default values.
309 *
309 *
310 */
310 */
311
311
312 unsigned int i = 0;
312 unsigned int i = 0;
313 unsigned char *parameters;
313 unsigned char *parameters;
314
314
315 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
315 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
316 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
316 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
317 {
317 {
318 parameters[i] = 0x00;
318 parameters[i] = 0x00;
319 }
319 }
320 // init status word
320 // init status word
321 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
321 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
322 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
322 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
323 // init software version
323 // init software version
324 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
324 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
325 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
325 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
326 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
326 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
327 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
327 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
328 // init fpga version
328 // init fpga version
329 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
329 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
330 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
330 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
331 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
331 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
332 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
332 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
333 }
333 }
334
334
335 void increment_seq_counter( unsigned short *packetSequenceControl )
335 void increment_seq_counter( unsigned short *packetSequenceControl )
336 {
336 {
337 /** This function increment the sequence counter psased in argument.
337 /** This function increment the sequence counter psased in argument.
338 *
338 *
339 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
339 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
340 *
340 *
341 */
341 */
342
342
343 unsigned short segmentation_grouping_flag;
343 unsigned short segmentation_grouping_flag;
344 unsigned short sequence_cnt;
344 unsigned short sequence_cnt;
345
345
346 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
346 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
347 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
347 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
348
348
349 if ( sequence_cnt < SEQ_CNT_MAX)
349 if ( sequence_cnt < SEQ_CNT_MAX)
350 {
350 {
351 sequence_cnt = sequence_cnt + 1;
351 sequence_cnt = sequence_cnt + 1;
352 }
352 }
353 else
353 else
354 {
354 {
355 sequence_cnt = 0;
355 sequence_cnt = 0;
356 }
356 }
357
357
358 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
358 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
359 }
359 }
360
360
361 void getTime( unsigned char *time)
361 void getTime( unsigned char *time)
362 {
362 {
363 /** This function write the current local time in the time buffer passed in argument.
363 /** This function write the current local time in the time buffer passed in argument.
364 *
364 *
365 */
365 */
366
366
367 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
367 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
368 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
368 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
369 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
369 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
370 time[3] = (unsigned char) (time_management_regs->coarse_time);
370 time[3] = (unsigned char) (time_management_regs->coarse_time);
371 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
371 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
372 time[5] = (unsigned char) (time_management_regs->fine_time);
372 time[5] = (unsigned char) (time_management_regs->fine_time);
373 }
373 }
374
374
375 unsigned long long int getTimeAsUnsignedLongLongInt( )
375 unsigned long long int getTimeAsUnsignedLongLongInt( )
376 {
376 {
377 /** This function write the current local time in the time buffer passed in argument.
377 /** This function write the current local time in the time buffer passed in argument.
378 *
378 *
379 */
379 */
380 unsigned long long int time;
380 unsigned long long int time;
381
381
382 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
382 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
383 + time_management_regs->fine_time;
383 + time_management_regs->fine_time;
384
384
385 return time;
385 return time;
386 }
386 }
387
387
388 void send_dumb_hk( void )
388 void send_dumb_hk( void )
389 {
389 {
390 Packet_TM_LFR_HK_t dummy_hk_packet;
390 Packet_TM_LFR_HK_t dummy_hk_packet;
391 unsigned char *parameters;
391 unsigned char *parameters;
392 unsigned int i;
392 unsigned int i;
393 rtems_id queue_id;
393 rtems_id queue_id;
394
394
395 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
395 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
396 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
396 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
397 dummy_hk_packet.reserved = DEFAULT_RESERVED;
397 dummy_hk_packet.reserved = DEFAULT_RESERVED;
398 dummy_hk_packet.userApplication = CCSDS_USER_APP;
398 dummy_hk_packet.userApplication = CCSDS_USER_APP;
399 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
399 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
400 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
400 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
401 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
401 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
402 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
402 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
403 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
403 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
404 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
404 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
405 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
405 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
406 dummy_hk_packet.serviceType = TM_TYPE_HK;
406 dummy_hk_packet.serviceType = TM_TYPE_HK;
407 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
407 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
408 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
408 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
409 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
409 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
410 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
410 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
411 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
411 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
412 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
412 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
413 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
413 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
414 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
414 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
415 dummy_hk_packet.sid = SID_HK;
415 dummy_hk_packet.sid = SID_HK;
416
416
417 // init status word
417 // init status word
418 dummy_hk_packet.lfr_status_word[0] = 0xff;
418 dummy_hk_packet.lfr_status_word[0] = 0xff;
419 dummy_hk_packet.lfr_status_word[1] = 0xff;
419 dummy_hk_packet.lfr_status_word[1] = 0xff;
420 // init software version
420 // init software version
421 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
421 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
422 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
422 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
423 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
423 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
424 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
424 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
425 // init fpga version
425 // init fpga version
426 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
426 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
427 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
427 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
428 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
428 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
429 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
429 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
430
430
431 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
431 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
432
432
433 for (i=0; i<100; i++)
433 for (i=0; i<100; i++)
434 {
434 {
435 parameters[i] = 0xff;
435 parameters[i] = 0xff;
436 }
436 }
437
437
438 get_message_queue_id_send( &queue_id );
438 get_message_queue_id_send( &queue_id );
439
439
440 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
440 rtems_message_queue_send( queue_id, &dummy_hk_packet,
441 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
441 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
442 }
442 }
443
443
444 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
444 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
445 {
445 {
446 unsigned int coarseTime;
447 unsigned int acquisitionTime;
448 unsigned int deltaT = 0;
449 unsigned char *bufferPtr;
450
451 unsigned int offset_in_samples;
452 unsigned int offset_in_bytes;
453 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
454
455 bufferPtr = NULL;
456
457 if (lfrCurrentMode == LFR_MODE_STANDBY)
458 {
459 spacecraft_potential[0] = 0x00;
460 spacecraft_potential[1] = 0x00;
461 spacecraft_potential[2] = 0x00;
462 spacecraft_potential[3] = 0x00;
463 spacecraft_potential[4] = 0x00;
464 spacecraft_potential[5] = 0x00;
465 }
466 else
467 {
468 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
469 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
470 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
471 + (unsigned int) ( bufferPtr[1] << 16 )
472 + (unsigned int) ( bufferPtr[2] << 8 )
473 + (unsigned int) ( bufferPtr[3] );
474 if ( coarseTime > acquisitionTime )
475 {
476 deltaT = coarseTime - acquisitionTime;
477 offset_in_samples = (deltaT-1) * f3 ;
478 }
479 else if( coarseTime == acquisitionTime )
480 {
481 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
482 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
483 }
484 else
485 {
486 offset_in_samples = 0;
487 // PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
488 }
489
490 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
491 {
492 // PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
493 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
494 }
495 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
496 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
497 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
498 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
499 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
500 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
501 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
502 }
503 }
504
505 void get_v_e1_e2_f3_alt( unsigned char *spacecraft_potential )
506 {
507 unsigned long long int localTime_asLong;
446 unsigned long long int localTime_asLong;
508 unsigned long long int f3_0_AcquisitionTime_asLong;
447 unsigned long long int f3_0_AcquisitionTime_asLong;
509 unsigned long long int f3_1_AcquisitionTime_asLong;
448 unsigned long long int f3_1_AcquisitionTime_asLong;
510 unsigned long long int deltaT;
449 unsigned long long int deltaT;
511 unsigned long long int deltaT_f3_0;
450 unsigned long long int deltaT_f3_0;
512 unsigned long long int deltaT_f3_1;
451 unsigned long long int deltaT_f3_1;
513 unsigned char *bufferPtr;
452 unsigned char *bufferPtr;
514
453
515 unsigned int offset_in_samples;
454 unsigned int offset_in_samples;
516 unsigned int offset_in_bytes;
455 unsigned int offset_in_bytes;
517 unsigned char f3;
456 unsigned char f3;
518
457
519 bufferPtr = NULL;
458 bufferPtr = NULL;
520 deltaT = 0;
459 deltaT = 0;
521 deltaT_f3_0 = 0xffffffff;
460 deltaT_f3_0 = 0xffffffff;
522 deltaT_f3_1 = 0xffffffff;
461 deltaT_f3_1 = 0xffffffff;
523 f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
462 f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
524
463
525 if (lfrCurrentMode == LFR_MODE_STANDBY)
464 if (lfrCurrentMode == LFR_MODE_STANDBY)
526 {
465 {
527 spacecraft_potential[0] = 0x00;
466 spacecraft_potential[0] = 0x00;
528 spacecraft_potential[1] = 0x00;
467 spacecraft_potential[1] = 0x00;
529 spacecraft_potential[2] = 0x00;
468 spacecraft_potential[2] = 0x00;
530 spacecraft_potential[3] = 0x00;
469 spacecraft_potential[3] = 0x00;
531 spacecraft_potential[4] = 0x00;
470 spacecraft_potential[4] = 0x00;
532 spacecraft_potential[5] = 0x00;
471 spacecraft_potential[5] = 0x00;
533 }
472 }
534 else
473 else
535 {
474 {
536 localTime_asLong = get_acquisition_time( (unsigned char *) &time_management_regs->coarse_time );
475 localTime_asLong = get_acquisition_time( (unsigned char *) &time_management_regs->coarse_time );
537 f3_0_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_0_coarse_time );
476 f3_0_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_0_coarse_time );
538 f3_1_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_1_coarse_time );
477 f3_1_AcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &waveform_picker_regs->f3_1_coarse_time );
539 printf("localTime 0x%llx, f3_0 0x%llx, f3_1 0x%llx\n",
478 printf("localTime 0x%llx, f3_0 0x%llx, f3_1 0x%llx\n",
540 localTime_asLong,
479 localTime_asLong,
541 f3_0_AcquisitionTime_asLong,
480 f3_0_AcquisitionTime_asLong,
542 f3_1_AcquisitionTime_asLong);
481 f3_1_AcquisitionTime_asLong);
543
482
544 if ( localTime_asLong >= f3_0_AcquisitionTime_asLong )
483 if ( localTime_asLong >= f3_0_AcquisitionTime_asLong )
545 {
484 {
546 deltaT_f3_0 = localTime_asLong - f3_0_AcquisitionTime_asLong;
485 deltaT_f3_0 = localTime_asLong - f3_0_AcquisitionTime_asLong;
547 }
486 }
548
487
549 if ( localTime_asLong > f3_1_AcquisitionTime_asLong )
488 if ( localTime_asLong > f3_1_AcquisitionTime_asLong )
550 {
489 {
551 deltaT_f3_1 = localTime_asLong - f3_1_AcquisitionTime_asLong;
490 deltaT_f3_1 = localTime_asLong - f3_1_AcquisitionTime_asLong;
552 }
491 }
553
492
554 if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
493 if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
555 {
494 {
556 if ( deltaT_f3_0 > deltaT_f3_1 )
495 if ( deltaT_f3_0 > deltaT_f3_1 )
557 {
496 {
558 deltaT = deltaT_f3_1;
497 deltaT = deltaT_f3_1;
559 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
498 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
560 }
499 }
561 else
500 else
562 {
501 {
563 deltaT = deltaT_f3_0;
502 deltaT = deltaT_f3_0;
564 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_0;
503 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_0;
565 }
504 }
566 }
505 }
567 else if ( (deltaT_f3_0 == 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
506 else if ( (deltaT_f3_0 == 0xffffffff) && (deltaT_f3_1 != 0xffffffff) )
568 {
507 {
569 deltaT = deltaT_f3_1;
508 deltaT = deltaT_f3_1;
570 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
509 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
571 }
510 }
572 else if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 == 0xffffffff) )
511 else if ( (deltaT_f3_0 != 0xffffffff) && (deltaT_f3_1 == 0xffffffff) )
573 {
512 {
574 deltaT = deltaT_f3_0;
513 deltaT = deltaT_f3_0;
575 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
514 bufferPtr = (unsigned char*) waveform_picker_regs->addr_data_f3_1;
576 }
515 }
577 else
516 else
578 {
517 {
579 deltaT = 0xffffffff;
518 deltaT = 0xffffffff;
580 }
519 }
581
520
582 if ( deltaT == 0xffffffff )
521 if ( deltaT == 0xffffffff )
583 {
522 {
584 spacecraft_potential[0] = 0x00;
523 spacecraft_potential[0] = 0x00;
585 spacecraft_potential[1] = 0x00;
524 spacecraft_potential[1] = 0x00;
586 spacecraft_potential[2] = 0x00;
525 spacecraft_potential[2] = 0x00;
587 spacecraft_potential[3] = 0x00;
526 spacecraft_potential[3] = 0x00;
588 spacecraft_potential[4] = 0x00;
527 spacecraft_potential[4] = 0x00;
589 spacecraft_potential[5] = 0x00;
528 spacecraft_potential[5] = 0x00;
590 }
529 }
591 else
530 else
592 {
531 {
593 offset_in_samples = ( (double) deltaT ) / 65536. * f3;
532 offset_in_samples = ( (double) deltaT ) / 65536. * f3;
594 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
533 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
595 {
534 {
596 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
535 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
597 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT - 1;
536 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT - 1;
598 }
537 }
599 offset_in_bytes = offset_in_samples * NB_WORDS_SWF_BLK * 4;
538 offset_in_bytes = offset_in_samples * NB_WORDS_SWF_BLK * 4;
600 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
539 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
601 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
540 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
602 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
541 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
603 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
542 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
604 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
543 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
605 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
544 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
606 }
545 }
607 }
546 }
608 }
547 }
609
548
610 void get_cpu_load( unsigned char *resource_statistics )
549 void get_cpu_load( unsigned char *resource_statistics )
611 {
550 {
612 unsigned char cpu_load;
551 unsigned char cpu_load;
613
552
614 cpu_load = lfr_rtems_cpu_usage_report();
553 cpu_load = lfr_rtems_cpu_usage_report();
615
554
616 // HK_LFR_CPU_LOAD
555 // HK_LFR_CPU_LOAD
617 resource_statistics[0] = cpu_load;
556 resource_statistics[0] = cpu_load;
618
557
619 // HK_LFR_CPU_LOAD_MAX
558 // HK_LFR_CPU_LOAD_MAX
620 if (cpu_load > resource_statistics[1])
559 if (cpu_load > resource_statistics[1])
621 {
560 {
622 resource_statistics[1] = cpu_load;
561 resource_statistics[1] = cpu_load;
623 }
562 }
624
563
625 // CPU_LOAD_AVE
564 // CPU_LOAD_AVE
626 resource_statistics[2] = 0;
565 resource_statistics[2] = 0;
627
566
628 #ifndef PRINT_TASK_STATISTICS
567 #ifndef PRINT_TASK_STATISTICS
629 rtems_cpu_usage_reset();
568 rtems_cpu_usage_reset();
630 #endif
569 #endif
631
570
632 }
571 }
633
572
634
573
635
574
@@ -1,624 +1,1103
1 /** Functions related to the SpaceWire interface.
1 /** Functions related to the SpaceWire interface.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle SpaceWire transmissions:
6 * A group of functions to handle SpaceWire transmissions:
7 * - configuration of the SpaceWire link
7 * - configuration of the SpaceWire link
8 * - SpaceWire related interruption requests processing
8 * - SpaceWire related interruption requests processing
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
11 *
11 *
12 */
12 */
13
13
14 #include "fsw_spacewire.h"
14 #include "fsw_spacewire.h"
15
15
16 rtems_name semq_name;
16 rtems_name semq_name;
17 rtems_id semq_id;
17 rtems_id semq_id;
18
18
19 //*****************
20 // waveform headers
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF;
22 Header_TM_LFR_SCIENCE_SWF_t headerSWF;
23 Header_TM_LFR_SCIENCE_ASM_t headerASM;
24
19 //***********
25 //***********
20 // RTEMS TASK
26 // RTEMS TASK
21 rtems_task spiq_task(rtems_task_argument unused)
27 rtems_task spiq_task(rtems_task_argument unused)
22 {
28 {
23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
29 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
24 *
30 *
25 * @param unused is the starting argument of the RTEMS task
31 * @param unused is the starting argument of the RTEMS task
26 *
32 *
27 */
33 */
28
34
29 rtems_event_set event_out;
35 rtems_event_set event_out;
30 rtems_status_code status;
36 rtems_status_code status;
31 int linkStatus;
37 int linkStatus;
32
38
33 BOOT_PRINTF("in SPIQ *** \n")
39 BOOT_PRINTF("in SPIQ *** \n")
34
40
35 while(true){
41 while(true){
36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
42 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
43 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
38
44
39 // [0] SUSPEND RECV AND SEND TASKS
45 // [0] SUSPEND RECV AND SEND TASKS
40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
46 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
41 if ( status != RTEMS_SUCCESSFUL ) {
47 if ( status != RTEMS_SUCCESSFUL ) {
42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
48 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
43 }
49 }
44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
50 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
45 if ( status != RTEMS_SUCCESSFUL ) {
51 if ( status != RTEMS_SUCCESSFUL ) {
46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
52 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
47 }
53 }
48
54
49 // [1] CHECK THE LINK
55 // [1] CHECK THE LINK
50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
56 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
51 if ( linkStatus != 5) {
57 if ( linkStatus != 5) {
52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
58 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
59 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
54 }
60 }
55
61
56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
62 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
63 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
64 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
59 {
65 {
60 spacewire_compute_stats_offsets();
66 spacewire_compute_stats_offsets();
61 status = spacewire_reset_link( );
67 status = spacewire_reset_link( );
62 }
68 }
63 else // [2.b] in run state, start the link
69 else // [2.b] in run state, start the link
64 {
70 {
65 status = spacewire_stop_and_start_link( fdSPW ); // start the link
71 status = spacewire_stop_and_start_link( fdSPW ); // start the link
66 if ( status != RTEMS_SUCCESSFUL)
72 if ( status != RTEMS_SUCCESSFUL)
67 {
73 {
68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
74 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
69 }
75 }
70 }
76 }
71
77
72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
78 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
79 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
74 {
80 {
75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
81 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
76 if ( status != RTEMS_SUCCESSFUL ) {
82 if ( status != RTEMS_SUCCESSFUL ) {
77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
83 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
78 }
84 }
79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
85 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
80 if ( status != RTEMS_SUCCESSFUL ) {
86 if ( status != RTEMS_SUCCESSFUL ) {
81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
87 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
82 }
88 }
83 }
89 }
84 else // [3.b] the link is not in run state, go in STANDBY mode
90 else // [3.b] the link is not in run state, go in STANDBY mode
85 {
91 {
86 status = stop_current_mode();
92 status = stop_current_mode();
87 if ( status != RTEMS_SUCCESSFUL ) {
93 if ( status != RTEMS_SUCCESSFUL ) {
88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
94 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
89 }
95 }
90 status = enter_mode( LFR_MODE_STANDBY, 0 );
96 status = enter_mode( LFR_MODE_STANDBY, 0 );
91 if ( status != RTEMS_SUCCESSFUL ) {
97 if ( status != RTEMS_SUCCESSFUL ) {
92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
98 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
93 }
99 }
94 // wake the WTDG task up to wait for the link recovery
100 // wake the WTDG task up to wait for the link recovery
95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
101 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
96 status = rtems_task_suspend( RTEMS_SELF );
102 status = rtems_task_suspend( RTEMS_SELF );
97 }
103 }
98 }
104 }
99 }
105 }
100
106
101 rtems_task recv_task( rtems_task_argument unused )
107 rtems_task recv_task( rtems_task_argument unused )
102 {
108 {
103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
109 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
104 *
110 *
105 * @param unused is the starting argument of the RTEMS task
111 * @param unused is the starting argument of the RTEMS task
106 *
112 *
107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
113 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
108 * 1. It reads the incoming data.
114 * 1. It reads the incoming data.
109 * 2. Launches the acceptance procedure.
115 * 2. Launches the acceptance procedure.
110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
116 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
111 *
117 *
112 */
118 */
113
119
114 int len;
120 int len;
115 ccsdsTelecommandPacket_t currentTC;
121 ccsdsTelecommandPacket_t currentTC;
116 unsigned char computed_CRC[ 2 ];
122 unsigned char computed_CRC[ 2 ];
117 unsigned char currentTC_LEN_RCV[ 2 ];
123 unsigned char currentTC_LEN_RCV[ 2 ];
118 unsigned char destinationID;
124 unsigned char destinationID;
119 unsigned int estimatedPacketLength;
125 unsigned int estimatedPacketLength;
120 unsigned int parserCode;
126 unsigned int parserCode;
121 rtems_status_code status;
127 rtems_status_code status;
122 rtems_id queue_recv_id;
128 rtems_id queue_recv_id;
123 rtems_id queue_send_id;
129 rtems_id queue_send_id;
124
130
125 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
131 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
126
132
127 status = get_message_queue_id_recv( &queue_recv_id );
133 status = get_message_queue_id_recv( &queue_recv_id );
128 if (status != RTEMS_SUCCESSFUL)
134 if (status != RTEMS_SUCCESSFUL)
129 {
135 {
130 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
136 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
131 }
137 }
132
138
133 status = get_message_queue_id_send( &queue_send_id );
139 status = get_message_queue_id_send( &queue_send_id );
134 if (status != RTEMS_SUCCESSFUL)
140 if (status != RTEMS_SUCCESSFUL)
135 {
141 {
136 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
142 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
137 }
143 }
138
144
139 BOOT_PRINTF("in RECV *** \n")
145 BOOT_PRINTF("in RECV *** \n")
140
146
141 while(1)
147 while(1)
142 {
148 {
143 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
149 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
144 if (len == -1){ // error during the read call
150 if (len == -1){ // error during the read call
145 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
151 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
146 }
152 }
147 else {
153 else {
148 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
154 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
149 PRINTF("in RECV *** packet lenght too short\n")
155 PRINTF("in RECV *** packet lenght too short\n")
150 }
156 }
151 else {
157 else {
152 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
158 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
159 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
160 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
155 // CHECK THE TC
161 // CHECK THE TC
156 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
162 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
157 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
163 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
158 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
164 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
159 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
165 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
160 || (parserCode == WRONG_SRC_ID) )
166 || (parserCode == WRONG_SRC_ID) )
161 { // send TM_LFR_TC_EXE_CORRUPTED
167 { // send TM_LFR_TC_EXE_CORRUPTED
162 PRINTF1("TC corrupted received, with code: %d\n", parserCode)
168 PRINTF1("TC corrupted received, with code: %d\n", parserCode)
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
169 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 &&
170 &&
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
171 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 )
172 )
167 {
173 {
168 if ( parserCode == WRONG_SRC_ID )
174 if ( parserCode == WRONG_SRC_ID )
169 {
175 {
170 destinationID = SID_TC_GROUND;
176 destinationID = SID_TC_GROUND;
171 }
177 }
172 else
178 else
173 {
179 {
174 destinationID = currentTC.sourceID;
180 destinationID = currentTC.sourceID;
175 }
181 }
176 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
182 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
177 computed_CRC, currentTC_LEN_RCV,
183 computed_CRC, currentTC_LEN_RCV,
178 destinationID );
184 destinationID );
179 }
185 }
180 }
186 }
181 else
187 else
182 { // send valid TC to the action launcher
188 { // send valid TC to the action launcher
183 status = rtems_message_queue_send( queue_recv_id, &currentTC,
189 status = rtems_message_queue_send( queue_recv_id, &currentTC,
184 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
190 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
185 }
191 }
186 }
192 }
187 }
193 }
188 }
194 }
189 }
195 }
190
196
191 rtems_task send_task( rtems_task_argument argument)
197 rtems_task send_task( rtems_task_argument argument)
192 {
198 {
193 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
199 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
194 *
200 *
195 * @param unused is the starting argument of the RTEMS task
201 * @param unused is the starting argument of the RTEMS task
196 *
202 *
197 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
203 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
198 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
204 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
199 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
205 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
200 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
206 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
201 * data it contains.
207 * data it contains.
202 *
208 *
203 */
209 */
204
210
205 rtems_status_code status; // RTEMS status code
211 rtems_status_code status; // RTEMS status code
206 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
212 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
213 ring_node *incomingRingNodePtr;
214 int ring_node_address;
215 char *charPtr;
207 spw_ioctl_pkt_send *spw_ioctl_send;
216 spw_ioctl_pkt_send *spw_ioctl_send;
208 size_t size; // size of the incoming TC packet
217 size_t size; // size of the incoming TC packet
209 u_int32_t count;
218 u_int32_t count;
210 rtems_id queue_id;
219 rtems_id queue_id;
220 unsigned char sid;
221
222 incomingRingNodePtr = NULL;
223 ring_node_address = 0;
224 charPtr = (char *) &ring_node_address;
225 sid = 0;
226
227 init_header_cwf( &headerCWF );
228 init_header_swf( &headerSWF );
229 init_header_asm( &headerASM );
211
230
212 status = get_message_queue_id_send( &queue_id );
231 status = get_message_queue_id_send( &queue_id );
213 if (status != RTEMS_SUCCESSFUL)
232 if (status != RTEMS_SUCCESSFUL)
214 {
233 {
215 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
234 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
216 }
235 }
217
236
218 BOOT_PRINTF("in SEND *** \n")
237 BOOT_PRINTF("in SEND *** \n")
219
238
220 while(1)
239 while(1)
221 {
240 {
222 status = rtems_message_queue_receive( queue_id, incomingData, &size,
241 status = rtems_message_queue_receive( queue_id, incomingData, &size,
223 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
242 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
224
243
225 if (status!=RTEMS_SUCCESSFUL)
244 if (status!=RTEMS_SUCCESSFUL)
226 {
245 {
227 PRINTF1("in SEND *** (1) ERR = %d\n", status)
246 PRINTF1("in SEND *** (1) ERR = %d\n", status)
228 }
247 }
229 else
248 else
230 {
249 {
231 if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet
250 if ( size == sizeof(ring_node*) )
251 {
252 charPtr[0] = incomingData[0];
253 charPtr[1] = incomingData[1];
254 charPtr[2] = incomingData[2];
255 charPtr[3] = incomingData[3];
256 incomingRingNodePtr = (ring_node*) ring_node_address;
257 sid = incomingRingNodePtr->sid;
258 // printf("sid = %d\n", incomingRingNodePtr->sid);
259 if ( (sid==SID_NORM_CWF_LONG_F3)
260 || (sid==SID_BURST_CWF_F2 )
261 || (sid==SID_SBM1_CWF_F1 )
262 || (sid==SID_SBM2_CWF_F2 ))
263 {
264 spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF );
265 }
266 else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) )
267 {
268 spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF );
269 }
270 else if ( (sid==SID_NORM_CWF_F3) )
271 {
272 spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF );
273 }
274 else if ( (sid==SID_NORM_ASM_F0) || (SID_NORM_ASM_F1) || (SID_NORM_ASM_F2) )
275 {
276 spw_send_asm( incomingRingNodePtr, &headerASM );
277 }
278 else
279 {
280 printf("unexpected sid = %d\n", sid);
281 }
282 }
283 else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet
232 {
284 {
233 status = write( fdSPW, incomingData, size );
285 status = write( fdSPW, incomingData, size );
234 if (status == -1){
286 if (status == -1){
235 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
287 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
236 }
288 }
237 }
289 }
238 else // the incoming message is a spw_ioctl_pkt_send structure
290 else // the incoming message is a spw_ioctl_pkt_send structure
239 {
291 {
240 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
292 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
241 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
293 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
242 if (status == -1){
294 if (status == -1){
295 printf("size = %d, %x, %x, %x, %x, %x\n",
296 size,
297 incomingData[0],
298 incomingData[1],
299 incomingData[2],
300 incomingData[3],
301 incomingData[4]);
243 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
302 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
244 }
303 }
245 }
304 }
246 }
305 }
247
306
248 status = rtems_message_queue_get_number_pending( queue_id, &count );
307 status = rtems_message_queue_get_number_pending( queue_id, &count );
249 if (status != RTEMS_SUCCESSFUL)
308 if (status != RTEMS_SUCCESSFUL)
250 {
309 {
251 PRINTF1("in SEND *** (3) ERR = %d\n", status)
310 PRINTF1("in SEND *** (3) ERR = %d\n", status)
252 }
311 }
253 else
312 else
254 {
313 {
255 if (count > maxCount)
314 if (count > maxCount)
256 {
315 {
257 maxCount = count;
316 maxCount = count;
258 }
317 }
259 }
318 }
260 }
319 }
261 }
320 }
262
321
263 rtems_task wtdg_task( rtems_task_argument argument )
322 rtems_task wtdg_task( rtems_task_argument argument )
264 {
323 {
265 rtems_event_set event_out;
324 rtems_event_set event_out;
266 rtems_status_code status;
325 rtems_status_code status;
267 int linkStatus;
326 int linkStatus;
268
327
269 BOOT_PRINTF("in WTDG ***\n")
328 BOOT_PRINTF("in WTDG ***\n")
270
329
271 while(1)
330 while(1)
272 {
331 {
273 // wait for an RTEMS_EVENT
332 // wait for an RTEMS_EVENT
274 rtems_event_receive( RTEMS_EVENT_0,
333 rtems_event_receive( RTEMS_EVENT_0,
275 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
334 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
276 PRINTF("in WTDG *** wait for the link\n")
335 PRINTF("in WTDG *** wait for the link\n")
277 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
336 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
278 while( linkStatus != 5) // wait for the link
337 while( linkStatus != 5) // wait for the link
279 {
338 {
280 rtems_task_wake_after( 10 );
339 rtems_task_wake_after( 10 );
281 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
340 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
282 }
341 }
283
342
284 status = spacewire_stop_and_start_link( fdSPW );
343 status = spacewire_stop_and_start_link( fdSPW );
285
344
286 if (status != RTEMS_SUCCESSFUL)
345 if (status != RTEMS_SUCCESSFUL)
287 {
346 {
288 PRINTF1("in WTDG *** ERR link not started %d\n", status)
347 PRINTF1("in WTDG *** ERR link not started %d\n", status)
289 }
348 }
290 else
349 else
291 {
350 {
292 PRINTF("in WTDG *** OK link started\n")
351 PRINTF("in WTDG *** OK link started\n")
293 }
352 }
294
353
295 // restart the SPIQ task
354 // restart the SPIQ task
296 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
355 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
297 if ( status != RTEMS_SUCCESSFUL ) {
356 if ( status != RTEMS_SUCCESSFUL ) {
298 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
357 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
299 }
358 }
300
359
301 // restart RECV and SEND
360 // restart RECV and SEND
302 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
361 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
303 if ( status != RTEMS_SUCCESSFUL ) {
362 if ( status != RTEMS_SUCCESSFUL ) {
304 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
363 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
305 }
364 }
306 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
365 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
307 if ( status != RTEMS_SUCCESSFUL ) {
366 if ( status != RTEMS_SUCCESSFUL ) {
308 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
367 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
309 }
368 }
310 }
369 }
311 }
370 }
312
371
313 //****************
372 //****************
314 // OTHER FUNCTIONS
373 // OTHER FUNCTIONS
315 int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);]
374 int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);]
316 {
375 {
317 /** This function opens the SpaceWire link.
376 /** This function opens the SpaceWire link.
318 *
377 *
319 * @return a valid file descriptor in case of success, -1 in case of a failure
378 * @return a valid file descriptor in case of success, -1 in case of a failure
320 *
379 *
321 */
380 */
322 rtems_status_code status;
381 rtems_status_code status;
323
382
324 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
383 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
325 if ( fdSPW < 0 ) {
384 if ( fdSPW < 0 ) {
326 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
385 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
327 }
386 }
328 else
387 else
329 {
388 {
330 status = RTEMS_SUCCESSFUL;
389 status = RTEMS_SUCCESSFUL;
331 }
390 }
332
391
333 return status;
392 return status;
334 }
393 }
335
394
336 int spacewire_start_link( int fd )
395 int spacewire_start_link( int fd )
337 {
396 {
338 rtems_status_code status;
397 rtems_status_code status;
339
398
340 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
399 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
341 // -1 default hardcoded driver timeout
400 // -1 default hardcoded driver timeout
342
401
343 return status;
402 return status;
344 }
403 }
345
404
346 int spacewire_stop_and_start_link( int fd )
405 int spacewire_stop_and_start_link( int fd )
347 {
406 {
348 rtems_status_code status;
407 rtems_status_code status;
349
408
350 status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
409 status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
351 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
410 status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
352 // -1 default hardcoded driver timeout
411 // -1 default hardcoded driver timeout
353
412
354 return status;
413 return status;
355 }
414 }
356
415
357 int spacewire_configure_link( int fd )
416 int spacewire_configure_link( int fd )
358 {
417 {
359 /** This function configures the SpaceWire link.
418 /** This function configures the SpaceWire link.
360 *
419 *
361 * @return GR-RTEMS-DRIVER directive status codes:
420 * @return GR-RTEMS-DRIVER directive status codes:
362 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
421 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
363 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
422 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
364 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
423 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
365 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
424 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
366 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
425 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
367 * - 5 EIO - Error when writing to grswp hardware registers.
426 * - 5 EIO - Error when writing to grswp hardware registers.
368 * - 2 ENOENT - No such file or directory
427 * - 2 ENOENT - No such file or directory
369 */
428 */
370
429
371 rtems_status_code status;
430 rtems_status_code status;
372
431
373 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
432 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
374 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
433 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
375
434
376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
435 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
377 if (status!=RTEMS_SUCCESSFUL) {
436 if (status!=RTEMS_SUCCESSFUL) {
378 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
437 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
379 }
438 }
380 //
439 //
381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
440 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
382 if (status!=RTEMS_SUCCESSFUL) {
441 if (status!=RTEMS_SUCCESSFUL) {
383 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
442 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
384 }
443 }
385 //
444 //
386 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
445 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
387 if (status!=RTEMS_SUCCESSFUL) {
446 if (status!=RTEMS_SUCCESSFUL) {
388 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
447 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
389 }
448 }
390 //
449 //
391 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
450 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
392 if (status!=RTEMS_SUCCESSFUL) {
451 if (status!=RTEMS_SUCCESSFUL) {
393 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
452 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
394 }
453 }
395 //
454 //
396 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
455 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks
397 if (status!=RTEMS_SUCCESSFUL) {
456 if (status!=RTEMS_SUCCESSFUL) {
398 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
457 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
399 }
458 }
400 //
459 //
401 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
460 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
402 if (status!=RTEMS_SUCCESSFUL) {
461 if (status!=RTEMS_SUCCESSFUL) {
403 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
462 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
404 }
463 }
405 //
464 //
406 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
465 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
407 if (status!=RTEMS_SUCCESSFUL) {
466 if (status!=RTEMS_SUCCESSFUL) {
408 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
467 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
409 }
468 }
410
469
411 return status;
470 return status;
412 }
471 }
413
472
414 int spacewire_reset_link( void )
473 int spacewire_reset_link( void )
415 {
474 {
416 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
475 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
417 *
476 *
418 * @return RTEMS directive status code:
477 * @return RTEMS directive status code:
419 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
478 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
420 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
479 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
421 *
480 *
422 */
481 */
423
482
424 rtems_status_code status_spw;
483 rtems_status_code status_spw;
425 int i;
484 int i;
426
485
427 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
486 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
428 {
487 {
429 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
488 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
430
489
431 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
490 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
432
491
433 status_spw = spacewire_stop_and_start_link( fdSPW );
492 status_spw = spacewire_stop_and_start_link( fdSPW );
434 if ( status_spw != RTEMS_SUCCESSFUL )
493 if ( status_spw != RTEMS_SUCCESSFUL )
435 {
494 {
436 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
495 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
437 }
496 }
438
497
439 if ( status_spw == RTEMS_SUCCESSFUL)
498 if ( status_spw == RTEMS_SUCCESSFUL)
440 {
499 {
441 break;
500 break;
442 }
501 }
443 }
502 }
444
503
445 return status_spw;
504 return status_spw;
446 }
505 }
447
506
448 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
507 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
449 {
508 {
450 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
509 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
451 *
510 *
452 * @param val is the value, 0 or 1, used to set the value of the NP bit.
511 * @param val is the value, 0 or 1, used to set the value of the NP bit.
453 * @param regAddr is the address of the GRSPW control register.
512 * @param regAddr is the address of the GRSPW control register.
454 *
513 *
455 * NP is the bit 20 of the GRSPW control register.
514 * NP is the bit 20 of the GRSPW control register.
456 *
515 *
457 */
516 */
458
517
459 unsigned int *spwptr = (unsigned int*) regAddr;
518 unsigned int *spwptr = (unsigned int*) regAddr;
460
519
461 if (val == 1) {
520 if (val == 1) {
462 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
521 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
463 }
522 }
464 if (val== 0) {
523 if (val== 0) {
465 *spwptr = *spwptr & 0xffdfffff;
524 *spwptr = *spwptr & 0xffdfffff;
466 }
525 }
467 }
526 }
468
527
469 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
528 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
470 {
529 {
471 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
530 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
472 *
531 *
473 * @param val is the value, 0 or 1, used to set the value of the RE bit.
532 * @param val is the value, 0 or 1, used to set the value of the RE bit.
474 * @param regAddr is the address of the GRSPW control register.
533 * @param regAddr is the address of the GRSPW control register.
475 *
534 *
476 * RE is the bit 16 of the GRSPW control register.
535 * RE is the bit 16 of the GRSPW control register.
477 *
536 *
478 */
537 */
479
538
480 unsigned int *spwptr = (unsigned int*) regAddr;
539 unsigned int *spwptr = (unsigned int*) regAddr;
481
540
482 if (val == 1)
541 if (val == 1)
483 {
542 {
484 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
543 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
485 }
544 }
486 if (val== 0)
545 if (val== 0)
487 {
546 {
488 *spwptr = *spwptr & 0xfffdffff;
547 *spwptr = *spwptr & 0xfffdffff;
489 }
548 }
490 }
549 }
491
550
492 void spacewire_compute_stats_offsets( void )
551 void spacewire_compute_stats_offsets( void )
493 {
552 {
494 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
553 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
495 *
554 *
496 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
555 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
497 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
556 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
498 * during the open systel call).
557 * during the open systel call).
499 *
558 *
500 */
559 */
501
560
502 spw_stats spacewire_stats_grspw;
561 spw_stats spacewire_stats_grspw;
503 rtems_status_code status;
562 rtems_status_code status;
504
563
505 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
564 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
506
565
507 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
566 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
508 + spacewire_stats.packets_received;
567 + spacewire_stats.packets_received;
509 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
568 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
510 + spacewire_stats.packets_sent;
569 + spacewire_stats.packets_sent;
511 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
570 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
512 + spacewire_stats.parity_err;
571 + spacewire_stats.parity_err;
513 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
572 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
514 + spacewire_stats.disconnect_err;
573 + spacewire_stats.disconnect_err;
515 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
574 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
516 + spacewire_stats.escape_err;
575 + spacewire_stats.escape_err;
517 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
576 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
518 + spacewire_stats.credit_err;
577 + spacewire_stats.credit_err;
519 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
578 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
520 + spacewire_stats.write_sync_err;
579 + spacewire_stats.write_sync_err;
521 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
580 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
522 + spacewire_stats.rx_rmap_header_crc_err;
581 + spacewire_stats.rx_rmap_header_crc_err;
523 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
582 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
524 + spacewire_stats.rx_rmap_data_crc_err;
583 + spacewire_stats.rx_rmap_data_crc_err;
525 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
584 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
526 + spacewire_stats.early_ep;
585 + spacewire_stats.early_ep;
527 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
586 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
528 + spacewire_stats.invalid_address;
587 + spacewire_stats.invalid_address;
529 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
588 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
530 + spacewire_stats.rx_eep_err;
589 + spacewire_stats.rx_eep_err;
531 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
590 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
532 + spacewire_stats.rx_truncated;
591 + spacewire_stats.rx_truncated;
533 }
592 }
534
593
535 void spacewire_update_statistics( void )
594 void spacewire_update_statistics( void )
536 {
595 {
537 rtems_status_code status;
596 rtems_status_code status;
538 spw_stats spacewire_stats_grspw;
597 spw_stats spacewire_stats_grspw;
539
598
540 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
599 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
541
600
542 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
601 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
543 + spacewire_stats_grspw.packets_received;
602 + spacewire_stats_grspw.packets_received;
544 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
603 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
545 + spacewire_stats_grspw.packets_sent;
604 + spacewire_stats_grspw.packets_sent;
546 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
605 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
547 + spacewire_stats_grspw.parity_err;
606 + spacewire_stats_grspw.parity_err;
548 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
607 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
549 + spacewire_stats_grspw.disconnect_err;
608 + spacewire_stats_grspw.disconnect_err;
550 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
609 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
551 + spacewire_stats_grspw.escape_err;
610 + spacewire_stats_grspw.escape_err;
552 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
611 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
553 + spacewire_stats_grspw.credit_err;
612 + spacewire_stats_grspw.credit_err;
554 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
613 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
555 + spacewire_stats_grspw.write_sync_err;
614 + spacewire_stats_grspw.write_sync_err;
556 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
615 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
557 + spacewire_stats_grspw.rx_rmap_header_crc_err;
616 + spacewire_stats_grspw.rx_rmap_header_crc_err;
558 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
617 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
559 + spacewire_stats_grspw.rx_rmap_data_crc_err;
618 + spacewire_stats_grspw.rx_rmap_data_crc_err;
560 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
619 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
561 + spacewire_stats_grspw.early_ep;
620 + spacewire_stats_grspw.early_ep;
562 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
621 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
563 + spacewire_stats_grspw.invalid_address;
622 + spacewire_stats_grspw.invalid_address;
564 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
623 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
565 + spacewire_stats_grspw.rx_eep_err;
624 + spacewire_stats_grspw.rx_eep_err;
566 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
625 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
567 + spacewire_stats_grspw.rx_truncated;
626 + spacewire_stats_grspw.rx_truncated;
568 //spacewire_stats.tx_link_err;
627 //spacewire_stats.tx_link_err;
569
628
570 //****************************
629 //****************************
571 // DPU_SPACEWIRE_IF_STATISTICS
630 // DPU_SPACEWIRE_IF_STATISTICS
572 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
631 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
573 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
632 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
574 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
633 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
575 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
634 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
576 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
635 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
577 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
636 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
578
637
579 //******************************************
638 //******************************************
580 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
639 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
581 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
640 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
582 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
641 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
583 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
642 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
584 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
643 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
585 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
644 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
586
645
587 //*********************************************
646 //*********************************************
588 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
647 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
589 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
648 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
590 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
649 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
591 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
650 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
592 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
651 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
593 }
652 }
594
653
595 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
654 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
596 {
655 {
597 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 );
656 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_9 );
598 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
657 struct grgpio_regs_str *grgpio_regs = (struct grgpio_regs_str *) REGS_ADDR_GRGPIO;
599
658
600 grgpio_regs->io_port_direction_register =
659 grgpio_regs->io_port_direction_register =
601 grgpio_regs->io_port_direction_register | 0x04; // [0000 0100], 0 = output disabled, 1 = output enabled
660 grgpio_regs->io_port_direction_register | 0x04; // [0000 0100], 0 = output disabled, 1 = output enabled
602
661
603 if ( (grgpio_regs->io_port_output_register & 0x04) == 0x04 )
662 if ( (grgpio_regs->io_port_output_register & 0x04) == 0x04 )
604 {
663 {
605 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfb; // [1111 1011]
664 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register & 0xfb; // [1111 1011]
606 }
665 }
607 else
666 else
608 {
667 {
609 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x04; // [0000 0100]
668 grgpio_regs->io_port_output_register = grgpio_regs->io_port_output_register | 0x04; // [0000 0100]
610 }
669 }
611 }
670 }
612
671
613 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
672 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
614 {
673 {
615 int linkStatus;
674 int linkStatus;
616 rtems_status_code status;
675 rtems_status_code status;
617
676
618 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
677 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
619
678
620 if ( linkStatus == 5) {
679 if ( linkStatus == 5) {
621 PRINTF("in spacewire_reset_link *** link is running\n")
680 PRINTF("in spacewire_reset_link *** link is running\n")
622 status = RTEMS_SUCCESSFUL;
681 status = RTEMS_SUCCESSFUL;
623 }
682 }
624 }
683 }
684
685 void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header )
686 {
687 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
688 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
689 header->reserved = DEFAULT_RESERVED;
690 header->userApplication = CCSDS_USER_APP;
691 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
692 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
693 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
694 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
695 // DATA FIELD HEADER
696 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
697 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
698 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
699 header->destinationID = TM_DESTINATION_ID_GROUND;
700 header->time[0] = 0x00;
701 header->time[0] = 0x00;
702 header->time[0] = 0x00;
703 header->time[0] = 0x00;
704 header->time[0] = 0x00;
705 header->time[0] = 0x00;
706 // AUXILIARY DATA HEADER
707 header->sid = 0x00;
708 header->hkBIA = DEFAULT_HKBIA;
709 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
710 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
711 }
712
713 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header )
714 {
715 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
716 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
717 header->reserved = DEFAULT_RESERVED;
718 header->userApplication = CCSDS_USER_APP;
719 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
720 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
721 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
722 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
723 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
724 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
725 // DATA FIELD HEADER
726 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
727 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
728 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
729 header->destinationID = TM_DESTINATION_ID_GROUND;
730 header->time[0] = 0x00;
731 header->time[0] = 0x00;
732 header->time[0] = 0x00;
733 header->time[0] = 0x00;
734 header->time[0] = 0x00;
735 header->time[0] = 0x00;
736 // AUXILIARY DATA HEADER
737 header->sid = 0x00;
738 header->hkBIA = DEFAULT_HKBIA;
739 header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT
740 header->pktNr = 0x00;
741 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
742 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
743 }
744
745 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header )
746 {
747 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
748 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
749 header->reserved = DEFAULT_RESERVED;
750 header->userApplication = CCSDS_USER_APP;
751 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
752 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
753 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
754 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
755 header->packetLength[0] = 0x00;
756 header->packetLength[1] = 0x00;
757 // DATA FIELD HEADER
758 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
759 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
760 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
761 header->destinationID = TM_DESTINATION_ID_GROUND;
762 header->time[0] = 0x00;
763 header->time[0] = 0x00;
764 header->time[0] = 0x00;
765 header->time[0] = 0x00;
766 header->time[0] = 0x00;
767 header->time[0] = 0x00;
768 // AUXILIARY DATA HEADER
769 header->sid = 0x00;
770 header->biaStatusInfo = 0x00;
771 header->pa_lfr_pkt_cnt_asm = 0x00;
772 header->pa_lfr_pkt_nr_asm = 0x00;
773 header->pa_lfr_asm_blk_nr[0] = 0x00;
774 header->pa_lfr_asm_blk_nr[1] = 0x00;
775 }
776
777 int spw_send_waveform_CWF( ring_node *ring_node_to_send,
778 Header_TM_LFR_SCIENCE_CWF_t *header )
779 {
780 /** This function sends CWF CCSDS packets (F2, F1 or F0).
781 *
782 * @param waveform points to the buffer containing the data that will be send.
783 * @param sid is the source identifier of the data that will be sent.
784 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
785 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
786 * contain information to setup the transmission of the data packets.
787 *
788 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
789 *
790 */
791
792 unsigned int i;
793 int ret;
794 unsigned int coarseTime;
795 unsigned int fineTime;
796 rtems_status_code status;
797 spw_ioctl_pkt_send spw_ioctl_send_CWF;
798 int *dataPtr;
799 unsigned char sid;
800
801 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
802 spw_ioctl_send_CWF.options = 0;
803
804 ret = LFR_DEFAULT;
805 sid = (unsigned char) ring_node_to_send->sid;
806
807 coarseTime = ring_node_to_send->coarseTime;
808 fineTime = ring_node_to_send->fineTime;
809 dataPtr = (int*) ring_node_to_send->buffer_address;
810
811 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
812 {
813 spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ];
814 spw_ioctl_send_CWF.hdr = (char*) header;
815 // BUILD THE DATA
816 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
817
818 // SET PACKET SEQUENCE CONTROL
819 increment_seq_counter_source_id( header->packetSequenceControl, sid );
820
821 // SET SID
822 header->sid = sid;
823
824 // SET PACKET TIME
825 compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime);
826 //
827 header->time[0] = header->acquisitionTime[0];
828 header->time[1] = header->acquisitionTime[1];
829 header->time[2] = header->acquisitionTime[2];
830 header->time[3] = header->acquisitionTime[3];
831 header->time[4] = header->acquisitionTime[4];
832 header->time[5] = header->acquisitionTime[5];
833
834 // SET PACKET ID
835 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
836 {
837 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
838 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
839 }
840 else
841 {
842 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
843 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
844 }
845
846 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF );
847 if (status != RTEMS_SUCCESSFUL) {
848 printf("%d-%d, ERR %d\n", sid, i, (int) status);
849 ret = LFR_DEFAULT;
850 }
851 }
852
853 return ret;
854 }
855
856 int spw_send_waveform_SWF( ring_node *ring_node_to_send,
857 Header_TM_LFR_SCIENCE_SWF_t *header )
858 {
859 /** This function sends SWF CCSDS packets (F2, F1 or F0).
860 *
861 * @param waveform points to the buffer containing the data that will be send.
862 * @param sid is the source identifier of the data that will be sent.
863 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
864 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
865 * contain information to setup the transmission of the data packets.
866 *
867 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
868 *
869 */
870
871 unsigned int i;
872 int ret;
873 unsigned int coarseTime;
874 unsigned int fineTime;
875 rtems_status_code status;
876 spw_ioctl_pkt_send spw_ioctl_send_SWF;
877 int *dataPtr;
878 unsigned char sid;
879
880 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
881 spw_ioctl_send_SWF.options = 0;
882
883 ret = LFR_DEFAULT;
884
885 coarseTime = ring_node_to_send->coarseTime;
886 fineTime = ring_node_to_send->fineTime;
887 dataPtr = (int*) ring_node_to_send->buffer_address;
888 sid = ring_node_to_send->sid;
889
890 for (i=0; i<7; i++) // send waveform
891 {
892 spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ];
893 spw_ioctl_send_SWF.hdr = (char*) header;
894
895 // SET PACKET SEQUENCE CONTROL
896 increment_seq_counter_source_id( header->packetSequenceControl, sid );
897
898 // SET PACKET LENGTH AND BLKNR
899 if (i == 6)
900 {
901 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
902 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
903 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
904 header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
905 header->blkNr[1] = (unsigned char) (BLK_NR_224 );
906 }
907 else
908 {
909 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
910 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
911 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
912 header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
913 header->blkNr[1] = (unsigned char) (BLK_NR_304 );
914 }
915
916 // SET PACKET TIME
917 compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime );
918 //
919 header->time[0] = header->acquisitionTime[0];
920 header->time[1] = header->acquisitionTime[1];
921 header->time[2] = header->acquisitionTime[2];
922 header->time[3] = header->acquisitionTime[3];
923 header->time[4] = header->acquisitionTime[4];
924 header->time[5] = header->acquisitionTime[5];
925
926 // SET SID
927 header->sid = sid;
928
929 // SET PKTNR
930 header->pktNr = i+1; // PKT_NR
931
932 // SEND PACKET
933 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF );
934 if (status != RTEMS_SUCCESSFUL) {
935 printf("%d-%d, ERR %d\n", sid, i, (int) status);
936 ret = LFR_DEFAULT;
937 }
938 }
939
940 return ret;
941 }
942
943 int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send,
944 Header_TM_LFR_SCIENCE_CWF_t *header )
945 {
946 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
947 *
948 * @param waveform points to the buffer containing the data that will be send.
949 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
950 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
951 * contain information to setup the transmission of the data packets.
952 *
953 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
954 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
955 *
956 */
957
958 unsigned int i;
959 int ret;
960 unsigned int coarseTime;
961 unsigned int fineTime;
962 rtems_status_code status;
963 spw_ioctl_pkt_send spw_ioctl_send_CWF;
964 char *dataPtr;
965 unsigned char sid;
966
967 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
968 spw_ioctl_send_CWF.options = 0;
969
970 ret = LFR_DEFAULT;
971 sid = ring_node_to_send->sid;
972
973 coarseTime = ring_node_to_send->coarseTime;
974 fineTime = ring_node_to_send->fineTime;
975 dataPtr = (char*) ring_node_to_send->buffer_address;
976
977 //*********************
978 // SEND CWF3_light DATA
979 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
980 {
981 spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ];
982 spw_ioctl_send_CWF.hdr = (char*) header;
983 // BUILD THE DATA
984 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
985
986 // SET PACKET SEQUENCE COUNTER
987 increment_seq_counter_source_id( header->packetSequenceControl, sid );
988
989 // SET SID
990 header->sid = sid;
991
992 // SET PACKET TIME
993 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime );
994 //
995 header->time[0] = header->acquisitionTime[0];
996 header->time[1] = header->acquisitionTime[1];
997 header->time[2] = header->acquisitionTime[2];
998 header->time[3] = header->acquisitionTime[3];
999 header->time[4] = header->acquisitionTime[4];
1000 header->time[5] = header->acquisitionTime[5];
1001
1002 // SET PACKET ID
1003 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
1004 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
1005
1006 // SEND PACKET
1007 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF );
1008 if (status != RTEMS_SUCCESSFUL) {
1009 printf("%d-%d, ERR %d\n", sid, i, (int) status);
1010 ret = LFR_DEFAULT;
1011 }
1012 }
1013
1014 return ret;
1015 }
1016
1017 void spw_send_asm( ring_node *ring_node_to_send,
1018 Header_TM_LFR_SCIENCE_ASM_t *header )
1019 {
1020 unsigned int i;
1021 unsigned int length = 0;
1022 rtems_status_code status;
1023 unsigned int sid;
1024 char *spectral_matrix;
1025 int coarseTime;
1026 int fineTime;
1027 spw_ioctl_pkt_send spw_ioctl_send_ASM;
1028
1029 sid = ring_node_to_send->sid;
1030 spectral_matrix = (char*) ring_node_to_send->buffer_address;
1031 coarseTime = ring_node_to_send->coarseTime;
1032 fineTime = ring_node_to_send->fineTime;
1033
1034 for (i=0; i<2; i++)
1035 {
1036 // (1) BUILD THE DATA
1037 switch(sid)
1038 {
1039 case SID_NORM_ASM_F0:
1040 spw_ioctl_send_ASM.dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
1041 spw_ioctl_send_ASM.data = &spectral_matrix[
1042 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
1043 ];
1044 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
1045 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
1046 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
1047 break;
1048 case SID_NORM_ASM_F1:
1049 spw_ioctl_send_ASM.dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
1050 spw_ioctl_send_ASM.data = &spectral_matrix[
1051 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
1052 ];
1053 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
1054 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
1055 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
1056 break;
1057 case SID_NORM_ASM_F2:
1058 spw_ioctl_send_ASM.dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
1059 spw_ioctl_send_ASM.data = &spectral_matrix[
1060 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
1061 ];
1062 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
1063 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
1064 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
1065 break;
1066 default:
1067 PRINTF1("ERR *** in spw_send_asm *** unexpected sid %d\n", sid)
1068 break;
1069 }
1070 spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
1071 spw_ioctl_send_ASM.hdr = (char *) header;
1072 spw_ioctl_send_ASM.options = 0;
1073
1074 // (2) BUILD THE HEADER
1075 increment_seq_counter_source_id( header->packetSequenceControl, sid );
1076 header->packetLength[0] = (unsigned char) (length>>8);
1077 header->packetLength[1] = (unsigned char) (length);
1078 header->sid = (unsigned char) sid; // SID
1079 header->pa_lfr_pkt_cnt_asm = 2;
1080 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
1081
1082 // (3) SET PACKET TIME
1083 header->time[0] = (unsigned char) (coarseTime>>24);
1084 header->time[1] = (unsigned char) (coarseTime>>16);
1085 header->time[2] = (unsigned char) (coarseTime>>8);
1086 header->time[3] = (unsigned char) (coarseTime);
1087 header->time[4] = (unsigned char) (fineTime>>8);
1088 header->time[5] = (unsigned char) (fineTime);
1089 //
1090 header->acquisitionTime[0] = header->time[0];
1091 header->acquisitionTime[1] = header->time[1];
1092 header->acquisitionTime[2] = header->time[2];
1093 header->acquisitionTime[3] = header->time[3];
1094 header->acquisitionTime[4] = header->time[4];
1095 header->acquisitionTime[5] = header->time[5];
1096
1097 // (4) SEND PACKET
1098 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM );
1099 if (status != RTEMS_SUCCESSFUL) {
1100 printf("in ASM_send *** ERR %d\n", (int) status);
1101 }
1102 }
1103 }
@@ -1,380 +1,401
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "avf0_prc0.h"
10 #include "avf0_prc0.h"
11 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
14
14
15 //***
15 //***
16 // F0
16 // F0
17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
18 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
18 ring_node_asm asm_ring_burst_sbm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ];
19
19
20 ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ];
21 char buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ];
22
20 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
23 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
21 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
24 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
22 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
25 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
23 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
26 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
24 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
27 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
25 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
28 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
26
29
27 //************
30 //************
28 // RTEMS TASKS
31 // RTEMS TASKS
29
32
30 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
33 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
31 {
34 {
32 int i;
35 int i;
33
36
34 rtems_event_set event_out;
37 rtems_event_set event_out;
35 rtems_status_code status;
38 rtems_status_code status;
36 rtems_id queue_id_prc0;
39 rtems_id queue_id_prc0;
37 asm_msg msgForMATR;
40 asm_msg msgForMATR;
38 ring_node_sm *ring_node_tab[8];
41 ring_node_sm *ring_node_tab[8];
39 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
42 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
40 ring_node_asm *current_ring_node_asm_norm_f0;
43 ring_node_asm *current_ring_node_asm_norm_f0;
41
44
42 unsigned int nb_norm_bp1;
45 unsigned int nb_norm_bp1;
43 unsigned int nb_norm_bp2;
46 unsigned int nb_norm_bp2;
44 unsigned int nb_norm_asm;
47 unsigned int nb_norm_asm;
45 unsigned int nb_sbm_bp1;
48 unsigned int nb_sbm_bp1;
46 unsigned int nb_sbm_bp2;
49 unsigned int nb_sbm_bp2;
47
50
48 nb_norm_bp1 = 0;
51 nb_norm_bp1 = 0;
49 nb_norm_bp2 = 0;
52 nb_norm_bp2 = 0;
50 nb_norm_asm = 0;
53 nb_norm_asm = 0;
51 nb_sbm_bp1 = 0;
54 nb_sbm_bp1 = 0;
52 nb_sbm_bp2 = 0;
55 nb_sbm_bp2 = 0;
53
56
54 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
57 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
55 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
58 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
56 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
59 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
57 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
60 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
58 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
61 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
59
62
60 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
63 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
61
64
62 status = get_message_queue_id_prc0( &queue_id_prc0 );
65 status = get_message_queue_id_prc0( &queue_id_prc0 );
63 if (status != RTEMS_SUCCESSFUL)
66 if (status != RTEMS_SUCCESSFUL)
64 {
67 {
65 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
68 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
66 }
69 }
67
70
68 while(1){
71 while(1){
69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
72 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
70
73
71 //****************************************
74 //****************************************
72 // initialize the mesage for the MATR task
75 // initialize the mesage for the MATR task
73 msgForMATR.norm = current_ring_node_asm_norm_f0;
76 msgForMATR.norm = current_ring_node_asm_norm_f0;
74 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
77 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
75 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
78 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
76 msgForMATR.coarseTime = ring_node_for_averaging_sm_f0->coarseTime;
79 msgForMATR.coarseTime = ring_node_for_averaging_sm_f0->coarseTime;
77 msgForMATR.fineTime = ring_node_for_averaging_sm_f0->fineTime;
80 msgForMATR.fineTime = ring_node_for_averaging_sm_f0->fineTime;
78 //
81 //
79 //****************************************
82 //****************************************
80
83
81 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
84 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
82 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
85 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
83 {
86 {
84 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
87 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
85 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
88 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
86 }
89 }
87
90
88 // compute the average and store it in the averaged_sm_f1 buffer
91 // compute the average and store it in the averaged_sm_f1 buffer
89 SM_average( current_ring_node_asm_norm_f0->matrix,
92 SM_average( current_ring_node_asm_norm_f0->matrix,
90 current_ring_node_asm_burst_sbm_f0->matrix,
93 current_ring_node_asm_burst_sbm_f0->matrix,
91 ring_node_tab,
94 ring_node_tab,
92 nb_norm_bp1, nb_sbm_bp1 );
95 nb_norm_bp1, nb_sbm_bp1 );
93
96
94 // update nb_average
97 // update nb_average
95 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
98 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
96 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
99 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
97 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
100 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
98 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
101 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
99 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
102 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
100
103
101 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
104 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
102 {
105 {
103 nb_sbm_bp1 = 0;
106 nb_sbm_bp1 = 0;
104 // set another ring for the ASM storage
107 // set another ring for the ASM storage
105 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
108 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
106 if ( lfrCurrentMode == LFR_MODE_BURST )
109 if ( lfrCurrentMode == LFR_MODE_BURST )
107 {
110 {
108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
111 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
109 }
112 }
110 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
113 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
111 {
114 {
112 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
115 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
113 }
116 }
114 }
117 }
115
118
116 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
119 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
117 {
120 {
118 nb_sbm_bp2 = 0;
121 nb_sbm_bp2 = 0;
119 if ( lfrCurrentMode == LFR_MODE_BURST )
122 if ( lfrCurrentMode == LFR_MODE_BURST )
120 {
123 {
121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
124 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
122 }
125 }
123 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
126 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
124 {
127 {
125 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
128 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
126 }
129 }
127 }
130 }
128
131
129 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
132 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
130 {
133 {
131 nb_norm_bp1 = 0;
134 nb_norm_bp1 = 0;
132 // set another ring for the ASM storage
135 // set another ring for the ASM storage
133 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
136 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
134 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
137 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
135 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
138 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
136 {
139 {
137 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
140 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
138 }
141 }
139 }
142 }
140
143
141 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
144 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
142 {
145 {
143 nb_norm_bp2 = 0;
146 nb_norm_bp2 = 0;
144 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
147 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
145 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
148 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
146 {
149 {
147 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
150 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
148 }
151 }
149 }
152 }
150
153
151 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
154 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
152 {
155 {
153 nb_norm_asm = 0;
156 nb_norm_asm = 0;
154 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
157 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
155 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
158 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
156 {
159 {
157 // PRINTF1("%lld\n", localTime)
160 // PRINTF1("%lld\n", localTime)
158 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
161 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
159 }
162 }
160 }
163 }
161
164
162 //*************************
165 //*************************
163 // send the message to MATR
166 // send the message to MATR
164 if (msgForMATR.event != 0x00)
167 if (msgForMATR.event != 0x00)
165 {
168 {
166 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
169 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
167 }
170 }
168
171
169 if (status != RTEMS_SUCCESSFUL) {
172 if (status != RTEMS_SUCCESSFUL) {
170 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
173 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
171 }
174 }
172 }
175 }
173 }
176 }
174
177
175 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
178 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
176 {
179 {
177 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
180 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
178 size_t size; // size of the incoming TC packet
181 size_t size; // size of the incoming TC packet
179 asm_msg *incomingMsg;
182 asm_msg *incomingMsg;
180 //
183 //
181 unsigned char sid;
184 unsigned char sid;
182 spw_ioctl_pkt_send spw_ioctl_send_ASM;
185 spw_ioctl_pkt_send spw_ioctl_send_ASM;
183 rtems_status_code status;
186 rtems_status_code status;
184 rtems_id queue_id;
187 rtems_id queue_id;
185 rtems_id queue_id_q_p0;
188 rtems_id queue_id_q_p0;
186 Header_TM_LFR_SCIENCE_ASM_t headerASM;
189 Header_TM_LFR_SCIENCE_ASM_t headerASM;
187 bp_packet_with_spare packet_norm_bp1_f0;
190 bp_packet_with_spare packet_norm_bp1_f0;
188 bp_packet packet_norm_bp2_f0;
191 bp_packet packet_norm_bp2_f0;
189 bp_packet packet_sbm_bp1_f0;
192 bp_packet packet_sbm_bp1_f0;
190 bp_packet packet_sbm_bp2_f0;
193 bp_packet packet_sbm_bp2_f0;
194 ring_node *current_ring_node_to_send_asm_f0;
191
195
192 unsigned long long int localTime;
196 unsigned long long int localTime;
193
197
194 ASM_init_header( &headerASM );
198 ASM_init_header( &headerASM );
195
199
200 // init the ring of the averaged spectral matrices which will be transmitted to the DPU
201 init_ring( ring_to_send_asm_f0, NB_RING_NODES_ASM_F0, (volatile int*) buffer_asm_f0, TOTAL_SIZE_SM );
202 current_ring_node_to_send_asm_f0 = ring_to_send_asm_f0;
203
196 //*************
204 //*************
197 // NORM headers
205 // NORM headers
198 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
206 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
199 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
207 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
200 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
208 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
201 BP_init_header( &packet_norm_bp2_f0.header,
209 BP_init_header( &packet_norm_bp2_f0.header,
202 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
203 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
211 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
204
212
205 //****************************
213 //****************************
206 // BURST SBM1 and SBM2 headers
214 // BURST SBM1 and SBM2 headers
207 if ( lfrRequestedMode == LFR_MODE_BURST )
215 if ( lfrRequestedMode == LFR_MODE_BURST )
208 {
216 {
209 BP_init_header( &packet_sbm_bp1_f0.header,
217 BP_init_header( &packet_sbm_bp1_f0.header,
210 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
218 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
211 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
219 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
212 BP_init_header( &packet_sbm_bp2_f0.header,
220 BP_init_header( &packet_sbm_bp2_f0.header,
213 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
221 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
214 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
215 }
223 }
216 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
224 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
217 {
225 {
218 BP_init_header( &packet_sbm_bp1_f0.header,
226 BP_init_header( &packet_sbm_bp1_f0.header,
219 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
227 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
220 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
228 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
221 BP_init_header( &packet_sbm_bp2_f0.header,
229 BP_init_header( &packet_sbm_bp2_f0.header,
222 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
223 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
224 }
232 }
225 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
233 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
226 {
234 {
227 BP_init_header( &packet_sbm_bp1_f0.header,
235 BP_init_header( &packet_sbm_bp1_f0.header,
228 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
236 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
229 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
237 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
230 BP_init_header( &packet_sbm_bp2_f0.header,
238 BP_init_header( &packet_sbm_bp2_f0.header,
231 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
239 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
232 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
240 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
233 }
241 }
234 else
242 else
235 {
243 {
236 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
244 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
237 }
245 }
238
246
239 status = get_message_queue_id_send( &queue_id );
247 status = get_message_queue_id_send( &queue_id );
240 if (status != RTEMS_SUCCESSFUL)
248 if (status != RTEMS_SUCCESSFUL)
241 {
249 {
242 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
250 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
243 }
251 }
244 status = get_message_queue_id_prc0( &queue_id_q_p0);
252 status = get_message_queue_id_prc0( &queue_id_q_p0);
245 if (status != RTEMS_SUCCESSFUL)
253 if (status != RTEMS_SUCCESSFUL)
246 {
254 {
247 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
255 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
248 }
256 }
249
257
250 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
258 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
251
259
252 while(1){
260 while(1){
253 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
261 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
254 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
262 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
255
263
256 incomingMsg = (asm_msg*) incomingData;
264 incomingMsg = (asm_msg*) incomingData;
257
265
258 localTime = getTimeAsUnsignedLongLongInt( );
266 localTime = getTimeAsUnsignedLongLongInt( );
259
267
260 //****************
268 //****************
261 //****************
269 //****************
262 // BURST SBM1 SBM2
270 // BURST SBM1 SBM2
263 //****************
271 //****************
264 //****************
272 //****************
265 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
273 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
266 {
274 {
267 sid = getSID( incomingMsg->event );
275 sid = getSID( incomingMsg->event );
268 // 1) compress the matrix for Basic Parameters calculation
276 // 1) compress the matrix for Basic Parameters calculation
269 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
277 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
270 nb_sm_before_f0.burst_sbm_bp1,
278 nb_sm_before_f0.burst_sbm_bp1,
271 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
279 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
272 ASM_F0_INDICE_START);
280 ASM_F0_INDICE_START);
273 // 2) compute the BP1 set
281 // 2) compute the BP1 set
274 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
282 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
275 // 3) send the BP1 set
283 // 3) send the BP1 set
276 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
284 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
277 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
285 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
278 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
286 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
279 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
287 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
280 sid);
288 sid);
281 // 4) compute the BP2 set if needed
289 // 4) compute the BP2 set if needed
282 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
290 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
283 {
291 {
284 // 1) compute the BP2 set
292 // 1) compute the BP2 set
285
293
286 // 2) send the BP2 set
294 // 2) send the BP2 set
287 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
295 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
288 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
296 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
289 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
297 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
290 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
298 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
291 sid);
299 sid);
292 }
300 }
293 }
301 }
294
302
295 //*****
303 //*****
296 //*****
304 //*****
297 // NORM
305 // NORM
298 //*****
306 //*****
299 //*****
307 //*****
300 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
308 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
301 {
309 {
302 // 1) compress the matrix for Basic Parameters calculation
310 // 1) compress the matrix for Basic Parameters calculation
303 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
311 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
304 nb_sm_before_f0.norm_bp1,
312 nb_sm_before_f0.norm_bp1,
305 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
313 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
306 ASM_F0_INDICE_START );
314 ASM_F0_INDICE_START );
307 // 2) compute the BP1 set
315 // 2) compute the BP1 set
308 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
316 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
309 // 3) send the BP1 set
317 // 3) send the BP1 set
310 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
318 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
311 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
319 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
312 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
320 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
313 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
321 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
314 SID_NORM_BP1_F0 );
322 SID_NORM_BP1_F0 );
315 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
323 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
316 {
324 {
317 // 1) compute the BP2 set using the same ASM as the one used for BP1
325 // 1) compute the BP2 set using the same ASM as the one used for BP1
318
326
319 // 2) send the BP2 set
327 // 2) send the BP2 set
320 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
328 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
321 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
329 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
322 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
330 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
323 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
331 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
324 SID_NORM_BP2_F0);
332 SID_NORM_BP2_F0);
325 }
333 }
326 }
334 }
327
335
328 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
336 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
329 {
337 {
338 // // 1) reorganize the ASM and divide
339 // ASM_reorganize_and_divide( incomingMsg->norm->matrix,
340 // asm_f0_reorganized,
341 // nb_sm_before_f0.norm_bp1 );
342 // // 2) convert the float array in a char array
343 // ASM_convert( asm_f0_reorganized, (char*) current_ring_node_to_send_asm_f0->buffer_address );
344 // current_ring_node_to_send_asm_f0->coarseTime = incomingMsg->coarseTime;
345 // current_ring_node_to_send_asm_f0->fineTime = incomingMsg->fineTime;
346 // current_ring_node_to_send_asm_f0->sid = SID_NORM_ASM_F0;
347 // // 3) send the spectral matrix packets
348 // status = rtems_message_queue_send( queue_id, &current_ring_node_to_send_asm_f0, sizeof( ring_node* ) );
349 // // change asm ring node
350 // current_ring_node_to_send_asm_f0 = current_ring_node_to_send_asm_f0->next;
330 // 1) reorganize the ASM and divide
351 // 1) reorganize the ASM and divide
331 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
352 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
332 asm_f0_reorganized,
353 asm_f0_reorganized,
333 nb_sm_before_f0.norm_bp1 );
354 nb_sm_before_f0.norm_bp1 );
334 // 2) convert the float array in a char array
355 // 2) convert the float array in a char array
335 ASM_convert( asm_f0_reorganized, asm_f0_char);
356 ASM_convert( asm_f0_reorganized, asm_f0_char);
336 // 3) send the spectral matrix packets
357 // 3) send the spectral matrix packets
337 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
358 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
338 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
359 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
339 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
360 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
340 }
361 }
341
362
342 }
363 }
343 }
364 }
344
365
345 //**********
366 //**********
346 // FUNCTIONS
367 // FUNCTIONS
347
368
348 void reset_nb_sm_f0( unsigned char lfrMode )
369 void reset_nb_sm_f0( unsigned char lfrMode )
349 {
370 {
350 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
371 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
351 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
372 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
352 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
373 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
353 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
374 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
354 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
375 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
355 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
376 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
356 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
377 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
357 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
378 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
358 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
379 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
359
380
360 if (lfrMode == LFR_MODE_SBM1)
381 if (lfrMode == LFR_MODE_SBM1)
361 {
382 {
362 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
383 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
363 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
384 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
364 }
385 }
365 else if (lfrMode == LFR_MODE_SBM2)
386 else if (lfrMode == LFR_MODE_SBM2)
366 {
387 {
367 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
388 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
368 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
389 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
369 }
390 }
370 else if (lfrMode == LFR_MODE_BURST)
391 else if (lfrMode == LFR_MODE_BURST)
371 {
392 {
372 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
393 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
373 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
394 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
374 }
395 }
375 else
396 else
376 {
397 {
377 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
398 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
378 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
399 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
379 }
400 }
380 }
401 }
@@ -1,712 +1,688
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "fsw_processing.h"
10 #include "fsw_processing.h"
11 #include "fsw_processing_globals.c"
11 #include "fsw_processing_globals.c"
12
12
13 unsigned int nb_sm_f0;
13 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0_aux_f1;
14 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f1;
15 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f0_aux_f2;
16 unsigned int nb_sm_f0_aux_f2;
17
17
18 //************************
18 //************************
19 // spectral matrices rings
19 // spectral matrices rings
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
20 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
21 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
22 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
23 ring_node_sm *current_ring_node_sm_f0;
23 ring_node_sm *current_ring_node_sm_f0;
24 ring_node_sm *current_ring_node_sm_f1;
24 ring_node_sm *current_ring_node_sm_f1;
25 ring_node_sm *current_ring_node_sm_f2;
25 ring_node_sm *current_ring_node_sm_f2;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
26 ring_node_sm *ring_node_for_averaging_sm_f0;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
27 ring_node_sm *ring_node_for_averaging_sm_f1;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
28 ring_node_sm *ring_node_for_averaging_sm_f2;
29
29
30 //***********************************************************
30 //***********************************************************
31 // Interrupt Service Routine for spectral matrices processing
31 // Interrupt Service Routine for spectral matrices processing
32
32
33 void spectral_matrices_isr_f0( void )
33 void spectral_matrices_isr_f0( void )
34 {
34 {
35 unsigned char status;
35 unsigned char status;
36 unsigned long long int time_0;
36 unsigned long long int time_0;
37 unsigned long long int time_1;
37 unsigned long long int time_1;
38 unsigned long long int syncBit0;
38 unsigned long long int syncBit0;
39 unsigned long long int syncBit1;
39 unsigned long long int syncBit1;
40
40
41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
41 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
42
42
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
43 time_0 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_0_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
44 time_1 = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f0_1_coarse_time );
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
45 syncBit0 = ( (unsigned long long int) (spectral_matrix_regs->f0_0_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
46 syncBit1 = ( (unsigned long long int) (spectral_matrix_regs->f0_1_coarse_time & 0x80000000) ) << 16;
47
47
48 switch(status)
48 switch(status)
49 {
49 {
50 case 0:
50 case 0:
51 break;
51 break;
52 case 3:
52 case 3:
53 if ( time_0 < time_1 )
53 if ( time_0 < time_1 )
54 {
54 {
55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
55 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
56 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
57 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
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;
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],
59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
60 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
63 }
63 }
64 else
64 else
65 {
65 {
66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
66 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
67 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
68 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
69 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
70 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
71 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
72 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
73 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
74 }
74 }
75 spectral_matrix_regs->status = 0x03; // [0011]
75 spectral_matrix_regs->status = 0x03; // [0011]
76 break;
76 break;
77 case 1:
77 case 1:
78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
78 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
79 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_0 | syncBit0);
80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
80 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
81 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
82 spectral_matrix_regs->status = 0x01; // [0001]
82 spectral_matrix_regs->status = 0x01; // [0001]
83 break;
83 break;
84 case 2:
84 case 2:
85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
85 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0],
86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
86 ring_node_for_averaging_sm_f0, current_ring_node_sm_f0, time_1 | syncBit1);
87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
87 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
88 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
89 spectral_matrix_regs->status = 0x02; // [0010]
89 spectral_matrix_regs->status = 0x02; // [0010]
90 break;
90 break;
91 }
91 }
92 }
92 }
93
93
94 void spectral_matrices_isr_f1( void )
94 void spectral_matrices_isr_f1( void )
95 {
95 {
96 unsigned char status;
96 unsigned char status;
97 unsigned long long int time;
97 unsigned long long int time;
98 unsigned long long int syncBit;
98 unsigned long long int syncBit;
99 rtems_status_code status_code;
99 rtems_status_code status_code;
100
100
101 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
101 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
102
102
103 switch(status)
103 switch(status)
104 {
104 {
105 case 0:
105 case 0:
106 break;
106 break;
107 case 3:
107 case 3:
108 // UNEXPECTED VALUE
108 // UNEXPECTED VALUE
109 spectral_matrix_regs->status = 0xc0; // [1100]
109 spectral_matrix_regs->status = 0xc0; // [1100]
110 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
110 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
111 break;
111 break;
112 case 1:
112 case 1:
113 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
113 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_0_coarse_time );
114 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
114 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_0_coarse_time & 0x80000000) ) << 16;
115 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
115 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
116 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
116 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
117 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
117 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
118 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
118 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
119 spectral_matrix_regs->status = 0x04; // [0100]
119 spectral_matrix_regs->status = 0x04; // [0100]
120 break;
120 break;
121 case 2:
121 case 2:
122 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
122 time = get_acquisition_time( (unsigned char *) &spectral_matrix_regs->f1_1_coarse_time );
123 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
123 syncBit = ( (unsigned long long int) (spectral_matrix_regs->f1_1_coarse_time & 0x80000000) ) << 16;
124 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
124 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1],
125 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
125 ring_node_for_averaging_sm_f1, current_ring_node_sm_f1, time | syncBit);
126 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
126 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
127 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
127 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
128 spectral_matrix_regs->status = 0x08; // [1000]
128 spectral_matrix_regs->status = 0x08; // [1000]
129 break;
129 break;
130 }
130 }
131 }
131 }
132
132
133 void spectral_matrices_isr_f2( void )
133 void spectral_matrices_isr_f2( void )
134 {
134 {
135 unsigned char status;
135 unsigned char status;
136 rtems_status_code status_code;
136 rtems_status_code status_code;
137
137
138 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
138 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
139
139
140 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
140 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
141
141
142 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
142 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
143
143
144 switch(status)
144 switch(status)
145 {
145 {
146 case 0:
146 case 0:
147 break;
147 break;
148 case 3:
148 case 3:
149 // UNEXPECTED VALUE
149 // UNEXPECTED VALUE
150 spectral_matrix_regs->status = 0x30; // [0011 0000]
150 spectral_matrix_regs->status = 0x30; // [0011 0000]
151 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
151 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
152 break;
152 break;
153 case 1:
153 case 1:
154 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
154 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
155 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
155 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
156 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
156 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
157 spectral_matrix_regs->status = 0x10; // [0001 0000]
157 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 {
159 {
160 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
160 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 }
161 }
162 break;
162 break;
163 case 2:
163 case 2:
164 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
164 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
165 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
165 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
166 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
166 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
167 spectral_matrix_regs->status = 0x20; // [0010 0000]
167 spectral_matrix_regs->status = 0x20; // [0010 0000]
168 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
168 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
169 {
169 {
170 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
170 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
171 }
171 }
172 break;
172 break;
173 }
173 }
174 }
174 }
175
175
176 void spectral_matrix_isr_error_handler( void )
176 void spectral_matrix_isr_error_handler( void )
177 {
177 {
178 rtems_status_code status_code;
178 rtems_status_code status_code;
179
179
180 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
180 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
181 {
181 {
182 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
182 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
183 }
183 }
184 }
184 }
185
185
186 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
186 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
187 {
187 {
188 // STATUS REGISTER
188 // STATUS REGISTER
189 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
189 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
190 // 10 9 8
190 // 10 9 8
191 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
191 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
192 // 7 6 5 4 3 2 1 0
192 // 7 6 5 4 3 2 1 0
193
193
194 spectral_matrices_isr_f0();
194 spectral_matrices_isr_f0();
195
195
196 spectral_matrices_isr_f1();
196 spectral_matrices_isr_f1();
197
197
198 spectral_matrices_isr_f2();
198 spectral_matrices_isr_f2();
199
199
200 // spectral_matrix_isr_error_handler();
200 // spectral_matrix_isr_error_handler();
201 }
201 }
202
202
203 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
203 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
204 {
204 {
205 rtems_status_code status_code;
205 rtems_status_code status_code;
206
206
207 //***
207 //***
208 // F0
208 // F0
209 nb_sm_f0 = nb_sm_f0 + 1;
209 nb_sm_f0 = nb_sm_f0 + 1;
210 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
210 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
211 {
211 {
212 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
212 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
213 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
213 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
214 {
214 {
215 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
215 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
216 }
216 }
217 nb_sm_f0 = 0;
217 nb_sm_f0 = 0;
218 }
218 }
219
219
220 //***
220 //***
221 // F1
221 // F1
222 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
222 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
223 if (nb_sm_f0_aux_f1 == 6)
223 if (nb_sm_f0_aux_f1 == 6)
224 {
224 {
225 nb_sm_f0_aux_f1 = 0;
225 nb_sm_f0_aux_f1 = 0;
226 nb_sm_f1 = nb_sm_f1 + 1;
226 nb_sm_f1 = nb_sm_f1 + 1;
227 }
227 }
228 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
228 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
229 {
229 {
230 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
230 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
231 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
231 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
232 {
232 {
233 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
233 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
234 }
234 }
235 nb_sm_f1 = 0;
235 nb_sm_f1 = 0;
236 }
236 }
237
237
238 //***
238 //***
239 // F2
239 // F2
240 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
240 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
241 if (nb_sm_f0_aux_f2 == 96)
241 if (nb_sm_f0_aux_f2 == 96)
242 {
242 {
243 nb_sm_f0_aux_f2 = 0;
243 nb_sm_f0_aux_f2 = 0;
244 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
244 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
245 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
245 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
246 {
246 {
247 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
247 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
248 }
248 }
249 }
249 }
250 }
250 }
251
251
252 //******************
252 //******************
253 // Spectral Matrices
253 // Spectral Matrices
254
254
255 void reset_nb_sm( void )
255 void reset_nb_sm( void )
256 {
256 {
257 nb_sm_f0 = 0;
257 nb_sm_f0 = 0;
258 nb_sm_f0_aux_f1 = 0;
258 nb_sm_f0_aux_f1 = 0;
259 nb_sm_f0_aux_f2 = 0;
259 nb_sm_f0_aux_f2 = 0;
260
260
261 nb_sm_f1 = 0;
261 nb_sm_f1 = 0;
262 }
262 }
263
263
264 //void SM_init_rings_alt( void )
265 //{
266 // init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
267 // init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f0, TOTAL_SIZE_SM );
268 // init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f0, TOTAL_SIZE_SM );
269
270 // DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
271 // DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
272 // DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
273 // DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
274 // DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
275 // DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
276 //}
277
264 void SM_init_rings( void )
278 void SM_init_rings( void )
265 {
279 {
266 unsigned char i;
280 unsigned char i;
267
268 // F0 RING
281 // F0 RING
269 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
282 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
270 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
283 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
271 sm_ring_f0[0].buffer_address =
284 sm_ring_f0[0].buffer_address =
272 (int) &sm_f0[ 0 ];
285 (int) &sm_f0[ 0 ];
273
274 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
286 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
275 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
287 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
276 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
288 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
277 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
289 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
278
279 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
290 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
280 {
291 {
281 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
292 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
282 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
293 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
283 sm_ring_f0[i].buffer_address =
294 sm_ring_f0[i].buffer_address =
284 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
295 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
285 }
296 }
286
287 // F1 RING
297 // F1 RING
288 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
298 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
289 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
299 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
290 sm_ring_f1[0].buffer_address =
300 sm_ring_f1[0].buffer_address =
291 (int) &sm_f1[ 0 ];
301 (int) &sm_f1[ 0 ];
292
293 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
302 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
294 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
303 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
295 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
304 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
296 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
305 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
297
298 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
306 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
299 {
307 {
300 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
308 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
301 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
309 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
302 sm_ring_f1[i].buffer_address =
310 sm_ring_f1[i].buffer_address =
303 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
311 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
304 }
312 }
305
306 // F2 RING
313 // F2 RING
307 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
314 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
308 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
315 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
309 sm_ring_f2[0].buffer_address =
316 sm_ring_f2[0].buffer_address =
310 (int) &sm_f2[ 0 ];
317 (int) &sm_f2[ 0 ];
311
312 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
318 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
313 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
319 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
314 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
320 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
315 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
321 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
316
317 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
322 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
318 {
323 {
319 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
324 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
320 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
325 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
321 sm_ring_f2[i].buffer_address =
326 sm_ring_f2[i].buffer_address =
322 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
327 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
323 }
328 }
324
325 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
329 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
326 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
330 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
327 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
331 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
328
329 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
332 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
330 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
333 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
331 }
334 }
332
335
333 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
334 {
335 unsigned char i;
336
337 //***************
338 // BUFFER ADDRESS
339 for(i=0; i<nbNodes; i++)
340 {
341 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
342 }
343
344 //*****
345 // NEXT
346 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
347 for(i=0; i<nbNodes-1; i++)
348 {
349 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
350 }
351
352 //*********
353 // PREVIOUS
354 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
355 for(i=1; i<nbNodes; i++)
356 {
357 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
358 }
359 }
360
336
361 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
337 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
362 {
338 {
363 unsigned char i;
339 unsigned char i;
364
340
365 ring[ nbNodes - 1 ].next
341 ring[ nbNodes - 1 ].next
366 = (ring_node_asm*) &ring[ 0 ];
342 = (ring_node_asm*) &ring[ 0 ];
367
343
368 for(i=0; i<nbNodes-1; i++)
344 for(i=0; i<nbNodes-1; i++)
369 {
345 {
370 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
346 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
371 }
347 }
372 }
348 }
373
349
374 void SM_reset_current_ring_nodes( void )
350 void SM_reset_current_ring_nodes( void )
375 {
351 {
376 current_ring_node_sm_f0 = sm_ring_f0[0].next;
352 current_ring_node_sm_f0 = sm_ring_f0[0].next;
377 current_ring_node_sm_f1 = sm_ring_f1[0].next;
353 current_ring_node_sm_f1 = sm_ring_f1[0].next;
378 current_ring_node_sm_f2 = sm_ring_f2[0].next;
354 current_ring_node_sm_f2 = sm_ring_f2[0].next;
379
355
380 ring_node_for_averaging_sm_f0 = sm_ring_f0;
356 ring_node_for_averaging_sm_f0 = sm_ring_f0;
381 ring_node_for_averaging_sm_f1 = sm_ring_f1;
357 ring_node_for_averaging_sm_f1 = sm_ring_f1;
382 ring_node_for_averaging_sm_f2 = sm_ring_f2;
358 ring_node_for_averaging_sm_f2 = sm_ring_f2;
383 }
359 }
384
360
385 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
361 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
386 {
362 {
387 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
363 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
388 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
364 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
389 header->reserved = 0x00;
365 header->reserved = 0x00;
390 header->userApplication = CCSDS_USER_APP;
366 header->userApplication = CCSDS_USER_APP;
391 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
367 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
392 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
368 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
393 header->packetSequenceControl[0] = 0xc0;
369 header->packetSequenceControl[0] = 0xc0;
394 header->packetSequenceControl[1] = 0x00;
370 header->packetSequenceControl[1] = 0x00;
395 header->packetLength[0] = 0x00;
371 header->packetLength[0] = 0x00;
396 header->packetLength[1] = 0x00;
372 header->packetLength[1] = 0x00;
397 // DATA FIELD HEADER
373 // DATA FIELD HEADER
398 header->spare1_pusVersion_spare2 = 0x10;
374 header->spare1_pusVersion_spare2 = 0x10;
399 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
375 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
400 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
376 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
401 header->destinationID = TM_DESTINATION_ID_GROUND;
377 header->destinationID = TM_DESTINATION_ID_GROUND;
402 // AUXILIARY DATA HEADER
403 header->sid = 0x00;
404 header->biaStatusInfo = 0x00;
405 header->pa_lfr_pkt_cnt_asm = 0x00;
406 header->pa_lfr_pkt_nr_asm = 0x00;
407 header->time[0] = 0x00;
378 header->time[0] = 0x00;
408 header->time[0] = 0x00;
379 header->time[0] = 0x00;
409 header->time[0] = 0x00;
380 header->time[0] = 0x00;
410 header->time[0] = 0x00;
381 header->time[0] = 0x00;
411 header->time[0] = 0x00;
382 header->time[0] = 0x00;
412 header->time[0] = 0x00;
383 header->time[0] = 0x00;
384 // AUXILIARY DATA HEADER
385 header->sid = 0x00;
386 header->biaStatusInfo = 0x00;
387 header->pa_lfr_pkt_cnt_asm = 0x00;
388 header->pa_lfr_pkt_nr_asm = 0x00;
413 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
389 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
414 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
390 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
415 }
391 }
416
392
417 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
393 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
418 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
394 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
419 {
395 {
420 unsigned int i;
396 unsigned int i;
421 unsigned int length = 0;
397 unsigned int length = 0;
422 rtems_status_code status;
398 rtems_status_code status;
423
399
424 for (i=0; i<2; i++)
400 for (i=0; i<2; i++)
425 {
401 {
426 // (1) BUILD THE DATA
402 // (1) BUILD THE DATA
427 switch(sid)
403 switch(sid)
428 {
404 {
429 case SID_NORM_ASM_F0:
405 case SID_NORM_ASM_F0:
430 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
406 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
431 spw_ioctl_send->data = &spectral_matrix[
407 spw_ioctl_send->data = &spectral_matrix[
432 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
408 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
433 ];
409 ];
434 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
410 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
435 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
411 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
436 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
412 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
437 break;
413 break;
438 case SID_NORM_ASM_F1:
414 case SID_NORM_ASM_F1:
439 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
415 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
440 spw_ioctl_send->data = &spectral_matrix[
416 spw_ioctl_send->data = &spectral_matrix[
441 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
417 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
442 ];
418 ];
443 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
419 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
444 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
420 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
445 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
421 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
446 break;
422 break;
447 case SID_NORM_ASM_F2:
423 case SID_NORM_ASM_F2:
448 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
424 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
449 spw_ioctl_send->data = &spectral_matrix[
425 spw_ioctl_send->data = &spectral_matrix[
450 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
426 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
451 ];
427 ];
452 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
428 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
453 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
429 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
454 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
430 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
455 break;
431 break;
456 default:
432 default:
457 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
433 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
458 break;
434 break;
459 }
435 }
460 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
436 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
461 spw_ioctl_send->hdr = (char *) header;
437 spw_ioctl_send->hdr = (char *) header;
462 spw_ioctl_send->options = 0;
438 spw_ioctl_send->options = 0;
463
439
464 // (2) BUILD THE HEADER
440 // (2) BUILD THE HEADER
465 increment_seq_counter_source_id( header->packetSequenceControl, sid );
441 increment_seq_counter_source_id( header->packetSequenceControl, sid );
466 header->packetLength[0] = (unsigned char) (length>>8);
442 header->packetLength[0] = (unsigned char) (length>>8);
467 header->packetLength[1] = (unsigned char) (length);
443 header->packetLength[1] = (unsigned char) (length);
468 header->sid = (unsigned char) sid; // SID
444 header->sid = (unsigned char) sid; // SID
469 header->pa_lfr_pkt_cnt_asm = 2;
445 header->pa_lfr_pkt_cnt_asm = 2;
470 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
446 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
471
447
472 // (3) SET PACKET TIME
448 // (3) SET PACKET TIME
473 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
449 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
474 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
450 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
475 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
451 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
476 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
452 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
477 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
453 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
478 header->time[5] = (unsigned char) (time_management_regs->fine_time);
454 header->time[5] = (unsigned char) (time_management_regs->fine_time);
479 //
455 //
480 header->acquisitionTime[0] = header->time[0];
456 header->acquisitionTime[0] = header->time[0];
481 header->acquisitionTime[1] = header->time[1];
457 header->acquisitionTime[1] = header->time[1];
482 header->acquisitionTime[2] = header->time[2];
458 header->acquisitionTime[2] = header->time[2];
483 header->acquisitionTime[3] = header->time[3];
459 header->acquisitionTime[3] = header->time[3];
484 header->acquisitionTime[4] = header->time[4];
460 header->acquisitionTime[4] = header->time[4];
485 header->acquisitionTime[5] = header->time[5];
461 header->acquisitionTime[5] = header->time[5];
486
462
487 // (4) SEND PACKET
463 // (4) SEND PACKET
488 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
464 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
489 if (status != RTEMS_SUCCESSFUL) {
465 if (status != RTEMS_SUCCESSFUL) {
490 printf("in ASM_send *** ERR %d\n", (int) status);
466 printf("in ASM_send *** ERR %d\n", (int) status);
491 }
467 }
492 }
468 }
493 }
469 }
494
470
495 //*****************
471 //*****************
496 // Basic Parameters
472 // Basic Parameters
497
473
498 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
474 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
499 unsigned int apid, unsigned char sid,
475 unsigned int apid, unsigned char sid,
500 unsigned int packetLength, unsigned char blkNr )
476 unsigned int packetLength, unsigned char blkNr )
501 {
477 {
502 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
478 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
503 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
479 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
504 header->reserved = 0x00;
480 header->reserved = 0x00;
505 header->userApplication = CCSDS_USER_APP;
481 header->userApplication = CCSDS_USER_APP;
506 header->packetID[0] = (unsigned char) (apid >> 8);
482 header->packetID[0] = (unsigned char) (apid >> 8);
507 header->packetID[1] = (unsigned char) (apid);
483 header->packetID[1] = (unsigned char) (apid);
508 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
484 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
509 header->packetSequenceControl[1] = 0x00;
485 header->packetSequenceControl[1] = 0x00;
510 header->packetLength[0] = (unsigned char) (packetLength >> 8);
486 header->packetLength[0] = (unsigned char) (packetLength >> 8);
511 header->packetLength[1] = (unsigned char) (packetLength);
487 header->packetLength[1] = (unsigned char) (packetLength);
512 // DATA FIELD HEADER
488 // DATA FIELD HEADER
513 header->spare1_pusVersion_spare2 = 0x10;
489 header->spare1_pusVersion_spare2 = 0x10;
514 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
490 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
515 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
491 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
516 header->destinationID = TM_DESTINATION_ID_GROUND;
492 header->destinationID = TM_DESTINATION_ID_GROUND;
517 // AUXILIARY DATA HEADER
493 // AUXILIARY DATA HEADER
518 header->sid = sid;
494 header->sid = sid;
519 header->biaStatusInfo = 0x00;
495 header->biaStatusInfo = 0x00;
520 header->time[0] = 0x00;
496 header->time[0] = 0x00;
521 header->time[0] = 0x00;
497 header->time[0] = 0x00;
522 header->time[0] = 0x00;
498 header->time[0] = 0x00;
523 header->time[0] = 0x00;
499 header->time[0] = 0x00;
524 header->time[0] = 0x00;
500 header->time[0] = 0x00;
525 header->time[0] = 0x00;
501 header->time[0] = 0x00;
526 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
502 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
527 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
503 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
528 }
504 }
529
505
530 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
506 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
531 unsigned int apid, unsigned char sid,
507 unsigned int apid, unsigned char sid,
532 unsigned int packetLength , unsigned char blkNr)
508 unsigned int packetLength , unsigned char blkNr)
533 {
509 {
534 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
510 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
535 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
511 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
536 header->reserved = 0x00;
512 header->reserved = 0x00;
537 header->userApplication = CCSDS_USER_APP;
513 header->userApplication = CCSDS_USER_APP;
538 header->packetID[0] = (unsigned char) (apid >> 8);
514 header->packetID[0] = (unsigned char) (apid >> 8);
539 header->packetID[1] = (unsigned char) (apid);
515 header->packetID[1] = (unsigned char) (apid);
540 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
516 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
541 header->packetSequenceControl[1] = 0x00;
517 header->packetSequenceControl[1] = 0x00;
542 header->packetLength[0] = (unsigned char) (packetLength >> 8);
518 header->packetLength[0] = (unsigned char) (packetLength >> 8);
543 header->packetLength[1] = (unsigned char) (packetLength);
519 header->packetLength[1] = (unsigned char) (packetLength);
544 // DATA FIELD HEADER
520 // DATA FIELD HEADER
545 header->spare1_pusVersion_spare2 = 0x10;
521 header->spare1_pusVersion_spare2 = 0x10;
546 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
522 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
547 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
523 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
548 header->destinationID = TM_DESTINATION_ID_GROUND;
524 header->destinationID = TM_DESTINATION_ID_GROUND;
549 // AUXILIARY DATA HEADER
525 // AUXILIARY DATA HEADER
550 header->sid = sid;
526 header->sid = sid;
551 header->biaStatusInfo = 0x00;
527 header->biaStatusInfo = 0x00;
552 header->time[0] = 0x00;
528 header->time[0] = 0x00;
553 header->time[0] = 0x00;
529 header->time[0] = 0x00;
554 header->time[0] = 0x00;
530 header->time[0] = 0x00;
555 header->time[0] = 0x00;
531 header->time[0] = 0x00;
556 header->time[0] = 0x00;
532 header->time[0] = 0x00;
557 header->time[0] = 0x00;
533 header->time[0] = 0x00;
558 header->source_data_spare = 0x00;
534 header->source_data_spare = 0x00;
559 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
535 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
560 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
536 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
561 }
537 }
562
538
563 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
539 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
564 {
540 {
565 rtems_status_code status;
541 rtems_status_code status;
566
542
567 // SET THE SEQUENCE_CNT PARAMETER
543 // SET THE SEQUENCE_CNT PARAMETER
568 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
544 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
569 // SEND PACKET
545 // SEND PACKET
570 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
546 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
571 if (status != RTEMS_SUCCESSFUL)
547 if (status != RTEMS_SUCCESSFUL)
572 {
548 {
573 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
549 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
574 }
550 }
575 }
551 }
576
552
577 //******************
553 //******************
578 // general functions
554 // general functions
579
555
580 void reset_sm_status( void )
556 void reset_sm_status( void )
581 {
557 {
582 // error
558 // error
583 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
559 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
584 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
560 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
585 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
561 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
586 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
562 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
587
563
588 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
564 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
589 }
565 }
590
566
591 void reset_spectral_matrix_regs( void )
567 void reset_spectral_matrix_regs( void )
592 {
568 {
593 /** This function resets the spectral matrices module registers.
569 /** This function resets the spectral matrices module registers.
594 *
570 *
595 * The registers affected by this function are located at the following offset addresses:
571 * The registers affected by this function are located at the following offset addresses:
596 *
572 *
597 * - 0x00 config
573 * - 0x00 config
598 * - 0x04 status
574 * - 0x04 status
599 * - 0x08 matrixF0_Address0
575 * - 0x08 matrixF0_Address0
600 * - 0x10 matrixFO_Address1
576 * - 0x10 matrixFO_Address1
601 * - 0x14 matrixF1_Address
577 * - 0x14 matrixF1_Address
602 * - 0x18 matrixF2_Address
578 * - 0x18 matrixF2_Address
603 *
579 *
604 */
580 */
605
581
606 set_sm_irq_onError( 0 );
582 set_sm_irq_onError( 0 );
607
583
608 set_sm_irq_onNewMatrix( 0 );
584 set_sm_irq_onNewMatrix( 0 );
609
585
610 reset_sm_status();
586 reset_sm_status();
611
587
612 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
588 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
613 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
589 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
614 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
590 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
615 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
591 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
616 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
592 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
617 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
593 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
618
594
619 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
595 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
620 }
596 }
621
597
622 void set_time( unsigned char *time, unsigned char * timeInBuffer )
598 void set_time( unsigned char *time, unsigned char * timeInBuffer )
623 {
599 {
624 time[0] = timeInBuffer[0];
600 time[0] = timeInBuffer[0];
625 time[1] = timeInBuffer[1];
601 time[1] = timeInBuffer[1];
626 time[2] = timeInBuffer[2];
602 time[2] = timeInBuffer[2];
627 time[3] = timeInBuffer[3];
603 time[3] = timeInBuffer[3];
628 time[4] = timeInBuffer[6];
604 time[4] = timeInBuffer[6];
629 time[5] = timeInBuffer[7];
605 time[5] = timeInBuffer[7];
630 }
606 }
631
607
632 unsigned long long int get_acquisition_time( unsigned char *timePtr )
608 unsigned long long int get_acquisition_time( unsigned char *timePtr )
633 {
609 {
634 unsigned long long int acquisitionTimeAslong;
610 unsigned long long int acquisitionTimeAslong;
635 acquisitionTimeAslong = 0x00;
611 acquisitionTimeAslong = 0x00;
636 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
612 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
637 + ( (unsigned long long int) timePtr[1] << 32 )
613 + ( (unsigned long long int) timePtr[1] << 32 )
638 + ( (unsigned long long int) timePtr[2] << 24 )
614 + ( (unsigned long long int) timePtr[2] << 24 )
639 + ( (unsigned long long int) timePtr[3] << 16 )
615 + ( (unsigned long long int) timePtr[3] << 16 )
640 + ( (unsigned long long int) timePtr[6] << 8 )
616 + ( (unsigned long long int) timePtr[6] << 8 )
641 + ( (unsigned long long int) timePtr[7] );
617 + ( (unsigned long long int) timePtr[7] );
642 return acquisitionTimeAslong;
618 return acquisitionTimeAslong;
643 }
619 }
644
620
645 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
621 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id avf_task_id,
646 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
622 ring_node_sm *node_for_averaging, ring_node_sm *ringNode,
647 unsigned long long int time )
623 unsigned long long int time )
648 {
624 {
649 unsigned char *timePtr;
625 unsigned char *timePtr;
650 unsigned char *coarseTimePtr;
626 unsigned char *coarseTimePtr;
651 unsigned char *fineTimePtr;
627 unsigned char *fineTimePtr;
652 rtems_status_code status_code;
628 rtems_status_code status_code;
653
629
654 timePtr = (unsigned char *) &time;
630 timePtr = (unsigned char *) &time;
655 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
631 coarseTimePtr = (unsigned char *) &node_for_averaging->coarseTime;
656 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
632 fineTimePtr = (unsigned char *) &node_for_averaging->fineTime;
657
633
658 *nb_sm = *nb_sm + 1;
634 *nb_sm = *nb_sm + 1;
659 if (*nb_sm == nb_sm_before_avf)
635 if (*nb_sm == nb_sm_before_avf)
660 {
636 {
661 node_for_averaging = ringNode;
637 node_for_averaging = ringNode;
662 coarseTimePtr[0] = timePtr[2];
638 coarseTimePtr[0] = timePtr[2];
663 coarseTimePtr[1] = timePtr[3];
639 coarseTimePtr[1] = timePtr[3];
664 coarseTimePtr[2] = timePtr[4];
640 coarseTimePtr[2] = timePtr[4];
665 coarseTimePtr[3] = timePtr[5];
641 coarseTimePtr[3] = timePtr[5];
666 fineTimePtr[2] = timePtr[6];
642 fineTimePtr[2] = timePtr[6];
667 fineTimePtr[3] = timePtr[7];
643 fineTimePtr[3] = timePtr[7];
668 if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
644 if (rtems_event_send( avf_task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
669 {
645 {
670 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
646 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
671 }
647 }
672 *nb_sm = 0;
648 *nb_sm = 0;
673 }
649 }
674 }
650 }
675
651
676 unsigned char getSID( rtems_event_set event )
652 unsigned char getSID( rtems_event_set event )
677 {
653 {
678 unsigned char sid;
654 unsigned char sid;
679
655
680 rtems_event_set eventSetBURST;
656 rtems_event_set eventSetBURST;
681 rtems_event_set eventSetSBM;
657 rtems_event_set eventSetSBM;
682
658
683 //******
659 //******
684 // BURST
660 // BURST
685 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
661 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
686 | RTEMS_EVENT_BURST_BP1_F1
662 | RTEMS_EVENT_BURST_BP1_F1
687 | RTEMS_EVENT_BURST_BP2_F0
663 | RTEMS_EVENT_BURST_BP2_F0
688 | RTEMS_EVENT_BURST_BP2_F1;
664 | RTEMS_EVENT_BURST_BP2_F1;
689
665
690 //****
666 //****
691 // SBM
667 // SBM
692 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
668 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
693 | RTEMS_EVENT_SBM_BP1_F1
669 | RTEMS_EVENT_SBM_BP1_F1
694 | RTEMS_EVENT_SBM_BP2_F0
670 | RTEMS_EVENT_SBM_BP2_F0
695 | RTEMS_EVENT_SBM_BP2_F1;
671 | RTEMS_EVENT_SBM_BP2_F1;
696
672
697 if (event & eventSetBURST)
673 if (event & eventSetBURST)
698 {
674 {
699 sid = SID_BURST_BP1_F0;
675 sid = SID_BURST_BP1_F0;
700 }
676 }
701 else if (event & eventSetSBM)
677 else if (event & eventSetSBM)
702 {
678 {
703 sid = SID_SBM1_BP1_F0;
679 sid = SID_SBM1_BP1_F0;
704 }
680 }
705 else
681 else
706 {
682 {
707 sid = 0;
683 sid = 0;
708 }
684 }
709
685
710 return sid;
686 return sid;
711 }
687 }
712
688
@@ -1,1643 +1,1347
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 //*****************
13 // waveform headers
14 // SWF
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 // 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 ];
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 ];
23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ];
24
25 //***************
12 //***************
26 // waveform rings
13 // waveform rings
27 // F0
14 // F0
28 ring_node waveform_ring_f0[NB_RING_NODES_F0];
15 ring_node waveform_ring_f0[NB_RING_NODES_F0];
29 ring_node *current_ring_node_f0;
16 ring_node *current_ring_node_f0;
30 ring_node *ring_node_to_send_swf_f0;
17 ring_node *ring_node_to_send_swf_f0;
31 // F1
18 // F1
32 ring_node waveform_ring_f1[NB_RING_NODES_F1];
19 ring_node waveform_ring_f1[NB_RING_NODES_F1];
33 ring_node *current_ring_node_f1;
20 ring_node *current_ring_node_f1;
34 ring_node *ring_node_to_send_swf_f1;
21 ring_node *ring_node_to_send_swf_f1;
35 ring_node *ring_node_to_send_cwf_f1;
22 ring_node *ring_node_to_send_cwf_f1;
36 // F2
23 // F2
37 ring_node waveform_ring_f2[NB_RING_NODES_F2];
24 ring_node waveform_ring_f2[NB_RING_NODES_F2];
38 ring_node *current_ring_node_f2;
25 ring_node *current_ring_node_f2;
39 ring_node *ring_node_to_send_swf_f2;
26 ring_node *ring_node_to_send_swf_f2;
40 ring_node *ring_node_to_send_cwf_f2;
27 ring_node *ring_node_to_send_cwf_f2;
41 // F3
28 // F3
42 ring_node waveform_ring_f3[NB_RING_NODES_F3];
29 ring_node waveform_ring_f3[NB_RING_NODES_F3];
43 ring_node *current_ring_node_f3;
30 ring_node *current_ring_node_f3;
44 ring_node *ring_node_to_send_cwf_f3;
31 ring_node *ring_node_to_send_cwf_f3;
45
32
46 bool extractSWF = false;
33 bool extractSWF = false;
47 bool swf_f0_ready = false;
34 bool swf_f0_ready = false;
48 bool swf_f1_ready = false;
35 bool swf_f1_ready = false;
49 bool swf_f2_ready = false;
36 bool swf_f2_ready = false;
50
37
51 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
38 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
52 ring_node ring_node_wf_snap_extracted;
39 ring_node ring_node_wf_snap_extracted;
53
40
54 //*********************
41 //*********************
55 // Interrupt SubRoutine
42 // Interrupt SubRoutine
56
43
57 void reset_extractSWF( void )
44 void reset_extractSWF( void )
58 {
45 {
59 extractSWF = false;
46 extractSWF = false;
60 swf_f0_ready = false;
47 swf_f0_ready = false;
61 swf_f1_ready = false;
48 swf_f1_ready = false;
62 swf_f2_ready = false;
49 swf_f2_ready = false;
63 }
50 }
64
51
65 void waveforms_isr_f3( void )
52 inline void waveforms_isr_f3( void )
66 {
53 {
67 rtems_status_code spare_status;
54 rtems_status_code spare_status;
68
55
69 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
56 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
70 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
57 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
71 { // in modes other than STANDBY and BURST, send the CWF_F3 data
58 { // in modes other than STANDBY and BURST, send the CWF_F3 data
72 //***
59 //***
73 // F3
60 // F3
74 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
61 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
75 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
62 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
76 current_ring_node_f3 = current_ring_node_f3->next;
63 current_ring_node_f3 = current_ring_node_f3->next;
77 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
64 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
78 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
65 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
79 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
66 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
80 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
67 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
81 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
68 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
82 }
69 }
83 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
70 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
84 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
71 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
85 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
72 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
86 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
73 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
87 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
74 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
88 }
75 }
89 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
76 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
90 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
77 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
91 }
78 }
92 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
79 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2);
93 }
80 }
94 }
81 }
95 }
82 }
96
83
97 void waveforms_isr_normal( void )
84 inline void waveforms_isr_normal( void )
98 {
85 {
99 rtems_status_code status;
86 rtems_status_code status;
100
87
101 if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits
88 if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits
102 && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits
89 && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits
103 && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
90 && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
104 {
91 {
105 //***
92 //***
106 // F0
93 // F0
107 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
94 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
108 current_ring_node_f0 = current_ring_node_f0->next;
95 current_ring_node_f0 = current_ring_node_f0->next;
109 if ( (waveform_picker_regs->status & 0x01) == 0x01)
96 if ( (waveform_picker_regs->status & 0x01) == 0x01)
110 {
97 {
111
98
112 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
99 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
113 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
100 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
114 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
101 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
115 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
102 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
116 }
103 }
117 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
104 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
118 {
105 {
119 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
106 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
120 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
107 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
121 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
108 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
122 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
109 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
123 }
110 }
124
111
125 //***
112 //***
126 // F1
113 // F1
127 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
114 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
128 current_ring_node_f1 = current_ring_node_f1->next;
115 current_ring_node_f1 = current_ring_node_f1->next;
129 if ( (waveform_picker_regs->status & 0x04) == 0x04)
116 if ( (waveform_picker_regs->status & 0x04) == 0x04)
130 {
117 {
131 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
118 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
132 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
119 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
133 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
120 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
134 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
121 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
135 }
122 }
136 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
123 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
137 {
124 {
138 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
125 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
139 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
126 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
140 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
127 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
141 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
128 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
142 }
129 }
143
130
144 //***
131 //***
145 // F2
132 // F2
146 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
133 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
147 current_ring_node_f2 = current_ring_node_f2->next;
134 current_ring_node_f2 = current_ring_node_f2->next;
148 if ( (waveform_picker_regs->status & 0x10) == 0x10)
135 if ( (waveform_picker_regs->status & 0x10) == 0x10)
149 {
136 {
150 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
137 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
151 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
138 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
152 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
139 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
153 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
140 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
154 }
141 }
155 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
142 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
156 {
143 {
157 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
144 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
158 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
145 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
159 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
146 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
160 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
147 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
161 }
148 }
162 //
149 //
163 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
150 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
164 if ( status != RTEMS_SUCCESSFUL)
151 if ( status != RTEMS_SUCCESSFUL)
165 {
152 {
166 status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
153 status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
167 }
154 }
168 }
155 }
169 }
156 }
170
157
171 void waveforms_isr_burst( void )
158 inline void waveforms_isr_burst( void )
172 {
159 {
173 rtems_status_code spare_status;
160 rtems_status_code spare_status;
174
161
175 if ( (waveform_picker_regs->status & 0x30) != 0 ){ // [0100] check the f2 full bit
162 if ( (waveform_picker_regs->status & 0x30) != 0 ){ // [0100] check the f2 full bit
176 // (1) change the receiving buffer for the waveform picker
163 // (1) change the receiving buffer for the waveform picker
177 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
164 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
178 current_ring_node_f2 = current_ring_node_f2->next;
165 current_ring_node_f2 = current_ring_node_f2->next;
179 if ( (waveform_picker_regs->status & 0x10) == 0x10)
166 if ( (waveform_picker_regs->status & 0x10) == 0x10)
180 {
167 {
181 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
168 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
182 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
169 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
183 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
170 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
184 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
171 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
185 }
172 }
186 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
173 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
187 {
174 {
188 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
175 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
189 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
176 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
190 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
177 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
191 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
178 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
192 }
179 }
193 // (2) send an event for the waveforms transmission
180 // (2) send an event for the waveforms transmission
194 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
181 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
195 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
182 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
196 }
183 }
197 }
184 }
198 }
185 }
199
186
200 void waveforms_isr_sbm1( void )
187 inline void waveforms_isr_sbm1( void )
201 {
188 {
202 rtems_status_code status;
189 rtems_status_code status;
203 rtems_status_code spare_status;
204
190
205 //***
191 //***
206 // F1
192 // F1
207 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
193 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
208 // (1) change the receiving buffer for the waveform picker
194 // (1) change the receiving buffer for the waveform picker
209 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
195 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
210 current_ring_node_f1 = current_ring_node_f1->next;
196 current_ring_node_f1 = current_ring_node_f1->next;
211 if ( (waveform_picker_regs->status & 0x04) == 0x04)
197 if ( (waveform_picker_regs->status & 0x04) == 0x04)
212 {
198 {
213 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
199 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
214 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
200 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
215 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
201 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
216 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
202 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
217 }
203 }
218 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
204 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
219 {
205 {
220 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
206 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
221 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
207 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
222 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
208 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
223 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
209 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
224 }
210 }
225 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
211 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
226 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
212 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
227 }
213 }
228
214
229 //***
215 //***
230 // F0
216 // F0
231 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits
217 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits
232 swf_f0_ready = true;
218 swf_f0_ready = true;
233 // change f0 buffer
219 // change f0 buffer
234 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
220 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
235 current_ring_node_f0 = current_ring_node_f0->next;
221 current_ring_node_f0 = current_ring_node_f0->next;
236 if ( (waveform_picker_regs->status & 0x01) == 0x01)
222 if ( (waveform_picker_regs->status & 0x01) == 0x01)
237 {
223 {
238
224
239 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
225 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
240 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
226 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
241 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
227 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
242 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
228 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
243 }
229 }
244 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
230 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
245 {
231 {
246 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
232 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
247 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
233 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
248 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
234 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
249 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
235 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
250 }
236 }
251 }
237 }
252
238
253 //***
239 //***
254 // F2
240 // F2
255 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits
241 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits
256 swf_f2_ready = true;
242 swf_f2_ready = true;
257 // change f2 buffer
243 // change f2 buffer
258 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
244 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
259 current_ring_node_f2 = current_ring_node_f2->next;
245 current_ring_node_f2 = current_ring_node_f2->next;
260 if ( (waveform_picker_regs->status & 0x10) == 0x10)
246 if ( (waveform_picker_regs->status & 0x10) == 0x10)
261 {
247 {
262 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
248 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
263 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
249 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
264 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
250 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
265 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
251 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
266 }
252 }
267 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
253 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
268 {
254 {
269 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
255 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
270 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
256 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
271 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
257 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
272 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
258 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
273 }
259 }
274 // start the snapshots transmission
275 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL)
276 {
277 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
278 }
279 }
260 }
280 }
261 }
281
262
282 void waveforms_isr_sbm2( void )
263 inline void waveforms_isr_sbm2( void )
283 {
264 {
284 rtems_status_code status;
265 rtems_status_code status;
285
266
286 //***
267 //***
287 // F2
268 // F2
288 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
269 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
289 // (1) change the receiving buffer for the waveform picker
270 // (1) change the receiving buffer for the waveform picker
290 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
271 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
291 current_ring_node_f2 = current_ring_node_f2->next;
272 current_ring_node_f2 = current_ring_node_f2->next;
292 if ( (waveform_picker_regs->status & 0x10) == 0x10)
273 if ( (waveform_picker_regs->status & 0x10) == 0x10)
293 {
274 {
294 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
275 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
295 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
276 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
296 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
277 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
297 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
278 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
298 }
279 }
299 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
280 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
300 {
281 {
301 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
282 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
302 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
283 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
303 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
284 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
304 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
285 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
305 }
286 }
306 // (2) send an event for the waveforms transmission
287 // (2) send an event for the waveforms transmission
307 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
288 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
308 }
289 }
309
290
310 //***
291 //***
311 // F0
292 // F0
312 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit
293 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit
313 swf_f0_ready = true;
294 swf_f0_ready = true;
314 // change f0 buffer
295 // change f0 buffer
315 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
296 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
316 current_ring_node_f0 = current_ring_node_f0->next;
297 current_ring_node_f0 = current_ring_node_f0->next;
317 if ( (waveform_picker_regs->status & 0x01) == 0x01)
298 if ( (waveform_picker_regs->status & 0x01) == 0x01)
318 {
299 {
319
300
320 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
301 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
321 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
302 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
322 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
303 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
323 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
304 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
324 }
305 }
325 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
306 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
326 {
307 {
327 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
308 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
328 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
309 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
329 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
310 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
330 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
311 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
331 }
312 }
332 }
313 }
333
314
334 //***
315 //***
335 // F1
316 // F1
336 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit
317 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit
337 swf_f1_ready = true;
318 swf_f1_ready = true;
338 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
319 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
339 current_ring_node_f1 = current_ring_node_f1->next;
320 current_ring_node_f1 = current_ring_node_f1->next;
340 if ( (waveform_picker_regs->status & 0x04) == 0x04)
321 if ( (waveform_picker_regs->status & 0x04) == 0x04)
341 {
322 {
342 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
323 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
343 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
324 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
344 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
325 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
345 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
326 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
346 }
327 }
347 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
328 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
348 {
329 {
349 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
330 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
350 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
331 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
351 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
332 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
352 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
333 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
353 }
334 }
354 }
335 }
355 }
336 }
356
337
357 rtems_isr waveforms_isr( rtems_vector_number vector )
338 rtems_isr waveforms_isr( rtems_vector_number vector )
358 {
339 {
359 /** This is the interrupt sub routine called by the waveform picker core.
340 /** This is the interrupt sub routine called by the waveform picker core.
360 *
341 *
361 * This ISR launch different actions depending mainly on two pieces of information:
342 * This ISR launch different actions depending mainly on two pieces of information:
362 * 1. the values read in the registers of the waveform picker.
343 * 1. the values read in the registers of the waveform picker.
363 * 2. the current LFR mode.
344 * 2. the current LFR mode.
364 *
345 *
365 */
346 */
366
347
367 // STATUS
348 // STATUS
368 // new error error buffer full
349 // new error error buffer full
369 // 15 14 13 12 11 10 9 8
350 // 15 14 13 12 11 10 9 8
370 // f3 f2 f1 f0 f3 f2 f1 f0
351 // f3 f2 f1 f0 f3 f2 f1 f0
371 //
352 //
372 // ready buffer
353 // ready buffer
373 // 7 6 5 4 3 2 1 0
354 // 7 6 5 4 3 2 1 0
374 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
355 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
375
356
376 rtems_status_code spare_status;
357 rtems_status_code spare_status;
377
358
378 waveforms_isr_f3();
359 waveforms_isr_f3();
379
360
380 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
361 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
381 {
362 {
382 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
363 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
383 }
364 }
384
365
385 switch(lfrCurrentMode)
366 switch(lfrCurrentMode)
386 {
367 {
387 //********
368 //********
388 // STANDBY
369 // STANDBY
389 case(LFR_MODE_STANDBY):
370 case(LFR_MODE_STANDBY):
390 break;
371 break;
391
372
392 //******
373 //******
393 // NORMAL
374 // NORMAL
394 case(LFR_MODE_NORMAL):
375 case(LFR_MODE_NORMAL):
395 waveforms_isr_normal();
376 waveforms_isr_normal();
396 break;
377 break;
397
378
398 //******
379 //******
399 // BURST
380 // BURST
400 case(LFR_MODE_BURST):
381 case(LFR_MODE_BURST):
401 waveforms_isr_burst();
382 waveforms_isr_burst();
402 break;
383 break;
403
384
404 //*****
385 //*****
405 // SBM1
386 // SBM1
406 case(LFR_MODE_SBM1):
387 case(LFR_MODE_SBM1):
407 waveforms_isr_sbm1();
388 waveforms_isr_sbm1();
408 break;
389 break;
409
390
410 //*****
391 //*****
411 // SBM2
392 // SBM2
412 case(LFR_MODE_SBM2):
393 case(LFR_MODE_SBM2):
413 waveforms_isr_sbm2();
394 waveforms_isr_sbm2();
414 break;
395 break;
415
396
416 //********
397 //********
417 // DEFAULT
398 // DEFAULT
418 default:
399 default:
419 break;
400 break;
420 }
401 }
421 }
402 }
422
403
423 //************
404 //************
424 // RTEMS TASKS
405 // RTEMS TASKS
425
406
426 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
407 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
427 {
408 {
428 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
409 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
429 *
410 *
430 * @param unused is the starting argument of the RTEMS task
411 * @param unused is the starting argument of the RTEMS task
431 *
412 *
432 * The following data packets are sent by this task:
413 * The following data packets are sent by this task:
433 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
414 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
434 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
415 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
435 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
416 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
436 *
417 *
437 */
418 */
438
419
439 rtems_event_set event_out;
420 rtems_event_set event_out;
440 rtems_id queue_id;
421 rtems_id queue_id;
441 rtems_status_code status;
422 rtems_status_code status;
442 bool resynchronisationEngaged;
423 bool resynchronisationEngaged;
424 ring_node *ring_node_wf_snap_extracted_ptr;
425
426 ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted;
443
427
444 resynchronisationEngaged = false;
428 resynchronisationEngaged = false;
445
429
446 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
447 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
448 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
449
450 status = get_message_queue_id_send( &queue_id );
430 status = get_message_queue_id_send( &queue_id );
451 if (status != RTEMS_SUCCESSFUL)
431 if (status != RTEMS_SUCCESSFUL)
452 {
432 {
453 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
433 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
454 }
434 }
455
435
456 BOOT_PRINTF("in WFRM ***\n")
436 BOOT_PRINTF("in WFRM ***\n")
457
437
458 while(1){
438 while(1){
459 // wait for an RTEMS_EVENT
439 // wait for an RTEMS_EVENT
460 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
440 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
461 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
441 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
462 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
442 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
463 if(resynchronisationEngaged == false)
443 if(resynchronisationEngaged == false)
464 { // engage resynchronisation
444 { // engage resynchronisation
465 snapshot_resynchronization( (unsigned char *) ring_node_to_send_swf_f0->buffer_address);
445 snapshot_resynchronization( (unsigned char *) ring_node_to_send_swf_f0->coarseTime );
466 resynchronisationEngaged = true;
446 resynchronisationEngaged = true;
467 }
447 }
468 else
448 else
469 { // reset delta_snapshot to the nominal value
449 { // reset delta_snapshot to the nominal value
470 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
450 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
471 set_wfp_delta_snapshot();
451 set_wfp_delta_snapshot();
472 resynchronisationEngaged = false;
452 resynchronisationEngaged = false;
473 }
453 }
474 //
454 //
475
455
476 if (event_out == RTEMS_EVENT_MODE_NORMAL)
456 if (event_out == RTEMS_EVENT_MODE_NORMAL)
477 {
457 {
478 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
458 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
479 send_waveform_SWF( ring_node_to_send_swf_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
459 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
480 send_waveform_SWF( ring_node_to_send_swf_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
460 ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1;
481 send_waveform_SWF( ring_node_to_send_swf_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
461 ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2;
462 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
463 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) );
464 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) );
482 }
465 }
483 if (event_out == RTEMS_EVENT_MODE_SBM1)
466 if (event_out == RTEMS_EVENT_MODE_SBM1)
484 {
467 {
485 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
468 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
486 send_waveform_SWF( ring_node_to_send_swf_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
469 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
487 send_waveform_SWF( &ring_node_wf_snap_extracted, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
470 ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1;
488 send_waveform_SWF( ring_node_to_send_swf_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
471 ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2;
472 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
473 status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) );
474 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) );
489 }
475 }
490 if (event_out == RTEMS_EVENT_MODE_SBM2)
476 if (event_out == RTEMS_EVENT_MODE_SBM2)
491 {
477 {
492 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
478 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
493 send_waveform_SWF( ring_node_to_send_swf_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
479 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
494 send_waveform_SWF( ring_node_to_send_swf_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
480 ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1;
495 send_waveform_SWF( &ring_node_wf_snap_extracted, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
481 ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2;
482 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
483 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) );
484 status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) );
496 }
485 }
497 }
486 }
498 }
487 }
499
488
500 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
489 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
501 {
490 {
502 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
491 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
503 *
492 *
504 * @param unused is the starting argument of the RTEMS task
493 * @param unused is the starting argument of the RTEMS task
505 *
494 *
506 * The following data packet is sent by this task:
495 * The following data packet is sent by this task:
507 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
496 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
508 *
497 *
509 */
498 */
510
499
511 rtems_event_set event_out;
500 rtems_event_set event_out;
512 rtems_id queue_id;
501 rtems_id queue_id;
513 rtems_status_code status;
502 rtems_status_code status;
514
503 ring_node ring_node_cwf3_light;
515 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
516 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
517
504
518 status = get_message_queue_id_send( &queue_id );
505 status = get_message_queue_id_send( &queue_id );
519 if (status != RTEMS_SUCCESSFUL)
506 if (status != RTEMS_SUCCESSFUL)
520 {
507 {
521 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
508 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
522 }
509 }
523
510
511 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
512
513 // init the ring_node_cwf3_light structure
514 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
515 ring_node_cwf3_light.coarseTime = 0x00;
516 ring_node_cwf3_light.fineTime = 0x00;
517 ring_node_cwf3_light.next = NULL;
518 ring_node_cwf3_light.previous = NULL;
519 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
520 ring_node_cwf3_light.status = 0x00;
521
524 BOOT_PRINTF("in CWF3 ***\n")
522 BOOT_PRINTF("in CWF3 ***\n")
525
523
526 while(1){
524 while(1){
527 // wait for an RTEMS_EVENT
525 // wait for an RTEMS_EVENT
528 rtems_event_receive( RTEMS_EVENT_0,
526 rtems_event_receive( RTEMS_EVENT_0,
529 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
527 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
530 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
528 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
531 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
529 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
532 {
530 {
533 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
531 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
534 {
532 {
535 PRINTF("send CWF_LONG_F3\n")
533 PRINTF("send CWF_LONG_F3\n")
536 send_waveform_CWF( ring_node_to_send_cwf_f3,
534 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
537 SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
535 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
538 }
536 }
539 else
537 else
540 {
538 {
541 PRINTF("send CWF_F3 (light)\n")
539 PRINTF("send CWF_F3 (light)\n")
542 send_waveform_CWF3_light( ring_node_to_send_cwf_f3,
540 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_F3;
543 headerCWF_F3_light, queue_id );
541 send_waveform_CWF3_light( ring_node_to_send_cwf_f3, &ring_node_cwf3_light, queue_id );
544 }
542 }
545
543
546 }
544 }
547 else
545 else
548 {
546 {
549 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
547 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
550 }
548 }
551 }
549 }
552 }
550 }
553
551
554 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
552 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
555 {
553 {
556 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
554 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
557 *
555 *
558 * @param unused is the starting argument of the RTEMS task
556 * @param unused is the starting argument of the RTEMS task
559 *
557 *
560 * The following data packet is sent by this function:
558 * The following data packet is sent by this function:
561 * - TM_LFR_SCIENCE_BURST_CWF_F2
559 * - TM_LFR_SCIENCE_BURST_CWF_F2
562 * - TM_LFR_SCIENCE_SBM2_CWF_F2
560 * - TM_LFR_SCIENCE_SBM2_CWF_F2
563 *
561 *
564 */
562 */
565
563
566 rtems_event_set event_out;
564 rtems_event_set event_out;
567 rtems_id queue_id;
565 rtems_id queue_id;
568 rtems_status_code status;
566 rtems_status_code status;
569
567
570 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
571 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
572
573 status = get_message_queue_id_send( &queue_id );
568 status = get_message_queue_id_send( &queue_id );
574 if (status != RTEMS_SUCCESSFUL)
569 if (status != RTEMS_SUCCESSFUL)
575 {
570 {
576 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
571 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
577 }
572 }
578
573
579 BOOT_PRINTF("in CWF2 ***\n")
574 BOOT_PRINTF("in CWF2 ***\n")
580
575
581 while(1){
576 while(1){
582 // wait for an RTEMS_EVENT
577 // wait for an RTEMS_EVENT
583 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
578 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
584 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
579 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
585 if (event_out == RTEMS_EVENT_MODE_BURST)
580 if (event_out == RTEMS_EVENT_MODE_BURST)
586 {
581 {
587 send_waveform_CWF( ring_node_to_send_cwf_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
582 // send_waveform_CWF( ring_node_to_send_cwf_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
583 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
584 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
588 }
585 }
589 if (event_out == RTEMS_EVENT_MODE_SBM2)
586 if (event_out == RTEMS_EVENT_MODE_SBM2)
590 {
587 {
591 send_waveform_CWF( ring_node_to_send_cwf_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
588 // send_waveform_CWF( ring_node_to_send_cwf_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
589 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
590 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f2, sizeof( ring_node* ) );
592 // launch snapshot extraction if needed
591 // launch snapshot extraction if needed
593 if (extractSWF == true)
592 if (extractSWF == true)
594 {
593 {
595 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
594 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
596 // extract the snapshot
595 // extract the snapshot
597 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
596 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
598 // send the snapshot when built
597 // send the snapshot when built
599 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
598 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
600 extractSWF = false;
599 extractSWF = false;
601 }
600 }
602 if (swf_f0_ready && swf_f1_ready)
601 if (swf_f0_ready && swf_f1_ready)
603 {
602 {
604 extractSWF = true;
603 extractSWF = true;
605 swf_f0_ready = false;
604 swf_f0_ready = false;
606 swf_f1_ready = false;
605 swf_f1_ready = false;
607 }
606 }
608 }
607 }
609 }
608 }
610 }
609 }
611
610
612 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
611 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
613 {
612 {
614 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
613 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
615 *
614 *
616 * @param unused is the starting argument of the RTEMS task
615 * @param unused is the starting argument of the RTEMS task
617 *
616 *
618 * The following data packet is sent by this function:
617 * The following data packet is sent by this function:
619 * - TM_LFR_SCIENCE_SBM1_CWF_F1
618 * - TM_LFR_SCIENCE_SBM1_CWF_F1
620 *
619 *
621 */
620 */
622
621
623 rtems_event_set event_out;
622 rtems_event_set event_out;
624 rtems_id queue_id;
623 rtems_id queue_id;
625 rtems_status_code status;
624 rtems_status_code status;
626
625
627 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
626 // init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
628
627
629 status = get_message_queue_id_send( &queue_id );
628 status = get_message_queue_id_send( &queue_id );
630 if (status != RTEMS_SUCCESSFUL)
629 if (status != RTEMS_SUCCESSFUL)
631 {
630 {
632 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
631 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
633 }
632 }
634
633
635 BOOT_PRINTF("in CWF1 ***\n")
634 BOOT_PRINTF("in CWF1 ***\n")
636
635
637 while(1){
636 while(1){
638 // wait for an RTEMS_EVENT
637 // wait for an RTEMS_EVENT
639 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
638 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
640 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
639 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
641 send_waveform_CWF( ring_node_to_send_cwf_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
640 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
641 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf_f1, sizeof( ring_node* ) );
642 // launch snapshot extraction if needed
642 // launch snapshot extraction if needed
643 if (extractSWF == true)
643 if (extractSWF == true)
644 {
644 {
645 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
645 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
646 // launch the snapshot extraction
646 // launch the snapshot extraction
647 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
647 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
648 extractSWF = false;
648 extractSWF = false;
649 }
649 }
650 if (swf_f0_ready == true)
650 if (swf_f0_ready == true)
651 {
651 {
652 extractSWF = true;
652 extractSWF = true;
653 swf_f0_ready = false; // this step shall be executed only one time
653 swf_f0_ready = false; // this step shall be executed only one time
654 }
654 }
655 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
655 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
656 {
656 {
657 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
657 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
658 swf_f1_ready = false;
658 swf_f1_ready = false;
659 swf_f2_ready = false;
659 swf_f2_ready = false;
660 }
660 }
661 }
661 }
662 }
662 }
663
663
664 rtems_task swbd_task(rtems_task_argument argument)
664 rtems_task swbd_task(rtems_task_argument argument)
665 {
665 {
666 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
666 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
667 *
667 *
668 * @param unused is the starting argument of the RTEMS task
668 * @param unused is the starting argument of the RTEMS task
669 *
669 *
670 */
670 */
671
671
672 rtems_event_set event_out;
672 rtems_event_set event_out;
673
673
674 BOOT_PRINTF("in SWBD ***\n")
674 BOOT_PRINTF("in SWBD ***\n")
675
675
676 while(1){
676 while(1){
677 // wait for an RTEMS_EVENT
677 // wait for an RTEMS_EVENT
678 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
678 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
679 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
679 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
680 if (event_out == RTEMS_EVENT_MODE_SBM1)
680 if (event_out == RTEMS_EVENT_MODE_SBM1)
681 {
681 {
682 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
682 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
683 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
683 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
684 }
684 }
685 else
685 else
686 {
686 {
687 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
687 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
688 }
688 }
689 }
689 }
690 }
690 }
691
691
692 //******************
692 //******************
693 // general functions
693 // general functions
694
694
695 void WFP_init_rings( void )
695 void WFP_init_rings( void )
696 {
696 {
697 // F0 RING
697 // F0 RING
698 init_waveform_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_snap_f0 );
698 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
699 // F1 RING
699 // F1 RING
700 init_waveform_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_snap_f1 );
700 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
701 // F2 RING
701 // F2 RING
702 init_waveform_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_snap_f2 );
702 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
703 // F3 RING
703 // F3 RING
704 init_waveform_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_cont_f3 );
704 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER );
705
705
706 ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted;
706 ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted;
707
707
708 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
708 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
709 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
709 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
710 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
710 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
711 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
711 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
712 DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0)
713 DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1)
714 DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2)
715 DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3)
716
712 }
717 }
713
718
714 void init_waveform_ring(ring_node waveform_ring[], unsigned char nbNodes, volatile int wfrm[] )
719 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
715 {
720 {
716 unsigned char i;
721 unsigned char i;
717
722
718 waveform_ring[0].next = (ring_node*) &waveform_ring[ 1 ];
723 //***************
719 waveform_ring[0].previous = (ring_node*) &waveform_ring[ nbNodes - 1 ];
724 // BUFFER ADDRESS
720 waveform_ring[0].buffer_address = (int) &wfrm[0];
725 for(i=0; i<nbNodes; i++)
726 {
727 ring[i].coarseTime = 0x00;
728 ring[i].fineTime = 0x00;
729 ring[i].sid = 0x00;
730 ring[i].status = 0x00;
731 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
732 }
721
733
722 waveform_ring[nbNodes-1].next = (ring_node*) &waveform_ring[ 0 ];
734 //*****
723 waveform_ring[nbNodes-1].previous = (ring_node*) &waveform_ring[ nbNodes - 2 ];
735 // NEXT
724 waveform_ring[nbNodes-1].buffer_address = (int) &wfrm[ (nbNodes-1) * WFRM_BUFFER ];
736 ring[nbNodes-1].next = (ring_node*) &ring[ 0 ];
737 for(i=0; i<nbNodes-1; i++)
738 {
739 ring[i].next = (ring_node*) &ring[ i + 1 ];
740 }
725
741
726 for(i=1; i<nbNodes-1; i++)
742 //*********
743 // PREVIOUS
744 ring[0].previous = (ring_node*) &ring[ nbNodes - 1 ];
745 for(i=1; i<nbNodes; i++)
727 {
746 {
728 waveform_ring[i].next = (ring_node*) &waveform_ring[ i + 1 ];
747 ring[i].previous = (ring_node*) &ring[ i - 1 ];
729 waveform_ring[i].previous = (ring_node*) &waveform_ring[ i - 1 ];
730 waveform_ring[i].buffer_address = (int) &wfrm[ i * WFRM_BUFFER ];
731 }
748 }
732 }
749 }
733
750
734 void WFP_reset_current_ring_nodes( void )
751 void WFP_reset_current_ring_nodes( void )
735 {
752 {
736 current_ring_node_f0 = waveform_ring_f0;
753 current_ring_node_f0 = waveform_ring_f0;
737 ring_node_to_send_swf_f0 = waveform_ring_f0;
754 ring_node_to_send_swf_f0 = waveform_ring_f0;
738
755
739 current_ring_node_f1 = waveform_ring_f1;
756 current_ring_node_f1 = waveform_ring_f1;
740 ring_node_to_send_cwf_f1 = waveform_ring_f1;
757 ring_node_to_send_cwf_f1 = waveform_ring_f1;
741 ring_node_to_send_swf_f1 = waveform_ring_f1;
758 ring_node_to_send_swf_f1 = waveform_ring_f1;
742
759
743 current_ring_node_f2 = waveform_ring_f2;
760 current_ring_node_f2 = waveform_ring_f2;
744 ring_node_to_send_cwf_f2 = waveform_ring_f2;
761 ring_node_to_send_cwf_f2 = waveform_ring_f2;
745 ring_node_to_send_swf_f2 = waveform_ring_f2;
762 ring_node_to_send_swf_f2 = waveform_ring_f2;
746
763
747 current_ring_node_f3 = waveform_ring_f3;
764 current_ring_node_f3 = waveform_ring_f3;
748 ring_node_to_send_cwf_f3 = waveform_ring_f3;
765 ring_node_to_send_cwf_f3 = waveform_ring_f3;
749 }
766 }
750
767
751 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
768 int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id )
752 {
753 unsigned char i;
754 int return_value;
755
756 return_value = LFR_SUCCESSFUL;
757
758 for (i=0; i<7; i++)
759 {
760 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
761 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
762 headerSWF[ i ].reserved = DEFAULT_RESERVED;
763 headerSWF[ i ].userApplication = CCSDS_USER_APP;
764 headerSWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
765 headerSWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
766 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
767 if (i == 6)
768 {
769 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
770 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
771 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
772 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
773 }
774 else
775 {
776 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
777 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
778 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
779 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
780 }
781 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
782 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
783 headerSWF[ i ].pktNr = i+1; // PKT_NR
784 // DATA FIELD HEADER
785 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
786 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
787 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
788 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
789 // AUXILIARY DATA HEADER
790 headerSWF[ i ].time[0] = 0x00;
791 headerSWF[ i ].time[0] = 0x00;
792 headerSWF[ i ].time[0] = 0x00;
793 headerSWF[ i ].time[0] = 0x00;
794 headerSWF[ i ].time[0] = 0x00;
795 headerSWF[ i ].time[0] = 0x00;
796 headerSWF[ i ].sid = sid;
797 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
798 }
799
800 return return_value;
801 }
802
803 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
804 {
805 unsigned int i;
806 int return_value;
807
808 return_value = LFR_SUCCESSFUL;
809
810 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++)
811 {
812 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
813 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
814 headerCWF[ i ].reserved = DEFAULT_RESERVED;
815 headerCWF[ i ].userApplication = CCSDS_USER_APP;
816 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
817 {
818 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
819 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
820 }
821 else
822 {
823 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
824 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
825 }
826 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
827 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
828 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
829 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
830 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF );
831 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
832 // DATA FIELD HEADER
833 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
834 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
835 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
836 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
837 // AUXILIARY DATA HEADER
838 headerCWF[ i ].sid = sid;
839 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
840 headerCWF[ i ].time[0] = 0x00;
841 headerCWF[ i ].time[0] = 0x00;
842 headerCWF[ i ].time[0] = 0x00;
843 headerCWF[ i ].time[0] = 0x00;
844 headerCWF[ i ].time[0] = 0x00;
845 headerCWF[ i ].time[0] = 0x00;
846 }
847
848 return return_value;
849 }
850
851 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
852 {
853 unsigned int i;
854 int return_value;
855
856 return_value = LFR_SUCCESSFUL;
857
858 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++)
859 {
860 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
861 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
862 headerCWF[ i ].reserved = DEFAULT_RESERVED;
863 headerCWF[ i ].userApplication = CCSDS_USER_APP;
864
865 headerCWF[ i ].packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
866 headerCWF[ i ].packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
867
868 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
869 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
870 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
871 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
872 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
873
874 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
875 // DATA FIELD HEADER
876 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
877 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
878 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
879 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
880 // AUXILIARY DATA HEADER
881 headerCWF[ i ].sid = SID_NORM_CWF_F3;
882 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
883 headerCWF[ i ].time[0] = 0x00;
884 headerCWF[ i ].time[0] = 0x00;
885 headerCWF[ i ].time[0] = 0x00;
886 headerCWF[ i ].time[0] = 0x00;
887 headerCWF[ i ].time[0] = 0x00;
888 headerCWF[ i ].time[0] = 0x00;
889 }
890
891 return return_value;
892 }
893
894 int send_waveform_SWF( ring_node *ring_node_to_send, unsigned int sid,
895 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
896 {
897 /** This function sends SWF CCSDS packets (F2, F1 or F0).
898 *
899 * @param waveform points to the buffer containing the data that will be send.
900 * @param sid is the source identifier of the data that will be sent.
901 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
902 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
903 * contain information to setup the transmission of the data packets.
904 *
905 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
906 *
907 */
908
909 unsigned int i;
910 int ret;
911 unsigned int coarseTime;
912 unsigned int fineTime;
913 rtems_status_code status;
914 spw_ioctl_pkt_send spw_ioctl_send_SWF;
915 int *dataPtr;
916
917 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
918 spw_ioctl_send_SWF.options = 0;
919
920 ret = LFR_DEFAULT;
921
922 coarseTime = ring_node_to_send->coarseTime;
923 fineTime = ring_node_to_send->fineTime;
924 dataPtr = (int*) ring_node_to_send->buffer_address;
925
926 for (i=0; i<7; i++) // send waveform
927 {
928 spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ];
929 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
930 // BUILD THE DATA
931 if (i==6) {
932 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
933 }
934 else {
935 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
936 }
937 // SET PACKET SEQUENCE COUNTER
938 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
939 // SET PACKET TIME
940 compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime );
941 //
942 headerSWF[ i ].time[0] = headerSWF[ i ].acquisitionTime[0];
943 headerSWF[ i ].time[1] = headerSWF[ i ].acquisitionTime[1];
944 headerSWF[ i ].time[2] = headerSWF[ i ].acquisitionTime[2];
945 headerSWF[ i ].time[3] = headerSWF[ i ].acquisitionTime[3];
946 headerSWF[ i ].time[4] = headerSWF[ i ].acquisitionTime[4];
947 headerSWF[ i ].time[5] = headerSWF[ i ].acquisitionTime[5];
948 // SEND PACKET
949 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
950 if (status != RTEMS_SUCCESSFUL) {
951 printf("%d-%d, ERR %d\n", sid, i, (int) status);
952 ret = LFR_DEFAULT;
953 }
954 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
955 }
956
957 return ret;
958 }
959
960 int send_waveform_CWF(ring_node *ring_node_to_send, unsigned int sid,
961 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
962 {
963 /** This function sends CWF CCSDS packets (F2, F1 or F0).
964 *
965 * @param waveform points to the buffer containing the data that will be send.
966 * @param sid is the source identifier of the data that will be sent.
967 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
968 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
969 * contain information to setup the transmission of the data packets.
970 *
971 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
972 *
973 */
974
975 unsigned int i;
976 int ret;
977 unsigned int coarseTime;
978 unsigned int fineTime;
979 rtems_status_code status;
980 spw_ioctl_pkt_send spw_ioctl_send_CWF;
981 int *dataPtr;
982
983 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
984 spw_ioctl_send_CWF.options = 0;
985
986 ret = LFR_DEFAULT;
987
988 coarseTime = ring_node_to_send->coarseTime;
989 fineTime = ring_node_to_send->fineTime;
990 dataPtr = (int*) ring_node_to_send->buffer_address;
991
992 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
993 {
994 spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ];
995 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
996 // BUILD THE DATA
997 spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK;
998 // SET PACKET SEQUENCE COUNTER
999 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
1000 // SET PACKET TIME
1001 compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime);
1002 //
1003 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
1004 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
1005 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
1006 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
1007 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
1008 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
1009 // SEND PACKET
1010 if (sid == SID_NORM_CWF_LONG_F3)
1011 {
1012 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
1013 if (status != RTEMS_SUCCESSFUL) {
1014 printf("%d-%d, ERR %d\n", sid, i, (int) status);
1015 ret = LFR_DEFAULT;
1016 }
1017 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
1018 }
1019 else
1020 {
1021 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
1022 if (status != RTEMS_SUCCESSFUL) {
1023 printf("%d-%d, ERR %d\n", sid, i, (int) status);
1024 ret = LFR_DEFAULT;
1025 }
1026 }
1027 }
1028
1029 return ret;
1030 }
1031
1032 int send_waveform_CWF3_light( ring_node *ring_node_to_send, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id )
1033 {
769 {
1034 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
770 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
1035 *
771 *
1036 * @param waveform points to the buffer containing the data that will be send.
772 * @param waveform points to the buffer containing the data that will be send.
1037 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
773 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
1038 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
774 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
1039 * contain information to setup the transmission of the data packets.
775 * contain information to setup the transmission of the data packets.
1040 *
776 *
1041 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
777 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
1042 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
778 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
1043 *
779 *
1044 */
780 */
1045
781
1046 unsigned int i;
782 unsigned int i;
1047 int ret;
783 int ret;
1048 unsigned int coarseTime;
1049 unsigned int fineTime;
1050 rtems_status_code status;
784 rtems_status_code status;
1051 spw_ioctl_pkt_send spw_ioctl_send_CWF;
785 spw_ioctl_pkt_send spw_ioctl_send_CWF;
1052 char *sample;
786 char *sample;
1053 int *dataPtr;
787 int *dataPtr;
1054
788
1055 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
789 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
1056 spw_ioctl_send_CWF.options = 0;
790 spw_ioctl_send_CWF.options = 0;
1057
791
1058 ret = LFR_DEFAULT;
792 ret = LFR_DEFAULT;
1059
793
1060 coarseTime = ring_node_to_send->coarseTime;
1061 fineTime = ring_node_to_send->fineTime;
1062 dataPtr = (int*) ring_node_to_send->buffer_address;
794 dataPtr = (int*) ring_node_to_send->buffer_address;
1063
795
796 ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime;
797 ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime;
798
1064 //**********************
799 //**********************
1065 // BUILD CWF3_light DATA
800 // BUILD CWF3_light DATA
1066 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
801 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
1067 {
802 {
1068 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
803 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
1069 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
804 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
1070 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
805 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
1071 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
806 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
1072 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
807 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
1073 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
808 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
1074 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
809 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
1075 }
810 }
1076
811
1077 //*********************
1078 // SEND CWF3_light DATA
1079 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform
1080 {
1081 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ];
1082 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
1083 // BUILD THE DATA
1084 spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK;
1085 // SET PACKET SEQUENCE COUNTER
1086 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
1087 // SET PACKET TIME
1088 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime );
1089 //
1090 headerCWF[ i ].time[0] = headerCWF[ i ].acquisitionTime[0];
1091 headerCWF[ i ].time[1] = headerCWF[ i ].acquisitionTime[1];
1092 headerCWF[ i ].time[2] = headerCWF[ i ].acquisitionTime[2];
1093 headerCWF[ i ].time[3] = headerCWF[ i ].acquisitionTime[3];
1094 headerCWF[ i ].time[4] = headerCWF[ i ].acquisitionTime[4];
1095 headerCWF[ i ].time[5] = headerCWF[ i ].acquisitionTime[5];
1096 // SEND PACKET
812 // SEND PACKET
1097 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
813 status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) );
1098 if (status != RTEMS_SUCCESSFUL) {
814 if (status != RTEMS_SUCCESSFUL) {
1099 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
815 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
1100 ret = LFR_DEFAULT;
816 ret = LFR_DEFAULT;
1101 }
817 }
1102 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
1103 }
1104
818
1105 return ret;
819 return ret;
1106 }
820 }
1107
821
1108 int send_ring_node_CWF( ring_node *ring_node_to_send )
1109 {
1110 int status;
1111
1112 status = LFR_SUCCESSFUL;
1113 // status = rtems_message_queue_send( queue_id, ring_node_to_send, 4 );
1114
1115 return status;
1116 }
1117
1118 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
822 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
1119 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
823 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
1120 {
824 {
1121 unsigned long long int acquisitionTimeAsLong;
825 unsigned long long int acquisitionTimeAsLong;
1122 unsigned char localAcquisitionTime[6];
826 unsigned char localAcquisitionTime[6];
1123 double deltaT;
827 double deltaT;
1124
828
1125 deltaT = 0.;
829 deltaT = 0.;
1126
830
1127 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
831 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
1128 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
832 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
1129 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
833 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
1130 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
834 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
1131 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
835 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
1132 localAcquisitionTime[5] = (unsigned char) ( fineTime );
836 localAcquisitionTime[5] = (unsigned char) ( fineTime );
1133
837
1134 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
838 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
1135 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
839 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
1136 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
840 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
1137 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
841 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
1138 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
842 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
1139 + ( (unsigned long long int) localAcquisitionTime[5] );
843 + ( (unsigned long long int) localAcquisitionTime[5] );
1140
844
1141 switch( sid )
845 switch( sid )
1142 {
846 {
1143 case SID_NORM_SWF_F0:
847 case SID_NORM_SWF_F0:
1144 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
848 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
1145 break;
849 break;
1146
850
1147 case SID_NORM_SWF_F1:
851 case SID_NORM_SWF_F1:
1148 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
852 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
1149 break;
853 break;
1150
854
1151 case SID_NORM_SWF_F2:
855 case SID_NORM_SWF_F2:
1152 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
856 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
1153 break;
857 break;
1154
858
1155 case SID_SBM1_CWF_F1:
859 case SID_SBM1_CWF_F1:
1156 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
860 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
1157 break;
861 break;
1158
862
1159 case SID_SBM2_CWF_F2:
863 case SID_SBM2_CWF_F2:
1160 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
864 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
1161 break;
865 break;
1162
866
1163 case SID_BURST_CWF_F2:
867 case SID_BURST_CWF_F2:
1164 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
868 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
1165 break;
869 break;
1166
870
1167 case SID_NORM_CWF_F3:
871 case SID_NORM_CWF_F3:
1168 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
872 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
1169 break;
873 break;
1170
874
1171 case SID_NORM_CWF_LONG_F3:
875 case SID_NORM_CWF_LONG_F3:
1172 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
876 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
1173 break;
877 break;
1174
878
1175 default:
879 default:
1176 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d", sid)
880 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid)
1177 deltaT = 0.;
881 deltaT = 0.;
1178 break;
882 break;
1179 }
883 }
1180
884
1181 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
885 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
1182 //
886 //
1183 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
887 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
1184 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
888 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
1185 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
889 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
1186 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
890 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
1187 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
891 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
1188 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
892 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
1189
893
1190 }
894 }
1191
895
1192 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
896 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
1193 {
897 {
1194 unsigned int i;
898 unsigned int i;
1195 unsigned long long int centerTime_asLong;
899 unsigned long long int centerTime_asLong;
1196 unsigned long long int acquisitionTimeF0_asLong;
900 unsigned long long int acquisitionTimeF0_asLong;
1197 unsigned long long int acquisitionTime_asLong;
901 unsigned long long int acquisitionTime_asLong;
1198 unsigned long long int bufferAcquisitionTime_asLong;
902 unsigned long long int bufferAcquisitionTime_asLong;
1199 unsigned char *ptr1;
903 unsigned char *ptr1;
1200 unsigned char *ptr2;
904 unsigned char *ptr2;
1201 unsigned char *timeCharPtr;
905 unsigned char *timeCharPtr;
1202 unsigned char nb_ring_nodes;
906 unsigned char nb_ring_nodes;
1203 unsigned long long int frequency_asLong;
907 unsigned long long int frequency_asLong;
1204 unsigned long long int nbTicksPerSample_asLong;
908 unsigned long long int nbTicksPerSample_asLong;
1205 unsigned long long int nbSamplesPart1_asLong;
909 unsigned long long int nbSamplesPart1_asLong;
1206 unsigned long long int sampleOffset_asLong;
910 unsigned long long int sampleOffset_asLong;
1207
911
1208 unsigned int deltaT_F0;
912 unsigned int deltaT_F0;
1209 unsigned int deltaT_F1;
913 unsigned int deltaT_F1;
1210 unsigned long long int deltaT_F2;
914 unsigned long long int deltaT_F2;
1211
915
1212 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
916 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1213 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
917 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1214 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
918 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1215 sampleOffset_asLong = 0x00;
919 sampleOffset_asLong = 0x00;
1216
920
1217 // (1) get the f0 acquisition time
921 // (1) get the f0 acquisition time
1218 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
922 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
1219
923
1220 // (2) compute the central reference time
924 // (2) compute the central reference time
1221 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
925 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1222
926
1223 // (3) compute the acquisition time of the current snapshot
927 // (3) compute the acquisition time of the current snapshot
1224 switch(frequencyChannel)
928 switch(frequencyChannel)
1225 {
929 {
1226 case 1: // 1 is for F1 = 4096 Hz
930 case 1: // 1 is for F1 = 4096 Hz
1227 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
931 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1228 nb_ring_nodes = NB_RING_NODES_F1;
932 nb_ring_nodes = NB_RING_NODES_F1;
1229 frequency_asLong = 4096;
933 frequency_asLong = 4096;
1230 nbTicksPerSample_asLong = 16; // 65536 / 4096;
934 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1231 break;
935 break;
1232 case 2: // 2 is for F2 = 256 Hz
936 case 2: // 2 is for F2 = 256 Hz
1233 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
937 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1234 nb_ring_nodes = NB_RING_NODES_F2;
938 nb_ring_nodes = NB_RING_NODES_F2;
1235 frequency_asLong = 256;
939 frequency_asLong = 256;
1236 nbTicksPerSample_asLong = 256; // 65536 / 256;
940 nbTicksPerSample_asLong = 256; // 65536 / 256;
1237 break;
941 break;
1238 default:
942 default:
1239 acquisitionTime_asLong = centerTime_asLong;
943 acquisitionTime_asLong = centerTime_asLong;
1240 frequency_asLong = 256;
944 frequency_asLong = 256;
1241 nbTicksPerSample_asLong = 256;
945 nbTicksPerSample_asLong = 256;
1242 break;
946 break;
1243 }
947 }
1244
948
1245 //****************************************************************************
949 //****************************************************************************
1246 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
950 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
1247 for (i=0; i<nb_ring_nodes; i++)
951 for (i=0; i<nb_ring_nodes; i++)
1248 {
952 {
1249 PRINTF1("%d ... ", i)
953 PRINTF1("%d ... ", i)
1250 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) ring_node_to_send->coarseTime );
954 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) ring_node_to_send->coarseTime );
1251 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
955 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1252 {
956 {
1253 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
957 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1254 break;
958 break;
1255 }
959 }
1256 ring_node_to_send = ring_node_to_send->previous;
960 ring_node_to_send = ring_node_to_send->previous;
1257 }
961 }
1258
962
1259 // (5) compute the number of samples to take in the current buffer
963 // (5) compute the number of samples to take in the current buffer
1260 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
964 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1261 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
965 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1262 PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong)
966 PRINTF2("sampleOffset_asLong = %llx, nbSamplesPart1_asLong = %llx\n", sampleOffset_asLong, nbSamplesPart1_asLong)
1263
967
1264 // (6) compute the final acquisition time
968 // (6) compute the final acquisition time
1265 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
969 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1266 sampleOffset_asLong * nbTicksPerSample_asLong;
970 sampleOffset_asLong * nbTicksPerSample_asLong;
1267
971
1268 // (7) copy the acquisition time at the beginning of the extrated snapshot
972 // (7) copy the acquisition time at the beginning of the extrated snapshot
1269 ptr1 = (unsigned char*) &acquisitionTime_asLong;
973 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1270 // fine time
974 // fine time
1271 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime;
975 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime;
1272 ptr2[2] = ptr1[ 4 + 2 ];
976 ptr2[2] = ptr1[ 4 + 2 ];
1273 ptr2[3] = ptr1[ 5 + 2 ];
977 ptr2[3] = ptr1[ 5 + 2 ];
1274 // coarse time
978 // coarse time
1275 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime;
979 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime;
1276 ptr2[0] = ptr1[ 0 + 2 ];
980 ptr2[0] = ptr1[ 0 + 2 ];
1277 ptr2[1] = ptr1[ 1 + 2 ];
981 ptr2[1] = ptr1[ 1 + 2 ];
1278 ptr2[2] = ptr1[ 2 + 2 ];
982 ptr2[2] = ptr1[ 2 + 2 ];
1279 ptr2[3] = ptr1[ 3 + 2 ];
983 ptr2[3] = ptr1[ 3 + 2 ];
1280
984
1281 // re set the synchronization bit
985 // re set the synchronization bit
1282 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
986 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
1283 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
987 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
1284
988
1285 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
989 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
1286 {
990 {
1287 nbSamplesPart1_asLong = 0;
991 nbSamplesPart1_asLong = 0;
1288 }
992 }
1289 // copy the part 1 of the snapshot in the extracted buffer
993 // copy the part 1 of the snapshot in the extracted buffer
1290 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
994 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1291 {
995 {
1292 wf_snap_extracted[i] =
996 wf_snap_extracted[i] =
1293 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
997 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
1294 }
998 }
1295 // copy the part 2 of the snapshot in the extracted buffer
999 // copy the part 2 of the snapshot in the extracted buffer
1296 ring_node_to_send = ring_node_to_send->next;
1000 ring_node_to_send = ring_node_to_send->next;
1297 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1001 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1298 {
1002 {
1299 wf_snap_extracted[i] =
1003 wf_snap_extracted[i] =
1300 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
1004 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
1301 }
1005 }
1302 }
1006 }
1303
1007
1304 void snapshot_resynchronization( unsigned char *timePtr )
1008 void snapshot_resynchronization( unsigned char *timePtr )
1305 {
1009 {
1306 unsigned long long int acquisitionTime;
1010 unsigned long long int acquisitionTime;
1307 unsigned long long int centerTime;
1011 unsigned long long int centerTime;
1308 unsigned long long int previousTick;
1012 unsigned long long int previousTick;
1309 unsigned long long int nextTick;
1013 unsigned long long int nextTick;
1310 unsigned long long int deltaPreviousTick;
1014 unsigned long long int deltaPreviousTick;
1311 unsigned long long int deltaNextTick;
1015 unsigned long long int deltaNextTick;
1312 unsigned int deltaTickInF2;
1016 unsigned int deltaTickInF2;
1313 double deltaPrevious;
1017 double deltaPrevious;
1314 double deltaNext;
1018 double deltaNext;
1315
1019
1316 acquisitionTime = get_acquisition_time( timePtr );
1020 acquisitionTime = get_acquisition_time( timePtr );
1317
1021
1318 // compute center time
1022 // compute center time
1319 centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1023 centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1320 previousTick = centerTime - (centerTime & 0xffff);
1024 previousTick = centerTime - (centerTime & 0xffff);
1321 nextTick = previousTick + 65536;
1025 nextTick = previousTick + 65536;
1322
1026
1323 deltaPreviousTick = centerTime - previousTick;
1027 deltaPreviousTick = centerTime - previousTick;
1324 deltaNextTick = nextTick - centerTime;
1028 deltaNextTick = nextTick - centerTime;
1325
1029
1326 deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.;
1030 deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.;
1327 deltaNext = ((double) deltaNextTick) / 65536. * 1000.;
1031 deltaNext = ((double) deltaNextTick) / 65536. * 1000.;
1328
1032
1329 printf("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext);
1033 printf("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext);
1330 printf("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick);
1034 printf("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick);
1331
1035
1332 // which tick is the closest
1036 // which tick is the closest
1333 if (deltaPreviousTick > deltaNextTick)
1037 if (deltaPreviousTick > deltaNextTick)
1334 {
1038 {
1335 deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here
1039 deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here
1336 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
1040 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
1337 printf("correction of = + %u\n", deltaTickInF2);
1041 printf("correction of = + %u\n", deltaTickInF2);
1338 }
1042 }
1339 else
1043 else
1340 {
1044 {
1341 deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here
1045 deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here
1342 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2;
1046 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2;
1343 printf("correction of = - %u\n", deltaTickInF2);
1047 printf("correction of = - %u\n", deltaTickInF2);
1344 }
1048 }
1345 }
1049 }
1346
1050
1347 //**************
1051 //**************
1348 // wfp registers
1052 // wfp registers
1349 void reset_wfp_burst_enable( void )
1053 void reset_wfp_burst_enable( void )
1350 {
1054 {
1351 /** This function resets the waveform picker burst_enable register.
1055 /** This function resets the waveform picker burst_enable register.
1352 *
1056 *
1353 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1057 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1354 *
1058 *
1355 */
1059 */
1356
1060
1357 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1061 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1358 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80;
1062 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80;
1359 }
1063 }
1360
1064
1361 void reset_wfp_status( void )
1065 void reset_wfp_status( void )
1362 {
1066 {
1363 /** This function resets the waveform picker status register.
1067 /** This function resets the waveform picker status register.
1364 *
1068 *
1365 * All status bits are set to 0 [new_err full_err full].
1069 * All status bits are set to 0 [new_err full_err full].
1366 *
1070 *
1367 */
1071 */
1368
1072
1369 waveform_picker_regs->status = 0xffff;
1073 waveform_picker_regs->status = 0xffff;
1370 }
1074 }
1371
1075
1372 void reset_wfp_buffer_addresses( void )
1076 void reset_wfp_buffer_addresses( void )
1373 {
1077 {
1374 // F0
1078 // F0
1375 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; // 0x08
1079 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; // 0x08
1376 current_ring_node_f0 = current_ring_node_f0->next;
1080 current_ring_node_f0 = current_ring_node_f0->next;
1377 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1081 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1378 // F1
1082 // F1
1379 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; // 0x10
1083 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; // 0x10
1380 current_ring_node_f1 = current_ring_node_f1->next;
1084 current_ring_node_f1 = current_ring_node_f1->next;
1381 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1085 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1382 // F2
1086 // F2
1383 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; // 0x18
1087 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; // 0x18
1384 current_ring_node_f2 = current_ring_node_f2->next;
1088 current_ring_node_f2 = current_ring_node_f2->next;
1385 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1089 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1386 // F3
1090 // F3
1387 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; // 0x20
1091 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; // 0x20
1388 current_ring_node_f3 = current_ring_node_f3->next;
1092 current_ring_node_f3 = current_ring_node_f3->next;
1389 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1093 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1390 }
1094 }
1391
1095
1392 void reset_waveform_picker_regs( void )
1096 void reset_waveform_picker_regs( void )
1393 {
1097 {
1394 /** This function resets the waveform picker module registers.
1098 /** This function resets the waveform picker module registers.
1395 *
1099 *
1396 * The registers affected by this function are located at the following offset addresses:
1100 * The registers affected by this function are located at the following offset addresses:
1397 * - 0x00 data_shaping
1101 * - 0x00 data_shaping
1398 * - 0x04 run_burst_enable
1102 * - 0x04 run_burst_enable
1399 * - 0x08 addr_data_f0
1103 * - 0x08 addr_data_f0
1400 * - 0x0C addr_data_f1
1104 * - 0x0C addr_data_f1
1401 * - 0x10 addr_data_f2
1105 * - 0x10 addr_data_f2
1402 * - 0x14 addr_data_f3
1106 * - 0x14 addr_data_f3
1403 * - 0x18 status
1107 * - 0x18 status
1404 * - 0x1C delta_snapshot
1108 * - 0x1C delta_snapshot
1405 * - 0x20 delta_f0
1109 * - 0x20 delta_f0
1406 * - 0x24 delta_f0_2
1110 * - 0x24 delta_f0_2
1407 * - 0x28 delta_f1
1111 * - 0x28 delta_f1
1408 * - 0x2c delta_f2
1112 * - 0x2c delta_f2
1409 * - 0x30 nb_data_by_buffer
1113 * - 0x30 nb_data_by_buffer
1410 * - 0x34 nb_snapshot_param
1114 * - 0x34 nb_snapshot_param
1411 * - 0x38 start_date
1115 * - 0x38 start_date
1412 * - 0x3c nb_word_in_buffer
1116 * - 0x3c nb_word_in_buffer
1413 *
1117 *
1414 */
1118 */
1415
1119
1416 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1120 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1417
1121
1418 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1122 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1419
1123
1420 reset_wfp_buffer_addresses();
1124 reset_wfp_buffer_addresses();
1421
1125
1422 reset_wfp_status(); // 0x18
1126 reset_wfp_status(); // 0x18
1423
1127
1424 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
1128 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
1425
1129
1426 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1130 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1427
1131
1428 set_wfp_delta_f1(); // 0x28
1132 set_wfp_delta_f1(); // 0x28
1429
1133
1430 set_wfp_delta_f2(); // 0x2c
1134 set_wfp_delta_f2(); // 0x2c
1431
1135
1432 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1136 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1433 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1137 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1434 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1138 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1435 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1139 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1436 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1140 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1437 // 2688 = 8 * 336
1141 // 2688 = 8 * 336
1438 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1142 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1439 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1143 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1440 waveform_picker_regs->start_date = 0x7fffffff; // 0x38
1144 waveform_picker_regs->start_date = 0x7fffffff; // 0x38
1441 //
1145 //
1442 // coarse time and fine time registers are not initialized, they are volatile
1146 // coarse time and fine time registers are not initialized, they are volatile
1443 //
1147 //
1444 waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1148 waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1445 }
1149 }
1446
1150
1447 void set_wfp_data_shaping( void )
1151 void set_wfp_data_shaping( void )
1448 {
1152 {
1449 /** This function sets the data_shaping register of the waveform picker module.
1153 /** This function sets the data_shaping register of the waveform picker module.
1450 *
1154 *
1451 * The value is read from one field of the parameter_dump_packet structure:\n
1155 * The value is read from one field of the parameter_dump_packet structure:\n
1452 * bw_sp0_sp1_r0_r1
1156 * bw_sp0_sp1_r0_r1
1453 *
1157 *
1454 */
1158 */
1455
1159
1456 unsigned char data_shaping;
1160 unsigned char data_shaping;
1457
1161
1458 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1162 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1459 // waveform picker : [R1 R0 SP1 SP0 BW]
1163 // waveform picker : [R1 R0 SP1 SP0 BW]
1460
1164
1461 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1165 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
1462
1166
1463 waveform_picker_regs->data_shaping =
1167 waveform_picker_regs->data_shaping =
1464 ( (data_shaping & 0x10) >> 4 ) // BW
1168 ( (data_shaping & 0x10) >> 4 ) // BW
1465 + ( (data_shaping & 0x08) >> 2 ) // SP0
1169 + ( (data_shaping & 0x08) >> 2 ) // SP0
1466 + ( (data_shaping & 0x04) ) // SP1
1170 + ( (data_shaping & 0x04) ) // SP1
1467 + ( (data_shaping & 0x02) << 2 ) // R0
1171 + ( (data_shaping & 0x02) << 2 ) // R0
1468 + ( (data_shaping & 0x01) << 4 ); // R1
1172 + ( (data_shaping & 0x01) << 4 ); // R1
1469 }
1173 }
1470
1174
1471 void set_wfp_burst_enable_register( unsigned char mode )
1175 void set_wfp_burst_enable_register( unsigned char mode )
1472 {
1176 {
1473 /** This function sets the waveform picker burst_enable register depending on the mode.
1177 /** This function sets the waveform picker burst_enable register depending on the mode.
1474 *
1178 *
1475 * @param mode is the LFR mode to launch.
1179 * @param mode is the LFR mode to launch.
1476 *
1180 *
1477 * The burst bits shall be before the enable bits.
1181 * The burst bits shall be before the enable bits.
1478 *
1182 *
1479 */
1183 */
1480
1184
1481 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1185 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1482 // the burst bits shall be set first, before the enable bits
1186 // the burst bits shall be set first, before the enable bits
1483 switch(mode) {
1187 switch(mode) {
1484 case(LFR_MODE_NORMAL):
1188 case(LFR_MODE_NORMAL):
1485 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1189 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1486 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1190 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1487 break;
1191 break;
1488 case(LFR_MODE_BURST):
1192 case(LFR_MODE_BURST):
1489 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1193 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1490 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1194 // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1491 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1195 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1492 break;
1196 break;
1493 case(LFR_MODE_SBM1):
1197 case(LFR_MODE_SBM1):
1494 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1198 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1495 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1199 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1496 break;
1200 break;
1497 case(LFR_MODE_SBM2):
1201 case(LFR_MODE_SBM2):
1498 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1202 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1499 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1203 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1500 break;
1204 break;
1501 default:
1205 default:
1502 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1206 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1503 break;
1207 break;
1504 }
1208 }
1505 }
1209 }
1506
1210
1507 void set_wfp_delta_snapshot( void )
1211 void set_wfp_delta_snapshot( void )
1508 {
1212 {
1509 /** This function sets the delta_snapshot register of the waveform picker module.
1213 /** This function sets the delta_snapshot register of the waveform picker module.
1510 *
1214 *
1511 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1215 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1512 * - sy_lfr_n_swf_p[0]
1216 * - sy_lfr_n_swf_p[0]
1513 * - sy_lfr_n_swf_p[1]
1217 * - sy_lfr_n_swf_p[1]
1514 *
1218 *
1515 */
1219 */
1516
1220
1517 unsigned int delta_snapshot;
1221 unsigned int delta_snapshot;
1518 unsigned int delta_snapshot_in_T2;
1222 unsigned int delta_snapshot_in_T2;
1519
1223
1520 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1224 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1521 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1225 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1522
1226
1523 delta_snapshot_in_T2 = delta_snapshot * 256;
1227 delta_snapshot_in_T2 = delta_snapshot * 256;
1524 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1228 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1525 }
1229 }
1526
1230
1527 void set_wfp_delta_f0_f0_2( void )
1231 void set_wfp_delta_f0_f0_2( void )
1528 {
1232 {
1529 unsigned int delta_snapshot;
1233 unsigned int delta_snapshot;
1530 unsigned int nb_samples_per_snapshot;
1234 unsigned int nb_samples_per_snapshot;
1531 float delta_f0_in_float;
1235 float delta_f0_in_float;
1532
1236
1533 delta_snapshot = waveform_picker_regs->delta_snapshot;
1237 delta_snapshot = waveform_picker_regs->delta_snapshot;
1534 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1238 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1535 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1239 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1536
1240
1537 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1241 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1538 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1242 waveform_picker_regs->delta_f0_2 = 0x7; // max 7 bits
1539 }
1243 }
1540
1244
1541 void set_wfp_delta_f1( void )
1245 void set_wfp_delta_f1( void )
1542 {
1246 {
1543 unsigned int delta_snapshot;
1247 unsigned int delta_snapshot;
1544 unsigned int nb_samples_per_snapshot;
1248 unsigned int nb_samples_per_snapshot;
1545 float delta_f1_in_float;
1249 float delta_f1_in_float;
1546
1250
1547 delta_snapshot = waveform_picker_regs->delta_snapshot;
1251 delta_snapshot = waveform_picker_regs->delta_snapshot;
1548 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1252 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1549 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1253 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1550
1254
1551 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1255 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1552 }
1256 }
1553
1257
1554 void set_wfp_delta_f2()
1258 void set_wfp_delta_f2()
1555 {
1259 {
1556 unsigned int delta_snapshot;
1260 unsigned int delta_snapshot;
1557 unsigned int nb_samples_per_snapshot;
1261 unsigned int nb_samples_per_snapshot;
1558
1262
1559 delta_snapshot = waveform_picker_regs->delta_snapshot;
1263 delta_snapshot = waveform_picker_regs->delta_snapshot;
1560 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1264 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1561
1265
1562 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1266 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1563 }
1267 }
1564
1268
1565 //*****************
1269 //*****************
1566 // local parameters
1270 // local parameters
1567
1271
1568 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1272 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1569 {
1273 {
1570 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1274 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1571 *
1275 *
1572 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1276 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1573 * @param sid is the source identifier of the packet being updated.
1277 * @param sid is the source identifier of the packet being updated.
1574 *
1278 *
1575 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1279 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1576 * The sequence counters shall wrap around from 2^14 to zero.
1280 * The sequence counters shall wrap around from 2^14 to zero.
1577 * The sequence counter shall start at zero at startup.
1281 * The sequence counter shall start at zero at startup.
1578 *
1282 *
1579 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1283 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1580 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1284 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1581 *
1285 *
1582 */
1286 */
1583
1287
1584 unsigned short *sequence_cnt;
1288 unsigned short *sequence_cnt;
1585 unsigned short segmentation_grouping_flag;
1289 unsigned short segmentation_grouping_flag;
1586 unsigned short new_packet_sequence_control;
1290 unsigned short new_packet_sequence_control;
1587 rtems_mode initial_mode_set;
1291 rtems_mode initial_mode_set;
1588 rtems_mode current_mode_set;
1292 rtems_mode current_mode_set;
1589 rtems_status_code status;
1293 rtems_status_code status;
1590
1294
1591 //******************************************
1295 //******************************************
1592 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1296 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1593 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1297 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1594
1298
1595 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1299 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1596 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1300 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1597 || (sid == SID_BURST_CWF_F2)
1301 || (sid == SID_BURST_CWF_F2)
1598 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1302 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1599 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1303 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1600 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1304 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1601 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1305 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1602 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1306 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1603 {
1307 {
1604 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1308 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1605 }
1309 }
1606 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1310 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1607 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1311 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1608 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1312 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1609 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1313 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1610 {
1314 {
1611 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1315 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1612 }
1316 }
1613 else
1317 else
1614 {
1318 {
1615 sequence_cnt = (unsigned short *) NULL;
1319 sequence_cnt = (unsigned short *) NULL;
1616 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1320 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1617 }
1321 }
1618
1322
1619 if (sequence_cnt != NULL)
1323 if (sequence_cnt != NULL)
1620 {
1324 {
1621 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1325 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1622 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1326 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1623
1327
1624 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1328 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1625
1329
1626 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1330 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1627 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1331 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1628
1332
1629 // increment the sequence counter
1333 // increment the sequence counter
1630 if ( *sequence_cnt < SEQ_CNT_MAX)
1334 if ( *sequence_cnt < SEQ_CNT_MAX)
1631 {
1335 {
1632 *sequence_cnt = *sequence_cnt + 1;
1336 *sequence_cnt = *sequence_cnt + 1;
1633 }
1337 }
1634 else
1338 else
1635 {
1339 {
1636 *sequence_cnt = 0;
1340 *sequence_cnt = 0;
1637 }
1341 }
1638 }
1342 }
1639
1343
1640 //***********************************
1344 //***********************************
1641 // RESET THE MODE OF THE CALLING TASK
1345 // RESET THE MODE OF THE CALLING TASK
1642 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1346 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1643 }
1347 }
General Comments 0
You need to be logged in to leave comments. Login now