##// END OF EJS Templates
A few changes to debug the VHDL design update
paul -
r83:e32329954fdb nov2013
parent child
Show More
@@ -1,248 +1,248
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Nov 15 07:19:44 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Nov 19 13:58:57 2013
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=22 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=22 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_processing.c \
49 49 ../src/fsw_misc.c \
50 50 ../src/fsw_init.c \
51 51 ../src/fsw_globals.c \
52 52 ../src/fsw_spacewire.c \
53 53 ../src/tc_load_dump_parameters.c \
54 54 ../src/tm_lfr_tc_exe.c \
55 55 ../src/tc_acceptance.c
56 56 OBJECTS = obj/wf_handler.o \
57 57 obj/tc_handler.o \
58 58 obj/fsw_processing.o \
59 59 obj/fsw_misc.o \
60 60 obj/fsw_init.o \
61 61 obj/fsw_globals.o \
62 62 obj/fsw_spacewire.o \
63 63 obj/tc_load_dump_parameters.o \
64 64 obj/tm_lfr_tc_exe.o \
65 65 obj/tc_acceptance.o
66 66 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
67 67 /usr/lib64/qt4/mkspecs/common/linux.conf \
68 68 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
69 69 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
70 70 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
71 71 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
72 72 /usr/lib64/qt4/mkspecs/qconfig.pri \
73 73 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
74 74 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
75 75 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
76 76 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
77 77 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
78 78 sparc.pri \
79 79 /usr/lib64/qt4/mkspecs/features/release.prf \
80 80 /usr/lib64/qt4/mkspecs/features/default_post.prf \
81 81 /usr/lib64/qt4/mkspecs/features/shared.prf \
82 82 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
83 83 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
84 84 /usr/lib64/qt4/mkspecs/features/resources.prf \
85 85 /usr/lib64/qt4/mkspecs/features/uic.prf \
86 86 /usr/lib64/qt4/mkspecs/features/yacc.prf \
87 87 /usr/lib64/qt4/mkspecs/features/lex.prf \
88 88 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
89 89 fsw-qt.pro
90 90 QMAKE_TARGET = fsw
91 91 DESTDIR = bin/
92 92 TARGET = bin/fsw
93 93
94 94 first: all
95 95 ####### Implicit rules
96 96
97 97 .SUFFIXES: .o .c .cpp .cc .cxx .C
98 98
99 99 .cpp.o:
100 100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101 101
102 102 .cc.o:
103 103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
104 104
105 105 .cxx.o:
106 106 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
107 107
108 108 .C.o:
109 109 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
110 110
111 111 .c.o:
112 112 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
113 113
114 114 ####### Build rules
115 115
116 116 all: Makefile $(TARGET)
117 117
118 118 $(TARGET): $(OBJECTS)
119 119 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
120 120 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
121 121
122 122 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
123 123 /usr/lib64/qt4/mkspecs/common/linux.conf \
124 124 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
125 125 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
126 126 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
127 127 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
128 128 /usr/lib64/qt4/mkspecs/qconfig.pri \
129 129 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
130 130 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
131 131 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
132 132 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
133 133 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
134 134 sparc.pri \
135 135 /usr/lib64/qt4/mkspecs/features/release.prf \
136 136 /usr/lib64/qt4/mkspecs/features/default_post.prf \
137 137 /usr/lib64/qt4/mkspecs/features/shared.prf \
138 138 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
139 139 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
140 140 /usr/lib64/qt4/mkspecs/features/resources.prf \
141 141 /usr/lib64/qt4/mkspecs/features/uic.prf \
142 142 /usr/lib64/qt4/mkspecs/features/yacc.prf \
143 143 /usr/lib64/qt4/mkspecs/features/lex.prf \
144 144 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
145 145 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
146 146 /usr/lib64/qt4/mkspecs/common/unix.conf:
147 147 /usr/lib64/qt4/mkspecs/common/linux.conf:
148 148 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
149 149 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
150 150 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
151 151 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
152 152 /usr/lib64/qt4/mkspecs/qconfig.pri:
153 153 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
154 154 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
155 155 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
156 156 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
157 157 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
158 158 sparc.pri:
159 159 /usr/lib64/qt4/mkspecs/features/release.prf:
160 160 /usr/lib64/qt4/mkspecs/features/default_post.prf:
161 161 /usr/lib64/qt4/mkspecs/features/shared.prf:
162 162 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
163 163 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
164 164 /usr/lib64/qt4/mkspecs/features/resources.prf:
165 165 /usr/lib64/qt4/mkspecs/features/uic.prf:
166 166 /usr/lib64/qt4/mkspecs/features/yacc.prf:
167 167 /usr/lib64/qt4/mkspecs/features/lex.prf:
168 168 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
169 169 qmake: FORCE
170 170 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
171 171
172 172 dist:
173 173 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
174 174 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
175 175
176 176
177 177 clean:compiler_clean
178 178 -$(DEL_FILE) $(OBJECTS)
179 179 -$(DEL_FILE) *~ core *.core
180 180
181 181
182 182 ####### Sub-libraries
183 183
184 184 distclean: clean
185 185 -$(DEL_FILE) $(TARGET)
186 186 -$(DEL_FILE) Makefile
187 187
188 188
189 189 grmon:
190 190 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
191 191
192 192 check: first
193 193
194 194 compiler_rcc_make_all:
195 195 compiler_rcc_clean:
196 196 compiler_uic_make_all:
197 197 compiler_uic_clean:
198 198 compiler_image_collection_make_all: qmake_image_collection.cpp
199 199 compiler_image_collection_clean:
200 200 -$(DEL_FILE) qmake_image_collection.cpp
201 201 compiler_yacc_decl_make_all:
202 202 compiler_yacc_decl_clean:
203 203 compiler_yacc_impl_make_all:
204 204 compiler_yacc_impl_clean:
205 205 compiler_lex_make_all:
206 206 compiler_lex_clean:
207 207 compiler_clean:
208 208
209 209 ####### Compile
210 210
211 211 obj/wf_handler.o: ../src/wf_handler.c
212 212 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
213 213
214 214 obj/tc_handler.o: ../src/tc_handler.c
215 215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
216 216
217 217 obj/fsw_processing.o: ../src/fsw_processing.c ../src/fsw_processing_globals.c
218 218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
219 219
220 220 obj/fsw_misc.o: ../src/fsw_misc.c
221 221 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
222 222
223 223 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
224 224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
225 225
226 226 obj/fsw_globals.o: ../src/fsw_globals.c
227 227 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
228 228
229 229 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
230 230 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
231 231
232 232 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
233 233 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
234 234
235 235 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
236 236 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
237 237
238 238 obj/tc_acceptance.o: ../src/tc_acceptance.c
239 239 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
240 240
241 241 ####### Install
242 242
243 243 install: FORCE
244 244
245 245 uninstall: FORCE
246 246
247 247 FORCE:
248 248
@@ -1,78 +1,78
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
4 CONFIG += console verbose cpu_usage_report
4 CONFIG += console verbose
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 10 SWVERSION=-0-22
11 11 DEFINES += SW_VERSION_N1=0
12 12 DEFINES += SW_VERSION_N2=0
13 13 DEFINES += SW_VERSION_N3=0
14 14 DEFINES += SW_VERSION_N4=22
15 15
16 16 contains( CONFIG, verbose ) {
17 17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 18 }
19 19
20 20 contains( CONFIG, debug_messages ) {
21 21 DEFINES += DEBUG_MESSAGES
22 22 }
23 23
24 24 contains( CONFIG, cpu_usage_report ) {
25 25 DEFINES += PRINT_TASK_STATISTICS
26 26 }
27 27
28 28 contains( CONFIG, stack_report ) {
29 29 DEFINES += PRINT_STACK_REPORT
30 30 }
31 31
32 32 contains( CONFIG, boot_messages ) {
33 33 DEFINES += BOOT_MESSAGES
34 34 }
35 35
36 36 #doxygen.target = doxygen
37 37 #doxygen.commands = doxygen ../doc/Doxyfile
38 38 #QMAKE_EXTRA_TARGETS += doxygen
39 39
40 40 TARGET = fsw
41 41 contains( CONFIG, gsa ) {
42 42 DEFINES += GSA
43 43 TARGET = fsw-gsa
44 44 }
45 45
46 46 INCLUDEPATH += \
47 47 ../src \
48 48 ../header
49 49
50 50 SOURCES += \
51 51 ../src/wf_handler.c \
52 52 ../src/tc_handler.c \
53 53 ../src/fsw_processing.c \
54 54 ../src/fsw_misc.c \
55 55 ../src/fsw_init.c \
56 56 ../src/fsw_globals.c \
57 57 ../src/fsw_spacewire.c \
58 58 ../src/tc_load_dump_parameters.c \
59 59 ../src/tm_lfr_tc_exe.c \
60 60 ../src/tc_acceptance.c
61 61
62 62
63 63 HEADERS += \
64 64 ../header/wf_handler.h \
65 65 ../header/tc_handler.h \
66 66 ../header/grlib_regs.h \
67 67 ../header/fsw_processing.h \
68 68 ../header/fsw_params.h \
69 69 ../header/fsw_misc.h \
70 70 ../header/fsw_init.h \
71 71 ../header/ccsds_types.h \
72 72 ../header/fsw_params_processing.h \
73 73 ../header/fsw_spacewire.h \
74 74 ../header/tm_byte_positions.h \
75 75 ../header/tc_load_dump_parameters.h \
76 76 ../header/tm_lfr_tc_exe.h \
77 77 ../header/tc_acceptance.h
78 78
@@ -1,305 +1,305
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.1, 2013-11-15T16:54:28. -->
3 <!-- Written by QtCreator 2.8.1, 2013-11-21T16:57:00. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 7 <value type="int">0</value>
8 8 </data>
9 9 <data>
10 10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 11 <valuemap type="QVariantMap">
12 12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 16 <value type="QString" key="language">Cpp</value>
17 17 <valuemap type="QVariantMap" key="value">
18 18 <value type="QString" key="CurrentPreferences">CppGlobal</value>
19 19 </valuemap>
20 20 </valuemap>
21 21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 22 <value type="QString" key="language">QmlJS</value>
23 23 <valuemap type="QVariantMap" key="value">
24 24 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
25 25 </valuemap>
26 26 </valuemap>
27 27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 28 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
29 29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 45 </valuemap>
46 46 </data>
47 47 <data>
48 48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 49 <valuemap type="QVariantMap"/>
50 50 </data>
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
63 63 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
64 64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
65 65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
66 66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
67 67 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
69 69 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
70 70 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
71 71 </valuemap>
72 72 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
73 73 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
74 74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
75 75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
76 76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
77 77 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
78 78 <value type="QString">-w</value>
79 79 <value type="QString">-r</value>
80 80 </valuelist>
81 81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w -j 4</value>
83 83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 84 </valuemap>
85 85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
86 86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88 88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
89 89 </valuemap>
90 90 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
91 91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
92 92 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
93 93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
96 96 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
97 97 <value type="QString">-w</value>
98 98 <value type="QString">-r</value>
99 99 </valuelist>
100 100 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
101 101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
102 102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
103 103 </valuemap>
104 104 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
105 105 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
106 106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
107 107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
108 108 </valuemap>
109 109 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
110 110 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
111 111 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
112 112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
115 115 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
116 116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
117 117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 118 </valuemap>
119 119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
122 122 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
124 124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
126 126 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
127 127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
128 128 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
129 129 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
130 130 </valuemap>
131 131 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
132 132 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
133 133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
134 134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
136 136 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
137 137 <value type="QString">-w</value>
138 138 <value type="QString">-r</value>
139 139 </valuelist>
140 140 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
141 141 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
142 142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
143 143 </valuemap>
144 144 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
145 145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
146 146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
147 147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
148 148 </valuemap>
149 149 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
150 150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
151 151 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
152 152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
153 153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
154 154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
155 155 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
156 156 <value type="QString">-w</value>
157 157 <value type="QString">-r</value>
158 158 </valuelist>
159 159 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
160 160 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
161 161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
162 162 </valuemap>
163 163 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
164 164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
165 165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
166 166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
167 167 </valuemap>
168 168 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
169 169 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
170 170 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
171 171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
172 172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
174 174 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
175 175 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
176 176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
177 177 </valuemap>
178 178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
179 179 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180 180 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181 181 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182 182 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183 183 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184 184 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185 185 </valuemap>
186 186 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187 187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
188 188 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
189 189 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
190 190 </valuemap>
191 191 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
192 192 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
193 193 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
194 194 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
195 195 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
196 196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
197 197 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
198 198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
199 199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
200 200 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
201 201 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
202 202 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
203 203 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
204 204 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205 205 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206 206 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
207 207 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
208 208 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
209 209 <value type="int">0</value>
210 210 <value type="int">1</value>
211 211 <value type="int">2</value>
212 212 <value type="int">3</value>
213 213 <value type="int">4</value>
214 214 <value type="int">5</value>
215 215 <value type="int">6</value>
216 216 <value type="int">7</value>
217 217 <value type="int">8</value>
218 218 <value type="int">9</value>
219 219 <value type="int">10</value>
220 220 <value type="int">11</value>
221 221 <value type="int">12</value>
222 222 <value type="int">13</value>
223 223 <value type="int">14</value>
224 224 </valuelist>
225 225 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
226 226 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
227 227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
228 228 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
229 229 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
230 230 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
231 231 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
232 232 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
233 233 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
234 234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
235 235 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
236 236 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
237 237 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
238 238 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
239 239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240 240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
241 241 </valuemap>
242 242 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
243 243 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
244 244 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
245 245 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
246 246 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
247 247 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
248 248 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
249 249 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
250 250 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
251 251 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
252 252 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
253 253 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
254 254 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
255 255 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
256 256 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
257 257 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
258 258 <value type="int">0</value>
259 259 <value type="int">1</value>
260 260 <value type="int">2</value>
261 261 <value type="int">3</value>
262 262 <value type="int">4</value>
263 263 <value type="int">5</value>
264 264 <value type="int">6</value>
265 265 <value type="int">7</value>
266 266 <value type="int">8</value>
267 267 <value type="int">9</value>
268 268 <value type="int">10</value>
269 269 <value type="int">11</value>
270 270 <value type="int">12</value>
271 271 <value type="int">13</value>
272 272 <value type="int">14</value>
273 273 </valuelist>
274 274 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
275 275 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
276 276 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
277 277 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">doxygen</value>
278 278 <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">true</value>
279 279 <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/opt/DEV_PLE/doc</value>
280 280 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run doxygen</value>
281 281 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
282 282 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
283 283 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
284 284 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
285 285 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
286 286 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
287 287 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
288 288 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
289 289 </valuemap>
290 290 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
291 291 </valuemap>
292 292 </data>
293 293 <data>
294 294 <variable>ProjectExplorer.Project.TargetCount</variable>
295 295 <value type="int">1</value>
296 296 </data>
297 297 <data>
298 298 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
299 299 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
300 300 </data>
301 301 <data>
302 302 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
303 303 <value type="int">14</value>
304 304 </data>
305 305 </qtcreator>
@@ -1,211 +1,212
1 1 #ifndef FSW_PARAMS_H_INCLUDED
2 2 #define FSW_PARAMS_H_INCLUDED
3 3
4 4 #include "grlib_regs.h"
5 5 #include "fsw_params_processing.h"
6 6 #include "tm_byte_positions.h"
7 7 #include "ccsds_types.h"
8 8
9 9 #define GRSPW_DEVICE_NAME "/dev/grspw0"
10 10 #define UART_DEVICE_NAME "/dev/console"
11 11
12 12 //************************
13 13 // flight software version
14 14 // this parameters is handled by the Qt project options
15 15
16 16 //**********
17 17 // LFR MODES
18 18 #define LFR_MODE_STANDBY 0
19 19 #define LFR_MODE_NORMAL 1
20 20 #define LFR_MODE_BURST 2
21 21 #define LFR_MODE_SBM1 3
22 22 #define LFR_MODE_SBM2 4
23 23 #define LFR_MODE_NORMAL_CWF_F3 5
24 24
25 25 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
26 26 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
27 27 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
28 28 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
29 29 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
30 30 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
31 31
32 32 //****************************
33 33 // LFR DEFAULT MODE PARAMETERS
34 34 // COMMON
35 35 #define DEFAULT_SY_LFR_COMMON0 0x00
36 36 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
37 37 // NORM
38 38 #define SY_LFR_N_SWF_L 2048 // nb sample
39 39 #define SY_LFR_N_SWF_P 296 // sec
40 40 #define SY_LFR_N_ASM_P 3600 // sec
41 41 #define SY_LFR_N_BP_P0 4 // sec
42 42 #define SY_LFR_N_BP_P1 20 // sec
43 43 #define MIN_DELTA_SNAPSHOT 16 // sec
44 44 // BURST
45 45 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
46 46 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
47 47 // SBM1
48 48 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
49 49 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
50 50 // SBM2
51 51 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
52 52 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
53 53 // ADDITIONAL PARAMETERS
54 54 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
55 55 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
56 56 // STATUS WORD
57 57 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
58 58 #define DEFAULT_STATUS_WORD_BYTE1 0x00
59 59 //
60 60 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
61 61 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
62 62 //****************************
63 63
64 64 //*****************************
65 65 // APB REGISTERS BASE ADDRESSES
66 66 #define REGS_ADDR_APBUART 0x80000100
67 67 #define REGS_ADDR_GPTIMER 0x80000300
68 68 #define REGS_ADDR_GRSPW 0x80000500
69 69 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
70 70 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
71 71
72 72 #ifdef GSA
73 73 #else
74 74 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
75 75 #endif
76 76
77 77 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
78 78 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
79 79
80 80 //**********
81 81 // IRQ LINES
82 82 #define IRQ_SM 9
83 83 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
84 84 #define IRQ_WF 10
85 85 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
86 86 #define IRQ_TIME1 12
87 87 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
88 88 #define IRQ_TIME2 13
89 89 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
90 90 #define IRQ_WAVEFORM_PICKER 14
91 91 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
92 92 #define IRQ_SPECTRAL_MATRIX 6
93 93 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
94 94
95 95 //*****
96 96 // TIME
97 97 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
98 98 #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s
99 99 #define TIMER_SM_SIMULATOR 1
100 100 #define TIMER_WF_SIMULATOR 2
101 101 #define HK_PERIOD 100 // 100 * 10ms => 1sec
102 102
103 103 //**********
104 104 // LPP CODES
105 105 #define LFR_SUCCESSFUL 0
106 106 #define LFR_DEFAULT 1
107 107
108 108 //******
109 109 // RTEMS
110 110 #define TASKID_RECV 1
111 111 #define TASKID_ACTN 2
112 112 #define TASKID_SPIQ 3
113 113 #define TASKID_SMIQ 4
114 114 #define TASKID_STAT 5
115 115 #define TASKID_AVF0 6
116 116 #define TASKID_BPF0 7
117 117 #define TASKID_WFRM 8
118 118 #define TASKID_DUMB 9
119 119 #define TASKID_HOUS 10
120 120 #define TASKID_MATR 11
121 121 #define TASKID_CWF3 12
122 122 #define TASKID_CWF2 13
123 123 #define TASKID_CWF1 14
124 124 #define TASKID_SEND 15
125 125 #define TASKID_WTDG 16
126 126
127 127 #define TASK_PRIORITY_SPIQ 5
128 128 #define TASK_PRIORITY_SMIQ 10
129 129 //
130 130 #define TASK_PRIORITY_WTDG 20
131 131 //
132 132 #define TASK_PRIORITY_HOUS 30
133 133 //
134 134 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
135 135 #define TASK_PRIORITY_CWF2 35 //
136 136 //
137 137 #define TASK_PRIORITY_WFRM 40
138 138 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
139 139 //
140 140 #define TASK_PRIORITY_SEND 45
141 141 //
142 142 #define TASK_PRIORITY_RECV 50
143 143 #define TASK_PRIORITY_ACTN 50
144 144 //
145 145 #define TASK_PRIORITY_AVF0 60
146 146 #define TASK_PRIORITY_BPF0 60
147 147 #define TASK_PRIORITY_MATR 100
148 148 #define TASK_PRIORITY_STAT 200
149 149 #define TASK_PRIORITY_DUMB 200
150 150
151 151 #define SEMQ_PRIORITY_CEILING 30
152 152
153 153 #define ACTION_MSG_QUEUE_COUNT 10
154 154 #define ACTION_MSG_PKTS_COUNT 50
155 155 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
156 156 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
157 157
158 158 #define QUEUE_RECV 0
159 159 #define QUEUE_SEND 1
160 160
161 161 //*******
162 162 // MACROS
163 163 #ifdef PRINT_MESSAGES_ON_CONSOLE
164 164 #define PRINTF(x) printf(x);
165 165 #define PRINTF1(x,y) printf(x,y);
166 166 #define PRINTF2(x,y,z) printf(x,y,z);
167 167 #else
168 168 #define PRINTF(x) ;
169 169 #define PRINTF1(x,y) ;
170 170 #define PRINTF2(x,y,z) ;
171 171 #endif
172 172
173 173 #ifdef BOOT_MESSAGES
174 174 #define BOOT_PRINTF(x) printf(x);
175 175 #define BOOT_PRINTF1(x,y) printf(x,y);
176 176 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
177 177 #else
178 178 #define BOOT_PRINTF(x) ;
179 179 #define BOOT_PRINTF1(x,y) ;
180 180 #define BOOT_PRINTF2(x,y,z) ;
181 181 #endif
182 182
183 183 #ifdef DEBUG_MESSAGES
184 184 #define DEBUG_PRINTF(x) printf(x);
185 185 #define DEBUG_PRINTF1(x,y) printf(x,y);
186 186 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
187 187 #else
188 188 #define DEBUG_PRINTF(x) ;
189 189 #define DEBUG_PRINTF1(x,y) ;
190 190 #define DEBUG_PRINTF2(x,y,z) ;
191 191 #endif
192 192
193 193 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
194 194
195 195 #define NB_SAMPLES_PER_SNAPSHOT 2048
196 196 #define TIME_OFFSET 2
197 #define ALIGNEMENT_OFFSET 100
197 198 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
198 199 #define NB_BYTES_SWF_BLK (2 * 6)
199 200 #define NB_WORDS_SWF_BLK 3
200 201 #define NB_BYTES_CWF3_LIGHT_BLK 6
201 202 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
202 203
203 204 struct param_local_str{
204 205 unsigned int local_sbm1_nb_cwf_sent;
205 206 unsigned int local_sbm1_nb_cwf_max;
206 207 unsigned int local_sbm2_nb_cwf_sent;
207 208 unsigned int local_sbm2_nb_cwf_max;
208 209 unsigned int local_nb_interrupt_f0_MAX;
209 210 };
210 211
211 212 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,86 +1,87
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8
9 9 #include "fsw_params.h"
10 10
11 11 #define pi 3.1415
12 12
13 13 extern int fdSPW;
14 14 extern volatile int wf_snap_f0[ ];
15 15 //
16 16 extern volatile int wf_snap_f1[ ];
17 17 extern volatile int wf_snap_f1_bis[ ];
18 18 extern volatile int wf_snap_f1_norm[ ];
19 19 //
20 20 extern volatile int wf_snap_f2[ ];
21 21 extern volatile int wf_snap_f2_bis[ ];
22 22 extern volatile int wf_snap_f2_norm[ ];
23 23 //
24 24 extern volatile int wf_cont_f3[ ];
25 25 extern volatile int wf_cont_f3_bis[ ];
26 26 extern char wf_cont_f3_light[ ];
27 27 extern new_waveform_picker_regs_t *new_waveform_picker_regs;
28 28 extern time_management_regs_t *time_management_regs;
29 29 extern Packet_TM_LFR_HK_t housekeeping_packet;
30 30 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
31 31 extern struct param_local_str param_local;
32 32
33 33 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
34 34 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
35 35 extern unsigned short sequenceCounters_TC_EXE[];
36 36
37 37 extern rtems_name misc_name[5];
38 38 extern rtems_name Task_name[20]; /* array of task ids */
39 39 extern rtems_id Task_id[20]; /* array of task ids */
40 40
41 41 extern unsigned char lfrCurrentMode;
42 42
43 43 rtems_isr waveforms_isr( rtems_vector_number vector );
44 44 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
45 45 rtems_task wfrm_task( rtems_task_argument argument );
46 46 rtems_task cwf3_task( rtems_task_argument argument );
47 47 rtems_task cwf2_task( rtems_task_argument argument );
48 48 rtems_task cwf1_task( rtems_task_argument argument );
49 49
50 50 //******************
51 51 // general functions
52 52 void init_waveforms( void );
53 53 //
54 54 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
55 55 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
56 56 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
57 57 //
58 58 void reset_waveforms( void );
59 59 //
60 60 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
61 61 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
62 62 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
63 63 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 64 //
65 65 rtems_id get_pkts_queue_id( void );
66 66
67 67 //**************
68 68 // wfp registers
69 69 void set_wfp_data_shaping();
70 70 char set_wfp_delta_snapshot();
71 71 void set_wfp_burst_enable_register( unsigned char mode);
72 72 void reset_wfp_run_burst_enable();
73 73 void reset_wfp_status();
74 74 void reset_new_waveform_picker_regs();
75 unsigned int address_alignment( volatile int *address);
75 76
76 77 //*****************
77 78 // local parameters
78 79 void set_local_sbm1_nb_cwf_max();
79 80 void set_local_sbm2_nb_cwf_max();
80 81 void set_local_nb_interrupt_f0_MAX();
81 82 void reset_local_sbm1_nb_cwf_sent();
82 83 void reset_local_sbm2_nb_cwf_sent();
83 84
84 85 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
85 86
86 87 #endif // WF_HANDLER_H_INCLUDED
@@ -1,91 +1,91
1 1 /** Global variables of the LFR flight software.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * Among global variables, there are:
7 7 * - RTEMS names and id.
8 8 * - APB configuration registers.
9 9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 10 * - spectral matrices buffesr, used by the hardware module to store data.
11 11 * - variable related to LFR modes parameters.
12 12 * - the global HK packet buffer.
13 13 * - the global dump parameter buffer.
14 14 *
15 15 */
16 16
17 17 #include <rtems.h>
18 18 #include <grspw.h>
19 19
20 20 #include "ccsds_types.h"
21 21 #include "grlib_regs.h"
22 22 #include "fsw_params.h"
23 23
24 24 // RTEMS GLOBAL VARIABLES
25 25 rtems_name misc_name[5];
26 26 rtems_id misc_id[5];
27 27 rtems_name Task_name[20]; /* array of task names */
28 28 rtems_id Task_id[20]; /* array of task ids */
29 29 unsigned int maxCount;
30 30 int fdSPW = 0;
31 31 int fdUART = 0;
32 32 unsigned char lfrCurrentMode;
33 33
34 34 // APB CONFIGURATION REGISTERS
35 35 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
36 36 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
37 37 #ifdef GSA
38 38 #else
39 39 new_waveform_picker_regs_t *new_waveform_picker_regs = (new_waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
40 40 #endif
41 41 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
42 42
43 43 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
44 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
44 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
45 45 //
46 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
47 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
48 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
46 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
47 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
48 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
49 49 //
50 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
51 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
52 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
50 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
51 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
52 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
53 53 //
54 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
55 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
56 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ];
54 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
55 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET + ALIGNEMENT_OFFSET ];
56 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK + ALIGNEMENT_OFFSET ];
57 57
58 58 // SPECTRAL MATRICES GLOBAL VARIABLES
59 59 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
60 60 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
61 61 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
62 62 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
63 63 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
64 64 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
65 65 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
66 66 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
67 67 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
68 68 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
69 69 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
70 70 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
71 71 //
72 72 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
73 73 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
74 74 //
75 75 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
76 76 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
77 77
78 78 // MODE PARAMETERS
79 79 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
80 80 struct param_local_str param_local;
81 81
82 82 // HK PACKETS
83 83 Packet_TM_LFR_HK_t housekeeping_packet;
84 84 // sequence counters are incremented by APID (PID + CAT) and destination ID
85 85 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
86 86 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
87 87 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
88 88 spw_stats spacewire_stats;
89 89 spw_stats spacewire_stats_backup;
90 90
91 91
@@ -1,325 +1,328
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 char *DumbMessages[7] = {"in DUMB *** default", // RTEMS_EVENT_0
10 char *DumbMessages[9] = {"in DUMB *** default", // RTEMS_EVENT_0
11 11 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
12 12 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
13 13 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
14 14 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
15 15 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
16 "ERR HK" // RTEMS_EVENT_6
16 "ERR HK", // RTEMS_EVENT_6
17 "full is 0", // RTEMS_EVENT_7
18 "full is 1" // RTEMS_EVENT_8
17 19 };
18 20
19 21 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
20 22 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
21 23 {
22 24 /** This function configures a GPTIMER timer instantiated in the VHDL design.
23 25 *
24 26 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
25 27 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
26 28 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
27 29 * @param interrupt_level is the interrupt level that the timer drives.
28 30 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
29 31 *
30 32 * @return
31 33 *
32 34 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
33 35 *
34 36 */
35 37
36 38 rtems_status_code status;
37 39 rtems_isr_entry old_isr_handler;
38 40
39 41 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
40 42 if (status!=RTEMS_SUCCESSFUL)
41 43 {
42 44 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
43 45 }
44 46
45 47 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
46 48
47 49 return 1;
48 50 }
49 51
50 52 int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
51 53 {
52 54 /** This function starts a GPTIMER timer.
53 55 *
54 56 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
55 57 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
56 58 *
57 59 * @return 1
58 60 *
59 61 */
60 62
61 63 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
62 64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
63 65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
64 66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
65 67 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
66 68
67 69 return 1;
68 70 }
69 71
70 72 int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
71 73 {
72 74 /** This function stops a GPTIMER timer.
73 75 *
74 76 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
75 77 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
76 78 *
77 79 * @return 1
78 80 *
79 81 */
80 82
81 83 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
82 84 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
83 85 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
84 86
85 87 return 1;
86 88 }
87 89
88 90 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
89 91 {
90 92 /** This function sets the clock divider of a GPTIMER timer.
91 93 *
92 94 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
93 95 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
94 96 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
95 97 *
96 98 * @return 1
97 99 *
98 100 */
99 101
100 102 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
101 103
102 104 return 1;
103 105 }
104 106
105 107 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
106 108 {
107 109 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
108 110
109 111 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
110 112 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
111 113
112 114 return 0;
113 115 }
114 116
115 117 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
116 118 {
117 119 /** This function sets the scaler reload register of the apbuart module
118 120 *
119 121 * @param regs is the address of the apbuart registers in memory
120 122 * @param value is the value that will be stored in the scaler register
121 123 *
122 124 * The value shall be set by the software to get data on the serial interface.
123 125 *
124 126 */
125 127
126 128 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
127 129
128 130 apbuart_regs->scaler = value;
129 131 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
130 132 }
131 133
132 134 //************
133 135 // RTEMS TASKS
134 136
135 137 rtems_task stat_task(rtems_task_argument argument)
136 138 {
137 139 int i;
138 140 int j;
139 141 i = 0;
140 142 j = 0;
141 143 BOOT_PRINTF("in STAT *** \n")
142 144 while(1){
143 145 rtems_task_wake_after(1000);
144 146 PRINTF1("%d\n", j)
145 147 if (i == CPU_USAGE_REPORT_PERIOD) {
146 148 // #ifdef PRINT_TASK_STATISTICS
147 149 // rtems_cpu_usage_report();
148 150 // rtems_cpu_usage_reset();
149 151 // #endif
150 152 i = 0;
151 153 }
152 154 else i++;
153 155 j++;
154 156 }
155 157 }
156 158
157 159 rtems_task hous_task(rtems_task_argument argument)
158 160 {
159 161 rtems_status_code status;
160 162 rtems_id queue_id;
161 163
162 164 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
163 165 if (status != RTEMS_SUCCESSFUL)
164 166 {
165 167 PRINTF1("in HOUS *** ERR %d\n", status)
166 168 }
167 169
168 170 BOOT_PRINTF("in HOUS ***\n")
169 171
170 172 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
171 173 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
172 174 if( status != RTEMS_SUCCESSFUL ) {
173 175 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
174 176 }
175 177 }
176 178
177 179 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
178 180 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
179 181 housekeeping_packet.reserved = DEFAULT_RESERVED;
180 182 housekeeping_packet.userApplication = CCSDS_USER_APP;
181 183 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
182 184 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
183 185 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
184 186 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
185 187 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
186 188 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
187 189 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
188 190 housekeeping_packet.serviceType = TM_TYPE_HK;
189 191 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
190 192 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
191 193
192 194 status = rtems_rate_monotonic_cancel(HK_id);
193 195 if( status != RTEMS_SUCCESSFUL ) {
194 196 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
195 197 }
196 198 else {
197 199 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
198 200 }
199 201
200 202 while(1){ // launch the rate monotonic task
201 203 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
202 204 if ( status != RTEMS_SUCCESSFUL ) {
203 205 PRINTF1( "in HOUS *** ERR period: %d\n", status);
204 206 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
205 207 }
206 208 else {
207 209 increment_seq_counter( housekeeping_packet.packetSequenceControl );
208 210 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
209 211 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
210 212 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
211 213 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
212 214 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
213 215 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
214 216 housekeeping_packet.sid = SID_HK;
215 217
216 218 spacewire_update_statistics();
217 219
218 220 // SEND PACKET
219 221 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
220 222 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
221 223 if (status != RTEMS_SUCCESSFUL) {
222 224 PRINTF1("in HOUS *** ERR send: %d\n", status)
223 225 }
224 226 }
225 227 }
226 228
227 229 PRINTF("in HOUS *** deleting task\n")
228 230
229 231 status = rtems_task_delete( RTEMS_SELF ); // should not return
230 232 printf( "rtems_task_delete returned with status of %d.\n", status );
231 233 return;
232 234 }
233 235
234 236 rtems_task dumb_task( rtems_task_argument unused )
235 237 {
236 238 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
237 239 *
238 240 * @param unused is the starting argument of the RTEMS task
239 241 *
240 242 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
241 243 *
242 244 */
243 245
244 246 unsigned int i;
245 247 unsigned int intEventOut;
246 248 unsigned int coarse_time = 0;
247 249 unsigned int fine_time = 0;
248 250 rtems_event_set event_out;
249 251
250 252 BOOT_PRINTF("in DUMB *** \n")
251 253
252 254 while(1){
253 255 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
254 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6,
256 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6
257 | RTEMS_EVENT_7 | RTEMS_EVENT_8 | RTEMS_EVENT_9 ,
255 258 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
256 259 intEventOut = (unsigned int) event_out;
257 260 for ( i=0; i<32; i++)
258 261 {
259 262 if ( ((intEventOut >> i) & 0x0001) != 0)
260 263 {
261 264 coarse_time = time_management_regs->coarse_time;
262 265 fine_time = time_management_regs->fine_time;
263 266 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
264 267 }
265 268 }
266 269 }
267 270 }
268 271
269 272 //*****************************
270 273 // init housekeeping parameters
271 274
272 275 void init_housekeeping_parameters( void )
273 276 {
274 277 /** This function initialize the housekeeping_packet global variable with default values.
275 278 *
276 279 */
277 280
278 281 unsigned int i = 0;
279 282 char *parameters;
280 283
281 284 parameters = (char*) &housekeeping_packet.lfr_status_word;
282 285 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
283 286 {
284 287 parameters[i] = 0x00;
285 288 }
286 289 // init status word
287 290 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
288 291 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
289 292 // init software version
290 293 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
291 294 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
292 295 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
293 296 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
294 297
295 298 }
296 299
297 300 void increment_seq_counter( unsigned char *packet_sequence_control)
298 301 {
299 302 unsigned short sequence_cnt;
300 303 unsigned short segmentation_grouping_flag;
301 304 unsigned short new_packet_sequence_control;
302 305
303 306 segmentation_grouping_flag = (unsigned short) ( (packet_sequence_control[0] & 0xc0) << 8 ); // keep bits 7 downto 6
304 307 sequence_cnt = (unsigned short) (
305 308 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
306 309 + packet_sequence_control[1]
307 310 );
308 311
309 312 if ( sequence_cnt < SEQ_CNT_MAX)
310 313 {
311 314 sequence_cnt = sequence_cnt + 1;
312 315 }
313 316 else
314 317 {
315 318 sequence_cnt = 0;
316 319 }
317 320
318 321 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
319 322
320 323 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
321 324 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
322 325 }
323 326
324 327
325 328
@@ -1,772 +1,772
1 1 /** Functions and tasks related to TeleCommand handling.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle TeleCommands:\n
7 7 * action launching\n
8 8 * TC parsing\n
9 9 * ...
10 10 *
11 11 */
12 12
13 13 #include "tc_handler.h"
14 14
15 15 //***********
16 16 // RTEMS TASK
17 17
18 18 rtems_task actn_task( rtems_task_argument unused )
19 19 {
20 20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 21 *
22 22 * @param unused is the starting argument of the RTEMS task
23 23 *
24 24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 25 * on the incoming TeleCommand.
26 26 *
27 27 */
28 28
29 29 int result;
30 30 rtems_status_code status; // RTEMS status code
31 31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 32 size_t size; // size of the incoming TC packet
33 33 unsigned char subtype; // subtype of the current TC packet
34 34 rtems_id queue_rcv_id;
35 35 rtems_id queue_snd_id;
36 36
37 37 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id );
38 38 if (status != RTEMS_SUCCESSFUL)
39 39 {
40 40 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
41 41 }
42 42
43 43 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id );
44 44 if (status != RTEMS_SUCCESSFUL)
45 45 {
46 46 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
47 47 }
48 48
49 49 result = LFR_SUCCESSFUL;
50 50 subtype = 0; // subtype of the current TC packet
51 51
52 52 BOOT_PRINTF("in ACTN *** \n")
53 53
54 54 while(1)
55 55 {
56 56 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 57 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
58 58 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
59 59 else
60 60 {
61 61 subtype = TC.serviceSubType;
62 62 switch(subtype)
63 63 {
64 64 case TC_SUBTYPE_RESET:
65 65 result = action_reset( &TC, queue_snd_id );
66 66 close_action( &TC, result, queue_snd_id );
67 67 break;
68 68 //
69 69 case TC_SUBTYPE_LOAD_COMM:
70 70 result = action_load_common_par( &TC );
71 71 close_action( &TC, result, queue_snd_id );
72 72 break;
73 73 //
74 74 case TC_SUBTYPE_LOAD_NORM:
75 75 result = action_load_normal_par( &TC, queue_snd_id );
76 76 close_action( &TC, result, queue_snd_id );
77 77 break;
78 78 //
79 79 case TC_SUBTYPE_LOAD_BURST:
80 80 result = action_load_burst_par( &TC, queue_snd_id );
81 81 close_action( &TC, result, queue_snd_id );
82 82 break;
83 83 //
84 84 case TC_SUBTYPE_LOAD_SBM1:
85 85 result = action_load_sbm1_par( &TC, queue_snd_id );
86 86 close_action( &TC, result, queue_snd_id );
87 87 break;
88 88 //
89 89 case TC_SUBTYPE_LOAD_SBM2:
90 90 result = action_load_sbm2_par( &TC, queue_snd_id );
91 91 close_action( &TC, result, queue_snd_id );
92 92 break;
93 93 //
94 94 case TC_SUBTYPE_DUMP:
95 95 result = action_dump_par( queue_snd_id );
96 96 close_action( &TC, result, queue_snd_id );
97 97 break;
98 98 //
99 99 case TC_SUBTYPE_ENTER:
100 100 result = action_enter_mode( &TC, queue_snd_id );
101 101 close_action( &TC, result, queue_snd_id );
102 102 break;
103 103 //
104 104 case TC_SUBTYPE_UPDT_INFO:
105 105 result = action_update_info( &TC, queue_snd_id );
106 106 close_action( &TC, result, queue_snd_id );
107 107 break;
108 108 //
109 109 case TC_SUBTYPE_EN_CAL:
110 110 result = action_enable_calibration( &TC, queue_snd_id );
111 111 close_action( &TC, result, queue_snd_id );
112 112 break;
113 113 //
114 114 case TC_SUBTYPE_DIS_CAL:
115 115 result = action_disable_calibration( &TC, queue_snd_id );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 //
119 119 case TC_SUBTYPE_UPDT_TIME:
120 120 result = action_update_time( &TC );
121 121 close_action( &TC, result, queue_snd_id );
122 122 break;
123 123 //
124 124 default:
125 125 break;
126 126 }
127 127 }
128 128 }
129 129 }
130 130
131 131 //***********
132 132 // TC ACTIONS
133 133
134 134 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
135 135 {
136 136 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
137 137 *
138 138 * @param TC points to the TeleCommand packet that is being processed
139 139 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
140 140 *
141 141 */
142 142
143 143 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
144 144 return LFR_DEFAULT;
145 145 }
146 146
147 147 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
148 148 {
149 149 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
150 150 *
151 151 * @param TC points to the TeleCommand packet that is being processed
152 152 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
153 153 *
154 154 */
155 155
156 156 rtems_status_code status;
157 157 unsigned char requestedMode;
158 158
159 159 requestedMode = TC->dataAndCRC[1];
160 160
161 161 if ( (requestedMode != LFR_MODE_STANDBY)
162 162 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
163 163 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
164 164 {
165 165 status = RTEMS_UNSATISFIED;
166 166 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
167 167 }
168 168 else
169 169 {
170 170 printf("try to enter mode %d\n", requestedMode);
171 171
172 172 #ifdef PRINT_TASK_STATISTICS
173 173 if (requestedMode != LFR_MODE_STANDBY)
174 174 {
175 175 rtems_cpu_usage_reset();
176 176 maxCount = 0;
177 177 }
178 178 #endif
179 179
180 180 status = transition_validation(requestedMode);
181 181
182 182 if ( status == LFR_SUCCESSFUL ) {
183 183 if ( lfrCurrentMode != LFR_MODE_STANDBY)
184 184 {
185 185 status = stop_current_mode();
186 186 }
187 187 if (status != RTEMS_SUCCESSFUL)
188 188 {
189 189 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
190 190 }
191 191 status = enter_mode(requestedMode, TC);
192 192 }
193 193 else
194 194 {
195 195 PRINTF("ERR *** in action_enter *** transition rejected\n")
196 196 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
197 197 }
198 198 }
199 199
200 200 return status;
201 201 }
202 202
203 203 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
204 204 {
205 205 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
206 206 *
207 207 * @param TC points to the TeleCommand packet that is being processed
208 208 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
209 209 *
210 210 * @return LFR directive status code:
211 211 * - LFR_DEFAULT
212 212 * - LFR_SUCCESSFUL
213 213 *
214 214 */
215 215
216 216 unsigned int val;
217 217 int result;
218 218
219 219 result = LFR_DEFAULT;
220 220
221 221 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
222 222 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
223 223 val++;
224 224 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
225 225 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
226 226
227 227 return result;
228 228 }
229 229
230 230 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
231 231 {
232 232 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
233 233 *
234 234 * @param TC points to the TeleCommand packet that is being processed
235 235 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
236 236 *
237 237 */
238 238
239 239 int result;
240 240 unsigned char lfrMode;
241 241
242 242 result = LFR_DEFAULT;
243 243 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
244 244
245 245 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
246 246 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
247 247 result = LFR_DEFAULT;
248 248 }
249 249 else {
250 250 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
251 251 result = LFR_DEFAULT;
252 252 }
253 253 return result;
254 254 }
255 255
256 256 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
257 257 {
258 258 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
259 259 *
260 260 * @param TC points to the TeleCommand packet that is being processed
261 261 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
262 262 *
263 263 */
264 264
265 265 int result;
266 266 unsigned char lfrMode;
267 267
268 268 result = LFR_DEFAULT;
269 269 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
270 270
271 271 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
272 272 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
273 273 result = LFR_DEFAULT;
274 274 }
275 275 else {
276 276 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
277 277 result = LFR_DEFAULT;
278 278 }
279 279 return result;
280 280 }
281 281
282 282 int action_update_time(ccsdsTelecommandPacket_t *TC)
283 283 {
284 284 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
285 285 *
286 286 * @param TC points to the TeleCommand packet that is being processed
287 287 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
288 288 *
289 289 * @return LFR_SUCCESSFUL
290 290 *
291 291 */
292 292
293 293 unsigned int val;
294 294
295 295 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
296 296 + (TC->dataAndCRC[1] << 16)
297 297 + (TC->dataAndCRC[2] << 8)
298 298 + TC->dataAndCRC[3];
299 299 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
300 300 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
301 301 val++;
302 302 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
303 303 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
304 304 time_management_regs->ctrl = time_management_regs->ctrl | 1;
305 305
306 306 return LFR_SUCCESSFUL;
307 307 }
308 308
309 309 //*******************
310 310 // ENTERING THE MODES
311 311
312 312 int transition_validation(unsigned char requestedMode)
313 313 {
314 314 int status;
315 315
316 316 switch (requestedMode)
317 317 {
318 318 case LFR_MODE_STANDBY:
319 319 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
320 320 status = LFR_DEFAULT;
321 321 }
322 322 else
323 323 {
324 324 status = LFR_SUCCESSFUL;
325 325 }
326 326 break;
327 327 case LFR_MODE_NORMAL:
328 328 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
329 329 status = LFR_DEFAULT;
330 330 }
331 331 else {
332 332 status = LFR_SUCCESSFUL;
333 333 }
334 334 break;
335 335 case LFR_MODE_BURST:
336 336 if ( lfrCurrentMode == LFR_MODE_BURST ) {
337 337 status = LFR_DEFAULT;
338 338 }
339 339 else {
340 340 status = LFR_SUCCESSFUL;
341 341 }
342 342 break;
343 343 case LFR_MODE_SBM1:
344 344 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
345 345 status = LFR_DEFAULT;
346 346 }
347 347 else {
348 348 status = LFR_SUCCESSFUL;
349 349 }
350 350 break;
351 351 case LFR_MODE_SBM2:
352 352 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
353 353 status = LFR_DEFAULT;
354 354 }
355 355 else {
356 356 status = LFR_SUCCESSFUL;
357 357 }
358 358 break;
359 359 default:
360 360 status = LFR_DEFAULT;
361 361 break;
362 362 }
363 363
364 364 return status;
365 365 }
366 366
367 367 int stop_current_mode()
368 368 {
369 369 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
370 370 *
371 371 * @return RTEMS directive status codes:
372 372 * - RTEMS_SUCCESSFUL - task restarted successfully
373 373 * - RTEMS_INVALID_ID - task id invalid
374 374 * - RTEMS_ALREADY_SUSPENDED - task already suspended
375 375 *
376 376 */
377 377
378 378 rtems_status_code status;
379 379
380 380 status = RTEMS_SUCCESSFUL;
381 381
382 382 #ifdef GSA
383 383 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
384 384 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
385 385 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
386 386 #else
387 387 // mask interruptions
388 388 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
389 389 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
390 390 // reset registers
391 391 reset_wfp_run_burst_enable(); // reset run, burst and enable bits, [r b2 b1 b0 e3 e2 e1 e0]
392 392 reset_wfp_status(); // reset all the status bits
393 393 // creal interruptions
394 394 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
395 395 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
396 396 #endif
397 397 //**********************
398 398 // suspend several tasks
399 399 if (lfrCurrentMode != LFR_MODE_STANDBY) {
400 400 status = suspend_science_tasks();
401 401 }
402 402
403 403 if (status != RTEMS_SUCCESSFUL)
404 404 {
405 405 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
406 406 }
407 407
408 408 return status;
409 409 }
410 410
411 411 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
412 412 {
413 413 rtems_status_code status;
414 414
415 415 status = RTEMS_UNSATISFIED;
416 416
417 417 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
418 418 updateLFRCurrentMode();
419 419
420 420 switch(mode){
421 421 case LFR_MODE_STANDBY:
422 422 status = enter_standby_mode( );
423 423 break;
424 424 case LFR_MODE_NORMAL:
425 425 status = enter_normal_mode( );
426 426 break;
427 427 case LFR_MODE_BURST:
428 428 status = enter_burst_mode( );
429 429 break;
430 430 case LFR_MODE_SBM1:
431 431 status = enter_sbm1_mode( );
432 432 break;
433 433 case LFR_MODE_SBM2:
434 434 status = enter_sbm2_mode( );
435 435 break;
436 436 default:
437 437 status = RTEMS_UNSATISFIED;
438 438 }
439 439
440 440 if (status != RTEMS_SUCCESSFUL)
441 441 {
442 442 PRINTF("in enter_mode *** ERR\n")
443 443 status = RTEMS_UNSATISFIED;
444 444 }
445 445
446 446 return status;
447 447 }
448 448
449 449 int enter_standby_mode()
450 450 {
451 451 PRINTF1("maxCount = %d\n", maxCount)
452 452
453 453 #ifdef PRINT_TASK_STATISTICS
454 454 rtems_cpu_usage_report();
455 455 #endif
456 456
457 457 #ifdef PRINT_STACK_REPORT
458 458 rtems_stack_checker_report_usage();
459 459 #endif
460 460
461 461 return LFR_SUCCESSFUL;
462 462 }
463 463
464 464 int enter_normal_mode()
465 465 {
466 466 rtems_status_code status;
467 467 int startDate;
468 468
469 469 status = restart_science_tasks();
470 470
471 471 #ifdef GSA
472 472 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
473 473 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
474 474 LEON_Clear_interrupt( IRQ_WF );
475 475 LEON_Unmask_interrupt( IRQ_WF );
476 476 //
477 477 set_local_nb_interrupt_f0_MAX();
478 478 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
479 479 LEON_Unmask_interrupt( IRQ_SM );
480 480 #else
481 481 //****************
482 482 // waveform picker
483 483 reset_new_waveform_picker_regs();
484 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
484 set_wfp_burst_enable_register( LFR_MODE_NORMAL );
485 485 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
486 486 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
487 487 startDate = time_management_regs->coarse_time + 2;
488 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
488 489 new_waveform_picker_regs->start_date = startDate;
489 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
490 490 //****************
491 491 // spectral matrix
492 492 #endif
493 493
494 494 return status;
495 495 }
496 496
497 497 int enter_burst_mode()
498 498 {
499 499 rtems_status_code status;
500 500
501 501 status = restart_science_tasks();
502 502
503 503 #ifdef GSA
504 504 LEON_Unmask_interrupt( IRQ_SM );
505 505 #else
506 506 reset_new_waveform_picker_regs();
507 507 set_wfp_burst_enable_register(LFR_MODE_BURST);
508 508 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
509 509 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
510 510 #endif
511 511
512 512 return status;
513 513 }
514 514
515 515 int enter_sbm1_mode()
516 516 {
517 517 rtems_status_code status;
518 518
519 519 status = restart_science_tasks();
520 520
521 521 set_local_sbm1_nb_cwf_max();
522 522
523 523 reset_local_sbm1_nb_cwf_sent();
524 524
525 525 #ifdef GSA
526 526 LEON_Unmask_interrupt( IRQ_SM );
527 527 #else
528 528 reset_new_waveform_picker_regs();
529 529 set_wfp_burst_enable_register(LFR_MODE_SBM1);
530 530 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
531 531 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
532 532 // SM simulation
533 533 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
534 534 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
535 535 // LEON_Unmask_interrupt( IRQ_SM );
536 536 #endif
537 537
538 538 return status;
539 539 }
540 540
541 541 int enter_sbm2_mode()
542 542 {
543 543 rtems_status_code status;
544 544
545 545 status = restart_science_tasks();
546 546
547 547 set_local_sbm2_nb_cwf_max();
548 548
549 549 reset_local_sbm2_nb_cwf_sent();
550 550
551 551 #ifdef GSA
552 552 LEON_Unmask_interrupt( IRQ_SM );
553 553 #else
554 554 reset_new_waveform_picker_regs();
555 555 set_wfp_burst_enable_register(LFR_MODE_SBM2);
556 556 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
557 557 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
558 558 #endif
559 559
560 560 return status;
561 561 }
562 562
563 563 int restart_science_tasks()
564 564 {
565 565 rtems_status_code status[6];
566 566 rtems_status_code ret;
567 567
568 568 ret = RTEMS_SUCCESSFUL;
569 569
570 570 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
571 571 if (status[0] != RTEMS_SUCCESSFUL)
572 572 {
573 573 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
574 574 }
575 575
576 576 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
577 577 if (status[1] != RTEMS_SUCCESSFUL)
578 578 {
579 579 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
580 580 }
581 581
582 582 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
583 583 if (status[2] != RTEMS_SUCCESSFUL)
584 584 {
585 585 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
586 586 }
587 587
588 588 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
589 589 if (status[3] != RTEMS_SUCCESSFUL)
590 590 {
591 591 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
592 592 }
593 593
594 594 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
595 595 if (status[4] != RTEMS_SUCCESSFUL)
596 596 {
597 597 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
598 598 }
599 599
600 600 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
601 601 if (status[5] != RTEMS_SUCCESSFUL)
602 602 {
603 603 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
604 604 }
605 605
606 606 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
607 607 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
608 608 {
609 609 ret = RTEMS_UNSATISFIED;
610 610 }
611 611
612 612 return ret;
613 613 }
614 614
615 615 int suspend_science_tasks()
616 616 {
617 617 /** This function suspends the science tasks.
618 618 *
619 619 * @return RTEMS directive status codes:
620 620 * - RTEMS_SUCCESSFUL - task restarted successfully
621 621 * - RTEMS_INVALID_ID - task id invalid
622 622 * - RTEMS_ALREADY_SUSPENDED - task already suspended
623 623 *
624 624 */
625 625
626 626 rtems_status_code status;
627 627
628 628 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
629 629 if (status != RTEMS_SUCCESSFUL)
630 630 {
631 631 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
632 632 }
633 633
634 634 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
635 635 {
636 636 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
637 637 if (status != RTEMS_SUCCESSFUL)
638 638 {
639 639 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
640 640 }
641 641 }
642 642
643 643 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
644 644 {
645 645 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
646 646 if (status != RTEMS_SUCCESSFUL)
647 647 {
648 648 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
649 649 }
650 650 }
651 651
652 652 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
653 653 {
654 654 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
655 655 if (status != RTEMS_SUCCESSFUL)
656 656 {
657 657 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
658 658 }
659 659 }
660 660
661 661 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
662 662 {
663 663 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
664 664 if (status != RTEMS_SUCCESSFUL)
665 665 {
666 666 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
667 667 }
668 668 }
669 669
670 670 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
671 671 {
672 672 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
673 673 if (status != RTEMS_SUCCESSFUL)
674 674 {
675 675 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
676 676 }
677 677 }
678 678
679 679 return status;
680 680 }
681 681
682 682 //****************
683 683 // CLOSING ACTIONS
684 684 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
685 685 {
686 686 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
687 687 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
688 688 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
689 689 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
690 690 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
691 691 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
692 692 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
693 693 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
694 694 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
695 695 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
696 696 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
697 697 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
698 698 }
699 699
700 700 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
701 701 {
702 702 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
703 703 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
704 704 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
705 705 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
706 706 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
707 707 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
708 708 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
709 709 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
710 710 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
711 711 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
712 712 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
713 713 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
714 714 }
715 715
716 716 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id)
717 717 {
718 718 unsigned int val = 0;
719 719 if (result == LFR_SUCCESSFUL)
720 720 {
721 721 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
722 722 &&
723 723 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
724 724 )
725 725 {
726 726 send_tm_lfr_tc_exe_success( TC, queue_id );
727 727 }
728 728 update_last_TC_exe( TC );
729 729 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
730 730 val++;
731 731 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
732 732 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
733 733 }
734 734 else
735 735 {
736 736 update_last_TC_rej( TC );
737 737 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
738 738 val++;
739 739 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
740 740 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
741 741 }
742 742 }
743 743
744 744 //***************************
745 745 // Interrupt Service Routines
746 746 rtems_isr commutation_isr1( rtems_vector_number vector )
747 747 {
748 748 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
749 749 printf("In commutation_isr1 *** Error sending event to DUMB\n");
750 750 }
751 751 }
752 752
753 753 rtems_isr commutation_isr2( rtems_vector_number vector )
754 754 {
755 755 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
756 756 printf("In commutation_isr2 *** Error sending event to DUMB\n");
757 757 }
758 758 }
759 759
760 760 //****************
761 761 // OTHER FUNCTIONS
762 762 void updateLFRCurrentMode()
763 763 {
764 764 /** This function updates the value of the global variable lfrCurrentMode.
765 765 *
766 766 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
767 767 *
768 768 */
769 769 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
770 770 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
771 771 }
772 772
@@ -1,1251 +1,1351
1 1 /** Functions and tasks related to waveform packet generation.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 7 *
8 8 */
9 9
10 10 #include "wf_handler.h"
11 11
12 12 // SWF
13 13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
14 14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
15 15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
16 16 // CWF
17 17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
18 18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
19 19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
20 20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
21 21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
22 22
23 23 unsigned char doubleSendCWF1 = 0;
24 24 unsigned char doubleSendCWF2 = 0;
25 25 unsigned char fullRecord;
26 26
27 27 rtems_isr waveforms_isr( rtems_vector_number vector )
28 28 {
29 29 unsigned int statusReg;
30 30
31 31 /** This is the interrupt sub routine called by the waveform picker core.
32 32 *
33 33 * This ISR launch different actions depending mainly on two pieces of information:
34 34 * 1. the values read in the registers of the waveform picker.
35 35 * 2. the current LFR mode.
36 36 *
37 37 */
38 38
39 39 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff00f; // clear new_err and full_err
40 40
41 41 #ifdef GSA
42 42 #else
43 43 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
44 44 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
45 45 { // in modes other than STANDBY and BURST, send the CWF_F3 data
46 46 if ((new_waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
47 47 // (1) change the receiving buffer for the waveform picker
48 48 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
49 49 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
50 50 }
51 51 else {
52 52 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
53 53 }
54 54 // (2) send an event for the waveforms transmission
55 55 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
56 56 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
57 57 }
58 58 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
59 59 }
60 60 }
61 61 #endif
62 62
63 63 switch(lfrCurrentMode)
64 64 {
65 65 //********
66 66 // STANDBY
67 67 case(LFR_MODE_STANDBY):
68 68 break;
69 69
70 70 //******
71 71 // NORMAL
72 72 case(LFR_MODE_NORMAL):
73 73 #ifdef GSA
74 74 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
75 75 #else
76 76 statusReg = new_waveform_picker_regs->status;
77 77 fullRecord = fullRecord | ( statusReg & 0x7 );
78 78 // if ( (new_waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
79 if ( (new_waveform_picker_regs->status & 0x1) == 0x1 ){ // f2 is full
79 // if ( (new_waveform_picker_regs->status & 0x1) == 0x1 ) // f0 is full
80 if ( (new_waveform_picker_regs->status & 0x4) == 0x4 ) // f2 is full
81 {
80 82 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
81 83 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
82 84 }
83 85 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
86 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
87 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
88 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
89 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
90 // if ( (new_waveform_picker_regs->status & 0x1) == 0x1 )
91 if ( (new_waveform_picker_regs->status & 0x4) == 0x4 ) // f2 is full
92 {
93 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
94 }
95 // if ( (new_waveform_picker_regs->status & 0x1) == 0x0 )
96 if ( (new_waveform_picker_regs->status & 0x4) == 0x0 )
97 {
98 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_7 );
99 }
84 100 }
85 // if ( fullRecord == 0x7 ){ // f2 f1 and f0 are full
86 // if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
87 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
88 // }
89 // fullRecord = 0x00;
90 // }
91 // new_waveform_picker_regs->status = ( new_waveform_picker_regs->status & (~statusReg) )
92 // | ( new_waveform_picker_regs->status & 0xfffffff8 );
93 101 #endif
94 102 break;
95 103
96 104 //******
97 105 // BURST
98 106 case(LFR_MODE_BURST):
99 107 #ifdef GSA
100 108 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
101 109 #else
102 110 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
103 111 // (1) change the receiving buffer for the waveform picker
104 112 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
105 113 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
106 114 }
107 115 else {
108 116 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
109 117 }
110 118 // (2) send an event for the waveforms transmission
111 119 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
112 120 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
113 121 }
114 122 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
115 123 }
116 124 #endif
117 125 break;
118 126
119 127 //*****
120 128 // SBM1
121 129 case(LFR_MODE_SBM1):
122 130 #ifdef GSA
123 131 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
124 132 #else
125 133 if ((new_waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
126 134 // (1) change the receiving buffer for the waveform picker
127 135 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
128 136 {
129 137 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
130 138 }
131 139 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
132 140 {
133 141 doubleSendCWF1 = 1;
134 142 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
135 143 }
136 144 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
137 145 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
138 146 }
139 147 else {
140 148 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
141 149 }
142 150 // (2) send an event for the waveforms transmission
143 151 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
144 152 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
145 153 }
146 154 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
147 155 }
148 156 if ( ( (new_waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
149 157 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
150 158 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
151 159 }
152 160 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
153 161 reset_local_sbm1_nb_cwf_sent();
154 162 }
155 163
156 164 #endif
157 165 break;
158 166
159 167 //*****
160 168 // SBM2
161 169 case(LFR_MODE_SBM2):
162 170 #ifdef GSA
163 171 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
164 172 #else
165 173 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
166 174 // (1) change the receiving buffer for the waveform picker
167 175 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
168 176 {
169 177 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
170 178 }
171 179 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
172 180 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
173 181 doubleSendCWF2 = 1;
174 182 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
175 183 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
176 184 }
177 185 reset_local_sbm2_nb_cwf_sent();
178 186 }
179 187 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
180 188 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
181 189 }
182 190 else {
183 191 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
184 192 }
185 193 // (2) send an event for the waveforms transmission
186 194 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
187 195 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
188 196 }
189 197 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
190 198 }
191 199 if ( ( (new_waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
192 200 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
193 201 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
194 202 }
195 203 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
196 204 }
197 205 #endif
198 206 break;
199 207
200 208 //********
201 209 // DEFAULT
202 210 default:
203 211 break;
204 212 }
205 213 }
206 214
207 215 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
208 216 {
209 217 /** This is the interrupt sub routine called by the waveform picker simulator.
210 218 *
211 219 * This ISR is for debug purpose only.
212 220 *
213 221 */
214 222
215 223 unsigned char lfrMode;
216 224 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
217 225
218 226 switch(lfrMode) {
219 227 case (LFR_MODE_STANDBY):
220 228 break;
221 229 case (LFR_MODE_NORMAL):
222 230 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
223 231 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
224 232 }
225 233 break;
226 234 case (LFR_MODE_BURST):
227 235 break;
228 236 case (LFR_MODE_SBM1):
229 237 break;
230 238 case (LFR_MODE_SBM2):
231 239 break;
232 240 }
233 241 }
234 242
235 243 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
236 244 {
237 245 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
238 246 *
239 247 * @param unused is the starting argument of the RTEMS task
240 248 *
241 249 * The following data packets are sent by this task:
242 250 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
243 251 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
244 252 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
245 253 *
246 254 */
247 255
248 256 rtems_event_set event_out;
249 257 rtems_id queue_id;
250 258
251 259 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
252 260 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
253 261 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
254 262
255 263 init_waveforms();
256 264
257 265 queue_id = get_pkts_queue_id();
258 266
259 267 BOOT_PRINTF("in WFRM ***\n")
260 268
261 269 while(1){
262 270 // wait for an RTEMS_EVENT
263 271 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
264 272 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
265 273 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
266 274
267 275 if (event_out == RTEMS_EVENT_MODE_NORMAL)
268 276 {
269 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
270 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
277 //send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
278 //send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
271 279 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
272 280 #ifdef GSA
273 281 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
274 282 #endif
275 283 }
276 284 else if (event_out == RTEMS_EVENT_MODE_SBM1)
277 285 {
278 286 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
279 287 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
280 288 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
281 289 #ifdef GSA
282 290 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
283 291 #endif
284 292 }
285 293 else if (event_out == RTEMS_EVENT_MODE_SBM2)
286 294 {
287 295 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
288 296 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
289 297 #ifdef GSA
290 298 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
291 299 #endif
292 300 }
293 301 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
294 302 {
295 303 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
296 304 }
297 305 else
298 306 {
299 307 PRINTF("in WFRM *** unexpected event")
300 308 }
301 309
302 310
303 311 #ifdef GSA
304 312 // irq processed, reset the related register of the timer unit
305 313 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
306 314 // clear the interruption
307 315 LEON_Unmask_interrupt( IRQ_WF );
308 316 #endif
309 317 }
310 318 }
311 319
312 320 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
313 321 {
314 322 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
315 323 *
316 324 * @param unused is the starting argument of the RTEMS task
317 325 *
318 326 * The following data packet is sent by this task:
319 327 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
320 328 *
321 329 */
322 330
323 331 rtems_event_set event_out;
324 332 rtems_id queue_id;
325 333
326 334 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
327 335 init_header_continuous_wf3_light_table( headerCWF_F3_light );
328 336
329 337 queue_id = get_pkts_queue_id();
330 338
331 339 BOOT_PRINTF("in CWF3 ***\n")
332 340
333 341 while(1){
334 342 // wait for an RTEMS_EVENT
335 343 rtems_event_receive( RTEMS_EVENT_0,
336 344 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
337 345 PRINTF("send CWF F3 \n")
338 346 #ifdef GSA
339 347 #else
340 348 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
341 349 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
342 350 }
343 351 else {
344 352 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
345 353 }
346 354 #endif
347 355 }
348 356 }
349 357
350 358 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
351 359 {
352 360 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
353 361 *
354 362 * @param unused is the starting argument of the RTEMS task
355 363 *
356 364 * The following data packet is sent by this function:
357 365 * - TM_LFR_SCIENCE_BURST_CWF_F2
358 366 * - TM_LFR_SCIENCE_SBM2_CWF_F2
359 367 *
360 368 */
361 369
362 370 rtems_event_set event_out;
363 371 rtems_id queue_id;
364 372
365 373 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
366 374 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
367 375
368 376 queue_id = get_pkts_queue_id();
369 377
370 378 BOOT_PRINTF("in CWF2 ***\n")
371 379
372 380 while(1){
373 381 // wait for an RTEMS_EVENT
374 382 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
375 383 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
376 384
377 385 if (event_out == RTEMS_EVENT_MODE_BURST)
378 386 {
379 387 // F2
380 388 #ifdef GSA
381 389 #else
382 390 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
383 391 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
384 392 }
385 393 else {
386 394 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
387 395 }
388 396 #endif
389 397 }
390 398
391 399 else if (event_out == RTEMS_EVENT_MODE_SBM2)
392 400 {
393 401 #ifdef GSA
394 402 #else
395 403 if (doubleSendCWF2 == 1)
396 404 {
397 405 doubleSendCWF2 = 0;
398 406 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
399 407 }
400 408 else if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
401 409 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
402 410 }
403 411 else {
404 412 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
405 413 }
406 414 param_local.local_sbm2_nb_cwf_sent ++;
407 415 #endif
408 416 }
409 417 else
410 418 {
411 419 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
412 420 }
413 421 }
414 422 }
415 423
416 424 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
417 425 {
418 426 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
419 427 *
420 428 * @param unused is the starting argument of the RTEMS task
421 429 *
422 430 * The following data packet is sent by this function:
423 431 * - TM_LFR_SCIENCE_SBM1_CWF_F1
424 432 *
425 433 */
426 434
427 435 rtems_event_set event_out;
428 436 rtems_id queue_id;
429 437
430 438 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
431 439
432 440 queue_id = get_pkts_queue_id();
433 441
434 442 BOOT_PRINTF("in CWF1 ***\n")
435 443
436 444 while(1){
437 445 // wait for an RTEMS_EVENT
438 446 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
439 447 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
440 448 if (event_out == RTEMS_EVENT_MODE_SBM1)
441 449 {
442 450 #ifdef GSA
443 451 #else
444 452 if (doubleSendCWF1 == 1)
445 453 {
446 454 doubleSendCWF1 = 0;
447 455 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
448 456 }
449 457 else if (new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
450 458 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
451 459 }
452 460 else {
453 461 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
454 462 }
455 463 param_local.local_sbm1_nb_cwf_sent ++;
456 464 #endif
457 465 }
458 466 else
459 467 {
460 468 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
461 469 }
462 470 }
463 471 }
464 472
465 473 //******************
466 474 // general functions
467 475 void init_waveforms( void )
468 476 {
469 477 int i = 0;
470 478
471 479 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
472 480 {
473 481 // //***
474 482 // // F0
475 483 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
476 484 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
477 485 // wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
478 486
479 487 // //***
480 488 // // F1
481 489 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
482 490 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
483 491 // wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
484 492
485 493 // //***
486 494 // // F2
487 495 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
488 496 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
489 497 // wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
490 498
491 499 //***
492 500 // F0
493 501 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x0; //
494 502 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x0; //
495 503 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x0; //
496 504
497 505 //***
498 506 // F1
499 507 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x0;
500 508 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x0;
501 509 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x0;
502 510
503 511 //***
504 512 // F2
505 513 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x0;
506 514 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x0;
507 515 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x0;
508 516
509 517 //***
510 518 // F3
511 519 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
512 520 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
513 521 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
514 522 }
515 523 }
516 524
517 525 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
518 526 {
519 527 unsigned char i;
520 528
521 529 for (i=0; i<7; i++)
522 530 {
523 531 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
524 532 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
525 533 headerSWF[ i ].reserved = DEFAULT_RESERVED;
526 534 headerSWF[ i ].userApplication = CCSDS_USER_APP;
527 535 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
528 536 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
529 537 if (i == 0)
530 538 {
531 539 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
532 540 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
533 541 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
534 542 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
535 543 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
536 544 }
537 545 else if (i == 6)
538 546 {
539 547 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
540 548 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
541 549 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
542 550 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
543 551 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
544 552 }
545 553 else
546 554 {
547 555 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
548 556 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
549 557 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
550 558 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
551 559 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
552 560 }
553 561 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
554 562 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
555 563 headerSWF[ i ].pktNr = i+1; // PKT_NR
556 564 // DATA FIELD HEADER
557 565 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
558 566 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
559 567 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
560 568 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
561 569 // AUXILIARY DATA HEADER
562 570 headerSWF[ i ].sid = sid;
563 571 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
564 572 headerSWF[ i ].time[0] = 0x00;
565 573 headerSWF[ i ].time[0] = 0x00;
566 574 headerSWF[ i ].time[0] = 0x00;
567 575 headerSWF[ i ].time[0] = 0x00;
568 576 headerSWF[ i ].time[0] = 0x00;
569 577 headerSWF[ i ].time[0] = 0x00;
570 578 }
571 579 return LFR_SUCCESSFUL;
572 580 }
573 581
574 582 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
575 583 {
576 584 unsigned int i;
577 585
578 586 for (i=0; i<7; i++)
579 587 {
580 588 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
581 589 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
582 590 headerCWF[ i ].reserved = DEFAULT_RESERVED;
583 591 headerCWF[ i ].userApplication = CCSDS_USER_APP;
584 592 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
585 593 {
586 594 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
587 595 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
588 596 }
589 597 else
590 598 {
591 599 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
592 600 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
593 601 }
594 602 if (i == 0)
595 603 {
596 604 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
597 605 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
598 606 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
599 607 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
600 608 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
601 609 }
602 610 else if (i == 6)
603 611 {
604 612 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
605 613 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
606 614 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
607 615 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
608 616 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
609 617 }
610 618 else
611 619 {
612 620 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
613 621 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
614 622 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
615 623 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
616 624 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
617 625 }
618 626 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
619 627 // PKT_CNT
620 628 // PKT_NR
621 629 // DATA FIELD HEADER
622 630 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
623 631 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
624 632 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
625 633 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
626 634 // AUXILIARY DATA HEADER
627 635 headerCWF[ i ].sid = sid;
628 636 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
629 637 headerCWF[ i ].time[0] = 0x00;
630 638 headerCWF[ i ].time[0] = 0x00;
631 639 headerCWF[ i ].time[0] = 0x00;
632 640 headerCWF[ i ].time[0] = 0x00;
633 641 headerCWF[ i ].time[0] = 0x00;
634 642 headerCWF[ i ].time[0] = 0x00;
635 643 }
636 644 return LFR_SUCCESSFUL;
637 645 }
638 646
639 647 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
640 648 {
641 649 unsigned int i;
642 650
643 651 for (i=0; i<7; i++)
644 652 {
645 653 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
646 654 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
647 655 headerCWF[ i ].reserved = DEFAULT_RESERVED;
648 656 headerCWF[ i ].userApplication = CCSDS_USER_APP;
649 657
650 658 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
651 659 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
652 660 if (i == 0)
653 661 {
654 662 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
655 663 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
656 664 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
657 665 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
658 666 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
659 667 }
660 668 else if (i == 6)
661 669 {
662 670 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
663 671 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
664 672 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
665 673 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
666 674 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
667 675 }
668 676 else
669 677 {
670 678 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
671 679 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
672 680 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
673 681 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
674 682 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
675 683 }
676 684 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
677 685 // DATA FIELD HEADER
678 686 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
679 687 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
680 688 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
681 689 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
682 690 // AUXILIARY DATA HEADER
683 691 headerCWF[ i ].sid = SID_NORM_CWF_F3;
684 692 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
685 693 headerCWF[ i ].time[0] = 0x00;
686 694 headerCWF[ i ].time[0] = 0x00;
687 695 headerCWF[ i ].time[0] = 0x00;
688 696 headerCWF[ i ].time[0] = 0x00;
689 697 headerCWF[ i ].time[0] = 0x00;
690 698 headerCWF[ i ].time[0] = 0x00;
691 699 }
692 700 return LFR_SUCCESSFUL;
693 701 }
694 702
695 703 void reset_waveforms( void )
696 704 {
697 705 int i = 0;
698 706
699 707 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
700 708 {
701 709 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
702 710 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
703 711 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
704 712
705 713 //***
706 714 // F1
707 715 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
708 716 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
709 717 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
710 718
711 719 //***
712 720 // F2
713 721 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
714 722 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
715 723 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
716 724
717 725 //***
718 726 // F3
719 727 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
720 728 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
721 729 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
722 730 }
723 731 }
724 732
725 733 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
726 734 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
727 735 {
728 736 /** This function sends SWF CCSDS packets (F2, F1 or F0).
729 737 *
730 738 * @param waveform points to the buffer containing the data that will be send.
731 739 * @param sid is the source identifier of the data that will be sent.
732 740 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
733 741 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
734 742 * contain information to setup the transmission of the data packets.
735 743 *
736 744 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
737 745 *
738 746 */
739 747
740 748 unsigned int i;
741 749 int ret;
742 750 rtems_status_code status;
743 751 spw_ioctl_pkt_send spw_ioctl_send_SWF;
744 752
745 753 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
746 754 spw_ioctl_send_SWF.options = 0;
747 755
748 756 ret = LFR_DEFAULT;
749 757
750 758 for (i=0; i<7; i++) // send waveform
751 759 {
752 760 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
753 761 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
754 762 // BUILD THE DATA
755 763 if (i==6) {
756 764 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
757 765 }
758 766 else {
759 767 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
760 768 }
761 769 // SET PACKET SEQUENCE COUNTER
762 770 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
763 771 // SET PACKET TIME
764 772 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
765 773 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
766 774 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
767 775 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
768 776 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
769 777 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
770 778 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
771 779 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
772 780 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
773 781 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
774 782 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
775 783 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
776 784 // SEND PACKET
777 785 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
778 786 if (status != RTEMS_SUCCESSFUL) {
779 787 printf("%d-%d, ERR %d\n", sid, i, (int) status);
780 788 ret = LFR_DEFAULT;
781 789 }
782 790 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
783 791 }
784 792
785 793 return ret;
786 794 }
787 795
788 796 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
789 797 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
790 798 {
791 799 /** This function sends CWF CCSDS packets (F2, F1 or F0).
792 800 *
793 801 * @param waveform points to the buffer containing the data that will be send.
794 802 * @param sid is the source identifier of the data that will be sent.
795 803 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
796 804 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
797 805 * contain information to setup the transmission of the data packets.
798 806 *
799 807 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
800 808 *
801 809 */
802 810
803 811 unsigned int i;
804 812 int ret;
805 813 rtems_status_code status;
806 814 spw_ioctl_pkt_send spw_ioctl_send_CWF;
807 815
808 816 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
809 817 spw_ioctl_send_CWF.options = 0;
810 818
811 819 ret = LFR_DEFAULT;
812 820
813 821 for (i=0; i<7; i++) // send waveform
814 822 {
815 823 int coarseTime = 0x00;
816 824 int fineTime = 0x00;
817 825 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
818 826 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
819 827 // BUILD THE DATA
820 828 if (i==6) {
821 829 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
822 830 }
823 831 else {
824 832 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
825 833 }
826 834 // SET PACKET SEQUENCE COUNTER
827 835 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
828 836 // SET PACKET TIME
829 837 coarseTime = time_management_regs->coarse_time;
830 838 fineTime = time_management_regs->fine_time;
831 839 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
832 840 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
833 841 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
834 842 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
835 843 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
836 844 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
837 845 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
838 846 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
839 847 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
840 848 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
841 849 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
842 850 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
843 851 // SEND PACKET
844 852 if (sid == SID_NORM_CWF_F3)
845 853 {
846 854 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
847 855 if (status != RTEMS_SUCCESSFUL) {
848 856 printf("%d-%d, ERR %d\n", sid, i, (int) status);
849 857 ret = LFR_DEFAULT;
850 858 }
851 859 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
852 860 }
853 861 else
854 862 {
855 863 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
856 864 if (status != RTEMS_SUCCESSFUL) {
857 865 printf("%d-%d, ERR %d\n", sid, i, (int) status);
858 866 ret = LFR_DEFAULT;
859 867 }
860 868 }
861 869 }
862 870
863 871 return ret;
864 872 }
865 873
866 874 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
867 875 {
868 876 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
869 877 *
870 878 * @param waveform points to the buffer containing the data that will be send.
871 879 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
872 880 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
873 881 * contain information to setup the transmission of the data packets.
874 882 *
875 883 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
876 884 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
877 885 *
878 886 */
879 887
880 888 unsigned int i;
881 889 int ret;
882 890 rtems_status_code status;
883 891 spw_ioctl_pkt_send spw_ioctl_send_CWF;
884 892 char *sample;
885 893
886 894 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
887 895 spw_ioctl_send_CWF.options = 0;
888 896
889 897 ret = LFR_DEFAULT;
890 898
891 899 //**********************
892 900 // BUILD CWF3_light DATA
893 901 for ( i=0; i< 2048; i++)
894 902 {
895 903 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
896 904 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
897 905 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
898 906 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
899 907 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
900 908 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
901 909 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
902 910 }
903 911
904 912 //*********************
905 913 // SEND CWF3_light DATA
906 914
907 915 for (i=0; i<7; i++) // send waveform
908 916 {
909 917 int coarseTime = 0x00;
910 918 int fineTime = 0x00;
911 919 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
912 920 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
913 921 // BUILD THE DATA
914 922 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
915 923 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
916 924 }
917 925 else {
918 926 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
919 927 }
920 928 // SET PACKET SEQUENCE COUNTER
921 929 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
922 930 // SET PACKET TIME
923 931 coarseTime = time_management_regs->coarse_time;
924 932 fineTime = time_management_regs->fine_time;
925 933 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
926 934 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
927 935 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
928 936 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
929 937 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
930 938 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
931 939 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
932 940 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
933 941 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
934 942 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
935 943 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
936 944 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
937 945 // SEND PACKET
938 946 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
939 947 if (status != RTEMS_SUCCESSFUL) {
940 948 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
941 949 ret = LFR_DEFAULT;
942 950 }
943 951 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
944 952 }
945 953
946 954 return ret;
947 955 }
948 956
949 957
950 958 //**************
951 959 // wfp registers
952 960 void set_wfp_data_shaping()
953 961 {
954 962 /** This function sets the data_shaping register of the waveform picker module.
955 963 *
956 964 * The value is read from one field of the parameter_dump_packet structure:\n
957 965 * bw_sp0_sp1_r0_r1
958 966 *
959 967 */
960 968
961 969 unsigned char data_shaping;
962 970
963 971 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
964 972 // waveform picker : [R1 R0 SP1 SP0 BW]
965 973
966 974 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
967 975
968 976 #ifdef GSA
969 977 #else
970 978 new_waveform_picker_regs->data_shaping =
971 979 ( (data_shaping & 0x10) >> 4 ) // BW
972 980 + ( (data_shaping & 0x08) >> 2 ) // SP0
973 981 + ( (data_shaping & 0x04) ) // SP1
974 982 + ( (data_shaping & 0x02) << 2 ) // R0
975 983 + ( (data_shaping & 0x01) << 4 ); // R1
976 984 #endif
977 985 }
978 986
979 987 char set_wfp_delta_snapshot()
980 988 {
981 989 /** This function sets the delta_snapshot register of the waveform picker module.
982 990 *
983 991 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
984 992 * - sy_lfr_n_swf_p[0]
985 993 * - sy_lfr_n_swf_p[1]
986 994 *
987 995 */
988 996
989 997 char ret;
990 998 unsigned int delta_snapshot;
991 999 unsigned int aux;
992 1000
993 1001 aux = 0;
994 1002 ret = LFR_DEFAULT;
995 1003
996 1004 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
997 1005 + parameter_dump_packet.sy_lfr_n_swf_p[1];
998 1006
999 1007 #ifdef GSA
1000 1008 #else
1001 1009 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
1002 1010 {
1003 1011 aux = MIN_DELTA_SNAPSHOT;
1004 1012 ret = LFR_DEFAULT;
1005 1013 }
1006 1014 else
1007 1015 {
1008 1016 aux = delta_snapshot ;
1009 1017 ret = LFR_SUCCESSFUL;
1010 1018 }
1011 1019 new_waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
1012 1020 #endif
1013 1021
1014 1022 return ret;
1015 1023 }
1016 1024
1017 1025 void set_wfp_burst_enable_register( unsigned char mode)
1018 1026 {
1019 1027 /** This function sets the waveform picker burst_enable register depending on the mode.
1020 1028 *
1021 1029 * @param mode is the LFR mode to launch.
1022 1030 *
1023 1031 * The burst bits shall be before the enable bits.
1024 1032 *
1025 1033 */
1026 1034
1027 1035 #ifdef GSA
1028 1036 #else
1029 1037 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1030 1038 // the burst bits shall be set first, before the enable bits
1031 1039 switch(mode) {
1032 1040 case(LFR_MODE_NORMAL):
1033 1041 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1034 1042 // new_waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1035 1043 // new_waveform_picker_regs->run_burst_enable = 0x07; // [0000 0111] enable f2 f1 f0
1036 new_waveform_picker_regs->run_burst_enable = 0x01; // [0000 0111] enable f0
1044 // new_waveform_picker_regs->run_burst_enable = 0x01; // [0000 0001] enable f0
1045 new_waveform_picker_regs->run_burst_enable = 0x04; // [0000 0100] enable f0
1037 1046 break;
1038 1047 case(LFR_MODE_BURST):
1039 1048 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1040 1049 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1041 1050 break;
1042 1051 case(LFR_MODE_SBM1):
1043 1052 new_waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1044 1053 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1045 1054 break;
1046 1055 case(LFR_MODE_SBM2):
1047 1056 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1048 1057 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1049 1058 break;
1050 1059 default:
1051 1060 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1052 1061 break;
1053 1062 }
1054 1063 #endif
1055 1064 }
1056 1065
1057 1066 void reset_wfp_run_burst_enable()
1058 1067 {
1059 1068 /** This function resets the waveform picker burst_enable register.
1060 1069 *
1061 1070 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1062 1071 *
1063 1072 */
1064 1073
1065 1074 #ifdef GSA
1066 1075 #else
1067 1076 new_waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1068 1077 #endif
1069 1078 }
1070 1079
1071 1080 void reset_wfp_status()
1072 1081 {
1073 1082 /** This function resets the waveform picker status register.
1074 1083 *
1075 1084 * All status bits are set to 0 [new_err full_err full].
1076 1085 *
1077 1086 */
1078 1087
1079 1088 #ifdef GSA
1080 1089 #else
1081 1090 new_waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1082 1091 #endif
1083 1092 }
1084 1093
1085 1094 void reset_new_waveform_picker_regs()
1086 1095 {
1087 1096 /** This function resets the waveform picker module registers.
1088 1097 *
1089 1098 * The registers affected by this function are located at the following offset addresses:
1090 1099 * - 0x00 data_shaping
1091 1100 * - 0x04 run_burst_enable
1092 1101 * - 0x08 addr_data_f0
1093 1102 * - 0x0C addr_data_f1
1094 1103 * - 0x10 addr_data_f2
1095 1104 * - 0x14 addr_data_f3
1096 1105 * - 0x18 status
1097 1106 * - 0x1C delta_snapshot
1098 1107 * - 0x20 delta_f0
1099 1108 * - 0x24 delta_f0_2
1100 1109 * - 0x28 delta_f1
1101 1110 * - 0x2c delta_f2
1102 1111 * - 0x30 nb_data_by_buffer
1103 1112 * - 0x34 nb_snapshot_param
1104 1113 * - 0x38 start_date
1105 1114 * - 0x3c nb_word_in_buffer
1106 1115 *
1107 1116 */
1108 1117
1118 unsigned int wf_snap_f0_aligned;
1119 unsigned int wf_snap_f1_aligned;
1120 unsigned int wf_snap_f2_aligned;
1121 unsigned int wf_cont_f3_aligned;
1122
1109 1123 new_waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1110 1124 new_waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1111 new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1112 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // 0x0c
1113 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // 0x10
1114 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // 0x14
1125 wf_snap_f0_aligned = address_alignment( wf_snap_f0 );
1126 wf_snap_f1_aligned = address_alignment( wf_snap_f1 );
1127 wf_snap_f2_aligned = address_alignment( wf_snap_f2 );
1128 wf_cont_f3_aligned = address_alignment( wf_cont_f3 );
1129 new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0_aligned); // 0x08
1130 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_aligned); // 0x0c
1131 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_aligned); // 0x10
1132 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_aligned); // 0x14
1133 new_waveform_picker_regs->status = 0x00; // 0x18
1134 // new_waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776
1135 // new_waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1136 new_waveform_picker_regs->delta_snapshot = 0x2000; // 0x1c 32 * 256 = 8192
1137 new_waveform_picker_regs->delta_f0 = 0xbf5; // 0x20 *** 1013
1138 new_waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 [7 bits]
1139 new_waveform_picker_regs->delta_f1 = 0xbc0; // 0x28 *** 960
1140 // new_waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 74240
1141 new_waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 3072
1142 new_waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1 => nb samples -1
1143 new_waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048 => nb samples
1144 new_waveform_picker_regs->start_date = 0x00; // 0x38
1145 new_waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146
1146 }
1147
1148 void reset_new_waveform_picker_regs_alt()
1149 {
1150 /** This function resets the waveform picker module registers.
1151 *
1152 * The registers affected by this function are located at the following offset addresses:
1153 * - 0x00 data_shaping
1154 * - 0x04 run_burst_enable
1155 * - 0x08 addr_data_f0
1156 * - 0x0C addr_data_f1
1157 * - 0x10 addr_data_f2
1158 * - 0x14 addr_data_f3
1159 * - 0x18 status
1160 * - 0x1C delta_snapshot
1161 * - 0x20 delta_f0
1162 * - 0x24 delta_f0_2
1163 * - 0x28 delta_f1
1164 * - 0x2c delta_f2
1165 * - 0x30 nb_data_by_buffer
1166 * - 0x34 nb_snapshot_param
1167 * - 0x38 start_date
1168 * - 0x3c nb_word_in_buffer
1169 *
1170 */
1171
1172 unsigned int wf_snap_f0_aligned;
1173 unsigned int wf_snap_f1_aligned;
1174 unsigned int wf_snap_f2_aligned;
1175 unsigned int wf_cont_f3_aligned;
1176
1177 new_waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1178 new_waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1179 wf_snap_f0_aligned = address_alignment( wf_snap_f0 );
1180 wf_snap_f1_aligned = address_alignment( wf_snap_f1 );
1181 wf_snap_f2_aligned = address_alignment( wf_snap_f2 );
1182 wf_cont_f3_aligned = address_alignment( wf_cont_f3 );
1183 new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0_aligned); // 0x08
1184 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_aligned); // 0x0c
1185 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_aligned); // 0x10
1186 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_aligned); // 0x14
1115 1187 new_waveform_picker_regs->status = 0x00; // 0x18
1116 1188 // new_waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776
1117 1189 new_waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1118 new_waveform_picker_regs->delta_f0 = 0x3f5; // 0x20 *** 1013
1190 new_waveform_picker_regs->delta_f0 = 0xbf5; // 0x20 *** 1013
1119 1191 new_waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 [7 bits]
1120 new_waveform_picker_regs->delta_f1 = 0x3c0; // 0x28 *** 960
1192 new_waveform_picker_regs->delta_f1 = 0xbc0; // 0x28 *** 960
1121 1193 // new_waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 74240
1122 1194 new_waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 3072
1123 new_waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1
1124 new_waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048
1195 new_waveform_picker_regs->nb_data_by_buffer = 0x07; // 0x30 *** 7
1196 new_waveform_picker_regs->snapshot_param = 0x10; // 0x34 *** 16
1125 1197 new_waveform_picker_regs->start_date = 0x00; // 0x38
1126 new_waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146
1198 new_waveform_picker_regs->nb_word_in_buffer = 0x34; // 0x3c *** (3 * 8 + 2) * 2
1127 1199 }
1128 1200
1129 1201 //*****************
1130 1202 // local parameters
1131 1203 void set_local_sbm1_nb_cwf_max()
1132 1204 {
1133 1205 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1134 1206 *
1135 1207 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1136 1208 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1137 1209 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1138 1210 *
1139 1211 */
1140 1212 param_local.local_sbm1_nb_cwf_max = 2 *
1141 1213 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1142 1214 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1143 1215 }
1144 1216
1145 1217 void set_local_sbm2_nb_cwf_max()
1146 1218 {
1147 1219 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1148 1220 *
1149 1221 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1150 1222 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1151 1223 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1152 1224 *
1153 1225 */
1154 1226
1155 1227 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1156 1228 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1157 1229 }
1158 1230
1159 1231 void set_local_nb_interrupt_f0_MAX()
1160 1232 {
1161 1233 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1162 1234 *
1163 1235 * This parameter is used for the SM validation only.\n
1164 1236 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1165 1237 * module before launching a basic processing.
1166 1238 *
1167 1239 */
1168 1240
1169 1241 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1170 1242 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1171 1243 }
1172 1244
1173 1245 void reset_local_sbm1_nb_cwf_sent()
1174 1246 {
1175 1247 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1176 1248 *
1177 1249 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1178 1250 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1179 1251 *
1180 1252 */
1181 1253
1182 1254 param_local.local_sbm1_nb_cwf_sent = 0;
1183 1255 }
1184 1256
1185 1257 void reset_local_sbm2_nb_cwf_sent()
1186 1258 {
1187 1259 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1188 1260 *
1189 1261 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1190 1262 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1191 1263 *
1192 1264 */
1193 1265
1194 1266 param_local.local_sbm2_nb_cwf_sent = 0;
1195 1267 }
1196 1268
1197 1269 rtems_id get_pkts_queue_id( void )
1198 1270 {
1199 1271 rtems_id queue_id;
1200 1272 rtems_status_code status;
1201 1273 rtems_name queue_send_name;
1202 1274
1203 1275 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1204 1276
1205 1277 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1206 1278 if (status != RTEMS_SUCCESSFUL)
1207 1279 {
1208 1280 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1209 1281 }
1210 1282 return queue_id;
1211 1283 }
1212 1284
1213 1285 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1214 1286 {
1215 1287 unsigned short *sequence_cnt;
1216 1288 unsigned short segmentation_grouping_flag;
1217 1289 unsigned short new_packet_sequence_control;
1218 1290
1219 1291 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1220 1292 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1221 1293 {
1222 1294 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1223 1295 }
1224 1296 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1225 1297 {
1226 1298 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1227 1299 }
1228 1300 else
1229 1301 {
1230 1302 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1231 1303 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1232 1304 }
1233 1305
1234 1306 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1235 1307 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1236 1308
1237 1309 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1238 1310
1239 1311 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1240 1312 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1241 1313
1242 1314 // increment the sequence counter for the next packet
1243 1315 if ( *sequence_cnt < SEQ_CNT_MAX)
1244 1316 {
1245 1317 *sequence_cnt = *sequence_cnt + 1;
1246 1318 }
1247 1319 else
1248 1320 {
1249 1321 *sequence_cnt = 0;
1250 1322 }
1251 1323 }
1324
1325 unsigned int address_alignment( volatile int *address)
1326 {
1327 unsigned char i;
1328 unsigned char lastByte;
1329 unsigned int addressAligned;
1330
1331 addressAligned = (unsigned int) address;
1332
1333 PRINTF1("address %x\n", addressAligned );
1334
1335 for (i=0; i<256; i++)
1336 {
1337 lastByte = (unsigned char) ( addressAligned & 0x000000ff ) ;
1338 if (lastByte == 0x00)
1339 {
1340 break;
1341 }
1342 else
1343 {
1344 addressAligned = addressAligned + 1;
1345 }
1346 }
1347
1348 PRINTF2("i = %d, address %x\n", i, (int) addressAligned);
1349
1350 return addressAligned;
1351 }
General Comments 0
You need to be logged in to leave comments. Login now