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