##// END OF EJS Templates
Bug 117
paul -
r149:60ce8c978d3f VHDLib206
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 Jun 13 07:44:08 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Jun 16 09:16:01 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=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=9 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=10 -DPRINT_MESSAGES_ON_CONSOLE
14 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 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,95 +1,95
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 CONFIG += console verbose
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-1-0
11 11 DEFINES += SW_VERSION_N1=1 # major
12 12 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=9 # internal
14 DEFINES += SW_VERSION_N4=10 # internal
15 15
16 16 contains( CONFIG, debug_tch ) {
17 17 DEFINES += DEBUG_TCH
18 18 }
19 19
20 20 contains( CONFIG, vhdl_dev ) {
21 21 DEFINES += VHDL_DEV
22 22 }
23 23
24 24 contains( CONFIG, verbose ) {
25 25 DEFINES += PRINT_MESSAGES_ON_CONSOLE
26 26 }
27 27
28 28 contains( CONFIG, debug_messages ) {
29 29 DEFINES += DEBUG_MESSAGES
30 30 }
31 31
32 32 contains( CONFIG, cpu_usage_report ) {
33 33 DEFINES += PRINT_TASK_STATISTICS
34 34 }
35 35
36 36 contains( CONFIG, stack_report ) {
37 37 DEFINES += PRINT_STACK_REPORT
38 38 }
39 39
40 40 contains( CONFIG, boot_messages ) {
41 41 DEFINES += BOOT_MESSAGES
42 42 }
43 43
44 44 #doxygen.target = doxygen
45 45 #doxygen.commands = doxygen ../doc/Doxyfile
46 46 #QMAKE_EXTRA_TARGETS += doxygen
47 47
48 48 TARGET = fsw
49 49
50 50 INCLUDEPATH += \
51 51 ../src \
52 52 ../header \
53 53 ../header/processing \
54 54 ../src/LFR_basic-parameters
55 55
56 56 SOURCES += \
57 57 ../src/wf_handler.c \
58 58 ../src/tc_handler.c \
59 59 ../src/fsw_misc.c \
60 60 ../src/fsw_init.c \
61 61 ../src/fsw_globals.c \
62 62 ../src/fsw_spacewire.c \
63 63 ../src/tc_load_dump_parameters.c \
64 64 ../src/tm_lfr_tc_exe.c \
65 65 ../src/tc_acceptance.c \
66 66 ../src/processing/fsw_processing.c \
67 67 ../src/processing/avf0_prc0.c \
68 68 ../src/processing/avf1_prc1.c \
69 69 ../src/processing/avf2_prc2.c \
70 70 ../src/lfr_cpu_usage_report.c \
71 71 ../src/LFR_basic-parameters/basic_parameters.c
72 72
73 73 HEADERS += \
74 74 ../header/wf_handler.h \
75 75 ../header/tc_handler.h \
76 76 ../header/grlib_regs.h \
77 77 ../header/fsw_params.h \
78 78 ../header/fsw_misc.h \
79 79 ../header/fsw_init.h \
80 80 ../header/ccsds_types.h \
81 81 ../header/fsw_spacewire.h \
82 82 ../header/tc_load_dump_parameters.h \
83 83 ../header/tm_lfr_tc_exe.h \
84 84 ../header/tc_acceptance.h \
85 85 ../header/fsw_params_nb_bytes.h \
86 86 ../header/fsw_params_processing.h \
87 87 ../header/processing/fsw_processing.h \
88 88 ../header/processing/avf0_prc0.h \
89 89 ../header/processing/avf1_prc1.h \
90 90 ../header/processing/avf2_prc2.h \
91 91 ../header/fsw_params_wf_handler.h \
92 92 ../header/lfr_cpu_usage_report.h \
93 93 ../src/LFR_basic-parameters/basic_parameters.h \
94 94 ../src/LFR_basic-parameters/basic_parameters_params.h
95 95
@@ -1,201 +1,201
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-06-13T09:37:55. -->
3 <!-- Written by QtCreator 3.0.1, 2014-06-16T07:35:26. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
118 118 </valuemap>
119 119 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
126 126 </valuemap>
127 127 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
128 128 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
131 131 </valuemap>
132 132 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
135 135 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
136 136 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
137 137 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
138 138 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
139 139 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
140 140 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
141 141 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
142 142 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
143 143 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
144 144 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
145 145 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
146 146 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
147 147 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
148 148 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
149 149 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
150 150 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
151 151 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
152 152 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
153 153 <value type="int">0</value>
154 154 <value type="int">1</value>
155 155 <value type="int">2</value>
156 156 <value type="int">3</value>
157 157 <value type="int">4</value>
158 158 <value type="int">5</value>
159 159 <value type="int">6</value>
160 160 <value type="int">7</value>
161 161 <value type="int">8</value>
162 162 <value type="int">9</value>
163 163 <value type="int">10</value>
164 164 <value type="int">11</value>
165 165 <value type="int">12</value>
166 166 <value type="int">13</value>
167 167 <value type="int">14</value>
168 168 </valuelist>
169 169 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
170 170 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
174 174 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
177 177 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
178 178 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
179 179 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
180 180 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
181 181 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
182 182 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
183 183 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
184 184 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
187 187 </valuemap>
188 188 </data>
189 189 <data>
190 190 <variable>ProjectExplorer.Project.TargetCount</variable>
191 191 <value type="int">1</value>
192 192 </data>
193 193 <data>
194 194 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
195 195 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
196 196 </data>
197 197 <data>
198 198 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
199 199 <value type="int">15</value>
200 200 </data>
201 201 </qtcreator>
@@ -1,48 +1,49
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 //extern rtems_name misc_name[5];
16 16 //time_management_regs_t *time_management_regs;
17 17 //extern Packet_TM_LFR_HK_t housekeeping_packet;
18 18
19 19 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
20 20 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
21 21 void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 22 void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
23 23 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
24 24
25 25 // SERIAL LINK
26 26 int send_console_outputs_on_apbuart_port( void );
27 27 int enable_apbuart_transmitter( void );
28 28 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
29 29
30 30 // RTEMS TASKS
31 31 rtems_task stat_task( rtems_task_argument argument );
32 32 rtems_task hous_task( rtems_task_argument argument );
33 33 rtems_task dumb_task( rtems_task_argument unused );
34 34
35 35 void init_housekeeping_parameters( void );
36 void increment_seq_counter( unsigned char *packet_sequence_control);
36 void increment_seq_counter(unsigned short *packetSequenceControl);
37 37 void getTime( unsigned char *time);
38 38 unsigned long long int getTimeAsUnsignedLongLongInt( );
39 39 void send_dumb_hk( void );
40 40 void get_v_e1_e2_f3 (unsigned char *spacecraft_potential);
41 41 void get_cpu_load( unsigned char *resource_statistics );
42 42
43 43 extern int sched_yield( void );
44 44 extern int rtems_cpu_usage_reset();
45 45 extern ring_node *current_ring_node_f3;
46 46 extern ring_node *ring_node_to_send_cwf_f3;
47 extern unsigned short sequenceCounterHK;
47 48
48 49 #endif // FSW_MISC_H_INCLUDED
@@ -1,251 +1,255
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 16 int buffer_address;
17 17 struct ring_node *next;
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 21 //************************
22 22 // flight software version
23 23 // this parameters is handled by the Qt project options
24 24
25 25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 28 #define TIME_OFFSET 2
29 29 #define TIME_OFFSET_IN_BYTES 8
30 30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 31 #define NB_BYTES_SWF_BLK (2 * 6)
32 32 #define NB_WORDS_SWF_BLK 3
33 33 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 38 #define NB_RING_NODES_F3 3 // AT LEAST 3
39 39
40 40 //**********
41 41 // LFR MODES
42 42 #define LFR_MODE_STANDBY 0
43 43 #define LFR_MODE_NORMAL 1
44 44 #define LFR_MODE_BURST 2
45 45 #define LFR_MODE_SBM1 3
46 46 #define LFR_MODE_SBM2 4
47 47
48 48 #define TDS_MODE_LFM 5
49 49 #define TDS_MODE_STANDBY 0
50 50 #define TDS_MODE_NORMAL 1
51 51 #define TDS_MODE_BURST 2
52 52 #define TDS_MODE_SBM1 3
53 53 #define TDS_MODE_SBM2 4
54 54
55 55 #define THR_MODE_STANDBY 0
56 56 #define THR_MODE_NORMAL 1
57 57 #define THR_MODE_BURST 2
58 58
59 59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
60 60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
61 61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
62 62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
63 63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
64 64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
65 65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
66 66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
67 67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
68 68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
69 69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
70 70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
71 71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
72 72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
73 73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
74 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
75 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
76 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
77 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
74 #define RTEMS_EVENT_SBM_BP1_F0 RTEMS_EVENT_15
75 #define RTEMS_EVENT_SBM_BP2_F0 RTEMS_EVENT_16
76 #define RTEMS_EVENT_SBM_BP1_F1 RTEMS_EVENT_17
77 #define RTEMS_EVENT_SBM_BP2_F1 RTEMS_EVENT_18
78 #define RTEMS_EVENT_BURST_BP1_F0 RTEMS_EVENT_19
79 #define RTEMS_EVENT_BURST_BP2_F0 RTEMS_EVENT_20
80 #define RTEMS_EVENT_BURST_BP1_F1 RTEMS_EVENT_21
81 #define RTEMS_EVENT_BURST_BP2_F1 RTEMS_EVENT_22
78 82
79 83 //****************************
80 84 // LFR DEFAULT MODE PARAMETERS
81 85 // COMMON
82 86 #define DEFAULT_SY_LFR_COMMON0 0x00
83 87 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
84 88 // NORM
85 89 #define SY_LFR_N_SWF_L 2048 // nb sample
86 90 #define SY_LFR_N_SWF_P 300 // sec
87 91 #define SY_LFR_N_ASM_P 3600 // sec
88 92 #define SY_LFR_N_BP_P0 4 // sec
89 93 #define SY_LFR_N_BP_P1 20 // sec
90 94 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
91 95 #define MIN_DELTA_SNAPSHOT 16 // sec
92 96 // BURST
93 97 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
94 98 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
95 99 // SBM1
96 100 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
97 101 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
98 102 // SBM2
99 103 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
100 104 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
101 105 // ADDITIONAL PARAMETERS
102 106 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
103 107 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
104 108 // STATUS WORD
105 109 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
106 110 #define DEFAULT_STATUS_WORD_BYTE1 0x00
107 111 //
108 112 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
109 113 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
110 114 //****************************
111 115
112 116 //*****************************
113 117 // APB REGISTERS BASE ADDRESSES
114 118 #define REGS_ADDR_APBUART 0x80000100
115 119 #define REGS_ADDR_GPTIMER 0x80000300
116 120 #define REGS_ADDR_GRSPW 0x80000500
117 121 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
118 122 #define REGS_ADDR_GRGPIO 0x80000b00
119 123
120 124 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
121 125 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
122 126 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
123 127
124 128 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
125 129 #define APBUART_CTRL_REG_MASK_TE 0x00000002
126 130 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
127 131
128 132 //**********
129 133 // IRQ LINES
130 134 #define IRQ_SM_SIMULATOR 9
131 135 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
132 136 #define IRQ_WAVEFORM_PICKER 14
133 137 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
134 138 #define IRQ_SPECTRAL_MATRIX 6
135 139 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
136 140
137 141 //*****
138 142 // TIME
139 143 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
140 144 #define TIMER_SM_SIMULATOR 1
141 145 #define HK_PERIOD 100 // 100 * 10ms => 1s
142 146 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
143 147 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
144 148
145 149 //**********
146 150 // LPP CODES
147 151 #define LFR_SUCCESSFUL 0
148 152 #define LFR_DEFAULT 1
149 153 #define LFR_EXE_ERROR 2
150 154
151 155 //******
152 156 // RTEMS
153 157 #define TASKID_RECV 1
154 158 #define TASKID_ACTN 2
155 159 #define TASKID_SPIQ 3
156 160 #define TASKID_STAT 4
157 161 #define TASKID_AVF0 5
158 162 #define TASKID_SWBD 6
159 163 #define TASKID_WFRM 7
160 164 #define TASKID_DUMB 8
161 165 #define TASKID_HOUS 9
162 166 #define TASKID_PRC0 10
163 167 #define TASKID_CWF3 11
164 168 #define TASKID_CWF2 12
165 169 #define TASKID_CWF1 13
166 170 #define TASKID_SEND 14
167 171 #define TASKID_WTDG 15
168 172 #define TASKID_AVF1 16
169 173 #define TASKID_PRC1 17
170 174 #define TASKID_AVF2 18
171 175 #define TASKID_PRC2 19
172 176
173 177 #define TASK_PRIORITY_SPIQ 5
174 178 #define TASK_PRIORITY_WTDG 20
175 179 #define TASK_PRIORITY_HOUS 30
176 180 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
177 181 #define TASK_PRIORITY_CWF2 35 //
178 182 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
179 183 #define TASK_PRIORITY_WFRM 40
180 184 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
181 185 #define TASK_PRIORITY_SEND 45
182 186 #define TASK_PRIORITY_RECV 50
183 187 #define TASK_PRIORITY_ACTN 50
184 188 #define TASK_PRIORITY_AVF0 60
185 189 #define TASK_PRIORITY_AVF1 70
186 190 #define TASK_PRIORITY_PRC0 100
187 191 #define TASK_PRIORITY_PRC1 100
188 192 #define TASK_PRIORITY_AVF2 110
189 193 #define TASK_PRIORITY_PRC2 110
190 194 #define TASK_PRIORITY_STAT 200
191 195 #define TASK_PRIORITY_DUMB 200
192 196
193 197 #define MSG_QUEUE_COUNT_RECV 10
194 198 #define MSG_QUEUE_COUNT_SEND 50
195 199 #define MSG_QUEUE_COUNT_PRC0 10
196 200 #define MSG_QUEUE_COUNT_PRC1 10
197 201 #define MSG_QUEUE_COUNT_PRC2 5
198 202 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
199 203 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
200 204 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
201 205 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
202 206 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
203 207
204 208 #define QUEUE_RECV 0
205 209 #define QUEUE_SEND 1
206 210 #define QUEUE_PRC0 2
207 211 #define QUEUE_PRC1 3
208 212 #define QUEUE_PRC2 4
209 213
210 214 //*******
211 215 // MACROS
212 216 #ifdef PRINT_MESSAGES_ON_CONSOLE
213 217 #define PRINTF(x) printf(x);
214 218 #define PRINTF1(x,y) printf(x,y);
215 219 #define PRINTF2(x,y,z) printf(x,y,z);
216 220 #else
217 221 #define PRINTF(x) ;
218 222 #define PRINTF1(x,y) ;
219 223 #define PRINTF2(x,y,z) ;
220 224 #endif
221 225
222 226 #ifdef BOOT_MESSAGES
223 227 #define BOOT_PRINTF(x) printf(x);
224 228 #define BOOT_PRINTF1(x,y) printf(x,y);
225 229 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
226 230 #else
227 231 #define BOOT_PRINTF(x) ;
228 232 #define BOOT_PRINTF1(x,y) ;
229 233 #define BOOT_PRINTF2(x,y,z) ;
230 234 #endif
231 235
232 236 #ifdef DEBUG_MESSAGES
233 237 #define DEBUG_PRINTF(x) printf(x);
234 238 #define DEBUG_PRINTF1(x,y) printf(x,y);
235 239 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
236 240 #else
237 241 #define DEBUG_PRINTF(x) ;
238 242 #define DEBUG_PRINTF1(x,y) ;
239 243 #define DEBUG_PRINTF2(x,y,z) ;
240 244 #endif
241 245
242 246 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
243 247
244 248 struct param_local_str{
245 249 unsigned int local_sbm1_nb_cwf_sent;
246 250 unsigned int local_sbm1_nb_cwf_max;
247 251 unsigned int local_sbm2_nb_cwf_sent;
248 252 unsigned int local_sbm2_nb_cwf_max;
249 253 };
250 254
251 255 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,242 +1,243
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 99 void reset_spectral_matrix_regs( void );
100 100 void set_time(unsigned char *time, unsigned char *timeInBuffer );
101 101 unsigned long long int get_acquisition_time( unsigned char *timePtr );
102 102 void close_matrix_actions(unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
103 103 ring_node_sm *node_for_averaging, ring_node_sm *ringNode);
104 unsigned char getSID( rtems_event_set event );
104 105
105 106 extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
106 107 extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
107 108
108 109 //***************************************
109 110 // DEFINITIONS OF STATIC INLINE FUNCTIONS
110 111 static inline void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
111 112 ring_node_sm *ring_node_tab[],
112 113 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 );
113 114 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
114 115 float divider );
115 116 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
116 117 float divider,
117 118 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart);
118 119 static inline void ASM_convert(volatile float *input_matrix, char *output_matrix);
119 120
120 121 void SM_average( float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
121 122 ring_node_sm *ring_node_tab[],
122 123 unsigned int nbAverageNormF0, unsigned int nbAverageSBM1F0 )
123 124 {
124 125 float sum;
125 126 unsigned int i;
126 127
127 128 for(i=0; i<TOTAL_SIZE_SM; i++)
128 129 {
129 130 sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]
130 131 + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ]
131 132 + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ]
132 133 + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ]
133 134 + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ]
134 135 + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ]
135 136 + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
136 137 + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
137 138
138 139 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
139 140 {
140 141 averaged_spec_mat_f0[ i ] = sum;
141 142 averaged_spec_mat_f1[ i ] = sum;
142 143 }
143 144 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
144 145 {
145 146 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
146 147 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
147 148 }
148 149 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
149 150 {
150 151 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
151 152 averaged_spec_mat_f1[ i ] = sum;
152 153 }
153 154 else
154 155 {
155 156 PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNormF0, nbAverageSBM1F0)
156 157 }
157 158 }
158 159 }
159 160
160 161 void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider )
161 162 {
162 163 int frequencyBin;
163 164 int asmComponent;
164 165 unsigned int offsetAveragedSpecMatReorganized;
165 166 unsigned int offsetAveragedSpecMat;
166 167
167 168 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
168 169 {
169 170 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
170 171 {
171 172 offsetAveragedSpecMatReorganized =
172 173 frequencyBin * NB_VALUES_PER_SM
173 174 + asmComponent;
174 175 offsetAveragedSpecMat =
175 176 asmComponent * NB_BINS_PER_SM
176 177 + frequencyBin;
177 178 averaged_spec_mat_reorganized[offsetAveragedSpecMatReorganized ] =
178 179 averaged_spec_mat[ offsetAveragedSpecMat ] / divider;
179 180 }
180 181 }
181 182 }
182 183
183 184 void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
184 185 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart )
185 186 {
186 187 int frequencyBin;
187 188 int asmComponent;
188 189 int offsetASM;
189 190 int offsetCompressed;
190 191 int k;
191 192
192 193 // build data
193 194 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
194 195 {
195 196 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
196 197 {
197 198 offsetCompressed = // NO TIME OFFSET
198 199 frequencyBin * NB_VALUES_PER_SM
199 200 + asmComponent;
200 201 offsetASM = // NO TIME OFFSET
201 202 asmComponent * NB_BINS_PER_SM
202 203 + ASMIndexStart
203 204 + frequencyBin * nbBinsToAverage;
204 205 compressed_spec_mat[ offsetCompressed ] = 0;
205 206 for ( k = 0; k < nbBinsToAverage; k++ )
206 207 {
207 208 compressed_spec_mat[offsetCompressed ] =
208 209 ( compressed_spec_mat[ offsetCompressed ]
209 210 + averaged_spec_mat[ offsetASM + k ] ) / (divider * nbBinsToAverage);
210 211 }
211 212 }
212 213 }
213 214 }
214 215
215 216 void ASM_convert( volatile float *input_matrix, char *output_matrix)
216 217 {
217 218 unsigned int frequencyBin;
218 219 unsigned int asmComponent;
219 220 char * pt_char_input;
220 221 char * pt_char_output;
221 222 unsigned int offsetInput;
222 223 unsigned int offsetOutput;
223 224
224 225 pt_char_input = (char*) &input_matrix;
225 226 pt_char_output = (char*) &output_matrix;
226 227
227 228 // convert all other data
228 229 for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++)
229 230 {
230 231 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
231 232 {
232 233 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
233 234 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
234 235 pt_char_input = (char*) &input_matrix [ offsetInput ];
235 236 pt_char_output = (char*) &output_matrix[ offsetOutput ];
236 237 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
237 238 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
238 239 }
239 240 }
240 241 }
241 242
242 243 #endif // FSW_PROCESSING_H_INCLUDED
@@ -1,46 +1,48
1 1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 2 #define TC_LOAD_DUMP_PARAMETERS_H
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "wf_handler.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "fsw_misc.h"
11 11
12 extern unsigned short sequenceCounterParameterDump;
13
12 14 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
13 15 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
14 16 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
15 17 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
16 18 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
17 19 int action_dump_par(rtems_id queue_id );
18 20
19 21 // NORMAL
20 22 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
21 23 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
22 24 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
23 25 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
24 26 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
25 27 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
26 28
27 29 // BURST
28 30 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 31 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
30 32
31 33 // SBM1
32 34 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
33 35 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
34 36
35 37 // SBM2
36 38 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
37 39 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
38 40
39 41 // TC_LFR_UPDATE_INFO
40 42 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
41 43 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
42 44 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
43 45
44 46 void init_parameter_dump( void );
45 47
46 48 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,73 +1,75
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 23 #include "fsw_params_wf_handler.h"
24 24
25 25 // RTEMS GLOBAL VARIABLES
26 26 rtems_name misc_name[5];
27 27 rtems_id misc_id[5];
28 28 rtems_name Task_name[20]; /* array of task names */
29 29 rtems_id Task_id[20]; /* array of task ids */
30 30 unsigned int maxCount;
31 31 int fdSPW = 0;
32 32 int fdUART = 0;
33 33 unsigned char lfrCurrentMode;
34 34
35 35 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
36 36 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
37 37 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
38 38 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
39 39 // F0 F1 F2 F3
40 40 volatile int wf_snap_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
41 41 volatile int wf_snap_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
42 42 volatile int wf_snap_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 43 volatile int wf_cont_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
44 44 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
45 45
46 46 //***********************************
47 47 // SPECTRAL MATRICES GLOBAL VARIABLES
48 48
49 49 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
50 50 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 51 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 52 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53 53
54 54 // APB CONFIGURATION REGISTERS
55 55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
56 56 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
57 57 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
58 58 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
59 59
60 60 // MODE PARAMETERS
61 61 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
62 62 struct param_local_str param_local;
63 63
64 64 // HK PACKETS
65 65 Packet_TM_LFR_HK_t housekeeping_packet;
66 66 // sequence counters are incremented by APID (PID + CAT) and destination ID
67 67 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
68 68 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
69 69 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
70 unsigned short sequenceCounterHK;
71 unsigned short sequenceCounterParameterDump;
70 72 spw_stats spacewire_stats;
71 73 spw_stats spacewire_stats_backup;
72 74
73 75
@@ -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 76 reset_local_time();
77 77
78 78 rtems_cpu_usage_reset();
79 79
80 80 rtems_status_code status;
81 81 rtems_status_code status_spw;
82 82 rtems_isr_entry old_isr_handler;
83 83
84 84 // UART settings
85 85 send_console_outputs_on_apbuart_port();
86 86 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
87 87 enable_apbuart_transmitter();
88 88 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
89 89
90 90 PRINTF("\n\n\n\n\n")
91 91 PRINTF("*************************\n")
92 92 PRINTF("** LFR Flight Software **\n")
93 93 PRINTF1("** %d.", SW_VERSION_N1)
94 94 PRINTF1("%d." , SW_VERSION_N2)
95 95 PRINTF1("%d." , SW_VERSION_N3)
96 96 PRINTF1("%d **\n", SW_VERSION_N4)
97 97
98 98 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
99 99 PRINTF("** VHDL **\n")
100 100 PRINTF1("** %d.", vhdlVersion[1])
101 101 PRINTF1("%d." , vhdlVersion[2])
102 102 PRINTF1("%d **\n", vhdlVersion[3])
103 103 PRINTF("*************************\n")
104 104 PRINTF("\n\n")
105 105
106 106 init_parameter_dump();
107 107 init_local_mode_parameters();
108 108 init_housekeeping_parameters();
109 109
110 110 // waveform picker initialization
111 111 WFP_init_rings(); // initialize the waveform rings
112 112 WFP_reset_current_ring_nodes();
113 113 reset_waveform_picker_regs();
114 114
115 115 // spectral matrices initialization
116 116 SM_init_rings(); // initialize spectral matrices rings
117 117 SM_reset_current_ring_nodes();
118 118 reset_spectral_matrix_regs();
119 119
120 120 updateLFRCurrentMode();
121 121
122 122 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
123 123
124 124 create_names(); // create all names
125 125
126 126 status = create_message_queues(); // create message queues
127 127 if (status != RTEMS_SUCCESSFUL)
128 128 {
129 129 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
130 130 }
131 131
132 132 status = create_all_tasks(); // create all tasks
133 133 if (status != RTEMS_SUCCESSFUL)
134 134 {
135 135 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
136 136 }
137 137
138 138 // **************************
139 139 // <SPACEWIRE INITIALIZATION>
140 140 grspw_timecode_callback = &timecode_irq_handler;
141 141
142 142 status_spw = spacewire_open_link(); // (1) open the link
143 143 if ( status_spw != RTEMS_SUCCESSFUL )
144 144 {
145 145 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
146 146 }
147 147
148 148 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
149 149 {
150 150 status_spw = spacewire_configure_link( fdSPW );
151 151 if ( status_spw != RTEMS_SUCCESSFUL )
152 152 {
153 153 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
154 154 }
155 155 }
156 156
157 157 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
158 158 {
159 159 status_spw = spacewire_start_link( fdSPW );
160 160 if ( status_spw != RTEMS_SUCCESSFUL )
161 161 {
162 162 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
163 163 }
164 164 }
165 165 // </SPACEWIRE INITIALIZATION>
166 166 // ***************************
167 167
168 168 status = start_all_tasks(); // start all tasks
169 169 if (status != RTEMS_SUCCESSFUL)
170 170 {
171 171 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
172 172 }
173 173
174 174 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
175 175 status = start_recv_send_tasks();
176 176 if ( status != RTEMS_SUCCESSFUL )
177 177 {
178 178 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
179 179 }
180 180
181 181 // suspend science tasks, they will be restarted later depending on the mode
182 182 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
183 183 if (status != RTEMS_SUCCESSFUL)
184 184 {
185 185 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
186 186 }
187 187
188 188 //******************************
189 189 // <SPECTRAL MATRICES SIMULATOR>
190 190 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
191 191 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
192 192 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
193 193 // </SPECTRAL MATRICES SIMULATOR>
194 194 //*******************************
195 195
196 196 // configure IRQ handling for the waveform picker unit
197 197 status = rtems_interrupt_catch( waveforms_isr,
198 198 IRQ_SPARC_WAVEFORM_PICKER,
199 199 &old_isr_handler) ;
200 200 // configure IRQ handling for the spectral matrices unit
201 201 status = rtems_interrupt_catch( spectral_matrices_isr,
202 202 IRQ_SPARC_SPECTRAL_MATRIX,
203 203 &old_isr_handler) ;
204 204
205 205 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
206 206 if ( status_spw != RTEMS_SUCCESSFUL )
207 207 {
208 208 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
209 209 if ( status != RTEMS_SUCCESSFUL ) {
210 210 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
211 211 }
212 212 }
213 213
214 214 BOOT_PRINTF("delete INIT\n")
215 215
216 216 send_dumb_hk();
217 217
218 218 status = rtems_task_delete(RTEMS_SELF);
219 219
220 220 }
221 221
222 222 void init_local_mode_parameters( void )
223 223 {
224 224 /** This function initialize the param_local global variable with default values.
225 225 *
226 226 */
227 227
228 228 unsigned int i;
229 229
230 230 // LOCAL PARAMETERS
231 231
232 232 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
233 233 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
234 234 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
235 235
236 236 // init sequence counters
237 237
238 238 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
239 239 {
240 240 sequenceCounters_TC_EXE[i] = 0x00;
241 241 }
242 242 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
243 243 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
244 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
245 sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
244 246 }
245 247
246 248 void reset_local_time( void )
247 249 {
248 250 time_management_regs->ctrl = 0x02; // 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 469 RTEMS_DEFAULT_ATTRIBUTES, &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,586 +1,615
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_id queue_id;
146 146 rtems_rate_monotonic_period_status period_status;
147 147
148 148 status = get_message_queue_id_send( &queue_id );
149 149 if (status != RTEMS_SUCCESSFUL)
150 150 {
151 151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 152 }
153 153
154 154 BOOT_PRINTF("in HOUS ***\n")
155 155
156 156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 158 if( status != RTEMS_SUCCESSFUL ) {
159 159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
160 160 }
161 161 }
162 162
163 163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 174 housekeeping_packet.serviceType = TM_TYPE_HK;
175 175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 177 housekeeping_packet.sid = SID_HK;
178 178
179 179 status = rtems_rate_monotonic_cancel(HK_id);
180 180 if( status != RTEMS_SUCCESSFUL ) {
181 181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 182 }
183 183 else {
184 184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 185 }
186 186
187 187 // startup phase
188 188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 192 {
193 193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 194 {
195 195 break; // break if LFR is synchronized
196 196 }
197 197 else
198 198 {
199 199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 200 // sched_yield();
201 201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
202 202 }
203 203 }
204 204 status = rtems_rate_monotonic_cancel(HK_id);
205 205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
206 206
207 207 while(1){ // launch the rate monotonic task
208 208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 209 if ( status != RTEMS_SUCCESSFUL ) {
210 210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 212 }
213 213 else {
214 increment_seq_counter( housekeeping_packet.packetSequenceControl );
214 housekeeping_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterHK >> 8;
215 housekeeping_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterHK;
216 increment_seq_counter( &sequenceCounterHK );
217
215 218 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
216 219 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
217 220 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
218 221 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
219 222 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
220 223 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
221 224
222 225 spacewire_update_statistics();
223 226
224 227 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
225 228 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
226 229
227 230 // SEND PACKET
228 231 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
229 232 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
230 233 if (status != RTEMS_SUCCESSFUL) {
231 234 PRINTF1("in HOUS *** ERR send: %d\n", status)
232 235 }
233 236 }
234 237 }
235 238
236 239 PRINTF("in HOUS *** deleting task\n")
237 240
238 241 status = rtems_task_delete( RTEMS_SELF ); // should not return
239 242 printf( "rtems_task_delete returned with status of %d.\n", status );
240 243 return;
241 244 }
242 245
243 246 rtems_task dumb_task( rtems_task_argument unused )
244 247 {
245 248 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
246 249 *
247 250 * @param unused is the starting argument of the RTEMS task
248 251 *
249 252 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
250 253 *
251 254 */
252 255
253 256 unsigned int i;
254 257 unsigned int intEventOut;
255 258 unsigned int coarse_time = 0;
256 259 unsigned int fine_time = 0;
257 260 rtems_event_set event_out;
258 261
259 262 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
260 263 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
261 264 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
262 265 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
263 266 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
264 267 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
265 268 "ERR HK", // RTEMS_EVENT_6
266 269 "ready for dump", // RTEMS_EVENT_7
267 270 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
268 271 "tick" // RTEMS_EVENT_9
269 272 };
270 273
271 274 BOOT_PRINTF("in DUMB *** \n")
272 275
273 276 while(1){
274 277 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
275 278 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
276 279 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
277 280 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
278 281 intEventOut = (unsigned int) event_out;
279 282 for ( i=0; i<32; i++)
280 283 {
281 284 if ( ((intEventOut >> i) & 0x0001) != 0)
282 285 {
283 286 coarse_time = time_management_regs->coarse_time;
284 287 fine_time = time_management_regs->fine_time;
285 288 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
286 289 if (i==8)
287 290 {
288 291 PRINTF1("status = %x\n", spectral_matrix_regs->status)
289 292 }
290 293 }
291 294 }
292 295 }
293 296 }
294 297
295 298 //*****************************
296 299 // init housekeeping parameters
297 300
298 301 void init_housekeeping_parameters( void )
299 302 {
300 303 /** This function initialize the housekeeping_packet global variable with default values.
301 304 *
302 305 */
303 306
304 307 unsigned int i = 0;
305 308 unsigned char *parameters;
306 309
307 310 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
308 311 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
309 312 {
310 313 parameters[i] = 0x00;
311 314 }
312 315 // init status word
313 316 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
314 317 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
315 318 // init software version
316 319 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
317 320 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
318 321 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
319 322 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
320 323 // init fpga version
321 324 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
322 325 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
323 326 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
324 327 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
325 328 }
326 329
327 void increment_seq_counter( unsigned char *packet_sequence_control)
330 void increment_seq_counter_old( unsigned char *packet_sequence_control)
328 331 {
329 332 /** This function increment the sequence counter psased in argument.
330 333 *
331 334 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
332 335 *
333 336 */
334 337
335 338 unsigned short sequence_cnt;
336 339 unsigned short segmentation_grouping_flag;
337 340 unsigned short new_packet_sequence_control;
338 341
339 342 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
340 343 sequence_cnt = (unsigned short) (
341 344 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
342 345 + packet_sequence_control[1]
343 346 );
344 347
345 348 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
346 349
347 350 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
348 351 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
349 352
350 353 if ( sequence_cnt < SEQ_CNT_MAX)
351 354 {
352 355 sequence_cnt = sequence_cnt + 1;
353 356 }
354 357 else
355 358 {
356 359 sequence_cnt = 0;
357 360 }
358 361 }
359 362
363 void increment_seq_counter( unsigned short *packetSequenceControl )
364 {
365 /** This function increment the sequence counter psased in argument.
366 *
367 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
368 *
369 */
370
371 unsigned short sequence_cnt;
372 unsigned short segmentation_grouping_flag;
373
374 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
375 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
376
377 if ( sequence_cnt < SEQ_CNT_MAX)
378 {
379 sequence_cnt = sequence_cnt + 1;
380 }
381 else
382 {
383 sequence_cnt = 0;
384 }
385
386 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
387 }
388
360 389 void getTime( unsigned char *time)
361 390 {
362 391 /** This function write the current local time in the time buffer passed in argument.
363 392 *
364 393 */
365 394
366 395 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
367 396 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
368 397 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
369 398 time[3] = (unsigned char) (time_management_regs->coarse_time);
370 399 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
371 400 time[5] = (unsigned char) (time_management_regs->fine_time);
372 401 }
373 402
374 403 unsigned long long int getTimeAsUnsignedLongLongInt( )
375 404 {
376 405 /** This function write the current local time in the time buffer passed in argument.
377 406 *
378 407 */
379 408 unsigned long long int time;
380 409
381 410 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
382 411 + time_management_regs->fine_time;
383 412
384 413 return time;
385 414 }
386 415
387 416 void send_dumb_hk( void )
388 417 {
389 418 Packet_TM_LFR_HK_t dummy_hk_packet;
390 419 unsigned char *parameters;
391 420 unsigned int i;
392 421 rtems_id queue_id;
393 422
394 423 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
395 424 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
396 425 dummy_hk_packet.reserved = DEFAULT_RESERVED;
397 426 dummy_hk_packet.userApplication = CCSDS_USER_APP;
398 427 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
399 428 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
400 429 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
401 430 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
402 431 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
403 432 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
404 433 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
405 434 dummy_hk_packet.serviceType = TM_TYPE_HK;
406 435 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
407 436 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
408 437 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
409 438 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
410 439 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
411 440 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
412 441 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
413 442 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
414 443 dummy_hk_packet.sid = SID_HK;
415 444
416 445 // init status word
417 446 dummy_hk_packet.lfr_status_word[0] = 0xff;
418 447 dummy_hk_packet.lfr_status_word[1] = 0xff;
419 448 // init software version
420 449 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
421 450 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
422 451 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
423 452 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
424 453 // init fpga version
425 454 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
426 455 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
427 456 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
428 457 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
429 458
430 459 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
431 460
432 461 for (i=0; i<100; i++)
433 462 {
434 463 parameters[i] = 0xff;
435 464 }
436 465
437 466 get_message_queue_id_send( &queue_id );
438 467
439 468 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
440 469 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
441 470 }
442 471
443 472 void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential )
444 473 {
445 474 unsigned int coarseTime;
446 475 unsigned int acquisitionTime;
447 476 unsigned int deltaT = 0;
448 477 unsigned char *bufferPtr;
449 478
450 479 unsigned int offset_in_samples;
451 480 unsigned int offset_in_bytes;
452 481 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
453 482
454 483 if (lfrCurrentMode == LFR_MODE_STANDBY)
455 484 {
456 485 spacecraft_potential[0] = 0x00;
457 486 spacecraft_potential[1] = 0x00;
458 487 spacecraft_potential[2] = 0x00;
459 488 spacecraft_potential[3] = 0x00;
460 489 spacecraft_potential[4] = 0x00;
461 490 spacecraft_potential[5] = 0x00;
462 491 }
463 492 else
464 493 {
465 494 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
466 495 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
467 496 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
468 497 + (unsigned int) ( bufferPtr[3] << 16 )
469 498 + (unsigned int) ( bufferPtr[0] << 8 )
470 499 + (unsigned int) ( bufferPtr[1] );
471 500 if ( coarseTime > acquisitionTime )
472 501 {
473 502 deltaT = coarseTime - acquisitionTime;
474 503 offset_in_samples = (deltaT-1) * f3 ;
475 504 }
476 505 else if( coarseTime == acquisitionTime )
477 506 {
478 507 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
479 508 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
480 509 }
481 510 else
482 511 {
483 512 offset_in_samples = 0;
484 513 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
485 514 }
486 515
487 516 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
488 517 {
489 518 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
490 519 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
491 520 }
492 521 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
493 522 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
494 523 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
495 524 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
496 525 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
497 526 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
498 527 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
499 528 }
500 529 }
501 530
502 531 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
503 532 {
504 533 unsigned int coarseTime;
505 534 unsigned int acquisitionTime;
506 535 unsigned int deltaT = 0;
507 536 unsigned char *bufferPtr;
508 537
509 538 unsigned int offset_in_samples;
510 539 unsigned int offset_in_bytes;
511 540 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
512 541
513 542 if (lfrCurrentMode == LFR_MODE_STANDBY)
514 543 {
515 544 spacecraft_potential[0] = 0x00;
516 545 spacecraft_potential[1] = 0x00;
517 546 spacecraft_potential[2] = 0x00;
518 547 spacecraft_potential[3] = 0x00;
519 548 spacecraft_potential[4] = 0x00;
520 549 spacecraft_potential[5] = 0x00;
521 550 }
522 551 else
523 552 {
524 553 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
525 554 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
526 555 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
527 556 + (unsigned int) ( bufferPtr[1] << 16 )
528 557 + (unsigned int) ( bufferPtr[2] << 8 )
529 558 + (unsigned int) ( bufferPtr[3] );
530 559 if ( coarseTime > acquisitionTime )
531 560 {
532 561 deltaT = coarseTime - acquisitionTime;
533 562 offset_in_samples = (deltaT-1) * f3 ;
534 563 }
535 564 else if( coarseTime == acquisitionTime )
536 565 {
537 566 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
538 567 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
539 568 }
540 569 else
541 570 {
542 571 offset_in_samples = 0;
543 572 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
544 573 }
545 574
546 575 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
547 576 {
548 577 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
549 578 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
550 579 }
551 580 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
552 581 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
553 582 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
554 583 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
555 584 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
556 585 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
557 586 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
558 587 }
559 588 }
560 589
561 590 void get_cpu_load( unsigned char *resource_statistics )
562 591 {
563 592 unsigned char cpu_load;
564 593
565 594 cpu_load = lfr_rtems_cpu_usage_report();
566 595
567 596 // HK_LFR_CPU_LOAD
568 597 resource_statistics[0] = cpu_load;
569 598
570 599 // HK_LFR_CPU_LOAD_MAX
571 600 if (cpu_load > resource_statistics[1])
572 601 {
573 602 resource_statistics[1] = cpu_load;
574 603 }
575 604
576 605 // CPU_LOAD_AVE
577 606 resource_statistics[2] = 0;
578 607
579 608 #ifndef PRINT_TASK_STATISTICS
580 609 rtems_cpu_usage_reset();
581 610 #endif
582 611
583 612 }
584 613
585 614
586 615
@@ -1,371 +1,379
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 "avf0_prc0.h"
11 11 #include "fsw_processing.h"
12 12
13 13 nb_sm_before_bp_asm_f0 nb_sm_before_f0;
14 14
15 15 //***
16 16 // F0
17 17 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_NORM_F0 ];
18 18 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
19 19
20 20 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
21 21 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
22 22 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
23 23 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
24 24 //unsigned char bp1_norm_f0 [ TOTAL_SIZE_BP1_NORM_F0 ];
25 25 //unsigned char bp1_sbm_f0 [ TOTAL_SIZE_BP1_SBM_F0 ];
26 26
27 27 //************
28 28 // RTEMS TASKS
29 29
30 30 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
31 31 {
32 32 int i;
33 33
34 34 rtems_event_set event_out;
35 35 rtems_status_code status;
36 36 rtems_id queue_id_prc0;
37 37 asm_msg msgForMATR;
38 38 ring_node_sm *ring_node_tab[8];
39 39 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
40 40 ring_node_asm *current_ring_node_asm_norm_f0;
41 41
42 42 unsigned int nb_norm_bp1;
43 43 unsigned int nb_norm_bp2;
44 44 unsigned int nb_norm_asm;
45 45 unsigned int nb_sbm_bp1;
46 46 unsigned int nb_sbm_bp2;
47 47
48 48 nb_norm_bp1 = 0;
49 49 nb_norm_bp2 = 0;
50 50 nb_norm_asm = 0;
51 51 nb_sbm_bp1 = 0;
52 52 nb_sbm_bp2 = 0;
53 53
54 54 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
55 55 ASM_generic_init_ring( asm_ring_norm_f0, NB_RING_NODES_ASM_NORM_F0 );
56 56 ASM_generic_init_ring( asm_ring_burst_sbm_f0, NB_RING_NODES_ASM_BURST_SBM_F0 );
57 57 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
58 58 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
59 59
60 60 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
61 61
62 62 status = get_message_queue_id_prc0( &queue_id_prc0 );
63 63 if (status != RTEMS_SUCCESSFUL)
64 64 {
65 65 PRINTF1("in MATR *** ERR get_message_queue_id_prc0 %d\n", status)
66 66 }
67 67
68 68 while(1){
69 69 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
70 70 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
71 71 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
72 72 {
73 73 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
74 74 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
75 75 }
76 76
77 77 // compute the average and store it in the averaged_sm_f1 buffer
78 78 SM_average( current_ring_node_asm_norm_f0->matrix,
79 79 current_ring_node_asm_burst_sbm_f0->matrix,
80 80 ring_node_tab,
81 81 nb_norm_bp1, nb_sbm_bp1 );
82 82
83 83 // update nb_average
84 84 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
85 85 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
86 86 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
87 87 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
88 88 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
89 89
90 90 //****************************************
91 91 // initialize the mesage for the MATR task
92 92 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
93 93 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f0;
94 94 msgForMATR.norm = current_ring_node_asm_norm_f0;
95 95 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
96 96 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
97 97 msgForMATR.coarseTime = time_management_regs->coarse_time;
98 98 msgForMATR.fineTime = time_management_regs->fine_time;
99 99
100 100 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
101 101 {
102 102 nb_sbm_bp1 = 0;
103 103 // set another ring for the ASM storage
104 104 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
105 if ( (lfrCurrentMode == LFR_MODE_BURST)
106 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
105 if ( lfrCurrentMode == LFR_MODE_BURST )
107 106 {
108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
107 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F0;
108 }
109 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
110 {
111 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F0;
109 112 }
110 113 }
111 114
112 115 if (nb_sbm_bp2 == nb_sm_before_f0.burst_sbm_bp2)
113 116 {
114 117 nb_sbm_bp2 = 0;
115 if ( (lfrCurrentMode == LFR_MODE_BURST)
116 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
118 if ( lfrCurrentMode == LFR_MODE_BURST )
117 119 {
118 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
120 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F0;
121 }
122 else if ( (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
123 {
124 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F0;
119 125 }
120 126 }
121 127
122 128 if (nb_norm_bp1 == nb_sm_before_f0.norm_bp1)
123 129 {
124 130 nb_norm_bp1 = 0;
125 131 // set another ring for the ASM storage
126 132 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
127 133 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
128 134 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
129 135 {
130 136 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
131 137 }
132 138 }
133 139
134 140 if (nb_norm_bp2 == nb_sm_before_f0.norm_bp2)
135 141 {
136 142 nb_norm_bp2 = 0;
137 143 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
138 144 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
139 145 {
140 146 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
141 147 }
142 148 }
143 149
144 150 if (nb_norm_asm == nb_sm_before_f0.norm_asm)
145 151 {
146 152 nb_norm_asm = 0;
147 153 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
148 154 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
149 155 {
150 156 // PRINTF1("%lld\n", localTime)
151 157 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
152 158 }
153 159 }
154 160
155 161 //*************************
156 162 // send the message to MATR
157 163 if (msgForMATR.event != 0x00)
158 164 {
159 165 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC0);
160 166 }
161 167
162 168 if (status != RTEMS_SUCCESSFUL) {
163 169 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
164 170 }
165 171 }
166 172 }
167 173
168 174 rtems_task prc0_task( rtems_task_argument lfrRequestedMode )
169 175 {
170 176 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
171 177 size_t size; // size of the incoming TC packet
172 178 asm_msg *incomingMsg;
173 179 //
180 unsigned char sid;
174 181 spw_ioctl_pkt_send spw_ioctl_send_ASM;
175 182 rtems_status_code status;
176 183 rtems_id queue_id;
177 184 rtems_id queue_id_q_p0;
178 185 Header_TM_LFR_SCIENCE_ASM_t headerASM;
179 186 bp_packet_with_spare packet_norm_bp1_f0;
180 187 bp_packet packet_norm_bp2_f0;
181 188 bp_packet packet_sbm_bp1_f0;
182 189 bp_packet packet_sbm_bp2_f0;
183 190
184 191 unsigned long long int localTime;
185 192
186 193 ASM_init_header( &headerASM );
187 194
188 195 //*************
189 196 // NORM headers
190 197 BP_init_header_with_spare( &packet_norm_bp1_f0.header,
191 198 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
192 199 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
193 200 BP_init_header( &packet_norm_bp2_f0.header,
194 201 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
195 202 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
196 203
197 204 //****************************
198 205 // BURST SBM1 and SBM2 headers
199 206 if ( lfrRequestedMode == LFR_MODE_BURST )
200 207 {
201 208 BP_init_header( &packet_sbm_bp1_f0.header,
202 209 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
203 210 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
204 211 BP_init_header( &packet_sbm_bp2_f0.header,
205 212 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
206 213 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
207 214 }
208 215 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
209 216 {
210 217 BP_init_header( &packet_sbm_bp1_f0.header,
211 218 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
212 219 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
213 220 BP_init_header( &packet_sbm_bp2_f0.header,
214 221 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
215 222 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
216 223 }
217 224 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
218 225 {
219 226 BP_init_header( &packet_sbm_bp1_f0.header,
220 227 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
221 228 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
222 229 BP_init_header( &packet_sbm_bp2_f0.header,
223 230 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
224 231 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
225 232 }
226 233 else
227 234 {
228 235 PRINTF1("in PRC0 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
229 236 }
230 237
231 238 status = get_message_queue_id_send( &queue_id );
232 239 if (status != RTEMS_SUCCESSFUL)
233 240 {
234 241 PRINTF1("in PRC0 *** ERR get_message_queue_id_send %d\n", status)
235 242 }
236 243 status = get_message_queue_id_prc0( &queue_id_q_p0);
237 244 if (status != RTEMS_SUCCESSFUL)
238 245 {
239 246 PRINTF1("in PRC0 *** ERR get_message_queue_id_prc0 %d\n", status)
240 247 }
241 248
242 249 BOOT_PRINTF1("in PRC0 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
243 250
244 251 while(1){
245 252 status = rtems_message_queue_receive( queue_id_q_p0, incomingData, &size, //************************************
246 253 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
247 254
248 255 incomingMsg = (asm_msg*) incomingData;
249 256
250 257 localTime = getTimeAsUnsignedLongLongInt( );
251 258
252 259 //****************
253 260 //****************
254 261 // BURST SBM1 SBM2
255 262 //****************
256 263 //****************
257 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
264 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F0 ) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F0 ) )
258 265 {
266 sid = getSID( incomingMsg->event );
259 267 // 1) compress the matrix for Basic Parameters calculation
260 268 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
261 269 nb_sm_before_f0.burst_sbm_bp1,
262 270 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
263 271 ASM_F0_INDICE_START);
264 272 // 2) compute the BP1 set
265 273 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_SBM_F0, bp1_sbm_f0 );
266 274 // 3) send the BP1 set
267 275 set_time( packet_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
268 276 set_time( packet_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
269 277 BP_send( (char *) &packet_sbm_bp1_f0, queue_id,
270 278 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA,
271 SID_SBM1_BP1_F0);
279 sid);
272 280 // 4) compute the BP2 set if needed
273 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
281 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F0) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F0) )
274 282 {
275 283 // 1) compute the BP2 set
276 284
277 285 // 2) send the BP2 set
278 286 set_time( packet_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
279 287 set_time( packet_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
280 288 BP_send( (char *) &packet_sbm_bp2_f0, queue_id,
281 289 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA,
282 SID_SBM1_BP2_F0);
290 sid);
283 291 }
284 292 }
285 293
286 294 //*****
287 295 //*****
288 296 // NORM
289 297 //*****
290 298 //*****
291 299 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
292 300 {
293 301 // 1) compress the matrix for Basic Parameters calculation
294 302 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
295 303 nb_sm_before_f0.norm_bp1,
296 304 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
297 305 ASM_F0_INDICE_START );
298 306 // 2) compute the BP1 set
299 307 // BP1_set( compressed_sm_norm_f0, NB_BINS_COMPRESSED_SM_F0, bp1_norm_f0 );
300 308 // 3) send the BP1 set
301 309 set_time( packet_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
302 310 set_time( packet_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
303 311 BP_send( (char *) &packet_norm_bp1_f0, queue_id,
304 312 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA,
305 313 SID_NORM_BP1_F0 );
306 314 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
307 315 {
308 316 // 1) compute the BP2 set using the same ASM as the one used for BP1
309 317
310 318 // 2) send the BP2 set
311 319 set_time( packet_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
312 320 set_time( packet_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
313 321 BP_send( (char *) &packet_norm_bp2_f0, queue_id,
314 322 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA,
315 323 SID_NORM_BP2_F0);
316 324 }
317 325 }
318 326
319 327 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
320 328 {
321 329 // 1) reorganize the ASM and divide
322 330 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
323 331 asm_f0_reorganized,
324 332 nb_sm_before_f0.norm_bp1 );
325 333 // 2) convert the float array in a char array
326 334 ASM_convert( asm_f0_reorganized, asm_f0_char);
327 335 // 3) send the spectral matrix packets
328 336 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
329 337 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
330 338 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
331 339 }
332 340
333 341 }
334 342 }
335 343
336 344 //**********
337 345 // FUNCTIONS
338 346
339 347 void reset_nb_sm_f0( unsigned char lfrMode )
340 348 {
341 349 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
342 350 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
343 351 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
344 352 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
345 353 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
346 354 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
347 355 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
348 356 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
349 357 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
350 358
351 359 if (lfrMode == LFR_MODE_SBM1)
352 360 {
353 361 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm1_bp1;
354 362 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm1_bp2;
355 363 }
356 364 else if (lfrMode == LFR_MODE_SBM2)
357 365 {
358 366 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.sbm2_bp1;
359 367 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.sbm2_bp2;
360 368 }
361 369 else if (lfrMode == LFR_MODE_BURST)
362 370 {
363 371 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
364 372 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
365 373 }
366 374 else
367 375 {
368 376 nb_sm_before_f0.burst_sbm_bp1 = nb_sm_before_f0.burst_bp1;
369 377 nb_sm_before_f0.burst_sbm_bp2 = nb_sm_before_f0.burst_bp2;
370 378 }
371 379 }
@@ -1,349 +1,359
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 "avf1_prc1.h"
11 11
12 12 nb_sm_before_bp_asm_f1 nb_sm_before_f1;
13 13
14 14 //***
15 15 // F1
16 16 ring_node_asm asm_ring_norm_f1 [ NB_RING_NODES_ASM_NORM_F1 ];
17 17 ring_node_asm asm_ring_burst_sbm_f1[ NB_RING_NODES_ASM_BURST_SBM_F1 ];
18 18
19 19 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
20 20 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
21 21 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
22 22 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
23 23
24 24 //************
25 25 // RTEMS TASKS
26 26
27 27 rtems_task avf1_task( rtems_task_argument lfrRequestedMode )
28 28 {
29 29 int i;
30 30
31 31 rtems_event_set event_out;
32 32 rtems_status_code status;
33 33 rtems_id queue_id_prc1;
34 34 asm_msg msgForMATR;
35 35 ring_node_sm *ring_node_tab[8];
36 36 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
37 37 ring_node_asm *current_ring_node_asm_norm_f1;
38 38
39 39 unsigned int nb_norm_bp1;
40 40 unsigned int nb_norm_bp2;
41 41 unsigned int nb_norm_asm;
42 42 unsigned int nb_sbm_bp1;
43 43 unsigned int nb_sbm_bp2;
44 44
45 45 nb_norm_bp1 = 0;
46 46 nb_norm_bp2 = 0;
47 47 nb_norm_asm = 0;
48 48 nb_sbm_bp1 = 0;
49 49 nb_sbm_bp2 = 0;
50 50
51 51 reset_nb_sm_f1( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
52 52 ASM_generic_init_ring( asm_ring_norm_f1, NB_RING_NODES_ASM_NORM_F1 );
53 53 ASM_generic_init_ring( asm_ring_burst_sbm_f1, NB_RING_NODES_ASM_BURST_SBM_F1 );
54 54 current_ring_node_asm_norm_f1 = asm_ring_norm_f1;
55 55 current_ring_node_asm_burst_sbm_f1 = asm_ring_burst_sbm_f1;
56 56
57 57 BOOT_PRINTF1("in AVF1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
58 58
59 59 status = get_message_queue_id_prc1( &queue_id_prc1 );
60 60 if (status != RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("in AVF1 *** ERR get_message_queue_id_prc1 %d\n", status)
63 63 }
64 64
65 65 while(1){
66 66 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
67 67 ring_node_tab[NB_SM_BEFORE_AVF1-1] = ring_node_for_averaging_sm_f1;
68 68 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
69 69 {
70 70 ring_node_for_averaging_sm_f1 = ring_node_for_averaging_sm_f1->previous;
71 71 ring_node_tab[NB_SM_BEFORE_AVF1-i] = ring_node_for_averaging_sm_f1;
72 72 }
73 73
74 74 // compute the average and store it in the averaged_sm_f1 buffer
75 75 SM_average( current_ring_node_asm_norm_f1->matrix,
76 76 current_ring_node_asm_burst_sbm_f1->matrix,
77 77 ring_node_tab,
78 78 nb_norm_bp1, nb_sbm_bp1 );
79 79
80 80 // update nb_average
81 81 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
82 82 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
83 83 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
84 84 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
85 85 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
86 86
87 87 //****************************************
88 88 // initialize the mesage for the MATR task
89 89 msgForMATR.event = 0x00; // this composite event will be sent to the PRC1 task
90 90 msgForMATR.burst_sbm = current_ring_node_asm_burst_sbm_f1;
91 91 msgForMATR.norm = current_ring_node_asm_norm_f1;
92 92 // msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
93 93 // msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
94 94 msgForMATR.coarseTime = time_management_regs->coarse_time;
95 95 msgForMATR.fineTime = time_management_regs->fine_time;
96 96
97 97 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
98 98 {
99 99 nb_sbm_bp1 = 0;
100 100 // set another ring for the ASM storage
101 101 current_ring_node_asm_burst_sbm_f1 = current_ring_node_asm_burst_sbm_f1->next;
102 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
102 if ( lfrCurrentMode == LFR_MODE_BURST )
103 103 {
104 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F1;
104 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP1_F1;
105 }
106 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
107 {
108 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP1_F1;
105 109 }
106 110 }
107 111
108 112 if (nb_sbm_bp2 == nb_sm_before_f1.burst_sbm_bp2)
109 113 {
110 114 nb_sbm_bp2 = 0;
111 if ( (lfrCurrentMode == LFR_MODE_BURST) || (lfrCurrentMode == LFR_MODE_SBM2) )
115 if ( lfrCurrentMode == LFR_MODE_BURST )
112 116 {
113 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F1;
117 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_BP2_F1;
118 }
119 else if ( lfrCurrentMode == LFR_MODE_SBM2 )
120 {
121 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_SBM_BP2_F1;
114 122 }
115 123 }
116 124
117 125 if (nb_norm_bp1 == nb_sm_before_f1.norm_bp1)
118 126 {
119 127 nb_norm_bp1 = 0;
120 128 // set another ring for the ASM storage
121 129 current_ring_node_asm_norm_f1 = current_ring_node_asm_norm_f1->next;
122 130 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
123 131 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
124 132 {
125 133 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F1;
126 134 }
127 135 }
128 136
129 137 if (nb_norm_bp2 == nb_sm_before_f1.norm_bp2)
130 138 {
131 139 nb_norm_bp2 = 0;
132 140 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
133 141 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
134 142 {
135 143 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F1;
136 144 }
137 145 }
138 146
139 147 if (nb_norm_asm == nb_sm_before_f1.norm_asm)
140 148 {
141 149 nb_norm_asm = 0;
142 150 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
143 151 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
144 152 {
145 153 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F1;
146 154 }
147 155 }
148 156
149 157 //*************************
150 158 // send the message to MATR
151 159 if (msgForMATR.event != 0x00)
152 160 {
153 161 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForMATR, MSG_QUEUE_SIZE_PRC1);
154 162 }
155 163
156 164 if (status != RTEMS_SUCCESSFUL) {
157 165 printf("in AVF1 *** Error sending message to PRC1, code %d\n", status);
158 166 }
159 167 }
160 168 }
161 169
162 170 rtems_task prc1_task( rtems_task_argument lfrRequestedMode )
163 171 {
164 172 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
165 173 size_t size; // size of the incoming TC packet
166 174 asm_msg *incomingMsg;
167 175 //
176 unsigned char sid;
168 177 spw_ioctl_pkt_send spw_ioctl_send_ASM;
169 178 rtems_status_code status;
170 179 rtems_id queue_id_send;
171 180 rtems_id queue_id_q_p1;
172 181 Header_TM_LFR_SCIENCE_ASM_t headerASM;
173 182 bp_packet_with_spare packet_norm_bp1;
174 183 bp_packet packet_norm_bp2;
175 184 bp_packet packet_sbm_bp1;
176 185 bp_packet packet_sbm_bp2;
177 186
178 187 unsigned long long int localTime;
179 188
180 189 ASM_init_header( &headerASM );
181 190
182 191 //*************
183 192 // NORM headers
184 193 BP_init_header_with_spare( &packet_norm_bp1.header,
185 194 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F1,
186 195 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1, NB_BINS_COMPRESSED_SM_F1 );
187 196 BP_init_header( &packet_norm_bp2.header,
188 197 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F1,
189 198 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1, NB_BINS_COMPRESSED_SM_F1);
190 199
191 200 //***********************
192 201 // BURST and SBM2 headers
193 202 if ( lfrRequestedMode == LFR_MODE_BURST )
194 203 {
195 204 BP_init_header( &packet_sbm_bp1.header,
196 205 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F1,
197 206 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
198 207 BP_init_header( &packet_sbm_bp2.header,
199 208 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F1,
200 209 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
201 210 }
202 211 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
203 212 {
204 213 BP_init_header( &packet_sbm_bp1.header,
205 214 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F1,
206 215 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
207 216 BP_init_header( &packet_sbm_bp2.header,
208 217 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F1,
209 218 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1, NB_BINS_COMPRESSED_SM_SBM_F1);
210 219 }
211 220 else
212 221 {
213 222 PRINTF1("in PRC1 *** lfrRequestedMode is %d, several headers not initialized\n", (unsigned int) lfrRequestedMode)
214 223 }
215 224
216 225 status = get_message_queue_id_send( &queue_id_send );
217 226 if (status != RTEMS_SUCCESSFUL)
218 227 {
219 228 PRINTF1("in PRC1 *** ERR get_message_queue_id_send %d\n", status)
220 229 }
221 230 status = get_message_queue_id_prc1( &queue_id_q_p1);
222 231 if (status != RTEMS_SUCCESSFUL)
223 232 {
224 233 PRINTF1("in PRC1 *** ERR get_message_queue_id_prc1 %d\n", status)
225 234 }
226 235
227 236 BOOT_PRINTF1("in PRC1 *** lfrRequestedMode = %d\n", (int) lfrRequestedMode)
228 237
229 238 while(1){
230 239 status = rtems_message_queue_receive( queue_id_q_p1, incomingData, &size, //************************************
231 240 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
232 241
233 242 incomingMsg = (asm_msg*) incomingData;
234 243
235 244 localTime = getTimeAsUnsignedLongLongInt( );
236 245 //***********
237 246 //***********
238 247 // BURST SBM2
239 248 //***********
240 249 //***********
241 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F1 )
250 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP1_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP1_F1) )
242 251 {
252 sid = getSID( incomingMsg->event );
243 253 // 1) compress the matrix for Basic Parameters calculation
244 254 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f1,
245 255 nb_sm_before_f1.burst_sbm_bp1,
246 256 NB_BINS_COMPRESSED_SM_SBM_F1, NB_BINS_TO_AVERAGE_ASM_SBM_F1,
247 257 ASM_F1_INDICE_START);
248 258 // 2) compute the BP1 set
249 259
250 260 // 3) send the BP1 set
251 261 set_time( packet_sbm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
252 262 set_time( packet_sbm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
253 263 BP_send( (char *) &packet_sbm_bp1, queue_id_send,
254 264 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F1 + PACKET_LENGTH_DELTA,
255 SID_SBM2_BP1_F1 );
265 sid );
256 266 // 4) compute the BP2 set if needed
257 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F1 )
267 if ( (incomingMsg->event & RTEMS_EVENT_BURST_BP2_F1) || (incomingMsg->event & RTEMS_EVENT_SBM_BP2_F1) )
258 268 {
259 269 // 1) compute the BP2 set
260 270
261 271 // 2) send the BP2 set
262 272 set_time( packet_sbm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
263 273 set_time( packet_sbm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
264 274 BP_send( (char *) &packet_sbm_bp2, queue_id_send,
265 275 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F1 + PACKET_LENGTH_DELTA,
266 SID_SBM2_BP2_F1 );
276 sid );
267 277 }
268 278 }
269 279
270 280 //*****
271 281 //*****
272 282 // NORM
273 283 //*****
274 284 //*****
275 285 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F1)
276 286 {
277 287 // 1) compress the matrix for Basic Parameters calculation
278 288 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f1,
279 289 nb_sm_before_f1.norm_bp1,
280 290 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
281 291 ASM_F0_INDICE_START );
282 292 // 2) compute the BP1 set
283 293
284 294 // 3) send the BP1 set
285 295 set_time( packet_norm_bp1.header.time, (unsigned char *) &incomingMsg->coarseTime );
286 296 set_time( packet_norm_bp1.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
287 297 BP_send( (char *) &packet_norm_bp1, queue_id_send,
288 298 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F1 + PACKET_LENGTH_DELTA,
289 299 SID_NORM_BP1_F1 );
290 300 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F1)
291 301 {
292 302 // 1) compute the BP2 set
293 303
294 304 // 2) send the BP2 set
295 305 set_time( packet_norm_bp2.header.time, (unsigned char *) &incomingMsg->coarseTime );
296 306 set_time( packet_norm_bp2.header.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
297 307 BP_send( (char *) &packet_norm_bp2, queue_id_send,
298 308 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F1 + PACKET_LENGTH_DELTA,
299 309 SID_NORM_BP2_F1 );
300 310 }
301 311 }
302 312
303 313 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F1)
304 314 {
305 315 // 1) reorganize the ASM and divide
306 316 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
307 317 asm_f1_reorganized,
308 318 nb_sm_before_f1.norm_bp1 );
309 319 // 2) convert the float array in a char array
310 320 ASM_convert( asm_f1_reorganized, asm_f1_char);
311 321 // 3) send the spectral matrix packets
312 322 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
313 323 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
314 324 ASM_send( &headerASM, asm_f1_char, SID_NORM_ASM_F1, &spw_ioctl_send_ASM, queue_id_send);
315 325 }
316 326
317 327 }
318 328 }
319 329
320 330 //**********
321 331 // FUNCTIONS
322 332
323 333 void reset_nb_sm_f1( unsigned char lfrMode )
324 334 {
325 335 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
326 336 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
327 337 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
328 338 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
329 339 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
330 340 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
331 341 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
332 342
333 343 if (lfrMode == LFR_MODE_SBM2)
334 344 {
335 345 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.sbm2_bp1;
336 346 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.sbm2_bp2;
337 347 }
338 348 else if (lfrMode == LFR_MODE_BURST)
339 349 {
340 350 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
341 351 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
342 352 }
343 353 else
344 354 {
345 355 nb_sm_before_f1.burst_sbm_bp1 = nb_sm_before_f1.burst_bp1;
346 356 nb_sm_before_f1.burst_sbm_bp2 = nb_sm_before_f1.burst_bp2;
347 357 }
348 358 }
349 359
@@ -1,632 +1,678
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
39 39 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
40 40
41 41 switch(status)
42 42 {
43 43 case 0:
44 44 break;
45 45 case 3:
46 46 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_0_coarse_time );
47 47 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f0_1_coarse_time );
48 48 if ( time_0 < time_1 )
49 49 {
50 50 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
51 51 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
52 52 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
53 53 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
54 54 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
55 55 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
56 56 }
57 57 else
58 58 {
59 59 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
60 60 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
61 61 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
62 62 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
63 63 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
64 64 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
65 65 }
66 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x03; // [0011]
66 spectral_matrix_regs->status = 0x03; // [0011]
67 67 break;
68 68 case 1:
69 69 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
70 70 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
71 71 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
72 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x01; // [0001]
72 spectral_matrix_regs->status = 0x01; // [0001]
73 73 break;
74 74 case 2:
75 75 close_matrix_actions( &nb_sm_f0, NB_SM_BEFORE_AVF0, Task_id[TASKID_AVF0], ring_node_for_averaging_sm_f0, current_ring_node_sm_f0->previous);
76 76 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
77 77 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
78 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x02; // [0010]
78 spectral_matrix_regs->status = 0x02; // [0010]
79 79 break;
80 80 }
81 81 }
82 82
83 83 void spectral_matrices_isr_f1( void )
84 84 {
85 85 unsigned char status;
86 86 unsigned long long int time_0;
87 87 unsigned long long int time_1;
88 88
89 89 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
90 90
91 91 switch(status)
92 92 {
93 93 case 0:
94 94 break;
95 95 case 3:
96 96 time_0 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_0_coarse_time );
97 97 time_1 = get_acquisition_time( (unsigned char *) spectral_matrix_regs->f1_1_coarse_time );
98 98 if ( time_0 < time_1 )
99 99 {
100 100 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
101 101 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
102 102 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
103 103 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
104 104 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
105 105 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
106 106 }
107 107 else
108 108 {
109 109 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
110 110 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
111 111 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
112 112 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
113 113 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
114 114 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
115 115 }
116 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x0c; // [1100]
116 spectral_matrix_regs->status = 0x0c; // [1100]
117 117 break;
118 118 case 1:
119 119 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
120 120 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
121 121 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
122 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x07; // [0100]
122 spectral_matrix_regs->status = 0x04; // [0100]
123 123 break;
124 124 case 2:
125 125 close_matrix_actions( &nb_sm_f1, NB_SM_BEFORE_AVF1, Task_id[TASKID_AVF1], ring_node_for_averaging_sm_f1, current_ring_node_sm_f1->previous);
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 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x08; // [1000]
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
137 137 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
138 138
139 139 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
140 140
141 141 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
142 142
143 143 switch(status)
144 144 {
145 145 case 0:
146 break;
146 147 case 3:
148 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
149 spectral_matrix_regs->status = 0x30; // [0011 0000]
150 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
151 {
152 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 }
147 154 break;
148 155 case 1:
149 156 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
150 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x10; // [0001 0000]
157 spectral_matrix_regs->status = 0x10; // [0001 0000]
158 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 {
160 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 }
151 162 break;
152 163 case 2:
153 164 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
154 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x20; // [0010 0000]
155 break;
156 }
157
165 spectral_matrix_regs->status = 0x20; // [0010 0000]
158 166 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
159 167 {
160 168 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
161 169 }
170 break;
171 }
162 172 }
163 173
164 174 void spectral_matrix_isr_error_handler( void )
165 175 {
166 176 spectral_matrix_regs->status = 0x7c0; // [0111 1100 0000]
167 177 }
168 178
169 179 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
170 180 {
171 181 // STATUS REGISTER
172 182 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
173 183 // 10 9 8
174 184 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
175 185 // 7 6 5 4 3 2 1 0
176 186
177 187 spectral_matrices_isr_f0();
178 188
179 189 spectral_matrices_isr_f1();
180 190
181 191 spectral_matrices_isr_f2();
182 192
183 spectral_matrix_isr_error_handler();
193 // spectral_matrix_isr_error_handler();
184 194 }
185 195
186 196 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
187 197 {
188 198 //***
189 199 // F0
190 200 nb_sm_f0 = nb_sm_f0 + 1;
191 201 if (nb_sm_f0 == NB_SM_BEFORE_AVF0 )
192 202 {
193 203 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
194 204 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
195 205 {
196 206 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
197 207 }
198 208 nb_sm_f0 = 0;
199 209 }
200 210
201 211 //***
202 212 // F1
203 213 nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1;
204 214 if (nb_sm_f0_aux_f1 == 6)
205 215 {
206 216 nb_sm_f0_aux_f1 = 0;
207 217 nb_sm_f1 = nb_sm_f1 + 1;
208 218 }
209 219 if (nb_sm_f1 == NB_SM_BEFORE_AVF1 )
210 220 {
211 221 ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1;
212 222 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
213 223 {
214 224 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
215 225 }
216 226 nb_sm_f1 = 0;
217 227 }
218 228
219 229 //***
220 230 // F2
221 231 nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1;
222 232 if (nb_sm_f0_aux_f2 == 96)
223 233 {
224 234 nb_sm_f0_aux_f2 = 0;
225 235 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2;
226 236 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
227 237 {
228 238 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
229 239 }
230 240 }
231 241 }
232 242
233 243 //******************
234 244 // Spectral Matrices
235 245
236 246 void reset_nb_sm( void )
237 247 {
238 248 nb_sm_f0 = 0;
239 249 nb_sm_f0_aux_f1 = 0;
240 250 nb_sm_f0_aux_f2 = 0;
241 251
242 252 nb_sm_f1 = 0;
243 253 }
244 254
245 255 void SM_init_rings( void )
246 256 {
247 257 unsigned char i;
248 258
249 259 // F0 RING
250 260 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
251 261 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
252 262 sm_ring_f0[0].buffer_address =
253 263 (int) &sm_f0[ 0 ];
254 264
255 265 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
256 266 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
257 267 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
258 268 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
259 269
260 270 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
261 271 {
262 272 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
263 273 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
264 274 sm_ring_f0[i].buffer_address =
265 275 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
266 276 }
267 277
268 278 // F1 RING
269 279 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
270 280 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
271 281 sm_ring_f1[0].buffer_address =
272 282 (int) &sm_f1[ 0 ];
273 283
274 284 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
275 285 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
276 286 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
277 287 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
278 288
279 289 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
280 290 {
281 291 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
282 292 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
283 293 sm_ring_f1[i].buffer_address =
284 294 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
285 295 }
286 296
287 297 // F2 RING
288 298 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
289 299 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
290 300 sm_ring_f2[0].buffer_address =
291 301 (int) &sm_f2[ 0 ];
292 302
293 303 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
294 304 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
295 305 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
296 306 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
297 307
298 308 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
299 309 {
300 310 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
301 311 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
302 312 sm_ring_f2[i].buffer_address =
303 313 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
304 314 }
305 315
306 316 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
307 317 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
308 318 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
309 319
310 320 spectral_matrix_regs->f0_0_address = sm_ring_f0[0].buffer_address;
311 321 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->f0_0_address)
312 322 }
313 323
314 324 void SM_generic_init_ring( ring_node_sm *ring, unsigned char nbNodes, volatile int sm_f[] )
315 325 {
316 326 unsigned char i;
317 327
318 328 //***************
319 329 // BUFFER ADDRESS
320 330 for(i=0; i<nbNodes; i++)
321 331 {
322 332 ring[ i ].buffer_address = (int) &sm_f[ i * TOTAL_SIZE_SM ];
323 333 }
324 334
325 335 //*****
326 336 // NEXT
327 337 ring[ nbNodes - 1 ].next = (ring_node_sm*) &ring[ 0 ];
328 338 for(i=0; i<nbNodes-1; i++)
329 339 {
330 340 ring[ i ].next = (ring_node_sm*) &ring[ i + 1 ];
331 341 }
332 342
333 343 //*********
334 344 // PREVIOUS
335 345 ring[ 0 ].previous = (ring_node_sm*) &ring[ nbNodes -1 ];
336 346 for(i=1; i<nbNodes; i++)
337 347 {
338 348 ring[ i ].previous = (ring_node_sm*) &ring[ i - 1 ];
339 349 }
340 350 }
341 351
342 352 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
343 353 {
344 354 unsigned char i;
345 355
346 356 ring[ nbNodes - 1 ].next
347 357 = (ring_node_asm*) &ring[ 0 ];
348 358
349 359 for(i=0; i<nbNodes-1; i++)
350 360 {
351 361 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
352 362 }
353 363 }
354 364
355 365 void SM_reset_current_ring_nodes( void )
356 366 {
357 367 current_ring_node_sm_f0 = sm_ring_f0[0].next;
358 368 current_ring_node_sm_f1 = sm_ring_f1[0].next;
359 369 current_ring_node_sm_f2 = sm_ring_f2[0].next;
360 370
361 371 ring_node_for_averaging_sm_f0 = sm_ring_f0;
362 372 ring_node_for_averaging_sm_f1 = sm_ring_f1;
363 373 ring_node_for_averaging_sm_f2 = sm_ring_f2;
364 374 }
365 375
366 376 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
367 377 {
368 378 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
369 379 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
370 380 header->reserved = 0x00;
371 381 header->userApplication = CCSDS_USER_APP;
372 382 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
373 383 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
374 384 header->packetSequenceControl[0] = 0xc0;
375 385 header->packetSequenceControl[1] = 0x00;
376 386 header->packetLength[0] = 0x00;
377 387 header->packetLength[1] = 0x00;
378 388 // DATA FIELD HEADER
379 389 header->spare1_pusVersion_spare2 = 0x10;
380 390 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
381 391 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
382 392 header->destinationID = TM_DESTINATION_ID_GROUND;
383 393 // AUXILIARY DATA HEADER
384 394 header->sid = 0x00;
385 395 header->biaStatusInfo = 0x00;
386 396 header->pa_lfr_pkt_cnt_asm = 0x00;
387 397 header->pa_lfr_pkt_nr_asm = 0x00;
388 398 header->time[0] = 0x00;
389 399 header->time[0] = 0x00;
390 400 header->time[0] = 0x00;
391 401 header->time[0] = 0x00;
392 402 header->time[0] = 0x00;
393 403 header->time[0] = 0x00;
394 404 header->pa_lfr_asm_blk_nr[0] = 0x00; // BLK_NR MSB
395 405 header->pa_lfr_asm_blk_nr[1] = 0x00; // BLK_NR LSB
396 406 }
397 407
398 408 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
399 409 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
400 410 {
401 411 unsigned int i;
402 412 unsigned int length = 0;
403 413 rtems_status_code status;
404 414
405 415 for (i=0; i<2; i++)
406 416 {
407 417 // (1) BUILD THE DATA
408 418 switch(sid)
409 419 {
410 420 case SID_NORM_ASM_F0:
411 421 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F0_IN_BYTES / 2; // 2 packets will be sent
412 422 spw_ioctl_send->data = &spectral_matrix[
413 423 ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0) ) * NB_VALUES_PER_SM ) * 2
414 424 ];
415 425 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0;
416 426 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0) >> 8 ); // BLK_NR MSB
417 427 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0); // BLK_NR LSB
418 428 break;
419 429 case SID_NORM_ASM_F1:
420 430 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F1_IN_BYTES / 2; // 2 packets will be sent
421 431 spw_ioctl_send->data = &spectral_matrix[
422 432 ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1) ) * NB_VALUES_PER_SM ) * 2
423 433 ];
424 434 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1;
425 435 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1) >> 8 ); // BLK_NR MSB
426 436 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1); // BLK_NR LSB
427 437 break;
428 438 case SID_NORM_ASM_F2:
429 439 spw_ioctl_send->dlen = TOTAL_SIZE_ASM_F2_IN_BYTES / 2; // 2 packets will be sent
430 440 spw_ioctl_send->data = &spectral_matrix[
431 441 ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) * 2
432 442 ];
433 443 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
434 444 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
435 445 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
436 446 break;
437 447 default:
438 448 PRINTF1("ERR *** in ASM_send *** unexpected sid %d\n", sid)
439 449 break;
440 450 }
441 451 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
442 452 spw_ioctl_send->hdr = (char *) header;
443 453 spw_ioctl_send->options = 0;
444 454
445 455 // (2) BUILD THE HEADER
446 456 increment_seq_counter_source_id( header->packetSequenceControl, sid );
447 457 header->packetLength[0] = (unsigned char) (length>>8);
448 458 header->packetLength[1] = (unsigned char) (length);
449 459 header->sid = (unsigned char) sid; // SID
450 460 header->pa_lfr_pkt_cnt_asm = 2;
451 461 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
452 462
453 463 // (3) SET PACKET TIME
454 464 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
455 465 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
456 466 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
457 467 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
458 468 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
459 469 header->time[5] = (unsigned char) (time_management_regs->fine_time);
460 470 //
461 471 header->acquisitionTime[0] = header->time[0];
462 472 header->acquisitionTime[1] = header->time[1];
463 473 header->acquisitionTime[2] = header->time[2];
464 474 header->acquisitionTime[3] = header->time[3];
465 475 header->acquisitionTime[4] = header->time[4];
466 476 header->acquisitionTime[5] = header->time[5];
467 477
468 478 // (4) SEND PACKET
469 479 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
470 480 if (status != RTEMS_SUCCESSFUL) {
471 481 printf("in ASM_send *** ERR %d\n", (int) status);
472 482 }
473 483 }
474 484 }
475 485
476 486 //*****************
477 487 // Basic Parameters
478 488
479 489 void BP_init_header( Header_TM_LFR_SCIENCE_BP_t *header,
480 490 unsigned int apid, unsigned char sid,
481 491 unsigned int packetLength, unsigned char blkNr )
482 492 {
483 493 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
484 494 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
485 495 header->reserved = 0x00;
486 496 header->userApplication = CCSDS_USER_APP;
487 497 header->packetID[0] = (unsigned char) (apid >> 8);
488 498 header->packetID[1] = (unsigned char) (apid);
489 499 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
490 500 header->packetSequenceControl[1] = 0x00;
491 501 header->packetLength[0] = (unsigned char) (packetLength >> 8);
492 502 header->packetLength[1] = (unsigned char) (packetLength);
493 503 // DATA FIELD HEADER
494 504 header->spare1_pusVersion_spare2 = 0x10;
495 505 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
496 506 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
497 507 header->destinationID = TM_DESTINATION_ID_GROUND;
498 508 // AUXILIARY DATA HEADER
499 509 header->sid = sid;
500 510 header->biaStatusInfo = 0x00;
501 511 header->time[0] = 0x00;
502 512 header->time[0] = 0x00;
503 513 header->time[0] = 0x00;
504 514 header->time[0] = 0x00;
505 515 header->time[0] = 0x00;
506 516 header->time[0] = 0x00;
507 517 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
508 518 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
509 519 }
510 520
511 521 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
512 522 unsigned int apid, unsigned char sid,
513 523 unsigned int packetLength , unsigned char blkNr)
514 524 {
515 525 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
516 526 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
517 527 header->reserved = 0x00;
518 528 header->userApplication = CCSDS_USER_APP;
519 529 header->packetID[0] = (unsigned char) (apid >> 8);
520 530 header->packetID[1] = (unsigned char) (apid);
521 531 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
522 532 header->packetSequenceControl[1] = 0x00;
523 533 header->packetLength[0] = (unsigned char) (packetLength >> 8);
524 534 header->packetLength[1] = (unsigned char) (packetLength);
525 535 // DATA FIELD HEADER
526 536 header->spare1_pusVersion_spare2 = 0x10;
527 537 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
528 538 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
529 539 header->destinationID = TM_DESTINATION_ID_GROUND;
530 540 // AUXILIARY DATA HEADER
531 541 header->sid = sid;
532 542 header->biaStatusInfo = 0x00;
533 543 header->time[0] = 0x00;
534 544 header->time[0] = 0x00;
535 545 header->time[0] = 0x00;
536 546 header->time[0] = 0x00;
537 547 header->time[0] = 0x00;
538 548 header->time[0] = 0x00;
539 549 header->source_data_spare = 0x00;
540 550 header->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
541 551 header->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
542 552 }
543 553
544 554 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
545 555 {
546 556 rtems_status_code status;
547 557
548 558 // SET THE SEQUENCE_CNT PARAMETER
549 559 increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid );
550 560 // SEND PACKET
551 561 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
552 562 if (status != RTEMS_SUCCESSFUL)
553 563 {
554 564 printf("ERR *** in BP_send *** ERR %d\n", (int) status);
555 565 }
556 566 }
557 567
558 568 //******************
559 569 // general functions
560 570
561 571 void reset_spectral_matrix_regs( void )
562 572 {
563 573 /** This function resets the spectral matrices module registers.
564 574 *
565 575 * The registers affected by this function are located at the following offset addresses:
566 576 *
567 577 * - 0x00 config
568 578 * - 0x04 status
569 579 * - 0x08 matrixF0_Address0
570 580 * - 0x10 matrixFO_Address1
571 581 * - 0x14 matrixF1_Address
572 582 * - 0x18 matrixF2_Address
573 583 *
574 584 */
575 585
576 586 spectral_matrix_regs->config = 0x00;
577 587 spectral_matrix_regs->status = 0x00;
578 588
579 589 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
580 590 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
581 591 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
582 592 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
583 593 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
584 594 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
585 595 }
586 596
587 597 void set_time( unsigned char *time, unsigned char * timeInBuffer )
588 598 {
589 599 // time[0] = timeInBuffer[2];
590 600 // time[1] = timeInBuffer[3];
591 601 // time[2] = timeInBuffer[0];
592 602 // time[3] = timeInBuffer[1];
593 603 // time[4] = timeInBuffer[6];
594 604 // time[5] = timeInBuffer[7];
595 605
596 606 time[0] = timeInBuffer[0];
597 607 time[1] = timeInBuffer[1];
598 608 time[2] = timeInBuffer[2];
599 609 time[3] = timeInBuffer[3];
600 610 time[4] = timeInBuffer[6];
601 611 time[5] = timeInBuffer[7];
602 612 }
603 613
604 614 unsigned long long int get_acquisition_time( unsigned char *timePtr )
605 615 {
606 616 unsigned long long int acquisitionTimeAslong;
607 617 acquisitionTimeAslong = 0x00;
608 618 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
609 619 + ( (unsigned long long int) timePtr[1] << 32 )
610 620 + ( timePtr[2] << 24 )
611 621 + ( timePtr[3] << 16 )
612 622 + ( timePtr[4] << 8 )
613 623 + ( timePtr[5] );
614 624 return acquisitionTimeAslong;
615 625 }
616 626
617 627 void close_matrix_actions( unsigned int *nb_sm, unsigned int nb_sm_before_avf, rtems_id task_id,
618 628 ring_node_sm *node_for_averaging, ring_node_sm *ringNode )
619 629 {
620 630 *nb_sm = *nb_sm + 1;
621 631 if (*nb_sm == nb_sm_before_avf)
622 632 {
623 633 node_for_averaging = ringNode;
624 634 if (rtems_event_send( task_id, RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
625 635 {
626 636 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
627 637 }
628 638 *nb_sm = 0;
629 639 }
630 640 }
631 641
642 unsigned char getSID( rtems_event_set event )
643 {
644 unsigned char sid;
632 645
646 rtems_event_set eventSetBURST;
647 rtems_event_set eventSetSBM;
648
649 //******
650 // BURST
651 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
652 | RTEMS_EVENT_BURST_BP1_F1
653 | RTEMS_EVENT_BURST_BP2_F0
654 | RTEMS_EVENT_BURST_BP2_F1;
655
656 //****
657 // SBM
658 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
659 | RTEMS_EVENT_SBM_BP1_F1
660 | RTEMS_EVENT_SBM_BP2_F0
661 | RTEMS_EVENT_SBM_BP2_F1;
662
663 if (event & eventSetBURST)
664 {
665 sid = SID_BURST_BP1_F0;
666 }
667 else if (event & eventSetSBM)
668 {
669 sid = SID_SBM1_BP1_F0;
670 }
671 else
672 {
673 sid = 0;
674 }
675
676 return sid;
677 }
678
@@ -1,878 +1,881
1 1 /** Functions to load and dump parameters in the LFR registers.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 7 * TC_LFR_LOAD_COMMON_PAR\n
8 8 * TC_LFR_LOAD_NORMAL_PAR\n
9 9 * TC_LFR_LOAD_BURST_PAR\n
10 10 * TC_LFR_LOAD_SBM1_PAR\n
11 11 * TC_LFR_LOAD_SBM2_PAR\n
12 12 *
13 13 */
14 14
15 15 #include "tc_load_dump_parameters.h"
16 16
17 17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 18 {
19 19 /** This function updates the LFR registers with the incoming common parameters.
20 20 *
21 21 * @param TC points to the TeleCommand packet that is being processed
22 22 *
23 23 *
24 24 */
25 25
26 26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 28 set_wfp_data_shaping( );
29 29 return LFR_SUCCESSFUL;
30 30 }
31 31
32 32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 33 {
34 34 /** This function updates the LFR registers with the incoming normal parameters.
35 35 *
36 36 * @param TC points to the TeleCommand packet that is being processed
37 37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 38 *
39 39 */
40 40
41 41 int result;
42 42 int flag;
43 43 rtems_status_code status;
44 44 unsigned char sy_lfr_n_bp_p0;
45 45 unsigned char sy_lfr_n_bp_p1;
46 46 unsigned int sy_lfr_n_asm_p;
47 47 float aux;
48 48
49 49 flag = LFR_SUCCESSFUL;
50 50
51 51 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
52 52 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
53 53 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
54 54 flag = LFR_DEFAULT;
55 55 }
56 56
57 57 //***************
58 58 // sy_lfr_n_swf_l
59 59 if (flag == LFR_SUCCESSFUL)
60 60 {
61 61 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
62 62 if (result != LFR_SUCCESSFUL)
63 63 {
64 64 flag = LFR_DEFAULT;
65 65 }
66 66 }
67 67
68 68 //***************
69 69 // sy_lfr_n_swf_p
70 70 if (flag == LFR_SUCCESSFUL)
71 71 {
72 72 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
73 73 if (result != LFR_SUCCESSFUL)
74 74 {
75 75 flag = LFR_DEFAULT;
76 76 }
77 77 }
78 78
79 79 //****************************************************************
80 80 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
81 81 if (flag == LFR_SUCCESSFUL)
82 82 {
83 83 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
84 84 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
85 85 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
86 86 if (aux != 0)
87 87 {
88 88 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
89 89 flag = LFR_DEFAULT;
90 90 }
91 91 }
92 92
93 93 //***************
94 94 // sy_lfr_n_bp_p0
95 95 if (flag == LFR_SUCCESSFUL)
96 96 {
97 97 result = set_sy_lfr_n_bp_p0( TC, queue_id );
98 98 if (result != LFR_SUCCESSFUL)
99 99 {
100 100 flag = LFR_DEFAULT;
101 101 }
102 102 }
103 103
104 104 //****************************************************************
105 105 // check the consistency between sy_lfr_n_bp_p0 and sy_lfr_n_bp_p1
106 106 if (flag == LFR_SUCCESSFUL)
107 107 {
108 108 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
109 109 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
110 110 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
111 111 if (aux != 0)
112 112 {
113 113 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
114 114 flag = LFR_DEFAULT;
115 115 }
116 116 }
117 117
118 118 //***************
119 119 // sy_lfr_n_bp_p1
120 120 if (flag == LFR_SUCCESSFUL)
121 121 {
122 122 result = set_sy_lfr_n_bp_p1( TC, queue_id );
123 123 if (result != LFR_SUCCESSFUL)
124 124 {
125 125 flag = LFR_DEFAULT;
126 126 }
127 127 }
128 128
129 129 //****************************************************************
130 130 // check the consistency between sy_lfr_n_asm_p and sy_lfr_n_bp_p0
131 131 if (flag == LFR_SUCCESSFUL)
132 132 {
133 133 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
134 134 sy_lfr_n_asm_p =
135 135 TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ] * 256
136 136 + TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P + 1 ];
137 137 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
138 138 if (aux != 0)
139 139 {
140 140 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
141 141 flag = LFR_DEFAULT;
142 142 }
143 143 }
144 144
145 145 //***************
146 146 // sy_lfr_n_asm_p
147 147 if (flag == LFR_SUCCESSFUL)
148 148 {
149 149 result = set_sy_lfr_n_asm_p( TC, queue_id );
150 150 if (result != LFR_SUCCESSFUL)
151 151 {
152 152 flag = LFR_DEFAULT;
153 153 }
154 154 }
155 155
156 156 //*********************
157 157 // sy_lfr_n_cwf_long_f3
158 158 if (flag == LFR_SUCCESSFUL)
159 159 {
160 160 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
161 161 if (result != LFR_SUCCESSFUL)
162 162 {
163 163 flag = LFR_DEFAULT;
164 164 }
165 165 }
166 166
167 167 return flag;
168 168 }
169 169
170 170 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
171 171 {
172 172 /** This function updates the LFR registers with the incoming burst parameters.
173 173 *
174 174 * @param TC points to the TeleCommand packet that is being processed
175 175 * @param queue_id is the id of the queue which handles TM related to this execution step
176 176 *
177 177 */
178 178
179 179 int result;
180 180 int flag;
181 181 rtems_status_code status;
182 182 unsigned char sy_lfr_b_bp_p0;
183 183 unsigned char sy_lfr_b_bp_p1;
184 184 float aux;
185 185
186 186 flag = LFR_SUCCESSFUL;
187 187
188 188 if ( lfrCurrentMode == LFR_MODE_BURST ) {
189 189 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
190 190 result = LFR_DEFAULT;
191 191 }
192 192
193 193 //****************************************************************
194 194 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
195 195 if (flag == LFR_SUCCESSFUL)
196 196 {
197 197 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
198 198 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
199 199 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
200 200 if (aux != 0)
201 201 {
202 202 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
203 203 flag = LFR_DEFAULT;
204 204 }
205 205 }
206 206
207 207 //***************
208 208 // sy_lfr_b_bp_p0
209 209 if (flag == LFR_SUCCESSFUL)
210 210 {
211 211 result = set_sy_lfr_b_bp_p0( TC, queue_id );
212 212 if (result != LFR_SUCCESSFUL)
213 213 {
214 214 flag = LFR_DEFAULT;
215 215 }
216 216 }
217 217
218 218 //***************
219 219 // sy_lfr_b_bp_p1
220 220 if (flag == LFR_SUCCESSFUL)
221 221 {
222 222 result = set_sy_lfr_b_bp_p1( TC, queue_id );
223 223 if (result != LFR_SUCCESSFUL)
224 224 {
225 225 flag = LFR_DEFAULT;
226 226 }
227 227 }
228 228
229 229 return flag;
230 230 }
231 231
232 232 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
233 233 {
234 234 /** This function updates the LFR registers with the incoming sbm1 parameters.
235 235 *
236 236 * @param TC points to the TeleCommand packet that is being processed
237 237 * @param queue_id is the id of the queue which handles TM related to this execution step
238 238 *
239 239 */
240 240
241 241 int result;
242 242 int flag;
243 243 rtems_status_code status;
244 244 unsigned char sy_lfr_s1_bp_p0;
245 245 unsigned char sy_lfr_s1_bp_p1;
246 246 float aux;
247 247
248 248 flag = LFR_SUCCESSFUL;
249 249
250 250 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
251 251 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
252 252 result = LFR_DEFAULT;
253 253 }
254 254
255 255 //******************************************************************
256 256 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
257 257 if (flag == LFR_SUCCESSFUL)
258 258 {
259 259 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
260 260 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
261 261 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
262 262 if (aux != 0)
263 263 {
264 264 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
265 265 flag = LFR_DEFAULT;
266 266 }
267 267 }
268 268
269 269 //***************
270 270 // sy_lfr_s1_bp_p0
271 271 if (flag == LFR_SUCCESSFUL)
272 272 {
273 273 result = set_sy_lfr_s1_bp_p0( TC, queue_id );
274 274 if (result != LFR_SUCCESSFUL)
275 275 {
276 276 flag = LFR_DEFAULT;
277 277 }
278 278 }
279 279
280 280 //***************
281 281 // sy_lfr_s1_bp_p1
282 282 if (flag == LFR_SUCCESSFUL)
283 283 {
284 284 result = set_sy_lfr_s1_bp_p1( TC, queue_id );
285 285 if (result != LFR_SUCCESSFUL)
286 286 {
287 287 flag = LFR_DEFAULT;
288 288 }
289 289 }
290 290
291 291 return flag;
292 292 }
293 293
294 294 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
295 295 {
296 296 /** This function updates the LFR registers with the incoming sbm2 parameters.
297 297 *
298 298 * @param TC points to the TeleCommand packet that is being processed
299 299 * @param queue_id is the id of the queue which handles TM related to this execution step
300 300 *
301 301 */
302 302
303 303 int result;
304 304 int flag;
305 305 rtems_status_code status;
306 306 unsigned char sy_lfr_s2_bp_p0;
307 307 unsigned char sy_lfr_s2_bp_p1;
308 308 float aux;
309 309
310 310 flag = LFR_SUCCESSFUL;
311 311
312 312 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
313 313 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
314 314 result = LFR_DEFAULT;
315 315 }
316 316
317 317 //******************************************************************
318 318 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
319 319 if (flag == LFR_SUCCESSFUL)
320 320 {
321 321 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
322 322 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
323 323 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
324 324 if (aux != 0)
325 325 {
326 326 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
327 327 flag = LFR_DEFAULT;
328 328 }
329 329 }
330 330
331 331 //***************
332 332 // sy_lfr_s2_bp_p0
333 333 if (flag == LFR_SUCCESSFUL)
334 334 {
335 335 result = set_sy_lfr_s2_bp_p0( TC, queue_id );
336 336 if (result != LFR_SUCCESSFUL)
337 337 {
338 338 flag = LFR_DEFAULT;
339 339 }
340 340 }
341 341
342 342 //***************
343 343 // sy_lfr_s2_bp_p1
344 344 if (flag == LFR_SUCCESSFUL)
345 345 {
346 346 result = set_sy_lfr_s2_bp_p1( TC, queue_id );
347 347 if (result != LFR_SUCCESSFUL)
348 348 {
349 349 flag = LFR_DEFAULT;
350 350 }
351 351 }
352 352
353 353 return flag;
354 354 }
355 355
356 356 int action_dump_par( rtems_id queue_id )
357 357 {
358 358 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
359 359 *
360 360 * @param queue_id is the id of the queue which handles TM related to this execution step.
361 361 *
362 362 * @return RTEMS directive status codes:
363 363 * - RTEMS_SUCCESSFUL - message sent successfully
364 364 * - RTEMS_INVALID_ID - invalid queue id
365 365 * - RTEMS_INVALID_SIZE - invalid message size
366 366 * - RTEMS_INVALID_ADDRESS - buffer is NULL
367 367 * - RTEMS_UNSATISFIED - out of message buffers
368 368 * - RTEMS_TOO_MANY - queue s limit has been reached
369 369 *
370 370 */
371 371
372 372 int status;
373 373
374 374 // UPDATE TIME
375 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
375 parameter_dump_packet.packetSequenceControl[0] = (unsigned char) sequenceCounterParameterDump >> 8;
376 parameter_dump_packet.packetSequenceControl[1] = (unsigned char) sequenceCounterParameterDump;
377 increment_seq_counter( &sequenceCounterParameterDump );
378
376 379 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
377 380 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
378 381 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
379 382 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
380 383 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
381 384 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
382 385 // SEND DATA
383 386 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
384 387 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
385 388 if (status != RTEMS_SUCCESSFUL) {
386 389 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
387 390 }
388 391
389 392 return status;
390 393 }
391 394
392 395 //***********************
393 396 // NORMAL MODE PARAMETERS
394 397
395 398 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
396 399 {
397 400 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
398 401 *
399 402 * @param TC points to the TeleCommand packet that is being processed
400 403 * @param queue_id is the id of the queue which handles TM related to this execution step
401 404 *
402 405 */
403 406
404 407 unsigned int tmp;
405 408 int result;
406 409 unsigned char msb;
407 410 unsigned char lsb;
408 411 rtems_status_code status;
409 412
410 413 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
411 414 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
412 415
413 416 tmp = ( unsigned int ) floor(
414 417 ( ( msb*256 ) + lsb ) / 16
415 418 ) * 16;
416 419
417 420 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
418 421 { // 2048 is the maximum limit due to the size of the buffers
419 422 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, lsb );
420 423 result = WRONG_APP_DATA;
421 424 }
422 425 else if (tmp != 2048)
423 426 {
424 427 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
425 428 result = FUNCT_NOT_IMPL;
426 429 }
427 430 else
428 431 {
429 432 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
430 433 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
431 434 result = LFR_SUCCESSFUL;
432 435 }
433 436
434 437 return result;
435 438 }
436 439
437 440 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
438 441 {
439 442 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
440 443 *
441 444 * @param TC points to the TeleCommand packet that is being processed
442 445 * @param queue_id is the id of the queue which handles TM related to this execution step
443 446 *
444 447 */
445 448
446 449 unsigned int tmp;
447 450 int result;
448 451 unsigned char msb;
449 452 unsigned char lsb;
450 453 rtems_status_code status;
451 454
452 455 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
453 456 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
454 457
455 458 tmp = msb * 256 + lsb;
456 459
457 460 if ( tmp < 16 )
458 461 {
459 462 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, lsb );
460 463 result = WRONG_APP_DATA;
461 464 }
462 465 else
463 466 {
464 467 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
465 468 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
466 469 result = LFR_SUCCESSFUL;
467 470 }
468 471
469 472 return result;
470 473 }
471 474
472 475 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
473 476 {
474 477 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
475 478 *
476 479 * @param TC points to the TeleCommand packet that is being processed
477 480 * @param queue_id is the id of the queue which handles TM related to this execution step
478 481 *
479 482 */
480 483
481 484 int result;
482 485 unsigned char msb;
483 486 unsigned char lsb;
484 487
485 488 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
486 489 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
487 490
488 491 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
489 492 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
490 493 result = LFR_SUCCESSFUL;
491 494
492 495 return result;
493 496 }
494 497
495 498 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
496 499 {
497 500 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
498 501 *
499 502 * @param TC points to the TeleCommand packet that is being processed
500 503 * @param queue_id is the id of the queue which handles TM related to this execution step
501 504 *
502 505 */
503 506
504 507 int status;
505 508 unsigned char val;
506 509
507 510 status = LFR_SUCCESSFUL;
508 511
509 512 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
510 513
511 514 if (val < SY_LFR_N_BP_P0)
512 515 {
513 516 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, val );
514 517 status = WRONG_APP_DATA;
515 518 }
516 519 else
517 520 {
518 521 parameter_dump_packet.sy_lfr_n_bp_p0 = val;
519 522 }
520 523
521 524 return status;
522 525 }
523 526
524 527 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
525 528 {
526 529 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
527 530 *
528 531 * @param TC points to the TeleCommand packet that is being processed
529 532 * @param queue_id is the id of the queue which handles TM related to this execution step
530 533 *
531 534 */
532 535
533 536 int status;
534 537 unsigned char val;
535 538
536 539 status = LFR_SUCCESSFUL;
537 540
538 541 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
539 542
540 543 if (val < SY_LFR_N_BP_P1)
541 544 {
542 545 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, val );
543 546 status = WRONG_APP_DATA;
544 547 }
545 548 else
546 549 {
547 550 parameter_dump_packet.sy_lfr_n_bp_p1 = val;
548 551 }
549 552
550 553 return status;
551 554 }
552 555
553 556 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
554 557 {
555 558 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
556 559 *
557 560 * @param TC points to the TeleCommand packet that is being processed
558 561 * @param queue_id is the id of the queue which handles TM related to this execution step
559 562 *
560 563 */
561 564
562 565 int status;
563 566
564 567 status = LFR_SUCCESSFUL;
565 568
566 569 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
567 570
568 571 return status;
569 572 }
570 573
571 574 //**********************
572 575 // BURST MODE PARAMETERS
573 576 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
574 577 {
575 578 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
576 579 *
577 580 * @param TC points to the TeleCommand packet that is being processed
578 581 * @param queue_id is the id of the queue which handles TM related to this execution step
579 582 *
580 583 */
581 584
582 585 int status;
583 586 unsigned char val;
584 587
585 588 status = LFR_SUCCESSFUL;
586 589
587 590 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
588 591
589 592 if (val < DEFAULT_SY_LFR_B_BP_P0 )
590 593 {
591 594 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, val );
592 595 status = WRONG_APP_DATA;
593 596 }
594 597 else
595 598 {
596 599 parameter_dump_packet.sy_lfr_b_bp_p0 = val;
597 600 }
598 601
599 602 return status;
600 603 }
601 604
602 605 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
603 606 {
604 607 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
605 608 *
606 609 * @param TC points to the TeleCommand packet that is being processed
607 610 * @param queue_id is the id of the queue which handles TM related to this execution step
608 611 *
609 612 */
610 613
611 614 int status;
612 615 unsigned char val;
613 616
614 617 status = LFR_SUCCESSFUL;
615 618
616 619 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
617 620
618 621 if (val < DEFAULT_SY_LFR_B_BP_P1 )
619 622 {
620 623 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, val );
621 624 status = WRONG_APP_DATA;
622 625 }
623 626 else
624 627 {
625 628 parameter_dump_packet.sy_lfr_b_bp_p1 = val;
626 629 }
627 630
628 631 return status;
629 632 }
630 633
631 634 //*********************
632 635 // SBM1 MODE PARAMETERS
633 636 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
634 637 {
635 638 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
636 639 *
637 640 * @param TC points to the TeleCommand packet that is being processed
638 641 * @param queue_id is the id of the queue which handles TM related to this execution step
639 642 *
640 643 */
641 644
642 645 int status;
643 646 unsigned char val;
644 647
645 648 status = LFR_SUCCESSFUL;
646 649
647 650 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
648 651
649 652 if (val < DEFAULT_SY_LFR_S1_BP_P0 )
650 653 {
651 654 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, val );
652 655 status = WRONG_APP_DATA;
653 656 }
654 657 else
655 658 {
656 659 parameter_dump_packet.sy_lfr_s1_bp_p0 = val;
657 660 }
658 661
659 662 return status;
660 663 }
661 664
662 665 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
663 666 {
664 667 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
665 668 *
666 669 * @param TC points to the TeleCommand packet that is being processed
667 670 * @param queue_id is the id of the queue which handles TM related to this execution step
668 671 *
669 672 */
670 673
671 674 int status;
672 675 unsigned char val;
673 676
674 677 status = LFR_SUCCESSFUL;
675 678
676 679 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
677 680
678 681 if (val < DEFAULT_SY_LFR_S1_BP_P1 )
679 682 {
680 683 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, val );
681 684 status = WRONG_APP_DATA;
682 685 }
683 686 else
684 687 {
685 688 parameter_dump_packet.sy_lfr_s1_bp_p1 = val;
686 689 }
687 690
688 691 return status;
689 692 }
690 693
691 694 //*********************
692 695 // SBM2 MODE PARAMETERS
693 696 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
694 697 {
695 698 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
696 699 *
697 700 * @param TC points to the TeleCommand packet that is being processed
698 701 * @param queue_id is the id of the queue which handles TM related to this execution step
699 702 *
700 703 */
701 704
702 705 int status;
703 706 unsigned char val;
704 707
705 708 status = LFR_SUCCESSFUL;
706 709
707 710 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
708 711
709 712 if (val < DEFAULT_SY_LFR_S2_BP_P0 )
710 713 {
711 714 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, val );
712 715 status = WRONG_APP_DATA;
713 716 }
714 717 else
715 718 {
716 719 parameter_dump_packet.sy_lfr_s2_bp_p0 = val;
717 720 }
718 721
719 722 return status;
720 723 }
721 724
722 725 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
723 726 {
724 727 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
725 728 *
726 729 * @param TC points to the TeleCommand packet that is being processed
727 730 * @param queue_id is the id of the queue which handles TM related to this execution step
728 731 *
729 732 */
730 733
731 734 int status;
732 735 unsigned char val;
733 736
734 737 status = LFR_SUCCESSFUL;
735 738
736 739 val = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
737 740
738 741 if (val < DEFAULT_SY_LFR_S2_BP_P1 )
739 742 {
740 743 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, val );
741 744 status = WRONG_APP_DATA;
742 745 }
743 746 else
744 747 {
745 748 parameter_dump_packet.sy_lfr_s2_bp_p1 = val;
746 749 }
747 750
748 751 return status;
749 752 }
750 753
751 754
752 755 //*******************
753 756 // TC_LFR_UPDATE_INFO
754 757 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
755 758 {
756 759 unsigned int status;
757 760
758 761 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
759 762 || (mode == LFR_MODE_BURST)
760 763 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
761 764 {
762 765 status = LFR_SUCCESSFUL;
763 766 }
764 767 else
765 768 {
766 769 status = LFR_DEFAULT;
767 770 }
768 771
769 772 return status;
770 773 }
771 774
772 775 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
773 776 {
774 777 unsigned int status;
775 778
776 779 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
777 780 || (mode == TDS_MODE_BURST)
778 781 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
779 782 || (mode == TDS_MODE_LFM))
780 783 {
781 784 status = LFR_SUCCESSFUL;
782 785 }
783 786 else
784 787 {
785 788 status = LFR_DEFAULT;
786 789 }
787 790
788 791 return status;
789 792 }
790 793
791 794 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
792 795 {
793 796 unsigned int status;
794 797
795 798 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
796 799 || (mode == THR_MODE_BURST))
797 800 {
798 801 status = LFR_SUCCESSFUL;
799 802 }
800 803 else
801 804 {
802 805 status = LFR_DEFAULT;
803 806 }
804 807
805 808 return status;
806 809 }
807 810
808 811 //**********
809 812 // init dump
810 813
811 814 void init_parameter_dump( void )
812 815 {
813 816 /** This function initialize the parameter_dump_packet global variable with default values.
814 817 *
815 818 */
816 819
817 820 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
818 821 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
819 822 parameter_dump_packet.reserved = CCSDS_RESERVED;
820 823 parameter_dump_packet.userApplication = CCSDS_USER_APP;
821 824 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
822 825 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
823 826 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
824 827 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
825 828 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
826 829 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
827 830 // DATA FIELD HEADER
828 831 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
829 832 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
830 833 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
831 834 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
832 835 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
833 836 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
834 837 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
835 838 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
836 839 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
837 840 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
838 841 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
839 842
840 843 //******************
841 844 // COMMON PARAMETERS
842 845 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
843 846 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
844 847
845 848 //******************
846 849 // NORMAL PARAMETERS
847 850 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
848 851 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
849 852 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
850 853 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
851 854 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
852 855 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
853 856 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
854 857 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
855 858 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3;
856 859
857 860 //*****************
858 861 // BURST PARAMETERS
859 862 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
860 863 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
861 864
862 865 //****************
863 866 // SBM1 PARAMETERS
864 867 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
865 868 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
866 869
867 870 //****************
868 871 // SBM2 PARAMETERS
869 872 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
870 873 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
871 874 }
872 875
873 876
874 877
875 878
876 879
877 880
878 881
General Comments 0
You need to be logged in to leave comments. Login now