@@ -1,243 +1,243 | |||||
1 | ############################################################################# |
|
1 | ############################################################################# | |
2 | # Makefile for building: bin/fsw |
|
2 | # Makefile for building: bin/fsw | |
3 |
# Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 17 1 |
|
3 | # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Oct 17 13:22:13 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=1 |
|
13 | DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=16 -DPRINT_MESSAGES_ON_CONSOLE | |
14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
14 | CFLAGS = -pipe -O3 -Wall $(DEFINES) | |
15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) |
|
15 | CXXFLAGS = -pipe -O3 -Wall $(DEFINES) | |
16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header |
|
16 | INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header | |
17 | LINK = sparc-rtems-g++ |
|
17 | LINK = sparc-rtems-g++ | |
18 | LFLAGS = |
|
18 | LFLAGS = | |
19 | LIBS = $(SUBLIBS) |
|
19 | LIBS = $(SUBLIBS) | |
20 | AR = sparc-rtems-ar rcs |
|
20 | AR = sparc-rtems-ar rcs | |
21 | RANLIB = |
|
21 | RANLIB = | |
22 | QMAKE = /usr/bin/qmake-qt4 |
|
22 | QMAKE = /usr/bin/qmake-qt4 | |
23 | TAR = tar -cf |
|
23 | TAR = tar -cf | |
24 | COMPRESS = gzip -9f |
|
24 | COMPRESS = gzip -9f | |
25 | COPY = cp -f |
|
25 | COPY = cp -f | |
26 | SED = sed |
|
26 | SED = sed | |
27 | COPY_FILE = $(COPY) |
|
27 | COPY_FILE = $(COPY) | |
28 | COPY_DIR = $(COPY) -r |
|
28 | COPY_DIR = $(COPY) -r | |
29 | STRIP = sparc-rtems-strip |
|
29 | STRIP = sparc-rtems-strip | |
30 | INSTALL_FILE = install -m 644 -p |
|
30 | INSTALL_FILE = install -m 644 -p | |
31 | INSTALL_DIR = $(COPY_DIR) |
|
31 | INSTALL_DIR = $(COPY_DIR) | |
32 | INSTALL_PROGRAM = install -m 755 -p |
|
32 | INSTALL_PROGRAM = install -m 755 -p | |
33 | DEL_FILE = rm -f |
|
33 | DEL_FILE = rm -f | |
34 | SYMLINK = ln -f -s |
|
34 | SYMLINK = ln -f -s | |
35 | DEL_DIR = rmdir |
|
35 | DEL_DIR = rmdir | |
36 | MOVE = mv -f |
|
36 | MOVE = mv -f | |
37 | CHK_DIR_EXISTS= test -d |
|
37 | CHK_DIR_EXISTS= test -d | |
38 | MKDIR = mkdir -p |
|
38 | MKDIR = mkdir -p | |
39 |
|
39 | |||
40 | ####### Output directory |
|
40 | ####### Output directory | |
41 |
|
41 | |||
42 | OBJECTS_DIR = obj/ |
|
42 | OBJECTS_DIR = obj/ | |
43 |
|
43 | |||
44 | ####### Files |
|
44 | ####### Files | |
45 |
|
45 | |||
46 | SOURCES = ../src/wf_handler.c \ |
|
46 | SOURCES = ../src/wf_handler.c \ | |
47 | ../src/tc_handler.c \ |
|
47 | ../src/tc_handler.c \ | |
48 | ../src/fsw_processing.c \ |
|
48 | ../src/fsw_processing.c \ | |
49 | ../src/fsw_misc.c \ |
|
49 | ../src/fsw_misc.c \ | |
50 | ../src/fsw_init.c \ |
|
50 | ../src/fsw_init.c \ | |
51 | ../src/fsw_globals.c \ |
|
51 | ../src/fsw_globals.c \ | |
52 | ../src/fsw_spacewire.c \ |
|
52 | ../src/fsw_spacewire.c \ | |
53 | ../src/tc_load_dump_parameters.c \ |
|
53 | ../src/tc_load_dump_parameters.c \ | |
54 | ../src/tm_lfr_tc_exe.c |
|
54 | ../src/tm_lfr_tc_exe.c | |
55 | OBJECTS = obj/wf_handler.o \ |
|
55 | OBJECTS = obj/wf_handler.o \ | |
56 | obj/tc_handler.o \ |
|
56 | obj/tc_handler.o \ | |
57 | obj/fsw_processing.o \ |
|
57 | obj/fsw_processing.o \ | |
58 | obj/fsw_misc.o \ |
|
58 | obj/fsw_misc.o \ | |
59 | obj/fsw_init.o \ |
|
59 | obj/fsw_init.o \ | |
60 | obj/fsw_globals.o \ |
|
60 | obj/fsw_globals.o \ | |
61 | obj/fsw_spacewire.o \ |
|
61 | obj/fsw_spacewire.o \ | |
62 | obj/tc_load_dump_parameters.o \ |
|
62 | obj/tc_load_dump_parameters.o \ | |
63 | obj/tm_lfr_tc_exe.o |
|
63 | obj/tm_lfr_tc_exe.o | |
64 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
64 | DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \ | |
65 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
65 | /usr/lib64/qt4/mkspecs/common/linux.conf \ | |
66 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
66 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ | |
67 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
67 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ | |
68 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
68 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ | |
69 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
69 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ | |
70 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
70 | /usr/lib64/qt4/mkspecs/qconfig.pri \ | |
71 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
71 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ | |
72 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
72 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ | |
73 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
73 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ | |
74 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
74 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ | |
75 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
75 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ | |
76 | sparc.pri \ |
|
76 | sparc.pri \ | |
77 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
77 | /usr/lib64/qt4/mkspecs/features/release.prf \ | |
78 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
78 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ | |
79 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
79 | /usr/lib64/qt4/mkspecs/features/shared.prf \ | |
80 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
80 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ | |
81 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
81 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ | |
82 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
82 | /usr/lib64/qt4/mkspecs/features/resources.prf \ | |
83 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
83 | /usr/lib64/qt4/mkspecs/features/uic.prf \ | |
84 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
84 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ | |
85 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
85 | /usr/lib64/qt4/mkspecs/features/lex.prf \ | |
86 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ |
|
86 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ | |
87 | fsw-qt.pro |
|
87 | fsw-qt.pro | |
88 | QMAKE_TARGET = fsw |
|
88 | QMAKE_TARGET = fsw | |
89 | DESTDIR = bin/ |
|
89 | DESTDIR = bin/ | |
90 | TARGET = bin/fsw |
|
90 | TARGET = bin/fsw | |
91 |
|
91 | |||
92 | first: all |
|
92 | first: all | |
93 | ####### Implicit rules |
|
93 | ####### Implicit rules | |
94 |
|
94 | |||
95 | .SUFFIXES: .o .c .cpp .cc .cxx .C |
|
95 | .SUFFIXES: .o .c .cpp .cc .cxx .C | |
96 |
|
96 | |||
97 | .cpp.o: |
|
97 | .cpp.o: | |
98 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
98 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
99 |
|
99 | |||
100 | .cc.o: |
|
100 | .cc.o: | |
101 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
101 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
102 |
|
102 | |||
103 | .cxx.o: |
|
103 | .cxx.o: | |
104 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
104 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
105 |
|
105 | |||
106 | .C.o: |
|
106 | .C.o: | |
107 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" |
|
107 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" | |
108 |
|
108 | |||
109 | .c.o: |
|
109 | .c.o: | |
110 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" |
|
110 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" | |
111 |
|
111 | |||
112 | ####### Build rules |
|
112 | ####### Build rules | |
113 |
|
113 | |||
114 | all: Makefile $(TARGET) |
|
114 | all: Makefile $(TARGET) | |
115 |
|
115 | |||
116 | $(TARGET): $(OBJECTS) |
|
116 | $(TARGET): $(OBJECTS) | |
117 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ |
|
117 | @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/ | |
118 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) |
|
118 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) | |
119 |
|
119 | |||
120 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ |
|
120 | Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \ | |
121 | /usr/lib64/qt4/mkspecs/common/linux.conf \ |
|
121 | /usr/lib64/qt4/mkspecs/common/linux.conf \ | |
122 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ |
|
122 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf \ | |
123 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ |
|
123 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \ | |
124 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ |
|
124 | /usr/lib64/qt4/mkspecs/common/g++-base.conf \ | |
125 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ |
|
125 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf \ | |
126 | /usr/lib64/qt4/mkspecs/qconfig.pri \ |
|
126 | /usr/lib64/qt4/mkspecs/qconfig.pri \ | |
127 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ |
|
127 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \ | |
128 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ |
|
128 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf \ | |
129 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ |
|
129 | /usr/lib64/qt4/mkspecs/features/qt_config.prf \ | |
130 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ |
|
130 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \ | |
131 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ |
|
131 | /usr/lib64/qt4/mkspecs/features/default_pre.prf \ | |
132 | sparc.pri \ |
|
132 | sparc.pri \ | |
133 | /usr/lib64/qt4/mkspecs/features/release.prf \ |
|
133 | /usr/lib64/qt4/mkspecs/features/release.prf \ | |
134 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ |
|
134 | /usr/lib64/qt4/mkspecs/features/default_post.prf \ | |
135 | /usr/lib64/qt4/mkspecs/features/shared.prf \ |
|
135 | /usr/lib64/qt4/mkspecs/features/shared.prf \ | |
136 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ |
|
136 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ | |
137 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ |
|
137 | /usr/lib64/qt4/mkspecs/features/warn_on.prf \ | |
138 | /usr/lib64/qt4/mkspecs/features/resources.prf \ |
|
138 | /usr/lib64/qt4/mkspecs/features/resources.prf \ | |
139 | /usr/lib64/qt4/mkspecs/features/uic.prf \ |
|
139 | /usr/lib64/qt4/mkspecs/features/uic.prf \ | |
140 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ |
|
140 | /usr/lib64/qt4/mkspecs/features/yacc.prf \ | |
141 | /usr/lib64/qt4/mkspecs/features/lex.prf \ |
|
141 | /usr/lib64/qt4/mkspecs/features/lex.prf \ | |
142 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf |
|
142 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf | |
143 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
143 | $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro | |
144 | /usr/lib64/qt4/mkspecs/common/unix.conf: |
|
144 | /usr/lib64/qt4/mkspecs/common/unix.conf: | |
145 | /usr/lib64/qt4/mkspecs/common/linux.conf: |
|
145 | /usr/lib64/qt4/mkspecs/common/linux.conf: | |
146 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: |
|
146 | /usr/lib64/qt4/mkspecs/common/gcc-base.conf: | |
147 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: |
|
147 | /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf: | |
148 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: |
|
148 | /usr/lib64/qt4/mkspecs/common/g++-base.conf: | |
149 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: |
|
149 | /usr/lib64/qt4/mkspecs/common/g++-unix.conf: | |
150 | /usr/lib64/qt4/mkspecs/qconfig.pri: |
|
150 | /usr/lib64/qt4/mkspecs/qconfig.pri: | |
151 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: |
|
151 | /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri: | |
152 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: |
|
152 | /usr/lib64/qt4/mkspecs/features/qt_functions.prf: | |
153 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: |
|
153 | /usr/lib64/qt4/mkspecs/features/qt_config.prf: | |
154 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: |
|
154 | /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf: | |
155 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: |
|
155 | /usr/lib64/qt4/mkspecs/features/default_pre.prf: | |
156 | sparc.pri: |
|
156 | sparc.pri: | |
157 | /usr/lib64/qt4/mkspecs/features/release.prf: |
|
157 | /usr/lib64/qt4/mkspecs/features/release.prf: | |
158 | /usr/lib64/qt4/mkspecs/features/default_post.prf: |
|
158 | /usr/lib64/qt4/mkspecs/features/default_post.prf: | |
159 | /usr/lib64/qt4/mkspecs/features/shared.prf: |
|
159 | /usr/lib64/qt4/mkspecs/features/shared.prf: | |
160 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: |
|
160 | /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: | |
161 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: |
|
161 | /usr/lib64/qt4/mkspecs/features/warn_on.prf: | |
162 | /usr/lib64/qt4/mkspecs/features/resources.prf: |
|
162 | /usr/lib64/qt4/mkspecs/features/resources.prf: | |
163 | /usr/lib64/qt4/mkspecs/features/uic.prf: |
|
163 | /usr/lib64/qt4/mkspecs/features/uic.prf: | |
164 | /usr/lib64/qt4/mkspecs/features/yacc.prf: |
|
164 | /usr/lib64/qt4/mkspecs/features/yacc.prf: | |
165 | /usr/lib64/qt4/mkspecs/features/lex.prf: |
|
165 | /usr/lib64/qt4/mkspecs/features/lex.prf: | |
166 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: |
|
166 | /usr/lib64/qt4/mkspecs/features/include_source_dir.prf: | |
167 | qmake: FORCE |
|
167 | qmake: FORCE | |
168 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro |
|
168 | @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro | |
169 |
|
169 | |||
170 | dist: |
|
170 | dist: | |
171 | @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 |
|
171 | @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 | |
172 | $(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 |
|
172 | $(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 | |
173 |
|
173 | |||
174 |
|
174 | |||
175 | clean:compiler_clean |
|
175 | clean:compiler_clean | |
176 | -$(DEL_FILE) $(OBJECTS) |
|
176 | -$(DEL_FILE) $(OBJECTS) | |
177 | -$(DEL_FILE) *~ core *.core |
|
177 | -$(DEL_FILE) *~ core *.core | |
178 |
|
178 | |||
179 |
|
179 | |||
180 | ####### Sub-libraries |
|
180 | ####### Sub-libraries | |
181 |
|
181 | |||
182 | distclean: clean |
|
182 | distclean: clean | |
183 | -$(DEL_FILE) $(TARGET) |
|
183 | -$(DEL_FILE) $(TARGET) | |
184 | -$(DEL_FILE) Makefile |
|
184 | -$(DEL_FILE) Makefile | |
185 |
|
185 | |||
186 |
|
186 | |||
187 | grmon: |
|
187 | grmon: | |
188 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u |
|
188 | cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u | |
189 |
|
189 | |||
190 | check: first |
|
190 | check: first | |
191 |
|
191 | |||
192 | compiler_rcc_make_all: |
|
192 | compiler_rcc_make_all: | |
193 | compiler_rcc_clean: |
|
193 | compiler_rcc_clean: | |
194 | compiler_uic_make_all: |
|
194 | compiler_uic_make_all: | |
195 | compiler_uic_clean: |
|
195 | compiler_uic_clean: | |
196 | compiler_image_collection_make_all: qmake_image_collection.cpp |
|
196 | compiler_image_collection_make_all: qmake_image_collection.cpp | |
197 | compiler_image_collection_clean: |
|
197 | compiler_image_collection_clean: | |
198 | -$(DEL_FILE) qmake_image_collection.cpp |
|
198 | -$(DEL_FILE) qmake_image_collection.cpp | |
199 | compiler_yacc_decl_make_all: |
|
199 | compiler_yacc_decl_make_all: | |
200 | compiler_yacc_decl_clean: |
|
200 | compiler_yacc_decl_clean: | |
201 | compiler_yacc_impl_make_all: |
|
201 | compiler_yacc_impl_make_all: | |
202 | compiler_yacc_impl_clean: |
|
202 | compiler_yacc_impl_clean: | |
203 | compiler_lex_make_all: |
|
203 | compiler_lex_make_all: | |
204 | compiler_lex_clean: |
|
204 | compiler_lex_clean: | |
205 | compiler_clean: |
|
205 | compiler_clean: | |
206 |
|
206 | |||
207 | ####### Compile |
|
207 | ####### Compile | |
208 |
|
208 | |||
209 | obj/wf_handler.o: ../src/wf_handler.c |
|
209 | obj/wf_handler.o: ../src/wf_handler.c | |
210 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c |
|
210 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c | |
211 |
|
211 | |||
212 | obj/tc_handler.o: ../src/tc_handler.c |
|
212 | obj/tc_handler.o: ../src/tc_handler.c | |
213 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c |
|
213 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c | |
214 |
|
214 | |||
215 | obj/fsw_processing.o: ../src/fsw_processing.c |
|
215 | obj/fsw_processing.o: ../src/fsw_processing.c | |
216 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c |
|
216 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c | |
217 |
|
217 | |||
218 | obj/fsw_misc.o: ../src/fsw_misc.c |
|
218 | obj/fsw_misc.o: ../src/fsw_misc.c | |
219 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c |
|
219 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c | |
220 |
|
220 | |||
221 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c |
|
221 | obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c | |
222 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c |
|
222 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c | |
223 |
|
223 | |||
224 | obj/fsw_globals.o: ../src/fsw_globals.c |
|
224 | obj/fsw_globals.o: ../src/fsw_globals.c | |
225 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c |
|
225 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c | |
226 |
|
226 | |||
227 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c |
|
227 | obj/fsw_spacewire.o: ../src/fsw_spacewire.c | |
228 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c |
|
228 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c | |
229 |
|
229 | |||
230 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c |
|
230 | obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c | |
231 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c |
|
231 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c | |
232 |
|
232 | |||
233 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c |
|
233 | obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c | |
234 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c |
|
234 | $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c | |
235 |
|
235 | |||
236 | ####### Install |
|
236 | ####### Install | |
237 |
|
237 | |||
238 | install: FORCE |
|
238 | install: FORCE | |
239 |
|
239 | |||
240 | uninstall: FORCE |
|
240 | uninstall: FORCE | |
241 |
|
241 | |||
242 | FORCE: |
|
242 | FORCE: | |
243 |
|
243 |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,71 +1,71 | |||||
1 | TEMPLATE = app |
|
1 | TEMPLATE = app | |
2 | # CONFIG += console v8 sim |
|
2 | # CONFIG += console v8 sim | |
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa |
|
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa | |
4 | CONFIG += console verbose |
|
4 | CONFIG += console verbose | |
5 | CONFIG -= qt |
|
5 | CONFIG -= qt | |
6 |
|
6 | |||
7 | include(./sparc.pri) |
|
7 | include(./sparc.pri) | |
8 |
|
8 | |||
9 | # flight software version |
|
9 | # flight software version | |
10 |
SWVERSION=-0-1 |
|
10 | SWVERSION=-0-16 | |
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=1 |
|
14 | DEFINES += SW_VERSION_N4=16 | |
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 | contains( CONFIG, stack_report ) { |
|
24 | contains( CONFIG, stack_report ) { | |
25 | DEFINES += PRINT_STACK_REPORT |
|
25 | DEFINES += PRINT_STACK_REPORT | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | contains( CONFIG, boot_messages ) { |
|
28 | contains( CONFIG, boot_messages ) { | |
29 | DEFINES += BOOT_MESSAGES |
|
29 | DEFINES += BOOT_MESSAGES | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | #doxygen.target = doxygen |
|
32 | #doxygen.target = doxygen | |
33 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
33 | #doxygen.commands = doxygen ../doc/Doxyfile | |
34 | #QMAKE_EXTRA_TARGETS += doxygen |
|
34 | #QMAKE_EXTRA_TARGETS += doxygen | |
35 |
|
35 | |||
36 | TARGET = fsw |
|
36 | TARGET = fsw | |
37 | contains( CONFIG, gsa ) { |
|
37 | contains( CONFIG, gsa ) { | |
38 | DEFINES += GSA |
|
38 | DEFINES += GSA | |
39 | TARGET = fsw-gsa |
|
39 | TARGET = fsw-gsa | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | INCLUDEPATH += \ |
|
42 | INCLUDEPATH += \ | |
43 | ../src \ |
|
43 | ../src \ | |
44 | ../header |
|
44 | ../header | |
45 |
|
45 | |||
46 | SOURCES += \ |
|
46 | SOURCES += \ | |
47 | ../src/wf_handler.c \ |
|
47 | ../src/wf_handler.c \ | |
48 | ../src/tc_handler.c \ |
|
48 | ../src/tc_handler.c \ | |
49 | ../src/fsw_processing.c \ |
|
49 | ../src/fsw_processing.c \ | |
50 | ../src/fsw_misc.c \ |
|
50 | ../src/fsw_misc.c \ | |
51 | ../src/fsw_init.c \ |
|
51 | ../src/fsw_init.c \ | |
52 | ../src/fsw_globals.c \ |
|
52 | ../src/fsw_globals.c \ | |
53 | ../src/fsw_spacewire.c \ |
|
53 | ../src/fsw_spacewire.c \ | |
54 | ../src/tc_load_dump_parameters.c \ |
|
54 | ../src/tc_load_dump_parameters.c \ | |
55 | ../src/tm_lfr_tc_exe.c |
|
55 | ../src/tm_lfr_tc_exe.c | |
56 |
|
56 | |||
57 | HEADERS += \ |
|
57 | HEADERS += \ | |
58 | ../header/wf_handler.h \ |
|
58 | ../header/wf_handler.h \ | |
59 | ../header/tc_handler.h \ |
|
59 | ../header/tc_handler.h \ | |
60 | ../header/grlib_regs.h \ |
|
60 | ../header/grlib_regs.h \ | |
61 | ../header/fsw_processing.h \ |
|
61 | ../header/fsw_processing.h \ | |
62 | ../header/fsw_params.h \ |
|
62 | ../header/fsw_params.h \ | |
63 | ../header/fsw_misc.h \ |
|
63 | ../header/fsw_misc.h \ | |
64 | ../header/fsw_init.h \ |
|
64 | ../header/fsw_init.h \ | |
65 | ../header/ccsds_types.h \ |
|
65 | ../header/ccsds_types.h \ | |
66 | ../header/fsw_params_processing.h \ |
|
66 | ../header/fsw_params_processing.h \ | |
67 | ../header/fsw_spacewire.h \ |
|
67 | ../header/fsw_spacewire.h \ | |
68 | ../header/tm_byte_positions.h \ |
|
68 | ../header/tm_byte_positions.h \ | |
69 | ../header/tc_load_dump_parameters.h \ |
|
69 | ../header/tc_load_dump_parameters.h \ | |
70 | ../header/tm_lfr_tc_exe |
|
70 | ../header/tm_lfr_tc_exe.h | |
71 |
|
71 |
@@ -1,225 +1,225 | |||||
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 "grlib_regs.h" |
|
4 | #include "grlib_regs.h" | |
5 | #include "fsw_params_processing.h" |
|
5 | #include "fsw_params_processing.h" | |
6 | #include "tm_byte_positions.h" |
|
6 | #include "tm_byte_positions.h" | |
7 | #include "ccsds_types.h" |
|
7 | #include "ccsds_types.h" | |
8 |
|
8 | |||
9 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
9 | #define GRSPW_DEVICE_NAME "/dev/grspw0" | |
10 | #define UART_DEVICE_NAME "/dev/console" |
|
10 | #define UART_DEVICE_NAME "/dev/console" | |
11 |
|
11 | |||
12 | //************************ |
|
12 | //************************ | |
13 | // flight software version |
|
13 | // flight software version | |
14 | // this parameters is handled by the Qt project options |
|
14 | // this parameters is handled by the Qt project options | |
15 |
|
15 | |||
16 | //********** |
|
16 | //********** | |
17 | // LFR MODES |
|
17 | // LFR MODES | |
18 | #define LFR_MODE_STANDBY 0 |
|
18 | #define LFR_MODE_STANDBY 0 | |
19 | #define LFR_MODE_NORMAL 1 |
|
19 | #define LFR_MODE_NORMAL 1 | |
20 | #define LFR_MODE_BURST 2 |
|
20 | #define LFR_MODE_BURST 2 | |
21 | #define LFR_MODE_SBM1 3 |
|
21 | #define LFR_MODE_SBM1 3 | |
22 | #define LFR_MODE_SBM2 4 |
|
22 | #define LFR_MODE_SBM2 4 | |
23 | #define LFR_MODE_NORMAL_CWF_F3 5 |
|
23 | #define LFR_MODE_NORMAL_CWF_F3 5 | |
24 |
|
24 | |||
25 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 |
|
25 | #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0 | |
26 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 |
|
26 | #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1 | |
27 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 |
|
27 | #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2 | |
28 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 |
|
28 | #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3 | |
29 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 |
|
29 | #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4 | |
30 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 |
|
30 | #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5 | |
31 |
|
31 | |||
32 | //**************************** |
|
32 | //**************************** | |
33 | // LFR DEFAULT MODE PARAMETERS |
|
33 | // LFR DEFAULT MODE PARAMETERS | |
34 | // COMMON |
|
34 | // COMMON | |
35 | #define DEFAULT_SY_LFR_COMMON0 0x00 |
|
35 | #define DEFAULT_SY_LFR_COMMON0 0x00 | |
36 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 |
|
36 | #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0 | |
37 | // NORM |
|
37 | // NORM | |
38 | #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample |
|
38 | #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample | |
39 | #define DEFAULT_SY_LFR_N_SWF_P 16 // sec |
|
39 | #define DEFAULT_SY_LFR_N_SWF_P 16 // sec | |
40 | #define DEFAULT_SY_LFR_N_ASM_P 16 // sec |
|
40 | #define DEFAULT_SY_LFR_N_ASM_P 16 // sec | |
41 | #define DEFAULT_SY_LFR_N_BP_P0 4 // sec |
|
41 | #define DEFAULT_SY_LFR_N_BP_P0 4 // sec | |
42 | #define DEFAULT_SY_LFR_N_BP_P1 20 // sec |
|
42 | #define DEFAULT_SY_LFR_N_BP_P1 20 // sec | |
43 | #define MIN_DELTA_SNAPSHOT 16 // sec |
|
43 | #define MIN_DELTA_SNAPSHOT 16 // sec | |
44 | // BURST |
|
44 | // BURST | |
45 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec |
|
45 | #define DEFAULT_SY_LFR_B_BP_P0 1 // sec | |
46 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec |
|
46 | #define DEFAULT_SY_LFR_B_BP_P1 5 // sec | |
47 | // SBM1 |
|
47 | // SBM1 | |
48 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec |
|
48 | #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec | |
49 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec |
|
49 | #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec | |
50 | // SBM2 |
|
50 | // SBM2 | |
51 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec |
|
51 | #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec | |
52 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec |
|
52 | #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec | |
53 | // ADDITIONAL PARAMETERS |
|
53 | // ADDITIONAL PARAMETERS | |
54 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms |
|
54 | #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms | |
55 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s |
|
55 | #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s | |
56 | // |
|
56 | // | |
57 | //**************************** |
|
57 | //**************************** | |
58 |
|
58 | |||
59 | //***************************** |
|
59 | //***************************** | |
60 | // APB REGISTERS BASE ADDRESSES |
|
60 | // APB REGISTERS BASE ADDRESSES | |
61 | #define REGS_ADDR_APBUART 0x80000100 |
|
61 | #define REGS_ADDR_APBUART 0x80000100 | |
62 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
62 | #define REGS_ADDR_GPTIMER 0x80000300 | |
63 | #define REGS_ADDR_GRSPW 0x80000500 |
|
63 | #define REGS_ADDR_GRSPW 0x80000500 | |
64 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
64 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 | |
65 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 |
|
65 | #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 | |
66 |
|
66 | |||
67 | #ifdef GSA |
|
67 | #ifdef GSA | |
68 | #else |
|
68 | #else | |
69 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 |
|
69 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 | |
70 | #endif |
|
70 | #endif | |
71 |
|
71 | |||
72 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
72 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff | |
73 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) |
|
73 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) | |
74 |
|
74 | |||
75 | //********** |
|
75 | //********** | |
76 | // IRQ LINES |
|
76 | // IRQ LINES | |
77 | #define IRQ_SM 9 |
|
77 | #define IRQ_SM 9 | |
78 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
78 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels | |
79 | #define IRQ_WF 10 |
|
79 | #define IRQ_WF 10 | |
80 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels |
|
80 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels | |
81 | #define IRQ_TIME1 12 |
|
81 | #define IRQ_TIME1 12 | |
82 | #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels |
|
82 | #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels | |
83 | #define IRQ_TIME2 13 |
|
83 | #define IRQ_TIME2 13 | |
84 | #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels |
|
84 | #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels | |
85 | #define IRQ_WAVEFORM_PICKER 14 |
|
85 | #define IRQ_WAVEFORM_PICKER 14 | |
86 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels |
|
86 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels | |
87 | #define IRQ_SPECTRAL_MATRIX 6 |
|
87 | #define IRQ_SPECTRAL_MATRIX 6 | |
88 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels |
|
88 | #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels | |
89 |
|
89 | |||
90 | //***** |
|
90 | //***** | |
91 | // TIME |
|
91 | // TIME | |
92 | #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms |
|
92 | #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms | |
93 | #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s |
|
93 | #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s | |
94 | #define TIMER_SM_SIMULATOR 1 |
|
94 | #define TIMER_SM_SIMULATOR 1 | |
95 | #define TIMER_WF_SIMULATOR 2 |
|
95 | #define TIMER_WF_SIMULATOR 2 | |
96 | #define HK_PERIOD 100 // 100 * 10ms => 1sec |
|
96 | #define HK_PERIOD 100 // 100 * 10ms => 1sec | |
97 |
|
97 | |||
98 | //********** |
|
98 | //********** | |
99 | // LPP CODES |
|
99 | // LPP CODES | |
100 | #define LFR_SUCCESSFUL 0 |
|
100 | #define LFR_SUCCESSFUL 0 | |
101 | #define LFR_DEFAULT 1 |
|
101 | #define LFR_DEFAULT 1 | |
102 |
|
102 | |||
103 | //****** |
|
103 | //****** | |
104 | // RTEMS |
|
104 | // RTEMS | |
105 | #define TASKID_RECV 1 |
|
105 | #define TASKID_RECV 1 | |
106 | #define TASKID_ACTN 2 |
|
106 | #define TASKID_ACTN 2 | |
107 | #define TASKID_SPIQ 3 |
|
107 | #define TASKID_SPIQ 3 | |
108 | #define TASKID_SMIQ 4 |
|
108 | #define TASKID_SMIQ 4 | |
109 | #define TASKID_STAT 5 |
|
109 | #define TASKID_STAT 5 | |
110 | #define TASKID_AVF0 6 |
|
110 | #define TASKID_AVF0 6 | |
111 | #define TASKID_BPF0 7 |
|
111 | #define TASKID_BPF0 7 | |
112 | #define TASKID_WFRM 8 |
|
112 | #define TASKID_WFRM 8 | |
113 | #define TASKID_DUMB 9 |
|
113 | #define TASKID_DUMB 9 | |
114 | #define TASKID_HOUS 10 |
|
114 | #define TASKID_HOUS 10 | |
115 | #define TASKID_MATR 11 |
|
115 | #define TASKID_MATR 11 | |
116 | #define TASKID_CWF3 12 |
|
116 | #define TASKID_CWF3 12 | |
117 | #define TASKID_CWF2 13 |
|
117 | #define TASKID_CWF2 13 | |
118 | #define TASKID_CWF1 14 |
|
118 | #define TASKID_CWF1 14 | |
119 | #define TASKID_SEND 15 |
|
119 | #define TASKID_SEND 15 | |
120 |
|
120 | |||
121 | #define TASK_PRIORITY_SPIQ 5 |
|
121 | #define TASK_PRIORITY_SPIQ 5 | |
122 | #define TASK_PRIORITY_SMIQ 10 |
|
122 | #define TASK_PRIORITY_SMIQ 10 | |
123 | // |
|
123 | // | |
124 | #define TASK_PRIORITY_RECV 20 |
|
124 | #define TASK_PRIORITY_RECV 20 | |
125 | #define TASK_PRIORITY_ACTN 30 |
|
125 | #define TASK_PRIORITY_ACTN 30 | |
126 | // |
|
126 | // | |
127 | #define TASK_PRIORITY_HOUS 40 |
|
127 | #define TASK_PRIORITY_HOUS 40 | |
128 | #define TASK_PRIORITY_CWF1 40 |
|
128 | #define TASK_PRIORITY_CWF1 40 | |
129 | #define TASK_PRIORITY_CWF2 40 |
|
129 | #define TASK_PRIORITY_CWF2 40 | |
130 | #define TASK_PRIORITY_WFRM 40 |
|
130 | #define TASK_PRIORITY_WFRM 40 | |
131 | #define TASK_PRIORITY_CWF3 40 |
|
131 | #define TASK_PRIORITY_CWF3 40 | |
132 | // |
|
132 | // | |
133 | #define TASK_PRIORITY_SEND 40 |
|
133 | #define TASK_PRIORITY_SEND 40 | |
134 | // |
|
134 | // | |
135 | #define TASK_PRIORITY_AVF0 60 |
|
135 | #define TASK_PRIORITY_AVF0 60 | |
136 | #define TASK_PRIORITY_BPF0 60 |
|
136 | #define TASK_PRIORITY_BPF0 60 | |
137 | #define TASK_PRIORITY_MATR 100 |
|
137 | #define TASK_PRIORITY_MATR 100 | |
138 | #define TASK_PRIORITY_STAT 200 |
|
138 | #define TASK_PRIORITY_STAT 200 | |
139 | #define TASK_PRIORITY_DUMB 200 |
|
139 | #define TASK_PRIORITY_DUMB 200 | |
140 |
|
140 | |||
141 | #define ACTION_MSG_QUEUE_COUNT 10 |
|
141 | #define ACTION_MSG_QUEUE_COUNT 10 | |
142 | #define ACTION_MSG_PKTS_COUNT 50 |
|
142 | #define ACTION_MSG_PKTS_COUNT 50 | |
143 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) |
|
143 | #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES) | |
144 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options |
|
144 | #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options | |
145 |
|
145 | |||
146 |
#define QUEUE_ |
|
146 | #define QUEUE_RECV 0 | |
147 |
#define QUEUE_ |
|
147 | #define QUEUE_SEND 1 | |
148 |
|
148 | |||
149 | //******* |
|
149 | //******* | |
150 | // MACROS |
|
150 | // MACROS | |
151 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
151 | #ifdef PRINT_MESSAGES_ON_CONSOLE | |
152 | #define PRINTF(x) printf(x); |
|
152 | #define PRINTF(x) printf(x); | |
153 | #define PRINTF1(x,y) printf(x,y); |
|
153 | #define PRINTF1(x,y) printf(x,y); | |
154 | #define PRINTF2(x,y,z) printf(x,y,z); |
|
154 | #define PRINTF2(x,y,z) printf(x,y,z); | |
155 | #else |
|
155 | #else | |
156 | #define PRINTF(x) ; |
|
156 | #define PRINTF(x) ; | |
157 | #define PRINTF1(x,y) ; |
|
157 | #define PRINTF1(x,y) ; | |
158 | #define PRINTF2(x,y,z) ; |
|
158 | #define PRINTF2(x,y,z) ; | |
159 | #endif |
|
159 | #endif | |
160 |
|
160 | |||
161 | #ifdef BOOT_MESSAGES |
|
161 | #ifdef BOOT_MESSAGES | |
162 | #define BOOT_PRINTF(x) printf(x); |
|
162 | #define BOOT_PRINTF(x) printf(x); | |
163 | #define BOOT_PRINTF1(x,y) printf(x,y); |
|
163 | #define BOOT_PRINTF1(x,y) printf(x,y); | |
164 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); |
|
164 | #define BOOT_PRINTF2(x,y,z) printf(x,y,z); | |
165 | #else |
|
165 | #else | |
166 | #define BOOT_PRINTF(x) ; |
|
166 | #define BOOT_PRINTF(x) ; | |
167 | #define BOOT_PRINTF1(x,y) ; |
|
167 | #define BOOT_PRINTF1(x,y) ; | |
168 | #define BOOT_PRINTF2(x,y,z) ; |
|
168 | #define BOOT_PRINTF2(x,y,z) ; | |
169 | #endif |
|
169 | #endif | |
170 |
|
170 | |||
171 | #ifdef DEBUG_MESSAGES |
|
171 | #ifdef DEBUG_MESSAGES | |
172 | #define DEBUG_PRINTF(x) printf(x); |
|
172 | #define DEBUG_PRINTF(x) printf(x); | |
173 | #define DEBUG_PRINTF1(x,y) printf(x,y); |
|
173 | #define DEBUG_PRINTF1(x,y) printf(x,y); | |
174 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); |
|
174 | #define DEBUG_PRINTF2(x,y,z) printf(x,y,z); | |
175 | #else |
|
175 | #else | |
176 | #define DEBUG_PRINTF(x) ; |
|
176 | #define DEBUG_PRINTF(x) ; | |
177 | #define DEBUG_PRINTF1(x,y) ; |
|
177 | #define DEBUG_PRINTF1(x,y) ; | |
178 | #define DEBUG_PRINTF2(x,y,z) ; |
|
178 | #define DEBUG_PRINTF2(x,y,z) ; | |
179 | #endif |
|
179 | #endif | |
180 |
|
180 | |||
181 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period |
|
181 | #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period | |
182 |
|
182 | |||
183 | #define NB_SAMPLES_PER_SNAPSHOT 2048 |
|
183 | #define NB_SAMPLES_PER_SNAPSHOT 2048 | |
184 | #define TIME_OFFSET 2 |
|
184 | #define TIME_OFFSET 2 | |
185 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 |
|
185 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 | |
186 | #define NB_BYTES_SWF_BLK (2 * 6) |
|
186 | #define NB_BYTES_SWF_BLK (2 * 6) | |
187 | #define NB_WORDS_SWF_BLK 3 |
|
187 | #define NB_WORDS_SWF_BLK 3 | |
188 | #define NB_BYTES_CWF3_LIGHT_BLK 6 |
|
188 | #define NB_BYTES_CWF3_LIGHT_BLK 6 | |
189 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 |
|
189 | #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 | |
190 |
|
190 | |||
191 | //****************** |
|
191 | //****************** | |
192 | // SEQUENCE COUNTERS |
|
192 | // SEQUENCE COUNTERS | |
193 | #define SEQ_CNT_NB_PID 2 |
|
193 | #define SEQ_CNT_NB_PID 2 | |
194 | #define SEQ_CNT_NB_CAT 4 |
|
194 | #define SEQ_CNT_NB_CAT 4 | |
195 | #define SEQ_CNT_NB_DEST_ID 11 |
|
195 | #define SEQ_CNT_NB_DEST_ID 11 | |
196 | // pid |
|
196 | // pid | |
197 | #define SEQ_CNT_PID_76 0 |
|
197 | #define SEQ_CNT_PID_76 0 | |
198 | #define SEQ_CNT_PID_79 1 |
|
198 | #define SEQ_CNT_PID_79 1 | |
199 | //cat |
|
199 | //cat | |
200 | #define SEQ_CNT_CAT_1 0 |
|
200 | #define SEQ_CNT_CAT_1 0 | |
201 | #define SEQ_CNT_CAT_4 1 |
|
201 | #define SEQ_CNT_CAT_4 1 | |
202 | #define SEQ_CNT_CAT_9 2 |
|
202 | #define SEQ_CNT_CAT_9 2 | |
203 | #define SEQ_CNT_CAT_12 3 |
|
203 | #define SEQ_CNT_CAT_12 3 | |
204 | // destination id |
|
204 | // destination id | |
205 | #define SEQ_CNT_DST_ID_GROUND 0 |
|
205 | #define SEQ_CNT_DST_ID_GROUND 0 | |
206 | #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1 |
|
206 | #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1 | |
207 | #define SEQ_CNT_DST_ID_TC_SEQUENCES 2 |
|
207 | #define SEQ_CNT_DST_ID_TC_SEQUENCES 2 | |
208 | #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3 |
|
208 | #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3 | |
209 | #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4 |
|
209 | #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4 | |
210 | #define SEQ_CNT_DST_ID_DIRECT_CMD 5 |
|
210 | #define SEQ_CNT_DST_ID_DIRECT_CMD 5 | |
211 | #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6 |
|
211 | #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6 | |
212 | #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7 |
|
212 | #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7 | |
213 | #define SEQ_CNT_DST_ID_OBCP 8 |
|
213 | #define SEQ_CNT_DST_ID_OBCP 8 | |
214 | #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9 |
|
214 | #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9 | |
215 | #define SEQ_CNT_DST_ID_AOCS 10 |
|
215 | #define SEQ_CNT_DST_ID_AOCS 10 | |
216 |
|
216 | |||
217 | struct param_local_str{ |
|
217 | struct param_local_str{ | |
218 | unsigned int local_sbm1_nb_cwf_sent; |
|
218 | unsigned int local_sbm1_nb_cwf_sent; | |
219 | unsigned int local_sbm1_nb_cwf_max; |
|
219 | unsigned int local_sbm1_nb_cwf_max; | |
220 | unsigned int local_sbm2_nb_cwf_sent; |
|
220 | unsigned int local_sbm2_nb_cwf_sent; | |
221 | unsigned int local_sbm2_nb_cwf_max; |
|
221 | unsigned int local_sbm2_nb_cwf_max; | |
222 | unsigned int local_nb_interrupt_f0_MAX; |
|
222 | unsigned int local_nb_interrupt_f0_MAX; | |
223 | }; |
|
223 | }; | |
224 |
|
224 | |||
225 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
|
225 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
@@ -1,71 +1,71 | |||||
1 | #ifndef TC_HANDLER_H_INCLUDED |
|
1 | #ifndef TC_HANDLER_H_INCLUDED | |
2 | #define TC_HANDLER_H_INCLUDED |
|
2 | #define TC_HANDLER_H_INCLUDED | |
3 |
|
3 | |||
4 | #include "fsw_init.h" |
|
4 | #include "fsw_init.h" | |
5 | #include "tc_load_dump_parameters.h" |
|
5 | #include "tc_load_dump_parameters.h" | |
6 | #include "tm_lfr_tc_exe.h" |
|
6 | #include "tm_lfr_tc_exe.h" | |
7 |
|
7 | |||
8 | // MODE PARAMETERS |
|
8 | // MODE PARAMETERS | |
9 | extern struct param_sbm1_str param_sbm1; |
|
9 | extern struct param_sbm1_str param_sbm1; | |
10 | extern struct param_sbm2_str param_sbm2; |
|
10 | extern struct param_sbm2_str param_sbm2; | |
11 | extern time_management_regs_t *time_management_regs; |
|
11 | extern time_management_regs_t *time_management_regs; | |
12 | extern waveform_picker_regs_t *waveform_picker_regs; |
|
12 | extern waveform_picker_regs_t *waveform_picker_regs; | |
13 | extern gptimer_regs_t *gptimer_regs; |
|
13 | extern gptimer_regs_t *gptimer_regs; | |
14 |
|
14 | |||
15 | //**** |
|
15 | //**** | |
16 | // ISR |
|
16 | // ISR | |
17 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
17 | rtems_isr commutation_isr1( rtems_vector_number vector ); | |
18 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
18 | rtems_isr commutation_isr2( rtems_vector_number vector ); | |
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 | void initLookUpTableForCRC( void ); |
|
23 | void initLookUpTableForCRC( void ); | |
24 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); |
|
24 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); | |
25 | void updateLFRCurrentMode(); |
|
25 | void updateLFRCurrentMode(); | |
26 |
|
26 | |||
27 | //********************* |
|
27 | //********************* | |
28 | // ACCEPTANCE FUNCTIONS |
|
28 | // ACCEPTANCE FUNCTIONS | |
29 |
int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_ |
|
29 | int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_recv_id, rtems_id queue_send_id); | |
30 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV); |
|
30 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV); | |
31 | int tc_check_type( unsigned char packetType ); |
|
31 | int tc_check_type( unsigned char packetType ); | |
32 | int tc_check_subtype( unsigned char packetType ); |
|
32 | int tc_check_subtype( unsigned char packetType ); | |
33 | int tc_check_length( unsigned char packetType, unsigned int length ); |
|
33 | int tc_check_length( unsigned char packetType, unsigned int length ); | |
34 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length ); |
|
34 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length ); | |
35 |
|
35 | |||
36 | //*********** |
|
36 | //*********** | |
37 | // RTEMS TASK |
|
37 | // RTEMS TASK | |
38 | rtems_task recv_task( rtems_task_argument unused ); |
|
38 | rtems_task recv_task( rtems_task_argument unused ); | |
39 | rtems_task actn_task( rtems_task_argument unused ); |
|
39 | rtems_task actn_task( rtems_task_argument unused ); | |
40 | rtems_task dumb_task( rtems_task_argument unused ); |
|
40 | rtems_task dumb_task( rtems_task_argument unused ); | |
41 |
|
41 | |||
42 | //*********** |
|
42 | //*********** | |
43 | // TC ACTIONS |
|
43 | // TC ACTIONS | |
44 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
44 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
45 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
45 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
46 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
46 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
47 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
47 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
48 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
48 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
49 | int action_update_time(ccsdsTelecommandPacket_t *TC); |
|
49 | int action_update_time(ccsdsTelecommandPacket_t *TC); | |
50 |
|
50 | |||
51 | // mode transition |
|
51 | // mode transition | |
52 | int transition_validation(unsigned char requestedMode); |
|
52 | int transition_validation(unsigned char requestedMode); | |
53 | int stop_current_mode(); |
|
53 | int stop_current_mode(); | |
54 | int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC); |
|
54 | int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC); | |
55 | int enter_standby_mode(); |
|
55 | int enter_standby_mode(); | |
56 | int enter_normal_mode(); |
|
56 | int enter_normal_mode(); | |
57 | int enter_burst_mode(); |
|
57 | int enter_burst_mode(); | |
58 | int enter_sbm1_mode(); |
|
58 | int enter_sbm1_mode(); | |
59 | int enter_sbm2_mode(); |
|
59 | int enter_sbm2_mode(); | |
60 | int restart_science_tasks(); |
|
60 | int restart_science_tasks(); | |
61 | int suspend_science_tasks(); |
|
61 | int suspend_science_tasks(); | |
62 |
|
62 | |||
63 | // other functions |
|
63 | // other functions | |
64 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC); |
|
64 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC); | |
65 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC); |
|
65 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC); | |
66 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id); |
|
66 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id); | |
67 |
|
67 | |||
68 | #endif // TC_HANDLER_H_INCLUDED |
|
68 | #endif // TC_HANDLER_H_INCLUDED | |
69 |
|
69 | |||
70 |
|
70 | |||
71 |
|
71 |
@@ -1,573 +1,573 | |||||
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 20 |
|
18 | #define CONFIGURE_MAXIMUM_TASKS 20 | |
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 1 // instead of 100 |
|
22 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 | |
23 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
23 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) | |
24 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
24 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
25 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
25 | #define CONFIGURE_MAXIMUM_PERIODS 5 | |
26 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
26 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) | |
27 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 |
|
27 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2 | |
28 | #ifdef PRINT_STACK_REPORT |
|
28 | #ifdef PRINT_STACK_REPORT | |
29 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
29 | #define CONFIGURE_STACK_CHECKER_ENABLED | |
30 | #endif |
|
30 | #endif | |
31 |
|
31 | |||
32 | #include <rtems/confdefs.h> |
|
32 | #include <rtems/confdefs.h> | |
33 |
|
33 | |||
34 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
34 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
35 | #ifdef RTEMS_DRVMGR_STARTUP |
|
35 | #ifdef RTEMS_DRVMGR_STARTUP | |
36 | #ifdef LEON3 |
|
36 | #ifdef LEON3 | |
37 | /* Add Timer and UART Driver */ |
|
37 | /* Add Timer and UART Driver */ | |
38 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
38 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
39 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
39 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |
40 | #endif |
|
40 | #endif | |
41 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
41 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
42 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
42 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
43 | #endif |
|
43 | #endif | |
44 | #endif |
|
44 | #endif | |
45 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
45 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
46 | #include <drvmgr/drvmgr_confdefs.h> |
|
46 | #include <drvmgr/drvmgr_confdefs.h> | |
47 | #endif |
|
47 | #endif | |
48 |
|
48 | |||
49 | #include "fsw_init.h" |
|
49 | #include "fsw_init.h" | |
50 | #include "fsw_config.c" |
|
50 | #include "fsw_config.c" | |
51 |
|
51 | |||
52 | rtems_task Init( rtems_task_argument ignored ) |
|
52 | rtems_task Init( rtems_task_argument ignored ) | |
53 | { |
|
53 | { | |
54 | rtems_status_code status; |
|
54 | rtems_status_code status; | |
55 | rtems_isr_entry old_isr_handler; |
|
55 | rtems_isr_entry old_isr_handler; | |
56 |
|
56 | |||
57 | BOOT_PRINTF("\n\n\n\n\n") |
|
57 | BOOT_PRINTF("\n\n\n\n\n") | |
58 | BOOT_PRINTF("***************************\n") |
|
58 | BOOT_PRINTF("***************************\n") | |
59 | BOOT_PRINTF("** START Flight Software **\n") |
|
59 | BOOT_PRINTF("** START Flight Software **\n") | |
60 | BOOT_PRINTF("***************************\n") |
|
60 | BOOT_PRINTF("***************************\n") | |
61 | BOOT_PRINTF("\n\n") |
|
61 | BOOT_PRINTF("\n\n") | |
62 |
|
62 | |||
63 | //send_console_outputs_on_apbuart_port(); |
|
63 | //send_console_outputs_on_apbuart_port(); | |
64 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
64 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
65 |
|
65 | |||
66 | init_parameter_dump(); |
|
66 | init_parameter_dump(); | |
67 | init_local_mode_parameters(); |
|
67 | init_local_mode_parameters(); | |
68 | init_housekeeping_parameters(); |
|
68 | init_housekeeping_parameters(); | |
69 |
|
69 | |||
70 | create_names(); // create all names |
|
70 | create_names(); // create all names | |
71 |
|
71 | |||
72 | create_message_queues(); |
|
72 | create_message_queues(); | |
73 |
|
73 | |||
74 | status = create_all_tasks(); // create all tasks |
|
74 | status = create_all_tasks(); // create all tasks | |
75 | if (status != RTEMS_SUCCESSFUL) |
|
75 | if (status != RTEMS_SUCCESSFUL) | |
76 | { |
|
76 | { | |
77 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) |
|
77 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status) | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | status = start_all_tasks(); // start all tasks |
|
80 | status = start_all_tasks(); // start all tasks | |
81 | if (status != RTEMS_SUCCESSFUL) |
|
81 | if (status != RTEMS_SUCCESSFUL) | |
82 | { |
|
82 | { | |
83 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
83 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | status = stop_current_mode(); // go in STANDBY mode |
|
86 | status = stop_current_mode(); // go in STANDBY mode | |
87 | if (status != RTEMS_SUCCESSFUL) |
|
87 | if (status != RTEMS_SUCCESSFUL) | |
88 | { |
|
88 | { | |
89 | PRINTF1("in INIT *** ERR in stop_current_mode, code %d", status) |
|
89 | PRINTF1("in INIT *** ERR in stop_current_mode, code %d", status) | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | grspw_timecode_callback = &timecode_irq_handler; |
|
92 | grspw_timecode_callback = &timecode_irq_handler; | |
93 |
|
93 | |||
94 | spacewire_configure_link(); |
|
94 | spacewire_configure_link(); | |
95 |
|
95 | |||
96 | #ifdef GSA |
|
96 | #ifdef GSA | |
97 | // mask IRQ lines |
|
97 | // mask IRQ lines | |
98 | LEON_Mask_interrupt( IRQ_SM ); |
|
98 | LEON_Mask_interrupt( IRQ_SM ); | |
99 | LEON_Mask_interrupt( IRQ_WF ); |
|
99 | LEON_Mask_interrupt( IRQ_WF ); | |
100 | // Spectral Matrices simulator |
|
100 | // Spectral Matrices simulator | |
101 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
101 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, | |
102 | IRQ_SPARC_SM, spectral_matrices_isr ); |
|
102 | IRQ_SPARC_SM, spectral_matrices_isr ); | |
103 | // WaveForms |
|
103 | // WaveForms | |
104 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, |
|
104 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, | |
105 | IRQ_SPARC_WF, waveforms_simulator_isr ); |
|
105 | IRQ_SPARC_WF, waveforms_simulator_isr ); | |
106 | #else |
|
106 | #else | |
107 | // mask IRQ lines |
|
107 | // mask IRQ lines | |
108 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
108 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); | |
109 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
109 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
110 | // reset configuration registers |
|
110 | // reset configuration registers | |
111 | reset_waveform_picker_regs(); |
|
111 | reset_waveform_picker_regs(); | |
112 | reset_spectral_matrix_regs(); |
|
112 | reset_spectral_matrix_regs(); | |
113 | // configure IRQ handling for the waveform picker unit |
|
113 | // configure IRQ handling for the waveform picker unit | |
114 | status = rtems_interrupt_catch( waveforms_isr, |
|
114 | status = rtems_interrupt_catch( waveforms_isr, | |
115 | IRQ_SPARC_WAVEFORM_PICKER, |
|
115 | IRQ_SPARC_WAVEFORM_PICKER, | |
116 | &old_isr_handler) ; |
|
116 | &old_isr_handler) ; | |
117 | // configure IRQ handling for the spectral matrix unit |
|
117 | // configure IRQ handling for the spectral matrix unit | |
118 | // status = rtems_interrupt_catch( spectral_matrices_isr, |
|
118 | // status = rtems_interrupt_catch( spectral_matrices_isr, | |
119 | // IRQ_SPARC_SPECTRAL_MATRIX, |
|
119 | // IRQ_SPARC_SPECTRAL_MATRIX, | |
120 | // &old_isr_handler) ; |
|
120 | // &old_isr_handler) ; | |
121 | // Spectral Matrices simulator |
|
121 | // Spectral Matrices simulator | |
122 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
122 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, | |
123 | IRQ_SPARC_SM, spectral_matrices_isr_simu ); |
|
123 | IRQ_SPARC_SM, spectral_matrices_isr_simu ); | |
124 | #endif |
|
124 | #endif | |
125 |
|
125 | |||
126 | BOOT_PRINTF("delete INIT\n") |
|
126 | BOOT_PRINTF("delete INIT\n") | |
127 |
|
127 | |||
128 | status = rtems_task_delete(RTEMS_SELF); |
|
128 | status = rtems_task_delete(RTEMS_SELF); | |
129 |
|
129 | |||
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | void init_parameter_dump( void ) |
|
132 | void init_parameter_dump( void ) | |
133 | { |
|
133 | { | |
134 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
134 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
135 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
135 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
136 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
136 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
137 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
137 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
138 | parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8); |
|
138 | parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8); | |
139 | parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; |
|
139 | parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP; | |
140 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
140 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
141 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
141 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
142 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
142 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); | |
143 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
143 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
144 | // DATA FIELD HEADER |
|
144 | // DATA FIELD HEADER | |
145 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
145 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
146 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
146 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
147 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
147 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
148 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
148 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
149 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
149 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
150 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
150 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
151 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
151 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
152 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
152 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
153 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
153 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
154 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
154 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
155 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
155 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
156 |
|
156 | |||
157 | //****************** |
|
157 | //****************** | |
158 | // COMMON PARAMETERS |
|
158 | // COMMON PARAMETERS | |
159 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; |
|
159 | parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0; | |
160 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; |
|
160 | parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1; | |
161 |
|
161 | |||
162 | //****************** |
|
162 | //****************** | |
163 | // NORMAL PARAMETERS |
|
163 | // NORMAL PARAMETERS | |
164 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L >> 8); |
|
164 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L >> 8); | |
165 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L ); |
|
165 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L ); | |
166 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P >> 8); |
|
166 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P >> 8); | |
167 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P ); |
|
167 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P ); | |
168 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P >> 8); |
|
168 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P >> 8); | |
169 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P ); |
|
169 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P ); | |
170 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DEFAULT_SY_LFR_N_BP_P0; |
|
170 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DEFAULT_SY_LFR_N_BP_P0; | |
171 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DEFAULT_SY_LFR_N_BP_P1; |
|
171 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DEFAULT_SY_LFR_N_BP_P1; | |
172 |
|
172 | |||
173 | //***************** |
|
173 | //***************** | |
174 | // BURST PARAMETERS |
|
174 | // BURST PARAMETERS | |
175 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
175 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
176 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
176 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
177 |
|
177 | |||
178 | //**************** |
|
178 | //**************** | |
179 | // SBM1 PARAMETERS |
|
179 | // SBM1 PARAMETERS | |
180 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
180 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period | |
181 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
181 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
182 |
|
182 | |||
183 | //**************** |
|
183 | //**************** | |
184 | // SBM2 PARAMETERS |
|
184 | // SBM2 PARAMETERS | |
185 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
185 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
186 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
186 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | void init_local_mode_parameters( void ) |
|
189 | void init_local_mode_parameters( void ) | |
190 | { |
|
190 | { | |
191 | // LOCAL PARAMETERS |
|
191 | // LOCAL PARAMETERS | |
192 | set_local_sbm1_nb_cwf_max(); |
|
192 | set_local_sbm1_nb_cwf_max(); | |
193 | set_local_sbm2_nb_cwf_max(); |
|
193 | set_local_sbm2_nb_cwf_max(); | |
194 | set_local_nb_interrupt_f0_MAX(); |
|
194 | set_local_nb_interrupt_f0_MAX(); | |
195 |
|
195 | |||
196 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
196 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
197 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
197 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
198 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
198 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
199 |
|
199 | |||
200 | reset_local_sbm1_nb_cwf_sent(); |
|
200 | reset_local_sbm1_nb_cwf_sent(); | |
201 | reset_local_sbm2_nb_cwf_sent(); |
|
201 | reset_local_sbm2_nb_cwf_sent(); | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | void init_housekeeping_parameters( void ) |
|
204 | void init_housekeeping_parameters( void ) | |
205 | { |
|
205 | { | |
206 | unsigned int i = 0; |
|
206 | unsigned int i = 0; | |
207 | unsigned int j = 0; |
|
207 | unsigned int j = 0; | |
208 | unsigned int k = 0; |
|
208 | unsigned int k = 0; | |
209 | char *parameters; |
|
209 | char *parameters; | |
210 |
|
210 | |||
211 | parameters = (char*) &housekeeping_packet.lfr_status_word; |
|
211 | parameters = (char*) &housekeeping_packet.lfr_status_word; | |
212 | for(i = 0; i< SIZE_HK_PARAMETERS; i++) |
|
212 | for(i = 0; i< SIZE_HK_PARAMETERS; i++) | |
213 | { |
|
213 | { | |
214 | parameters[i] = 0x00; |
|
214 | parameters[i] = 0x00; | |
215 | } |
|
215 | } | |
216 | // init status word |
|
216 | // init status word | |
217 | housekeeping_packet.lfr_status_word[0] = 0x00; |
|
217 | housekeeping_packet.lfr_status_word[0] = 0x00; | |
218 | housekeeping_packet.lfr_status_word[1] = 0x00; |
|
218 | housekeeping_packet.lfr_status_word[1] = 0x00; | |
219 | // init software version |
|
219 | // init software version | |
220 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
220 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
221 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
221 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
222 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
222 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
223 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
223 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
224 | // init sequence counters |
|
224 | // init sequence counters | |
225 | for (i = 0; i<SEQ_CNT_NB_PID; i++) |
|
225 | for (i = 0; i<SEQ_CNT_NB_PID; i++) | |
226 | { |
|
226 | { | |
227 | for(j = 0; j<SEQ_CNT_NB_CAT; j++) |
|
227 | for(j = 0; j<SEQ_CNT_NB_CAT; j++) | |
228 | { |
|
228 | { | |
229 | for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++) |
|
229 | for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++) | |
230 | { |
|
230 | { | |
231 | sequenceCounters[i][j][k] = 0x00; |
|
231 | sequenceCounters[i][j][k] = 0x00; | |
232 | } |
|
232 | } | |
233 | } |
|
233 | } | |
234 | } |
|
234 | } | |
235 | updateLFRCurrentMode(); |
|
235 | updateLFRCurrentMode(); | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | int create_names( void ) // create all names for tasks and queues |
|
238 | int create_names( void ) // create all names for tasks and queues | |
239 | { |
|
239 | { | |
240 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
240 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
241 | * |
|
241 | * | |
242 | * @return RTEMS directive status codes: |
|
242 | * @return RTEMS directive status codes: | |
243 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
243 | * - RTEMS_SUCCESSFUL - message sent successfully | |
244 | * |
|
244 | * | |
245 | */ |
|
245 | */ | |
246 |
|
246 | |||
247 | // task names |
|
247 | // task names | |
248 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
248 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
249 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
249 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
250 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
250 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
251 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
251 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); | |
252 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
252 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |
253 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
253 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
254 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); |
|
254 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); | |
255 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
255 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
256 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
256 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
257 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
257 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
258 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); |
|
258 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); | |
259 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
259 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
260 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
260 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
261 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
261 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
262 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
262 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
263 |
|
263 | |||
264 | // rate monotonic period name |
|
264 | // rate monotonic period name | |
265 | HK_name = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
265 | HK_name = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
266 |
|
266 | |||
267 |
misc_name[QUEUE_ |
|
267 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', 'U', 'E', 'U' ); | |
268 |
misc_name[QUEUE_ |
|
268 | misc_name[QUEUE_SEND] = rtems_build_name( 'P', 'K', 'T', 'S' ); | |
269 |
|
269 | |||
270 | return RTEMS_SUCCESSFUL; |
|
270 | return RTEMS_SUCCESSFUL; | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | int create_all_tasks( void ) // create all tasks which run in the software |
|
273 | int create_all_tasks( void ) // create all tasks which run in the software | |
274 | { |
|
274 | { | |
275 | /** This function creates all RTEMS tasks used in the software. |
|
275 | /** This function creates all RTEMS tasks used in the software. | |
276 | * |
|
276 | * | |
277 | * @return RTEMS directive status codes: |
|
277 | * @return RTEMS directive status codes: | |
278 | * - RTEMS_SUCCESSFUL - task created successfully |
|
278 | * - RTEMS_SUCCESSFUL - task created successfully | |
279 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
279 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
280 | * - RTEMS_INVALID_NAME - invalid task name |
|
280 | * - RTEMS_INVALID_NAME - invalid task name | |
281 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
281 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
282 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
282 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
283 | * - RTEMS_TOO_MANY - too many tasks created |
|
283 | * - RTEMS_TOO_MANY - too many tasks created | |
284 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
284 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
285 | * - RTEMS_TOO_MANY - too many global objects |
|
285 | * - RTEMS_TOO_MANY - too many global objects | |
286 | * |
|
286 | * | |
287 | */ |
|
287 | */ | |
288 |
|
288 | |||
289 | rtems_status_code status; |
|
289 | rtems_status_code status; | |
290 |
|
290 | |||
291 | // RECV |
|
291 | // RECV | |
292 | status = rtems_task_create( |
|
292 | status = rtems_task_create( | |
293 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
293 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
294 | RTEMS_DEFAULT_MODES, |
|
294 | RTEMS_DEFAULT_MODES, | |
295 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
295 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
296 | ); |
|
296 | ); | |
297 |
|
297 | |||
298 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
298 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
299 | { |
|
299 | { | |
300 | status = rtems_task_create( |
|
300 | status = rtems_task_create( | |
301 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
301 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
302 | RTEMS_DEFAULT_MODES, |
|
302 | RTEMS_DEFAULT_MODES, | |
303 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
303 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
304 | ); |
|
304 | ); | |
305 | } |
|
305 | } | |
306 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
306 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
307 | { |
|
307 | { | |
308 | status = rtems_task_create( |
|
308 | status = rtems_task_create( | |
309 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
309 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
310 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
310 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
311 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
311 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
312 | ); |
|
312 | ); | |
313 | } |
|
313 | } | |
314 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
314 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
315 | { |
|
315 | { | |
316 | status = rtems_task_create( |
|
316 | status = rtems_task_create( | |
317 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
317 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, | |
318 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
318 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
319 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] |
|
319 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] | |
320 | ); |
|
320 | ); | |
321 | } |
|
321 | } | |
322 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
322 | if (status == RTEMS_SUCCESSFUL) // STAT | |
323 | { |
|
323 | { | |
324 | status = rtems_task_create( |
|
324 | status = rtems_task_create( | |
325 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
325 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
326 | RTEMS_DEFAULT_MODES, |
|
326 | RTEMS_DEFAULT_MODES, | |
327 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
327 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
328 | ); |
|
328 | ); | |
329 | } |
|
329 | } | |
330 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
330 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
331 | { |
|
331 | { | |
332 | status = rtems_task_create( |
|
332 | status = rtems_task_create( | |
333 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
333 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
334 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
334 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
335 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
335 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
336 | ); |
|
336 | ); | |
337 | } |
|
337 | } | |
338 | if (status == RTEMS_SUCCESSFUL) // BPF0 |
|
338 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
339 | { |
|
339 | { | |
340 | status = rtems_task_create( |
|
340 | status = rtems_task_create( | |
341 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, |
|
341 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, | |
342 | RTEMS_DEFAULT_MODES, |
|
342 | RTEMS_DEFAULT_MODES, | |
343 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] |
|
343 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] | |
344 | ); |
|
344 | ); | |
345 | } |
|
345 | } | |
346 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
346 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
347 | { |
|
347 | { | |
348 | status = rtems_task_create( |
|
348 | status = rtems_task_create( | |
349 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
349 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
350 | RTEMS_DEFAULT_MODES, |
|
350 | RTEMS_DEFAULT_MODES, | |
351 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
351 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
352 | ); |
|
352 | ); | |
353 | } |
|
353 | } | |
354 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
354 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
355 | { |
|
355 | { | |
356 | status = rtems_task_create( |
|
356 | status = rtems_task_create( | |
357 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
357 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
358 | RTEMS_DEFAULT_MODES, |
|
358 | RTEMS_DEFAULT_MODES, | |
359 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
359 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
360 | ); |
|
360 | ); | |
361 | } |
|
361 | } | |
362 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
362 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
363 | { |
|
363 | { | |
364 | status = rtems_task_create( |
|
364 | status = rtems_task_create( | |
365 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
365 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
366 | RTEMS_DEFAULT_MODES, |
|
366 | RTEMS_DEFAULT_MODES, | |
367 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] |
|
367 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] | |
368 | ); |
|
368 | ); | |
369 | } |
|
369 | } | |
370 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
370 | if (status == RTEMS_SUCCESSFUL) // MATR | |
371 | { |
|
371 | { | |
372 | status = rtems_task_create( |
|
372 | status = rtems_task_create( | |
373 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, |
|
373 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, | |
374 | RTEMS_DEFAULT_MODES, |
|
374 | RTEMS_DEFAULT_MODES, | |
375 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] |
|
375 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] | |
376 | ); |
|
376 | ); | |
377 | } |
|
377 | } | |
378 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
378 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
379 | { |
|
379 | { | |
380 | status = rtems_task_create( |
|
380 | status = rtems_task_create( | |
381 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
381 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
382 | RTEMS_DEFAULT_MODES, |
|
382 | RTEMS_DEFAULT_MODES, | |
383 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] |
|
383 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] | |
384 | ); |
|
384 | ); | |
385 | } |
|
385 | } | |
386 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
386 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
387 | { |
|
387 | { | |
388 | status = rtems_task_create( |
|
388 | status = rtems_task_create( | |
389 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
389 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
390 | RTEMS_DEFAULT_MODES, |
|
390 | RTEMS_DEFAULT_MODES, | |
391 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] |
|
391 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] | |
392 | ); |
|
392 | ); | |
393 | } |
|
393 | } | |
394 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
394 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
395 | { |
|
395 | { | |
396 | status = rtems_task_create( |
|
396 | status = rtems_task_create( | |
397 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
397 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
398 | RTEMS_DEFAULT_MODES, |
|
398 | RTEMS_DEFAULT_MODES, | |
399 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] |
|
399 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] | |
400 | ); |
|
400 | ); | |
401 | } |
|
401 | } | |
402 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
402 | if (status == RTEMS_SUCCESSFUL) // SEND | |
403 | { |
|
403 | { | |
404 | status = rtems_task_create( |
|
404 | status = rtems_task_create( | |
405 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, |
|
405 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, | |
406 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
406 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
407 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] |
|
407 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] | |
408 | ); |
|
408 | ); | |
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | return status; |
|
411 | return status; | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | int start_all_tasks( void ) |
|
414 | int start_all_tasks( void ) | |
415 | { |
|
415 | { | |
416 | /** This function starts all RTEMS tasks used in the software. |
|
416 | /** This function starts all RTEMS tasks used in the software. | |
417 | * |
|
417 | * | |
418 | * @return RTEMS directive status codes: |
|
418 | * @return RTEMS directive status codes: | |
419 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
419 | * - RTEMS_SUCCESSFUL - ask started successfully | |
420 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
420 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
421 | * - RTEMS_INVALID_ID - invalid task id |
|
421 | * - RTEMS_INVALID_ID - invalid task id | |
422 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
422 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
423 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
423 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
424 | * |
|
424 | * | |
425 | */ |
|
425 | */ | |
426 | // starts all the tasks fot eh flight software |
|
426 | // starts all the tasks fot eh flight software | |
427 |
|
427 | |||
428 | rtems_status_code status; |
|
428 | rtems_status_code status; | |
429 |
|
429 | |||
430 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
430 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
431 | if (status!=RTEMS_SUCCESSFUL) { |
|
431 | if (status!=RTEMS_SUCCESSFUL) { | |
432 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
432 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
433 | } |
|
433 | } | |
434 |
|
434 | |||
435 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
435 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
436 | { |
|
436 | { | |
437 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); |
|
437 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); | |
438 | if (status!=RTEMS_SUCCESSFUL) { |
|
438 | if (status!=RTEMS_SUCCESSFUL) { | |
439 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") |
|
439 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") | |
440 | } |
|
440 | } | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | if (status == RTEMS_SUCCESSFUL) // RECV |
|
443 | if (status == RTEMS_SUCCESSFUL) // RECV | |
444 | { |
|
444 | { | |
445 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
445 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
446 | if (status!=RTEMS_SUCCESSFUL) { |
|
446 | if (status!=RTEMS_SUCCESSFUL) { | |
447 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
447 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
448 | } |
|
448 | } | |
449 | } |
|
449 | } | |
450 |
|
450 | |||
451 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
451 | if (status == RTEMS_SUCCESSFUL) // SEND | |
452 | { |
|
452 | { | |
453 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
453 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
454 | if (status!=RTEMS_SUCCESSFUL) { |
|
454 | if (status!=RTEMS_SUCCESSFUL) { | |
455 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
455 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
456 | } |
|
456 | } | |
457 | } |
|
457 | } | |
458 |
|
458 | |||
459 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
459 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
460 | { |
|
460 | { | |
461 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
461 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
462 | if (status!=RTEMS_SUCCESSFUL) { |
|
462 | if (status!=RTEMS_SUCCESSFUL) { | |
463 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
463 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
464 | } |
|
464 | } | |
465 | } |
|
465 | } | |
466 |
|
466 | |||
467 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
467 | if (status == RTEMS_SUCCESSFUL) // STAT | |
468 | { |
|
468 | { | |
469 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
469 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
470 | if (status!=RTEMS_SUCCESSFUL) { |
|
470 | if (status!=RTEMS_SUCCESSFUL) { | |
471 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
471 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
472 | } |
|
472 | } | |
473 | } |
|
473 | } | |
474 |
|
474 | |||
475 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
475 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
476 | { |
|
476 | { | |
477 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); |
|
477 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); | |
478 | if (status!=RTEMS_SUCCESSFUL) { |
|
478 | if (status!=RTEMS_SUCCESSFUL) { | |
479 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
479 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
480 | } |
|
480 | } | |
481 | } |
|
481 | } | |
482 |
|
482 | |||
483 | if (status == RTEMS_SUCCESSFUL) // BPF0 |
|
483 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
484 | { |
|
484 | { | |
485 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); |
|
485 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); | |
486 | if (status!=RTEMS_SUCCESSFUL) { |
|
486 | if (status!=RTEMS_SUCCESSFUL) { | |
487 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") |
|
487 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") | |
488 | } |
|
488 | } | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
491 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
491 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
492 | { |
|
492 | { | |
493 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
493 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
494 | if (status!=RTEMS_SUCCESSFUL) { |
|
494 | if (status!=RTEMS_SUCCESSFUL) { | |
495 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
495 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
496 | } |
|
496 | } | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
499 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
499 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
500 | { |
|
500 | { | |
501 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
501 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
502 | if (status!=RTEMS_SUCCESSFUL) { |
|
502 | if (status!=RTEMS_SUCCESSFUL) { | |
503 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
503 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
504 | } |
|
504 | } | |
505 | } |
|
505 | } | |
506 |
|
506 | |||
507 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
507 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
508 | { |
|
508 | { | |
509 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
509 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
510 | if (status!=RTEMS_SUCCESSFUL) { |
|
510 | if (status!=RTEMS_SUCCESSFUL) { | |
511 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
511 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
512 | } |
|
512 | } | |
513 | } |
|
513 | } | |
514 |
|
514 | |||
515 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
515 | if (status == RTEMS_SUCCESSFUL) // MATR | |
516 | { |
|
516 | { | |
517 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); |
|
517 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); | |
518 | if (status!=RTEMS_SUCCESSFUL) { |
|
518 | if (status!=RTEMS_SUCCESSFUL) { | |
519 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") |
|
519 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") | |
520 | } |
|
520 | } | |
521 | } |
|
521 | } | |
522 |
|
522 | |||
523 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
523 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
524 | { |
|
524 | { | |
525 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
525 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
526 | if (status!=RTEMS_SUCCESSFUL) { |
|
526 | if (status!=RTEMS_SUCCESSFUL) { | |
527 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
527 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
528 | } |
|
528 | } | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
531 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
532 | { |
|
532 | { | |
533 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
533 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
534 | if (status!=RTEMS_SUCCESSFUL) { |
|
534 | if (status!=RTEMS_SUCCESSFUL) { | |
535 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
535 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
536 | } |
|
536 | } | |
537 | } |
|
537 | } | |
538 |
|
538 | |||
539 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
539 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
540 | { |
|
540 | { | |
541 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
541 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
542 | if (status!=RTEMS_SUCCESSFUL) { |
|
542 | if (status!=RTEMS_SUCCESSFUL) { | |
543 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
543 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
544 | } |
|
544 | } | |
545 | } |
|
545 | } | |
546 |
|
546 | |||
547 | return status; |
|
547 | return status; | |
548 | } |
|
548 | } | |
549 |
|
549 | |||
550 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
550 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
551 | { |
|
551 | { | |
552 | rtems_status_code status; |
|
552 | rtems_status_code status; | |
553 | rtems_status_code ret; |
|
553 | rtems_status_code ret; | |
554 | rtems_id queue_id; |
|
554 | rtems_id queue_id; | |
555 |
|
555 | |||
|
556 | // create the queue for handling valid TCs | |||
|
557 | status = rtems_message_queue_create( misc_name[QUEUE_RECV], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, | |||
|
558 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |||
|
559 | if (status != RTEMS_SUCCESSFUL) { | |||
|
560 | ret = status; | |||
|
561 | BOOT_PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", ret) | |||
|
562 | } | |||
|
563 | ||||
556 | // create the queue for handling TM packet sending |
|
564 | // create the queue for handling TM packet sending | |
557 |
ret = rtems_message_queue_create( misc_name[QUEUE_ |
|
565 | ret = rtems_message_queue_create( misc_name[QUEUE_SEND], ACTION_MSG_PKTS_COUNT, | |
558 | ACTION_MSG_PKTS_MAX_SIZE, |
|
566 | ACTION_MSG_PKTS_MAX_SIZE, | |
559 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
567 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
560 | if (ret != RTEMS_SUCCESSFUL) { |
|
568 | if (ret != RTEMS_SUCCESSFUL) { | |
561 | BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret) |
|
569 | BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret) | |
562 | } |
|
570 | } | |
563 |
|
571 | |||
564 | // create the queue for handling valid TCs |
|
572 | return ret; | |
565 | status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, |
|
|||
566 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
|||
567 | if (status != RTEMS_SUCCESSFUL) { |
|
|||
568 | ret = status; |
|
|||
569 | BOOT_PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", ret) |
|
|||
570 | } |
|
|||
571 |
|
||||
572 | return ret; |
|
|||
573 | } |
|
573 | } |
@@ -1,331 +1,331 | |||||
1 | #include "fsw_misc.h" |
|
1 | #include "fsw_misc.h" | |
2 |
|
2 | |||
3 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
3 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, | |
4 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
4 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
5 | { // configure the timer for the waveforms simulation |
|
5 | { // configure the timer for the waveforms simulation | |
6 | rtems_status_code status; |
|
6 | rtems_status_code status; | |
7 | rtems_isr_entry old_isr_handler; |
|
7 | rtems_isr_entry old_isr_handler; | |
8 |
|
8 | |||
9 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
9 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
10 | if (status!=RTEMS_SUCCESSFUL) |
|
10 | if (status!=RTEMS_SUCCESSFUL) | |
11 | { |
|
11 | { | |
12 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
12 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
13 | } |
|
13 | } | |
14 |
|
14 | |||
15 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); |
|
15 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); | |
16 |
|
16 | |||
17 | return 1; |
|
17 | return 1; | |
18 | } |
|
18 | } | |
19 |
|
19 | |||
20 | int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
20 | int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) | |
21 | { |
|
21 | { | |
22 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
22 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
23 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
23 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register | |
24 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
24 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer | |
25 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
25 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart | |
26 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
26 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable | |
27 |
|
27 | |||
28 | return 1; |
|
28 | return 1; | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
31 | int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) | |
32 | { |
|
32 | { | |
33 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
33 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer | |
34 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
34 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable | |
35 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
35 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
36 |
|
36 | |||
37 | return 1; |
|
37 | return 1; | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) |
|
40 | int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) | |
41 | { |
|
41 | { | |
42 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
42 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
43 |
|
43 | |||
44 | return 1; |
|
44 | return 1; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void update_spacewire_statistics() |
|
47 | void update_spacewire_statistics() | |
48 | { |
|
48 | { | |
49 | rtems_status_code status; |
|
49 | rtems_status_code status; | |
50 | spw_stats spacewire_stats_grspw; |
|
50 | spw_stats spacewire_stats_grspw; | |
51 |
|
51 | |||
52 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
52 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
53 |
|
53 | |||
54 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
54 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
55 | + spacewire_stats_grspw.packets_received; |
|
55 | + spacewire_stats_grspw.packets_received; | |
56 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
56 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
57 | + spacewire_stats_grspw.packets_sent; |
|
57 | + spacewire_stats_grspw.packets_sent; | |
58 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
58 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
59 | + spacewire_stats_grspw.parity_err; |
|
59 | + spacewire_stats_grspw.parity_err; | |
60 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
60 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
61 | + spacewire_stats_grspw.disconnect_err; |
|
61 | + spacewire_stats_grspw.disconnect_err; | |
62 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
62 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
63 | + spacewire_stats_grspw.escape_err; |
|
63 | + spacewire_stats_grspw.escape_err; | |
64 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
64 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
65 | + spacewire_stats_grspw.credit_err; |
|
65 | + spacewire_stats_grspw.credit_err; | |
66 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
66 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
67 | + spacewire_stats_grspw.write_sync_err; |
|
67 | + spacewire_stats_grspw.write_sync_err; | |
68 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
68 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
69 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
69 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
70 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
70 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
71 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
71 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
72 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
72 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
73 | + spacewire_stats_grspw.early_ep; |
|
73 | + spacewire_stats_grspw.early_ep; | |
74 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
74 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
75 | + spacewire_stats_grspw.invalid_address; |
|
75 | + spacewire_stats_grspw.invalid_address; | |
76 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
76 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
77 | + spacewire_stats_grspw.rx_eep_err; |
|
77 | + spacewire_stats_grspw.rx_eep_err; | |
78 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
78 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
79 | + spacewire_stats_grspw.rx_truncated; |
|
79 | + spacewire_stats_grspw.rx_truncated; | |
80 | //spacewire_stats.tx_link_err; |
|
80 | //spacewire_stats.tx_link_err; | |
81 |
|
81 | |||
82 | //**************************** |
|
82 | //**************************** | |
83 | // DPU_SPACEWIRE_IF_STATISTICS |
|
83 | // DPU_SPACEWIRE_IF_STATISTICS | |
84 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
84 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
85 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
85 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
86 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
86 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
87 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
87 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
88 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
88 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
89 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
89 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
90 |
|
90 | |||
91 | //****************************************** |
|
91 | //****************************************** | |
92 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
92 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
93 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
93 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
94 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
94 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
95 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
95 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
96 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
96 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
97 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
97 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
98 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb; |
|
98 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb; | |
99 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb; |
|
99 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb; | |
100 | housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err; |
|
100 | housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err; | |
101 | housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err; |
|
101 | housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err; | |
102 |
|
102 | |||
103 | //********************************************* |
|
103 | //********************************************* | |
104 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
104 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
105 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
105 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
106 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
106 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
107 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
107 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
108 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
108 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
109 |
|
109 | |||
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
112 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port | |
113 | { |
|
113 | { | |
114 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
114 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
115 |
|
115 | |||
116 | apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB; |
|
116 | apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB; | |
117 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
117 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
118 |
|
118 | |||
119 | return 0; |
|
119 | return 0; | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
122 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
123 | { |
|
123 | { | |
124 | /** This function sets the scaler reload register of the apbuart module |
|
124 | /** This function sets the scaler reload register of the apbuart module | |
125 | * |
|
125 | * | |
126 | * @param regs is the address of the apbuart registers in memory |
|
126 | * @param regs is the address of the apbuart registers in memory | |
127 | * @param value is the value that will be stored in the scaler register |
|
127 | * @param value is the value that will be stored in the scaler register | |
128 | * |
|
128 | * | |
129 | * The value shall be set by the software to get data on the serial interface. |
|
129 | * The value shall be set by the software to get data on the serial interface. | |
130 | * |
|
130 | * | |
131 | */ |
|
131 | */ | |
132 |
|
132 | |||
133 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
133 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
134 |
|
134 | |||
135 | apbuart_regs->scaler = value; |
|
135 | apbuart_regs->scaler = value; | |
136 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
136 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | //************ |
|
139 | //************ | |
140 | // RTEMS TASKS |
|
140 | // RTEMS TASKS | |
141 |
|
141 | |||
142 | rtems_task stat_task(rtems_task_argument argument) |
|
142 | rtems_task stat_task(rtems_task_argument argument) | |
143 | { |
|
143 | { | |
144 | int i; |
|
144 | int i; | |
145 | int j; |
|
145 | int j; | |
146 | i = 0; |
|
146 | i = 0; | |
147 | j = 0; |
|
147 | j = 0; | |
148 | BOOT_PRINTF("in STAT *** \n") |
|
148 | BOOT_PRINTF("in STAT *** \n") | |
149 | while(1){ |
|
149 | while(1){ | |
150 | rtems_task_wake_after(1000); |
|
150 | rtems_task_wake_after(1000); | |
151 | PRINTF1("%d\n", j) |
|
151 | PRINTF1("%d\n", j) | |
152 | if (i == CPU_USAGE_REPORT_PERIOD) { |
|
152 | if (i == CPU_USAGE_REPORT_PERIOD) { | |
153 | // #ifdef PRINT_TASK_STATISTICS |
|
153 | // #ifdef PRINT_TASK_STATISTICS | |
154 | // rtems_cpu_usage_report(); |
|
154 | // rtems_cpu_usage_report(); | |
155 | // rtems_cpu_usage_reset(); |
|
155 | // rtems_cpu_usage_reset(); | |
156 | // #endif |
|
156 | // #endif | |
157 | i = 0; |
|
157 | i = 0; | |
158 | } |
|
158 | } | |
159 | else i++; |
|
159 | else i++; | |
160 | j++; |
|
160 | j++; | |
161 | } |
|
161 | } | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | rtems_task hous_task(rtems_task_argument argument) |
|
164 | rtems_task hous_task(rtems_task_argument argument) | |
165 | { |
|
165 | { | |
166 | rtems_status_code status; |
|
166 | rtems_status_code status; | |
167 | spw_ioctl_pkt_send spw_ioctl_send; |
|
167 | spw_ioctl_pkt_send spw_ioctl_send; | |
168 | rtems_id queue_id; |
|
168 | rtems_id queue_id; | |
169 |
|
169 | |||
170 | spw_ioctl_send.hlen = 0; |
|
170 | spw_ioctl_send.hlen = 0; | |
171 | spw_ioctl_send.hdr = NULL; |
|
171 | spw_ioctl_send.hdr = NULL; | |
172 | spw_ioctl_send.dlen = PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
172 | spw_ioctl_send.dlen = PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
173 | spw_ioctl_send.data = (char*) &housekeeping_packet; |
|
173 | spw_ioctl_send.data = (char*) &housekeeping_packet; | |
174 | spw_ioctl_send.options = 0; |
|
174 | spw_ioctl_send.options = 0; | |
175 |
|
175 | |||
176 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
176 | status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id ); | |
177 | if (status != RTEMS_SUCCESSFUL) |
|
177 | if (status != RTEMS_SUCCESSFUL) | |
178 | { |
|
178 | { | |
179 | PRINTF1("in HOUS *** ERR %d\n", status) |
|
179 | PRINTF1("in HOUS *** ERR %d\n", status) | |
180 | } |
|
180 | } | |
181 |
|
181 | |||
182 | BOOT_PRINTF("in HOUS ***\n") |
|
182 | BOOT_PRINTF("in HOUS ***\n") | |
183 |
|
183 | |||
184 | if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) { |
|
184 | if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) { | |
185 | status = rtems_rate_monotonic_create( HK_name, &HK_id ); |
|
185 | status = rtems_rate_monotonic_create( HK_name, &HK_id ); | |
186 | if( status != RTEMS_SUCCESSFUL ) { |
|
186 | if( status != RTEMS_SUCCESSFUL ) { | |
187 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
187 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
191 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
192 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
192 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
193 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
193 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
194 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
194 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
195 | housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8); |
|
195 | housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8); | |
196 | housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK); |
|
196 | housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK); | |
197 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
197 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
198 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
198 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
199 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
199 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
200 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
200 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
201 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
201 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
202 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
202 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
203 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
203 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
204 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
204 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
205 |
|
205 | |||
206 | status = rtems_rate_monotonic_cancel(HK_id); |
|
206 | status = rtems_rate_monotonic_cancel(HK_id); | |
207 | if( status != RTEMS_SUCCESSFUL ) { |
|
207 | if( status != RTEMS_SUCCESSFUL ) { | |
208 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
208 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) | |
209 | } |
|
209 | } | |
210 | else { |
|
210 | else { | |
211 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
211 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | while(1){ // launch the rate monotonic task |
|
214 | while(1){ // launch the rate monotonic task | |
215 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
215 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
216 | if ( status != RTEMS_SUCCESSFUL ) { |
|
216 | if ( status != RTEMS_SUCCESSFUL ) { | |
217 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status); |
|
217 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status); | |
218 | } |
|
218 | } | |
219 | else { |
|
219 | else { | |
220 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
220 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
221 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
221 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
222 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
222 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
223 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
223 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
224 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
224 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
225 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
225 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
226 | housekeeping_packet.sid = SID_HK; |
|
226 | housekeeping_packet.sid = SID_HK; | |
227 |
|
227 | |||
228 | update_spacewire_statistics(); |
|
228 | update_spacewire_statistics(); | |
229 |
|
229 | |||
230 | // SEND PACKET |
|
230 | // SEND PACKET | |
231 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
231 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); | |
232 | if (status != RTEMS_SUCCESSFUL) { |
|
232 | if (status != RTEMS_SUCCESSFUL) { | |
233 | PRINTF1("in HOUS *** ERR %d\n", status) |
|
233 | PRINTF1("in HOUS *** ERR %d\n", status) | |
234 | } |
|
234 | } | |
235 | } |
|
235 | } | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | PRINTF("in HOUS *** deleting task\n") |
|
238 | PRINTF("in HOUS *** deleting task\n") | |
239 |
|
239 | |||
240 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
240 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
241 | printf( "rtems_task_delete returned with status of %d.\n", status ); |
|
241 | printf( "rtems_task_delete returned with status of %d.\n", status ); | |
242 | exit( 1 ); |
|
242 | exit( 1 ); | |
243 | } |
|
243 | } | |
244 |
|
244 | |||
245 | rtems_task send_task( rtems_task_argument argument) |
|
245 | rtems_task send_task( rtems_task_argument argument) | |
246 | { |
|
246 | { | |
247 | rtems_status_code status; // RTEMS status code |
|
247 | rtems_status_code status; // RTEMS status code | |
248 | char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer |
|
248 | char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer | |
249 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
249 | spw_ioctl_pkt_send *spw_ioctl_send; | |
250 | size_t size; // size of the incoming TC packet |
|
250 | size_t size; // size of the incoming TC packet | |
251 | u_int32_t count; |
|
251 | u_int32_t count; | |
252 | rtems_id queue_id; |
|
252 | rtems_id queue_id; | |
253 |
|
253 | |||
254 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
254 | status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id ); | |
255 | if (status != RTEMS_SUCCESSFUL) |
|
255 | if (status != RTEMS_SUCCESSFUL) | |
256 | { |
|
256 | { | |
257 | PRINTF1("in SEND *** ERR getting queue id, %d\n", status) |
|
257 | PRINTF1("in SEND *** ERR getting queue id, %d\n", status) | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | BOOT_PRINTF("in SEND *** \n") |
|
260 | BOOT_PRINTF("in SEND *** \n") | |
261 |
|
261 | |||
262 | while(1) |
|
262 | while(1) | |
263 | { |
|
263 | { | |
264 | status = rtems_message_queue_receive( queue_id, incomingData, &size, |
|
264 | status = rtems_message_queue_receive( queue_id, incomingData, &size, | |
265 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
265 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
266 |
|
266 | |||
267 | if (status!=RTEMS_SUCCESSFUL) |
|
267 | if (status!=RTEMS_SUCCESSFUL) | |
268 | { |
|
268 | { | |
269 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
269 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
270 | } |
|
270 | } | |
271 | else |
|
271 | else | |
272 | { |
|
272 | { | |
273 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet |
|
273 | if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet | |
274 | { |
|
274 | { | |
275 | status = write( fdSPW, incomingData, size ); |
|
275 | status = write( fdSPW, incomingData, size ); | |
276 | if (status == -1){ |
|
276 | if (status == -1){ | |
277 | PRINTF2("in SEND *** (2.a) ERR = %d, size = %d\n", status, size) |
|
277 | PRINTF2("in SEND *** (2.a) ERR = %d, size = %d\n", status, size) | |
278 | } |
|
278 | } | |
279 | } |
|
279 | } | |
280 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
280 | else // the incoming message is a spw_ioctl_pkt_send structure | |
281 | { |
|
281 | { | |
282 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
282 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
283 | if (spw_ioctl_send->hlen == 0) |
|
283 | if (spw_ioctl_send->hlen == 0) | |
284 | { |
|
284 | { | |
285 | status = write( fdSPW, spw_ioctl_send->data, spw_ioctl_send->dlen ); |
|
285 | status = write( fdSPW, spw_ioctl_send->data, spw_ioctl_send->dlen ); | |
286 | if (status == -1){ |
|
286 | if (status == -1){ | |
287 | PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen) |
|
287 | PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen) | |
288 | } |
|
288 | } | |
289 | } |
|
289 | } | |
290 | else |
|
290 | else | |
291 | { |
|
291 | { | |
292 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
292 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
293 | if (status == -1){ |
|
293 | if (status == -1){ | |
294 | PRINTF2("in SEND *** (2.c) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen) |
|
294 | PRINTF2("in SEND *** (2.c) ERR = %d, dlen = %d\n", status, spw_ioctl_send->dlen) | |
295 | PRINTF1(" hlen = %d\n", spw_ioctl_send->hlen) |
|
295 | PRINTF1(" hlen = %d\n", spw_ioctl_send->hlen) | |
296 | } |
|
296 | } | |
297 | } |
|
297 | } | |
298 | } |
|
298 | } | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
301 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
302 | if (status != RTEMS_SUCCESSFUL) |
|
302 | if (status != RTEMS_SUCCESSFUL) | |
303 | { |
|
303 | { | |
304 | PRINTF1("in SEND *** (3) ERR = %d\n", status) |
|
304 | PRINTF1("in SEND *** (3) ERR = %d\n", status) | |
305 | } |
|
305 | } | |
306 | else |
|
306 | else | |
307 | { |
|
307 | { | |
308 | if (count > maxCount) |
|
308 | if (count > maxCount) | |
309 | { |
|
309 | { | |
310 | maxCount = count; |
|
310 | maxCount = count; | |
311 | } |
|
311 | } | |
312 | } |
|
312 | } | |
313 | } |
|
313 | } | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | rtems_id get_pkts_queue_id( void ) |
|
316 | rtems_id get_pkts_queue_id( void ) | |
317 | { |
|
317 | { | |
318 | rtems_id queue_id; |
|
318 | rtems_id queue_id; | |
319 | rtems_status_code status; |
|
319 | rtems_status_code status; | |
320 |
|
320 | |||
321 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
321 | status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id ); | |
322 | if (status != RTEMS_SUCCESSFUL) |
|
322 | if (status != RTEMS_SUCCESSFUL) | |
323 | { |
|
323 | { | |
324 | PRINTF1("in get_pkts_queue_id *** ERR %d\n", status) |
|
324 | PRINTF1("in get_pkts_queue_id *** ERR %d\n", status) | |
325 | } |
|
325 | } | |
326 | return queue_id; |
|
326 | return queue_id; | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 |
|
329 | |||
330 |
|
330 | |||
331 |
|
331 |
@@ -1,669 +1,669 | |||||
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 ]; |
|
6 | unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_SM_F0 * 9 ]; | |
7 | BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ]; |
|
7 | BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ]; | |
8 | float averaged_spec_mat_f0[ TOTAL_SIZE_SM ]; |
|
8 | float averaged_spec_mat_f0[ TOTAL_SIZE_SM ]; | |
9 | char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ]; |
|
9 | char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ]; | |
10 | float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; |
|
10 | float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; | |
11 |
|
11 | |||
12 | //*********************************************************** |
|
12 | //*********************************************************** | |
13 | // Interrupt Service Routine for spectral matrices processing |
|
13 | // Interrupt Service Routine for spectral matrices processing | |
14 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
14 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) | |
15 | { |
|
15 | { | |
16 | unsigned char status; |
|
16 | unsigned char status; | |
17 | unsigned char i; |
|
17 | unsigned char i; | |
18 |
|
18 | |||
19 | status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0] |
|
19 | status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0] | |
20 | for (i=0; i<4; i++) |
|
20 | for (i=0; i<4; i++) | |
21 | { |
|
21 | { | |
22 | if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation |
|
22 | if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation | |
23 | { |
|
23 | { | |
24 | switch(i) |
|
24 | switch(i) | |
25 | { |
|
25 | { | |
26 | case 0: |
|
26 | case 0: | |
27 | if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0) |
|
27 | if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0) | |
28 | { |
|
28 | { | |
29 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis; |
|
29 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis; | |
30 | } |
|
30 | } | |
31 | else |
|
31 | else | |
32 | { |
|
32 | { | |
33 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0; |
|
33 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0; | |
34 | } |
|
34 | } | |
35 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; |
|
35 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; | |
36 | break; |
|
36 | break; | |
37 | case 1: |
|
37 | case 1: | |
38 | if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1) |
|
38 | if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1) | |
39 | { |
|
39 | { | |
40 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis; |
|
40 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis; | |
41 | } |
|
41 | } | |
42 | else |
|
42 | else | |
43 | { |
|
43 | { | |
44 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; |
|
44 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; | |
45 | } |
|
45 | } | |
46 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; |
|
46 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; | |
47 | break; |
|
47 | break; | |
48 | case 2: |
|
48 | case 2: | |
49 | if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1) |
|
49 | if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1) | |
50 | { |
|
50 | { | |
51 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis; |
|
51 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis; | |
52 | } |
|
52 | } | |
53 | else |
|
53 | else | |
54 | { |
|
54 | { | |
55 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; |
|
55 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; | |
56 | } |
|
56 | } | |
57 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb; |
|
57 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb; | |
58 | break; |
|
58 | break; | |
59 | case 3: |
|
59 | case 3: | |
60 | if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2) |
|
60 | if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2) | |
61 | { |
|
61 | { | |
62 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis; |
|
62 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis; | |
63 | } |
|
63 | } | |
64 | else |
|
64 | else | |
65 | { |
|
65 | { | |
66 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; |
|
66 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; | |
67 | } |
|
67 | } | |
68 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7; |
|
68 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7; | |
69 | break; |
|
69 | break; | |
70 | default: |
|
70 | default: | |
71 | break; |
|
71 | break; | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | // reset error codes to 0 |
|
76 | // reset error codes to 0 | |
77 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111] |
|
77 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111] | |
78 |
|
78 | |||
79 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
79 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
80 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 ); |
|
80 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 ); | |
81 | } |
|
81 | } | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
84 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) | |
85 | { |
|
85 | { | |
86 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
86 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
87 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 ); |
|
87 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 ); | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | //************ |
|
91 | //************ | |
92 | // RTEMS TASKS |
|
92 | // RTEMS TASKS | |
93 |
|
93 | |||
94 | rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ |
|
94 | rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ | |
95 | { |
|
95 | { | |
96 | rtems_event_set event_out; |
|
96 | rtems_event_set event_out; | |
97 | unsigned int nb_interrupt_f0 = 0; |
|
97 | unsigned int nb_interrupt_f0 = 0; | |
98 |
|
98 | |||
99 | BOOT_PRINTF("in SMIQ *** \n") |
|
99 | BOOT_PRINTF("in SMIQ *** \n") | |
100 |
|
100 | |||
101 | while(1){ |
|
101 | while(1){ | |
102 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
102 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
103 | nb_interrupt_f0 = nb_interrupt_f0 + 1; |
|
103 | nb_interrupt_f0 = nb_interrupt_f0 + 1; | |
104 | if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){ |
|
104 | if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){ | |
105 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
105 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
106 | { |
|
106 | { | |
107 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
107 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
108 | } |
|
108 | } | |
109 | nb_interrupt_f0 = 0; |
|
109 | nb_interrupt_f0 = 0; | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | //rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ |
|
114 | //rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ | |
115 | //{ |
|
115 | //{ | |
116 | // rtems_event_set event_out; |
|
116 | // rtems_event_set event_out; | |
117 | // unsigned int nb_interrupt_f0 = 0; |
|
117 | // unsigned int nb_interrupt_f0 = 0; | |
118 |
|
118 | |||
119 | // PRINTF("in SMIQ *** \n") |
|
119 | // PRINTF("in SMIQ *** \n") | |
120 |
|
120 | |||
121 | // while(1){ |
|
121 | // while(1){ | |
122 | // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
122 | // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
123 | // nb_interrupt_f0 = nb_interrupt_f0 + 1; |
|
123 | // nb_interrupt_f0 = nb_interrupt_f0 + 1; | |
124 | // if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){ |
|
124 | // if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){ | |
125 | // if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
125 | // if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
126 | // { |
|
126 | // { | |
127 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
127 | // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
128 | // } |
|
128 | // } | |
129 | // nb_interrupt_f0 = 0; |
|
129 | // nb_interrupt_f0 = 0; | |
130 | // } |
|
130 | // } | |
131 | // } |
|
131 | // } | |
132 | //} |
|
132 | //} | |
133 |
|
133 | |||
134 | rtems_task spw_bppr_task(rtems_task_argument argument) |
|
134 | rtems_task spw_bppr_task(rtems_task_argument argument) | |
135 | { |
|
135 | { | |
136 | rtems_status_code status; |
|
136 | rtems_status_code status; | |
137 | rtems_event_set event_out; |
|
137 | rtems_event_set event_out; | |
138 |
|
138 | |||
139 | BOOT_PRINTF("in BPPR ***\n"); |
|
139 | BOOT_PRINTF("in BPPR ***\n"); | |
140 |
|
140 | |||
141 | while( true ){ // wait for an event to begin with the processing |
|
141 | while( true ){ // wait for an event to begin with the processing | |
142 | status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); |
|
142 | status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); | |
143 | } |
|
143 | } | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | rtems_task avf0_task(rtems_task_argument argument) |
|
146 | rtems_task avf0_task(rtems_task_argument argument) | |
147 | { |
|
147 | { | |
148 | int i; |
|
148 | int i; | |
149 | static int nb_average; |
|
149 | static int nb_average; | |
150 | rtems_event_set event_out; |
|
150 | rtems_event_set event_out; | |
151 | rtems_status_code status; |
|
151 | rtems_status_code status; | |
152 |
|
152 | |||
153 | nb_average = 0; |
|
153 | nb_average = 0; | |
154 |
|
154 | |||
155 | BOOT_PRINTF("in AVFO *** \n") |
|
155 | BOOT_PRINTF("in AVFO *** \n") | |
156 |
|
156 | |||
157 | while(1){ |
|
157 | while(1){ | |
158 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
158 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
159 | for(i=0; i<TOTAL_SIZE_SM; i++){ |
|
159 | for(i=0; i<TOTAL_SIZE_SM; i++){ | |
160 | averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i] |
|
160 | averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i] | |
161 | + spec_mat_f0_b[i] |
|
161 | + spec_mat_f0_b[i] | |
162 | + spec_mat_f0_c[i] |
|
162 | + spec_mat_f0_c[i] | |
163 | + spec_mat_f0_d[i] |
|
163 | + spec_mat_f0_d[i] | |
164 | + spec_mat_f0_e[i] |
|
164 | + spec_mat_f0_e[i] | |
165 | + spec_mat_f0_f[i] |
|
165 | + spec_mat_f0_f[i] | |
166 | + spec_mat_f0_g[i] |
|
166 | + spec_mat_f0_g[i] | |
167 | + spec_mat_f0_h[i]; |
|
167 | + spec_mat_f0_h[i]; | |
168 | } |
|
168 | } | |
169 | nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0; |
|
169 | nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0; | |
170 | if (nb_average == NB_AVERAGE_NORMAL_f0) { |
|
170 | if (nb_average == NB_AVERAGE_NORMAL_f0) { | |
171 | nb_average = 0; |
|
171 | nb_average = 0; | |
172 | status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0 |
|
172 | status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0 | |
173 | if (status != RTEMS_SUCCESSFUL) { |
|
173 | if (status != RTEMS_SUCCESSFUL) { | |
174 | printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status); |
|
174 | printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status); | |
175 | } |
|
175 | } | |
176 | } |
|
176 | } | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | rtems_task bpf0_task(rtems_task_argument argument) |
|
180 | rtems_task bpf0_task(rtems_task_argument argument) | |
181 | { |
|
181 | { | |
182 | rtems_event_set event_out; |
|
182 | rtems_event_set event_out; | |
183 |
|
183 | |||
184 | BOOT_PRINTF("in BPFO *** \n") |
|
184 | BOOT_PRINTF("in BPFO *** \n") | |
185 |
|
185 | |||
186 | while(1){ |
|
186 | while(1){ | |
187 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
187 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
188 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); |
|
188 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); | |
189 | BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0); |
|
189 | BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0); | |
190 | //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n") |
|
190 | //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n") | |
191 | } |
|
191 | } | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | rtems_task matr_task(rtems_task_argument argument) |
|
194 | rtems_task matr_task(rtems_task_argument argument) | |
195 | { |
|
195 | { | |
196 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
196 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
197 | rtems_event_set event_out; |
|
197 | rtems_event_set event_out; | |
198 | rtems_status_code status; |
|
198 | rtems_status_code status; | |
199 | rtems_id queue_id; |
|
199 | rtems_id queue_id; | |
200 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
200 | Header_TM_LFR_SCIENCE_ASM_t headerASM; | |
201 |
|
201 | |||
202 | init_header_asm( &headerASM ); |
|
202 | init_header_asm( &headerASM ); | |
203 |
|
203 | |||
204 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
204 | status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id ); | |
205 | if (status != RTEMS_SUCCESSFUL) |
|
205 | if (status != RTEMS_SUCCESSFUL) | |
206 | { |
|
206 | { | |
207 | PRINTF1("in MATR *** ERR getting queue id, %d\n", status) |
|
207 | PRINTF1("in MATR *** ERR getting queue id, %d\n", status) | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | BOOT_PRINTF("in MATR *** \n") |
|
210 | BOOT_PRINTF("in MATR *** \n") | |
211 |
|
211 | |||
212 | fill_averaged_spectral_matrix( ); |
|
212 | fill_averaged_spectral_matrix( ); | |
213 |
|
213 | |||
214 | while(1){ |
|
214 | while(1){ | |
215 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
215 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
216 |
|
216 | |||
217 | #ifdef GSA |
|
217 | #ifdef GSA | |
218 | #else |
|
218 | #else | |
219 | fill_averaged_spectral_matrix( ); |
|
219 | fill_averaged_spectral_matrix( ); | |
220 | #endif |
|
220 | #endif | |
221 | convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char); |
|
221 | convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char); | |
222 |
|
222 | |||
223 | send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); |
|
223 | send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id); | |
224 | } |
|
224 | } | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | //***************************** |
|
227 | //***************************** | |
228 | // Spectral matrices processing |
|
228 | // Spectral matrices processing | |
229 |
|
229 | |||
230 | void matrix_reset(volatile float *averaged_spec_mat) |
|
230 | void matrix_reset(volatile float *averaged_spec_mat) | |
231 | { |
|
231 | { | |
232 | // int i; |
|
232 | // int i; | |
233 | // for(i=0; i<TOTAL_SIZE_SM; i++){ |
|
233 | // for(i=0; i<TOTAL_SIZE_SM; i++){ | |
234 | // averaged_spec_mat_f0[i] = 0; |
|
234 | // averaged_spec_mat_f0[i] = 0; | |
235 | // } |
|
235 | // } | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat) |
|
238 | void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat) | |
239 | { |
|
239 | { | |
240 | int i; |
|
240 | int i; | |
241 | int j; |
|
241 | int j; | |
242 | switch (fChannel){ |
|
242 | switch (fChannel){ | |
243 | case 0: |
|
243 | case 0: | |
244 | for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){ |
|
244 | for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){ | |
245 | j = 17 + (i * 8); |
|
245 | j = 17 + (i * 8); | |
246 | compressed_spec_mat[i] = (averaged_spec_mat[j] |
|
246 | compressed_spec_mat[i] = (averaged_spec_mat[j] | |
247 | + averaged_spec_mat[j+1] |
|
247 | + averaged_spec_mat[j+1] | |
248 | + averaged_spec_mat[j+2] |
|
248 | + averaged_spec_mat[j+2] | |
249 | + averaged_spec_mat[j+3] |
|
249 | + averaged_spec_mat[j+3] | |
250 | + averaged_spec_mat[j+4] |
|
250 | + averaged_spec_mat[j+4] | |
251 | + averaged_spec_mat[j+5] |
|
251 | + averaged_spec_mat[j+5] | |
252 | + averaged_spec_mat[j+6] |
|
252 | + averaged_spec_mat[j+6] | |
253 | + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0); |
|
253 | + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0); | |
254 | } |
|
254 | } | |
255 | break; |
|
255 | break; | |
256 | case 1: |
|
256 | case 1: | |
257 | // case fChannel = f1 to be completed later |
|
257 | // case fChannel = f1 to be completed later | |
258 | break; |
|
258 | break; | |
259 | case 2: |
|
259 | case 2: | |
260 | // case fChannel = f1 to be completed later |
|
260 | // case fChannel = f1 to be completed later | |
261 | break; |
|
261 | break; | |
262 | default: |
|
262 | default: | |
263 | break; |
|
263 | break; | |
264 | } |
|
264 | } | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ |
|
267 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ | |
268 | int i; |
|
268 | int i; | |
269 | int j; |
|
269 | int j; | |
270 | unsigned char tmp_u_char; |
|
270 | unsigned char tmp_u_char; | |
271 | unsigned char * pt_char = NULL; |
|
271 | unsigned char * pt_char = NULL; | |
272 | float PSDB, PSDE; |
|
272 | float PSDB, PSDE; | |
273 | float NVEC_V0; |
|
273 | float NVEC_V0; | |
274 | float NVEC_V1; |
|
274 | float NVEC_V1; | |
275 | float NVEC_V2; |
|
275 | float NVEC_V2; | |
276 | //float significand; |
|
276 | //float significand; | |
277 | //int exponent; |
|
277 | //int exponent; | |
278 | float aux; |
|
278 | float aux; | |
279 | float tr_SB_SB; |
|
279 | float tr_SB_SB; | |
280 | float tmp; |
|
280 | float tmp; | |
281 | float sx_re; |
|
281 | float sx_re; | |
282 | float sx_im; |
|
282 | float sx_im; | |
283 | float nebx_re = 0; |
|
283 | float nebx_re = 0; | |
284 | float nebx_im = 0; |
|
284 | float nebx_im = 0; | |
285 | float ny = 0; |
|
285 | float ny = 0; | |
286 | float nz = 0; |
|
286 | float nz = 0; | |
287 | float bx_bx_star = 0; |
|
287 | float bx_bx_star = 0; | |
288 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ |
|
288 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ | |
289 | //============================================== |
|
289 | //============================================== | |
290 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits |
|
290 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits | |
291 | PSDB = compressed_spec_mat[i*30] // S11 |
|
291 | PSDB = compressed_spec_mat[i*30] // S11 | |
292 | + compressed_spec_mat[(i*30) + 10] // S22 |
|
292 | + compressed_spec_mat[(i*30) + 10] // S22 | |
293 | + compressed_spec_mat[(i*30) + 18]; // S33 |
|
293 | + compressed_spec_mat[(i*30) + 18]; // S33 | |
294 | //significand = frexp(PSDB, &exponent); |
|
294 | //significand = frexp(PSDB, &exponent); | |
295 | pt_char = (unsigned char*) &PSDB; |
|
295 | pt_char = (unsigned char*) &PSDB; | |
296 | LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float |
|
296 | LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float | |
297 | LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float |
|
297 | LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float | |
298 | //============================================== |
|
298 | //============================================== | |
299 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits |
|
299 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits | |
300 | PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44 |
|
300 | PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44 | |
301 | + compressed_spec_mat[(i*30) + 28] * K55_pe // S55 |
|
301 | + compressed_spec_mat[(i*30) + 28] * K55_pe // S55 | |
302 | + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45 |
|
302 | + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45 | |
303 | - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45 |
|
303 | - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45 | |
304 | pt_char = (unsigned char*) &PSDE; |
|
304 | pt_char = (unsigned char*) &PSDE; | |
305 | LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float |
|
305 | LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float | |
306 | LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float |
|
306 | LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float | |
307 | //============================================================================== |
|
307 | //============================================================================== | |
308 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits |
|
308 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits | |
309 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits |
|
309 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits | |
310 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits |
|
310 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits | |
311 | tmp = sqrt( |
|
311 | tmp = sqrt( | |
312 | compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12 |
|
312 | compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12 | |
313 | +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13 |
|
313 | +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13 | |
314 | +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23 |
|
314 | +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23 | |
315 | ); |
|
315 | ); | |
316 | NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23 |
|
316 | NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23 | |
317 | NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13 |
|
317 | NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13 | |
318 | NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12 |
|
318 | NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12 | |
319 | LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127); |
|
319 | LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127); | |
320 | LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127); |
|
320 | LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127); | |
321 | pt_char = (unsigned char*) &NVEC_V2; |
|
321 | pt_char = (unsigned char*) &NVEC_V2; | |
322 | LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 |
|
322 | LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 | |
323 | //======================================================= |
|
323 | //======================================================= | |
324 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits |
|
324 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits | |
325 | aux = 2*tmp / PSDB; // compute the ellipticity |
|
325 | aux = 2*tmp / PSDB; // compute the ellipticity | |
326 | tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity |
|
326 | tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity | |
327 | LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char |
|
327 | LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char | |
328 | //============================================================== |
|
328 | //============================================================== | |
329 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits |
|
329 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits | |
330 | for(j = 0; j<NB_VALUES_PER_SM;j++){ |
|
330 | for(j = 0; j<NB_VALUES_PER_SM;j++){ | |
331 | tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30] |
|
331 | tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30] | |
332 | + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10] |
|
332 | + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10] | |
333 | + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18] |
|
333 | + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18] | |
334 | + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2] |
|
334 | + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2] | |
335 | + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3] |
|
335 | + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3] | |
336 | + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4] |
|
336 | + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4] | |
337 | + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5] |
|
337 | + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5] | |
338 | + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12] |
|
338 | + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12] | |
339 | + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13]; |
|
339 | + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13]; | |
340 | } |
|
340 | } | |
341 | aux = PSDB*PSDB; |
|
341 | aux = PSDB*PSDB; | |
342 | tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) ); |
|
342 | tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) ); | |
343 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); |
|
343 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); | |
344 | LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char |
|
344 | LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char | |
345 | //======================================================================================= |
|
345 | //======================================================================================= | |
346 | // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) |
|
346 | // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) | |
347 | sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re |
|
347 | sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re | |
348 | + compressed_spec_mat[(i*30) + 6] * K14_sx_re |
|
348 | + compressed_spec_mat[(i*30) + 6] * K14_sx_re | |
349 | + compressed_spec_mat[(i*30) + 8] * K15_sx_re |
|
349 | + compressed_spec_mat[(i*30) + 8] * K15_sx_re | |
350 | + compressed_spec_mat[(i*30) + 14] * K24_sx_re |
|
350 | + compressed_spec_mat[(i*30) + 14] * K24_sx_re | |
351 | + compressed_spec_mat[(i*30) + 16] * K25_sx_re |
|
351 | + compressed_spec_mat[(i*30) + 16] * K25_sx_re | |
352 | + compressed_spec_mat[(i*30) + 22] * K35_sx_re; |
|
352 | + compressed_spec_mat[(i*30) + 22] * K35_sx_re; | |
353 | sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im |
|
353 | sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im | |
354 | + compressed_spec_mat[(i*30) + 7] * K14_sx_im |
|
354 | + compressed_spec_mat[(i*30) + 7] * K14_sx_im | |
355 | + compressed_spec_mat[(i*30) + 9] * K15_sx_im |
|
355 | + compressed_spec_mat[(i*30) + 9] * K15_sx_im | |
356 | + compressed_spec_mat[(i*30) + 15] * K24_sx_im |
|
356 | + compressed_spec_mat[(i*30) + 15] * K24_sx_im | |
357 | + compressed_spec_mat[(i*30) + 17] * K25_sx_im |
|
357 | + compressed_spec_mat[(i*30) + 17] * K25_sx_im | |
358 | + compressed_spec_mat[(i*30) + 23] * K35_sx_im; |
|
358 | + compressed_spec_mat[(i*30) + 23] * K35_sx_im; | |
359 | LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression |
|
359 | LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression | |
360 | if ( abs(sx_re) > abs(sx_im) ) { |
|
360 | if ( abs(sx_re) > abs(sx_im) ) { | |
361 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx |
|
361 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx | |
362 | } |
|
362 | } | |
363 | else { |
|
363 | else { | |
364 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx |
|
364 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx | |
365 | } |
|
365 | } | |
366 | //====================================================================== |
|
366 | //====================================================================== | |
367 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) |
|
367 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) | |
368 | ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2; |
|
368 | ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2; | |
369 | nz = NVEC_V0; |
|
369 | nz = NVEC_V0; | |
370 | bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22 |
|
370 | bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22 | |
371 | + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33 |
|
371 | + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33 | |
372 | - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23 |
|
372 | - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23 | |
373 | nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re |
|
373 | nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re | |
374 | +compressed_spec_mat[(i*30) + 16] * K25_ny_re |
|
374 | +compressed_spec_mat[(i*30) + 16] * K25_ny_re | |
375 | +compressed_spec_mat[(i*30) + 20] * K34_ny_re |
|
375 | +compressed_spec_mat[(i*30) + 20] * K34_ny_re | |
376 | +compressed_spec_mat[(i*30) + 22] * K35_ny_re) |
|
376 | +compressed_spec_mat[(i*30) + 22] * K35_ny_re) | |
377 | + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re |
|
377 | + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re | |
378 | +compressed_spec_mat[(i*30) + 16] * K25_nz_re |
|
378 | +compressed_spec_mat[(i*30) + 16] * K25_nz_re | |
379 | +compressed_spec_mat[(i*30) + 20] * K34_nz_re |
|
379 | +compressed_spec_mat[(i*30) + 20] * K34_nz_re | |
380 | +compressed_spec_mat[(i*30) + 22] * K35_nz_re); |
|
380 | +compressed_spec_mat[(i*30) + 22] * K35_nz_re); | |
381 | nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re |
|
381 | nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re | |
382 | +compressed_spec_mat[(i*30) + 17] * K25_ny_re |
|
382 | +compressed_spec_mat[(i*30) + 17] * K25_ny_re | |
383 | +compressed_spec_mat[(i*30) + 21] * K34_ny_re |
|
383 | +compressed_spec_mat[(i*30) + 21] * K34_ny_re | |
384 | +compressed_spec_mat[(i*30) + 23] * K35_ny_re) |
|
384 | +compressed_spec_mat[(i*30) + 23] * K35_ny_re) | |
385 | + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im |
|
385 | + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im | |
386 | +compressed_spec_mat[(i*30) + 17] * K25_nz_im |
|
386 | +compressed_spec_mat[(i*30) + 17] * K25_nz_im | |
387 | +compressed_spec_mat[(i*30) + 21] * K34_nz_im |
|
387 | +compressed_spec_mat[(i*30) + 21] * K34_nz_im | |
388 | +compressed_spec_mat[(i*30) + 23] * K35_nz_im); |
|
388 | +compressed_spec_mat[(i*30) + 23] * K35_nz_im); | |
389 | tmp = nebx_re / bx_bx_star; |
|
389 | tmp = nebx_re / bx_bx_star; | |
390 | LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression |
|
390 | LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression | |
391 | if ( abs(nebx_re) > abs(nebx_im) ) { |
|
391 | if ( abs(nebx_re) > abs(nebx_im) ) { | |
392 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx |
|
392 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx | |
393 | } |
|
393 | } | |
394 | else { |
|
394 | else { | |
395 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx |
|
395 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx | |
396 | } |
|
396 | } | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | } |
|
399 | } | |
400 |
|
400 | |||
401 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ |
|
401 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ | |
402 | // BP2 autocorrelation |
|
402 | // BP2 autocorrelation | |
403 | int i; |
|
403 | int i; | |
404 | int aux = 0; |
|
404 | int aux = 0; | |
405 |
|
405 | |||
406 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ |
|
406 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ | |
407 | // S12 |
|
407 | // S12 | |
408 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]); |
|
408 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]); | |
409 | compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux; |
|
409 | compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux; | |
410 | compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux; |
|
410 | compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux; | |
411 | // S13 |
|
411 | // S13 | |
412 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]); |
|
412 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]); | |
413 | compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux; |
|
413 | compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux; | |
414 | compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux; |
|
414 | compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux; | |
415 | // S23 |
|
415 | // S23 | |
416 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]); |
|
416 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]); | |
417 | compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux; |
|
417 | compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux; | |
418 | compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux; |
|
418 | compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux; | |
419 | // S45 |
|
419 | // S45 | |
420 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]); |
|
420 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]); | |
421 | compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux; |
|
421 | compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux; | |
422 | compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux; |
|
422 | compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux; | |
423 | // S14 |
|
423 | // S14 | |
424 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]); |
|
424 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]); | |
425 | compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux; |
|
425 | compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux; | |
426 | compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux; |
|
426 | compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux; | |
427 | // S15 |
|
427 | // S15 | |
428 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]); |
|
428 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]); | |
429 | compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux; |
|
429 | compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux; | |
430 | compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux; |
|
430 | compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux; | |
431 | // S24 |
|
431 | // S24 | |
432 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]); |
|
432 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]); | |
433 | compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux; |
|
433 | compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux; | |
434 | compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux; |
|
434 | compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux; | |
435 | // S25 |
|
435 | // S25 | |
436 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]); |
|
436 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]); | |
437 | compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux; |
|
437 | compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux; | |
438 | compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux; |
|
438 | compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux; | |
439 | // S34 |
|
439 | // S34 | |
440 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]); |
|
440 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]); | |
441 | compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux; |
|
441 | compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux; | |
442 | compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux; |
|
442 | compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux; | |
443 | // S35 |
|
443 | // S35 | |
444 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]); |
|
444 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]); | |
445 | compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux; |
|
445 | compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux; | |
446 | compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux; |
|
446 | compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux; | |
447 | } |
|
447 | } | |
448 | } |
|
448 | } | |
449 |
|
449 | |||
450 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header) |
|
450 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header) | |
451 | { |
|
451 | { | |
452 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
452 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
453 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
453 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
454 | header->reserved = 0x00; |
|
454 | header->reserved = 0x00; | |
455 | header->userApplication = CCSDS_USER_APP; |
|
455 | header->userApplication = CCSDS_USER_APP; | |
456 | header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
456 | header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |
457 | header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
457 | header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |
458 | header->packetSequenceControl[0] = 0xc0; |
|
458 | header->packetSequenceControl[0] = 0xc0; | |
459 | header->packetSequenceControl[1] = 0x00; |
|
459 | header->packetSequenceControl[1] = 0x00; | |
460 | header->packetLength[0] = 0x00; |
|
460 | header->packetLength[0] = 0x00; | |
461 | header->packetLength[1] = 0x00; |
|
461 | header->packetLength[1] = 0x00; | |
462 | // DATA FIELD HEADER |
|
462 | // DATA FIELD HEADER | |
463 | header->spare1_pusVersion_spare2 = 0x10; |
|
463 | header->spare1_pusVersion_spare2 = 0x10; | |
464 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
464 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
465 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
465 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
466 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
466 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
467 | // AUXILIARY DATA HEADER |
|
467 | // AUXILIARY DATA HEADER | |
468 | header->sid = 0x00; |
|
468 | header->sid = 0x00; | |
469 | header->biaStatusInfo = 0x00; |
|
469 | header->biaStatusInfo = 0x00; | |
470 | header->cntASM = 0x00; |
|
470 | header->cntASM = 0x00; | |
471 | header->nrASM = 0x00; |
|
471 | header->nrASM = 0x00; | |
472 | header->time[0] = 0x00; |
|
472 | header->time[0] = 0x00; | |
473 | header->time[0] = 0x00; |
|
473 | header->time[0] = 0x00; | |
474 | header->time[0] = 0x00; |
|
474 | header->time[0] = 0x00; | |
475 | header->time[0] = 0x00; |
|
475 | header->time[0] = 0x00; | |
476 | header->time[0] = 0x00; |
|
476 | header->time[0] = 0x00; | |
477 | header->time[0] = 0x00; |
|
477 | header->time[0] = 0x00; | |
478 | header->blkNr[0] = 0x00; // BLK_NR MSB |
|
478 | header->blkNr[0] = 0x00; // BLK_NR MSB | |
479 | header->blkNr[1] = 0x00; // BLK_NR LSB |
|
479 | header->blkNr[1] = 0x00; // BLK_NR LSB | |
480 | } |
|
480 | } | |
481 |
|
481 | |||
482 | void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, |
|
482 | void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix, | |
483 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id) |
|
483 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id) | |
484 | { |
|
484 | { | |
485 | unsigned int i; |
|
485 | unsigned int i; | |
486 | unsigned int length = 0; |
|
486 | unsigned int length = 0; | |
487 | rtems_status_code status; |
|
487 | rtems_status_code status; | |
488 |
|
488 | |||
489 | header->sid = (unsigned char) sid; |
|
489 | header->sid = (unsigned char) sid; | |
490 |
|
490 | |||
491 | for (i=0; i<2; i++) |
|
491 | for (i=0; i<2; i++) | |
492 | { |
|
492 | { | |
493 | // BUILD THE DATA |
|
493 | // BUILD THE DATA | |
494 | spw_ioctl_send->dlen = TOTAL_SIZE_SM; |
|
494 | spw_ioctl_send->dlen = TOTAL_SIZE_SM; | |
495 | spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM]; |
|
495 | spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM]; | |
496 | spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
496 | spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
497 | spw_ioctl_send->hdr = (char *) header; |
|
497 | spw_ioctl_send->hdr = (char *) header; | |
498 | spw_ioctl_send->options = 0; |
|
498 | spw_ioctl_send->options = 0; | |
499 |
|
499 | |||
500 | // BUILD THE HEADER |
|
500 | // BUILD THE HEADER | |
501 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM; |
|
501 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM; | |
502 | header->packetLength[0] = (unsigned char) (length>>8); |
|
502 | header->packetLength[0] = (unsigned char) (length>>8); | |
503 | header->packetLength[1] = (unsigned char) (length); |
|
503 | header->packetLength[1] = (unsigned char) (length); | |
504 | header->sid = (unsigned char) sid; // SID |
|
504 | header->sid = (unsigned char) sid; // SID | |
505 | header->cntASM = 2; |
|
505 | header->cntASM = 2; | |
506 | header->nrASM = (unsigned char) (i+1); |
|
506 | header->nrASM = (unsigned char) (i+1); | |
507 | header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB |
|
507 | header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB | |
508 | header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB |
|
508 | header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB | |
509 | // SET PACKET TIME |
|
509 | // SET PACKET TIME | |
510 | header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
510 | header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
511 | header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
511 | header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
512 | header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
512 | header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
513 | header->time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
513 | header->time[3] = (unsigned char) (time_management_regs->coarse_time); | |
514 | header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
514 | header->time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
515 | header->time[5] = (unsigned char) (time_management_regs->fine_time); |
|
515 | header->time[5] = (unsigned char) (time_management_regs->fine_time); | |
516 | header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
516 | header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
517 | header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
517 | header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
518 | header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
518 | header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
519 | header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); |
|
519 | header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); | |
520 | header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
520 | header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
521 | header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); |
|
521 | header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); | |
522 | // SEND PACKET |
|
522 | // SEND PACKET | |
523 | status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
523 | status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_SPW_IOCTL_SEND_SIZE); | |
524 | if (status != RTEMS_SUCCESSFUL) { |
|
524 | if (status != RTEMS_SUCCESSFUL) { | |
525 | printf("in send_spectral_matrix *** ERR %d\n", (int) status); |
|
525 | printf("in send_spectral_matrix *** ERR %d\n", (int) status); | |
526 | } |
|
526 | } | |
527 | } |
|
527 | } | |
528 | } |
|
528 | } | |
529 |
|
529 | |||
530 | void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix) |
|
530 | void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix) | |
531 | { |
|
531 | { | |
532 | unsigned int i; |
|
532 | unsigned int i; | |
533 | unsigned int j; |
|
533 | unsigned int j; | |
534 | char * pt_char_input; |
|
534 | char * pt_char_input; | |
535 | char * pt_char_output; |
|
535 | char * pt_char_output; | |
536 |
|
536 | |||
537 | pt_char_input = NULL; |
|
537 | pt_char_input = NULL; | |
538 | pt_char_output = NULL; |
|
538 | pt_char_output = NULL; | |
539 |
|
539 | |||
540 | for( i=0; i<NB_BINS_PER_SM; i++) |
|
540 | for( i=0; i<NB_BINS_PER_SM; i++) | |
541 | { |
|
541 | { | |
542 | for ( j=0; j<NB_VALUES_PER_SM; j++) |
|
542 | for ( j=0; j<NB_VALUES_PER_SM; j++) | |
543 | { |
|
543 | { | |
544 | pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ]; |
|
544 | pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ]; | |
545 | pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ]; |
|
545 | pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ]; | |
546 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
546 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float | |
547 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
547 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float | |
548 | } |
|
548 | } | |
549 | } |
|
549 | } | |
550 | } |
|
550 | } | |
551 |
|
551 | |||
552 | void fill_averaged_spectral_matrix(void) |
|
552 | void fill_averaged_spectral_matrix(void) | |
553 | { |
|
553 | { | |
554 | /** This function fills spectral matrices related buffers with arbitrary data. |
|
554 | /** This function fills spectral matrices related buffers with arbitrary data. | |
555 | * |
|
555 | * | |
556 | * This function is for testing purpose only. |
|
556 | * This function is for testing purpose only. | |
557 | * |
|
557 | * | |
558 | */ |
|
558 | */ | |
559 |
|
559 | |||
560 | #ifdef GSA |
|
560 | #ifdef GSA | |
561 | float offset = 10.; |
|
561 | float offset = 10.; | |
562 | float coeff = 100000.; |
|
562 | float coeff = 100000.; | |
563 |
|
563 | |||
564 | averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset; |
|
564 | averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset; | |
565 | averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset; |
|
565 | averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset; | |
566 | averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset; |
|
566 | averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset; | |
567 | averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset; |
|
567 | averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset; | |
568 | averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset; |
|
568 | averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset; | |
569 | averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset; |
|
569 | averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset; | |
570 | averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset; |
|
570 | averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset; | |
571 | averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset; |
|
571 | averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset; | |
572 | averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset; |
|
572 | averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset; | |
573 | averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset; |
|
573 | averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset; | |
574 | averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset; |
|
574 | averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset; | |
575 | averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset; |
|
575 | averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset; | |
576 | averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset; |
|
576 | averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset; | |
577 | averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset; |
|
577 | averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset; | |
578 | averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset; |
|
578 | averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset; | |
579 | averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff; |
|
579 | averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff; | |
580 | averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff; |
|
580 | averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff; | |
581 | averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff; |
|
581 | averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff; | |
582 | averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff; |
|
582 | averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff; | |
583 | averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff; |
|
583 | averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff; | |
584 | averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff; |
|
584 | averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff; | |
585 | averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff; |
|
585 | averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff; | |
586 | averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff; |
|
586 | averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff; | |
587 | averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff; |
|
587 | averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff; | |
588 | averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff; |
|
588 | averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff; | |
589 | averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff; |
|
589 | averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff; | |
590 | averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff; |
|
590 | averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff; | |
591 | averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff; |
|
591 | averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff; | |
592 | averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff; |
|
592 | averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff; | |
593 | averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff; |
|
593 | averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff; | |
594 | offset = 10000000; |
|
594 | offset = 10000000; | |
595 | averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff; |
|
595 | averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff; | |
596 | averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff; |
|
596 | averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff; | |
597 | averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff; |
|
597 | averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff; | |
598 | averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff; |
|
598 | averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff; | |
599 | averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff; |
|
599 | averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff; | |
600 | averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff; |
|
600 | averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff; | |
601 | averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff; |
|
601 | averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff; | |
602 | averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff; |
|
602 | averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff; | |
603 | averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff; |
|
603 | averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff; | |
604 | averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff; |
|
604 | averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff; | |
605 | averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff; |
|
605 | averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff; | |
606 | averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff; |
|
606 | averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff; | |
607 | averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff; |
|
607 | averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff; | |
608 | averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff; |
|
608 | averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff; | |
609 | averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff; |
|
609 | averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff; | |
610 |
|
610 | |||
611 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ]; |
|
611 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ]; | |
612 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ]; |
|
612 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ]; | |
613 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ]; |
|
613 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ]; | |
614 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ]; |
|
614 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ]; | |
615 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ]; |
|
615 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ]; | |
616 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ]; |
|
616 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ]; | |
617 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ]; |
|
617 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ]; | |
618 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ]; |
|
618 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ]; | |
619 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ]; |
|
619 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ]; | |
620 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ]; |
|
620 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ]; | |
621 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ]; |
|
621 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ]; | |
622 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ]; |
|
622 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ]; | |
623 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ]; |
|
623 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ]; | |
624 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ]; |
|
624 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ]; | |
625 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ]; |
|
625 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ]; | |
626 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ]; |
|
626 | averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ]; | |
627 | #else |
|
627 | #else | |
628 | unsigned int i; |
|
628 | unsigned int i; | |
629 |
|
629 | |||
630 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
630 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
631 | { |
|
631 | { | |
632 | if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0) |
|
632 | if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0) | |
633 | averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ]; |
|
633 | averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ]; | |
634 | else |
|
634 | else | |
635 | averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ]; |
|
635 | averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ]; | |
636 | } |
|
636 | } | |
637 | #endif |
|
637 | #endif | |
638 | } |
|
638 | } | |
639 |
|
639 | |||
640 | void reset_spectral_matrix_regs() |
|
640 | void reset_spectral_matrix_regs() | |
641 | { |
|
641 | { | |
642 | /** This function resets the spectral matrices module registers. |
|
642 | /** This function resets the spectral matrices module registers. | |
643 | * |
|
643 | * | |
644 | * The registers affected by this function are located at the following offset addresses: |
|
644 | * The registers affected by this function are located at the following offset addresses: | |
645 | * |
|
645 | * | |
646 | * - 0x00 config |
|
646 | * - 0x00 config | |
647 | * - 0x04 status |
|
647 | * - 0x04 status | |
648 | * - 0x08 matrixF0_Address0 |
|
648 | * - 0x08 matrixF0_Address0 | |
649 | * - 0x10 matrixFO_Address1 |
|
649 | * - 0x10 matrixFO_Address1 | |
650 | * - 0x14 matrixF1_Address |
|
650 | * - 0x14 matrixF1_Address | |
651 | * - 0x18 matrixF2_Address |
|
651 | * - 0x18 matrixF2_Address | |
652 | * |
|
652 | * | |
653 | */ |
|
653 | */ | |
654 |
|
654 | |||
655 | #ifdef GSA |
|
655 | #ifdef GSA | |
656 | #else |
|
656 | #else | |
657 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0; |
|
657 | spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0; | |
658 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; |
|
658 | spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; | |
659 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; |
|
659 | spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; | |
660 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; |
|
660 | spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; | |
661 | #endif |
|
661 | #endif | |
662 | } |
|
662 | } | |
663 |
|
663 | |||
664 | //****************** |
|
664 | //****************** | |
665 | // general functions |
|
665 | // general functions | |
666 |
|
666 | |||
667 |
|
667 | |||
668 |
|
668 | |||
669 |
|
669 |
@@ -1,1284 +1,1284 | |||||
1 | /** Functions and tasks related to TeleCommand handling. |
|
1 | /** Functions and tasks related to TeleCommand handling. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TeleCommands:\n |
|
6 | * A group of functions to handle TeleCommands:\n | |
7 | * action launching\n |
|
7 | * action launching\n | |
8 | * TC parsing\n |
|
8 | * TC parsing\n | |
9 | * ... |
|
9 | * ... | |
10 | * |
|
10 | * | |
11 | */ |
|
11 | */ | |
12 |
|
12 | |||
13 | #include "tc_handler.h" |
|
13 | #include "tc_handler.h" | |
14 |
|
14 | |||
15 | char *DumbMessages[6] = {"in DUMB *** default", // RTEMS_EVENT_0 |
|
15 | char *DumbMessages[6] = {"in DUMB *** default", // RTEMS_EVENT_0 | |
16 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
16 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 | |
17 | "in DUMB *** waveforms_isr", // RTEMS_EVENT_2 |
|
17 | "in DUMB *** waveforms_isr", // RTEMS_EVENT_2 | |
18 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
18 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 | |
19 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
19 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 | |
20 | "in DUMB *** waveforms_simulator_isr" // RTEMS_EVENT_5 |
|
20 | "in DUMB *** waveforms_simulator_isr" // RTEMS_EVENT_5 | |
21 | }; |
|
21 | }; | |
22 |
|
22 | |||
23 | unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field |
|
23 | unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field | |
24 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; |
|
24 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; | |
25 | unsigned int currentTM_length; |
|
25 | unsigned int currentTM_length; | |
26 | unsigned char currentTC_processedFlag; |
|
26 | unsigned char currentTC_processedFlag; | |
27 |
|
27 | |||
28 | unsigned int lookUpTableForCRC[256]; |
|
28 | unsigned int lookUpTableForCRC[256]; | |
29 |
|
29 | |||
30 | //********************** |
|
30 | //********************** | |
31 | // GENERAL USE FUNCTIONS |
|
31 | // GENERAL USE FUNCTIONS | |
32 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) |
|
32 | unsigned int Crc_opt( unsigned char D, unsigned int Chk) | |
33 | { |
|
33 | { | |
34 | /** This function generate the CRC for one byte and returns the value of the new syndrome. |
|
34 | /** This function generate the CRC for one byte and returns the value of the new syndrome. | |
35 | * |
|
35 | * | |
36 | * @param D is the current byte of data. |
|
36 | * @param D is the current byte of data. | |
37 | * @param Chk is the current syndrom value. |
|
37 | * @param Chk is the current syndrom value. | |
38 | * @return the value of the new syndrome on two bytes. |
|
38 | * @return the value of the new syndrome on two bytes. | |
39 | * |
|
39 | * | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); |
|
42 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | void initLookUpTableForCRC( void ) |
|
45 | void initLookUpTableForCRC( void ) | |
46 | { |
|
46 | { | |
47 | /** This function is used to initiates the look-up table for fast CRC computation. |
|
47 | /** This function is used to initiates the look-up table for fast CRC computation. | |
48 | * |
|
48 | * | |
49 | * The global table lookUpTableForCRC[256] is initiated. |
|
49 | * The global table lookUpTableForCRC[256] is initiated. | |
50 | * |
|
50 | * | |
51 | */ |
|
51 | */ | |
52 |
|
52 | |||
53 | unsigned int i; |
|
53 | unsigned int i; | |
54 | unsigned int tmp; |
|
54 | unsigned int tmp; | |
55 |
|
55 | |||
56 | for (i=0; i<256; i++) |
|
56 | for (i=0; i<256; i++) | |
57 | { |
|
57 | { | |
58 | tmp = 0; |
|
58 | tmp = 0; | |
59 | if((i & 1) != 0) { |
|
59 | if((i & 1) != 0) { | |
60 | tmp = tmp ^ 0x1021; |
|
60 | tmp = tmp ^ 0x1021; | |
61 | } |
|
61 | } | |
62 | if((i & 2) != 0) { |
|
62 | if((i & 2) != 0) { | |
63 | tmp = tmp ^ 0x2042; |
|
63 | tmp = tmp ^ 0x2042; | |
64 | } |
|
64 | } | |
65 | if((i & 4) != 0) { |
|
65 | if((i & 4) != 0) { | |
66 | tmp = tmp ^ 0x4084; |
|
66 | tmp = tmp ^ 0x4084; | |
67 | } |
|
67 | } | |
68 | if((i & 8) != 0) { |
|
68 | if((i & 8) != 0) { | |
69 | tmp = tmp ^ 0x8108; |
|
69 | tmp = tmp ^ 0x8108; | |
70 | } |
|
70 | } | |
71 | if((i & 16) != 0) { |
|
71 | if((i & 16) != 0) { | |
72 | tmp = tmp ^ 0x1231; |
|
72 | tmp = tmp ^ 0x1231; | |
73 | } |
|
73 | } | |
74 | if((i & 32) != 0) { |
|
74 | if((i & 32) != 0) { | |
75 | tmp = tmp ^ 0x2462; |
|
75 | tmp = tmp ^ 0x2462; | |
76 | } |
|
76 | } | |
77 | if((i & 64) != 0) { |
|
77 | if((i & 64) != 0) { | |
78 | tmp = tmp ^ 0x48c4; |
|
78 | tmp = tmp ^ 0x48c4; | |
79 | } |
|
79 | } | |
80 | if((i & 128) != 0) { |
|
80 | if((i & 128) != 0) { | |
81 | tmp = tmp ^ 0x9188; |
|
81 | tmp = tmp ^ 0x9188; | |
82 | } |
|
82 | } | |
83 | lookUpTableForCRC[i] = tmp; |
|
83 | lookUpTableForCRC[i] = tmp; | |
84 | } |
|
84 | } | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) |
|
87 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData) | |
88 | { |
|
88 | { | |
89 | /** This function calculates a two bytes Cyclic Redundancy Code. |
|
89 | /** This function calculates a two bytes Cyclic Redundancy Code. | |
90 | * |
|
90 | * | |
91 | * @param data points to a buffer containing the data on which to compute the CRC. |
|
91 | * @param data points to a buffer containing the data on which to compute the CRC. | |
92 | * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored. |
|
92 | * @param crcAsTwoBytes points points to a two bytes buffer in which the CRC is stored. | |
93 | * @param sizeOfData is the number of bytes of *data* used to compute the CRC. |
|
93 | * @param sizeOfData is the number of bytes of *data* used to compute the CRC. | |
94 | * |
|
94 | * | |
95 | * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A. |
|
95 | * The specification of the Cyclic Redundancy Code is described in the following document: ECSS-E-70-41-A. | |
96 | * |
|
96 | * | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | unsigned int Chk; |
|
99 | unsigned int Chk; | |
100 | int j; |
|
100 | int j; | |
101 | Chk = 0xffff; // reset the syndrom to all ones |
|
101 | Chk = 0xffff; // reset the syndrom to all ones | |
102 | for (j=0; j<sizeOfData; j++) { |
|
102 | for (j=0; j<sizeOfData; j++) { | |
103 | Chk = Crc_opt(data[j], Chk); |
|
103 | Chk = Crc_opt(data[j], Chk); | |
104 | } |
|
104 | } | |
105 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); |
|
105 | crcAsTwoBytes[0] = (unsigned char) (Chk >> 8); | |
106 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); |
|
106 | crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff); | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | void updateLFRCurrentMode() |
|
109 | void updateLFRCurrentMode() | |
110 | { |
|
110 | { | |
111 | /** This function updates the value of the global variable lfrCurrentMode. |
|
111 | /** This function updates the value of the global variable lfrCurrentMode. | |
112 | * |
|
112 | * | |
113 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
113 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
114 | * |
|
114 | * | |
115 | */ |
|
115 | */ | |
116 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
116 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
117 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
117 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | //********************* |
|
120 | //********************* | |
121 | // ACCEPTANCE FUNCTIONS |
|
121 | // ACCEPTANCE FUNCTIONS | |
122 |
int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv, rtems_id queue_ |
|
122 | int tc_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv, rtems_id queue_recv_id, rtems_id queue_send_id) | |
123 | { |
|
123 | { | |
124 | /** This function executes the TeleCommand acceptance steps. |
|
124 | /** This function executes the TeleCommand acceptance steps. | |
125 | * |
|
125 | * | |
126 | * @param TC points to the TeleCommand packet which is under investigation. |
|
126 | * @param TC points to the TeleCommand packet which is under investigation. | |
127 | * @param tc_len_recv contains the length of the packet that has been received. |
|
127 | * @param tc_len_recv contains the length of the packet that has been received. | |
128 |
* @param queue_ |
|
128 | * @param queue_recv_id is the id of the rtems queue in which messages are written if the acceptance is not successful | |
129 |
* @param queue_ |
|
129 | * @param queue_send_id is the id of the rtems queue in which messages are written if the acceptance is successful | |
130 | * @return status code |
|
130 | * @return status code | |
131 | * |
|
131 | * | |
132 | * The acceptance steps can result in two different actions. |
|
132 | * The acceptance steps can result in two different actions. | |
133 | * 1. If the acceptance is successful, the TC is sent in the receiving queue for processing. |
|
133 | * 1. If the acceptance is successful, the TC is sent in the receiving queue for processing. | |
134 | * 2. If the acceptance fails, a TM packet is transmitted to report the error. |
|
134 | * 2. If the acceptance fails, a TM packet is transmitted to report the error. | |
135 | * |
|
135 | * | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | int ret = 0; |
|
138 | int ret = 0; | |
139 | rtems_status_code status; |
|
139 | rtems_status_code status; | |
140 | unsigned int parserCode = 0; |
|
140 | unsigned int parserCode = 0; | |
141 | unsigned char computed_CRC[2]; |
|
141 | unsigned char computed_CRC[2]; | |
142 |
|
142 | |||
143 | GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 ); |
|
143 | GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 ); | |
144 | parserCode = tc_parser( TC, tc_len_recv ) ; |
|
144 | parserCode = tc_parser( TC, tc_len_recv ) ; | |
145 | if ( (parserCode == ILLEGAL_APID) | (parserCode == WRONG_LEN_PACKET) | (parserCode == INCOR_CHECKSUM) |
|
145 | if ( (parserCode == ILLEGAL_APID) | (parserCode == WRONG_LEN_PACKET) | (parserCode == INCOR_CHECKSUM) | |
146 | | (parserCode == ILL_TYPE) | (parserCode == ILL_SUBTYPE) | (parserCode == WRONG_APP_DATA) ) |
|
146 | | (parserCode == ILL_TYPE) | (parserCode == ILL_SUBTYPE) | (parserCode == WRONG_APP_DATA) ) | |
147 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
147 | { // send TM_LFR_TC_EXE_CORRUPTED | |
148 |
send_tm_lfr_tc_exe_corrupted( TC, queue_ |
|
148 | send_tm_lfr_tc_exe_corrupted( TC, queue_send_id, computed_CRC, currentTC_LEN_RCV ); | |
149 | } |
|
149 | } | |
150 | else { // send valid TC to the action launcher |
|
150 | else { // send valid TC to the action launcher | |
151 |
status = rtems_message_queue_send( queue_ |
|
151 | status = rtems_message_queue_send( queue_recv_id, TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
152 | ret = LFR_SUCCESSFUL; |
|
152 | ret = LFR_SUCCESSFUL; | |
153 | } |
|
153 | } | |
154 | return ret; |
|
154 | return ret; | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
157 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV) |
|
157 | int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV) | |
158 | { |
|
158 | { | |
159 | /** This function parses TeleCommands. |
|
159 | /** This function parses TeleCommands. | |
160 | * |
|
160 | * | |
161 | * @param TC points to the TeleCommand that will be parsed. |
|
161 | * @param TC points to the TeleCommand that will be parsed. | |
162 | * @param TC_LEN_RCV is the received packet length. |
|
162 | * @param TC_LEN_RCV is the received packet length. | |
163 | * @return Status code of the parsing. |
|
163 | * @return Status code of the parsing. | |
164 | * |
|
164 | * | |
165 | * The parsing checks: |
|
165 | * The parsing checks: | |
166 | * - process id |
|
166 | * - process id | |
167 | * - category |
|
167 | * - category | |
168 | * - length: a global check is performed and a per subtype check also |
|
168 | * - length: a global check is performed and a per subtype check also | |
169 | * - type |
|
169 | * - type | |
170 | * - subtype |
|
170 | * - subtype | |
171 | * - crc |
|
171 | * - crc | |
172 | * |
|
172 | * | |
173 | */ |
|
173 | */ | |
174 |
|
174 | |||
175 | int status; |
|
175 | int status; | |
176 | unsigned char pid; |
|
176 | unsigned char pid; | |
177 | unsigned char category; |
|
177 | unsigned char category; | |
178 | unsigned int length; |
|
178 | unsigned int length; | |
179 | unsigned char packetType; |
|
179 | unsigned char packetType; | |
180 | unsigned char packetSubtype; |
|
180 | unsigned char packetSubtype; | |
181 |
|
181 | |||
182 | status = CCSDS_TM_VALID; |
|
182 | status = CCSDS_TM_VALID; | |
183 |
|
183 | |||
184 | // APID check *** APID on 2 bytes |
|
184 | // APID check *** APID on 2 bytes | |
185 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx |
|
185 | pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx | |
186 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 |
|
186 | category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 | |
187 | length = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; |
|
187 | length = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1]; | |
188 | packetType = TCPacket->serviceType; |
|
188 | packetType = TCPacket->serviceType; | |
189 | packetSubtype = TCPacket->serviceSubType; |
|
189 | packetSubtype = TCPacket->serviceSubType; | |
190 |
|
190 | |||
191 | if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID |
|
191 | if ( pid != CCSDS_PROCESS_ID ) // CHECK THE PROCESS ID | |
192 | { |
|
192 | { | |
193 | status = ILLEGAL_APID; |
|
193 | status = ILLEGAL_APID; | |
194 | } |
|
194 | } | |
195 | if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY |
|
195 | if (status == CCSDS_TM_VALID) // CHECK THE CATEGORY | |
196 | { |
|
196 | { | |
197 | if ( category != CCSDS_PACKET_CATEGORY ) |
|
197 | if ( category != CCSDS_PACKET_CATEGORY ) | |
198 | { |
|
198 | { | |
199 | status = ILLEGAL_APID; |
|
199 | status = ILLEGAL_APID; | |
200 | } |
|
200 | } | |
201 | } |
|
201 | } | |
202 | if (status == CCSDS_TM_VALID) // CHECK THE PACKET LENGTH FIELD AND THE ACTUAL LENGTH COMPLIANCE |
|
202 | if (status == CCSDS_TM_VALID) // CHECK THE PACKET LENGTH FIELD AND THE ACTUAL LENGTH COMPLIANCE | |
203 | { |
|
203 | { | |
204 | if (length != TC_LEN_RCV ) { |
|
204 | if (length != TC_LEN_RCV ) { | |
205 | status = WRONG_LEN_PACKET; |
|
205 | status = WRONG_LEN_PACKET; | |
206 | } |
|
206 | } | |
207 | } |
|
207 | } | |
208 | if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE |
|
208 | if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE | |
209 | { |
|
209 | { | |
210 | if ( length >= CCSDS_TC_PKT_MAX_SIZE ) { |
|
210 | if ( length >= CCSDS_TC_PKT_MAX_SIZE ) { | |
211 | status = WRONG_LEN_PACKET; |
|
211 | status = WRONG_LEN_PACKET; | |
212 | } |
|
212 | } | |
213 | } |
|
213 | } | |
214 | if (status == CCSDS_TM_VALID) // CHECK THE TYPE |
|
214 | if (status == CCSDS_TM_VALID) // CHECK THE TYPE | |
215 | { |
|
215 | { | |
216 | status = tc_check_type( packetType ); |
|
216 | status = tc_check_type( packetType ); | |
217 | } |
|
217 | } | |
218 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE |
|
218 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE | |
219 | { |
|
219 | { | |
220 | status = tc_check_subtype( packetSubtype ); |
|
220 | status = tc_check_subtype( packetSubtype ); | |
221 | } |
|
221 | } | |
222 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE |
|
222 | if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE | |
223 | { |
|
223 | { | |
224 | status = tc_check_length( packetSubtype, length ); |
|
224 | status = tc_check_length( packetSubtype, length ); | |
225 | } |
|
225 | } | |
226 | if (status == CCSDS_TM_VALID ) // CHECK CRC |
|
226 | if (status == CCSDS_TM_VALID ) // CHECK CRC | |
227 | { |
|
227 | { | |
228 | status = tc_check_crc( TCPacket, length ); |
|
228 | status = tc_check_crc( TCPacket, length ); | |
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 | return status; |
|
231 | return status; | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | int tc_check_type( unsigned char packetType ) |
|
234 | int tc_check_type( unsigned char packetType ) | |
235 | { |
|
235 | { | |
236 | /** This function checks that the type of a TeleCommand is valid. |
|
236 | /** This function checks that the type of a TeleCommand is valid. | |
237 | * |
|
237 | * | |
238 | * @param packetType is the type to check. |
|
238 | * @param packetType is the type to check. | |
239 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
239 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. | |
240 | * |
|
240 | * | |
241 | */ |
|
241 | */ | |
242 |
|
242 | |||
243 | int status; |
|
243 | int status; | |
244 |
|
244 | |||
245 | if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME)) |
|
245 | if ( (packetType == TC_TYPE_GEN) || (packetType == TC_TYPE_TIME)) | |
246 | { |
|
246 | { | |
247 | status = CCSDS_TM_VALID; |
|
247 | status = CCSDS_TM_VALID; | |
248 | } |
|
248 | } | |
249 | else |
|
249 | else | |
250 | { |
|
250 | { | |
251 | status = ILL_TYPE; |
|
251 | status = ILL_TYPE; | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | return status; |
|
254 | return status; | |
255 | } |
|
255 | } | |
256 |
|
256 | |||
257 | int tc_check_subtype( unsigned char packetSubType ) |
|
257 | int tc_check_subtype( unsigned char packetSubType ) | |
258 | { |
|
258 | { | |
259 | /** This function checks that the subtype of a TeleCommand is valid. |
|
259 | /** This function checks that the subtype of a TeleCommand is valid. | |
260 | * |
|
260 | * | |
261 | * @param packetSubType is the subtype to check. |
|
261 | * @param packetSubType is the subtype to check. | |
262 | * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. |
|
262 | * @return Status code CCSDS_TM_VALID or ILL_SUBTYPE. | |
263 | * |
|
263 | * | |
264 | */ |
|
264 | */ | |
265 |
|
265 | |||
266 | int status; |
|
266 | int status; | |
267 |
|
267 | |||
268 | if ( (packetSubType == TC_SUBTYPE_RESET) |
|
268 | if ( (packetSubType == TC_SUBTYPE_RESET) | |
269 | || (packetSubType == TC_SUBTYPE_LOAD_COMM) |
|
269 | || (packetSubType == TC_SUBTYPE_LOAD_COMM) | |
270 | || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) |
|
270 | || (packetSubType == TC_SUBTYPE_LOAD_NORM) || (packetSubType == TC_SUBTYPE_LOAD_BURST) | |
271 | || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) |
|
271 | || (packetSubType == TC_SUBTYPE_LOAD_SBM1) || (packetSubType == TC_SUBTYPE_LOAD_SBM2) | |
272 | || (packetSubType == TC_SUBTYPE_DUMP) |
|
272 | || (packetSubType == TC_SUBTYPE_DUMP) | |
273 | || (packetSubType == TC_SUBTYPE_ENTER) |
|
273 | || (packetSubType == TC_SUBTYPE_ENTER) | |
274 | || (packetSubType == TC_SUBTYPE_UPDT_INFO) || (packetSubType == TC_SUBTYPE_UPDT_TIME) |
|
274 | || (packetSubType == TC_SUBTYPE_UPDT_INFO) || (packetSubType == TC_SUBTYPE_UPDT_TIME) | |
275 | || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) ) |
|
275 | || (packetSubType == TC_SUBTYPE_EN_CAL) || (packetSubType == TC_SUBTYPE_DIS_CAL) ) | |
276 | { |
|
276 | { | |
277 | status = CCSDS_TM_VALID; |
|
277 | status = CCSDS_TM_VALID; | |
278 | } |
|
278 | } | |
279 | else |
|
279 | else | |
280 | { |
|
280 | { | |
281 | status = ILL_TYPE; |
|
281 | status = ILL_TYPE; | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | return status; |
|
284 | return status; | |
285 | } |
|
285 | } | |
286 |
|
286 | |||
287 | int tc_check_length( unsigned char packetSubType, unsigned int length ) |
|
287 | int tc_check_length( unsigned char packetSubType, unsigned int length ) | |
288 | { |
|
288 | { | |
289 | /** This function checks that the subtype and the length are compliant. |
|
289 | /** This function checks that the subtype and the length are compliant. | |
290 | * |
|
290 | * | |
291 | * @param packetSubType is the subtype to check. |
|
291 | * @param packetSubType is the subtype to check. | |
292 | * @param length is the length to check. |
|
292 | * @param length is the length to check. | |
293 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. |
|
293 | * @return Status code CCSDS_TM_VALID or ILL_TYPE. | |
294 | * |
|
294 | * | |
295 | */ |
|
295 | */ | |
296 |
|
296 | |||
297 | int status; |
|
297 | int status; | |
298 |
|
298 | |||
299 | status = LFR_SUCCESSFUL; |
|
299 | status = LFR_SUCCESSFUL; | |
300 |
|
300 | |||
301 | switch(packetSubType) |
|
301 | switch(packetSubType) | |
302 | { |
|
302 | { | |
303 | case TC_SUBTYPE_RESET: |
|
303 | case TC_SUBTYPE_RESET: | |
304 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
304 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { | |
305 | status = WRONG_LEN_PACKET; |
|
305 | status = WRONG_LEN_PACKET; | |
306 | } |
|
306 | } | |
307 | else { |
|
307 | else { | |
308 | status = CCSDS_TM_VALID; |
|
308 | status = CCSDS_TM_VALID; | |
309 | } |
|
309 | } | |
310 | break; |
|
310 | break; | |
311 | case TC_SUBTYPE_LOAD_COMM: |
|
311 | case TC_SUBTYPE_LOAD_COMM: | |
312 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
312 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
313 | status = WRONG_LEN_PACKET; |
|
313 | status = WRONG_LEN_PACKET; | |
314 | } |
|
314 | } | |
315 | else { |
|
315 | else { | |
316 | status = CCSDS_TM_VALID; |
|
316 | status = CCSDS_TM_VALID; | |
317 | } |
|
317 | } | |
318 | break; |
|
318 | break; | |
319 | case TC_SUBTYPE_LOAD_NORM: |
|
319 | case TC_SUBTYPE_LOAD_NORM: | |
320 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
320 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { | |
321 | status = WRONG_LEN_PACKET; |
|
321 | status = WRONG_LEN_PACKET; | |
322 | } |
|
322 | } | |
323 | else { |
|
323 | else { | |
324 | status = CCSDS_TM_VALID; |
|
324 | status = CCSDS_TM_VALID; | |
325 | } |
|
325 | } | |
326 | break; |
|
326 | break; | |
327 | case TC_SUBTYPE_LOAD_BURST: |
|
327 | case TC_SUBTYPE_LOAD_BURST: | |
328 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
328 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { | |
329 | status = WRONG_LEN_PACKET; |
|
329 | status = WRONG_LEN_PACKET; | |
330 | } |
|
330 | } | |
331 | else { |
|
331 | else { | |
332 | status = CCSDS_TM_VALID; |
|
332 | status = CCSDS_TM_VALID; | |
333 | } |
|
333 | } | |
334 | break; |
|
334 | break; | |
335 | case TC_SUBTYPE_LOAD_SBM1: |
|
335 | case TC_SUBTYPE_LOAD_SBM1: | |
336 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
336 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { | |
337 | status = WRONG_LEN_PACKET; |
|
337 | status = WRONG_LEN_PACKET; | |
338 | } |
|
338 | } | |
339 | else { |
|
339 | else { | |
340 | status = CCSDS_TM_VALID; |
|
340 | status = CCSDS_TM_VALID; | |
341 | } |
|
341 | } | |
342 | break; |
|
342 | break; | |
343 | case TC_SUBTYPE_LOAD_SBM2: |
|
343 | case TC_SUBTYPE_LOAD_SBM2: | |
344 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
344 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { | |
345 | status = WRONG_LEN_PACKET; |
|
345 | status = WRONG_LEN_PACKET; | |
346 | } |
|
346 | } | |
347 | else { |
|
347 | else { | |
348 | status = CCSDS_TM_VALID; |
|
348 | status = CCSDS_TM_VALID; | |
349 | } |
|
349 | } | |
350 | break; |
|
350 | break; | |
351 | case TC_SUBTYPE_DUMP: |
|
351 | case TC_SUBTYPE_DUMP: | |
352 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
352 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { | |
353 | status = WRONG_LEN_PACKET; |
|
353 | status = WRONG_LEN_PACKET; | |
354 | } |
|
354 | } | |
355 | else { |
|
355 | else { | |
356 | status = CCSDS_TM_VALID; |
|
356 | status = CCSDS_TM_VALID; | |
357 | } |
|
357 | } | |
358 | break; |
|
358 | break; | |
359 | case TC_SUBTYPE_ENTER: |
|
359 | case TC_SUBTYPE_ENTER: | |
360 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
360 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { | |
361 | status = WRONG_LEN_PACKET; |
|
361 | status = WRONG_LEN_PACKET; | |
362 | } |
|
362 | } | |
363 | else { |
|
363 | else { | |
364 | status = CCSDS_TM_VALID; |
|
364 | status = CCSDS_TM_VALID; | |
365 | } |
|
365 | } | |
366 | break; |
|
366 | break; | |
367 | case TC_SUBTYPE_UPDT_INFO: |
|
367 | case TC_SUBTYPE_UPDT_INFO: | |
368 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
368 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { | |
369 | status = WRONG_LEN_PACKET; |
|
369 | status = WRONG_LEN_PACKET; | |
370 | } |
|
370 | } | |
371 | else { |
|
371 | else { | |
372 | status = CCSDS_TM_VALID; |
|
372 | status = CCSDS_TM_VALID; | |
373 | } |
|
373 | } | |
374 | break; |
|
374 | break; | |
375 | case TC_SUBTYPE_EN_CAL: |
|
375 | case TC_SUBTYPE_EN_CAL: | |
376 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
376 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
377 | status = WRONG_LEN_PACKET; |
|
377 | status = WRONG_LEN_PACKET; | |
378 | } |
|
378 | } | |
379 | else { |
|
379 | else { | |
380 | status = CCSDS_TM_VALID; |
|
380 | status = CCSDS_TM_VALID; | |
381 | } |
|
381 | } | |
382 | break; |
|
382 | break; | |
383 | case TC_SUBTYPE_DIS_CAL: |
|
383 | case TC_SUBTYPE_DIS_CAL: | |
384 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
384 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |
385 | status = WRONG_LEN_PACKET; |
|
385 | status = WRONG_LEN_PACKET; | |
386 | } |
|
386 | } | |
387 | else { |
|
387 | else { | |
388 | status = CCSDS_TM_VALID; |
|
388 | status = CCSDS_TM_VALID; | |
389 | } |
|
389 | } | |
390 | break; |
|
390 | break; | |
391 | case TC_SUBTYPE_UPDT_TIME: |
|
391 | case TC_SUBTYPE_UPDT_TIME: | |
392 | if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { |
|
392 | if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { | |
393 | status = WRONG_LEN_PACKET; |
|
393 | status = WRONG_LEN_PACKET; | |
394 | } |
|
394 | } | |
395 | else { |
|
395 | else { | |
396 | status = CCSDS_TM_VALID; |
|
396 | status = CCSDS_TM_VALID; | |
397 | } |
|
397 | } | |
398 | break; |
|
398 | break; | |
399 | default: // if the subtype is not a legal value, return ILL_SUBTYPE |
|
399 | default: // if the subtype is not a legal value, return ILL_SUBTYPE | |
400 | status = ILL_SUBTYPE; |
|
400 | status = ILL_SUBTYPE; | |
401 | break ; |
|
401 | break ; | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | return status; |
|
404 | return status; | |
405 | } |
|
405 | } | |
406 |
|
406 | |||
407 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length ) |
|
407 | int tc_check_crc( ccsdsTelecommandPacket_t * TCPacket, unsigned int length ) | |
408 | { |
|
408 | { | |
409 | /** This function checks the CRC validity of the corresponding TeleCommand packet. |
|
409 | /** This function checks the CRC validity of the corresponding TeleCommand packet. | |
410 | * |
|
410 | * | |
411 | * @param TCPacket points to the TeleCommand packet to check. |
|
411 | * @param TCPacket points to the TeleCommand packet to check. | |
412 | * @param length is the length of the TC packet. |
|
412 | * @param length is the length of the TC packet. | |
413 | * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM. |
|
413 | * @return Status code CCSDS_TM_VALID or INCOR_CHECKSUM. | |
414 | * |
|
414 | * | |
415 | */ |
|
415 | */ | |
416 |
|
416 | |||
417 | int status; |
|
417 | int status; | |
418 | unsigned char * CCSDSContent; |
|
418 | unsigned char * CCSDSContent; | |
419 | unsigned char currentTC_COMPUTED_CRC[2]; |
|
419 | unsigned char currentTC_COMPUTED_CRC[2]; | |
420 |
|
420 | |||
421 | CCSDSContent = (unsigned char*) TCPacket->packetID; |
|
421 | CCSDSContent = (unsigned char*) TCPacket->packetID; | |
422 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC |
|
422 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC | |
423 | if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { |
|
423 | if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { | |
424 | status = INCOR_CHECKSUM; |
|
424 | status = INCOR_CHECKSUM; | |
425 | } |
|
425 | } | |
426 | else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { |
|
426 | else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { | |
427 | status = INCOR_CHECKSUM; |
|
427 | status = INCOR_CHECKSUM; | |
428 | } |
|
428 | } | |
429 | else { |
|
429 | else { | |
430 | status = CCSDS_TM_VALID; |
|
430 | status = CCSDS_TM_VALID; | |
431 | } |
|
431 | } | |
432 |
|
432 | |||
433 | return status; |
|
433 | return status; | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | //*********** |
|
436 | //*********** | |
437 | // RTEMS TASK |
|
437 | // RTEMS TASK | |
438 | rtems_task recv_task( rtems_task_argument unused ) |
|
438 | rtems_task recv_task( rtems_task_argument unused ) | |
439 | { |
|
439 | { | |
440 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
440 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
441 | * |
|
441 | * | |
442 | * @param unused is the starting argument of the RTEMS task |
|
442 | * @param unused is the starting argument of the RTEMS task | |
443 | * |
|
443 | * | |
444 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
444 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
445 | * 1. It reads the incoming data. |
|
445 | * 1. It reads the incoming data. | |
446 | * 2. Launches the acceptance procedure. |
|
446 | * 2. Launches the acceptance procedure. | |
447 | * 3. If the Telecommand is valid, sends it to the ACTN task using an RTEMS message queue. |
|
447 | * 3. If the Telecommand is valid, sends it to the ACTN task using an RTEMS message queue. | |
448 | * |
|
448 | * | |
449 | */ |
|
449 | */ | |
450 |
|
450 | |||
451 | int len = 0; |
|
451 | int len = 0; | |
452 | unsigned int i = 0; |
|
452 | unsigned int i = 0; | |
453 | ccsdsTelecommandPacket_t currentTC; |
|
453 | ccsdsTelecommandPacket_t currentTC; | |
454 | char data[100]; |
|
454 | char data[100]; | |
455 | rtems_status_code status; |
|
455 | rtems_status_code status; | |
456 |
rtems_id queue_ |
|
456 | rtems_id queue_recv_id; | |
457 |
rtems_id queue_ |
|
457 | rtems_id queue_send_id; | |
458 |
|
458 | |||
459 | for(i=0; i<100; i++) data[i] = 0; |
|
459 | for(i=0; i<100; i++) data[i] = 0; | |
460 |
|
460 | |||
461 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
461 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
462 |
|
462 | |||
463 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
463 | status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_recv_id ); | |
464 | if (status != RTEMS_SUCCESSFUL) |
|
464 | if (status != RTEMS_SUCCESSFUL) | |
465 | { |
|
465 | { | |
466 |
PRINTF1("in RECV *** ERR getting |
|
466 | PRINTF1("in RECV *** ERR getting QUEUE_RECV id, %d\n", status) | |
467 | } |
|
467 | } | |
468 |
|
468 | |||
469 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
469 | status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_send_id ); | |
470 | if (status != RTEMS_SUCCESSFUL) |
|
470 | if (status != RTEMS_SUCCESSFUL) | |
471 | { |
|
471 | { | |
472 |
PRINTF1("in RECV *** ERR getting |
|
472 | PRINTF1("in RECV *** ERR getting QUEUE_SEND id, %d\n", status) | |
473 | } |
|
473 | } | |
474 |
|
474 | |||
475 | BOOT_PRINTF("in RECV *** \n") |
|
475 | BOOT_PRINTF("in RECV *** \n") | |
476 |
|
476 | |||
477 | while(1) |
|
477 | while(1) | |
478 | { |
|
478 | { | |
479 | len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking |
|
479 | len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking | |
480 | if (len == -1){ // error during the read call |
|
480 | if (len == -1){ // error during the read call | |
481 | PRINTF("In RECV *** last read call returned -1\n") |
|
481 | PRINTF("In RECV *** last read call returned -1\n") | |
482 | } |
|
482 | } | |
483 | else { |
|
483 | else { | |
484 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
484 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
485 | PRINTF("In RECV *** packet lenght too short\n") |
|
485 | PRINTF("In RECV *** packet lenght too short\n") | |
486 | } |
|
486 | } | |
487 | else { |
|
487 | else { | |
488 | currentTC_LEN_RCV[0] = 0x00; |
|
488 | currentTC_LEN_RCV[0] = 0x00; | |
489 | currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field |
|
489 | currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field | |
490 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
490 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
491 | // CHECK THE TC |
|
491 | // CHECK THE TC | |
492 |
tc_acceptance(¤tTC, currentTC_LEN_RCV_AsUnsignedInt, queue_ |
|
492 | tc_acceptance(¤tTC, currentTC_LEN_RCV_AsUnsignedInt, queue_recv_id, queue_send_id); | |
493 | } |
|
493 | } | |
494 | } |
|
494 | } | |
495 | } |
|
495 | } | |
496 | } |
|
496 | } | |
497 |
|
497 | |||
498 | rtems_task actn_task( rtems_task_argument unused ) |
|
498 | rtems_task actn_task( rtems_task_argument unused ) | |
499 | { |
|
499 | { | |
500 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
500 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
501 | * |
|
501 | * | |
502 | * @param unused is the starting argument of the RTEMS task |
|
502 | * @param unused is the starting argument of the RTEMS task | |
503 | * |
|
503 | * | |
504 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
504 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
505 | * on the incoming TeleCommand. |
|
505 | * on the incoming TeleCommand. | |
506 | * |
|
506 | * | |
507 | */ |
|
507 | */ | |
508 |
|
508 | |||
509 | int result; |
|
509 | int result; | |
510 | rtems_status_code status; // RTEMS status code |
|
510 | rtems_status_code status; // RTEMS status code | |
511 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
511 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task | |
512 | size_t size; // size of the incoming TC packet |
|
512 | size_t size; // size of the incoming TC packet | |
513 | unsigned char subtype; // subtype of the current TC packet |
|
513 | unsigned char subtype; // subtype of the current TC packet | |
514 | rtems_id queue_rcv_id; |
|
514 | rtems_id queue_rcv_id; | |
515 | rtems_id queue_snd_id; |
|
515 | rtems_id queue_snd_id; | |
516 |
|
516 | |||
517 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
517 | status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id ); | |
518 | if (status != RTEMS_SUCCESSFUL) |
|
518 | if (status != RTEMS_SUCCESSFUL) | |
519 | { |
|
519 | { | |
520 | PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status) |
|
520 | PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status) | |
521 | } |
|
521 | } | |
522 |
|
522 | |||
523 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
523 | status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id ); | |
524 | if (status != RTEMS_SUCCESSFUL) |
|
524 | if (status != RTEMS_SUCCESSFUL) | |
525 | { |
|
525 | { | |
526 | PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status) |
|
526 | PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status) | |
527 | } |
|
527 | } | |
528 |
|
528 | |||
529 | result = LFR_SUCCESSFUL; |
|
529 | result = LFR_SUCCESSFUL; | |
530 | subtype = 0; // subtype of the current TC packet |
|
530 | subtype = 0; // subtype of the current TC packet | |
531 |
|
531 | |||
532 | BOOT_PRINTF("in ACTN *** \n") |
|
532 | BOOT_PRINTF("in ACTN *** \n") | |
533 |
|
533 | |||
534 | while(1) |
|
534 | while(1) | |
535 | { |
|
535 | { | |
536 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
536 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
537 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
537 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
538 | if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
538 | if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
539 | else |
|
539 | else | |
540 | { |
|
540 | { | |
541 | subtype = TC.serviceSubType; |
|
541 | subtype = TC.serviceSubType; | |
542 | switch(subtype) |
|
542 | switch(subtype) | |
543 | { |
|
543 | { | |
544 | case TC_SUBTYPE_RESET: |
|
544 | case TC_SUBTYPE_RESET: | |
545 | result = action_reset( &TC, queue_snd_id ); |
|
545 | result = action_reset( &TC, queue_snd_id ); | |
546 | close_action( &TC, result, queue_snd_id ); |
|
546 | close_action( &TC, result, queue_snd_id ); | |
547 | break; |
|
547 | break; | |
548 | // |
|
548 | // | |
549 | case TC_SUBTYPE_LOAD_COMM: |
|
549 | case TC_SUBTYPE_LOAD_COMM: | |
550 | result = action_load_common_par( &TC ); |
|
550 | result = action_load_common_par( &TC ); | |
551 | close_action( &TC, result, queue_snd_id ); |
|
551 | close_action( &TC, result, queue_snd_id ); | |
552 | break; |
|
552 | break; | |
553 | // |
|
553 | // | |
554 | case TC_SUBTYPE_LOAD_NORM: |
|
554 | case TC_SUBTYPE_LOAD_NORM: | |
555 | result = action_load_normal_par( &TC, queue_snd_id ); |
|
555 | result = action_load_normal_par( &TC, queue_snd_id ); | |
556 | close_action( &TC, result, queue_snd_id ); |
|
556 | close_action( &TC, result, queue_snd_id ); | |
557 | break; |
|
557 | break; | |
558 | // |
|
558 | // | |
559 | case TC_SUBTYPE_LOAD_BURST: |
|
559 | case TC_SUBTYPE_LOAD_BURST: | |
560 | result = action_load_burst_par( &TC, queue_snd_id ); |
|
560 | result = action_load_burst_par( &TC, queue_snd_id ); | |
561 | close_action( &TC, result, queue_snd_id ); |
|
561 | close_action( &TC, result, queue_snd_id ); | |
562 | break; |
|
562 | break; | |
563 | // |
|
563 | // | |
564 | case TC_SUBTYPE_LOAD_SBM1: |
|
564 | case TC_SUBTYPE_LOAD_SBM1: | |
565 | result = action_load_sbm1_par( &TC, queue_snd_id ); |
|
565 | result = action_load_sbm1_par( &TC, queue_snd_id ); | |
566 | close_action( &TC, result, queue_snd_id ); |
|
566 | close_action( &TC, result, queue_snd_id ); | |
567 | break; |
|
567 | break; | |
568 | // |
|
568 | // | |
569 | case TC_SUBTYPE_LOAD_SBM2: |
|
569 | case TC_SUBTYPE_LOAD_SBM2: | |
570 | result = action_load_sbm2_par( &TC, queue_snd_id ); |
|
570 | result = action_load_sbm2_par( &TC, queue_snd_id ); | |
571 | close_action( &TC, result, queue_snd_id ); |
|
571 | close_action( &TC, result, queue_snd_id ); | |
572 | break; |
|
572 | break; | |
573 | // |
|
573 | // | |
574 | case TC_SUBTYPE_DUMP: |
|
574 | case TC_SUBTYPE_DUMP: | |
575 | result = action_dump_par( queue_snd_id ); |
|
575 | result = action_dump_par( queue_snd_id ); | |
576 | close_action( &TC, result, queue_snd_id ); |
|
576 | close_action( &TC, result, queue_snd_id ); | |
577 | break; |
|
577 | break; | |
578 | // |
|
578 | // | |
579 | case TC_SUBTYPE_ENTER: |
|
579 | case TC_SUBTYPE_ENTER: | |
580 | result = action_enter_mode( &TC, queue_snd_id ); |
|
580 | result = action_enter_mode( &TC, queue_snd_id ); | |
581 | close_action( &TC, result, queue_snd_id ); |
|
581 | close_action( &TC, result, queue_snd_id ); | |
582 | break; |
|
582 | break; | |
583 | // |
|
583 | // | |
584 | case TC_SUBTYPE_UPDT_INFO: |
|
584 | case TC_SUBTYPE_UPDT_INFO: | |
585 | result = action_update_info( &TC, queue_snd_id ); |
|
585 | result = action_update_info( &TC, queue_snd_id ); | |
586 | close_action( &TC, result, queue_snd_id ); |
|
586 | close_action( &TC, result, queue_snd_id ); | |
587 | break; |
|
587 | break; | |
588 | // |
|
588 | // | |
589 | case TC_SUBTYPE_EN_CAL: |
|
589 | case TC_SUBTYPE_EN_CAL: | |
590 | result = action_enable_calibration( &TC, queue_snd_id ); |
|
590 | result = action_enable_calibration( &TC, queue_snd_id ); | |
591 | close_action( &TC, result, queue_snd_id ); |
|
591 | close_action( &TC, result, queue_snd_id ); | |
592 | break; |
|
592 | break; | |
593 | // |
|
593 | // | |
594 | case TC_SUBTYPE_DIS_CAL: |
|
594 | case TC_SUBTYPE_DIS_CAL: | |
595 | result = action_disable_calibration( &TC, queue_snd_id ); |
|
595 | result = action_disable_calibration( &TC, queue_snd_id ); | |
596 | close_action( &TC, result, queue_snd_id ); |
|
596 | close_action( &TC, result, queue_snd_id ); | |
597 | break; |
|
597 | break; | |
598 | // |
|
598 | // | |
599 | case TC_SUBTYPE_UPDT_TIME: |
|
599 | case TC_SUBTYPE_UPDT_TIME: | |
600 | result = action_update_time( &TC ); |
|
600 | result = action_update_time( &TC ); | |
601 | close_action( &TC, result, queue_snd_id ); |
|
601 | close_action( &TC, result, queue_snd_id ); | |
602 | break; |
|
602 | break; | |
603 | // |
|
603 | // | |
604 | default: |
|
604 | default: | |
605 | break; |
|
605 | break; | |
606 | } |
|
606 | } | |
607 | } |
|
607 | } | |
608 | } |
|
608 | } | |
609 | } |
|
609 | } | |
610 |
|
610 | |||
611 | rtems_task dumb_task( rtems_task_argument unused ) |
|
611 | rtems_task dumb_task( rtems_task_argument unused ) | |
612 | { |
|
612 | { | |
613 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
613 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
614 | * |
|
614 | * | |
615 | * @param unused is the starting argument of the RTEMS task |
|
615 | * @param unused is the starting argument of the RTEMS task | |
616 | * |
|
616 | * | |
617 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
617 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
618 | * |
|
618 | * | |
619 | */ |
|
619 | */ | |
620 |
|
620 | |||
621 | unsigned int i; |
|
621 | unsigned int i; | |
622 | unsigned int intEventOut; |
|
622 | unsigned int intEventOut; | |
623 | unsigned int coarse_time = 0; |
|
623 | unsigned int coarse_time = 0; | |
624 | unsigned int fine_time = 0; |
|
624 | unsigned int fine_time = 0; | |
625 | rtems_event_set event_out; |
|
625 | rtems_event_set event_out; | |
626 |
|
626 | |||
627 | BOOT_PRINTF("in DUMB *** \n") |
|
627 | BOOT_PRINTF("in DUMB *** \n") | |
628 |
|
628 | |||
629 | while(1){ |
|
629 | while(1){ | |
630 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4 | RTEMS_EVENT_5, |
|
630 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4 | RTEMS_EVENT_5, | |
631 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
631 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
632 | intEventOut = (unsigned int) event_out; |
|
632 | intEventOut = (unsigned int) event_out; | |
633 | for ( i=0; i<32; i++) |
|
633 | for ( i=0; i<32; i++) | |
634 | { |
|
634 | { | |
635 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
635 | if ( ((intEventOut >> i) & 0x0001) != 0) | |
636 | { |
|
636 | { | |
637 | coarse_time = time_management_regs->coarse_time; |
|
637 | coarse_time = time_management_regs->coarse_time; | |
638 | fine_time = time_management_regs->fine_time; |
|
638 | fine_time = time_management_regs->fine_time; | |
639 | printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); |
|
639 | printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); | |
640 | } |
|
640 | } | |
641 | } |
|
641 | } | |
642 | } |
|
642 | } | |
643 | } |
|
643 | } | |
644 |
|
644 | |||
645 | //*********** |
|
645 | //*********** | |
646 | // TC ACTIONS |
|
646 | // TC ACTIONS | |
647 |
|
647 | |||
648 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
648 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
649 | { |
|
649 | { | |
650 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
650 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
651 | * |
|
651 | * | |
652 | * @param TC points to the TeleCommand packet that is being processed |
|
652 | * @param TC points to the TeleCommand packet that is being processed | |
653 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
653 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
654 | * |
|
654 | * | |
655 | */ |
|
655 | */ | |
656 |
|
656 | |||
657 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
657 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); | |
658 | return LFR_DEFAULT; |
|
658 | return LFR_DEFAULT; | |
659 | } |
|
659 | } | |
660 |
|
660 | |||
661 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
661 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
662 | { |
|
662 | { | |
663 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
663 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
664 | * |
|
664 | * | |
665 | * @param TC points to the TeleCommand packet that is being processed |
|
665 | * @param TC points to the TeleCommand packet that is being processed | |
666 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
666 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
667 | * |
|
667 | * | |
668 | */ |
|
668 | */ | |
669 |
|
669 | |||
670 | rtems_status_code status; |
|
670 | rtems_status_code status; | |
671 | unsigned char requestedMode; |
|
671 | unsigned char requestedMode; | |
672 |
|
672 | |||
673 | requestedMode = TC->dataAndCRC[1]; |
|
673 | requestedMode = TC->dataAndCRC[1]; | |
674 |
|
674 | |||
675 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
675 | if ( (requestedMode != LFR_MODE_STANDBY) | |
676 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
676 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
677 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
677 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
678 | { |
|
678 | { | |
679 | status = RTEMS_UNSATISFIED; |
|
679 | status = RTEMS_UNSATISFIED; | |
680 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode ); |
|
680 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode ); | |
681 | } |
|
681 | } | |
682 | else |
|
682 | else | |
683 | { |
|
683 | { | |
684 | printf("try to enter mode %d\n", requestedMode); |
|
684 | printf("try to enter mode %d\n", requestedMode); | |
685 |
|
685 | |||
686 | #ifdef PRINT_TASK_STATISTICS |
|
686 | #ifdef PRINT_TASK_STATISTICS | |
687 | if (requestedMode != LFR_MODE_STANDBY) |
|
687 | if (requestedMode != LFR_MODE_STANDBY) | |
688 | { |
|
688 | { | |
689 | rtems_cpu_usage_reset(); |
|
689 | rtems_cpu_usage_reset(); | |
690 | maxCount = 0; |
|
690 | maxCount = 0; | |
691 | } |
|
691 | } | |
692 | #endif |
|
692 | #endif | |
693 |
|
693 | |||
694 | status = transition_validation(requestedMode); |
|
694 | status = transition_validation(requestedMode); | |
695 |
|
695 | |||
696 | if ( status == LFR_SUCCESSFUL ) { |
|
696 | if ( status == LFR_SUCCESSFUL ) { | |
697 | if ( lfrCurrentMode != LFR_MODE_STANDBY) |
|
697 | if ( lfrCurrentMode != LFR_MODE_STANDBY) | |
698 | { |
|
698 | { | |
699 | status = stop_current_mode(); |
|
699 | status = stop_current_mode(); | |
700 | } |
|
700 | } | |
701 | if (status != RTEMS_SUCCESSFUL) |
|
701 | if (status != RTEMS_SUCCESSFUL) | |
702 | { |
|
702 | { | |
703 | PRINTF("ERR *** in action_enter *** stop_current_mode\n") |
|
703 | PRINTF("ERR *** in action_enter *** stop_current_mode\n") | |
704 | } |
|
704 | } | |
705 | status = enter_mode(requestedMode, TC); |
|
705 | status = enter_mode(requestedMode, TC); | |
706 | } |
|
706 | } | |
707 | else |
|
707 | else | |
708 | { |
|
708 | { | |
709 | PRINTF("ERR *** in action_enter *** transition rejected\n") |
|
709 | PRINTF("ERR *** in action_enter *** transition rejected\n") | |
710 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
710 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
711 | } |
|
711 | } | |
712 | } |
|
712 | } | |
713 |
|
713 | |||
714 | return status; |
|
714 | return status; | |
715 | } |
|
715 | } | |
716 |
|
716 | |||
717 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
717 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
718 | { |
|
718 | { | |
719 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
719 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
720 | * |
|
720 | * | |
721 | * @param TC points to the TeleCommand packet that is being processed |
|
721 | * @param TC points to the TeleCommand packet that is being processed | |
722 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
722 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
723 | * |
|
723 | * | |
724 | */ |
|
724 | */ | |
725 |
|
725 | |||
726 | unsigned int val; |
|
726 | unsigned int val; | |
727 | int result; |
|
727 | int result; | |
728 | unsigned char lfrMode; |
|
728 | unsigned char lfrMode; | |
729 |
|
729 | |||
730 | result = LFR_DEFAULT; |
|
730 | result = LFR_DEFAULT; | |
731 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
731 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
732 |
|
732 | |||
733 | if ( (lfrMode == LFR_MODE_STANDBY) ) { |
|
733 | if ( (lfrMode == LFR_MODE_STANDBY) ) { | |
734 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
734 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); | |
735 | result = LFR_DEFAULT; |
|
735 | result = LFR_DEFAULT; | |
736 | } |
|
736 | } | |
737 | else { |
|
737 | else { | |
738 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
738 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
739 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
739 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
740 | val++; |
|
740 | val++; | |
741 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
741 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
742 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
742 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
743 | result = LFR_SUCCESSFUL; |
|
743 | result = LFR_SUCCESSFUL; | |
744 | } |
|
744 | } | |
745 |
|
745 | |||
746 | return result; |
|
746 | return result; | |
747 | } |
|
747 | } | |
748 |
|
748 | |||
749 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
749 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
750 | { |
|
750 | { | |
751 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
751 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
752 | * |
|
752 | * | |
753 | * @param TC points to the TeleCommand packet that is being processed |
|
753 | * @param TC points to the TeleCommand packet that is being processed | |
754 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
754 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
755 | * |
|
755 | * | |
756 | */ |
|
756 | */ | |
757 |
|
757 | |||
758 | int result; |
|
758 | int result; | |
759 | unsigned char lfrMode; |
|
759 | unsigned char lfrMode; | |
760 |
|
760 | |||
761 | result = LFR_DEFAULT; |
|
761 | result = LFR_DEFAULT; | |
762 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
762 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
763 |
|
763 | |||
764 | if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { |
|
764 | if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { | |
765 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
765 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
766 | result = LFR_DEFAULT; |
|
766 | result = LFR_DEFAULT; | |
767 | } |
|
767 | } | |
768 | else { |
|
768 | else { | |
769 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
769 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); | |
770 | result = LFR_DEFAULT; |
|
770 | result = LFR_DEFAULT; | |
771 | } |
|
771 | } | |
772 | return result; |
|
772 | return result; | |
773 | } |
|
773 | } | |
774 |
|
774 | |||
775 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
775 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
776 | { |
|
776 | { | |
777 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
777 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
778 | * |
|
778 | * | |
779 | * @param TC points to the TeleCommand packet that is being processed |
|
779 | * @param TC points to the TeleCommand packet that is being processed | |
780 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
780 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
781 | * |
|
781 | * | |
782 | */ |
|
782 | */ | |
783 |
|
783 | |||
784 | int result; |
|
784 | int result; | |
785 | unsigned char lfrMode; |
|
785 | unsigned char lfrMode; | |
786 |
|
786 | |||
787 | result = LFR_DEFAULT; |
|
787 | result = LFR_DEFAULT; | |
788 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
788 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
789 |
|
789 | |||
790 | if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { |
|
790 | if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) { | |
791 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
791 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
792 | result = LFR_DEFAULT; |
|
792 | result = LFR_DEFAULT; | |
793 | } |
|
793 | } | |
794 | else { |
|
794 | else { | |
795 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); |
|
795 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id ); | |
796 | result = LFR_DEFAULT; |
|
796 | result = LFR_DEFAULT; | |
797 | } |
|
797 | } | |
798 | return result; |
|
798 | return result; | |
799 | } |
|
799 | } | |
800 |
|
800 | |||
801 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
801 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
802 | { |
|
802 | { | |
803 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
803 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
804 | * |
|
804 | * | |
805 | * @param TC points to the TeleCommand packet that is being processed |
|
805 | * @param TC points to the TeleCommand packet that is being processed | |
806 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
806 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
807 | * |
|
807 | * | |
808 | */ |
|
808 | */ | |
809 |
|
809 | |||
810 | unsigned int val; |
|
810 | unsigned int val; | |
811 |
|
811 | |||
812 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
812 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
813 | + (TC->dataAndCRC[1] << 16) |
|
813 | + (TC->dataAndCRC[1] << 16) | |
814 | + (TC->dataAndCRC[2] << 8) |
|
814 | + (TC->dataAndCRC[2] << 8) | |
815 | + TC->dataAndCRC[3]; |
|
815 | + TC->dataAndCRC[3]; | |
816 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
816 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
817 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
817 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
818 | val++; |
|
818 | val++; | |
819 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
819 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
820 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
820 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
821 | time_management_regs->ctrl = time_management_regs->ctrl | 1; |
|
821 | time_management_regs->ctrl = time_management_regs->ctrl | 1; | |
822 |
|
822 | |||
823 | return LFR_SUCCESSFUL; |
|
823 | return LFR_SUCCESSFUL; | |
824 | } |
|
824 | } | |
825 |
|
825 | |||
826 | //******************* |
|
826 | //******************* | |
827 | // ENTERING THE MODES |
|
827 | // ENTERING THE MODES | |
828 |
|
828 | |||
829 | int transition_validation(unsigned char requestedMode) |
|
829 | int transition_validation(unsigned char requestedMode) | |
830 | { |
|
830 | { | |
831 | int status; |
|
831 | int status; | |
832 |
|
832 | |||
833 | switch (requestedMode) |
|
833 | switch (requestedMode) | |
834 | { |
|
834 | { | |
835 | case LFR_MODE_STANDBY: |
|
835 | case LFR_MODE_STANDBY: | |
836 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
836 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
837 | status = LFR_DEFAULT; |
|
837 | status = LFR_DEFAULT; | |
838 | } |
|
838 | } | |
839 | else |
|
839 | else | |
840 | { |
|
840 | { | |
841 | status = LFR_SUCCESSFUL; |
|
841 | status = LFR_SUCCESSFUL; | |
842 | } |
|
842 | } | |
843 | break; |
|
843 | break; | |
844 | case LFR_MODE_NORMAL: |
|
844 | case LFR_MODE_NORMAL: | |
845 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
845 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
846 | status = LFR_DEFAULT; |
|
846 | status = LFR_DEFAULT; | |
847 | } |
|
847 | } | |
848 | else { |
|
848 | else { | |
849 | status = LFR_SUCCESSFUL; |
|
849 | status = LFR_SUCCESSFUL; | |
850 | } |
|
850 | } | |
851 | break; |
|
851 | break; | |
852 | case LFR_MODE_BURST: |
|
852 | case LFR_MODE_BURST: | |
853 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
853 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
854 | status = LFR_DEFAULT; |
|
854 | status = LFR_DEFAULT; | |
855 | } |
|
855 | } | |
856 | else { |
|
856 | else { | |
857 | status = LFR_SUCCESSFUL; |
|
857 | status = LFR_SUCCESSFUL; | |
858 | } |
|
858 | } | |
859 | break; |
|
859 | break; | |
860 | case LFR_MODE_SBM1: |
|
860 | case LFR_MODE_SBM1: | |
861 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
861 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
862 | status = LFR_DEFAULT; |
|
862 | status = LFR_DEFAULT; | |
863 | } |
|
863 | } | |
864 | else { |
|
864 | else { | |
865 | status = LFR_SUCCESSFUL; |
|
865 | status = LFR_SUCCESSFUL; | |
866 | } |
|
866 | } | |
867 | break; |
|
867 | break; | |
868 | case LFR_MODE_SBM2: |
|
868 | case LFR_MODE_SBM2: | |
869 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
869 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
870 | status = LFR_DEFAULT; |
|
870 | status = LFR_DEFAULT; | |
871 | } |
|
871 | } | |
872 | else { |
|
872 | else { | |
873 | status = LFR_SUCCESSFUL; |
|
873 | status = LFR_SUCCESSFUL; | |
874 | } |
|
874 | } | |
875 | break; |
|
875 | break; | |
876 | default: |
|
876 | default: | |
877 | status = LFR_DEFAULT; |
|
877 | status = LFR_DEFAULT; | |
878 | break; |
|
878 | break; | |
879 | } |
|
879 | } | |
880 |
|
880 | |||
881 | return status; |
|
881 | return status; | |
882 | } |
|
882 | } | |
883 |
|
883 | |||
884 | int stop_current_mode() |
|
884 | int stop_current_mode() | |
885 | { |
|
885 | { | |
886 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
886 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
887 | * |
|
887 | * | |
888 | * @return RTEMS directive status codes: |
|
888 | * @return RTEMS directive status codes: | |
889 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
889 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
890 | * - RTEMS_INVALID_ID - task id invalid |
|
890 | * - RTEMS_INVALID_ID - task id invalid | |
891 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
891 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
892 | * |
|
892 | * | |
893 | */ |
|
893 | */ | |
894 |
|
894 | |||
895 | rtems_status_code status; |
|
895 | rtems_status_code status; | |
896 |
|
896 | |||
897 | status = RTEMS_SUCCESSFUL; |
|
897 | status = RTEMS_SUCCESSFUL; | |
898 |
|
898 | |||
899 | // mask all IRQ lines related to signal processing |
|
899 | // mask all IRQ lines related to signal processing | |
900 | LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP) |
|
900 | LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP) | |
901 | LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP) |
|
901 | LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP) | |
902 |
|
902 | |||
903 | #ifdef GSA |
|
903 | #ifdef GSA | |
904 | LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP) |
|
904 | LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP) | |
905 | LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP) |
|
905 | LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP) | |
906 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR ); |
|
906 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR ); | |
907 | #else |
|
907 | #else | |
908 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
908 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
909 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
909 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
910 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt |
|
910 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt | |
911 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
911 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
912 | LEON_Mask_interrupt( IRQ_SM ); // for SM simulation |
|
912 | LEON_Mask_interrupt( IRQ_SM ); // for SM simulation | |
913 | LEON_Clear_interrupt( IRQ_SM ); // for SM simulation |
|
913 | LEON_Clear_interrupt( IRQ_SM ); // for SM simulation | |
914 | #endif |
|
914 | #endif | |
915 | //********************** |
|
915 | //********************** | |
916 | // suspend several tasks |
|
916 | // suspend several tasks | |
917 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
917 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
918 | status = suspend_science_tasks(); |
|
918 | status = suspend_science_tasks(); | |
919 | } |
|
919 | } | |
920 |
|
920 | |||
921 | if (status != RTEMS_SUCCESSFUL) |
|
921 | if (status != RTEMS_SUCCESSFUL) | |
922 | { |
|
922 | { | |
923 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
923 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
924 | } |
|
924 | } | |
925 |
|
925 | |||
926 | //************************* |
|
926 | //************************* | |
927 | // initialize the registers |
|
927 | // initialize the registers | |
928 | #ifdef GSA |
|
928 | #ifdef GSA | |
929 | #else |
|
929 | #else | |
930 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
930 | reset_wfp_burst_enable(); // reset burst and enable bits | |
931 | reset_wfp_status(); // reset all the status bits |
|
931 | reset_wfp_status(); // reset all the status bits | |
932 | #endif |
|
932 | #endif | |
933 |
|
933 | |||
934 | return status; |
|
934 | return status; | |
935 | } |
|
935 | } | |
936 |
|
936 | |||
937 | int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC ) |
|
937 | int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC ) | |
938 | { |
|
938 | { | |
939 | rtems_status_code status; |
|
939 | rtems_status_code status; | |
940 |
|
940 | |||
941 | status = RTEMS_UNSATISFIED; |
|
941 | status = RTEMS_UNSATISFIED; | |
942 |
|
942 | |||
943 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); |
|
943 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); | |
944 | lfrCurrentMode = mode; |
|
944 | lfrCurrentMode = mode; | |
945 |
|
945 | |||
946 | switch(mode){ |
|
946 | switch(mode){ | |
947 | case LFR_MODE_STANDBY: |
|
947 | case LFR_MODE_STANDBY: | |
948 | status = enter_standby_mode( TC ); |
|
948 | status = enter_standby_mode( TC ); | |
949 | break; |
|
949 | break; | |
950 | case LFR_MODE_NORMAL: |
|
950 | case LFR_MODE_NORMAL: | |
951 | status = enter_normal_mode( TC ); |
|
951 | status = enter_normal_mode( TC ); | |
952 | break; |
|
952 | break; | |
953 | case LFR_MODE_BURST: |
|
953 | case LFR_MODE_BURST: | |
954 | status = enter_burst_mode( TC ); |
|
954 | status = enter_burst_mode( TC ); | |
955 | break; |
|
955 | break; | |
956 | case LFR_MODE_SBM1: |
|
956 | case LFR_MODE_SBM1: | |
957 | status = enter_sbm1_mode( TC ); |
|
957 | status = enter_sbm1_mode( TC ); | |
958 | break; |
|
958 | break; | |
959 | case LFR_MODE_SBM2: |
|
959 | case LFR_MODE_SBM2: | |
960 | status = enter_sbm2_mode( TC ); |
|
960 | status = enter_sbm2_mode( TC ); | |
961 | break; |
|
961 | break; | |
962 | default: |
|
962 | default: | |
963 | status = RTEMS_UNSATISFIED; |
|
963 | status = RTEMS_UNSATISFIED; | |
964 | } |
|
964 | } | |
965 |
|
965 | |||
966 | if (status != RTEMS_SUCCESSFUL) |
|
966 | if (status != RTEMS_SUCCESSFUL) | |
967 | { |
|
967 | { | |
968 | PRINTF("in enter_mode *** ERR\n") |
|
968 | PRINTF("in enter_mode *** ERR\n") | |
969 | status = RTEMS_UNSATISFIED; |
|
969 | status = RTEMS_UNSATISFIED; | |
970 | } |
|
970 | } | |
971 |
|
971 | |||
972 | return status; |
|
972 | return status; | |
973 | } |
|
973 | } | |
974 |
|
974 | |||
975 | int enter_standby_mode() |
|
975 | int enter_standby_mode() | |
976 | { |
|
976 | { | |
977 | reset_waveform_picker_regs(); |
|
977 | reset_waveform_picker_regs(); | |
978 |
|
978 | |||
979 | PRINTF1("maxCount = %d\n", maxCount) |
|
979 | PRINTF1("maxCount = %d\n", maxCount) | |
980 |
|
980 | |||
981 | #ifdef PRINT_TASK_STATISTICS |
|
981 | #ifdef PRINT_TASK_STATISTICS | |
982 | rtems_cpu_usage_report(); |
|
982 | rtems_cpu_usage_report(); | |
983 | #endif |
|
983 | #endif | |
984 |
|
984 | |||
985 | #ifdef PRINT_STACK_REPORT |
|
985 | #ifdef PRINT_STACK_REPORT | |
986 | rtems_stack_checker_report_usage(); |
|
986 | rtems_stack_checker_report_usage(); | |
987 | #endif |
|
987 | #endif | |
988 |
|
988 | |||
989 | return LFR_SUCCESSFUL; |
|
989 | return LFR_SUCCESSFUL; | |
990 | } |
|
990 | } | |
991 |
|
991 | |||
992 | int enter_normal_mode() |
|
992 | int enter_normal_mode() | |
993 | { |
|
993 | { | |
994 | rtems_status_code status; |
|
994 | rtems_status_code status; | |
995 |
|
995 | |||
996 | status = restart_science_tasks(); |
|
996 | status = restart_science_tasks(); | |
997 |
|
997 | |||
998 | #ifdef GSA |
|
998 | #ifdef GSA | |
999 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR ); |
|
999 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR ); | |
1000 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
1000 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
1001 | LEON_Clear_interrupt( IRQ_WF ); |
|
1001 | LEON_Clear_interrupt( IRQ_WF ); | |
1002 | LEON_Unmask_interrupt( IRQ_WF ); |
|
1002 | LEON_Unmask_interrupt( IRQ_WF ); | |
1003 | // |
|
1003 | // | |
1004 | set_local_nb_interrupt_f0_MAX(); |
|
1004 | set_local_nb_interrupt_f0_MAX(); | |
1005 | LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board |
|
1005 | LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board | |
1006 | LEON_Unmask_interrupt( IRQ_SM ); |
|
1006 | LEON_Unmask_interrupt( IRQ_SM ); | |
1007 | #else |
|
1007 | #else | |
1008 | //**************** |
|
1008 | //**************** | |
1009 | // waveform picker |
|
1009 | // waveform picker | |
1010 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1010 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1011 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1011 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1012 | reset_waveform_picker_regs(); |
|
1012 | reset_waveform_picker_regs(); | |
1013 | set_wfp_burst_enable_register(LFR_MODE_NORMAL); |
|
1013 | set_wfp_burst_enable_register(LFR_MODE_NORMAL); | |
1014 | //**************** |
|
1014 | //**************** | |
1015 | // spectral matrix |
|
1015 | // spectral matrix | |
1016 | // set_local_nb_interrupt_f0_MAX(); |
|
1016 | // set_local_nb_interrupt_f0_MAX(); | |
1017 | // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board |
|
1017 | // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board | |
1018 | // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1018 | // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1019 | // spectral_matrix_regs->config = 0x01; |
|
1019 | // spectral_matrix_regs->config = 0x01; | |
1020 | // spectral_matrix_regs->status = 0x00; |
|
1020 | // spectral_matrix_regs->status = 0x00; | |
1021 | #endif |
|
1021 | #endif | |
1022 |
|
1022 | |||
1023 | return status; |
|
1023 | return status; | |
1024 | } |
|
1024 | } | |
1025 |
|
1025 | |||
1026 | int enter_burst_mode() |
|
1026 | int enter_burst_mode() | |
1027 | { |
|
1027 | { | |
1028 | rtems_status_code status; |
|
1028 | rtems_status_code status; | |
1029 |
|
1029 | |||
1030 | status = restart_science_tasks(); |
|
1030 | status = restart_science_tasks(); | |
1031 |
|
1031 | |||
1032 | #ifdef GSA |
|
1032 | #ifdef GSA | |
1033 | LEON_Unmask_interrupt( IRQ_SM ); |
|
1033 | LEON_Unmask_interrupt( IRQ_SM ); | |
1034 | #else |
|
1034 | #else | |
1035 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1035 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1036 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1036 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1037 | reset_waveform_picker_regs(); |
|
1037 | reset_waveform_picker_regs(); | |
1038 | set_wfp_burst_enable_register(LFR_MODE_BURST); |
|
1038 | set_wfp_burst_enable_register(LFR_MODE_BURST); | |
1039 | #endif |
|
1039 | #endif | |
1040 |
|
1040 | |||
1041 | return status; |
|
1041 | return status; | |
1042 | } |
|
1042 | } | |
1043 |
|
1043 | |||
1044 | int enter_sbm1_mode() |
|
1044 | int enter_sbm1_mode() | |
1045 | { |
|
1045 | { | |
1046 | rtems_status_code status; |
|
1046 | rtems_status_code status; | |
1047 |
|
1047 | |||
1048 | status = restart_science_tasks(); |
|
1048 | status = restart_science_tasks(); | |
1049 |
|
1049 | |||
1050 | set_local_sbm1_nb_cwf_max(); |
|
1050 | set_local_sbm1_nb_cwf_max(); | |
1051 |
|
1051 | |||
1052 | reset_local_sbm1_nb_cwf_sent(); |
|
1052 | reset_local_sbm1_nb_cwf_sent(); | |
1053 |
|
1053 | |||
1054 | #ifdef GSA |
|
1054 | #ifdef GSA | |
1055 | LEON_Unmask_interrupt( IRQ_SM ); |
|
1055 | LEON_Unmask_interrupt( IRQ_SM ); | |
1056 | #else |
|
1056 | #else | |
1057 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1057 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1058 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1058 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1059 | reset_waveform_picker_regs(); |
|
1059 | reset_waveform_picker_regs(); | |
1060 | set_wfp_burst_enable_register(LFR_MODE_SBM1); |
|
1060 | set_wfp_burst_enable_register(LFR_MODE_SBM1); | |
1061 | // SM simulation |
|
1061 | // SM simulation | |
1062 | // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
1062 | // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
1063 | // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board |
|
1063 | // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board | |
1064 | // LEON_Unmask_interrupt( IRQ_SM ); |
|
1064 | // LEON_Unmask_interrupt( IRQ_SM ); | |
1065 | #endif |
|
1065 | #endif | |
1066 |
|
1066 | |||
1067 | return status; |
|
1067 | return status; | |
1068 | } |
|
1068 | } | |
1069 |
|
1069 | |||
1070 | int enter_sbm2_mode() |
|
1070 | int enter_sbm2_mode() | |
1071 | { |
|
1071 | { | |
1072 | rtems_status_code status; |
|
1072 | rtems_status_code status; | |
1073 |
|
1073 | |||
1074 | status = restart_science_tasks(); |
|
1074 | status = restart_science_tasks(); | |
1075 |
|
1075 | |||
1076 | set_local_sbm2_nb_cwf_max(); |
|
1076 | set_local_sbm2_nb_cwf_max(); | |
1077 |
|
1077 | |||
1078 | reset_local_sbm2_nb_cwf_sent(); |
|
1078 | reset_local_sbm2_nb_cwf_sent(); | |
1079 |
|
1079 | |||
1080 | #ifdef GSA |
|
1080 | #ifdef GSA | |
1081 | LEON_Unmask_interrupt( IRQ_SM ); |
|
1081 | LEON_Unmask_interrupt( IRQ_SM ); | |
1082 | #else |
|
1082 | #else | |
1083 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1083 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1084 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1084 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1085 | reset_waveform_picker_regs(); |
|
1085 | reset_waveform_picker_regs(); | |
1086 | set_wfp_burst_enable_register(LFR_MODE_SBM2); |
|
1086 | set_wfp_burst_enable_register(LFR_MODE_SBM2); | |
1087 | #endif |
|
1087 | #endif | |
1088 |
|
1088 | |||
1089 | return status; |
|
1089 | return status; | |
1090 | } |
|
1090 | } | |
1091 |
|
1091 | |||
1092 | int restart_science_tasks() |
|
1092 | int restart_science_tasks() | |
1093 | { |
|
1093 | { | |
1094 | rtems_status_code status[6]; |
|
1094 | rtems_status_code status[6]; | |
1095 | rtems_status_code ret; |
|
1095 | rtems_status_code ret; | |
1096 |
|
1096 | |||
1097 | ret = RTEMS_SUCCESSFUL; |
|
1097 | ret = RTEMS_SUCCESSFUL; | |
1098 |
|
1098 | |||
1099 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); |
|
1099 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 ); | |
1100 | if (status[0] != RTEMS_SUCCESSFUL) |
|
1100 | if (status[0] != RTEMS_SUCCESSFUL) | |
1101 | { |
|
1101 | { | |
1102 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) |
|
1102 | PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0]) | |
1103 | } |
|
1103 | } | |
1104 |
|
1104 | |||
1105 | status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 ); |
|
1105 | status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 ); | |
1106 | if (status[1] != RTEMS_SUCCESSFUL) |
|
1106 | if (status[1] != RTEMS_SUCCESSFUL) | |
1107 | { |
|
1107 | { | |
1108 | PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1]) |
|
1108 | PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1]) | |
1109 | } |
|
1109 | } | |
1110 |
|
1110 | |||
1111 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
1111 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
1112 | if (status[2] != RTEMS_SUCCESSFUL) |
|
1112 | if (status[2] != RTEMS_SUCCESSFUL) | |
1113 | { |
|
1113 | { | |
1114 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) |
|
1114 | PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2]) | |
1115 | } |
|
1115 | } | |
1116 |
|
1116 | |||
1117 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
1117 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
1118 | if (status[3] != RTEMS_SUCCESSFUL) |
|
1118 | if (status[3] != RTEMS_SUCCESSFUL) | |
1119 | { |
|
1119 | { | |
1120 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) |
|
1120 | PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3]) | |
1121 | } |
|
1121 | } | |
1122 |
|
1122 | |||
1123 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
1123 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
1124 | if (status[4] != RTEMS_SUCCESSFUL) |
|
1124 | if (status[4] != RTEMS_SUCCESSFUL) | |
1125 | { |
|
1125 | { | |
1126 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) |
|
1126 | PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4]) | |
1127 | } |
|
1127 | } | |
1128 |
|
1128 | |||
1129 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
1129 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
1130 | if (status[5] != RTEMS_SUCCESSFUL) |
|
1130 | if (status[5] != RTEMS_SUCCESSFUL) | |
1131 | { |
|
1131 | { | |
1132 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) |
|
1132 | PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5]) | |
1133 | } |
|
1133 | } | |
1134 |
|
1134 | |||
1135 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || |
|
1135 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) || | |
1136 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
1136 | (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
1137 | { |
|
1137 | { | |
1138 | ret = RTEMS_UNSATISFIED; |
|
1138 | ret = RTEMS_UNSATISFIED; | |
1139 | } |
|
1139 | } | |
1140 |
|
1140 | |||
1141 | return ret; |
|
1141 | return ret; | |
1142 | } |
|
1142 | } | |
1143 |
|
1143 | |||
1144 | int suspend_science_tasks() |
|
1144 | int suspend_science_tasks() | |
1145 | { |
|
1145 | { | |
1146 | /** This function suspends the science tasks. |
|
1146 | /** This function suspends the science tasks. | |
1147 | * |
|
1147 | * | |
1148 | * @return RTEMS directive status codes: |
|
1148 | * @return RTEMS directive status codes: | |
1149 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1149 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1150 | * - RTEMS_INVALID_ID - task id invalid |
|
1150 | * - RTEMS_INVALID_ID - task id invalid | |
1151 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1151 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1152 | * |
|
1152 | * | |
1153 | */ |
|
1153 | */ | |
1154 |
|
1154 | |||
1155 | rtems_status_code status; |
|
1155 | rtems_status_code status; | |
1156 |
|
1156 | |||
1157 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); |
|
1157 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); | |
1158 | if (status != RTEMS_SUCCESSFUL) |
|
1158 | if (status != RTEMS_SUCCESSFUL) | |
1159 | { |
|
1159 | { | |
1160 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1160 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1161 | } |
|
1161 | } | |
1162 | if (status == RTEMS_SUCCESSFUL) // suspend BPF0 |
|
1162 | if (status == RTEMS_SUCCESSFUL) // suspend BPF0 | |
1163 | { |
|
1163 | { | |
1164 | status = rtems_task_suspend( Task_id[TASKID_BPF0] ); |
|
1164 | status = rtems_task_suspend( Task_id[TASKID_BPF0] ); | |
1165 | if (status != RTEMS_SUCCESSFUL) |
|
1165 | if (status != RTEMS_SUCCESSFUL) | |
1166 | { |
|
1166 | { | |
1167 | PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status) |
|
1167 | PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status) | |
1168 | } |
|
1168 | } | |
1169 | } |
|
1169 | } | |
1170 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
1170 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
1171 | { |
|
1171 | { | |
1172 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
1172 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
1173 | if (status != RTEMS_SUCCESSFUL) |
|
1173 | if (status != RTEMS_SUCCESSFUL) | |
1174 | { |
|
1174 | { | |
1175 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
1175 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
1176 | } |
|
1176 | } | |
1177 | } |
|
1177 | } | |
1178 |
|
1178 | |||
1179 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
1179 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
1180 | { |
|
1180 | { | |
1181 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
1181 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
1182 | if (status != RTEMS_SUCCESSFUL) |
|
1182 | if (status != RTEMS_SUCCESSFUL) | |
1183 | { |
|
1183 | { | |
1184 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
1184 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
1185 | } |
|
1185 | } | |
1186 | } |
|
1186 | } | |
1187 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
1187 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
1188 | { |
|
1188 | { | |
1189 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
1189 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
1190 | if (status != RTEMS_SUCCESSFUL) |
|
1190 | if (status != RTEMS_SUCCESSFUL) | |
1191 | { |
|
1191 | { | |
1192 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
1192 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
1193 | } |
|
1193 | } | |
1194 | } |
|
1194 | } | |
1195 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
1195 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
1196 | { |
|
1196 | { | |
1197 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
1197 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
1198 | if (status != RTEMS_SUCCESSFUL) |
|
1198 | if (status != RTEMS_SUCCESSFUL) | |
1199 | { |
|
1199 | { | |
1200 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
1200 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
1201 | } |
|
1201 | } | |
1202 | } |
|
1202 | } | |
1203 |
|
1203 | |||
1204 | return status; |
|
1204 | return status; | |
1205 | } |
|
1205 | } | |
1206 |
|
1206 | |||
1207 | //**************** |
|
1207 | //**************** | |
1208 | // CLOSING ACTIONS |
|
1208 | // CLOSING ACTIONS | |
1209 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC) |
|
1209 | void update_last_TC_exe(ccsdsTelecommandPacket_t *TC) | |
1210 | { |
|
1210 | { | |
1211 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1211 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1212 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1212 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1213 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1213 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1214 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1214 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1215 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1215 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1216 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1216 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1217 | 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[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1218 | 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[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1219 | 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[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1220 | 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[3] = (unsigned char) (time_management_regs->coarse_time); | |
1221 | 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[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1222 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1222 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time); | |
1223 | } |
|
1223 | } | |
1224 |
|
1224 | |||
1225 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC) |
|
1225 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC) | |
1226 | { |
|
1226 | { | |
1227 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1227 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1228 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1228 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1229 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1229 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1230 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1230 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1231 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1231 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1232 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1232 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1233 | 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[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1234 | 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[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1235 | 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[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1236 | 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[3] = (unsigned char) (time_management_regs->coarse_time); | |
1237 | 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[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1238 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1238 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time); | |
1239 | } |
|
1239 | } | |
1240 |
|
1240 | |||
1241 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id) |
|
1241 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id) | |
1242 | { |
|
1242 | { | |
1243 | unsigned int val = 0; |
|
1243 | unsigned int val = 0; | |
1244 | if (result == LFR_SUCCESSFUL) |
|
1244 | if (result == LFR_SUCCESSFUL) | |
1245 | { |
|
1245 | { | |
1246 | if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) ) |
|
1246 | if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) ) | |
1247 | { |
|
1247 | { | |
1248 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1248 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1249 | } |
|
1249 | } | |
1250 | update_last_TC_exe( TC ); |
|
1250 | update_last_TC_exe( TC ); | |
1251 | val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1]; |
|
1251 | val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1]; | |
1252 | val++; |
|
1252 | val++; | |
1253 | housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8); |
|
1253 | housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8); | |
1254 | housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val); |
|
1254 | housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val); | |
1255 | } |
|
1255 | } | |
1256 | else |
|
1256 | else | |
1257 | { |
|
1257 | { | |
1258 | update_last_TC_rej( TC ); |
|
1258 | update_last_TC_rej( TC ); | |
1259 | val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1]; |
|
1259 | val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1]; | |
1260 | val++; |
|
1260 | val++; | |
1261 | housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8); |
|
1261 | housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8); | |
1262 | housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val); |
|
1262 | housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val); | |
1263 | } |
|
1263 | } | |
1264 | } |
|
1264 | } | |
1265 |
|
1265 | |||
1266 | //*************************** |
|
1266 | //*************************** | |
1267 | // Interrupt Service Routines |
|
1267 | // Interrupt Service Routines | |
1268 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1268 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1269 | { |
|
1269 | { | |
1270 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1270 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1271 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
1271 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | |
1272 | } |
|
1272 | } | |
1273 | } |
|
1273 | } | |
1274 |
|
1274 | |||
1275 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1275 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1276 | { |
|
1276 | { | |
1277 | 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) { | |
1278 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
1278 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | |
1279 | } |
|
1279 | } | |
1280 | } |
|
1280 | } | |
1281 |
|
1281 | |||
1282 |
|
1282 | |||
1283 |
|
1283 | |||
1284 |
|
1284 |
@@ -1,1106 +1,1106 | |||||
1 | /** Functions and tasks related to waveform packet generation. |
|
1 | /** Functions and tasks related to waveform packet generation. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 |
|
11 | |||
12 | // SWF |
|
12 | // SWF | |
13 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; |
|
13 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7]; | |
14 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; |
|
14 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; | |
15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; |
|
15 | Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; | |
16 | // CWF |
|
16 | // CWF | |
17 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7]; |
|
17 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7]; | |
18 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7]; |
|
18 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7]; | |
19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7]; |
|
19 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7]; | |
20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7]; |
|
20 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7]; | |
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7]; |
|
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7]; | |
22 |
|
22 | |||
23 | unsigned char doubleSendCWF1 = 0; |
|
23 | unsigned char doubleSendCWF1 = 0; | |
24 | unsigned char doubleSendCWF2 = 0; |
|
24 | unsigned char doubleSendCWF2 = 0; | |
25 |
|
25 | |||
26 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
26 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
27 | { |
|
27 | { | |
28 |
|
28 | |||
29 | #ifdef GSA |
|
29 | #ifdef GSA | |
30 | #else |
|
30 | #else | |
31 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
31 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
32 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
32 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
33 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
33 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
34 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full |
|
34 | if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full | |
35 | // (1) change the receiving buffer for the waveform picker |
|
35 | // (1) change the receiving buffer for the waveform picker | |
36 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) { |
|
36 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) { | |
37 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis); |
|
37 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis); | |
38 | } |
|
38 | } | |
39 | else { |
|
39 | else { | |
40 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); |
|
40 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); | |
41 | } |
|
41 | } | |
42 | // (2) send an event for the waveforms transmission |
|
42 | // (2) send an event for the waveforms transmission | |
43 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
43 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
44 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
44 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
45 | } |
|
45 | } | |
46 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] |
|
46 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111] | |
47 | } |
|
47 | } | |
48 | } |
|
48 | } | |
49 | #endif |
|
49 | #endif | |
50 |
|
50 | |||
51 | switch(lfrCurrentMode) |
|
51 | switch(lfrCurrentMode) | |
52 | { |
|
52 | { | |
53 | //******** |
|
53 | //******** | |
54 | // STANDBY |
|
54 | // STANDBY | |
55 | case(LFR_MODE_STANDBY): |
|
55 | case(LFR_MODE_STANDBY): | |
56 | break; |
|
56 | break; | |
57 |
|
57 | |||
58 | //****** |
|
58 | //****** | |
59 | // NORMAL |
|
59 | // NORMAL | |
60 | case(LFR_MODE_NORMAL): |
|
60 | case(LFR_MODE_NORMAL): | |
61 | #ifdef GSA |
|
61 | #ifdef GSA | |
62 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
62 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") | |
63 | #else |
|
63 | #else | |
64 | if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable |
|
64 | if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable | |
65 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
65 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
66 | } |
|
66 | } | |
67 | else { |
|
67 | else { | |
68 | if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full |
|
68 | if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full | |
69 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08; |
|
69 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08; | |
70 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
70 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
71 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
71 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
72 | } |
|
72 | } | |
73 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00; |
|
73 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00; | |
74 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0 |
|
74 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0 | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 | #endif |
|
77 | #endif | |
78 | break; |
|
78 | break; | |
79 |
|
79 | |||
80 | //****** |
|
80 | //****** | |
81 | // BURST |
|
81 | // BURST | |
82 | case(LFR_MODE_BURST): |
|
82 | case(LFR_MODE_BURST): | |
83 | #ifdef GSA |
|
83 | #ifdef GSA | |
84 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
84 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") | |
85 | #else |
|
85 | #else | |
86 | if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit |
|
86 | if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit | |
87 | // (1) change the receiving buffer for the waveform picker |
|
87 | // (1) change the receiving buffer for the waveform picker | |
88 | if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { |
|
88 | if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { | |
89 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis); |
|
89 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis); | |
90 | } |
|
90 | } | |
91 | else { |
|
91 | else { | |
92 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); |
|
92 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); | |
93 | } |
|
93 | } | |
94 | // (2) send an event for the waveforms transmission |
|
94 | // (2) send an event for the waveforms transmission | |
95 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
95 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
96 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
96 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
97 | } |
|
97 | } | |
98 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 |
|
98 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0 | |
99 | } |
|
99 | } | |
100 | #endif |
|
100 | #endif | |
101 | break; |
|
101 | break; | |
102 |
|
102 | |||
103 | //***** |
|
103 | //***** | |
104 | // SBM1 |
|
104 | // SBM1 | |
105 | case(LFR_MODE_SBM1): |
|
105 | case(LFR_MODE_SBM1): | |
106 | #ifdef GSA |
|
106 | #ifdef GSA | |
107 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
107 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") | |
108 | #else |
|
108 | #else | |
109 | if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit |
|
109 | if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit | |
110 | // (1) change the receiving buffer for the waveform picker |
|
110 | // (1) change the receiving buffer for the waveform picker | |
111 | if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) ) |
|
111 | if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) ) | |
112 | { |
|
112 | { | |
113 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm); |
|
113 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm); | |
114 | } |
|
114 | } | |
115 | else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm ) |
|
115 | else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm ) | |
116 | { |
|
116 | { | |
117 | doubleSendCWF1 = 1; |
|
117 | doubleSendCWF1 = 1; | |
118 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); |
|
118 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); | |
119 | } |
|
119 | } | |
120 | else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) { |
|
120 | else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) { | |
121 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis); |
|
121 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis); | |
122 | } |
|
122 | } | |
123 | else { |
|
123 | else { | |
124 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); |
|
124 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); | |
125 | } |
|
125 | } | |
126 | // (2) send an event for the waveforms transmission |
|
126 | // (2) send an event for the waveforms transmission | |
127 | if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { |
|
127 | if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) { | |
128 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
128 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
129 | } |
|
129 | } | |
130 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 |
|
130 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0 | |
131 | } |
|
131 | } | |
132 | if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit |
|
132 | if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit | |
133 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
133 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
134 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
134 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
135 | } |
|
135 | } | |
136 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 |
|
136 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0 | |
137 | reset_local_sbm1_nb_cwf_sent(); |
|
137 | reset_local_sbm1_nb_cwf_sent(); | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | #endif |
|
140 | #endif | |
141 | break; |
|
141 | break; | |
142 |
|
142 | |||
143 | //***** |
|
143 | //***** | |
144 | // SBM2 |
|
144 | // SBM2 | |
145 | case(LFR_MODE_SBM2): |
|
145 | case(LFR_MODE_SBM2): | |
146 | #ifdef GSA |
|
146 | #ifdef GSA | |
147 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") |
|
147 | PRINTF("in waveform_isr *** unexpected waveform picker interruption\n") | |
148 | #else |
|
148 | #else | |
149 | if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit |
|
149 | if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit | |
150 | // (1) change the receiving buffer for the waveform picker |
|
150 | // (1) change the receiving buffer for the waveform picker | |
151 | if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) ) |
|
151 | if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) ) | |
152 | { |
|
152 | { | |
153 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm); |
|
153 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm); | |
154 | } |
|
154 | } | |
155 | else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) { |
|
155 | else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) { | |
156 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); |
|
156 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); | |
157 | doubleSendCWF2 = 1; |
|
157 | doubleSendCWF2 = 1; | |
158 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) { |
|
158 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) { | |
159 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
159 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
160 | } |
|
160 | } | |
161 | reset_local_sbm2_nb_cwf_sent(); |
|
161 | reset_local_sbm2_nb_cwf_sent(); | |
162 | } |
|
162 | } | |
163 | else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) { |
|
163 | else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) { | |
164 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis); |
|
164 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis); | |
165 | } |
|
165 | } | |
166 | else { |
|
166 | else { | |
167 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); |
|
167 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); | |
168 | } |
|
168 | } | |
169 | // (2) send an event for the waveforms transmission |
|
169 | // (2) send an event for the waveforms transmission | |
170 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { |
|
170 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { | |
171 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
171 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
172 | } |
|
172 | } | |
173 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 |
|
173 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0 | |
174 | } |
|
174 | } | |
175 | if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full |
|
175 | if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full | |
176 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { |
|
176 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) { | |
177 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); |
|
177 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); | |
178 | } |
|
178 | } | |
179 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 |
|
179 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 | |
180 | } |
|
180 | } | |
181 | #endif |
|
181 | #endif | |
182 | break; |
|
182 | break; | |
183 |
|
183 | |||
184 | //******** |
|
184 | //******** | |
185 | // DEFAULT |
|
185 | // DEFAULT | |
186 | default: |
|
186 | default: | |
187 | break; |
|
187 | break; | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ) |
|
191 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ) | |
192 | { |
|
192 | { | |
193 | unsigned char lfrMode; |
|
193 | unsigned char lfrMode; | |
194 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
194 | lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
195 |
|
195 | |||
196 | switch(lfrMode) { |
|
196 | switch(lfrMode) { | |
197 | case (LFR_MODE_STANDBY): |
|
197 | case (LFR_MODE_STANDBY): | |
198 | break; |
|
198 | break; | |
199 | case (LFR_MODE_NORMAL): |
|
199 | case (LFR_MODE_NORMAL): | |
200 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { |
|
200 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { | |
201 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 ); |
|
201 | rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 ); | |
202 | } |
|
202 | } | |
203 | break; |
|
203 | break; | |
204 | case (LFR_MODE_BURST): |
|
204 | case (LFR_MODE_BURST): | |
205 | break; |
|
205 | break; | |
206 | case (LFR_MODE_SBM1): |
|
206 | case (LFR_MODE_SBM1): | |
207 | break; |
|
207 | break; | |
208 | case (LFR_MODE_SBM2): |
|
208 | case (LFR_MODE_SBM2): | |
209 | break; |
|
209 | break; | |
210 | } |
|
210 | } | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
213 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
214 | { |
|
214 | { | |
215 | rtems_event_set event_out; |
|
215 | rtems_event_set event_out; | |
216 | rtems_id queue_id; |
|
216 | rtems_id queue_id; | |
217 | rtems_status_code status; |
|
217 | rtems_status_code status; | |
218 |
|
218 | |||
219 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); |
|
219 | init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 ); | |
220 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); |
|
220 | init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 ); | |
221 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); |
|
221 | init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 ); | |
222 |
|
222 | |||
223 | init_waveforms(); |
|
223 | init_waveforms(); | |
224 |
|
224 | |||
225 |
status = rtems_message_queue_ident( misc_name[QUEUE_ |
|
225 | status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id ); | |
226 | if (status != RTEMS_SUCCESSFUL) |
|
226 | if (status != RTEMS_SUCCESSFUL) | |
227 | { |
|
227 | { | |
228 | PRINTF1("in WFRM *** ERR getting queue id, %d\n", status) |
|
228 | PRINTF1("in WFRM *** ERR getting queue id, %d\n", status) | |
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 | BOOT_PRINTF("in WFRM ***\n") |
|
231 | BOOT_PRINTF("in WFRM ***\n") | |
232 |
|
232 | |||
233 | while(1){ |
|
233 | while(1){ | |
234 | // wait for an RTEMS_EVENT |
|
234 | // wait for an RTEMS_EVENT | |
235 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
235 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 | |
236 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
236 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, | |
237 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
237 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
238 |
|
238 | |||
239 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
239 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
240 | { |
|
240 | { | |
241 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
241 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); | |
242 | send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
242 | send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id); | |
243 | send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
243 | send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id); | |
244 | #ifdef GSA |
|
244 | #ifdef GSA | |
245 | waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0 |
|
245 | waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0 | |
246 | #endif |
|
246 | #endif | |
247 | } |
|
247 | } | |
248 | else if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
248 | else if (event_out == RTEMS_EVENT_MODE_SBM1) | |
249 | { |
|
249 | { | |
250 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
250 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); | |
251 | send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
251 | send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id); | |
252 | send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
252 | send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id); | |
253 | #ifdef GSA |
|
253 | #ifdef GSA | |
254 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0 |
|
254 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0 | |
255 | #endif |
|
255 | #endif | |
256 | } |
|
256 | } | |
257 | else if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
257 | else if (event_out == RTEMS_EVENT_MODE_SBM2) | |
258 | { |
|
258 | { | |
259 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); |
|
259 | send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id); | |
260 | send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id); |
|
260 | send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id); | |
261 | #ifdef GSA |
|
261 | #ifdef GSA | |
262 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 |
|
262 | waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0 | |
263 | #endif |
|
263 | #endif | |
264 | } |
|
264 | } | |
265 | else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM) |
|
265 | else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM) | |
266 | { |
|
266 | { | |
267 | send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id); |
|
267 | send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id); | |
268 | } |
|
268 | } | |
269 | else |
|
269 | else | |
270 | { |
|
270 | { | |
271 | PRINTF("in WFRM *** unexpected event") |
|
271 | PRINTF("in WFRM *** unexpected event") | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 |
|
274 | |||
275 | #ifdef GSA |
|
275 | #ifdef GSA | |
276 | // irq processed, reset the related register of the timer unit |
|
276 | // irq processed, reset the related register of the timer unit | |
277 | gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010; |
|
277 | gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010; | |
278 | // clear the interruption |
|
278 | // clear the interruption | |
279 | LEON_Unmask_interrupt( IRQ_WF ); |
|
279 | LEON_Unmask_interrupt( IRQ_WF ); | |
280 | #endif |
|
280 | #endif | |
281 | } |
|
281 | } | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
284 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
285 | { |
|
285 | { | |
286 | rtems_event_set event_out; |
|
286 | rtems_event_set event_out; | |
287 | rtems_id queue_id; |
|
287 | rtems_id queue_id; | |
288 |
|
288 | |||
289 | init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 ); |
|
289 | init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 ); | |
290 | init_header_continuous_wf3_light_table( headerCWF_F3_light ); |
|
290 | init_header_continuous_wf3_light_table( headerCWF_F3_light ); | |
291 |
|
291 | |||
292 | queue_id = get_pkts_queue_id(); |
|
292 | queue_id = get_pkts_queue_id(); | |
293 |
|
293 | |||
294 | BOOT_PRINTF("in CWF3 ***\n") |
|
294 | BOOT_PRINTF("in CWF3 ***\n") | |
295 |
|
295 | |||
296 | while(1){ |
|
296 | while(1){ | |
297 | // wait for an RTEMS_EVENT |
|
297 | // wait for an RTEMS_EVENT | |
298 | rtems_event_receive( RTEMS_EVENT_0, |
|
298 | rtems_event_receive( RTEMS_EVENT_0, | |
299 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
299 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
300 | PRINTF("send CWF F3 \n") |
|
300 | PRINTF("send CWF F3 \n") | |
301 | #ifdef GSA |
|
301 | #ifdef GSA | |
302 | #else |
|
302 | #else | |
303 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) { |
|
303 | if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) { | |
304 | send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id ); |
|
304 | send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id ); | |
305 | } |
|
305 | } | |
306 | else { |
|
306 | else { | |
307 | send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id ); |
|
307 | send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id ); | |
308 | } |
|
308 | } | |
309 | #endif |
|
309 | #endif | |
310 | } |
|
310 | } | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
313 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
314 | { |
|
314 | { | |
315 | rtems_event_set event_out; |
|
315 | rtems_event_set event_out; | |
316 | rtems_id queue_id; |
|
316 | rtems_id queue_id; | |
317 |
|
317 | |||
318 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); |
|
318 | init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST ); | |
319 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); |
|
319 | init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 ); | |
320 |
|
320 | |||
321 | queue_id = get_pkts_queue_id(); |
|
321 | queue_id = get_pkts_queue_id(); | |
322 |
|
322 | |||
323 | BOOT_PRINTF("in CWF2 ***\n") |
|
323 | BOOT_PRINTF("in CWF2 ***\n") | |
324 |
|
324 | |||
325 | while(1){ |
|
325 | while(1){ | |
326 | // wait for an RTEMS_EVENT |
|
326 | // wait for an RTEMS_EVENT | |
327 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
327 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, | |
328 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
328 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
329 |
|
329 | |||
330 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
330 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
331 | { |
|
331 | { | |
332 | // F2 |
|
332 | // F2 | |
333 | #ifdef GSA |
|
333 | #ifdef GSA | |
334 | #else |
|
334 | #else | |
335 | if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { |
|
335 | if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { | |
336 | send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
336 | send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); | |
337 | } |
|
337 | } | |
338 | else { |
|
338 | else { | |
339 | send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); |
|
339 | send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id ); | |
340 | } |
|
340 | } | |
341 | #endif |
|
341 | #endif | |
342 | } |
|
342 | } | |
343 |
|
343 | |||
344 | else if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
344 | else if (event_out == RTEMS_EVENT_MODE_SBM2) | |
345 | { |
|
345 | { | |
346 | #ifdef GSA |
|
346 | #ifdef GSA | |
347 | #else |
|
347 | #else | |
348 | if (doubleSendCWF2 == 1) |
|
348 | if (doubleSendCWF2 == 1) | |
349 | { |
|
349 | { | |
350 | doubleSendCWF2 = 0; |
|
350 | doubleSendCWF2 = 0; | |
351 | send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
351 | send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); | |
352 | } |
|
352 | } | |
353 | else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { |
|
353 | else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) { | |
354 | send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
354 | send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); | |
355 | } |
|
355 | } | |
356 | else { |
|
356 | else { | |
357 | send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); |
|
357 | send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id ); | |
358 | } |
|
358 | } | |
359 | param_local.local_sbm2_nb_cwf_sent ++; |
|
359 | param_local.local_sbm2_nb_cwf_sent ++; | |
360 | #endif |
|
360 | #endif | |
361 | } |
|
361 | } | |
362 | else |
|
362 | else | |
363 | { |
|
363 | { | |
364 | PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode) |
|
364 | PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode) | |
365 | } |
|
365 | } | |
366 | } |
|
366 | } | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
369 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
370 | { |
|
370 | { | |
371 | rtems_event_set event_out; |
|
371 | rtems_event_set event_out; | |
372 | rtems_id queue_id; |
|
372 | rtems_id queue_id; | |
373 |
|
373 | |||
374 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); |
|
374 | init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 ); | |
375 |
|
375 | |||
376 | queue_id = get_pkts_queue_id(); |
|
376 | queue_id = get_pkts_queue_id(); | |
377 |
|
377 | |||
378 | BOOT_PRINTF("in CWF1 ***\n") |
|
378 | BOOT_PRINTF("in CWF1 ***\n") | |
379 |
|
379 | |||
380 | while(1){ |
|
380 | while(1){ | |
381 | // wait for an RTEMS_EVENT |
|
381 | // wait for an RTEMS_EVENT | |
382 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
382 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, | |
383 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
383 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
384 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
384 | if (event_out == RTEMS_EVENT_MODE_SBM1) | |
385 | { |
|
385 | { | |
386 | #ifdef GSA |
|
386 | #ifdef GSA | |
387 | #else |
|
387 | #else | |
388 | if (doubleSendCWF1 == 1) |
|
388 | if (doubleSendCWF1 == 1) | |
389 | { |
|
389 | { | |
390 | doubleSendCWF1 = 0; |
|
390 | doubleSendCWF1 = 0; | |
391 | send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
391 | send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); | |
392 | } |
|
392 | } | |
393 | else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) { |
|
393 | else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) { | |
394 | send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
394 | send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); | |
395 | } |
|
395 | } | |
396 | else { |
|
396 | else { | |
397 | send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); |
|
397 | send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id ); | |
398 | } |
|
398 | } | |
399 | param_local.local_sbm1_nb_cwf_sent ++; |
|
399 | param_local.local_sbm1_nb_cwf_sent ++; | |
400 | #endif |
|
400 | #endif | |
401 | } |
|
401 | } | |
402 | else |
|
402 | else | |
403 | { |
|
403 | { | |
404 | PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode) |
|
404 | PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode) | |
405 | } |
|
405 | } | |
406 | } |
|
406 | } | |
407 | } |
|
407 | } | |
408 |
|
408 | |||
409 | //****************** |
|
409 | //****************** | |
410 | // general functions |
|
410 | // general functions | |
411 | void init_waveforms( void ) |
|
411 | void init_waveforms( void ) | |
412 | { |
|
412 | { | |
413 | int i = 0; |
|
413 | int i = 0; | |
414 |
|
414 | |||
415 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
415 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
416 | { |
|
416 | { | |
417 | //*** |
|
417 | //*** | |
418 | // F0 |
|
418 | // F0 | |
419 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // |
|
419 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // | |
420 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // |
|
420 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // | |
421 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // |
|
421 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // | |
422 |
|
422 | |||
423 | //*** |
|
423 | //*** | |
424 | // F1 |
|
424 | // F1 | |
425 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111; |
|
425 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111; | |
426 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333; |
|
426 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333; | |
427 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
427 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; | |
428 |
|
428 | |||
429 | //*** |
|
429 | //*** | |
430 | // F2 |
|
430 | // F2 | |
431 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333; |
|
431 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333; | |
432 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; |
|
432 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; | |
433 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; |
|
433 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; | |
434 |
|
434 | |||
435 | //*** |
|
435 | //*** | |
436 | // F3 |
|
436 | // F3 | |
437 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; |
|
437 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; | |
438 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; |
|
438 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; | |
439 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; |
|
439 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; | |
440 | } |
|
440 | } | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) |
|
443 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF) | |
444 | { |
|
444 | { | |
445 | unsigned char i; |
|
445 | unsigned char i; | |
446 |
|
446 | |||
447 | for (i=0; i<7; i++) |
|
447 | for (i=0; i<7; i++) | |
448 | { |
|
448 | { | |
449 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
449 | headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; | |
450 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
450 | headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
451 | headerSWF[ i ].reserved = DEFAULT_RESERVED; |
|
451 | headerSWF[ i ].reserved = DEFAULT_RESERVED; | |
452 | headerSWF[ i ].userApplication = CCSDS_USER_APP; |
|
452 | headerSWF[ i ].userApplication = CCSDS_USER_APP; | |
453 | headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
453 | headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |
454 | headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
454 | headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |
455 | if (i == 0) |
|
455 | if (i == 0) | |
456 | { |
|
456 | { | |
457 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; |
|
457 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; | |
458 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8); |
|
458 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8); | |
459 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 ); |
|
459 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 ); | |
460 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
460 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); | |
461 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
461 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); | |
462 | } |
|
462 | } | |
463 | else if (i == 6) |
|
463 | else if (i == 6) | |
464 | { |
|
464 | { | |
465 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; |
|
465 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; | |
466 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8); |
|
466 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8); | |
467 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 ); |
|
467 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 ); | |
468 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); |
|
468 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); | |
469 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); |
|
469 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); | |
470 | } |
|
470 | } | |
471 | else |
|
471 | else | |
472 | { |
|
472 | { | |
473 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; |
|
473 | headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; | |
474 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8); |
|
474 | headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8); | |
475 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 ); |
|
475 | headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 ); | |
476 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
476 | headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); | |
477 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
477 | headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); | |
478 | } |
|
478 | } | |
479 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
479 | headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
480 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
480 | headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
481 | headerSWF[ i ].pktNr = i+1; // PKT_NR |
|
481 | headerSWF[ i ].pktNr = i+1; // PKT_NR | |
482 | // DATA FIELD HEADER |
|
482 | // DATA FIELD HEADER | |
483 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
483 | headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
484 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
484 | headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
485 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
485 | headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
486 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
486 | headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; | |
487 | // AUXILIARY DATA HEADER |
|
487 | // AUXILIARY DATA HEADER | |
488 | headerSWF[ i ].sid = sid; |
|
488 | headerSWF[ i ].sid = sid; | |
489 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
489 | headerSWF[ i ].hkBIA = DEFAULT_HKBIA; | |
490 | headerSWF[ i ].time[0] = 0x00; |
|
490 | headerSWF[ i ].time[0] = 0x00; | |
491 | headerSWF[ i ].time[0] = 0x00; |
|
491 | headerSWF[ i ].time[0] = 0x00; | |
492 | headerSWF[ i ].time[0] = 0x00; |
|
492 | headerSWF[ i ].time[0] = 0x00; | |
493 | headerSWF[ i ].time[0] = 0x00; |
|
493 | headerSWF[ i ].time[0] = 0x00; | |
494 | headerSWF[ i ].time[0] = 0x00; |
|
494 | headerSWF[ i ].time[0] = 0x00; | |
495 | headerSWF[ i ].time[0] = 0x00; |
|
495 | headerSWF[ i ].time[0] = 0x00; | |
496 | } |
|
496 | } | |
497 | return LFR_SUCCESSFUL; |
|
497 | return LFR_SUCCESSFUL; | |
498 | } |
|
498 | } | |
499 |
|
499 | |||
500 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
500 | int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) | |
501 | { |
|
501 | { | |
502 | unsigned int i; |
|
502 | unsigned int i; | |
503 |
|
503 | |||
504 | for (i=0; i<7; i++) |
|
504 | for (i=0; i<7; i++) | |
505 | { |
|
505 | { | |
506 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
506 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; | |
507 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
507 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
508 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
508 | headerCWF[ i ].reserved = DEFAULT_RESERVED; | |
509 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
509 | headerCWF[ i ].userApplication = CCSDS_USER_APP; | |
510 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
510 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
511 | { |
|
511 | { | |
512 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); |
|
512 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8); | |
513 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); |
|
513 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2); | |
514 | } |
|
514 | } | |
515 | else |
|
515 | else | |
516 | { |
|
516 | { | |
517 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
517 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |
518 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
518 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |
519 | } |
|
519 | } | |
520 | if (i == 0) |
|
520 | if (i == 0) | |
521 | { |
|
521 | { | |
522 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; |
|
522 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; | |
523 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); |
|
523 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); | |
524 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); |
|
524 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); | |
525 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
525 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); | |
526 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
526 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); | |
527 | } |
|
527 | } | |
528 | else if (i == 6) |
|
528 | else if (i == 6) | |
529 | { |
|
529 | { | |
530 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; |
|
530 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; | |
531 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8); |
|
531 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8); | |
532 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 ); |
|
532 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 ); | |
533 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); |
|
533 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); | |
534 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); |
|
534 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); | |
535 | } |
|
535 | } | |
536 | else |
|
536 | else | |
537 | { |
|
537 | { | |
538 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; |
|
538 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; | |
539 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); |
|
539 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); | |
540 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); |
|
540 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); | |
541 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
541 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); | |
542 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
542 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); | |
543 | } |
|
543 | } | |
544 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
544 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
545 | // PKT_CNT |
|
545 | // PKT_CNT | |
546 | // PKT_NR |
|
546 | // PKT_NR | |
547 | // DATA FIELD HEADER |
|
547 | // DATA FIELD HEADER | |
548 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
548 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
549 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
549 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
550 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
550 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
551 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
551 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; | |
552 | // AUXILIARY DATA HEADER |
|
552 | // AUXILIARY DATA HEADER | |
553 | headerCWF[ i ].sid = sid; |
|
553 | headerCWF[ i ].sid = sid; | |
554 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
554 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; | |
555 | headerCWF[ i ].time[0] = 0x00; |
|
555 | headerCWF[ i ].time[0] = 0x00; | |
556 | headerCWF[ i ].time[0] = 0x00; |
|
556 | headerCWF[ i ].time[0] = 0x00; | |
557 | headerCWF[ i ].time[0] = 0x00; |
|
557 | headerCWF[ i ].time[0] = 0x00; | |
558 | headerCWF[ i ].time[0] = 0x00; |
|
558 | headerCWF[ i ].time[0] = 0x00; | |
559 | headerCWF[ i ].time[0] = 0x00; |
|
559 | headerCWF[ i ].time[0] = 0x00; | |
560 | headerCWF[ i ].time[0] = 0x00; |
|
560 | headerCWF[ i ].time[0] = 0x00; | |
561 | } |
|
561 | } | |
562 | return LFR_SUCCESSFUL; |
|
562 | return LFR_SUCCESSFUL; | |
563 | } |
|
563 | } | |
564 |
|
564 | |||
565 | int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) |
|
565 | int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ) | |
566 | { |
|
566 | { | |
567 | unsigned int i; |
|
567 | unsigned int i; | |
568 |
|
568 | |||
569 | for (i=0; i<7; i++) |
|
569 | for (i=0; i<7; i++) | |
570 | { |
|
570 | { | |
571 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
571 | headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID; | |
572 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
572 | headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
573 | headerCWF[ i ].reserved = DEFAULT_RESERVED; |
|
573 | headerCWF[ i ].reserved = DEFAULT_RESERVED; | |
574 | headerCWF[ i ].userApplication = CCSDS_USER_APP; |
|
574 | headerCWF[ i ].userApplication = CCSDS_USER_APP; | |
575 |
|
575 | |||
576 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); |
|
576 | headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); | |
577 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); |
|
577 | headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); | |
578 | if (i == 0) |
|
578 | if (i == 0) | |
579 | { |
|
579 | { | |
580 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; |
|
580 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; | |
581 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); |
|
581 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); | |
582 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); |
|
582 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); | |
583 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
583 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); | |
584 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
584 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); | |
585 | } |
|
585 | } | |
586 | else if (i == 6) |
|
586 | else if (i == 6) | |
587 | { |
|
587 | { | |
588 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; |
|
588 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; | |
589 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8); |
|
589 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8); | |
590 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 ); |
|
590 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 ); | |
591 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); |
|
591 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); | |
592 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); |
|
592 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); | |
593 | } |
|
593 | } | |
594 | else |
|
594 | else | |
595 | { |
|
595 | { | |
596 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; |
|
596 | headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; | |
597 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); |
|
597 | headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); | |
598 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); |
|
598 | headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); | |
599 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); |
|
599 | headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); | |
600 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); |
|
600 | headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); | |
601 | } |
|
601 | } | |
602 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
602 | headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
603 | // DATA FIELD HEADER |
|
603 | // DATA FIELD HEADER | |
604 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
604 | headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
605 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
605 | headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
606 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype |
|
606 | headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
607 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; |
|
607 | headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND; | |
608 | // AUXILIARY DATA HEADER |
|
608 | // AUXILIARY DATA HEADER | |
609 | headerCWF[ i ].sid = SID_NORM_CWF_F3; |
|
609 | headerCWF[ i ].sid = SID_NORM_CWF_F3; | |
610 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; |
|
610 | headerCWF[ i ].hkBIA = DEFAULT_HKBIA; | |
611 | headerCWF[ i ].time[0] = 0x00; |
|
611 | headerCWF[ i ].time[0] = 0x00; | |
612 | headerCWF[ i ].time[0] = 0x00; |
|
612 | headerCWF[ i ].time[0] = 0x00; | |
613 | headerCWF[ i ].time[0] = 0x00; |
|
613 | headerCWF[ i ].time[0] = 0x00; | |
614 | headerCWF[ i ].time[0] = 0x00; |
|
614 | headerCWF[ i ].time[0] = 0x00; | |
615 | headerCWF[ i ].time[0] = 0x00; |
|
615 | headerCWF[ i ].time[0] = 0x00; | |
616 | headerCWF[ i ].time[0] = 0x00; |
|
616 | headerCWF[ i ].time[0] = 0x00; | |
617 | } |
|
617 | } | |
618 | return LFR_SUCCESSFUL; |
|
618 | return LFR_SUCCESSFUL; | |
619 | } |
|
619 | } | |
620 |
|
620 | |||
621 | void reset_waveforms( void ) |
|
621 | void reset_waveforms( void ) | |
622 | { |
|
622 | { | |
623 | int i = 0; |
|
623 | int i = 0; | |
624 |
|
624 | |||
625 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
625 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
626 | { |
|
626 | { | |
627 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000; |
|
627 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000; | |
628 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; |
|
628 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; | |
629 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; |
|
629 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; | |
630 |
|
630 | |||
631 | //*** |
|
631 | //*** | |
632 | // F1 |
|
632 | // F1 | |
633 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000; |
|
633 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000; | |
634 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000; |
|
634 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000; | |
635 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; |
|
635 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; | |
636 |
|
636 | |||
637 | //*** |
|
637 | //*** | |
638 | // F2 |
|
638 | // F2 | |
639 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000; |
|
639 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000; | |
640 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; |
|
640 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; | |
641 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000; |
|
641 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000; | |
642 |
|
642 | |||
643 | //*** |
|
643 | //*** | |
644 | // F3 |
|
644 | // F3 | |
645 | /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1 |
|
645 | /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1 | |
646 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1 |
|
646 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1 | |
647 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/ |
|
647 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/ | |
648 | } |
|
648 | } | |
649 | } |
|
649 | } | |
650 |
|
650 | |||
651 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, |
|
651 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, | |
652 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) |
|
652 | Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ) | |
653 | { |
|
653 | { | |
654 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
654 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
655 | * |
|
655 | * | |
656 | * @param waveform points to the buffer containing the data that will be send. |
|
656 | * @param waveform points to the buffer containing the data that will be send. | |
657 | * @param sid is the source identifier of the data that will be sent. |
|
657 | * @param sid is the source identifier of the data that will be sent. | |
658 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
658 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
659 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
659 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
660 | * contain information to setup the transmission of the data packets. |
|
660 | * contain information to setup the transmission of the data packets. | |
661 | * |
|
661 | * | |
662 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
662 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
663 | * |
|
663 | * | |
664 | */ |
|
664 | */ | |
665 |
|
665 | |||
666 | unsigned int i; |
|
666 | unsigned int i; | |
667 | int ret; |
|
667 | int ret; | |
668 | rtems_status_code status; |
|
668 | rtems_status_code status; | |
669 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
669 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
670 |
|
670 | |||
671 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header |
|
671 | spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header | |
672 | spw_ioctl_send_SWF.options = 0; |
|
672 | spw_ioctl_send_SWF.options = 0; | |
673 |
|
673 | |||
674 | ret = LFR_DEFAULT; |
|
674 | ret = LFR_DEFAULT; | |
675 |
|
675 | |||
676 | for (i=0; i<7; i++) // send waveform |
|
676 | for (i=0; i<7; i++) // send waveform | |
677 | { |
|
677 | { | |
678 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; |
|
678 | spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; | |
679 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; |
|
679 | spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; | |
680 | // BUILD THE DATA |
|
680 | // BUILD THE DATA | |
681 | if (i==6) { |
|
681 | if (i==6) { | |
682 | spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK; |
|
682 | spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK; | |
683 | } |
|
683 | } | |
684 | else { |
|
684 | else { | |
685 | spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK; |
|
685 | spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK; | |
686 | } |
|
686 | } | |
687 | // SET PACKET TIME |
|
687 | // SET PACKET TIME | |
688 | headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
688 | headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
689 | headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
689 | headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
690 | headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
690 | headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
691 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
691 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); | |
692 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
692 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
693 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); |
|
693 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); | |
694 | headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
694 | headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
695 | headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
695 | headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
696 | headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
696 | headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
697 | headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); |
|
697 | headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); | |
698 | headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
698 | headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
699 | headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); |
|
699 | headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); | |
700 | // SEND PACKET |
|
700 | // SEND PACKET | |
701 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
701 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); | |
702 | if (status != RTEMS_SUCCESSFUL) { |
|
702 | if (status != RTEMS_SUCCESSFUL) { | |
703 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
703 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
704 | ret = LFR_DEFAULT; |
|
704 | ret = LFR_DEFAULT; | |
705 | } |
|
705 | } | |
706 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds |
|
706 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds | |
707 | } |
|
707 | } | |
708 |
|
708 | |||
709 | return ret; |
|
709 | return ret; | |
710 | } |
|
710 | } | |
711 |
|
711 | |||
712 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
712 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, | |
713 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
713 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) | |
714 | { |
|
714 | { | |
715 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
715 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
716 | * |
|
716 | * | |
717 | * @param waveform points to the buffer containing the data that will be send. |
|
717 | * @param waveform points to the buffer containing the data that will be send. | |
718 | * @param sid is the source identifier of the data that will be sent. |
|
718 | * @param sid is the source identifier of the data that will be sent. | |
719 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
719 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
720 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
720 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
721 | * contain information to setup the transmission of the data packets. |
|
721 | * contain information to setup the transmission of the data packets. | |
722 | * |
|
722 | * | |
723 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
723 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
724 | * |
|
724 | * | |
725 | */ |
|
725 | */ | |
726 |
|
726 | |||
727 | unsigned int i; |
|
727 | unsigned int i; | |
728 | int ret; |
|
728 | int ret; | |
729 | rtems_status_code status; |
|
729 | rtems_status_code status; | |
730 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
730 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
731 |
|
731 | |||
732 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
732 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header | |
733 | spw_ioctl_send_CWF.options = 0; |
|
733 | spw_ioctl_send_CWF.options = 0; | |
734 |
|
734 | |||
735 | ret = LFR_DEFAULT; |
|
735 | ret = LFR_DEFAULT; | |
736 |
|
736 | |||
737 | for (i=0; i<7; i++) // send waveform |
|
737 | for (i=0; i<7; i++) // send waveform | |
738 | { |
|
738 | { | |
739 | int coarseTime = 0x00; |
|
739 | int coarseTime = 0x00; | |
740 | int fineTime = 0x00; |
|
740 | int fineTime = 0x00; | |
741 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; |
|
741 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; | |
742 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
742 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; | |
743 | // BUILD THE DATA |
|
743 | // BUILD THE DATA | |
744 | if (i==6) { |
|
744 | if (i==6) { | |
745 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK; |
|
745 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK; | |
746 | } |
|
746 | } | |
747 | else { |
|
747 | else { | |
748 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK; |
|
748 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK; | |
749 | } |
|
749 | } | |
750 | // SET PACKET TIME |
|
750 | // SET PACKET TIME | |
751 | coarseTime = time_management_regs->coarse_time; |
|
751 | coarseTime = time_management_regs->coarse_time; | |
752 | fineTime = time_management_regs->fine_time; |
|
752 | fineTime = time_management_regs->fine_time; | |
753 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
753 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); | |
754 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
754 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); | |
755 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
755 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); | |
756 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
756 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); | |
757 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
757 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); | |
758 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
758 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); | |
759 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
759 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); | |
760 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
760 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); | |
761 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
761 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); | |
762 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
762 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); | |
763 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
763 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); | |
764 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
764 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); | |
765 | // SEND PACKET |
|
765 | // SEND PACKET | |
766 | if (sid == SID_NORM_CWF_F3) |
|
766 | if (sid == SID_NORM_CWF_F3) | |
767 | { |
|
767 | { | |
768 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
768 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
769 | if (status != RTEMS_SUCCESSFUL) { |
|
769 | if (status != RTEMS_SUCCESSFUL) { | |
770 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
770 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
771 | ret = LFR_DEFAULT; |
|
771 | ret = LFR_DEFAULT; | |
772 | } |
|
772 | } | |
773 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
773 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); | |
774 | } |
|
774 | } | |
775 | else |
|
775 | else | |
776 | { |
|
776 | { | |
777 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
777 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
778 | if (status != RTEMS_SUCCESSFUL) { |
|
778 | if (status != RTEMS_SUCCESSFUL) { | |
779 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
779 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
780 | ret = LFR_DEFAULT; |
|
780 | ret = LFR_DEFAULT; | |
781 | } |
|
781 | } | |
782 | } |
|
782 | } | |
783 | } |
|
783 | } | |
784 |
|
784 | |||
785 | return ret; |
|
785 | return ret; | |
786 | } |
|
786 | } | |
787 |
|
787 | |||
788 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
788 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) | |
789 | { |
|
789 | { | |
790 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
790 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
791 | * |
|
791 | * | |
792 | * @param waveform points to the buffer containing the data that will be send. |
|
792 | * @param waveform points to the buffer containing the data that will be send. | |
793 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
793 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
794 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
794 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
795 | * contain information to setup the transmission of the data packets. |
|
795 | * contain information to setup the transmission of the data packets. | |
796 | * |
|
796 | * | |
797 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
797 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
798 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
798 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
799 | * |
|
799 | * | |
800 | */ |
|
800 | */ | |
801 |
|
801 | |||
802 | unsigned int i; |
|
802 | unsigned int i; | |
803 | int ret; |
|
803 | int ret; | |
804 | rtems_status_code status; |
|
804 | rtems_status_code status; | |
805 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
805 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
806 | char *sample; |
|
806 | char *sample; | |
807 |
|
807 | |||
808 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
808 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header | |
809 | spw_ioctl_send_CWF.options = 0; |
|
809 | spw_ioctl_send_CWF.options = 0; | |
810 |
|
810 | |||
811 | ret = LFR_DEFAULT; |
|
811 | ret = LFR_DEFAULT; | |
812 |
|
812 | |||
813 | //********************** |
|
813 | //********************** | |
814 | // BUILD CWF3_light DATA |
|
814 | // BUILD CWF3_light DATA | |
815 | for ( i=0; i< 2048; i++) |
|
815 | for ( i=0; i< 2048; i++) | |
816 | { |
|
816 | { | |
817 | sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ]; |
|
817 | sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ]; | |
818 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
818 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; | |
819 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; |
|
819 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; | |
820 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; |
|
820 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; | |
821 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; |
|
821 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; | |
822 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; |
|
822 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; | |
823 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; |
|
823 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; | |
824 | } |
|
824 | } | |
825 |
|
825 | |||
826 | //********************* |
|
826 | //********************* | |
827 | // SEND CWF3_light DATA |
|
827 | // SEND CWF3_light DATA | |
828 |
|
828 | |||
829 | for (i=0; i<7; i++) // send waveform |
|
829 | for (i=0; i<7; i++) // send waveform | |
830 | { |
|
830 | { | |
831 | int coarseTime = 0x00; |
|
831 | int coarseTime = 0x00; | |
832 | int fineTime = 0x00; |
|
832 | int fineTime = 0x00; | |
833 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
833 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ]; | |
834 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
834 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; | |
835 | // BUILD THE DATA |
|
835 | // BUILD THE DATA | |
836 | if ( i == WFRM_INDEX_OF_LAST_PACKET ) { |
|
836 | if ( i == WFRM_INDEX_OF_LAST_PACKET ) { | |
837 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK; |
|
837 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK; | |
838 | } |
|
838 | } | |
839 | else { |
|
839 | else { | |
840 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK; |
|
840 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK; | |
841 | } |
|
841 | } | |
842 | // SET PACKET TIME |
|
842 | // SET PACKET TIME | |
843 | coarseTime = time_management_regs->coarse_time; |
|
843 | coarseTime = time_management_regs->coarse_time; | |
844 | fineTime = time_management_regs->fine_time; |
|
844 | fineTime = time_management_regs->fine_time; | |
845 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
845 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); | |
846 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
846 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); | |
847 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
847 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); | |
848 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
848 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); | |
849 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
849 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); | |
850 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
850 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); | |
851 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
851 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); | |
852 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
852 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); | |
853 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
853 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); | |
854 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
854 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); | |
855 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
855 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); | |
856 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
856 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); | |
857 | // SEND PACKET |
|
857 | // SEND PACKET | |
858 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
858 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
859 | if (status != RTEMS_SUCCESSFUL) { |
|
859 | if (status != RTEMS_SUCCESSFUL) { | |
860 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
860 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); | |
861 | ret = LFR_DEFAULT; |
|
861 | ret = LFR_DEFAULT; | |
862 | } |
|
862 | } | |
863 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
863 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); | |
864 | } |
|
864 | } | |
865 |
|
865 | |||
866 | return ret; |
|
866 | return ret; | |
867 | } |
|
867 | } | |
868 |
|
868 | |||
869 |
|
869 | |||
870 | //************** |
|
870 | //************** | |
871 | // wfp registers |
|
871 | // wfp registers | |
872 | void set_wfp_data_shaping() |
|
872 | void set_wfp_data_shaping() | |
873 | { |
|
873 | { | |
874 | /** This function sets the data_shaping register of the waveform picker module. |
|
874 | /** This function sets the data_shaping register of the waveform picker module. | |
875 | * |
|
875 | * | |
876 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
876 | * The value is read from one field of the parameter_dump_packet structure:\n | |
877 | * bw_sp0_sp1_r0_r1 |
|
877 | * bw_sp0_sp1_r0_r1 | |
878 | * |
|
878 | * | |
879 | */ |
|
879 | */ | |
880 |
|
880 | |||
881 | unsigned char data_shaping; |
|
881 | unsigned char data_shaping; | |
882 |
|
882 | |||
883 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
883 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
884 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
884 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
885 |
|
885 | |||
886 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
886 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; | |
887 |
|
887 | |||
888 | #ifdef GSA |
|
888 | #ifdef GSA | |
889 | #else |
|
889 | #else | |
890 | waveform_picker_regs->data_shaping = |
|
890 | waveform_picker_regs->data_shaping = | |
891 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
891 | ( (data_shaping & 0x10) >> 4 ) // BW | |
892 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
892 | + ( (data_shaping & 0x08) >> 2 ) // SP0 | |
893 | + ( (data_shaping & 0x04) ) // SP1 |
|
893 | + ( (data_shaping & 0x04) ) // SP1 | |
894 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
894 | + ( (data_shaping & 0x02) << 2 ) // R0 | |
895 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
895 | + ( (data_shaping & 0x01) << 4 ); // R1 | |
896 | #endif |
|
896 | #endif | |
897 | } |
|
897 | } | |
898 |
|
898 | |||
899 | char set_wfp_delta_snapshot() |
|
899 | char set_wfp_delta_snapshot() | |
900 | { |
|
900 | { | |
901 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
901 | /** This function sets the delta_snapshot register of the waveform picker module. | |
902 | * |
|
902 | * | |
903 | * The value is read from two (unsigned char) of the parameter_dump_packet structure:\n |
|
903 | * The value is read from two (unsigned char) of the parameter_dump_packet structure:\n | |
904 | * sy_lfr_n_swf_p[0] \n |
|
904 | * sy_lfr_n_swf_p[0] \n | |
905 | * sy_lfr_n_swf_p[1] |
|
905 | * sy_lfr_n_swf_p[1] | |
906 | * |
|
906 | * | |
907 | */ |
|
907 | */ | |
908 |
|
908 | |||
909 | char ret; |
|
909 | char ret; | |
910 | unsigned int delta_snapshot; |
|
910 | unsigned int delta_snapshot; | |
911 | unsigned int aux; |
|
911 | unsigned int aux; | |
912 |
|
912 | |||
913 | aux = 0; |
|
913 | aux = 0; | |
914 | ret = LFR_DEFAULT; |
|
914 | ret = LFR_DEFAULT; | |
915 |
|
915 | |||
916 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
916 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 | |
917 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
917 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
918 |
|
918 | |||
919 | #ifdef GSA |
|
919 | #ifdef GSA | |
920 | #else |
|
920 | #else | |
921 | if ( delta_snapshot < MIN_DELTA_SNAPSHOT ) |
|
921 | if ( delta_snapshot < MIN_DELTA_SNAPSHOT ) | |
922 | { |
|
922 | { | |
923 | aux = MIN_DELTA_SNAPSHOT; |
|
923 | aux = MIN_DELTA_SNAPSHOT; | |
924 | ret = LFR_DEFAULT; |
|
924 | ret = LFR_DEFAULT; | |
925 | } |
|
925 | } | |
926 | else |
|
926 | else | |
927 | { |
|
927 | { | |
928 | aux = delta_snapshot ; |
|
928 | aux = delta_snapshot ; | |
929 | ret = LFR_SUCCESSFUL; |
|
929 | ret = LFR_SUCCESSFUL; | |
930 | } |
|
930 | } | |
931 | waveform_picker_regs->delta_snapshot = aux; // max 2 bytes |
|
931 | waveform_picker_regs->delta_snapshot = aux; // max 2 bytes | |
932 | #endif |
|
932 | #endif | |
933 |
|
933 | |||
934 | return ret; |
|
934 | return ret; | |
935 | } |
|
935 | } | |
936 |
|
936 | |||
937 | void set_wfp_burst_enable_register( unsigned char mode) |
|
937 | void set_wfp_burst_enable_register( unsigned char mode) | |
938 | { |
|
938 | { | |
939 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
939 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
940 | * |
|
940 | * | |
941 | * @param mode is the LFR mode to launch. |
|
941 | * @param mode is the LFR mode to launch. | |
942 | * |
|
942 | * | |
943 | * The burst bits shall be before the enable bits. |
|
943 | * The burst bits shall be before the enable bits. | |
944 | * |
|
944 | * | |
945 | */ |
|
945 | */ | |
946 |
|
946 | |||
947 | #ifdef GSA |
|
947 | #ifdef GSA | |
948 | #else |
|
948 | #else | |
949 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
949 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
950 | // the burst bits shall be set first, before the enable bits |
|
950 | // the burst bits shall be set first, before the enable bits | |
951 | switch(mode) { |
|
951 | switch(mode) { | |
952 | case(LFR_MODE_NORMAL): |
|
952 | case(LFR_MODE_NORMAL): | |
953 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable |
|
953 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable | |
954 | waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
954 | waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 | |
955 | break; |
|
955 | break; | |
956 | case(LFR_MODE_BURST): |
|
956 | case(LFR_MODE_BURST): | |
957 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
957 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
958 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2 |
|
958 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2 | |
959 | break; |
|
959 | break; | |
960 | case(LFR_MODE_SBM1): |
|
960 | case(LFR_MODE_SBM1): | |
961 | waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
961 | waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled | |
962 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
962 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
963 | break; |
|
963 | break; | |
964 | case(LFR_MODE_SBM2): |
|
964 | case(LFR_MODE_SBM2): | |
965 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
965 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
966 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
966 | waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
967 | break; |
|
967 | break; | |
968 | default: |
|
968 | default: | |
969 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
969 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled | |
970 | break; |
|
970 | break; | |
971 | } |
|
971 | } | |
972 | #endif |
|
972 | #endif | |
973 | } |
|
973 | } | |
974 |
|
974 | |||
975 | void reset_wfp_burst_enable() |
|
975 | void reset_wfp_burst_enable() | |
976 | { |
|
976 | { | |
977 | /** This function resets the waveform picker burst_enable register. |
|
977 | /** This function resets the waveform picker burst_enable register. | |
978 | * |
|
978 | * | |
979 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
979 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
980 | * |
|
980 | * | |
981 | */ |
|
981 | */ | |
982 |
|
982 | |||
983 | #ifdef GSA |
|
983 | #ifdef GSA | |
984 | #else |
|
984 | #else | |
985 | waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
985 | waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 | |
986 | #endif |
|
986 | #endif | |
987 | } |
|
987 | } | |
988 |
|
988 | |||
989 | void reset_wfp_status() |
|
989 | void reset_wfp_status() | |
990 | { |
|
990 | { | |
991 | /** This function resets the waveform picker status register. |
|
991 | /** This function resets the waveform picker status register. | |
992 | * |
|
992 | * | |
993 | * All status bits are set to 0 [new_err full_err full]. |
|
993 | * All status bits are set to 0 [new_err full_err full]. | |
994 | * |
|
994 | * | |
995 | */ |
|
995 | */ | |
996 |
|
996 | |||
997 | #ifdef GSA |
|
997 | #ifdef GSA | |
998 | #else |
|
998 | #else | |
999 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
999 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 | |
1000 | #endif |
|
1000 | #endif | |
1001 | } |
|
1001 | } | |
1002 |
|
1002 | |||
1003 | void reset_waveform_picker_regs() |
|
1003 | void reset_waveform_picker_regs() | |
1004 | { |
|
1004 | { | |
1005 | /** This function resets the waveform picker module registers. |
|
1005 | /** This function resets the waveform picker module registers. | |
1006 | * |
|
1006 | * | |
1007 | * The registers affected by this function are located at the following offset addresses: |
|
1007 | * The registers affected by this function are located at the following offset addresses: | |
1008 | * - 0x00 data_shaping |
|
1008 | * - 0x00 data_shaping | |
1009 | * - 0x04 burst_enable |
|
1009 | * - 0x04 burst_enable | |
1010 | * - 0x08 addr_data_f0 |
|
1010 | * - 0x08 addr_data_f0 | |
1011 | * - 0x0C addr_data_f1 |
|
1011 | * - 0x0C addr_data_f1 | |
1012 | * - 0x10 addr_data_f2 |
|
1012 | * - 0x10 addr_data_f2 | |
1013 | * - 0x14 addr_data_f3 |
|
1013 | * - 0x14 addr_data_f3 | |
1014 | * - 0x18 status |
|
1014 | * - 0x18 status | |
1015 | * - 0x1C delta_snapshot |
|
1015 | * - 0x1C delta_snapshot | |
1016 | * - 0x20 delta_f2_f1 |
|
1016 | * - 0x20 delta_f2_f1 | |
1017 | * - 0x24 delta_f2_f0 |
|
1017 | * - 0x24 delta_f2_f0 | |
1018 | * - 0x28 nb_burst |
|
1018 | * - 0x28 nb_burst | |
1019 | * - 0x2C nb_snapshot |
|
1019 | * - 0x2C nb_snapshot | |
1020 | * |
|
1020 | * | |
1021 | */ |
|
1021 | */ | |
1022 |
|
1022 | |||
1023 | #ifdef GSA |
|
1023 | #ifdef GSA | |
1024 | #else |
|
1024 | #else | |
1025 | set_wfp_data_shaping(); |
|
1025 | set_wfp_data_shaping(); | |
1026 | reset_wfp_burst_enable(); |
|
1026 | reset_wfp_burst_enable(); | |
1027 | waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // |
|
1027 | waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // | |
1028 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // |
|
1028 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // | |
1029 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // |
|
1029 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // | |
1030 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // |
|
1030 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // | |
1031 | set_wfp_delta_snapshot(); // time in seconds between two snapshots |
|
1031 | set_wfp_delta_snapshot(); // time in seconds between two snapshots | |
1032 | waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes) |
|
1032 | waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes) | |
1033 | waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes) |
|
1033 | waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes) | |
1034 | waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets) |
|
1034 | waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets) | |
1035 | waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1 |
|
1035 | waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1 | |
1036 | waveform_picker_regs->status = 0x00; // |
|
1036 | waveform_picker_regs->status = 0x00; // | |
1037 | #endif |
|
1037 | #endif | |
1038 | } |
|
1038 | } | |
1039 |
|
1039 | |||
1040 | //***************** |
|
1040 | //***************** | |
1041 | // local parameters |
|
1041 | // local parameters | |
1042 | void set_local_sbm1_nb_cwf_max() |
|
1042 | void set_local_sbm1_nb_cwf_max() | |
1043 | { |
|
1043 | { | |
1044 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. |
|
1044 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. | |
1045 | * |
|
1045 | * | |
1046 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n |
|
1046 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n | |
1047 | * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n |
|
1047 | * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n | |
1048 | * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot) |
|
1048 | * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot) | |
1049 | * |
|
1049 | * | |
1050 | */ |
|
1050 | */ | |
1051 | param_local.local_sbm1_nb_cwf_max = 2 * |
|
1051 | param_local.local_sbm1_nb_cwf_max = 2 * | |
1052 | (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 |
|
1052 | (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 | |
1053 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2 |
|
1053 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2 | |
1054 | } |
|
1054 | } | |
1055 |
|
1055 | |||
1056 | void set_local_sbm2_nb_cwf_max() |
|
1056 | void set_local_sbm2_nb_cwf_max() | |
1057 | { |
|
1057 | { | |
1058 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. |
|
1058 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. | |
1059 | * |
|
1059 | * | |
1060 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n |
|
1060 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n | |
1061 | * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n |
|
1061 | * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n | |
1062 | * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz) |
|
1062 | * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz) | |
1063 | * |
|
1063 | * | |
1064 | */ |
|
1064 | */ | |
1065 |
|
1065 | |||
1066 | param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 |
|
1066 | param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 | |
1067 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8; |
|
1067 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8; | |
1068 | } |
|
1068 | } | |
1069 |
|
1069 | |||
1070 | void set_local_nb_interrupt_f0_MAX() |
|
1070 | void set_local_nb_interrupt_f0_MAX() | |
1071 | { |
|
1071 | { | |
1072 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. |
|
1072 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. | |
1073 | * |
|
1073 | * | |
1074 | * This parameter is used for the SM validation only.\n |
|
1074 | * This parameter is used for the SM validation only.\n | |
1075 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices |
|
1075 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices | |
1076 | * module before launching a basic processing. |
|
1076 | * module before launching a basic processing. | |
1077 | * |
|
1077 | * | |
1078 | */ |
|
1078 | */ | |
1079 |
|
1079 | |||
1080 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 |
|
1080 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 | |
1081 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; |
|
1081 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; | |
1082 | } |
|
1082 | } | |
1083 |
|
1083 | |||
1084 | void reset_local_sbm1_nb_cwf_sent() |
|
1084 | void reset_local_sbm1_nb_cwf_sent() | |
1085 | { |
|
1085 | { | |
1086 | /** This function resets the value of the sbm1_nb_cwf_sent local parameter. |
|
1086 | /** This function resets the value of the sbm1_nb_cwf_sent local parameter. | |
1087 | * |
|
1087 | * | |
1088 | * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n |
|
1088 | * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n | |
1089 | * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active. |
|
1089 | * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active. | |
1090 | * |
|
1090 | * | |
1091 | */ |
|
1091 | */ | |
1092 |
|
1092 | |||
1093 | param_local.local_sbm1_nb_cwf_sent = 0; |
|
1093 | param_local.local_sbm1_nb_cwf_sent = 0; | |
1094 | } |
|
1094 | } | |
1095 |
|
1095 | |||
1096 | void reset_local_sbm2_nb_cwf_sent() |
|
1096 | void reset_local_sbm2_nb_cwf_sent() | |
1097 | { |
|
1097 | { | |
1098 | /** This function resets the value of the sbm2_nb_cwf_sent local parameter. |
|
1098 | /** This function resets the value of the sbm2_nb_cwf_sent local parameter. | |
1099 | * |
|
1099 | * | |
1100 | * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n |
|
1100 | * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n | |
1101 | * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active. |
|
1101 | * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active. | |
1102 | * |
|
1102 | * | |
1103 | */ |
|
1103 | */ | |
1104 |
|
1104 | |||
1105 | param_local.local_sbm2_nb_cwf_sent = 0; |
|
1105 | param_local.local_sbm2_nb_cwf_sent = 0; | |
1106 | } |
|
1106 | } |
General Comments 0
You need to be logged in to leave comments.
Login now