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