##// END OF EJS Templates
VHDL_DEV implemented. The code is compatible with:...
paul -
r91:6af3303996c6 VHDLib206
parent child
Show More
@@ -1,248 +1,248
1 1 #############################################################################
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Jan 21 15:38:15 2014
2 # Makefile for building: bin/fsw-vhdl-dev
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Jan 23 13:51:15 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES -DVHDL_DEV
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_processing.c \
49 49 ../src/fsw_misc.c \
50 50 ../src/fsw_init.c \
51 51 ../src/fsw_globals.c \
52 52 ../src/fsw_spacewire.c \
53 53 ../src/tc_load_dump_parameters.c \
54 54 ../src/tm_lfr_tc_exe.c \
55 55 ../src/tc_acceptance.c
56 56 OBJECTS = obj/wf_handler.o \
57 57 obj/tc_handler.o \
58 58 obj/fsw_processing.o \
59 59 obj/fsw_misc.o \
60 60 obj/fsw_init.o \
61 61 obj/fsw_globals.o \
62 62 obj/fsw_spacewire.o \
63 63 obj/tc_load_dump_parameters.o \
64 64 obj/tm_lfr_tc_exe.o \
65 65 obj/tc_acceptance.o
66 66 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
67 67 /usr/lib64/qt4/mkspecs/common/linux.conf \
68 68 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
69 69 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
70 70 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
71 71 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
72 72 /usr/lib64/qt4/mkspecs/qconfig.pri \
73 73 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
74 74 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
75 75 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
76 76 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
77 77 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
78 78 sparc.pri \
79 79 /usr/lib64/qt4/mkspecs/features/release.prf \
80 80 /usr/lib64/qt4/mkspecs/features/default_post.prf \
81 81 /usr/lib64/qt4/mkspecs/features/shared.prf \
82 82 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
83 83 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
84 84 /usr/lib64/qt4/mkspecs/features/resources.prf \
85 85 /usr/lib64/qt4/mkspecs/features/uic.prf \
86 86 /usr/lib64/qt4/mkspecs/features/yacc.prf \
87 87 /usr/lib64/qt4/mkspecs/features/lex.prf \
88 88 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
89 89 fsw-qt.pro
90 QMAKE_TARGET = fsw
90 QMAKE_TARGET = fsw-vhdl-dev
91 91 DESTDIR = bin/
92 TARGET = bin/fsw
92 TARGET = bin/fsw-vhdl-dev
93 93
94 94 first: all
95 95 ####### Implicit rules
96 96
97 97 .SUFFIXES: .o .c .cpp .cc .cxx .C
98 98
99 99 .cpp.o:
100 100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101 101
102 102 .cc.o:
103 103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
104 104
105 105 .cxx.o:
106 106 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
107 107
108 108 .C.o:
109 109 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
110 110
111 111 .c.o:
112 112 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
113 113
114 114 ####### Build rules
115 115
116 116 all: Makefile $(TARGET)
117 117
118 118 $(TARGET): $(OBJECTS)
119 119 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
120 120 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
121 121
122 122 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
123 123 /usr/lib64/qt4/mkspecs/common/linux.conf \
124 124 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
125 125 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
126 126 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
127 127 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
128 128 /usr/lib64/qt4/mkspecs/qconfig.pri \
129 129 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
130 130 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
131 131 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
132 132 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
133 133 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
134 134 sparc.pri \
135 135 /usr/lib64/qt4/mkspecs/features/release.prf \
136 136 /usr/lib64/qt4/mkspecs/features/default_post.prf \
137 137 /usr/lib64/qt4/mkspecs/features/shared.prf \
138 138 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
139 139 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
140 140 /usr/lib64/qt4/mkspecs/features/resources.prf \
141 141 /usr/lib64/qt4/mkspecs/features/uic.prf \
142 142 /usr/lib64/qt4/mkspecs/features/yacc.prf \
143 143 /usr/lib64/qt4/mkspecs/features/lex.prf \
144 144 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
145 145 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
146 146 /usr/lib64/qt4/mkspecs/common/unix.conf:
147 147 /usr/lib64/qt4/mkspecs/common/linux.conf:
148 148 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
149 149 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
150 150 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
151 151 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
152 152 /usr/lib64/qt4/mkspecs/qconfig.pri:
153 153 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
154 154 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
155 155 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
156 156 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
157 157 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
158 158 sparc.pri:
159 159 /usr/lib64/qt4/mkspecs/features/release.prf:
160 160 /usr/lib64/qt4/mkspecs/features/default_post.prf:
161 161 /usr/lib64/qt4/mkspecs/features/shared.prf:
162 162 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
163 163 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
164 164 /usr/lib64/qt4/mkspecs/features/resources.prf:
165 165 /usr/lib64/qt4/mkspecs/features/uic.prf:
166 166 /usr/lib64/qt4/mkspecs/features/yacc.prf:
167 167 /usr/lib64/qt4/mkspecs/features/lex.prf:
168 168 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
169 169 qmake: FORCE
170 170 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
171 171
172 172 dist:
173 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
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
173 @$(CHK_DIR_EXISTS) obj/fsw-vhdl-dev1.0.0 || $(MKDIR) obj/fsw-vhdl-dev1.0.0
174 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw-vhdl-dev1.0.0/ && (cd `dirname obj/fsw-vhdl-dev1.0.0` && $(TAR) fsw-vhdl-dev1.0.0.tar fsw-vhdl-dev1.0.0 && $(COMPRESS) fsw-vhdl-dev1.0.0.tar) && $(MOVE) `dirname obj/fsw-vhdl-dev1.0.0`/fsw-vhdl-dev1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw-vhdl-dev1.0.0
175 175
176 176
177 177 clean:compiler_clean
178 178 -$(DEL_FILE) $(OBJECTS)
179 179 -$(DEL_FILE) *~ core *.core
180 180
181 181
182 182 ####### Sub-libraries
183 183
184 184 distclean: clean
185 185 -$(DEL_FILE) $(TARGET)
186 186 -$(DEL_FILE) Makefile
187 187
188 188
189 189 grmon:
190 190 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
191 191
192 192 check: first
193 193
194 194 compiler_rcc_make_all:
195 195 compiler_rcc_clean:
196 196 compiler_uic_make_all:
197 197 compiler_uic_clean:
198 198 compiler_image_collection_make_all: qmake_image_collection.cpp
199 199 compiler_image_collection_clean:
200 200 -$(DEL_FILE) qmake_image_collection.cpp
201 201 compiler_yacc_decl_make_all:
202 202 compiler_yacc_decl_clean:
203 203 compiler_yacc_impl_make_all:
204 204 compiler_yacc_impl_clean:
205 205 compiler_lex_make_all:
206 206 compiler_lex_clean:
207 207 compiler_clean:
208 208
209 209 ####### Compile
210 210
211 211 obj/wf_handler.o: ../src/wf_handler.c
212 212 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
213 213
214 214 obj/tc_handler.o: ../src/tc_handler.c
215 215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
216 216
217 217 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
218 218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
219 219
220 220 obj/fsw_misc.o: ../src/fsw_misc.c
221 221 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
222 222
223 223 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
224 224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
225 225
226 226 obj/fsw_globals.o: ../src/fsw_globals.c
227 227 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
228 228
229 229 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
230 230 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
231 231
232 232 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
233 233 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
234 234
235 235 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
236 236 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
237 237
238 238 obj/tc_acceptance.o: ../src/tc_acceptance.c
239 239 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
240 240
241 241 ####### Install
242 242
243 243 install: FORCE
244 244
245 245 uninstall: FORCE
246 246
247 247 FORCE:
248 248
@@ -1,85 +1,85
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 *** vhdl_dev
4 4 CONFIG += console verbose debug_messages vhdl_dev
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-1-0
11 11 DEFINES += SW_VERSION_N1=1 # major
12 12 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 14 DEFINES += SW_VERSION_N4=1 # internal
15 15
16 16 contains( CONFIG, verbose ) {
17 17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 18 }
19 19
20 20 contains( CONFIG, debug_messages ) {
21 21 DEFINES += DEBUG_MESSAGES
22 22 }
23 23
24 24 contains( CONFIG, cpu_usage_report ) {
25 25 DEFINES += PRINT_TASK_STATISTICS
26 26 }
27 27
28 28 contains( CONFIG, stack_report ) {
29 29 DEFINES += PRINT_STACK_REPORT
30 30 }
31 31
32 32 contains( CONFIG, boot_messages ) {
33 33 DEFINES += BOOT_MESSAGES
34 34 }
35 35
36 36 #doxygen.target = doxygen
37 37 #doxygen.commands = doxygen ../doc/Doxyfile
38 38 #QMAKE_EXTRA_TARGETS += doxygen
39 39
40 40 TARGET = fsw
41 41 contains( CONFIG, gsa ) {
42 42 DEFINES += GSA
43 43 TARGET = fsw-gsa
44 44 }
45 45
46 46 TARGET = fsw
47 47 contains( CONFIG, vhdl_dev ) {
48 48 DEFINES += VHDL_DEV
49 TARGET = fsw
49 TARGET = fsw-vhdl-dev
50 50 }
51 51
52 52 INCLUDEPATH += \
53 53 ../src \
54 54 ../header
55 55
56 56 SOURCES += \
57 57 ../src/wf_handler.c \
58 58 ../src/tc_handler.c \
59 59 ../src/fsw_processing.c \
60 60 ../src/fsw_misc.c \
61 61 ../src/fsw_init.c \
62 62 ../src/fsw_globals.c \
63 63 ../src/fsw_spacewire.c \
64 64 ../src/tc_load_dump_parameters.c \
65 65 ../src/tm_lfr_tc_exe.c \
66 66 ../src/tc_acceptance.c
67 67
68 68
69 69 HEADERS += \
70 70 ../header/wf_handler.h \
71 71 ../header/tc_handler.h \
72 72 ../header/grlib_regs.h \
73 73 ../header/fsw_processing.h \
74 74 ../header/fsw_params.h \
75 75 ../header/fsw_misc.h \
76 76 ../header/fsw_init.h \
77 77 ../header/ccsds_types.h \
78 78 ../header/fsw_params_processing.h \
79 79 ../header/fsw_spacewire.h \
80 80 ../header/tm_byte_positions.h \
81 81 ../header/tc_load_dump_parameters.h \
82 82 ../header/tm_lfr_tc_exe.h \
83 83 ../header/tc_acceptance.h \
84 84 ../header/fsw_params_nb_bytes.h
85 85
@@ -1,311 +1,311
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.0, 2014-01-21T15:59:52. -->
3 <!-- Written by QtCreator 3.0.0, 2014-01-24T06:51:07. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63 63 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64 64 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
67 67 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
69 69 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
70 70 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
71 71 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
72 72 </valuemap>
73 73 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
74 74 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
77 77 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
78 78 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
79 79 <value type="QString">-w</value>
80 80 <value type="QString">-r</value>
81 81 </valuelist>
82 82 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</value>
84 84 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
85 85 </valuemap>
86 86 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
89 89 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
90 90 </valuemap>
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
92 92 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
93 93 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
96 96 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
97 97 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
98 98 <value type="QString">-w</value>
99 99 <value type="QString">-r</value>
100 100 </valuelist>
101 101 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
103 103 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
104 104 </valuemap>
105 105 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108 108 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
109 109 </valuemap>
110 110 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
111 111 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
112 112 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
115 115 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
116 116 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 118 </valuemap>
119 119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 120 <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
122 122 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
123 123 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
126 126 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
127 127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
128 128 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
129 129 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
130 130 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
131 131 </valuemap>
132 132 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
133 133 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
134 134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
136 136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
137 137 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
138 138 <value type="QString">-w</value>
139 139 <value type="QString">-r</value>
140 140 </valuelist>
141 141 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
142 142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
143 143 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
144 144 </valuemap>
145 145 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
146 146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
147 147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
148 148 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
149 149 </valuemap>
150 150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
151 151 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
152 152 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
153 153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
154 154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
155 155 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
156 156 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
157 157 <value type="QString">-w</value>
158 158 <value type="QString">-r</value>
159 159 </valuelist>
160 160 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
161 161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
162 162 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
163 163 </valuemap>
164 164 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
165 165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
166 166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
167 167 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
168 168 </valuemap>
169 169 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
170 170 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
171 171 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
174 174 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
175 175 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
177 177 </valuemap>
178 178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
179 179 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180 180 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181 181 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182 182 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183 183 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184 184 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187 187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
188 188 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
189 189 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
190 190 </valuemap>
191 191 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
192 192 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
193 193 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
194 194 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
195 195 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
196 196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
197 197 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
198 198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
199 199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
200 200 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
201 201 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
202 202 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
203 203 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
204 204 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205 205 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206 206 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
207 207 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
208 208 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
209 209 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
210 210 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
211 211 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
212 212 <value type="int">0</value>
213 213 <value type="int">1</value>
214 214 <value type="int">2</value>
215 215 <value type="int">3</value>
216 216 <value type="int">4</value>
217 217 <value type="int">5</value>
218 218 <value type="int">6</value>
219 219 <value type="int">7</value>
220 220 <value type="int">8</value>
221 221 <value type="int">9</value>
222 222 <value type="int">10</value>
223 223 <value type="int">11</value>
224 224 <value type="int">12</value>
225 225 <value type="int">13</value>
226 226 <value type="int">14</value>
227 227 </valuelist>
228 228 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
229 229 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
230 230 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
231 231 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
232 232 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
233 233 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
234 234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
235 235 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
236 236 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
237 237 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
238 238 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
239 239 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
240 240 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
241 241 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
242 242 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
243 243 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
244 244 </valuemap>
245 245 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
246 246 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
247 247 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
248 248 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
249 249 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
250 250 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
251 251 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
252 252 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
253 253 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
254 254 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
255 255 <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
256 256 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
257 257 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
258 258 <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
259 259 <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
260 260 <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
261 261 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
262 262 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
263 263 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
264 264 <value type="int">0</value>
265 265 <value type="int">1</value>
266 266 <value type="int">2</value>
267 267 <value type="int">3</value>
268 268 <value type="int">4</value>
269 269 <value type="int">5</value>
270 270 <value type="int">6</value>
271 271 <value type="int">7</value>
272 272 <value type="int">8</value>
273 273 <value type="int">9</value>
274 274 <value type="int">10</value>
275 275 <value type="int">11</value>
276 276 <value type="int">12</value>
277 277 <value type="int">13</value>
278 278 <value type="int">14</value>
279 279 </valuelist>
280 280 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
281 281 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
282 282 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
283 283 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value>
284 284 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value>
285 285 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value>
286 286 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value>
287 287 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
288 288 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
289 289 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
290 290 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
291 291 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
292 292 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
293 293 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
294 294 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
295 295 </valuemap>
296 296 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
297 297 </valuemap>
298 298 </data>
299 299 <data>
300 300 <variable>ProjectExplorer.Project.TargetCount</variable>
301 301 <value type="int">1</value>
302 302 </data>
303 303 <data>
304 304 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
305 305 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
306 306 </data>
307 307 <data>
308 308 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
309 309 <value type="int">15</value>
310 310 </data>
311 311 </qtcreator>
@@ -1,94 +1,93
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8
9 9 #include "fsw_params.h"
10 10 #include "fsw_spacewire.h"
11 11 #include "fsw_misc.h"
12 12
13 13 #define pi 3.1415
14 14
15 15 typedef struct ring_node
16 16 {
17 17 struct ring_node *previous;
18 18 int buffer_address;
19 19 struct ring_node *next;
20 20 unsigned int status;
21 21 } ring_node;
22 22
23 23 extern int fdSPW;
24 24
25 25 //*****************
26 26 // waveform buffers
27 27 // F0
28 28 extern volatile int wf_snap_f0[ ];
29 // F1
30 extern volatile int wf_snap_f1[ ][ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
31 // F2
32 extern volatile int wf_snap_f2[ ][ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
29 // F1 F2
30 extern volatile int wf_snap_f1[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ];
31 extern volatile int wf_snap_f2[ ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ];
33 32 // F3
34 33 extern volatile int wf_cont_f3_a[ ];
35 34 extern volatile int wf_cont_f3_b[ ];
36 35 extern char wf_cont_f3_light[ ];
37 36
38 37 #ifdef VHDL_DEV
39 38 extern waveform_picker_regs_new_t *waveform_picker_regs;
40 39 #else
41 40 extern waveform_picker_regs_t *waveform_picker_regs;
42 41 #endif
43 42 extern time_management_regs_t *time_management_regs;
44 43 extern Packet_TM_LFR_HK_t housekeeping_packet;
45 44 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
46 45 extern struct param_local_str param_local;
47 46
48 47 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
49 48 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
50 49
51 50 extern rtems_id Task_id[20]; /* array of task ids */
52 51
53 52 extern unsigned char lfrCurrentMode;
54 53
55 54 rtems_isr waveforms_isr( rtems_vector_number vector );
56 55 rtems_task wfrm_task( rtems_task_argument argument );
57 56 rtems_task cwf3_task( rtems_task_argument argument );
58 57 rtems_task cwf2_task( rtems_task_argument argument );
59 58 rtems_task cwf1_task( rtems_task_argument argument );
60 59
61 60 //******************
62 61 // general functions
63 62 void init_waveforms( void );
64 63 void init_waveform_rings( void );
65 64 void reset_current_ring_nodes( void );
66 65 //
67 66 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
68 67 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
69 68 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
70 69 //
71 70 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
72 71 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
73 72 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
74 73 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
75 74 //
76 75 rtems_id get_pkts_queue_id( void );
77 76
78 77 //**************
79 78 // wfp registers
80 79 void set_wfp_data_shaping();
81 80 char set_wfp_delta_snapshot();
82 81 void set_wfp_burst_enable_register( unsigned char mode );
83 82 void reset_wfp_burst_enable();
84 83 void reset_wfp_status();
85 84 void reset_waveform_picker_regs();
86 85 void reset_new_waveform_picker_regs();
87 86
88 87 //*****************
89 88 // local parameters
90 89 void set_local_nb_interrupt_f0_MAX( void );
91 90
92 91 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
93 92
94 93 #endif // WF_HANDLER_H_INCLUDED
@@ -1,89 +1,89
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 23
24 24 // RTEMS GLOBAL VARIABLES
25 25 rtems_name misc_name[5];
26 26 rtems_id misc_id[5];
27 27 rtems_name Task_name[20]; /* array of task names */
28 28 rtems_id Task_id[20]; /* array of task ids */
29 29 unsigned int maxCount;
30 30 int fdSPW = 0;
31 31 int fdUART = 0;
32 32 unsigned char lfrCurrentMode;
33 33
34 34 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
35 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
36 //
37 volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
38 //
39 volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
40 //
41 volatile int wf_cont_f3_a[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
42 volatile int wf_cont_f3_b[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
43 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ];
35 // F0
36 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
37 // F1 F2
38 volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100)));
39 volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100)));
40 // F3
41 volatile int wf_cont_f3_a[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
42 volatile int wf_cont_f3_b[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
43 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ] __attribute__((aligned(0x100)));
44 44
45 45 // SPECTRAL MATRICES GLOBAL VARIABLES
46 46 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
47 47 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
48 48 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
49 49 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
50 50 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
51 51 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
52 52 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
53 53 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
54 54 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
55 55 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
56 56 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
57 57 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
58 58 //
59 59 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
60 60 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
61 61 //
62 62 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
63 63 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
64 64
65 65 // APB CONFIGURATION REGISTERS
66 66 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
67 67 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
68 68
69 69 #ifdef VHDL_DEV
70 70 waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER;
71 71 #else
72 72 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
73 73 #endif
74 74 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
75 75
76 76 // MODE PARAMETERS
77 77 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
78 78 struct param_local_str param_local;
79 79
80 80 // HK PACKETS
81 81 Packet_TM_LFR_HK_t housekeeping_packet;
82 82 // sequence counters are incremented by APID (PID + CAT) and destination ID
83 83 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
84 84 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
85 85 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
86 86 spw_stats spacewire_stats;
87 87 spw_stats spacewire_stats_backup;
88 88
89 89
@@ -1,606 +1,609
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 #ifdef VHDL_DEV
82 PRINTF("/!\\ this is the VHDL_DEV flight software /!\\ \n")
83 #endif
81 84 BOOT_PRINTF("***************************\n")
82 85 BOOT_PRINTF("\n\n")
83 86
84 87 //send_console_outputs_on_apbuart_port();
85 88 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
86 89
87 90 reset_wfp_burst_enable(); // stop the waveform picker if it was running
88 91 init_waveform_rings(); // initialize the waveform rings
89 92
90 93 init_parameter_dump();
91 94 init_local_mode_parameters();
92 95 init_housekeeping_parameters();
93 96
94 97 updateLFRCurrentMode();
95 98
96 99 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
97 100
98 101 create_names(); // create all names
99 102
100 103 status = create_message_queues(); // create message queues
101 104 if (status != RTEMS_SUCCESSFUL)
102 105 {
103 106 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
104 107 }
105 108
106 109 status = create_all_tasks(); // create all tasks
107 110 if (status != RTEMS_SUCCESSFUL)
108 111 {
109 112 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
110 113 }
111 114
112 115 // **************************
113 116 // <SPACEWIRE INITIALIZATION>
114 117 grspw_timecode_callback = &timecode_irq_handler;
115 118
116 119 status_spw = spacewire_open_link(); // (1) open the link
117 120 if ( status_spw != RTEMS_SUCCESSFUL )
118 121 {
119 122 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
120 123 }
121 124
122 125 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
123 126 {
124 127 status_spw = spacewire_configure_link( fdSPW );
125 128 if ( status_spw != RTEMS_SUCCESSFUL )
126 129 {
127 130 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
128 131 }
129 132 }
130 133
131 134 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
132 135 {
133 136 status_spw = spacewire_start_link( fdSPW );
134 137 if ( status_spw != RTEMS_SUCCESSFUL )
135 138 {
136 139 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
137 140 }
138 141 }
139 142 // </SPACEWIRE INITIALIZATION>
140 143 // ***************************
141 144
142 145 status = start_all_tasks(); // start all tasks
143 146 if (status != RTEMS_SUCCESSFUL)
144 147 {
145 148 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
146 149 }
147 150
148 151 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
149 152 status = start_recv_send_tasks();
150 153 if ( status != RTEMS_SUCCESSFUL )
151 154 {
152 155 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
153 156 }
154 157
155 158 // suspend science tasks. they will be restarted later depending on the mode
156 159 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
157 160 if (status != RTEMS_SUCCESSFUL)
158 161 {
159 162 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
160 163 }
161 164
162 165 #ifdef GSA
163 166 // mask IRQ lines
164 167 LEON_Mask_interrupt( IRQ_SM );
165 168 LEON_Mask_interrupt( IRQ_WF );
166 169 // Spectral Matrices simulator
167 170 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
168 171 IRQ_SPARC_SM, spectral_matrices_isr );
169 172 // WaveForms
170 173 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
171 174 IRQ_SPARC_WF, waveforms_simulator_isr );
172 175 #else
173 176 // configure IRQ handling for the waveform picker unit
174 177 status = rtems_interrupt_catch( waveforms_isr,
175 178 IRQ_SPARC_WAVEFORM_PICKER,
176 179 &old_isr_handler) ;
177 180 #endif
178 181
179 182 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
180 183 if ( status_spw != RTEMS_SUCCESSFUL )
181 184 {
182 185 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
183 186 if ( status != RTEMS_SUCCESSFUL ) {
184 187 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
185 188 }
186 189 }
187 190
188 191 BOOT_PRINTF("delete INIT\n")
189 192
190 193 status = rtems_task_delete(RTEMS_SELF);
191 194
192 195 }
193 196
194 197 void init_local_mode_parameters( void )
195 198 {
196 199 /** This function initialize the param_local global variable with default values.
197 200 *
198 201 */
199 202
200 203 unsigned int i;
201 204
202 205 // LOCAL PARAMETERS
203 206 set_local_nb_interrupt_f0_MAX();
204 207
205 208 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
206 209 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
207 210 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
208 211
209 212 // init sequence counters
210 213
211 214 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
212 215 {
213 216 sequenceCounters_TC_EXE[i] = 0x00;
214 217 }
215 218 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
216 219 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
217 220 }
218 221
219 222 void create_names( void ) // create all names for tasks and queues
220 223 {
221 224 /** This function creates all RTEMS names used in the software for tasks and queues.
222 225 *
223 226 * @return RTEMS directive status codes:
224 227 * - RTEMS_SUCCESSFUL - successful completion
225 228 *
226 229 */
227 230
228 231 // task names
229 232 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
230 233 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
231 234 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
232 235 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
233 236 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
234 237 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
235 238 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
236 239 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
237 240 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
238 241 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
239 242 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
240 243 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
241 244 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
242 245 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
243 246 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
244 247 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
245 248
246 249 // rate monotonic period names
247 250 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
248 251
249 252 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
250 253 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
251 254 }
252 255
253 256 int create_all_tasks( void ) // create all tasks which run in the software
254 257 {
255 258 /** This function creates all RTEMS tasks used in the software.
256 259 *
257 260 * @return RTEMS directive status codes:
258 261 * - RTEMS_SUCCESSFUL - task created successfully
259 262 * - RTEMS_INVALID_ADDRESS - id is NULL
260 263 * - RTEMS_INVALID_NAME - invalid task name
261 264 * - RTEMS_INVALID_PRIORITY - invalid task priority
262 265 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
263 266 * - RTEMS_TOO_MANY - too many tasks created
264 267 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
265 268 * - RTEMS_TOO_MANY - too many global objects
266 269 *
267 270 */
268 271
269 272 rtems_status_code status;
270 273
271 274 // RECV
272 275 status = rtems_task_create(
273 276 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
274 277 RTEMS_DEFAULT_MODES,
275 278 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
276 279 );
277 280
278 281 if (status == RTEMS_SUCCESSFUL) // ACTN
279 282 {
280 283 status = rtems_task_create(
281 284 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
282 285 RTEMS_DEFAULT_MODES,
283 286 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
284 287 );
285 288 }
286 289 if (status == RTEMS_SUCCESSFUL) // SPIQ
287 290 {
288 291 status = rtems_task_create(
289 292 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
290 293 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
291 294 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
292 295 );
293 296 }
294 297 if (status == RTEMS_SUCCESSFUL) // SMIQ
295 298 {
296 299 status = rtems_task_create(
297 300 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
298 301 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
299 302 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
300 303 );
301 304 }
302 305 if (status == RTEMS_SUCCESSFUL) // STAT
303 306 {
304 307 status = rtems_task_create(
305 308 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
306 309 RTEMS_DEFAULT_MODES,
307 310 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
308 311 );
309 312 }
310 313 if (status == RTEMS_SUCCESSFUL) // AVF0
311 314 {
312 315 status = rtems_task_create(
313 316 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
314 317 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
315 318 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
316 319 );
317 320 }
318 321 if (status == RTEMS_SUCCESSFUL) // BPF0
319 322 {
320 323 status = rtems_task_create(
321 324 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
322 325 RTEMS_DEFAULT_MODES,
323 326 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
324 327 );
325 328 }
326 329 if (status == RTEMS_SUCCESSFUL) // WFRM
327 330 {
328 331 status = rtems_task_create(
329 332 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
330 333 RTEMS_DEFAULT_MODES,
331 334 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
332 335 );
333 336 }
334 337 if (status == RTEMS_SUCCESSFUL) // DUMB
335 338 {
336 339 status = rtems_task_create(
337 340 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
338 341 RTEMS_DEFAULT_MODES,
339 342 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
340 343 );
341 344 }
342 345 if (status == RTEMS_SUCCESSFUL) // HOUS
343 346 {
344 347 status = rtems_task_create(
345 348 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
346 349 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 350 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
348 351 );
349 352 }
350 353 if (status == RTEMS_SUCCESSFUL) // MATR
351 354 {
352 355 status = rtems_task_create(
353 356 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
354 357 RTEMS_DEFAULT_MODES,
355 358 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
356 359 );
357 360 }
358 361 if (status == RTEMS_SUCCESSFUL) // CWF3
359 362 {
360 363 status = rtems_task_create(
361 364 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
362 365 RTEMS_DEFAULT_MODES,
363 366 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
364 367 );
365 368 }
366 369 if (status == RTEMS_SUCCESSFUL) // CWF2
367 370 {
368 371 status = rtems_task_create(
369 372 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
370 373 RTEMS_DEFAULT_MODES,
371 374 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
372 375 );
373 376 }
374 377 if (status == RTEMS_SUCCESSFUL) // CWF1
375 378 {
376 379 status = rtems_task_create(
377 380 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
378 381 RTEMS_DEFAULT_MODES,
379 382 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
380 383 );
381 384 }
382 385 if (status == RTEMS_SUCCESSFUL) // SEND
383 386 {
384 387 status = rtems_task_create(
385 388 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
386 389 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
387 390 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
388 391 );
389 392 }
390 393 if (status == RTEMS_SUCCESSFUL) // WTDG
391 394 {
392 395 status = rtems_task_create(
393 396 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
394 397 RTEMS_DEFAULT_MODES,
395 398 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
396 399 );
397 400 }
398 401
399 402 return status;
400 403 }
401 404
402 405 int start_recv_send_tasks( void )
403 406 {
404 407 rtems_status_code status;
405 408
406 409 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
407 410 if (status!=RTEMS_SUCCESSFUL) {
408 411 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
409 412 }
410 413
411 414 if (status == RTEMS_SUCCESSFUL) // SEND
412 415 {
413 416 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
414 417 if (status!=RTEMS_SUCCESSFUL) {
415 418 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
416 419 }
417 420 }
418 421
419 422 return status;
420 423 }
421 424
422 425 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
423 426 {
424 427 /** This function starts all RTEMS tasks used in the software.
425 428 *
426 429 * @return RTEMS directive status codes:
427 430 * - RTEMS_SUCCESSFUL - ask started successfully
428 431 * - RTEMS_INVALID_ADDRESS - invalid task entry point
429 432 * - RTEMS_INVALID_ID - invalid task id
430 433 * - RTEMS_INCORRECT_STATE - task not in the dormant state
431 434 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
432 435 *
433 436 */
434 437 // starts all the tasks fot eh flight software
435 438
436 439 rtems_status_code status;
437 440
438 441 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
439 442 if (status!=RTEMS_SUCCESSFUL) {
440 443 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
441 444 }
442 445
443 446 if (status == RTEMS_SUCCESSFUL) // WTDG
444 447 {
445 448 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
446 449 if (status!=RTEMS_SUCCESSFUL) {
447 450 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
448 451 }
449 452 }
450 453
451 454 if (status == RTEMS_SUCCESSFUL) // SMIQ
452 455 {
453 456 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
454 457 if (status!=RTEMS_SUCCESSFUL) {
455 458 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
456 459 }
457 460 }
458 461
459 462 if (status == RTEMS_SUCCESSFUL) // ACTN
460 463 {
461 464 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
462 465 if (status!=RTEMS_SUCCESSFUL) {
463 466 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
464 467 }
465 468 }
466 469
467 470 if (status == RTEMS_SUCCESSFUL) // STAT
468 471 {
469 472 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
470 473 if (status!=RTEMS_SUCCESSFUL) {
471 474 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
472 475 }
473 476 }
474 477
475 478 if (status == RTEMS_SUCCESSFUL) // AVF0
476 479 {
477 480 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
478 481 if (status!=RTEMS_SUCCESSFUL) {
479 482 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
480 483 }
481 484 }
482 485
483 486 if (status == RTEMS_SUCCESSFUL) // BPF0
484 487 {
485 488 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
486 489 if (status!=RTEMS_SUCCESSFUL) {
487 490 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
488 491 }
489 492 }
490 493
491 494 if (status == RTEMS_SUCCESSFUL) // WFRM
492 495 {
493 496 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
494 497 if (status!=RTEMS_SUCCESSFUL) {
495 498 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
496 499 }
497 500 }
498 501
499 502 if (status == RTEMS_SUCCESSFUL) // DUMB
500 503 {
501 504 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
502 505 if (status!=RTEMS_SUCCESSFUL) {
503 506 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
504 507 }
505 508 }
506 509
507 510 if (status == RTEMS_SUCCESSFUL) // HOUS
508 511 {
509 512 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
510 513 if (status!=RTEMS_SUCCESSFUL) {
511 514 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
512 515 }
513 516 }
514 517
515 518 if (status == RTEMS_SUCCESSFUL) // MATR
516 519 {
517 520 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
518 521 if (status!=RTEMS_SUCCESSFUL) {
519 522 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
520 523 }
521 524 }
522 525
523 526 if (status == RTEMS_SUCCESSFUL) // CWF3
524 527 {
525 528 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
526 529 if (status!=RTEMS_SUCCESSFUL) {
527 530 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
528 531 }
529 532 }
530 533
531 534 if (status == RTEMS_SUCCESSFUL) // CWF2
532 535 {
533 536 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
534 537 if (status!=RTEMS_SUCCESSFUL) {
535 538 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
536 539 }
537 540 }
538 541
539 542 if (status == RTEMS_SUCCESSFUL) // CWF1
540 543 {
541 544 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
542 545 if (status!=RTEMS_SUCCESSFUL) {
543 546 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
544 547 }
545 548 }
546 549 return status;
547 550 }
548 551
549 552 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
550 553 {
551 554 rtems_status_code status_recv;
552 555 rtems_status_code status_send;
553 556 rtems_status_code ret;
554 557 rtems_id queue_id;
555 558
556 559 // create the queue for handling valid TCs
557 560 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
558 561 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
559 562 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
560 563 if ( status_recv != RTEMS_SUCCESSFUL ) {
561 564 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
562 565 }
563 566
564 567 // create the queue for handling TM packet sending
565 568 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
566 569 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
567 570 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
568 571 if ( status_send != RTEMS_SUCCESSFUL ) {
569 572 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
570 573 }
571 574
572 575 if ( status_recv != RTEMS_SUCCESSFUL )
573 576 {
574 577 ret = status_recv;
575 578 }
576 579 else
577 580 {
578 581 ret = status_send;
579 582 }
580 583
581 584 return ret;
582 585 }
583 586
584 587 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
585 588 {
586 589 rtems_status_code status;
587 590 rtems_name queue_name;
588 591
589 592 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
590 593
591 594 status = rtems_message_queue_ident( queue_name, 0, queue_id );
592 595
593 596 return status;
594 597 }
595 598
596 599 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
597 600 {
598 601 rtems_status_code status;
599 602 rtems_name queue_name;
600 603
601 604 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
602 605
603 606 status = rtems_message_queue_ident( queue_name, 0, queue_id );
604 607
605 608 return status;
606 609 }
@@ -1,832 +1,833
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 unsigned char time[6];
35 35 rtems_id queue_rcv_id;
36 36 rtems_id queue_snd_id;
37 37
38 38 status = get_message_queue_id_recv( &queue_rcv_id );
39 39 if (status != RTEMS_SUCCESSFUL)
40 40 {
41 41 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 42 }
43 43
44 44 status = get_message_queue_id_send( &queue_snd_id );
45 45 if (status != RTEMS_SUCCESSFUL)
46 46 {
47 47 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 48 }
49 49
50 50 result = LFR_SUCCESSFUL;
51 51 subtype = 0; // subtype of the current TC packet
52 52
53 53 BOOT_PRINTF("in ACTN *** \n")
54 54
55 55 while(1)
56 56 {
57 57 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 58 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 59 getTime( time ); // set time to the current time
60 60 if (status!=RTEMS_SUCCESSFUL)
61 61 {
62 62 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 63 }
64 64 else
65 65 {
66 66 subtype = TC.serviceSubType;
67 67 switch(subtype)
68 68 {
69 69 case TC_SUBTYPE_RESET:
70 70 result = action_reset( &TC, queue_snd_id, time );
71 71 close_action( &TC, result, queue_snd_id, time );
72 72 break;
73 73 //
74 74 case TC_SUBTYPE_LOAD_COMM:
75 75 result = action_load_common_par( &TC );
76 76 close_action( &TC, result, queue_snd_id, time );
77 77 break;
78 78 //
79 79 case TC_SUBTYPE_LOAD_NORM:
80 80 result = action_load_normal_par( &TC, queue_snd_id, time );
81 81 close_action( &TC, result, queue_snd_id, time );
82 82 break;
83 83 //
84 84 case TC_SUBTYPE_LOAD_BURST:
85 85 result = action_load_burst_par( &TC, queue_snd_id, time );
86 86 close_action( &TC, result, queue_snd_id, time );
87 87 break;
88 88 //
89 89 case TC_SUBTYPE_LOAD_SBM1:
90 90 result = action_load_sbm1_par( &TC, queue_snd_id, time );
91 91 close_action( &TC, result, queue_snd_id, time );
92 92 break;
93 93 //
94 94 case TC_SUBTYPE_LOAD_SBM2:
95 95 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 96 close_action( &TC, result, queue_snd_id, time );
97 97 break;
98 98 //
99 99 case TC_SUBTYPE_DUMP:
100 100 result = action_dump_par( queue_snd_id );
101 101 close_action( &TC, result, queue_snd_id, time );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_ENTER:
105 105 result = action_enter_mode( &TC, queue_snd_id, time );
106 106 close_action( &TC, result, queue_snd_id, time );
107 107 break;
108 108 //
109 109 case TC_SUBTYPE_UPDT_INFO:
110 110 result = action_update_info( &TC, queue_snd_id );
111 111 close_action( &TC, result, queue_snd_id, time );
112 112 break;
113 113 //
114 114 case TC_SUBTYPE_EN_CAL:
115 115 result = action_enable_calibration( &TC, queue_snd_id, time );
116 116 close_action( &TC, result, queue_snd_id, time );
117 117 break;
118 118 //
119 119 case TC_SUBTYPE_DIS_CAL:
120 120 result = action_disable_calibration( &TC, queue_snd_id, time );
121 121 close_action( &TC, result, queue_snd_id, time );
122 122 break;
123 123 //
124 124 case TC_SUBTYPE_UPDT_TIME:
125 125 result = action_update_time( &TC );
126 126 close_action( &TC, result, queue_snd_id, time );
127 127 break;
128 128 //
129 129 default:
130 130 break;
131 131 }
132 132 }
133 133 }
134 134 }
135 135
136 136 //***********
137 137 // TC ACTIONS
138 138
139 139 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 140 {
141 141 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 142 *
143 143 * @param TC points to the TeleCommand packet that is being processed
144 144 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 145 *
146 146 */
147 147
148 148 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
149 149 return LFR_DEFAULT;
150 150 }
151 151
152 152 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
153 153 {
154 154 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
155 155 *
156 156 * @param TC points to the TeleCommand packet that is being processed
157 157 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
158 158 *
159 159 */
160 160
161 161 rtems_status_code status;
162 162 unsigned char requestedMode;
163 163
164 164 requestedMode = TC->dataAndCRC[1];
165 165
166 166 if ( (requestedMode != LFR_MODE_STANDBY)
167 167 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
168 168 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
169 169 {
170 170 status = RTEMS_UNSATISFIED;
171 171 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode, time );
172 172 }
173 173 else
174 174 {
175 printf("try to enter mode %d\n", requestedMode);
175 printf("in action_enter_mode *** enter mode %d\n", requestedMode);
176 176
177 177 #ifdef PRINT_TASK_STATISTICS
178 178 if (requestedMode != LFR_MODE_STANDBY)
179 179 {
180 180 rtems_cpu_usage_reset();
181 181 maxCount = 0;
182 182 }
183 183 #endif
184 184
185 185 status = transition_validation(requestedMode);
186 186
187 187 if ( status == LFR_SUCCESSFUL ) {
188 188 if ( lfrCurrentMode != LFR_MODE_STANDBY)
189 189 {
190 190 status = stop_current_mode();
191 191 }
192 192 if (status != RTEMS_SUCCESSFUL)
193 193 {
194 194 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
195 195 }
196 196 status = enter_mode( requestedMode );
197 197 }
198 198 else
199 199 {
200 200 PRINTF("ERR *** in action_enter *** transition rejected\n")
201 201 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
202 202 }
203 203 }
204 204
205 205 return status;
206 206 }
207 207
208 208 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
209 209 {
210 210 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
211 211 *
212 212 * @param TC points to the TeleCommand packet that is being processed
213 213 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
214 214 *
215 215 * @return LFR directive status code:
216 216 * - LFR_DEFAULT
217 217 * - LFR_SUCCESSFUL
218 218 *
219 219 */
220 220
221 221 unsigned int val;
222 222 int result;
223 223
224 224 result = LFR_SUCCESSFUL;
225 225
226 226 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
227 227 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
228 228 val++;
229 229 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
230 230 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
231 231
232 232 return result;
233 233 }
234 234
235 235 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
236 236 {
237 237 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
238 238 *
239 239 * @param TC points to the TeleCommand packet that is being processed
240 240 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
241 241 *
242 242 */
243 243
244 244 int result;
245 245 unsigned char lfrMode;
246 246
247 247 result = LFR_DEFAULT;
248 248 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
249 249
250 250 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
251 251 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
252 252 result = LFR_DEFAULT;
253 253 }
254 254 else {
255 255 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
256 256 result = LFR_DEFAULT;
257 257 }
258 258 return result;
259 259 }
260 260
261 261 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
262 262 {
263 263 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
264 264 *
265 265 * @param TC points to the TeleCommand packet that is being processed
266 266 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
267 267 *
268 268 */
269 269
270 270 int result;
271 271 unsigned char lfrMode;
272 272
273 273 result = LFR_DEFAULT;
274 274 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
275 275
276 276 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
277 277 send_tm_lfr_tc_exe_not_executable( TC, queue_id, time );
278 278 result = LFR_DEFAULT;
279 279 }
280 280 else {
281 281 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
282 282 result = LFR_DEFAULT;
283 283 }
284 284 return result;
285 285 }
286 286
287 287 int action_update_time(ccsdsTelecommandPacket_t *TC)
288 288 {
289 289 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
290 290 *
291 291 * @param TC points to the TeleCommand packet that is being processed
292 292 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
293 293 *
294 294 * @return LFR_SUCCESSFUL
295 295 *
296 296 */
297 297
298 298 unsigned int val;
299 299
300 300 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
301 301 + (TC->dataAndCRC[1] << 16)
302 302 + (TC->dataAndCRC[2] << 8)
303 303 + TC->dataAndCRC[3];
304 304 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
305 305 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
306 306 val++;
307 307 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
308 308 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
309 309 time_management_regs->ctrl = time_management_regs->ctrl | 1;
310 310
311 311 return LFR_SUCCESSFUL;
312 312 }
313 313
314 314 //*******************
315 315 // ENTERING THE MODES
316 316
317 317 int transition_validation(unsigned char requestedMode)
318 318 {
319 319 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
320 320 *
321 321 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
322 322 *
323 323 * @return LFR directive status codes:
324 324 * - LFR_SUCCESSFUL - the transition is authorized
325 325 * - LFR_DEFAULT - the transition is not authorized
326 326 *
327 327 */
328 328
329 329 int status;
330 330
331 331 switch (requestedMode)
332 332 {
333 333 case LFR_MODE_STANDBY:
334 334 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
335 335 status = LFR_DEFAULT;
336 336 }
337 337 else
338 338 {
339 339 status = LFR_SUCCESSFUL;
340 340 }
341 341 break;
342 342 case LFR_MODE_NORMAL:
343 343 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
344 344 status = LFR_DEFAULT;
345 345 }
346 346 else {
347 347 status = LFR_SUCCESSFUL;
348 348 }
349 349 break;
350 350 case LFR_MODE_BURST:
351 351 if ( lfrCurrentMode == LFR_MODE_BURST ) {
352 352 status = LFR_DEFAULT;
353 353 }
354 354 else {
355 355 status = LFR_SUCCESSFUL;
356 356 }
357 357 break;
358 358 case LFR_MODE_SBM1:
359 359 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
360 360 status = LFR_DEFAULT;
361 361 }
362 362 else {
363 363 status = LFR_SUCCESSFUL;
364 364 }
365 365 break;
366 366 case LFR_MODE_SBM2:
367 367 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
368 368 status = LFR_DEFAULT;
369 369 }
370 370 else {
371 371 status = LFR_SUCCESSFUL;
372 372 }
373 373 break;
374 374 default:
375 375 status = LFR_DEFAULT;
376 376 break;
377 377 }
378 378
379 379 return status;
380 380 }
381 381
382 382 int stop_current_mode()
383 383 {
384 384 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
385 385 *
386 386 * @return RTEMS directive status codes:
387 387 * - RTEMS_SUCCESSFUL - task restarted successfully
388 388 * - RTEMS_INVALID_ID - task id invalid
389 389 * - RTEMS_ALREADY_SUSPENDED - task already suspended
390 390 *
391 391 */
392 392
393 393 rtems_status_code status;
394 394
395 395 status = RTEMS_SUCCESSFUL;
396 396
397 #ifdef GSA
398 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
399 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
400 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
401 #else
402 397 // mask interruptions
403 398 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
404 399 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
405 400 // reset registers
406 401 reset_wfp_burst_enable(); // reset burst and enable bits
407 402 reset_wfp_status(); // reset all the status bits
408 // creal interruptions
403 // clear interruptions
409 404 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
410 405 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
411 #endif
412 406 //**********************
413 407 // suspend several tasks
414 408 if (lfrCurrentMode != LFR_MODE_STANDBY) {
415 409 status = suspend_science_tasks();
416 410 }
417 411
418 412 if (status != RTEMS_SUCCESSFUL)
419 413 {
420 414 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
421 415 }
422 416
423 417 return status;
424 418 }
425 419
426 420 int enter_mode(unsigned char mode )
427 421 {
428 422 /** This function is launched after a mode transition validation.
429 423 *
430 424 * @param mode is the mode in which LFR will be put.
431 425 *
432 426 * @return RTEMS directive status codes:
433 427 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
434 428 * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully
435 429 *
436 430 */
437 431
438 432 rtems_status_code status;
439 433
440 434 status = RTEMS_UNSATISFIED;
441 435
442 436 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
443 437 updateLFRCurrentMode();
444 438
445 439 switch(mode){
446 440 case LFR_MODE_STANDBY:
447 441 status = enter_standby_mode( );
448 442 break;
449 443 case LFR_MODE_NORMAL:
450 444 status = enter_normal_mode( );
451 445 break;
452 446 case LFR_MODE_BURST:
453 447 status = enter_burst_mode( );
454 448 break;
455 449 case LFR_MODE_SBM1:
456 450 status = enter_sbm1_mode( );
457 451 break;
458 452 case LFR_MODE_SBM2:
459 453 status = enter_sbm2_mode( );
460 454 break;
461 455 default:
462 456 status = RTEMS_UNSATISFIED;
463 457 }
464 458
465 459 if (status != RTEMS_SUCCESSFUL)
466 460 {
467 461 PRINTF("in enter_mode *** ERR\n")
468 462 status = RTEMS_UNSATISFIED;
469 463 }
470 464
471 465 return status;
472 466 }
473 467
474 468 int enter_standby_mode()
475 469 {
476 470 /** This function is used to enter the STANDBY mode.
477 471 *
478 472 * @return RTEMS directive status codes:
479 473 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
480 474 *
481 475 */
482 476
483 477 PRINTF1("maxCount = %d\n", maxCount)
484 478
485 479 #ifdef PRINT_TASK_STATISTICS
486 480 rtems_cpu_usage_report();
487 481 #endif
488 482
489 483 #ifdef PRINT_STACK_REPORT
490 484 rtems_stack_checker_report_usage();
491 485 #endif
492 486
493 487 return LFR_SUCCESSFUL;
494 488 }
495 489
496 490 int enter_normal_mode()
497 491 {
498 492 rtems_status_code status;
499 493
500 494 status = restart_science_tasks();
501 495
502 496 #ifdef GSA
503 497 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
504 498 //
505 499 set_local_nb_interrupt_f0_MAX();
506 500 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
507 501 LEON_Unmask_interrupt( IRQ_SM );
508 502 #else
509 503 launch_waveform_picker( LFR_MODE_SBM1 );
510 504 #endif
511 505
512 506 return status;
513 507 }
514 508
515 509 int enter_burst_mode()
516 510 {
517 511 /** This function is used to enter the STANDBY mode.
518 512 *
519 513 * @return RTEMS directive status codes:
520 514 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
521 515 * - RTEMS_INVALID_ID - task id invalid
522 516 * - RTEMS_INCORRECT_STATE - task never started
523 517 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
524 518 *
525 519 */
526 520
527 521 rtems_status_code status;
528 522
529 523 status = restart_science_tasks();
530 524
531 525 launch_waveform_picker( LFR_MODE_BURST );
532 526
533 527 return status;
534 528 }
535 529
536 530 int enter_sbm1_mode()
537 531 {
538 532 /** This function is used to enter the SBM1 mode.
539 533 *
540 534 * @return RTEMS directive status codes:
541 535 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
542 536 * - RTEMS_INVALID_ID - task id invalid
543 537 * - RTEMS_INCORRECT_STATE - task never started
544 538 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
545 539 *
546 540 */
547 541
548 542 rtems_status_code status;
549 543
550 544 status = restart_science_tasks();
551 545
552 546 launch_waveform_picker( LFR_MODE_SBM1 );
553 547
554 548 return status;
555 549 }
556 550
557 551 int enter_sbm2_mode()
558 552 {
559 553 /** This function is used to enter the SBM2 mode.
560 554 *
561 555 * @return RTEMS directive status codes:
562 556 * - RTEMS_SUCCESSFUL - the mode has been entered successfully
563 557 * - RTEMS_INVALID_ID - task id invalid
564 558 * - RTEMS_INCORRECT_STATE - task never started
565 559 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
566 560 *
567 561 */
568 562
569 563 rtems_status_code status;
570 564
571 565 status = restart_science_tasks();
572 566
573 567 launch_waveform_picker( LFR_MODE_SBM2 );
574 568
575 569 return status;
576 570 }
577 571
578 572 int restart_science_tasks()
579 573 {
580 574 /** This function is used to restart all science tasks.
581 575 *
582 576 * @return RTEMS directive status codes:
583 577 * - RTEMS_SUCCESSFUL - task restarted successfully
584 578 * - RTEMS_INVALID_ID - task id invalid
585 579 * - RTEMS_INCORRECT_STATE - task never started
586 580 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
587 581 *
588 582 * Science tasks are AVF0, BPF0, WFRM, CWF3, CW2, CWF1
589 583 *
590 584 */
591 585
592 586 rtems_status_code status[6];
593 587 rtems_status_code ret;
594 588
595 589 ret = RTEMS_SUCCESSFUL;
596 590
597 591 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
598 592 if (status[0] != RTEMS_SUCCESSFUL)
599 593 {
600 594 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
601 595 }
602 596
603 597 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
604 598 if (status[1] != RTEMS_SUCCESSFUL)
605 599 {
606 600 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
607 601 }
608 602
609 603 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
610 604 if (status[2] != RTEMS_SUCCESSFUL)
611 605 {
612 606 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
613 607 }
614 608
615 609 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
616 610 if (status[3] != RTEMS_SUCCESSFUL)
617 611 {
618 612 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
619 613 }
620 614
621 615 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
622 616 if (status[4] != RTEMS_SUCCESSFUL)
623 617 {
624 618 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
625 619 }
626 620
627 621 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
628 622 if (status[5] != RTEMS_SUCCESSFUL)
629 623 {
630 624 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
631 625 }
632 626
633 627 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
634 628 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
635 629 {
636 630 ret = RTEMS_UNSATISFIED;
637 631 }
638 632
639 633 return ret;
640 634 }
641 635
642 636 int suspend_science_tasks()
643 637 {
644 638 /** This function suspends the science tasks.
645 639 *
646 640 * @return RTEMS directive status codes:
647 641 * - RTEMS_SUCCESSFUL - task restarted successfully
648 642 * - RTEMS_INVALID_ID - task id invalid
649 643 * - RTEMS_ALREADY_SUSPENDED - task already suspended
650 644 *
651 645 */
652 646
653 647 rtems_status_code status;
654 648
655 649 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
656 650 if (status != RTEMS_SUCCESSFUL)
657 651 {
658 652 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
659 653 }
660 654
661 655 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
662 656 {
663 657 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
664 658 if (status != RTEMS_SUCCESSFUL)
665 659 {
666 660 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
667 661 }
668 662 }
669 663
670 664 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
671 665 {
672 666 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
673 667 if (status != RTEMS_SUCCESSFUL)
674 668 {
675 669 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
676 670 }
677 671 }
678 672
679 673 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
680 674 {
681 675 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
682 676 if (status != RTEMS_SUCCESSFUL)
683 677 {
684 678 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
685 679 }
686 680 }
687 681
688 682 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
689 683 {
690 684 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
691 685 if (status != RTEMS_SUCCESSFUL)
692 686 {
693 687 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
694 688 }
695 689 }
696 690
697 691 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
698 692 {
699 693 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
700 694 if (status != RTEMS_SUCCESSFUL)
701 695 {
702 696 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
703 697 }
704 698 }
705 699
706 700 return status;
707 701 }
708 702
709 703 void launch_waveform_picker( unsigned char mode )
710 704 {
705 int startDate;
706
711 707 reset_current_ring_nodes();
712 708 reset_waveform_picker_regs();
713 709 set_wfp_burst_enable_register( mode );
714 710 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
715 711 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
712 #ifdef VHDL_DEV
713 startDate = time_management_regs->coarse_time + 2;
714 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
715 waveform_picker_regs->start_date = startDate;
716 #endif
716 717 }
717 718
718 719 //****************
719 720 // CLOSING ACTIONS
720 721 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC, unsigned char *time)
721 722 {
722 723 /** This function is used to update the HK packets statistics after a successful TC execution.
723 724 *
724 725 * @param TC points to the TC being processed
725 726 * @param time is the time used to date the TC execution
726 727 *
727 728 */
728 729
729 730 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
730 731 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
731 732 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
732 733 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
733 734 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
734 735 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
735 736 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
736 737 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
737 738 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
738 739 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
739 740 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
740 741 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
741 742 }
742 743
743 744 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char *time)
744 745 {
745 746 /** This function is used to update the HK packets statistics after a TC rejection.
746 747 *
747 748 * @param TC points to the TC being processed
748 749 * @param time is the time used to date the TC rejection
749 750 *
750 751 */
751 752
752 753 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
753 754 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
754 755 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
755 756 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
756 757 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
757 758 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
758 759 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
759 760 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
760 761 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
761 762 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
762 763 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
763 764 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
764 765 }
765 766
766 767 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id, unsigned char *time)
767 768 {
768 769 /** This function is the last step of the TC execution workflow.
769 770 *
770 771 * @param TC points to the TC being processed
771 772 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
772 773 * @param queue_id is the id of the RTEMS message queue used to send TM packets
773 774 * @param time is the time used to date the TC execution
774 775 *
775 776 */
776 777
777 778 unsigned int val = 0;
778 779
779 780 if (result == LFR_SUCCESSFUL)
780 781 {
781 782 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
782 783 &&
783 784 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
784 785 )
785 786 {
786 787 send_tm_lfr_tc_exe_success( TC, queue_id, time );
787 788 }
788 789 update_last_TC_exe( TC, time );
789 790 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
790 791 val++;
791 792 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
792 793 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
793 794 }
794 795 else
795 796 {
796 797 update_last_TC_rej( TC, time );
797 798 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
798 799 val++;
799 800 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
800 801 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
801 802 }
802 803 }
803 804
804 805 //***************************
805 806 // Interrupt Service Routines
806 807 rtems_isr commutation_isr1( rtems_vector_number vector )
807 808 {
808 809 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
809 810 printf("In commutation_isr1 *** Error sending event to DUMB\n");
810 811 }
811 812 }
812 813
813 814 rtems_isr commutation_isr2( rtems_vector_number vector )
814 815 {
815 816 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
816 817 printf("In commutation_isr2 *** Error sending event to DUMB\n");
817 818 }
818 819 }
819 820
820 821 //****************
821 822 // OTHER FUNCTIONS
822 823 void updateLFRCurrentMode()
823 824 {
824 825 /** This function updates the value of the global variable lfrCurrentMode.
825 826 *
826 827 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
827 828 *
828 829 */
829 830 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
830 831 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
831 832 }
832 833
@@ -1,1146 +1,1146
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 //*****************
13 13 // waveform headers
14 14 // SWF
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
16 16 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
17 17 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
18 18 // CWF
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
22 22 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
23 23 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
24 24
25 25 //**************
26 26 // waveform ring
27 27 ring_node waveform_ring_f1[NB_RING_NODES_F1];
28 28 ring_node waveform_ring_f2[NB_RING_NODES_F2];
29 29 ring_node *current_ring_node_f1;
30 30 ring_node *ring_node_to_send_swf_f1;
31 31 ring_node *ring_node_to_send_cwf_f1;
32 32 ring_node *current_ring_node_f2;
33 33 ring_node *ring_node_to_send_swf_f2;
34 34 ring_node *ring_node_to_send_cwf_f2;
35 35
36 36 unsigned char doubleSendCWF2 = 0;
37 37
38 38 rtems_isr waveforms_isr( rtems_vector_number vector )
39 39 {
40 40 /** This is the interrupt sub routine called by the waveform picker core.
41 41 *
42 42 * This ISR launch different actions depending mainly on two pieces of information:
43 43 * 1. the values read in the registers of the waveform picker.
44 44 * 2. the current LFR mode.
45 45 *
46 46 */
47 47
48 48 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
49 49 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
50 50 { // in modes other than STANDBY and BURST, send the CWF_F3 data
51 51 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
52 52 // (1) change the receiving buffer for the waveform picker
53 53 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
54 54 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_b);
55 55 }
56 56 else {
57 57 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
58 58 }
59 59 // (2) send an event for the waveforms transmission
60 60 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
61 61 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
62 62 }
63 63 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
64 64 }
65 65 }
66 66
67 67 switch(lfrCurrentMode)
68 68 {
69 69 //********
70 70 // STANDBY
71 71 case(LFR_MODE_STANDBY):
72 72 break;
73 73
74 74 //******
75 75 // NORMAL
76 76 case(LFR_MODE_NORMAL):
77 77 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
78 78 // change F1 ring node
79 79 ring_node_to_send_swf_f1 = current_ring_node_f1;
80 80 current_ring_node_f1 = current_ring_node_f1->next;
81 81 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
82 82 // change F2 ring node
83 83 ring_node_to_send_swf_f2 = current_ring_node_f2;
84 84 current_ring_node_f2 = current_ring_node_f2->next;
85 85 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
86 86 // send an event to the WFRM task
87 87 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
88 88 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
89 89 }
90 90 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000]
91 91 }
92 92 break;
93 93
94 94 //******
95 95 // BURST
96 96 case(LFR_MODE_BURST):
97 97 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
98 98 // (1) change the receiving buffer for the waveform picker
99 99 ring_node_to_send_cwf_f2 = current_ring_node_f2;
100 100 current_ring_node_f2 = current_ring_node_f2->next;
101 101 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
102 102 // (2) send an event for the waveforms transmission
103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
104 104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
105 105 }
106 106 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
107 107 }
108 108 break;
109 109
110 110 //*****
111 111 // SBM1
112 112 case(LFR_MODE_SBM1):
113 113 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
114 114 // (1) change the receiving buffer for the waveform picker
115 115 ring_node_to_send_cwf_f1 = current_ring_node_f1;
116 116 current_ring_node_f1 = current_ring_node_f1->next;
117 117 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
118 118 // (2) send an event for the waveforms transmission
119 119 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
120 120 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
121 121 }
122 122 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
123 123 }
124 124 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
125 125 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
126 126 }
127 127 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
128 128 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
129 129 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
130 130 }
131 131 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
132 132 }
133 133 break;
134 134
135 135 //*****
136 136 // SBM2
137 137 case(LFR_MODE_SBM2):
138 138 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
139 139 // (1) change the receiving buffer for the waveform picker
140 140 ring_node_to_send_cwf_f2 = current_ring_node_f2;
141 141 current_ring_node_f2 = current_ring_node_f2->next;
142 142 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
143 143 // (2) send an event for the waveforms transmission
144 144 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
145 145 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
146 146 }
147 147 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
148 148 }
149 149 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
150 150 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
151 151 }
152 152 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
153 153 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
154 154 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
155 155 }
156 156 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
157 157 }
158 158 break;
159 159
160 160 //********
161 161 // DEFAULT
162 162 default:
163 163 break;
164 164 }
165 165 }
166 166
167 167 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
168 168 {
169 169 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
170 170 *
171 171 * @param unused is the starting argument of the RTEMS task
172 172 *
173 173 * The following data packets are sent by this task:
174 174 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
175 175 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
176 176 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
177 177 *
178 178 */
179 179
180 180 rtems_event_set event_out;
181 181 rtems_id queue_id;
182 182 rtems_status_code status;
183 183
184 184 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
185 185 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
186 186 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
187 187
188 188 init_waveforms();
189 189
190 190 status = get_message_queue_id_send( &queue_id );
191 191 if (status != RTEMS_SUCCESSFUL)
192 192 {
193 193 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
194 194 }
195 195
196 196 BOOT_PRINTF("in WFRM ***\n")
197 197
198 198 while(1){
199 199 // wait for an RTEMS_EVENT
200 200 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
201 201 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
202 202 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
203 203 if (event_out == RTEMS_EVENT_MODE_NORMAL)
204 204 {
205 205 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
206 206 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
207 207 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
208 208 }
209 209 else
210 210 {
211 211 PRINTF("in WFRM *** unexpected event")
212 212 }
213 213 }
214 214 }
215 215
216 216 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
217 217 {
218 218 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
219 219 *
220 220 * @param unused is the starting argument of the RTEMS task
221 221 *
222 222 * The following data packet is sent by this task:
223 223 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
224 224 *
225 225 */
226 226
227 227 rtems_event_set event_out;
228 228 rtems_id queue_id;
229 229 rtems_status_code status;
230 230
231 231 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
232 232 init_header_continuous_wf3_light_table( headerCWF_F3_light );
233 233
234 234 status = get_message_queue_id_send( &queue_id );
235 235 if (status != RTEMS_SUCCESSFUL)
236 236 {
237 237 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
238 238 }
239 239
240 240 BOOT_PRINTF("in CWF3 ***\n")
241 241
242 242 while(1){
243 243 // wait for an RTEMS_EVENT
244 244 rtems_event_receive( RTEMS_EVENT_0,
245 245 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
246 246 PRINTF("send CWF F3 \n")
247 247 #ifdef GSA
248 248 #else
249 249 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) {
250 250 send_waveform_CWF3_light( wf_cont_f3_b, headerCWF_F3_light, queue_id );
251 251 }
252 252 else {
253 253 send_waveform_CWF3_light( wf_cont_f3_a, headerCWF_F3_light, queue_id );
254 254 }
255 255 #endif
256 256 }
257 257 }
258 258
259 259 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
260 260 {
261 261 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
262 262 *
263 263 * @param unused is the starting argument of the RTEMS task
264 264 *
265 265 * The following data packet is sent by this function:
266 266 * - TM_LFR_SCIENCE_BURST_CWF_F2
267 267 * - TM_LFR_SCIENCE_SBM2_CWF_F2
268 268 *
269 269 */
270 270
271 271 rtems_event_set event_out;
272 272 rtems_id queue_id;
273 273 rtems_status_code status;
274 274
275 275 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
276 276 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
277 277
278 278 status = get_message_queue_id_send( &queue_id );
279 279 if (status != RTEMS_SUCCESSFUL)
280 280 {
281 281 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
282 282 }
283 283
284 284 BOOT_PRINTF("in CWF2 ***\n")
285 285
286 286 while(1){
287 287 // wait for an RTEMS_EVENT
288 288 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
289 289 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
290 290 if (event_out == RTEMS_EVENT_MODE_BURST)
291 291 {
292 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
292 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
293 293 }
294 294 if (event_out == RTEMS_EVENT_MODE_SBM2)
295 295 {
296 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
296 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
297 297 }
298 298 }
299 299 }
300 300
301 301 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
302 302 {
303 303 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
304 304 *
305 305 * @param unused is the starting argument of the RTEMS task
306 306 *
307 307 * The following data packet is sent by this function:
308 308 * - TM_LFR_SCIENCE_SBM1_CWF_F1
309 309 *
310 310 */
311 311
312 312 rtems_event_set event_out;
313 313 rtems_id queue_id;
314 314 rtems_status_code status;
315 315
316 316 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
317 317
318 318 status = get_message_queue_id_send( &queue_id );
319 319 if (status != RTEMS_SUCCESSFUL)
320 320 {
321 321 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
322 322 }
323 323
324 324 BOOT_PRINTF("in CWF1 ***\n")
325 325
326 326 while(1){
327 327 // wait for an RTEMS_EVENT
328 328 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
329 329 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
330 send_waveform_CWF((volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
330 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
331 331 }
332 332 }
333 333
334 334 //******************
335 335 // general functions
336 336 void init_waveforms( void )
337 337 {
338 338 int i = 0;
339 339
340 340 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
341 341 {
342 342 //***
343 343 // F0
344 344 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
345 345 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
346 346 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
347 347
348 348 //***
349 349 // F1
350 350 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
351 351 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
352 352 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
353 353
354 354 //***
355 355 // F2
356 356 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
357 357 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
358 358 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
359 359
360 360 //***
361 361 // F3
362 362 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
363 363 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
364 364 // wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
365 365 }
366 366 }
367 367
368 368 void init_waveform_rings( void )
369 369 {
370 370 unsigned char i;
371 371
372 372 // F1 RING
373 373 waveform_ring_f1[0].next = (ring_node*) &waveform_ring_f1[1];
374 374 waveform_ring_f1[0].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-1];
375 375 waveform_ring_f1[0].buffer_address = (int) &wf_snap_f1[0][0];
376 376
377 377 waveform_ring_f1[NB_RING_NODES_F1-1].next = (ring_node*) &waveform_ring_f1[0];
378 378 waveform_ring_f1[NB_RING_NODES_F1-1].previous = (ring_node*) &waveform_ring_f1[NB_RING_NODES_F1-2];
379 379 waveform_ring_f1[NB_RING_NODES_F1-1].buffer_address = (int) &wf_snap_f1[NB_RING_NODES_F1-1][0];
380 380
381 381 for(i=1; i<NB_RING_NODES_F1-1; i++)
382 382 {
383 383 waveform_ring_f1[i].next = (ring_node*) &waveform_ring_f1[i+1];
384 384 waveform_ring_f1[i].previous = (ring_node*) &waveform_ring_f1[i-1];
385 385 waveform_ring_f1[i].buffer_address = (int) &wf_snap_f1[i][0];
386 386 }
387 387
388 388 // F2 RING
389 389 waveform_ring_f2[0].next = (ring_node*) &waveform_ring_f2[1];
390 390 waveform_ring_f2[0].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-1];
391 391 waveform_ring_f2[0].buffer_address = (int) &wf_snap_f2[0][0];
392 392
393 393 waveform_ring_f2[NB_RING_NODES_F2-1].next = (ring_node*) &waveform_ring_f2[0];
394 394 waveform_ring_f2[NB_RING_NODES_F2-1].previous = (ring_node*) &waveform_ring_f2[NB_RING_NODES_F2-2];
395 395 waveform_ring_f2[NB_RING_NODES_F2-1].buffer_address = (int) &wf_snap_f2[NB_RING_NODES_F2-1][0];
396 396
397 397 for(i=1; i<NB_RING_NODES_F2-1; i++)
398 398 {
399 399 waveform_ring_f2[i].next = (ring_node*) &waveform_ring_f2[i+1];
400 400 waveform_ring_f2[i].previous = (ring_node*) &waveform_ring_f2[i-1];
401 401 waveform_ring_f2[i].buffer_address = (int) &wf_snap_f2[i][0];
402 402 }
403 403
404 404 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
405 405 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
406 406
407 407 }
408 408
409 409 void reset_current_ring_nodes( void )
410 410 {
411 411 current_ring_node_f1 = waveform_ring_f1;
412 412 ring_node_to_send_cwf_f1 = waveform_ring_f1;
413 413 ring_node_to_send_swf_f1 = waveform_ring_f1;
414 414
415 415 current_ring_node_f2 = waveform_ring_f2;
416 416 ring_node_to_send_cwf_f2 = waveform_ring_f2;
417 417 ring_node_to_send_swf_f2 = waveform_ring_f2;
418 418 }
419 419
420 420 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
421 421 {
422 422 unsigned char i;
423 423
424 424 for (i=0; i<7; i++)
425 425 {
426 426 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
427 427 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
428 428 headerSWF[ i ].reserved = DEFAULT_RESERVED;
429 429 headerSWF[ i ].userApplication = CCSDS_USER_APP;
430 430 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
431 431 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
432 432 if (i == 0)
433 433 {
434 434 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
435 435 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
436 436 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
437 437 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
438 438 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
439 439 }
440 440 else if (i == 6)
441 441 {
442 442 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
443 443 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
444 444 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
445 445 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
446 446 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
447 447 }
448 448 else
449 449 {
450 450 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
451 451 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
452 452 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
453 453 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
454 454 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
455 455 }
456 456 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
457 457 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
458 458 headerSWF[ i ].pktNr = i+1; // PKT_NR
459 459 // DATA FIELD HEADER
460 460 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
461 461 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
462 462 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
463 463 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
464 464 // AUXILIARY DATA HEADER
465 465 headerSWF[ i ].time[0] = 0x00;
466 466 headerSWF[ i ].time[0] = 0x00;
467 467 headerSWF[ i ].time[0] = 0x00;
468 468 headerSWF[ i ].time[0] = 0x00;
469 469 headerSWF[ i ].time[0] = 0x00;
470 470 headerSWF[ i ].time[0] = 0x00;
471 471 headerSWF[ i ].sid = sid;
472 472 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
473 473 }
474 474 return LFR_SUCCESSFUL;
475 475 }
476 476
477 477 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
478 478 {
479 479 unsigned int i;
480 480
481 481 for (i=0; i<7; i++)
482 482 {
483 483 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
484 484 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
485 485 headerCWF[ i ].reserved = DEFAULT_RESERVED;
486 486 headerCWF[ i ].userApplication = CCSDS_USER_APP;
487 487 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
488 488 {
489 489 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
490 490 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
491 491 }
492 492 else
493 493 {
494 494 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
495 495 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
496 496 }
497 497 if (i == 0)
498 498 {
499 499 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
500 500 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
501 501 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
502 502 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
503 503 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
504 504 }
505 505 else if (i == 6)
506 506 {
507 507 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
508 508 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
509 509 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
510 510 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
511 511 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
512 512 }
513 513 else
514 514 {
515 515 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
516 516 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
517 517 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
518 518 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
519 519 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
520 520 }
521 521 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
522 522 // PKT_CNT
523 523 // PKT_NR
524 524 // DATA FIELD HEADER
525 525 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
526 526 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
527 527 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
528 528 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
529 529 // AUXILIARY DATA HEADER
530 530 headerCWF[ i ].sid = sid;
531 531 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
532 532 headerCWF[ i ].time[0] = 0x00;
533 533 headerCWF[ i ].time[0] = 0x00;
534 534 headerCWF[ i ].time[0] = 0x00;
535 535 headerCWF[ i ].time[0] = 0x00;
536 536 headerCWF[ i ].time[0] = 0x00;
537 537 headerCWF[ i ].time[0] = 0x00;
538 538 }
539 539 return LFR_SUCCESSFUL;
540 540 }
541 541
542 542 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
543 543 {
544 544 unsigned int i;
545 545
546 546 for (i=0; i<7; i++)
547 547 {
548 548 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
549 549 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
550 550 headerCWF[ i ].reserved = DEFAULT_RESERVED;
551 551 headerCWF[ i ].userApplication = CCSDS_USER_APP;
552 552
553 553 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
554 554 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
555 555 if (i == 0)
556 556 {
557 557 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
558 558 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
559 559 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
560 560 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
561 561 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
562 562 }
563 563 else if (i == 6)
564 564 {
565 565 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
566 566 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
567 567 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
568 568 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
569 569 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
570 570 }
571 571 else
572 572 {
573 573 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
574 574 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
575 575 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
576 576 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
577 577 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
578 578 }
579 579 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
580 580 // DATA FIELD HEADER
581 581 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
582 582 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
583 583 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
584 584 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
585 585 // AUXILIARY DATA HEADER
586 586 headerCWF[ i ].sid = SID_NORM_CWF_F3;
587 587 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
588 588 headerCWF[ i ].time[0] = 0x00;
589 589 headerCWF[ i ].time[0] = 0x00;
590 590 headerCWF[ i ].time[0] = 0x00;
591 591 headerCWF[ i ].time[0] = 0x00;
592 592 headerCWF[ i ].time[0] = 0x00;
593 593 headerCWF[ i ].time[0] = 0x00;
594 594 }
595 595 return LFR_SUCCESSFUL;
596 596 }
597 597
598 598 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
599 599 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
600 600 {
601 601 /** This function sends SWF CCSDS packets (F2, F1 or F0).
602 602 *
603 603 * @param waveform points to the buffer containing the data that will be send.
604 604 * @param sid is the source identifier of the data that will be sent.
605 605 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
606 606 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
607 607 * contain information to setup the transmission of the data packets.
608 608 *
609 609 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
610 610 *
611 611 */
612 612
613 613 unsigned int i;
614 614 int ret;
615 615 rtems_status_code status;
616 616 spw_ioctl_pkt_send spw_ioctl_send_SWF;
617 617
618 618 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
619 619 spw_ioctl_send_SWF.options = 0;
620 620
621 621 ret = LFR_DEFAULT;
622 622
623 623 for (i=0; i<7; i++) // send waveform
624 624 {
625 625 #ifdef VHDL_DEV
626 626 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
627 627 #else
628 628 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
629 629 #endif
630 630 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
631 631 // BUILD THE DATA
632 632 if (i==6) {
633 633 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
634 634 }
635 635 else {
636 636 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
637 637 }
638 638 // SET PACKET SEQUENCE COUNTER
639 639 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
640 640 // SET PACKET TIME
641 641 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
642 642 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
643 643 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
644 644 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
645 645 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
646 646 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
647 647 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
648 648 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
649 649 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
650 650 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
651 651 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
652 652 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
653 653 // SEND PACKET
654 654 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
655 655 if (status != RTEMS_SUCCESSFUL) {
656 656 printf("%d-%d, ERR %d\n", sid, i, (int) status);
657 657 ret = LFR_DEFAULT;
658 658 }
659 659 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
660 660 }
661 661
662 662 return ret;
663 663 }
664 664
665 665 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
666 666 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
667 667 {
668 668 /** This function sends CWF CCSDS packets (F2, F1 or F0).
669 669 *
670 670 * @param waveform points to the buffer containing the data that will be send.
671 671 * @param sid is the source identifier of the data that will be sent.
672 672 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
673 673 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
674 674 * contain information to setup the transmission of the data packets.
675 675 *
676 676 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
677 677 *
678 678 */
679 679
680 680 unsigned int i;
681 681 int ret;
682 682 rtems_status_code status;
683 683 spw_ioctl_pkt_send spw_ioctl_send_CWF;
684 684
685 685 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
686 686 spw_ioctl_send_CWF.options = 0;
687 687
688 688 ret = LFR_DEFAULT;
689 689
690 690 for (i=0; i<7; i++) // send waveform
691 691 {
692 692 int coarseTime = 0x00;
693 693 int fineTime = 0x00;
694 694 #ifdef VHDL_DEV
695 695 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + TIME_OFFSET];
696 696 #else
697 697 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
698 698 #endif
699 699 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
700 700 // BUILD THE DATA
701 701 if (i==6) {
702 702 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
703 703 }
704 704 else {
705 705 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
706 706 }
707 707 // SET PACKET SEQUENCE COUNTER
708 708 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
709 709 // SET PACKET TIME
710 710 coarseTime = time_management_regs->coarse_time;
711 711 fineTime = time_management_regs->fine_time;
712 712 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
713 713 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
714 714 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
715 715 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
716 716 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
717 717 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
718 718 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
719 719 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
720 720 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
721 721 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
722 722 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
723 723 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
724 724 // SEND PACKET
725 725 if (sid == SID_NORM_CWF_F3)
726 726 {
727 727 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
728 728 if (status != RTEMS_SUCCESSFUL) {
729 729 printf("%d-%d, ERR %d\n", sid, i, (int) status);
730 730 ret = LFR_DEFAULT;
731 731 }
732 732 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
733 733 }
734 734 else
735 735 {
736 736 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
737 737 if (status != RTEMS_SUCCESSFUL) {
738 738 printf("%d-%d, ERR %d\n", sid, i, (int) status);
739 739 ret = LFR_DEFAULT;
740 740 }
741 741 }
742 742 }
743 743
744 744 return ret;
745 745 }
746 746
747 747 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
748 748 {
749 749 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
750 750 *
751 751 * @param waveform points to the buffer containing the data that will be send.
752 752 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
753 753 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
754 754 * contain information to setup the transmission of the data packets.
755 755 *
756 756 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
757 757 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
758 758 *
759 759 */
760 760
761 761 unsigned int i;
762 762 int ret;
763 763 rtems_status_code status;
764 764 spw_ioctl_pkt_send spw_ioctl_send_CWF;
765 765 char *sample;
766 766
767 767 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
768 768 spw_ioctl_send_CWF.options = 0;
769 769
770 770 ret = LFR_DEFAULT;
771 771
772 772 //**********************
773 773 // BUILD CWF3_light DATA
774 774 for ( i=0; i< 2048; i++)
775 775 {
776 776 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
777 777 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
778 778 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
779 779 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
780 780 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
781 781 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
782 782 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
783 783 }
784 784
785 785 //*********************
786 786 // SEND CWF3_light DATA
787 787
788 788 for (i=0; i<7; i++) // send waveform
789 789 {
790 790 int coarseTime = 0x00;
791 791 int fineTime = 0x00;
792 792 #ifdef VHDL_DEV
793 793 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET];
794 794 #else
795 795 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
796 796 #endif
797 797 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
798 798 // BUILD THE DATA
799 799 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
800 800 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
801 801 }
802 802 else {
803 803 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
804 804 }
805 805 // SET PACKET SEQUENCE COUNTER
806 806 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
807 807 // SET PACKET TIME
808 808 coarseTime = time_management_regs->coarse_time;
809 809 fineTime = time_management_regs->fine_time;
810 810 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
811 811 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
812 812 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
813 813 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
814 814 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
815 815 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
816 816 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
817 817 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
818 818 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
819 819 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
820 820 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
821 821 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
822 822 // SEND PACKET
823 823 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
824 824 if (status != RTEMS_SUCCESSFUL) {
825 825 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
826 826 ret = LFR_DEFAULT;
827 827 }
828 828 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
829 829 }
830 830
831 831 return ret;
832 832 }
833 833
834 834
835 835 //**************
836 836 // wfp registers
837 837 void set_wfp_data_shaping()
838 838 {
839 839 /** This function sets the data_shaping register of the waveform picker module.
840 840 *
841 841 * The value is read from one field of the parameter_dump_packet structure:\n
842 842 * bw_sp0_sp1_r0_r1
843 843 *
844 844 */
845 845
846 846 unsigned char data_shaping;
847 847
848 848 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
849 849 // waveform picker : [R1 R0 SP1 SP0 BW]
850 850
851 851 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
852 852
853 853 #ifdef GSA
854 854 #else
855 855 waveform_picker_regs->data_shaping =
856 856 ( (data_shaping & 0x10) >> 4 ) // BW
857 857 + ( (data_shaping & 0x08) >> 2 ) // SP0
858 858 + ( (data_shaping & 0x04) ) // SP1
859 859 + ( (data_shaping & 0x02) << 2 ) // R0
860 860 + ( (data_shaping & 0x01) << 4 ); // R1
861 861 #endif
862 862 }
863 863
864 864 char set_wfp_delta_snapshot()
865 865 {
866 866 /** This function sets the delta_snapshot register of the waveform picker module.
867 867 *
868 868 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
869 869 * - sy_lfr_n_swf_p[0]
870 870 * - sy_lfr_n_swf_p[1]
871 871 *
872 872 */
873 873
874 874 char ret;
875 875 unsigned int delta_snapshot;
876 876 unsigned int aux;
877 877
878 878 aux = 0;
879 879 ret = LFR_DEFAULT;
880 880
881 881 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
882 882 + parameter_dump_packet.sy_lfr_n_swf_p[1];
883 883
884 884 #ifdef GSA
885 885 #else
886 886 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
887 887 {
888 888 aux = MIN_DELTA_SNAPSHOT;
889 889 ret = LFR_DEFAULT;
890 890 }
891 891 else
892 892 {
893 893 aux = delta_snapshot ;
894 894 ret = LFR_SUCCESSFUL;
895 895 }
896 896 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
897 897 #endif
898 898
899 899 return ret;
900 900 }
901 901
902 902 #ifdef VHDL_DEV
903 903 void set_wfp_burst_enable_register( unsigned char mode )
904 904 {
905 905 /** This function sets the waveform picker burst_enable register depending on the mode.
906 906 *
907 907 * @param mode is the LFR mode to launch.
908 908 *
909 909 * The burst bits shall be before the enable bits.
910 910 *
911 911 */
912 912
913 913 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
914 914 // the burst bits shall be set first, before the enable bits
915 915 switch(mode) {
916 916 case(LFR_MODE_NORMAL):
917 917 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
918 918 waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
919 919 break;
920 920 case(LFR_MODE_BURST):
921 921 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
922 922 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
923 923 break;
924 924 case(LFR_MODE_SBM1):
925 925 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
926 926 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
927 927 break;
928 928 case(LFR_MODE_SBM2):
929 929 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
930 930 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
931 931 break;
932 932 default:
933 933 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
934 934 break;
935 935 }
936 936 }
937 937 #else
938 938 void set_wfp_burst_enable_register( unsigned char mode )
939 939 {
940 940 /** This function sets the waveform picker burst_enable register depending on the mode.
941 941 *
942 942 * @param mode is the LFR mode to launch.
943 943 *
944 944 * The burst bits shall be before the enable bits.
945 945 *
946 946 */
947 947
948 948 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
949 949 // the burst bits shall be set first, before the enable bits
950 950 switch(mode) {
951 951 case(LFR_MODE_NORMAL):
952 952 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
953 953 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
954 954 break;
955 955 case(LFR_MODE_BURST):
956 956 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
957 957 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
958 958 break;
959 959 case(LFR_MODE_SBM1):
960 960 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
961 961 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
962 962 break;
963 963 case(LFR_MODE_SBM2):
964 964 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
965 965 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
966 966 break;
967 967 default:
968 968 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
969 969 break;
970 970 }
971 971 }
972 972 #endif
973 973
974 974 void reset_wfp_burst_enable()
975 975 {
976 976 /** This function resets the waveform picker burst_enable register.
977 977 *
978 978 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
979 979 *
980 980 */
981 981
982 982 #ifdef VHDL_DEV
983 983 waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
984 984 #else
985 985 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
986 986 #endif
987 987 }
988 988
989 989 void reset_wfp_status()
990 990 {
991 991 /** This function resets the waveform picker status register.
992 992 *
993 993 * All status bits are set to 0 [new_err full_err full].
994 994 *
995 995 */
996 996
997 997 #ifdef GSA
998 998 #else
999 999 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1000 1000 #endif
1001 1001 }
1002 1002
1003 1003 #ifdef VHDL_DEV
1004 1004 void reset_waveform_picker_regs()
1005 1005 {
1006 1006 /** This function resets the waveform picker module registers.
1007 1007 *
1008 1008 * The registers affected by this function are located at the following offset addresses:
1009 1009 * - 0x00 data_shaping
1010 1010 * - 0x04 run_burst_enable
1011 1011 * - 0x08 addr_data_f0
1012 1012 * - 0x0C addr_data_f1
1013 1013 * - 0x10 addr_data_f2
1014 1014 * - 0x14 addr_data_f3
1015 1015 * - 0x18 status
1016 1016 * - 0x1C delta_snapshot
1017 1017 * - 0x20 delta_f0
1018 1018 * - 0x24 delta_f0_2
1019 1019 * - 0x28 delta_f1
1020 1020 * - 0x2c delta_f2
1021 1021 * - 0x30 nb_data_by_buffer
1022 1022 * - 0x34 nb_snapshot_param
1023 1023 * - 0x38 start_date
1024 1024 * - 0x3c nb_word_in_buffer
1025 1025 *
1026 1026 */
1027 1027 waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1028 1028 waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1029 1029 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1030 1030 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address; // 0x0c
1031 1031 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10
1032 1032 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14
1033 1033 waveform_picker_regs->status = 0x00; // 0x18
1034 1034 // waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776
1035 1035 // waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1036 1036 waveform_picker_regs->delta_snapshot = 0x2000; // 0x1c 32 * 256 = 8192
1037 1037 waveform_picker_regs->delta_f0 = 0xbf5; // 0x20 *** 1013
1038 1038 waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 [7 bits]
1039 1039 waveform_picker_regs->delta_f1 = 0xbc0; // 0x28 *** 960
1040 1040 // waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 290 * 256 = 74240
1041 1041 waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 3072
1042 1042 waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1 => nb samples -1
1043 1043 waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048 => nb samples
1044 1044 waveform_picker_regs->start_date = 0x00; // 0x38
1045 1045 waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146
1046 1046 }
1047 1047 #else
1048 1048 void reset_waveform_picker_regs()
1049 1049 {
1050 1050 /** This function resets the waveform picker module registers.
1051 1051 *
1052 1052 * The registers affected by this function are located at the following offset addresses:
1053 1053 * - 0x00 data_shaping
1054 1054 * - 0x04 burst_enable
1055 1055 * - 0x08 addr_data_f0
1056 1056 * - 0x0C addr_data_f1
1057 1057 * - 0x10 addr_data_f2
1058 1058 * - 0x14 addr_data_f3
1059 1059 * - 0x18 status
1060 1060 * - 0x1C delta_snapshot
1061 1061 * - 0x20 delta_f2_f1
1062 1062 * - 0x24 delta_f2_f0
1063 1063 * - 0x28 nb_burst
1064 1064 * - 0x2C nb_snapshot
1065 1065 *
1066 1066 */
1067 1067
1068 1068 reset_wfp_burst_enable();
1069 1069 reset_wfp_status();
1070 1070 // set buffer addresses
1071 1071 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0);
1072 1072 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
1073 1073 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
1074 1074 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a);
1075 1075 // set other parameters
1076 1076 set_wfp_data_shaping();
1077 1077 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1078 1078 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1079 1079 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1080 1080 // waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1081 1081 // // 3 * 2048 / 16 = 384
1082 1082 // waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1083 1083 waveform_picker_regs->nb_burst_available = 0x1b9; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1084 1084 // 3 * 2352 / 16 = 441
1085 1085 waveform_picker_regs->nb_snapshot_param = 0x944; // max 3 octets, 2372 - 1
1086 1086 }
1087 1087 #endif
1088 1088
1089 1089 //*****************
1090 1090 // local parameters
1091 1091 void set_local_nb_interrupt_f0_MAX( void )
1092 1092 {
1093 1093 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1094 1094 *
1095 1095 * This parameter is used for the SM validation only.\n
1096 1096 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1097 1097 * module before launching a basic processing.
1098 1098 *
1099 1099 */
1100 1100
1101 1101 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1102 1102 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1103 1103 }
1104 1104
1105 1105 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1106 1106 {
1107 1107 unsigned short *sequence_cnt;
1108 1108 unsigned short segmentation_grouping_flag;
1109 1109 unsigned short new_packet_sequence_control;
1110 1110
1111 1111 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1112 1112 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1113 1113 {
1114 1114 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1115 1115 }
1116 1116 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1117 1117 {
1118 1118 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1119 1119 }
1120 1120 else
1121 1121 {
1122 1122 sequence_cnt = NULL;
1123 1123 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1124 1124 }
1125 1125
1126 1126 if (sequence_cnt != NULL)
1127 1127 {
1128 1128 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1129 1129 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1130 1130
1131 1131 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1132 1132
1133 1133 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1134 1134 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1135 1135
1136 1136 // increment the sequence counter for the next packet
1137 1137 if ( *sequence_cnt < SEQ_CNT_MAX)
1138 1138 {
1139 1139 *sequence_cnt = *sequence_cnt + 1;
1140 1140 }
1141 1141 else
1142 1142 {
1143 1143 *sequence_cnt = 0;
1144 1144 }
1145 1145 }
1146 1146 }
General Comments 0
You need to be logged in to leave comments. Login now