##// END OF EJS Templates
fsw-0-16...
paul -
r47:186d868466e5 default
parent child
Show More
@@ -1,248 +1,248
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 24 15:59:05 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Oct 25 11:58:08 2013
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=16 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=16 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_processing.c \
49 49 ../src/fsw_misc.c \
50 50 ../src/fsw_init.c \
51 51 ../src/fsw_globals.c \
52 52 ../src/fsw_spacewire.c \
53 53 ../src/tc_load_dump_parameters.c \
54 54 ../src/tm_lfr_tc_exe.c \
55 55 ../src/tc_acceptance.c
56 56 OBJECTS = obj/wf_handler.o \
57 57 obj/tc_handler.o \
58 58 obj/fsw_processing.o \
59 59 obj/fsw_misc.o \
60 60 obj/fsw_init.o \
61 61 obj/fsw_globals.o \
62 62 obj/fsw_spacewire.o \
63 63 obj/tc_load_dump_parameters.o \
64 64 obj/tm_lfr_tc_exe.o \
65 65 obj/tc_acceptance.o
66 66 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
67 67 /usr/lib64/qt4/mkspecs/common/linux.conf \
68 68 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
69 69 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
70 70 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
71 71 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
72 72 /usr/lib64/qt4/mkspecs/qconfig.pri \
73 73 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
74 74 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
75 75 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
76 76 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
77 77 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
78 78 sparc.pri \
79 79 /usr/lib64/qt4/mkspecs/features/release.prf \
80 80 /usr/lib64/qt4/mkspecs/features/default_post.prf \
81 81 /usr/lib64/qt4/mkspecs/features/shared.prf \
82 82 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
83 83 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
84 84 /usr/lib64/qt4/mkspecs/features/resources.prf \
85 85 /usr/lib64/qt4/mkspecs/features/uic.prf \
86 86 /usr/lib64/qt4/mkspecs/features/yacc.prf \
87 87 /usr/lib64/qt4/mkspecs/features/lex.prf \
88 88 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
89 89 fsw-qt.pro
90 90 QMAKE_TARGET = fsw
91 91 DESTDIR = bin/
92 92 TARGET = bin/fsw
93 93
94 94 first: all
95 95 ####### Implicit rules
96 96
97 97 .SUFFIXES: .o .c .cpp .cc .cxx .C
98 98
99 99 .cpp.o:
100 100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101 101
102 102 .cc.o:
103 103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
104 104
105 105 .cxx.o:
106 106 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
107 107
108 108 .C.o:
109 109 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
110 110
111 111 .c.o:
112 112 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
113 113
114 114 ####### Build rules
115 115
116 116 all: Makefile $(TARGET)
117 117
118 118 $(TARGET): $(OBJECTS)
119 119 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
120 120 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
121 121
122 122 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
123 123 /usr/lib64/qt4/mkspecs/common/linux.conf \
124 124 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
125 125 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
126 126 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
127 127 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
128 128 /usr/lib64/qt4/mkspecs/qconfig.pri \
129 129 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
130 130 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
131 131 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
132 132 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
133 133 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
134 134 sparc.pri \
135 135 /usr/lib64/qt4/mkspecs/features/release.prf \
136 136 /usr/lib64/qt4/mkspecs/features/default_post.prf \
137 137 /usr/lib64/qt4/mkspecs/features/shared.prf \
138 138 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
139 139 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
140 140 /usr/lib64/qt4/mkspecs/features/resources.prf \
141 141 /usr/lib64/qt4/mkspecs/features/uic.prf \
142 142 /usr/lib64/qt4/mkspecs/features/yacc.prf \
143 143 /usr/lib64/qt4/mkspecs/features/lex.prf \
144 144 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
145 145 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
146 146 /usr/lib64/qt4/mkspecs/common/unix.conf:
147 147 /usr/lib64/qt4/mkspecs/common/linux.conf:
148 148 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
149 149 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
150 150 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
151 151 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
152 152 /usr/lib64/qt4/mkspecs/qconfig.pri:
153 153 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
154 154 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
155 155 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
156 156 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
157 157 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
158 158 sparc.pri:
159 159 /usr/lib64/qt4/mkspecs/features/release.prf:
160 160 /usr/lib64/qt4/mkspecs/features/default_post.prf:
161 161 /usr/lib64/qt4/mkspecs/features/shared.prf:
162 162 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
163 163 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
164 164 /usr/lib64/qt4/mkspecs/features/resources.prf:
165 165 /usr/lib64/qt4/mkspecs/features/uic.prf:
166 166 /usr/lib64/qt4/mkspecs/features/yacc.prf:
167 167 /usr/lib64/qt4/mkspecs/features/lex.prf:
168 168 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
169 169 qmake: FORCE
170 170 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
171 171
172 172 dist:
173 173 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
174 174 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
175 175
176 176
177 177 clean:compiler_clean
178 178 -$(DEL_FILE) $(OBJECTS)
179 179 -$(DEL_FILE) *~ core *.core
180 180
181 181
182 182 ####### Sub-libraries
183 183
184 184 distclean: clean
185 185 -$(DEL_FILE) $(TARGET)
186 186 -$(DEL_FILE) Makefile
187 187
188 188
189 189 grmon:
190 190 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
191 191
192 192 check: first
193 193
194 194 compiler_rcc_make_all:
195 195 compiler_rcc_clean:
196 196 compiler_uic_make_all:
197 197 compiler_uic_clean:
198 198 compiler_image_collection_make_all: qmake_image_collection.cpp
199 199 compiler_image_collection_clean:
200 200 -$(DEL_FILE) qmake_image_collection.cpp
201 201 compiler_yacc_decl_make_all:
202 202 compiler_yacc_decl_clean:
203 203 compiler_yacc_impl_make_all:
204 204 compiler_yacc_impl_clean:
205 205 compiler_lex_make_all:
206 206 compiler_lex_clean:
207 207 compiler_clean:
208 208
209 209 ####### Compile
210 210
211 211 obj/wf_handler.o: ../src/wf_handler.c
212 212 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
213 213
214 214 obj/tc_handler.o: ../src/tc_handler.c
215 215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
216 216
217 217 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
218 218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
219 219
220 220 obj/fsw_misc.o: ../src/fsw_misc.c
221 221 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
222 222
223 223 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
224 224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
225 225
226 226 obj/fsw_globals.o: ../src/fsw_globals.c
227 227 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
228 228
229 229 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
230 230 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
231 231
232 232 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
233 233 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
234 234
235 235 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
236 236 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
237 237
238 238 obj/tc_acceptance.o: ../src/tc_acceptance.c
239 239 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
240 240
241 241 ####### Install
242 242
243 243 install: FORCE
244 244
245 245 uninstall: FORCE
246 246
247 247 FORCE:
248 248
1 NO CONTENT: modified file, binary diff hidden
@@ -1,74 +1,74
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
4 CONFIG += console verbose cpu_usage_report
4 CONFIG += console verbose
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-0-16
11 11 DEFINES += SW_VERSION_N1=0
12 12 DEFINES += SW_VERSION_N2=0
13 13 DEFINES += SW_VERSION_N3=0
14 14 DEFINES += SW_VERSION_N4=16
15 15
16 16 contains( CONFIG, verbose ) {
17 17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 18 }
19 19
20 20 contains( CONFIG, cpu_usage_report ) {
21 21 DEFINES += PRINT_TASK_STATISTICS
22 22 }
23 23
24 24 contains( CONFIG, stack_report ) {
25 25 DEFINES += PRINT_STACK_REPORT
26 26 }
27 27
28 28 contains( CONFIG, boot_messages ) {
29 29 DEFINES += BOOT_MESSAGES
30 30 }
31 31
32 32 #doxygen.target = doxygen
33 33 #doxygen.commands = doxygen ../doc/Doxyfile
34 34 #QMAKE_EXTRA_TARGETS += doxygen
35 35
36 36 TARGET = fsw
37 37 contains( CONFIG, gsa ) {
38 38 DEFINES += GSA
39 39 TARGET = fsw-gsa
40 40 }
41 41
42 42 INCLUDEPATH += \
43 43 ../src \
44 44 ../header
45 45
46 46 SOURCES += \
47 47 ../src/wf_handler.c \
48 48 ../src/tc_handler.c \
49 49 ../src/fsw_processing.c \
50 50 ../src/fsw_misc.c \
51 51 ../src/fsw_init.c \
52 52 ../src/fsw_globals.c \
53 53 ../src/fsw_spacewire.c \
54 54 ../src/tc_load_dump_parameters.c \
55 55 ../src/tm_lfr_tc_exe.c \
56 56 ../src/tc_acceptance.c
57 57
58 58
59 59 HEADERS += \
60 60 ../header/wf_handler.h \
61 61 ../header/tc_handler.h \
62 62 ../header/grlib_regs.h \
63 63 ../header/fsw_processing.h \
64 64 ../header/fsw_params.h \
65 65 ../header/fsw_misc.h \
66 66 ../header/fsw_init.h \
67 67 ../header/ccsds_types.h \
68 68 ../header/fsw_params_processing.h \
69 69 ../header/fsw_spacewire.h \
70 70 ../header/tm_byte_positions.h \
71 71 ../header/tc_load_dump_parameters.h \
72 72 ../header/tm_lfr_tc_exe.h \
73 73 ../header/tc_acceptance.h
74 74
@@ -1,305 +1,305
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.0, 2013-10-24T06:53:47. -->
3 <!-- Written by QtCreator 2.8.0, 2013-10-25T06:57:59. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QString" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">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 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
63 63 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
64 64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
67 67 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
69 69 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
70 70 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
71 71 </valuemap>
72 72 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
73 73 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
74 74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
77 77 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
78 78 <value type="QString">-w</value>
79 79 <value type="QString">-r</value>
80 80 </valuelist>
81 81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 84 </valuemap>
85 85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
86 86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
89 89 </valuemap>
90 90 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
92 92 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
93 93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
96 96 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
97 97 <value type="QString">-w</value>
98 98 <value type="QString">-r</value>
99 99 </valuelist>
100 100 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
101 101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
103 103 </valuemap>
104 104 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
105 105 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
108 108 </valuemap>
109 109 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
110 110 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
111 111 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
112 112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
115 115 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
116 116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 118 </valuemap>
119 119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
122 122 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
126 126 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
127 127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
128 128 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
129 129 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
130 130 </valuemap>
131 131 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
132 132 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
133 133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
134 134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
136 136 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
137 137 <value type="QString">-w</value>
138 138 <value type="QString">-r</value>
139 139 </valuelist>
140 140 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
141 141 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
142 142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
143 143 </valuemap>
144 144 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
145 145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
146 146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
147 147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
148 148 </valuemap>
149 149 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
150 150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
151 151 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
152 152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
153 153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
154 154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
155 155 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
156 156 <value type="QString">-w</value>
157 157 <value type="QString">-r</value>
158 158 </valuelist>
159 159 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
160 160 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
161 161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
162 162 </valuemap>
163 163 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
164 164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
165 165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
166 166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
167 167 </valuemap>
168 168 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
169 169 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
170 170 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
174 174 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
177 177 </valuemap>
178 178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
179 179 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180 180 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181 181 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182 182 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183 183 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184 184 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187 187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">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 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
195 195 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
196 196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
197 197 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
198 198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
199 199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
200 200 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
201 201 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
202 202 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
203 203 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
204 204 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205 205 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206 206 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
207 207 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
208 208 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
209 209 <value type="int">0</value>
210 210 <value type="int">1</value>
211 211 <value type="int">2</value>
212 212 <value type="int">3</value>
213 213 <value type="int">4</value>
214 214 <value type="int">5</value>
215 215 <value type="int">6</value>
216 216 <value type="int">7</value>
217 217 <value type="int">8</value>
218 218 <value type="int">9</value>
219 219 <value type="int">10</value>
220 220 <value type="int">11</value>
221 221 <value type="int">12</value>
222 222 <value type="int">13</value>
223 223 <value type="int">14</value>
224 224 </valuelist>
225 225 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
226 226 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
227 227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
228 228 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
229 229 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
230 230 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
231 231 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
232 232 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
233 233 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
234 234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
235 235 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
236 236 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
237 237 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
238 238 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
239 239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240 240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
241 241 </valuemap>
242 242 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
243 243 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
244 244 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
245 245 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
246 246 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
247 247 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
248 248 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
249 249 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
250 250 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
251 251 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
252 252 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
253 253 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
254 254 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
255 255 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
256 256 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
257 257 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
258 258 <value type="int">0</value>
259 259 <value type="int">1</value>
260 260 <value type="int">2</value>
261 261 <value type="int">3</value>
262 262 <value type="int">4</value>
263 263 <value type="int">5</value>
264 264 <value type="int">6</value>
265 265 <value type="int">7</value>
266 266 <value type="int">8</value>
267 267 <value type="int">9</value>
268 268 <value type="int">10</value>
269 269 <value type="int">11</value>
270 270 <value type="int">12</value>
271 271 <value type="int">13</value>
272 272 <value type="int">14</value>
273 273 </valuelist>
274 274 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
275 275 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
276 276 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
277 277 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value>
278 278 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value>
279 279 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value>
280 280 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value>
281 281 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
282 282 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
283 283 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
284 284 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
285 285 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
286 286 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
287 287 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
288 288 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
289 289 </valuemap>
290 290 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
291 291 </valuemap>
292 292 </data>
293 293 <data>
294 294 <variable>ProjectExplorer.Project.TargetCount</variable>
295 295 <value type="int">1</value>
296 296 </data>
297 297 <data>
298 298 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
299 299 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
300 300 </data>
301 301 <data>
302 302 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
303 303 <value type="int">14</value>
304 304 </data>
305 305 </qtcreator>
@@ -1,233 +1,233
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 //**********
17 17 // LFR MODES
18 18 #define LFR_MODE_STANDBY 0
19 19 #define LFR_MODE_NORMAL 1
20 20 #define LFR_MODE_BURST 2
21 21 #define LFR_MODE_SBM1 3
22 22 #define LFR_MODE_SBM2 4
23 23 #define LFR_MODE_NORMAL_CWF_F3 5
24 24
25 25 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
26 26 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
27 27 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
28 28 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
29 29 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
30 30 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
31 31
32 32 //****************************
33 33 // LFR DEFAULT MODE PARAMETERS
34 34 // COMMON
35 35 #define DEFAULT_SY_LFR_COMMON0 0x00
36 36 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
37 37 // NORM
38 38 #define SY_LFR_N_SWF_L 2048 // nb sample
39 39 #define SY_LFR_N_SWF_P 300 // sec
40 40 #define SY_LFR_N_ASM_P 3600 // sec
41 41 #define SY_LFR_N_BP_P0 4 // sec
42 42 #define SY_LFR_N_BP_P1 20 // sec
43 43 #define MIN_DELTA_SNAPSHOT 16 // sec
44 44 // BURST
45 45 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
46 46 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
47 47 // SBM1
48 48 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
49 49 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
50 50 // SBM2
51 51 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
52 52 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
53 53 // ADDITIONAL PARAMETERS
54 54 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
55 55 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
56 56 // STATUS WORD
57 57 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
58 58 #define DEFAULT_STATUS_WORD_BYTE1 0x00
59 59 //
60 60 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
61 61 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
62 62 //****************************
63 63
64 64 //*****************************
65 65 // APB REGISTERS BASE ADDRESSES
66 66 #define REGS_ADDR_APBUART 0x80000100
67 67 #define REGS_ADDR_GPTIMER 0x80000300
68 68 #define REGS_ADDR_GRSPW 0x80000500
69 69 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
70 70 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
71 71
72 72 #ifdef GSA
73 73 #else
74 74 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
75 75 #endif
76 76
77 77 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
78 78 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
79 79
80 80 //**********
81 81 // IRQ LINES
82 82 #define IRQ_SM 9
83 83 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
84 84 #define IRQ_WF 10
85 85 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
86 86 #define IRQ_TIME1 12
87 87 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
88 88 #define IRQ_TIME2 13
89 89 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
90 90 #define IRQ_WAVEFORM_PICKER 14
91 91 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
92 92 #define IRQ_SPECTRAL_MATRIX 6
93 93 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
94 94
95 95 //*****
96 96 // TIME
97 97 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
98 98 #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s
99 99 #define TIMER_SM_SIMULATOR 1
100 100 #define TIMER_WF_SIMULATOR 2
101 101 #define HK_PERIOD 100 // 100 * 10ms => 1sec
102 102
103 103 //**********
104 104 // LPP CODES
105 105 #define LFR_SUCCESSFUL 0
106 106 #define LFR_DEFAULT 1
107 107
108 108 //******
109 109 // RTEMS
110 110 #define TASKID_RECV 1
111 111 #define TASKID_ACTN 2
112 112 #define TASKID_SPIQ 3
113 113 #define TASKID_SMIQ 4
114 114 #define TASKID_STAT 5
115 115 #define TASKID_AVF0 6
116 116 #define TASKID_BPF0 7
117 117 #define TASKID_WFRM 8
118 118 #define TASKID_DUMB 9
119 119 #define TASKID_HOUS 10
120 120 #define TASKID_MATR 11
121 121 #define TASKID_CWF3 12
122 122 #define TASKID_CWF2 13
123 123 #define TASKID_CWF1 14
124 124 #define TASKID_SEND 15
125 125 #define TASKID_WTDG 16
126 126
127 127 #define TASK_PRIORITY_SPIQ 5
128 128 #define TASK_PRIORITY_SMIQ 10
129 129 //
130 130 #define TASK_PRIORITY_WTDG 20
131 131 //
132 #define TASK_PRIORITY_RECV 30
132 133 #define TASK_PRIORITY_ACTN 30
133 134 //
134 135 #define TASK_PRIORITY_HOUS 40
135 136 #define TASK_PRIORITY_CWF1 40
136 137 #define TASK_PRIORITY_CWF2 40
137 138 #define TASK_PRIORITY_WFRM 40
138 139 #define TASK_PRIORITY_CWF3 40
140 //
139 141 #define TASK_PRIORITY_SEND 40
140 142 //
141 #define TASK_PRIORITY_RECV 50 // this priority prevents the blocking of of other tasks in case of link deconnexion
142 //
143 143 #define TASK_PRIORITY_AVF0 60
144 144 #define TASK_PRIORITY_BPF0 60
145 145 #define TASK_PRIORITY_MATR 100
146 146 #define TASK_PRIORITY_STAT 200
147 147 #define TASK_PRIORITY_DUMB 200
148 148
149 149 #define ACTION_MSG_QUEUE_COUNT 10
150 150 #define ACTION_MSG_PKTS_COUNT 50
151 151 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
152 152 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
153 153
154 154 #define QUEUE_RECV 0
155 155 #define QUEUE_SEND 1
156 156
157 157 //*******
158 158 // MACROS
159 159 #ifdef PRINT_MESSAGES_ON_CONSOLE
160 160 #define PRINTF(x) printf(x);
161 161 #define PRINTF1(x,y) printf(x,y);
162 162 #define PRINTF2(x,y,z) printf(x,y,z);
163 163 #else
164 164 #define PRINTF(x) ;
165 165 #define PRINTF1(x,y) ;
166 166 #define PRINTF2(x,y,z) ;
167 167 #endif
168 168
169 169 #ifdef BOOT_MESSAGES
170 170 #define BOOT_PRINTF(x) printf(x);
171 171 #define BOOT_PRINTF1(x,y) printf(x,y);
172 172 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
173 173 #else
174 174 #define BOOT_PRINTF(x) ;
175 175 #define BOOT_PRINTF1(x,y) ;
176 176 #define BOOT_PRINTF2(x,y,z) ;
177 177 #endif
178 178
179 179 #ifdef DEBUG_MESSAGES
180 180 #define DEBUG_PRINTF(x) printf(x);
181 181 #define DEBUG_PRINTF1(x,y) printf(x,y);
182 182 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
183 183 #else
184 184 #define DEBUG_PRINTF(x) ;
185 185 #define DEBUG_PRINTF1(x,y) ;
186 186 #define DEBUG_PRINTF2(x,y,z) ;
187 187 #endif
188 188
189 189 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
190 190
191 191 #define NB_SAMPLES_PER_SNAPSHOT 2048
192 192 #define TIME_OFFSET 2
193 193 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
194 194 #define NB_BYTES_SWF_BLK (2 * 6)
195 195 #define NB_WORDS_SWF_BLK 3
196 196 #define NB_BYTES_CWF3_LIGHT_BLK 6
197 197 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
198 198
199 199 //******************
200 200 // SEQUENCE COUNTERS
201 201 #define SEQ_CNT_NB_PID 2
202 202 #define SEQ_CNT_NB_CAT 4
203 203 #define SEQ_CNT_NB_DEST_ID 11
204 204 // pid
205 205 #define SEQ_CNT_PID_76 0
206 206 #define SEQ_CNT_PID_79 1
207 207 //cat
208 208 #define SEQ_CNT_CAT_1 0
209 209 #define SEQ_CNT_CAT_4 1
210 210 #define SEQ_CNT_CAT_9 2
211 211 #define SEQ_CNT_CAT_12 3
212 212 // destination id
213 213 #define SEQ_CNT_DST_ID_GROUND 0
214 214 #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1
215 215 #define SEQ_CNT_DST_ID_TC_SEQUENCES 2
216 216 #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3
217 217 #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4
218 218 #define SEQ_CNT_DST_ID_DIRECT_CMD 5
219 219 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6
220 220 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7
221 221 #define SEQ_CNT_DST_ID_OBCP 8
222 222 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
223 223 #define SEQ_CNT_DST_ID_AOCS 10
224 224
225 225 struct param_local_str{
226 226 unsigned int local_sbm1_nb_cwf_sent;
227 227 unsigned int local_sbm1_nb_cwf_max;
228 228 unsigned int local_sbm2_nb_cwf_sent;
229 229 unsigned int local_sbm2_nb_cwf_max;
230 230 unsigned int local_nb_interrupt_f0_MAX;
231 231 };
232 232
233 233 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,40 +1,41
1 1 #ifndef FSW_SPACEWIRE_H_INCLUDED
2 2 #define FSW_SPACEWIRE_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6
7 7 #include <fcntl.h> // for O_RDWR
8 8 #include <unistd.h> // for the read call
9 9 #include <sys/ioctl.h> // for the ioctl call
10 10 #include <errno.h>
11 11
12 12 #include "fsw_params.h"
13 13 #include "tc_handler.h"
14 14
15 15 extern spw_stats spacewire_stats;
16 16 extern spw_stats spacewire_stats_backup;
17 17 extern Packet_TM_LFR_HK_t housekeeping_packet;
18 18 extern rtems_id Task_id[20]; /* array of task ids */
19 19
20 20 // RTEMS TASK
21 21 rtems_task spiq_task( rtems_task_argument argument );
22 22 rtems_task recv_task( rtems_task_argument unused );
23 23 rtems_task send_task( rtems_task_argument argument );
24 24 rtems_task wtdg_task( rtems_task_argument argument );
25 25
26 26 int spacewire_open_link( void );
27 27 int spacewire_start_link( int fd );
28 int spacewire_stop_start_link( int fd );
28 29 int spacewire_configure_link(int fd );
29 30 int spacewire_reset_link( void );
30 31 void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force
31 32 void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable
32 33 void spacewire_compute_stats_offsets( void );
33 34 void spacewire_update_statistics( void );
34 35
35 36 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc );
36 37 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data );
37 38
38 39 void (*grspw_timecode_callback) ( void *pDev, void *regs, int minor, unsigned int tc );
39 40
40 41 #endif // FSW_SPACEWIRE_H_INCLUDED
@@ -1,595 +1,596
1 1 /** This is the RTEMS initialization module.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * This module contains two very different information:
7 7 * - specific instructions to configure the compilation of the RTEMS executive
8 8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 9 *
10 10 */
11 11
12 12 //*************************
13 13 // GPL reminder to be added
14 14 //*************************
15 15
16 16 #include <rtems.h>
17 17
18 18 /* configuration information */
19 19
20 20 #define CONFIGURE_INIT
21 21
22 22 #include <bsp.h> /* for device driver prototypes */
23 23
24 24 /* configuration information */
25 25
26 26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28 28
29 29 #define CONFIGURE_MAXIMUM_TASKS 20
30 30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
39 39 #ifdef PRINT_STACK_REPORT
40 40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 41 #endif
42 42
43 43 #include <rtems/confdefs.h>
44 44
45 45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 46 #ifdef RTEMS_DRVMGR_STARTUP
47 47 #ifdef LEON3
48 48 /* Add Timer and UART Driver */
49 49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 51 #endif
52 52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 54 #endif
55 55 #endif
56 56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 57 #include <drvmgr/drvmgr_confdefs.h>
58 58 #endif
59 59
60 60 #include "fsw_init.h"
61 61 #include "fsw_config.c"
62 62
63 63 rtems_task Init( rtems_task_argument ignored )
64 64 {
65 65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 66 *
67 67 * @param unused is the starting argument of the RTEMS task
68 68 *
69 69 * The INIT task create and run all other RTEMS tasks.
70 70 *
71 71 */
72 72
73 73
74 74 rtems_status_code status;
75 75 rtems_status_code status_spw;
76 76 rtems_isr_entry old_isr_handler;
77 77
78 78 BOOT_PRINTF("\n\n\n\n\n")
79 79 BOOT_PRINTF("***************************\n")
80 80 BOOT_PRINTF("** START Flight Software **\n")
81 81 BOOT_PRINTF("***************************\n")
82 82 BOOT_PRINTF("\n\n")
83 83
84 84 //send_console_outputs_on_apbuart_port();
85 85 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
86 86
87 87 init_parameter_dump();
88 88 init_local_mode_parameters();
89 89 init_housekeeping_parameters();
90 90
91 updateLFRCurrentMode();
92
93 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
94
91 95 create_names(); // create all names
96
92 97 status = create_message_queues(); // create message queues
93 98 if (status != RTEMS_SUCCESSFUL)
94 99 {
95 100 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
96 101 }
97 102
98 103 status = create_all_tasks(); // create all tasks
99 104 if (status != RTEMS_SUCCESSFUL)
100 105 {
101 106 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
102 107 }
103 108
104 109 // **************************
105 110 // <SPACEWIRE INITIALIZATION>
106 111 grspw_timecode_callback = &timecode_irq_handler;
107 112
108 113 status_spw = spacewire_open_link(); // (1) open the link
109 114 if ( status_spw != RTEMS_SUCCESSFUL )
110 115 {
111 116 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
112 117 }
113 118
114 119 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
115 120 {
116 121 status_spw = spacewire_configure_link( fdSPW );
117 122 if ( status_spw != RTEMS_SUCCESSFUL )
118 123 {
119 124 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
120 125 }
121 126 }
122 127
123 128 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
124 129 {
125 130 status_spw = spacewire_start_link( fdSPW );
126 131 if ( status_spw != RTEMS_SUCCESSFUL )
127 132 {
128 133 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
129 134 }
130 135 }
131 136 // </SPACEWIRE INITIALIZATION>
132 137 // ***************************
133 138
134 139 status = start_all_tasks(); // start all tasks
135 140 if (status != RTEMS_SUCCESSFUL)
136 141 {
137 142 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
138 143 }
139 144
145 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
140 146 status = start_recv_send_tasks();
141 147 if ( status != RTEMS_SUCCESSFUL )
142 148 {
143 149 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
144 150 }
145 151
146 status = stop_current_mode(); // go in STANDBY mode
152 // suspend science tasks. they will be restarted later depending on the mode
153 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
154 if (status != RTEMS_SUCCESSFUL)
155 {
156 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
157 }
158
159 status = stop_current_mode(); // go in STANDBY mode
147 160 if (status != RTEMS_SUCCESSFUL)
148 161 {
149 162 PRINTF1("in INIT *** ERR in stop_current_mode, code %d", status)
150 163 }
151 164
152 165 #ifdef GSA
153 166 // mask IRQ lines
154 167 LEON_Mask_interrupt( IRQ_SM );
155 168 LEON_Mask_interrupt( IRQ_WF );
156 169 // Spectral Matrices simulator
157 170 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
158 171 IRQ_SPARC_SM, spectral_matrices_isr );
159 172 // WaveForms
160 173 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
161 174 IRQ_SPARC_WF, waveforms_simulator_isr );
162 175 #else
163 // mask IRQ lines
164 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
165 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX );
166 // reset configuration registers
167 reset_waveform_picker_regs();
168 reset_spectral_matrix_regs();
169 176 // configure IRQ handling for the waveform picker unit
170 177 status = rtems_interrupt_catch( waveforms_isr,
171 178 IRQ_SPARC_WAVEFORM_PICKER,
172 179 &old_isr_handler) ;
173 // configure IRQ handling for the spectral matrix unit
174 // status = rtems_interrupt_catch( spectral_matrices_isr,
175 // IRQ_SPARC_SPECTRAL_MATRIX,
176 // &old_isr_handler) ;
177 // Spectral Matrices simulator
178 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
179 IRQ_SPARC_SM, spectral_matrices_isr_simu );
180 180 #endif
181 181
182 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
182 183 if ( status_spw != RTEMS_SUCCESSFUL )
183 184 {
184 185 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
185 186 if ( status != RTEMS_SUCCESSFUL ) {
186 187 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
187 188 }
188 189 }
189 190
190 191 BOOT_PRINTF("delete INIT\n")
191 192
192 193 status = rtems_task_delete(RTEMS_SELF);
193 194
194 195 }
195 196
196 197 void init_local_mode_parameters( void )
197 198 {
198 199 /** This function initialize the param_local global variable with default values.
199 200 *
200 201 */
201 202
202 203 unsigned int i;
203 204 unsigned int j;
204 205 unsigned int k;
205 206
206 207 // LOCAL PARAMETERS
207 208 set_local_sbm1_nb_cwf_max();
208 209 set_local_sbm2_nb_cwf_max();
209 210 set_local_nb_interrupt_f0_MAX();
210 211
211 212 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
212 213 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
213 214 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
214 215
215 216 reset_local_sbm1_nb_cwf_sent();
216 217 reset_local_sbm2_nb_cwf_sent();
217 218
218 219 // init sequence counters
219 220 for (i = 0; i<SEQ_CNT_NB_PID; i++)
220 221 {
221 222 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
222 223 {
223 224 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
224 225 {
225 226 sequenceCounters[i][j][k] = 0x00;
226 227 }
227 228 }
228 229 }
229 230 }
230 231
231 232 void create_names( void ) // create all names for tasks and queues
232 233 {
233 234 /** This function creates all RTEMS names used in the software for tasks and queues.
234 235 *
235 236 * @return RTEMS directive status codes:
236 237 * - RTEMS_SUCCESSFUL - successful completion
237 238 *
238 239 */
239 240
240 241 // task names
241 242 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
242 243 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
243 244 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
244 245 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
245 246 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
246 247 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
247 248 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
248 249 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
249 250 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
250 251 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
251 252 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
252 253 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
253 254 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
254 255 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
255 256 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
256 257 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
257 258
258 259 // rate monotonic period names
259 260 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
260 261
261 262 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
262 263 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
263 264 }
264 265
265 266 int create_all_tasks( void ) // create all tasks which run in the software
266 267 {
267 268 /** This function creates all RTEMS tasks used in the software.
268 269 *
269 270 * @return RTEMS directive status codes:
270 271 * - RTEMS_SUCCESSFUL - task created successfully
271 272 * - RTEMS_INVALID_ADDRESS - id is NULL
272 273 * - RTEMS_INVALID_NAME - invalid task name
273 274 * - RTEMS_INVALID_PRIORITY - invalid task priority
274 275 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
275 276 * - RTEMS_TOO_MANY - too many tasks created
276 277 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
277 278 * - RTEMS_TOO_MANY - too many global objects
278 279 *
279 280 */
280 281
281 282 rtems_status_code status;
282 283
283 284 // RECV
284 285 status = rtems_task_create(
285 286 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
286 287 RTEMS_DEFAULT_MODES,
287 288 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
288 289 );
289 290
290 291 if (status == RTEMS_SUCCESSFUL) // ACTN
291 292 {
292 293 status = rtems_task_create(
293 294 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
294 295 RTEMS_DEFAULT_MODES,
295 296 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
296 297 );
297 298 }
298 299 if (status == RTEMS_SUCCESSFUL) // SPIQ
299 300 {
300 301 status = rtems_task_create(
301 302 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
302 303 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
303 304 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
304 305 );
305 306 }
306 307 if (status == RTEMS_SUCCESSFUL) // SMIQ
307 308 {
308 309 status = rtems_task_create(
309 310 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
310 311 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
311 312 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
312 313 );
313 314 }
314 315 if (status == RTEMS_SUCCESSFUL) // STAT
315 316 {
316 317 status = rtems_task_create(
317 318 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
318 319 RTEMS_DEFAULT_MODES,
319 320 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
320 321 );
321 322 }
322 323 if (status == RTEMS_SUCCESSFUL) // AVF0
323 324 {
324 325 status = rtems_task_create(
325 326 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
326 327 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
327 328 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
328 329 );
329 330 }
330 331 if (status == RTEMS_SUCCESSFUL) // BPF0
331 332 {
332 333 status = rtems_task_create(
333 334 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
334 335 RTEMS_DEFAULT_MODES,
335 336 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
336 337 );
337 338 }
338 339 if (status == RTEMS_SUCCESSFUL) // WFRM
339 340 {
340 341 status = rtems_task_create(
341 342 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
342 343 RTEMS_DEFAULT_MODES,
343 344 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
344 345 );
345 346 }
346 347 if (status == RTEMS_SUCCESSFUL) // DUMB
347 348 {
348 349 status = rtems_task_create(
349 350 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
350 351 RTEMS_DEFAULT_MODES,
351 352 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
352 353 );
353 354 }
354 355 if (status == RTEMS_SUCCESSFUL) // HOUS
355 356 {
356 357 status = rtems_task_create(
357 358 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
358 359 RTEMS_DEFAULT_MODES,
359 360 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
360 361 );
361 362 }
362 363 if (status == RTEMS_SUCCESSFUL) // MATR
363 364 {
364 365 status = rtems_task_create(
365 366 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
366 367 RTEMS_DEFAULT_MODES,
367 368 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
368 369 );
369 370 }
370 371 if (status == RTEMS_SUCCESSFUL) // CWF3
371 372 {
372 373 status = rtems_task_create(
373 374 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
374 375 RTEMS_DEFAULT_MODES,
375 376 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
376 377 );
377 378 }
378 379 if (status == RTEMS_SUCCESSFUL) // CWF2
379 380 {
380 381 status = rtems_task_create(
381 382 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
382 383 RTEMS_DEFAULT_MODES,
383 384 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
384 385 );
385 386 }
386 387 if (status == RTEMS_SUCCESSFUL) // CWF1
387 388 {
388 389 status = rtems_task_create(
389 390 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
390 391 RTEMS_DEFAULT_MODES,
391 392 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
392 393 );
393 394 }
394 395 if (status == RTEMS_SUCCESSFUL) // SEND
395 396 {
396 397 status = rtems_task_create(
397 398 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
398 399 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
399 400 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
400 401 );
401 402 }
402 403 if (status == RTEMS_SUCCESSFUL) // WTDG
403 404 {
404 405 status = rtems_task_create(
405 406 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
406 407 RTEMS_DEFAULT_MODES,
407 408 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
408 409 );
409 410 }
410 411
411 412 return status;
412 413 }
413 414
414 415 int start_recv_send_tasks( void )
415 416 {
416 417 rtems_status_code status;
417 418
418 419 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
419 420 if (status!=RTEMS_SUCCESSFUL) {
420 421 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
421 422 }
422 423
423 424 if (status == RTEMS_SUCCESSFUL) // SEND
424 425 {
425 426 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
426 427 if (status!=RTEMS_SUCCESSFUL) {
427 428 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
428 429 }
429 430 }
430 431
431 432 return status;
432 433 }
433 434
434 435 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
435 436 {
436 437 /** This function starts all RTEMS tasks used in the software.
437 438 *
438 439 * @return RTEMS directive status codes:
439 440 * - RTEMS_SUCCESSFUL - ask started successfully
440 441 * - RTEMS_INVALID_ADDRESS - invalid task entry point
441 442 * - RTEMS_INVALID_ID - invalid task id
442 443 * - RTEMS_INCORRECT_STATE - task not in the dormant state
443 444 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
444 445 *
445 446 */
446 447 // starts all the tasks fot eh flight software
447 448
448 449 rtems_status_code status;
449 450
450 451 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
451 452 if (status!=RTEMS_SUCCESSFUL) {
452 453 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
453 454 }
454 455
455 456 if (status == RTEMS_SUCCESSFUL) // WTDG
456 457 {
457 458 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
458 459 if (status!=RTEMS_SUCCESSFUL) {
459 460 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
460 461 }
461 462 }
462 463
463 464 if (status == RTEMS_SUCCESSFUL) // SMIQ
464 465 {
465 466 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
466 467 if (status!=RTEMS_SUCCESSFUL) {
467 468 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
468 469 }
469 470 }
470 471
471 472 if (status == RTEMS_SUCCESSFUL) // ACTN
472 473 {
473 474 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
474 475 if (status!=RTEMS_SUCCESSFUL) {
475 476 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
476 477 }
477 478 }
478 479
479 480 if (status == RTEMS_SUCCESSFUL) // STAT
480 481 {
481 482 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
482 483 if (status!=RTEMS_SUCCESSFUL) {
483 484 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
484 485 }
485 486 }
486 487
487 488 if (status == RTEMS_SUCCESSFUL) // AVF0
488 489 {
489 490 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
490 491 if (status!=RTEMS_SUCCESSFUL) {
491 492 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
492 493 }
493 494 }
494 495
495 496 if (status == RTEMS_SUCCESSFUL) // BPF0
496 497 {
497 498 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
498 499 if (status!=RTEMS_SUCCESSFUL) {
499 500 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
500 501 }
501 502 }
502 503
503 504 if (status == RTEMS_SUCCESSFUL) // WFRM
504 505 {
505 506 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
506 507 if (status!=RTEMS_SUCCESSFUL) {
507 508 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
508 509 }
509 510 }
510 511
511 512 if (status == RTEMS_SUCCESSFUL) // DUMB
512 513 {
513 514 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
514 515 if (status!=RTEMS_SUCCESSFUL) {
515 516 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
516 517 }
517 518 }
518 519
519 520 if (status == RTEMS_SUCCESSFUL) // HOUS
520 521 {
521 522 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
522 523 if (status!=RTEMS_SUCCESSFUL) {
523 524 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
524 525 }
525 526 }
526 527
527 528 if (status == RTEMS_SUCCESSFUL) // MATR
528 529 {
529 530 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
530 531 if (status!=RTEMS_SUCCESSFUL) {
531 532 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
532 533 }
533 534 }
534 535
535 536 if (status == RTEMS_SUCCESSFUL) // CWF3
536 537 {
537 538 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
538 539 if (status!=RTEMS_SUCCESSFUL) {
539 540 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
540 541 }
541 542 }
542 543
543 544 if (status == RTEMS_SUCCESSFUL) // CWF2
544 545 {
545 546 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
546 547 if (status!=RTEMS_SUCCESSFUL) {
547 548 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
548 549 }
549 550 }
550 551
551 552 if (status == RTEMS_SUCCESSFUL) // CWF1
552 553 {
553 554 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
554 555 if (status!=RTEMS_SUCCESSFUL) {
555 556 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
556 557 }
557 558 }
558 559 return status;
559 560 }
560 561
561 562 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
562 563 {
563 564 rtems_status_code status_recv;
564 565 rtems_status_code status_send;
565 566 rtems_status_code ret;
566 567 rtems_id queue_id;
567 568
568 569 // create the queue for handling valid TCs
569 570 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
570 571 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
571 572 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
572 573 if ( status_recv != RTEMS_SUCCESSFUL ) {
573 574 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
574 575 }
575 576
576 577 // create the queue for handling TM packet sending
577 578 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
578 579 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
579 580 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
580 581 if ( status_send != RTEMS_SUCCESSFUL ) {
581 582 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
582 583 }
583 584
584 585 if ( status_recv != RTEMS_SUCCESSFUL )
585 586 {
586 587 ret = status_recv;
587 588 }
588 589 else
589 590 {
590 591 ret = status_send;
591 592 }
592 593
593 594 return ret;
594 595 }
595 596
@@ -1,580 +1,586
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 char *lstates[6] = {"Error-reset",
17 17 "Error-wait",
18 18 "Ready",
19 19 "Started",
20 20 "Connecting",
21 21 "Run"
22 22 };
23 23
24 24 //***********
25 25 // RTEMS TASK
26 26 rtems_task spiq_task(rtems_task_argument unused)
27 27 {
28 28 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
29 29 *
30 30 * @param unused is the starting argument of the RTEMS task
31 31 *
32 32 */
33 33
34 34 rtems_event_set event_out;
35 35 rtems_status_code status;
36 36 int linkStatus;
37 37
38 38 BOOT_PRINTF("in SPIQ *** \n")
39 39
40 40 while(true){
41 41 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
42 42
43 // CHECK THE LINK
43 // [0] SUSPEND RECV ADN SEND TASKS
44 rtems_task_suspend( Task_id[ TASKID_RECV ] );
45 rtems_task_suspend( Task_id[ TASKID_SEND ] );
46
47 // [1] CHECK THE LINK
44 48 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
45 49 if ( linkStatus != 5) {
46 rtems_task_suspend( Task_id[ TASKID_RECV ] );
47 rtems_task_suspend( Task_id[ TASKID_SEND ] );
48 50 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
49 51 rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
50 52 }
51 53
52 // RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
54 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
53 55 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
54 if ( linkStatus != 5 ) // not in run state, reset the link
56 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
55 57 {
56 58 spacewire_compute_stats_offsets();
57 59 status = spacewire_reset_link( );
58 60 }
59 else
60 { // in run state, restart the link
61 status = spacewire_start_link( fdSPW ); // restart the link
61 else // [2.b] in run state, start the link
62 {
63 status = spacewire_stop_start_link( fdSPW ); // start the link
62 64 if ( status != RTEMS_SUCCESSFUL)
63 65 {
64 66 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
65 67 }
66 68 }
67 69
68 if ( status == RTEMS_SUCCESSFUL ) // the link is in run state and has been started successfully
70 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
71 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
69 72 {
70 73 status = rtems_task_resume( Task_id[ TASKID_SEND ] );
71 74 if ( status != RTEMS_SUCCESSFUL ) {
72 75 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
73 76 }
74 77 status = rtems_task_resume( Task_id[ TASKID_RECV ] );
75 78 if ( status != RTEMS_SUCCESSFUL ) {
76 79 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
77 80 }
78 81 }
79 else // if the link is not up after SY_LFR_DPU_CONNECT_ATTEMPT tries, go in STANDBY mode
82 else // [3.b] the link is not in run state, go in STANDBY mode
80 83 {
81 84 status = enter_mode( LFR_MODE_STANDBY, NULL ); // enter the STANDBY mode
82 85 if ( status != RTEMS_SUCCESSFUL ) {
83 86 PRINTF1("in SPIQ *** ERR enter_mode *** code %d\n", status)
84 87 }
85 88 // wake the WTDG task
86 89 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
87 90 rtems_task_suspend( RTEMS_SELF );
88 91 }
89 92 }
90 93 }
91 94
92 95 rtems_task recv_task( rtems_task_argument unused )
93 96 {
94 97 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
95 98 *
96 99 * @param unused is the starting argument of the RTEMS task
97 100 *
98 101 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
99 102 * 1. It reads the incoming data.
100 103 * 2. Launches the acceptance procedure.
101 104 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
102 105 *
103 106 */
104 107
105 108 int len;
106 109 ccsdsTelecommandPacket_t currentTC;
107 110 unsigned char computed_CRC[ 2 ];
108 111 unsigned char currentTC_LEN_RCV[ 2 ];
109 112 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
110 113 unsigned int parserCode;
111 114 rtems_status_code status;
112 115 rtems_id queue_recv_id;
113 116 rtems_id queue_send_id;
114 117
115 118 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
116 119
117 120 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_recv_id );
118 121 if (status != RTEMS_SUCCESSFUL)
119 122 {
120 123 PRINTF1("in RECV *** ERR getting QUEUE_RECV id, %d\n", status)
121 124 }
122 125
123 126 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_send_id );
124 127 if (status != RTEMS_SUCCESSFUL)
125 128 {
126 129 PRINTF1("in RECV *** ERR getting QUEUE_SEND id, %d\n", status)
127 130 }
128 131
129 132 BOOT_PRINTF("in RECV *** \n")
130 133
131 134 while(1)
132 135 {
133 136 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
134 137 if (len == -1){ // error during the read call
135 138 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
136 139 }
137 140 else {
138 141 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
139 142 PRINTF("in RECV *** packet lenght too short\n")
140 143 }
141 144 else {
142 145 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
143 146 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
144 147 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
145 148 // CHECK THE TC
146 149 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
147 150 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PACKET) || (parserCode == INCOR_CHECKSUM)
148 151 | (parserCode == ILL_TYPE) || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) )
149 152 { // send TM_LFR_TC_EXE_CORRUPTED
150 153 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id, computed_CRC, currentTC_LEN_RCV );
151 154 }
152 155 else
153 156 { // send valid TC to the action launcher
154 157 status = rtems_message_queue_send( queue_recv_id, &currentTC,
155 158 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
156 159 }
157 160 }
158 161 }
159 162 }
160 163 }
161 164
162 165 rtems_task send_task( rtems_task_argument argument)
163 166 {
164 167 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
165 168 *
166 169 * @param unused is the starting argument of the RTEMS task
167 170 *
168 171 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
169 172 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
170 173 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
171 174 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
172 175 * data it contains.
173 176 *
174 177 */
175 178
176 179 rtems_status_code status; // RTEMS status code
177 180 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
178 181 spw_ioctl_pkt_send *spw_ioctl_send;
179 182 size_t size; // size of the incoming TC packet
180 183 u_int32_t count;
181 184 rtems_id queue_id;
182 185
183 186 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
184 187 if (status != RTEMS_SUCCESSFUL)
185 188 {
186 189 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
187 190 }
188 191
189 192 BOOT_PRINTF("in SEND *** \n")
190 193
191 194 while(1)
192 195 {
193 196 status = rtems_message_queue_receive( queue_id, incomingData, &size,
194 197 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
195 198
196 199 if (status!=RTEMS_SUCCESSFUL)
197 200 {
198 201 PRINTF1("in SEND *** (1) ERR = %d\n", status)
199 202 }
200 203 else
201 204 {
202 205 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
203 206 {
204 207 status = write( fdSPW, incomingData, size );
205 208 if (status == -1){
206 209 PRINTF2("in SEND *** (2.a) ERR = %d, size = %d\n", status, size)
207 210 }
208 211 }
209 212 else // the incoming message is a spw_ioctl_pkt_send structure
210 213 {
211 214 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
212 215 if (spw_ioctl_send->hlen == 0)
213 216 {
214 217 status = write( fdSPW, spw_ioctl_send->data, spw_ioctl_send->dlen );
215 218 if (status == -1){
216 219 PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen)
217 220 }
218 221 }
219 222 else
220 223 {
221 224 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
222 225 if (status == -1){
223 226 PRINTF2("in SEND *** (2.c) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen)
224 227 PRINTF1(" hlen = %d\n", spw_ioctl_send->hlen)
225 228 }
226 229 }
227 230 }
228 231 }
229 232
230 233 status = rtems_message_queue_get_number_pending( queue_id, &count );
231 234 if (status != RTEMS_SUCCESSFUL)
232 235 {
233 236 PRINTF1("in SEND *** (3) ERR = %d\n", status)
234 237 }
235 238 else
236 239 {
237 240 if (count > maxCount)
238 241 {
239 242 maxCount = count;
240 243 }
241 244 }
242 245 }
243 246 }
244 247
245 248 rtems_task wtdg_task( rtems_task_argument argument )
246 249 {
247 250 rtems_event_set event_out;
248 251 rtems_status_code status;
249 252 int linkStatus;
250 253
251 254 BOOT_PRINTF("in WTDG ***\n")
252 255
253 while(1){
256 while(1)
257 {
254 258 // wait for an RTEMS_EVENT
255 259 rtems_event_receive( RTEMS_EVENT_0,
256 260 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
257 261 PRINTF("in WTDG *** wait for the link\n")
258 262 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
259 263 while( linkStatus != 5) // wait for the link
260 264 {
261 265 rtems_task_wake_after( 10 );
262 266 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
263 267 }
264 268
265 // if START is not called, subsequent call to read and write will fail
266 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is in run state
267 if ( status == RTEMS_SUCCESSFUL )
269 status = spacewire_stop_start_link( fdSPW );
270
271 if (status != RTEMS_SUCCESSFUL)
268 272 {
269 PRINTF("in WTDG *** link started\n")
273 PRINTF1("in WTDG *** ERR link not started %d\n", status)
270 274 }
271 275 else
272 276 {
273 PRINTF1("in WTDG *** ERR start, code %d\n", status)
277 PRINTF("in WTDG *** OK link started\n")
274 278 }
275 279
280 // restart the SPIQ task
276 281 rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
277 282
278 rtems_task_resume( Task_id[TASKID_RECV] );
279
280 rtems_task_resume( Task_id[TASKID_SEND] );
283 // resume RECV and SEND
284 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
285 if ( status != RTEMS_SUCCESSFUL ) {
286 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
287 }
288 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
289 if ( status != RTEMS_SUCCESSFUL ) {
290 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
291 }
281 292 }
282 293 }
283 294
284 295 //****************
285 296 // OTHER FUNCTIONS
286 297 int spacewire_open_link( void )
287 298 {
288 299 /** This function opens the SpaceWire link.
289 300 *
290 301 * @return a valid file descriptor in case of success, -1 in case of a failure
291 302 *
292 303 */
293 304 rtems_status_code status;
294 305
295 close( fdSPW ); // close the device if it is already open
296 306 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
297 307 if ( fdSPW < 0 ) {
298 308 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
299 309 }
300 310 else
301 311 {
302 312 status = RTEMS_SUCCESSFUL;
303 313 }
304 314
305 315 return status;
306 316 }
307 317
308 318 int spacewire_start_link( int fd )
309 319 {
310 320 rtems_status_code status;
311 321
312 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is in run state
322 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
323 // -1 default hardcoded driver timeout
324
325 return status;
326 }
327
328 int spacewire_stop_start_link( int fd )
329 {
330 rtems_status_code status;
331
332 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
333 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
313 334 // -1 default hardcoded driver timeout
314 335
315 336 return status;
316 337 }
317 338
318 339 int spacewire_configure_link( int fd )
319 340 {
320 341 /** This function configures the SpaceWire link.
321 342 *
322 343 * @return GR-RTEMS-DRIVER directive status codes:
323 344 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
324 345 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
325 346 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
326 347 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
327 348 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
328 349 * - 5 EIO - Error when writing to grswp hardware registers.
329 350 * - 2 ENOENT - No such file or directory
330 351 */
331 352
332 353 rtems_status_code status;
333 354
334 355 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
335 356 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
336 357
337 358 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
338 359 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
339 360 //
340 361 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
341 362 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
342 363 //
343 364 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
344 365 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
345 366 //
346 367 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
347 368 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
348 369 //
349 370 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
350 371 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
351 372 //
352 373 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
353 374 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
354 375 //
355 376 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
356 377 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
357 378
358 379 return status;
359 380 }
360 381
361 382 int spacewire_reset_link( void )
362 383 {
363 384 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
364 385 *
365 386 * @return RTEMS directive status code:
366 387 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
367 388 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
368 389 *
369 390 */
370 391
371 392 rtems_status_code status_spw;
372 393 int i;
373 394
374 395 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
375 396 {
376 397 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
377 status_spw = spacewire_open_link(); // (1) open the link
378 if ( status_spw != RTEMS_SUCCESSFUL )
379 {
380 PRINTF1("in spacewire_reset_link *** ERR spacewire_open_link code %d\n", status_spw)
381 }
398
399 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
382 400
383 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
401 status_spw = spacewire_stop_start_link( fdSPW );
402 if ( status_spw != RTEMS_SUCCESSFUL )
384 403 {
385 status_spw = spacewire_configure_link( fdSPW );
386 if ( status_spw != RTEMS_SUCCESSFUL )
387 {
388 PRINTF1("in spacewire_reset_link *** ERR spacewire_configure_link code %d\n", status_spw)
389 }
390 }
391
392 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
393 {
394 status_spw = spacewire_start_link( fdSPW );
395 if ( status_spw != RTEMS_SUCCESSFUL )
396 {
397 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
398 }
404 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
399 405 }
400 406
401 407 if ( status_spw == RTEMS_SUCCESSFUL)
402 408 {
403 409 break;
404 410 }
405 411 }
406 412
407 413 return status_spw;
408 414 }
409 415
410 416 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
411 417 {
412 418 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
413 419 *
414 420 * @param val is the value, 0 or 1, used to set the value of the NP bit.
415 421 * @param regAddr is the address of the GRSPW control register.
416 422 *
417 423 * NP is the bit 20 of the GRSPW control register.
418 424 *
419 425 */
420 426
421 427 unsigned int *spwptr = (unsigned int*) regAddr;
422 428
423 429 if (val == 1) {
424 430 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
425 431 }
426 432 if (val== 0) {
427 433 *spwptr = *spwptr & 0xffdfffff;
428 434 }
429 435 }
430 436
431 437 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
432 438 {
433 439 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
434 440 *
435 441 * @param val is the value, 0 or 1, used to set the value of the RE bit.
436 442 * @param regAddr is the address of the GRSPW control register.
437 443 *
438 444 * RE is the bit 16 of the GRSPW control register.
439 445 *
440 446 */
441 447
442 448 unsigned int *spwptr = (unsigned int*) regAddr;
443 449
444 450 if (val == 1)
445 451 {
446 452 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
447 453 }
448 454 if (val== 0)
449 455 {
450 456 *spwptr = *spwptr & 0xfffdffff;
451 457 }
452 458 }
453 459
454 460 void spacewire_compute_stats_offsets( void )
455 461 {
456 462 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
457 463 *
458 464 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
459 465 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
460 466 * during the open systel call).
461 467 *
462 468 */
463 469
464 470 spw_stats spacewire_stats_grspw;
465 471 rtems_status_code status;
466 472
467 473 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
468 474
469 475 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
470 476 + spacewire_stats.packets_received;
471 477 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
472 478 + spacewire_stats.packets_sent;
473 479 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
474 480 + spacewire_stats.parity_err;
475 481 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
476 482 + spacewire_stats.disconnect_err;
477 483 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
478 484 + spacewire_stats.escape_err;
479 485 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
480 486 + spacewire_stats.credit_err;
481 487 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
482 488 + spacewire_stats.write_sync_err;
483 489 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
484 490 + spacewire_stats.rx_rmap_header_crc_err;
485 491 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
486 492 + spacewire_stats.rx_rmap_data_crc_err;
487 493 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
488 494 + spacewire_stats.early_ep;
489 495 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
490 496 + spacewire_stats.invalid_address;
491 497 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
492 498 + spacewire_stats.rx_eep_err;
493 499 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
494 500 + spacewire_stats.rx_truncated;
495 501 }
496 502
497 503 void spacewire_update_statistics( void )
498 504 {
499 505 rtems_status_code status;
500 506 spw_stats spacewire_stats_grspw;
501 507
502 508 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
503 509
504 510 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
505 511 + spacewire_stats_grspw.packets_received;
506 512 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
507 513 + spacewire_stats_grspw.packets_sent;
508 514 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
509 515 + spacewire_stats_grspw.parity_err;
510 516 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
511 517 + spacewire_stats_grspw.disconnect_err;
512 518 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
513 519 + spacewire_stats_grspw.escape_err;
514 520 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
515 521 + spacewire_stats_grspw.credit_err;
516 522 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
517 523 + spacewire_stats_grspw.write_sync_err;
518 524 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
519 525 + spacewire_stats_grspw.rx_rmap_header_crc_err;
520 526 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
521 527 + spacewire_stats_grspw.rx_rmap_data_crc_err;
522 528 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
523 529 + spacewire_stats_grspw.early_ep;
524 530 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
525 531 + spacewire_stats_grspw.invalid_address;
526 532 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
527 533 + spacewire_stats_grspw.rx_eep_err;
528 534 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
529 535 + spacewire_stats_grspw.rx_truncated;
530 536 //spacewire_stats.tx_link_err;
531 537
532 538 //****************************
533 539 // DPU_SPACEWIRE_IF_STATISTICS
534 540 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
535 541 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
536 542 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
537 543 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
538 544 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
539 545 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
540 546
541 547 //******************************************
542 548 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
543 549 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
544 550 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
545 551 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
546 552 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
547 553 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
548 554 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
549 555 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
550 556 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
551 557 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
552 558
553 559 //*********************************************
554 560 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
555 561 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
556 562 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
557 563 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
558 564 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
559 565
560 566 }
561 567
562 568 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
563 569 {
564 570 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
565 571 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
566 572 //}
567 573 }
568 574
569 575 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
570 576 {
571 577 int linkStatus;
572 578 rtems_status_code status;
573 579
574 580 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
575 581
576 582 if ( linkStatus == 5) {
577 583 PRINTF("in spacewire_reset_link *** link is running\n")
578 584 status = RTEMS_SUCCESSFUL;
579 585 }
580 586 }
@@ -1,780 +1,770
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 rtems_id queue_rcv_id;
35 35 rtems_id queue_snd_id;
36 36
37 37 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id );
38 38 if (status != RTEMS_SUCCESSFUL)
39 39 {
40 40 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
41 41 }
42 42
43 43 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id );
44 44 if (status != RTEMS_SUCCESSFUL)
45 45 {
46 46 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
47 47 }
48 48
49 49 result = LFR_SUCCESSFUL;
50 50 subtype = 0; // subtype of the current TC packet
51 51
52 52 BOOT_PRINTF("in ACTN *** \n")
53 53
54 54 while(1)
55 55 {
56 56 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 57 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
58 58 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
59 59 else
60 60 {
61 61 subtype = TC.serviceSubType;
62 62 switch(subtype)
63 63 {
64 64 case TC_SUBTYPE_RESET:
65 65 result = action_reset( &TC, queue_snd_id );
66 66 close_action( &TC, result, queue_snd_id );
67 67 break;
68 68 //
69 69 case TC_SUBTYPE_LOAD_COMM:
70 70 result = action_load_common_par( &TC );
71 71 close_action( &TC, result, queue_snd_id );
72 72 break;
73 73 //
74 74 case TC_SUBTYPE_LOAD_NORM:
75 75 result = action_load_normal_par( &TC, queue_snd_id );
76 76 close_action( &TC, result, queue_snd_id );
77 77 break;
78 78 //
79 79 case TC_SUBTYPE_LOAD_BURST:
80 80 result = action_load_burst_par( &TC, queue_snd_id );
81 81 close_action( &TC, result, queue_snd_id );
82 82 break;
83 83 //
84 84 case TC_SUBTYPE_LOAD_SBM1:
85 85 result = action_load_sbm1_par( &TC, queue_snd_id );
86 86 close_action( &TC, result, queue_snd_id );
87 87 break;
88 88 //
89 89 case TC_SUBTYPE_LOAD_SBM2:
90 90 result = action_load_sbm2_par( &TC, queue_snd_id );
91 91 close_action( &TC, result, queue_snd_id );
92 92 break;
93 93 //
94 94 case TC_SUBTYPE_DUMP:
95 95 result = action_dump_par( queue_snd_id );
96 96 close_action( &TC, result, queue_snd_id );
97 97 break;
98 98 //
99 99 case TC_SUBTYPE_ENTER:
100 100 result = action_enter_mode( &TC, queue_snd_id );
101 101 close_action( &TC, result, queue_snd_id );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_UPDT_INFO:
105 105 result = action_update_info( &TC, queue_snd_id );
106 106 close_action( &TC, result, queue_snd_id );
107 107 break;
108 108 //
109 109 case TC_SUBTYPE_EN_CAL:
110 110 result = action_enable_calibration( &TC, queue_snd_id );
111 111 close_action( &TC, result, queue_snd_id );
112 112 break;
113 113 //
114 114 case TC_SUBTYPE_DIS_CAL:
115 115 result = action_disable_calibration( &TC, queue_snd_id );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 //
119 119 case TC_SUBTYPE_UPDT_TIME:
120 120 result = action_update_time( &TC );
121 121 close_action( &TC, result, queue_snd_id );
122 122 break;
123 123 //
124 124 default:
125 125 break;
126 126 }
127 127 }
128 128 }
129 129 }
130 130
131 131 //***********
132 132 // TC ACTIONS
133 133
134 134 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
135 135 {
136 136 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
137 137 *
138 138 * @param TC points to the TeleCommand packet that is being processed
139 139 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
140 140 *
141 141 */
142 142
143 143 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
144 144 return LFR_DEFAULT;
145 145 }
146 146
147 147 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
148 148 {
149 149 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
150 150 *
151 151 * @param TC points to the TeleCommand packet that is being processed
152 152 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
153 153 *
154 154 */
155 155
156 156 rtems_status_code status;
157 157 unsigned char requestedMode;
158 158
159 159 requestedMode = TC->dataAndCRC[1];
160 160
161 161 if ( (requestedMode != LFR_MODE_STANDBY)
162 162 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
163 163 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
164 164 {
165 165 status = RTEMS_UNSATISFIED;
166 166 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
167 167 }
168 168 else
169 169 {
170 170 printf("try to enter mode %d\n", requestedMode);
171 171
172 172 #ifdef PRINT_TASK_STATISTICS
173 173 if (requestedMode != LFR_MODE_STANDBY)
174 174 {
175 175 rtems_cpu_usage_reset();
176 176 maxCount = 0;
177 177 }
178 178 #endif
179 179
180 180 status = transition_validation(requestedMode);
181 181
182 182 if ( status == LFR_SUCCESSFUL ) {
183 183 if ( lfrCurrentMode != LFR_MODE_STANDBY)
184 184 {
185 185 status = stop_current_mode();
186 186 }
187 187 if (status != RTEMS_SUCCESSFUL)
188 188 {
189 189 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
190 190 }
191 191 status = enter_mode(requestedMode, TC);
192 192 }
193 193 else
194 194 {
195 195 PRINTF("ERR *** in action_enter *** transition rejected\n")
196 196 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
197 197 }
198 198 }
199 199
200 200 return status;
201 201 }
202 202
203 203 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
204 204 {
205 205 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
206 206 *
207 207 * @param TC points to the TeleCommand packet that is being processed
208 208 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
209 209 *
210 210 * @return LFR directive status code:
211 211 * - LFR_DEFAULT
212 212 * - LFR_SUCCESSFUL
213 213 *
214 214 */
215 215
216 216 unsigned int val;
217 217 int result;
218 218
219 219 result = LFR_DEFAULT;
220 220
221 221 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
222 222 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
223 223 val++;
224 224 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
225 225 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
226 226
227 227 return result;
228 228 }
229 229
230 230 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
231 231 {
232 232 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
233 233 *
234 234 * @param TC points to the TeleCommand packet that is being processed
235 235 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
236 236 *
237 237 */
238 238
239 239 int result;
240 240 unsigned char lfrMode;
241 241
242 242 result = LFR_DEFAULT;
243 243 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
244 244
245 245 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
246 246 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
247 247 result = LFR_DEFAULT;
248 248 }
249 249 else {
250 250 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
251 251 result = LFR_DEFAULT;
252 252 }
253 253 return result;
254 254 }
255 255
256 256 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
257 257 {
258 258 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
259 259 *
260 260 * @param TC points to the TeleCommand packet that is being processed
261 261 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
262 262 *
263 263 */
264 264
265 265 int result;
266 266 unsigned char lfrMode;
267 267
268 268 result = LFR_DEFAULT;
269 269 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
270 270
271 271 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
272 272 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
273 273 result = LFR_DEFAULT;
274 274 }
275 275 else {
276 276 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
277 277 result = LFR_DEFAULT;
278 278 }
279 279 return result;
280 280 }
281 281
282 282 int action_update_time(ccsdsTelecommandPacket_t *TC)
283 283 {
284 284 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
285 285 *
286 286 * @param TC points to the TeleCommand packet that is being processed
287 287 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
288 288 *
289 289 * @return LFR_SUCCESSFUL
290 290 *
291 291 */
292 292
293 293 unsigned int val;
294 294
295 295 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
296 296 + (TC->dataAndCRC[1] << 16)
297 297 + (TC->dataAndCRC[2] << 8)
298 298 + TC->dataAndCRC[3];
299 299 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
300 300 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
301 301 val++;
302 302 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
303 303 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
304 304 time_management_regs->ctrl = time_management_regs->ctrl | 1;
305 305
306 306 return LFR_SUCCESSFUL;
307 307 }
308 308
309 309 //*******************
310 310 // ENTERING THE MODES
311 311
312 312 int transition_validation(unsigned char requestedMode)
313 313 {
314 314 int status;
315 315
316 316 switch (requestedMode)
317 317 {
318 318 case LFR_MODE_STANDBY:
319 319 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
320 320 status = LFR_DEFAULT;
321 321 }
322 322 else
323 323 {
324 324 status = LFR_SUCCESSFUL;
325 325 }
326 326 break;
327 327 case LFR_MODE_NORMAL:
328 328 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
329 329 status = LFR_DEFAULT;
330 330 }
331 331 else {
332 332 status = LFR_SUCCESSFUL;
333 333 }
334 334 break;
335 335 case LFR_MODE_BURST:
336 336 if ( lfrCurrentMode == LFR_MODE_BURST ) {
337 337 status = LFR_DEFAULT;
338 338 }
339 339 else {
340 340 status = LFR_SUCCESSFUL;
341 341 }
342 342 break;
343 343 case LFR_MODE_SBM1:
344 344 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
345 345 status = LFR_DEFAULT;
346 346 }
347 347 else {
348 348 status = LFR_SUCCESSFUL;
349 349 }
350 350 break;
351 351 case LFR_MODE_SBM2:
352 352 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
353 353 status = LFR_DEFAULT;
354 354 }
355 355 else {
356 356 status = LFR_SUCCESSFUL;
357 357 }
358 358 break;
359 359 default:
360 360 status = LFR_DEFAULT;
361 361 break;
362 362 }
363 363
364 364 return status;
365 365 }
366 366
367 367 int stop_current_mode()
368 368 {
369 369 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
370 370 *
371 371 * @return RTEMS directive status codes:
372 372 * - RTEMS_SUCCESSFUL - task restarted successfully
373 373 * - RTEMS_INVALID_ID - task id invalid
374 374 * - RTEMS_ALREADY_SUSPENDED - task already suspended
375 375 *
376 376 */
377 377
378 378 rtems_status_code status;
379 379
380 380 status = RTEMS_SUCCESSFUL;
381 381
382 // mask all IRQ lines related to signal processing
383 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
384 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
385
386 382 #ifdef GSA
387 383 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
388 384 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
389 385 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
390 386 #else
387 // mask interruptions
391 388 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
392 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
393 389 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
394 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
395 LEON_Mask_interrupt( IRQ_SM ); // for SM simulation
396 LEON_Clear_interrupt( IRQ_SM ); // for SM simulation
390 // reset registers
391 reset_wfp_burst_enable(); // reset burst and enable bits
392 reset_wfp_status(); // reset all the status bits
393 // creal interruptions
394 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
395 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
397 396 #endif
398 397 //**********************
399 398 // suspend several tasks
400 399 if (lfrCurrentMode != LFR_MODE_STANDBY) {
401 400 status = suspend_science_tasks();
402 401 }
403 402
404 403 if (status != RTEMS_SUCCESSFUL)
405 404 {
406 405 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
407 406 }
408 407
409 //*************************
410 // initialize the registers
411 #ifdef GSA
412 #else
413 reset_wfp_burst_enable(); // reset burst and enable bits
414 reset_wfp_status(); // reset all the status bits
415 #endif
416
417 408 return status;
418 409 }
419 410
420 411 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
421 412 {
422 413 rtems_status_code status;
423 414
424 415 status = RTEMS_UNSATISFIED;
425 416
426 417 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
427 418 lfrCurrentMode = mode;
428 419
429 420 switch(mode){
430 421 case LFR_MODE_STANDBY:
431 422 status = enter_standby_mode( TC );
432 423 break;
433 424 case LFR_MODE_NORMAL:
434 425 status = enter_normal_mode( TC );
435 426 break;
436 427 case LFR_MODE_BURST:
437 428 status = enter_burst_mode( TC );
438 429 break;
439 430 case LFR_MODE_SBM1:
440 431 status = enter_sbm1_mode( TC );
441 432 break;
442 433 case LFR_MODE_SBM2:
443 434 status = enter_sbm2_mode( TC );
444 435 break;
445 436 default:
446 437 status = RTEMS_UNSATISFIED;
447 438 }
448 439
449 440 if (status != RTEMS_SUCCESSFUL)
450 441 {
451 442 PRINTF("in enter_mode *** ERR\n")
452 443 status = RTEMS_UNSATISFIED;
453 444 }
454 445
455 446 return status;
456 447 }
457 448
458 449 int enter_standby_mode()
459 450 {
460 451 reset_waveform_picker_regs();
461 452
462 453 PRINTF1("maxCount = %d\n", maxCount)
463 454
464 455 #ifdef PRINT_TASK_STATISTICS
465 456 rtems_cpu_usage_report();
466 457 #endif
467 458
468 459 #ifdef PRINT_STACK_REPORT
469 460 rtems_stack_checker_report_usage();
470 461 #endif
471 462
472 463 return LFR_SUCCESSFUL;
473 464 }
474 465
475 466 int enter_normal_mode()
476 467 {
477 468 rtems_status_code status;
478 469
479 470 status = restart_science_tasks();
480 471
481 472 #ifdef GSA
482 473 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
483 474 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
484 475 LEON_Clear_interrupt( IRQ_WF );
485 476 LEON_Unmask_interrupt( IRQ_WF );
486 477 //
487 478 set_local_nb_interrupt_f0_MAX();
488 479 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
489 480 LEON_Unmask_interrupt( IRQ_SM );
490 481 #else
491 482 //****************
492 483 // waveform picker
484 reset_waveform_picker_regs();
485 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
493 486 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
494 487 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
495 reset_waveform_picker_regs();
496 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
497 488 //****************
498 489 // spectral matrix
499 // set_local_nb_interrupt_f0_MAX();
500 // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
501 // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
502 // spectral_matrix_regs->config = 0x01;
503 // spectral_matrix_regs->status = 0x00;
504 490 #endif
505 491
506 492 return status;
507 493 }
508 494
509 495 int enter_burst_mode()
510 496 {
511 497 rtems_status_code status;
512 498
513 499 status = restart_science_tasks();
514 500
515 501 #ifdef GSA
516 502 LEON_Unmask_interrupt( IRQ_SM );
517 503 #else
504 reset_waveform_picker_regs();
505 set_wfp_burst_enable_register(LFR_MODE_BURST);
518 506 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
519 507 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
520 reset_waveform_picker_regs();
521 set_wfp_burst_enable_register(LFR_MODE_BURST);
522 508 #endif
523 509
524 510 return status;
525 511 }
526 512
527 513 int enter_sbm1_mode()
528 514 {
529 515 rtems_status_code status;
530 516
531 517 status = restart_science_tasks();
532 518
533 519 set_local_sbm1_nb_cwf_max();
534 520
535 521 reset_local_sbm1_nb_cwf_sent();
536 522
537 523 #ifdef GSA
538 524 LEON_Unmask_interrupt( IRQ_SM );
539 525 #else
526 reset_waveform_picker_regs();
527 set_wfp_burst_enable_register(LFR_MODE_SBM1);
540 528 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
541 529 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
542 reset_waveform_picker_regs();
543 set_wfp_burst_enable_register(LFR_MODE_SBM1);
544 530 // SM simulation
545 531 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
546 532 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
547 533 // LEON_Unmask_interrupt( IRQ_SM );
548 534 #endif
549 535
550 536 return status;
551 537 }
552 538
553 539 int enter_sbm2_mode()
554 540 {
555 541 rtems_status_code status;
556 542
557 543 status = restart_science_tasks();
558 544
559 545 set_local_sbm2_nb_cwf_max();
560 546
561 547 reset_local_sbm2_nb_cwf_sent();
562 548
563 549 #ifdef GSA
564 550 LEON_Unmask_interrupt( IRQ_SM );
565 551 #else
552 reset_waveform_picker_regs();
553 set_wfp_burst_enable_register(LFR_MODE_SBM2);
566 554 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
567 555 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
568 reset_waveform_picker_regs();
569 set_wfp_burst_enable_register(LFR_MODE_SBM2);
570 556 #endif
571 557
572 558 return status;
573 559 }
574 560
575 561 int restart_science_tasks()
576 562 {
577 563 rtems_status_code status[6];
578 564 rtems_status_code ret;
579 565
580 566 ret = RTEMS_SUCCESSFUL;
581 567
582 568 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
583 569 if (status[0] != RTEMS_SUCCESSFUL)
584 570 {
585 571 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
586 572 }
587 573
588 574 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
589 575 if (status[1] != RTEMS_SUCCESSFUL)
590 576 {
591 577 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
592 578 }
593 579
594 580 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
595 581 if (status[2] != RTEMS_SUCCESSFUL)
596 582 {
597 583 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
598 584 }
599 585
600 586 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
601 587 if (status[3] != RTEMS_SUCCESSFUL)
602 588 {
603 589 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
604 590 }
605 591
606 592 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
607 593 if (status[4] != RTEMS_SUCCESSFUL)
608 594 {
609 595 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
610 596 }
611 597
612 598 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
613 599 if (status[5] != RTEMS_SUCCESSFUL)
614 600 {
615 601 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
616 602 }
617 603
618 604 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
619 605 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
620 606 {
621 607 ret = RTEMS_UNSATISFIED;
622 608 }
623 609
624 610 return ret;
625 611 }
626 612
627 613 int suspend_science_tasks()
628 614 {
629 615 /** This function suspends the science tasks.
630 616 *
631 617 * @return RTEMS directive status codes:
632 618 * - RTEMS_SUCCESSFUL - task restarted successfully
633 619 * - RTEMS_INVALID_ID - task id invalid
634 620 * - RTEMS_ALREADY_SUSPENDED - task already suspended
635 621 *
636 622 */
637 623
638 624 rtems_status_code status;
639 625
640 626 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
641 627 if (status != RTEMS_SUCCESSFUL)
642 628 {
643 629 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
644 630 }
631
645 632 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
646 633 {
647 634 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
648 635 if (status != RTEMS_SUCCESSFUL)
649 636 {
650 637 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
651 638 }
652 639 }
640
653 641 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
654 642 {
655 643 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
656 644 if (status != RTEMS_SUCCESSFUL)
657 645 {
658 646 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
659 647 }
660 648 }
661 649
662 650 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
663 651 {
664 652 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
665 653 if (status != RTEMS_SUCCESSFUL)
666 654 {
667 655 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
668 656 }
669 657 }
658
670 659 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
671 660 {
672 661 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
673 662 if (status != RTEMS_SUCCESSFUL)
674 663 {
675 664 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
676 665 }
677 666 }
667
678 668 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
679 669 {
680 670 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
681 671 if (status != RTEMS_SUCCESSFUL)
682 672 {
683 673 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
684 674 }
685 675 }
686 676
687 677 return status;
688 678 }
689 679
690 680 //****************
691 681 // CLOSING ACTIONS
692 682 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
693 683 {
694 684 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
695 685 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
696 686 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
697 687 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
698 688 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
699 689 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
700 690 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
701 691 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
702 692 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
703 693 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
704 694 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
705 695 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
706 696 }
707 697
708 698 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
709 699 {
710 700 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
711 701 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
712 702 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
713 703 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
714 704 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
715 705 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
716 706 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
717 707 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
718 708 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
719 709 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
720 710 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
721 711 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
722 712 }
723 713
724 714 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id)
725 715 {
726 716 unsigned int val = 0;
727 717 if (result == LFR_SUCCESSFUL)
728 718 {
729 719 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
730 720 &&
731 721 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
732 722 )
733 723 {
734 724 send_tm_lfr_tc_exe_success( TC, queue_id );
735 725 }
736 726 update_last_TC_exe( TC );
737 727 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
738 728 val++;
739 729 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
740 730 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
741 731 }
742 732 else
743 733 {
744 734 update_last_TC_rej( TC );
745 735 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
746 736 val++;
747 737 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
748 738 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
749 739 }
750 740 }
751 741
752 742 //***************************
753 743 // Interrupt Service Routines
754 744 rtems_isr commutation_isr1( rtems_vector_number vector )
755 745 {
756 746 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
757 747 printf("In commutation_isr1 *** Error sending event to DUMB\n");
758 748 }
759 749 }
760 750
761 751 rtems_isr commutation_isr2( rtems_vector_number vector )
762 752 {
763 753 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
764 754 printf("In commutation_isr2 *** Error sending event to DUMB\n");
765 755 }
766 756 }
767 757
768 758 //****************
769 759 // OTHER FUNCTIONS
770 760 void updateLFRCurrentMode()
771 761 {
772 762 /** This function updates the value of the global variable lfrCurrentMode.
773 763 *
774 764 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
775 765 *
776 766 */
777 767 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
778 768 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
779 769 }
780 770
@@ -1,448 +1,448
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)
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
44 44 flag = LFR_SUCCESSFUL;
45 45 result = LFR_SUCCESSFUL;
46 46
47 47 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
48 48 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
49 49 flag = LFR_DEFAULT;
50 50 }
51 51
52 52 //***************
53 53 // sy_lfr_n_swf_l
54 54 if (flag == LFR_SUCCESSFUL)
55 55 {
56 56 result = set_sy_lfr_n_swf_l( TC, queue_id );
57 57 if (result != LFR_SUCCESSFUL)
58 58 {
59 59 flag = LFR_DEFAULT;
60 60 }
61 61 }
62 62
63 63 //***************
64 64 // sy_lfr_n_swf_p
65 65 if (flag == LFR_SUCCESSFUL)
66 66 {
67 67 result = set_sy_lfr_n_swf_p( TC, queue_id );
68 68 if (result != LFR_SUCCESSFUL)
69 69 {
70 70 flag = LFR_DEFAULT;
71 71 }
72 72 }
73 73
74 74 //***************
75 75 // SY_LFR_N_ASM_P
76 76 if (flag == LFR_SUCCESSFUL)
77 77 {
78 78 result = set_sy_lfr_n_asm_p( TC, queue_id );
79 79 if (result != LFR_SUCCESSFUL)
80 80 {
81 81 flag = LFR_DEFAULT;
82 82 }
83 83 }
84 84
85 85 //***************
86 86 // SY_LFR_N_BP_P0
87 87 if (flag == LFR_SUCCESSFUL)
88 88 {
89 89 result = set_sy_lfr_n_bp_p0( TC, queue_id );
90 90 if (result != LFR_SUCCESSFUL)
91 91 {
92 92 flag = LFR_DEFAULT;
93 93 }
94 94 }
95 95
96 96 //***************
97 97 // sy_lfr_n_bp_p1
98 98 if (flag == LFR_SUCCESSFUL)
99 99 {
100 100 result = set_sy_lfr_n_bp_p1( TC, queue_id );
101 101 if (result != LFR_SUCCESSFUL)
102 102 {
103 103 flag = LFR_DEFAULT;
104 104 }
105 105 }
106 106
107 107 return result;
108 108 }
109 109
110 110 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
111 111 {
112 112 /** This function updates the LFR registers with the incoming burst parameters.
113 113 *
114 114 * @param TC points to the TeleCommand packet that is being processed
115 115 * @param queue_id is the id of the queue which handles TM related to this execution step
116 116 *
117 117 */
118 118
119 119 int result;
120 120 unsigned char lfrMode;
121 121
122 122 result = LFR_DEFAULT;
123 123 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
124 124
125 125 if ( lfrMode == LFR_MODE_BURST ) {
126 126 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
127 127 result = LFR_DEFAULT;
128 128 }
129 129 else {
130 130 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
131 131 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
132 132
133 133 result = LFR_SUCCESSFUL;
134 134 }
135 135
136 136 return result;
137 137 }
138 138
139 139 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
140 140 {
141 141 /** This function updates the LFR registers with the incoming sbm1 parameters.
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 related to this execution step
145 145 *
146 146 */
147 147 int result;
148 148 unsigned char lfrMode;
149 149
150 150 result = LFR_DEFAULT;
151 151 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
152 152
153 153 if ( lfrMode == LFR_MODE_SBM1 ) {
154 154 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
155 155 result = LFR_DEFAULT;
156 156 }
157 157 else {
158 158 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
159 159 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
160 160
161 161 result = LFR_SUCCESSFUL;
162 162 }
163 163
164 164 return result;
165 165 }
166 166
167 167 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
168 168 {
169 169 /** This function updates the LFR registers with the incoming sbm2 parameters.
170 170 *
171 171 * @param TC points to the TeleCommand packet that is being processed
172 172 * @param queue_id is the id of the queue which handles TM related to this execution step
173 173 *
174 174 */
175 175
176 176 int result;
177 177 unsigned char lfrMode;
178 178
179 179 result = LFR_DEFAULT;
180 180 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
181 181
182 182 if ( lfrMode == LFR_MODE_SBM2 ) {
183 183 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
184 184 result = LFR_DEFAULT;
185 185 }
186 186 else {
187 187 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
188 188 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
189 189
190 190 result = LFR_SUCCESSFUL;
191 191 }
192 192
193 193 return result;
194 194 }
195 195
196 196 int action_dump_par( rtems_id queue_id )
197 197 {
198 198 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
199 199 *
200 200 * @param queue_id is the id of the queue which handles TM related to this execution step.
201 201 *
202 202 * @return RTEMS directive status codes:
203 203 * - RTEMS_SUCCESSFUL - message sent successfully
204 204 * - RTEMS_INVALID_ID - invalid queue id
205 205 * - RTEMS_INVALID_SIZE - invalid message size
206 206 * - RTEMS_INVALID_ADDRESS - buffer is NULL
207 207 * - RTEMS_UNSATISFIED - out of message buffers
208 208 * - RTEMS_TOO_MANY - queue s limit has been reached
209 209 *
210 210 */
211 211
212 212 int status;
213 213
214 214 // UPDATE TIME
215 215 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
216 216 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
217 217 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
218 218 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
219 219 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
220 220 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
221 221 // SEND DATA
222 222 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
223 223 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
224 224 if (status != RTEMS_SUCCESSFUL) {
225 225 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
226 226 }
227 227
228 228 return status;
229 229 }
230 230
231 231 //***********************
232 232 // NORMAL MODE PARAMETERS
233 233
234 234 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
235 235 {
236 236 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
237 237 *
238 238 * @param TC points to the TeleCommand packet that is being processed
239 239 * @param queue_id is the id of the queue which handles TM related to this execution step
240 240 *
241 241 */
242 242
243 243 unsigned int tmp;
244 244 int result;
245 245 unsigned char msb;
246 246 unsigned char lsb;
247 247
248 248 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
249 249 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
250 250
251 251 tmp = ( unsigned int ) floor(
252 252 ( ( msb*256 ) + lsb ) / 16
253 253 ) * 16;
254 254
255 255 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
256 { // 2048 is the maximum limit due to thesize of the buffers
256 { // 2048 is the maximum limit due to the size of the buffers
257 257 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
258 258 result = WRONG_APP_DATA;
259 259 }
260 260 else if (tmp != 2048)
261 261 {
262 262 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
263 263 result = FUNCT_NOT_IMPL;
264 264 }
265 265 else
266 266 {
267 267 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
268 268 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
269 269 result = LFR_SUCCESSFUL;
270 270 }
271 271
272 272 return result;
273 273 }
274 274
275 275 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
276 276 {
277 277 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
278 278 *
279 279 * @param TC points to the TeleCommand packet that is being processed
280 280 * @param queue_id is the id of the queue which handles TM related to this execution step
281 281 *
282 282 */
283 283
284 284 unsigned int tmp;
285 285 int result;
286 286 unsigned char msb;
287 287 unsigned char lsb;
288 288
289 289 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
290 290 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
291 291
292 292 tmp = ( unsigned int ) floor(
293 293 ( ( msb*256 ) + lsb ) / 8
294 294 ) * 8;
295 295
296 296 if ( (tmp < 16) || (tmp > 65528) )
297 297 {
298 298 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
299 299 result = WRONG_APP_DATA;
300 300 }
301 301 else
302 302 {
303 303 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
304 304 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
305 305 result = LFR_SUCCESSFUL;
306 306 }
307 307
308 308 return result;
309 309 }
310 310
311 311 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
312 312 {
313 313 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
314 314 *
315 315 * @param TC points to the TeleCommand packet that is being processed
316 316 * @param queue_id is the id of the queue which handles TM related to this execution step
317 317 *
318 318 */
319 319
320 320 int result;
321 321 unsigned char msb;
322 322 unsigned char lsb;
323 323
324 324 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
325 325 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
326 326
327 327 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
328 328 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
329 329 result = LFR_SUCCESSFUL;
330 330
331 331 return result;
332 332 }
333 333
334 334 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
335 335 {
336 336 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
337 337 *
338 338 * @param TC points to the TeleCommand packet that is being processed
339 339 * @param queue_id is the id of the queue which handles TM related to this execution step
340 340 *
341 341 */
342 342
343 343 int status;
344 344
345 345 status = LFR_SUCCESSFUL;
346 346
347 347 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
348 348
349 349 return status;
350 350 }
351 351
352 352 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
353 353 {
354 354 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
355 355 *
356 356 * @param TC points to the TeleCommand packet that is being processed
357 357 * @param queue_id is the id of the queue which handles TM related to this execution step
358 358 *
359 359 */
360 360
361 361 int status;
362 362
363 363 status = LFR_SUCCESSFUL;
364 364
365 365 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
366 366
367 367 return status;
368 368 }
369 369
370 370 //**********************
371 371 // BURST MODE PARAMETERS
372 372
373 373 //*********************
374 374 // SBM1 MODE PARAMETERS
375 375
376 376 //*********************
377 377 // SBM2 MODE PARAMETERS
378 378
379 379 //**********
380 380 // init dump
381 381
382 382 void init_parameter_dump( void )
383 383 {
384 384 /** This function initialize the parameter_dump_packet global variable with default values.
385 385 *
386 386 */
387 387
388 388 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
389 389 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
390 390 parameter_dump_packet.reserved = CCSDS_RESERVED;
391 391 parameter_dump_packet.userApplication = CCSDS_USER_APP;
392 392 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
393 393 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
394 394 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
395 395 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
396 396 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
397 397 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
398 398 // DATA FIELD HEADER
399 399 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
400 400 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
401 401 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
402 402 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
403 403 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
404 404 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
405 405 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
406 406 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
407 407 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
408 408 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
409 409 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
410 410
411 411 //******************
412 412 // COMMON PARAMETERS
413 413 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
414 414 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
415 415
416 416 //******************
417 417 // NORMAL PARAMETERS
418 418 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
419 419 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
420 420 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
421 421 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
422 422 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
423 423 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
424 424 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
425 425 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
426 426
427 427 //*****************
428 428 // BURST PARAMETERS
429 429 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
430 430 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
431 431
432 432 //****************
433 433 // SBM1 PARAMETERS
434 434 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
435 435 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
436 436
437 437 //****************
438 438 // SBM2 PARAMETERS
439 439 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
440 440 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
441 441 }
442 442
443 443
444 444
445 445
446 446
447 447
448 448
@@ -1,1166 +1,1167
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 // SWF
13 13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
14 14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
16 16 // CWF
17 17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
18 18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
22 22
23 23 unsigned char doubleSendCWF1 = 0;
24 24 unsigned char doubleSendCWF2 = 0;
25 25
26 26 rtems_isr waveforms_isr( rtems_vector_number vector )
27 27 {
28 28 /** This is the interrupt sub routine called by the waveform picker core.
29 29 *
30 30 * This ISR launch different actions depending mainly on two pieces of information:
31 31 * 1. the values read in the registers of the waveform picker.
32 32 * 2. the current LFR mode.
33 33 *
34 34 */
35 35
36 36 #ifdef GSA
37 37 #else
38 38 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
39 39 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
40 40 { // in modes other than STANDBY and BURST, send the CWF_F3 data
41 41 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
42 42 // (1) change the receiving buffer for the waveform picker
43 43 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
44 44 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
45 45 }
46 46 else {
47 47 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
48 48 }
49 49 // (2) send an event for the waveforms transmission
50 50 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
51 51 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
52 52 }
53 53 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
54 54 }
55 55 }
56 56 #endif
57 57
58 58 switch(lfrCurrentMode)
59 59 {
60 60 //********
61 61 // STANDBY
62 62 case(LFR_MODE_STANDBY):
63 63 break;
64 64
65 65 //******
66 66 // NORMAL
67 67 case(LFR_MODE_NORMAL):
68 68 #ifdef GSA
69 69 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
70 70 #else
71 71 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
72 72 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
73 73 }
74 74 else {
75 75 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
76 76 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
77 77 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
78 78 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
79 79 }
80 waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
80 // waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
81 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888;
81 82 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
82 83 }
83 84 }
84 85 #endif
85 86 break;
86 87
87 88 //******
88 89 // BURST
89 90 case(LFR_MODE_BURST):
90 91 #ifdef GSA
91 92 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
92 93 #else
93 94 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
94 95 // (1) change the receiving buffer for the waveform picker
95 96 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
96 97 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
97 98 }
98 99 else {
99 100 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
100 101 }
101 102 // (2) send an event for the waveforms transmission
102 103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
103 104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
104 105 }
105 106 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
106 107 }
107 108 #endif
108 109 break;
109 110
110 111 //*****
111 112 // SBM1
112 113 case(LFR_MODE_SBM1):
113 114 #ifdef GSA
114 115 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
115 116 #else
116 117 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
117 118 // (1) change the receiving buffer for the waveform picker
118 119 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
119 120 {
120 121 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
121 122 }
122 123 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
123 124 {
124 125 doubleSendCWF1 = 1;
125 126 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
126 127 }
127 128 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
128 129 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
129 130 }
130 131 else {
131 132 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
132 133 }
133 134 // (2) send an event for the waveforms transmission
134 135 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
135 136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
136 137 }
137 138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
138 139 }
139 140 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
140 141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
141 142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
142 143 }
143 144 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
144 145 reset_local_sbm1_nb_cwf_sent();
145 146 }
146 147
147 148 #endif
148 149 break;
149 150
150 151 //*****
151 152 // SBM2
152 153 case(LFR_MODE_SBM2):
153 154 #ifdef GSA
154 155 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
155 156 #else
156 157 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
157 158 // (1) change the receiving buffer for the waveform picker
158 159 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
159 160 {
160 161 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
161 162 }
162 163 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
163 164 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
164 165 doubleSendCWF2 = 1;
165 166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
166 167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
167 168 }
168 169 reset_local_sbm2_nb_cwf_sent();
169 170 }
170 171 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
171 172 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
172 173 }
173 174 else {
174 175 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
175 176 }
176 177 // (2) send an event for the waveforms transmission
177 178 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
178 179 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
179 180 }
180 181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
181 182 }
182 183 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
183 184 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
184 185 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
185 186 }
186 187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
187 188 }
188 189 #endif
189 190 break;
190 191
191 192 //********
192 193 // DEFAULT
193 194 default:
194 195 break;
195 196 }
196 197 }
197 198
198 199 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
199 200 {
200 201 /** This is the interrupt sub routine called by the waveform picker simulator.
201 202 *
202 203 * This ISR is for debug purpose only.
203 204 *
204 205 */
205 206
206 207 unsigned char lfrMode;
207 208 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
208 209
209 210 switch(lfrMode) {
210 211 case (LFR_MODE_STANDBY):
211 212 break;
212 213 case (LFR_MODE_NORMAL):
213 214 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
214 215 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
215 216 }
216 217 break;
217 218 case (LFR_MODE_BURST):
218 219 break;
219 220 case (LFR_MODE_SBM1):
220 221 break;
221 222 case (LFR_MODE_SBM2):
222 223 break;
223 224 }
224 225 }
225 226
226 227 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
227 228 {
228 229 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
229 230 *
230 231 * @param unused is the starting argument of the RTEMS task
231 232 *
232 233 * The following data packets are sent by this task:
233 234 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
234 235 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
235 236 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
236 237 *
237 238 */
238 239
239 240 rtems_event_set event_out;
240 241 rtems_id queue_id;
241 242
242 243 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
243 244 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
244 245 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
245 246
246 247 init_waveforms();
247 248
248 249 queue_id = get_pkts_queue_id();
249 250
250 251 BOOT_PRINTF("in WFRM ***\n")
251 252
252 253 while(1){
253 254 // wait for an RTEMS_EVENT
254 255 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
255 256 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
256 257 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
257 258
258 259 if (event_out == RTEMS_EVENT_MODE_NORMAL)
259 260 {
260 261 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
261 262 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
262 263 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
263 264 #ifdef GSA
264 265 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
265 266 #endif
266 267 }
267 268 else if (event_out == RTEMS_EVENT_MODE_SBM1)
268 269 {
269 270 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
270 271 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
271 272 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
272 273 #ifdef GSA
273 274 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
274 275 #endif
275 276 }
276 277 else if (event_out == RTEMS_EVENT_MODE_SBM2)
277 278 {
278 279 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
279 280 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
280 281 #ifdef GSA
281 282 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
282 283 #endif
283 284 }
284 285 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
285 286 {
286 287 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
287 288 }
288 289 else
289 290 {
290 291 PRINTF("in WFRM *** unexpected event")
291 292 }
292 293
293 294
294 295 #ifdef GSA
295 296 // irq processed, reset the related register of the timer unit
296 297 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
297 298 // clear the interruption
298 299 LEON_Unmask_interrupt( IRQ_WF );
299 300 #endif
300 301 }
301 302 }
302 303
303 304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
304 305 {
305 306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
306 307 *
307 308 * @param unused is the starting argument of the RTEMS task
308 309 *
309 310 * The following data packet is sent by this task:
310 311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
311 312 *
312 313 */
313 314
314 315 rtems_event_set event_out;
315 316 rtems_id queue_id;
316 317
317 318 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
318 319 init_header_continuous_wf3_light_table( headerCWF_F3_light );
319 320
320 321 queue_id = get_pkts_queue_id();
321 322
322 323 BOOT_PRINTF("in CWF3 ***\n")
323 324
324 325 while(1){
325 326 // wait for an RTEMS_EVENT
326 327 rtems_event_receive( RTEMS_EVENT_0,
327 328 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
328 329 PRINTF("send CWF F3 \n")
329 330 #ifdef GSA
330 331 #else
331 332 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
332 333 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
333 334 }
334 335 else {
335 336 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
336 337 }
337 338 #endif
338 339 }
339 340 }
340 341
341 342 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
342 343 {
343 344 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
344 345 *
345 346 * @param unused is the starting argument of the RTEMS task
346 347 *
347 348 * The following data packet is sent by this function:
348 349 * - TM_LFR_SCIENCE_BURST_CWF_F2
349 350 * - TM_LFR_SCIENCE_SBM2_CWF_F2
350 351 *
351 352 */
352 353
353 354 rtems_event_set event_out;
354 355 rtems_id queue_id;
355 356
356 357 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
357 358 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
358 359
359 360 queue_id = get_pkts_queue_id();
360 361
361 362 BOOT_PRINTF("in CWF2 ***\n")
362 363
363 364 while(1){
364 365 // wait for an RTEMS_EVENT
365 366 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
366 367 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
367 368
368 369 if (event_out == RTEMS_EVENT_MODE_BURST)
369 370 {
370 371 // F2
371 372 #ifdef GSA
372 373 #else
373 374 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
374 375 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
375 376 }
376 377 else {
377 378 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
378 379 }
379 380 #endif
380 381 }
381 382
382 383 else if (event_out == RTEMS_EVENT_MODE_SBM2)
383 384 {
384 385 #ifdef GSA
385 386 #else
386 387 if (doubleSendCWF2 == 1)
387 388 {
388 389 doubleSendCWF2 = 0;
389 390 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
390 391 }
391 392 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
392 393 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
393 394 }
394 395 else {
395 396 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
396 397 }
397 398 param_local.local_sbm2_nb_cwf_sent ++;
398 399 #endif
399 400 }
400 401 else
401 402 {
402 403 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
403 404 }
404 405 }
405 406 }
406 407
407 408 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
408 409 {
409 410 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
410 411 *
411 412 * @param unused is the starting argument of the RTEMS task
412 413 *
413 414 * The following data packet is sent by this function:
414 415 * - TM_LFR_SCIENCE_SBM1_CWF_F1
415 416 *
416 417 */
417 418
418 419 rtems_event_set event_out;
419 420 rtems_id queue_id;
420 421
421 422 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
422 423
423 424 queue_id = get_pkts_queue_id();
424 425
425 426 BOOT_PRINTF("in CWF1 ***\n")
426 427
427 428 while(1){
428 429 // wait for an RTEMS_EVENT
429 430 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
430 431 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
431 432 if (event_out == RTEMS_EVENT_MODE_SBM1)
432 433 {
433 434 #ifdef GSA
434 435 #else
435 436 if (doubleSendCWF1 == 1)
436 437 {
437 438 doubleSendCWF1 = 0;
438 439 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
439 440 }
440 441 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
441 442 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
442 443 }
443 444 else {
444 445 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
445 446 }
446 447 param_local.local_sbm1_nb_cwf_sent ++;
447 448 #endif
448 449 }
449 450 else
450 451 {
451 452 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
452 453 }
453 454 }
454 455 }
455 456
456 457 //******************
457 458 // general functions
458 459 void init_waveforms( void )
459 460 {
460 461 int i = 0;
461 462
462 463 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
463 464 {
464 465 //***
465 466 // F0
466 467 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
467 468 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
468 469 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
469 470
470 471 //***
471 472 // F1
472 473 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
473 474 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
474 475 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
475 476
476 477 //***
477 478 // F2
478 479 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
479 480 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
480 481 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
481 482
482 483 //***
483 484 // F3
484 485 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
485 486 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
486 487 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
487 488 }
488 489 }
489 490
490 491 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
491 492 {
492 493 unsigned char i;
493 494
494 495 for (i=0; i<7; i++)
495 496 {
496 497 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
497 498 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
498 499 headerSWF[ i ].reserved = DEFAULT_RESERVED;
499 500 headerSWF[ i ].userApplication = CCSDS_USER_APP;
500 501 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
501 502 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
502 503 if (i == 0)
503 504 {
504 505 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
505 506 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
506 507 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
507 508 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
508 509 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
509 510 }
510 511 else if (i == 6)
511 512 {
512 513 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
513 514 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
514 515 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
515 516 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
516 517 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
517 518 }
518 519 else
519 520 {
520 521 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
521 522 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
522 523 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
523 524 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
524 525 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
525 526 }
526 527 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
527 528 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
528 529 headerSWF[ i ].pktNr = i+1; // PKT_NR
529 530 // DATA FIELD HEADER
530 531 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
531 532 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
532 533 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
533 534 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
534 535 // AUXILIARY DATA HEADER
535 536 headerSWF[ i ].sid = sid;
536 537 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
537 538 headerSWF[ i ].time[0] = 0x00;
538 539 headerSWF[ i ].time[0] = 0x00;
539 540 headerSWF[ i ].time[0] = 0x00;
540 541 headerSWF[ i ].time[0] = 0x00;
541 542 headerSWF[ i ].time[0] = 0x00;
542 543 headerSWF[ i ].time[0] = 0x00;
543 544 }
544 545 return LFR_SUCCESSFUL;
545 546 }
546 547
547 548 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
548 549 {
549 550 unsigned int i;
550 551
551 552 for (i=0; i<7; i++)
552 553 {
553 554 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
554 555 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
555 556 headerCWF[ i ].reserved = DEFAULT_RESERVED;
556 557 headerCWF[ i ].userApplication = CCSDS_USER_APP;
557 558 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
558 559 {
559 560 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
560 561 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
561 562 }
562 563 else
563 564 {
564 565 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
565 566 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
566 567 }
567 568 if (i == 0)
568 569 {
569 570 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
570 571 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
571 572 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
572 573 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
573 574 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
574 575 }
575 576 else if (i == 6)
576 577 {
577 578 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
578 579 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
579 580 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
580 581 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
581 582 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
582 583 }
583 584 else
584 585 {
585 586 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
586 587 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
587 588 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
588 589 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
589 590 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
590 591 }
591 592 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
592 593 // PKT_CNT
593 594 // PKT_NR
594 595 // DATA FIELD HEADER
595 596 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
596 597 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
597 598 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
598 599 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
599 600 // AUXILIARY DATA HEADER
600 601 headerCWF[ i ].sid = sid;
601 602 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
602 603 headerCWF[ i ].time[0] = 0x00;
603 604 headerCWF[ i ].time[0] = 0x00;
604 605 headerCWF[ i ].time[0] = 0x00;
605 606 headerCWF[ i ].time[0] = 0x00;
606 607 headerCWF[ i ].time[0] = 0x00;
607 608 headerCWF[ i ].time[0] = 0x00;
608 609 }
609 610 return LFR_SUCCESSFUL;
610 611 }
611 612
612 613 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
613 614 {
614 615 unsigned int i;
615 616
616 617 for (i=0; i<7; i++)
617 618 {
618 619 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
619 620 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
620 621 headerCWF[ i ].reserved = DEFAULT_RESERVED;
621 622 headerCWF[ i ].userApplication = CCSDS_USER_APP;
622 623
623 624 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
624 625 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
625 626 if (i == 0)
626 627 {
627 628 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
628 629 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
629 630 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
630 631 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
631 632 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
632 633 }
633 634 else if (i == 6)
634 635 {
635 636 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
636 637 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
637 638 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
638 639 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
639 640 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
640 641 }
641 642 else
642 643 {
643 644 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
644 645 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
645 646 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
646 647 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
647 648 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
648 649 }
649 650 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
650 651 // DATA FIELD HEADER
651 652 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
652 653 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
653 654 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
654 655 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
655 656 // AUXILIARY DATA HEADER
656 657 headerCWF[ i ].sid = SID_NORM_CWF_F3;
657 658 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
658 659 headerCWF[ i ].time[0] = 0x00;
659 660 headerCWF[ i ].time[0] = 0x00;
660 661 headerCWF[ i ].time[0] = 0x00;
661 662 headerCWF[ i ].time[0] = 0x00;
662 663 headerCWF[ i ].time[0] = 0x00;
663 664 headerCWF[ i ].time[0] = 0x00;
664 665 }
665 666 return LFR_SUCCESSFUL;
666 667 }
667 668
668 669 void reset_waveforms( void )
669 670 {
670 671 int i = 0;
671 672
672 673 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
673 674 {
674 675 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
675 676 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
676 677 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
677 678
678 679 //***
679 680 // F1
680 681 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
681 682 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
682 683 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
683 684
684 685 //***
685 686 // F2
686 687 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
687 688 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
688 689 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
689 690
690 691 //***
691 692 // F3
692 693 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
693 694 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
694 695 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
695 696 }
696 697 }
697 698
698 699 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
699 700 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
700 701 {
701 702 /** This function sends SWF CCSDS packets (F2, F1 or F0).
702 703 *
703 704 * @param waveform points to the buffer containing the data that will be send.
704 705 * @param sid is the source identifier of the data that will be sent.
705 706 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
706 707 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
707 708 * contain information to setup the transmission of the data packets.
708 709 *
709 710 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
710 711 *
711 712 */
712 713
713 714 unsigned int i;
714 715 int ret;
715 716 rtems_status_code status;
716 717 spw_ioctl_pkt_send spw_ioctl_send_SWF;
717 718
718 719 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
719 720 spw_ioctl_send_SWF.options = 0;
720 721
721 722 ret = LFR_DEFAULT;
722 723
723 724 for (i=0; i<7; i++) // send waveform
724 725 {
725 726 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
726 727 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
727 728 // BUILD THE DATA
728 729 if (i==6) {
729 730 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
730 731 }
731 732 else {
732 733 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
733 734 }
734 735 // SET PACKET TIME
735 736 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
736 737 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
737 738 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
738 739 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
739 740 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
740 741 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
741 742 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
742 743 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
743 744 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
744 745 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
745 746 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
746 747 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
747 748 // SEND PACKET
748 749 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
749 750 if (status != RTEMS_SUCCESSFUL) {
750 751 printf("%d-%d, ERR %d\n", sid, i, (int) status);
751 752 ret = LFR_DEFAULT;
752 753 }
753 754 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
754 755 }
755 756
756 757 return ret;
757 758 }
758 759
759 760 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
760 761 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
761 762 {
762 763 /** This function sends CWF CCSDS packets (F2, F1 or F0).
763 764 *
764 765 * @param waveform points to the buffer containing the data that will be send.
765 766 * @param sid is the source identifier of the data that will be sent.
766 767 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
767 768 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
768 769 * contain information to setup the transmission of the data packets.
769 770 *
770 771 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
771 772 *
772 773 */
773 774
774 775 unsigned int i;
775 776 int ret;
776 777 rtems_status_code status;
777 778 spw_ioctl_pkt_send spw_ioctl_send_CWF;
778 779
779 780 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
780 781 spw_ioctl_send_CWF.options = 0;
781 782
782 783 ret = LFR_DEFAULT;
783 784
784 785 for (i=0; i<7; i++) // send waveform
785 786 {
786 787 int coarseTime = 0x00;
787 788 int fineTime = 0x00;
788 789 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
789 790 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
790 791 // BUILD THE DATA
791 792 if (i==6) {
792 793 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
793 794 }
794 795 else {
795 796 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
796 797 }
797 798 // SET PACKET TIME
798 799 coarseTime = time_management_regs->coarse_time;
799 800 fineTime = time_management_regs->fine_time;
800 801 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
801 802 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
802 803 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
803 804 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
804 805 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
805 806 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
806 807 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
807 808 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
808 809 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
809 810 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
810 811 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
811 812 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
812 813 // SEND PACKET
813 814 if (sid == SID_NORM_CWF_F3)
814 815 {
815 816 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
816 817 if (status != RTEMS_SUCCESSFUL) {
817 818 printf("%d-%d, ERR %d\n", sid, i, (int) status);
818 819 ret = LFR_DEFAULT;
819 820 }
820 821 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
821 822 }
822 823 else
823 824 {
824 825 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
825 826 if (status != RTEMS_SUCCESSFUL) {
826 827 printf("%d-%d, ERR %d\n", sid, i, (int) status);
827 828 ret = LFR_DEFAULT;
828 829 }
829 830 }
830 831 }
831 832
832 833 return ret;
833 834 }
834 835
835 836 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
836 837 {
837 838 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
838 839 *
839 840 * @param waveform points to the buffer containing the data that will be send.
840 841 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
841 842 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
842 843 * contain information to setup the transmission of the data packets.
843 844 *
844 845 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
845 846 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
846 847 *
847 848 */
848 849
849 850 unsigned int i;
850 851 int ret;
851 852 rtems_status_code status;
852 853 spw_ioctl_pkt_send spw_ioctl_send_CWF;
853 854 char *sample;
854 855
855 856 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
856 857 spw_ioctl_send_CWF.options = 0;
857 858
858 859 ret = LFR_DEFAULT;
859 860
860 861 //**********************
861 862 // BUILD CWF3_light DATA
862 863 for ( i=0; i< 2048; i++)
863 864 {
864 865 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
865 866 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
866 867 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
867 868 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
868 869 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
869 870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
870 871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
871 872 }
872 873
873 874 //*********************
874 875 // SEND CWF3_light DATA
875 876
876 877 for (i=0; i<7; i++) // send waveform
877 878 {
878 879 int coarseTime = 0x00;
879 880 int fineTime = 0x00;
880 881 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
881 882 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
882 883 // BUILD THE DATA
883 884 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
884 885 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
885 886 }
886 887 else {
887 888 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
888 889 }
889 890 // SET PACKET TIME
890 891 coarseTime = time_management_regs->coarse_time;
891 892 fineTime = time_management_regs->fine_time;
892 893 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
893 894 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
894 895 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
895 896 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
896 897 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
897 898 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
898 899 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
899 900 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
900 901 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
901 902 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
902 903 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
903 904 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
904 905 // SEND PACKET
905 906 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
906 907 if (status != RTEMS_SUCCESSFUL) {
907 908 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
908 909 ret = LFR_DEFAULT;
909 910 }
910 911 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
911 912 }
912 913
913 914 return ret;
914 915 }
915 916
916 917
917 918 //**************
918 919 // wfp registers
919 920 void set_wfp_data_shaping()
920 921 {
921 922 /** This function sets the data_shaping register of the waveform picker module.
922 923 *
923 924 * The value is read from one field of the parameter_dump_packet structure:\n
924 925 * bw_sp0_sp1_r0_r1
925 926 *
926 927 */
927 928
928 929 unsigned char data_shaping;
929 930
930 931 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
931 932 // waveform picker : [R1 R0 SP1 SP0 BW]
932 933
933 934 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
934 935
935 936 #ifdef GSA
936 937 #else
937 938 waveform_picker_regs->data_shaping =
938 939 ( (data_shaping & 0x10) >> 4 ) // BW
939 940 + ( (data_shaping & 0x08) >> 2 ) // SP0
940 941 + ( (data_shaping & 0x04) ) // SP1
941 942 + ( (data_shaping & 0x02) << 2 ) // R0
942 943 + ( (data_shaping & 0x01) << 4 ); // R1
943 944 #endif
944 945 }
945 946
946 947 char set_wfp_delta_snapshot()
947 948 {
948 949 /** This function sets the delta_snapshot register of the waveform picker module.
949 950 *
950 951 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
951 952 * - sy_lfr_n_swf_p[0]
952 953 * - sy_lfr_n_swf_p[1]
953 954 *
954 955 */
955 956
956 957 char ret;
957 958 unsigned int delta_snapshot;
958 959 unsigned int aux;
959 960
960 961 aux = 0;
961 962 ret = LFR_DEFAULT;
962 963
963 964 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
964 965 + parameter_dump_packet.sy_lfr_n_swf_p[1];
965 966
966 967 #ifdef GSA
967 968 #else
968 969 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
969 970 {
970 971 aux = MIN_DELTA_SNAPSHOT;
971 972 ret = LFR_DEFAULT;
972 973 }
973 974 else
974 975 {
975 976 aux = delta_snapshot ;
976 977 ret = LFR_SUCCESSFUL;
977 978 }
978 979 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
979 980 #endif
980 981
981 982 return ret;
982 983 }
983 984
984 985 void set_wfp_burst_enable_register( unsigned char mode)
985 986 {
986 987 /** This function sets the waveform picker burst_enable register depending on the mode.
987 988 *
988 989 * @param mode is the LFR mode to launch.
989 990 *
990 991 * The burst bits shall be before the enable bits.
991 992 *
992 993 */
993 994
994 995 #ifdef GSA
995 996 #else
996 997 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
997 998 // the burst bits shall be set first, before the enable bits
998 999 switch(mode) {
999 1000 case(LFR_MODE_NORMAL):
1000 1001 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
1001 1002 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1002 1003 break;
1003 1004 case(LFR_MODE_BURST):
1004 1005 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1005 1006 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
1006 1007 break;
1007 1008 case(LFR_MODE_SBM1):
1008 1009 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
1009 1010 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1010 1011 break;
1011 1012 case(LFR_MODE_SBM2):
1012 1013 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1013 1014 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1014 1015 break;
1015 1016 default:
1016 1017 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1017 1018 break;
1018 1019 }
1019 1020 #endif
1020 1021 }
1021 1022
1022 1023 void reset_wfp_burst_enable()
1023 1024 {
1024 1025 /** This function resets the waveform picker burst_enable register.
1025 1026 *
1026 1027 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1027 1028 *
1028 1029 */
1029 1030
1030 1031 #ifdef GSA
1031 1032 #else
1032 1033 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1033 1034 #endif
1034 1035 }
1035 1036
1036 1037 void reset_wfp_status()
1037 1038 {
1038 1039 /** This function resets the waveform picker status register.
1039 1040 *
1040 1041 * All status bits are set to 0 [new_err full_err full].
1041 1042 *
1042 1043 */
1043 1044
1044 1045 #ifdef GSA
1045 1046 #else
1046 1047 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1047 1048 #endif
1048 1049 }
1049 1050
1050 1051 void reset_waveform_picker_regs()
1051 1052 {
1052 1053 /** This function resets the waveform picker module registers.
1053 1054 *
1054 1055 * The registers affected by this function are located at the following offset addresses:
1055 1056 * - 0x00 data_shaping
1056 1057 * - 0x04 burst_enable
1057 1058 * - 0x08 addr_data_f0
1058 1059 * - 0x0C addr_data_f1
1059 1060 * - 0x10 addr_data_f2
1060 1061 * - 0x14 addr_data_f3
1061 1062 * - 0x18 status
1062 1063 * - 0x1C delta_snapshot
1063 1064 * - 0x20 delta_f2_f1
1064 1065 * - 0x24 delta_f2_f0
1065 1066 * - 0x28 nb_burst
1066 1067 * - 0x2C nb_snapshot
1067 1068 *
1068 1069 */
1069 1070
1070 1071 #ifdef GSA
1071 1072 #else
1073 reset_wfp_burst_enable();
1072 1074 set_wfp_data_shaping();
1073 reset_wfp_burst_enable();
1074 1075 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
1075 1076 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
1076 1077 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
1077 1078 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
1078 1079 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1079 1080 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1080 1081 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1081 1082 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1082 1083 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1083 waveform_picker_regs->status = 0x00; //
1084 reset_wfp_status();
1084 1085 #endif
1085 1086 }
1086 1087
1087 1088 //*****************
1088 1089 // local parameters
1089 1090 void set_local_sbm1_nb_cwf_max()
1090 1091 {
1091 1092 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1092 1093 *
1093 1094 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1094 1095 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1095 1096 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1096 1097 *
1097 1098 */
1098 1099 param_local.local_sbm1_nb_cwf_max = 2 *
1099 1100 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1100 1101 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1101 1102 }
1102 1103
1103 1104 void set_local_sbm2_nb_cwf_max()
1104 1105 {
1105 1106 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1106 1107 *
1107 1108 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1108 1109 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1109 1110 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1110 1111 *
1111 1112 */
1112 1113
1113 1114 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1114 1115 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1115 1116 }
1116 1117
1117 1118 void set_local_nb_interrupt_f0_MAX()
1118 1119 {
1119 1120 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1120 1121 *
1121 1122 * This parameter is used for the SM validation only.\n
1122 1123 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1123 1124 * module before launching a basic processing.
1124 1125 *
1125 1126 */
1126 1127
1127 1128 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1128 1129 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1129 1130 }
1130 1131
1131 1132 void reset_local_sbm1_nb_cwf_sent()
1132 1133 {
1133 1134 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1134 1135 *
1135 1136 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1136 1137 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1137 1138 *
1138 1139 */
1139 1140
1140 1141 param_local.local_sbm1_nb_cwf_sent = 0;
1141 1142 }
1142 1143
1143 1144 void reset_local_sbm2_nb_cwf_sent()
1144 1145 {
1145 1146 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1146 1147 *
1147 1148 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1148 1149 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1149 1150 *
1150 1151 */
1151 1152
1152 1153 param_local.local_sbm2_nb_cwf_sent = 0;
1153 1154 }
1154 1155
1155 1156 rtems_id get_pkts_queue_id( void )
1156 1157 {
1157 1158 rtems_id queue_id;
1158 1159 rtems_status_code status;
1159 1160
1160 1161 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
1161 1162 if (status != RTEMS_SUCCESSFUL)
1162 1163 {
1163 1164 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1164 1165 }
1165 1166 return queue_id;
1166 1167 }
General Comments 0
You need to be logged in to leave comments. Login now