##// END OF EJS Templates
All modes implemented for the waveforms...
paul@pc-solar1.lab-lpp.local -
r23:af9a6b32a71f default
parent child
Show More
@@ -1,225 +1,225
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw-gsa
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Jun 18 14:00:55 2013
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Jun 28 07:59:21 2013
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 #############################################################################
7 #############################################################################
8
8
9 ####### Compiler, tools and options
9 ####### Compiler, tools and options
10
10
11 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=5 -DPRINT_MESSAGES_ON_CONSOLE -DGSA
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=5 -DPRINT_MESSAGES_ON_CONSOLE
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
20 AR = sparc-rtems-ar rcs
20 AR = sparc-rtems-ar rcs
21 RANLIB =
21 RANLIB =
22 QMAKE = /usr/bin/qmake-qt4
22 QMAKE = /usr/bin/qmake-qt4
23 TAR = tar -cf
23 TAR = tar -cf
24 COMPRESS = gzip -9f
24 COMPRESS = gzip -9f
25 COPY = cp -f
25 COPY = cp -f
26 SED = sed
26 SED = sed
27 COPY_FILE = $(COPY)
27 COPY_FILE = $(COPY)
28 COPY_DIR = $(COPY) -r
28 COPY_DIR = $(COPY) -r
29 STRIP = sparc-rtems-strip
29 STRIP = sparc-rtems-strip
30 INSTALL_FILE = install -m 644 -p
30 INSTALL_FILE = install -m 644 -p
31 INSTALL_DIR = $(COPY_DIR)
31 INSTALL_DIR = $(COPY_DIR)
32 INSTALL_PROGRAM = install -m 755 -p
32 INSTALL_PROGRAM = install -m 755 -p
33 DEL_FILE = rm -f
33 DEL_FILE = rm -f
34 SYMLINK = ln -f -s
34 SYMLINK = ln -f -s
35 DEL_DIR = rmdir
35 DEL_DIR = rmdir
36 MOVE = mv -f
36 MOVE = mv -f
37 CHK_DIR_EXISTS= test -d
37 CHK_DIR_EXISTS= test -d
38 MKDIR = mkdir -p
38 MKDIR = mkdir -p
39
39
40 ####### Output directory
40 ####### Output directory
41
41
42 OBJECTS_DIR = obj/
42 OBJECTS_DIR = obj/
43
43
44 ####### Files
44 ####### Files
45
45
46 SOURCES = ../src/wf_handler.c \
46 SOURCES = ../src/wf_handler.c \
47 ../src/tc_handler.c \
47 ../src/tc_handler.c \
48 ../src/fsw_processing.c \
48 ../src/fsw_processing.c \
49 ../src/fsw_misc.c \
49 ../src/fsw_misc.c \
50 ../src/fsw_init.c \
50 ../src/fsw_init.c \
51 ../src/fsw_globals.c
51 ../src/fsw_globals.c
52 OBJECTS = obj/wf_handler.o \
52 OBJECTS = obj/wf_handler.o \
53 obj/tc_handler.o \
53 obj/tc_handler.o \
54 obj/fsw_processing.o \
54 obj/fsw_processing.o \
55 obj/fsw_misc.o \
55 obj/fsw_misc.o \
56 obj/fsw_init.o \
56 obj/fsw_init.o \
57 obj/fsw_globals.o
57 obj/fsw_globals.o
58 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
58 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
59 /usr/lib64/qt4/mkspecs/common/linux.conf \
59 /usr/lib64/qt4/mkspecs/common/linux.conf \
60 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
60 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
61 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
61 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
62 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
62 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
63 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
63 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
64 /usr/lib64/qt4/mkspecs/qconfig.pri \
64 /usr/lib64/qt4/mkspecs/qconfig.pri \
65 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
65 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
66 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
66 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
67 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
67 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
68 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
68 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
69 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
69 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
70 sparc.pri \
70 sparc.pri \
71 /usr/lib64/qt4/mkspecs/features/release.prf \
71 /usr/lib64/qt4/mkspecs/features/release.prf \
72 /usr/lib64/qt4/mkspecs/features/default_post.prf \
72 /usr/lib64/qt4/mkspecs/features/default_post.prf \
73 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
73 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
74 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
74 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
75 /usr/lib64/qt4/mkspecs/features/resources.prf \
75 /usr/lib64/qt4/mkspecs/features/resources.prf \
76 /usr/lib64/qt4/mkspecs/features/uic.prf \
76 /usr/lib64/qt4/mkspecs/features/uic.prf \
77 /usr/lib64/qt4/mkspecs/features/yacc.prf \
77 /usr/lib64/qt4/mkspecs/features/yacc.prf \
78 /usr/lib64/qt4/mkspecs/features/lex.prf \
78 /usr/lib64/qt4/mkspecs/features/lex.prf \
79 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
79 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
80 fsw-qt.pro
80 fsw-qt.pro
81 QMAKE_TARGET = fsw-gsa
81 QMAKE_TARGET = fsw
82 DESTDIR = bin/
82 DESTDIR = bin/
83 TARGET = bin/fsw-gsa
83 TARGET = bin/fsw
84
84
85 first: all
85 first: all
86 ####### Implicit rules
86 ####### Implicit rules
87
87
88 .SUFFIXES: .o .c .cpp .cc .cxx .C
88 .SUFFIXES: .o .c .cpp .cc .cxx .C
89
89
90 .cpp.o:
90 .cpp.o:
91 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
91 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
92
92
93 .cc.o:
93 .cc.o:
94 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
94 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
95
95
96 .cxx.o:
96 .cxx.o:
97 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
97 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
98
98
99 .C.o:
99 .C.o:
100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101
101
102 .c.o:
102 .c.o:
103 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
103 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
104
104
105 ####### Build rules
105 ####### Build rules
106
106
107 all: Makefile $(TARGET)
107 all: Makefile $(TARGET)
108
108
109 $(TARGET): $(OBJECTS)
109 $(TARGET): $(OBJECTS)
110 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
110 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
111 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
111 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
112
112
113 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
113 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
114 /usr/lib64/qt4/mkspecs/common/linux.conf \
114 /usr/lib64/qt4/mkspecs/common/linux.conf \
115 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
115 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
116 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
116 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
117 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
117 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
118 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
118 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
119 /usr/lib64/qt4/mkspecs/qconfig.pri \
119 /usr/lib64/qt4/mkspecs/qconfig.pri \
120 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
120 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
121 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
121 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
122 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
122 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
123 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
123 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
124 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
124 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
125 sparc.pri \
125 sparc.pri \
126 /usr/lib64/qt4/mkspecs/features/release.prf \
126 /usr/lib64/qt4/mkspecs/features/release.prf \
127 /usr/lib64/qt4/mkspecs/features/default_post.prf \
127 /usr/lib64/qt4/mkspecs/features/default_post.prf \
128 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
128 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
129 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
129 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
130 /usr/lib64/qt4/mkspecs/features/resources.prf \
130 /usr/lib64/qt4/mkspecs/features/resources.prf \
131 /usr/lib64/qt4/mkspecs/features/uic.prf \
131 /usr/lib64/qt4/mkspecs/features/uic.prf \
132 /usr/lib64/qt4/mkspecs/features/yacc.prf \
132 /usr/lib64/qt4/mkspecs/features/yacc.prf \
133 /usr/lib64/qt4/mkspecs/features/lex.prf \
133 /usr/lib64/qt4/mkspecs/features/lex.prf \
134 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
134 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
135 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
135 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
136 /usr/lib64/qt4/mkspecs/common/unix.conf:
136 /usr/lib64/qt4/mkspecs/common/unix.conf:
137 /usr/lib64/qt4/mkspecs/common/linux.conf:
137 /usr/lib64/qt4/mkspecs/common/linux.conf:
138 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
138 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
139 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
139 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
140 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
140 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
141 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
141 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
142 /usr/lib64/qt4/mkspecs/qconfig.pri:
142 /usr/lib64/qt4/mkspecs/qconfig.pri:
143 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
143 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
144 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
144 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
145 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
145 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
146 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
146 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
147 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
147 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
148 sparc.pri:
148 sparc.pri:
149 /usr/lib64/qt4/mkspecs/features/release.prf:
149 /usr/lib64/qt4/mkspecs/features/release.prf:
150 /usr/lib64/qt4/mkspecs/features/default_post.prf:
150 /usr/lib64/qt4/mkspecs/features/default_post.prf:
151 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
151 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
152 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
152 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
153 /usr/lib64/qt4/mkspecs/features/resources.prf:
153 /usr/lib64/qt4/mkspecs/features/resources.prf:
154 /usr/lib64/qt4/mkspecs/features/uic.prf:
154 /usr/lib64/qt4/mkspecs/features/uic.prf:
155 /usr/lib64/qt4/mkspecs/features/yacc.prf:
155 /usr/lib64/qt4/mkspecs/features/yacc.prf:
156 /usr/lib64/qt4/mkspecs/features/lex.prf:
156 /usr/lib64/qt4/mkspecs/features/lex.prf:
157 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
157 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
158 qmake: FORCE
158 qmake: FORCE
159 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
159 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
160
160
161 dist:
161 dist:
162 @$(CHK_DIR_EXISTS) obj/fsw-gsa1.0.0 || $(MKDIR) obj/fsw-gsa1.0.0
162 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.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
163 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
164
164
165
165
166 clean:compiler_clean
166 clean:compiler_clean
167 -$(DEL_FILE) $(OBJECTS)
167 -$(DEL_FILE) $(OBJECTS)
168 -$(DEL_FILE) *~ core *.core
168 -$(DEL_FILE) *~ core *.core
169
169
170
170
171 ####### Sub-libraries
171 ####### Sub-libraries
172
172
173 distclean: clean
173 distclean: clean
174 -$(DEL_FILE) $(TARGET)
174 -$(DEL_FILE) $(TARGET)
175 -$(DEL_FILE) Makefile
175 -$(DEL_FILE) Makefile
176
176
177
177
178 grmon:
178 grmon:
179 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
179 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
180
180
181 check: first
181 check: first
182
182
183 compiler_rcc_make_all:
183 compiler_rcc_make_all:
184 compiler_rcc_clean:
184 compiler_rcc_clean:
185 compiler_uic_make_all:
185 compiler_uic_make_all:
186 compiler_uic_clean:
186 compiler_uic_clean:
187 compiler_image_collection_make_all: qmake_image_collection.cpp
187 compiler_image_collection_make_all: qmake_image_collection.cpp
188 compiler_image_collection_clean:
188 compiler_image_collection_clean:
189 -$(DEL_FILE) qmake_image_collection.cpp
189 -$(DEL_FILE) qmake_image_collection.cpp
190 compiler_yacc_decl_make_all:
190 compiler_yacc_decl_make_all:
191 compiler_yacc_decl_clean:
191 compiler_yacc_decl_clean:
192 compiler_yacc_impl_make_all:
192 compiler_yacc_impl_make_all:
193 compiler_yacc_impl_clean:
193 compiler_yacc_impl_clean:
194 compiler_lex_make_all:
194 compiler_lex_make_all:
195 compiler_lex_clean:
195 compiler_lex_clean:
196 compiler_clean:
196 compiler_clean:
197
197
198 ####### Compile
198 ####### Compile
199
199
200 obj/wf_handler.o: ../src/wf_handler.c
200 obj/wf_handler.o: ../src/wf_handler.c
201 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
201 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
202
202
203 obj/tc_handler.o: ../src/tc_handler.c
203 obj/tc_handler.o: ../src/tc_handler.c
204 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
204 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
205
205
206 obj/fsw_processing.o: ../src/fsw_processing.c
206 obj/fsw_processing.o: ../src/fsw_processing.c
207 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
207 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
208
208
209 obj/fsw_misc.o: ../src/fsw_misc.c
209 obj/fsw_misc.o: ../src/fsw_misc.c
210 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
210 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
211
211
212 obj/fsw_init.o: ../src/fsw_init.c
212 obj/fsw_init.o: ../src/fsw_init.c
213 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
213 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
214
214
215 obj/fsw_globals.o: ../src/fsw_globals.c
215 obj/fsw_globals.o: ../src/fsw_globals.c
216 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
216 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
217
217
218 ####### Install
218 ####### Install
219
219
220 install: FORCE
220 install: FORCE
221
221
222 uninstall: FORCE
222 uninstall: FORCE
223
223
224 FORCE:
224 FORCE:
225
225
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,51 +1,51
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** cpu_usage_report *** gsa
3 # CONFIG options = verbose *** cpu_usage_report *** gsa
4 CONFIG += console verbose gsa
4 CONFIG += console verbose
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
8
8
9 # flight software version
9 # flight software version
10 SWVERSION=-0-5
10 SWVERSION=-0-5
11 DEFINES += SW_VERSION_N1=0
11 DEFINES += SW_VERSION_N1=0
12 DEFINES += SW_VERSION_N2=0
12 DEFINES += SW_VERSION_N2=0
13 DEFINES += SW_VERSION_N3=0
13 DEFINES += SW_VERSION_N3=0
14 DEFINES += SW_VERSION_N4=5
14 DEFINES += SW_VERSION_N4=5
15
15
16 contains( CONFIG, verbose ) {
16 contains( CONFIG, verbose ) {
17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 }
18 }
19
19
20 contains( CONFIG, cpu_usage_report ) {
20 contains( CONFIG, cpu_usage_report ) {
21 DEFINES += PRINT_TASK_STATISTICS
21 DEFINES += PRINT_TASK_STATISTICS
22 }
22 }
23
23
24 TARGET = fsw
24 TARGET = fsw
25 contains( CONFIG, gsa ) {
25 contains( CONFIG, gsa ) {
26 DEFINES += GSA
26 DEFINES += GSA
27 TARGET = fsw-gsa
27 TARGET = fsw-gsa
28 }
28 }
29
29
30 INCLUDEPATH += \
30 INCLUDEPATH += \
31 ../src \
31 ../src \
32 ../header
32 ../header
33
33
34 SOURCES += \
34 SOURCES += \
35 ../src/wf_handler.c \
35 ../src/wf_handler.c \
36 ../src/tc_handler.c \
36 ../src/tc_handler.c \
37 ../src/fsw_processing.c \
37 ../src/fsw_processing.c \
38 ../src/fsw_misc.c \
38 ../src/fsw_misc.c \
39 ../src/fsw_init.c \
39 ../src/fsw_init.c \
40 ../src/fsw_globals.c
40 ../src/fsw_globals.c
41
41
42 HEADERS += \
42 HEADERS += \
43 ../header/wf_handler.h \
43 ../header/wf_handler.h \
44 ../header/tc_handler.h \
44 ../header/tc_handler.h \
45 ../header/grlib_regs.h \
45 ../header/grlib_regs.h \
46 ../header/fsw_processing.h \
46 ../header/fsw_processing.h \
47 ../header/fsw_params.h \
47 ../header/fsw_params.h \
48 ../header/fsw_misc.h \
48 ../header/fsw_misc.h \
49 ../header/fsw_init.h \
49 ../header/fsw_init.h \
50 ../header/ccsds_types.h
50 ../header/ccsds_types.h
51
51
@@ -1,265 +1,265
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by Qt Creator 2.4.1, 2013-06-18T14:38:28. -->
3 <!-- Written by Qt Creator 2.4.1, 2013-06-28T14:26:12. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">0</value>
7 <value type="int">0</value>
8 </data>
8 </data>
9 <data>
9 <data>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 <valuemap type="QVariantMap">
11 <valuemap type="QVariantMap">
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
14 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15 <value type="QString" key="language">Cpp</value>
15 <value type="QString" key="language">Cpp</value>
16 <valuemap type="QVariantMap" key="value">
16 <valuemap type="QVariantMap" key="value">
17 <value type="QString" key="CurrentPreferences">CppGlobal</value>
17 <value type="QString" key="CurrentPreferences">CppGlobal</value>
18 </valuemap>
18 </valuemap>
19 </valuemap>
19 </valuemap>
20 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
20 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21 <value type="QString" key="language">QmlJS</value>
21 <value type="QString" key="language">QmlJS</value>
22 <valuemap type="QVariantMap" key="value">
22 <valuemap type="QVariantMap" key="value">
23 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
23 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
24 </valuemap>
24 </valuemap>
25 </valuemap>
25 </valuemap>
26 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
26 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
27 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
28 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
28 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29 <value type="int" key="EditorConfiguration.IndentSize">4</value>
29 <value type="int" key="EditorConfiguration.IndentSize">4</value>
30 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
30 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
31 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
31 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
32 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
32 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
33 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
33 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
34 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
34 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
35 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
35 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
36 <value type="int" key="EditorConfiguration.TabSize">8</value>
36 <value type="int" key="EditorConfiguration.TabSize">8</value>
37 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
37 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
38 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
38 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
39 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
39 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
40 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
40 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
41 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
41 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
42 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
42 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
43 </valuemap>
43 </valuemap>
44 </data>
44 </data>
45 <data>
45 <data>
46 <variable>ProjectExplorer.Project.PluginSettings</variable>
46 <variable>ProjectExplorer.Project.PluginSettings</variable>
47 <valuemap type="QVariantMap"/>
47 <valuemap type="QVariantMap"/>
48 </data>
48 </data>
49 <data>
49 <data>
50 <variable>ProjectExplorer.Project.Target.0</variable>
50 <variable>ProjectExplorer.Project.Target.0</variable>
51 <valuemap type="QVariantMap">
51 <valuemap type="QVariantMap">
52 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
52 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
53 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
53 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
55 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
55 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
56 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
56 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
58 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
58 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
59 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
59 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
60 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
60 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
62 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
62 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
63 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
63 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
65 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
65 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
66 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
66 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
67 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
67 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
69 </valuemap>
69 </valuemap>
70 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
70 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
71 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
71 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
72 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
72 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
73 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
73 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
74 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
74 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
75 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
75 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
76 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
76 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
77 </valuemap>
77 </valuemap>
78 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
78 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
79 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
79 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
80 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
80 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
81 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
81 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
82 </valuemap>
82 </valuemap>
83 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
83 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
84 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
84 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
85 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
85 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
88 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
88 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
89 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
89 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
90 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
90 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
91 </valuemap>
91 </valuemap>
92 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
92 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
96 </valuemap>
96 </valuemap>
97 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
97 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
98 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
98 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
99 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
99 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
100 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
100 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
101 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
101 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
102 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
102 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
103 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
103 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
104 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
104 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
105 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
105 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
106 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
106 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
107 </valuemap>
107 </valuemap>
108 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
108 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
109 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
109 <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value>
110 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
110 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
111 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
111 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
115 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
115 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
116 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
116 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
117 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
117 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
118 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
118 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
119 </valuemap>
119 </valuemap>
120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
121 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
121 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
122 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
122 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
124 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
124 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
125 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
125 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
126 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
126 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
127 </valuemap>
127 </valuemap>
128 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
128 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
129 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
130 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
131 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
132 </valuemap>
132 </valuemap>
133 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
133 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
134 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
134 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
136 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
137 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
137 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
138 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
138 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
139 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
139 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
140 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
140 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
141 </valuemap>
141 </valuemap>
142 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
142 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
143 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
143 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
144 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
144 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
146 </valuemap>
146 </valuemap>
147 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
147 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
148 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
148 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
149 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
149 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
150 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
150 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
151 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
151 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
153 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
153 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
154 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
154 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
155 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
155 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
156 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
156 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
157 </valuemap>
157 </valuemap>
158 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
158 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
159 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
159 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
160 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
160 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
161 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
161 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
162 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
162 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
163 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
163 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
165 </valuemap>
165 </valuemap>
166 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
166 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
167 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
167 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
168 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
168 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
169 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
169 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
170 </valuemap>
170 </valuemap>
171 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
171 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
172 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
172 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
173 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
173 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
174 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
174 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
175 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
175 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
176 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
176 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
177 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
177 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
178 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
178 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
179 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
179 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
180 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
180 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
181 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
181 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
182 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
182 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
183 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
183 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
184 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
184 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
185 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
185 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
186 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
186 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
187 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
187 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
188 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
188 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
189 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
189 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
190 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
190 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
191 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
191 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
192 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
192 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
193 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
193 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
194 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
194 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
195 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
195 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
196 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
196 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
197 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
197 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
198 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
198 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
199 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
199 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
200 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
200 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
201 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
201 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
202 <value type="int">0</value>
202 <value type="int">0</value>
203 <value type="int">1</value>
203 <value type="int">1</value>
204 <value type="int">2</value>
204 <value type="int">2</value>
205 <value type="int">3</value>
205 <value type="int">3</value>
206 <value type="int">4</value>
206 <value type="int">4</value>
207 <value type="int">5</value>
207 <value type="int">5</value>
208 <value type="int">6</value>
208 <value type="int">6</value>
209 <value type="int">7</value>
209 <value type="int">7</value>
210 <value type="int">8</value>
210 <value type="int">8</value>
211 <value type="int">9</value>
211 <value type="int">9</value>
212 <value type="int">10</value>
212 <value type="int">10</value>
213 <value type="int">11</value>
213 <value type="int">11</value>
214 <value type="int">12</value>
214 <value type="int">12</value>
215 <value type="int">13</value>
215 <value type="int">13</value>
216 <value type="int">14</value>
216 <value type="int">14</value>
217 </valuelist>
217 </valuelist>
218 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
218 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
219 <value type="int">0</value>
219 <value type="int">0</value>
220 <value type="int">1</value>
220 <value type="int">1</value>
221 <value type="int">2</value>
221 <value type="int">2</value>
222 <value type="int">3</value>
222 <value type="int">3</value>
223 <value type="int">4</value>
223 <value type="int">4</value>
224 <value type="int">5</value>
224 <value type="int">5</value>
225 <value type="int">6</value>
225 <value type="int">6</value>
226 <value type="int">7</value>
226 <value type="int">7</value>
227 <value type="int">8</value>
227 <value type="int">8</value>
228 <value type="int">9</value>
228 <value type="int">9</value>
229 <value type="int">10</value>
229 <value type="int">10</value>
230 <value type="int">11</value>
230 <value type="int">11</value>
231 <value type="int">12</value>
231 <value type="int">12</value>
232 <value type="int">13</value>
232 <value type="int">13</value>
233 <value type="int">14</value>
233 <value type="int">14</value>
234 </valuelist>
234 </valuelist>
235 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
235 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
236 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
236 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
237 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
237 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
238 <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
238 <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
239 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
239 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
240 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
240 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
241 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
241 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
242 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
242 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
243 <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
243 <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
244 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
244 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
245 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
245 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
246 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
246 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
247 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
247 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
248 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
248 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
249 </valuemap>
249 </valuemap>
250 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
250 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
251 </valuemap>
251 </valuemap>
252 </data>
252 </data>
253 <data>
253 <data>
254 <variable>ProjectExplorer.Project.TargetCount</variable>
254 <variable>ProjectExplorer.Project.TargetCount</variable>
255 <value type="int">1</value>
255 <value type="int">1</value>
256 </data>
256 </data>
257 <data>
257 <data>
258 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
258 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
259 <value type="QString">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
259 <value type="QString">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
260 </data>
260 </data>
261 <data>
261 <data>
262 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
262 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
263 <value type="int">10</value>
263 <value type="int">10</value>
264 </data>
264 </data>
265 </qtcreator>
265 </qtcreator>
@@ -1,308 +1,369
1 #ifndef CCSDS_H_INCLUDED
1 #ifndef CCSDS_H_INCLUDED
2 #define CCSDS_H_INCLUDED
2 #define CCSDS_H_INCLUDED
3
3
4 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
4 #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4
5 #define CCSDS_TM_PKT_MAX_SIZE 4412
5 #define CCSDS_TM_PKT_MAX_SIZE 4412
6 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
6 #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4
7 #define CCSDS_TC_PKT_MAX_SIZE 256
7 #define CCSDS_TC_PKT_MAX_SIZE 256
8 #define CCSDS_TC_PKT_MIN_SIZE 16
8 #define CCSDS_TC_PKT_MIN_SIZE 16
9 #define CCSDS_TC_TM_PACKET_OFFSET 7
9 #define CCSDS_TC_TM_PACKET_OFFSET 7
10 #define CCSDS_PROCESS_ID 76
10 #define CCSDS_PROCESS_ID 76
11 #define CCSDS_PACKET_CATEGORY 12
11 #define CCSDS_PACKET_CATEGORY 12
12 #define CCSDS_NODE_ADDRESS 0xfe
12 #define CCSDS_NODE_ADDRESS 0xfe
13
14 // PACKET IDs
15 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
16 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
17 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
18 #define TM_PACKET_ID_SCIENCE_NORMAL 0x0ccc // PID 76 CAT 12
19 #define TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2 0x0cfc // PID 79 CAT 12
20
21 // FAILURE CODES
22 #define FAILURE_CODE_INCONSISTENT 5 // 0x00 0x05
23 #define FAILURE_CODE_NOT_EXECUTABLE 40000 // 0x9c 0x40
24 #define FAILURE_CODE_NOT_IMPLEMENTED 40002 // 0x9c 0x42
25 #define FAILURE_CODE_ERROR 40003 // 0x9c 0x43
26 #define FAILURE_CODE_CORRUPTED 40005 // 0x9c 0x45
13 //
27 //
14 #define CCSDS_DESTINATION_ID_GROUND 0x00
28 #define TM_DESTINATION_ID_GROUND 0
29 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
30 #define TM_DESTINATION_ID_TC_SEQUENCES 111
31 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
32 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
33 #define TM_DESTINATION_ID_DIRECT_CMD 120
34 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
35 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
36 #define TM_DESTINATION_ID_OBCP 15
37 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
38 #define TM_DESTINATION_ID_AOCS 11
39
15 #define CCSDS_DESTINATION_ID 0x01
40 #define CCSDS_DESTINATION_ID 0x01
16 #define CCSDS_DESTINATION_ID_DPU 0x01
17 //
18 #define CCSDS_PROTOCOLE_ID 0x02
41 #define CCSDS_PROTOCOLE_ID 0x02
19 #define CCSDS_USER_APP 0x00
42 #define CCSDS_USER_APP 0x00
20
43
21 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
44 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
22 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
45 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
23 #define SIZE_HK_PARAMETERS 112
46 #define SIZE_HK_PARAMETERS 112
24
47
25 #define ILLEGAL_APID 0
48 #define ILLEGAL_APID 0
26 #define WRONG_LEN_PACKET 1
49 #define WRONG_LEN_PACKET 1
27 #define INCOR_CHECKSUM 2
50 #define INCOR_CHECKSUM 2
28 #define ILL_TYPE 3
51 #define ILL_TYPE 3
29 #define ILL_SUBTYPE 4
52 #define ILL_SUBTYPE 4
30 #define WRONG_APP_DATA 5
53 #define WRONG_APP_DATA 5
31 #define WRONG_CMD_CODE 6
54 #define WRONG_CMD_CODE 6
32 #define CCSDS_TM_VALID 7
55 #define CCSDS_TM_VALID 7
33
56
34 // TC TYPES
57 // TC TYPES
35 #define TC_TYPE_GEN 181
58 #define TC_TYPE_GEN 181
36 #define TC_TYPE_TIME 9
59 #define TC_TYPE_TIME 9
37
60
38 // TC SUBTYPES
61 // TC SUBTYPES
39 #define TC_SUBTYPE_RESET 1
62 #define TC_SUBTYPE_RESET 1
40 #define TC_SUBTYPE_LOAD_COMM 11
63 #define TC_SUBTYPE_LOAD_COMM 11
41 #define TC_SUBTYPE_LOAD_NORM 13
64 #define TC_SUBTYPE_LOAD_NORM 13
42 #define TC_SUBTYPE_LOAD_BURST 19
65 #define TC_SUBTYPE_LOAD_BURST 19
43 #define TC_SUBTYPE_LOAD_SBM1 25
66 #define TC_SUBTYPE_LOAD_SBM1 25
44 #define TC_SUBTYPE_LOAD_SBM2 27
67 #define TC_SUBTYPE_LOAD_SBM2 27
45 #define TC_SUBTYPE_DUMP 31
68 #define TC_SUBTYPE_DUMP 31
46 #define TC_SUBTYPE_ENTER 41
69 #define TC_SUBTYPE_ENTER 41
47 #define TC_SUBTYPE_UPDT_INFO 51
70 #define TC_SUBTYPE_UPDT_INFO 51
48 #define TC_SUBTYPE_EN_CAL 61
71 #define TC_SUBTYPE_EN_CAL 61
49 #define TC_SUBTYPE_DIS_CAL 63
72 #define TC_SUBTYPE_DIS_CAL 63
50 #define TC_SUBTYPE_UPDT_TIME 129
73 #define TC_SUBTYPE_UPDT_TIME 129
51
74
52 // TC LEN
75 // TC LEN
53 #define TC_LEN_RESET 12
76 #define TC_LEN_RESET 12
54 #define TC_LEN_LOAD_COMM 14
77 #define TC_LEN_LOAD_COMM 14
55 #define TC_LEN_LOAD_NORM 20
78 #define TC_LEN_LOAD_NORM 20
56 #define TC_LEN_LOAD_BURST 14
79 #define TC_LEN_LOAD_BURST 14
57 #define TC_LEN_LOAD_SBM1 14
80 #define TC_LEN_LOAD_SBM1 14
58 #define TC_LEN_LOAD_SBM2 14
81 #define TC_LEN_LOAD_SBM2 14
59 #define TC_LEN_DUMP 12
82 #define TC_LEN_DUMP 12
60 #define TC_LEN_ENTER 20
83 #define TC_LEN_ENTER 20
61 #define TC_LEN_UPDT_INFO 48
84 #define TC_LEN_UPDT_INFO 48
62 #define TC_LEN_EN_CAL 12
85 #define TC_LEN_EN_CAL 12
63 #define TC_LEN_DIS_CAL 12
86 #define TC_LEN_DIS_CAL 12
64 #define TC_LEN_UPDT_TIME 18
87 #define TC_LEN_UPDT_TIME 18
65
88
66 // TM TYPES
89 // TM TYPES
90 #define TM_TYPE_TC_EXE 1
91 #define TM_TYPE_HK 3
67 #define TM_TYPE_LFR_SCIENCE 21
92 #define TM_TYPE_LFR_SCIENCE 21
68 #define TM_TYPE_HK 3
69
93
70 // TM SUBTYPES
94 // TM SUBTYPES
71 #define TM_SUBTYPE_EXE_OK 7
95 #define TM_SUBTYPE_EXE_OK 7
72 #define TM_SUBTYPE_EXE_NOK 8
96 #define TM_SUBTYPE_EXE_NOK 8
73 #define TM_SUBTYPE_HK 25
97 #define TM_SUBTYPE_HK 25
74 #define TM_SUBTYPE_SCIENCE 3
98 #define TM_SUBTYPE_SCIENCE 3
75 #define TM_SUBTYPE_LFR_SCIENCE 3
99 #define TM_SUBTYPE_LFR_SCIENCE 3
76
100
77 // TM SID
101 // TM SID
78 #define SID_DEFAULT 0
102 #define SID_DEFAULT 0
79 #define SID_HK 1
103 #define SID_HK 1
80 #define SID_EXE_INC 5
104 #define SID_EXE_INC 5
81 #define SID_NOT_EXE 40000
105 #define SID_NOT_EXE 40000
82 #define SID_NOT_IMP 40002
106 #define SID_NOT_IMP 40002
83 #define SID_EXE_ERR 40003
107 #define SID_EXE_ERR 40003
84 #define SID_EXE_CORR 40005
108 #define SID_EXE_CORR 40005
85
109
86 #define SID_NORM_SWF_F0 3
110 #define SID_NORM_SWF_F0 3
87 #define SID_NORM_SWF_F1 4
111 #define SID_NORM_SWF_F1 4
88 #define SID_NORM_SWF_F2 5
112 #define SID_NORM_SWF_F2 5
89 #define SID_NORM_CWF_F3 1
113 #define SID_NORM_CWF_F3 1
90 #define SID_BURST_CWF_F2 2
114 #define SID_BURST_CWF_F2 2
91 #define SID_SBM1_CWF_F1 24
115 #define SID_SBM1_CWF_F1 24
92 #define SID_SBM2_CWF_F2 25
116 #define SID_SBM2_CWF_F2 25
93 #define SID_NORM_ASM_F0 11
117 #define SID_NORM_ASM_F0 11
94 #define SID_NORM_ASM_F1 12
118 #define SID_NORM_ASM_F1 12
95 #define SID_NORM_ASM_F2 13
119 #define SID_NORM_ASM_F2 13
96 #define SID_NORM_BP1_F0 14
120 #define SID_NORM_BP1_F0 14
97 #define SID_NORM_BP1_F1 15
121 #define SID_NORM_BP1_F1 15
98 #define SID_NORM_BP1_F2 16
122 #define SID_NORM_BP1_F2 16
99 #define SID_NORM_BP2_F0 19
123 #define SID_NORM_BP2_F0 19
100 #define SID_NORM_BP2_F1 20
124 #define SID_NORM_BP2_F1 20
101 #define SID_NORM_BP2_F2 21
125 #define SID_NORM_BP2_F2 21
102 #define SID_BURST_BP1_F0 17
126 #define SID_BURST_BP1_F0 17
103 #define SID_BURST_BP2_F0 22
127 #define SID_BURST_BP2_F0 22
104 #define SID_BURST_BP1_F1 18
128 #define SID_BURST_BP1_F1 18
105 #define SID_BURST_BP2_F1 23
129 #define SID_BURST_BP2_F1 23
106 #define SID_SBM1_BP1_F0 28
130 #define SID_SBM1_BP1_F0 28
107 #define SID_SBM1_BP2_F0 31
131 #define SID_SBM1_BP2_F0 31
108 #define SID_SBM2_BP1_F0 29
132 #define SID_SBM2_BP1_F0 29
109 #define SID_SBM2_BP2_F0 32
133 #define SID_SBM2_BP2_F0 32
110 #define SID_SBM1_BP1_F1 30
134 #define SID_SBM1_BP1_F1 30
111 #define SID_SBM1_BP2_F1 33
135 #define SID_SBM1_BP2_F1 33
112
136
113 // LENGTH (BYTES)
137 // LENGTH (BYTES)
138 #define LENGTH_TM_LFR_TC_EXE_MAX 32
114 #define LENGTH_TM_LFR_HK 126
139 #define LENGTH_TM_LFR_HK 126
115 #define LENGTH_TM_LFR_TC_EXE_MAX 32
140 // PACKET_LENGTH
116 #define LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX 4102
141 #define PACKET_LENGTH_TC_EXE_SUCCESS 20 - CCSDS_TC_TM_PACKET_OFFSET
117 //
142 #define PACKET_LENGTH_TC_EXE_INCONSISTENT 26 - CCSDS_TC_TM_PACKET_OFFSET
118 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
143 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE 26 - CCSDS_TC_TM_PACKET_OFFSET
119 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
144 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED 24 - CCSDS_TC_TM_PACKET_OFFSET
120 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
145 #define PACKET_LENGTH_TC_EXE_ERROR 24 - CCSDS_TC_TM_PACKET_OFFSET
121 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
146 #define PACKET_LENGTH_TC_EXE_CORRUPTED 32 - CCSDS_TC_TM_PACKET_OFFSET
122 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
147 #define PACKET_LENGTH_HK 126 - CCSDS_TC_TM_PACKET_OFFSET
148 #define PACKET_LENGTH_PARAMETER_DUMP 28 - CCSDS_TC_TM_PACKET_OFFSET
123 #define TM_HEADER_LEN 16
149 #define TM_HEADER_LEN 16
124
150
125 #define LEN_TM_LFR_HK 126 + 4
151 #define LEN_TM_LFR_HK 126 + 4
126 #define LEN_TM_LFR_TC_EXE_NOT_IMP 24 +4
152 #define LEN_TM_LFR_TC_EXE_NOT_IMP 24 +4
127
153
128 #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1
154 #define TM_LEN_SCI_SWF_340 340 * 12 + 10 + 12 - 1
129 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
155 #define TM_LEN_SCI_SWF_8 8 * 12 + 10 + 12 - 1
156 #define TM_LEN_SCI_CWF_340 340 * 12 + 10 + 10 - 1
157 #define TM_LEN_SCI_CWF_8 8 * 12 + 10 + 10 - 1
130
158
131 enum TM_TYPE{
159 enum TM_TYPE{
132 TM_LFR_TC_EXE_OK,
160 TM_LFR_TC_EXE_OK,
133 TM_LFR_TC_EXE_ERR,
161 TM_LFR_TC_EXE_ERR,
134 TM_LFR_HK,
162 TM_LFR_HK,
135 TM_LFR_SCI,
163 TM_LFR_SCI,
136 TM_LFR_SCI_SBM,
164 TM_LFR_SCI_SBM,
137 TM_LFR_PAR_DUMP
165 TM_LFR_PAR_DUMP
138 };
166 };
139
167
140 struct TMHeader_str
168 struct TMHeader_str
141 {
169 {
142 volatile unsigned char targetLogicalAddress;
170 volatile unsigned char targetLogicalAddress;
143 volatile unsigned char protocolIdentifier;
171 volatile unsigned char protocolIdentifier;
144 volatile unsigned char reserved;
172 volatile unsigned char reserved;
145 volatile unsigned char userApplication;
173 volatile unsigned char userApplication;
146 volatile unsigned char packetID[2];
174 volatile unsigned char packetID[2];
147 volatile unsigned char packetSequenceControl[2];
175 volatile unsigned char packetSequenceControl[2];
148 volatile unsigned char packetLength[2];
176 volatile unsigned char packetLength[2];
149 volatile unsigned char dataFieldHeader[10];
177 // DATA FIELD HEADER
178 volatile unsigned char spare1_pusVersion_spare2;
179 volatile unsigned char serviceType;
180 volatile unsigned char serviceSubType;
181 volatile unsigned char destinationID;
182 volatile unsigned char time[6];
150 };
183 };
151 typedef struct TMHeader_str TMHeader_t;
184 typedef struct TMHeader_str TMHeader_t;
152
185
153 struct Packet_TM_LFR_TC_EXE_str
186 struct Packet_TM_LFR_TC_EXE_str
154 {
187 {
155 volatile unsigned char targetLogicalAddress;
188 volatile unsigned char targetLogicalAddress;
156 volatile unsigned char protocolIdentifier;
189 volatile unsigned char protocolIdentifier;
157 volatile unsigned char reserved;
190 volatile unsigned char reserved;
158 volatile unsigned char userApplication;
191 volatile unsigned char userApplication;
159 volatile unsigned char packetID[2];
192 volatile unsigned char packetID[2];
160 volatile unsigned char packetSequenceControl[2];
193 volatile unsigned char packetSequenceControl[2];
161 volatile unsigned char packetLength[2];
194 volatile unsigned char packetLength[2];
162 volatile unsigned char dataFieldHeader[10];
195 // DATA FIELD HEADER
196 volatile unsigned char spare1_pusVersion_spare2;
197 volatile unsigned char serviceType;
198 volatile unsigned char serviceSubType;
199 volatile unsigned char destinationID;
200 volatile unsigned char time[6];
163 volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1];
201 volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1];
164 };
202 };
165 typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t;
203 typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t;
166
204
167 struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str
205 struct Header_TM_LFR_SCIENCE_SWF_str
168 {
206 {
169 volatile unsigned char targetLogicalAddress;
207 volatile unsigned char targetLogicalAddress;
170 volatile unsigned char protocolIdentifier;
208 volatile unsigned char protocolIdentifier;
171 volatile unsigned char reserved;
209 volatile unsigned char reserved;
172 volatile unsigned char userApplication;
210 volatile unsigned char userApplication;
173 volatile unsigned char packetID[2];
211 volatile unsigned char packetID[2];
174 volatile unsigned char packetSequenceControl[2];
212 volatile unsigned char packetSequenceControl[2];
175 volatile unsigned char packetLength[2];
213 volatile unsigned char packetLength[2];
176 volatile unsigned char dataFieldHeader[10];
214 // DATA FIELD HEADER
177 volatile unsigned char auxiliaryHeader[6];
215 volatile unsigned char spare1_pusVersion_spare2;
178 volatile unsigned char data[LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX - 10 + 1];
216 volatile unsigned char serviceType;
217 volatile unsigned char serviceSubType;
218 volatile unsigned char destinationID;
219 volatile unsigned char time[6];
220 // AUXILIARY HEADER
221 volatile unsigned char sid;
222 volatile unsigned char hkBIA;
223 volatile unsigned char pktCnt;
224 volatile unsigned char pktNr;
225 volatile unsigned char acquisitionTime[6];
226 volatile unsigned char blkNr[2];
179 };
227 };
180 typedef struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str Packet_TM_LFR_SCIENCE_NORMAL_WF_t;
228 typedef struct Header_TM_LFR_SCIENCE_SWF_str Header_TM_LFR_SCIENCE_SWF_t;
181
229
182 struct ExtendedTMHeader_str
230 struct Header_TM_LFR_SCIENCE_CWF_str
183 {
231 {
184 volatile unsigned char targetLogicalAddress;
232 volatile unsigned char targetLogicalAddress;
185 volatile unsigned char protocolIdentifier;
233 volatile unsigned char protocolIdentifier;
186 volatile unsigned char reserved;
234 volatile unsigned char reserved;
187 volatile unsigned char userApplication;
235 volatile unsigned char userApplication;
188 volatile unsigned char packetID[2];
236 volatile unsigned char packetID[2];
189 volatile unsigned char packetSequenceControl[2];
237 volatile unsigned char packetSequenceControl[2];
190 volatile unsigned char packetLength[2];
238 volatile unsigned char packetLength[2];
191 volatile unsigned char dataFieldHeader[10];
239 // DATA FIELD HEADER
192 volatile unsigned char auxiliaryHeader[6];
240 volatile unsigned char spare1_pusVersion_spare2;
241 volatile unsigned char serviceType;
242 volatile unsigned char serviceSubType;
243 volatile unsigned char destinationID;
244 volatile unsigned char time[6];
245 // AUXILIARY DATA HEADER
246 volatile unsigned char sid;
247 volatile unsigned char hkBIA;
248 volatile unsigned char acquisitionTime[6];
249 volatile unsigned char blkNr[2];
193 };
250 };
194 typedef struct ExtendedTMHeader_str ExtendedTMHeader_t;
251 typedef struct Header_TM_LFR_SCIENCE_CWF_str Header_TM_LFR_SCIENCE_CWF_t;
195
252
196 struct ccsdsTelecommandPacket_str
253 struct ccsdsTelecommandPacket_str
197 {
254 {
198 //unsigned char targetLogicalAddress; // removed by the grspw module
255 //unsigned char targetLogicalAddress; // removed by the grspw module
199 volatile unsigned char protocolIdentifier;
256 volatile unsigned char protocolIdentifier;
200 volatile unsigned char reserved;
257 volatile unsigned char reserved;
201 volatile unsigned char userApplication;
258 volatile unsigned char userApplication;
202 volatile unsigned char packetID[2];
259 volatile unsigned char packetID[2];
203 volatile unsigned char packetSequenceControl[2];
260 volatile unsigned char packetSequenceControl[2];
204 volatile unsigned char packetLength[2];
261 volatile unsigned char packetLength[2];
205 volatile unsigned char dataFieldHeader[4];
262 // DATA FIELD HEADER
263 volatile unsigned char headerFlag_pusVersion_Ack;
264 volatile unsigned char serviceType;
265 volatile unsigned char serviceSubType;
266 volatile unsigned char sourceID;
206 volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
267 volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
207 };
268 };
208 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
269 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
209
270
210 struct Packet_TM_LFR_HK_str
271 struct Packet_TM_LFR_HK_str
211 {
272 {
212 volatile unsigned char targetLogicalAddress;
273 volatile unsigned char targetLogicalAddress;
213 volatile unsigned char protocolIdentifier;
274 volatile unsigned char protocolIdentifier;
214 volatile unsigned char reserved;
275 volatile unsigned char reserved;
215 volatile unsigned char userApplication;
276 volatile unsigned char userApplication;
216 volatile unsigned char packetID[2];
277 volatile unsigned char packetID[2];
217 volatile unsigned char packetSequenceControl[2];
278 volatile unsigned char packetSequenceControl[2];
218 volatile unsigned char packetLength[2];
279 volatile unsigned char packetLength[2];
219 volatile unsigned char dataFieldHeader[10];
280 volatile unsigned char dataFieldHeader[10];
220 volatile unsigned char sid;
281 volatile unsigned char sid;
221
282
222 //**************
283 //**************
223 // HK PARAMETERS
284 // HK PARAMETERS
224 unsigned char lfr_status_word[2];
285 unsigned char lfr_status_word[2];
225 unsigned char lfr_sw_version[4];
286 unsigned char lfr_sw_version[4];
226 // tc statistics
287 // tc statistics
227 unsigned char hk_lfr_update_info_tc_cnt[2];
288 unsigned char hk_lfr_update_info_tc_cnt[2];
228 unsigned char hk_lfr_update_time_tc_cnt[2];
289 unsigned char hk_lfr_update_time_tc_cnt[2];
229 unsigned char hk_dpu_exe_tc_lfr_cnt[2];
290 unsigned char hk_dpu_exe_tc_lfr_cnt[2];
230 unsigned char hk_dpu_rej_tc_lfr_cnt[2];
291 unsigned char hk_dpu_rej_tc_lfr_cnt[2];
231 unsigned char hk_lfr_last_exe_tc_id[2];
292 unsigned char hk_lfr_last_exe_tc_id[2];
232 unsigned char hk_lfr_last_exe_tc_type[2];
293 unsigned char hk_lfr_last_exe_tc_type[2];
233 unsigned char hk_lfr_last_exe_tc_subtype[2];
294 unsigned char hk_lfr_last_exe_tc_subtype[2];
234 unsigned char hk_lfr_last_exe_tc_time[6];
295 unsigned char hk_lfr_last_exe_tc_time[6];
235 unsigned char hk_lfr_last_rej_tc_id[2];
296 unsigned char hk_lfr_last_rej_tc_id[2];
236 unsigned char hk_lfr_last_rej_tc_type[2];
297 unsigned char hk_lfr_last_rej_tc_type[2];
237 unsigned char hk_lfr_last_rej_tc_subtype[2];
298 unsigned char hk_lfr_last_rej_tc_subtype[2];
238 unsigned char hk_lfr_last_rej_tc_time[6];
299 unsigned char hk_lfr_last_rej_tc_time[6];
239 // anomaly statistics
300 // anomaly statistics
240 unsigned char hk_lfr_le_cnt[2];
301 unsigned char hk_lfr_le_cnt[2];
241 unsigned char hk_lfr_me_cnt[2];
302 unsigned char hk_lfr_me_cnt[2];
242 unsigned char hk_lfr_he_cnt[2];
303 unsigned char hk_lfr_he_cnt[2];
243 unsigned char hk_lfr_last_er_rid[2];
304 unsigned char hk_lfr_last_er_rid[2];
244 unsigned char hk_lfr_last_er_code;
305 unsigned char hk_lfr_last_er_code;
245 unsigned char hk_lfr_last_er_time[6];
306 unsigned char hk_lfr_last_er_time[6];
246 // vhdl_blk_status
307 // vhdl_blk_status
247 unsigned char hk_lfr_vhdl_aa_sm;
308 unsigned char hk_lfr_vhdl_aa_sm;
248 unsigned char hk_lfr_vhdl_fft_sr;
309 unsigned char hk_lfr_vhdl_fft_sr;
249 unsigned char hk_lfr_vhdl_cic_hk;
310 unsigned char hk_lfr_vhdl_cic_hk;
250 unsigned char hk_lfr_vhdl_iir_cal;
311 unsigned char hk_lfr_vhdl_iir_cal;
251 // spacewire_if_statistics
312 // spacewire_if_statistics
252 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
313 unsigned char hk_lfr_dpu_spw_pkt_rcv_cnt[2];
253 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
314 unsigned char hk_lfr_dpu_spw_pkt_sent_cnt[2];
254 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
315 unsigned char hk_lfr_dpu_spw_tick_out_cnt;
255 unsigned char hk_lfr_dpu_spw_last_timc;
316 unsigned char hk_lfr_dpu_spw_last_timc;
256 // ahb error statistics
317 // ahb error statistics
257 unsigned int hk_lfr_last_fail_addr;
318 unsigned int hk_lfr_last_fail_addr;
258 // temperatures
319 // temperatures
259 unsigned char hk_lfr_temp_scm[2];
320 unsigned char hk_lfr_temp_scm[2];
260 unsigned char hk_lfr_temp_pcb[2];
321 unsigned char hk_lfr_temp_pcb[2];
261 unsigned char hk_lfr_temp_fpga[2];
322 unsigned char hk_lfr_temp_fpga[2];
262 // error counters
323 // error counters
263 unsigned char hk_lfr_dpu_spw_parity;
324 unsigned char hk_lfr_dpu_spw_parity;
264 unsigned char hk_lfr_dpu_spw_disconnect;
325 unsigned char hk_lfr_dpu_spw_disconnect;
265 unsigned char hk_lfr_dpu_spw_escape;
326 unsigned char hk_lfr_dpu_spw_escape;
266 unsigned char hk_lfr_dpu_spw_credit;
327 unsigned char hk_lfr_dpu_spw_credit;
267 unsigned char hk_lfr_dpu_spw_write_sync;
328 unsigned char hk_lfr_dpu_spw_write_sync;
268 unsigned char hk_lfr_dpu_spw_rx_ahb;
329 unsigned char hk_lfr_dpu_spw_rx_ahb;
269 unsigned char hk_lfr_dpu_spw_tx_ahb;
330 unsigned char hk_lfr_dpu_spw_tx_ahb;
270 unsigned char hk_lfr_dpu_spw_header_crc;
331 unsigned char hk_lfr_dpu_spw_header_crc;
271 unsigned char hk_lfr_dpu_spw_data_crc;
332 unsigned char hk_lfr_dpu_spw_data_crc;
272 unsigned char hk_lfr_dpu_spw_early_eop;
333 unsigned char hk_lfr_dpu_spw_early_eop;
273 unsigned char hk_lfr_dpu_spw_invalid_addr;
334 unsigned char hk_lfr_dpu_spw_invalid_addr;
274 unsigned char hk_lfr_dpu_spw_eep;
335 unsigned char hk_lfr_dpu_spw_eep;
275 unsigned char hk_lfr_dpu_spw_rx_too_big;
336 unsigned char hk_lfr_dpu_spw_rx_too_big;
276 // timecode
337 // timecode
277 unsigned char hk_lfr_timecode_erroneous;
338 unsigned char hk_lfr_timecode_erroneous;
278 unsigned char hk_lfr_timecode_missing;
339 unsigned char hk_lfr_timecode_missing;
279 unsigned char hk_lfr_timecode_invalid;
340 unsigned char hk_lfr_timecode_invalid;
280 // time
341 // time
281 unsigned char hk_lfr_time_timecode_it;
342 unsigned char hk_lfr_time_timecode_it;
282 unsigned char hk_lfr_time_not_synchro;
343 unsigned char hk_lfr_time_not_synchro;
283 unsigned char hk_lfr_time_timecode_ctr;
344 unsigned char hk_lfr_time_timecode_ctr;
284 // hk_lfr_buffer_dpu_
345 // hk_lfr_buffer_dpu_
285 unsigned char hk_lfr_buffer_dpu_tc_fifo;
346 unsigned char hk_lfr_buffer_dpu_tc_fifo;
286 unsigned char hk_lfr_buffer_dpu_tm_fifo;
347 unsigned char hk_lfr_buffer_dpu_tm_fifo;
287 // hk_lfr_ahb_
348 // hk_lfr_ahb_
288 unsigned char hk_lfr_ahb_correctable;
349 unsigned char hk_lfr_ahb_correctable;
289 unsigned char hk_lfr_ahb_uncorrectable;
350 unsigned char hk_lfr_ahb_uncorrectable;
290 unsigned char hk_lfr_ahb_fails_trans;
351 unsigned char hk_lfr_ahb_fails_trans;
291 // hk_lfr_adc_
352 // hk_lfr_adc_
292 unsigned char hk_lfr_adc_failure;
353 unsigned char hk_lfr_adc_failure;
293 unsigned char hk_lfr_adc_timeout;
354 unsigned char hk_lfr_adc_timeout;
294 unsigned char hk_lfr_toomany_err;
355 unsigned char hk_lfr_toomany_err;
295 // hk_lfr_cpu_
356 // hk_lfr_cpu_
296 unsigned char hk_lfr_cpu_write_err;
357 unsigned char hk_lfr_cpu_write_err;
297 unsigned char hk_lfr_cpu_ins_access_err;
358 unsigned char hk_lfr_cpu_ins_access_err;
298 unsigned char hk_lfr_cpu_illegal_ins;
359 unsigned char hk_lfr_cpu_illegal_ins;
299 unsigned char hk_lfr_cpu_privilegied_ins;
360 unsigned char hk_lfr_cpu_privilegied_ins;
300 unsigned char hk_lfr_cpu_register_hw;
361 unsigned char hk_lfr_cpu_register_hw;
301 unsigned char hk_lfr_cpu_not_aligned;
362 unsigned char hk_lfr_cpu_not_aligned;
302 unsigned char hk_lfr_cpu_data_exception;
363 unsigned char hk_lfr_cpu_data_exception;
303 unsigned char hk_lfr_cpu_div_exception;
364 unsigned char hk_lfr_cpu_div_exception;
304 unsigned char hk_lfr_cpu_arith_overflow;
365 unsigned char hk_lfr_cpu_arith_overflow;
305 };
366 };
306 typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t;
367 typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t;
307
368
308 #endif // CCSDS_H_INCLUDED
369 #endif // CCSDS_H_INCLUDED
@@ -1,64 +1,67
1 #ifndef FSW_RTEMS_H_INCLUDED
1 #ifndef FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
3
3
4 #include <errno.h>
4 #include <errno.h>
5 #include <fcntl.h>
5 #include <fcntl.h>
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <stdlib.h>
7 #include <stdlib.h>
8
8
9 #include <grspw.h>
9 #include <grspw.h>
10 #include <apbuart.h>
10 #include <apbuart.h>
11
11
12 #include <fsw_params.h>
12 #include <fsw_params.h>
13 #include <fsw_misc.h>
13 #include <fsw_misc.h>
14 #include <fsw_processing.h>
14 #include <fsw_processing.h>
15 #include <tc_handler.h>
15 #include <tc_handler.h>
16 #include <wf_handler.h>
16 #include <wf_handler.h>
17 #include <grlib_regs.h>
17 #include <grlib_regs.h>
18 #include <ccsds_types.h>
18 #include <ccsds_types.h>
19
19
20 extern int sched_yield( void );
20 extern int sched_yield( void );
21 extern int errno;
21 extern int errno;
22 extern rtems_id Task_id[ ]; /* array of task ids */
22 extern rtems_id Task_id[ ]; /* array of task ids */
23 extern rtems_name Task_name[ ]; /* array of task names */
23 extern rtems_name Task_name[ ]; /* array of task names */
24 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
24 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
25 extern int fdSPW; // grspw file descriptor
25 extern int fdSPW; // grspw file descriptor
26 extern int fdUART; // uart file descriptor
26 extern int fdUART; // uart file descriptor
27
27
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
29
29
30 // MODE PARAMETERS
30 // MODE PARAMETERS
31 extern struct param_local_str param_local;
31 extern struct param_common_str param_common;
32 extern struct param_common_str param_common;
32 extern struct param_norm_str param_norm;
33 extern struct param_norm_str param_norm;
33 extern struct param_burst_str param_burst;
34 extern struct param_burst_str param_burst;
34 extern struct param_sbm1_str param_sbm1;
35 extern struct param_sbm1_str param_sbm1;
35 extern struct param_sbm2_str param_sbm2;
36 extern struct param_sbm2_str param_sbm2;
36 extern Packet_TM_LFR_HK_t housekeeping_packet;
37 extern Packet_TM_LFR_HK_t housekeeping_packet;
37 extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
38 extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
38
39
39 // RTEMS TASKS
40 // RTEMS TASKS
40 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
41 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
41 rtems_task recv_task(rtems_task_argument argument);
42 rtems_task recv_task(rtems_task_argument argument);
42 rtems_task spiq_task(rtems_task_argument argument);
43 rtems_task spiq_task(rtems_task_argument argument);
43 rtems_task stat_task(rtems_task_argument argument);
44 rtems_task stat_task(rtems_task_argument argument);
44 rtems_task wfrm_task(rtems_task_argument argument);
45 rtems_task wfrm_task(rtems_task_argument argument);
45 int create_names( void );
46 int create_names( void );
46 int create_all_tasks( void );
47 int create_all_tasks( void );
47 int start_all_tasks( void );
48 int start_all_tasks( void );
48 int create_message_queue( void );
49 int create_message_queue( void );
49
50
50 // OTHER functions
51 // OTHER functions
51 void init_default_mode_parameters( void );
52 void init_default_mode_parameters( void );
52 void init_housekeeping_parameters( void );
53 void init_housekeeping_parameters( void );
53
54
54 int configure_spw_link( void );
55 int spacewire_configure_link( void );
55 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
56 int spacewire_try_to_start(void);
56 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
57 void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
58 void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
59 void spacewire_compute_stats_offsets();
57
60
58 extern int rtems_cpu_usage_report( void );
61 extern int rtems_cpu_usage_report( void );
59 extern int rtems_cpu_usage_reset( void );
62 extern int rtems_cpu_usage_reset( void );
60
63
61 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
64 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
62 void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc);
65 void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc);
63
66
64 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
67 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,28 +1,30
1 #ifndef FSW_MISC_H_INCLUDED
1 #ifndef FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6
6
7 #include <fsw_init.h>
7 #include <fsw_init.h>
8 #include <fsw_params.h>
8 #include <fsw_params.h>
9 #include <grlib_regs.h>
9 #include <grlib_regs.h>
10 #include <grspw.h>
10 #include <grspw.h>
11 #include <ccsds_types.h>
11 #include <ccsds_types.h>
12
12
13 rtems_name HK_name; // name of the HK rate monotonic
13 rtems_name HK_name; // name of the HK rate monotonic
14 rtems_id HK_id; // id of the HK rate monotonic period
14 rtems_id HK_id; // id of the HK rate monotonic period
15 extern spw_stats spacewire_stats;
16 extern spw_stats spacewire_stats_backup;
15
17
16 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
18 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
17 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
18 void print_statistics(spw_stats *stats);
20 void update_spacewire_statistics();
19
21
20 // SERIAL LINK
22 // SERIAL LINK
21 int send_console_outputs_on_serial_port( void );
23 int send_console_outputs_on_serial_port( void );
22 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
24 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
23
25
24 // RTEMS TASKS
26 // RTEMS TASKS
25 rtems_task stat_task(rtems_task_argument argument);
27 rtems_task stat_task(rtems_task_argument argument);
26 rtems_task hous_task(rtems_task_argument argument);
28 rtems_task hous_task(rtems_task_argument argument);
27
29
28 #endif // FSW_MISC_H_INCLUDED
30 #endif // FSW_MISC_H_INCLUDED
@@ -1,150 +1,175
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3
3
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 #define UART_DEVICE_NAME "/dev/console"
5 #define UART_DEVICE_NAME "/dev/console"
6
6
7 //************************
7 //************************
8 // flight software version
8 // flight software version
9 // this parameters is handled by the Qt project options
9 // this parameters is handled by the Qt project options
10
10
11 //**********
11 //**********
12 // LFR MODES
12 // LFR MODES
13 #define LFR_MODE_STANDBY 0
13 #define LFR_MODE_STANDBY 0
14 #define LFR_MODE_NORMAL 1
14 #define LFR_MODE_NORMAL 1
15 #define LFR_MODE_BURST 2
15 #define LFR_MODE_BURST 2
16 #define LFR_MODE_SBM1 3
16 #define LFR_MODE_SBM1 3
17 #define LFR_MODE_SBM2 4
17 #define LFR_MODE_SBM2 4
18
18
19 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
19 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
20 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
20 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
21 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
21 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
22 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
22 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
23 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
23 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
24
24
25 //****************************
26 // LFR DEFAULT MODE PARAMETERS
27 // NORM
28 #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample
29 #define DEFAULT_SY_LFR_N_SWF_P 16 // sec
30 #define DEFAULT_SY_LFR_N_ASM_P 3600 // sec
31 #define DEFAULT_SY_LFR_N_BP_P0 4 // sec
32 #define DEFAULT_SY_LFR_N_BP_P1 20 // sec
33 // BURST
34 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
35 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
36 // SBM1
37 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
38 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
39 // SBM2
40 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
41 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
42
25 //*****************************
43 //*****************************
26 // APB REGISTERS BASE ADDRESSES
44 // APB REGISTERS BASE ADDRESSES
27 #define REGS_ADDR_APBUART 0x80000100
45 #define REGS_ADDR_APBUART 0x80000100
28 #define REGS_ADDR_GPTIMER 0x80000300
46 #define REGS_ADDR_GPTIMER 0x80000300
29 #define REGS_ADDR_GRSPW 0x80000500
47 #define REGS_ADDR_GRSPW 0x80000500
30 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
48 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
31 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
49 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
32 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
50 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
33
51
34 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
52 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
35 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400
53 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400
36
54
37 //**********
55 //**********
38 // IRQ LINES
56 // IRQ LINES
39 #define IRQ_SM 9
57 #define IRQ_SM 9
40 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
58 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
41 #define IRQ_WF 10
59 #define IRQ_WF 10
42 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
60 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
43 #define IRQ_TIME1 12
61 #define IRQ_TIME1 12
44 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
62 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
45 #define IRQ_TIME2 13
63 #define IRQ_TIME2 13
46 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
64 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
47 #define IRQ_WAVEFORM_PICKER 14
65 #define IRQ_WAVEFORM_PICKER 14
48 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
66 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
49
67
50 //*****
68 //*****
51 // TIME
69 // TIME
52 #define CLKDIV_SM_SIMULATOR 9999
70 #define CLKDIV_SM_SIMULATOR 9999
53 #define CLKDIV_WF_SIMULATOR 9999999
71 #define CLKDIV_WF_SIMULATOR 9999999
54 #define TIMER_SM_SIMULATOR 1
72 #define TIMER_SM_SIMULATOR 1
55 #define TIMER_WF_SIMULATOR 2
73 #define TIMER_WF_SIMULATOR 2
56 #define HK_PERIOD 100 // 100 * 10ms => 1sec
74 #define HK_PERIOD 100 // 100 * 10ms => 1sec
57
75
58 //**********
76 //**********
59 // LPP CODES
77 // LPP CODES
60 #define LFR_SUCCESSFUL 0
78 #define LFR_SUCCESSFUL 0
61 #define LFR_DEFAULT 1
79 #define LFR_DEFAULT 1
62
80
63 //******
81 //******
64 // RTEMS
82 // RTEMS
65 #define TASKID_RECV 1
83 #define TASKID_RECV 1
66 #define TASKID_ACTN 2
84 #define TASKID_ACTN 2
67 #define TASKID_SPIQ 3
85 #define TASKID_SPIQ 3
68 #define TASKID_SMIQ 4
86 #define TASKID_SMIQ 4
69 #define TASKID_STAT 5
87 #define TASKID_STAT 5
70 #define TASKID_AVF0 6
88 #define TASKID_AVF0 6
71 #define TASKID_BPF0 7
89 #define TASKID_BPF0 7
72 #define TASKID_WFRM 8
90 #define TASKID_WFRM 8
73 #define TASKID_DUMB 9
91 #define TASKID_DUMB 9
74 #define TASKID_HOUS 10
92 #define TASKID_HOUS 10
75
93
76 #define ACTION_MSG_QUEUE_COUNT 10
94 #define ACTION_MSG_QUEUE_COUNT 10
77
95
78 //*******
96 //*******
79 // MACROS
97 // MACROS
80 #ifdef PRINT_MESSAGES_ON_CONSOLE
98 #ifdef PRINT_MESSAGES_ON_CONSOLE
81 #define PRINTF(x) printf(x);
99 #define PRINTF(x) printf(x);
82 #define PRINTF1(x,y) printf(x,y);
100 #define PRINTF1(x,y) printf(x,y);
83 #define PRINTF2(x,y,z) printf(x,y,z);
101 #define PRINTF2(x,y,z) printf(x,y,z);
84 #else
102 #else
85 #define PRINTF(x) ;
103 #define PRINTF(x) ;
86 #define PRINTF1(x,y) ;
104 #define PRINTF1(x,y) ;
87 #define PRINTF2(x,y,z) ;
105 #define PRINTF2(x,y,z) ;
88 #endif
106 #endif
89
107
90 #define NB_SAMPLES_PER_SNAPSHOT 2048
108 #define NB_SAMPLES_PER_SNAPSHOT 2048
91 #define TIME_OFFSET 2
109 #define TIME_OFFSET 2
92 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
110 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
93 #define NB_BYTES_SWF_BLK 2 * 6
111 #define NB_BYTES_SWF_BLK 2 * 6
94 #define NB_WORDS_SWF_BLK 3
112 #define NB_WORDS_SWF_BLK 3
95
113
96 //******************
114 //******************
97 // SEQUENCE COUNTERS
115 // SEQUENCE COUNTERS
98 #define SEQ_CNT_NB_PID 2
116 #define SEQ_CNT_NB_PID 2
99 #define SEQ_CNT_NB_CAT 4
117 #define SEQ_CNT_NB_CAT 4
100 #define SEQ_CNT_NB_DEST_ID 11
118 #define SEQ_CNT_NB_DEST_ID 11
101 // pid
119 // pid
102 #define SEQ_CNT_PID_76 0
120 #define SEQ_CNT_PID_76 0
103 #define SEQ_CNT_PID_79 1
121 #define SEQ_CNT_PID_79 1
104 //cat
122 //cat
105 #define SEQ_CNT_CAT_1 0
123 #define SEQ_CNT_CAT_1 0
106 #define SEQ_CNT_CAT_4 1
124 #define SEQ_CNT_CAT_4 1
107 #define SEQ_CNT_CAT_9 2
125 #define SEQ_CNT_CAT_9 2
108 #define SEQ_CNT_CAT_12 3
126 #define SEQ_CNT_CAT_12 3
109 // destination id
127 // destination id
110 #define SEQ_CNT_DST_ID_GROUND 0
128 #define SEQ_CNT_DST_ID_GROUND 0
111 #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1
129 #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1
112 #define SEQ_CNT_DST_ID_TC_SEQUENCES 2
130 #define SEQ_CNT_DST_ID_TC_SEQUENCES 2
113 #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3
131 #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3
114 #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4
132 #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4
115 #define SEQ_CNT_DST_ID_DIRECT_CMD 5
133 #define SEQ_CNT_DST_ID_DIRECT_CMD 5
116 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6
134 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6
117 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7
135 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7
118 #define SEQ_CNT_DST_ID_OBCP 8
136 #define SEQ_CNT_DST_ID_OBCP 8
119 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
137 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
120 #define SEQ_CNT_DST_ID_AOCS 10
138 #define SEQ_CNT_DST_ID_AOCS 10
121
139
140 struct param_local_str{
141 unsigned int local_sbm1_nb_cwf_sent;
142 unsigned int local_sbm1_nb_cwf_max;
143 unsigned int local_sbm2_nb_cwf_sent;
144 unsigned int local_sbm2_nb_cwf_max;
145 };
146
122 struct param_common_str{
147 struct param_common_str{
123 unsigned char sy_lfr_common0;
148 unsigned char sy_lfr_common0;
124 unsigned char sy_lfr_common1;
149 unsigned char sy_lfr_common1;
125 };
150 };
126
151
127 struct param_norm_str{
152 struct param_norm_str{
128 unsigned int sy_lfr_n_swf_l; // length of the snapshots
153 unsigned int sy_lfr_n_swf_l; // length of the snapshots
129 unsigned int sy_lfr_n_swf_p; // time between two snapshots
154 unsigned int sy_lfr_n_swf_p; // time between two snapshots
130 unsigned int sy_lfr_n_asm_p; // time between two asm
155 unsigned int sy_lfr_n_asm_p; // time between two asm
131 unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set
156 unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set
132 unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set
157 unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set
133 };
158 };
134
159
135 struct param_burst_str{
160 struct param_burst_str{
136 unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set
161 unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set
137 unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set
162 unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set
138 };
163 };
139
164
140 struct param_sbm1_str{
165 struct param_sbm1_str{
141 unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set
166 unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set
142 unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set
167 unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set
143 };
168 };
144
169
145 struct param_sbm2_str{
170 struct param_sbm2_str{
146 unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set
171 unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set
147 unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set
172 unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set
148 };
173 };
149
174
150 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
175 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,76 +1,87
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <bsp.h> // for the LEON_Unmask_interrupt function
5 #include <bsp.h> // for the LEON_Unmask_interrupt function
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <unistd.h> // for the read call
7 #include <unistd.h> // for the read call
8 #include <sys/ioctl.h> // for the ioctl call
8 #include <sys/ioctl.h> // for the ioctl call
9 #include <ccsds_types.h>
9 #include <ccsds_types.h>
10 #include <grspw.h>
10 #include <grspw.h>
11 #include <fsw_init.h>
11 #include <fsw_init.h>
12
12
13 extern int fdSPW;
13 extern int fdSPW;
14 extern rtems_name misc_name[ ];
14 extern rtems_name misc_name[ ];
15 extern rtems_name misc_id[ ];
15 extern rtems_name misc_id[ ];
16 extern rtems_id Task_id[ ]; // array of task ids
16 extern rtems_id Task_id[ ]; // array of task ids
17 // MODE PARAMETERS
17 // MODE PARAMETERS
18 extern struct param_common_str param_common;
18 extern struct param_common_str param_common;
19 extern struct param_norm_str param_norm;
19 extern struct param_norm_str param_norm;
20 extern struct param_sbm1_str param_sbm1;
20 extern struct param_sbm1_str param_sbm1;
21 extern struct param_sbm2_str param_sbm2;
21 extern struct param_sbm2_str param_sbm2;
22 extern Packet_TM_LFR_HK_t housekeeping_packet;
22 extern Packet_TM_LFR_HK_t housekeeping_packet;
23 extern time_management_regs_t *time_management_regs;
23 extern time_management_regs_t *time_management_regs;
24 extern waveform_picker_regs_t *waveform_picker_regs;
24 extern waveform_picker_regs_t *waveform_picker_regs;
25 extern gptimer_regs_t *gptimer_regs;
25 extern gptimer_regs_t *gptimer_regs;
26
26
27 //****
27 //****
28 // ISR
28 // ISR
29 rtems_isr commutation_isr1( rtems_vector_number vector );
29 rtems_isr commutation_isr1( rtems_vector_number vector );
30 rtems_isr commutation_isr2( rtems_vector_number vector );
30 rtems_isr commutation_isr2( rtems_vector_number vector );
31
31
32 //**********************
32 //**********************
33 // GENERAL USE FUNCTIONS
33 // GENERAL USE FUNCTIONS
34 void initLookUpTableForCRC( void );
34 void initLookUpTableForCRC( void );
35 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
35 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
36
36
37 //*********************
37 //*********************
38 // ACCEPTANCE FUNCTIONS
38 // ACCEPTANCE FUNCTIONS
39 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
39 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
40 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
40
41
41 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
42 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
42 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
43 TMHeader_t *TMHeader, unsigned char tc_sid);
43 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
44 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
44 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
45
45
46 //***********
46 //***********
47 // RTEMS TASK
47 // RTEMS TASK
48 rtems_task recv_task( rtems_task_argument unused );
48 rtems_task recv_task( rtems_task_argument unused );
49 rtems_task actn_task( rtems_task_argument unused );
49 rtems_task actn_task( rtems_task_argument unused );
50 rtems_task dumb_task( rtems_task_argument unused );
50 rtems_task dumb_task( rtems_task_argument unused );
51 int create_message_queue( void );
51 int create_message_queue( void );
52
52
53 //***********
53 //***********
54 // TC ACTIONS
54 // TC ACTIONS
55 int action_default(ccsdsTelecommandPacket_t *TC);
55 int action_default(ccsdsTelecommandPacket_t *TC);
56 int action_default_alt(ccsdsTelecommandPacket_t *TC);
56 int action_enter(ccsdsTelecommandPacket_t *TC);
57 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
57 int action_updt_info(ccsdsTelecommandPacket_t *TC);
58 //
58 int action_enable_calibration(ccsdsTelecommandPacket_t *TC);
59 int action_disable_calibration(ccsdsTelecommandPacket_t *TC);
60 int action_updt_time(ccsdsTelecommandPacket_t *TC);
61 // mode transition
62 int transition_validation(unsigned char requestedMode);
59 int stop_current_mode();
63 int stop_current_mode();
60 int enter_normal_mode();
64 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
61 int enter_burst_mode();
65 int enter_standby_mode(ccsdsTelecommandPacket_t *TC);
62 int enter_sbm1_mode();
66 int enter_normal_mode(ccsdsTelecommandPacket_t *TC);
63 int enter_sbm2_mode();
67 int enter_burst_mode(ccsdsTelecommandPacket_t *TC);
68 int enter_sbm1_mode(ccsdsTelecommandPacket_t *TC);
69 int enter_sbm2_mode(ccsdsTelecommandPacket_t *TC);
70 // parameters loading
64 int action_load_comm(ccsdsTelecommandPacket_t *TC);
71 int action_load_comm(ccsdsTelecommandPacket_t *TC);
65 int action_load_norm(ccsdsTelecommandPacket_t *TC);
72 int action_load_norm(ccsdsTelecommandPacket_t *TC);
66 int action_enter(ccsdsTelecommandPacket_t *TC);
73 int action_load_burst(ccsdsTelecommandPacket_t *TC);
67 int action_updt_time(ccsdsTelecommandPacket_t *TC);
74 int action_load_sbm1(ccsdsTelecommandPacket_t *TC);
68 //
75 int action_load_sbm2(ccsdsTelecommandPacket_t *TC);
76 // other functions
69 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
77 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
70 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
78 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
71 void close_action(ccsdsTelecommandPacket_t *TC, int result);
79 void close_action(ccsdsTelecommandPacket_t *TC, int result);
80 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
81 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC);
82 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC);
72
83
73 #endif // TC_HANDLER_H_INCLUDED
84 #endif // TC_HANDLER_H_INCLUDED
74
85
75
86
76
87
@@ -1,40 +1,55
1 #ifndef WF_HANDLER_H_INCLUDED
1 #ifndef WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <fsw_params.h>
5 #include <fsw_params.h>
6 #include <grspw.h>
6 #include <grspw.h>
7 #include <grlib_regs.h>
7 #include <grlib_regs.h>
8 #include <ccsds_types.h>
8 #include <ccsds_types.h>
9 #include <stdio.h>
9 #include <stdio.h>
10 #include <fsw_init.h>
10 #include <fsw_init.h>
11 #include <math.h>
11 #include <math.h>
12
12
13 #define pi 3.1415
13 #define pi 3.1415
14
14
15 //#include <sys/ioctl.h>
15 //#include <sys/ioctl.h>
16
16
17 extern rtems_id Task_id[]; /* array of task ids */
17 extern rtems_id Task_id[]; /* array of task ids */
18 extern int fdSPW;
18 extern int fdSPW;
19 extern volatile int wf_snap_f0[ ];
19 extern volatile int wf_snap_f0[ ];
20 extern volatile int wf_snap_f1[ ];
20 extern volatile int wf_snap_f1[ ];
21 extern volatile int wf_snap_f1_bis[ ];
21 extern volatile int wf_snap_f1_bis[ ];
22 extern volatile int wf_snap_f2[ ];
22 extern volatile int wf_snap_f2[ ];
23 extern volatile int wf_snap_f2_bis[ ];
23 extern volatile int wf_snap_f2_bis[ ];
24 extern volatile int wf_cont_f3[ ];
24 extern volatile int wf_cont_f3[ ];
25 extern waveform_picker_regs_t *waveform_picker_regs;
25 extern waveform_picker_regs_t *waveform_picker_regs;
26
26
27 rtems_isr waveforms_isr( rtems_vector_number vector );
27 rtems_isr waveforms_isr( rtems_vector_number vector );
28 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
28 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
29 rtems_task wfrm_task(rtems_task_argument argument);
29 rtems_task wfrm_task(rtems_task_argument argument);
30
30
31 //******************
31 //******************
32 // general functions
32 // general functions
33 void init_waveforms( void );
33 void init_waveforms( void );
34 void init_header_snapshot_wf( Header_TM_LFR_SCIENCE_SWF_t *header );
35 void init_header_continuous_wf( Header_TM_LFR_SCIENCE_CWF_t *header );
34 void reset_waveforms( void );
36 void reset_waveforms( void );
35 void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform, unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
37 void send_waveform_norm(Header_TM_LFR_SCIENCE_SWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
36 void init_waveform_picker_regs();
38 void send_waveform_burst(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
37 void set_data_shaping_parameters(unsigned char parameters);
39 void send_waveform_sbm1(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
40 void send_waveform_sbm2(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
41 void send_waveform_SWF( Header_TM_LFR_SCIENCE_SWF_t *header, volatile int *waveform,
42 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
43 void send_waveform_CWF( Header_TM_LFR_SCIENCE_CWF_t *header, volatile int *waveform,
44 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
45
46 //**************
47 // wfp registers
48 void set_wfp_data_shaping(unsigned char data_shaping);
49 void set_wfp_delta_snapshot(unsigned int delta_snapshot);
50 void reset_wfp_burst_enable();
51 void reset_wfp_regs();
52 //
38 int build_value(int value1, int value0);
53 int build_value(int value1, int value0);
39
54
40 #endif // WF_HANDLER_H_INCLUDED
55 #endif // WF_HANDLER_H_INCLUDED
@@ -1,55 +1,55
1 #include <drvmgr/ambapp_bus.h>
1 #include <drvmgr/ambapp_bus.h>
2
2
3 // GRSPW0 resources
3 // GRSPW0 resources
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+6}}, // 6 is for the auxiliary header, when needed
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+12}}, // 12 is for the auxiliary header, when needed
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
10 KEY_EMPTY
10 KEY_EMPTY
11 };
11 };
12
12
13 #if 0
13 #if 0
14 /* APBUART0 */
14 /* APBUART0 */
15 struct drvmgr_key grlib_drv_res_apbuart0[] =
15 struct drvmgr_key grlib_drv_res_apbuart0[] =
16 {
16 {
17 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
17 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
18 {"syscon", KEY_TYPE_INT, {(unsigned int)1}},
18 {"syscon", KEY_TYPE_INT, {(unsigned int)1}},
19 KEY_EMPTY
19 KEY_EMPTY
20 };
20 };
21 /* APBUART1 */
21 /* APBUART1 */
22 struct drvmgr_key grlib_drv_res_apbuart1[] =
22 struct drvmgr_key grlib_drv_res_apbuart1[] =
23 {
23 {
24 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
24 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
25 {"syscon", KEY_TYPE_INT, {(unsigned int)0}},
25 {"syscon", KEY_TYPE_INT, {(unsigned int)0}},
26 KEY_EMPTY
26 KEY_EMPTY
27 };
27 };
28 /* LEON3 System with driver configuration for 2 APBUARTs, the
28 /* LEON3 System with driver configuration for 2 APBUARTs, the
29 * the rest of the AMBA device drivers use their defaults.
29 * the rest of the AMBA device drivers use their defaults.
30 */
30 */
31
31
32 /* Override default debug UART assignment.
32 /* Override default debug UART assignment.
33 * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0,
33 * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0,
34 * CPU1=APBUART1...
34 * CPU1=APBUART1...
35 * 1 = APBUART[0]
35 * 1 = APBUART[0]
36 * 2 = APBUART[1]
36 * 2 = APBUART[1]
37 * 3 = APBUART[2]
37 * 3 = APBUART[2]
38 * ...
38 * ...
39 */
39 */
40 //int debug_uart_index = 2; /* second UART -- APBUART[1] */
40 //int debug_uart_index = 2; /* second UART -- APBUART[1] */
41 #endif
41 #endif
42
42
43 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
43 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
44
44
45 struct drvmgr_bus_res grlib_drv_resources = {
45 struct drvmgr_bus_res grlib_drv_resources = {
46 .next = NULL,
46 .next = NULL,
47 .resource = {
47 .resource = {
48 {DRIVER_AMBAPP_GAISLER_GRSPW_ID, 0, &grlib_grspw_0n1_res[0]},
48 {DRIVER_AMBAPP_GAISLER_GRSPW_ID, 0, &grlib_grspw_0n1_res[0]},
49 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 0, &grlib_drv_res_apbuart0[0]},
49 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 0, &grlib_drv_res_apbuart0[0]},
50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
51 RES_EMPTY /* Mark end of device resource array */
51 RES_EMPTY /* Mark end of device resource array */
52 }
52 }
53 };
53 };
54
55
54
55
@@ -1,55 +1,60
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <rtems.h>
2 #include <rtems.h>
3 #include <grspw.h>
3 #include <ccsds_types.h>
4 #include <ccsds_types.h>
4
5
5 // RTEMS GLOBAL VARIABLES
6 // RTEMS GLOBAL VARIABLES
6 rtems_name misc_name[5];
7 rtems_name misc_name[5];
7 rtems_name misc_id[5];
8 rtems_name misc_id[5];
8 rtems_id Task_id[15]; /* array of task ids */
9 rtems_id Task_id[15]; /* array of task ids */
9 rtems_name Task_name[15]; /* array of task names */
10 rtems_name Task_name[15]; /* array of task names */
10 int fdSPW = 0;
11 int fdSPW = 0;
11 int fdUART = 0;
12 int fdUART = 0;
12
13
13 spectral_matrices_regs_t *spectral_matrices_regs = NULL;
14 spectral_matrices_regs_t *spectral_matrices_regs = NULL;
14
15
15 // APB CONFIGURATION REGISTERS
16 // APB CONFIGURATION REGISTERS
16 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
17 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
17 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
18 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
18 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
19 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
19
20
20 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
21 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
21 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
22 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
22 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
23 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
23 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
24 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
24 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
25 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];
26 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
26 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
27 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
27
28
28 // SPECTRAL MATRICES GLOBAL VARIABLES
29 // SPECTRAL MATRICES GLOBAL VARIABLES
29 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
30 volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ];
30 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
31 volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ];
31 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
32 volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ];
32 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
33 volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ];
33 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
34 volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ];
34 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
35 volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ];
35 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
36 volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ];
36 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
37 volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ];
37 //
38 //
38 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
39 float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ];
39 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
40 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
40
41
41 // MODE PARAMETERS
42 // MODE PARAMETERS
43 struct param_local_str param_local;
42 struct param_common_str param_common;
44 struct param_common_str param_common;
43 struct param_norm_str param_norm;
45 struct param_norm_str param_norm;
44 struct param_burst_str param_burst;
46 struct param_burst_str param_burst;
45 struct param_sbm1_str param_sbm1;
47 struct param_sbm1_str param_sbm1;
46 struct param_sbm2_str param_sbm2;
48 struct param_sbm2_str param_sbm2;
47
49
48 // HK PACKETS
50 // HK PACKETS
49 Packet_TM_LFR_HK_t housekeeping_packet;
51 Packet_TM_LFR_HK_t housekeeping_packet;
52 // sequence counters are incremented by APID (PID + CAT) and destination ID
50 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
53 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
54 spw_stats spacewire_stats;
55 spw_stats spacewire_stats_backup;
51
56
52 // BASIC PARAMETERS GLOBAL VARIABLES
57 // BASIC PARAMETERS GLOBAL VARIABLES
53 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
58 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
54 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
59 BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ];
55
60
@@ -1,449 +1,547
1 //*************************
1 //*************************
2 // GPL reminder to be added
2 // GPL reminder to be added
3 //*************************
3 //*************************
4
4
5 #include <rtems.h>
5 #include <rtems.h>
6
6
7 /* configuration information */
7 /* configuration information */
8
8
9 #define CONFIGURE_INIT
9 #define CONFIGURE_INIT
10
10
11 #include <bsp.h> /* for device driver prototypes */
11 #include <bsp.h> /* for device driver prototypes */
12
12
13 /* configuration information */
13 /* configuration information */
14
14
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17
17
18 #define CONFIGURE_MAXIMUM_TASKS 15
18 #define CONFIGURE_MAXIMUM_TASKS 15
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_PERIODS 5
24 #define CONFIGURE_MAXIMUM_PERIODS 5
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
26
26
27 #include <rtems/confdefs.h>
27 #include <rtems/confdefs.h>
28
28
29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
30 #ifdef RTEMS_DRVMGR_STARTUP
30 #ifdef RTEMS_DRVMGR_STARTUP
31 #ifdef LEON3
31 #ifdef LEON3
32 /* Add Timer and UART Driver */
32 /* Add Timer and UART Driver */
33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
35 #endif
35 #endif
36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
38 #endif
38 #endif
39 #endif
39 #endif
40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
41 #include <drvmgr/drvmgr_confdefs.h>
41 #include <drvmgr/drvmgr_confdefs.h>
42 #endif
42 #endif
43
43
44 #include <fsw_init.h>
44 #include <fsw_init.h>
45 #include <fsw_config.c>
45 #include <fsw_config.c>
46
46
47 char *lstates[6] = {"Error-reset",
47 char *lstates[6] = {"Error-reset",
48 "Error-wait",
48 "Error-wait",
49 "Ready",
49 "Ready",
50 "Started",
50 "Started",
51 "Connecting",
51 "Connecting",
52 "Run"
52 "Run"
53 };
53 };
54
54
55 rtems_task Init( rtems_task_argument ignored )
55 rtems_task Init( rtems_task_argument ignored )
56 {
56 {
57 rtems_status_code status;
57 rtems_status_code status;
58 rtems_isr_entry old_isr_handler;
58 rtems_isr_entry old_isr_handler;
59
59
60 PRINTF("\n\n\n\n\n")
60 PRINTF("\n\n\n\n\n")
61 PRINTF("***************************\n")
61 PRINTF("***************************\n")
62 PRINTF("** START Flight Software **\n")
62 PRINTF("** START Flight Software **\n")
63 PRINTF("***************************\n")
63 PRINTF("***************************\n")
64 PRINTF("\n\n")
64 PRINTF("\n\n")
65
65
66 //send_console_outputs_on_serial_port();
66 //send_console_outputs_on_serial_port();
67 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
67 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
68
68
69 initLookUpTableForCRC(); // in tc_handler.h
69 initLookUpTableForCRC(); // in tc_handler.h
70 init_default_mode_parameters();
70 init_default_mode_parameters();
71 init_housekeeping_parameters();
71 init_housekeeping_parameters();
72 create_message_queue();
72 create_message_queue();
73
73
74 create_names(); // create all names
74 create_names(); // create all names
75 create_all_tasks(); // create all tasks
75 create_all_tasks(); // create all tasks
76 start_all_tasks(); // start all tasks
76 start_all_tasks(); // start all tasks
77 stop_current_mode(); // go in STANDBY mode
77 stop_current_mode(); // go in STANDBY mode
78
78
79 grspw_timecode_callback = &timecode_irq_handler;
79 grspw_timecode_callback = &timecode_irq_handler;
80
80
81 configure_spw_link();
81 spacewire_configure_link();
82
82
83 //****************************
83 //****************************
84 // Spectral Matrices simulator
84 // Spectral Matrices simulator
85 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
85 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
86 IRQ_SPARC_SM, spectral_matrices_isr );
86 IRQ_SPARC_SM, spectral_matrices_isr );
87
87
88 //**********
88 //**********
89 // WAVEFORMS
89 // WAVEFORMS
90 // simulator
90 // simulator
91
91
92 #ifdef GSA
92 #ifdef GSA
93 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
93 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
94 IRQ_SPARC_WF, waveforms_simulator_isr );
94 IRQ_SPARC_WF, waveforms_simulator_isr );
95 #else
95 #else
96 // configure the registers of the waveform picker
96 // configure the registers of the waveform picker
97 init_waveform_picker_regs();
97 reset_wfp_regs();
98 // configure the waveform picker interrupt service routine
98 // configure the waveform picker interrupt service routine
99 status = rtems_interrupt_catch( waveforms_isr,
99 status = rtems_interrupt_catch( waveforms_isr,
100 IRQ_SPARC_WAVEFORM_PICKER,
100 IRQ_SPARC_WAVEFORM_PICKER,
101 &old_isr_handler) ;
101 &old_isr_handler) ;
102 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
102 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
103 #endif
103 #endif
104
104
105 //**********
105 //**********
106
106
107 //*****************************************
107 //*****************************************
108 // irq handling of the time management unit
108 // irq handling of the time management unit
109 status = rtems_interrupt_catch( commutation_isr1,
109 status = rtems_interrupt_catch( commutation_isr1,
110 IRQ_SPARC_TIME1,
110 IRQ_SPARC_TIME1,
111 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
111 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
112 if (status==RTEMS_SUCCESSFUL) {
112 if (status==RTEMS_SUCCESSFUL) {
113 PRINTF("OK *** commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
113 PRINTF("OK *** commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
114 }
114 }
115
115
116 status = rtems_interrupt_catch( commutation_isr2,
116 status = rtems_interrupt_catch( commutation_isr2,
117 IRQ_SPARC_TIME2,
117 IRQ_SPARC_TIME2,
118 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
118 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
119 if (status==RTEMS_SUCCESSFUL) {
119 if (status==RTEMS_SUCCESSFUL) {
120 PRINTF("OK *** commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
120 PRINTF("OK *** commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
121 }
121 }
122
122
123 LEON_Unmask_interrupt( IRQ_TIME1 );
123 LEON_Unmask_interrupt( IRQ_TIME1 );
124 LEON_Unmask_interrupt( IRQ_TIME2 );
124 LEON_Unmask_interrupt( IRQ_TIME2 );
125
125
126 #ifdef GSA
126 #ifdef GSA
127 //if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
127 //if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
128 // printf("in INIT *** Error sending event to WFRM\n");
128 // printf("in INIT *** Error sending event to WFRM\n");
129 //}
129 //}
130 #endif
130 #endif
131
131
132 status = rtems_task_delete(RTEMS_SELF);
132 status = rtems_task_delete(RTEMS_SELF);
133
133
134 }
134 }
135
135
136 rtems_task spiq_task(rtems_task_argument unused)
136 rtems_task spiq_task(rtems_task_argument unused)
137 {
137 {
138 rtems_event_set event_out;
138 rtems_event_set event_out;
139 rtems_status_code status;
139 rtems_status_code status;
140 unsigned char lfrMode;
140
141
141 while(true){
142 while(true){
142 PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
143 PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
143 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
144 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
144
145
146 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
147
148 //****************
149 // STOP THE SYSTEM
150 spacewire_compute_stats_offsets();
151 stop_current_mode();
145 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
152 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
146 PRINTF("in SPIQ *** Error suspending RECV Task\n")
153 PRINTF("in SPIQ *** Error suspending RECV Task\n")
147 }
154 }
148 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task
155 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task
149 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
156 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
150 }
157 }
151
158
152 configure_spw_link();
159 //***************************
160 // RESTART THE SPACEWIRE LINK
161 status = spacewire_try_to_start();
162 if (status != RTEMS_SUCCESSFUL) {
163 spacewire_configure_link();
164 }
153
165
166 //*******************
167 // RESTART THE SYSTEM
168 //ioctl(fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS); // clear statistics
154 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
169 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
155 if (status!=RTEMS_SUCCESSFUL) {
170 if (status != RTEMS_SUCCESSFUL) {
156 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
171 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
157 }
172 }
158
173 if (rtems_task_restart(Task_id[TASKID_RECV], 1) != RTEMS_SUCCESSFUL) { // restart RECV task
159 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) { // restart RECV task
160 PRINTF("in SPIQ *** Error restarting RECV Task\n")
174 PRINTF("in SPIQ *** Error restarting RECV Task\n")
161 }
175 }
176 //enter_mode(lfrMode, NULL); // enter the mode that was running before the SpaceWire interruption
162 }
177 }
163 }
178 }
164
179
165 void init_default_mode_parameters(void)
180 void init_default_mode_parameters(void)
166 {
181 {
167 // COMMON PARAMETERS
182 // COMMON PARAMETERS
168 param_common.sy_lfr_common0 = 0x00;
183 param_common.sy_lfr_common0 = 0x00;
169 param_common.sy_lfr_common1 = 0x10; // default value 0 0 0 1 0 0 0 0
184 param_common.sy_lfr_common1 = 0x10; // default value 0 0 0 1 0 0 0 0
185
170 // NORMAL MODE
186 // NORMAL MODE
171 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
187 param_norm.sy_lfr_n_swf_l = DEFAULT_SY_LFR_N_SWF_L; // nb sample
172 param_norm.sy_lfr_n_swf_p = 300; // sec
188 param_norm.sy_lfr_n_swf_p = DEFAULT_SY_LFR_N_SWF_P; // sec
173 param_norm.sy_lfr_n_asm_p = 3600; // sec
189 param_norm.sy_lfr_n_asm_p = DEFAULT_SY_LFR_N_ASM_P; // sec
174 param_norm.sy_lfr_n_bp_p0 = 4; // sec
190 param_norm.sy_lfr_n_bp_p0 = DEFAULT_SY_LFR_N_BP_P0; // sec
175 param_norm.sy_lfr_n_bp_p1 = 20; // sec
191 param_norm.sy_lfr_n_bp_p1 = DEFAULT_SY_LFR_N_BP_P1; // sec
192
176 // BURST MODE
193 // BURST MODE
177 param_burst.sy_lfr_b_bp_p0 = 1; // sec
194 param_burst.sy_lfr_b_bp_p0 = DEFAULT_SY_LFR_B_BP_P0; // sec
178 param_burst.sy_lfr_b_bp_p1 = 5; // sec
195 param_burst.sy_lfr_b_bp_p1 = DEFAULT_SY_LFR_B_BP_P1; // sec
196
179 // SBM1 MODE
197 // SBM1 MODE
180 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
198 param_sbm1.sy_lfr_s1_bp_p0 = DEFAULT_SY_LFR_S1_BP_P0; // sec
181 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
199 param_sbm1.sy_lfr_s1_bp_p1 = DEFAULT_SY_LFR_B_BP_P1; // sec
200
182 // SBM2 MODE
201 // SBM2 MODE
183 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
202 param_sbm2.sy_lfr_s2_bp_p0 = DEFAULT_SY_LFR_S2_BP_P0; // sec
184 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
203 param_sbm2.sy_lfr_s2_bp_p1 = DEFAULT_SY_LFR_S2_BP_P1; // sec
204
205 // LOCAL PARAMETERS
206 // (2 snapshots of 2048 points per seconds) * (period of the NORM snashots)
207 param_local.local_sbm1_nb_cwf_max = 2 * param_norm.sy_lfr_n_swf_p;
208 // (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
209 param_local.local_sbm2_nb_cwf_max = param_norm.sy_lfr_n_swf_p / 8;
210
211 PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
212 PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
213
214 param_local.local_sbm1_nb_cwf_sent = 0;
215 param_local.local_sbm2_nb_cwf_sent = 0;
185 }
216 }
186
217
187 void init_housekeeping_parameters(void)
218 void init_housekeeping_parameters(void)
188 {
219 {
189 unsigned int i = 0;
220 unsigned int i = 0;
190 unsigned int j = 0;
221 unsigned int j = 0;
191 unsigned int k = 0;
222 unsigned int k = 0;
192 char *parameters;
223 char *parameters;
193
224
194 parameters = (char*) &housekeeping_packet.lfr_status_word;
225 parameters = (char*) &housekeeping_packet.lfr_status_word;
195 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
226 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
196 {
227 {
197 parameters[i] = 0x00;
228 parameters[i] = 0x00;
198 }
229 }
199 // init status word
230 // init status word
200 housekeeping_packet.lfr_status_word[0] = 0x00;
231 housekeeping_packet.lfr_status_word[0] = 0x00;
201 housekeeping_packet.lfr_status_word[1] = 0x00;
232 housekeeping_packet.lfr_status_word[1] = 0x00;
202 // init software version
233 // init software version
203 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
234 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
204 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
235 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
205 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
236 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
206 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
237 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
207 // init sequence counters
238 // init sequence counters
208 for (i = 0; i<SEQ_CNT_NB_PID; i++)
239 for (i = 0; i<SEQ_CNT_NB_PID; i++)
209 {
240 {
210 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
241 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
211 {
242 {
212 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
243 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
213 {
244 {
214 sequenceCounters[i][j][k] = 0x00;
245 sequenceCounters[i][j][k] = 0x00;
215 }
246 }
216 }
247 }
217 }
248 }
218 }
249 }
219
250
220 int create_names( void )
251 int create_names( void )
221 {
252 {
222 // task names
253 // task names
223 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
254 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
224 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
255 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
225 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
256 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
226 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
257 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
227 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
258 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
228 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
259 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
229 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
260 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
230 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
261 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
231 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
262 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
232 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
263 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
233
264
234 // rate monotonic period name
265 // rate monotonic period name
235 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
266 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
236
267
237 return 0;
268 return 0;
238 }
269 }
239
270
240 int create_all_tasks( void )
271 int create_all_tasks( void )
241 {
272 {
242 rtems_status_code status;
273 rtems_status_code status;
243
274
244 // RECV
275 // RECV
245 status = rtems_task_create(
276 status = rtems_task_create(
246 Task_name[TASKID_RECV], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
277 Task_name[TASKID_RECV], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
247 RTEMS_DEFAULT_MODES,
278 RTEMS_DEFAULT_MODES,
248 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
279 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
249 );
280 );
250 // ACTN
281 // ACTN
251 status = rtems_task_create(
282 status = rtems_task_create(
252 Task_name[TASKID_ACTN], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
283 Task_name[TASKID_ACTN], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
253 RTEMS_DEFAULT_MODES,
284 RTEMS_DEFAULT_MODES,
254 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
285 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
255 );
286 );
256 // SPIQ
287 // SPIQ
257 status = rtems_task_create(
288 status = rtems_task_create(
258 Task_name[TASKID_SPIQ], 5, RTEMS_MINIMUM_STACK_SIZE * 2,
289 Task_name[TASKID_SPIQ], 5, RTEMS_MINIMUM_STACK_SIZE * 2,
259 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
290 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
260 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
291 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
261 );
292 );
262 // SMIQ
293 // SMIQ
263 status = rtems_task_create(
294 status = rtems_task_create(
264 Task_name[TASKID_SMIQ], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
295 Task_name[TASKID_SMIQ], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
265 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
296 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
266 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
297 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
267 );
298 );
268 // STAT
299 // STAT
269 status = rtems_task_create(
300 status = rtems_task_create(
270 Task_name[TASKID_STAT], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
301 Task_name[TASKID_STAT], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
271 RTEMS_DEFAULT_MODES,
302 RTEMS_DEFAULT_MODES,
272 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
303 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
273 );
304 );
274 // AVF0
305 // AVF0
275 status = rtems_task_create(
306 status = rtems_task_create(
276 Task_name[TASKID_AVF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
307 Task_name[TASKID_AVF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
277 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
308 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
278 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
309 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
279 );
310 );
280 // BPF0
311 // BPF0
281 status = rtems_task_create(
312 status = rtems_task_create(
282 Task_name[TASKID_BPF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
313 Task_name[TASKID_BPF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
283 RTEMS_DEFAULT_MODES,
314 RTEMS_DEFAULT_MODES,
284 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
315 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
285 );
316 );
286 // WFRM
317 // WFRM
287 status = rtems_task_create(
318 status = rtems_task_create(
288 Task_name[TASKID_WFRM], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
319 Task_name[TASKID_WFRM], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
289 RTEMS_DEFAULT_MODES,
320 RTEMS_DEFAULT_MODES,
290 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
321 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
291 );
322 );
292 // DUMB
323 // DUMB
293 status = rtems_task_create(
324 status = rtems_task_create(
294 Task_name[TASKID_DUMB], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
325 Task_name[TASKID_DUMB], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
295 RTEMS_DEFAULT_MODES,
326 RTEMS_DEFAULT_MODES,
296 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
327 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
297 );
328 );
298 // HOUS
329 // HOUS
299 status = rtems_task_create(
330 status = rtems_task_create(
300 Task_name[TASKID_HOUS], 199, RTEMS_MINIMUM_STACK_SIZE * 2,
331 Task_name[TASKID_HOUS], 199, RTEMS_MINIMUM_STACK_SIZE * 2,
301 RTEMS_DEFAULT_MODES,
332 RTEMS_DEFAULT_MODES,
302 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
333 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
303 );
334 );
304
335
305 return 0;
336 return 0;
306 }
337 }
307
338
308 int start_all_tasks( void )
339 int start_all_tasks( void )
309 {
340 {
310 rtems_status_code status;
341 rtems_status_code status;
311
342
312 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
343 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
313 if (status!=RTEMS_SUCCESSFUL) {
344 if (status!=RTEMS_SUCCESSFUL) {
314 PRINTF("In INIT *** Error starting TASK_SPIQ\n")
345 PRINTF("In INIT *** Error starting TASK_SPIQ\n")
315 }
346 }
316
347
317 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
348 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
318 if (status!=RTEMS_SUCCESSFUL) {
349 if (status!=RTEMS_SUCCESSFUL) {
319 PRINTF("In INIT *** Error starting TASK_RECV\n")
350 PRINTF("In INIT *** Error starting TASK_RECV\n")
320 }
351 }
321
352
322 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
353 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
323 if (status!=RTEMS_SUCCESSFUL) {
354 if (status!=RTEMS_SUCCESSFUL) {
324 PRINTF("In INIT *** Error starting TASK_ACTN\n")
355 PRINTF("In INIT *** Error starting TASK_ACTN\n")
325 }
356 }
326
357
327 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
358 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
328 if (status!=RTEMS_SUCCESSFUL) {
359 if (status!=RTEMS_SUCCESSFUL) {
329 PRINTF("In INIT *** Error starting TASK_BPPR\n")
360 PRINTF("In INIT *** Error starting TASK_BPPR\n")
330 }
361 }
331
362
332 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
363 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
333 if (status!=RTEMS_SUCCESSFUL) {
364 if (status!=RTEMS_SUCCESSFUL) {
334 PRINTF("In INIT *** Error starting TASK_STAT\n")
365 PRINTF("In INIT *** Error starting TASK_STAT\n")
335 }
366 }
336
367
337 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
368 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
338 if (status!=RTEMS_SUCCESSFUL) {
369 if (status!=RTEMS_SUCCESSFUL) {
339 PRINTF("In INIT *** Error starting TASK_AVF0\n")
370 PRINTF("In INIT *** Error starting TASK_AVF0\n")
340 }
371 }
341
372
342 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
373 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
343 if (status!=RTEMS_SUCCESSFUL) {
374 if (status!=RTEMS_SUCCESSFUL) {
344 PRINTF("In INIT *** Error starting TASK_BPF0\n")
375 PRINTF("In INIT *** Error starting TASK_BPF0\n")
345 }
376 }
346
377
347 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
378 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
348 if (status!=RTEMS_SUCCESSFUL) {
379 if (status!=RTEMS_SUCCESSFUL) {
349 PRINTF("In INIT *** Error starting TASK_WFRM\n")
380 PRINTF("In INIT *** Error starting TASK_WFRM\n")
350 }
381 }
351
382
352 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
383 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
353 if (status!=RTEMS_SUCCESSFUL) {
384 if (status!=RTEMS_SUCCESSFUL) {
354 PRINTF("In INIT *** Error starting TASK_DUMB\n")
385 PRINTF("In INIT *** Error starting TASK_DUMB\n")
355 }
386 }
356
387
357 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
388 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
358 if (status!=RTEMS_SUCCESSFUL) {
389 if (status!=RTEMS_SUCCESSFUL) {
359 PRINTF("In INIT *** Error starting TASK_HOUS\n")
390 PRINTF("In INIT *** Error starting TASK_HOUS\n")
360 }
391 }
361
392
362 return 0;
393 return 0;
363 }
394 }
364
395
365 int configure_spw_link( void )
396 int spacewire_configure_link( void )
366 {
397 {
367 rtems_status_code status;
398 rtems_status_code status;
368
399
369 close(fdSPW); // close the device if it is already open
400 close(fdSPW); // close the device if it is already open
370 PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
401 PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
371 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
402 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
372 if (fdSPW<0) PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
403 if ( fdSPW<0 ) {
373 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
404 PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
405 }
406
407 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, -1) != RTEMS_SUCCESSFUL){
374 PRINTF(".")
408 PRINTF(".")
375 fflush(stdout);
409 fflush( stdout );
376 close(fdSPW); // close the device
410 close( fdSPW ); // close the device
377 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
411 fdSPW = open( GRSPW_DEVICE_NAME, O_RDWR ); // open the device. the open call reset the hardware
378 if (fdSPW<0) PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
412 if (fdSPW<0) {
413 PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
414 }
379 rtems_task_wake_after(100);
415 rtems_task_wake_after(100);
380 }
416 }
381
417
382 PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
418 PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
383
419
384 configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
420 spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
385 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
421 spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
386
422
387 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
423 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
388 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
424 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
389 //
425 //
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
426 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
391 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
427 //if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
392 //
428 //
393 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
429 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
394 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
430 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
395 //
431 //
396 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
432 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
397 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
433 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
398 //
434 //
435 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
436 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
437 //
399 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
438 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
400 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
439 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
401 //
440 //
402 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909);
441 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909);
403 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
442 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
404
443
405 PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
444 PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
406
445
407 return RTEMS_SUCCESSFUL;
446 return RTEMS_SUCCESSFUL;
408 }
447 }
409
448
410 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force
449 int spacewire_try_to_start(void)
450 {
451 unsigned int i;
452 int linkStatus;
453 rtems_status_code status = RTEMS_UNSATISFIED;
454
455 for(i = 0; i< 10; i++){
456 PRINTF(".")
457 fflush( stdout );
458 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
459 PRINTF1("in spacewire_try_to_start *** link status is: %s\n", lstates[linkStatus])
460 if ( linkStatus == 5) {
461 PRINTF("in spacewire_try_to_start *** link is running\n")
462 status = RTEMS_SUCCESSFUL;
463 break;
464 }
465 rtems_task_wake_after(100);
466 }
467
468 return status;
469 }
470
471 void spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force
411 {
472 {
412 unsigned int *spwptr = (unsigned int*) regAddr;
473 unsigned int *spwptr = (unsigned int*) regAddr;
413
474
414 if (val == 1) {
475 if (val == 1) {
415 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
476 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
416 }
477 }
417 if (val== 0) {
478 if (val== 0) {
418 *spwptr = *spwptr & 0xffdfffff;
479 *spwptr = *spwptr & 0xffdfffff;
419 }
480 }
420 }
481 }
421
482
422 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable
483 void spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable
423 {
484 {
424 unsigned int *spwptr = (unsigned int*) regAddr;
485 unsigned int *spwptr = (unsigned int*) regAddr;
425
486
426 if (val == 1)
487 if (val == 1)
427 {
488 {
428 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
489 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
429 }
490 }
430 if (val== 0)
491 if (val== 0)
431 {
492 {
432 *spwptr = *spwptr & 0xfffdffff;
493 *spwptr = *spwptr & 0xfffdffff;
433 }
494 }
434 }
495 }
435
496
497 void spacewire_compute_stats_offsets()
498 {
499 spw_stats spacewire_stats_grspw;
500 rtems_status_code status;
501
502 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
503
504 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
505 + spacewire_stats.packets_received;
506 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
507 + spacewire_stats.packets_sent;
508 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
509 + spacewire_stats.parity_err;
510 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
511 + spacewire_stats.disconnect_err;
512 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
513 + spacewire_stats.escape_err;
514 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
515 + spacewire_stats.credit_err;
516 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
517 + spacewire_stats.write_sync_err;
518 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
519 + spacewire_stats.rx_rmap_header_crc_err;
520 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
521 + spacewire_stats.rx_rmap_data_crc_err;
522 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
523 + spacewire_stats.early_ep;
524 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
525 + spacewire_stats.invalid_address;
526 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
527 + spacewire_stats.rx_eep_err;
528 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
529 + spacewire_stats.rx_truncated;
530 }
531
436 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
532 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
437 {
533 {
438 rtems_status_code status;
534 rtems_status_code status;
439 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
535 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
536 if (status != RTEMS_SUCCESSFUL){
537 //PRINTF1("ERR *** in write_spw *** write operation failed with code: %d\n", status)
538 }
440 return status;
539 return status;
441 }
540 }
442
541
443 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc)
542 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc)
444 {
543 {
445 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
544 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
446 printf("In timecode_irq_handler *** Error sending event to DUMB\n");
545 printf("In timecode_irq_handler *** Error sending event to DUMB\n");
447 }
546 }
448 }
547 }
449
@@ -1,156 +1,205
1 #include <fsw_misc.h>
1 #include <fsw_misc.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 extern rtems_id Task_id[]; /* array of task ids */
4 extern rtems_id Task_id[]; /* array of task ids */
5 extern int fdSPW;
5 extern int fdSPW;
6 extern TMHeader_t housekeeping_header;
6 extern TMHeader_t housekeeping_header;
7 extern char housekeeping_data[];
7 extern char housekeeping_data[];
8 extern Packet_TM_LFR_HK_t housekeeping_packet;
8 extern Packet_TM_LFR_HK_t housekeeping_packet;
9
9
10 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
10 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 { // configure the timer for the waveforms simulation
12 { // configure the timer for the waveforms simulation
13 rtems_status_code status;
13 rtems_status_code status;
14 rtems_isr_entry old_isr_handler;
14 rtems_isr_entry old_isr_handler;
15
15
16 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
16 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
17 //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n")
17 //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n")
18
18
19 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
19 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
20 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
20 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
21 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
21 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
22 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
22 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
23 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
23 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
24 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
24 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
25
25
26 return 1;
26 return 1;
27 }
27 }
28
28
29 void print_statistics(spw_stats *stats)
29 void update_spacewire_statistics()
30 {
30 {
31 //printf(" ******** STATISTICS ******** \n");
31 rtems_status_code status;
32 printf("Transmit link errors: %i\n", stats->tx_link_err);
32 spw_stats spacewire_stats_grspw;
33 printf("Receiver RMAP header CRC errors: %i\n", stats->rx_rmap_header_crc_err);
33
34 printf("Receiver RMAP data CRC errors: %i\n", stats->rx_rmap_data_crc_err);
34 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
35 printf("Receiver EEP errors: %i\n", stats->rx_eep_err);
35
36 printf("Receiver truncation errors: %i\n", stats->rx_truncated);
36 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
37 printf("Parity errors: %i\n", stats->parity_err);
37 + spacewire_stats_grspw.packets_received;
38 printf("Escape errors: %i\n", stats->escape_err);
38 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
39 printf("Credit errors: %i\n", stats->credit_err);
39 + spacewire_stats_grspw.packets_sent;
40 printf("Disconnect errors: %i\n", stats->disconnect_err);
40 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
41 printf("Write synchronization errors: %i\n", stats->write_sync_err);
41 + spacewire_stats_grspw.parity_err;
42 printf("Early EOP/EEP: %i\n", stats->early_ep);
42 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
43 printf("Invalid Node Address: %i\n", stats->invalid_address);
43 + spacewire_stats_grspw.disconnect_err;
44 printf("Packets transmitted: %i\n", stats->packets_sent);
44 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
45 printf("Packets received: %i\n", stats->packets_received);
45 + spacewire_stats_grspw.escape_err;
46 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
47 + spacewire_stats_grspw.credit_err;
48 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
49 + spacewire_stats_grspw.write_sync_err;
50 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
51 + spacewire_stats_grspw.rx_rmap_header_crc_err;
52 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
53 + spacewire_stats_grspw.rx_rmap_data_crc_err;
54 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
55 + spacewire_stats_grspw.early_ep;
56 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
57 + spacewire_stats_grspw.invalid_address;
58 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
59 + spacewire_stats_grspw.rx_eep_err;
60 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
61 + spacewire_stats_grspw.rx_truncated;
62 //spacewire_stats.tx_link_err;
63
64 //****************************
65 // DPU_SPACEWIRE_IF_STATISTICS
66 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
67 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
68 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
69 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
70 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
71 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
72
73 //******************************************
74 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
75 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
76 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
77 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
78 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
79 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
80 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
81 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
82 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
83 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
84
85 //*********************************************
86 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
87 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
88 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
89 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
90 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
91
46 }
92 }
47
93
48 int send_console_outputs_on_serial_port( void ) // Send the console outputs on the serial port
94 int send_console_outputs_on_serial_port( void ) // Send the console outputs on the serial port
49 {
95 {
50 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
96 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
51
97
52 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
98 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
53 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
99 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
54
100
55 return 0;
101 return 0;
56 }
102 }
57
103
58 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
104 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
59 {
105 {
60 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
106 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
61
107
62 apbuart_regs->scaler = value;
108 apbuart_regs->scaler = value;
63 PRINTF1("OK *** COM port scaler reload register set to %x\n", value)
109 PRINTF1("OK *** COM port scaler reload register set to %x\n", value)
64
110
65 return 0;
111 return 0;
66 }
112 }
67
113
68 //************
114 //************
69 // RTEMS TASKS
115 // RTEMS TASKS
70
116
71 rtems_task stat_task(rtems_task_argument argument)
117 rtems_task stat_task(rtems_task_argument argument)
72 {
118 {
73 int i;
119 int i;
74 int j;
120 int j;
75 i = 0;
121 i = 0;
76 j = 0;
122 j = 0;
77 PRINTF("in STAT *** \n")
123 PRINTF("in STAT *** \n")
78 while(1){
124 while(1){
79 rtems_task_wake_after(1000);
125 rtems_task_wake_after(1000);
80 PRINTF1("%d\n", j)
126 PRINTF1("%d\n", j)
81 if (i == 2) {
127 if (i == 2) {
82 #ifdef PRINT_TASK_STATISTICS
128 #ifdef PRINT_TASK_STATISTICS
83 rtems_cpu_usage_report();
129 rtems_cpu_usage_report();
84 rtems_cpu_usage_reset();
130 rtems_cpu_usage_reset();
85 #endif
131 #endif
86 i = 0;
132 i = 0;
87 }
133 }
88 else i++;
134 else i++;
89 j++;
135 j++;
90 }
136 }
91 }
137 }
92
138
93 rtems_task hous_task(rtems_task_argument argument)
139 rtems_task hous_task(rtems_task_argument argument)
94 {
140 {
95 int result;
141 int result;
96 rtems_status_code status;
142 rtems_status_code status;
97
143
98 PRINTF("in HOUS ***\n")
144 PRINTF("in HOUS ***\n")
99
145
100 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
146 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
101 status = rtems_rate_monotonic_create( HK_name, &HK_id );
147 status = rtems_rate_monotonic_create( HK_name, &HK_id );
102 if( status != RTEMS_SUCCESSFUL ) {
148 if( status != RTEMS_SUCCESSFUL ) {
103 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
149 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
104 }
150 }
105 }
151 }
106
152
107 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
153 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
108 housekeeping_packet.protocolIdentifier = 0x02;
154 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
109 housekeeping_packet.reserved = 0x00;
155 housekeeping_packet.reserved = 0x00;
110 housekeeping_packet.userApplication = 0x00;
156 housekeeping_packet.userApplication = 0x00;
111 housekeeping_packet.packetID[0] = 0x0c;
157 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
112 housekeeping_packet.packetID[1] = 0xc4;
158 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
113 housekeeping_packet.packetSequenceControl[0] = 0xc0;
159 housekeeping_packet.packetSequenceControl[0] = 0xc0;
114 housekeeping_packet.packetSequenceControl[1] = 0x00;
160 housekeeping_packet.packetSequenceControl[1] = 0x00;
115 housekeeping_packet.packetLength[0] = 0x00;
161 housekeeping_packet.packetLength[0] = 0x00;
116 housekeeping_packet.packetLength[1] = 0x77;
162 housekeeping_packet.packetLength[1] = 0x77;
117 housekeeping_packet.dataFieldHeader[0] = 0x10;
163 housekeeping_packet.dataFieldHeader[0] = 0x10;
118 housekeeping_packet.dataFieldHeader[1] = TM_TYPE_HK;
164 housekeeping_packet.dataFieldHeader[1] = TM_TYPE_HK;
119 housekeeping_packet.dataFieldHeader[2] = TM_SUBTYPE_HK;
165 housekeeping_packet.dataFieldHeader[2] = TM_SUBTYPE_HK;
120 housekeeping_packet.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
166 housekeeping_packet.dataFieldHeader[3] = TM_DESTINATION_ID_GROUND;
121
167
122 status = rtems_rate_monotonic_cancel(HK_id);
168 status = rtems_rate_monotonic_cancel(HK_id);
123 if( status != RTEMS_SUCCESSFUL )
169 if( status != RTEMS_SUCCESSFUL ) {
124 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
170 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
125 else
171 }
126 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
172 else {
173 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
174 }
127
175
128 while(1){ // launch the rate monotonic task
176 while(1){ // launch the rate monotonic task
129 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
177 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
130 if ( status != RTEMS_SUCCESSFUL ){
178 if ( status != RTEMS_SUCCESSFUL ) {
131 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
179 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
132 }
180 }
133 else
181 else {
134 {
135 housekeeping_packet.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
182 housekeeping_packet.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
136 housekeeping_packet.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
183 housekeeping_packet.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
137 housekeeping_packet.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
184 housekeeping_packet.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
138 housekeeping_packet.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
185 housekeeping_packet.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
139 housekeeping_packet.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
186 housekeeping_packet.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
140 housekeeping_packet.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
187 housekeeping_packet.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
141 housekeeping_packet.sid = CCSDS_DESTINATION_ID_DPU;
188 housekeeping_packet.sid = SID_HK;
189
190 update_spacewire_statistics();
191
142 result = write ( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
192 result = write ( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
143 if (result==-1)
193 if (result==-1) {
144 {
145 PRINTF("ERR *** in HOUS *** HK send\n");
194 PRINTF("ERR *** in HOUS *** HK send\n");
146 }
195 }
147 }
196 }
148 }
197 }
149
198
150 PRINTF("in HOUS *** deleting task\n")
199 PRINTF("in HOUS *** deleting task\n")
151
200
152 status = rtems_task_delete( RTEMS_SELF ); // should not return
201 status = rtems_task_delete( RTEMS_SELF ); // should not return
153 printf( "rtems_task_delete returned with status of %d.\n", status );
202 printf( "rtems_task_delete returned with status of %d.\n", status );
154 exit( 1 );
203 exit( 1 );
155 }
204 }
156
205
This diff has been collapsed as it changes many lines, (606 lines changed) Show them Hide them
@@ -1,361 +1,363
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <math.h>
2 #include <math.h>
3
3
4 #include <fsw_processing_globals.c>
4 #include <fsw_processing_globals.c>
5
5
6 //***********************************************************
6 //***********************************************************
7 // Interrupt Service Routine for spectral matrices processing
7 // Interrupt Service Routine for spectral matrices processing
8 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
8 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
9 {
9 {
10 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
10 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
11 printf("in spectral_matrices_isr *** Error sending event to AVF0\n");
11 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
12 }
12 }
13 }
13 }
14
14
15 //************
15 //************
16 // RTEMS TASKS
16 // RTEMS TASKS
17 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
17 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
18 {
18 {
19 rtems_event_set event_out;
19 rtems_event_set event_out;
20 unsigned char nb_interrupt_f0 = 0;
20 unsigned char nb_interrupt_f0 = 0;
21
21
22 PRINTF("in SMIQ *** \n")
22 PRINTF("in SMIQ *** \n")
23
23
24 while(1){
24 while(1){
25 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
25 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
26 nb_interrupt_f0 = nb_interrupt_f0 + 1;
26 nb_interrupt_f0 = nb_interrupt_f0 + 1;
27 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
27 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
28 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
28 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
29 printf("in SMIQ *** Error sending event to AVF0\n");
29 {
30 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
31 }
30 nb_interrupt_f0 = 0;
32 nb_interrupt_f0 = 0;
31 }
33 }
32 }
34 }
33 }
35 }
34
36
35 rtems_task spw_bppr_task(rtems_task_argument argument)
37 rtems_task spw_bppr_task(rtems_task_argument argument)
36 {
38 {
37 rtems_status_code status;
39 rtems_status_code status;
38 rtems_event_set event_out;
40 rtems_event_set event_out;
39 static int Nb_average_f0 = 0;
41 static int Nb_average_f0 = 0;
40 //static int nb_average_f1 = 0;
42 //static int nb_average_f1 = 0;
41 //static int nb_average_f2 = 0;
43 //static int nb_average_f2 = 0;
42
44
43 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
45 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
44 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
46 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
45 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
47 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
46
48
47 printf("in BPPR ***\n");
49 printf("in BPPR ***\n");
48
50
49 while(true){ // wait for an event to begin with the processing
51 while(true){ // wait for an event to begin with the processing
50 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
52 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
51 if (status == RTEMS_SUCCESSFUL) {
53 if (status == RTEMS_SUCCESSFUL) {
52 if ((spectral_matrices_regs->ctrl & 0x00000001)==1) {
54 if ((spectral_matrices_regs->ctrl & 0x00000001)==1) {
53 matrix_average(spec_mat_f0_a, averaged_spec_mat_f0);
55 matrix_average(spec_mat_f0_a, averaged_spec_mat_f0);
54 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe;
56 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe;
55 //printf("f0_a\n");
57 //printf("f0_a\n");
56 Nb_average_f0++;
58 Nb_average_f0++;
57 }
59 }
58 if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1) {
60 if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1) {
59 matrix_average(spec_mat_f0_b, compressed_spec_mat_f0);
61 matrix_average(spec_mat_f0_b, compressed_spec_mat_f0);
60 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd;
62 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd;
61 //printf("f0_b\n");
63 //printf("f0_b\n");
62 Nb_average_f0++;
64 Nb_average_f0++;
63 }
65 }
64 if (Nb_average_f0 == NB_AVERAGE_NORMAL_f0) {
66 if (Nb_average_f0 == NB_AVERAGE_NORMAL_f0) {
65 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
67 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
66 //printf("f0 compressed\n");
68 //printf("f0 compressed\n");
67 Nb_average_f0 = 0;
69 Nb_average_f0 = 0;
68 matrix_reset(averaged_spec_mat_f0);
70 matrix_reset(averaged_spec_mat_f0);
69 }
71 }
70 }
72 }
71 }
73 }
72 }
74 }
73
75
74 rtems_task avf0_task(rtems_task_argument argument){
76 rtems_task avf0_task(rtems_task_argument argument){
75 int i;
77 int i;
76 static int nb_average;
78 static int nb_average;
77 rtems_event_set event_out;
79 rtems_event_set event_out;
78 rtems_status_code status;
80 rtems_status_code status;
79
81
80 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
82 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
81 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
83 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
82 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
84 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
83
85
84 nb_average = 0;
86 nb_average = 0;
85
87
86 PRINTF("in AVFO *** \n")
88 PRINTF("in AVFO *** \n")
87
89
88 while(1){
90 while(1){
89 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
91 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
90 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
92 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
91 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
93 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
92 + spec_mat_f0_b[i]
94 + spec_mat_f0_b[i]
93 + spec_mat_f0_c[i]
95 + spec_mat_f0_c[i]
94 + spec_mat_f0_d[i]
96 + spec_mat_f0_d[i]
95 + spec_mat_f0_e[i]
97 + spec_mat_f0_e[i]
96 + spec_mat_f0_f[i]
98 + spec_mat_f0_f[i]
97 + spec_mat_f0_g[i]
99 + spec_mat_f0_g[i]
98 + spec_mat_f0_h[i];
100 + spec_mat_f0_h[i];
99 }
101 }
100 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
102 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
101 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
103 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
102 if (nb_average == NB_AVERAGE_NORMAL_f0) {
104 if (nb_average == NB_AVERAGE_NORMAL_f0) {
103 nb_average = 0;
105 nb_average = 0;
104 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
106 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
105 if (status != RTEMS_SUCCESSFUL) {
107 if (status != RTEMS_SUCCESSFUL) {
106 printf("iN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
108 printf("iN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
107 }
109 }
108 }
110 }
109 }
111 }
110 }
112 }
111
113
112 rtems_task bpf0_task(rtems_task_argument argument){
114 rtems_task bpf0_task(rtems_task_argument argument){
113 rtems_event_set event_out;
115 rtems_event_set event_out;
114
116
115 PRINTF("in BPFO *** \n")
117 PRINTF("in BPFO *** \n")
116
118
117 while(1){
119 while(1){
118 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
120 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
119 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
121 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
120 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
122 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
121 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
123 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
122 }
124 }
123 }
125 }
124
126
125 //*****************************
127 //*****************************
126 // Spectral matrices processing
128 // Spectral matrices processing
127 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
129 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
128 {
130 {
129 int i;
131 int i;
130 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
132 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
131 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i]
133 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i]
132 + spec_mat_f0_b[i]
134 + spec_mat_f0_b[i]
133 + spec_mat_f0_c[i]
135 + spec_mat_f0_c[i]
134 + spec_mat_f0_d[i]
136 + spec_mat_f0_d[i]
135 + spec_mat_f0_e[i]
137 + spec_mat_f0_e[i]
136 + spec_mat_f0_f[i]
138 + spec_mat_f0_f[i]
137 + spec_mat_f0_g[i]
139 + spec_mat_f0_g[i]
138 + spec_mat_f0_h[i];
140 + spec_mat_f0_h[i];
139 }
141 }
140 }
142 }
141
143
142 void matrix_reset(float *averaged_spec_mat)
144 void matrix_reset(float *averaged_spec_mat)
143 {
145 {
144 int i;
146 int i;
145 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
147 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
146 averaged_spec_mat_f0[i] = 0;
148 averaged_spec_mat_f0[i] = 0;
147 }
149 }
148 }
150 }
149
151
150 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
152 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
151 {
153 {
152 int i;
154 int i;
153 int j;
155 int j;
154 switch (fChannel){
156 switch (fChannel){
155 case 0:
157 case 0:
156 for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){
158 for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){
157 j = 17 + (i * 8);
159 j = 17 + (i * 8);
158 compressed_spec_mat[i] = (averaged_spec_mat[j]
160 compressed_spec_mat[i] = (averaged_spec_mat[j]
159 + averaged_spec_mat[j+1]
161 + averaged_spec_mat[j+1]
160 + averaged_spec_mat[j+2]
162 + averaged_spec_mat[j+2]
161 + averaged_spec_mat[j+3]
163 + averaged_spec_mat[j+3]
162 + averaged_spec_mat[j+4]
164 + averaged_spec_mat[j+4]
163 + averaged_spec_mat[j+5]
165 + averaged_spec_mat[j+5]
164 + averaged_spec_mat[j+6]
166 + averaged_spec_mat[j+6]
165 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
167 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
166 }
168 }
167 break;
169 break;
168 case 1:
170 case 1:
169 // case fChannel = f1 to be completed later
171 // case fChannel = f1 to be completed later
170 break;
172 break;
171 case 2:
173 case 2:
172 // case fChannel = f1 to be completed later
174 // case fChannel = f1 to be completed later
173 break;
175 break;
174 default:
176 default:
175 break;
177 break;
176 }
178 }
177 }
179 }
178
180
179 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
181 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
180 int i;
182 int i;
181 int j;
183 int j;
182 unsigned char tmp_u_char;
184 unsigned char tmp_u_char;
183 unsigned char * pt_char = NULL;
185 unsigned char * pt_char = NULL;
184 float PSDB, PSDE;
186 float PSDB, PSDE;
185 float NVEC_V0;
187 float NVEC_V0;
186 float NVEC_V1;
188 float NVEC_V1;
187 float NVEC_V2;
189 float NVEC_V2;
188 //float significand;
190 //float significand;
189 //int exponent;
191 //int exponent;
190 float aux;
192 float aux;
191 float tr_SB_SB;
193 float tr_SB_SB;
192 float tmp;
194 float tmp;
193 float sx_re;
195 float sx_re;
194 float sx_im;
196 float sx_im;
195 float nebx_re = 0;
197 float nebx_re = 0;
196 float nebx_im = 0;
198 float nebx_im = 0;
197 float ny = 0;
199 float ny = 0;
198 float nz = 0;
200 float nz = 0;
199 float bx_bx_star = 0;
201 float bx_bx_star = 0;
200 for(i=0; i<nb_bins_compressed_spec_mat; i++){
202 for(i=0; i<nb_bins_compressed_spec_mat; i++){
201 //==============================================
203 //==============================================
202 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
204 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
203 PSDB = compressed_spec_mat[i*30] // S11
205 PSDB = compressed_spec_mat[i*30] // S11
204 + compressed_spec_mat[(i*30) + 10] // S22
206 + compressed_spec_mat[(i*30) + 10] // S22
205 + compressed_spec_mat[(i*30) + 18]; // S33
207 + compressed_spec_mat[(i*30) + 18]; // S33
206 //significand = frexp(PSDB, &exponent);
208 //significand = frexp(PSDB, &exponent);
207 pt_char = (unsigned char*) &PSDB;
209 pt_char = (unsigned char*) &PSDB;
208 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
210 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
209 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
211 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
210 //==============================================
212 //==============================================
211 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
213 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
212 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
214 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
213 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
215 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
214 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
216 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
215 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
217 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
216 pt_char = (unsigned char*) &PSDE;
218 pt_char = (unsigned char*) &PSDE;
217 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
219 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
218 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
220 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
219 //==============================================================================
221 //==============================================================================
220 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
222 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
221 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
223 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
222 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
224 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
223 tmp = sqrt(
225 tmp = sqrt(
224 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
226 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
225 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
227 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
226 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
228 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
227 );
229 );
228 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
230 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
229 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
231 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
230 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
232 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
231 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
233 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
232 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
234 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
233 pt_char = (unsigned char*) &NVEC_V2;
235 pt_char = (unsigned char*) &NVEC_V2;
234 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
236 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
235 //=======================================================
237 //=======================================================
236 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
238 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
237 aux = 2*tmp / PSDB; // compute the ellipticity
239 aux = 2*tmp / PSDB; // compute the ellipticity
238 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
240 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
239 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
241 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
240 //==============================================================
242 //==============================================================
241 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
243 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
242 for(j = 0; j<NB_VALUES_PER_spec_mat;j++){
244 for(j = 0; j<NB_VALUES_PER_spec_mat;j++){
243 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
245 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
244 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
246 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
245 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
247 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
246 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
248 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
247 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
249 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
248 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
250 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
249 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
251 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
250 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
252 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
251 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
253 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
252 }
254 }
253 aux = PSDB*PSDB;
255 aux = PSDB*PSDB;
254 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
256 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
255 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
257 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
256 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
258 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
257 //=======================================================================================
259 //=======================================================================================
258 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
260 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
259 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
261 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
260 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
262 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
261 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
263 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
262 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
264 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
263 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
265 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
264 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
266 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
265 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
267 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
266 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
268 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
267 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
269 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
268 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
270 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
269 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
271 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
270 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
272 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
271 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
273 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
272 if ( abs(sx_re) > abs(sx_im) ) {
274 if ( abs(sx_re) > abs(sx_im) ) {
273 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
275 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
274 }
276 }
275 else {
277 else {
276 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
278 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
277 }
279 }
278 //======================================================================
280 //======================================================================
279 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
281 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
280 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
282 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
281 nz = NVEC_V0;
283 nz = NVEC_V0;
282 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
284 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
283 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
285 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
284 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
286 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
285 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
287 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
286 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
288 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
287 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
289 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
288 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
290 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
289 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
291 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
290 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
292 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
291 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
293 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
292 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
294 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
293 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
295 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
294 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
296 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
295 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
297 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
296 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
298 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
297 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
299 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
298 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
300 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
299 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
301 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
300 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
302 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
301 tmp = nebx_re / bx_bx_star;
303 tmp = nebx_re / bx_bx_star;
302 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
304 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
303 if ( abs(nebx_re) > abs(nebx_im) ) {
305 if ( abs(nebx_re) > abs(nebx_im) ) {
304 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
306 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
305 }
307 }
306 else {
308 else {
307 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
309 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
308 }
310 }
309 }
311 }
310
312
311 }
313 }
312
314
313 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
315 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
314 // BP2 autocorrelation
316 // BP2 autocorrelation
315 int i;
317 int i;
316 int aux = 0;
318 int aux = 0;
317
318 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
319 // S12
320 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
321 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
322 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
323 // S13
324 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
325 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
326 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
327 // S23
328 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
329 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
330 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
331 // S45
332 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
333 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
334 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
335 // S14
336 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
337 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
338 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
339 // S15
340 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
341 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
342 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
343 // S24
344 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
345 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
346 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
347 // S25
348 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
349 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
350 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
351 // S34
352 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
353 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
354 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
355 // S35
356 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
357 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
358 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
359 }
360 }
361
319
320 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
321 // S12
322 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
323 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
324 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
325 // S13
326 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
327 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
328 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
329 // S23
330 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
331 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
332 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
333 // S45
334 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
335 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
336 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
337 // S14
338 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
339 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
340 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
341 // S15
342 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
343 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
344 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
345 // S24
346 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
347 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
348 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
349 // S25
350 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
351 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
352 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
353 // S34
354 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
355 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
356 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
357 // S35
358 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
359 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
360 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
361 }
362 }
363
This diff has been collapsed as it changes many lines, (869 lines changed) Show them Hide them
@@ -1,969 +1,1216
1 #include <tc_handler.h>
1 #include <tc_handler.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 char *DumbMessages[5] = {"in DUMB *** default",
4 char *DumbMessages[5] = {"in DUMB *** default", // RTEMS_EVENT_0
5 "in DUMB *** timecode_irq_handler",
5 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
6 "in DUMB *** waveforms_isr",
6 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
7 "",
7 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
8 ""
8 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ" // RTEMS_EVENT_4
9 };
9 };
10
10
11 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
11 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
12 unsigned char currentTC_COMPUTED_CRC[2];
12 unsigned char currentTC_COMPUTED_CRC[2];
13 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
13 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
14 unsigned int currentTM_length;
14 unsigned int currentTM_length;
15 unsigned char currentTC_processedFlag;
15 unsigned char currentTC_processedFlag;
16
16
17 unsigned int lookUpTableForCRC[256];
17 unsigned int lookUpTableForCRC[256];
18
18
19 //**********************
19 //**********************
20 // GENERAL USE FUNCTIONS
20 // GENERAL USE FUNCTIONS
21 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
21 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
22 {
22 {
23 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
23 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
24 }
24 }
25
25
26 void initLookUpTableForCRC( void )
26 void initLookUpTableForCRC( void )
27 {
27 {
28 unsigned int i;
28 unsigned int i;
29 unsigned int tmp;
29 unsigned int tmp;
30
30
31 for (i=0; i<256; i++)
31 for (i=0; i<256; i++)
32 {
32 {
33 tmp = 0;
33 tmp = 0;
34 if((i & 1) != 0) {
34 if((i & 1) != 0) {
35 tmp = tmp ^ 0x1021;
35 tmp = tmp ^ 0x1021;
36 }
36 }
37 if((i & 2) != 0) {
37 if((i & 2) != 0) {
38 tmp = tmp ^ 0x2042;
38 tmp = tmp ^ 0x2042;
39 }
39 }
40 if((i & 4) != 0) {
40 if((i & 4) != 0) {
41 tmp = tmp ^ 0x4084;
41 tmp = tmp ^ 0x4084;
42 }
42 }
43 if((i & 8) != 0) {
43 if((i & 8) != 0) {
44 tmp = tmp ^ 0x8108;
44 tmp = tmp ^ 0x8108;
45 }
45 }
46 if((i & 16) != 0) {
46 if((i & 16) != 0) {
47 tmp = tmp ^ 0x1231;
47 tmp = tmp ^ 0x1231;
48 }
48 }
49 if((i & 32) != 0) {
49 if((i & 32) != 0) {
50 tmp = tmp ^ 0x2462;
50 tmp = tmp ^ 0x2462;
51 }
51 }
52 if((i & 64) != 0) {
52 if((i & 64) != 0) {
53 tmp = tmp ^ 0x48c4;
53 tmp = tmp ^ 0x48c4;
54 }
54 }
55 if((i & 128) != 0) {
55 if((i & 128) != 0) {
56 tmp = tmp ^ 0x9188;
56 tmp = tmp ^ 0x9188;
57 }
57 }
58 lookUpTableForCRC[i] = tmp;
58 lookUpTableForCRC[i] = tmp;
59 }
59 }
60 }
60 }
61
61
62 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
62 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
63 {
63 {
64 unsigned int Chk;
64 unsigned int Chk;
65 int j;
65 int j;
66 Chk = 0xffff; // reset the syndrom to all ones
66 Chk = 0xffff; // reset the syndrom to all ones
67 for (j=0; j<sizeOfData; j++) {
67 for (j=0; j<sizeOfData; j++) {
68 Chk = Crc_opt(data[j], Chk);
68 Chk = Crc_opt(data[j], Chk);
69 }
69 }
70 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
70 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
71 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
71 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
72 }
72 }
73
73
74 //*********************
74 //*********************
75 // ACCEPTANCE FUNCTIONS
75 // ACCEPTANCE FUNCTIONS
76 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
76 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
77 {
77 {
78 int ret = 0;
78 int ret = 0;
79 rtems_status_code status;
79 rtems_status_code status;
80 spw_ioctl_pkt_send spw_ioctl_send;
80 spw_ioctl_pkt_send spw_ioctl_send;
81 TMHeader_t TM_header;
81 TMHeader_t TM_header;
82 unsigned int code = 0;
82 unsigned int code = 0;
83 unsigned char computed_CRC[2];
83 unsigned char computed_CRC[2];
84 char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
84 char data[ PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
85
85
86 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
86 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
87 code = acceptTM( TC, tc_len_recv ) ;
87 code = TC_parser( TC, tc_len_recv ) ;
88 if ( (code == ILLEGAL_APID) | (code == WRONG_LEN_PACKET) | (code == INCOR_CHECKSUM)
88 if ( (code == ILLEGAL_APID) | (code == WRONG_LEN_PACKET) | (code == INCOR_CHECKSUM)
89 | (code == ILL_TYPE) | (code == ILL_SUBTYPE) | (code == WRONG_APP_DATA) )
89 | (code == ILL_TYPE) | (code == ILL_SUBTYPE) | (code == WRONG_APP_DATA) )
90 { // generate TM_LFR_TC_EXE_CORRUPTED
90 { // generate TM_LFR_TC_EXE_CORRUPTED
91 // BUILD HEADER
91 // BUILD HEADER
92 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_EXE_CORR, 0, 0, &TM_header);
92 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_CORRUPTED,
93 &TM_header, TC->sourceID); // TC source ID
93 // BUILD DATA
94 // BUILD DATA
94 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
95 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
95 // PREPARE TM SENDING
96 // PREPARE TM SENDING
96 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
97 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
97 spw_ioctl_send.hdr = (char*) &TM_header;
98 spw_ioctl_send.hdr = (char*) &TM_header;
98 spw_ioctl_send.dlen = 16;
99 spw_ioctl_send.dlen = 16;
99 spw_ioctl_send.data = data;
100 spw_ioctl_send.data = data;
100 // SEND PACKET
101 // SEND PACKET
101 write_spw(&spw_ioctl_send);
102 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
102 }
103 }
103 else { // send valid TC to the action launcher
104 else { // send valid TC to the action launcher
104 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
105 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
105 ret = -1;
106 ret = -1;
106 }
107 }
107 return ret;
108 return ret;
108 }
109 }
109
110
110 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
111 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
111 {
112 {
112 unsigned char ret = 0;
113 unsigned char ret = 0;
113 unsigned char pid = 0;
114 unsigned char pid = 0;
114 unsigned char category = 0;
115 unsigned char category = 0;
115 unsigned int length = 0;
116 unsigned int length = 0;
116 unsigned char packetType = 0;
117 unsigned char packetType = 0;
117 unsigned char packetSubtype = 0;
118 unsigned char packetSubtype = 0;
118 unsigned char * CCSDSContent = NULL;
119 unsigned char * CCSDSContent = NULL;
119
120
120 // APID check *** APID on 2 bytes
121 // APID check *** APID on 2 bytes
121 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
122 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
122 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
123 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
123 length = (TMPacket->packetLength[0] * 256) + TMPacket->packetLength[1];
124 length = (TMPacket->packetLength[0] * 256) + TMPacket->packetLength[1];
124 packetType = TMPacket->dataFieldHeader[1];
125 packetType = TMPacket->serviceType;
125 packetSubtype = TMPacket->dataFieldHeader[2];
126 packetSubtype = TMPacket->serviceSubType;
126
127
127 if (pid!=CCSDS_PROCESS_ID) {
128 if ( pid != CCSDS_PROCESS_ID ) {
128 ret = ILLEGAL_APID;
129 ret = ILLEGAL_APID;
129 }
130 }
130 else if (category!=CCSDS_PACKET_CATEGORY) {
131 else if ( category != CCSDS_PACKET_CATEGORY ) {
131 ret = ILLEGAL_APID;
132 ret = ILLEGAL_APID;
132 }
133 }
133 else if (length != TC_LEN_RCV ) { // packet length check
134 else if (length != TC_LEN_RCV ) { // packet length check
134 ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
135 ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
135 }
136 }
136 else if (length >= CCSDS_TC_PKT_MAX_SIZE) {
137 else if ( length >= CCSDS_TC_PKT_MAX_SIZE ) {
137 ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
138 ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
138 }
139 }
139 else if (packetType == TC_TYPE_GEN){ // service type, subtype and packet length check
140 else if ( packetType == TC_TYPE_GEN ){ // service type, subtype and packet length check
140 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
141 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
141 case TC_SUBTYPE_RESET:
142 case TC_SUBTYPE_RESET:
142 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
143 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
143 ret = WRONG_LEN_PACKET;
144 ret = WRONG_LEN_PACKET;
144 }
145 }
145 else {
146 else {
146 ret = CCSDS_TM_VALID;
147 ret = CCSDS_TM_VALID;
147 }
148 }
148 break;
149 break;
149 case TC_SUBTYPE_LOAD_COMM:
150 case TC_SUBTYPE_LOAD_COMM:
150 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
151 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
151 ret = WRONG_LEN_PACKET;
152 ret = WRONG_LEN_PACKET;
152 }
153 }
153 else {
154 else {
154 ret = CCSDS_TM_VALID;
155 ret = CCSDS_TM_VALID;
155 }
156 }
156 break;
157 break;
157 case TC_SUBTYPE_LOAD_NORM:
158 case TC_SUBTYPE_LOAD_NORM:
158 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
159 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
159 ret = WRONG_LEN_PACKET;
160 ret = WRONG_LEN_PACKET;
160 }
161 }
161 else {
162 else {
162 ret = CCSDS_TM_VALID;
163 ret = CCSDS_TM_VALID;
163 }
164 }
164 break;
165 break;
165 case TC_SUBTYPE_LOAD_BURST:
166 case TC_SUBTYPE_LOAD_BURST:
166 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
167 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
167 ret = WRONG_LEN_PACKET;
168 ret = WRONG_LEN_PACKET;
168 }
169 }
169 else {
170 else {
170 ret = CCSDS_TM_VALID;
171 ret = CCSDS_TM_VALID;
171 }
172 }
172 break;
173 break;
173 case TC_SUBTYPE_LOAD_SBM1:
174 case TC_SUBTYPE_LOAD_SBM1:
174 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
175 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
175 ret = WRONG_LEN_PACKET;
176 ret = WRONG_LEN_PACKET;
176 }
177 }
177 else {
178 else {
178 ret = CCSDS_TM_VALID;
179 ret = CCSDS_TM_VALID;
179 }
180 }
180 break;
181 break;
181 case TC_SUBTYPE_LOAD_SBM2:
182 case TC_SUBTYPE_LOAD_SBM2:
182 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
183 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
183 ret = WRONG_LEN_PACKET;
184 ret = WRONG_LEN_PACKET;
184 }
185 }
185 else {
186 else {
186 ret = CCSDS_TM_VALID;
187 ret = CCSDS_TM_VALID;
187 }
188 }
188 break;
189 break;
189 case TC_SUBTYPE_DUMP:
190 case TC_SUBTYPE_DUMP:
190 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
191 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
191 ret = WRONG_LEN_PACKET;
192 ret = WRONG_LEN_PACKET;
192 }
193 }
193 else {
194 else {
194 ret = CCSDS_TM_VALID;
195 ret = CCSDS_TM_VALID;
195 }
196 }
196 break;
197 break;
197 case TC_SUBTYPE_ENTER:
198 case TC_SUBTYPE_ENTER:
198 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
199 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
199 ret = WRONG_LEN_PACKET;
200 ret = WRONG_LEN_PACKET;
200 }
201 }
201 else {
202 else {
202 ret = CCSDS_TM_VALID;
203 ret = CCSDS_TM_VALID;
203 }
204 }
204 break;
205 break;
205 case TC_SUBTYPE_UPDT_INFO:
206 case TC_SUBTYPE_UPDT_INFO:
206 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
207 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
207 ret = WRONG_LEN_PACKET;
208 ret = WRONG_LEN_PACKET;
208 }
209 }
209 else {
210 else {
210 ret = CCSDS_TM_VALID;
211 ret = CCSDS_TM_VALID;
211 }
212 }
212 break;
213 break;
213 case TC_SUBTYPE_EN_CAL:
214 case TC_SUBTYPE_EN_CAL:
214 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
215 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
215 ret = WRONG_LEN_PACKET;
216 ret = WRONG_LEN_PACKET;
216 }
217 }
217 else {
218 else {
218 ret = CCSDS_TM_VALID;
219 ret = CCSDS_TM_VALID;
219 }
220 }
220 break;
221 break;
221 case TC_SUBTYPE_DIS_CAL:
222 case TC_SUBTYPE_DIS_CAL:
222 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
223 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
223 ret = WRONG_LEN_PACKET;
224 ret = WRONG_LEN_PACKET;
224 }
225 }
225 else {
226 else {
226 ret = CCSDS_TM_VALID;
227 ret = CCSDS_TM_VALID;
227 }
228 }
228 break;
229 break;
229 default:
230 default:
230 ret = ILL_SUBTYPE;
231 ret = ILL_SUBTYPE;
231 break;
232 break;
232 }
233 }
233 }
234 }
234 else if (packetType == TC_TYPE_TIME){
235 else if ( packetType == TC_TYPE_TIME ){
235 if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) {
236 if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) {
236 ret = ILL_SUBTYPE;
237 ret = ILL_SUBTYPE;
237 }
238 }
238 else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
239 else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
239 ret = WRONG_LEN_PACKET;
240 ret = WRONG_LEN_PACKET;
240 }
241 }
241 else {
242 else {
242 ret = CCSDS_TM_VALID;
243 ret = CCSDS_TM_VALID;
243 }
244 }
244 }
245 }
245 else {
246 else {
246 ret = ILL_TYPE;
247 ret = ILL_TYPE;
247 }
248 }
248
249
249 // source ID check // Source ID not documented in the ICD
250 // source ID check // Source ID not documented in the ICD
250
251
251 // packet error control, CRC check
252 // packet error control, CRC check
252 if ( ret == CCSDS_TM_VALID ) {
253 if ( ret == CCSDS_TM_VALID ) {
253 CCSDSContent = (unsigned char*) TMPacket->packetID;
254 CCSDSContent = (unsigned char*) TMPacket->packetID;
254 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
255 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
255 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
256 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
256 ret = INCOR_CHECKSUM;
257 ret = INCOR_CHECKSUM;
257 }
258 }
258 else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
259 else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
259 ret = INCOR_CHECKSUM;
260 ret = INCOR_CHECKSUM;
260 }
261 }
261 else {
262 else {
262 ret = CCSDS_TM_VALID;
263 ret = CCSDS_TM_VALID;
263 }
264 }
264 }
265 }
265
266
266 return ret;
267 return ret;
267 }
268 }
268
269
269 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
270 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
270 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader)
271 TMHeader_t *TMHeader, unsigned char tc_sid)
271 {
272 {
272 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
273 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
273 TMHeader->protocolIdentifier = 0x02;
274 TMHeader->protocolIdentifier = CCSDS_PROTOCOLE_ID;
274 TMHeader->reserved = 0x00;
275 TMHeader->reserved = 0x00;
275 TMHeader->userApplication = 0x00;
276 TMHeader->userApplication = 0x00;
276 TMHeader->packetID[0] = 0x0c;
277 TMHeader->packetID[0] = 0x0c;
277 TMHeader->packetSequenceControl[0] = 0xc0;
278 TMHeader->packetSequenceControl[0] = 0xc0;
278 TMHeader->packetSequenceControl[1] = 0x00;
279 TMHeader->packetSequenceControl[1] = 0x00;
279 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
280 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
280 TMHeader->packetLength[1] = (unsigned char) packetLength;
281 TMHeader->packetLength[1] = (unsigned char) packetLength;
281 TMHeader->dataFieldHeader[0] = 0x10;
282 TMHeader->spare1_pusVersion_spare2 = 0x10;
282 TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
283 TMHeader->destinationID = CCSDS_DESTINATION_ID; // default destination id
283 switch (tm_type){
284 switch (tm_type){
284 case(TM_LFR_TC_EXE_OK):
285 case(TM_LFR_TC_EXE_OK):
285 TMHeader->packetID[1] = 0xc1;
286 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
286 TMHeader->dataFieldHeader[1] = 1; // type
287 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
287 TMHeader->dataFieldHeader[2] = 7; // subtype
288 TMHeader->serviceSubType = TM_SUBTYPE_EXE_OK; // subtype
289 TMHeader->destinationID = tc_sid; // destination id
288 break;
290 break;
289 case(TM_LFR_TC_EXE_ERR):
291 case(TM_LFR_TC_EXE_ERR):
290 TMHeader->packetID[1] = 0xc1;
292 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
291 TMHeader->dataFieldHeader[1] = 1; // type
293 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
292 TMHeader->dataFieldHeader[2] = 8; // subtype
294 TMHeader->serviceSubType = TM_SUBTYPE_EXE_NOK; // subtype
293 break;
295 break;
294 case(TM_LFR_HK):
296 case(TM_LFR_HK):
295 TMHeader->packetID[1] = 0xc4;
297 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_HK;
296 TMHeader->dataFieldHeader[1] = 3; // type
298 TMHeader->serviceType = TM_TYPE_HK; // type
297 TMHeader->dataFieldHeader[2] = 25; // subtype
299 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
298 break;
300 break;
299 case(TM_LFR_SCI):
301 case(TM_LFR_SCI):
300 TMHeader->packetID[1] = 0xcc;
302 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_NORMAL;
301 TMHeader->dataFieldHeader[1] = 21; // type
303 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
302 TMHeader->dataFieldHeader[2] = 3; // subtype
304 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
303 break;
305 break;
304 case(TM_LFR_SCI_SBM):
306 case(TM_LFR_SCI_SBM):
305 TMHeader->packetID[1] = 0xfc;
307 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2;
306 TMHeader->dataFieldHeader[1] = 21; // type
308 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
307 TMHeader->dataFieldHeader[2] = 3; // subtype
309 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
308 break;
310 break;
309 case(TM_LFR_PAR_DUMP):
311 case(TM_LFR_PAR_DUMP):
310 TMHeader->packetID[1] = 0xc9;
312 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
311 TMHeader->dataFieldHeader[1] = 181; // type
313 TMHeader->serviceType = TM_TYPE_HK; // type
312 TMHeader->dataFieldHeader[2] = 31; // subtype
314 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
313 break;
315 break;
314 default:
316 default:
315 return 0;
317 return 0;
316 }
318 }
317 TMHeader->dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
319 TMHeader->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
318 TMHeader->dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
320 TMHeader->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
319 TMHeader->dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
321 TMHeader->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
320 TMHeader->dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
322 TMHeader->time[3] = (unsigned char) (time_management_regs->coarse_time);
321 TMHeader->dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
323 TMHeader->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
322 TMHeader->dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
324 TMHeader->time[5] = (unsigned char) (time_management_regs->fine_time);
323 return 1;
324 }
325
326 unsigned char TM_build_header_bis( enum TM_TYPE tm_type, unsigned int packetLength,
327 unsigned int coarseTime, unsigned int fineTime, Packet_TM_LFR_TC_EXE_t *packet)
328 {
329
325
330 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
326 return LFR_SUCCESSFUL;
331 packet->protocolIdentifier = 0x02;
332 packet->reserved = 0x00;
333 packet->userApplication = 0x00;
334 packet->packetID[0] = 0x0c;
335 packet->packetSequenceControl[0] = 0xc0;
336 packet->packetSequenceControl[1] = 0x00;
337 packet->packetLength[0] = (unsigned char) (packetLength>>8);
338 packet->packetLength[1] = (unsigned char) packetLength;
339 packet->dataFieldHeader[0] = 0x10;
340 packet->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
341 switch (tm_type){
342 case(TM_LFR_TC_EXE_OK):
343 packet->packetID[1] = 0xc1;
344 packet->dataFieldHeader[1] = 1; // type
345 packet->dataFieldHeader[2] = 7; // subtype
346 break;
347 case(TM_LFR_TC_EXE_ERR):
348 packet->packetID[1] = 0xc1;
349 packet->dataFieldHeader[1] = 1; // type
350 packet->dataFieldHeader[2] = 8; // subtype
351 break;
352 case(TM_LFR_HK):
353 packet->packetID[1] = 0xc4;
354 packet->dataFieldHeader[1] = 3; // type
355 packet->dataFieldHeader[2] = 25; // subtype
356 break;
357 case(TM_LFR_SCI):
358 packet->packetID[1] = 0xcc;
359 packet->dataFieldHeader[1] = 21; // type
360 packet->dataFieldHeader[2] = 3; // subtype
361 break;
362 case(TM_LFR_SCI_SBM):
363 packet->packetID[1] = 0xfc;
364 packet->dataFieldHeader[1] = 21; // type
365 packet->dataFieldHeader[2] = 3; // subtype
366 break;
367 case(TM_LFR_PAR_DUMP):
368 packet->packetID[1] = 0xc9;
369 packet->dataFieldHeader[1] = 181; // type
370 packet->dataFieldHeader[2] = 31; // subtype
371 break;
372 default:
373 return 0;
374 }
375 packet->dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
376 packet->dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
377 packet->dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
378 packet->dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
379 packet->dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
380 packet->dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
381 return 1;
382 }
327 }
383
328
384 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
329 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
385 {
330 {
386 unsigned int packetLength;
331 unsigned int packetLength;
387 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1];
332 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1];
388 switch (SID){
333 switch (SID){
389 case (SID_NOT_EXE):
334 case (SID_NOT_EXE):
390 break;
335 break;
391 case (SID_NOT_IMP):
336 case (SID_NOT_IMP):
392 data[0] = 0x9c;
337 data[0] = 0x9c;
393 data[1] = 0x42;
338 data[1] = 0x42;
394 data[2] = TC->packetID[0];
339 data[2] = TC->packetID[0];
395 data[3] = TC->packetID[1];
340 data[3] = TC->packetID[1];
396 data[4] = TC->packetSequenceControl[0];
341 data[4] = TC->packetSequenceControl[0];
397 data[5] = TC->packetSequenceControl[1];
342 data[5] = TC->packetSequenceControl[1];
398 data[6] = TC->dataFieldHeader[1]; // type
343 data[6] = TC->serviceType; // type
399 data[7] = TC->dataFieldHeader[2]; // subtype
344 data[7] = TC->serviceSubType; // subtype
400 break;
345 break;
401 case (SID_EXE_ERR):
346 case (SID_EXE_ERR):
402 break;
347 break;
403 case (SID_EXE_CORR):
348 case (SID_EXE_CORR):
404 data[0] = 0x9c;
349 data[0] = 0x9c;
405 data[1] = 0x45;
350 data[1] = 0x45;
406 data[2] = TC->packetID[0];
351 data[2] = TC->packetID[0];
407 data[3] = TC->packetID[1];
352 data[3] = TC->packetID[1];
408 data[4] = TC->packetSequenceControl[0];
353 data[4] = TC->packetSequenceControl[0];
409 data[5] = TC->packetSequenceControl[1];
354 data[5] = TC->packetSequenceControl[1];
410 data[6] = TC->dataFieldHeader[1]; // type
355 data[6] = TC->serviceType; // type
411 data[7] = TC->dataFieldHeader[2]; // subtype
356 data[7] = TC->serviceSubType; // subtype
412 data[8] = currentTC_LEN_RCV[0];
357 data[8] = currentTC_LEN_RCV[0];
413 data[9] = currentTC_LEN_RCV[1];
358 data[9] = currentTC_LEN_RCV[1];
414 data[10] = TC->packetLength[0];
359 data[10] = TC->packetLength[0];
415 data[11] = TC->packetLength[1];
360 data[11] = TC->packetLength[1];
416 data[12] = TC->dataAndCRC[packetLength];
361 data[12] = TC->dataAndCRC[packetLength];
417 data[13] = TC->dataAndCRC[packetLength+1];
362 data[13] = TC->dataAndCRC[packetLength+1];
418 data[14] = computed_CRC[0];
363 data[14] = computed_CRC[0];
419 data[15] = computed_CRC[1];
364 data[15] = computed_CRC[1];
420 break;
365 break;
421 default:
366 default:
422 return 0;
367 return 0;
423 }
368 }
424 return 1;
369 return 1;
425 }
370 }
426
371
427 int create_message_queue( void )
372 int create_message_queue( void )
428 {
373 {
429 rtems_status_code status;
374 rtems_status_code status;
430 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
375 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
431 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
376 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
432 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
377 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
433 if (status!=RTEMS_SUCCESSFUL) {
378 if (status!=RTEMS_SUCCESSFUL) {
434 PRINTF("in create_message_queue *** error creating message queue\n")
379 PRINTF("in create_message_queue *** error creating message queue\n")
435 }
380 }
436
381
437 return 0;
382 return 0;
438 }
383 }
439
384
440 //***********
385 //***********
441 // RTEMS TASK
386 // RTEMS TASK
442 rtems_task recv_task( rtems_task_argument unused )
387 rtems_task recv_task( rtems_task_argument unused )
443 {
388 {
444 int len = 0;
389 int len = 0;
445 unsigned int i = 0;
390 unsigned int i = 0;
446 unsigned int data_length = 0;
391 unsigned int data_length = 0;
447 ccsdsTelecommandPacket_t currentTC;
392 ccsdsTelecommandPacket_t currentTC;
448 char data[100];
393 char data[100];
449
394
450 for(i=0; i<100; i++) data[i] = 0;
395 for(i=0; i<100; i++) data[i] = 0;
451
396
452 PRINTF("in RECV *** \n")
397 PRINTF("in RECV *** \n")
453
398
454 while(1)
399 while(1)
455 {
400 {
456 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
401 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
457 if (len == -1){ // error during the read call
402 if (len == -1){ // error during the read call
458 PRINTF("In RECV *** last read call returned -1\n")
403 PRINTF("In RECV *** last read call returned -1\n")
459 if (rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) {
404 //if (rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) {
460 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
405 // PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
461 }
406 //}
462 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) {
407 //if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) {
463 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
408 // PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
464 }
409 //}
465 }
410 }
466 else {
411 else {
467 PRINTF1("Got pck of length %d\n", len+1)
412 PRINTF1("Got pck of length %d\n", len+1)
468 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
413 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
469 PRINTF("In RECV *** packet lenght too short\n")
414 PRINTF("In RECV *** packet lenght too short\n")
470 }
415 }
471 else {
416 else {
472 currentTC_LEN_RCV[0] = 0x00;
417 currentTC_LEN_RCV[0] = 0x00;
473 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
418 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
474 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
419 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
475 // CHECK THE TC AND BUILD THE APPROPRIATE TM
420 // CHECK THE TC AND BUILD THE APPROPRIATE TM
476 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
421 data_length = TC_acceptance(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
477 if (data_length!=-1)
422 if (data_length!=-1)
478 {
423 {
479 }
424 }
480 }
425 }
481 }
426 }
482 }
427 }
483 }
428 }
484
429
485 rtems_task actn_task( rtems_task_argument unused )
430 rtems_task actn_task( rtems_task_argument unused )
486 {
431 {
487 int result = 0;
432 int result;
488 unsigned int val;
433 rtems_status_code status; // RTEMS status code
489 rtems_status_code status; // RTEMS status code
434 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
490 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
435 size_t size; // size of the incoming TC packet
491 size_t size; // size of the incoming TC packet
436 unsigned char subtype; // subtype of the current TC packet
492 unsigned char subtype = 0; // subtype of the current TC packet
437
438 result = LFR_SUCCESSFUL;
439 subtype = 0; // subtype of the current TC packet
493
440
494 PRINTF("in ACTN *** \n")
441 PRINTF("in ACTN *** \n")
495
442
496 while(1)
443 while(1)
497 {
444 {
498 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
445 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
499 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
446 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
500 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
447 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
501 else
448 else
502 {
449 {
503 subtype = TC.dataFieldHeader[2];
450 subtype = TC.serviceSubType;
504 switch(subtype)
451 switch(subtype)
505 {
452 {
506 case TC_SUBTYPE_RESET:
453 case TC_SUBTYPE_RESET:
507 result = action_default( &TC );
454 result = action_default( &TC );
508 break;
455 break;
509 //
456 //
510 case TC_SUBTYPE_LOAD_COMM:
457 case TC_SUBTYPE_LOAD_COMM:
511 result = action_load_comm( &TC );
458 result = action_load_comm( &TC );
512 close_action( &TC, result );
459 close_action( &TC, result );
513 break;
460 break;
514 //
461 //
515 case TC_SUBTYPE_LOAD_NORM:
462 case TC_SUBTYPE_LOAD_NORM:
516 result = action_load_norm( &TC );
463 result = action_load_norm( &TC );
517 close_action( &TC, result );
464 close_action( &TC, result );
518 break;
465 break;
519 //
466 //
520 case TC_SUBTYPE_LOAD_BURST:
467 case TC_SUBTYPE_LOAD_BURST:
521 result = action_default( &TC );
468 result = action_default( &TC );
522 close_action( &TC, result );
469 close_action( &TC, result );
523 break;
470 break;
524 //
471 //
525 case TC_SUBTYPE_LOAD_SBM1:
472 case TC_SUBTYPE_LOAD_SBM1:
526 result = action_default( &TC );
473 result = action_default( &TC );
527 close_action( &TC, result );
474 close_action( &TC, result );
528 break;
475 break;
529 //
476 //
530 case TC_SUBTYPE_LOAD_SBM2:
477 case TC_SUBTYPE_LOAD_SBM2:
531 result = action_default( &TC );
478 result = action_default( &TC );
532 close_action( &TC, result );
479 close_action( &TC, result );
533 break;
480 break;
534 //
481 //
535 case TC_SUBTYPE_DUMP:
482 case TC_SUBTYPE_DUMP:
536 result = action_default( &TC );
483 result = action_default( &TC );
537 close_action( &TC, result );
484 close_action( &TC, result );
538 break;
485 break;
539 //
486 //
540 case TC_SUBTYPE_ENTER:
487 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 }
549 result = action_enter( &TC );
488 result = action_enter( &TC );
550 close_action( &TC, result );
489 close_action( &TC, result );
551 break;
490 break;
552 //
491 //
553 case TC_SUBTYPE_UPDT_INFO:
492 case TC_SUBTYPE_UPDT_INFO:
554 result = action_default( &TC );
493 result = action_updt_info( &TC );
555 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
494 close_action( &TC, result );
556 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
557 val++;
558 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
559 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
560 break;
495 break;
561 //
496 //
562 case TC_SUBTYPE_EN_CAL:
497 case TC_SUBTYPE_EN_CAL:
563 result = action_default( &TC );
498 result = action_enable_calibration( &TC );
499 close_action( &TC, result );
564 break;
500 break;
565 //
501 //
566 case TC_SUBTYPE_DIS_CAL:
502 case TC_SUBTYPE_DIS_CAL:
567 result = action_default( &TC );
503 result = action_disable_calibration( &TC );
504 close_action( &TC, result );
568 break;
505 break;
569 //
506 //
570 case TC_SUBTYPE_UPDT_TIME:
507 case TC_SUBTYPE_UPDT_TIME:
571 result = action_updt_time( &TC );
508 result = action_updt_time( &TC );
572 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
573 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
574 val++;
575 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
576 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
577 break;
509 break;
578 //
510 //
579 default:
511 default:
580 break;
512 break;
581 }
513 }
582 }
514 }
583 }
515 }
584 }
516 }
585
517
586 rtems_task dumb_task( rtems_task_argument unused )
518 rtems_task dumb_task( rtems_task_argument unused )
587 {
519 {
520 unsigned int i;
521 unsigned int intEventOut;
588 unsigned int coarse_time = 0;
522 unsigned int coarse_time = 0;
589 unsigned int fine_time = 0;
523 unsigned int fine_time = 0;
590 unsigned int indice = 0;
591 unsigned int shiftedIndice = 0;
592 rtems_event_set event_out;
524 rtems_event_set event_out;
593
525
594 PRINTF("in DUMB *** \n")
526 PRINTF("in DUMB *** \n")
595
527
596 while(1){
528 while(1){
597 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
529 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
598 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
530 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
599 indice = 0;
531 intEventOut = (unsigned int) event_out;
600 shiftedIndice = (unsigned int) event_out;
532 PRINTF1("in DUMB *** event_out %x\n", (int) event_out)
601 while(!(shiftedIndice & 0x0001))
533 for ( i=0; i<32; i++)
602 {
534 {
603 shiftedIndice = shiftedIndice >> 1;
535 if ( ((intEventOut >> i) & 0x0001) != 0)
604 indice++;
536 {
537 coarse_time = time_management_regs->coarse_time;
538 fine_time = time_management_regs->fine_time;
539 printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
540 }
605 }
541 }
606 coarse_time = time_management_regs->coarse_time;
607 fine_time = time_management_regs->fine_time;
608 printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[indice]);
609 }
542 }
610 }
543 }
611
544
612 //***********
545 //***********
613 // TC ACTIONS
546 // TC ACTIONS
614
547
615 int action_default(ccsdsTelecommandPacket_t *TC)
548 int action_default(ccsdsTelecommandPacket_t *TC)
616 {
549 {
617 Packet_TM_LFR_TC_EXE_t packet;
550 rtems_status_code status;
551 TMHeader_t header;
552 spw_ioctl_pkt_send spw_ioctl_send;
553 unsigned char data[10];
618
554
619 TM_build_header_bis( TM_LFR_TC_EXE_ERR, TM_LEN_NOT_IMP,
555 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED,
620 time_management_regs->coarse_time, time_management_regs->fine_time, &packet);
556 &header, TC->sourceID);
621
557
622 packet.data[0] = 0x9c;
558 spw_ioctl_send.hlen = TM_HEADER_LEN + 4;
623 packet.data[1] = 0x42;
559 spw_ioctl_send.hdr = (char *) &header;
624 packet.data[2] = TC->packetID[0];
560 spw_ioctl_send.dlen = 8;
625 packet.data[3] = TC->packetID[1];
561 spw_ioctl_send.data = (char *) data;
626 packet.data[4] = TC->packetSequenceControl[0];
562 spw_ioctl_send.options = 0;
627 packet.data[5] = TC->packetSequenceControl[1];
563
628 packet.data[6] = TC->dataFieldHeader[1]; // type
564 data[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8);
629 packet.data[7] = TC->dataFieldHeader[2]; // subtype
565 data[1] = (char) FAILURE_CODE_NOT_IMPLEMENTED;
566 data[2] = TC->packetID[0];
567 data[3] = TC->packetID[1];
568 data[4] = TC->packetSequenceControl[0];
569 data[5] = TC->packetSequenceControl[1];
570 data[6] = TC->serviceType; // type
571 data[7] = TC->serviceSubType; // subtype
630
572
631 // SEND DATA
573 // SEND DATA
632 if (write ( fdSPW, &packet, LEN_TM_LFR_TC_EXE_NOT_IMP)==-1) {
574 status = write_spw(&spw_ioctl_send);
633 PRINTF("ERR *** in action_default *** send TM packet\n");
575 if (status != RTEMS_SUCCESSFUL)
576 {
577 PRINTF("ERR *** in action_default *** send TM packet\n")
634 }
578 }
635
579
636 return LFR_DEFAULT;
580 return LFR_DEFAULT;
637 }
581 }
638
582
639 int action_enter(ccsdsTelecommandPacket_t *TC)
583 int action_enter(ccsdsTelecommandPacket_t *TC)
640 {
584 {
641 rtems_status_code status = RTEMS_SUCCESSFUL;
585 rtems_status_code status;
642 unsigned char lfr_mode = TC->dataAndCRC[1];
586 unsigned char requestedMode;
643 printf("enter mode %d\n", lfr_mode);
587
644 switch(lfr_mode)
588 requestedMode = TC->dataAndCRC[1];
589
590 printf("try to enter mode %d\n", requestedMode);
591
592 status = transition_validation(requestedMode);
593
594 if ( status == LFR_SUCCESSFUL ) {
595 if ( (housekeeping_packet.lfr_status_word[0] & 0xf0) != LFR_MODE_STANDBY)
596 {
597 status = stop_current_mode();
598 }
599 if (status != RTEMS_SUCCESSFUL)
600 {
601 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
602 }
603 status = enter_mode(requestedMode, TC);
604 }
605 else
645 {
606 {
646 //********
607 PRINTF("ERR *** in action_enter *** transition rejected\n")
647 // STANDBY
608 send_tm_lfr_tc_exe_not_executable( TC );
648 case(LFR_MODE_STANDBY):
609 }
649 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_STANDBY << 4) + 0x0d);
610
650 break;
611 return status;
612 }
613
614 int action_load_comm(ccsdsTelecommandPacket_t *TC)
615 {
616 param_common.sy_lfr_common0 = TC->dataAndCRC[0];
617 param_common.sy_lfr_common1 = TC->dataAndCRC[1];
618
619 set_wfp_data_shaping(param_common.sy_lfr_common1);
620
621 return LFR_SUCCESSFUL;
622 }
623
624 int action_load_norm(ccsdsTelecommandPacket_t *TC)
625 {
626 int result;
627 unsigned char lfrMode;
628
629 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
630
631 if ( lfrMode == LFR_MODE_NORMAL ) {
632 send_tm_lfr_tc_exe_not_executable( TC );
633 result = LFR_DEFAULT;
634 }
635 else {
636 param_norm.sy_lfr_n_swf_l = (TC->dataAndCRC[0] * 256) + TC->dataAndCRC[1];
637 param_norm.sy_lfr_n_swf_p = (TC->dataAndCRC[2] * 256) + TC->dataAndCRC[3];
638 param_norm.sy_lfr_n_asm_p = (TC->dataAndCRC[4] * 256) + TC->dataAndCRC[5];
639 param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
640 param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
641 result = LFR_SUCCESSFUL;
642 }
643
644 return result;
645 }
646
647 int action_load_burst(ccsdsTelecommandPacket_t *TC)
648 {
649 int result;
650 unsigned char lfrMode;
651
652 result = LFR_DEFAULT;
653 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
651
654
652 //******
655 if ( lfrMode == LFR_MODE_BURST ) {
653 // NORMAL
656 send_tm_lfr_tc_exe_not_executable( TC );
654 case(LFR_MODE_NORMAL):
657 result = LFR_DEFAULT;
655 status = enter_normal_mode();
658 }
656 if (status == RTEMS_SUCCESSFUL)
659 else {
657 {
660 send_tm_lfr_tc_exe_not_implemented( TC );
658 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_NORMAL << 4) + 0x0d);
661 result = LFR_DEFAULT;
659 }
662 }
660 break;
663
664 return result;
665 }
666
667 int action_load_sbm1(ccsdsTelecommandPacket_t *TC)
668 {
669 int result;
670 unsigned char lfrMode;
671
672 result = LFR_DEFAULT;
673 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
674
675 if ( (lfrMode == LFR_MODE_SBM1) | (lfrMode == LFR_MODE_SBM2) ) {
676 send_tm_lfr_tc_exe_not_executable( TC );
677 result = LFR_DEFAULT;
678 }
679 else {
680 send_tm_lfr_tc_exe_not_implemented( TC );
681 result = LFR_DEFAULT;
682 }
683
684 return result;
685 }
686
687 int action_load_sbm2(ccsdsTelecommandPacket_t *TC)
688 {
689 int result;
690 unsigned char lfrMode;
691
692 result = LFR_DEFAULT;
693 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
694
695 if ( (lfrMode == LFR_MODE_SBM1) | (lfrMode == LFR_MODE_SBM2) ) {
696 send_tm_lfr_tc_exe_not_executable( TC );
697 result = LFR_DEFAULT;
698 }
699 else {
700 send_tm_lfr_tc_exe_not_implemented( TC );
701 result = LFR_DEFAULT;
702 }
703
704 return result;
705 }
706
707 int action_updt_info(ccsdsTelecommandPacket_t *TC) {
708 unsigned int val;
709 int result;
710 unsigned char lfrMode;
711
712 result = LFR_DEFAULT;
713 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
661
714
662 //******
715 if ( (lfrMode == LFR_MODE_STANDBY) ) {
663 // BURST
716 send_tm_lfr_tc_exe_not_executable( TC );
664 case(LFR_MODE_BURST):
717 result = LFR_DEFAULT;
665 status = enter_burst_mode();
718 }
666 if (status == RTEMS_SUCCESSFUL)
719 else {
667 {
720 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
668 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_BURST << 4) + 0x0d);
721 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
669 }
722 val++;
670 break;
723 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
724 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
725 result = LFR_SUCCESSFUL;
726 }
727
728 return result;
729 }
730
731 int action_enable_calibration(ccsdsTelecommandPacket_t *TC)
732 {
733 int result;
734 unsigned char lfrMode;
735
736 result = LFR_DEFAULT;
737 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
738
739 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
740 send_tm_lfr_tc_exe_not_executable( TC );
741 result = LFR_DEFAULT;
742 }
743 else {
744 send_tm_lfr_tc_exe_not_implemented( TC );
745 result = LFR_DEFAULT;
746 }
747 return result;
748 }
749
750 int action_disable_calibration(ccsdsTelecommandPacket_t *TC)
751 {
752 int result;
753 unsigned char lfrMode;
754
755 result = LFR_DEFAULT;
756 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
757
758 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
759 send_tm_lfr_tc_exe_not_executable( TC );
760 result = LFR_DEFAULT;
761 }
762 else {
763 send_tm_lfr_tc_exe_not_implemented( TC );
764 result = LFR_DEFAULT;
765 }
766 return result;
767 }
768
769 int action_updt_time(ccsdsTelecommandPacket_t *TC)
770 {
771 unsigned int val;
671
772
672 //*****
773 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
673 // SBM1
774 + (TC->dataAndCRC[1] << 16)
674 case(LFR_MODE_SBM1):
775 + (TC->dataAndCRC[2] << 8)
675 status = enter_sbm1_mode();
776 + TC->dataAndCRC[3];
676 if (status == RTEMS_SUCCESSFUL)
777 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
677 {
778 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
678 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_SBM1 << 4) + 0x0d);
779 val++;
679 }
780 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
680 break;
781 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
782 //time_management_regs->ctrl = time_management_regs->ctrl | 1;
783
784 return LFR_SUCCESSFUL;
785 }
786
787 //*******************
788 // ENTERING THE MODES
789
790 int transition_validation(unsigned char requestedMode)
791 {
792 int status;
793 unsigned char lfrMode;
794
795 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
681
796
682 //*****
797 switch (requestedMode)
683 // SBM2
798 {
684 case(LFR_MODE_SBM2):
799 case LFR_MODE_STANDBY:
685 status = enter_sbm2_mode();
800 if ( (lfrMode == LFR_MODE_STANDBY) ) {
686 if (status == RTEMS_SUCCESSFUL)
801 status = LFR_DEFAULT;
687 {
802 }
688 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_SBM2 << 4) + 0x0d);
803 else
689 }
804 {
690 break;
805 status = LFR_SUCCESSFUL;
806 }
807 break;
808 case LFR_MODE_NORMAL:
809 if ( (lfrMode == LFR_MODE_NORMAL) ) {
810 status = LFR_DEFAULT;
811 }
812 else {
813 status = LFR_SUCCESSFUL;
814 }
815 break;
816 case LFR_MODE_BURST:
817 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST)
818 | (lfrMode == LFR_MODE_SBM2) ) {
819 status = LFR_DEFAULT;
820 }
821 else {
822 status = LFR_SUCCESSFUL;
823 }
824 break;
825 case LFR_MODE_SBM1:
826 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_SBM1) ) {
827 status = LFR_DEFAULT;
828 }
829 else {
830 status = LFR_SUCCESSFUL;
831 }
832 break;
833 case LFR_MODE_SBM2:
834 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_NORMAL)
835 | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
836 status = LFR_DEFAULT;
837 }
838 else {
839 status = LFR_SUCCESSFUL;
840 }
841 break;
842 default:
843 status = LFR_DEFAULT;
844 break;
845 }
691
846
692 //********
693 // DEFAULT
694 default:
695 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_STANDBY << 4) + 0x0d);
696 break;
697 }
698 return status;
847 return status;
699 }
848 }
700
849
701 int stop_current_mode()
850 int stop_current_mode()
702 {
851 {
703 rtems_status_code status;
852 rtems_status_code status;
853 unsigned char lfrMode;
854
855 status = RTEMS_SUCCESSFUL;
856 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
704
857
705 // mask all IRQ lines related to signal processing
858 // mask all IRQ lines related to signal processing
706 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
859 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
707 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
860 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
708 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
861 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
709
862
710 // clear all pending interruptions related to signal processing
863 // clear all pending interruptions related to signal processing
711 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
864 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
712 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
865 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
713 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
866 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
714
867
715 // suspend several tasks
868 // suspend several tasks
716
869
717 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
870 if (lfrMode != LFR_MODE_STANDBY) {
718 if (status == RTEMS_SUCCESSFUL) {
871 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
719 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
872 if (status == RTEMS_SUCCESSFUL) {
720 if (status == RTEMS_SUCCESSFUL) {
873 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
721 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
874 if (status == RTEMS_SUCCESSFUL) {
722 }
875 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
876 }
877 }
723 }
878 }
724
879
725 if (status != RTEMS_SUCCESSFUL)
880 if (status != RTEMS_SUCCESSFUL)
726 {
881 {
727 PRINTF("ERR *** in stop_current_mode *** suspending tasks\n")
882 PRINTF("ERR *** in stop_current_mode *** suspending tasks\n")
728 }
883 }
729
884
730 // initialize the registers
885 // initialize the registers
731 waveform_picker_regs->burst_enable = 0x00; // initialize
886 waveform_picker_regs->burst_enable = 0x00; // initialize
732
887
733 return status;
888 return status;
734 }
889 }
735
890
736 int enter_normal_mode()
891 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
737 {
892 {
738 rtems_status_code status;
893 rtems_status_code status;
739
894
740 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
895 switch(mode){
741 if (status == RTEMS_SUCCESSFUL) {
896 case LFR_MODE_STANDBY:
742 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
897 status = enter_standby_mode( TC );
743 if (status == RTEMS_SUCCESSFUL) {
898 break;
744 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
899 case LFR_MODE_NORMAL:
745 }
900 status = enter_normal_mode( TC );
901 break;
902 case LFR_MODE_BURST:
903 status = enter_burst_mode( TC );
904 break;
905 case LFR_MODE_SBM1:
906 status = enter_sbm1_mode( TC );
907 break;
908 case LFR_MODE_SBM2:
909 status = enter_sbm2_mode( TC );
910 break;
911 default:
912 status = RTEMS_UNSATISFIED;
746 }
913 }
747
914
748 #ifdef GSA
915 if (status == RTEMS_SUCCESSFUL)
749 LEON_Unmask_interrupt( IRQ_WF );
916 {
750 #else
917 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
751 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
918 }
752 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
753 waveform_picker_regs->burst_enable = 0x07;
754 waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1;
755 waveform_picker_regs->status = 0x00;
756 #endif
757 LEON_Unmask_interrupt( IRQ_SM );
758
919
759 return status;
920 return status;
760 }
921 }
761
922
762 int enter_burst_mode()
923 int enter_standby_mode(ccsdsTelecommandPacket_t *TC)
763 {
924 {
764 rtems_status_code status;
925 return LFR_SUCCESSFUL;
765
766 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
767 if (status == RTEMS_SUCCESSFUL) {
768 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
769 if (status == RTEMS_SUCCESSFUL) {
770 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
771 }
772 }
773
774 #ifdef GSA
775 #else
776 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
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 }
926 }
787
927
788 int enter_sbm1_mode()
928 int enter_normal_mode( ccsdsTelecommandPacket_t *TC )
789 {
929 {
790 rtems_status_code status;
930 rtems_status_code status;
791
931
792 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
932 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
793 if (status == RTEMS_SUCCESSFUL) {
933 if (status == RTEMS_SUCCESSFUL) {
794 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
934 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
795 if (status == RTEMS_SUCCESSFUL) {
935 if (status == RTEMS_SUCCESSFUL) {
796 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
936 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
797 }
937 }
798 }
938 }
799
939
800 #ifdef GSA
940 #ifdef GSA
941 LEON_Unmask_interrupt( IRQ_WF );
801 #else
942 #else
802 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
943 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
803 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
944 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
804 waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1;
945 waveform_picker_regs->burst_enable = 0x07;
805 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] burst f2, f1, f0 enable f3 f2 f1 f0
946 waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1;
806 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x02;
947 waveform_picker_regs->status = 0x00;
807 waveform_picker_regs->status = 0x00;
948 #endif
949 LEON_Unmask_interrupt( IRQ_SM );
950
951 return status;
952 }
953
954 int enter_burst_mode(ccsdsTelecommandPacket_t *TC)
955 {
956 rtems_status_code status;
957 unsigned char lfrMode;
958
959 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
960
961 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
962 if (status == RTEMS_SUCCESSFUL) {
963 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
964 if (status == RTEMS_SUCCESSFUL) {
965 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
966 }
967 }
968
969 #ifdef GSA
970 #else
971 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
972 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
973 waveform_picker_regs->addr_data_f2 = (int) wf_snap_f2;
974 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] burst f2, f1, f0 enable f3 f2 f1 f0
975 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04;
976 waveform_picker_regs->status = 0x00;
808 #endif
977 #endif
809
978
810 LEON_Unmask_interrupt( IRQ_SM );
979 LEON_Unmask_interrupt( IRQ_SM );
980
811 return status;
981 return status;
812 }
982 }
813
983
814 int enter_sbm2_mode()
984 int enter_sbm1_mode(ccsdsTelecommandPacket_t *TC)
815 {
985 {
816 rtems_status_code status;
986 rtems_status_code status;
817
987
818 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
988 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
819 if (status == RTEMS_SUCCESSFUL) {
989 if (status == RTEMS_SUCCESSFUL) {
820 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
990 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
821 if (status == RTEMS_SUCCESSFUL) {
991 if (status == RTEMS_SUCCESSFUL) {
822 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
992 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
823 }
993 }
824 }
994 }
825
995
996 // at the beginning of the mode, the parameter local_sbm1_nb_cwf_max has a specific value
997 param_local.local_sbm1_nb_cwf_max = 2 * param_norm.sy_lfr_n_swf_p / 4;
998
999 #ifdef GSA
1000 #else
1001 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1002 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1003 waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1;
1004 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1005 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f3 f2 f1 f0
1006 waveform_picker_regs->status = 0x00;
1007 #endif
1008
1009 LEON_Unmask_interrupt( IRQ_SM );
1010
1011 return status;
1012 }
1013
1014 int enter_sbm2_mode(ccsdsTelecommandPacket_t *TC)
1015 {
1016 rtems_status_code status;
1017
1018 status = rtems_task_restart( Task_id[TASKID_AVF0], 0 );
1019 if (status == RTEMS_SUCCESSFUL) {
1020 status = rtems_task_restart( Task_id[TASKID_BPF0], 0 );
1021 if (status == RTEMS_SUCCESSFUL) {
1022 status = rtems_task_restart( Task_id[TASKID_WFRM], 0 );
1023 }
1024 }
1025
1026 // at the beginning of the mode, the parameter local_sbm2_nb_cwf_max has a specific value
1027 param_local.local_sbm1_nb_cwf_max = param_norm.sy_lfr_n_swf_p / 16;
1028
826 #ifdef GSA
1029 #ifdef GSA
827 #else
1030 #else
828 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1031 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
829 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1032 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
830 waveform_picker_regs->addr_data_f2 = (int) wf_snap_f2;
1033 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
1034 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;
1035 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04;
833 waveform_picker_regs->status = 0x00;
1036 waveform_picker_regs->status = 0x00;
834 #endif
1037 #endif
835
1038
836 LEON_Unmask_interrupt( IRQ_SM );
1039 LEON_Unmask_interrupt( IRQ_SM );
1040
837 return status;
1041 return status;
838 }
1042 }
839
1043
840 int action_load_norm(ccsdsTelecommandPacket_t *TC)
1044 //****************
841 {
1045 // CLOSING ACTIONS
842 param_norm.sy_lfr_n_swf_l = (TC->dataAndCRC[0] * 256) + TC->dataAndCRC[1];
843 param_norm.sy_lfr_n_swf_p = (TC->dataAndCRC[2] * 256) + TC->dataAndCRC[3];
844 param_norm.sy_lfr_n_asm_p = (TC->dataAndCRC[4] * 256) + TC->dataAndCRC[5];
845 param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
846 param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
847
848 return LFR_SUCCESSFUL;
849 }
850
851 int action_load_comm(ccsdsTelecommandPacket_t *TC)
852 {
853 param_common.sy_lfr_common0 = TC->dataAndCRC[0];
854 param_common.sy_lfr_common1 = TC->dataAndCRC[1];
855
856 set_data_shaping_parameters(param_common.sy_lfr_common1);
857
858 return LFR_SUCCESSFUL;
859 }
860
861 int action_updt_time(ccsdsTelecommandPacket_t *TC)
862 {
863 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
864 + (TC->dataAndCRC[1] << 16)
865 + (TC->dataAndCRC[2] << 8)
866 + TC->dataAndCRC[3];
867 //time_management_regs->ctrl = time_management_regs->ctrl | 1;
868 return 0;
869 }
870
1046
871 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC)
1047 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC)
872 {
1048 {
1049 rtems_status_code status;
873 TMHeader_t TM_header;
1050 TMHeader_t TM_header;
874 char data[4];
1051 char data[4];
875 spw_ioctl_pkt_send spw_ioctl_send;
1052 spw_ioctl_pkt_send spw_ioctl_send;
876
1053
877 TM_build_header( TM_LFR_TC_EXE_OK, TM_LEN_EXE,
1054 TM_build_header( TM_LFR_TC_EXE_OK, PACKET_LENGTH_TC_EXE_SUCCESS,
878 time_management_regs->coarse_time, time_management_regs->fine_time, &TM_header);
1055 &TM_header,
1056 TC->sourceID); // TC source ID
879
1057
880 data[0] = TC->packetID[0];
1058 data[0] = TC->packetID[0];
881 data[1] = TC->packetID[1];
1059 data[1] = TC->packetID[1];
882 data[2] = TC->packetSequenceControl[0];
1060 data[2] = TC->packetSequenceControl[0];
883 data[3] = TC->packetSequenceControl[1];
1061 data[3] = TC->packetSequenceControl[1];
884
1062
885 // filling the structure for the spacewire transmission
1063 // filling the structure for the spacewire transmission
886 spw_ioctl_send.hlen = TM_HEADER_LEN + 3; // + 4 is for the protocole extra header
1064 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
887 spw_ioctl_send.hdr = (char*) &TM_header;
1065 spw_ioctl_send.hdr = (char*) &TM_header;
888 spw_ioctl_send.dlen = 3;
1066 spw_ioctl_send.dlen = 4;
889 spw_ioctl_send.data = data;
1067 spw_ioctl_send.data = data;
1068 spw_ioctl_send.options = 0;
890
1069
891 // SEND DATA
1070 // SEND DATA
892 write_spw(&spw_ioctl_send);
1071 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1072
1073 return LFR_SUCCESSFUL;
1074 }
1075
1076 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC)
1077 {
1078 rtems_status_code status;
1079 TMHeader_t TM_header;
1080 char data[10];
1081 spw_ioctl_pkt_send spw_ioctl_send;
1082
1083 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE,
1084 &TM_header,
1085 TC->sourceID); // TC source ID
1086
1087 data[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8);
1088 data[1] = (char) FAILURE_CODE_NOT_EXECUTABLE;
1089 data[2] = TC->packetID[0];
1090 data[3] = TC->packetID[1];
1091 data[4] = TC->packetSequenceControl[0];
1092 data[5] = TC->packetSequenceControl[1];
1093 data[6] = TC->serviceType; // type of the rejected TC
1094 data[7] = TC->serviceSubType; // subtype of the rejected TC
1095 data[8] = housekeeping_packet.lfr_status_word[0];
1096 data[6] = housekeeping_packet.lfr_status_word[1];
1097
1098 // filling the structure for the spacewire transmission
1099 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1100 spw_ioctl_send.hdr = (char*) &TM_header;
1101 spw_ioctl_send.dlen = 10;
1102 spw_ioctl_send.data = data;
1103 spw_ioctl_send.options = 0;
893
1104
894 return 0;
1105 // SEND DATA
1106 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1107
1108 return LFR_SUCCESSFUL;
1109 }
1110
1111 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC)
1112 {
1113 rtems_status_code status;
1114 TMHeader_t TM_header;
1115 char data[8];
1116 spw_ioctl_pkt_send spw_ioctl_send;
1117
1118 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED,
1119 &TM_header,
1120 TC->sourceID); // TC source ID
1121
1122 data[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8);
1123 data[1] = (char) FAILURE_CODE_NOT_IMPLEMENTED;
1124 data[2] = TC->packetID[0];
1125 data[3] = TC->packetID[1];
1126 data[4] = TC->packetSequenceControl[0];
1127 data[5] = TC->packetSequenceControl[1];
1128 data[6] = TC->serviceType; // type of the rejected TC
1129 data[7] = TC->serviceSubType; // subtype of the rejected TC
1130
1131 // filling the structure for the spacewire transmission
1132 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1133 spw_ioctl_send.hdr = (char*) &TM_header;
1134 spw_ioctl_send.dlen = 8;
1135 spw_ioctl_send.data = data;
1136 spw_ioctl_send.options = 0;
1137
1138 // SEND DATA
1139 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1140
1141 return LFR_SUCCESSFUL;
895 }
1142 }
896
1143
897 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
1144 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
898 {
1145 {
899 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1146 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
900 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1147 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
901 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1148 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
902 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->dataFieldHeader[1];
1149 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
903 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1150 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
904 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->dataFieldHeader[2];
1151 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
905 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1152 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
906 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1153 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
907 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1154 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
908 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
1155 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
909 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1156 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
910 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1157 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
911 }
1158 }
912
1159
913 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
1160 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
914 {
1161 {
915 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1162 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
916 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1163 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
917 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1164 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
918 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->dataFieldHeader[1];
1165 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
919 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1166 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
920 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->dataFieldHeader[2];
1167 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
921 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1168 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
922 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1169 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
923 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1170 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
924 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
1171 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
925 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1172 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
926 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1173 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
927 }
1174 }
928
1175
929 void close_action(ccsdsTelecommandPacket_t *TC, int result)
1176 void close_action(ccsdsTelecommandPacket_t *TC, int result)
930 {
1177 {
931 unsigned int val = 0;
1178 unsigned int val = 0;
932 if (result == LFR_SUCCESSFUL)
1179 if (result == LFR_SUCCESSFUL)
933 {
1180 {
934 send_tm_lfr_tc_exe_success( TC );
1181 send_tm_lfr_tc_exe_success( TC );
935 update_last_TC_exe( TC );
1182 update_last_TC_exe( TC );
936 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
1183 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
937 val++;
1184 val++;
938 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
1185 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
939 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
1186 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
940 }
1187 }
941 else
1188 else
942 {
1189 {
943 update_last_TC_rej( TC );
1190 update_last_TC_rej( TC );
944 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
1191 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
945 val++;
1192 val++;
946 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
1193 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
947 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
1194 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
948 }
1195 }
949 }
1196 }
950
1197
951 //***************************
1198 //***************************
952 // Interrupt Service Routines
1199 // Interrupt Service Routines
953 rtems_isr commutation_isr1( rtems_vector_number vector )
1200 rtems_isr commutation_isr1( rtems_vector_number vector )
954 {
1201 {
955 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1202 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
956 printf("In commutation_isr1 *** Error sending event to DUMB\n");
1203 printf("In commutation_isr1 *** Error sending event to DUMB\n");
957 }
1204 }
958 }
1205 }
959
1206
960 rtems_isr commutation_isr2( rtems_vector_number vector )
1207 rtems_isr commutation_isr2( rtems_vector_number vector )
961 {
1208 {
962 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1209 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
963 printf("In commutation_isr2 *** Error sending event to DUMB\n");
1210 printf("In commutation_isr2 *** Error sending event to DUMB\n");
964 }
1211 }
965 }
1212 }
966
1213
967
1214
968
1215
969
1216
This diff has been collapsed as it changes many lines, (552 lines changed) Show them Hide them
@@ -1,452 +1,664
1 #include <wf_handler.h>
1 #include <wf_handler.h>
2
2
3 rtems_isr waveforms_isr( rtems_vector_number vector )
3 rtems_isr waveforms_isr( rtems_vector_number vector )
4 {
4 {
5 unsigned char lfrMode;
5 unsigned char lfrMode;
6 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
6 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
7
7
8 switch(lfrMode)
8 switch(lfrMode)
9 {
9 {
10 //********
10 //********
11 // STANDBY
11 // STANDBY
12 case(LFR_MODE_STANDBY):
12 case(LFR_MODE_STANDBY):
13 break;
13 break;
14
14
15 //******
15 //******
16 // NORMAL
16 // NORMAL
17 case(LFR_MODE_NORMAL):
17 case(LFR_MODE_NORMAL):
18 #ifdef GSA
18 #ifdef GSA
19 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
19 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
20 #else
20 #else
21 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){// if no channel is enable
21 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){// if no channel is enable
22 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
22 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
23 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
23 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
24 }
24 }
25 }
25 }
26 else {
26 else {
27 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
27 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
28 waveform_picker_regs->burst_enable = 0x00;
28 waveform_picker_regs->burst_enable = 0x00;
29 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
29 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
30 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
30 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
31 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
31 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
32 }
32 }
33 }
33 }
34 }
34 }
35 }
35 }
36 #endif
36 #endif
37 break;
37 break;
38
38
39 //******
39 //******
40 // BURST
40 // BURST
41 case(LFR_MODE_BURST):
41 case(LFR_MODE_BURST):
42 break;
43
44 //*****
45 // SBM1
46 case(LFR_MODE_SBM1):
47 #ifdef GSA
48 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
49 #else
50 if (waveform_picker_regs->burst_enable == 0x22) {
51 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
52 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
53 }
54 else {
55 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
56 }
57 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
58 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
59 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
60 }
61 }
62 waveform_picker_regs->status = 0x00;
63 #endif
64 break;
65
66 //*****
67 // SBM2
68 case(LFR_MODE_SBM2):
69 #ifdef GSA
42 #ifdef GSA
70 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
43 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
71 #else
44 #else
72 if (waveform_picker_regs->burst_enable == 0x44) {
45 if (waveform_picker_regs->burst_enable == 0x44) {
73 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
46 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
74 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
47 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
75 }
48 }
76 else {
49 else {
77 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
50 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
78 }
51 }
79 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
52 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
80 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
53 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
81 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
54 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
82 }
55 }
83 }
56 }
84 waveform_picker_regs->status = 0x00;
57 waveform_picker_regs->status = 0x00;
85 #endif
58 #endif
86 break;
59 break;
87
60
61 //*****
62 // SBM1
63 case(LFR_MODE_SBM1):
64 #ifdef GSA
65 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
66 #else
67 if ((waveform_picker_regs->status & 0x02) == 0x02){ // check the f1 full bit
68 // (1) change the receiving buffer for the waveform picker
69 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
70 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
71 }
72 else {
73 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
74 }
75 // (2) send an event for the waveforms transmission
76 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
77 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
78 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
79 }
80 waveform_picker_regs->status = waveform_picker_regs->status & 0x000d; // reset the f1 full bit to 0
81 }
82 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] f3 f2 f1 f0, check the f2 and f0 full bit
83 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
84 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
85 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
86 }
87 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x05; // [0101] // enable f2 and f0
88 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // set to 0 the bits related to f2 and f0
89 }
90 #endif
91 break;
92
93 //*****
94 // SBM2
95 case(LFR_MODE_SBM2):
96 #ifdef GSA
97 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
98 #else
99 if ((waveform_picker_regs->status & 0x04) == 0x04){ // check the f2 full bit
100 // (1) change the receiving buffer for the waveform picker
101 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
102 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
103 }
104 else {
105 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
106 }
107 // (2) send an event for the waveforms transmission
108 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
109 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
110 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
111 }
112 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1011]
113 }
114 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, check the f2 and f0 full bit
115 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
116 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
117 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
118 }
119 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x03; // [0011] // enable f2 and f0
120 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // set to 0 the bits related to f1 and f0
121 }
122 #endif
123 break;
124
88 //********
125 //********
89 // DEFAULT
126 // DEFAULT
90 default:
127 default:
91 break;
128 break;
92 }
129 }
93 }
130 }
94
131
95 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
132 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
96 {
133 {
97 unsigned char lfrMode;
134 unsigned char lfrMode;
98 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
135 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
99
136
100 switch(lfrMode)
137 switch(lfrMode)
101 {
138 {
102 //********
139 //********
103 // STANDBY
140 // STANDBY
104 case(LFR_MODE_STANDBY):
141 case(LFR_MODE_STANDBY):
105 break;
142 break;
106
143
107 //******
144 //******
108 // NORMAL
145 // NORMAL
109 case(LFR_MODE_NORMAL):
146 case(LFR_MODE_NORMAL):
110 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
147 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");
148 PRINTF("ERR *** in waveforms_isr *** error sending event to WFRM\n");
112 }
149 }
113 break;
150 break;
114
151
115 //******
152 //******
116 // BURST
153 // BURST
117 case(LFR_MODE_BURST):
154 case(LFR_MODE_BURST):
118 break;
155 break;
119
156
120 //*****
157 //*****
121 // SBM1
158 // SBM1
122 case(LFR_MODE_SBM1):
159 case(LFR_MODE_SBM1):
123 break;
160 break;
124
161
125 //*****
162 //*****
126 // SBM2
163 // SBM2
127 case(LFR_MODE_SBM2):
164 case(LFR_MODE_SBM2):
128 break;
165 break;
129
166
130 //********
167 //********
131 // DEFAULT
168 // DEFAULT
132 default:
169 default:
133 break;
170 break;
134 }
171 }
135 }
172 }
136
173
137 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
174 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
138 {
175 {
139 spw_ioctl_pkt_send spw_ioctl_send;
176 unsigned int i;
177 unsigned int intEventOut;
178 spw_ioctl_pkt_send spw_ioctl_send_SWF;
179 spw_ioctl_pkt_send spw_ioctl_send_CWF;
140 rtems_event_set event_out;
180 rtems_event_set event_out;
141 ExtendedTMHeader_t header;
181 Header_TM_LFR_SCIENCE_SWF_t headerSWF;
182 Header_TM_LFR_SCIENCE_CWF_t headerCWF;
142
183
143 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
184 init_header_snapshot_wf( &headerSWF );
144 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
185 init_header_continuous_wf( &headerCWF );
145 header.reserved = 0x00;
146 header.userApplication = CCSDS_USER_APP;
147 header.packetID[0] = 0x0c;
148 header.packetID[1] = 0xcc;
149 header.packetSequenceControl[0] = 0x00;
150 header.packetSequenceControl[1] = 0x00;
151 header.packetLength[0] = 0x00;
152 header.packetLength[1] = 0x00;
153 header.dataFieldHeader[0] = 0x10;
154 header.dataFieldHeader[1] = TM_TYPE_LFR_SCIENCE; // service type
155 header.dataFieldHeader[2] = TM_SUBTYPE_LFR_SCIENCE; // service subtype
156 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
157
186
158 header.auxiliaryHeader[0] = 0x00;
187 // BUILD THE PACKET HEADERS
159 header.auxiliaryHeader[1] = 0x1f;
188 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
160 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
189 spw_ioctl_send_SWF.hdr = (char*) &headerSWF;
161 header.auxiliaryHeader[3] = 0x00; // PKT_NR
190 spw_ioctl_send_SWF.options = 0;
162 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
163 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
164
191
165 // BUILD THE PACKET HEADER
192 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
166 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
193 spw_ioctl_send_CWF.hdr = (char*) &headerCWF;
167 spw_ioctl_send.hdr = (char*) &header;
194 spw_ioctl_send_CWF.options = 0;
168
195
169 init_waveforms();
196 init_waveforms();
170
197
171 PRINTF("in WFRM ***\n")
198 PRINTF("in WFRM ***\n")
172
199
173 while(1){
200 while(1){
174 // wait for an RTEMS_EVENT
201 // wait for an RTEMS_EVENT
175 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
202 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
176 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
203 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
177 header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
204 intEventOut = (unsigned int) event_out;
178 header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
205 for (i = 0; i< 5; i++) {
179 header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
206 if ( ( (intEventOut >> i) & 0x0001) != 0 ) {
180 header.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
207 switch(i) {
181 header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
208 case(LFR_MODE_NORMAL):
182 header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
209 send_waveform_norm( &headerSWF, &spw_ioctl_send_SWF);
183
210 break;
184 switch(event_out)
211 case(LFR_MODE_BURST):
185 {
212 send_waveform_burst( &headerCWF, &spw_ioctl_send_CWF);
186 //********
213 break;
187 // STANDBY
214 case(LFR_MODE_SBM1):
188 case(RTEMS_EVENT_MODE_STANDBY):
215 send_waveform_sbm1( &headerCWF, &spw_ioctl_send_CWF);
189 break;
216 param_local.local_sbm1_nb_cwf_sent ++;
190
217 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) ) {
191 //*******
218 // send the f1 buffer as a NORM snapshot
192 // NORMAL
219 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
193 case(RTEMS_EVENT_MODE_NORMAL):
220 send_waveform_SWF( &headerSWF, wf_snap_f1_bis, SID_NORM_SWF_F1, &spw_ioctl_send_SWF );
194 //***************
221 }
195 // send snapshots
222 else {
196 // F0
223 send_waveform_SWF( &headerSWF, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send_SWF );
197 send_waveform( &header, wf_snap_f0, SID_NORM_SWF_F0, &spw_ioctl_send);
224 }
198 // F1
225 }
199 send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send);
226 break;
200 // F2
227 case(LFR_MODE_SBM2):
201 send_waveform( &header, wf_snap_f2, SID_NORM_SWF_F2, &spw_ioctl_send);
228 send_waveform_sbm2( &headerCWF, &spw_ioctl_send_CWF);
202 #ifdef GSA
229 param_local.local_sbm2_nb_cwf_sent ++;
203 // irq processed, reset the related register of the timer unit
230 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) ) {
204 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
231 // send the f2 buffer as a NORM snapshot
205 #else
232 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
206 // irq processed, reset the related register of the waveform picker
233 send_waveform_SWF( &headerSWF, wf_snap_f2_bis, SID_NORM_SWF_F2, &spw_ioctl_send_SWF );
207 waveform_picker_regs->status = 0x00;
234 }
208 waveform_picker_regs->burst_enable = 0x07;
235 else {
209 #endif
236 send_waveform_SWF( &headerSWF, wf_snap_f2, SID_NORM_SWF_F2, &spw_ioctl_send_SWF );
210 break;
237 }
211
238 }
212 //*****
239 break;
213 // SBM1
240 default:
214 case(RTEMS_EVENT_MODE_SBM1):
241 break;
215 // F1
216 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
217 send_waveform( &header, wf_snap_f1_bis, SID_NORM_SWF_F1, &spw_ioctl_send);
218 }
242 }
219 else {
243 }
220 send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send);
221 }
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
238 default:
239 break;
240 }
244 }
241 }
245 }
242 }
246 }
243
247
244 //******************
248 //******************
245 // general functions
249 // general functions
246 void init_waveforms( void )
250 void init_waveforms( void )
247 {
251 {
248 int i = 0;
252 int i = 0;
249
253
250 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
254 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
251 {
255 {
252 //***
256 //***
253 // F0
257 // F0
254 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
258 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
255 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
259 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
256 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
260 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
257
261
258 //***
262 //***
259 // F1
263 // F1
260 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
264 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
261 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
265 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
262 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
266 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
263
267
264 //***
268 //***
265 // F2
269 // F2
266 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
270 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
267 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
271 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
268 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
272 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
269
273
270 //***
274 //***
271 // F3
275 // F3
272 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
276 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
273 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
277 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
274 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
278 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
275 }
279 }
276 }
280 }
277
281
278 void init_waveform_header( ExtendedTMHeader_t * header, unsigned int sid )
282 void init_header_snapshot_wf( Header_TM_LFR_SCIENCE_SWF_t *header)
279 {
283 {
280
281 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
284 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
282 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
285 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
283 header->reserved = 0x00;
286 header->reserved = 0x00;
284 header->userApplication = CCSDS_USER_APP;
287 header->userApplication = CCSDS_USER_APP;
285 header->packetID[0] = 0x0c;
288 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL >> 8);
286 header->packetID[1] = 0xcc;
289 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL);
287 header->packetSequenceControl[0] = 0x00;
290 header->packetSequenceControl[0] = 0xc0;
288 header->packetSequenceControl[1] = 0x00;
291 header->packetSequenceControl[1] = 0x00;
289 header->packetLength[0] = 0x00;
292 header->packetLength[0] = 0x00;
290 header->packetLength[1] = 0x00;
293 header->packetLength[1] = 0x00;
291 header->dataFieldHeader[0] = 0x10;
294 // DATA FIELD HEADER
292 header->dataFieldHeader[1] = TM_TYPE_LFR_SCIENCE; // service type
295 header->spare1_pusVersion_spare2 = 0x10;
293 header->dataFieldHeader[2] = TM_SUBTYPE_LFR_SCIENCE; // service subtype
296 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
294 header->dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
297 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
298 header->destinationID = TM_DESTINATION_ID_GROUND;
299 // AUXILIARY DATA HEADER
300 header->sid = 0x00;
301 header->hkBIA = 0x1f;
302 header->pktCnt = 0x07; // PKT_CNT
303 header->pktNr = 0x00; // PKT_NR
304 header->time[0] = 0x00;
305 header->time[0] = 0x00;
306 header->time[0] = 0x00;
307 header->time[0] = 0x00;
308 header->time[0] = 0x00;
309 header->time[0] = 0x00;
310 header->blkNr[0] = 0x00; // BLK_NR MSB
311 header->blkNr[1] = 0x00; // BLK_NR LSB
312 }
295
313
296 header->auxiliaryHeader[0] = sid;
314 void init_header_continuous_wf( Header_TM_LFR_SCIENCE_CWF_t *header)
297 header->auxiliaryHeader[1] = 0x1f;
315 {
298 header->auxiliaryHeader[2] = 0x07; // PKT_CNT
316 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
299 header->auxiliaryHeader[3] = 0x00; // PKT_NR
317 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
300 header->auxiliaryHeader[4] = 0x00; // BLK_NR MSB
318 header->reserved = 0x00;
301 header->auxiliaryHeader[5] = 0x00; // BLK_NR LSB
319 header->userApplication = CCSDS_USER_APP;
320 header->packetID[0] = 0x00;
321 header->packetID[1] = 0x00;
322 header->packetSequenceControl[0] = 0xc0;
323 header->packetSequenceControl[1] = 0x00;
324 header->packetLength[0] = 0x00;
325 header->packetLength[1] = 0x00;
326 // DATA FIELD HEADER
327 header->spare1_pusVersion_spare2 = 0x10;
328 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
329 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
330 header->destinationID = TM_DESTINATION_ID_GROUND;
331 // AUXILIARY DATA HEADER
332 header->sid = 0x00;
333 header->hkBIA = 0x1f;
334 header->time[0] = 0x00;
335 header->time[0] = 0x00;
336 header->time[0] = 0x00;
337 header->time[0] = 0x00;
338 header->time[0] = 0x00;
339 header->time[0] = 0x00;
340 header->blkNr[0] = 0x00; // BLK_NR MSB
341 header->blkNr[1] = 0x00; // BLK_NR LSB
302 }
342 }
303
343
304 void reset_waveforms( void )
344 void reset_waveforms( void )
305 {
345 {
306 int i = 0;
346 int i = 0;
307
347
308 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
348 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
309 {
349 {
310 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
350 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
311 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
351 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
312 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
352 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
313
353
314 //***
354 //***
315 // F1
355 // F1
316 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
356 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
317 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
357 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
318 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
358 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
319
359
320 //***
360 //***
321 // F2
361 // F2
322 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
362 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
323 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
363 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
324 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
364 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
325
365
326 //***
366 //***
327 // F3
367 // F3
328 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
368 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
329 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
369 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
330 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
370 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
331 }
371 }
332 }
372 }
333
373
334 void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform,
374 void send_waveform_SWF( Header_TM_LFR_SCIENCE_SWF_t *header, volatile int *waveform,
335 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send)
375 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send)
336 {
376 {
337 unsigned int i = 0;
377 unsigned int i = 0;
338 unsigned int length = 0;
378 unsigned int length = 0;
339 rtems_status_code status;
379 rtems_status_code status;
340
380
381 header->sid = (unsigned char) sid;
382
341 for (i=0; i<7; i++) // send waveform
383 for (i=0; i<7; i++) // send waveform
342 {
384 {
343 header->auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR
385 header->pktNr = (unsigned char) i+1; // PKT_NR
344 // BUILD THE DATA
386 // BUILD THE DATA
345 if (i==6) {
387 if (i==6) {
346 spw_ioctl_send->dlen = 8 * NB_BYTES_SWF_BLK;
388 spw_ioctl_send->dlen = 8 * NB_BYTES_SWF_BLK;
347 length = TM_LEN_SCI_NORM_SWF_8;
389 length = TM_LEN_SCI_SWF_8;
348 header->auxiliaryHeader[4] = 0x00; // BLK_NR MSB
390 header->blkNr[0] = 0x00; // BLK_NR MSB
349 header->auxiliaryHeader[5] = 0x08; // BLK_NR LSB
391 header->blkNr[1] = 0x08; // BLK_NR LSB
350 }
392 }
351 else {
393 else {
352 spw_ioctl_send->dlen = 340 * NB_BYTES_SWF_BLK;
394 spw_ioctl_send->dlen = 340 * NB_BYTES_SWF_BLK;
353 length = TM_LEN_SCI_NORM_SWF_340;
395 length = TM_LEN_SCI_SWF_340;
354 header->auxiliaryHeader[4] = 0x01; // BLK_NR MSB
396 header->blkNr[0] = 0x01; // BLK_NR MSB
355 header->auxiliaryHeader[5] = 0x54; // BLK_NR LSB
397 header->blkNr[1] = 0x54; // BLK_NR LSB
356 }
357 if (sid == SID_NORM_SWF_F0) {
358 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ];
359 }
398 }
360 else if (sid == SID_NORM_SWF_F1) {
399 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
361 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ];
362 }
363 else if (sid == SID_NORM_SWF_F2) {
364 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ];
365 }
366 else {
367 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
368 }
369 // BUILD THE HEADER
400 // BUILD THE HEADER
370 header->packetLength[0] = (unsigned char) (length>>8);
401 header->packetLength[0] = (unsigned char) (length>>8);
371 header->packetLength[1] = (unsigned char) (length);
402 header->packetLength[1] = (unsigned char) (length);
372 header->auxiliaryHeader[0] = sid; // SID
403 header->sid = (unsigned char) sid; // SID
404 // SET PACKET TIME
405 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
406 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
407 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
408 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
409 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
410 header->time[5] = (unsigned char) (time_management_regs->fine_time);
411 // SEND PACKET
412 status = write_spw(spw_ioctl_send);
413 if (status != RTEMS_SUCCESSFUL) {
414 while (true) {
415 if (status != RTEMS_SUCCESSFUL) {
416 status = write_spw(spw_ioctl_send);
417 //PRINTF1("%d", i)
418 sched_yield();
419 }
420 else {
421 //PRINTF("\n")
422 break;
423 }
424 }
425 }
426 }
427 }
428
429 void send_waveform_CWF( Header_TM_LFR_SCIENCE_CWF_t *header, volatile int *waveform,
430 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send)
431 {
432 unsigned int i = 0;
433 unsigned int length = 0;
434 rtems_status_code status;
435
436 header->sid = (unsigned char) sid;
437
438 for (i=0; i<7; i++) // send waveform
439 {
440 // BUILD THE DATA
441 if (i==6) {
442 spw_ioctl_send->dlen = 8 * NB_BYTES_SWF_BLK;
443 length = TM_LEN_SCI_CWF_8;
444 header->blkNr[0] = 0x00; // BLK_NR MSB
445 header->blkNr[1] = 0x08; // BLK_NR LSB
446 }
447 else {
448 spw_ioctl_send->dlen = 340 * NB_BYTES_SWF_BLK;
449 length = TM_LEN_SCI_CWF_340;
450 header->blkNr[0] = 0x01; // BLK_NR MSB
451 header->blkNr[1] = 0x54; // BLK_NR LSB
452 }
453 spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
454 // BUILD THE HEADER
455 header->packetLength[0] = (unsigned char) (length>>8);
456 header->packetLength[1] = (unsigned char) (length);
373 // SEND PACKET
457 // SEND PACKET
374 status = write_spw(spw_ioctl_send);
458 status = write_spw(spw_ioctl_send);
375 if (status != RTEMS_SUCCESSFUL) {
459 if (status != RTEMS_SUCCESSFUL) {
376 while (true) {
460 while (true) {
377 if (status != RTEMS_SUCCESSFUL) {
461 if (status != RTEMS_SUCCESSFUL) {
378 status = write_spw(spw_ioctl_send);
462 status = write_spw(spw_ioctl_send);
379 //PRINTF1("%d", i)
463 //PRINTF1("%d", i)
380 sched_yield();
464 sched_yield();
381 }
465 }
382 else {
466 else {
383 //PRINTF("\n")
467 //PRINTF("\n")
384 break;
468 break;
385 }
469 }
386 }
470 }
387 }
471 }
388 }
472 }
389 }
473 }
390
474
391 int build_value(int value1, int value0)
475 int build_value(int value1, int value0)
392 {
476 {
393 int aux = 0;
477 int aux = 0;
394 int aux1 = 0;
478 int aux1 = 0;
395 int aux0 = 0;
479 int aux0 = 0;
396 int value1_aux = 0;
480 int value1_aux = 0;
397 int value0_aux = 0;
481 int value0_aux = 0;
398
482
399 value1_aux = value1;
483 value1_aux = value1;
400 value0_aux = value0;
484 value0_aux = value0;
401
485
402 //******
486 //******
403 // B3 B2
487 // B3 B2
404 if (value1_aux > 8191) value1_aux = 8191;
488 if (value1_aux > 8191) value1_aux = 8191;
405 if (value1_aux < -8192) value1_aux = -8192;
489 if (value1_aux < -8192) value1_aux = -8192;
406 aux1 = ( (int) ( ( (unsigned char) (value1_aux / 256 ) ) << 8 ) )
490 aux1 = ( (int) ( ( (unsigned char) (value1_aux / 256 ) ) << 8 ) )
407 + ( (int) ( (unsigned char) (value1_aux ) ) );
491 + ( (int) ( (unsigned char) (value1_aux ) ) );
408
492
409 //******
493 //******
410 // B1 B0
494 // B1 B0
411 if (value0_aux > 8191) value0_aux = 8191;
495 if (value0_aux > 8191) value0_aux = 8191;
412 if (value0_aux < -8192) value0_aux = -8192;
496 if (value0_aux < -8192) value0_aux = -8192;
413 aux0 = ( (int) ( ( (unsigned char) (value0_aux / 256) ) << 8 ) )
497 aux0 = ( (int) ( ( (unsigned char) (value0_aux / 256) ) << 8 ) )
414 + ( (int) ( (unsigned char) (value0_aux ) ) );
498 + ( (int) ( (unsigned char) (value0_aux ) ) );
415
499
416 aux = (aux1 << 16) + aux0;
500 aux = (aux1 << 16) + aux0;
417
501
418 return aux;
502 return aux;
419 }
503 }
420
504
421 void init_waveform_picker_regs()
505 void send_waveform_norm(Header_TM_LFR_SCIENCE_SWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send)
506 {
507 unsigned char lfrMode;
508 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
509
510 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL >> 8);
511 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL);
512 // TIME
513 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
514 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
515 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
516 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
517 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
518 header->time[5] = (unsigned char) (time_management_regs->fine_time);
519
520 //***************
521 // send snapshots
522 // F0
523 send_waveform_SWF( header, wf_snap_f0, SID_NORM_SWF_F0, spw_ioctl_send);
524 // F1
525 if (lfrMode == LFR_MODE_NORMAL) // in SBM1 mode, the snapshot is sent by the send_waveform_sbm1 function
526 {
527 send_waveform_SWF( header, wf_snap_f1, SID_NORM_SWF_F1, spw_ioctl_send);
528 }
529 // F2
530 send_waveform_SWF( header, wf_snap_f2, SID_NORM_SWF_F2, spw_ioctl_send);
531 #ifdef GSA
532 // irq processed, reset the related register of the timer unit
533 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
534 #else
535 // irq processed, reset the related register of the waveform picker
536 if (lfrMode == LFR_MODE_SBM1) {
537 param_local.local_sbm1_nb_cwf_sent = 0;
538 // after the first transmission of the swf at F1, the period is set to local_sbm1_nb_cwf_max
539 param_local.local_sbm1_nb_cwf_max = 2 * param_norm.sy_lfr_n_swf_p;
540 }
541 else if (lfrMode == LFR_MODE_SBM2) {
542 param_local.local_sbm2_nb_cwf_sent = 0;
543 // after the first transmission of the swf at F2, the period is set to local_sbm2_nb_cwf_max
544 param_local.local_sbm2_nb_cwf_max = param_norm.sy_lfr_n_swf_p / 8;
545 }
546 else {
547 waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
548 waveform_picker_regs->burst_enable = 0x07; // [0111] enable f2 f1 f0
549 }
550
551 #endif
552 }
553
554 void send_waveform_burst(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send)
422 {
555 {
423 set_data_shaping_parameters(param_common.sy_lfr_common1);
556 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2 >> 8);
557 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2);
558 // TIME
559 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
560 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
561 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
562 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
563 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
564 header->time[5] = (unsigned char) (time_management_regs->fine_time);
565 // ACQUISITION TIME
566
567 // F2
568 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
569 send_waveform_CWF( header, wf_snap_f2_bis, SID_BURST_CWF_F2, spw_ioctl_send);
570 }
571 else {
572 send_waveform_CWF( header, wf_snap_f2, SID_BURST_CWF_F2, spw_ioctl_send);
573 }
574 }
575
576 void send_waveform_sbm1(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send)
577 {
578 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2 >> 8);
579 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2);
580 // TIME
581 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
582 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
583 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
584 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
585 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
586 header->time[5] = (unsigned char) (time_management_regs->fine_time);
587
588 // F1
589 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
590 send_waveform_CWF( header, wf_snap_f1_bis, SID_SBM1_CWF_F1, spw_ioctl_send );
591 }
592 else {
593 send_waveform_CWF( header, wf_snap_f1, SID_SBM1_CWF_F1, spw_ioctl_send );
594 }
595 }
596
597 void send_waveform_sbm2(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send)
598 {
599 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2 >> 8);
600 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2);
601 // TIME
602 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
603 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
604 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
605 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
606 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
607 header->time[5] = (unsigned char) (time_management_regs->fine_time);
608
609 // F2
610 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
611 send_waveform_CWF( header, wf_snap_f2_bis, SID_SBM2_CWF_F2, spw_ioctl_send);
612 }
613 else {
614 send_waveform_CWF( header, wf_snap_f2, SID_SBM2_CWF_F2, spw_ioctl_send);
615 }
616 }
617
618 //**************
619 // wfp registers
620 void set_wfp_data_shaping(unsigned char data_shaping)
621 {
622 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
623 // waveform picker : [R1 R0 SP1 SP0 BW]
624 waveform_picker_regs->data_shaping =
625 ( (data_shaping & 0x10) >> 4 ) // BW
626 + ( (data_shaping & 0x08) >> 2 ) // SP0
627 + ( (data_shaping & 0x04) ) // SP1
628 + ( (data_shaping & 0x02) << 2 ) // R0
629 + ( (data_shaping & 0x01) << 4 ); // R1
630 }
631
632 void set_wfp_delta_snapshot(unsigned int delta_snapshot)
633 {
634 unsigned char aux = 0;
635 aux = delta_snapshot / 2 ;
636 waveform_picker_regs->delta_snapshot = aux; // max 2 bytes
637 //waveform_picker_regs->delta_snapshot = 0x5; // max 2 bytes
638 }
639
640 void reset_wfp_burst_enable()
641 {
424 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
642 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
425 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
643 }
426 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
644
427 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
645 void reset_wfp_regs()
428 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
646 {
647 set_wfp_data_shaping(param_common.sy_lfr_common1);
648 reset_wfp_burst_enable();
649 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
650 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
651 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
652 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
429 waveform_picker_regs->status = 0x00; //
653 waveform_picker_regs->status = 0x00; //
430 waveform_picker_regs->delta_snapshot = 0x5; // max 2 bytes
654 set_wfp_delta_snapshot( param_norm.sy_lfr_n_swf_p ); // time in seconds between two snapshots
431 waveform_picker_regs->delta_f2_f1 = 0xffff; // max 4 bytes
655 waveform_picker_regs->delta_f2_f1 = 0xffff; // max 4 bytes
432 waveform_picker_regs->delta_f2_f0 = 0x17c00; // max 5 bytes
656 waveform_picker_regs->delta_f2_f0 = 0x17c00; // max 5 bytes
433 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
657 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
434 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
658 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
435 //waveform_picker_regs->delta_snapshot = 0x2; // max 2 bytes, = period / 2
659 //waveform_picker_regs->delta_snapshot = 0x2; // max 2 bytes, = period / 2
436 //waveform_picker_regs->delta_f2_f1 = 0x2d00; // max 4 bytes
660 //waveform_picker_regs->delta_f2_f1 = 0x2d00; // max 4 bytes
437 //waveform_picker_regs->delta_f2_f0 = 0x2f80; // max 5 bytes
661 //waveform_picker_regs->delta_f2_f0 = 0x2f80; // max 5 bytes
438 //waveform_picker_regs->nb_burst_available = 0x30; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
662 //waveform_picker_regs->nb_burst_available = 0x30; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
439 //waveform_picker_regs->nb_snapshot_param = 0xff; // max 3 octets, 256 - 1
663 //waveform_picker_regs->nb_snapshot_param = 0xff; // max 3 octets, 256 - 1
440 }
664 }
441
442 void set_data_shaping_parameters(unsigned char parameters)
443 {
444 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
445 // waveform picker : [R1 R0 SP1 SP0 BW]
446 waveform_picker_regs->data_shaping =
447 ( (parameters & 0x10) >> 4 ) // BW
448 + ( (parameters & 0x08) >> 2 ) // SP0
449 + ( (parameters & 0x04) ) // SP1
450 + ( (parameters & 0x02) << 2 ) // R0
451 + ( (parameters & 0x01) << 4 ); // R1
452 }
General Comments 0
You need to be logged in to leave comments. Login now