##// END OF EJS Templates
ICD 2.0...
paul -
r92:7c50b5fd63ee VHDLib206
parent child
Show More
@@ -1,248 +1,248
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw-vhdl-dev
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Jan 23 13:51:15 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Mon Jan 27 07:11:41 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES -DVHDL_DEV
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-vhdl-dev
91 91 DESTDIR = bin/
92 92 TARGET = bin/fsw-vhdl-dev
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/fsw-vhdl-dev1.0.0 || $(MKDIR) obj/fsw-vhdl-dev1.0.0
174 174 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw-vhdl-dev1.0.0/ && (cd `dirname obj/fsw-vhdl-dev1.0.0` && $(TAR) fsw-vhdl-dev1.0.0.tar fsw-vhdl-dev1.0.0 && $(COMPRESS) fsw-vhdl-dev1.0.0.tar) && $(MOVE) `dirname obj/fsw-vhdl-dev1.0.0`/fsw-vhdl-dev1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw-vhdl-dev1.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,311 +1,311
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.0, 2014-01-24T06:51:07. -->
3 <!-- Written by QtCreator 3.0.0, 2014-01-28T06:58: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="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">System</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">1</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 118 </valuemap>
119 119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 120 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
123 123 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
126 126 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
127 127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
128 128 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
129 129 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
130 130 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
131 131 </valuemap>
132 132 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
133 133 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
134 134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
136 136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
137 137 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
138 138 <value type="QString">-w</value>
139 139 <value type="QString">-r</value>
140 140 </valuelist>
141 141 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
142 142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
143 143 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
144 144 </valuemap>
145 145 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
146 146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
147 147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
148 148 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
149 149 </valuemap>
150 150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
151 151 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
152 152 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
153 153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
154 154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
155 155 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
156 156 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
157 157 <value type="QString">-w</value>
158 158 <value type="QString">-r</value>
159 159 </valuelist>
160 160 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
161 161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
162 162 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
163 163 </valuemap>
164 164 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
165 165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
166 166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
167 167 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
168 168 </valuemap>
169 169 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
170 170 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
171 171 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
174 174 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
175 175 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</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">No deployment</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 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
195 195 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
196 196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
197 197 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
198 198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
199 199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
200 200 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
201 201 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
202 202 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
203 203 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</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="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
207 207 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
208 208 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
209 209 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
210 210 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
211 211 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
212 212 <value type="int">0</value>
213 213 <value type="int">1</value>
214 214 <value type="int">2</value>
215 215 <value type="int">3</value>
216 216 <value type="int">4</value>
217 217 <value type="int">5</value>
218 218 <value type="int">6</value>
219 219 <value type="int">7</value>
220 220 <value type="int">8</value>
221 221 <value type="int">9</value>
222 222 <value type="int">10</value>
223 223 <value type="int">11</value>
224 224 <value type="int">12</value>
225 225 <value type="int">13</value>
226 226 <value type="int">14</value>
227 227 </valuelist>
228 228 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
229 229 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
230 230 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
231 231 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
232 232 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
233 233 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
234 234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
235 235 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
236 236 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
237 237 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
238 238 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
239 239 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
240 240 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
241 241 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
242 242 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
243 243 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
244 244 </valuemap>
245 245 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
246 246 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
247 247 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
248 248 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
249 249 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
250 250 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
251 251 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
252 252 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
253 253 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
254 254 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
255 255 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
256 256 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
257 257 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
258 258 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
259 259 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
260 260 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
261 261 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
262 262 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
263 263 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
264 264 <value type="int">0</value>
265 265 <value type="int">1</value>
266 266 <value type="int">2</value>
267 267 <value type="int">3</value>
268 268 <value type="int">4</value>
269 269 <value type="int">5</value>
270 270 <value type="int">6</value>
271 271 <value type="int">7</value>
272 272 <value type="int">8</value>
273 273 <value type="int">9</value>
274 274 <value type="int">10</value>
275 275 <value type="int">11</value>
276 276 <value type="int">12</value>
277 277 <value type="int">13</value>
278 278 <value type="int">14</value>
279 279 </valuelist>
280 280 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
281 281 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
282 282 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
283 283 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value>
284 284 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value>
285 285 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value>
286 286 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value>
287 287 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
288 288 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
289 289 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
290 290 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
291 291 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
292 292 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
293 293 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
294 294 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
295 295 </valuemap>
296 296 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
297 297 </valuemap>
298 298 </data>
299 299 <data>
300 300 <variable>ProjectExplorer.Project.TargetCount</variable>
301 301 <value type="int">1</value>
302 302 </data>
303 303 <data>
304 304 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
305 305 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
306 306 </data>
307 307 <data>
308 308 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
309 309 <value type="int">15</value>
310 310 </data>
311 311 </qtcreator>
@@ -1,197 +1,199
1 1 #ifndef TC_TYPES_H
2 2 #define TC_TYPES_H
3 3
4 4 #include <ccsds_types.h>
5 5
6 6 #define PROTOCOLE_IDENTIFIER 0x02
7 7
8 8 // PACKET ID
9 9 #define TC_LFR_PACKET_ID 0x1ccc // PID 76 CAT 12
10 10
11 11 #define PACKET_LENGTH_TC_LFR_RESET (12 - CCSDS_TC_TM_PACKET_OFFSET)
12 12 #define PACKET_LENGTH_TC_LFR_LOAD_COMMON_PAR (14 - CCSDS_TC_TM_PACKET_OFFSET)
13 #define PACKET_LENGTH_TC_LFR_LOAD_NORMAL_PAR (20 - CCSDS_TC_TM_PACKET_OFFSET)
13 #define PACKET_LENGTH_TC_LFR_LOAD_NORMAL_PAR (22 - CCSDS_TC_TM_PACKET_OFFSET)
14 14 #define PACKET_LENGTH_TC_LFR_LOAD_BURST_PAR (14 - CCSDS_TC_TM_PACKET_OFFSET)
15 15 #define PACKET_LENGTH_TC_LFR_LOAD_SBM1_PAR (14 - CCSDS_TC_TM_PACKET_OFFSET)
16 16 #define PACKET_LENGTH_TC_LFR_LOAD_SBM2_PAR (14 - CCSDS_TC_TM_PACKET_OFFSET)
17 17 #define PACKET_LENGTH_TC_LFR_DUMP_PAR (12 - CCSDS_TC_TM_PACKET_OFFSET)
18 18 #define PACKET_LENGTH_TC_LFR_ENTER_MODE (20 - CCSDS_TC_TM_PACKET_OFFSET)
19 #define PACKET_LENGTH_TC_LFR_UPDATE_INFO (48 - CCSDS_TC_TM_PACKET_OFFSET)
19 #define PACKET_LENGTH_TC_LFR_UPDATE_INFO (46 - CCSDS_TC_TM_PACKET_OFFSET)
20 20 #define PACKET_LENGTH_TC_LFR_ENABLE_CALIBRATION (12 - CCSDS_TC_TM_PACKET_OFFSET)
21 21 #define PACKET_LENGTH_TC_LFR_DISABLE_CALIBRATION (12 - CCSDS_TC_TM_PACKET_OFFSET)
22 22 #define PACKET_LENGTH_TC_LFR_UPDATE_TIME (18 - CCSDS_TC_TM_PACKET_OFFSET)
23 23
24 24 // TC TYPES
25 25 #define TC_TYPE_DEFAULT 181
26 26 #define TC_TYPE_LFR_UPDATE_TIME 9
27 27
28 28 // TC SUBTYPES
29 29 #define TC_SUBTYPE_RESET 1
30 30 #define TC_SUBTYPE_LOAD_COMMON_PAR 11
31 31 #define TC_SUBTYPE_LOAD_NORMAL_PAR 13
32 32 #define TC_SUBTYPE_LOAD_BURST_PAR 19
33 33 #define TC_SUBTYPE_LOAD_SBM1_PAR 25
34 34 #define TC_SUBTYPE_LOAD_SBM2_PAR 27
35 35 #define TC_SUBTYPE_DUMP_PAR 31
36 36 #define TC_SUBTYPE_ENTER_MODE 41
37 37 #define TC_SUBTYPE_UPDATE_INFO 51
38 38 #define TC_SUBTYPE_ENABLE_CALIBRATION 61
39 39 #define TC_SUBTYPE_DISABLE_CALIBRATION 63
40 40 #define TC_SUBTYPE_UPDATE_TIME 129
41 41
42 42 // OTHER CONSTANTS
43 43 #define TC_LFR_PACKET_SEQUENCE_CONTROL 0xc000 // PID 76 CAT 12
44 44 #define TC_LFR_DATA_FIELD_HEADER0 0x19
45 45 #define TC_LFR_LOAD_COMMON_PAR_SPARE 0x00
46 46
47 47 struct Packet_TC_LFR_RESET_str
48 48 { // the CCSDS header is added by LPPMON
49 49 unsigned char packetID[2];
50 50 unsigned char packetSequenceControl[2];
51 51 unsigned char packetLength[2];
52 52 // DATA FIELD HEADER
53 53 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
54 54 unsigned char serviceType;
55 55 unsigned char serviceSubType;
56 56 unsigned char sourceID;
57 57 unsigned char crc[2];
58 58 };
59 59 typedef struct Packet_TC_LFR_RESET_str Packet_TC_LFR_RESET_t;
60 60
61 61 struct Packet_TC_LFR_ENTER_MODE_str
62 62 { // the CCSDS header is added by LPPMON
63 63 unsigned char packetID[2];
64 64 unsigned char packetSequenceControl[2];
65 65 unsigned char packetLength[2];
66 66 // DATA FIELD HEADER
67 67 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
68 68 unsigned char serviceType;
69 69 unsigned char serviceSubType;
70 70 unsigned char sourceID;
71 71 unsigned char spare;
72 72 unsigned char mode;
73 73 unsigned char enterModeTime[6];
74 74 unsigned char crc[2];
75 75 };
76 76 typedef struct Packet_TC_LFR_ENTER_MODE_str Packet_TC_LFR_ENTER_MODE_t;
77 77
78 78 struct Packet_TC_LFR_UPDATE_INFO_str
79 79 { // the CCSDS header is added by LPPMON
80 80 unsigned char packetID[2];
81 81 unsigned char packetSequenceControl[2];
82 82 unsigned char packetLength[2];
83 83 // DATA FIELD HEADER
84 84 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
85 85 unsigned char serviceType;
86 86 unsigned char serviceSubType;
87 87 unsigned char sourceID;
88 88 unsigned char set1;
89 89 unsigned char set2;
90 90 unsigned char set3_bias_setting_set1[6];
91 91 unsigned char set3_bias_setting_set2[6];
92 92 unsigned char set3_bias_voltage[4];
93 93 unsigned char set4[8];
94 94 unsigned char set5;
95 95 unsigned char set6;
96 96 unsigned char set7[8];
97 97 unsigned char crc[2];
98 98 };
99 99 typedef struct Packet_TC_LFR_UPDATE_INFO_str Packet_TC_LFR_UPDATE_INFO_t;
100 100
101 101 struct Packet_TC_LFR_DUMP_PAR_str
102 102 { // the CCSDS header is added by LPPMON
103 103 unsigned char packetID[2];
104 104 unsigned char packetSequenceControl[2];
105 105 unsigned char packetLength[2];
106 106 // DATA FIELD HEADER
107 107 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
108 108 unsigned char serviceType;
109 109 unsigned char serviceSubType;
110 110 unsigned char sourceID;
111 111 unsigned char crc[2];
112 112
113 113 };
114 114 typedef struct Packet_TC_LFR_DUMP_PAR_str Packet_TC_LFR_DUMP_PAR_t;
115 115
116 116 struct Packet_TC_LFR_LOAD_COMMON_PAR_str
117 117 { // the CCSDS header is added by LPPMON
118 118 unsigned char packetID[2];
119 119 unsigned char packetSequenceControl[2];
120 120 unsigned char packetLength[2];
121 121 // DATA FIELD HEADER
122 122 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
123 123 unsigned char serviceType;
124 124 unsigned char serviceSubType;
125 125 unsigned char sourceID;
126 126 unsigned char spare;
127 127 unsigned char bw_sp0_sp1_r0_r1;
128 128 unsigned char crc[2];
129 129
130 130 };
131 131 typedef struct Packet_TC_LFR_LOAD_COMMON_PAR_str Packet_TC_LFR_LOAD_COMMON_PAR_t;
132 132
133 133 struct Packet_TC_LFR_LOAD_NORMAL_PAR_str
134 134 { // the CCSDS header is added by LPPMON
135 135 unsigned char packetID[2];
136 136 unsigned char packetSequenceControl[2];
137 137 unsigned char packetLength[2];
138 138 // DATA FIELD HEADER
139 139 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
140 140 unsigned char serviceType;
141 141 unsigned char serviceSubType;
142 142 unsigned char sourceID;
143 143 unsigned char sy_lfr_n_swf_l[2];
144 144 unsigned char sy_lfr_n_swf_p[2];
145 145 unsigned char sy_lfr_n_asm_p[2];
146 146 unsigned char sy_lfr_n_bp_p0;
147 147 unsigned char sy_lfr_n_bp_p1;
148 unsigned char sy_lfr_n_cwf_long_f3;
149 unsigned char lfr_normal_parameters_spare;
148 150 unsigned char crc[2];
149 151 };
150 152 typedef struct Packet_TC_LFR_LOAD_NORMAL_PAR_str Packet_TC_LFR_LOAD_NORMAL_PAR_t;
151 153
152 154 struct Packet_TC_LFR_LOAD_BURST_SBM1_SBM2_PAR_str
153 155 { // the CCSDS header is added by LPPMON
154 156 unsigned char packetID[2];
155 157 unsigned char packetSequenceControl[2];
156 158 unsigned char packetLength[2];
157 159 // DATA FIELD HEADER
158 160 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
159 161 unsigned char serviceType;
160 162 unsigned char serviceSubType;
161 163 unsigned char sourceID;
162 164 unsigned char sy_lfr_bp_p0;
163 165 unsigned char sy_lfr_bp_p1;
164 166 unsigned char crc[2];
165 167 };
166 168 typedef struct Packet_TC_LFR_LOAD_BURST_SBM1_SBM2_PAR_str Packet_TC_LFR_LOAD_BURST_SBM1_SBM2_PAR_t;
167 169
168 170 struct Packet_TC_LFR_ENABLE_DISABLE_CALIBRATION_str
169 171 { // the CCSDS header is added by LPPMON
170 172 unsigned char packetID[2];
171 173 unsigned char packetSequenceControl[2];
172 174 unsigned char packetLength[2];
173 175 // DATA FIELD HEADER
174 176 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
175 177 unsigned char serviceType;
176 178 unsigned char serviceSubType;
177 179 unsigned char sourceID;
178 180 unsigned char crc[2];
179 181 };
180 182 typedef struct Packet_TC_LFR_ENABLE_DISABLE_CALIBRATION_str Packet_TC_LFR_ENABLE_DISABLE_CALIBRATION_t;
181 183
182 184 struct Packet_TC_LFR_UPDATE_TIME_str
183 185 { // the CCSDS header is added by LPPMON
184 186 unsigned char packetID[2];
185 187 unsigned char packetSequenceControl[2];
186 188 unsigned char packetLength[2];
187 189 // DATA FIELD HEADER
188 190 unsigned char ccsdsSecHeaderFlag_pusVersion_ack;
189 191 unsigned char serviceType;
190 192 unsigned char serviceSubType;
191 193 unsigned char sourceID;
192 194 unsigned char cp_rpw_time[6];
193 195 unsigned char crc[2];
194 196 };
195 197 typedef struct Packet_TC_LFR_UPDATE_TIME_str Packet_TC_LFR_UPDATE_TIME_t;
196 198
197 199 #endif // TC_TYPES_H
@@ -1,599 +1,603
1 1 #ifndef CCSDS_TYPES_H_INCLUDED
2 2 #define CCSDS_TYPES_H_INCLUDED
3 3
4 4 #define CCSDS_PROTOCOLE_EXTRA_BYTES 4
5 5 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
6 6 #define CCSDS_TM_PKT_MAX_SIZE 4412
7 7 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
8 8 #define CCSDS_TC_PKT_MAX_SIZE 256
9 9 #define CCSDS_TC_PKT_MIN_SIZE 16
10 10 #define CCSDS_TC_TM_PACKET_OFFSET 7
11 11 #define CCSDS_PROCESS_ID 76
12 12 #define CCSDS_PACKET_CATEGORY 12
13 13 #define CCSDS_NODE_ADDRESS 0xfe
14 14 #define CCSDS_USER_APP 0x00
15 15
16 16 #define DEFAULT_SPARE1_PUSVERSION_SPARE2 0x10
17 17 #define DEFAULT_RESERVED 0x00
18 18 #define DEFAULT_HKBIA 0x1e // 0001 1110
19 19
20 20 // PACKET ID
21 21 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
22 22 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
23 23 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
24 24 #define TM_PACKET_ID_SCIENCE_NORMAL_BURST 0x0ccc // PID 76 CAT 12
25 25 #define TM_PACKET_ID_SCIENCE_SBM1_SBM2 0x0cfc // PID 79 CAT 12
26 26 #define TM_PACKET_PID_DEFAULT 76
27 27 #define TM_PACKET_PID_BURST_SBM1_SBM2 79
28 28 #define TM_PACKET_CAT_TC_EXE 1
29 29 #define TM_PACKET_CAT_HK 4
30 30 #define TM_PACKET_CAT_PARAMETER_DUMP 9
31 31 #define TM_PACKET_CAT_SCIENCE 12
32 32
33 33 // PACKET SEQUENCE CONTROL
34 34 #define TM_PACKET_SEQ_CTRL_CONTINUATION 0x00 // [0000 0000]
35 35 #define TM_PACKET_SEQ_CTRL_FIRST 0x40 // [0100 0000]
36 36 #define TM_PACKET_SEQ_CTRL_LAST 0x80 // [1000 0000]
37 37 #define TM_PACKET_SEQ_CTRL_STANDALONE 0xc0 // [1100 0000]
38 38 #define TM_PACKET_SEQ_CNT_DEFAULT 0x00 // [0000 0000]
39 39
40 40 // DESTINATION ID
41 41 #define TM_DESTINATION_ID_GROUND 0
42 42 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
43 43 #define TM_DESTINATION_ID_TC_SEQUENCES 111
44 44 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
45 45 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
46 46 #define TM_DESTINATION_ID_DIRECT_CMD 120
47 47 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
48 48 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
49 49 #define TM_DESTINATION_ID_OBCP 15
50 50 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
51 51 #define TM_DESTINATION_ID_AOCS 11
52 52
53 53 #define CCSDS_DESTINATION_ID 0x01
54 54 #define CCSDS_PROTOCOLE_ID 0x02
55 55 #define CCSDS_RESERVED 0x00
56 56 #define CCSDS_USER_APP 0x00
57 57
58 58 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
59 59 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
60 60 #define SIZE_HK_PARAMETERS 112
61 61
62 62 // TC TYPES
63 63 #define TC_TYPE_GEN 181
64 64 #define TC_TYPE_TIME 9
65 65
66 66 // TC SUBTYPES
67 67 #define TC_SUBTYPE_RESET 1
68 68 #define TC_SUBTYPE_LOAD_COMM 11
69 69 #define TC_SUBTYPE_LOAD_NORM 13
70 70 #define TC_SUBTYPE_LOAD_BURST 19
71 71 #define TC_SUBTYPE_LOAD_SBM1 25
72 72 #define TC_SUBTYPE_LOAD_SBM2 27
73 73 #define TC_SUBTYPE_DUMP 31
74 74 #define TC_SUBTYPE_ENTER 41
75 75 #define TC_SUBTYPE_UPDT_INFO 51
76 76 #define TC_SUBTYPE_EN_CAL 61
77 77 #define TC_SUBTYPE_DIS_CAL 63
78 78 #define TC_SUBTYPE_UPDT_TIME 129
79 79
80 80 // TC LEN
81 81 #define TC_LEN_RESET 12
82 82 #define TC_LEN_LOAD_COMM 14
83 #define TC_LEN_LOAD_NORM 20
83 #define TC_LEN_LOAD_NORM 22
84 84 #define TC_LEN_LOAD_BURST 14
85 85 #define TC_LEN_LOAD_SBM1 14
86 86 #define TC_LEN_LOAD_SBM2 14
87 87 #define TC_LEN_DUMP 12
88 88 #define TC_LEN_ENTER 20
89 #define TC_LEN_UPDT_INFO 48
89 #define TC_LEN_UPDT_INFO 46
90 90 #define TC_LEN_EN_CAL 12
91 91 #define TC_LEN_DIS_CAL 12
92 92 #define TC_LEN_UPDT_TIME 18
93 93
94 94 // TM TYPES
95 95 #define TM_TYPE_TC_EXE 1
96 96 #define TM_TYPE_HK 3
97 97 #define TM_TYPE_PARAMETER_DUMP 3
98 98 #define TM_TYPE_LFR_SCIENCE 21
99 99
100 100 // TM SUBTYPES
101 101 #define TM_SUBTYPE_EXE_OK 7
102 102 #define TM_SUBTYPE_EXE_NOK 8
103 103 #define TM_SUBTYPE_HK 25
104 104 #define TM_SUBTYPE_PARAMETER_DUMP 25
105 105 #define TM_SUBTYPE_SCIENCE 3
106 106 #define TM_SUBTYPE_LFR_SCIENCE 3
107 107
108 108 // FAILURE CODES
109 109 #define ILLEGAL_APID 0
110 110 #define WRONG_LEN_PKT 1
111 111 #define INCOR_CHECKSUM 2
112 112 #define ILL_TYPE 3
113 113 #define ILL_SUBTYPE 4
114 114 #define WRONG_APP_DATA 5 // 0x00 0x05
115 115 #define TC_NOT_EXE 42000 // 0xa4 0x10
116 116 #define WRONG_SRC_ID 42001 // 0xa4 0x11
117 117 #define FUNCT_NOT_IMPL 42002 // 0xa4 0x12
118 118 #define FAIL_DETECTED 42003 // 0xa4 0x13
119 119 #define NOT_ALLOWED 42004 // 0xa4 0x14
120 120 #define CORRUPTED 42005 // 0xa4 0x15
121 121 #define CCSDS_TM_VALID 7
122 122
123 123 // TC SID
124 124 #define SID_TC_GROUND 0
125 125 #define SID_TC_MISSION_TIMELINE 110
126 126 #define SID_TC_TC_SEQUENCES 111
127 127 #define SID_TC_RECOVERY_ACTION_CMD 112
128 128 #define SID_TC_BACKUP_MISSION_TIMELINE 113
129 129 #define SID_TC_DIRECT_CMD 120
130 130 #define SID_TC_SPARE_GRD_SRC1 121
131 131 #define SID_TC_SPARE_GRD_SRC2 122
132 132 #define SID_TC_OBCP 15
133 133 #define SID_TC_SYSTEM_CONTROL 14
134 134 #define SID_TC_AOCS 11
135 135 #define SID_TC_RPW_INTERNAL 254
136 136
137 137 enum apid_destid{
138 138 GROUND,
139 139 MISSION_TIMELINE,
140 140 TC_SEQUENCES,
141 141 RECOVERY_ACTION_CMD,
142 142 BACKUP_MISSION_TIMELINE,
143 143 DIRECT_CMD,
144 144 SPARE_GRD_SRC1,
145 145 SPARE_GRD_SRC2,
146 146 OBCP,
147 147 SYSTEM_CONTROL,
148 148 AOCS,
149 149 RPW_INTERNAL
150 150 };
151 151 // SEQUENCE COUNTERS
152 152 #define SEQ_CNT_MAX 16383
153 153 #define SEQ_CNT_NB_DEST_ID 12
154 154
155 155 // TM SID
156 156 #define SID_HK 1
157 157 #define SID_PARAMETER_DUMP 10
158 158
159 159 #define SID_NORM_SWF_F0 3
160 160 #define SID_NORM_SWF_F1 4
161 161 #define SID_NORM_SWF_F2 5
162 162 #define SID_NORM_CWF_F3 1
163 163 #define SID_BURST_CWF_F2 2
164 164 #define SID_SBM1_CWF_F1 24
165 165 #define SID_SBM2_CWF_F2 25
166 166 #define SID_NORM_ASM_F0 11
167 167 #define SID_NORM_ASM_F1 12
168 168 #define SID_NORM_ASM_F2 13
169 169 #define SID_NORM_BP1_F0 14
170 170 #define SID_NORM_BP1_F1 15
171 171 #define SID_NORM_BP1_F2 16
172 172 #define SID_NORM_BP2_F0 19
173 173 #define SID_NORM_BP2_F1 20
174 174 #define SID_NORM_BP2_F2 21
175 175 #define SID_BURST_BP1_F0 17
176 176 #define SID_BURST_BP2_F0 22
177 177 #define SID_BURST_BP1_F1 18
178 178 #define SID_BURST_BP2_F1 23
179 179 #define SID_SBM1_BP1_F0 28
180 180 #define SID_SBM1_BP2_F0 31
181 181 #define SID_SBM2_BP1_F0 29
182 182 #define SID_SBM2_BP2_F0 32
183 183 #define SID_SBM2_BP1_F1 30
184 184 #define SID_SBM2_BP2_F1 33
185 #define SID_NORM_CWF_LONG_F3 34
185 186
186 187 // LENGTH (BYTES)
187 188 #define LENGTH_TM_LFR_TC_EXE_MAX 32
188 189 #define LENGTH_TM_LFR_HK 126
189 190
190 191 // HEADER_LENGTH
191 192 #define TM_HEADER_LEN 16
192 193 #define HEADER_LENGTH_TM_LFR_SCIENCE_ASM 28
193 194 // PACKET_LENGTH
194 195 #define PACKET_LENGTH_TC_EXE_SUCCESS (20 - CCSDS_TC_TM_PACKET_OFFSET)
195 196 #define PACKET_LENGTH_TC_EXE_INCONSISTENT (26 - CCSDS_TC_TM_PACKET_OFFSET)
196 197 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE (26 - CCSDS_TC_TM_PACKET_OFFSET)
197 198 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED (24 - CCSDS_TC_TM_PACKET_OFFSET)
198 199 #define PACKET_LENGTH_TC_EXE_ERROR (24 - CCSDS_TC_TM_PACKET_OFFSET)
199 200 #define PACKET_LENGTH_TC_EXE_CORRUPTED (32 - CCSDS_TC_TM_PACKET_OFFSET)
200 201 #define PACKET_LENGTH_HK (126 - CCSDS_TC_TM_PACKET_OFFSET)
201 202 #define PACKET_LENGTH_PARAMETER_DUMP (34 - CCSDS_TC_TM_PACKET_OFFSET)
202 203 #define PACKET_LENGTH_TM_LFR_SCIENCE_ASM (TOTAL_SIZE_SM + HEADER_LENGTH_TM_LFR_SCIENCE_ASM - CCSDS_TC_TM_PACKET_OFFSET)
203 204
204 205 #define SPARE1_PUSVERSION_SPARE2 0x10
205 206
206 207 #define LEN_TM_LFR_HK 130 // 126 + 4
207 208 #define LEN_TM_LFR_TC_EXE_NOT_IMP 28 // 24 + 4
208 209
210 // R1
209 211 #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1
210 212 #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1
213 // R2
214 #define TM_LEN_SCI_SWF_304 3669 // 304 * 12 + 10 + 12 - 1
215 #define TM_LEN_SCI_SWF_224 2709 // 224 * 12 + 10 + 12 - 1
216 //
211 217 #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1
212 218 #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1
213 219 #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1
214 220 #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1
215 221 #define DEFAULT_PKTCNT 0x07
216 222 #define BLK_NR_340 0x0154
217 223 #define BLK_NR_8 0x0008
224 #define BLK_NR_304 0x0130
225 #define BLK_NR_224 0x00e0
218 226
219 227 enum TM_TYPE{
220 228 TM_LFR_TC_EXE_OK,
221 229 TM_LFR_TC_EXE_ERR,
222 230 TM_LFR_HK,
223 231 TM_LFR_SCI,
224 232 TM_LFR_SCI_SBM,
225 233 TM_LFR_PAR_DUMP
226 234 };
227 235
228 236 typedef struct {
229 237 unsigned char targetLogicalAddress;
230 238 unsigned char protocolIdentifier;
231 239 unsigned char reserved;
232 240 unsigned char userApplication;
233 241 // PACKET HEADER
234 242 unsigned char packetID[2];
235 243 unsigned char packetSequenceControl[2];
236 244 unsigned char packetLength[2];
237 245 // DATA FIELD HEADER
238 246 unsigned char spare1_pusVersion_spare2;
239 247 unsigned char serviceType;
240 248 unsigned char serviceSubType;
241 249 unsigned char destinationID;
242 250 unsigned char time[6];
243 251 //
244 252 unsigned char telecommand_pkt_id[2];
245 253 unsigned char pkt_seq_control[2];
246 254 } Packet_TM_LFR_TC_EXE_SUCCESS_t;
247 255
248 256 typedef struct {
249 257 unsigned char targetLogicalAddress;
250 258 unsigned char protocolIdentifier;
251 259 unsigned char reserved;
252 260 unsigned char userApplication;
253 261 // PACKET HEADER
254 262 unsigned char packetID[2];
255 263 unsigned char packetSequenceControl[2];
256 264 unsigned char packetLength[2];
257 265 // DATA FIELD HEADER
258 266 unsigned char spare1_pusVersion_spare2;
259 267 unsigned char serviceType;
260 268 unsigned char serviceSubType;
261 269 unsigned char destinationID;
262 270 unsigned char time[6];
263 271 //
264 272 unsigned char tc_failure_code[2];
265 273 unsigned char telecommand_pkt_id[2];
266 274 unsigned char pkt_seq_control[2];
267 275 unsigned char tc_service;
268 276 unsigned char tc_subtype;
269 277 unsigned char byte_position;
270 278 unsigned char rcv_value;
271 279 } Packet_TM_LFR_TC_EXE_INCONSISTENT_t;
272 280
273 281 typedef struct {
274 282 unsigned char targetLogicalAddress;
275 283 unsigned char protocolIdentifier;
276 284 unsigned char reserved;
277 285 unsigned char userApplication;
278 286 // PACKET HEADER
279 287 unsigned char packetID[2];
280 288 unsigned char packetSequenceControl[2];
281 289 unsigned char packetLength[2];
282 290 // DATA FIELD HEADER
283 291 unsigned char spare1_pusVersion_spare2;
284 292 unsigned char serviceType;
285 293 unsigned char serviceSubType;
286 294 unsigned char destinationID;
287 295 unsigned char time[6];
288 296 //
289 297 unsigned char tc_failure_code[2];
290 298 unsigned char telecommand_pkt_id[2];
291 299 unsigned char pkt_seq_control[2];
292 300 unsigned char tc_service;
293 301 unsigned char tc_subtype;
294 302 unsigned char lfr_status_word[2];
295 303 } Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t;
296 304
297 305 typedef struct {
298 306 unsigned char targetLogicalAddress;
299 307 unsigned char protocolIdentifier;
300 308 unsigned char reserved;
301 309 unsigned char userApplication;
302 310 // PACKET HEADER
303 311 unsigned char packetID[2];
304 312 unsigned char packetSequenceControl[2];
305 313 unsigned char packetLength[2];
306 314 // DATA FIELD HEADER
307 315 unsigned char spare1_pusVersion_spare2;
308 316 unsigned char serviceType;
309 317 unsigned char serviceSubType;
310 318 unsigned char destinationID;
311 319 unsigned char time[6];
312 320 //
313 321 unsigned char tc_failure_code[2];
314 322 unsigned char telecommand_pkt_id[2];
315 323 unsigned char pkt_seq_control[2];
316 324 unsigned char tc_service;
317 325 unsigned char tc_subtype;
318 326 } Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t;
319 327
320 328 typedef struct {
321 329 unsigned char targetLogicalAddress;
322 330 unsigned char protocolIdentifier;
323 331 unsigned char reserved;
324 332 unsigned char userApplication;
325 333 // PACKET HEADER
326 334 unsigned char packetID[2];
327 335 unsigned char packetSequenceControl[2];
328 336 unsigned char packetLength[2];
329 337 // DATA FIELD HEADER
330 338 unsigned char spare1_pusVersion_spare2;
331 339 unsigned char serviceType;
332 340 unsigned char serviceSubType;
333 341 unsigned char destinationID;
334 342 unsigned char time[6];
335 343 //
336 344 unsigned char tc_failure_code[2];
337 345 unsigned char telecommand_pkt_id[2];
338 346 unsigned char pkt_seq_control[2];
339 347 unsigned char tc_service;
340 348 unsigned char tc_subtype;
341 349 } Packet_TM_LFR_TC_EXE_ERROR_t;
342 350
343 351 typedef struct {
344 352 unsigned char targetLogicalAddress;
345 353 unsigned char protocolIdentifier;
346 354 unsigned char reserved;
347 355 unsigned char userApplication;
348 356 // PACKET HEADER
349 357 unsigned char packetID[2];
350 358 unsigned char packetSequenceControl[2];
351 359 unsigned char packetLength[2];
352 360 // DATA FIELD HEADER
353 361 unsigned char spare1_pusVersion_spare2;
354 362 unsigned char serviceType;
355 363 unsigned char serviceSubType;
356 364 unsigned char destinationID;
357 365 unsigned char time[6];
358 366 //
359 367 unsigned char tc_failure_code[2];
360 368 unsigned char telecommand_pkt_id[2];
361 369 unsigned char pkt_seq_control[2];
362 370 unsigned char tc_service;
363 371 unsigned char tc_subtype;
364 372 unsigned char pkt_len_rcv_value[2];
365 373 unsigned char pkt_datafieldsize_cnt[2];
366 374 unsigned char rcv_crc[2];
367 375 unsigned char computed_crc[2];
368 376 } Packet_TM_LFR_TC_EXE_CORRUPTED_t;
369 377
370 378 typedef struct {
371 379 unsigned char targetLogicalAddress;
372 380 unsigned char protocolIdentifier;
373 381 unsigned char reserved;
374 382 unsigned char userApplication;
375 383 unsigned char packetID[2];
376 384 unsigned char packetSequenceControl[2];
377 385 unsigned char packetLength[2];
378 386 // DATA FIELD HEADER
379 387 unsigned char spare1_pusVersion_spare2;
380 388 unsigned char serviceType;
381 389 unsigned char serviceSubType;
382 390 unsigned char destinationID;
383 391 unsigned char time[6];
384 392 // AUXILIARY HEADER
385 393 unsigned char sid;
386 394 unsigned char hkBIA;
387 395 unsigned char pktCnt;
388 396 unsigned char pktNr;
389 397 unsigned char acquisitionTime[6];
390 398 unsigned char blkNr[2];
391 399 } Header_TM_LFR_SCIENCE_SWF_t;
392 400
393 401 typedef struct {
394 402 unsigned char targetLogicalAddress;
395 403 unsigned char protocolIdentifier;
396 404 unsigned char reserved;
397 405 unsigned char userApplication;
398 406 unsigned char packetID[2];
399 407 unsigned char packetSequenceControl[2];
400 408 unsigned char packetLength[2];
401 409 // DATA FIELD HEADER
402 410 unsigned char spare1_pusVersion_spare2;
403 411 unsigned char serviceType;
404 412 unsigned char serviceSubType;
405 413 unsigned char destinationID;
406 414 unsigned char time[6];
407 415 // AUXILIARY DATA HEADER
408 416 unsigned char sid;
409 417 unsigned char hkBIA;
410 418 unsigned char acquisitionTime[6];
411 419 unsigned char blkNr[2];
412 420 } Header_TM_LFR_SCIENCE_CWF_t;
413 421
414 422 typedef struct {
415 423 unsigned char targetLogicalAddress;
416 424 unsigned char protocolIdentifier;
417 425 unsigned char reserved;
418 426 unsigned char userApplication;
419 427 unsigned char packetID[2];
420 428 unsigned char packetSequenceControl[2];
421 429 unsigned char packetLength[2];
422 430 // DATA FIELD HEADER
423 431 unsigned char spare1_pusVersion_spare2;
424 432 unsigned char serviceType;
425 433 unsigned char serviceSubType;
426 434 unsigned char destinationID;
427 435 unsigned char time[6];
428 436 // AUXILIARY HEADER
429 437 unsigned char sid;
430 438 unsigned char biaStatusInfo;
431 439 unsigned char cntASM;
432 440 unsigned char nrASM;
433 441 unsigned char acquisitionTime[6];
434 442 unsigned char blkNr[2];
435 443 } Header_TM_LFR_SCIENCE_ASM_t;
436 444
437 445 typedef struct {
438 446 //targetLogicalAddress is removed by the grspw module
439 447 unsigned char protocolIdentifier;
440 448 unsigned char reserved;
441 449 unsigned char userApplication;
442 450 unsigned char packetID[2];
443 451 unsigned char packetSequenceControl[2];
444 452 unsigned char packetLength[2];
445 453 // DATA FIELD HEADER
446 454 unsigned char headerFlag_pusVersion_Ack;
447 455 unsigned char serviceType;
448 456 unsigned char serviceSubType;
449 457 unsigned char sourceID;
450 458 unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
451 459 } ccsdsTelecommandPacket_t;
452 460
453 461 typedef struct {
454 462 unsigned char targetLogicalAddress;
455 463 unsigned char protocolIdentifier;
456 464 unsigned char reserved;
457 465 unsigned char userApplication;
458 466 unsigned char packetID[2];
459 467 unsigned char packetSequenceControl[2];
460 468 unsigned char packetLength[2];
461 469 unsigned char spare1_pusVersion_spare2;
462 470 unsigned char serviceType;
463 471 unsigned char serviceSubType;
464 472 unsigned char destinationID;
465 473 unsigned char time[6];
466 474 unsigned char sid;
467 475
468 476 //**************
469 477 // HK PARAMETERS
470 478 unsigned char lfr_status_word[2];
471 479 unsigned char lfr_sw_version[4];
480 unsigned char lfr_fpga_version[3];
481 // ressource statistics
482 unsigned char hk_lfr_cpu_load;
483 unsigned char hk_lfr_load_max;
484 unsigned char hk_lfr_load_aver;
472 485 // tc statistics
473 486 unsigned char hk_lfr_update_info_tc_cnt[2];
474 487 unsigned char hk_lfr_update_time_tc_cnt[2];
475 unsigned char hk_dpu_exe_tc_lfr_cnt[2];
476 unsigned char hk_dpu_rej_tc_lfr_cnt[2];
488 unsigned char hk_lfr_exe_tc_cnt[2];
489 unsigned char hk_lfr_rej_tc_cnt[2];
477 490 unsigned char hk_lfr_last_exe_tc_id[2];
478 491 unsigned char hk_lfr_last_exe_tc_type[2];
479 492 unsigned char hk_lfr_last_exe_tc_subtype[2];
480 493 unsigned char hk_lfr_last_exe_tc_time[6];
481 494 unsigned char hk_lfr_last_rej_tc_id[2];
482 495 unsigned char hk_lfr_last_rej_tc_type[2];
483 496 unsigned char hk_lfr_last_rej_tc_subtype[2];
484 497 unsigned char hk_lfr_last_rej_tc_time[6];
485 498 // anomaly statistics
486 499 unsigned char hk_lfr_le_cnt[2];
487 500 unsigned char hk_lfr_me_cnt[2];
488 501 unsigned char hk_lfr_he_cnt[2];
489 502 unsigned char hk_lfr_last_er_rid[2];
490 503 unsigned char hk_lfr_last_er_code;
491 504 unsigned char hk_lfr_last_er_time[6];
492 505 // vhdl_blk_status
493 506 unsigned char hk_lfr_vhdl_aa_sm;
494 507 unsigned char hk_lfr_vhdl_fft_sr;
495 508 unsigned char hk_lfr_vhdl_cic_hk;
496 509 unsigned char hk_lfr_vhdl_iir_cal;
497 510 // spacewire_if_statistics
498 511 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
499 512 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
500 513 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
501 unsigned char hk_lfr_dpu_spw_last_time;
514 unsigned char hk_lfr_dpu_spw_last_timc;
502 515 // ahb error statistics
503 516 unsigned int hk_lfr_last_fail_addr;
504 517 // temperatures
505 518 unsigned char hk_lfr_temp_scm[2];
506 519 unsigned char hk_lfr_temp_pcb[2];
507 520 unsigned char hk_lfr_temp_fpga[2];
521 // spacecraft potential
522 unsigned char hk_lfr_sc_v_f3[2];
523 unsigned char hk_lfr_sc_e1_f3[2];
524 unsigned char hk_lfr_sc_e2_f3[2];
508 525 // error counters
509 526 unsigned char hk_lfr_dpu_spw_parity;
510 527 unsigned char hk_lfr_dpu_spw_disconnect;
511 528 unsigned char hk_lfr_dpu_spw_escape;
512 529 unsigned char hk_lfr_dpu_spw_credit;
513 530 unsigned char hk_lfr_dpu_spw_write_sync;
514 531 unsigned char hk_lfr_dpu_spw_rx_ahb;
515 532 unsigned char hk_lfr_dpu_spw_tx_ahb;
516 unsigned char hk_lfr_dpu_spw_header_crc;
517 unsigned char hk_lfr_dpu_spw_data_crc;
518 533 unsigned char hk_lfr_dpu_spw_early_eop;
519 534 unsigned char hk_lfr_dpu_spw_invalid_addr;
520 535 unsigned char hk_lfr_dpu_spw_eep;
521 536 unsigned char hk_lfr_dpu_spw_rx_too_big;
522 537 // timecode
523 538 unsigned char hk_lfr_timecode_erroneous;
524 539 unsigned char hk_lfr_timecode_missing;
525 540 unsigned char hk_lfr_timecode_invalid;
526 541 // time
527 542 unsigned char hk_lfr_time_timecode_it;
528 543 unsigned char hk_lfr_time_not_synchro;
529 544 unsigned char hk_lfr_time_timecode_ctr;
530 545 // hk_lfr_buffer_dpu_
531 546 unsigned char hk_lfr_buffer_dpu_tc_fifo;
532 547 unsigned char hk_lfr_buffer_dpu_tm_fifo;
533 548 // hk_lfr_ahb_
534 549 unsigned char hk_lfr_ahb_correctable;
535 550 unsigned char hk_lfr_ahb_uncorrectable;
536 unsigned char hk_lfr_ahb_fails_trans;
537 // hk_lfr_adc_
538 unsigned char hk_lfr_adc_failure;
539 unsigned char hk_lfr_adc_timeout;
540 unsigned char hk_lfr_toomany_err;
541 // hk_lfr_cpu_
542 unsigned char hk_lfr_cpu_write_err;
543 unsigned char hk_lfr_cpu_ins_access_err;
544 unsigned char hk_lfr_cpu_illegal_ins;
545 unsigned char hk_lfr_cpu_privilegied_ins;
546 unsigned char hk_lfr_cpu_register_hw;
547 unsigned char hk_lfr_cpu_not_aligned;
548 unsigned char hk_lfr_cpu_data_exception;
549 unsigned char hk_lfr_cpu_div_exception;
550 unsigned char hk_lfr_cpu_arith_overflow;
551 // spare
552 unsigned char parameters_spare;
551 553 } Packet_TM_LFR_HK_t;
552 554
553 555 typedef struct {
554 556 unsigned char targetLogicalAddress;
555 557 unsigned char protocolIdentifier;
556 558 unsigned char reserved;
557 559 unsigned char userApplication;
558 560 unsigned char packetID[2];
559 561 unsigned char packetSequenceControl[2];
560 562 unsigned char packetLength[2];
561 563 // DATA FIELD HEADER
562 564 unsigned char spare1_pusVersion_spare2;
563 565 unsigned char serviceType;
564 566 unsigned char serviceSubType;
565 567 unsigned char destinationID;
566 568 unsigned char time[6];
567 569 unsigned char sid;
568 570
569 571 //******************
570 572 // COMMON PARAMETERS
571 573 unsigned char unused0;
572 574 unsigned char bw_sp0_sp1_r0_r1;
573 575
574 576 //******************
575 577 // NORMAL PARAMETERS
576 578 unsigned char sy_lfr_n_swf_l[2];
577 579 unsigned char sy_lfr_n_swf_p[2];
578 580 unsigned char sy_lfr_n_asm_p[2];
579 581 unsigned char sy_lfr_n_bp_p0;
580 582 unsigned char sy_lfr_n_bp_p1;
583 unsigned char sy_lfr_n_cwf_long_f3;
584 unsigned char lfr_normal_parameters_spare;
581 585
582 586 //*****************
583 587 // BURST PARAMETERS
584 588 unsigned char sy_lfr_b_bp_p0;
585 589 unsigned char sy_lfr_b_bp_p1;
586 590
587 591 //****************
588 592 // SBM1 PARAMETERS
589 593 unsigned char sy_lfr_s1_bp_p0;
590 594 unsigned char sy_lfr_s1_bp_p1;
591 595
592 596 //****************
593 597 // SBM2 PARAMETERS
594 598 unsigned char sy_lfr_s2_bp_p0;
595 599 unsigned char sy_lfr_s2_bp_p1;
596 600 } Packet_TM_LFR_PARAMETER_DUMP_t;
597 601
598 602
599 603 #endif // CCSDS_TYPES_H_INCLUDED
@@ -1,205 +1,206
1 1 #ifndef FSW_PARAMS_H_INCLUDED
2 2 #define FSW_PARAMS_H_INCLUDED
3 3
4 4 #include "grlib_regs.h"
5 5 #include "fsw_params_processing.h"
6 6 #include "tm_byte_positions.h"
7 7 #include "ccsds_types.h"
8 8
9 9 #define GRSPW_DEVICE_NAME "/dev/grspw0"
10 10 #define UART_DEVICE_NAME "/dev/console"
11 11
12 12 //************************
13 13 // flight software version
14 14 // this parameters is handled by the Qt project options
15 15
16 16 //#define NB_SAMPLES_PER_SNAPSHOT 2048
17 17 #define NB_SAMPLES_PER_SNAPSHOT 2352 // 336 * 7 = 2352
18 18 #define TIME_OFFSET 2
19 19 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
20 20 #define NB_BYTES_SWF_BLK (2 * 6)
21 21 #define NB_WORDS_SWF_BLK 3
22 22 #define NB_BYTES_CWF3_LIGHT_BLK 6
23 23 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
24 #define NB_RING_NODES_F0 3 // AT LEAST 3
24 25 #define NB_RING_NODES_F1 5 // AT LEAST 3
25 26 #define NB_RING_NODES_F2 5 // AT LEAST 3
26 27
27 28 //**********
28 29 // LFR MODES
29 30 #define LFR_MODE_STANDBY 0
30 31 #define LFR_MODE_NORMAL 1
31 32 #define LFR_MODE_BURST 2
32 33 #define LFR_MODE_SBM1 3
33 34 #define LFR_MODE_SBM2 4
34 35 #define LFR_MODE_NORMAL_CWF_F3 5
35 36
36 37 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
37 38 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
38 39 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
39 40 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
40 41 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
41 42 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
42 43
43 44 //****************************
44 45 // LFR DEFAULT MODE PARAMETERS
45 46 // COMMON
46 47 #define DEFAULT_SY_LFR_COMMON0 0x00
47 48 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
48 49 // NORM
49 50 #define SY_LFR_N_SWF_L 2048 // nb sample
50 51 #define SY_LFR_N_SWF_P 20 // sec
51 52 #define SY_LFR_N_ASM_P 3600 // sec
52 53 #define SY_LFR_N_BP_P0 4 // sec
53 54 #define SY_LFR_N_BP_P1 20 // sec
54 55 #define MIN_DELTA_SNAPSHOT 16 // sec
55 56 // BURST
56 57 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
57 58 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
58 59 // SBM1
59 60 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
60 61 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
61 62 // SBM2
62 63 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
63 64 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
64 65 // ADDITIONAL PARAMETERS
65 66 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
66 67 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
67 68 // STATUS WORD
68 69 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
69 70 #define DEFAULT_STATUS_WORD_BYTE1 0x00
70 71 //
71 72 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
72 73 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
73 74 //****************************
74 75
75 76 //*****************************
76 77 // APB REGISTERS BASE ADDRESSES
77 78 #define REGS_ADDR_APBUART 0x80000100
78 79 #define REGS_ADDR_GPTIMER 0x80000300
79 80 #define REGS_ADDR_GRSPW 0x80000500
80 81 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
81 82 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
82 83
83 84 #ifdef GSA
84 85 #else
85 86 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
86 87 #endif
87 88
88 89 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
89 90 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
90 91
91 92 //**********
92 93 // IRQ LINES
93 94 #define IRQ_SM 9
94 95 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
95 96 #define IRQ_WF 10
96 97 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
97 98 #define IRQ_TIME1 12
98 99 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
99 100 #define IRQ_TIME2 13
100 101 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
101 102 #define IRQ_WAVEFORM_PICKER 14
102 103 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
103 104 #define IRQ_SPECTRAL_MATRIX 6
104 105 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
105 106
106 107 //*****
107 108 // TIME
108 109 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
109 110 #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s
110 111 #define TIMER_SM_SIMULATOR 1
111 112 #define TIMER_WF_SIMULATOR 2
112 113 #define HK_PERIOD 100 // 100 * 10ms => 1sec
113 114
114 115 //**********
115 116 // LPP CODES
116 117 #define LFR_SUCCESSFUL 0
117 118 #define LFR_DEFAULT 1
118 119
119 120 //******
120 121 // RTEMS
121 122 #define TASKID_RECV 1
122 123 #define TASKID_ACTN 2
123 124 #define TASKID_SPIQ 3
124 125 #define TASKID_SMIQ 4
125 126 #define TASKID_STAT 5
126 127 #define TASKID_AVF0 6
127 128 #define TASKID_BPF0 7
128 129 #define TASKID_WFRM 8
129 130 #define TASKID_DUMB 9
130 131 #define TASKID_HOUS 10
131 132 #define TASKID_MATR 11
132 133 #define TASKID_CWF3 12
133 134 #define TASKID_CWF2 13
134 135 #define TASKID_CWF1 14
135 136 #define TASKID_SEND 15
136 137 #define TASKID_WTDG 16
137 138
138 139 #define TASK_PRIORITY_SPIQ 5
139 140 #define TASK_PRIORITY_SMIQ 10
140 141 #define TASK_PRIORITY_WTDG 20
141 142 #define TASK_PRIORITY_HOUS 30
142 143 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
143 144 #define TASK_PRIORITY_CWF2 35 //
144 145 #define TASK_PRIORITY_WFRM 40
145 146 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
146 147 #define TASK_PRIORITY_SEND 45
147 148 #define TASK_PRIORITY_RECV 50
148 149 #define TASK_PRIORITY_ACTN 50
149 150 #define TASK_PRIORITY_AVF0 60
150 151 #define TASK_PRIORITY_BPF0 60
151 152 #define TASK_PRIORITY_MATR 100
152 153 #define TASK_PRIORITY_STAT 200
153 154 #define TASK_PRIORITY_DUMB 200
154 155
155 156 #define ACTION_MSG_QUEUE_COUNT 10
156 157 #define ACTION_MSG_PKTS_COUNT 50
157 158 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
158 159 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
159 160
160 161 #define QUEUE_RECV 0
161 162 #define QUEUE_SEND 1
162 163
163 164 //*******
164 165 // MACROS
165 166 #ifdef PRINT_MESSAGES_ON_CONSOLE
166 167 #define PRINTF(x) printf(x);
167 168 #define PRINTF1(x,y) printf(x,y);
168 169 #define PRINTF2(x,y,z) printf(x,y,z);
169 170 #else
170 171 #define PRINTF(x) ;
171 172 #define PRINTF1(x,y) ;
172 173 #define PRINTF2(x,y,z) ;
173 174 #endif
174 175
175 176 #ifdef BOOT_MESSAGES
176 177 #define BOOT_PRINTF(x) printf(x);
177 178 #define BOOT_PRINTF1(x,y) printf(x,y);
178 179 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
179 180 #else
180 181 #define BOOT_PRINTF(x) ;
181 182 #define BOOT_PRINTF1(x,y) ;
182 183 #define BOOT_PRINTF2(x,y,z) ;
183 184 #endif
184 185
185 186 #ifdef DEBUG_MESSAGES
186 187 #define DEBUG_PRINTF(x) printf(x);
187 188 #define DEBUG_PRINTF1(x,y) printf(x,y);
188 189 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
189 190 #else
190 191 #define DEBUG_PRINTF(x) ;
191 192 #define DEBUG_PRINTF1(x,y) ;
192 193 #define DEBUG_PRINTF2(x,y,z) ;
193 194 #endif
194 195
195 196 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
196 197
197 198 struct param_local_str{
198 199 unsigned int local_sbm1_nb_cwf_sent;
199 200 unsigned int local_sbm1_nb_cwf_max;
200 201 unsigned int local_sbm2_nb_cwf_sent;
201 202 unsigned int local_sbm2_nb_cwf_max;
202 203 unsigned int local_nb_interrupt_f0_MAX;
203 204 };
204 205
205 206 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,27 +1,28
1 1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 2 #define TC_LOAD_DUMP_PARAMETERS_H
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6
7 7 #include "fsw_params.h"
8 8 #include "wf_handler.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "fsw_misc.h"
11 11
12 12 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
13 13 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
14 14 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
15 15 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
16 16 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
17 17 int action_dump_par(rtems_id queue_id );
18 18
19 19 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
20 20 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
21 21 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
22 22 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
23 23 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
24 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
24 25
25 26 void init_parameter_dump( void );
26 27
27 28 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,22 +1,23
1 1 #ifndef TM_BYTE_POSITIONS_H
2 2 #define TM_BYTE_POSITIONS_H
3 3
4 4 #define BYTE_POS_CP_LFR_MODE 11
5 5
6 6 // TC_LFR_LOAD_COMMON_PAR
7 7
8 8 // TC_LFR_LOAD_NORMAL_PAR
9 9 #define BYTE_POS_SY_LFR_N_SWF_L 0
10 10 #define BYTE_POS_SY_LFR_N_SWF_P 2
11 11 #define BYTE_POS_SY_LFR_N_ASM_P 4
12 12 #define BYTE_POS_SY_LFR_N_BP_P0 6
13 13 #define BYTE_POS_SY_LFR_N_BP_P1 7
14 #define BYTE_POS_SY_LFR_N_CWF_LONG_F3 8
14 15
15 16 // TC_LFR_LOAD_BURST_PAR
16 17
17 18 // TC_LFR_LOAD_SBM1_PAR
18 19
19 20 // TC_LFR_LOAD_SBM2_PAR
20 21
21 22
22 23 #endif // TM_BYTE_POSITIONS_H
@@ -1,93 +1,94
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 typedef struct ring_node
16 16 {
17 17 struct ring_node *previous;
18 18 int buffer_address;
19 19 struct ring_node *next;
20 20 unsigned int status;
21 21 } ring_node;
22 22
23 23 extern int fdSPW;
24 24
25 25 //*****************
26 26 // waveform buffers
27 27 // F0
28 extern volatile int wf_snap_f0[ ];
28 //extern volatile int wf_snap_f0[ ];
29 29 // F1 F2
30 extern volatile int wf_snap_f0[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ];
30 31 extern volatile int wf_snap_f1[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ];
31 32 extern volatile int wf_snap_f2[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ];
32 33 // F3
33 34 extern volatile int wf_cont_f3_a[ ];
34 35 extern volatile int wf_cont_f3_b[ ];
35 36 extern char wf_cont_f3_light[ ];
36 37
37 38 #ifdef VHDL_DEV
38 39 extern waveform_picker_regs_new_t *waveform_picker_regs;
39 40 #else
40 41 extern waveform_picker_regs_t *waveform_picker_regs;
41 42 #endif
42 43 extern time_management_regs_t *time_management_regs;
43 44 extern Packet_TM_LFR_HK_t housekeeping_packet;
44 45 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
45 46 extern struct param_local_str param_local;
46 47
47 48 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
48 49 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
49 50
50 51 extern rtems_id Task_id[20]; /* array of task ids */
51 52
52 53 extern unsigned char lfrCurrentMode;
53 54
54 55 rtems_isr waveforms_isr( rtems_vector_number vector );
55 56 rtems_task wfrm_task( rtems_task_argument argument );
56 57 rtems_task cwf3_task( rtems_task_argument argument );
57 58 rtems_task cwf2_task( rtems_task_argument argument );
58 59 rtems_task cwf1_task( rtems_task_argument argument );
59 60
60 61 //******************
61 62 // general functions
62 63 void init_waveforms( void );
63 64 void init_waveform_rings( void );
64 65 void reset_current_ring_nodes( void );
65 66 //
66 67 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
67 68 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
68 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
69 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
69 70 //
70 71 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
71 72 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
72 73 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
73 74 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
74 75 //
75 76 rtems_id get_pkts_queue_id( void );
76 77
77 78 //**************
78 79 // wfp registers
79 80 void set_wfp_data_shaping();
80 81 char set_wfp_delta_snapshot();
81 82 void set_wfp_burst_enable_register( unsigned char mode );
82 83 void reset_wfp_burst_enable();
83 84 void reset_wfp_status();
84 85 void reset_waveform_picker_regs();
85 86 void reset_new_waveform_picker_regs();
86 87
87 88 //*****************
88 89 // local parameters
89 90 void set_local_nb_interrupt_f0_MAX( void );
90 91
91 92 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
92 93
93 94 #endif // WF_HANDLER_H_INCLUDED
@@ -1,89 +1,90
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 23
24 24 // RTEMS GLOBAL VARIABLES
25 25 rtems_name misc_name[5];
26 26 rtems_id misc_id[5];
27 27 rtems_name Task_name[20]; /* array of task names */
28 28 rtems_id Task_id[20]; /* array of task ids */
29 29 unsigned int maxCount;
30 30 int fdSPW = 0;
31 31 int fdUART = 0;
32 32 unsigned char lfrCurrentMode;
33 33
34 34 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
35 35 // F0
36 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
36 //volatile int wf_snap_f0 [ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100)));
37 volatile int wf_snap_f0[ NB_RING_NODES_F0 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100)));
37 38 // F1 F2
38 39 volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100)));
39 40 volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100)));
40 41 // F3
41 42 volatile int wf_cont_f3_a[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
42 43 volatile int wf_cont_f3_b[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
43 44 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ] __attribute__((aligned(0x100)));
44 45
45 46 // SPECTRAL MATRICES GLOBAL VARIABLES
46 47 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
47 48 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
48 49 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
49 50 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
50 51 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
51 52 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
52 53 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
53 54 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
54 55 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
55 56 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
56 57 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
57 58 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
58 59 //
59 60 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
60 61 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
61 62 //
62 63 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
63 64 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
64 65
65 66 // APB CONFIGURATION REGISTERS
66 67 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
67 68 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
68 69
69 70 #ifdef VHDL_DEV
70 71 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
71 72 #else
72 73 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
73 74 #endif
74 75 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
75 76
76 77 // MODE PARAMETERS
77 78 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
78 79 struct param_local_str param_local;
79 80
80 81 // HK PACKETS
81 82 Packet_TM_LFR_HK_t housekeeping_packet;
82 83 // sequence counters are incremented by APID (PID + CAT) and destination ID
83 84 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
84 85 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
85 86 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
86 87 spw_stats spacewire_stats;
87 88 spw_stats spacewire_stats_backup;
88 89
89 90
@@ -1,609 +1,607
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 // UART settings
79 send_console_outputs_on_apbuart_port();
80 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
81
78 82 BOOT_PRINTF("\n\n\n\n\n")
79 83 BOOT_PRINTF("***************************\n")
80 84 BOOT_PRINTF("** START Flight Software **\n")
81 #ifdef VHDL_DEV
82 PRINTF("/!\\ this is the VHDL_DEV flight software /!\\ \n")
83 #endif
85 #ifdef VHDL_DEV
86 PRINTF("/!\\ this is the VHDL_DEV flight software /!\\ \n")
87 #endif
84 88 BOOT_PRINTF("***************************\n")
85 89 BOOT_PRINTF("\n\n")
86 90
87 //send_console_outputs_on_apbuart_port();
88 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
89
90 91 reset_wfp_burst_enable(); // stop the waveform picker if it was running
91 92 init_waveform_rings(); // initialize the waveform rings
92 93
93 94 init_parameter_dump();
94 95 init_local_mode_parameters();
95 96 init_housekeeping_parameters();
96 97
97 98 updateLFRCurrentMode();
98 99
99 100 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
100 101
101 102 create_names(); // create all names
102 103
103 104 status = create_message_queues(); // create message queues
104 105 if (status != RTEMS_SUCCESSFUL)
105 106 {
106 107 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
107 108 }
108 109
109 110 status = create_all_tasks(); // create all tasks
110 111 if (status != RTEMS_SUCCESSFUL)
111 112 {
112 113 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
113 114 }
114 115
115 116 // **************************
116 117 // <SPACEWIRE INITIALIZATION>
117 118 grspw_timecode_callback = &timecode_irq_handler;
118 119
119 120 status_spw = spacewire_open_link(); // (1) open the link
120 121 if ( status_spw != RTEMS_SUCCESSFUL )
121 122 {
122 123 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
123 124 }
124 125
125 126 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
126 127 {
127 128 status_spw = spacewire_configure_link( fdSPW );
128 129 if ( status_spw != RTEMS_SUCCESSFUL )
129 130 {
130 131 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
131 132 }
132 133 }
133 134
134 135 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
135 136 {
136 137 status_spw = spacewire_start_link( fdSPW );
137 138 if ( status_spw != RTEMS_SUCCESSFUL )
138 139 {
139 140 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
140 141 }
141 142 }
142 143 // </SPACEWIRE INITIALIZATION>
143 144 // ***************************
144 145
145 146 status = start_all_tasks(); // start all tasks
146 147 if (status != RTEMS_SUCCESSFUL)
147 148 {
148 149 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
149 150 }
150 151
151 152 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
152 153 status = start_recv_send_tasks();
153 154 if ( status != RTEMS_SUCCESSFUL )
154 155 {
155 156 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
156 157 }
157 158
158 159 // suspend science tasks. they will be restarted later depending on the mode
159 160 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
160 161 if (status != RTEMS_SUCCESSFUL)
161 162 {
162 163 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
163 164 }
164 165
165 #ifdef GSA
166 // mask IRQ lines
166
167 //******************************
168 // <SPECTRAL MATRICES SIMULATOR>
167 169 LEON_Mask_interrupt( IRQ_SM );
168 LEON_Mask_interrupt( IRQ_WF );
169 // Spectral Matrices simulator
170 170 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
171 IRQ_SPARC_SM, spectral_matrices_isr );
172 // WaveForms
173 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
174 IRQ_SPARC_WF, waveforms_simulator_isr );
175 #else
171 IRQ_SPARC_SM, spectral_matrices_isr_simu );
172 // </SPECTRAL MATRICES SIMULATOR>
173 //*******************************
174
176 175 // configure IRQ handling for the waveform picker unit
177 176 status = rtems_interrupt_catch( waveforms_isr,
178 177 IRQ_SPARC_WAVEFORM_PICKER,
179 178 &old_isr_handler) ;
180 #endif
181 179
182 180 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
183 181 if ( status_spw != RTEMS_SUCCESSFUL )
184 182 {
185 183 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
186 184 if ( status != RTEMS_SUCCESSFUL ) {
187 185 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
188 186 }
189 187 }
190 188
191 189 BOOT_PRINTF("delete INIT\n")
192 190
193 191 status = rtems_task_delete(RTEMS_SELF);
194 192
195 193 }
196 194
197 195 void init_local_mode_parameters( void )
198 196 {
199 197 /** This function initialize the param_local global variable with default values.
200 198 *
201 199 */
202 200
203 201 unsigned int i;
204 202
205 203 // LOCAL PARAMETERS
206 204 set_local_nb_interrupt_f0_MAX();
207 205
208 206 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
209 207 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
210 208 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
211 209
212 210 // init sequence counters
213 211
214 212 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
215 213 {
216 214 sequenceCounters_TC_EXE[i] = 0x00;
217 215 }
218 216 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
219 217 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
220 218 }
221 219
222 220 void create_names( void ) // create all names for tasks and queues
223 221 {
224 222 /** This function creates all RTEMS names used in the software for tasks and queues.
225 223 *
226 224 * @return RTEMS directive status codes:
227 225 * - RTEMS_SUCCESSFUL - successful completion
228 226 *
229 227 */
230 228
231 229 // task names
232 230 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
233 231 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
234 232 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
235 233 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
236 234 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
237 235 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
238 236 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
239 237 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
240 238 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
241 239 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
242 240 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
243 241 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
244 242 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
245 243 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
246 244 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
247 245 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
248 246
249 247 // rate monotonic period names
250 248 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
251 249
252 250 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
253 251 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
254 252 }
255 253
256 254 int create_all_tasks( void ) // create all tasks which run in the software
257 255 {
258 256 /** This function creates all RTEMS tasks used in the software.
259 257 *
260 258 * @return RTEMS directive status codes:
261 259 * - RTEMS_SUCCESSFUL - task created successfully
262 260 * - RTEMS_INVALID_ADDRESS - id is NULL
263 261 * - RTEMS_INVALID_NAME - invalid task name
264 262 * - RTEMS_INVALID_PRIORITY - invalid task priority
265 263 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
266 264 * - RTEMS_TOO_MANY - too many tasks created
267 265 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
268 266 * - RTEMS_TOO_MANY - too many global objects
269 267 *
270 268 */
271 269
272 270 rtems_status_code status;
273 271
274 272 // RECV
275 273 status = rtems_task_create(
276 274 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
277 275 RTEMS_DEFAULT_MODES,
278 276 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
279 277 );
280 278
281 279 if (status == RTEMS_SUCCESSFUL) // ACTN
282 280 {
283 281 status = rtems_task_create(
284 282 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
285 283 RTEMS_DEFAULT_MODES,
286 284 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
287 285 );
288 286 }
289 287 if (status == RTEMS_SUCCESSFUL) // SPIQ
290 288 {
291 289 status = rtems_task_create(
292 290 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
293 291 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
294 292 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
295 293 );
296 294 }
297 295 if (status == RTEMS_SUCCESSFUL) // SMIQ
298 296 {
299 297 status = rtems_task_create(
300 298 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
301 299 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
302 300 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
303 301 );
304 302 }
305 303 if (status == RTEMS_SUCCESSFUL) // STAT
306 304 {
307 305 status = rtems_task_create(
308 306 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
309 307 RTEMS_DEFAULT_MODES,
310 308 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
311 309 );
312 310 }
313 311 if (status == RTEMS_SUCCESSFUL) // AVF0
314 312 {
315 313 status = rtems_task_create(
316 314 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
317 315 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
318 316 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
319 317 );
320 318 }
321 319 if (status == RTEMS_SUCCESSFUL) // BPF0
322 320 {
323 321 status = rtems_task_create(
324 322 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
325 323 RTEMS_DEFAULT_MODES,
326 324 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
327 325 );
328 326 }
329 327 if (status == RTEMS_SUCCESSFUL) // WFRM
330 328 {
331 329 status = rtems_task_create(
332 330 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
333 331 RTEMS_DEFAULT_MODES,
334 332 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
335 333 );
336 334 }
337 335 if (status == RTEMS_SUCCESSFUL) // DUMB
338 336 {
339 337 status = rtems_task_create(
340 338 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
341 339 RTEMS_DEFAULT_MODES,
342 340 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
343 341 );
344 342 }
345 343 if (status == RTEMS_SUCCESSFUL) // HOUS
346 344 {
347 345 status = rtems_task_create(
348 346 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
349 347 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
350 348 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
351 349 );
352 350 }
353 351 if (status == RTEMS_SUCCESSFUL) // MATR
354 352 {
355 353 status = rtems_task_create(
356 354 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
357 355 RTEMS_DEFAULT_MODES,
358 356 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
359 357 );
360 358 }
361 359 if (status == RTEMS_SUCCESSFUL) // CWF3
362 360 {
363 361 status = rtems_task_create(
364 362 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
365 363 RTEMS_DEFAULT_MODES,
366 364 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
367 365 );
368 366 }
369 367 if (status == RTEMS_SUCCESSFUL) // CWF2
370 368 {
371 369 status = rtems_task_create(
372 370 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
373 371 RTEMS_DEFAULT_MODES,
374 372 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
375 373 );
376 374 }
377 375 if (status == RTEMS_SUCCESSFUL) // CWF1
378 376 {
379 377 status = rtems_task_create(
380 378 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
381 379 RTEMS_DEFAULT_MODES,
382 380 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
383 381 );
384 382 }
385 383 if (status == RTEMS_SUCCESSFUL) // SEND
386 384 {
387 385 status = rtems_task_create(
388 386 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
389 387 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
390 388 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
391 389 );
392 390 }
393 391 if (status == RTEMS_SUCCESSFUL) // WTDG
394 392 {
395 393 status = rtems_task_create(
396 394 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
397 395 RTEMS_DEFAULT_MODES,
398 396 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
399 397 );
400 398 }
401 399
402 400 return status;
403 401 }
404 402
405 403 int start_recv_send_tasks( void )
406 404 {
407 405 rtems_status_code status;
408 406
409 407 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
410 408 if (status!=RTEMS_SUCCESSFUL) {
411 409 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
412 410 }
413 411
414 412 if (status == RTEMS_SUCCESSFUL) // SEND
415 413 {
416 414 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
417 415 if (status!=RTEMS_SUCCESSFUL) {
418 416 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
419 417 }
420 418 }
421 419
422 420 return status;
423 421 }
424 422
425 423 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
426 424 {
427 425 /** This function starts all RTEMS tasks used in the software.
428 426 *
429 427 * @return RTEMS directive status codes:
430 428 * - RTEMS_SUCCESSFUL - ask started successfully
431 429 * - RTEMS_INVALID_ADDRESS - invalid task entry point
432 430 * - RTEMS_INVALID_ID - invalid task id
433 431 * - RTEMS_INCORRECT_STATE - task not in the dormant state
434 432 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
435 433 *
436 434 */
437 435 // starts all the tasks fot eh flight software
438 436
439 437 rtems_status_code status;
440 438
441 439 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
442 440 if (status!=RTEMS_SUCCESSFUL) {
443 441 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
444 442 }
445 443
446 444 if (status == RTEMS_SUCCESSFUL) // WTDG
447 445 {
448 446 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
449 447 if (status!=RTEMS_SUCCESSFUL) {
450 448 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
451 449 }
452 450 }
453 451
454 452 if (status == RTEMS_SUCCESSFUL) // SMIQ
455 453 {
456 454 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
457 455 if (status!=RTEMS_SUCCESSFUL) {
458 456 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
459 457 }
460 458 }
461 459
462 460 if (status == RTEMS_SUCCESSFUL) // ACTN
463 461 {
464 462 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
465 463 if (status!=RTEMS_SUCCESSFUL) {
466 464 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
467 465 }
468 466 }
469 467
470 468 if (status == RTEMS_SUCCESSFUL) // STAT
471 469 {
472 470 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
473 471 if (status!=RTEMS_SUCCESSFUL) {
474 472 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
475 473 }
476 474 }
477 475
478 476 if (status == RTEMS_SUCCESSFUL) // AVF0
479 477 {
480 478 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
481 479 if (status!=RTEMS_SUCCESSFUL) {
482 480 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
483 481 }
484 482 }
485 483
486 484 if (status == RTEMS_SUCCESSFUL) // BPF0
487 485 {
488 486 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
489 487 if (status!=RTEMS_SUCCESSFUL) {
490 488 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
491 489 }
492 490 }
493 491
494 492 if (status == RTEMS_SUCCESSFUL) // WFRM
495 493 {
496 494 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
497 495 if (status!=RTEMS_SUCCESSFUL) {
498 496 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
499 497 }
500 498 }
501 499
502 500 if (status == RTEMS_SUCCESSFUL) // DUMB
503 501 {
504 502 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
505 503 if (status!=RTEMS_SUCCESSFUL) {
506 504 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
507 505 }
508 506 }
509 507
510 508 if (status == RTEMS_SUCCESSFUL) // HOUS
511 509 {
512 510 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
513 511 if (status!=RTEMS_SUCCESSFUL) {
514 512 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
515 513 }
516 514 }
517 515
518 516 if (status == RTEMS_SUCCESSFUL) // MATR
519 517 {
520 518 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
521 519 if (status!=RTEMS_SUCCESSFUL) {
522 520 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
523 521 }
524 522 }
525 523
526 524 if (status == RTEMS_SUCCESSFUL) // CWF3
527 525 {
528 526 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
529 527 if (status!=RTEMS_SUCCESSFUL) {
530 528 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
531 529 }
532 530 }
533 531
534 532 if (status == RTEMS_SUCCESSFUL) // CWF2
535 533 {
536 534 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
537 535 if (status!=RTEMS_SUCCESSFUL) {
538 536 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
539 537 }
540 538 }
541 539
542 540 if (status == RTEMS_SUCCESSFUL) // CWF1
543 541 {
544 542 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
545 543 if (status!=RTEMS_SUCCESSFUL) {
546 544 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
547 545 }
548 546 }
549 547 return status;
550 548 }
551 549
552 550 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
553 551 {
554 552 rtems_status_code status_recv;
555 553 rtems_status_code status_send;
556 554 rtems_status_code ret;
557 555 rtems_id queue_id;
558 556
559 557 // create the queue for handling valid TCs
560 558 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
561 559 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
562 560 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
563 561 if ( status_recv != RTEMS_SUCCESSFUL ) {
564 562 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
565 563 }
566 564
567 565 // create the queue for handling TM packet sending
568 566 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
569 567 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
570 568 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
571 569 if ( status_send != RTEMS_SUCCESSFUL ) {
572 570 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
573 571 }
574 572
575 573 if ( status_recv != RTEMS_SUCCESSFUL )
576 574 {
577 575 ret = status_recv;
578 576 }
579 577 else
580 578 {
581 579 ret = status_send;
582 580 }
583 581
584 582 return ret;
585 583 }
586 584
587 585 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
588 586 {
589 587 rtems_status_code status;
590 588 rtems_name queue_name;
591 589
592 590 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
593 591
594 592 status = rtems_message_queue_ident( queue_name, 0, queue_id );
595 593
596 594 return status;
597 595 }
598 596
599 597 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
600 598 {
601 599 rtems_status_code status;
602 600 rtems_name queue_name;
603 601
604 602 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
605 603
606 604 status = rtems_message_queue_ident( queue_name, 0, queue_id );
607 605
608 606 return status;
609 607 }
@@ -1,336 +1,341
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 146 status = get_message_queue_id_send( &queue_id );
147 147 if (status != RTEMS_SUCCESSFUL)
148 148 {
149 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 175 housekeeping_packet.sid = SID_HK;
176 176
177 177 status = rtems_rate_monotonic_cancel(HK_id);
178 178 if( status != RTEMS_SUCCESSFUL ) {
179 179 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
180 180 }
181 181 else {
182 182 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
183 183 }
184 184
185 185 while(1){ // launch the rate monotonic task
186 186 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
187 187 if ( status != RTEMS_SUCCESSFUL ) {
188 188 PRINTF1( "in HOUS *** ERR period: %d\n", status);
189 189 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
190 190 }
191 191 else {
192 192 increment_seq_counter( housekeeping_packet.packetSequenceControl );
193 193 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
194 194 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
195 195 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
196 196 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
197 197 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
198 198 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
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 char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
234 char *DumbMessages[8] = {"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 "ERR HK" // RTEMS_EVENT_6
240 "ERR HK", // RTEMS_EVENT_6
241 "ready for dump" // RTEMS_EVENT_7
241 242 };
242 243
243 244 BOOT_PRINTF("in DUMB *** \n")
244 245
245 246 while(1){
246 247 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
247 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6,
248 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7,
248 249 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
249 250 intEventOut = (unsigned int) event_out;
250 251 for ( i=0; i<32; i++)
251 252 {
252 253 if ( ((intEventOut >> i) & 0x0001) != 0)
253 254 {
254 255 coarse_time = time_management_regs->coarse_time;
255 256 fine_time = time_management_regs->fine_time;
256 257 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
257 258 }
258 259 }
259 260 }
260 261 }
261 262
262 263 //*****************************
263 264 // init housekeeping parameters
264 265
265 266 void init_housekeeping_parameters( void )
266 267 {
267 268 /** This function initialize the housekeeping_packet global variable with default values.
268 269 *
269 270 */
270 271
271 272 unsigned int i = 0;
272 char *parameters;
273 unsigned char *parameters;
273 274
274 parameters = (char*) &housekeeping_packet.lfr_status_word;
275 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
275 276 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
276 277 {
277 278 parameters[i] = 0x00;
278 279 }
279 280 // init status word
280 281 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
281 282 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
282 283 // init software version
283 284 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
284 285 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
285 286 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
286 287 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
287
288 // init fpga version
289 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xd0);
290 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
291 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
292 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
288 293 }
289 294
290 295 void increment_seq_counter( unsigned char *packet_sequence_control)
291 296 {
292 297 /** This function increment the sequence counter psased in argument.
293 298 *
294 299 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
295 300 *
296 301 */
297 302
298 303 unsigned short sequence_cnt;
299 304 unsigned short segmentation_grouping_flag;
300 305 unsigned short new_packet_sequence_control;
301 306
302 307 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
303 308 sequence_cnt = (unsigned short) (
304 309 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
305 310 + packet_sequence_control[1]
306 311 );
307 312
308 313 if ( sequence_cnt < SEQ_CNT_MAX)
309 314 {
310 315 sequence_cnt = sequence_cnt + 1;
311 316 }
312 317 else
313 318 {
314 319 sequence_cnt = 0;
315 320 }
316 321
317 322 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
318 323
319 324 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
320 325 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
321 326 }
322 327
323 328 void getTime( unsigned char *time)
324 329 {
325 330 /** This function write the current local time in the time buffer passed in argument.
326 331 *
327 332 */
328 333
329 334 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
330 335 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
331 336 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
332 337 time[3] = (unsigned char) (time_management_regs->coarse_time);
333 338 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
334 339 time[5] = (unsigned char) (time_management_regs->fine_time);
335 340 }
336 341
@@ -1,656 +1,643
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 191 status = get_message_queue_id_send( &queue_id );
192 192 if (status != RTEMS_SUCCESSFUL)
193 193 {
194 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
204 #ifdef GSA
205 #else
206 fill_averaged_spectral_matrix( );
207 #endif
203 // 1) convert the float array in a char array
208 204 convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char);
209
205 // 2) send the spectral matrix packets
210 206 send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
211 207 }
212 208 }
213 209
214 210 //*****************************
215 211 // Spectral matrices processing
216 212
217 213 void matrix_reset(volatile float *averaged_spec_mat)
218 214 {
219 215 int i;
220 216 for(i=0; i<TOTAL_SIZE_SM; i++){
221 217 averaged_spec_mat[i] = 0;
222 218 }
223 219 }
224 220
225 221 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
226 222 {
227 223 int i;
228 224 int j;
229 225 switch (fChannel){
230 226 case 0:
231 227 for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){
232 228 j = 17 + (i * 8);
233 229 compressed_spec_mat[i] = (averaged_spec_mat[j]
234 230 + averaged_spec_mat[j+1]
235 231 + averaged_spec_mat[j+2]
236 232 + averaged_spec_mat[j+3]
237 233 + averaged_spec_mat[j+4]
238 234 + averaged_spec_mat[j+5]
239 235 + averaged_spec_mat[j+6]
240 236 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
241 237 }
242 238 break;
243 239 case 1:
244 240 // case fChannel = f1 to be completed later
245 241 break;
246 242 case 2:
247 243 // case fChannel = f1 to be completed later
248 244 break;
249 245 default:
250 246 break;
251 247 }
252 248 }
253 249
254 250 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
255 251 int i;
256 252 int j;
257 253 unsigned char tmp_u_char;
258 254 unsigned char * pt_char = NULL;
259 255 float PSDB, PSDE;
260 256 float NVEC_V0;
261 257 float NVEC_V1;
262 258 float NVEC_V2;
263 259 //float significand;
264 260 //int exponent;
265 261 float aux;
266 262 float tr_SB_SB;
267 263 float tmp;
268 264 float sx_re;
269 265 float sx_im;
270 266 float nebx_re = 0;
271 267 float nebx_im = 0;
272 268 float ny = 0;
273 269 float nz = 0;
274 270 float bx_bx_star = 0;
275 271 for(i=0; i<nb_bins_compressed_spec_mat; i++){
276 272 //==============================================
277 273 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
278 274 PSDB = compressed_spec_mat[i*30] // S11
279 275 + compressed_spec_mat[(i*30) + 10] // S22
280 276 + compressed_spec_mat[(i*30) + 18]; // S33
281 277 //significand = frexp(PSDB, &exponent);
282 278 pt_char = (unsigned char*) &PSDB;
283 279 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
284 280 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
285 281 //==============================================
286 282 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
287 283 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
288 284 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
289 285 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
290 286 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
291 287 pt_char = (unsigned char*) &PSDE;
292 288 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
293 289 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
294 290 //==============================================================================
295 291 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
296 292 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
297 293 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
298 294 tmp = sqrt(
299 295 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
300 296 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
301 297 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
302 298 );
303 299 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
304 300 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
305 301 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
306 302 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
307 303 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
308 304 pt_char = (unsigned char*) &NVEC_V2;
309 305 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
310 306 //=======================================================
311 307 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
312 308 aux = 2*tmp / PSDB; // compute the ellipticity
313 309 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
314 310 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
315 311 //==============================================================
316 312 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
317 313 for(j = 0; j<NB_VALUES_PER_SM;j++){
318 314 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
319 315 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
320 316 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
321 317 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
322 318 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
323 319 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
324 320 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
325 321 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
326 322 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
327 323 }
328 324 aux = PSDB*PSDB;
329 325 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
330 326 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
331 327 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
332 328 //=======================================================================================
333 329 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
334 330 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
335 331 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
336 332 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
337 333 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
338 334 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
339 335 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
340 336 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
341 337 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
342 338 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
343 339 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
344 340 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
345 341 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
346 342 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
347 343 if ( abs(sx_re) > abs(sx_im) ) {
348 344 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
349 345 }
350 346 else {
351 347 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
352 348 }
353 349 //======================================================================
354 350 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
355 351 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
356 352 nz = NVEC_V0;
357 353 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
358 354 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
359 355 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
360 356 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
361 357 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
362 358 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
363 359 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
364 360 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
365 361 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
366 362 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
367 363 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
368 364 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
369 365 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
370 366 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
371 367 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
372 368 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
373 369 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
374 370 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
375 371 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
376 372 tmp = nebx_re / bx_bx_star;
377 373 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
378 374 if ( abs(nebx_re) > abs(nebx_im) ) {
379 375 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
380 376 }
381 377 else {
382 378 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
383 379 }
384 380 }
385 381
386 382 }
387 383
388 384 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
389 385 // BP2 autocorrelation
390 386 int i;
391 387 int aux = 0;
392 388
393 389 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
394 390 // S12
395 391 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
396 392 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
397 393 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
398 394 // S13
399 395 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
400 396 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
401 397 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
402 398 // S23
403 399 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
404 400 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
405 401 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
406 402 // S45
407 403 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
408 404 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
409 405 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
410 406 // S14
411 407 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
412 408 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
413 409 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
414 410 // S15
415 411 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
416 412 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
417 413 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
418 414 // S24
419 415 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
420 416 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
421 417 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
422 418 // S25
423 419 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
424 420 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
425 421 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
426 422 // S34
427 423 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
428 424 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
429 425 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
430 426 // S35
431 427 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
432 428 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
433 429 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
434 430 }
435 431 }
436 432
437 433 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
438 434 {
439 435 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
440 436 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
441 437 header->reserved = 0x00;
442 438 header->userApplication = CCSDS_USER_APP;
443 439 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
444 440 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
445 441 header->packetSequenceControl[0] = 0xc0;
446 442 header->packetSequenceControl[1] = 0x00;
447 443 header->packetLength[0] = 0x00;
448 444 header->packetLength[1] = 0x00;
449 445 // DATA FIELD HEADER
450 446 header->spare1_pusVersion_spare2 = 0x10;
451 447 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
452 448 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
453 449 header->destinationID = TM_DESTINATION_ID_GROUND;
454 450 // AUXILIARY DATA HEADER
455 451 header->sid = 0x00;
456 452 header->biaStatusInfo = 0x00;
457 453 header->cntASM = 0x00;
458 454 header->nrASM = 0x00;
459 455 header->time[0] = 0x00;
460 456 header->time[0] = 0x00;
461 457 header->time[0] = 0x00;
462 458 header->time[0] = 0x00;
463 459 header->time[0] = 0x00;
464 460 header->time[0] = 0x00;
465 461 header->blkNr[0] = 0x00; // BLK_NR MSB
466 462 header->blkNr[1] = 0x00; // BLK_NR LSB
467 463 }
468 464
469 465 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
470 466 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
471 467 {
472 468 unsigned int i;
473 469 unsigned int length = 0;
474 470 rtems_status_code status;
475 471
476 472 header->sid = (unsigned char) sid;
477 473
478 474 for (i=0; i<2; i++)
479 475 {
480 476 // BUILD THE DATA
481 477 spw_ioctl_send->dlen = TOTAL_SIZE_SM;
482 478 spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM];
483 479 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
484 480 spw_ioctl_send->hdr = (char *) header;
485 481 spw_ioctl_send->options = 0;
486 482
487 483 // BUILD THE HEADER
488 484 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM;
489 485 header->packetLength[0] = (unsigned char) (length>>8);
490 486 header->packetLength[1] = (unsigned char) (length);
491 487 header->sid = (unsigned char) sid; // SID
492 488 header->cntASM = 2;
493 489 header->nrASM = (unsigned char) (i+1);
494 490 header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB
495 491 header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB
496 492 // SET PACKET TIME
497 493 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
498 494 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
499 495 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
500 496 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
501 497 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
502 498 header->time[5] = (unsigned char) (time_management_regs->fine_time);
503 499 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
504 500 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
505 501 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
506 502 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
507 503 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
508 504 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
509 505 // SEND PACKET
510 506 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
511 507 if (status != RTEMS_SUCCESSFUL) {
512 508 printf("in send_spectral_matrix *** ERR %d\n", (int) status);
513 509 }
514 510 }
515 511 }
516 512
517 513 void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix)
518 514 {
519 515 unsigned int i;
520 516 unsigned int j;
521 517 char * pt_char_input;
522 518 char * pt_char_output;
523 519
524 520 pt_char_input = NULL;
525 521 pt_char_output = NULL;
526 522
527 523 for( i=0; i<NB_BINS_PER_SM; i++)
528 524 {
529 525 for ( j=0; j<NB_VALUES_PER_SM; j++)
530 526 {
531 pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ];
527 pt_char_input = (char*) &input_matrix [ (i*NB_VALUES_PER_SM) + j ];
532 528 pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ];
533 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
534 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
529 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
530 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
535 531 }
536 532 }
537 533 }
538 534
539 535 void fill_averaged_spectral_matrix(void)
540 536 {
541 537 /** This function fills spectral matrices related buffers with arbitrary data.
542 538 *
543 539 * This function is for testing purpose only.
544 540 *
545 541 */
546 542
547 #ifdef GSA
548 float offset = 10.;
549 float coeff = 100000.;
543 float offset;
544 float coeff;
550 545
546 offset = 10.;
547 coeff = 100000.;
551 548 averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset;
552 549 averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset;
553 550 averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset;
554 551 averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset;
555 552 averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset;
556 553 averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset;
557 554 averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset;
558 555 averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset;
559 556 averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset;
560 557 averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset;
561 558 averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset;
562 559 averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset;
563 560 averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset;
564 561 averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset;
565 562 averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset;
566 563 averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
567 564 averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
568 565 averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
569 566 averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
570 567 averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
571 568 averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
572 569 averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
573 570 averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
574 571 averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
575 572 averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
576 573 averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
577 574 averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
578 575 averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
579 576 averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
580 577 averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
578
581 579 offset = 10000000;
582 580 averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
583 581 averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
584 582 averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
585 583 averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
586 584 averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
587 585 averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
588 586 averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
589 587 averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
590 588 averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
591 589 averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
592 590 averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
593 591 averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
594 592 averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
595 593 averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
596 594 averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
597 595
598 596 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ];
599 597 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ];
600 598 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ];
601 599 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ];
602 600 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ];
603 601 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ];
604 602 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ];
605 603 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ];
606 604 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ];
607 605 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ];
608 606 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ];
609 607 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ];
610 608 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ];
611 609 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ];
612 610 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ];
613 611 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ];
614 #else
615 unsigned int i;
616
617 for(i=0; i<TOTAL_SIZE_SM; i++)
618 {
619 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
620 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ];
621 else
622 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ];
623 }
624 #endif
625 612 }
626 613
627 614 void reset_spectral_matrix_regs()
628 615 {
629 616 /** This function resets the spectral matrices module registers.
630 617 *
631 618 * The registers affected by this function are located at the following offset addresses:
632 619 *
633 620 * - 0x00 config
634 621 * - 0x04 status
635 622 * - 0x08 matrixF0_Address0
636 623 * - 0x10 matrixFO_Address1
637 624 * - 0x14 matrixF1_Address
638 625 * - 0x18 matrixF2_Address
639 626 *
640 627 */
641 628
642 629 #ifdef GSA
643 630 #else
644 631 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
645 632 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
646 633 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
647 634 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
648 635 #endif
649 636 }
650 637
651 638 //******************
652 639 // general functions
653 640
654 641
655 642
656 643
@@ -1,606 +1,601
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 128 status = get_message_queue_id_recv( &queue_recv_id );
129 129 if (status != RTEMS_SUCCESSFUL)
130 130 {
131 131 PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status)
132 132 }
133 133
134 134 status = get_message_queue_id_send( &queue_send_id );
135 135 if (status != RTEMS_SUCCESSFUL)
136 136 {
137 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 214 status = get_message_queue_id_send( &queue_id );
215 215 if (status != RTEMS_SUCCESSFUL)
216 216 {
217 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 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
575 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
576 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
577 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
578 574
579 575 //*********************************************
580 576 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
581 577 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
582 578 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
583 579 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
584 580 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
585
586 581 }
587 582
588 583 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
589 584 {
590 585 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
591 586 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
592 587 //}
593 588 }
594 589
595 590 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
596 591 {
597 592 int linkStatus;
598 593 rtems_status_code status;
599 594
600 595 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
601 596
602 597 if ( linkStatus == 5) {
603 598 PRINTF("in spacewire_reset_link *** link is running\n")
604 599 status = RTEMS_SUCCESSFUL;
605 600 }
606 601 }
@@ -1,833 +1,833
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 unsigned char time[6];
35 35 rtems_id queue_rcv_id;
36 36 rtems_id queue_snd_id;
37 37
38 38 status = get_message_queue_id_recv( &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 42 }
43 43
44 44 status = get_message_queue_id_send( &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 48 }
49 49
50 50 result = LFR_SUCCESSFUL;
51 51 subtype = 0; // subtype of the current TC packet
52 52
53 53 BOOT_PRINTF("in ACTN *** \n")
54 54
55 55 while(1)
56 56 {
57 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 59 getTime( time ); // set time to the current time
60 60 if (status!=RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 63 }
64 64 else
65 65 {
66 66 subtype = TC.serviceSubType;
67 67 switch(subtype)
68 68 {
69 69 case TC_SUBTYPE_RESET:
70 70 result = action_reset( &TC, queue_snd_id, time );
71 71 close_action( &TC, result, queue_snd_id, 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("in action_enter_mode *** 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 // mask interruptions
398 398 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
399 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
399 //LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
400 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrix interrupt simulator
400 401 // reset registers
401 402 reset_wfp_burst_enable(); // reset burst and enable bits
402 403 reset_wfp_status(); // reset all the status bits
403 404 // clear interruptions
404 405 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
405 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
406 //LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
407 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrix interrupt simulator
406 408 //**********************
407 409 // suspend several tasks
408 410 if (lfrCurrentMode != LFR_MODE_STANDBY) {
409 411 status = suspend_science_tasks();
410 412 }
411 413
412 414 if (status != RTEMS_SUCCESSFUL)
413 415 {
414 416 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
415 417 }
416 418
417 419 return status;
418 420 }
419 421
420 422 int enter_mode(unsigned char mode )
421 423 {
422 424 /** This function is launched after a mode transition validation.
423 425 *
424 426 * @param mode is the mode in which LFR will be put.
425 427 *
426 428 * @return RTEMS directive status codes:
427 429 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
428 430 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
429 431 *
430 432 */
431 433
432 434 rtems_status_code status;
433 435
434 436 status = RTEMS_UNSATISFIED;
435 437
436 438 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
437 439 updateLFRCurrentMode();
438 440
439 441 switch(mode){
440 442 case LFR_MODE_STANDBY:
441 443 status = enter_standby_mode( );
442 444 break;
443 445 case LFR_MODE_NORMAL:
444 446 status = enter_normal_mode( );
445 447 break;
446 448 case LFR_MODE_BURST:
447 449 status = enter_burst_mode( );
448 450 break;
449 451 case LFR_MODE_SBM1:
450 452 status = enter_sbm1_mode( );
451 453 break;
452 454 case LFR_MODE_SBM2:
453 455 status = enter_sbm2_mode( );
454 456 break;
455 457 default:
456 458 status = RTEMS_UNSATISFIED;
457 459 }
458 460
459 461 if (status != RTEMS_SUCCESSFUL)
460 462 {
461 463 PRINTF("in enter_mode *** ERR\n")
462 464 status = RTEMS_UNSATISFIED;
463 465 }
464 466
465 467 return status;
466 468 }
467 469
468 470 int enter_standby_mode()
469 471 {
470 472 /** This function is used to enter the STANDBY mode.
471 473 *
472 474 * @return RTEMS directive status codes:
473 475 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
474 476 *
475 477 */
476 478
477 479 PRINTF1("maxCount = %d\n", maxCount)
478 480
479 481 #ifdef PRINT_TASK_STATISTICS
480 482 rtems_cpu_usage_report();
481 483 #endif
482 484
483 485 #ifdef PRINT_STACK_REPORT
484 486 rtems_stack_checker_report_usage();
485 487 #endif
486 488
487 489 return LFR_SUCCESSFUL;
488 490 }
489 491
490 492 int enter_normal_mode()
491 493 {
492 494 rtems_status_code status;
493 495
494 496 status = restart_science_tasks();
495 497
496 #ifdef GSA
497 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
498 //
499 set_local_nb_interrupt_f0_MAX();
500 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
501 LEON_Unmask_interrupt( IRQ_SM );
502 #else
503 launch_waveform_picker( LFR_MODE_SBM1 );
504 #endif
498 // Spectral Matrices simulator
499 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
500 // set_local_nb_interrupt_f0_MAX();
501 // LEON_Clear_interrupt( IRQ_SM );
502 // LEON_Unmask_interrupt( IRQ_SM );
503
504 launch_waveform_picker( LFR_MODE_NORMAL );
505 505
506 506 return status;
507 507 }
508 508
509 509 int enter_burst_mode()
510 510 {
511 511 /** This function is used to enter the STANDBY mode.
512 512 *
513 513 * @return RTEMS directive status codes:
514 514 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
515 515 * - RTEMS_INVALID_ID - task id invalid
516 516 * - RTEMS_INCORRECT_STATE - task never started
517 517 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
518 518 *
519 519 */
520 520
521 521 rtems_status_code status;
522 522
523 523 status = restart_science_tasks();
524 524
525 525 launch_waveform_picker( LFR_MODE_BURST );
526 526
527 527 return status;
528 528 }
529 529
530 530 int enter_sbm1_mode()
531 531 {
532 532 /** This function is used to enter the SBM1 mode.
533 533 *
534 534 * @return RTEMS directive status codes:
535 535 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
536 536 * - RTEMS_INVALID_ID - task id invalid
537 537 * - RTEMS_INCORRECT_STATE - task never started
538 538 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
539 539 *
540 540 */
541 541
542 542 rtems_status_code status;
543 543
544 544 status = restart_science_tasks();
545 545
546 546 launch_waveform_picker( LFR_MODE_SBM1 );
547 547
548 548 return status;
549 549 }
550 550
551 551 int enter_sbm2_mode()
552 552 {
553 553 /** This function is used to enter the SBM2 mode.
554 554 *
555 555 * @return RTEMS directive status codes:
556 556 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
557 557 * - RTEMS_INVALID_ID - task id invalid
558 558 * - RTEMS_INCORRECT_STATE - task never started
559 559 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
560 560 *
561 561 */
562 562
563 563 rtems_status_code status;
564 564
565 565 status = restart_science_tasks();
566 566
567 567 launch_waveform_picker( LFR_MODE_SBM2 );
568 568
569 569 return status;
570 570 }
571 571
572 572 int restart_science_tasks()
573 573 {
574 574 /** This function is used to restart all science tasks.
575 575 *
576 576 * @return RTEMS directive status codes:
577 577 * - RTEMS_SUCCESSFUL - task restarted successfully
578 578 * - RTEMS_INVALID_ID - task id invalid
579 579 * - RTEMS_INCORRECT_STATE - task never started
580 580 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
581 581 *
582 582 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
583 583 *
584 584 */
585 585
586 586 rtems_status_code status[6];
587 587 rtems_status_code ret;
588 588
589 589 ret = RTEMS_SUCCESSFUL;
590 590
591 591 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
592 592 if (status[0] != RTEMS_SUCCESSFUL)
593 593 {
594 594 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
595 595 }
596 596
597 597 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
598 598 if (status[1] != RTEMS_SUCCESSFUL)
599 599 {
600 600 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
601 601 }
602 602
603 603 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
604 604 if (status[2] != RTEMS_SUCCESSFUL)
605 605 {
606 606 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
607 607 }
608 608
609 609 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
610 610 if (status[3] != RTEMS_SUCCESSFUL)
611 611 {
612 612 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
613 613 }
614 614
615 615 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
616 616 if (status[4] != RTEMS_SUCCESSFUL)
617 617 {
618 618 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
619 619 }
620 620
621 621 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
622 622 if (status[5] != RTEMS_SUCCESSFUL)
623 623 {
624 624 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
625 625 }
626 626
627 627 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
628 628 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
629 629 {
630 630 ret = RTEMS_UNSATISFIED;
631 631 }
632 632
633 633 return ret;
634 634 }
635 635
636 636 int suspend_science_tasks()
637 637 {
638 638 /** This function suspends the science tasks.
639 639 *
640 640 * @return RTEMS directive status codes:
641 641 * - RTEMS_SUCCESSFUL - task restarted successfully
642 642 * - RTEMS_INVALID_ID - task id invalid
643 643 * - RTEMS_ALREADY_SUSPENDED - task already suspended
644 644 *
645 645 */
646 646
647 647 rtems_status_code status;
648 648
649 649 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
650 650 if (status != RTEMS_SUCCESSFUL)
651 651 {
652 652 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
653 653 }
654 654
655 655 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
656 656 {
657 657 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
658 658 if (status != RTEMS_SUCCESSFUL)
659 659 {
660 660 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
661 661 }
662 662 }
663 663
664 664 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
665 665 {
666 666 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
667 667 if (status != RTEMS_SUCCESSFUL)
668 668 {
669 669 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
670 670 }
671 671 }
672 672
673 673 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
674 674 {
675 675 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
676 676 if (status != RTEMS_SUCCESSFUL)
677 677 {
678 678 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
679 679 }
680 680 }
681 681
682 682 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
683 683 {
684 684 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
685 685 if (status != RTEMS_SUCCESSFUL)
686 686 {
687 687 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
688 688 }
689 689 }
690 690
691 691 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
692 692 {
693 693 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
694 694 if (status != RTEMS_SUCCESSFUL)
695 695 {
696 696 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
697 697 }
698 698 }
699 699
700 700 return status;
701 701 }
702 702
703 703 void launch_waveform_picker( unsigned char mode )
704 704 {
705 705 int startDate;
706 706
707 707 reset_current_ring_nodes();
708 708 reset_waveform_picker_regs();
709 709 set_wfp_burst_enable_register( mode );
710 710 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
711 711 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
712 712 #ifdef VHDL_DEV
713 713 startDate = time_management_regs->coarse_time + 2;
714 714 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
715 715 waveform_picker_regs->start_date = startDate;
716 716 #endif
717 717 }
718 718
719 719 //****************
720 720 // CLOSING ACTIONS
721 721 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time)
722 722 {
723 723 /** This function is used to update the HK packets statistics after a successful TC execution.
724 724 *
725 725 * @param TC points to the TC being processed
726 726 * @param time is the time used to date the TC execution
727 727 *
728 728 */
729 729
730 730 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
731 731 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
732 732 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
733 733 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
734 734 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
735 735 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
736 736 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
737 737 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
738 738 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
739 739 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
740 740 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
741 741 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
742 742 }
743 743
744 744 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time)
745 745 {
746 746 /** This function is used to update the HK packets statistics after a TC rejection.
747 747 *
748 748 * @param TC points to the TC being processed
749 749 * @param time is the time used to date the TC rejection
750 750 *
751 751 */
752 752
753 753 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
754 754 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
755 755 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
756 756 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
757 757 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
758 758 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
759 759 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
760 760 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
761 761 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
762 762 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
763 763 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
764 764 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
765 765 }
766 766
767 767 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time)
768 768 {
769 769 /** This function is the last step of the TC execution workflow.
770 770 *
771 771 * @param TC points to the TC being processed
772 772 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
773 773 * @param queue_id is the id of the RTEMS message queue used to send TM packets
774 774 * @param time is the time used to date the TC execution
775 775 *
776 776 */
777 777
778 778 unsigned int val = 0;
779 779
780 780 if (result == LFR_SUCCESSFUL)
781 781 {
782 782 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
783 783 &&
784 784 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
785 785 )
786 786 {
787 787 send_tm_lfr_tc_exe_success( TC, queue_id, time );
788 788 }
789 789 update_last_TC_exe( TC, time );
790 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
790 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
791 791 val++;
792 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
793 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
792 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
793 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
794 794 }
795 795 else
796 796 {
797 797 update_last_TC_rej( TC, time );
798 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
798 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
799 799 val++;
800 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
801 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
800 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
801 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
802 802 }
803 803 }
804 804
805 805 //***************************
806 806 // Interrupt Service Routines
807 807 rtems_isr commutation_isr1( rtems_vector_number vector )
808 808 {
809 809 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
810 810 printf("In commutation_isr1 *** Error sending event to DUMB\n");
811 811 }
812 812 }
813 813
814 814 rtems_isr commutation_isr2( rtems_vector_number vector )
815 815 {
816 816 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
817 817 printf("In commutation_isr2 *** Error sending event to DUMB\n");
818 818 }
819 819 }
820 820
821 821 //****************
822 822 // OTHER FUNCTIONS
823 823 void updateLFRCurrentMode()
824 824 {
825 825 /** This function updates the value of the global variable lfrCurrentMode.
826 826 *
827 827 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
828 828 *
829 829 */
830 830 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
831 831 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
832 832 }
833 833
@@ -1,455 +1,484
1 1 /** Functions to load and dump parameters in the LFR registers.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 7 * TC_LFR_LOAD_COMMON_PAR\n
8 8 * TC_LFR_LOAD_NORMAL_PAR\n
9 9 * TC_LFR_LOAD_BURST_PAR\n
10 10 * TC_LFR_LOAD_SBM1_PAR\n
11 11 * TC_LFR_LOAD_SBM2_PAR\n
12 12 *
13 13 */
14 14
15 15 #include "tc_load_dump_parameters.h"
16 16
17 17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 18 {
19 19 /** This function updates the LFR registers with the incoming common parameters.
20 20 *
21 21 * @param TC points to the TeleCommand packet that is being processed
22 22 *
23 23 *
24 24 */
25 25
26 26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 28 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
29 29 return LFR_SUCCESSFUL;
30 30 }
31 31
32 32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
33 33 {
34 34 /** This function updates the LFR registers with the incoming normal parameters.
35 35 *
36 36 * @param TC points to the TeleCommand packet that is being processed
37 37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 38 *
39 39 */
40 40
41 41 int result;
42 42 int flag;
43 43 rtems_status_code status;
44 44
45 45 flag = LFR_SUCCESSFUL;
46 46
47 47 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
48 48 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
49 49 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
50 50 flag = LFR_DEFAULT;
51 51 }
52 52
53 53 //***************
54 54 // sy_lfr_n_swf_l
55 55 if (flag == LFR_SUCCESSFUL)
56 56 {
57 57 result = set_sy_lfr_n_swf_l( TC, queue_id, time );
58 58 if (result != LFR_SUCCESSFUL)
59 59 {
60 60 flag = LFR_DEFAULT;
61 61 }
62 62 }
63 63
64 64 //***************
65 65 // sy_lfr_n_swf_p
66 66 if (flag == LFR_SUCCESSFUL)
67 67 {
68 68 result = set_sy_lfr_n_swf_p( TC, queue_id, time );
69 69 if (result != LFR_SUCCESSFUL)
70 70 {
71 71 flag = LFR_DEFAULT;
72 72 }
73 73 }
74 74
75 75 //***************
76 76 // SY_LFR_N_ASM_P
77 77 if (flag == LFR_SUCCESSFUL)
78 78 {
79 79 result = set_sy_lfr_n_asm_p( TC, queue_id );
80 80 if (result != LFR_SUCCESSFUL)
81 81 {
82 82 flag = LFR_DEFAULT;
83 83 }
84 84 }
85 85
86 86 //***************
87 87 // SY_LFR_N_BP_P0
88 88 if (flag == LFR_SUCCESSFUL)
89 89 {
90 90 result = set_sy_lfr_n_bp_p0( TC, queue_id );
91 91 if (result != LFR_SUCCESSFUL)
92 92 {
93 93 flag = LFR_DEFAULT;
94 94 }
95 95 }
96 96
97 97 //***************
98 98 // sy_lfr_n_bp_p1
99 99 if (flag == LFR_SUCCESSFUL)
100 100 {
101 101 result = set_sy_lfr_n_bp_p1( TC, queue_id );
102 102 if (result != LFR_SUCCESSFUL)
103 103 {
104 104 flag = LFR_DEFAULT;
105 105 }
106 106 }
107 107
108 //*********************
109 // sy_lfr_n_cwf_long_f3
110 if (flag == LFR_SUCCESSFUL)
111 {
112 result = set_sy_lfr_n_cwf_long_f3( TC, queue_id );
113 if (result != LFR_SUCCESSFUL)
114 {
115 flag = LFR_DEFAULT;
116 }
117 }
118
108 119 return flag;
109 120 }
110 121
111 122 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
112 123 {
113 124 /** This function updates the LFR registers with the incoming burst parameters.
114 125 *
115 126 * @param TC points to the TeleCommand packet that is being processed
116 127 * @param queue_id is the id of the queue which handles TM related to this execution step
117 128 *
118 129 */
119 130
120 131 int result;
121 132 unsigned char lfrMode;
122 133 rtems_status_code status;
123 134
124 135 result = LFR_DEFAULT;
125 136 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
126 137
127 138 if ( lfrMode == LFR_MODE_BURST ) {
128 139 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
129 140 result = LFR_DEFAULT;
130 141 }
131 142 else {
132 143 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
133 144 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
134 145
135 146 result = LFR_SUCCESSFUL;
136 147 }
137 148
138 149 return result;
139 150 }
140 151
141 152 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
142 153 {
143 154 /** This function updates the LFR registers with the incoming sbm1 parameters.
144 155 *
145 156 * @param TC points to the TeleCommand packet that is being processed
146 157 * @param queue_id is the id of the queue which handles TM related to this execution step
147 158 *
148 159 */
149 160 int result;
150 161 unsigned char lfrMode;
151 162 rtems_status_code status;
152 163
153 164 result = LFR_DEFAULT;
154 165 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
155 166
156 167 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
157 168 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
158 169 result = LFR_DEFAULT;
159 170 }
160 171 else {
161 172 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
162 173 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
163 174
164 175 result = LFR_SUCCESSFUL;
165 176 }
166 177
167 178 return result;
168 179 }
169 180
170 181 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
171 182 {
172 183 /** This function updates the LFR registers with the incoming sbm2 parameters.
173 184 *
174 185 * @param TC points to the TeleCommand packet that is being processed
175 186 * @param queue_id is the id of the queue which handles TM related to this execution step
176 187 *
177 188 */
178 189
179 190 int result;
180 191 unsigned char lfrMode;
181 192 rtems_status_code status;
182 193
183 194 result = LFR_DEFAULT;
184 195 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
185 196
186 197 if ( (lfrMode == LFR_MODE_SBM2) || (lfrMode == LFR_MODE_SBM2) ) {
187 198 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
188 199 result = LFR_DEFAULT;
189 200 }
190 201 else {
191 202 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
192 203 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
193 204
194 205 result = LFR_SUCCESSFUL;
195 206 }
196 207
197 208 return result;
198 209 }
199 210
200 211 int action_dump_par( rtems_id queue_id )
201 212 {
202 213 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
203 214 *
204 215 * @param queue_id is the id of the queue which handles TM related to this execution step.
205 216 *
206 217 * @return RTEMS directive status codes:
207 218 * - RTEMS_SUCCESSFUL - message sent successfully
208 219 * - RTEMS_INVALID_ID - invalid queue id
209 220 * - RTEMS_INVALID_SIZE - invalid message size
210 221 * - RTEMS_INVALID_ADDRESS - buffer is NULL
211 222 * - RTEMS_UNSATISFIED - out of message buffers
212 223 * - RTEMS_TOO_MANY - queue s limit has been reached
213 224 *
214 225 */
215 226
216 227 int status;
217 228
218 229 // UPDATE TIME
219 230 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
220 231 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
221 232 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
222 233 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
223 234 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
224 235 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
225 236 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
226 237 // SEND DATA
227 238 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
228 239 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
229 240 if (status != RTEMS_SUCCESSFUL) {
230 241 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
231 242 }
232 243
233 244 return status;
234 245 }
235 246
236 247 //***********************
237 248 // NORMAL MODE PARAMETERS
238 249
239 250 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
240 251 {
241 252 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
242 253 *
243 254 * @param TC points to the TeleCommand packet that is being processed
244 255 * @param queue_id is the id of the queue which handles TM related to this execution step
245 256 *
246 257 */
247 258
248 259 unsigned int tmp;
249 260 int result;
250 261 unsigned char msb;
251 262 unsigned char lsb;
252 263 rtems_status_code status;
253 264
254 265 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
255 266 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
256 267
257 268 tmp = ( unsigned int ) floor(
258 269 ( ( msb*256 ) + lsb ) / 16
259 270 ) * 16;
260 271
261 272 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
262 273 { // 2048 is the maximum limit due to the size of the buffers
263 274 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb, time );
264 275 result = WRONG_APP_DATA;
265 276 }
266 277 else if (tmp != 2048)
267 278 {
268 279 status = send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
269 280 result = FUNCT_NOT_IMPL;
270 281 }
271 282 else
272 283 {
273 284 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
274 285 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
275 286 result = LFR_SUCCESSFUL;
276 287 }
277 288
278 289 return result;
279 290 }
280 291
281 292 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time)
282 293 {
283 294 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
284 295 *
285 296 * @param TC points to the TeleCommand packet that is being processed
286 297 * @param queue_id is the id of the queue which handles TM related to this execution step
287 298 *
288 299 */
289 300
290 301 unsigned int tmp;
291 302 int result;
292 303 unsigned char msb;
293 304 unsigned char lsb;
294 305 rtems_status_code status;
295 306
296 307 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
297 308 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
298 309
299 310 tmp = ( unsigned int ) floor(
300 311 ( ( msb*256 ) + lsb ) / 8
301 312 ) * 8;
302 313
303 314 if ( (tmp < 16) || (tmp > 65528) )
304 315 {
305 316 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb, time );
306 317 result = WRONG_APP_DATA;
307 318 }
308 319 else
309 320 {
310 321 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
311 322 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
312 323 result = LFR_SUCCESSFUL;
313 324 }
314 325
315 326 return result;
316 327 }
317 328
318 329 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
319 330 {
320 331 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
321 332 *
322 333 * @param TC points to the TeleCommand packet that is being processed
323 334 * @param queue_id is the id of the queue which handles TM related to this execution step
324 335 *
325 336 */
326 337
327 338 int result;
328 339 unsigned char msb;
329 340 unsigned char lsb;
330 341
331 342 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
332 343 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
333 344
334 345 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
335 346 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
336 347 result = LFR_SUCCESSFUL;
337 348
338 349 return result;
339 350 }
340 351
341 352 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
342 353 {
343 354 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
344 355 *
345 356 * @param TC points to the TeleCommand packet that is being processed
346 357 * @param queue_id is the id of the queue which handles TM related to this execution step
347 358 *
348 359 */
349 360
350 361 int status;
351 362
352 363 status = LFR_SUCCESSFUL;
353 364
354 365 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
355 366
356 367 return status;
357 368 }
358 369
359 370 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
360 371 {
361 372 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
362 373 *
363 374 * @param TC points to the TeleCommand packet that is being processed
364 375 * @param queue_id is the id of the queue which handles TM related to this execution step
365 376 *
366 377 */
367 378
368 379 int status;
369 380
370 381 status = LFR_SUCCESSFUL;
371 382
372 383 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
373 384
374 385 return status;
375 386 }
376 387
388 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
389 {
390 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
391 *
392 * @param TC points to the TeleCommand packet that is being processed
393 * @param queue_id is the id of the queue which handles TM related to this execution step
394 *
395 */
396
397 int status;
398
399 status = LFR_SUCCESSFUL;
400
401 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_CWF_LONG_F3 ];
402
403 return status;
404 }
405
377 406 //**********************
378 407 // BURST MODE PARAMETERS
379 408
380 409 //*********************
381 410 // SBM1 MODE PARAMETERS
382 411
383 412 //*********************
384 413 // SBM2 MODE PARAMETERS
385 414
386 415 //**********
387 416 // init dump
388 417
389 418 void init_parameter_dump( void )
390 419 {
391 420 /** This function initialize the parameter_dump_packet global variable with default values.
392 421 *
393 422 */
394 423
395 424 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
396 425 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
397 426 parameter_dump_packet.reserved = CCSDS_RESERVED;
398 427 parameter_dump_packet.userApplication = CCSDS_USER_APP;
399 428 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
400 429 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
401 430 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
402 431 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
403 432 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
404 433 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
405 434 // DATA FIELD HEADER
406 435 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
407 436 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
408 437 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
409 438 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
410 439 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
411 440 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
412 441 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
413 442 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
414 443 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
415 444 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
416 445 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
417 446
418 447 //******************
419 448 // COMMON PARAMETERS
420 449 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
421 450 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
422 451
423 452 //******************
424 453 // NORMAL PARAMETERS
425 454 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
426 455 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
427 456 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
428 457 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
429 458 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
430 459 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
431 460 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
432 461 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
433 462
434 463 //*****************
435 464 // BURST PARAMETERS
436 465 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
437 466 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
438 467
439 468 //****************
440 469 // SBM1 PARAMETERS
441 470 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
442 471 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
443 472
444 473 //****************
445 474 // SBM2 PARAMETERS
446 475 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
447 476 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
448 477 }
449 478
450 479
451 480
452 481
453 482
454 483
455 484
@@ -1,1146 +1,1181
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 //*****************
13 13 // waveform headers
14 14 // SWF
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 18 // CWF
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
22 22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
23 23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
24 24
25 25 //**************
26 26 // waveform ring
27 ring_node waveform_ring_f0[NB_RING_NODES_F0];
27 28 ring_node waveform_ring_f1[NB_RING_NODES_F1];
28 29 ring_node waveform_ring_f2[NB_RING_NODES_F2];
30 ring_node *current_ring_node_f0;
31 ring_node *ring_node_to_send_swf_f0;
29 32 ring_node *current_ring_node_f1;
30 33 ring_node *ring_node_to_send_swf_f1;
31 34 ring_node *ring_node_to_send_cwf_f1;
32 35 ring_node *current_ring_node_f2;
33 36 ring_node *ring_node_to_send_swf_f2;
34 37 ring_node *ring_node_to_send_cwf_f2;
35 38
36 39 unsigned char doubleSendCWF2 = 0;
37 40
38 41 rtems_isr waveforms_isr( rtems_vector_number vector )
39 42 {
40 43 /** This is the interrupt sub routine called by the waveform picker core.
41 44 *
42 45 * This ISR launch different actions depending mainly on two pieces of information:
43 46 * 1. the values read in the registers of the waveform picker.
44 47 * 2. the current LFR mode.
45 48 *
46 49 */
47 50
48 51 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
49 52 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
50 53 { // in modes other than STANDBY and BURST, send the CWF_F3 data
51 54 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
52 55 // (1) change the receiving buffer for the waveform picker
53 56 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
54 57 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
55 58 }
56 59 else {
57 60 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
58 61 }
59 62 // (2) send an event for the waveforms transmission
60 63 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
61 64 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
62 65 }
63 66 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
64 67 }
65 68 }
66 69
67 70 switch(lfrCurrentMode)
68 71 {
69 72 //********
70 73 // STANDBY
71 74 case(LFR_MODE_STANDBY):
72 75 break;
73 76
74 77 //******
75 78 // NORMAL
76 79 case(LFR_MODE_NORMAL):
77 80 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
81 // change F0 ring node
82 ring_node_to_send_swf_f0 = current_ring_node_f0;
83 current_ring_node_f0 = current_ring_node_f0->next;
84 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address;
78 85 // change F1 ring node
79 86 ring_node_to_send_swf_f1 = current_ring_node_f1;
80 87 current_ring_node_f1 = current_ring_node_f1->next;
81 88 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
82 89 // change F2 ring node
83 90 ring_node_to_send_swf_f2 = current_ring_node_f2;
84 91 current_ring_node_f2 = current_ring_node_f2->next;
85 92 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
86 93 // send an event to the WFRM task
87 94 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
88 95 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
89 96 }
90 97 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
98 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_7 );
99 // reset_wfp_burst_enable();
91 100 }
92 101 break;
93 102
94 103 //******
95 104 // BURST
96 105 case(LFR_MODE_BURST):
97 106 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
98 107 // (1) change the receiving buffer for the waveform picker
99 108 ring_node_to_send_cwf_f2 = current_ring_node_f2;
100 109 current_ring_node_f2 = current_ring_node_f2->next;
101 110 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
102 111 // (2) send an event for the waveforms transmission
103 112 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
104 113 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
105 114 }
106 115 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
107 116 }
108 117 break;
109 118
110 119 //*****
111 120 // SBM1
112 121 case(LFR_MODE_SBM1):
113 122 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
114 123 // (1) change the receiving buffer for the waveform picker
115 124 ring_node_to_send_cwf_f1 = current_ring_node_f1;
116 125 current_ring_node_f1 = current_ring_node_f1->next;
117 126 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
118 127 // (2) send an event for the waveforms transmission
119 128 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
120 129 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
121 130 }
122 131 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
123 132 }
124 133 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
125 134 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
126 135 }
127 136 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
128 137 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
129 138 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
130 139 }
131 140 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
132 141 }
133 142 break;
134 143
135 144 //*****
136 145 // SBM2
137 146 case(LFR_MODE_SBM2):
138 147 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
139 148 // (1) change the receiving buffer for the waveform picker
140 149 ring_node_to_send_cwf_f2 = current_ring_node_f2;
141 150 current_ring_node_f2 = current_ring_node_f2->next;
142 151 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
143 152 // (2) send an event for the waveforms transmission
144 153 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
145 154 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
146 155 }
147 156 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
148 157 }
149 158 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
150 159 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
151 160 }
152 161 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
153 162 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
154 163 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
155 164 }
156 165 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
157 166 }
158 167 break;
159 168
160 169 //********
161 170 // DEFAULT
162 171 default:
163 172 break;
164 173 }
165 174 }
166 175
167 176 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
168 177 {
169 178 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
170 179 *
171 180 * @param unused is the starting argument of the RTEMS task
172 181 *
173 182 * The following data packets are sent by this task:
174 183 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
175 184 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
176 185 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
177 186 *
178 187 */
179 188
180 189 rtems_event_set event_out;
181 190 rtems_id queue_id;
182 191 rtems_status_code status;
183 192
184 193 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
185 194 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
186 195 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
187 196
188 197 init_waveforms();
189 198
190 199 status = get_message_queue_id_send( &queue_id );
191 200 if (status != RTEMS_SUCCESSFUL)
192 201 {
193 202 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
194 203 }
195 204
196 205 BOOT_PRINTF("in WFRM ***\n")
197 206
198 207 while(1){
199 208 // wait for an RTEMS_EVENT
200 209 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
201 210 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
202 211 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
203 212 if (event_out == RTEMS_EVENT_MODE_NORMAL)
204 213 {
205 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
214 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
206 215 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
207 216 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
208 217 }
209 218 else
210 219 {
211 220 PRINTF("in WFRM *** unexpected event")
212 221 }
213 222 }
214 223 }
215 224
216 225 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
217 226 {
218 227 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
219 228 *
220 229 * @param unused is the starting argument of the RTEMS task
221 230 *
222 231 * The following data packet is sent by this task:
223 232 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
224 233 *
225 234 */
226 235
227 236 rtems_event_set event_out;
228 237 rtems_id queue_id;
229 238 rtems_status_code status;
230 239
231 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
232 init_header_continuous_wf3_light_table( headerCWF_F3_light );
240 init_header_continuous_wf_table( SID_NORM_CWF_LONG_F3, headerCWF_F3 );
241 init_header_continuous_cwf3_light_table( headerCWF_F3_light );
233 242
234 243 status = get_message_queue_id_send( &queue_id );
235 244 if (status != RTEMS_SUCCESSFUL)
236 245 {
237 246 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
238 247 }
239 248
240 249 BOOT_PRINTF("in CWF3 ***\n")
241 250
242 251 while(1){
243 252 // wait for an RTEMS_EVENT
244 253 rtems_event_receive( RTEMS_EVENT_0,
245 254 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
246 255 PRINTF("send CWF F3 \n")
247 #ifdef GSA
248 #else
249 256 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
250 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
257 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
258 {
259 send_waveform_CWF( wf_cont_f3_b, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
260 }
261 else
262 {
263 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
264 }
251 265 }
252 else {
253 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
266 else
267 {
268 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x00)
269 {
270 send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id );
271 }
272 else
273 {
274 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
275 }
276
254 277 }
255 #endif
256 278 }
257 279 }
258 280
259 281 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
260 282 {
261 283 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
262 284 *
263 285 * @param unused is the starting argument of the RTEMS task
264 286 *
265 287 * The following data packet is sent by this function:
266 288 * - TM_LFR_SCIENCE_BURST_CWF_F2
267 289 * - TM_LFR_SCIENCE_SBM2_CWF_F2
268 290 *
269 291 */
270 292
271 293 rtems_event_set event_out;
272 294 rtems_id queue_id;
273 295 rtems_status_code status;
274 296
275 297 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
276 298 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
277 299
278 300 status = get_message_queue_id_send( &queue_id );
279 301 if (status != RTEMS_SUCCESSFUL)
280 302 {
281 303 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
282 304 }
283 305
284 306 BOOT_PRINTF("in CWF2 ***\n")
285 307
286 308 while(1){
287 309 // wait for an RTEMS_EVENT
288 310 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
289 311 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
290 312 if (event_out == RTEMS_EVENT_MODE_BURST)
291 313 {
292 314 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
293 315 }
294 316 if (event_out == RTEMS_EVENT_MODE_SBM2)
295 317 {
296 318 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
297 319 }
298 320 }
299 321 }
300 322
301 323 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
302 324 {
303 325 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
304 326 *
305 327 * @param unused is the starting argument of the RTEMS task
306 328 *
307 329 * The following data packet is sent by this function:
308 330 * - TM_LFR_SCIENCE_SBM1_CWF_F1
309 331 *
310 332 */
311 333
312 334 rtems_event_set event_out;
313 335 rtems_id queue_id;
314 336 rtems_status_code status;
315 337
316 338 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
317 339
318 340 status = get_message_queue_id_send( &queue_id );
319 341 if (status != RTEMS_SUCCESSFUL)
320 342 {
321 343 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
322 344 }
323 345
324 346 BOOT_PRINTF("in CWF1 ***\n")
325 347
326 348 while(1){
327 349 // wait for an RTEMS_EVENT
328 350 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
329 351 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
330 352 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
331 353 }
332 354 }
333 355
334 356 //******************
335 357 // general functions
336 358 void init_waveforms( void )
337 359 {
338 360 int i = 0;
339 361
340 362 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
341 363 {
342 364 //***
343 365 // F0
344 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
345 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
346 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
366 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
367 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
368 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
347 369
348 370 //***
349 371 // F1
350 372 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
351 373 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
352 374 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
353 375
354 376 //***
355 377 // F2
356 378 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
357 379 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
358 380 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
359 381
360 382 //***
361 383 // F3
362 384 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
363 385 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
364 386 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
365 387 }
366 388 }
367 389
368 390 void init_waveform_rings( void )
369 391 {
370 392 unsigned char i;
371 393
394 // F0 RING
395 waveform_ring_f0[0].next = (ring_node*) &waveform_ring_f0[1];
396 waveform_ring_f0[0].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-1];
397 waveform_ring_f0[0].buffer_address = (int) &wf_snap_f0[0][0];
398
399 waveform_ring_f0[NB_RING_NODES_F0-1].next = (ring_node*) &waveform_ring_f0[0];
400 waveform_ring_f0[NB_RING_NODES_F0-1].previous = (ring_node*) &waveform_ring_f0[NB_RING_NODES_F0-2];
401 waveform_ring_f0[NB_RING_NODES_F0-1].buffer_address = (int) &wf_snap_f0[NB_RING_NODES_F0-1][0];
402
403 for(i=1; i<NB_RING_NODES_F0-1; i++)
404 {
405 waveform_ring_f0[i].next = (ring_node*) &waveform_ring_f0[i+1];
406 waveform_ring_f0[i].previous = (ring_node*) &waveform_ring_f0[i-1];
407 waveform_ring_f0[i].buffer_address = (int) &wf_snap_f0[i][0];
408 }
409
372 410 // F1 RING
373 411 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
374 412 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
375 413 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
376 414
377 415 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
378 416 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
379 417 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
380 418
381 419 for(i=1; i<NB_RING_NODES_F1-1; i++)
382 420 {
383 421 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
384 422 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
385 423 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
386 424 }
387 425
388 426 // F2 RING
389 427 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
390 428 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
391 429 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
392 430
393 431 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
394 432 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
395 433 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
396 434
397 435 for(i=1; i<NB_RING_NODES_F2-1; i++)
398 436 {
399 437 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
400 438 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
401 439 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
402 440 }
403 441
442 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
404 443 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
405 444 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
406 445
407 446 }
408 447
409 448 void reset_current_ring_nodes( void )
410 449 {
450 current_ring_node_f0 = waveform_ring_f0;
451 ring_node_to_send_swf_f0 = waveform_ring_f0;
452
411 453 current_ring_node_f1 = waveform_ring_f1;
412 454 ring_node_to_send_cwf_f1 = waveform_ring_f1;
413 455 ring_node_to_send_swf_f1 = waveform_ring_f1;
414 456
415 457 current_ring_node_f2 = waveform_ring_f2;
416 458 ring_node_to_send_cwf_f2 = waveform_ring_f2;
417 459 ring_node_to_send_swf_f2 = waveform_ring_f2;
418 460 }
419 461
420 462 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
421 463 {
422 464 unsigned char i;
423 465
424 466 for (i=0; i<7; i++)
425 467 {
426 468 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
427 469 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
428 470 headerSWF[ i ].reserved = DEFAULT_RESERVED;
429 471 headerSWF[ i ].userApplication = CCSDS_USER_APP;
430 472 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
431 473 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
432 if (i == 0)
474 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
475 if (i == 6)
433 476 {
434 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
435 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
436 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
437 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
438 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
439 }
440 else if (i == 6)
441 {
442 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
443 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
444 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
445 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
446 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
477 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
478 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
479 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
480 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_224 );
447 481 }
448 482 else
449 483 {
450 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
451 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
452 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
453 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
454 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
484 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
485 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
486 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
487 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_304 );
455 488 }
456 489 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
457 490 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
458 491 headerSWF[ i ].pktNr = i+1; // PKT_NR
459 492 // DATA FIELD HEADER
460 493 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
461 494 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
462 495 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
463 496 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
464 497 // AUXILIARY DATA HEADER
465 498 headerSWF[ i ].time[0] = 0x00;
466 499 headerSWF[ i ].time[0] = 0x00;
467 500 headerSWF[ i ].time[0] = 0x00;
468 501 headerSWF[ i ].time[0] = 0x00;
469 502 headerSWF[ i ].time[0] = 0x00;
470 503 headerSWF[ i ].time[0] = 0x00;
471 504 headerSWF[ i ].sid = sid;
472 505 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
473 506 }
474 507 return LFR_SUCCESSFUL;
475 508 }
476 509
477 510 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
478 511 {
479 512 unsigned int i;
480 513
481 514 for (i=0; i<7; i++)
482 515 {
483 516 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
484 517 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
485 518 headerCWF[ i ].reserved = DEFAULT_RESERVED;
486 519 headerCWF[ i ].userApplication = CCSDS_USER_APP;
487 520 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
488 521 {
489 522 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
490 523 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
491 524 }
492 525 else
493 526 {
494 527 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
495 528 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
496 529 }
497 530 if (i == 0)
498 531 {
499 532 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
500 533 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
501 534 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
502 535 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
503 536 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
504 537 }
505 538 else if (i == 6)
506 539 {
507 540 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
508 541 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
509 542 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
510 543 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
511 544 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
512 545 }
513 546 else
514 547 {
515 548 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
516 549 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
517 550 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
518 551 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
519 552 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
520 553 }
521 554 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
522 555 // PKT_CNT
523 556 // PKT_NR
524 557 // DATA FIELD HEADER
525 558 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
526 559 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
527 560 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
528 561 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
529 562 // AUXILIARY DATA HEADER
530 563 headerCWF[ i ].sid = sid;
531 564 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
532 565 headerCWF[ i ].time[0] = 0x00;
533 566 headerCWF[ i ].time[0] = 0x00;
534 567 headerCWF[ i ].time[0] = 0x00;
535 568 headerCWF[ i ].time[0] = 0x00;
536 569 headerCWF[ i ].time[0] = 0x00;
537 570 headerCWF[ i ].time[0] = 0x00;
538 571 }
539 572 return LFR_SUCCESSFUL;
540 573 }
541 574
542 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
575 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
543 576 {
544 577 unsigned int i;
545 578
546 579 for (i=0; i<7; i++)
547 580 {
548 581 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
549 582 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
550 583 headerCWF[ i ].reserved = DEFAULT_RESERVED;
551 584 headerCWF[ i ].userApplication = CCSDS_USER_APP;
552 585
553 586 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
554 587 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
555 588 if (i == 0)
556 589 {
557 590 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
558 591 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
559 592 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
560 593 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
561 594 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
562 595 }
563 596 else if (i == 6)
564 597 {
565 598 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
566 599 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
567 600 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
568 601 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
569 602 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
570 603 }
571 604 else
572 605 {
573 606 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
574 607 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
575 608 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
576 609 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
577 610 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
578 611 }
579 612 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
580 613 // DATA FIELD HEADER
581 614 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
582 615 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
583 616 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
584 617 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
585 618 // AUXILIARY DATA HEADER
586 619 headerCWF[ i ].sid = SID_NORM_CWF_F3;
587 620 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
588 621 headerCWF[ i ].time[0] = 0x00;
589 622 headerCWF[ i ].time[0] = 0x00;
590 623 headerCWF[ i ].time[0] = 0x00;
591 624 headerCWF[ i ].time[0] = 0x00;
592 625 headerCWF[ i ].time[0] = 0x00;
593 626 headerCWF[ i ].time[0] = 0x00;
594 627 }
595 628 return LFR_SUCCESSFUL;
596 629 }
597 630
598 631 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
599 632 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
600 633 {
601 634 /** This function sends SWF CCSDS packets (F2, F1 or F0).
602 635 *
603 636 * @param waveform points to the buffer containing the data that will be send.
604 637 * @param sid is the source identifier of the data that will be sent.
605 638 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
606 639 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
607 640 * contain information to setup the transmission of the data packets.
608 641 *
609 642 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
610 643 *
611 644 */
612 645
613 646 unsigned int i;
614 647 int ret;
615 648 rtems_status_code status;
616 649 spw_ioctl_pkt_send spw_ioctl_send_SWF;
617 650
618 651 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
619 652 spw_ioctl_send_SWF.options = 0;
620 653
621 654 ret = LFR_DEFAULT;
622 655
623 656 for (i=0; i<7; i++) // send waveform
624 657 {
625 658 #ifdef VHDL_DEV
626 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
659 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 304 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
627 660 #else
628 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
661 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 304 * NB_WORDS_SWF_BLK) ];
629 662 #endif
630 663 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
631 664 // BUILD THE DATA
632 665 if (i==6) {
633 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
666 spw_ioctl_send_SWF.dlen = 224 * NB_BYTES_SWF_BLK;
634 667 }
635 668 else {
636 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
669 spw_ioctl_send_SWF.dlen = 304 * NB_BYTES_SWF_BLK;
637 670 }
638 671 // SET PACKET SEQUENCE COUNTER
639 672 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
640 673 // SET PACKET TIME
641 674 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
642 675 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
643 676 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
644 677 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
645 678 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
646 679 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
647 680 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
648 681 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
649 682 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
650 683 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
651 684 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
652 685 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
653 686 // SEND PACKET
654 687 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
655 688 if (status != RTEMS_SUCCESSFUL) {
656 689 printf("%d-%d, ERR %d\n", sid, i, (int) status);
657 690 ret = LFR_DEFAULT;
658 691 }
659 692 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
660 693 }
661 694
662 695 return ret;
663 696 }
664 697
665 698 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
666 699 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
667 700 {
668 701 /** This function sends CWF CCSDS packets (F2, F1 or F0).
669 702 *
670 703 * @param waveform points to the buffer containing the data that will be send.
671 704 * @param sid is the source identifier of the data that will be sent.
672 705 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
673 706 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
674 707 * contain information to setup the transmission of the data packets.
675 708 *
676 709 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
677 710 *
678 711 */
679 712
680 713 unsigned int i;
681 714 int ret;
682 715 rtems_status_code status;
683 716 spw_ioctl_pkt_send spw_ioctl_send_CWF;
684 717
685 718 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
686 719 spw_ioctl_send_CWF.options = 0;
687 720
688 721 ret = LFR_DEFAULT;
689 722
690 723 for (i=0; i<7; i++) // send waveform
691 724 {
692 725 int coarseTime = 0x00;
693 726 int fineTime = 0x00;
694 727 #ifdef VHDL_DEV
695 728 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
696 729 #else
697 730 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
698 731 #endif
699 732 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
700 733 // BUILD THE DATA
701 734 if (i==6) {
702 735 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
703 736 }
704 737 else {
705 738 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
706 739 }
707 740 // SET PACKET SEQUENCE COUNTER
708 741 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
709 742 // SET PACKET TIME
710 743 coarseTime = time_management_regs->coarse_time;
711 744 fineTime = time_management_regs->fine_time;
712 745 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
713 746 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
714 747 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
715 748 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
716 749 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
717 750 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
718 751 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
719 752 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
720 753 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
721 754 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
722 755 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
723 756 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
724 757 // SEND PACKET
725 if (sid == SID_NORM_CWF_F3)
758 if (sid == SID_NORM_CWF_LONG_F3)
726 759 {
727 760 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
728 761 if (status != RTEMS_SUCCESSFUL) {
729 762 printf("%d-%d, ERR %d\n", sid, i, (int) status);
730 763 ret = LFR_DEFAULT;
731 764 }
732 765 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
733 766 }
734 767 else
735 768 {
736 769 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
737 770 if (status != RTEMS_SUCCESSFUL) {
738 771 printf("%d-%d, ERR %d\n", sid, i, (int) status);
739 772 ret = LFR_DEFAULT;
740 773 }
741 774 }
742 775 }
743 776
744 777 return ret;
745 778 }
746 779
747 780 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
748 781 {
749 782 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
750 783 *
751 784 * @param waveform points to the buffer containing the data that will be send.
752 785 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
753 786 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
754 787 * contain information to setup the transmission of the data packets.
755 788 *
756 789 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
757 790 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
758 791 *
759 792 */
760 793
761 794 unsigned int i;
762 795 int ret;
763 796 rtems_status_code status;
764 797 spw_ioctl_pkt_send spw_ioctl_send_CWF;
765 798 char *sample;
766 799
767 800 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
768 801 spw_ioctl_send_CWF.options = 0;
769 802
770 803 ret = LFR_DEFAULT;
771 804
772 805 //**********************
773 806 // BUILD CWF3_light DATA
774 807 for ( i=0; i< 2048; i++)
775 808 {
809 #ifdef VHDL_DEV
810 sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
811 #else
776 812 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
813 #endif
777 814 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
778 815 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
779 816 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
780 817 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
781 818 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
782 819 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
783 820 }
784 821
785 822 //*********************
786 823 // SEND CWF3_light DATA
787 824
788 825 for (i=0; i<7; i++) // send waveform
789 826 {
790 827 int coarseTime = 0x00;
791 828 int fineTime = 0x00;
792 #ifdef VHDL_DEV
793 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET];
794 #else
829
795 830 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
796 #endif
797 831 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
798 832 // BUILD THE DATA
799 833 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
800 834 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
801 835 }
802 836 else {
803 837 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
804 838 }
805 839 // SET PACKET SEQUENCE COUNTER
806 840 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
807 841 // SET PACKET TIME
808 842 coarseTime = time_management_regs->coarse_time;
809 843 fineTime = time_management_regs->fine_time;
810 844 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
811 845 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
812 846 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
813 847 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
814 848 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
815 849 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
816 850 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
817 851 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
818 852 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
819 853 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
820 854 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
821 855 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
822 856 // SEND PACKET
823 857 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
824 858 if (status != RTEMS_SUCCESSFUL) {
825 859 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
826 860 ret = LFR_DEFAULT;
827 861 }
828 862 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
829 863 }
830 864
831 865 return ret;
832 866 }
833 867
834 868
835 869 //**************
836 870 // wfp registers
837 871 void set_wfp_data_shaping()
838 872 {
839 873 /** This function sets the data_shaping register of the waveform picker module.
840 874 *
841 875 * The value is read from one field of the parameter_dump_packet structure:\n
842 876 * bw_sp0_sp1_r0_r1
843 877 *
844 878 */
845 879
846 880 unsigned char data_shaping;
847 881
848 882 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
849 883 // waveform picker : [R1 R0 SP1 SP0 BW]
850 884
851 885 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
852 886
853 887 #ifdef GSA
854 888 #else
855 889 waveform_picker_regs->data_shaping =
856 890 ( (data_shaping & 0x10) >> 4 ) // BW
857 891 + ( (data_shaping & 0x08) >> 2 ) // SP0
858 892 + ( (data_shaping & 0x04) ) // SP1
859 893 + ( (data_shaping & 0x02) << 2 ) // R0
860 894 + ( (data_shaping & 0x01) << 4 ); // R1
861 895 #endif
862 896 }
863 897
864 898 char set_wfp_delta_snapshot()
865 899 {
866 900 /** This function sets the delta_snapshot register of the waveform picker module.
867 901 *
868 902 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
869 903 * - sy_lfr_n_swf_p[0]
870 904 * - sy_lfr_n_swf_p[1]
871 905 *
872 906 */
873 907
874 908 char ret;
875 909 unsigned int delta_snapshot;
876 910 unsigned int aux;
877 911
878 912 aux = 0;
879 913 ret = LFR_DEFAULT;
880 914
881 915 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
882 916 + parameter_dump_packet.sy_lfr_n_swf_p[1];
883 917
884 918 #ifdef GSA
885 919 #else
886 920 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
887 921 {
888 922 aux = MIN_DELTA_SNAPSHOT;
889 923 ret = LFR_DEFAULT;
890 924 }
891 925 else
892 926 {
893 927 aux = delta_snapshot ;
894 928 ret = LFR_SUCCESSFUL;
895 929 }
896 930 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
897 931 #endif
898 932
899 933 return ret;
900 934 }
901 935
902 936 #ifdef VHDL_DEV
903 937 void set_wfp_burst_enable_register( unsigned char mode )
904 938 {
905 939 /** This function sets the waveform picker burst_enable register depending on the mode.
906 940 *
907 941 * @param mode is the LFR mode to launch.
908 942 *
909 943 * The burst bits shall be before the enable bits.
910 944 *
911 945 */
912 946
913 947 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
914 948 // the burst bits shall be set first, before the enable bits
915 949 switch(mode) {
916 950 case(LFR_MODE_NORMAL):
917 951 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
918 952 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
919 953 break;
920 954 case(LFR_MODE_BURST):
921 955 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
922 956 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
923 957 break;
924 958 case(LFR_MODE_SBM1):
925 959 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
926 960 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
927 961 break;
928 962 case(LFR_MODE_SBM2):
929 963 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
930 964 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
931 965 break;
932 966 default:
933 967 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
934 968 break;
935 969 }
936 970 }
937 971 #else
938 972 void set_wfp_burst_enable_register( unsigned char mode )
939 973 {
940 974 /** This function sets the waveform picker burst_enable register depending on the mode.
941 975 *
942 976 * @param mode is the LFR mode to launch.
943 977 *
944 978 * The burst bits shall be before the enable bits.
945 979 *
946 980 */
947 981
948 982 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
949 983 // the burst bits shall be set first, before the enable bits
950 984 switch(mode) {
951 985 case(LFR_MODE_NORMAL):
952 986 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
953 987 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
954 988 break;
955 989 case(LFR_MODE_BURST):
956 990 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
957 991 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
958 992 break;
959 993 case(LFR_MODE_SBM1):
960 994 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
961 995 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
962 996 break;
963 997 case(LFR_MODE_SBM2):
964 998 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
965 999 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
966 1000 break;
967 1001 default:
968 1002 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
969 1003 break;
970 1004 }
971 1005 }
972 1006 #endif
973 1007
974 1008 void reset_wfp_burst_enable()
975 1009 {
976 1010 /** This function resets the waveform picker burst_enable register.
977 1011 *
978 1012 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
979 1013 *
980 1014 */
981 1015
982 1016 #ifdef VHDL_DEV
983 1017 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
984 1018 #else
985 1019 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
986 1020 #endif
987 1021 }
988 1022
989 1023 void reset_wfp_status()
990 1024 {
991 1025 /** This function resets the waveform picker status register.
992 1026 *
993 1027 * All status bits are set to 0 [new_err full_err full].
994 1028 *
995 1029 */
996 1030
997 1031 #ifdef GSA
998 1032 #else
999 1033 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1000 1034 #endif
1001 1035 }
1002 1036
1003 1037 #ifdef VHDL_DEV
1004 1038 void reset_waveform_picker_regs()
1005 1039 {
1006 1040 /** This function resets the waveform picker module registers.
1007 1041 *
1008 1042 * The registers affected by this function are located at the following offset addresses:
1009 1043 * - 0x00 data_shaping
1010 1044 * - 0x04 run_burst_enable
1011 1045 * - 0x08 addr_data_f0
1012 1046 * - 0x0C addr_data_f1
1013 1047 * - 0x10 addr_data_f2
1014 1048 * - 0x14 addr_data_f3
1015 1049 * - 0x18 status
1016 1050 * - 0x1C delta_snapshot
1017 1051 * - 0x20 delta_f0
1018 1052 * - 0x24 delta_f0_2
1019 1053 * - 0x28 delta_f1
1020 1054 * - 0x2c delta_f2
1021 1055 * - 0x30 nb_data_by_buffer
1022 1056 * - 0x34 nb_snapshot_param
1023 1057 * - 0x38 start_date
1024 1058 * - 0x3c nb_word_in_buffer
1025 1059 *
1026 1060 */
1027 1061 waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1028 1062 waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1029 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1063 //waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1064 waveform_picker_regs->addr_data_f0 = current_ring_node_f0->buffer_address; // 0x08
1030 1065 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1031 1066 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1032 1067 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1033 1068 waveform_picker_regs->status = 0x00; // 0x18
1034 1069 // waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776
1035 // waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1036 waveform_picker_regs->delta_snapshot = 0x2000; // 0x1c 32 * 256 = 8192
1070 waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1071 //waveform_picker_regs->delta_snapshot = 0x2000; // 0x1c 32 * 256 = 8192
1037 1072 waveform_picker_regs->delta_f0 = 0xbf5; // 0x20 *** 1013
1038 1073 waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 [7 bits]
1039 1074 waveform_picker_regs->delta_f1 = 0xbc0; // 0x28 *** 960
1040 1075 // waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 290 * 256 = 74240
1041 1076 waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 3072
1042 1077 waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1 => nb samples -1
1043 1078 waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048 => nb samples
1044 1079 waveform_picker_regs->start_date = 0x00; // 0x38
1045 1080 waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146
1046 1081 }
1047 1082 #else
1048 1083 void reset_waveform_picker_regs()
1049 1084 {
1050 1085 /** This function resets the waveform picker module registers.
1051 1086 *
1052 1087 * The registers affected by this function are located at the following offset addresses:
1053 1088 * - 0x00 data_shaping
1054 1089 * - 0x04 burst_enable
1055 1090 * - 0x08 addr_data_f0
1056 1091 * - 0x0C addr_data_f1
1057 1092 * - 0x10 addr_data_f2
1058 1093 * - 0x14 addr_data_f3
1059 1094 * - 0x18 status
1060 1095 * - 0x1C delta_snapshot
1061 1096 * - 0x20 delta_f2_f1
1062 1097 * - 0x24 delta_f2_f0
1063 1098 * - 0x28 nb_burst
1064 1099 * - 0x2C nb_snapshot
1065 1100 *
1066 1101 */
1067 1102
1068 1103 reset_wfp_burst_enable();
1069 1104 reset_wfp_status();
1070 1105 // set buffer addresses
1071 1106 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0);
1072 1107 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
1073 1108 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
1074 1109 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
1075 1110 // set other parameters
1076 1111 set_wfp_data_shaping();
1077 1112 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1078 1113 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1079 1114 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1080 1115 // waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1081 1116 // // 3 * 2048 / 16 = 384
1082 1117 // waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1083 1118 waveform_picker_regs->nb_burst_available = 0x1b9; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1084 1119 // 3 * 2352 / 16 = 441
1085 1120 waveform_picker_regs->nb_snapshot_param = 0x944; // max 3 octets, 2372 - 1
1086 1121 }
1087 1122 #endif
1088 1123
1089 1124 //*****************
1090 1125 // local parameters
1091 1126 void set_local_nb_interrupt_f0_MAX( void )
1092 1127 {
1093 1128 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1094 1129 *
1095 1130 * This parameter is used for the SM validation only.\n
1096 1131 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1097 1132 * module before launching a basic processing.
1098 1133 *
1099 1134 */
1100 1135
1101 1136 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1102 1137 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1103 1138 }
1104 1139
1105 1140 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1106 1141 {
1107 1142 unsigned short *sequence_cnt;
1108 1143 unsigned short segmentation_grouping_flag;
1109 1144 unsigned short new_packet_sequence_control;
1110 1145
1111 1146 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1112 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1147 || (sid ==SID_NORM_CWF_F3) || (sid==SID_NORM_CWF_LONG_F3) || (sid ==SID_BURST_CWF_F2) )
1113 1148 {
1114 1149 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1115 1150 }
1116 1151 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1117 1152 {
1118 1153 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1119 1154 }
1120 1155 else
1121 1156 {
1122 1157 sequence_cnt = NULL;
1123 1158 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1124 1159 }
1125 1160
1126 1161 if (sequence_cnt != NULL)
1127 1162 {
1128 1163 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1129 1164 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1130 1165
1131 1166 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1132 1167
1133 1168 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1134 1169 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1135 1170
1136 1171 // increment the sequence counter for the next packet
1137 1172 if ( *sequence_cnt < SEQ_CNT_MAX)
1138 1173 {
1139 1174 *sequence_cnt = *sequence_cnt + 1;
1140 1175 }
1141 1176 else
1142 1177 {
1143 1178 *sequence_cnt = 0;
1144 1179 }
1145 1180 }
1146 1181 }
General Comments 0
You need to be logged in to leave comments. Login now