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