##// END OF EJS Templates
fsw-1-0...
paul -
r82:4237b1096e59 VHDLib206
parent child
Show More
@@ -1,248 +1,248
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Nov 15 17:09:56 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Nov 19 10:04:58 2013
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=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=1 -DSW_VERSION_N4=0 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=0 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
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_processing.c \
49 49 ../src/fsw_misc.c \
50 50 ../src/fsw_init.c \
51 51 ../src/fsw_globals.c \
52 52 ../src/fsw_spacewire.c \
53 53 ../src/tc_load_dump_parameters.c \
54 54 ../src/tm_lfr_tc_exe.c \
55 55 ../src/tc_acceptance.c
56 56 OBJECTS = obj/wf_handler.o \
57 57 obj/tc_handler.o \
58 58 obj/fsw_processing.o \
59 59 obj/fsw_misc.o \
60 60 obj/fsw_init.o \
61 61 obj/fsw_globals.o \
62 62 obj/fsw_spacewire.o \
63 63 obj/tc_load_dump_parameters.o \
64 64 obj/tm_lfr_tc_exe.o \
65 65 obj/tc_acceptance.o
66 66 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
67 67 /usr/lib64/qt4/mkspecs/common/linux.conf \
68 68 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
69 69 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
70 70 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
71 71 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
72 72 /usr/lib64/qt4/mkspecs/qconfig.pri \
73 73 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
74 74 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
75 75 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
76 76 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
77 77 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
78 78 sparc.pri \
79 79 /usr/lib64/qt4/mkspecs/features/release.prf \
80 80 /usr/lib64/qt4/mkspecs/features/default_post.prf \
81 81 /usr/lib64/qt4/mkspecs/features/shared.prf \
82 82 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
83 83 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
84 84 /usr/lib64/qt4/mkspecs/features/resources.prf \
85 85 /usr/lib64/qt4/mkspecs/features/uic.prf \
86 86 /usr/lib64/qt4/mkspecs/features/yacc.prf \
87 87 /usr/lib64/qt4/mkspecs/features/lex.prf \
88 88 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
89 89 fsw-qt.pro
90 90 QMAKE_TARGET = fsw
91 91 DESTDIR = bin/
92 92 TARGET = bin/fsw
93 93
94 94 first: all
95 95 ####### Implicit rules
96 96
97 97 .SUFFIXES: .o .c .cpp .cc .cxx .C
98 98
99 99 .cpp.o:
100 100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101 101
102 102 .cc.o:
103 103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
104 104
105 105 .cxx.o:
106 106 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
107 107
108 108 .C.o:
109 109 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
110 110
111 111 .c.o:
112 112 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
113 113
114 114 ####### Build rules
115 115
116 116 all: Makefile $(TARGET)
117 117
118 118 $(TARGET): $(OBJECTS)
119 119 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
120 120 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
121 121
122 122 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
123 123 /usr/lib64/qt4/mkspecs/common/linux.conf \
124 124 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
125 125 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
126 126 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
127 127 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
128 128 /usr/lib64/qt4/mkspecs/qconfig.pri \
129 129 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
130 130 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
131 131 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
132 132 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
133 133 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
134 134 sparc.pri \
135 135 /usr/lib64/qt4/mkspecs/features/release.prf \
136 136 /usr/lib64/qt4/mkspecs/features/default_post.prf \
137 137 /usr/lib64/qt4/mkspecs/features/shared.prf \
138 138 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
139 139 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
140 140 /usr/lib64/qt4/mkspecs/features/resources.prf \
141 141 /usr/lib64/qt4/mkspecs/features/uic.prf \
142 142 /usr/lib64/qt4/mkspecs/features/yacc.prf \
143 143 /usr/lib64/qt4/mkspecs/features/lex.prf \
144 144 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
145 145 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
146 146 /usr/lib64/qt4/mkspecs/common/unix.conf:
147 147 /usr/lib64/qt4/mkspecs/common/linux.conf:
148 148 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
149 149 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
150 150 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
151 151 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
152 152 /usr/lib64/qt4/mkspecs/qconfig.pri:
153 153 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
154 154 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
155 155 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
156 156 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
157 157 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
158 158 sparc.pri:
159 159 /usr/lib64/qt4/mkspecs/features/release.prf:
160 160 /usr/lib64/qt4/mkspecs/features/default_post.prf:
161 161 /usr/lib64/qt4/mkspecs/features/shared.prf:
162 162 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
163 163 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
164 164 /usr/lib64/qt4/mkspecs/features/resources.prf:
165 165 /usr/lib64/qt4/mkspecs/features/uic.prf:
166 166 /usr/lib64/qt4/mkspecs/features/yacc.prf:
167 167 /usr/lib64/qt4/mkspecs/features/lex.prf:
168 168 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
169 169 qmake: FORCE
170 170 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
171 171
172 172 dist:
173 173 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
174 174 $(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
175 175
176 176
177 177 clean:compiler_clean
178 178 -$(DEL_FILE) $(OBJECTS)
179 179 -$(DEL_FILE) *~ core *.core
180 180
181 181
182 182 ####### Sub-libraries
183 183
184 184 distclean: clean
185 185 -$(DEL_FILE) $(TARGET)
186 186 -$(DEL_FILE) Makefile
187 187
188 188
189 189 grmon:
190 190 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
191 191
192 192 check: first
193 193
194 194 compiler_rcc_make_all:
195 195 compiler_rcc_clean:
196 196 compiler_uic_make_all:
197 197 compiler_uic_clean:
198 198 compiler_image_collection_make_all: qmake_image_collection.cpp
199 199 compiler_image_collection_clean:
200 200 -$(DEL_FILE) qmake_image_collection.cpp
201 201 compiler_yacc_decl_make_all:
202 202 compiler_yacc_decl_clean:
203 203 compiler_yacc_impl_make_all:
204 204 compiler_yacc_impl_clean:
205 205 compiler_lex_make_all:
206 206 compiler_lex_clean:
207 207 compiler_clean:
208 208
209 209 ####### Compile
210 210
211 211 obj/wf_handler.o: ../src/wf_handler.c
212 212 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
213 213
214 214 obj/tc_handler.o: ../src/tc_handler.c
215 215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
216 216
217 217 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
218 218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
219 219
220 220 obj/fsw_misc.o: ../src/fsw_misc.c
221 221 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
222 222
223 223 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
224 224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
225 225
226 226 obj/fsw_globals.o: ../src/fsw_globals.c
227 227 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
228 228
229 229 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
230 230 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
231 231
232 232 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
233 233 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
234 234
235 235 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
236 236 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
237 237
238 238 obj/tc_acceptance.o: ../src/tc_acceptance.c
239 239 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
240 240
241 241 ####### Install
242 242
243 243 install: FORCE
244 244
245 245 uninstall: FORCE
246 246
247 247 FORCE:
248 248
@@ -1,20 +1,20
1 1 SREC_PREFIX = RpwLfrApp
2 SREC_COUNTER = 0001
3 SREC_FSW_REF = fsw-0-7
2 SREC_COUNTER = 0002
3 SREC_FSW_REF = fsw-1-0
4 4 SREC_SUFFIX = .srec
5 5 SREC_TEXT = $(SREC_PREFIX)_$(SREC_COUNTER)_text_$(SREC_FSW_REF)$(SREC_SUFFIX)
6 6 SREC_DATA = $(SREC_PREFIX)_$(SREC_COUNTER)_data_$(SREC_FSW_REF)$(SREC_SUFFIX)
7 7 OBJCOPY = sparc-rtems-objcopy
8 8 OBJCOPY_OPT = -g -v
9 9
10 10 all: text data
11 11
12 12 text: fsw
13 13 $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_TEXT) -O srec -j .text
14 14
15 15 data: fsw
16 16 $(OBJCOPY) $(OBJCOPY_OPT) fsw $(SREC_DATA) -O srec -j .data
17 17
18 18 clean:
19 19 rm *.srec
20 20
@@ -1,79 +1,79
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
4 4 CONFIG += console verbose
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-1-0
11 DEFINES += SW_VERSION_N1=0
12 DEFINES += SW_VERSION_N2=0
13 DEFINES += SW_VERSION_N3=1
14 DEFINES += SW_VERSION_N4=0
11 DEFINES += SW_VERSION_N1=1 # major
12 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N4=0 # internal
15 15
16 16 contains( CONFIG, verbose ) {
17 17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 18 }
19 19
20 20 contains( CONFIG, debug_messages ) {
21 21 DEFINES += DEBUG_MESSAGES
22 22 }
23 23
24 24 contains( CONFIG, cpu_usage_report ) {
25 25 DEFINES += PRINT_TASK_STATISTICS
26 26 }
27 27
28 28 contains( CONFIG, stack_report ) {
29 29 DEFINES += PRINT_STACK_REPORT
30 30 }
31 31
32 32 contains( CONFIG, boot_messages ) {
33 33 DEFINES += BOOT_MESSAGES
34 34 }
35 35
36 36 #doxygen.target = doxygen
37 37 #doxygen.commands = doxygen ../doc/Doxyfile
38 38 #QMAKE_EXTRA_TARGETS += doxygen
39 39
40 40 TARGET = fsw
41 41 contains( CONFIG, gsa ) {
42 42 DEFINES += GSA
43 43 TARGET = fsw-gsa
44 44 }
45 45
46 46 INCLUDEPATH += \
47 47 ../src \
48 48 ../header
49 49
50 50 SOURCES += \
51 51 ../src/wf_handler.c \
52 52 ../src/tc_handler.c \
53 53 ../src/fsw_processing.c \
54 54 ../src/fsw_misc.c \
55 55 ../src/fsw_init.c \
56 56 ../src/fsw_globals.c \
57 57 ../src/fsw_spacewire.c \
58 58 ../src/tc_load_dump_parameters.c \
59 59 ../src/tm_lfr_tc_exe.c \
60 60 ../src/tc_acceptance.c
61 61
62 62
63 63 HEADERS += \
64 64 ../header/wf_handler.h \
65 65 ../header/tc_handler.h \
66 66 ../header/grlib_regs.h \
67 67 ../header/fsw_processing.h \
68 68 ../header/fsw_params.h \
69 69 ../header/fsw_misc.h \
70 70 ../header/fsw_init.h \
71 71 ../header/ccsds_types.h \
72 72 ../header/fsw_params_processing.h \
73 73 ../header/fsw_spacewire.h \
74 74 ../header/tm_byte_positions.h \
75 75 ../header/tc_load_dump_parameters.h \
76 76 ../header/tm_lfr_tc_exe.h \
77 77 ../header/tc_acceptance.h \
78 78 ../header/fsw_params_nb_bytes.h
79 79
@@ -1,439 +1,439
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.1, 2013-11-15T17:08:10. -->
3 <!-- Written by QtCreator 2.8.1, 2013-11-19T10:04:48. -->
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="QString" 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="QString" 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 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
63 63 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
64 64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
67 67 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
69 69 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
70 70 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
71 71 </valuemap>
72 72 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
73 73 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
74 74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
77 77 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
78 78 <value type="QString">-w</value>
79 79 <value type="QString">-r</value>
80 80 </valuelist>
81 81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 84 </valuemap>
85 85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
86 86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
89 89 </valuemap>
90 90 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
92 92 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
93 93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
96 96 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
97 97 <value type="QString">-w</value>
98 98 <value type="QString">-r</value>
99 99 </valuelist>
100 100 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
101 101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
103 103 </valuemap>
104 104 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
105 105 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
108 108 </valuemap>
109 109 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
110 110 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
111 111 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
112 112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
115 115 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
116 116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 118 </valuemap>
119 119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
122 122 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
126 126 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
127 127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
128 128 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
129 129 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
130 130 </valuemap>
131 131 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
132 132 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
133 133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
134 134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
136 136 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
137 137 <value type="QString">-w</value>
138 138 <value type="QString">-r</value>
139 139 </valuelist>
140 140 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
141 141 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
142 142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
143 143 </valuemap>
144 144 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
145 145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
146 146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
147 147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
148 148 </valuemap>
149 149 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
150 150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
151 151 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
152 152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
153 153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
154 154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
155 155 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
156 156 <value type="QString">-w</value>
157 157 <value type="QString">-r</value>
158 158 </valuelist>
159 159 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
160 160 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
161 161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
162 162 </valuemap>
163 163 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
164 164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
165 165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
166 166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
167 167 </valuemap>
168 168 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
169 169 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
170 170 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release2</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
174 174 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
177 177 </valuemap>
178 178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
179 179 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180 180 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181 181 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182 182 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183 183 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184 184 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187 187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
188 188 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
189 189 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
190 190 </valuemap>
191 191 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
192 192 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
193 193 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
194 194 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
195 195 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
196 196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
197 197 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
198 198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
199 199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
200 200 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
201 201 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
202 202 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
203 203 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
204 204 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205 205 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206 206 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
207 207 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
208 208 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
209 209 <value type="int">0</value>
210 210 <value type="int">1</value>
211 211 <value type="int">2</value>
212 212 <value type="int">3</value>
213 213 <value type="int">4</value>
214 214 <value type="int">5</value>
215 215 <value type="int">6</value>
216 216 <value type="int">7</value>
217 217 <value type="int">8</value>
218 218 <value type="int">9</value>
219 219 <value type="int">10</value>
220 220 <value type="int">11</value>
221 221 <value type="int">12</value>
222 222 <value type="int">13</value>
223 223 <value type="int">14</value>
224 224 </valuelist>
225 225 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
226 226 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
227 227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
228 228 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
229 229 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
230 230 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
231 231 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
232 232 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
233 233 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
234 234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
235 235 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
236 236 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
237 237 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
238 238 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
239 239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240 240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
241 241 </valuemap>
242 242 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
243 243 </valuemap>
244 244 </data>
245 245 <data>
246 246 <variable>ProjectExplorer.Project.Target.1</variable>
247 247 <valuemap type="QVariantMap">
248 248 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop2</value>
249 249 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop2</value>
250 250 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e96c4de1-323d-4095-8746-d006ca3bd573}</value>
251 251 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
252 252 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
253 253 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
254 254 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
255 255 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
256 256 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
257 257 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
258 258 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
259 259 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
260 260 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
261 261 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
262 262 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
263 263 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
264 264 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
265 265 </valuemap>
266 266 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
267 267 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
268 268 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
269 269 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
270 270 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
271 271 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
272 272 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
273 273 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
274 274 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
275 275 </valuemap>
276 276 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
277 277 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
278 278 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
279 279 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
280 280 </valuemap>
281 281 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
282 282 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
283 283 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
284 284 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
285 285 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
286 286 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
287 287 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
288 288 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
289 289 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
290 290 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
291 291 </valuemap>
292 292 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
293 293 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
294 294 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
295 295 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
296 296 </valuemap>
297 297 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
298 298 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
299 299 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
300 300 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
301 301 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
302 302 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
303 303 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
304 304 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
305 305 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
306 306 </valuemap>
307 307 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
308 308 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
309 309 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
310 310 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
311 311 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
312 312 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
313 313 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
314 314 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
315 315 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
316 316 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
317 317 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
318 318 </valuemap>
319 319 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
320 320 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
321 321 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
322 322 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
323 323 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
324 324 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
325 325 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
326 326 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
327 327 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
328 328 </valuemap>
329 329 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
330 330 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
331 331 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
332 332 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
333 333 </valuemap>
334 334 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
335 335 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
336 336 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
337 337 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
338 338 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
339 339 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
340 340 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
341 341 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
342 342 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
343 343 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
344 344 </valuemap>
345 345 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
346 346 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
347 347 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
348 348 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
349 349 </valuemap>
350 350 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
351 351 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
352 352 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
353 353 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release2</value>
354 354 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
355 355 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
356 356 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
357 357 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
358 358 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
359 359 </valuemap>
360 360 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
361 361 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
362 362 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
363 363 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
364 364 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
365 365 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
366 366 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
367 367 </valuemap>
368 368 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
369 369 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
370 370 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
371 371 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
372 372 </valuemap>
373 373 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
374 374 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
375 375 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
376 376 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
377 377 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
378 378 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
379 379 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
380 380 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
381 381 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
382 382 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
383 383 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
384 384 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
385 385 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
386 386 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
387 387 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
388 388 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
389 389 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
390 390 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
391 391 <value type="int">0</value>
392 392 <value type="int">1</value>
393 393 <value type="int">2</value>
394 394 <value type="int">3</value>
395 395 <value type="int">4</value>
396 396 <value type="int">5</value>
397 397 <value type="int">6</value>
398 398 <value type="int">7</value>
399 399 <value type="int">8</value>
400 400 <value type="int">9</value>
401 401 <value type="int">10</value>
402 402 <value type="int">11</value>
403 403 <value type="int">12</value>
404 404 <value type="int">13</value>
405 405 <value type="int">14</value>
406 406 </valuelist>
407 <value type="int" key="PE.EnvironmentAspect.Base">-1</value>
407 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
408 408 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
409 409 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
410 410 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
411 411 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
412 412 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
413 413 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
414 414 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
415 415 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
416 416 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
417 417 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
418 418 <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
419 419 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
420 420 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
421 421 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
422 422 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
423 423 </valuemap>
424 424 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
425 425 </valuemap>
426 426 </data>
427 427 <data>
428 428 <variable>ProjectExplorer.Project.TargetCount</variable>
429 429 <value type="int">2</value>
430 430 </data>
431 431 <data>
432 432 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
433 433 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
434 434 </data>
435 435 <data>
436 436 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
437 437 <value type="int">14</value>
438 438 </data>
439 439 </qtcreator>
@@ -1,35 +1,40
1 1 #ifndef FSW_INIT_H_INCLUDED
2 2 #define FSW_INIT_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "fsw_misc.h"
9 9 #include "fsw_processing.h"
10 10 #include "tc_handler.h"
11 11 #include "wf_handler.h"
12 12
13 13 #include "fsw_spacewire.h"
14 14
15 extern rtems_name Task_name[20]; /* array of task names */
16 extern rtems_id Task_id[20]; /* array of task ids */
17
15 18 // RTEMS TASKS
16 19 rtems_task Init( rtems_task_argument argument);
17 20
18 21 // OTHER functions
19 22 void create_names( void );
20 23 int create_all_tasks( void );
21 24 int start_all_tasks( void );
22 25 //
23 26 rtems_status_code create_message_queues( void );
27 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
28 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
24 29 //
25 30 int start_recv_send_tasks( void );
26 31 //
27 32 void init_local_mode_parameters( void );
28 33
29 34 extern int rtems_cpu_usage_report( void );
30 35 extern int rtems_cpu_usage_reset( void );
31 36 extern void rtems_stack_checker_report_usage( void );
32 37
33 38 extern int sched_yield( void );
34 39
35 40 #endif // FSW_INIT_H_INCLUDED
@@ -1,54 +1,57
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "tc_load_dump_parameters.h"
8 8 #include "tc_acceptance.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "wf_handler.h"
11 11
12 12 // MODE PARAMETERS
13 13 extern unsigned int maxCount;
14 14
15 15 //****
16 16 // ISR
17 17 rtems_isr commutation_isr1( rtems_vector_number vector );
18 18 rtems_isr commutation_isr2( rtems_vector_number vector );
19 19
20 20 //***********
21 21 // RTEMS TASK
22 22 rtems_task actn_task( rtems_task_argument unused );
23 23
24 24 //***********
25 25 // TC ACTIONS
26 26 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
27 27 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
28 28 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
29 29 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
30 30 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 31 int action_update_time(ccsdsTelecommandPacket_t *TC);
32 32
33 33 // mode transition
34 34 int transition_validation(unsigned char requestedMode);
35 35 int stop_current_mode();
36 36 int enter_mode(unsigned char mode);
37 37 int enter_standby_mode();
38 38 int enter_normal_mode();
39 39 int enter_burst_mode();
40 40 int enter_sbm1_mode();
41 41 int enter_sbm2_mode();
42 42 int restart_science_tasks();
43 43 int suspend_science_tasks();
44 44
45 45 // other functions
46 46 void updateLFRCurrentMode();
47 47 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time);
48 48 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time);
49 49 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time);
50 50
51 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
52 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
53
51 54 #endif // TC_HANDLER_H_INCLUDED
52 55
53 56
54 57
@@ -1,87 +1,85
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8
9 9 #include "fsw_params.h"
10 10 #include "fsw_spacewire.h"
11 11 #include "fsw_misc.h"
12 12
13 13 #define pi 3.1415
14 14
15 15 extern int fdSPW;
16 16 extern volatile int wf_snap_f0[ ];
17 17 //
18 18 extern volatile int wf_snap_f1[ ];
19 19 extern volatile int wf_snap_f1_bis[ ];
20 20 extern volatile int wf_snap_f1_norm[ ];
21 21 //
22 22 extern volatile int wf_snap_f2[ ];
23 23 extern volatile int wf_snap_f2_bis[ ];
24 24 extern volatile int wf_snap_f2_norm[ ];
25 25 //
26 26 extern volatile int wf_cont_f3[ ];
27 27 extern volatile int wf_cont_f3_bis[ ];
28 28 extern char wf_cont_f3_light[ ];
29 29 extern waveform_picker_regs_t *waveform_picker_regs;
30 30 extern time_management_regs_t *time_management_regs;
31 31 extern Packet_TM_LFR_HK_t housekeeping_packet;
32 32 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
33 33 extern struct param_local_str param_local;
34 34
35 35 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
36 36 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
37 37
38 extern rtems_name misc_name[5];
39 extern rtems_name Task_name[20]; /* array of task ids */
40 38 extern rtems_id Task_id[20]; /* array of task ids */
41 39
42 40 extern unsigned char lfrCurrentMode;
43 41
44 42 rtems_isr waveforms_isr( rtems_vector_number vector );
45 43 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
46 44 rtems_task wfrm_task( rtems_task_argument argument );
47 45 rtems_task cwf3_task( rtems_task_argument argument );
48 46 rtems_task cwf2_task( rtems_task_argument argument );
49 47 rtems_task cwf1_task( rtems_task_argument argument );
50 48
51 49 //******************
52 50 // general functions
53 51 void init_waveforms( void );
54 52 //
55 53 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
56 54 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
57 55 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
58 56 //
59 57 void reset_waveforms( void );
60 58 //
61 59 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
62 60 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
63 61 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 62 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 63 //
66 64 rtems_id get_pkts_queue_id( void );
67 65
68 66 //**************
69 67 // wfp registers
70 68 void set_wfp_data_shaping();
71 69 char set_wfp_delta_snapshot();
72 70 void set_wfp_burst_enable_register( unsigned char mode);
73 71 void reset_wfp_burst_enable();
74 72 void reset_wfp_status();
75 73 void reset_waveform_picker_regs();
76 74
77 75 //*****************
78 76 // local parameters
79 77 void set_local_sbm1_nb_cwf_max( void );
80 78 void set_local_sbm2_nb_cwf_max( void );
81 79 void set_local_nb_interrupt_f0_MAX( void );
82 80 void reset_local_sbm1_nb_cwf_sent( void );
83 81 void reset_local_sbm2_nb_cwf_sent( void );
84 82
85 83 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
86 84
87 85 #endif // WF_HANDLER_H_INCLUDED
@@ -1,586 +1,610
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 2
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
74 74 rtems_status_code status;
75 75 rtems_status_code status_spw;
76 76 rtems_isr_entry old_isr_handler;
77 77
78 78 BOOT_PRINTF("\n\n\n\n\n")
79 79 BOOT_PRINTF("***************************\n")
80 80 BOOT_PRINTF("** START Flight Software **\n")
81 81 BOOT_PRINTF("***************************\n")
82 82 BOOT_PRINTF("\n\n")
83 83
84 84 //send_console_outputs_on_apbuart_port();
85 85 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
86 86
87 87 reset_wfp_burst_enable(); // stop the waveform picker if it was running
88 88
89 89 init_parameter_dump();
90 90 init_local_mode_parameters();
91 91 init_housekeeping_parameters();
92 92
93 93 updateLFRCurrentMode();
94 94
95 95 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
96 96
97 97 create_names(); // create all names
98 98
99 99 status = create_message_queues(); // create message queues
100 100 if (status != RTEMS_SUCCESSFUL)
101 101 {
102 102 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
103 103 }
104 104
105 105 status = create_all_tasks(); // create all tasks
106 106 if (status != RTEMS_SUCCESSFUL)
107 107 {
108 108 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
109 109 }
110 110
111 111 // **************************
112 112 // <SPACEWIRE INITIALIZATION>
113 113 grspw_timecode_callback = &timecode_irq_handler;
114 114
115 115 status_spw = spacewire_open_link(); // (1) open the link
116 116 if ( status_spw != RTEMS_SUCCESSFUL )
117 117 {
118 118 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
119 119 }
120 120
121 121 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
122 122 {
123 123 status_spw = spacewire_configure_link( fdSPW );
124 124 if ( status_spw != RTEMS_SUCCESSFUL )
125 125 {
126 126 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
127 127 }
128 128 }
129 129
130 130 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
131 131 {
132 132 status_spw = spacewire_start_link( fdSPW );
133 133 if ( status_spw != RTEMS_SUCCESSFUL )
134 134 {
135 135 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
136 136 }
137 137 }
138 138 // </SPACEWIRE INITIALIZATION>
139 139 // ***************************
140 140
141 141 status = start_all_tasks(); // start all tasks
142 142 if (status != RTEMS_SUCCESSFUL)
143 143 {
144 144 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
145 145 }
146 146
147 147 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
148 148 status = start_recv_send_tasks();
149 149 if ( status != RTEMS_SUCCESSFUL )
150 150 {
151 151 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
152 152 }
153 153
154 154 // suspend science tasks. they will be restarted later depending on the mode
155 155 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
156 156 if (status != RTEMS_SUCCESSFUL)
157 157 {
158 158 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
159 159 }
160 160
161 161 #ifdef GSA
162 162 // mask IRQ lines
163 163 LEON_Mask_interrupt( IRQ_SM );
164 164 LEON_Mask_interrupt( IRQ_WF );
165 165 // Spectral Matrices simulator
166 166 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
167 167 IRQ_SPARC_SM, spectral_matrices_isr );
168 168 // WaveForms
169 169 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
170 170 IRQ_SPARC_WF, waveforms_simulator_isr );
171 171 #else
172 172 // configure IRQ handling for the waveform picker unit
173 173 status = rtems_interrupt_catch( waveforms_isr,
174 174 IRQ_SPARC_WAVEFORM_PICKER,
175 175 &old_isr_handler) ;
176 176 #endif
177 177
178 178 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
179 179 if ( status_spw != RTEMS_SUCCESSFUL )
180 180 {
181 181 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
182 182 if ( status != RTEMS_SUCCESSFUL ) {
183 183 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
184 184 }
185 185 }
186 186
187 187 BOOT_PRINTF("delete INIT\n")
188 188
189 189 status = rtems_task_delete(RTEMS_SELF);
190 190
191 191 }
192 192
193 193 void init_local_mode_parameters( void )
194 194 {
195 195 /** This function initialize the param_local global variable with default values.
196 196 *
197 197 */
198 198
199 199 unsigned int i;
200 200
201 201 // LOCAL PARAMETERS
202 202 set_local_sbm1_nb_cwf_max();
203 203 set_local_sbm2_nb_cwf_max();
204 204 set_local_nb_interrupt_f0_MAX();
205 205
206 206 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
207 207 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
208 208 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
209 209
210 210 reset_local_sbm1_nb_cwf_sent();
211 211 reset_local_sbm2_nb_cwf_sent();
212 212
213 213 // init sequence counters
214 214
215 215 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
216 216 {
217 217 sequenceCounters_TC_EXE[i] = 0x00;
218 218 }
219 219 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
220 220 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
221 221 }
222 222
223 223 void create_names( void ) // create all names for tasks and queues
224 224 {
225 225 /** This function creates all RTEMS names used in the software for tasks and queues.
226 226 *
227 227 * @return RTEMS directive status codes:
228 228 * - RTEMS_SUCCESSFUL - successful completion
229 229 *
230 230 */
231 231
232 232 // task names
233 233 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
234 234 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
235 235 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
236 236 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
237 237 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
238 238 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
239 239 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
240 240 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
241 241 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
242 242 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
243 243 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
244 244 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
245 245 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
246 246 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
247 247 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
248 248 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
249 249
250 250 // rate monotonic period names
251 251 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
252 252
253 253 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
254 254 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
255 255 }
256 256
257 257 int create_all_tasks( void ) // create all tasks which run in the software
258 258 {
259 259 /** This function creates all RTEMS tasks used in the software.
260 260 *
261 261 * @return RTEMS directive status codes:
262 262 * - RTEMS_SUCCESSFUL - task created successfully
263 263 * - RTEMS_INVALID_ADDRESS - id is NULL
264 264 * - RTEMS_INVALID_NAME - invalid task name
265 265 * - RTEMS_INVALID_PRIORITY - invalid task priority
266 266 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
267 267 * - RTEMS_TOO_MANY - too many tasks created
268 268 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
269 269 * - RTEMS_TOO_MANY - too many global objects
270 270 *
271 271 */
272 272
273 273 rtems_status_code status;
274 274
275 275 // RECV
276 276 status = rtems_task_create(
277 277 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
278 278 RTEMS_DEFAULT_MODES,
279 279 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
280 280 );
281 281
282 282 if (status == RTEMS_SUCCESSFUL) // ACTN
283 283 {
284 284 status = rtems_task_create(
285 285 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
286 286 RTEMS_DEFAULT_MODES,
287 287 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
288 288 );
289 289 }
290 290 if (status == RTEMS_SUCCESSFUL) // SPIQ
291 291 {
292 292 status = rtems_task_create(
293 293 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
294 294 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
295 295 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
296 296 );
297 297 }
298 298 if (status == RTEMS_SUCCESSFUL) // SMIQ
299 299 {
300 300 status = rtems_task_create(
301 301 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
302 302 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
303 303 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
304 304 );
305 305 }
306 306 if (status == RTEMS_SUCCESSFUL) // STAT
307 307 {
308 308 status = rtems_task_create(
309 309 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
310 310 RTEMS_DEFAULT_MODES,
311 311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
312 312 );
313 313 }
314 314 if (status == RTEMS_SUCCESSFUL) // AVF0
315 315 {
316 316 status = rtems_task_create(
317 317 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
318 318 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
319 319 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
320 320 );
321 321 }
322 322 if (status == RTEMS_SUCCESSFUL) // BPF0
323 323 {
324 324 status = rtems_task_create(
325 325 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
326 326 RTEMS_DEFAULT_MODES,
327 327 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
328 328 );
329 329 }
330 330 if (status == RTEMS_SUCCESSFUL) // WFRM
331 331 {
332 332 status = rtems_task_create(
333 333 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
334 334 RTEMS_DEFAULT_MODES,
335 335 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
336 336 );
337 337 }
338 338 if (status == RTEMS_SUCCESSFUL) // DUMB
339 339 {
340 340 status = rtems_task_create(
341 341 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
342 342 RTEMS_DEFAULT_MODES,
343 343 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
344 344 );
345 345 }
346 346 if (status == RTEMS_SUCCESSFUL) // HOUS
347 347 {
348 348 status = rtems_task_create(
349 349 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
350 350 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
351 351 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
352 352 );
353 353 }
354 354 if (status == RTEMS_SUCCESSFUL) // MATR
355 355 {
356 356 status = rtems_task_create(
357 357 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
358 358 RTEMS_DEFAULT_MODES,
359 359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
360 360 );
361 361 }
362 362 if (status == RTEMS_SUCCESSFUL) // CWF3
363 363 {
364 364 status = rtems_task_create(
365 365 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
366 366 RTEMS_DEFAULT_MODES,
367 367 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
368 368 );
369 369 }
370 370 if (status == RTEMS_SUCCESSFUL) // CWF2
371 371 {
372 372 status = rtems_task_create(
373 373 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
374 374 RTEMS_DEFAULT_MODES,
375 375 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
376 376 );
377 377 }
378 378 if (status == RTEMS_SUCCESSFUL) // CWF1
379 379 {
380 380 status = rtems_task_create(
381 381 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
382 382 RTEMS_DEFAULT_MODES,
383 383 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
384 384 );
385 385 }
386 386 if (status == RTEMS_SUCCESSFUL) // SEND
387 387 {
388 388 status = rtems_task_create(
389 389 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
390 390 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
391 391 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
392 392 );
393 393 }
394 394 if (status == RTEMS_SUCCESSFUL) // WTDG
395 395 {
396 396 status = rtems_task_create(
397 397 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
398 398 RTEMS_DEFAULT_MODES,
399 399 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
400 400 );
401 401 }
402 402
403 403 return status;
404 404 }
405 405
406 406 int start_recv_send_tasks( void )
407 407 {
408 408 rtems_status_code status;
409 409
410 410 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
411 411 if (status!=RTEMS_SUCCESSFUL) {
412 412 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
413 413 }
414 414
415 415 if (status == RTEMS_SUCCESSFUL) // SEND
416 416 {
417 417 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
418 418 if (status!=RTEMS_SUCCESSFUL) {
419 419 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
420 420 }
421 421 }
422 422
423 423 return status;
424 424 }
425 425
426 426 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
427 427 {
428 428 /** This function starts all RTEMS tasks used in the software.
429 429 *
430 430 * @return RTEMS directive status codes:
431 431 * - RTEMS_SUCCESSFUL - ask started successfully
432 432 * - RTEMS_INVALID_ADDRESS - invalid task entry point
433 433 * - RTEMS_INVALID_ID - invalid task id
434 434 * - RTEMS_INCORRECT_STATE - task not in the dormant state
435 435 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
436 436 *
437 437 */
438 438 // starts all the tasks fot eh flight software
439 439
440 440 rtems_status_code status;
441 441
442 442 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
443 443 if (status!=RTEMS_SUCCESSFUL) {
444 444 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
445 445 }
446 446
447 447 if (status == RTEMS_SUCCESSFUL) // WTDG
448 448 {
449 449 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
450 450 if (status!=RTEMS_SUCCESSFUL) {
451 451 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
452 452 }
453 453 }
454 454
455 455 if (status == RTEMS_SUCCESSFUL) // SMIQ
456 456 {
457 457 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
458 458 if (status!=RTEMS_SUCCESSFUL) {
459 459 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
460 460 }
461 461 }
462 462
463 463 if (status == RTEMS_SUCCESSFUL) // ACTN
464 464 {
465 465 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
466 466 if (status!=RTEMS_SUCCESSFUL) {
467 467 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
468 468 }
469 469 }
470 470
471 471 if (status == RTEMS_SUCCESSFUL) // STAT
472 472 {
473 473 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
474 474 if (status!=RTEMS_SUCCESSFUL) {
475 475 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
476 476 }
477 477 }
478 478
479 479 if (status == RTEMS_SUCCESSFUL) // AVF0
480 480 {
481 481 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
482 482 if (status!=RTEMS_SUCCESSFUL) {
483 483 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
484 484 }
485 485 }
486 486
487 487 if (status == RTEMS_SUCCESSFUL) // BPF0
488 488 {
489 489 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
490 490 if (status!=RTEMS_SUCCESSFUL) {
491 491 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
492 492 }
493 493 }
494 494
495 495 if (status == RTEMS_SUCCESSFUL) // WFRM
496 496 {
497 497 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
498 498 if (status!=RTEMS_SUCCESSFUL) {
499 499 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
500 500 }
501 501 }
502 502
503 503 if (status == RTEMS_SUCCESSFUL) // DUMB
504 504 {
505 505 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
506 506 if (status!=RTEMS_SUCCESSFUL) {
507 507 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
508 508 }
509 509 }
510 510
511 511 if (status == RTEMS_SUCCESSFUL) // HOUS
512 512 {
513 513 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
514 514 if (status!=RTEMS_SUCCESSFUL) {
515 515 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
516 516 }
517 517 }
518 518
519 519 if (status == RTEMS_SUCCESSFUL) // MATR
520 520 {
521 521 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
522 522 if (status!=RTEMS_SUCCESSFUL) {
523 523 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
524 524 }
525 525 }
526 526
527 527 if (status == RTEMS_SUCCESSFUL) // CWF3
528 528 {
529 529 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
530 530 if (status!=RTEMS_SUCCESSFUL) {
531 531 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
532 532 }
533 533 }
534 534
535 535 if (status == RTEMS_SUCCESSFUL) // CWF2
536 536 {
537 537 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
538 538 if (status!=RTEMS_SUCCESSFUL) {
539 539 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
540 540 }
541 541 }
542 542
543 543 if (status == RTEMS_SUCCESSFUL) // CWF1
544 544 {
545 545 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
546 546 if (status!=RTEMS_SUCCESSFUL) {
547 547 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
548 548 }
549 549 }
550 550 return status;
551 551 }
552 552
553 553 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
554 554 {
555 555 rtems_status_code status_recv;
556 556 rtems_status_code status_send;
557 557 rtems_status_code ret;
558 558 rtems_id queue_id;
559 559
560 560 // create the queue for handling valid TCs
561 561 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
562 562 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
563 563 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
564 564 if ( status_recv != RTEMS_SUCCESSFUL ) {
565 565 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
566 566 }
567 567
568 568 // create the queue for handling TM packet sending
569 569 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
570 570 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
571 571 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
572 572 if ( status_send != RTEMS_SUCCESSFUL ) {
573 573 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
574 574 }
575 575
576 576 if ( status_recv != RTEMS_SUCCESSFUL )
577 577 {
578 578 ret = status_recv;
579 579 }
580 580 else
581 581 {
582 582 ret = status_send;
583 583 }
584 584
585 585 return ret;
586 586 }
587
588 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
589 {
590 rtems_status_code status;
591 rtems_name queue_name;
592
593 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
594
595 status = rtems_message_queue_ident( queue_name, 0, queue_id );
596
597 return status;
598 }
599
600 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
601 {
602 rtems_status_code status;
603 rtems_name queue_name;
604
605 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
606
607 status = rtems_message_queue_ident( queue_name, 0, queue_id );
608
609 return status;
610 }
@@ -1,336 +1,336
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 //char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
11 11 // "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
12 12 // "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
13 13 // "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
14 14 // "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
15 15 // "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
16 16 // "ERR HK" // RTEMS_EVENT_6
17 17 //};
18 18
19 19 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
20 20 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
21 21 {
22 22 /** This function configures a GPTIMER timer instantiated in the VHDL design.
23 23 *
24 24 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
25 25 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
26 26 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
27 27 * @param interrupt_level is the interrupt level that the timer drives.
28 28 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
29 29 *
30 30 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
31 31 *
32 32 */
33 33
34 34 rtems_status_code status;
35 35 rtems_isr_entry old_isr_handler;
36 36
37 37 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
38 38 if (status!=RTEMS_SUCCESSFUL)
39 39 {
40 40 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
41 41 }
42 42
43 43 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
44 44 }
45 45
46 46 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
47 47 {
48 48 /** This function starts a GPTIMER timer.
49 49 *
50 50 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
51 51 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
52 52 *
53 53 */
54 54
55 55 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
56 56 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
57 57 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
58 58 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
59 59 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
60 60 }
61 61
62 62 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
63 63 {
64 64 /** This function stops a GPTIMER timer.
65 65 *
66 66 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
67 67 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
68 68 *
69 69 */
70 70
71 71 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
72 72 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
73 73 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
74 74 }
75 75
76 76 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
77 77 {
78 78 /** This function sets the clock divider of a GPTIMER timer.
79 79 *
80 80 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
81 81 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
82 82 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
83 83 *
84 84 */
85 85
86 86 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
87 87 }
88 88
89 89 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
90 90 {
91 91 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
92 92
93 93 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
94 94 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
95 95
96 96 return 0;
97 97 }
98 98
99 99 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
100 100 {
101 101 /** This function sets the scaler reload register of the apbuart module
102 102 *
103 103 * @param regs is the address of the apbuart registers in memory
104 104 * @param value is the value that will be stored in the scaler register
105 105 *
106 106 * The value shall be set by the software to get data on the serial interface.
107 107 *
108 108 */
109 109
110 110 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
111 111
112 112 apbuart_regs->scaler = value;
113 113 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
114 114 }
115 115
116 116 //************
117 117 // RTEMS TASKS
118 118
119 119 rtems_task stat_task(rtems_task_argument argument)
120 120 {
121 121 int i;
122 122 int j;
123 123 i = 0;
124 124 j = 0;
125 125 BOOT_PRINTF("in STAT *** \n")
126 126 while(1){
127 127 rtems_task_wake_after(1000);
128 128 PRINTF1("%d\n", j)
129 129 if (i == CPU_USAGE_REPORT_PERIOD) {
130 130 // #ifdef PRINT_TASK_STATISTICS
131 131 // rtems_cpu_usage_report();
132 132 // rtems_cpu_usage_reset();
133 133 // #endif
134 134 i = 0;
135 135 }
136 136 else i++;
137 137 j++;
138 138 }
139 139 }
140 140
141 141 rtems_task hous_task(rtems_task_argument argument)
142 142 {
143 143 rtems_status_code status;
144 144 rtems_id queue_id;
145 145
146 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
146 status = get_message_queue_id_send( &queue_id );
147 147 if (status != RTEMS_SUCCESSFUL)
148 148 {
149 PRINTF1("in HOUS *** ERR %d\n", status)
149 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
150 150 }
151 151
152 152 BOOT_PRINTF("in HOUS ***\n")
153 153
154 154 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
155 155 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
156 156 if( status != RTEMS_SUCCESSFUL ) {
157 157 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
158 158 }
159 159 }
160 160
161 161 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
162 162 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
163 163 housekeeping_packet.reserved = DEFAULT_RESERVED;
164 164 housekeeping_packet.userApplication = CCSDS_USER_APP;
165 165 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
166 166 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
167 167 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
168 168 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
169 169 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
170 170 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
171 171 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
172 172 housekeeping_packet.serviceType = TM_TYPE_HK;
173 173 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
174 174 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
175 housekeeping_packet.sid = SID_HK;
175 176
176 177 status = rtems_rate_monotonic_cancel(HK_id);
177 178 if( status != RTEMS_SUCCESSFUL ) {
178 179 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
179 180 }
180 181 else {
181 182 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
182 183 }
183 184
184 185 while(1){ // launch the rate monotonic task
185 186 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
186 187 if ( status != RTEMS_SUCCESSFUL ) {
187 188 PRINTF1( "in HOUS *** ERR period: %d\n", status);
188 189 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
189 190 }
190 191 else {
191 192 increment_seq_counter( housekeeping_packet.packetSequenceControl );
192 193 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
193 194 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
194 195 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
195 196 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
196 197 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
197 198 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
198 housekeeping_packet.sid = SID_HK;
199 199
200 200 spacewire_update_statistics();
201 201
202 202 // SEND PACKET
203 203 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
204 204 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
205 205 if (status != RTEMS_SUCCESSFUL) {
206 206 PRINTF1("in HOUS *** ERR send: %d\n", status)
207 207 }
208 208 }
209 209 }
210 210
211 211 PRINTF("in HOUS *** deleting task\n")
212 212
213 213 status = rtems_task_delete( RTEMS_SELF ); // should not return
214 214 printf( "rtems_task_delete returned with status of %d.\n", status );
215 215 return;
216 216 }
217 217
218 218 rtems_task dumb_task( rtems_task_argument unused )
219 219 {
220 220 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
221 221 *
222 222 * @param unused is the starting argument of the RTEMS task
223 223 *
224 224 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
225 225 *
226 226 */
227 227
228 228 unsigned int i;
229 229 unsigned int intEventOut;
230 230 unsigned int coarse_time = 0;
231 231 unsigned int fine_time = 0;
232 232 rtems_event_set event_out;
233 233
234 234 char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
235 235 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
236 236 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
237 237 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
238 238 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
239 239 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
240 240 "ERR HK" // RTEMS_EVENT_6
241 241 };
242 242
243 243 BOOT_PRINTF("in DUMB *** \n")
244 244
245 245 while(1){
246 246 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
247 247 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6,
248 248 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
249 249 intEventOut = (unsigned int) event_out;
250 250 for ( i=0; i<32; i++)
251 251 {
252 252 if ( ((intEventOut >> i) & 0x0001) != 0)
253 253 {
254 254 coarse_time = time_management_regs->coarse_time;
255 255 fine_time = time_management_regs->fine_time;
256 256 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
257 257 }
258 258 }
259 259 }
260 260 }
261 261
262 262 //*****************************
263 263 // init housekeeping parameters
264 264
265 265 void init_housekeeping_parameters( void )
266 266 {
267 267 /** This function initialize the housekeeping_packet global variable with default values.
268 268 *
269 269 */
270 270
271 271 unsigned int i = 0;
272 272 char *parameters;
273 273
274 274 parameters = (char*) &housekeeping_packet.lfr_status_word;
275 275 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
276 276 {
277 277 parameters[i] = 0x00;
278 278 }
279 279 // init status word
280 280 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
281 281 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
282 282 // init software version
283 283 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
284 284 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
285 285 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
286 286 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
287 287
288 288 }
289 289
290 290 void increment_seq_counter( unsigned char *packet_sequence_control)
291 291 {
292 292 /** This function increment the sequence counter psased in argument.
293 293 *
294 294 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
295 295 *
296 296 */
297 297
298 298 unsigned short sequence_cnt;
299 299 unsigned short segmentation_grouping_flag;
300 300 unsigned short new_packet_sequence_control;
301 301
302 302 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
303 303 sequence_cnt = (unsigned short) (
304 304 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
305 305 + packet_sequence_control[1]
306 306 );
307 307
308 308 if ( sequence_cnt < SEQ_CNT_MAX)
309 309 {
310 310 sequence_cnt = sequence_cnt + 1;
311 311 }
312 312 else
313 313 {
314 314 sequence_cnt = 0;
315 315 }
316 316
317 317 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
318 318
319 319 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
320 320 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
321 321 }
322 322
323 323 void getTime( unsigned char *time)
324 324 {
325 325 /** This function write the current local time in the time buffer passed in argument.
326 326 *
327 327 */
328 328
329 329 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
330 330 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
331 331 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
332 332 time[3] = (unsigned char) (time_management_regs->coarse_time);
333 333 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
334 334 time[5] = (unsigned char) (time_management_regs->fine_time);
335 335 }
336 336
@@ -1,656 +1,656
1 1 /** Functions related to data processing.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 7 *
8 8 */
9 9
10 10 #include <fsw_processing.h>
11 11
12 12 #include "fsw_processing_globals.c"
13 13
14 14 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
15 15 float averaged_spec_mat_f0[ TOTAL_SIZE_SM ];
16 16 char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ];
17 17 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
18 18
19 19 //***********************************************************
20 20 // Interrupt Service Routine for spectral matrices processing
21 21 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
22 22 {
23 23 unsigned char status;
24 24 unsigned char i;
25 25
26 26 status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0]
27 27 for (i=0; i<4; i++)
28 28 {
29 29 if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation
30 30 {
31 31 switch(i)
32 32 {
33 33 case 0:
34 34 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
35 35 {
36 36 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis;
37 37 }
38 38 else
39 39 {
40 40 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
41 41 }
42 42 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
43 43 break;
44 44 case 1:
45 45 if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1)
46 46 {
47 47 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis;
48 48 }
49 49 else
50 50 {
51 51 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
52 52 }
53 53 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd;
54 54 break;
55 55 case 2:
56 56 if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1)
57 57 {
58 58 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis;
59 59 }
60 60 else
61 61 {
62 62 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
63 63 }
64 64 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb;
65 65 break;
66 66 case 3:
67 67 if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2)
68 68 {
69 69 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis;
70 70 }
71 71 else
72 72 {
73 73 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
74 74 }
75 75 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7;
76 76 break;
77 77 default:
78 78 break;
79 79 }
80 80 }
81 81 }
82 82
83 83 // reset error codes to 0
84 84 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111]
85 85
86 86 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
87 87 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
88 88 }
89 89 }
90 90
91 91 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
92 92 {
93 93 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
94 94 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
95 95 }
96 96 }
97 97
98 98 //************
99 99 // RTEMS TASKS
100 100
101 101 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
102 102 {
103 103 rtems_event_set event_out;
104 104 unsigned int nb_interrupt_f0 = 0;
105 105
106 106 BOOT_PRINTF("in SMIQ *** \n")
107 107
108 108 while(1){
109 109 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
110 110 nb_interrupt_f0 = nb_interrupt_f0 + 1;
111 111 if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){
112 112 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
113 113 {
114 114 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
115 115 }
116 116 nb_interrupt_f0 = 0;
117 117 }
118 118 }
119 119 }
120 120
121 121 rtems_task spw_bppr_task(rtems_task_argument argument)
122 122 {
123 123 rtems_status_code status;
124 124 rtems_event_set event_out;
125 125
126 126 BOOT_PRINTF("in BPPR ***\n");
127 127
128 128 while( true ){ // wait for an event to begin with the processing
129 129 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
130 130 }
131 131 }
132 132
133 133 rtems_task avf0_task(rtems_task_argument argument)
134 134 {
135 135 int i;
136 136 static int nb_average;
137 137 rtems_event_set event_out;
138 138 rtems_status_code status;
139 139
140 140 nb_average = 0;
141 141
142 142 BOOT_PRINTF("in AVFO *** \n")
143 143
144 144 while(1){
145 145 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
146 146 for(i=0; i<TOTAL_SIZE_SM; i++){
147 147 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
148 148 + spec_mat_f0_b[i]
149 149 + spec_mat_f0_c[i]
150 150 + spec_mat_f0_d[i]
151 151 + spec_mat_f0_e[i]
152 152 + spec_mat_f0_f[i]
153 153 + spec_mat_f0_g[i]
154 154 + spec_mat_f0_h[i];
155 155 }
156 156 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
157 157 if (nb_average == NB_AVERAGE_NORMAL_f0) {
158 158 nb_average = 0;
159 159 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
160 160 if (status != RTEMS_SUCCESSFUL) {
161 161 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
162 162 }
163 163 }
164 164 }
165 165 }
166 166
167 167 rtems_task bpf0_task(rtems_task_argument argument)
168 168 {
169 169 rtems_event_set event_out;
170 170 static unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_SM_F0 * 9 ];
171 171
172 172 BOOT_PRINTF("in BPFO *** \n")
173 173
174 174 while(1){
175 175 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
176 176 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
177 177 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0);
178 178 }
179 179 }
180 180
181 181 rtems_task matr_task(rtems_task_argument argument)
182 182 {
183 183 spw_ioctl_pkt_send spw_ioctl_send_ASM;
184 184 rtems_event_set event_out;
185 185 rtems_status_code status;
186 186 rtems_id queue_id;
187 187 Header_TM_LFR_SCIENCE_ASM_t headerASM;
188 188
189 189 init_header_asm( &headerASM );
190 190
191 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
191 status = get_message_queue_id_send( &queue_id );
192 192 if (status != RTEMS_SUCCESSFUL)
193 193 {
194 PRINTF1("in MATR *** ERR getting queue id, %d\n", status)
194 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
195 195 }
196 196
197 197 BOOT_PRINTF("in MATR *** \n")
198 198
199 199 fill_averaged_spectral_matrix( );
200 200
201 201 while(1){
202 202 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
203 203
204 204 #ifdef GSA
205 205 #else
206 206 fill_averaged_spectral_matrix( );
207 207 #endif
208 208 convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char);
209 209
210 210 send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
211 211 }
212 212 }
213 213
214 214 //*****************************
215 215 // Spectral matrices processing
216 216
217 217 void matrix_reset(volatile float *averaged_spec_mat)
218 218 {
219 219 int i;
220 220 for(i=0; i<TOTAL_SIZE_SM; i++){
221 221 averaged_spec_mat[i] = 0;
222 222 }
223 223 }
224 224
225 225 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
226 226 {
227 227 int i;
228 228 int j;
229 229 switch (fChannel){
230 230 case 0:
231 231 for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){
232 232 j = 17 + (i * 8);
233 233 compressed_spec_mat[i] = (averaged_spec_mat[j]
234 234 + averaged_spec_mat[j+1]
235 235 + averaged_spec_mat[j+2]
236 236 + averaged_spec_mat[j+3]
237 237 + averaged_spec_mat[j+4]
238 238 + averaged_spec_mat[j+5]
239 239 + averaged_spec_mat[j+6]
240 240 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
241 241 }
242 242 break;
243 243 case 1:
244 244 // case fChannel = f1 to be completed later
245 245 break;
246 246 case 2:
247 247 // case fChannel = f1 to be completed later
248 248 break;
249 249 default:
250 250 break;
251 251 }
252 252 }
253 253
254 254 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
255 255 int i;
256 256 int j;
257 257 unsigned char tmp_u_char;
258 258 unsigned char * pt_char = NULL;
259 259 float PSDB, PSDE;
260 260 float NVEC_V0;
261 261 float NVEC_V1;
262 262 float NVEC_V2;
263 263 //float significand;
264 264 //int exponent;
265 265 float aux;
266 266 float tr_SB_SB;
267 267 float tmp;
268 268 float sx_re;
269 269 float sx_im;
270 270 float nebx_re = 0;
271 271 float nebx_im = 0;
272 272 float ny = 0;
273 273 float nz = 0;
274 274 float bx_bx_star = 0;
275 275 for(i=0; i<nb_bins_compressed_spec_mat; i++){
276 276 //==============================================
277 277 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
278 278 PSDB = compressed_spec_mat[i*30] // S11
279 279 + compressed_spec_mat[(i*30) + 10] // S22
280 280 + compressed_spec_mat[(i*30) + 18]; // S33
281 281 //significand = frexp(PSDB, &exponent);
282 282 pt_char = (unsigned char*) &PSDB;
283 283 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
284 284 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
285 285 //==============================================
286 286 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
287 287 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
288 288 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
289 289 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
290 290 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
291 291 pt_char = (unsigned char*) &PSDE;
292 292 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
293 293 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
294 294 //==============================================================================
295 295 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
296 296 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
297 297 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
298 298 tmp = sqrt(
299 299 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
300 300 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
301 301 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
302 302 );
303 303 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
304 304 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
305 305 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
306 306 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
307 307 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
308 308 pt_char = (unsigned char*) &NVEC_V2;
309 309 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
310 310 //=======================================================
311 311 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
312 312 aux = 2*tmp / PSDB; // compute the ellipticity
313 313 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
314 314 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
315 315 //==============================================================
316 316 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
317 317 for(j = 0; j<NB_VALUES_PER_SM;j++){
318 318 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
319 319 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
320 320 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
321 321 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
322 322 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
323 323 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
324 324 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
325 325 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
326 326 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
327 327 }
328 328 aux = PSDB*PSDB;
329 329 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
330 330 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
331 331 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
332 332 //=======================================================================================
333 333 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
334 334 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
335 335 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
336 336 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
337 337 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
338 338 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
339 339 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
340 340 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
341 341 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
342 342 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
343 343 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
344 344 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
345 345 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
346 346 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
347 347 if ( abs(sx_re) > abs(sx_im) ) {
348 348 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
349 349 }
350 350 else {
351 351 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
352 352 }
353 353 //======================================================================
354 354 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
355 355 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
356 356 nz = NVEC_V0;
357 357 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
358 358 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
359 359 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
360 360 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
361 361 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
362 362 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
363 363 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
364 364 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
365 365 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
366 366 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
367 367 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
368 368 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
369 369 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
370 370 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
371 371 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
372 372 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
373 373 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
374 374 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
375 375 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
376 376 tmp = nebx_re / bx_bx_star;
377 377 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
378 378 if ( abs(nebx_re) > abs(nebx_im) ) {
379 379 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
380 380 }
381 381 else {
382 382 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
383 383 }
384 384 }
385 385
386 386 }
387 387
388 388 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
389 389 // BP2 autocorrelation
390 390 int i;
391 391 int aux = 0;
392 392
393 393 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
394 394 // S12
395 395 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
396 396 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
397 397 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
398 398 // S13
399 399 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
400 400 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
401 401 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
402 402 // S23
403 403 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
404 404 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
405 405 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
406 406 // S45
407 407 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
408 408 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
409 409 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
410 410 // S14
411 411 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
412 412 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
413 413 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
414 414 // S15
415 415 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
416 416 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
417 417 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
418 418 // S24
419 419 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
420 420 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
421 421 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
422 422 // S25
423 423 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
424 424 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
425 425 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
426 426 // S34
427 427 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
428 428 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
429 429 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
430 430 // S35
431 431 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
432 432 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
433 433 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
434 434 }
435 435 }
436 436
437 437 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
438 438 {
439 439 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
440 440 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
441 441 header->reserved = 0x00;
442 442 header->userApplication = CCSDS_USER_APP;
443 443 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
444 444 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
445 445 header->packetSequenceControl[0] = 0xc0;
446 446 header->packetSequenceControl[1] = 0x00;
447 447 header->packetLength[0] = 0x00;
448 448 header->packetLength[1] = 0x00;
449 449 // DATA FIELD HEADER
450 450 header->spare1_pusVersion_spare2 = 0x10;
451 451 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
452 452 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
453 453 header->destinationID = TM_DESTINATION_ID_GROUND;
454 454 // AUXILIARY DATA HEADER
455 455 header->sid = 0x00;
456 456 header->biaStatusInfo = 0x00;
457 457 header->cntASM = 0x00;
458 458 header->nrASM = 0x00;
459 459 header->time[0] = 0x00;
460 460 header->time[0] = 0x00;
461 461 header->time[0] = 0x00;
462 462 header->time[0] = 0x00;
463 463 header->time[0] = 0x00;
464 464 header->time[0] = 0x00;
465 465 header->blkNr[0] = 0x00; // BLK_NR MSB
466 466 header->blkNr[1] = 0x00; // BLK_NR LSB
467 467 }
468 468
469 469 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
470 470 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
471 471 {
472 472 unsigned int i;
473 473 unsigned int length = 0;
474 474 rtems_status_code status;
475 475
476 476 header->sid = (unsigned char) sid;
477 477
478 478 for (i=0; i<2; i++)
479 479 {
480 480 // BUILD THE DATA
481 481 spw_ioctl_send->dlen = TOTAL_SIZE_SM;
482 482 spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM];
483 483 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
484 484 spw_ioctl_send->hdr = (char *) header;
485 485 spw_ioctl_send->options = 0;
486 486
487 487 // BUILD THE HEADER
488 488 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM;
489 489 header->packetLength[0] = (unsigned char) (length>>8);
490 490 header->packetLength[1] = (unsigned char) (length);
491 491 header->sid = (unsigned char) sid; // SID
492 492 header->cntASM = 2;
493 493 header->nrASM = (unsigned char) (i+1);
494 494 header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB
495 495 header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB
496 496 // SET PACKET TIME
497 497 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
498 498 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
499 499 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
500 500 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
501 501 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
502 502 header->time[5] = (unsigned char) (time_management_regs->fine_time);
503 503 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
504 504 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
505 505 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
506 506 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
507 507 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
508 508 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
509 509 // SEND PACKET
510 510 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
511 511 if (status != RTEMS_SUCCESSFUL) {
512 512 printf("in send_spectral_matrix *** ERR %d\n", (int) status);
513 513 }
514 514 }
515 515 }
516 516
517 517 void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix)
518 518 {
519 519 unsigned int i;
520 520 unsigned int j;
521 521 char * pt_char_input;
522 522 char * pt_char_output;
523 523
524 524 pt_char_input = NULL;
525 525 pt_char_output = NULL;
526 526
527 527 for( i=0; i<NB_BINS_PER_SM; i++)
528 528 {
529 529 for ( j=0; j<NB_VALUES_PER_SM; j++)
530 530 {
531 531 pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ];
532 532 pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ];
533 533 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
534 534 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
535 535 }
536 536 }
537 537 }
538 538
539 539 void fill_averaged_spectral_matrix(void)
540 540 {
541 541 /** This function fills spectral matrices related buffers with arbitrary data.
542 542 *
543 543 * This function is for testing purpose only.
544 544 *
545 545 */
546 546
547 547 #ifdef GSA
548 548 float offset = 10.;
549 549 float coeff = 100000.;
550 550
551 551 averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset;
552 552 averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset;
553 553 averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset;
554 554 averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset;
555 555 averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset;
556 556 averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset;
557 557 averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset;
558 558 averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset;
559 559 averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset;
560 560 averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset;
561 561 averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset;
562 562 averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset;
563 563 averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset;
564 564 averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset;
565 565 averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset;
566 566 averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
567 567 averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
568 568 averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
569 569 averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
570 570 averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
571 571 averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
572 572 averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
573 573 averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
574 574 averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
575 575 averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
576 576 averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
577 577 averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
578 578 averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
579 579 averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
580 580 averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
581 581 offset = 10000000;
582 582 averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
583 583 averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
584 584 averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
585 585 averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
586 586 averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
587 587 averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
588 588 averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
589 589 averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
590 590 averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
591 591 averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
592 592 averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
593 593 averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
594 594 averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
595 595 averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
596 596 averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
597 597
598 598 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ];
599 599 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ];
600 600 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ];
601 601 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ];
602 602 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ];
603 603 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ];
604 604 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ];
605 605 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ];
606 606 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ];
607 607 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ];
608 608 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ];
609 609 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ];
610 610 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ];
611 611 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ];
612 612 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ];
613 613 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ];
614 614 #else
615 615 unsigned int i;
616 616
617 617 for(i=0; i<TOTAL_SIZE_SM; i++)
618 618 {
619 619 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
620 620 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ];
621 621 else
622 622 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ];
623 623 }
624 624 #endif
625 625 }
626 626
627 627 void reset_spectral_matrix_regs()
628 628 {
629 629 /** This function resets the spectral matrices module registers.
630 630 *
631 631 * The registers affected by this function are located at the following offset addresses:
632 632 *
633 633 * - 0x00 config
634 634 * - 0x04 status
635 635 * - 0x08 matrixF0_Address0
636 636 * - 0x10 matrixFO_Address1
637 637 * - 0x14 matrixF1_Address
638 638 * - 0x18 matrixF2_Address
639 639 *
640 640 */
641 641
642 642 #ifdef GSA
643 643 #else
644 644 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
645 645 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
646 646 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
647 647 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
648 648 #endif
649 649 }
650 650
651 651 //******************
652 652 // general functions
653 653
654 654
655 655
656 656
@@ -1,624 +1,606
1 1 /** Functions related to the SpaceWire interface.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle SpaceWire transmissions:
7 7 * - configuration of the SpaceWire link
8 8 * - SpaceWire related interruption requests processing
9 9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 10 * - reception of TeleCommands by a dedicated RTEMS task
11 11 *
12 12 */
13 13
14 14 #include "fsw_spacewire.h"
15 15
16 16 rtems_name semq_name;
17 17 rtems_id semq_id;
18 18
19 19 //***********
20 20 // RTEMS TASK
21 21 rtems_task spiq_task(rtems_task_argument unused)
22 22 {
23 23 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
24 24 *
25 25 * @param unused is the starting argument of the RTEMS task
26 26 *
27 27 */
28 28
29 29 rtems_event_set event_out;
30 30 rtems_status_code status;
31 31 int linkStatus;
32 32
33 33 BOOT_PRINTF("in SPIQ *** \n")
34 34
35 35 while(true){
36 36 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
37 37 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
38 38
39 39 // [0] SUSPEND RECV AND SEND TASKS
40 40 status = rtems_task_suspend( Task_id[ TASKID_RECV ] );
41 41 if ( status != RTEMS_SUCCESSFUL ) {
42 42 PRINTF("in SPIQ *** ERR suspending RECV Task\n")
43 43 }
44 44 status = rtems_task_suspend( Task_id[ TASKID_SEND ] );
45 45 if ( status != RTEMS_SUCCESSFUL ) {
46 46 PRINTF("in SPIQ *** ERR suspending SEND Task\n")
47 47 }
48 48
49 49 // [1] CHECK THE LINK
50 50 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
51 51 if ( linkStatus != 5) {
52 52 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
53 53 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
54 54 }
55 55
56 56 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
57 57 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
58 58 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
59 59 {
60 60 spacewire_compute_stats_offsets();
61 61 status = spacewire_reset_link( );
62 62 }
63 63 else // [2.b] in run state, start the link
64 64 {
65 65 status = spacewire_stop_start_link( fdSPW ); // start the link
66 66 if ( status != RTEMS_SUCCESSFUL)
67 67 {
68 68 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
69 69 }
70 70 }
71 71
72 72 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
73 73 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
74 74 {
75 75 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
76 76 if ( status != RTEMS_SUCCESSFUL ) {
77 77 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
78 78 }
79 79 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
80 80 if ( status != RTEMS_SUCCESSFUL ) {
81 81 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
82 82 }
83 83 }
84 84 else // [3.b] the link is not in run state, go in STANDBY mode
85 85 {
86 86 status = stop_current_mode();
87 87 if ( status != RTEMS_SUCCESSFUL ) {
88 88 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
89 89 }
90 90 status = enter_standby_mode();
91 91 if ( status != RTEMS_SUCCESSFUL ) {
92 92 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
93 93 }
94 94 // wake the WTDG task up to wait for the link recovery
95 95 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
96 96 status = rtems_task_suspend( RTEMS_SELF );
97 97 }
98 98 }
99 99 }
100 100
101 101 rtems_task recv_task( rtems_task_argument unused )
102 102 {
103 103 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
104 104 *
105 105 * @param unused is the starting argument of the RTEMS task
106 106 *
107 107 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
108 108 * 1. It reads the incoming data.
109 109 * 2. Launches the acceptance procedure.
110 110 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
111 111 *
112 112 */
113 113
114 114 int len;
115 115 ccsdsTelecommandPacket_t currentTC;
116 116 unsigned char computed_CRC[ 2 ];
117 117 unsigned char currentTC_LEN_RCV[ 2 ];
118 118 unsigned char destinationID;
119 119 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
120 120 unsigned int parserCode;
121 121 unsigned char time[6];
122 122 rtems_status_code status;
123 123 rtems_id queue_recv_id;
124 124 rtems_id queue_send_id;
125 125
126 126 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
127 127
128 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_recv_id );
128 status = get_message_queue_id_recv( &queue_recv_id );
129 129 if (status != RTEMS_SUCCESSFUL)
130 130 {
131 PRINTF1("in RECV *** ERR getting QUEUE_RECV id, %d\n", status)
131 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
132 132 }
133 133
134 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_send_id );
134 status = get_message_queue_id_send( &queue_send_id );
135 135 if (status != RTEMS_SUCCESSFUL)
136 136 {
137 PRINTF1("in RECV *** ERR getting QUEUE_SEND id, %d\n", status)
137 PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status)
138 138 }
139 139
140 140 BOOT_PRINTF("in RECV *** \n")
141 141
142 142 while(1)
143 143 {
144 144 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
145 145 if (len == -1){ // error during the read call
146 146 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
147 147 }
148 148 else {
149 149 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
150 150 PRINTF("in RECV *** packet lenght too short\n")
151 151 }
152 152 else {
153 153 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
154 154 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
155 155 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
156 156 // CHECK THE TC
157 157 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
158 158 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
159 159 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
160 160 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
161 161 || (parserCode == WRONG_SRC_ID) )
162 162 { // send TM_LFR_TC_EXE_CORRUPTED
163 163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 164 &&
165 165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 166 )
167 167 {
168 168 if ( parserCode == WRONG_SRC_ID )
169 169 {
170 170 destinationID = SID_TC_GROUND;
171 171 }
172 172 else
173 173 {
174 174 destinationID = currentTC.sourceID;
175 175 }
176 176 getTime( time );
177 177 close_action( &currentTC, LFR_DEFAULT, queue_send_id, time);
178 178 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id,
179 179 computed_CRC, currentTC_LEN_RCV,
180 180 destinationID, time );
181 181 }
182 182 }
183 183 else
184 184 { // send valid TC to the action launcher
185 185 status = rtems_message_queue_send( queue_recv_id, &currentTC,
186 186 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
187 187 }
188 188 }
189 189 }
190 190 }
191 191 }
192 192
193 193 rtems_task send_task( rtems_task_argument argument)
194 194 {
195 195 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
196 196 *
197 197 * @param unused is the starting argument of the RTEMS task
198 198 *
199 199 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
200 200 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
201 201 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
202 202 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
203 203 * data it contains.
204 204 *
205 205 */
206 206
207 207 rtems_status_code status; // RTEMS status code
208 208 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
209 209 spw_ioctl_pkt_send *spw_ioctl_send;
210 210 size_t size; // size of the incoming TC packet
211 211 u_int32_t count;
212 212 rtems_id queue_id;
213 213
214 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
214 status = get_message_queue_id_send( &queue_id );
215 215 if (status != RTEMS_SUCCESSFUL)
216 216 {
217 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
217 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
218 218 }
219 219
220 220 BOOT_PRINTF("in SEND *** \n")
221 221
222 222 while(1)
223 223 {
224 224 status = rtems_message_queue_receive( queue_id, incomingData, &size,
225 225 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
226 226
227 227 if (status!=RTEMS_SUCCESSFUL)
228 228 {
229 229 PRINTF1("in SEND *** (1) ERR = %d\n", status)
230 230 }
231 231 else
232 232 {
233 233 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
234 234 {
235 235 status = write( fdSPW, incomingData, size );
236 236 if (status == -1){
237 237 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
238 238 }
239 239 }
240 240 else // the incoming message is a spw_ioctl_pkt_send structure
241 241 {
242 242 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
243 243 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
244 244 if (status == -1){
245 245 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
246 246 }
247 247 }
248 248 }
249 249
250 250 status = rtems_message_queue_get_number_pending( queue_id, &count );
251 251 if (status != RTEMS_SUCCESSFUL)
252 252 {
253 253 PRINTF1("in SEND *** (3) ERR = %d\n", status)
254 254 }
255 255 else
256 256 {
257 257 if (count > maxCount)
258 258 {
259 259 maxCount = count;
260 260 }
261 261 }
262 262 }
263 263 }
264 264
265 265 rtems_task wtdg_task( rtems_task_argument argument )
266 266 {
267 267 rtems_event_set event_out;
268 268 rtems_status_code status;
269 269 int linkStatus;
270 270
271 271 BOOT_PRINTF("in WTDG ***\n")
272 272
273 273 while(1)
274 274 {
275 275 // wait for an RTEMS_EVENT
276 276 rtems_event_receive( RTEMS_EVENT_0,
277 277 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
278 278 PRINTF("in WTDG *** wait for the link\n")
279 279 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
280 280 while( linkStatus != 5) // wait for the link
281 281 {
282 282 rtems_task_wake_after( 10 );
283 283 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
284 284 }
285 285
286 286 status = spacewire_stop_start_link( fdSPW );
287 287
288 288 if (status != RTEMS_SUCCESSFUL)
289 289 {
290 290 PRINTF1("in WTDG *** ERR link not started %d\n", status)
291 291 }
292 292 else
293 293 {
294 294 PRINTF("in WTDG *** OK link started\n")
295 295 }
296 296
297 297 // restart the SPIQ task
298 298 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
299 299 if ( status != RTEMS_SUCCESSFUL ) {
300 300 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
301 301 }
302 302
303 303 // restart RECV and SEND
304 304 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
305 305 if ( status != RTEMS_SUCCESSFUL ) {
306 306 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
307 307 }
308 308 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
309 309 if ( status != RTEMS_SUCCESSFUL ) {
310 310 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
311 311 }
312 312 }
313 313 }
314 314
315 315 //****************
316 316 // OTHER FUNCTIONS
317 317 int spacewire_open_link( void )
318 318 {
319 319 /** This function opens the SpaceWire link.
320 320 *
321 321 * @return a valid file descriptor in case of success, -1 in case of a failure
322 322 *
323 323 */
324 324 rtems_status_code status;
325 325
326 326 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
327 327 if ( fdSPW < 0 ) {
328 328 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
329 329 }
330 330 else
331 331 {
332 332 status = RTEMS_SUCCESSFUL;
333 333 }
334 334
335 335 return status;
336 336 }
337 337
338 338 int spacewire_start_link( int fd )
339 339 {
340 340 rtems_status_code status;
341 341
342 342 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
343 343 // -1 default hardcoded driver timeout
344 344
345 345 return status;
346 346 }
347 347
348 348 int spacewire_stop_start_link( int fd )
349 349 {
350 350 rtems_status_code status;
351 351
352 352 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
353 353 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
354 354 // -1 default hardcoded driver timeout
355 355
356 356 return status;
357 357 }
358 358
359 359 int spacewire_configure_link( int fd )
360 360 {
361 361 /** This function configures the SpaceWire link.
362 362 *
363 363 * @return GR-RTEMS-DRIVER directive status codes:
364 364 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
365 365 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
366 366 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
367 367 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
368 368 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
369 369 * - 5 EIO - Error when writing to grswp hardware registers.
370 370 * - 2 ENOENT - No such file or directory
371 371 */
372 372
373 373 rtems_status_code status;
374 374
375 375 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
376 376 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
377 377
378 378 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
379 379 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
380 380 //
381 381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
382 382 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
383 383 //
384 384 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
385 385 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
386 386 //
387 387 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
388 388 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
389 389 //
390 390 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
391 391 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
392 392 //
393 393 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
394 394 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
395 395 //
396 396 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
397 397 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
398 398
399 399 return status;
400 400 }
401 401
402 402 int spacewire_reset_link( void )
403 403 {
404 404 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
405 405 *
406 406 * @return RTEMS directive status code:
407 407 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
408 408 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
409 409 *
410 410 */
411 411
412 412 rtems_status_code status_spw;
413 413 int i;
414 414
415 415 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
416 416 {
417 417 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
418 418
419 419 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
420 420
421 421 status_spw = spacewire_stop_start_link( fdSPW );
422 422 if ( status_spw != RTEMS_SUCCESSFUL )
423 423 {
424 424 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
425 425 }
426 426
427 427 if ( status_spw == RTEMS_SUCCESSFUL)
428 428 {
429 429 break;
430 430 }
431 431 }
432 432
433 433 return status_spw;
434 434 }
435 435
436 436 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
437 437 {
438 438 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
439 439 *
440 440 * @param val is the value, 0 or 1, used to set the value of the NP bit.
441 441 * @param regAddr is the address of the GRSPW control register.
442 442 *
443 443 * NP is the bit 20 of the GRSPW control register.
444 444 *
445 445 */
446 446
447 447 unsigned int *spwptr = (unsigned int*) regAddr;
448 448
449 449 if (val == 1) {
450 450 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
451 451 }
452 452 if (val== 0) {
453 453 *spwptr = *spwptr & 0xffdfffff;
454 454 }
455 455 }
456 456
457 457 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
458 458 {
459 459 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
460 460 *
461 461 * @param val is the value, 0 or 1, used to set the value of the RE bit.
462 462 * @param regAddr is the address of the GRSPW control register.
463 463 *
464 464 * RE is the bit 16 of the GRSPW control register.
465 465 *
466 466 */
467 467
468 468 unsigned int *spwptr = (unsigned int*) regAddr;
469 469
470 470 if (val == 1)
471 471 {
472 472 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
473 473 }
474 474 if (val== 0)
475 475 {
476 476 *spwptr = *spwptr & 0xfffdffff;
477 477 }
478 478 }
479 479
480 480 void spacewire_compute_stats_offsets( void )
481 481 {
482 482 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
483 483 *
484 484 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
485 485 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
486 486 * during the open systel call).
487 487 *
488 488 */
489 489
490 490 spw_stats spacewire_stats_grspw;
491 491 rtems_status_code status;
492 492
493 493 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
494 494
495 495 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
496 496 + spacewire_stats.packets_received;
497 497 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
498 498 + spacewire_stats.packets_sent;
499 499 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
500 500 + spacewire_stats.parity_err;
501 501 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
502 502 + spacewire_stats.disconnect_err;
503 503 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
504 504 + spacewire_stats.escape_err;
505 505 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
506 506 + spacewire_stats.credit_err;
507 507 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
508 508 + spacewire_stats.write_sync_err;
509 509 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
510 510 + spacewire_stats.rx_rmap_header_crc_err;
511 511 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
512 512 + spacewire_stats.rx_rmap_data_crc_err;
513 513 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
514 514 + spacewire_stats.early_ep;
515 515 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
516 516 + spacewire_stats.invalid_address;
517 517 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
518 518 + spacewire_stats.rx_eep_err;
519 519 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
520 520 + spacewire_stats.rx_truncated;
521 521 }
522 522
523 523 void spacewire_update_statistics( void )
524 524 {
525 525 rtems_status_code status;
526 526 spw_stats spacewire_stats_grspw;
527 527
528 528 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
529 529
530 530 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
531 531 + spacewire_stats_grspw.packets_received;
532 532 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
533 533 + spacewire_stats_grspw.packets_sent;
534 534 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
535 535 + spacewire_stats_grspw.parity_err;
536 536 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
537 537 + spacewire_stats_grspw.disconnect_err;
538 538 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
539 539 + spacewire_stats_grspw.escape_err;
540 540 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
541 541 + spacewire_stats_grspw.credit_err;
542 542 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
543 543 + spacewire_stats_grspw.write_sync_err;
544 544 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
545 545 + spacewire_stats_grspw.rx_rmap_header_crc_err;
546 546 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
547 547 + spacewire_stats_grspw.rx_rmap_data_crc_err;
548 548 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
549 549 + spacewire_stats_grspw.early_ep;
550 550 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
551 551 + spacewire_stats_grspw.invalid_address;
552 552 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
553 553 + spacewire_stats_grspw.rx_eep_err;
554 554 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
555 555 + spacewire_stats_grspw.rx_truncated;
556 556 //spacewire_stats.tx_link_err;
557 557
558 558 //****************************
559 559 // DPU_SPACEWIRE_IF_STATISTICS
560 560 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
561 561 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
562 562 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
563 563 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
564 564 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
565 565 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
566 566
567 567 //******************************************
568 568 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
569 569 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
570 570 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
571 571 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
572 572 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
573 573 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
574 574 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
575 575 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
576 576 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
577 577 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
578 578
579 579 //*********************************************
580 580 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
581 581 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
582 582 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
583 583 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
584 584 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
585 585
586 586 }
587 587
588 588 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
589 589 {
590 590 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
591 591 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
592 592 //}
593 593 }
594 594
595 595 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
596 596 {
597 597 int linkStatus;
598 598 rtems_status_code status;
599 599
600 600 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
601 601
602 602 if ( linkStatus == 5) {
603 603 PRINTF("in spacewire_reset_link *** link is running\n")
604 604 status = RTEMS_SUCCESSFUL;
605 605 }
606 606 }
607
608 rtems_status_code rtems_message_queue_send_lfr( rtems_id id, const void *buffer, size_t size )
609 {
610 rtems_status_code status;
611 rtems_mode previous_mode_set;
612
613 // set the preemption OFF
614 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode_set );
615
616 // use the message queue
617 status = rtems_message_queue_send_lfr( id, buffer, size );
618
619 // set the preemption ON
620 status = rtems_task_mode( RTEMS_PREEMPT , RTEMS_PREEMPT_MASK, &previous_mode_set );
621
622 return status;
623 }
624
@@ -1,862 +1,862
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 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id );
38 status = get_message_queue_id_recv( &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 42 }
43 43
44 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id );
44 status = get_message_queue_id_send( &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
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, time );
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, time );
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, time );
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, time );
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, time );
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, time );
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, time );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_ENTER:
105 105 result = action_enter_mode( &TC, queue_snd_id, time );
106 106 close_action( &TC, result, queue_snd_id, time );
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, time );
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, time );
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, time );
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, time );
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, unsigned char *time)
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
164 164 requestedMode = TC->dataAndCRC[1];
165 165
166 166 if ( (requestedMode != LFR_MODE_STANDBY)
167 167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
168 168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
169 169 {
170 170 status = RTEMS_UNSATISFIED;
171 171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time );
172 172 }
173 173 else
174 174 {
175 175 printf("try to enter mode %d\n", requestedMode);
176 176
177 177 #ifdef PRINT_TASK_STATISTICS
178 178 if (requestedMode != LFR_MODE_STANDBY)
179 179 {
180 180 rtems_cpu_usage_reset();
181 181 maxCount = 0;
182 182 }
183 183 #endif
184 184
185 185 status = transition_validation(requestedMode);
186 186
187 187 if ( status == LFR_SUCCESSFUL ) {
188 188 if ( lfrCurrentMode != LFR_MODE_STANDBY)
189 189 {
190 190 status = stop_current_mode();
191 191 }
192 192 if (status != RTEMS_SUCCESSFUL)
193 193 {
194 194 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
195 195 }
196 196 status = enter_mode( requestedMode );
197 197 }
198 198 else
199 199 {
200 200 PRINTF("ERR *** in action_enter *** transition rejected\n")
201 201 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
202 202 }
203 203 }
204 204
205 205 return status;
206 206 }
207 207
208 208 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
209 209 {
210 210 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
211 211 *
212 212 * @param TC points to the TeleCommand packet that is being processed
213 213 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
214 214 *
215 215 * @return LFR directive status code:
216 216 * - LFR_DEFAULT
217 217 * - LFR_SUCCESSFUL
218 218 *
219 219 */
220 220
221 221 unsigned int val;
222 222 int result;
223 223
224 224 result = LFR_SUCCESSFUL;
225 225
226 226 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
227 227 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
228 228 val++;
229 229 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
230 230 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
231 231
232 232 return result;
233 233 }
234 234
235 235 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
236 236 {
237 237 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
238 238 *
239 239 * @param TC points to the TeleCommand packet that is being processed
240 240 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
241 241 *
242 242 */
243 243
244 244 int result;
245 245 unsigned char lfrMode;
246 246
247 247 result = LFR_DEFAULT;
248 248 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
249 249
250 250 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
251 251 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
252 252 result = LFR_DEFAULT;
253 253 }
254 254 else {
255 255 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
256 256 result = LFR_DEFAULT;
257 257 }
258 258 return result;
259 259 }
260 260
261 261 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
262 262 {
263 263 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
264 264 *
265 265 * @param TC points to the TeleCommand packet that is being processed
266 266 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
267 267 *
268 268 */
269 269
270 270 int result;
271 271 unsigned char lfrMode;
272 272
273 273 result = LFR_DEFAULT;
274 274 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
275 275
276 276 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
277 277 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
278 278 result = LFR_DEFAULT;
279 279 }
280 280 else {
281 281 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
282 282 result = LFR_DEFAULT;
283 283 }
284 284 return result;
285 285 }
286 286
287 287 int action_update_time(ccsdsTelecommandPacket_t *TC)
288 288 {
289 289 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
290 290 *
291 291 * @param TC points to the TeleCommand packet that is being processed
292 292 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
293 293 *
294 294 * @return LFR_SUCCESSFUL
295 295 *
296 296 */
297 297
298 298 unsigned int val;
299 299
300 300 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
301 301 + (TC->dataAndCRC[1] << 16)
302 302 + (TC->dataAndCRC[2] << 8)
303 303 + TC->dataAndCRC[3];
304 304 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
305 305 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
306 306 val++;
307 307 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
308 308 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
309 309 time_management_regs->ctrl = time_management_regs->ctrl | 1;
310 310
311 311 return LFR_SUCCESSFUL;
312 312 }
313 313
314 314 //*******************
315 315 // ENTERING THE MODES
316 316
317 317 int transition_validation(unsigned char requestedMode)
318 318 {
319 319 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
320 320 *
321 321 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
322 322 *
323 323 * @return LFR directive status codes:
324 324 * - LFR_SUCCESSFUL - the transition is authorized
325 325 * - LFR_DEFAULT - the transition is not authorized
326 326 *
327 327 */
328 328
329 329 int status;
330 330
331 331 switch (requestedMode)
332 332 {
333 333 case LFR_MODE_STANDBY:
334 334 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
335 335 status = LFR_DEFAULT;
336 336 }
337 337 else
338 338 {
339 339 status = LFR_SUCCESSFUL;
340 340 }
341 341 break;
342 342 case LFR_MODE_NORMAL:
343 343 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
344 344 status = LFR_DEFAULT;
345 345 }
346 346 else {
347 347 status = LFR_SUCCESSFUL;
348 348 }
349 349 break;
350 350 case LFR_MODE_BURST:
351 351 if ( lfrCurrentMode == LFR_MODE_BURST ) {
352 352 status = LFR_DEFAULT;
353 353 }
354 354 else {
355 355 status = LFR_SUCCESSFUL;
356 356 }
357 357 break;
358 358 case LFR_MODE_SBM1:
359 359 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
360 360 status = LFR_DEFAULT;
361 361 }
362 362 else {
363 363 status = LFR_SUCCESSFUL;
364 364 }
365 365 break;
366 366 case LFR_MODE_SBM2:
367 367 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
368 368 status = LFR_DEFAULT;
369 369 }
370 370 else {
371 371 status = LFR_SUCCESSFUL;
372 372 }
373 373 break;
374 374 default:
375 375 status = LFR_DEFAULT;
376 376 break;
377 377 }
378 378
379 379 return status;
380 380 }
381 381
382 382 int stop_current_mode()
383 383 {
384 384 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
385 385 *
386 386 * @return RTEMS directive status codes:
387 387 * - RTEMS_SUCCESSFUL - task restarted successfully
388 388 * - RTEMS_INVALID_ID - task id invalid
389 389 * - RTEMS_ALREADY_SUSPENDED - task already suspended
390 390 *
391 391 */
392 392
393 393 rtems_status_code status;
394 394
395 395 status = RTEMS_SUCCESSFUL;
396 396
397 397 #ifdef GSA
398 398 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
399 399 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
400 400 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
401 401 #else
402 402 // mask interruptions
403 403 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
404 404 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
405 405 // reset registers
406 406 reset_wfp_burst_enable(); // reset burst and enable bits
407 407 reset_wfp_status(); // reset all the status bits
408 408 // creal interruptions
409 409 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
410 410 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
411 411 #endif
412 412 //**********************
413 413 // suspend several tasks
414 414 if (lfrCurrentMode != LFR_MODE_STANDBY) {
415 415 status = suspend_science_tasks();
416 416 }
417 417
418 418 if (status != RTEMS_SUCCESSFUL)
419 419 {
420 420 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
421 421 }
422 422
423 423 return status;
424 424 }
425 425
426 426 int enter_mode(unsigned char mode )
427 427 {
428 428 /** This function is launched after a mode transition validation.
429 429 *
430 430 * @param mode is the mode in which LFR will be put.
431 431 *
432 432 * @return RTEMS directive status codes:
433 433 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
434 434 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
435 435 *
436 436 */
437 437
438 438 rtems_status_code status;
439 439
440 440 status = RTEMS_UNSATISFIED;
441 441
442 442 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
443 443 updateLFRCurrentMode();
444 444
445 445 switch(mode){
446 446 case LFR_MODE_STANDBY:
447 447 status = enter_standby_mode( );
448 448 break;
449 449 case LFR_MODE_NORMAL:
450 450 status = enter_normal_mode( );
451 451 break;
452 452 case LFR_MODE_BURST:
453 453 status = enter_burst_mode( );
454 454 break;
455 455 case LFR_MODE_SBM1:
456 456 status = enter_sbm1_mode( );
457 457 break;
458 458 case LFR_MODE_SBM2:
459 459 status = enter_sbm2_mode( );
460 460 break;
461 461 default:
462 462 status = RTEMS_UNSATISFIED;
463 463 }
464 464
465 465 if (status != RTEMS_SUCCESSFUL)
466 466 {
467 467 PRINTF("in enter_mode *** ERR\n")
468 468 status = RTEMS_UNSATISFIED;
469 469 }
470 470
471 471 return status;
472 472 }
473 473
474 474 int enter_standby_mode()
475 475 {
476 476 /** This function is used to enter the STANDBY mode.
477 477 *
478 478 * @return RTEMS directive status codes:
479 479 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
480 480 *
481 481 */
482 482
483 483 PRINTF1("maxCount = %d\n", maxCount)
484 484
485 485 #ifdef PRINT_TASK_STATISTICS
486 486 rtems_cpu_usage_report();
487 487 #endif
488 488
489 489 #ifdef PRINT_STACK_REPORT
490 490 rtems_stack_checker_report_usage();
491 491 #endif
492 492
493 493 return LFR_SUCCESSFUL;
494 494 }
495 495
496 496 int enter_normal_mode()
497 497 {
498 498 rtems_status_code status;
499 499
500 500 status = restart_science_tasks();
501 501
502 502 #ifdef GSA
503 503 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
504 504 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
505 505 LEON_Clear_interrupt( IRQ_WF );
506 506 LEON_Unmask_interrupt( IRQ_WF );
507 507 //
508 508 set_local_nb_interrupt_f0_MAX();
509 509 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
510 510 LEON_Unmask_interrupt( IRQ_SM );
511 511 #else
512 512 //****************
513 513 // waveform picker
514 514 reset_waveform_picker_regs();
515 515 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
516 516 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
517 517 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
518 518 //****************
519 519 // spectral matrix
520 520 #endif
521 521
522 522 return status;
523 523 }
524 524
525 525 int enter_burst_mode()
526 526 {
527 527 /** This function is used to enter the STANDBY mode.
528 528 *
529 529 * @return RTEMS directive status codes:
530 530 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
531 531 * - RTEMS_INVALID_ID - task id invalid
532 532 * - RTEMS_INCORRECT_STATE - task never started
533 533 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
534 534 *
535 535 */
536 536
537 537 rtems_status_code status;
538 538
539 539 status = restart_science_tasks();
540 540
541 541 #ifdef GSA
542 542 LEON_Unmask_interrupt( IRQ_SM );
543 543 #else
544 544 reset_waveform_picker_regs();
545 545 set_wfp_burst_enable_register(LFR_MODE_BURST);
546 546 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
547 547 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
548 548 #endif
549 549
550 550 return status;
551 551 }
552 552
553 553 int enter_sbm1_mode()
554 554 {
555 555 /** This function is used to enter the SBM1 mode.
556 556 *
557 557 * @return RTEMS directive status codes:
558 558 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
559 559 * - RTEMS_INVALID_ID - task id invalid
560 560 * - RTEMS_INCORRECT_STATE - task never started
561 561 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
562 562 *
563 563 */
564 564
565 565 rtems_status_code status;
566 566
567 567 status = restart_science_tasks();
568 568
569 569 set_local_sbm1_nb_cwf_max();
570 570
571 571 reset_local_sbm1_nb_cwf_sent();
572 572
573 573 #ifdef GSA
574 574 LEON_Unmask_interrupt( IRQ_SM );
575 575 #else
576 576 reset_waveform_picker_regs();
577 577 set_wfp_burst_enable_register(LFR_MODE_SBM1);
578 578 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
579 579 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
580 580 #endif
581 581
582 582 return status;
583 583 }
584 584
585 585 int enter_sbm2_mode()
586 586 {
587 587 /** This function is used to enter the SBM2 mode.
588 588 *
589 589 * @return RTEMS directive status codes:
590 590 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
591 591 * - RTEMS_INVALID_ID - task id invalid
592 592 * - RTEMS_INCORRECT_STATE - task never started
593 593 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
594 594 *
595 595 */
596 596
597 597 rtems_status_code status;
598 598
599 599 status = restart_science_tasks();
600 600
601 601 set_local_sbm2_nb_cwf_max();
602 602
603 603 reset_local_sbm2_nb_cwf_sent();
604 604
605 605 #ifdef GSA
606 606 LEON_Unmask_interrupt( IRQ_SM );
607 607 #else
608 608 reset_waveform_picker_regs();
609 609 set_wfp_burst_enable_register(LFR_MODE_SBM2);
610 610 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
611 611 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
612 612 #endif
613 613
614 614 return status;
615 615 }
616 616
617 617 int restart_science_tasks()
618 618 {
619 619 /** This function is used to restart all science tasks.
620 620 *
621 621 * @return RTEMS directive status codes:
622 622 * - RTEMS_SUCCESSFUL - task restarted successfully
623 623 * - RTEMS_INVALID_ID - task id invalid
624 624 * - RTEMS_INCORRECT_STATE - task never started
625 625 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
626 626 *
627 627 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
628 628 *
629 629 */
630 630
631 631 rtems_status_code status[6];
632 632 rtems_status_code ret;
633 633
634 634 ret = RTEMS_SUCCESSFUL;
635 635
636 636 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
637 637 if (status[0] != RTEMS_SUCCESSFUL)
638 638 {
639 639 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
640 640 }
641 641
642 642 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
643 643 if (status[1] != RTEMS_SUCCESSFUL)
644 644 {
645 645 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
646 646 }
647 647
648 648 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
649 649 if (status[2] != RTEMS_SUCCESSFUL)
650 650 {
651 651 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
652 652 }
653 653
654 654 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
655 655 if (status[3] != RTEMS_SUCCESSFUL)
656 656 {
657 657 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
658 658 }
659 659
660 660 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
661 661 if (status[4] != RTEMS_SUCCESSFUL)
662 662 {
663 663 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
664 664 }
665 665
666 666 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
667 667 if (status[5] != RTEMS_SUCCESSFUL)
668 668 {
669 669 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
670 670 }
671 671
672 672 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
673 673 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
674 674 {
675 675 ret = RTEMS_UNSATISFIED;
676 676 }
677 677
678 678 return ret;
679 679 }
680 680
681 681 int suspend_science_tasks()
682 682 {
683 683 /** This function suspends the science tasks.
684 684 *
685 685 * @return RTEMS directive status codes:
686 686 * - RTEMS_SUCCESSFUL - task restarted successfully
687 687 * - RTEMS_INVALID_ID - task id invalid
688 688 * - RTEMS_ALREADY_SUSPENDED - task already suspended
689 689 *
690 690 */
691 691
692 692 rtems_status_code status;
693 693
694 694 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
695 695 if (status != RTEMS_SUCCESSFUL)
696 696 {
697 697 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
698 698 }
699 699
700 700 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
701 701 {
702 702 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
703 703 if (status != RTEMS_SUCCESSFUL)
704 704 {
705 705 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
706 706 }
707 707 }
708 708
709 709 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
710 710 {
711 711 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
712 712 if (status != RTEMS_SUCCESSFUL)
713 713 {
714 714 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
715 715 }
716 716 }
717 717
718 718 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
719 719 {
720 720 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
721 721 if (status != RTEMS_SUCCESSFUL)
722 722 {
723 723 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
724 724 }
725 725 }
726 726
727 727 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
728 728 {
729 729 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
730 730 if (status != RTEMS_SUCCESSFUL)
731 731 {
732 732 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
733 733 }
734 734 }
735 735
736 736 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
737 737 {
738 738 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
739 739 if (status != RTEMS_SUCCESSFUL)
740 740 {
741 741 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
742 742 }
743 743 }
744 744
745 745 return status;
746 746 }
747 747
748 748 //****************
749 749 // CLOSING ACTIONS
750 750 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time)
751 751 {
752 752 /** This function is used to update the HK packets statistics after a successful TC execution.
753 753 *
754 754 * @param TC points to the TC being processed
755 755 * @param time is the time used to date the TC execution
756 756 *
757 757 */
758 758
759 759 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
760 760 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
761 761 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
762 762 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
763 763 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
764 764 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
765 765 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
766 766 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
767 767 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
768 768 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
769 769 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
770 770 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
771 771 }
772 772
773 773 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time)
774 774 {
775 775 /** This function is used to update the HK packets statistics after a TC rejection.
776 776 *
777 777 * @param TC points to the TC being processed
778 778 * @param time is the time used to date the TC rejection
779 779 *
780 780 */
781 781
782 782 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
783 783 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
784 784 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
785 785 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
786 786 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
787 787 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
788 788 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
789 789 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
790 790 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
791 791 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
792 792 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
793 793 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
794 794 }
795 795
796 796 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time)
797 797 {
798 798 /** This function is the last step of the TC execution workflow.
799 799 *
800 800 * @param TC points to the TC being processed
801 801 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
802 802 * @param queue_id is the id of the RTEMS message queue used to send TM packets
803 803 * @param time is the time used to date the TC execution
804 804 *
805 805 */
806 806
807 807 unsigned int val = 0;
808 808
809 809 if (result == LFR_SUCCESSFUL)
810 810 {
811 811 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
812 812 &&
813 813 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
814 814 )
815 815 {
816 816 send_tm_lfr_tc_exe_success( TC, queue_id, time );
817 817 }
818 818 update_last_TC_exe( TC, time );
819 819 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
820 820 val++;
821 821 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
822 822 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
823 823 }
824 824 else
825 825 {
826 826 update_last_TC_rej( TC, time );
827 827 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
828 828 val++;
829 829 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
830 830 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
831 831 }
832 832 }
833 833
834 834 //***************************
835 835 // Interrupt Service Routines
836 836 rtems_isr commutation_isr1( rtems_vector_number vector )
837 837 {
838 838 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
839 839 printf("In commutation_isr1 *** Error sending event to DUMB\n");
840 840 }
841 841 }
842 842
843 843 rtems_isr commutation_isr2( rtems_vector_number vector )
844 844 {
845 845 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
846 846 printf("In commutation_isr2 *** Error sending event to DUMB\n");
847 847 }
848 848 }
849 849
850 850 //****************
851 851 // OTHER FUNCTIONS
852 852 void updateLFRCurrentMode()
853 853 {
854 854 /** This function updates the value of the global variable lfrCurrentMode.
855 855 *
856 856 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
857 857 *
858 858 */
859 859 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
860 860 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
861 861 }
862 862
@@ -1,1219 +1,1223
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 // SWF
13 13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
14 14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
16 16 // CWF
17 17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
18 18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
22 22
23 23 unsigned char doubleSendCWF1 = 0;
24 24 unsigned char doubleSendCWF2 = 0;
25 25
26 26 rtems_isr waveforms_isr( rtems_vector_number vector )
27 27 {
28 28 /** This is the interrupt sub routine called by the waveform picker core.
29 29 *
30 30 * This ISR launch different actions depending mainly on two pieces of information:
31 31 * 1. the values read in the registers of the waveform picker.
32 32 * 2. the current LFR mode.
33 33 *
34 34 */
35 35
36 36 #ifdef GSA
37 37 #else
38 38 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
39 39 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
40 40 { // in modes other than STANDBY and BURST, send the CWF_F3 data
41 41 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
42 42 // (1) change the receiving buffer for the waveform picker
43 43 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
44 44 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
45 45 }
46 46 else {
47 47 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
48 48 }
49 49 // (2) send an event for the waveforms transmission
50 50 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
51 51 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
52 52 }
53 53 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
54 54 }
55 55 }
56 56 #endif
57 57
58 58 switch(lfrCurrentMode)
59 59 {
60 60 //********
61 61 // STANDBY
62 62 case(LFR_MODE_STANDBY):
63 63 break;
64 64
65 65 //******
66 66 // NORMAL
67 67 case(LFR_MODE_NORMAL):
68 68 #ifdef GSA
69 69 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
70 70 #else
71 71 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
72 72 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
73 73 }
74 74 else {
75 75 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
76 76 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
77 77 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
78 78 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
79 79 }
80 80 // waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
81 81 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888;
82 82 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
83 83 }
84 84 }
85 85 #endif
86 86 break;
87 87
88 88 //******
89 89 // BURST
90 90 case(LFR_MODE_BURST):
91 91 #ifdef GSA
92 92 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
93 93 #else
94 94 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
95 95 // (1) change the receiving buffer for the waveform picker
96 96 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
97 97 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
98 98 }
99 99 else {
100 100 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
101 101 }
102 102 // (2) send an event for the waveforms transmission
103 103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
104 104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
105 105 }
106 106 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
107 107 }
108 108 #endif
109 109 break;
110 110
111 111 //*****
112 112 // SBM1
113 113 case(LFR_MODE_SBM1):
114 114 #ifdef GSA
115 115 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
116 116 #else
117 117 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
118 118 // (1) change the receiving buffer for the waveform picker
119 119 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
120 120 {
121 121 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
122 122 }
123 123 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
124 124 {
125 125 doubleSendCWF1 = 1;
126 126 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
127 127 }
128 128 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
129 129 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
130 130 }
131 131 else {
132 132 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
133 133 }
134 134 // (2) send an event for the waveforms transmission
135 135 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
136 136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 137 }
138 138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
139 139 }
140 140 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
141 141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
142 142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
143 143 }
144 144 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
145 145 reset_local_sbm1_nb_cwf_sent();
146 146 }
147 147
148 148 #endif
149 149 break;
150 150
151 151 //*****
152 152 // SBM2
153 153 case(LFR_MODE_SBM2):
154 154 #ifdef GSA
155 155 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
156 156 #else
157 157 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
158 158 // (1) change the receiving buffer for the waveform picker
159 159 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
160 160 {
161 161 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
162 162 }
163 163 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
164 164 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
165 165 doubleSendCWF2 = 1;
166 166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
167 167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
168 168 }
169 169 reset_local_sbm2_nb_cwf_sent();
170 170 }
171 171 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
172 172 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
173 173 }
174 174 else {
175 175 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
176 176 }
177 177 // (2) send an event for the waveforms transmission
178 178 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
179 179 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
180 180 }
181 181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
182 182 }
183 183 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
184 184 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
185 185 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
186 186 }
187 187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
188 188 }
189 189 #endif
190 190 break;
191 191
192 192 //********
193 193 // DEFAULT
194 194 default:
195 195 break;
196 196 }
197 197 }
198 198
199 199 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
200 200 {
201 201 /** This is the interrupt sub routine called by the waveform picker simulator.
202 202 *
203 203 * This ISR is for debug purpose only.
204 204 *
205 205 */
206 206
207 207 unsigned char lfrMode;
208 208 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
209 209
210 210 switch(lfrMode) {
211 211 case (LFR_MODE_STANDBY):
212 212 break;
213 213 case (LFR_MODE_NORMAL):
214 214 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
215 215 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
216 216 }
217 217 break;
218 218 case (LFR_MODE_BURST):
219 219 break;
220 220 case (LFR_MODE_SBM1):
221 221 break;
222 222 case (LFR_MODE_SBM2):
223 223 break;
224 224 }
225 225 }
226 226
227 227 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
228 228 {
229 229 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
230 230 *
231 231 * @param unused is the starting argument of the RTEMS task
232 232 *
233 233 * The following data packets are sent by this task:
234 234 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
235 235 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
236 236 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
237 237 *
238 238 */
239 239
240 240 rtems_event_set event_out;
241 241 rtems_id queue_id;
242 rtems_status_code status;
242 243
243 244 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
244 245 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
245 246 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
246 247
247 248 init_waveforms();
248 249
249 queue_id = get_pkts_queue_id();
250 status = get_message_queue_id_send( &queue_id );
251 if (status != RTEMS_SUCCESSFUL)
252 {
253 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
254 }
250 255
251 256 BOOT_PRINTF("in WFRM ***\n")
252 257
253 258 while(1){
254 259 // wait for an RTEMS_EVENT
255 260 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
256 261 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
257 262 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
258 263
259 264 if (event_out == RTEMS_EVENT_MODE_NORMAL)
260 265 {
261 266 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
262 267 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
263 268 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
264 269 #ifdef GSA
265 270 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
266 271 #endif
267 272 }
268 273 else if (event_out == RTEMS_EVENT_MODE_SBM1)
269 274 {
270 275 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
271 276 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
272 277 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
273 278 #ifdef GSA
274 279 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
275 280 #endif
276 281 }
277 282 else if (event_out == RTEMS_EVENT_MODE_SBM2)
278 283 {
279 284 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
280 285 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
281 286 #ifdef GSA
282 287 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
283 288 #endif
284 289 }
285 290 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
286 291 {
287 292 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
288 293 }
289 294 else
290 295 {
291 296 PRINTF("in WFRM *** unexpected event")
292 297 }
293 298
294 299
295 300 #ifdef GSA
296 301 // irq processed, reset the related register of the timer unit
297 302 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
298 303 // clear the interruption
299 304 LEON_Unmask_interrupt( IRQ_WF );
300 305 #endif
301 306 }
302 307 }
303 308
304 309 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
305 310 {
306 311 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
307 312 *
308 313 * @param unused is the starting argument of the RTEMS task
309 314 *
310 315 * The following data packet is sent by this task:
311 316 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
312 317 *
313 318 */
314 319
315 320 rtems_event_set event_out;
316 321 rtems_id queue_id;
322 rtems_status_code status;
317 323
318 324 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
319 325 init_header_continuous_wf3_light_table( headerCWF_F3_light );
320 326
321 queue_id = get_pkts_queue_id();
327 status = get_message_queue_id_send( &queue_id );
328 if (status != RTEMS_SUCCESSFUL)
329 {
330 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
331 }
322 332
323 333 BOOT_PRINTF("in CWF3 ***\n")
324 334
325 335 while(1){
326 336 // wait for an RTEMS_EVENT
327 337 rtems_event_receive( RTEMS_EVENT_0,
328 338 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
329 339 PRINTF("send CWF F3 \n")
330 340 #ifdef GSA
331 341 #else
332 342 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
333 343 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
334 344 }
335 345 else {
336 346 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
337 347 }
338 348 #endif
339 349 }
340 350 }
341 351
342 352 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
343 353 {
344 354 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
345 355 *
346 356 * @param unused is the starting argument of the RTEMS task
347 357 *
348 358 * The following data packet is sent by this function:
349 359 * - TM_LFR_SCIENCE_BURST_CWF_F2
350 360 * - TM_LFR_SCIENCE_SBM2_CWF_F2
351 361 *
352 362 */
353 363
354 364 rtems_event_set event_out;
355 365 rtems_id queue_id;
366 rtems_status_code status;
356 367
357 368 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
358 369 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
359 370
360 queue_id = get_pkts_queue_id();
371 status = get_message_queue_id_send( &queue_id );
372 if (status != RTEMS_SUCCESSFUL)
373 {
374 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
375 }
361 376
362 377 BOOT_PRINTF("in CWF2 ***\n")
363 378
364 379 while(1){
365 380 // wait for an RTEMS_EVENT
366 381 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
367 382 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
368 383
369 384 if (event_out == RTEMS_EVENT_MODE_BURST)
370 385 {
371 386 // F2
372 387 #ifdef GSA
373 388 #else
374 389 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
375 390 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
376 391 }
377 392 else {
378 393 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
379 394 }
380 395 #endif
381 396 }
382 397
383 398 else if (event_out == RTEMS_EVENT_MODE_SBM2)
384 399 {
385 400 #ifdef GSA
386 401 #else
387 402 if (doubleSendCWF2 == 1)
388 403 {
389 404 doubleSendCWF2 = 0;
390 405 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
391 406 }
392 407 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
393 408 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
394 409 }
395 410 else {
396 411 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
397 412 }
398 413 param_local.local_sbm2_nb_cwf_sent ++;
399 414 #endif
400 415 }
401 416 else
402 417 {
403 418 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
404 419 }
405 420 }
406 421 }
407 422
408 423 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
409 424 {
410 425 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
411 426 *
412 427 * @param unused is the starting argument of the RTEMS task
413 428 *
414 429 * The following data packet is sent by this function:
415 430 * - TM_LFR_SCIENCE_SBM1_CWF_F1
416 431 *
417 432 */
418 433
419 434 rtems_event_set event_out;
420 435 rtems_id queue_id;
436 rtems_status_code status;
421 437
422 438 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
423 439
424 queue_id = get_pkts_queue_id();
440 status = get_message_queue_id_send( &queue_id );
441 if (status != RTEMS_SUCCESSFUL)
442 {
443 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
444 }
425 445
426 446 BOOT_PRINTF("in CWF1 ***\n")
427 447
428 448 while(1){
429 449 // wait for an RTEMS_EVENT
430 450 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
431 451 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
432 452 if (event_out == RTEMS_EVENT_MODE_SBM1)
433 453 {
434 454 #ifdef GSA
435 455 #else
436 456 if (doubleSendCWF1 == 1)
437 457 {
438 458 doubleSendCWF1 = 0;
439 459 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
440 460 }
441 461 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
442 462 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
443 463 }
444 464 else {
445 465 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
446 466 }
447 467 param_local.local_sbm1_nb_cwf_sent ++;
448 468 #endif
449 469 }
450 470 else
451 471 {
452 472 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
453 473 }
454 474 }
455 475 }
456 476
457 477 //******************
458 478 // general functions
459 479 void init_waveforms( void )
460 480 {
461 481 int i = 0;
462 482
463 483 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
464 484 {
465 485 //***
466 486 // F0
467 487 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
468 488 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
469 489 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
470 490
471 491 //***
472 492 // F1
473 493 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
474 494 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
475 495 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
476 496
477 497 //***
478 498 // F2
479 499 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
480 500 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
481 501 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
482 502
483 503 //***
484 504 // F3
485 505 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
486 506 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
487 507 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
488 508 }
489 509 }
490 510
491 511 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
492 512 {
493 513 unsigned char i;
494 514
495 515 for (i=0; i<7; i++)
496 516 {
497 517 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
498 518 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
499 519 headerSWF[ i ].reserved = DEFAULT_RESERVED;
500 520 headerSWF[ i ].userApplication = CCSDS_USER_APP;
501 521 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
502 522 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
503 523 if (i == 0)
504 524 {
505 525 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
506 526 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
507 527 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
508 528 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
509 529 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
510 530 }
511 531 else if (i == 6)
512 532 {
513 533 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
514 534 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
515 535 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
516 536 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
517 537 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
518 538 }
519 539 else
520 540 {
521 541 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
522 542 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
523 543 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
524 544 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
525 545 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
526 546 }
527 547 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
528 548 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
529 549 headerSWF[ i ].pktNr = i+1; // PKT_NR
530 550 // DATA FIELD HEADER
531 551 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
532 552 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
533 553 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
534 554 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
535 555 // AUXILIARY DATA HEADER
536 556 headerSWF[ i ].time[0] = 0x00;
537 557 headerSWF[ i ].time[0] = 0x00;
538 558 headerSWF[ i ].time[0] = 0x00;
539 559 headerSWF[ i ].time[0] = 0x00;
540 560 headerSWF[ i ].time[0] = 0x00;
541 561 headerSWF[ i ].time[0] = 0x00;
542 562 headerSWF[ i ].sid = sid;
543 563 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
544 564 }
545 565 return LFR_SUCCESSFUL;
546 566 }
547 567
548 568 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
549 569 {
550 570 unsigned int i;
551 571
552 572 for (i=0; i<7; i++)
553 573 {
554 574 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
555 575 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
556 576 headerCWF[ i ].reserved = DEFAULT_RESERVED;
557 577 headerCWF[ i ].userApplication = CCSDS_USER_APP;
558 578 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
559 579 {
560 580 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
561 581 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
562 582 }
563 583 else
564 584 {
565 585 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
566 586 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
567 587 }
568 588 if (i == 0)
569 589 {
570 590 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
571 591 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
572 592 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
573 593 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
574 594 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
575 595 }
576 596 else if (i == 6)
577 597 {
578 598 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
579 599 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
580 600 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
581 601 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
582 602 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
583 603 }
584 604 else
585 605 {
586 606 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
587 607 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
588 608 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
589 609 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
590 610 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
591 611 }
592 612 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
593 613 // PKT_CNT
594 614 // PKT_NR
595 615 // DATA FIELD HEADER
596 616 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
597 617 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
598 618 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
599 619 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
600 620 // AUXILIARY DATA HEADER
601 621 headerCWF[ i ].sid = sid;
602 622 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
603 623 headerCWF[ i ].time[0] = 0x00;
604 624 headerCWF[ i ].time[0] = 0x00;
605 625 headerCWF[ i ].time[0] = 0x00;
606 626 headerCWF[ i ].time[0] = 0x00;
607 627 headerCWF[ i ].time[0] = 0x00;
608 628 headerCWF[ i ].time[0] = 0x00;
609 629 }
610 630 return LFR_SUCCESSFUL;
611 631 }
612 632
613 633 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
614 634 {
615 635 unsigned int i;
616 636
617 637 for (i=0; i<7; i++)
618 638 {
619 639 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
620 640 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
621 641 headerCWF[ i ].reserved = DEFAULT_RESERVED;
622 642 headerCWF[ i ].userApplication = CCSDS_USER_APP;
623 643
624 644 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
625 645 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
626 646 if (i == 0)
627 647 {
628 648 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
629 649 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
630 650 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
631 651 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
632 652 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
633 653 }
634 654 else if (i == 6)
635 655 {
636 656 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
637 657 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
638 658 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
639 659 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
640 660 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
641 661 }
642 662 else
643 663 {
644 664 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
645 665 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
646 666 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
647 667 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
648 668 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
649 669 }
650 670 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
651 671 // DATA FIELD HEADER
652 672 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
653 673 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
654 674 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
655 675 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
656 676 // AUXILIARY DATA HEADER
657 677 headerCWF[ i ].sid = SID_NORM_CWF_F3;
658 678 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
659 679 headerCWF[ i ].time[0] = 0x00;
660 680 headerCWF[ i ].time[0] = 0x00;
661 681 headerCWF[ i ].time[0] = 0x00;
662 682 headerCWF[ i ].time[0] = 0x00;
663 683 headerCWF[ i ].time[0] = 0x00;
664 684 headerCWF[ i ].time[0] = 0x00;
665 685 }
666 686 return LFR_SUCCESSFUL;
667 687 }
668 688
669 689 void reset_waveforms( void )
670 690 {
671 691 int i = 0;
672 692
673 693 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
674 694 {
675 695 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
676 696 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
677 697 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
678 698
679 699 //***
680 700 // F1
681 701 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
682 702 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
683 703 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
684 704
685 705 //***
686 706 // F2
687 707 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
688 708 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
689 709 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
690 710
691 711 //***
692 712 // F3
693 713 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
694 714 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
695 715 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
696 716 }
697 717 }
698 718
699 719 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
700 720 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
701 721 {
702 722 /** This function sends SWF CCSDS packets (F2, F1 or F0).
703 723 *
704 724 * @param waveform points to the buffer containing the data that will be send.
705 725 * @param sid is the source identifier of the data that will be sent.
706 726 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
707 727 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
708 728 * contain information to setup the transmission of the data packets.
709 729 *
710 730 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
711 731 *
712 732 */
713 733
714 734 unsigned int i;
715 735 int ret;
716 736 rtems_status_code status;
717 737 spw_ioctl_pkt_send spw_ioctl_send_SWF;
718 738
719 739 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
720 740 spw_ioctl_send_SWF.options = 0;
721 741
722 742 ret = LFR_DEFAULT;
723 743
724 744 for (i=0; i<7; i++) // send waveform
725 745 {
726 746 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
727 747 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
728 748 // BUILD THE DATA
729 749 if (i==6) {
730 750 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
731 751 }
732 752 else {
733 753 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
734 754 }
735 755 // SET PACKET SEQUENCE COUNTER
736 756 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
737 757 // SET PACKET TIME
738 758 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
739 759 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
740 760 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
741 761 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
742 762 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
743 763 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
744 764 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
745 765 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
746 766 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
747 767 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
748 768 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
749 769 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
750 770 // SEND PACKET
751 771 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
752 772 if (status != RTEMS_SUCCESSFUL) {
753 773 printf("%d-%d, ERR %d\n", sid, i, (int) status);
754 774 ret = LFR_DEFAULT;
755 775 }
756 776 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
757 777 }
758 778
759 779 return ret;
760 780 }
761 781
762 782 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
763 783 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
764 784 {
765 785 /** This function sends CWF CCSDS packets (F2, F1 or F0).
766 786 *
767 787 * @param waveform points to the buffer containing the data that will be send.
768 788 * @param sid is the source identifier of the data that will be sent.
769 789 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
770 790 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
771 791 * contain information to setup the transmission of the data packets.
772 792 *
773 793 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
774 794 *
775 795 */
776 796
777 797 unsigned int i;
778 798 int ret;
779 799 rtems_status_code status;
780 800 spw_ioctl_pkt_send spw_ioctl_send_CWF;
781 801
782 802 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
783 803 spw_ioctl_send_CWF.options = 0;
784 804
785 805 ret = LFR_DEFAULT;
786 806
787 807 for (i=0; i<7; i++) // send waveform
788 808 {
789 809 int coarseTime = 0x00;
790 810 int fineTime = 0x00;
791 811 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
792 812 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
793 813 // BUILD THE DATA
794 814 if (i==6) {
795 815 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
796 816 }
797 817 else {
798 818 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
799 819 }
800 820 // SET PACKET SEQUENCE COUNTER
801 821 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
802 822 // SET PACKET TIME
803 823 coarseTime = time_management_regs->coarse_time;
804 824 fineTime = time_management_regs->fine_time;
805 825 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
806 826 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
807 827 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
808 828 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
809 829 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
810 830 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
811 831 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
812 832 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
813 833 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
814 834 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
815 835 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
816 836 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
817 837 // SEND PACKET
818 838 if (sid == SID_NORM_CWF_F3)
819 839 {
820 840 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
821 841 if (status != RTEMS_SUCCESSFUL) {
822 842 printf("%d-%d, ERR %d\n", sid, i, (int) status);
823 843 ret = LFR_DEFAULT;
824 844 }
825 845 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
826 846 }
827 847 else
828 848 {
829 849 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
830 850 if (status != RTEMS_SUCCESSFUL) {
831 851 printf("%d-%d, ERR %d\n", sid, i, (int) status);
832 852 ret = LFR_DEFAULT;
833 853 }
834 854 }
835 855 }
836 856
837 857 return ret;
838 858 }
839 859
840 860 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
841 861 {
842 862 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
843 863 *
844 864 * @param waveform points to the buffer containing the data that will be send.
845 865 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
846 866 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
847 867 * contain information to setup the transmission of the data packets.
848 868 *
849 869 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
850 870 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
851 871 *
852 872 */
853 873
854 874 unsigned int i;
855 875 int ret;
856 876 rtems_status_code status;
857 877 spw_ioctl_pkt_send spw_ioctl_send_CWF;
858 878 char *sample;
859 879
860 880 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
861 881 spw_ioctl_send_CWF.options = 0;
862 882
863 883 ret = LFR_DEFAULT;
864 884
865 885 //**********************
866 886 // BUILD CWF3_light DATA
867 887 for ( i=0; i< 2048; i++)
868 888 {
869 889 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
870 890 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
871 891 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
872 892 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
873 893 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
874 894 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
875 895 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
876 896 }
877 897
878 898 //*********************
879 899 // SEND CWF3_light DATA
880 900
881 901 for (i=0; i<7; i++) // send waveform
882 902 {
883 903 int coarseTime = 0x00;
884 904 int fineTime = 0x00;
885 905 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
886 906 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
887 907 // BUILD THE DATA
888 908 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
889 909 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
890 910 }
891 911 else {
892 912 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
893 913 }
894 914 // SET PACKET SEQUENCE COUNTER
895 915 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
896 916 // SET PACKET TIME
897 917 coarseTime = time_management_regs->coarse_time;
898 918 fineTime = time_management_regs->fine_time;
899 919 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
900 920 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
901 921 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
902 922 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
903 923 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
904 924 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
905 925 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
906 926 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
907 927 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
908 928 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
909 929 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
910 930 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
911 931 // SEND PACKET
912 932 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
913 933 if (status != RTEMS_SUCCESSFUL) {
914 934 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
915 935 ret = LFR_DEFAULT;
916 936 }
917 937 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
918 938 }
919 939
920 940 return ret;
921 941 }
922 942
923 943
924 944 //**************
925 945 // wfp registers
926 946 void set_wfp_data_shaping()
927 947 {
928 948 /** This function sets the data_shaping register of the waveform picker module.
929 949 *
930 950 * The value is read from one field of the parameter_dump_packet structure:\n
931 951 * bw_sp0_sp1_r0_r1
932 952 *
933 953 */
934 954
935 955 unsigned char data_shaping;
936 956
937 957 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
938 958 // waveform picker : [R1 R0 SP1 SP0 BW]
939 959
940 960 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
941 961
942 962 #ifdef GSA
943 963 #else
944 964 waveform_picker_regs->data_shaping =
945 965 ( (data_shaping & 0x10) >> 4 ) // BW
946 966 + ( (data_shaping & 0x08) >> 2 ) // SP0
947 967 + ( (data_shaping & 0x04) ) // SP1
948 968 + ( (data_shaping & 0x02) << 2 ) // R0
949 969 + ( (data_shaping & 0x01) << 4 ); // R1
950 970 #endif
951 971 }
952 972
953 973 char set_wfp_delta_snapshot()
954 974 {
955 975 /** This function sets the delta_snapshot register of the waveform picker module.
956 976 *
957 977 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
958 978 * - sy_lfr_n_swf_p[0]
959 979 * - sy_lfr_n_swf_p[1]
960 980 *
961 981 */
962 982
963 983 char ret;
964 984 unsigned int delta_snapshot;
965 985 unsigned int aux;
966 986
967 987 aux = 0;
968 988 ret = LFR_DEFAULT;
969 989
970 990 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
971 991 + parameter_dump_packet.sy_lfr_n_swf_p[1];
972 992
973 993 #ifdef GSA
974 994 #else
975 995 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
976 996 {
977 997 aux = MIN_DELTA_SNAPSHOT;
978 998 ret = LFR_DEFAULT;
979 999 }
980 1000 else
981 1001 {
982 1002 aux = delta_snapshot ;
983 1003 ret = LFR_SUCCESSFUL;
984 1004 }
985 1005 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
986 1006 #endif
987 1007
988 1008 return ret;
989 1009 }
990 1010
991 1011 void set_wfp_burst_enable_register( unsigned char mode)
992 1012 {
993 1013 /** This function sets the waveform picker burst_enable register depending on the mode.
994 1014 *
995 1015 * @param mode is the LFR mode to launch.
996 1016 *
997 1017 * The burst bits shall be before the enable bits.
998 1018 *
999 1019 */
1000 1020
1001 1021 #ifdef GSA
1002 1022 #else
1003 1023 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1004 1024 // the burst bits shall be set first, before the enable bits
1005 1025 switch(mode) {
1006 1026 case(LFR_MODE_NORMAL):
1007 1027 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
1008 1028 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1009 1029 break;
1010 1030 case(LFR_MODE_BURST):
1011 1031 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1012 1032 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
1013 1033 break;
1014 1034 case(LFR_MODE_SBM1):
1015 1035 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
1016 1036 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1017 1037 break;
1018 1038 case(LFR_MODE_SBM2):
1019 1039 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1020 1040 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1021 1041 break;
1022 1042 default:
1023 1043 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1024 1044 break;
1025 1045 }
1026 1046 #endif
1027 1047 }
1028 1048
1029 1049 void reset_wfp_burst_enable()
1030 1050 {
1031 1051 /** This function resets the waveform picker burst_enable register.
1032 1052 *
1033 1053 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1034 1054 *
1035 1055 */
1036 1056
1037 1057 #ifdef GSA
1038 1058 #else
1039 1059 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1040 1060 #endif
1041 1061 }
1042 1062
1043 1063 void reset_wfp_status()
1044 1064 {
1045 1065 /** This function resets the waveform picker status register.
1046 1066 *
1047 1067 * All status bits are set to 0 [new_err full_err full].
1048 1068 *
1049 1069 */
1050 1070
1051 1071 #ifdef GSA
1052 1072 #else
1053 1073 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1054 1074 #endif
1055 1075 }
1056 1076
1057 1077 void reset_waveform_picker_regs()
1058 1078 {
1059 1079 /** This function resets the waveform picker module registers.
1060 1080 *
1061 1081 * The registers affected by this function are located at the following offset addresses:
1062 1082 * - 0x00 data_shaping
1063 1083 * - 0x04 burst_enable
1064 1084 * - 0x08 addr_data_f0
1065 1085 * - 0x0C addr_data_f1
1066 1086 * - 0x10 addr_data_f2
1067 1087 * - 0x14 addr_data_f3
1068 1088 * - 0x18 status
1069 1089 * - 0x1C delta_snapshot
1070 1090 * - 0x20 delta_f2_f1
1071 1091 * - 0x24 delta_f2_f0
1072 1092 * - 0x28 nb_burst
1073 1093 * - 0x2C nb_snapshot
1074 1094 *
1075 1095 */
1076 1096
1077 1097 #ifdef GSA
1078 1098 #else
1079 1099 reset_wfp_burst_enable();
1080 1100 reset_wfp_status();
1081 1101 // set buffer addresses
1082 1102 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
1083 1103 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
1084 1104 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
1085 1105 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
1086 1106 // set other parameters
1087 1107 set_wfp_data_shaping();
1088 1108 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1089 1109 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1090 1110 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1091 1111 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1092 1112 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1093 1113 #endif
1094 1114 }
1095 1115
1096 1116 //*****************
1097 1117 // local parameters
1098 1118 void set_local_sbm1_nb_cwf_max( void )
1099 1119 {
1100 1120 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1101 1121 *
1102 1122 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1103 1123 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1104 1124 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1105 1125 *
1106 1126 */
1107 1127 param_local.local_sbm1_nb_cwf_max = 2 *
1108 1128 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1109 1129 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1110 1130 }
1111 1131
1112 1132 void set_local_sbm2_nb_cwf_max(void)
1113 1133 {
1114 1134 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1115 1135 *
1116 1136 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1117 1137 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1118 1138 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1119 1139 *
1120 1140 */
1121 1141
1122 1142 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1123 1143 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1124 1144 }
1125 1145
1126 1146 void set_local_nb_interrupt_f0_MAX( void )
1127 1147 {
1128 1148 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1129 1149 *
1130 1150 * This parameter is used for the SM validation only.\n
1131 1151 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1132 1152 * module before launching a basic processing.
1133 1153 *
1134 1154 */
1135 1155
1136 1156 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1137 1157 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1138 1158 }
1139 1159
1140 1160 void reset_local_sbm1_nb_cwf_sent( void )
1141 1161 {
1142 1162 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1143 1163 *
1144 1164 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1145 1165 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1146 1166 *
1147 1167 */
1148 1168
1149 1169 param_local.local_sbm1_nb_cwf_sent = 0;
1150 1170 }
1151 1171
1152 1172 void reset_local_sbm2_nb_cwf_sent( void )
1153 1173 {
1154 1174 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1155 1175 *
1156 1176 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1157 1177 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1158 1178 *
1159 1179 */
1160 1180
1161 1181 param_local.local_sbm2_nb_cwf_sent = 0;
1162 1182 }
1163 1183
1164 rtems_id get_pkts_queue_id( void )
1165 {
1166 rtems_id queue_id;
1167 rtems_status_code status;
1168 rtems_name queue_send_name;
1169
1170 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1171
1172 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1173 if (status != RTEMS_SUCCESSFUL)
1174 {
1175 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1176 }
1177 return queue_id;
1178 }
1179
1180 1184 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1181 1185 {
1182 1186 unsigned short *sequence_cnt;
1183 1187 unsigned short segmentation_grouping_flag;
1184 1188 unsigned short new_packet_sequence_control;
1185 1189
1186 1190 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1187 1191 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1188 1192 {
1189 1193 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1190 1194 }
1191 1195 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1192 1196 {
1193 1197 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1194 1198 }
1195 1199 else
1196 1200 {
1197 1201 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1198 1202 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1199 1203 }
1200 1204
1201 1205 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1202 1206 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1203 1207
1204 1208 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1205 1209
1206 1210 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1207 1211 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1208 1212
1209 1213 // increment the seuqence counter for the next packet
1210 1214 if ( *sequence_cnt < SEQ_CNT_MAX)
1211 1215 {
1212 1216 *sequence_cnt = *sequence_cnt + 1;
1213 1217 }
1214 1218 else
1215 1219 {
1216 1220 *sequence_cnt = 0;
1217 1221 }
1218 1222
1219 1223 }
General Comments 0
You need to be logged in to leave comments. Login now