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