##// END OF EJS Templates
All modes partially implemented...
paul@pc-solar1.lab-lpp.local -
r22:c4e2ba2dd2be default
parent child
Show More
@@ -1,225 +1,225
1 1 #############################################################################
2 # Makefile for building: bin/fsw$(SW_VERSION)
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Jun 14 07:50:58 2013
2 # Makefile for building: bin/fsw-gsa
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Jun 18 14:00:55 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=4 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=5 -DPRINT_MESSAGES_ON_CONSOLE -DGSA
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 OBJECTS = obj/wf_handler.o \
53 53 obj/tc_handler.o \
54 54 obj/fsw_processing.o \
55 55 obj/fsw_misc.o \
56 56 obj/fsw_init.o \
57 57 obj/fsw_globals.o
58 58 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
59 59 /usr/lib64/qt4/mkspecs/common/linux.conf \
60 60 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
61 61 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
62 62 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
63 63 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
64 64 /usr/lib64/qt4/mkspecs/qconfig.pri \
65 65 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
66 66 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
67 67 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
68 68 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
69 69 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
70 70 sparc.pri \
71 71 /usr/lib64/qt4/mkspecs/features/release.prf \
72 72 /usr/lib64/qt4/mkspecs/features/default_post.prf \
73 73 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
74 74 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
75 75 /usr/lib64/qt4/mkspecs/features/resources.prf \
76 76 /usr/lib64/qt4/mkspecs/features/uic.prf \
77 77 /usr/lib64/qt4/mkspecs/features/yacc.prf \
78 78 /usr/lib64/qt4/mkspecs/features/lex.prf \
79 79 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
80 80 fsw-qt.pro
81 QMAKE_TARGET = fsw$(SW_VERSION)
81 QMAKE_TARGET = fsw-gsa
82 82 DESTDIR = bin/
83 TARGET = bin/fsw$(SW_VERSION)
83 TARGET = bin/fsw-gsa
84 84
85 85 first: all
86 86 ####### Implicit rules
87 87
88 88 .SUFFIXES: .o .c .cpp .cc .cxx .C
89 89
90 90 .cpp.o:
91 91 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
92 92
93 93 .cc.o:
94 94 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
95 95
96 96 .cxx.o:
97 97 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
98 98
99 99 .C.o:
100 100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101 101
102 102 .c.o:
103 103 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
104 104
105 105 ####### Build rules
106 106
107 107 all: Makefile $(TARGET)
108 108
109 109 $(TARGET): $(OBJECTS)
110 110 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
111 111 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
112 112
113 113 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
114 114 /usr/lib64/qt4/mkspecs/common/linux.conf \
115 115 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
116 116 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
117 117 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
118 118 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
119 119 /usr/lib64/qt4/mkspecs/qconfig.pri \
120 120 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
121 121 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
122 122 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
123 123 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
124 124 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
125 125 sparc.pri \
126 126 /usr/lib64/qt4/mkspecs/features/release.prf \
127 127 /usr/lib64/qt4/mkspecs/features/default_post.prf \
128 128 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
129 129 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
130 130 /usr/lib64/qt4/mkspecs/features/resources.prf \
131 131 /usr/lib64/qt4/mkspecs/features/uic.prf \
132 132 /usr/lib64/qt4/mkspecs/features/yacc.prf \
133 133 /usr/lib64/qt4/mkspecs/features/lex.prf \
134 134 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
135 135 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
136 136 /usr/lib64/qt4/mkspecs/common/unix.conf:
137 137 /usr/lib64/qt4/mkspecs/common/linux.conf:
138 138 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
139 139 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
140 140 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
141 141 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
142 142 /usr/lib64/qt4/mkspecs/qconfig.pri:
143 143 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
144 144 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
145 145 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
146 146 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
147 147 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
148 148 sparc.pri:
149 149 /usr/lib64/qt4/mkspecs/features/release.prf:
150 150 /usr/lib64/qt4/mkspecs/features/default_post.prf:
151 151 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
152 152 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
153 153 /usr/lib64/qt4/mkspecs/features/resources.prf:
154 154 /usr/lib64/qt4/mkspecs/features/uic.prf:
155 155 /usr/lib64/qt4/mkspecs/features/yacc.prf:
156 156 /usr/lib64/qt4/mkspecs/features/lex.prf:
157 157 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
158 158 qmake: FORCE
159 159 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
160 160
161 161 dist:
162 @$(CHK_DIR_EXISTS) obj/fsw$(SW_VERSION)1.0.0 || $(MKDIR) obj/fsw$(SW_VERSION)1.0.0
163 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw$(SW_VERSION)1.0.0/ && (cd `dirname obj/fsw$(SW_VERSION)1.0.0` && $(TAR) fsw$(SW_VERSION)1.0.0.tar fsw$(SW_VERSION)1.0.0 && $(COMPRESS) fsw$(SW_VERSION)1.0.0.tar) && $(MOVE) `dirname obj/fsw$(SW_VERSION)1.0.0`/fsw$(SW_VERSION)1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw$(SW_VERSION)1.0.0
162 @$(CHK_DIR_EXISTS) obj/fsw-gsa1.0.0 || $(MKDIR) obj/fsw-gsa1.0.0
163 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw-gsa1.0.0/ && (cd `dirname obj/fsw-gsa1.0.0` && $(TAR) fsw-gsa1.0.0.tar fsw-gsa1.0.0 && $(COMPRESS) fsw-gsa1.0.0.tar) && $(MOVE) `dirname obj/fsw-gsa1.0.0`/fsw-gsa1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw-gsa1.0.0
164 164
165 165
166 166 clean:compiler_clean
167 167 -$(DEL_FILE) $(OBJECTS)
168 168 -$(DEL_FILE) *~ core *.core
169 169
170 170
171 171 ####### Sub-libraries
172 172
173 173 distclean: clean
174 174 -$(DEL_FILE) $(TARGET)
175 175 -$(DEL_FILE) Makefile
176 176
177 177
178 178 grmon:
179 179 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
180 180
181 181 check: first
182 182
183 183 compiler_rcc_make_all:
184 184 compiler_rcc_clean:
185 185 compiler_uic_make_all:
186 186 compiler_uic_clean:
187 187 compiler_image_collection_make_all: qmake_image_collection.cpp
188 188 compiler_image_collection_clean:
189 189 -$(DEL_FILE) qmake_image_collection.cpp
190 190 compiler_yacc_decl_make_all:
191 191 compiler_yacc_decl_clean:
192 192 compiler_yacc_impl_make_all:
193 193 compiler_yacc_impl_clean:
194 194 compiler_lex_make_all:
195 195 compiler_lex_clean:
196 196 compiler_clean:
197 197
198 198 ####### Compile
199 199
200 200 obj/wf_handler.o: ../src/wf_handler.c
201 201 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
202 202
203 203 obj/tc_handler.o: ../src/tc_handler.c
204 204 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
205 205
206 206 obj/fsw_processing.o: ../src/fsw_processing.c
207 207 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
208 208
209 209 obj/fsw_misc.o: ../src/fsw_misc.c
210 210 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
211 211
212 212 obj/fsw_init.o: ../src/fsw_init.c
213 213 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
214 214
215 215 obj/fsw_globals.o: ../src/fsw_globals.c
216 216 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
217 217
218 218 ####### Install
219 219
220 220 install: FORCE
221 221
222 222 uninstall: FORCE
223 223
224 224 FORCE:
225 225
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,51 +1,51
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** cpu_usage_report *** gsa
4 CONFIG += console verbose
4 CONFIG += console verbose gsa
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 9 # flight software version
10 SW_VERSION=-0-5
10 SWVERSION=-0-5
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=5
15 15
16 16 contains( CONFIG, verbose ) {
17 17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 18 }
19 19
20 20 contains( CONFIG, cpu_usage_report ) {
21 21 DEFINES += PRINT_TASK_STATISTICS
22 22 }
23 23
24 TARGET = fsw$(SW_VERSION)
24 TARGET = fsw
25 25 contains( CONFIG, gsa ) {
26 26 DEFINES += GSA
27 TARGET = fsw-gsa$(SW_VERSION)
27 TARGET = fsw-gsa
28 28 }
29 29
30 30 INCLUDEPATH += \
31 31 ../src \
32 32 ../header
33 33
34 34 SOURCES += \
35 35 ../src/wf_handler.c \
36 36 ../src/tc_handler.c \
37 37 ../src/fsw_processing.c \
38 38 ../src/fsw_misc.c \
39 39 ../src/fsw_init.c \
40 40 ../src/fsw_globals.c
41 41
42 42 HEADERS += \
43 43 ../header/wf_handler.h \
44 44 ../header/tc_handler.h \
45 45 ../header/grlib_regs.h \
46 46 ../header/fsw_processing.h \
47 47 ../header/fsw_params.h \
48 48 ../header/fsw_misc.h \
49 49 ../header/fsw_init.h \
50 50 ../header/ccsds_types.h
51 51
@@ -1,265 +1,265
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by Qt Creator 2.4.1, 2013-06-17T15:56:28. -->
3 <!-- Written by Qt Creator 2.4.1, 2013-06-18T14:38:28. -->
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 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15 15 <value type="QString" key="language">Cpp</value>
16 16 <valuemap type="QVariantMap" key="value">
17 17 <value type="QString" key="CurrentPreferences">CppGlobal</value>
18 18 </valuemap>
19 19 </valuemap>
20 20 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21 21 <value type="QString" key="language">QmlJS</value>
22 22 <valuemap type="QVariantMap" key="value">
23 23 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
24 24 </valuemap>
25 25 </valuemap>
26 26 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27 27 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
28 28 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29 29 <value type="int" key="EditorConfiguration.IndentSize">4</value>
30 30 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
31 31 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
32 32 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
33 33 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
34 34 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
35 35 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
36 36 <value type="int" key="EditorConfiguration.TabSize">8</value>
37 37 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
38 38 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
39 39 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
40 40 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
41 41 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
42 42 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
43 43 </valuemap>
44 44 </data>
45 45 <data>
46 46 <variable>ProjectExplorer.Project.PluginSettings</variable>
47 47 <valuemap type="QVariantMap"/>
48 48 </data>
49 49 <data>
50 50 <variable>ProjectExplorer.Project.Target.0</variable>
51 51 <valuemap type="QVariantMap">
52 52 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
53 53 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
54 54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
55 55 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
56 56 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
58 58 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
59 59 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
60 60 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
61 61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
62 62 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
63 63 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
64 64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
65 65 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
66 66 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
67 67 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
68 68 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
69 69 </valuemap>
70 70 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
71 71 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
72 72 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
73 73 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
74 74 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
75 75 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
76 76 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
77 77 </valuemap>
78 78 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
79 79 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
80 80 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
81 81 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
82 82 </valuemap>
83 83 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
84 84 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
85 85 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
86 86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
87 87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
88 88 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
89 89 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
90 90 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
91 91 </valuemap>
92 92 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
93 93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
94 94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
96 96 </valuemap>
97 97 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
98 98 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
99 99 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
100 100 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
101 101 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
102 102 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
103 103 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
104 104 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
105 105 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
106 106 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
107 107 </valuemap>
108 108 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
109 109 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
110 110 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
111 111 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
112 112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
113 113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
115 115 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
116 116 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
117 117 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
118 118 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
119 119 </valuemap>
120 120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
121 121 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
122 122 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
123 123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
124 124 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
125 125 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
126 126 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
127 127 </valuemap>
128 128 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
129 129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
130 130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
131 131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
132 132 </valuemap>
133 133 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
134 134 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
135 135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
136 136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
137 137 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
138 138 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
139 139 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
140 140 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
141 141 </valuemap>
142 142 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
143 143 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
144 144 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
145 145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
146 146 </valuemap>
147 147 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
148 148 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
149 149 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
150 150 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
151 151 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
152 152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
153 153 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
154 154 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
155 155 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
156 156 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
157 157 </valuemap>
158 158 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
159 159 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
160 160 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
161 161 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
162 162 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
163 163 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
164 164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
165 165 </valuemap>
166 166 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
167 167 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
168 168 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
169 169 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
170 170 </valuemap>
171 171 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
172 172 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
173 173 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
174 174 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
175 175 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
176 176 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
177 177 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
178 178 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
179 179 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
180 180 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
181 181 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
182 182 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
183 183 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
184 184 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
185 185 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
186 186 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
187 187 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
188 188 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
189 189 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
190 190 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
191 191 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
192 192 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
193 193 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
194 194 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
195 195 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
196 196 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
197 197 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
198 198 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
199 199 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
200 200 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
201 201 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
202 202 <value type="int">0</value>
203 203 <value type="int">1</value>
204 204 <value type="int">2</value>
205 205 <value type="int">3</value>
206 206 <value type="int">4</value>
207 207 <value type="int">5</value>
208 208 <value type="int">6</value>
209 209 <value type="int">7</value>
210 210 <value type="int">8</value>
211 211 <value type="int">9</value>
212 212 <value type="int">10</value>
213 213 <value type="int">11</value>
214 214 <value type="int">12</value>
215 215 <value type="int">13</value>
216 216 <value type="int">14</value>
217 217 </valuelist>
218 218 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
219 219 <value type="int">0</value>
220 220 <value type="int">1</value>
221 221 <value type="int">2</value>
222 222 <value type="int">3</value>
223 223 <value type="int">4</value>
224 224 <value type="int">5</value>
225 225 <value type="int">6</value>
226 226 <value type="int">7</value>
227 227 <value type="int">8</value>
228 228 <value type="int">9</value>
229 229 <value type="int">10</value>
230 230 <value type="int">11</value>
231 231 <value type="int">12</value>
232 232 <value type="int">13</value>
233 233 <value type="int">14</value>
234 234 </valuelist>
235 235 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
236 236 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
237 237 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
238 238 <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
239 239 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
240 240 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
241 241 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
242 242 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
243 243 <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
244 244 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
245 245 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
246 246 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
247 247 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
248 248 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
249 249 </valuemap>
250 250 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
251 251 </valuemap>
252 252 </data>
253 253 <data>
254 254 <variable>ProjectExplorer.Project.TargetCount</variable>
255 255 <value type="int">1</value>
256 256 </data>
257 257 <data>
258 258 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
259 259 <value type="QString">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
260 260 </data>
261 261 <data>
262 262 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
263 263 <value type="int">10</value>
264 264 </data>
265 265 </qtcreator>
@@ -1,77 +1,76
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <bsp.h> // for the LEON_Unmask_interrupt function
6 6 #include <stdio.h>
7 7 #include <unistd.h> // for the read call
8 8 #include <sys/ioctl.h> // for the ioctl call
9 9 #include <ccsds_types.h>
10 10 #include <grspw.h>
11 11 #include <fsw_init.h>
12 12
13 13 extern int fdSPW;
14 14 extern rtems_name misc_name[ ];
15 15 extern rtems_name misc_id[ ];
16 16 extern rtems_id Task_id[ ]; // array of task ids
17 17 // MODE PARAMETERS
18 18 extern struct param_common_str param_common;
19 19 extern struct param_norm_str param_norm;
20 20 extern struct param_sbm1_str param_sbm1;
21 21 extern struct param_sbm2_str param_sbm2;
22 22 extern Packet_TM_LFR_HK_t housekeeping_packet;
23 23 extern time_management_regs_t *time_management_regs;
24 24 extern waveform_picker_regs_t *waveform_picker_regs;
25 25 extern gptimer_regs_t *gptimer_regs;
26 26
27 27 //****
28 28 // ISR
29 29 rtems_isr commutation_isr1( rtems_vector_number vector );
30 30 rtems_isr commutation_isr2( rtems_vector_number vector );
31 31
32 32 //**********************
33 33 // GENERAL USE FUNCTIONS
34 34 void initLookUpTableForCRC( void );
35 35 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
36 36
37 37 //*********************
38 38 // ACCEPTANCE FUNCTIONS
39 39 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
40 40
41 41 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
42 42 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
43 43 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
44 44 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
45 45
46 46 //***********
47 47 // RTEMS TASK
48 48 rtems_task recv_task( rtems_task_argument unused );
49 49 rtems_task actn_task( rtems_task_argument unused );
50 50 rtems_task dumb_task( rtems_task_argument unused );
51 51 int create_message_queue( void );
52 52
53 53 //***********
54 54 // TC ACTIONS
55 55 int action_default(ccsdsTelecommandPacket_t *TC);
56 56 int action_default_alt(ccsdsTelecommandPacket_t *TC);
57 57 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
58 58 //
59 59 int stop_current_mode();
60 60 int enter_normal_mode();
61 int enter_burst_mode();
61 62 int enter_sbm1_mode();
63 int enter_sbm2_mode();
62 64 int action_load_comm(ccsdsTelecommandPacket_t *TC);
63 65 int action_load_norm(ccsdsTelecommandPacket_t *TC);
64 66 int action_enter(ccsdsTelecommandPacket_t *TC);
65 67 int action_updt_time(ccsdsTelecommandPacket_t *TC);
66 68 //
67 69 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
68 70 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
69 71 void close_action(ccsdsTelecommandPacket_t *TC, int result);
70 //
71 rtems_status_code restart_if_needed(rtems_id id);
72 rtems_status_code suspend_if_needed(rtems_id id);
73 72
74 73 #endif // TC_HANDLER_H_INCLUDED
75 74
76 75
77 76
@@ -1,40 +1,40
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <fsw_params.h>
6 6 #include <grspw.h>
7 7 #include <grlib_regs.h>
8 8 #include <ccsds_types.h>
9 9 #include <stdio.h>
10 10 #include <fsw_init.h>
11 11 #include <math.h>
12 12
13 13 #define pi 3.1415
14 14
15 15 //#include <sys/ioctl.h>
16 16
17 17 extern rtems_id Task_id[]; /* array of task ids */
18 18 extern int fdSPW;
19 19 extern volatile int wf_snap_f0[ ];
20 20 extern volatile int wf_snap_f1[ ];
21 21 extern volatile int wf_snap_f1_bis[ ];
22 22 extern volatile int wf_snap_f2[ ];
23 extern volatile int wf_snap_f2_bis[ ];
23 24 extern volatile int wf_cont_f3[ ];
24 25 extern waveform_picker_regs_t *waveform_picker_regs;
25 26
26 27 rtems_isr waveforms_isr( rtems_vector_number vector );
27 rtems_isr waveforms_isr_alternative( rtems_vector_number vector );
28 28 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
29 29 rtems_task wfrm_task(rtems_task_argument argument);
30 30
31 31 //******************
32 32 // general functions
33 33 void init_waveforms( void );
34 34 void reset_waveforms( void );
35 35 void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform, unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
36 36 void init_waveform_picker_regs();
37 37 void set_data_shaping_parameters(unsigned char parameters);
38 38 int build_value(int value1, int value0);
39 39
40 40 #endif // WF_HANDLER_H_INCLUDED
@@ -1,54 +1,55
1 1 #include <fsw_processing.h>
2 2 #include <rtems.h>
3 3 #include <ccsds_types.h>
4 4
5 5 // RTEMS GLOBAL VARIABLES
6 6 rtems_name misc_name[5];
7 7 rtems_name misc_id[5];
8 8 rtems_id Task_id[15]; /* array of task ids */
9 9 rtems_name Task_name[15]; /* array of task names */
10 10 int fdSPW = 0;
11 11 int fdUART = 0;
12 12
13 13 spectral_matrices_regs_t *spectral_matrices_regs = NULL;
14 14
15 15 // APB CONFIGURATION REGISTERS
16 16 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
17 17 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
18 18 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
19 19
20 20 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
21 21 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
22 22 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
23 23 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
24 24 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
25 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
25 26 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
26 27
27 28 // SPECTRAL MATRICES GLOBAL VARIABLES
28 29 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
29 30 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
30 31 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
31 32 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
32 33 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
33 34 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
34 35 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
35 36 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
36 37 //
37 38 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
38 39 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
39 40
40 41 // MODE PARAMETERS
41 42 struct param_common_str param_common;
42 43 struct param_norm_str param_norm;
43 44 struct param_burst_str param_burst;
44 45 struct param_sbm1_str param_sbm1;
45 46 struct param_sbm2_str param_sbm2;
46 47
47 48 // HK PACKETS
48 49 Packet_TM_LFR_HK_t housekeeping_packet;
49 50 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
50 51
51 52 // BASIC PARAMETERS GLOBAL VARIABLES
52 53 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
53 54 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
54 55
@@ -1,448 +1,449
1 1 //*************************
2 2 // GPL reminder to be added
3 3 //*************************
4 4
5 5 #include <rtems.h>
6 6
7 7 /* configuration information */
8 8
9 9 #define CONFIGURE_INIT
10 10
11 11 #include <bsp.h> /* for device driver prototypes */
12 12
13 13 /* configuration information */
14 14
15 15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17 17
18 18 #define CONFIGURE_MAXIMUM_TASKS 15
19 19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 24 #define CONFIGURE_MAXIMUM_PERIODS 5
25 25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
26 26
27 27 #include <rtems/confdefs.h>
28 28
29 29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
30 30 #ifdef RTEMS_DRVMGR_STARTUP
31 31 #ifdef LEON3
32 32 /* Add Timer and UART Driver */
33 33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
34 34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
35 35 #endif
36 36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
37 37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
38 38 #endif
39 39 #endif
40 40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
41 41 #include <drvmgr/drvmgr_confdefs.h>
42 42 #endif
43 43
44 44 #include <fsw_init.h>
45 45 #include <fsw_config.c>
46 46
47 47 char *lstates[6] = {"Error-reset",
48 48 "Error-wait",
49 49 "Ready",
50 50 "Started",
51 51 "Connecting",
52 52 "Run"
53 53 };
54 54
55 55 rtems_task Init( rtems_task_argument ignored )
56 56 {
57 57 rtems_status_code status;
58 58 rtems_isr_entry old_isr_handler;
59 59
60 60 PRINTF("\n\n\n\n\n")
61 61 PRINTF("***************************\n")
62 62 PRINTF("** START Flight Software **\n")
63 63 PRINTF("***************************\n")
64 64 PRINTF("\n\n")
65 65
66 66 //send_console_outputs_on_serial_port();
67 67 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
68 68
69 69 initLookUpTableForCRC(); // in tc_handler.h
70 70 init_default_mode_parameters();
71 71 init_housekeeping_parameters();
72 72 create_message_queue();
73 73
74 create_names();
75 create_all_tasks();
76 start_all_tasks();
74 create_names(); // create all names
75 create_all_tasks(); // create all tasks
76 start_all_tasks(); // start all tasks
77 stop_current_mode(); // go in STANDBY mode
77 78
78 79 grspw_timecode_callback = &timecode_irq_handler;
79 80
80 81 configure_spw_link();
81 82
82 83 //****************************
83 84 // Spectral Matrices simulator
84 85 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
85 86 IRQ_SPARC_SM, spectral_matrices_isr );
86 87
87 88 //**********
88 89 // WAVEFORMS
89 90 // simulator
90 91
91 92 #ifdef GSA
92 93 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
93 94 IRQ_SPARC_WF, waveforms_simulator_isr );
94 95 #else
95 96 // configure the registers of the waveform picker
96 97 init_waveform_picker_regs();
97 98 // configure the waveform picker interrupt service routine
98 99 status = rtems_interrupt_catch( waveforms_isr,
99 100 IRQ_SPARC_WAVEFORM_PICKER,
100 101 &old_isr_handler) ;
101 102 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
102 103 #endif
103 104
104 105 //**********
105 106
106 107 //*****************************************
107 108 // irq handling of the time management unit
108 109 status = rtems_interrupt_catch( commutation_isr1,
109 110 IRQ_SPARC_TIME1,
110 111 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
111 112 if (status==RTEMS_SUCCESSFUL) {
112 113 PRINTF("OK *** commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
113 114 }
114 115
115 116 status = rtems_interrupt_catch( commutation_isr2,
116 117 IRQ_SPARC_TIME2,
117 118 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
118 119 if (status==RTEMS_SUCCESSFUL) {
119 120 PRINTF("OK *** commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
120 121 }
121 122
122 123 LEON_Unmask_interrupt( IRQ_TIME1 );
123 124 LEON_Unmask_interrupt( IRQ_TIME2 );
124 125
125 126 #ifdef GSA
126 127 //if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
127 128 // printf("in INIT *** Error sending event to WFRM\n");
128 129 //}
129 130 #endif
130 131
131 132 status = rtems_task_delete(RTEMS_SELF);
132 133
133 134 }
134 135
135 136 rtems_task spiq_task(rtems_task_argument unused)
136 137 {
137 138 rtems_event_set event_out;
138 139 rtems_status_code status;
139 140
140 141 while(true){
141 142 PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
142 143 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
143 144
144 145 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
145 146 PRINTF("in SPIQ *** Error suspending RECV Task\n")
146 147 }
147 148 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task
148 149 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
149 150 }
150 151
151 152 configure_spw_link();
152 153
153 154 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
154 155 if (status!=RTEMS_SUCCESSFUL) {
155 156 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
156 157 }
157 158
158 159 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) { // restart RECV task
159 160 PRINTF("in SPIQ *** Error restarting RECV Task\n")
160 161 }
161 162 }
162 163 }
163 164
164 165 void init_default_mode_parameters(void)
165 166 {
166 167 // COMMON PARAMETERS
167 168 param_common.sy_lfr_common0 = 0x00;
168 169 param_common.sy_lfr_common1 = 0x10; // default value 0 0 0 1 0 0 0 0
169 170 // NORMAL MODE
170 171 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
171 172 param_norm.sy_lfr_n_swf_p = 300; // sec
172 173 param_norm.sy_lfr_n_asm_p = 3600; // sec
173 174 param_norm.sy_lfr_n_bp_p0 = 4; // sec
174 175 param_norm.sy_lfr_n_bp_p1 = 20; // sec
175 176 // BURST MODE
176 177 param_burst.sy_lfr_b_bp_p0 = 1; // sec
177 178 param_burst.sy_lfr_b_bp_p1 = 5; // sec
178 179 // SBM1 MODE
179 180 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
180 181 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
181 182 // SBM2 MODE
182 183 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
183 184 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
184 185 }
185 186
186 187 void init_housekeeping_parameters(void)
187 188 {
188 189 unsigned int i = 0;
189 190 unsigned int j = 0;
190 191 unsigned int k = 0;
191 192 char *parameters;
192 193
193 194 parameters = (char*) &housekeeping_packet.lfr_status_word;
194 195 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
195 196 {
196 197 parameters[i] = 0x00;
197 198 }
198 199 // init status word
199 200 housekeeping_packet.lfr_status_word[0] = 0x00;
200 201 housekeeping_packet.lfr_status_word[1] = 0x00;
201 202 // init software version
202 203 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
203 204 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
204 205 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
205 206 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
206 207 // init sequence counters
207 208 for (i = 0; i<SEQ_CNT_NB_PID; i++)
208 209 {
209 210 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
210 211 {
211 212 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
212 213 {
213 214 sequenceCounters[i][j][k] = 0x00;
214 215 }
215 216 }
216 217 }
217 218 }
218 219
219 220 int create_names( void )
220 221 {
221 222 // task names
222 223 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
223 224 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
224 225 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
225 226 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
226 227 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
227 228 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
228 229 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
229 230 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
230 231 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
231 232 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
232 233
233 234 // rate monotonic period name
234 235 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
235 236
236 237 return 0;
237 238 }
238 239
239 240 int create_all_tasks( void )
240 241 {
241 242 rtems_status_code status;
242 243
243 244 // RECV
244 245 status = rtems_task_create(
245 246 Task_name[TASKID_RECV], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
246 247 RTEMS_DEFAULT_MODES,
247 248 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
248 249 );
249 250 // ACTN
250 251 status = rtems_task_create(
251 252 Task_name[TASKID_ACTN], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
252 253 RTEMS_DEFAULT_MODES,
253 254 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
254 255 );
255 256 // SPIQ
256 257 status = rtems_task_create(
257 258 Task_name[TASKID_SPIQ], 5, RTEMS_MINIMUM_STACK_SIZE * 2,
258 259 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
259 260 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
260 261 );
261 262 // SMIQ
262 263 status = rtems_task_create(
263 264 Task_name[TASKID_SMIQ], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
264 265 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
265 266 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
266 267 );
267 268 // STAT
268 269 status = rtems_task_create(
269 270 Task_name[TASKID_STAT], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
270 271 RTEMS_DEFAULT_MODES,
271 272 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
272 273 );
273 274 // AVF0
274 275 status = rtems_task_create(
275 276 Task_name[TASKID_AVF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
276 277 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
277 278 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
278 279 );
279 280 // BPF0
280 281 status = rtems_task_create(
281 282 Task_name[TASKID_BPF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
282 283 RTEMS_DEFAULT_MODES,
283 284 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
284 285 );
285 286 // WFRM
286 287 status = rtems_task_create(
287 288 Task_name[TASKID_WFRM], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
288 289 RTEMS_DEFAULT_MODES,
289 290 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
290 291 );
291 292 // DUMB
292 293 status = rtems_task_create(
293 294 Task_name[TASKID_DUMB], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
294 295 RTEMS_DEFAULT_MODES,
295 296 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
296 297 );
297 298 // HOUS
298 299 status = rtems_task_create(
299 300 Task_name[TASKID_HOUS], 199, RTEMS_MINIMUM_STACK_SIZE * 2,
300 301 RTEMS_DEFAULT_MODES,
301 302 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
302 303 );
303 304
304 305 return 0;
305 306 }
306 307
307 308 int start_all_tasks( void )
308 309 {
309 310 rtems_status_code status;
310 311
311 312 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
312 313 if (status!=RTEMS_SUCCESSFUL) {
313 314 PRINTF("In INIT *** Error starting TASK_SPIQ\n")
314 315 }
315 316
316 317 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
317 318 if (status!=RTEMS_SUCCESSFUL) {
318 319 PRINTF("In INIT *** Error starting TASK_RECV\n")
319 320 }
320 321
321 322 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
322 323 if (status!=RTEMS_SUCCESSFUL) {
323 324 PRINTF("In INIT *** Error starting TASK_ACTN\n")
324 325 }
325 326
326 327 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
327 328 if (status!=RTEMS_SUCCESSFUL) {
328 329 PRINTF("In INIT *** Error starting TASK_BPPR\n")
329 330 }
330 331
331 332 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
332 333 if (status!=RTEMS_SUCCESSFUL) {
333 334 PRINTF("In INIT *** Error starting TASK_STAT\n")
334 335 }
335 336
336 337 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
337 338 if (status!=RTEMS_SUCCESSFUL) {
338 339 PRINTF("In INIT *** Error starting TASK_AVF0\n")
339 340 }
340 341
341 342 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
342 343 if (status!=RTEMS_SUCCESSFUL) {
343 344 PRINTF("In INIT *** Error starting TASK_BPF0\n")
344 345 }
345 346
346 347 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
347 348 if (status!=RTEMS_SUCCESSFUL) {
348 349 PRINTF("In INIT *** Error starting TASK_WFRM\n")
349 350 }
350 351
351 352 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
352 353 if (status!=RTEMS_SUCCESSFUL) {
353 354 PRINTF("In INIT *** Error starting TASK_DUMB\n")
354 355 }
355 356
356 357 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
357 358 if (status!=RTEMS_SUCCESSFUL) {
358 359 PRINTF("In INIT *** Error starting TASK_HOUS\n")
359 360 }
360 361
361 362 return 0;
362 363 }
363 364
364 365 int configure_spw_link( void )
365 366 {
366 367 rtems_status_code status;
367 368
368 369 close(fdSPW); // close the device if it is already open
369 370 PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
370 371 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
371 372 if (fdSPW<0) PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
372 373 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
373 374 PRINTF(".")
374 375 fflush(stdout);
375 376 close(fdSPW); // close the device
376 377 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
377 378 if (fdSPW<0) PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
378 379 rtems_task_wake_after(100);
379 380 }
380 381
381 382 PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
382 383
383 384 configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
384 385 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
385 386
386 387 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
387 388 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
388 389 //
389 390 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
390 391 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
391 392 //
392 393 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
393 394 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
394 395 //
395 396 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
396 397 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
397 398 //
398 399 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
399 400 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
400 401 //
401 402 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909);
402 403 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
403 404
404 405 PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
405 406
406 407 return RTEMS_SUCCESSFUL;
407 408 }
408 409
409 410 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force
410 411 {
411 412 unsigned int *spwptr = (unsigned int*) regAddr;
412 413
413 414 if (val == 1) {
414 415 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
415 416 }
416 417 if (val== 0) {
417 418 *spwptr = *spwptr & 0xffdfffff;
418 419 }
419 420 }
420 421
421 422 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable
422 423 {
423 424 unsigned int *spwptr = (unsigned int*) regAddr;
424 425
425 426 if (val == 1)
426 427 {
427 428 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
428 429 }
429 430 if (val== 0)
430 431 {
431 432 *spwptr = *spwptr & 0xfffdffff;
432 433 }
433 434 }
434 435
435 436 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
436 437 {
437 438 rtems_status_code status;
438 439 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
439 440 return status;
440 441 }
441 442
442 443 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc)
443 444 {
444 445 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
445 446 printf("In timecode_irq_handler *** Error sending event to DUMB\n");
446 447 }
447 448 }
448 449
@@ -1,942 +1,969
1 1 #include <tc_handler.h>
2 2 #include <fsw_params.h>
3 3
4 4 char *DumbMessages[5] = {"in DUMB *** default",
5 5 "in DUMB *** timecode_irq_handler",
6 6 "in DUMB *** waveforms_isr",
7 7 "",
8 8 ""
9 9 };
10 10
11 11 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
12 12 unsigned char currentTC_COMPUTED_CRC[2];
13 13 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
14 14 unsigned int currentTM_length;
15 15 unsigned char currentTC_processedFlag;
16 16
17 17 unsigned int lookUpTableForCRC[256];
18 18
19 19 //**********************
20 20 // GENERAL USE FUNCTIONS
21 21 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
22 22 {
23 23 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
24 24 }
25 25
26 26 void initLookUpTableForCRC( void )
27 27 {
28 28 unsigned int i;
29 29 unsigned int tmp;
30 30
31 31 for (i=0; i<256; i++)
32 32 {
33 33 tmp = 0;
34 34 if((i & 1) != 0) {
35 35 tmp = tmp ^ 0x1021;
36 36 }
37 37 if((i & 2) != 0) {
38 38 tmp = tmp ^ 0x2042;
39 39 }
40 40 if((i & 4) != 0) {
41 41 tmp = tmp ^ 0x4084;
42 42 }
43 43 if((i & 8) != 0) {
44 44 tmp = tmp ^ 0x8108;
45 45 }
46 46 if((i & 16) != 0) {
47 47 tmp = tmp ^ 0x1231;
48 48 }
49 49 if((i & 32) != 0) {
50 50 tmp = tmp ^ 0x2462;
51 51 }
52 52 if((i & 64) != 0) {
53 53 tmp = tmp ^ 0x48c4;
54 54 }
55 55 if((i & 128) != 0) {
56 56 tmp = tmp ^ 0x9188;
57 57 }
58 58 lookUpTableForCRC[i] = tmp;
59 59 }
60 60 }
61 61
62 62 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
63 63 {
64 64 unsigned int Chk;
65 65 int j;
66 66 Chk = 0xffff; // reset the syndrom to all ones
67 67 for (j=0; j<sizeOfData; j++) {
68 68 Chk = Crc_opt(data[j], Chk);
69 69 }
70 70 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
71 71 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
72 72 }
73 73
74 74 //*********************
75 75 // ACCEPTANCE FUNCTIONS
76 76 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
77 77 {
78 78 int ret = 0;
79 79 rtems_status_code status;
80 80 spw_ioctl_pkt_send spw_ioctl_send;
81 81 TMHeader_t TM_header;
82 82 unsigned int code = 0;
83 83 unsigned char computed_CRC[2];
84 84 char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
85 85
86 86 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
87 87 code = acceptTM( TC, tc_len_recv ) ;
88 88 if ( (code == ILLEGAL_APID) | (code == WRONG_LEN_PACKET) | (code == INCOR_CHECKSUM)
89 89 | (code == ILL_TYPE) | (code == ILL_SUBTYPE) | (code == WRONG_APP_DATA) )
90 90 { // generate TM_LFR_TC_EXE_CORRUPTED
91 91 // BUILD HEADER
92 92 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_EXE_CORR, 0, 0, &TM_header);
93 93 // BUILD DATA
94 94 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
95 95 // PREPARE TM SENDING
96 96 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
97 97 spw_ioctl_send.hdr = (char*) &TM_header;
98 98 spw_ioctl_send.dlen = 16;
99 99 spw_ioctl_send.data = data;
100 100 // SEND PACKET
101 101 write_spw(&spw_ioctl_send);
102 102 }
103 103 else { // send valid TC to the action launcher
104 104 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
105 105 ret = -1;
106 106 }
107 107 return ret;
108 108 }
109 109
110 110 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
111 111 {
112 112 unsigned char ret = 0;
113 113 unsigned char pid = 0;
114 114 unsigned char category = 0;
115 115 unsigned int length = 0;
116 116 unsigned char packetType = 0;
117 117 unsigned char packetSubtype = 0;
118 118 unsigned char * CCSDSContent = NULL;
119 119
120 120 // APID check *** APID on 2 bytes
121 121 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
122 122 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
123 123 length = (TMPacket->packetLength[0] * 256) + TMPacket->packetLength[1];
124 124 packetType = TMPacket->dataFieldHeader[1];
125 125 packetSubtype = TMPacket->dataFieldHeader[2];
126 126
127 127 if (pid!=CCSDS_PROCESS_ID) {
128 128 ret = ILLEGAL_APID;
129 129 }
130 130 else if (category!=CCSDS_PACKET_CATEGORY) {
131 131 ret = ILLEGAL_APID;
132 132 }
133 133 else if (length != TC_LEN_RCV ) { // packet length check
134 134 ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
135 135 }
136 136 else if (length >= CCSDS_TC_PKT_MAX_SIZE) {
137 137 ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
138 138 }
139 139 else if (packetType == TC_TYPE_GEN){ // service type, subtype and packet length check
140 140 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
141 141 case TC_SUBTYPE_RESET:
142 142 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
143 143 ret = WRONG_LEN_PACKET;
144 144 }
145 145 else {
146 146 ret = CCSDS_TM_VALID;
147 147 }
148 148 break;
149 149 case TC_SUBTYPE_LOAD_COMM:
150 150 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
151 151 ret = WRONG_LEN_PACKET;
152 152 }
153 153 else {
154 154 ret = CCSDS_TM_VALID;
155 155 }
156 156 break;
157 157 case TC_SUBTYPE_LOAD_NORM:
158 158 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
159 159 ret = WRONG_LEN_PACKET;
160 160 }
161 161 else {
162 162 ret = CCSDS_TM_VALID;
163 163 }
164 164 break;
165 165 case TC_SUBTYPE_LOAD_BURST:
166 166 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
167 167 ret = WRONG_LEN_PACKET;
168 168 }
169 169 else {
170 170 ret = CCSDS_TM_VALID;
171 171 }
172 172 break;
173 173 case TC_SUBTYPE_LOAD_SBM1:
174 174 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
175 175 ret = WRONG_LEN_PACKET;
176 176 }
177 177 else {
178 178 ret = CCSDS_TM_VALID;
179 179 }
180 180 break;
181 181 case TC_SUBTYPE_LOAD_SBM2:
182 182 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
183 183 ret = WRONG_LEN_PACKET;
184 184 }
185 185 else {
186 186 ret = CCSDS_TM_VALID;
187 187 }
188 188 break;
189 189 case TC_SUBTYPE_DUMP:
190 190 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
191 191 ret = WRONG_LEN_PACKET;
192 192 }
193 193 else {
194 194 ret = CCSDS_TM_VALID;
195 195 }
196 196 break;
197 197 case TC_SUBTYPE_ENTER:
198 198 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
199 199 ret = WRONG_LEN_PACKET;
200 200 }
201 201 else {
202 202 ret = CCSDS_TM_VALID;
203 203 }
204 204 break;
205 205 case TC_SUBTYPE_UPDT_INFO:
206 206 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
207 207 ret = WRONG_LEN_PACKET;
208 208 }
209 209 else {
210 210 ret = CCSDS_TM_VALID;
211 211 }
212 212 break;
213 213 case TC_SUBTYPE_EN_CAL:
214 214 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
215 215 ret = WRONG_LEN_PACKET;
216 216 }
217 217 else {
218 218 ret = CCSDS_TM_VALID;
219 219 }
220 220 break;
221 221 case TC_SUBTYPE_DIS_CAL:
222 222 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
223 223 ret = WRONG_LEN_PACKET;
224 224 }
225 225 else {
226 226 ret = CCSDS_TM_VALID;
227 227 }
228 228 break;
229 229 default:
230 230 ret = ILL_SUBTYPE;
231 231 break;
232 232 }
233 233 }
234 234 else if (packetType == TC_TYPE_TIME){
235 235 if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) {
236 236 ret = ILL_SUBTYPE;
237 237 }
238 238 else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
239 239 ret = WRONG_LEN_PACKET;
240 240 }
241 241 else {
242 242 ret = CCSDS_TM_VALID;
243 243 }
244 244 }
245 245 else {
246 246 ret = ILL_TYPE;
247 247 }
248 248
249 249 // source ID check // Source ID not documented in the ICD
250 250
251 251 // packet error control, CRC check
252 252 if ( ret == CCSDS_TM_VALID ) {
253 253 CCSDSContent = (unsigned char*) TMPacket->packetID;
254 254 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
255 255 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
256 256 ret = INCOR_CHECKSUM;
257 257 }
258 258 else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
259 259 ret = INCOR_CHECKSUM;
260 260 }
261 261 else {
262 262 ret = CCSDS_TM_VALID;
263 263 }
264 264 }
265 265
266 266 return ret;
267 267 }
268 268
269 269 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
270 270 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader)
271 271 {
272 272 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
273 273 TMHeader->protocolIdentifier = 0x02;
274 274 TMHeader->reserved = 0x00;
275 275 TMHeader->userApplication = 0x00;
276 276 TMHeader->packetID[0] = 0x0c;
277 277 TMHeader->packetSequenceControl[0] = 0xc0;
278 278 TMHeader->packetSequenceControl[1] = 0x00;
279 279 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
280 280 TMHeader->packetLength[1] = (unsigned char) packetLength;
281 281 TMHeader->dataFieldHeader[0] = 0x10;
282 282 TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
283 283 switch (tm_type){
284 284 case(TM_LFR_TC_EXE_OK):
285 285 TMHeader->packetID[1] = 0xc1;
286 286 TMHeader->dataFieldHeader[1] = 1; // type
287 287 TMHeader->dataFieldHeader[2] = 7; // subtype
288 288 break;
289 289 case(TM_LFR_TC_EXE_ERR):
290 290 TMHeader->packetID[1] = 0xc1;
291 291 TMHeader->dataFieldHeader[1] = 1; // type
292 292 TMHeader->dataFieldHeader[2] = 8; // subtype
293 293 break;
294 294 case(TM_LFR_HK):
295 295 TMHeader->packetID[1] = 0xc4;
296 296 TMHeader->dataFieldHeader[1] = 3; // type
297 297 TMHeader->dataFieldHeader[2] = 25; // subtype
298 298 break;
299 299 case(TM_LFR_SCI):
300 300 TMHeader->packetID[1] = 0xcc;
301 301 TMHeader->dataFieldHeader[1] = 21; // type
302 302 TMHeader->dataFieldHeader[2] = 3; // subtype
303 303 break;
304 304 case(TM_LFR_SCI_SBM):
305 305 TMHeader->packetID[1] = 0xfc;
306 306 TMHeader->dataFieldHeader[1] = 21; // type
307 307 TMHeader->dataFieldHeader[2] = 3; // subtype
308 308 break;
309 309 case(TM_LFR_PAR_DUMP):
310 310 TMHeader->packetID[1] = 0xc9;
311 311 TMHeader->dataFieldHeader[1] = 181; // type
312 312 TMHeader->dataFieldHeader[2] = 31; // subtype
313 313 break;
314 314 default:
315 315 return 0;
316 316 }
317 317 TMHeader->dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
318 318 TMHeader->dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
319 319 TMHeader->dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
320 320 TMHeader->dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
321 321 TMHeader->dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
322 322 TMHeader->dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
323 323 return 1;
324 324 }
325 325
326 326 unsigned char TM_build_header_bis( enum TM_TYPE tm_type, unsigned int packetLength,
327 327 unsigned int coarseTime, unsigned int fineTime, Packet_TM_LFR_TC_EXE_t *packet)
328 328 {
329 329
330 330 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
331 331 packet->protocolIdentifier = 0x02;
332 332 packet->reserved = 0x00;
333 333 packet->userApplication = 0x00;
334 334 packet->packetID[0] = 0x0c;
335 335 packet->packetSequenceControl[0] = 0xc0;
336 336 packet->packetSequenceControl[1] = 0x00;
337 337 packet->packetLength[0] = (unsigned char) (packetLength>>8);
338 338 packet->packetLength[1] = (unsigned char) packetLength;
339 339 packet->dataFieldHeader[0] = 0x10;
340 340 packet->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
341 341 switch (tm_type){
342 342 case(TM_LFR_TC_EXE_OK):
343 343 packet->packetID[1] = 0xc1;
344 344 packet->dataFieldHeader[1] = 1; // type
345 345 packet->dataFieldHeader[2] = 7; // subtype
346 346 break;
347 347 case(TM_LFR_TC_EXE_ERR):
348 348 packet->packetID[1] = 0xc1;
349 349 packet->dataFieldHeader[1] = 1; // type
350 350 packet->dataFieldHeader[2] = 8; // subtype
351 351 break;
352 352 case(TM_LFR_HK):
353 353 packet->packetID[1] = 0xc4;
354 354 packet->dataFieldHeader[1] = 3; // type
355 355 packet->dataFieldHeader[2] = 25; // subtype
356 356 break;
357 357 case(TM_LFR_SCI):
358 358 packet->packetID[1] = 0xcc;
359 359 packet->dataFieldHeader[1] = 21; // type
360 360 packet->dataFieldHeader[2] = 3; // subtype
361 361 break;
362 362 case(TM_LFR_SCI_SBM):
363 363 packet->packetID[1] = 0xfc;
364 364 packet->dataFieldHeader[1] = 21; // type
365 365 packet->dataFieldHeader[2] = 3; // subtype
366 366 break;
367 367 case(TM_LFR_PAR_DUMP):
368 368 packet->packetID[1] = 0xc9;
369 369 packet->dataFieldHeader[1] = 181; // type
370 370 packet->dataFieldHeader[2] = 31; // subtype
371 371 break;
372 372 default:
373 373 return 0;
374 374 }
375 375 packet->dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
376 376 packet->dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
377 377 packet->dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
378 378 packet->dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
379 379 packet->dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
380 380 packet->dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
381 381 return 1;
382 382 }
383 383
384 384 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
385 385 {
386 386 unsigned int packetLength;
387 387 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1];
388 388 switch (SID){
389 389 case (SID_NOT_EXE):
390 390 break;
391 391 case (SID_NOT_IMP):
392 392 data[0] = 0x9c;
393 393 data[1] = 0x42;
394 394 data[2] = TC->packetID[0];
395 395 data[3] = TC->packetID[1];
396 396 data[4] = TC->packetSequenceControl[0];
397 397 data[5] = TC->packetSequenceControl[1];
398 398 data[6] = TC->dataFieldHeader[1]; // type
399 399 data[7] = TC->dataFieldHeader[2]; // subtype
400 400 break;
401 401 case (SID_EXE_ERR):
402 402 break;
403 403 case (SID_EXE_CORR):
404 404 data[0] = 0x9c;
405 405 data[1] = 0x45;
406 406 data[2] = TC->packetID[0];
407 407 data[3] = TC->packetID[1];
408 408 data[4] = TC->packetSequenceControl[0];
409 409 data[5] = TC->packetSequenceControl[1];
410 410 data[6] = TC->dataFieldHeader[1]; // type
411 411 data[7] = TC->dataFieldHeader[2]; // subtype
412 412 data[8] = currentTC_LEN_RCV[0];
413 413 data[9] = currentTC_LEN_RCV[1];
414 414 data[10] = TC->packetLength[0];
415 415 data[11] = TC->packetLength[1];
416 416 data[12] = TC->dataAndCRC[packetLength];
417 417 data[13] = TC->dataAndCRC[packetLength+1];
418 418 data[14] = computed_CRC[0];
419 419 data[15] = computed_CRC[1];
420 420 break;
421 421 default:
422 422 return 0;
423 423 }
424 424 return 1;
425 425 }
426 426
427 427 int create_message_queue( void )
428 428 {
429 429 rtems_status_code status;
430 430 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
431 431 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
432 432 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
433 433 if (status!=RTEMS_SUCCESSFUL) {
434 434 PRINTF("in create_message_queue *** error creating message queue\n")
435 435 }
436 436
437 437 return 0;
438 438 }
439 439
440 440 //***********
441 441 // RTEMS TASK
442 442 rtems_task recv_task( rtems_task_argument unused )
443 443 {
444 444 int len = 0;
445 445 unsigned int i = 0;
446 446 unsigned int data_length = 0;
447 447 ccsdsTelecommandPacket_t currentTC;
448 448 char data[100];
449 449
450 450 for(i=0; i<100; i++) data[i] = 0;
451 451
452 452 PRINTF("in RECV *** \n")
453 453
454 454 while(1)
455 455 {
456 456 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
457 457 if (len == -1){ // error during the read call
458 458 PRINTF("In RECV *** last read call returned -1\n")
459 459 if (rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) {
460 460 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
461 461 }
462 462 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) {
463 463 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
464 464 }
465 465 }
466 466 else {
467 467 PRINTF1("Got pck of length %d\n", len+1)
468 468 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
469 469 PRINTF("In RECV *** packet lenght too short\n")
470 470 }
471 471 else {
472 472 currentTC_LEN_RCV[0] = 0x00;
473 473 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
474 474 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
475 475 // CHECK THE TC AND BUILD THE APPROPRIATE TM
476 476 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
477 477 if (data_length!=-1)
478 478 {
479 479 }
480 480 }
481 481 }
482 482 }
483 483 }
484 484
485 485 rtems_task actn_task( rtems_task_argument unused )
486 486 {
487 487 int result = 0;
488 488 unsigned int val;
489 489 rtems_status_code status; // RTEMS status code
490 490 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
491 491 size_t size; // size of the incoming TC packet
492 492 unsigned char subtype = 0; // subtype of the current TC packet
493 493
494 494 PRINTF("in ACTN *** \n")
495 495
496 496 while(1)
497 497 {
498 498 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
499 499 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
500 if (status!=RTEMS_SUCCESSFUL) PRINTF1("in task ACTN *** error receiving a message, code %d \n", status)
500 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
501 501 else
502 502 {
503 503 subtype = TC.dataFieldHeader[2];
504 504 switch(subtype)
505 505 {
506 506 case TC_SUBTYPE_RESET:
507 507 result = action_default( &TC );
508 508 break;
509 509 //
510 510 case TC_SUBTYPE_LOAD_COMM:
511 511 result = action_load_comm( &TC );
512 512 close_action( &TC, result );
513 513 break;
514 514 //
515 515 case TC_SUBTYPE_LOAD_NORM:
516 516 result = action_load_norm( &TC );
517 517 close_action( &TC, result );
518 518 break;
519 519 //
520 520 case TC_SUBTYPE_LOAD_BURST:
521 521 result = action_default( &TC );
522 522 close_action( &TC, result );
523 523 break;
524 524 //
525 525 case TC_SUBTYPE_LOAD_SBM1:
526 526 result = action_default( &TC );
527 527 close_action( &TC, result );
528 528 break;
529 529 //
530 530 case TC_SUBTYPE_LOAD_SBM2:
531 531 result = action_default( &TC );
532 532 close_action( &TC, result );
533 533 break;
534 534 //
535 535 case TC_SUBTYPE_DUMP:
536 536 result = action_default( &TC );
537 537 close_action( &TC, result );
538 538 break;
539 539 //
540 540 case TC_SUBTYPE_ENTER:
541 if ( (housekeeping_packet.lfr_status_word[0] & 0xf0) != LFR_MODE_STANDBY)
542 {
543 status = stop_current_mode();
544 }
545 if (status != RTEMS_SUCCESSFUL)
546 {
547 PRINTF("ERR *** in task ACTN *** TC_SUBTYPE_ENTER *** stop_current_mode\n")
548 }
541 549 result = action_enter( &TC );
542 550 close_action( &TC, result );
543 551 break;
544 552 //
545 553 case TC_SUBTYPE_UPDT_INFO:
546 554 result = action_default( &TC );
547 555 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
548 556 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
549 557 val++;
550 558 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
551 559 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
552 560 break;
553 561 //
554 562 case TC_SUBTYPE_EN_CAL:
555 563 result = action_default( &TC );
556 564 break;
557 565 //
558 566 case TC_SUBTYPE_DIS_CAL:
559 567 result = action_default( &TC );
560 568 break;
561 569 //
562 570 case TC_SUBTYPE_UPDT_TIME:
563 571 result = action_updt_time( &TC );
564 572 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
565 573 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
566 574 val++;
567 575 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
568 576 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
569 577 break;
570 578 //
571 579 default:
572 580 break;
573 581 }
574 582 }
575 583 }
576 584 }
577 585
578 586 rtems_task dumb_task( rtems_task_argument unused )
579 587 {
580 588 unsigned int coarse_time = 0;
581 589 unsigned int fine_time = 0;
582 590 unsigned int indice = 0;
583 591 unsigned int shiftedIndice = 0;
584 592 rtems_event_set event_out;
585 593
586 594 PRINTF("in DUMB *** \n")
587 595
588 596 while(1){
589 597 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
590 598 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
591 599 indice = 0;
592 600 shiftedIndice = (unsigned int) event_out;
593 601 while(!(shiftedIndice & 0x0001))
594 602 {
595 603 shiftedIndice = shiftedIndice >> 1;
596 604 indice++;
597 605 }
598 606 coarse_time = time_management_regs->coarse_time;
599 607 fine_time = time_management_regs->fine_time;
600 608 printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[indice]);
601 609 }
602 610 }
603 611
604 612 //***********
605 613 // TC ACTIONS
606 614
607 615 int action_default(ccsdsTelecommandPacket_t *TC)
608 616 {
609 617 Packet_TM_LFR_TC_EXE_t packet;
610 618
611 619 TM_build_header_bis( TM_LFR_TC_EXE_ERR, TM_LEN_NOT_IMP,
612 620 time_management_regs->coarse_time, time_management_regs->fine_time, &packet);
613 621
614 622 packet.data[0] = 0x9c;
615 623 packet.data[1] = 0x42;
616 624 packet.data[2] = TC->packetID[0];
617 625 packet.data[3] = TC->packetID[1];
618 626 packet.data[4] = TC->packetSequenceControl[0];
619 627 packet.data[5] = TC->packetSequenceControl[1];
620 628 packet.data[6] = TC->dataFieldHeader[1]; // type
621 629 packet.data[7] = TC->dataFieldHeader[2]; // subtype
622 630
623 631 // SEND DATA
624 632 if (write ( fdSPW, &packet, LEN_TM_LFR_TC_EXE_NOT_IMP)==-1) {
625 633 PRINTF("ERR *** in action_default *** send TM packet\n");
626 634 }
627 635
628 636 return LFR_DEFAULT;
629 637 }
630 638
631 639 int action_enter(ccsdsTelecommandPacket_t *TC)
632 640 {
633 rtems_status_code status;
641 rtems_status_code status = RTEMS_SUCCESSFUL;
634 642 unsigned char lfr_mode = TC->dataAndCRC[1];
635 643 printf("enter mode %d\n", lfr_mode);
636 644 switch(lfr_mode)
637 645 {
638 646 //********
639 647 // STANDBY
640 648 case(LFR_MODE_STANDBY):
641 status = stop_current_mode();
642 if (status != RTEMS_SUCCESSFUL)
643 {
644 PRINTF("in action_enter *** error going back to STANDBY mode\n")
645 }
646 649 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_STANDBY << 4) + 0x0d);
647 650 break;
648 651
649 652 //******
650 653 // NORMAL
651 654 case(LFR_MODE_NORMAL):
652 status = stop_current_mode();
653 655 status = enter_normal_mode();
654 656 if (status == RTEMS_SUCCESSFUL)
655 657 {
656 658 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_NORMAL << 4) + 0x0d);
657 659 }
658 660 break;
659 661
660 662 //******
661 663 // BURST
662 664 case(LFR_MODE_BURST):
663 status = stop_current_mode();
665 status = enter_burst_mode();
664 666 if (status == RTEMS_SUCCESSFUL)
665 667 {
666 668 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_BURST << 4) + 0x0d);
667 669 }
668 670 break;
669 671
670 672 //*****
671 673 // SBM1
672 674 case(LFR_MODE_SBM1):
673 status = stop_current_mode();
674 675 status = enter_sbm1_mode();
675 676 if (status == RTEMS_SUCCESSFUL)
676 677 {
677 678 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_SBM1 << 4) + 0x0d);
678 679 }
679 680 break;
680 681
681 682 //*****
682 683 // SBM2
683 684 case(LFR_MODE_SBM2):
684 status = stop_current_mode();
685 status = enter_sbm2_mode();
685 686 if (status == RTEMS_SUCCESSFUL)
686 687 {
687 688 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_SBM2 << 4) + 0x0d);
688 689 }
689 690 break;
690 691
691 692 //********
692 693 // DEFAULT
693 694 default:
694 status = stop_current_mode();
695 if (status == RTEMS_SUCCESSFUL)
696 {
697 695 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_STANDBY << 4) + 0x0d);
698 }
699 696 break;
700 697 }
701 698 return status;
702 699 }
703 700
704 701 int stop_current_mode()
705 702 {
706 703 rtems_status_code status;
704
707 705 // mask all IRQ lines related to signal processing
708 706 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
709 707 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
710 708 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
711 709
712 710 // clear all pending interruptions related to signal processing
713 711 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
714 712 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
715 713 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
716 714
717 715 // suspend several tasks
718 status = suspend_if_needed( Task_id[TASKID_AVF0] );
716
717 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
718 if (status == RTEMS_SUCCESSFUL) {
719 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
719 720 if (status == RTEMS_SUCCESSFUL) {
720 status = suspend_if_needed( Task_id[TASKID_BPF0] );
721 if (status == RTEMS_SUCCESSFUL) {
722 status = suspend_if_needed( Task_id[TASKID_WFRM] );
721 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
722 }
723 723 }
724
725 if (status != RTEMS_SUCCESSFUL)
726 {
727 PRINTF("ERR *** in stop_current_mode *** suspending tasks\n")
724 728 }
725 729
726 730 // initialize the registers
727 731 waveform_picker_regs->burst_enable = 0x00; // initialize
728 732
729 733 return status;
730 734 }
731 735
732 736 int enter_normal_mode()
733 737 {
734 738 rtems_status_code status;
735 739
736 status = restart_if_needed( Task_id[TASKID_AVF0] );
740 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
737 741 if (status == RTEMS_SUCCESSFUL) {
738 status = restart_if_needed( Task_id[TASKID_BPF0] );
742 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
739 743 if (status == RTEMS_SUCCESSFUL) {
740 status = restart_if_needed( Task_id[TASKID_WFRM] );
744 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
741 745 }
742 746 }
743 747
744 748 #ifdef GSA
745 749 LEON_Unmask_interrupt( IRQ_WF );
746 750 #else
747 751 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
748 752 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
749 753 waveform_picker_regs->burst_enable = 0x07;
750 754 waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1;
751 755 waveform_picker_regs->status = 0x00;
752 756 #endif
753 757 LEON_Unmask_interrupt( IRQ_SM );
754 758
755 759 return status;
756 760 }
757 761
758 int enter_sbm1_mode()
762 int enter_burst_mode()
759 763 {
760 764 rtems_status_code status;
761 status = restart_if_needed( Task_id[TASKID_AVF0] );
765
766 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
762 767 if (status == RTEMS_SUCCESSFUL) {
763 status = restart_if_needed( Task_id[TASKID_BPF0] );
768 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
764 769 if (status == RTEMS_SUCCESSFUL) {
765 status = restart_if_needed( Task_id[TASKID_WFRM] );
770 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
766 771 }
767 772 }
768 773
769 774 #ifdef GSA
770 775 #else
771 776 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
772 777 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
778 waveform_picker_regs->addr_data_f2 = (int) wf_snap_f2;
779 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] burst f2, f1, f0 enable f3 f2 f1 f0
780 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04;
781 waveform_picker_regs->status = 0x00;
782 #endif
783
784 LEON_Unmask_interrupt( IRQ_SM );
785 return status;
786 }
787
788 int enter_sbm1_mode()
789 {
790 rtems_status_code status;
791
792 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
793 if (status == RTEMS_SUCCESSFUL) {
794 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
795 if (status == RTEMS_SUCCESSFUL) {
796 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
797 }
798 }
799
800 #ifdef GSA
801 #else
802 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
803 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
804 waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1;
773 805 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] burst f2, f1, f0 enable f3 f2 f1 f0
774 806 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x02;
775 807 waveform_picker_regs->status = 0x00;
776 808 #endif
777 //LEON_Unmask_interrupt( IRQ_SM );
809
810 LEON_Unmask_interrupt( IRQ_SM );
811 return status;
812 }
813
814 int enter_sbm2_mode()
815 {
816 rtems_status_code status;
817
818 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
819 if (status == RTEMS_SUCCESSFUL) {
820 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
821 if (status == RTEMS_SUCCESSFUL) {
822 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
823 }
824 }
825
826 #ifdef GSA
827 #else
828 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
829 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
830 waveform_picker_regs->addr_data_f2 = (int) wf_snap_f2;
831 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] burst f2, f1, f0 enable f3 f2 f1 f0
832 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04;
833 waveform_picker_regs->status = 0x00;
834 #endif
835
836 LEON_Unmask_interrupt( IRQ_SM );
778 837 return status;
779 838 }
780 839
781 840 int action_load_norm(ccsdsTelecommandPacket_t *TC)
782 841 {
783 842 param_norm.sy_lfr_n_swf_l = (TC->dataAndCRC[0] * 256) + TC->dataAndCRC[1];
784 843 param_norm.sy_lfr_n_swf_p = (TC->dataAndCRC[2] * 256) + TC->dataAndCRC[3];
785 844 param_norm.sy_lfr_n_asm_p = (TC->dataAndCRC[4] * 256) + TC->dataAndCRC[5];
786 845 param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
787 846 param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
788 847
789 848 return LFR_SUCCESSFUL;
790 849 }
791 850
792 851 int action_load_comm(ccsdsTelecommandPacket_t *TC)
793 852 {
794 853 param_common.sy_lfr_common0 = TC->dataAndCRC[0];
795 854 param_common.sy_lfr_common1 = TC->dataAndCRC[1];
796 855
797 856 set_data_shaping_parameters(param_common.sy_lfr_common1);
798 857
799 858 return LFR_SUCCESSFUL;
800 859 }
801 860
802 861 int action_updt_time(ccsdsTelecommandPacket_t *TC)
803 862 {
804 863 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
805 864 + (TC->dataAndCRC[1] << 16)
806 865 + (TC->dataAndCRC[2] << 8)
807 866 + TC->dataAndCRC[3];
808 867 //time_management_regs->ctrl = time_management_regs->ctrl | 1;
809 868 return 0;
810 869 }
811 870
812 871 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC)
813 872 {
814 873 TMHeader_t TM_header;
815 874 char data[4];
816 875 spw_ioctl_pkt_send spw_ioctl_send;
817 876
818 877 TM_build_header( TM_LFR_TC_EXE_OK, TM_LEN_EXE,
819 878 time_management_regs->coarse_time, time_management_regs->fine_time, &TM_header);
820 879
821 880 data[0] = TC->packetID[0];
822 881 data[1] = TC->packetID[1];
823 882 data[2] = TC->packetSequenceControl[0];
824 883 data[3] = TC->packetSequenceControl[1];
825 884
826 885 // filling the structure for the spacewire transmission
827 886 spw_ioctl_send.hlen = TM_HEADER_LEN + 3; // + 4 is for the protocole extra header
828 887 spw_ioctl_send.hdr = (char*) &TM_header;
829 888 spw_ioctl_send.dlen = 3;
830 889 spw_ioctl_send.data = data;
831 890
832 891 // SEND DATA
833 892 write_spw(&spw_ioctl_send);
834 893
835 894 return 0;
836 895 }
837 896
838 rtems_status_code restart_if_needed(rtems_id id)
839 {
840 rtems_status_code status;
841
842 status = rtems_task_is_suspended( id );
843
844 if (status==RTEMS_SUCCESSFUL) {
845 status = rtems_task_restart( id, 0 );
846 if (status!=RTEMS_SUCCESSFUL) {
847 PRINTF1("in restart_if_needed *** Error restarting with id %d\n", (int) id)
848 }
849 }
850
851 return status;
852 }
853
854 rtems_status_code suspend_if_needed(rtems_id id)
855 {
856 rtems_status_code status;
857
858 status = rtems_task_is_suspended( id );
859
860 if (status!=RTEMS_SUCCESSFUL) {
861 status = rtems_task_suspend( id );
862 if (status!=RTEMS_SUCCESSFUL) {
863 PRINTF1("in suspend_if_needed *** Error suspending task with id %d\n", (int) id)
864 }
865 }
866
867 return status;
868 }
869
870 897 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
871 898 {
872 899 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
873 900 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
874 901 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
875 902 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->dataFieldHeader[1];
876 903 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
877 904 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->dataFieldHeader[2];
878 905 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
879 906 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
880 907 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
881 908 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
882 909 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
883 910 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
884 911 }
885 912
886 913 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
887 914 {
888 915 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
889 916 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
890 917 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
891 918 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->dataFieldHeader[1];
892 919 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
893 920 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->dataFieldHeader[2];
894 921 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
895 922 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
896 923 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
897 924 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
898 925 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
899 926 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
900 927 }
901 928
902 929 void close_action(ccsdsTelecommandPacket_t *TC, int result)
903 930 {
904 931 unsigned int val = 0;
905 932 if (result == LFR_SUCCESSFUL)
906 933 {
907 934 send_tm_lfr_tc_exe_success( TC );
908 935 update_last_TC_exe( TC );
909 936 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
910 937 val++;
911 938 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
912 939 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
913 940 }
914 941 else
915 942 {
916 943 update_last_TC_rej( TC );
917 944 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
918 945 val++;
919 946 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
920 947 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
921 948 }
922 949 }
923 950
924 951 //***************************
925 952 // Interrupt Service Routines
926 953 rtems_isr commutation_isr1( rtems_vector_number vector )
927 954 {
928 955 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
929 956 printf("In commutation_isr1 *** Error sending event to DUMB\n");
930 957 }
931 958 }
932 959
933 960 rtems_isr commutation_isr2( rtems_vector_number vector )
934 961 {
935 962 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
936 963 printf("In commutation_isr2 *** Error sending event to DUMB\n");
937 964 }
938 965 }
939 966
940 967
941 968
942 969
@@ -1,414 +1,452
1 1 #include <wf_handler.h>
2 2
3 rtems_isr waveforms_isr_alternative( rtems_vector_number vector )
4 {
5 if (waveform_picker_regs->burst_enable == 0x22) {
6 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
7 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
8 }
9 else {
10 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
11 }
12 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
13 //rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
14 }
15 }
16 waveform_picker_regs->status = 0x00;
17 /*else if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){// if no channel is enable
18 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
19 printf("In timecode_irq_handler *** Error sending event to DUMB\n");
20 }
21 }
22 else {
23 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
24 waveform_picker_regs->burst_enable = 0x00;
25 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
26 printf("In waveforms_isr *** Error sending event to WFRM\n");
27 }
28 }
29 }*/
30 }
31
32 3 rtems_isr waveforms_isr( rtems_vector_number vector )
33 4 {
34 5 unsigned char lfrMode;
35 6 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
36 7
37 8 switch(lfrMode)
38 9 {
39 10 //********
40 11 // STANDBY
41 12 case(LFR_MODE_STANDBY):
42 13 break;
43 14
44 15 //******
45 16 // NORMAL
46 17 case(LFR_MODE_NORMAL):
47 18 #ifdef GSA
48 19 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
49 20 #else
50 21 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){// if no channel is enable
51 22 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
52 23 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
53 24 }
54 25 }
55 26 else {
56 27 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
57 28 waveform_picker_regs->burst_enable = 0x00;
58 29 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
59 30 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
60 31 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
61 32 }
62 33 }
63 34 }
64 35 }
65 36 #endif
66 37 break;
67 38
68 39 //******
69 40 // BURST
70 41 case(LFR_MODE_BURST):
71 42 break;
72 43
73 44 //*****
74 45 // SBM1
75 46 case(LFR_MODE_SBM1):
76 47 #ifdef GSA
77 48 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
78 49 #else
79 50 if (waveform_picker_regs->burst_enable == 0x22) {
80 51 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
81 52 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
82 53 }
83 54 else {
84 55 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
85 56 }
86 57 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
87 58 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
88 59 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
89 60 }
90 61 }
91 62 waveform_picker_regs->status = 0x00;
92 63 #endif
93 64 break;
94 65
95 66 //*****
96 67 // SBM2
97 68 case(LFR_MODE_SBM2):
69 #ifdef GSA
70 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
71 #else
72 if (waveform_picker_regs->burst_enable == 0x44) {
73 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
74 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
75 }
76 else {
77 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
78 }
79 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
80 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
81 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
82 }
83 }
84 waveform_picker_regs->status = 0x00;
85 #endif
98 86 break;
99 87
100 88 //********
101 89 // DEFAULT
102 90 default:
103 91 break;
104 92 }
105 93 }
106 94
107 95 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
108 96 {
109 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
110 printf("In waveforms_isr *** Error sending event to WFRM\n");
97 unsigned char lfrMode;
98 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
99
100 switch(lfrMode)
101 {
102 //********
103 // STANDBY
104 case(LFR_MODE_STANDBY):
105 break;
106
107 //******
108 // NORMAL
109 case(LFR_MODE_NORMAL):
110 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
111 PRINTF("ERR *** in waveforms_isr *** error sending event to WFRM\n");
112 }
113 break;
114
115 //******
116 // BURST
117 case(LFR_MODE_BURST):
118 break;
119
120 //*****
121 // SBM1
122 case(LFR_MODE_SBM1):
123 break;
124
125 //*****
126 // SBM2
127 case(LFR_MODE_SBM2):
128 break;
129
130 //********
131 // DEFAULT
132 default:
133 break;
111 134 }
112 135 }
113 136
114 137 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
115 138 {
116 139 spw_ioctl_pkt_send spw_ioctl_send;
117 140 rtems_event_set event_out;
118 141 ExtendedTMHeader_t header;
119 142
120 143 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
121 144 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
122 145 header.reserved = 0x00;
123 146 header.userApplication = CCSDS_USER_APP;
124 147 header.packetID[0] = 0x0c;
125 148 header.packetID[1] = 0xcc;
126 149 header.packetSequenceControl[0] = 0x00;
127 150 header.packetSequenceControl[1] = 0x00;
128 151 header.packetLength[0] = 0x00;
129 152 header.packetLength[1] = 0x00;
130 153 header.dataFieldHeader[0] = 0x10;
131 154 header.dataFieldHeader[1] = TM_TYPE_LFR_SCIENCE; // service type
132 155 header.dataFieldHeader[2] = TM_SUBTYPE_LFR_SCIENCE; // service subtype
133 156 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
134 157
135 158 header.auxiliaryHeader[0] = 0x00;
136 159 header.auxiliaryHeader[1] = 0x1f;
137 160 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
138 161 header.auxiliaryHeader[3] = 0x00; // PKT_NR
139 162 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
140 163 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
141 164
142 165 // BUILD THE PACKET HEADER
143 166 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
144 167 spw_ioctl_send.hdr = (char*) &header;
145 168
146 169 init_waveforms();
147 170
148 171 PRINTF("in WFRM ***\n")
149 172
150 173 while(1){
151 174 // wait for an RTEMS_EVENT
152 175 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
153 176 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
154 177 header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
155 178 header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
156 179 header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
157 180 header.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
158 181 header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
159 182 header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
160 183
161 184 switch(event_out)
162 185 {
163 186 //********
164 187 // STANDBY
165 188 case(RTEMS_EVENT_MODE_STANDBY):
166 189 break;
167 190
168 191 //*******
169 192 // NORMAL
170 193 case(RTEMS_EVENT_MODE_NORMAL):
171 194 //***************
172 195 // send snapshots
173 196 // F0
174 197 send_waveform( &header, wf_snap_f0, SID_NORM_SWF_F0, &spw_ioctl_send);
175 198 // F1
176 199 send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send);
177 200 // F2
178 201 send_waveform( &header, wf_snap_f2, SID_NORM_SWF_F2, &spw_ioctl_send);
179 202 #ifdef GSA
180 203 // irq processed, reset the related register of the timer unit
181 204 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
182 205 #else
183 206 // irq processed, reset the related register of the waveform picker
184 207 waveform_picker_regs->status = 0x00;
185 208 waveform_picker_regs->burst_enable = 0x07;
186 209 #endif
187 210 break;
188 211
189 212 //*****
190 213 // SBM1
191 214 case(RTEMS_EVENT_MODE_SBM1):
192 215 // F1
193 216 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
194 217 send_waveform( &header, wf_snap_f1_bis, SID_NORM_SWF_F1, &spw_ioctl_send);
195 218 }
196 219 else {
197 220 send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send);
198 221 }
199 222 break;
223
224 //*****
225 // SBM2
226 case(RTEMS_EVENT_MODE_SBM2):
227 // F2
228 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
229 send_waveform( &header, wf_snap_f2_bis, SID_NORM_SWF_F2, &spw_ioctl_send);
230 }
231 else {
232 send_waveform( &header, wf_snap_f2, SID_NORM_SWF_F2, &spw_ioctl_send);
233 }
234 break;
235
236 //********
237 // DEFAULT
200 238 default:
201 239 break;
202 240 }
203 241 }
204 242 }
205 243
206 244 //******************
207 245 // general functions
208 246 void init_waveforms( void )
209 247 {
210 248 int i = 0;
211 249
212 250 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
213 251 {
214 252 //***
215 253 // F0
216 254 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
217 255 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
218 256 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
219 257
220 258 //***
221 259 // F1
222 260 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
223 261 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
224 262 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
225 263
226 264 //***
227 265 // F2
228 266 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
229 267 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
230 268 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
231 269
232 270 //***
233 271 // F3
234 272 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
235 273 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
236 274 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
237 275 }
238 276 }
239 277
240 278 void init_waveform_header( ExtendedTMHeader_t * header, unsigned int sid )
241 279 {
242 280
243 281 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
244 282 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
245 283 header->reserved = 0x00;
246 284 header->userApplication = CCSDS_USER_APP;
247 285 header->packetID[0] = 0x0c;
248 286 header->packetID[1] = 0xcc;
249 287 header->packetSequenceControl[0] = 0x00;
250 288 header->packetSequenceControl[1] = 0x00;
251 289 header->packetLength[0] = 0x00;
252 290 header->packetLength[1] = 0x00;
253 291 header->dataFieldHeader[0] = 0x10;
254 292 header->dataFieldHeader[1] = TM_TYPE_LFR_SCIENCE; // service type
255 293 header->dataFieldHeader[2] = TM_SUBTYPE_LFR_SCIENCE; // service subtype
256 294 header->dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
257 295
258 296 header->auxiliaryHeader[0] = sid;
259 297 header->auxiliaryHeader[1] = 0x1f;
260 298 header->auxiliaryHeader[2] = 0x07; // PKT_CNT
261 299 header->auxiliaryHeader[3] = 0x00; // PKT_NR
262 300 header->auxiliaryHeader[4] = 0x00; // BLK_NR MSB
263 301 header->auxiliaryHeader[5] = 0x00; // BLK_NR LSB
264 302 }
265 303
266 304 void reset_waveforms( void )
267 305 {
268 306 int i = 0;
269 307
270 308 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
271 309 {
272 310 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
273 311 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
274 312 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
275 313
276 314 //***
277 315 // F1
278 316 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
279 317 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
280 318 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
281 319
282 320 //***
283 321 // F2
284 322 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
285 323 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
286 324 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
287 325
288 326 //***
289 327 // F3
290 328 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
291 329 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
292 330 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
293 331 }
294 332 }
295 333
296 334 void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform,
297 335 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send)
298 336 {
299 337 unsigned int i = 0;
300 338 unsigned int length = 0;
301 339 rtems_status_code status;
302 340
303 341 for (i=0; i<7; i++) // send waveform
304 342 {
305 343 header->auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR
306 344 // BUILD THE DATA
307 345 if (i==6) {
308 346 spw_ioctl_send->dlen = 8 * NB_BYTES_SWF_BLK;
309 347 length = TM_LEN_SCI_NORM_SWF_8;
310 348 header->auxiliaryHeader[4] = 0x00; // BLK_NR MSB
311 349 header->auxiliaryHeader[5] = 0x08; // BLK_NR LSB
312 350 }
313 351 else {
314 352 spw_ioctl_send->dlen = 340 * NB_BYTES_SWF_BLK;
315 353 length = TM_LEN_SCI_NORM_SWF_340;
316 354 header->auxiliaryHeader[4] = 0x01; // BLK_NR MSB
317 355 header->auxiliaryHeader[5] = 0x54; // BLK_NR LSB
318 356 }
319 357 if (sid == SID_NORM_SWF_F0) {
320 358 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ];
321 359 }
322 360 else if (sid == SID_NORM_SWF_F1) {
323 361 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ];
324 362 }
325 363 else if (sid == SID_NORM_SWF_F2) {
326 364 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ];
327 365 }
328 366 else {
329 367 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
330 368 }
331 369 // BUILD THE HEADER
332 370 header->packetLength[0] = (unsigned char) (length>>8);
333 371 header->packetLength[1] = (unsigned char) (length);
334 372 header->auxiliaryHeader[0] = sid; // SID
335 373 // SEND PACKET
336 374 status = write_spw(spw_ioctl_send);
337 375 if (status != RTEMS_SUCCESSFUL) {
338 376 while (true) {
339 377 if (status != RTEMS_SUCCESSFUL) {
340 378 status = write_spw(spw_ioctl_send);
341 379 //PRINTF1("%d", i)
342 380 sched_yield();
343 381 }
344 382 else {
345 383 //PRINTF("\n")
346 384 break;
347 385 }
348 386 }
349 387 }
350 388 }
351 389 }
352 390
353 391 int build_value(int value1, int value0)
354 392 {
355 393 int aux = 0;
356 394 int aux1 = 0;
357 395 int aux0 = 0;
358 396 int value1_aux = 0;
359 397 int value0_aux = 0;
360 398
361 399 value1_aux = value1;
362 400 value0_aux = value0;
363 401
364 402 //******
365 403 // B3 B2
366 404 if (value1_aux > 8191) value1_aux = 8191;
367 405 if (value1_aux < -8192) value1_aux = -8192;
368 406 aux1 = ( (int) ( ( (unsigned char) (value1_aux / 256 ) ) << 8 ) )
369 407 + ( (int) ( (unsigned char) (value1_aux ) ) );
370 408
371 409 //******
372 410 // B1 B0
373 411 if (value0_aux > 8191) value0_aux = 8191;
374 412 if (value0_aux < -8192) value0_aux = -8192;
375 413 aux0 = ( (int) ( ( (unsigned char) (value0_aux / 256) ) << 8 ) )
376 414 + ( (int) ( (unsigned char) (value0_aux ) ) );
377 415
378 416 aux = (aux1 << 16) + aux0;
379 417
380 418 return aux;
381 419 }
382 420
383 421 void init_waveform_picker_regs()
384 422 {
385 423 set_data_shaping_parameters(param_common.sy_lfr_common1);
386 424 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
387 425 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
388 426 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
389 427 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
390 428 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
391 429 waveform_picker_regs->status = 0x00; //
392 430 waveform_picker_regs->delta_snapshot = 0x5; // max 2 bytes
393 431 waveform_picker_regs->delta_f2_f1 = 0xffff; // max 4 bytes
394 432 waveform_picker_regs->delta_f2_f0 = 0x17c00; // max 5 bytes
395 433 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
396 434 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
397 435 //waveform_picker_regs->delta_snapshot = 0x2; // max 2 bytes, = period / 2
398 436 //waveform_picker_regs->delta_f2_f1 = 0x2d00; // max 4 bytes
399 437 //waveform_picker_regs->delta_f2_f0 = 0x2f80; // max 5 bytes
400 438 //waveform_picker_regs->nb_burst_available = 0x30; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
401 439 //waveform_picker_regs->nb_snapshot_param = 0xff; // max 3 octets, 256 - 1
402 440 }
403 441
404 442 void set_data_shaping_parameters(unsigned char parameters)
405 443 {
406 444 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
407 445 // waveform picker : [R1 R0 SP1 SP0 BW]
408 446 waveform_picker_regs->data_shaping =
409 447 ( (parameters & 0x10) >> 4 ) // BW
410 448 + ( (parameters & 0x08) >> 2 ) // SP0
411 449 + ( (parameters & 0x04) ) // SP1
412 450 + ( (parameters & 0x02) << 2 ) // R0
413 451 + ( (parameters & 0x01) << 4 ); // R1
414 452 }
General Comments 0
You need to be logged in to leave comments. Login now