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